accounts/abi/bind: parse ABI only once on bind (#25574)

* accounts/abi/bind: parse ABI once on bind

* accounts/abi/bind: suppress 'imported and not used' error for abi package
This commit is contained in:
Mikhail Vazhnov 2022-09-29 13:44:22 +04:00 committed by GitHub
parent ff1f49245d
commit f651d6d56b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -110,6 +110,7 @@ var (
_ = common.Big1
_ = types.BloomLookup
_ = event.NewSubscription
_ = abi.ConvertType
)
{{$structs := .Structs}}
@ -268,11 +269,11 @@ var (
// bind{{.Type}} binds a generic wrapper to an already deployed contract.
func bind{{.Type}}(address common.Address, caller bind.ContractCaller, transactor bind.ContractTransactor, filterer bind.ContractFilterer) (*bind.BoundContract, error) {
parsed, err := abi.JSON(strings.NewReader({{.Type}}ABI))
parsed, err := {{.Type}}MetaData.GetAbi()
if err != nil {
return nil, err
}
return bind.NewBoundContract(address, parsed, caller, transactor, filterer), nil
return bind.NewBoundContract(address, *parsed, caller, transactor, filterer), nil
}
// Call invokes the (constant) contract method with params as input values and