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

abiGen crashes when on tuples #17152

Closed
StoyanD opened this issue Jul 9, 2018 · 7 comments
Closed

abiGen crashes when on tuples #17152

StoyanD opened this issue Jul 9, 2018 · 7 comments
Assignees

Comments

@StoyanD
Copy link

StoyanD commented Jul 9, 2018

When creating wrappers using abiGen, it crashes when you have nested struct's in your code. This occurs when abiGen tries to unmarshal json and the supported types don't match a tuple Leading to a runtime crash.

Expected behaviour

abiGen should not crash on tuples, or it should ignore them since in solidity no public function can take tuples as parameters or return them as output.

Actual behaviour

abiGen crashes on perfectly valid abi from the solc compiler

Steps to reproduce the behaviour

run abigen --sol Nested.sol --pkg main --out nested.go

On this file Nested.sol:

pragma solidity ^0.4.24;

contract Nested {

    Parent public parent;
    struct Parent {
        uint a;
        Child child;
    }

    struct Child {
        uint b;
    }

}

Backtrace

Failed to generate ABI binding: unsupported arg type: tuple
@EnchanterIO
Copy link

EnchanterIO commented Jul 11, 2018

I run into this issue today and it was for several reasons. For people debuggin make sure you:

  • don't return a struct from a smart contract's method 'returns' statement
  • specify name for return argument eg:
function hasRead(address account) public view returns (bool hasReadAccess) {

instead of:

function hasRead(address account) public view returns (bool) {

otherwise an exception will be raised. This is done to prevent bad auto generated names in the abigen binding class.

  • don't define an event with a struct in a smart contract

You can see specifically (what I realised an hour later...) what's the exact problem by reading the generated ABI:

"type": "tuple" and check the surroundings for the exact name of method/event.

@outprog
Copy link

outprog commented Sep 18, 2018

Same issue, because not support "type": "tulpe".
#17642

@gballet
Copy link
Member

gballet commented Jan 10, 2019

The merge of #18406 should fix this issue. Please re-open it in case it doesn't work

@gballet gballet closed this as completed Jan 10, 2019
@rjl493456442
Copy link
Member

@gballet for the abigen, we still need some modifications to make it work. I'll open another PR to fix it.

@gballet
Copy link
Member

gballet commented Jan 10, 2019

@rjl493456442 ok, reopening then. Let me know.

@gballet gballet reopened this Jan 10, 2019
@fabioberger
Copy link
Contributor

I just tried using #18406 to use abigen with contracts using ABIV2 and it did not work. @rjl493456442 are you still working on the missing modifications?

@rjl493456442
Copy link
Member

@fabioberger Please try this PR #18491. Feel sorry for the confusion, this PR only supports encode/decode tuple arguments, but #18491 supports tuple style golang binding generation.

And any feedback is appreciated for #18491 if there is any issue.

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

8 participants
@adamschmideg @StoyanD @fabioberger @gballet @EnchanterIO @rjl493456442 @outprog and others