kigawas / web3-input-decoder

A simple offline web3 transaction input decoder for functions and constructors.
MIT License
51 stars 11 forks source link

Error parsing function that takes input as a struct. #102

Closed sarinniural closed 1 year ago

sarinniural commented 1 year ago

I am trying to use the decoder, but it fails with the exception as follows. Maybe this can help https://github.com/ethereum/web3.py/pull/2211

ABI is here https://goerli.etherscan.io/address/0xADF688869E47D404af9aaD295e09Efa06bbAD593#code

def parse_function(input):
    decoder = InputDecoder(abi)
    result = decoder.decode_function(input)
    print(result)

parse_function(
    "0xe024c9080000000000000000000000000000000000000000000000000000000000000060000000000000000000000000cc4741e83b3c07284ba04d47ae04bb1592aeeff500000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000002434646465363836662d343730612d343035362d616336302d3839636163623061363037610000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000008584e41974f927d33f3801f5d87113a2abc8258d0000000000000000000000000000000000000000000000000000000040ac1760"
)
  File "test.py", line 121, in <module>
    parse_function(
  File "test.py", line 117, in parse_function
    result = decoder.decode_function(input)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/web3_input_decoder/decoder.py", line 35, in decode_function
    values = decode(types, args)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/codec.py", line 208, in decode
    decoders = [self._registry.get_decoder(type_str) for type_str in types]
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/codec.py", line 208, in <listcomp>
    decoders = [self._registry.get_decoder(type_str) for type_str in types]
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 488, in get_decoder
    return self._get_registration(self._decoders, type_str)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 370, in _get_registration
    return coder.from_type_str(type_str, self)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/base.py", line 74, in new_from_type_str
    return old_from_type_str(cls, abi_type, registry)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/decoding.py", line 233, in from_type_str
    item_decoder = registry.get_decoder(abi_type.item_type.to_type_str())
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 488, in get_decoder
    return self._get_registration(self._decoders, type_str)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 367, in _get_registration
    coder = super()._get_registration(mapping, type_str)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 349, in _get_registration
    value = mapping.find(type_str)
  File "/Users/sarinregmi/.pyenv/versions/3.8.14/lib/python3.8/site-packages/eth_abi/registry.py", line 94, in find
    raise NoEntriesFound(
eth_abi.exceptions.NoEntriesFound: No matching entries for 'tuple' in decoder registry
sarinniural commented 1 year ago

I figured out that the issue happens if I have the web3 dependency pip installed. Removing web3 and installing this package again resolved the issue

kigawas commented 1 year ago

Probably caused by eth-abi or eth-utils version discrepancy. Glad you have solved it :)