Skip to content
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

Unable to decode Arrays of Structs #169

Closed
antazoey opened this issue May 11, 2022 · 4 comments
Closed

Unable to decode Arrays of Structs #169

antazoey opened this issue May 11, 2022 · 4 comments

Comments

@antazoey
Copy link

If this is a bug report, please fill in the following sections.
If this is a feature request, delete and describe what you would like with examples.

What was wrong?

I have a function in a smart-contract that returns an Array of struct types. But, I was unable to decode it.

Code that produced the error

Method example:

@view
@external
def getStructList() -> DynArray[NestedStruct1, 2]:
    return [
        NestedStruct1({t: MyStruct({a: msg.sender, b: block.prevhash}), foo: 1}),
        NestedStruct1({t: MyStruct({a: msg.sender, b: block.prevhash}), foo: 2})
    ]

Example Python Code to reproduce (Note: If need more info about how I crafted the transaction, let me know. I am using ape)

raw_return_data = HexBytes('0x0000000000000000000000001e59ce931b4cfea3fe4b875411e280e173cb7a9c823cdd42013e4dcc999143ac0f75bcdc001b54c977d0e0d2ec78d9fa6d2ea9e000000000000000000000000000000000000000000000000000000000000000010000000000000000000000001e59ce931b4cfea3fe4b875411e280e173cb7a9c823cdd42013e4dcc999143ac0f75bcdc001b54c977d0e0d2ec78d9fa6d2ea9e00000000000000000000000000000000000000000000000000000000000000002')

output_types_from_method_abi = ['tuple[2]']

# The following line fails with: NoEntriesFound: No matching entries for 'tuple' in decoder registry
decode_abi(output_types_from_method_abi, raw_return_data)

Full error output

eth_abi.exceptions.NoEntriesFound: No matching entries for 'tuple' in decoder registry

Expected Result

list of tuples probably, like this:

[(0, 1), (1,2)]

Environment

# run this:
$ python -m eth_utils

aiohttp==3.8.1
aiosignal==1.2.0
alabaster==0.7.12
-e git+ssh://git@github.com/unparalleled-js/ape-alchemy.git@39e6a66e30fd2659768571ddbba293cac6cdc9da#egg=ape_alchemy
-e git+ssh://git@github.com/unparalleled-js/ape-cairo.git@7624c474141ee050c2276f8be1418585f86ee635#egg=ape_cairo
-e git+ssh://git@github.com/unparalleled-js/ape-etherscan.git@a970233426c6ac4793340077a1105800fa1f0747#egg=ape_etherscan
-e git+ssh://git@github.com/ApeWorX/ape-fantom.git@5bde3bbd32a5af3c96b737b611d29de9f65591e5#egg=ape_fantom
-e git+ssh://git@github.com/unparalleled-js/ape-foundry.git@2ffdf188fade524effac3d620ab71f7cdd3b53b0#egg=ape_foundry
-e git+ssh://git@github.com/unparalleled-js/ape-hardhat.git@43e3810c68b052f458abadeefa6b00f1ba7413de#egg=ape_hardhat
ape-infura==0.2.0
-e git+ssh://git@github.com/ApeWorX/ape-ledger.git@e514bf2cd3204515c37a7d4223a8f64088996097#egg=ape_ledger
ape-solidity==0.2.2
-e git+ssh://git@github.com/unparalleled-js/ape-starknet.git@acaae815c321b7b468cdfd451ffda0dc9ba8c887#egg=ape_starknet
-e git+ssh://git@github.com/unparalleled-js/ape-vyper.git@96a22e67728489511865e0c1ee712b3394b133c2#egg=ape_vyper
appnope==0.1.2
argcomplete==1.12.3
asgiref==3.5.0
async-timeout==4.0.2
asynctest==0.13.0
attrs==21.4.0
autoflake==1.4
Babel==2.9.1
backcall==0.2.0
backports.cached-property==1.0.1
bandit==1.7.4
base58==2.1.1
bitarray==1.2.2
black==22.3.0
bleach==4.1.0
bump2version==1.0.1
cached-property==1.5.2
cachetools==5.0.0
cairo-lang==0.8.1
certifi==2021.10.8
cffi==1.15.0
cfgv==3.3.1
charset-normalizer==2.0.11
click==8.1.3
click-default-group==1.2.2
colorama==0.4.4
commitizen==2.19.0
commonmark==0.9.1
coverage==6.3.1
cytoolz==0.11.2
dataclassy==0.10.4
decli==0.5.2
decorator==5.1.1
Deprecated==1.2.13
dill==0.3.4
distlib==0.3.4
docopt==0.6.2
docutils==0.16
ecdsa==0.17.0
ECPy==1.2.5
eip712==0.1.0
eth-abi==2.1.1
eth-account==0.5.7
-e git+ssh://git@github.com/unparalleled-js/ape.git@b7a0784b16e5f00046998ae3ec2d2d6ff623c57a#egg=eth_ape
eth-bloom==1.0.4
eth-hash==0.3.2
eth-keyfile==0.5.1
eth-keys==0.3.4
eth-rlp==0.2.1
eth-tester==0.6.0b6
eth-typing==2.3.0
eth-utils==1.10.0
ethpm-types==0.2.1
-e git+ssh://git@github.com/unparalleled-js/evm-trace.git@e1c65b8a367ff6f5049f209b7f1592911c3e5695#egg=evm_trace
execnet==1.9.0
fastecdsa==2.2.3
filelock==3.4.2
flake8==3.9.2
flake8-breakpoint==1.1.0
flake8-plugin-utils==1.3.2
flake8-print==4.0.0
Flask==2.0.3
Flask-Cors==3.0.10
frozendict==1.2
frozenlist==1.3.0
future==0.18.2
gitdb==4.0.9
GitPython==3.1.27
greenlet==0.4.17
hexbytes==0.2.2
hidapi==0.10.1
hypothesis==6.36.1
hypothesis-jsonschema==0.19.0
identify==2.4.8
idna==3.3
imagesize==1.3.0
importlib-metadata==4.10.1
incremental==21.3.0
iniconfig==1.1.1
ipdb==0.13.9
ipfshttpclient==0.8.0a2
ipython==7.32.0
isort==5.10.1
itsdangerous==2.1.0
jedi==0.18.1
Jinja2==3.0.3
jsonschema==3.2.0
keyring==23.5.0
lark-parser==0.12.0
ledgerblue==0.1.41
ledgereth @ file:///Users/jules/PycharmProjects/ledger-eth-lib
lru-dict==1.1.7
markdown-it-py==2.0.1
MarkupSafe==2.0.1
marshmallow==3.14.1
marshmallow-dataclass==8.5.3
marshmallow-enum==1.5.1
marshmallow-oneofschema==3.0.1
matplotlib-inline==0.1.3
mccabe==0.6.1
mdit-py-plugins==0.3.0
mdurl==0.1.0
meinheld==1.0.2
mpmath==1.2.1
multiaddr==0.0.9
multidict==6.0.2
mypy==0.950
mypy-extensions==0.4.3
myst-parser==0.16.0
netaddr==0.8.0
nodeenv==1.6.0
numpy==1.21.5
packaging==20.9
pandas==1.3.5
pandas-stubs==1.2.0.49
parsimonious==0.8.1
parso==0.8.3
pathspec==0.9.0
pbr==5.8.1
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.0.1
pipdeptree==2.2.1
pkginfo==1.8.2
platformdirs==2.4.1
pluggy==0.13.1
pockets==0.9.1
pre-commit==2.17.0
prometheus-client==0.13.1
prompt-toolkit==3.0.26
protobuf==3.19.4
ptyprocess==0.7.0
py==1.11.0
py-ecc==4.1.0
py-evm==0.5.0a3
py-geth==3.7.0
py-solc-x==1.1.1
pycodestyle==2.7.0
pycparser==2.21
pycryptodome==3.14.1
pycryptodomex==3.14.1
pydantic==1.9.0
pyethash==0.1.27
pyflakes==2.3.1
pygit2==1.8.0
PyGithub==1.55
Pygments==2.11.2
PyJWT==2.3.0
PyNaCl==1.5.0
pyparsing==3.0.7
pyrsistent==0.18.1
pysha3==1.0.2
pytest==6.2.5
pytest-asyncio==0.18.2
pytest-cov==3.0.0
pytest-forked==1.4.0
pytest-mock==3.7.0
pytest-watch==4.2.0
pytest-xdist==2.5.0
python-dateutil==2.8.2
python-u2flib-host==3.0.3
pytz==2021.3
pyupgrade==2.31.1
PyYAML==5.4.1
questionary==1.10.0
readme-renderer==32.0
requests==2.27.1
requests-toolbelt==0.9.1
rfc3986==2.0.0
rich==10.16.2
rlp==2.0.1
semantic-version==2.8.5
setuptools-scm==6.4.2
singledispatchmethod==1.0
six==1.16.0
smmap==5.0.0
snowballstemmer==2.2.0
sortedcontainers==2.4.0
Sphinx==3.5.4
sphinx-click==3.1.0
sphinx-rtd-theme==0.5.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-napoleon==0.7
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
starknet-devnet==0.1.23
starknet.py==0.2.2a0
stevedore==3.5.0
sympy==1.9
termcolor==1.1.0
tokenize-rt==4.2.1
tokenlists==0.1.1
toml==0.10.2
tomli==1.2.3
tomlkit==0.9.0
toolz==0.11.2
towncrier==19.9.0
tqdm==4.62.3
traitlets==5.1.1
trie==2.0.0a5
twine==3.8.0
typed-ast==1.5.2
typeguard==2.13.3
types-pkg-resources==0.1.3
types-PyYAML==6.0.4
types-requests==2.27.15
types-setuptools==57.4.11
types-urllib3==1.26.9
typing-extensions==3.10.0.2
typing-inspect==0.7.1
urllib3==1.26.8
varint==1.0.2
virtualenv==20.13.0
vvm==0.1.0
watchdog==2.1.6
wcwidth==0.2.5
web3==5.29.0
webencodings==0.5.1
websocket-client==1.3.1
websockets==9.1
Werkzeug==2.0.3
wrapt==1.13.3
yarl==1.7.2
zipp==3.7.0

How can it be fixed?

I am not sure!

@antazoey
Copy link
Author

closing as I realize I just need to convert the tuple

@hustnn
Copy link

hustnn commented Aug 27, 2022

Does it support decode on the data for type mystruct[] with unknown length

struct myStruct {
address,
uint256,
address
}

@blksith0
Copy link

closing as I realize I just need to convert the tuple

meaning?

@antazoey
Copy link
Author

antazoey commented Jul 17, 2023

meaning?

I don't fully remembers, probably had to go from tuple[2] to (uint256,address)[2] or something like that, using the ABI structure. The linked PR a few comments up probably contains the exact answer but that is already kinda outdated code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants