-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Negative large numbers throw exceptions when passed to encodeFunctionCall #5890
Comments
From 5/30/23 meeting, need to try and reproduce on 1.x/4.x. |
@zdenkolini To give you an update, as shown in #6221, this doesn't seem to be an issue in |
As an update, #6239 applies a fix for this in |
Fix has been merged, will be apart of next release - I'll get back to you with an eta |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue for this?
Current Behavior
When I pass a string representing a large number that is negative, for instance in the case of a int128:
2^128 / 2 - 1 = 170141183460469231731687303715884105727 * -1 = -170141183460469231731687303715884105727
I get this error:
Encode function call failed: invalid BigNumber string (argument="value", value="0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-170141183460469231731687303715884105727", code=INVALID_ARGUMENT, version=bignumber/5.7.0)
After snooping through the repo, I found that you padStart int/uint values, which is okay for uints, but not for ints. (source: https://github.com/web3/web3.js/blob/1.x/packages/web3-eth-abi/src/index.js#L266-L274)
This behaviour doesn't occur for small ints, for instance -2, only large ones.
Expected Behavior
Should be able to pass large negative numbers such as
-170141183460469231731687303715884105727
Steps to Reproduce
Web3.js Version
1.8.2
Environment
Anything Else?
No response
The text was updated successfully, but these errors were encountered: