ethereum / eth-typing

Python types for type hinting commonly used ethereum types
MIT License
31 stars 35 forks source link

Required types for ABI type definitions #79

Closed reedsa closed 4 months ago

reedsa commented 4 months ago

What was wrong?

Types for ABIs should match the spec.

The components attribute may not be present in all subtypes of ABIElement.

ABIElement subtypes, such as ABIEvent or ABIFunction may not require a components attribute for all inputs. The components attribute must be optional to accommodate TypedDicts of the form:

    abi_function = {
        "inputs": [{"name": "_arg0", "type": "uint256"}],
        "name": "logTwoEvents",
        "stateMutability": "nonpayable",
        "type": "function",
    }

Related to Issue https://github.com/ethereum/web3.py/issues/3036

How was it fixed?

total=False on the ABIComponent type makes all attributes optional, so instead using NotRequired to denote specific attributes as optional.

components can now be omitted when using ABIComponent.

Todo:

Cute Animal Picture