Closed julienmuller-forge closed 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions. If you believe this was a mistake, please comment.
Please re open this issue, i got the same problem! :)
Same issue. Please reopen it.
encoding ABIEncoderV2 tuples(struct) containing BigNumbers does not work currently. These BigNumbers should be converted to string, as ethers does not handle BigNumbers created using either BN.js or bignumber.js
Expected behavior
ABICoder.encodeParameters([{name: 'param', type:'tuple', components: [{name:'member',type:'uint256'}]}],[{member:new BigNumber(2)}])
should give the same result as
ABICoder.encodeParameters([{name: 'param', type:'tuple', components: [{name:'member',type:'uint256'}]}],[{member: 2}])
Actual behavior
ABICoder.encodeParameters([{name: 'param', type:'tuple', components: [{name:'member',type:'uint256'}]}],[{member: 2}])
gives
'0x0000000000000000000000000000000000000000000000000000000000000002'
whereas
ABICoder.encodeParameters([{name: 'param', type:'tuple', components: [{name:'member',type:'uint256'}]}],[{member:new BigNumber(2)}])
gives
Error: invalid BigNumber value (argument="value", value="2", code=INVALID_ARGUMENT, version=bignumber/5.0.11) at Logger.makeError (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/bignumber/node_modules/@ethersproject/logger/lib/index.js:179:21) at Logger.throwError (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/bignumber/node_modules/@ethersproject/logger/lib/index.js:188:20) at Logger.throwArgumentError (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/bignumber/node_modules/@ethersproject/logger/lib/index.js:191:21) at Function.BigNumber.from (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/bignumber/lib/bignumber.js:231:23) at NumberCoder.encode (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/abi/lib/coders/number.js:30:39) at /home/jmuller/dev/forge-platform/node_modules/@ethersproject/abi/lib/coders/array.js:55:19 at Array.forEach (<anonymous>) at Object.pack (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/abi/lib/coders/array.js:41:12) at TupleCoder.encode (/home/jmuller/dev/forge-platform/node_modules/@ethersproject/abi/lib/coders/tuple.js:36:24) { reason: 'invalid BigNumber value', code: 'INVALID_ARGUMENT', argument: 'value', value: BigNumber { s: 1, e: 0, c: [ 2 ] } }
Environment
OS: ubuntu 20.04 node 14.5.0 web3.js 1.2.11