You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
eth-abi fails to properly parse/use the ABI generated by solc for a library. One example of this is that for contracts the type of an enum is reported as an integer type (uint8 if enum has 256 of less entries) while for libraries it's enum L.E (where L is a library name and E is some enum).
An attempt to use such an enum with eth-abi results in an error:
ParseError: Parse error at '.E' (column 3) in type string '(L.E)'
Code that produced the error
Repro using Brownie.
Assuming you have it installed, just run these commands in shell in an empty directory:
brownie init
cat <<EOF > contracts/L.solpragma solidity =0.7.1;library L { enum BOOL {NO, YES} function f(BOOL b) public pure returns (BOOL) { return b; }}EOF
cat <<EOF > scripts/trigger_bug.pyfrom brownie import L, accountsl = L.deploy({'from': accounts[0]})l.f(1)EOF
brownie compile
brownie run trigger_bug
Full error output
Brownie v1.11.10 - Python development framework for Ethereum
FProject is the active project.
Launching 'ganache-cli --accounts 10 --hardfork istanbul --gasLimit 12000000 --mnemonic brownie --port 8545'...
Transaction sent: 0x5723c43998c3eaad6eabeb2e840843db80b028a4e024a7ea7fe96f6ec0dad640
Gas price: 0.0 gwei Gas limit: 12000000
L.constructor confirmed - Block: 1 Gas used: 90940 (0.76%)
L deployed at: 0x3194cBDC3dbcd3E11a07892e7bA5c3394048Cc87
File "brownie/_cli/run.py", line 49, in main
return_value = run(args["<filename>"], method_name=args["<function>"] or "main")
File "brownie/project/scripts.py", line 52, in run
module = _import_from_path(script)
File "brownie/project/scripts.py", line 110, in _import_from_path
_import_cache[import_str] = importlib.import_module(import_str)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen, line line, in in File "<frozen, line line, inin
File "<frozen, line line, in in File "<frozen, line line, inin
File "<frozen, line line, in in File "<frozen, line line, inin
File "./scripts/trigger_bug.py", line 3, in<module>
l.f(1)
File "brownie/network/contract.py", line 1232, in __call__
return self.call(*args, block_identifier=block_identifier)
File "brownie/network/contract.py", line 1033, in call
tx.update({"to": self._address, "data": self.encode_input(*args)})
File "brownie/network/contract.py", line 1113, in encode_input
data = format_input(self.abi, args)
File "brownie/convert/normalize.py", line 16, in format_input
abi_types = _get_abi_types(abi["inputs"])
File "brownie/convert/normalize.py", line 112, in _get_abi_types
tuple_type = parse(type_str)
File "eth_abi/grammar.py", line 125, in parse
raise ParseError(e.text, e.pos, e.expr)
ParseError: Parse error at '.BOOL' (column 3) intype string '(L.BOOL)'
Terminating local RPC client...
What was wrong?
eth-abi
fails to properly parse/use the ABI generated bysolc
for a library. One example of this is that for contracts thetype
of an enum is reported as an integer type (uint8
if enum has 256 of less entries) while for libraries it'senum L.E
(whereL
is a library name andE
is some enum).An attempt to use such an
enum
witheth-abi
results in an error:Code that produced the error
Repro using Brownie.
Assuming you have it installed, just run these commands in shell in an empty directory:
Full error output
Environment
How can it be fixed?
The inconsistent ABI for libraries is actually a problem in the compiler and is likely to be fixed in the near future (feedback welcome in ethereum/solidity#9278). It affects other tools too: dethcrypto/TypeChain#216, ethers-io/ethers.js#1126.
In the meantime (and for older versions when it's fixed), tools need to handle it differently than in contracts.
The text was updated successfully, but these errors were encountered: