ApeWorX / ethpm-types

Implementation of EIP-2678
Apache License 2.0
14 stars 8 forks source link

Add ability to determine the inner type of an array ABIType [APE-678] #63

Open fubuloubu opened 1 year ago

fubuloubu commented 1 year ago

Overview

It's often a little difficult working with ABIType instances of arrays. It would be nice to have some better tools.

Specification

class ABIType(...):
    ...

    def is_array(self) -> bool:
        # check if `self.type` is something like `...[]` or `...[...]`

    def array_type(self) -> Optional["ABIType"]:
        if self.is_array():
            # fetch the "inner type" of the array, if it is an array type

Dependencies

Would be helpful for https://github.com/ApeWorX/ape/pull/1319