Vyper: Vyper structs in ABI outputs incorrect ABI type

Created on 29 Jan 2019  路  3Comments  路  Source: vyperlang/vyper

What's your issue about?

Given example code:

struct MyStruct:
    a: address
    b: uint256

@public
@constant
def foo(s: MyStruct) -> MyStruct:
    return s

The current ABI output is:

{'abi': [{'name': 'foo',
 'outputs': [{'type': 'address', 'name': 'out'},
             {'type': 'uint256', 'name': 'out'}],
 'inputs': [{'type': '(address,uint256)', 'name': 's'}],
 'constant': True,
 'payable': False,
 'type': 'function'}]}

How can it be fixed?

Referencing the current location of ABI documentation:
https://solidity.readthedocs.io/en/latest/abi-spec.html#handling-tuple-types

The expected output should be:

{'abi': [{'name': 'foo',
 'outputs': [{'type': 'tuple', 'components': [
               {'type': 'address', 'name': 'a'},
               {'type': 'uint256', 'name': 'b'}]
             }],
 'inputs': [{'type': 'tuple', 'name': 's', 'components': [
               {'type': 'address', 'name': 'a'},
               {'type': 'uint256', 'name': 'b'}]
             }],
 'constant': True,
 'payable': False,
 'type': 'function'}]}

We should update the way structs are produced in the ABI in order to be compliant with the ABI v2 updates.

Also, may be related to: #932

Cute Animal Picture

happy frog

bug

All 3 comments

For reference:
https://github.com/charles-cooper/vyper/commit/9ca6aaf511d21803c646388ec0185f841c82aa7f
(The special case here might not be needed for ABIv2 https://github.com/charles-cooper/vyper/commit/da51e5c1a0a4b61fd9c9454ae5d2b0d797631a52)
https://github.com/charles-cooper/vyper/commit/ba553f6ecb69a800c0155ad78d9bed3119fb93c1

@fubuloubu The expected JSON ABI looks correct except that the name of the input 's' should appear in the JSON ABI like so:

{'abi': [{'name': 'foo',
 'outputs': [{'type': 'tuple', 'components': [
               {'type': 'address', 'name': 'a'},
               {'type': 'uint256', 'name': 'b'}]
             }],
 'inputs': [{'type': 'tuple', 'name': 's', 'components': [
               {'type': 'address', 'name': 'a'},
               {'type': 'uint256', 'name': 'b'}]
             }],
 'constant': True,
 'payable': False,
 'type': 'function'}]}

Updated!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robinsierra picture robinsierra  路  3Comments

jacqueswww picture jacqueswww  路  4Comments

ben-kaufman picture ben-kaufman  路  4Comments

jacqueswww picture jacqueswww  路  3Comments

denis-bogdanas picture denis-bogdanas  路  3Comments