Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Long support for ContractFunctionParameters parameters #1972

Closed
iron4548 opened this issue Oct 10, 2023 · 2 comments · Fixed by #1997
Closed

Add Long support for ContractFunctionParameters parameters #1972

iron4548 opened this issue Oct 10, 2023 · 2 comments · Fixed by #1997
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@iron4548
Copy link

Description

I have this code:

  const params = new ContractFunctionParameters();
  params.addAddress(demoToken1.toSolidityAddress()); //address token
  params.addUint256(liquidityAmountDemo1Tiny); //uint amountTokenDesired
  params.addUint256(liquidityAmountDemo1Tiny); //uint amountTokenMin
  params.addUint256(liquidityAmountHbar.toTinybars()); //uint amountETHMin
  params.addAddress(client.operatorAccountId!.toSolidityAddress()); //address to
  params.addUint256(Math.floor(Date.now() / 1000) + 20); //uint deadline - 20s from now

uint amountETHMin expects the amount in tinyhbar. So naturally I tried with liquidityAmountHbar.toTinybars() but I got an error: 'Argument of type 'Long' is not assignable to parameter of type 'number | BigNumber'.

So naturally what I did was changed liquidityAmountHbar.toBigNumber() to resolve the error. I also thought toBigNumber() would give me a tinybar in terms of BigNumber but that wasn't the case. It was hbar expressed as a BigNumber()

From Hbar.js

    /**
     * @returns {BigNumber}
     */
    toBigNumber() {
        return this.to(HbarUnit.Hbar);
    }

To avoid the mistake of using toBigNumber() in this context, which would have given incorrect results, for future developers, please add Long support for ContractFunctionParameters parameters such as params.addUint256 so developers can use Hbar.toTinybars()

Steps to reproduce

N/A

Additional context

No response

Hedera network

testnet

Version

2.35.0

Operating system

None

@iron4548 iron4548 added the bug Something isn't working label Oct 10, 2023
@iron4548
Copy link
Author

Just realized I incorrectly reported this as a bug. I can't figure out how to change it to enhancement.

@Petyo-Lukanov Petyo-Lukanov added enhancement New feature or request and removed bug Something isn't working labels Oct 11, 2023
@svetoslav-nikol0v svetoslav-nikol0v self-assigned this Oct 11, 2023
@Petyo-Lukanov Petyo-Lukanov added this to the 2.36.0 milestone Oct 11, 2023
@SimiHunjan SimiHunjan modified the milestones: 2.36.0, 2.37.0 Oct 16, 2023
@svetoslav-nikol0v
Copy link
Contributor

Hey iron4548,
We're working on that in order to be implemented in the next version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants