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 import of U256 is wrong #22192

Closed
vrde opened this issue Jan 19, 2021 · 2 comments
Closed

abigen import of U256 is wrong #22192

vrde opened this issue Jan 19, 2021 · 2 comments
Labels

Comments

@vrde
Copy link

vrde commented Jan 19, 2021

System information

Geth version: v1.9.25
OS & Version: Linux
Commit hash : (if develop)

Expected behaviour

Running abigen on the ABI of a smart contract should generate valid go code. I guess the regression bug has been introduced by #21020. The project go-solidity-sha3 had the same issue.

The correct code is the following:

// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.

package eth

import (
	"math/big"
	"strings"

	ethereum "github.com/ethereum/go-ethereum"
	"github.com/ethereum/go-ethereum/accounts/abi"
	"github.com/ethereum/go-ethereum/accounts/abi/bind"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/common/math"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/event"
)

// Reference imports to suppress errors if they are not otherwise used.
var (
	_ = big.NewInt
	_ = strings.NewReader
	_ = ethereum.NotFound
	_ = math.U256Bytes
	_ = bind.Bind
	_ = common.Big1
	_ = types.BloomLookup
	_ = event.NewSubscription
)

Actual behaviour

The compiler complains that in the generated code U256 not declared by package abi

// Code generated - DO NOT EDIT.
// This file is a generated binding and any manual changes will be lost.

package eth

import (
	"math/big"
	"strings"

	ethereum "github.com/ethereum/go-ethereum"
	"github.com/ethereum/go-ethereum/accounts/abi"
	"github.com/ethereum/go-ethereum/accounts/abi/bind"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
	"github.com/ethereum/go-ethereum/event"
)

// Reference imports to suppress errors if they are not otherwise used.
var (
	_ = big.NewInt
	_ = strings.NewReader
	_ = ethereum.NotFound
	_ = abi.U256 // 🚨🚨🚨 This is wrong: "U256 not declared by package abi" 🚨🚨🚨
	_ = bind.Bind
	_ = common.Big1
	_ = types.BloomLookup
	_ = event.NewSubscription
)

Steps to reproduce the behaviour

Run abigen on any abi file.

@vrde vrde added the type:bug label Jan 19, 2021
@MariusVanDerWijden
Copy link
Member

MariusVanDerWijden commented Jan 19, 2021

You need to update abigen see also #21644
Please reopen if that doesn't work

@vrde
Copy link
Author

vrde commented Jan 19, 2021

Thank you for your prompt reply. I installed abigen with go get, but I didn't notice I had an older abigen installed in my bin path.

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