This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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: