Go-ethereum: abigen: using structs (tuple) in function params results in generation of invalid code

Created on 16 Apr 2019  路  6Comments  路  Source: ethereum/go-ethereum

Hi there,

When trying to run abigen on contracts that uses structs in function params ("tuple" type in ABI JSON) and with ABIEncoderV2 enabled, the output produces invalid go code for the corresponding struct.

System information

Solc: 0.5.7+commit.6da8b019.Linux.g++
Go: go1.12.1 linux/amd64

Behaviour

abigen generates the following go code, which has invalid parts in the function params: data (address,address)

...
func (_Test *TestTransactor) TestData(opts *bind.TransactOpts , data (address,address) ) (*types.Transaction, error) {
    return _Test.contract.Transact(opts, "testData" , data)
}
...

Steps to reproduce the behaviour

run abigen --sol Test.sol --pkg main --out test.go

on Test.sol file with content:

pragma solidity ^0.5.5;
pragma experimental ABIEncoderV2;
contract Test {

    struct Data {
        address addr1;
        address addr2;
    }

    function testData(Data memory data)
        public
        returns(address)
    {
        return data.addr1;
    }
}

corresponding ABI JSON:

[
   {
      "constant":false,
      "inputs":[
         {
            "components":[
               {
                  "name":"addr1",
                  "type":"address"
               },
               {
                  "name":"addr2",
                  "type":"address"
               }
            ],
            "name":"data",
            "type":"tuple"
         }
      ],
      "name":"testData",
      "outputs":[
         {
            "name":"",
            "type":"address"
         }
      ],
      "payable":false,
      "stateMutability":"nonpayable",
      "type":"function"
   }
]

Backtrace

Failed to generate ABI binding: 201:80: expected ')', found ','
on-hold

Most helpful comment

This cannot be closed until the linked PR is merged.

All 6 comments

Fixed so closing

This cannot be closed until the linked PR is merged.

I think this can be closed, the fix is merged @fjl

@fjl @MariusVanDerWijden @adamschmideg sorry, but what is the status of it, eventually? Does abigen support structs or is it on hold?

Abigen supports structs as of July 2019

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VenusHu picture VenusHu  路  3Comments

JMaxU picture JMaxU  路  3Comments

tymat picture tymat  路  3Comments

phpsamsb picture phpsamsb  路  3Comments

carver picture carver  路  3Comments