dapptools
dapptools copied to clipboard
seth 4byte-decode "Error: unexpected character "(" at position 0 in "(address,address,uint24,address,uint256,uint256,uint256,uint160)"
Trying to decode the below data results in an error. Seems like it's because of the double parenthesis wrapping the arguments.
I believe they signify the input is encoded as a struct? Looks like that might not be supported in abi-decode?
❯ seth 4byte-decode 0x414bf38900000000000000000000000082af49447d8a07e3bd95bd0d56f35241523fbab1000000000000000000000000fc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a0000000000000000000000000000000000000000000000000000000000002710000000000000000000000000b47bec5577f8a02c78ca98f3db20e538e690f94c00000000000000000000000000000000000000000000000000000000614640eb0000000000000000000000000000000000000000000000000164e1e25de63b9500000000000000000000000000000000000000000000000130887aaad44e8a110000000000000000000000000000000000000000000000000000000000000000
1) "exactInputSingle((address,address,uint24,address,uint256,uint256,uint256,uint160))"
Select a function signature by number: 1
Error: unexpected character "(" at position 0 in "(address,address,uint24,address,uint256,uint256,uint256,uint160)"
The error is coming from ethers.js, when we try to construct an Interface type: https://github.com/dapphub/dapptools/blob/1729e1d87319fc0112e18536d9bc600cb1f3f623/src/seth/libexec/seth/seth---calldata-decode#L16
Seems like we either need to get an abi description from solc, or detect tuple types and prefix them with tuple to comply with the ethers.js human readable formatting requirements.
Alternatively we could just expose the abi decoding code in hevm and replace our usage of ethers.js with direct calls to hevm.
Once solution would also be updating from the current (very old) ethers v4 to ethers v5, which seems to handle not being provided the tuple keyword. Using the ethers CLI:
> interface = new ethers.utils.Interface(['function x((uint256,uint256)) external']) // no tuple keyword given
> i.format() // print human-readable ABI
[ 'function x(tuple(uint256, uint256))' ]
ah, yes that does seem like it might be a relatively easy fix.