ethereum / eth-abi

Ethereum ABI utilities for python
MIT License
247 stars 269 forks source link

`is_encodable_type` does not function properly with mispelled integer types #147

Closed fubuloubu closed 2 years ago

fubuloubu commented 3 years ago

What was wrong?

Code that produced the error

from eth_abi import is_encodable_type
is_encodable_type("uint25") 

Full error output

ABITypeError: For 'uint25' type at column 1 in 'uint25': integer size must be multiple of 8 

Expected Result

This section may be deleted if the expectation is "don't crash".

False

Environment

Python version:                                                                                                                                                                                             
3.8.7 (default, Jan 24 2021, 11:57:42)                                                                                                                                                                      
[GCC 9.3.0]                                                                                                                                                                                                 

Operating System: Linux-5.6.0-1048-oem-x86_64-with-glibc2.29                                                                                                                                                

pip freeze result:                                                                                                                                                                                          
alabaster==0.7.12                                                                                                                                                                                           
apipkg==1.5                                                                                                                                                                                                 
appdirs==1.4.4                                                                                                                                                                                              
atomicwrites==1.4.0                                                                                                                                                                                         
attrs==20.3.0                                                                                                                                                                                               
Babel==2.9.0                                                                                                                                                                                                
backcall==0.2.0                                                                                                                                                                                             
bitarray==1.2.2                                                                                                                                                                                             
bleach==3.3.0                                                                                                                                                                                               
certifi==2020.12.5                                                                                                                                                                                          
cffi==1.14.5                                                                                                                                                                                                
chardet==4.0.0                                                                                                                                                                                              
cryptography==3.4.6                                                                                                                                                                                         
cytoolz==0.11.0                                                                                                                                                                                             
dataclassy==0.7.2                                                                                                                                                                                           
decorator==4.4.2                                                                                                                                                                                            
distlib==0.3.1                                                                                                                                                                                              
docutils==0.16                                                                                                                                                                                              
eth-abi==2.1.1
eth-hash==0.3.1
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
execnet==1.8.0
filelock==3.0.12
hexbytes==0.2.1
hypothesis==4.57.1
idna==2.10
imagesize==1.2.0
importlib-metadata==3.7.3
ipdb==0.13.7
ipython==7.21.0
ipython-genutils==0.2.0
jedi==0.18.0
jeepney==0.6.0
Jinja2==2.11.3
MarkupSafe==1.1.1
more-itertools==8.7.0
mypy-extensions==0.4.3
packaging==20.9
parsimonious==0.8.1
parso==0.8.1
pexpect==4.8.0
pickleshare==0.7.5
pluggy==0.13.1
prompt-toolkit==3.0.17
ptyprocess==0.7.0
py==1.10.0
pycparser==2.20
pycryptodome==3.10.1
Pygments==2.8.1
pyparsing==2.4.7
pytest==4.6.11
pytest-forked==1.3.0
pytest-xdist==1.34.0
pytz==2021.1
requests==2.25.1
rlp==2.0.1
SecretStorage==3.3.1
six==1.15.0
snowballstemmer==2.1.0
sortedcontainers==2.3.0
sphinxcontrib-serializinghtml==1.1.4
sphinxcontrib-websupport==1.2.4
toml==0.10.2
toolz==0.11.1
tox==2.9.1
traitlets==5.0.5
urllib3==1.26.4
virtualenv==20.4.3
watchdog==2.0.2
wcwidth==0.2.5
webencodings==0.5.1
zipp==3.4.1

How can it be fixed?

Catch both NoEntriesFound and ABITypeError exceptions here: https://github.com/ethereum/eth-abi/blob/decaadcdf7a33020846aafd9ba36859c1ab82909/eth_abi/registry.py#L460-L463