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

Export ABI Types #150

Open
fubuloubu opened this issue Nov 4, 2021 · 2 comments
Open

Export ABI Types #150

fubuloubu opened this issue Nov 4, 2021 · 2 comments

Comments

@fubuloubu
Copy link
Contributor

It would be handy to be able to leverage this package to create type hints for other packages that describe restrictions in abi types for different purposes, e.g. https://github.com/ApeWorX/eip712 where we currently use is_encodeable_type to parse a deferred type when describing an EIP-712 structured message like so:

class Order(EIP712Message):
    a: "address"  # implicit validation using `eth_abi.is_encodeable_type`

It would be much nicer if all of the registered types were made available in mypy-compliant form to use for type checking code as follows:

from eth_abi.types import address

class Order(EIP712Message):
    a: address  # explicit validation provided by eth_abi

Ideally, these types would work as aliases for int, Decimal, str, bytes, etc., doing the proper size and bounds checks as well (or at least allowing us to perform that validation easily) to make it easier to integrate this work into other libraries.

@kclowes
Copy link
Contributor

kclowes commented Jul 15, 2022

@fubuloubu I just came across this - does the eth-typing library solve this?

@fubuloubu
Copy link
Contributor Author

@fubuloubu I just came across this - does the eth-typing library solve this?

No, not quite. My thinking was to be able to say things like this:

class Order(EIP712Message):
    a: abi_types.address
    b: abi_types.bytes32
    c: abi_types.array[abi_types.uint256]

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

No branches or pull requests

3 participants