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

JSON ABI types vs. Type string types #122

Open
davesque opened this issue Feb 23, 2019 · 0 comments
Open

JSON ABI types vs. Type string types #122

davesque opened this issue Feb 23, 2019 · 0 comments
Labels

Comments

@davesque
Copy link
Contributor

What was wrong?

The initial version of eth-abi was designed to accomodate basic types (types of the form <base><sub><arrlist> such as int256[2], fixed128x18 etc.

Later, support was added for tuples by extending eth-abi to handle type strings such as (int,int), (bool,(fixed,int))[] etc.

However, the problem with this approach is that most interaction with the ABI encoding format is done via information obtained from a JSON ABI specification for a contract. The JSON ABI represents tuple types entirely differently like the following:

{
  "type": "tuple",
  ...
  "components": [
    {"type": "int", ...}, {"type": "int", ...}
  ]
}

More information about the JSON ABI format can be found here: https://solidity.readthedocs.io/en/latest/abi-spec.html#json

Because of this, a number of utility functions were added to convert JSON ABI type information to type string representations. But this seems like a potentially unnecessary step. Ideally, we shouldn't have to use type strings as a kind of intermediate type format.

How can it be fixed?

One possible fix for this could be to convert or extend eth-abi to detect appropriate coders for a type based on a JSON ABI type description (instead of a type string). So a type registry could receive a dict object representing a JSON ABI type and produce the correct coder.

I'm not sure how hard this would be or if there are any problems with that approach that I'm not considering. But I wanted to make a note of it here in case we choose to take a look at it later.

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

No branches or pull requests

2 participants