From 9ab62d60f098901f5840da43b5e1ee402206ab5a Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Fri, 7 Feb 2025 07:03:02 -0800 Subject: [PATCH] accounts/abi/abigen: improve v2 template Co-authored-by: Gary Rong --- accounts/abi/abigen/bindv2_test.go | 83 ++----- accounts/abi/abigen/source2.go.tpl | 100 +++++---- .../abigen/testdata/v2/callbackparam.go.txt | 7 +- .../abi/abigen/testdata/v2/crowdsale.go.txt | 98 +++++---- accounts/abi/abigen/testdata/v2/dao.go.txt | 202 +++++++++++------- .../testdata/v2/deeplynestedarray.go.txt | 29 +-- accounts/abi/abigen/testdata/v2/empty.go.txt | 4 +- .../abigen/testdata/v2/eventchecker.go.txt | 41 +++- accounts/abi/abigen/testdata/v2/getter.go.txt | 18 +- .../testdata/v2/identifiercollision.go.txt | 26 ++- .../abigen/testdata/v2/inputchecker.go.txt | 22 +- .../abi/abigen/testdata/v2/interactor.go.txt | 33 +-- .../abigen/testdata/v2/nameconflict.go.txt | 26 ++- .../testdata/v2/numericmethodname.go.txt | 21 +- .../abigen/testdata/v2/outputchecker.go.txt | 81 ++++--- .../abi/abigen/testdata/v2/overload.go.txt | 28 ++- .../abigen/testdata/v2/rangekeyword.go.txt | 7 +- accounts/abi/abigen/testdata/v2/slicer.go.txt | 48 +++-- .../abi/abigen/testdata/v2/structs-abi.go.txt | 73 ++++--- .../abi/abigen/testdata/v2/structs.go.txt | 29 +-- accounts/abi/abigen/testdata/v2/token.go.txt | 107 ++++++---- accounts/abi/abigen/testdata/v2/tuple.go.txt | 50 +++-- accounts/abi/abigen/testdata/v2/tupler.go.txt | 18 +- .../abi/abigen/testdata/v2/underscorer.go.txt | 106 +++++---- .../bind/v2/internal/contracts/db/bindings.go | 79 ++++--- .../v2/internal/contracts/events/bindings.go | 50 +++-- .../contracts/nested_libraries/bindings.go | 98 +++++---- .../contracts/solc_errors/bindings.go | 77 ++++--- .../contracts/uint256arrayreturn/bindings.go | 13 +- accounts/abi/bind/v2/lib_test.go | 4 +- 30 files changed, 945 insertions(+), 633 deletions(-) diff --git a/accounts/abi/abigen/bindv2_test.go b/accounts/abi/abigen/bindv2_test.go index 4de6069d4d..8c36d7bbd3 100644 --- a/accounts/abi/abigen/bindv2_test.go +++ b/accounts/abi/abigen/bindv2_test.go @@ -34,31 +34,7 @@ type bindV2Test struct { aliases map[string]string } -// bindABI returns bindings for a test case supplying only the ABI definition for bindings, and not the deployer -// bytecode. -func bindABI(test *bindV2Test) (bound string, err error) { - var ( - abis []string - bins []string - types []string - ) - libs := make(map[string]string) - - for i := 0; i < len(test.types); i++ { - abis = append(abis, test.abis[i]) - bins = append(bins, "") - types = append(types, test.types[i]) - } - - code, err := BindV2(types, abis, bins, "convertedv1bindtests", libs, test.aliases) - if err != nil { - return "", fmt.Errorf("error creating bindings: %v", err) - } - - return code, nil -} - -func bindCombinedJSON(test *bindV2Test) (bound string, err error) { +func bindCombinedJSON(test *bindV2Test) (string, error) { var ( abis []string bins []string @@ -68,9 +44,8 @@ func bindCombinedJSON(test *bindV2Test) (bound string, err error) { for i := 0; i < len(test.types); i++ { // fully qualified name is of the form : typeName := test.types[i] - bin := test.bytecodes[i] abis = append(abis, test.abis[i]) - bins = append(bins, bin) + bins = append(bins, test.bytecodes[i]) types = append(types, typeName) // Derive the library placeholder which is a 34 character prefix of the @@ -83,11 +58,10 @@ func bindCombinedJSON(test *bindV2Test) (bound string, err error) { if test.aliases == nil { test.aliases = make(map[string]string) } - code, err := BindV2(types, abis, bins, "convertedv1bindtests", libs, test.aliases) + code, err := BindV2(types, abis, bins, "bindtests", libs, test.aliases) if err != nil { return "", fmt.Errorf("error creating bindings: %v", err) } - return code, nil } @@ -282,18 +256,18 @@ var combinedJSONBindTestsV2 = []bindV2Test{ nil, nil, }, + { + "Structs", + []string{`[{"inputs":[],"name":"F","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"},{"internalType":"uint256[]","name":"c","type":"uint256[]"},{"internalType":"bool[]","name":"d","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"G","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"}],"stateMutability":"view","type":"function"}]`}, + []string{`608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806328811f591461003b5780636fecb6231461005b575b600080fd5b610043610070565b604051610052939291906101a0565b60405180910390f35b6100636100d6565b6040516100529190610186565b604080516002808252606082810190935282918291829190816020015b610095610131565b81526020019060019003908161008d575050805190915061026960611b9082906000906100be57fe5b60209081029190910101515293606093508392509050565b6040805160028082526060828101909352829190816020015b6100f7610131565b8152602001906001900390816100ef575050805190915061026960611b90829060009061012057fe5b602090810291909101015152905090565b60408051602081019091526000815290565b815260200190565b6000815180845260208085019450808401835b8381101561017b578151518752958201959082019060010161015e565b509495945050505050565b600060208252610199602083018461014b565b9392505050565b6000606082526101b3606083018661014b565b6020838203818501528186516101c98185610239565b91508288019350845b818110156101f3576101e5838651610143565b9484019492506001016101d2565b505084810360408601528551808252908201925081860190845b8181101561022b57825115158552938301939183019160010161020d565b509298975050505050505050565b9081526020019056fea2646970667358221220eb85327e285def14230424c52893aebecec1e387a50bb6b75fc4fdbed647f45f64736f6c63430006050033`}, + nil, + nil, + }, } -var abiBindTestCase = bindV2Test{ - "Structs", - []string{`[{"inputs":[],"name":"F","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"},{"internalType":"uint256[]","name":"c","type":"uint256[]"},{"internalType":"bool[]","name":"d","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"G","outputs":[{"components":[{"internalType":"bytes32","name":"B","type":"bytes32"}],"internalType":"structStructs.A[]","name":"a","type":"tuple[]"}],"stateMutability":"view","type":"function"}]`}, - []string{`608060405234801561001057600080fd5b50610278806100206000396000f3fe608060405234801561001057600080fd5b50600436106100365760003560e01c806328811f591461003b5780636fecb6231461005b575b600080fd5b610043610070565b604051610052939291906101a0565b60405180910390f35b6100636100d6565b6040516100529190610186565b604080516002808252606082810190935282918291829190816020015b610095610131565b81526020019060019003908161008d575050805190915061026960611b9082906000906100be57fe5b60209081029190910101515293606093508392509050565b6040805160028082526060828101909352829190816020015b6100f7610131565b8152602001906001900390816100ef575050805190915061026960611b90829060009061012057fe5b602090810291909101015152905090565b60408051602081019091526000815290565b815260200190565b6000815180845260208085019450808401835b8381101561017b578151518752958201959082019060010161015e565b509495945050505050565b600060208252610199602083018461014b565b9392505050565b6000606082526101b3606083018661014b565b6020838203818501528186516101c98185610239565b91508288019350845b818110156101f3576101e5838651610143565b9484019492506001016101d2565b505084810360408601528551808252908201925081860190845b8181101561022b57825115158552938301939183019160010161020d565b509298975050505050505050565b9081526020019056fea2646970667358221220eb85327e285def14230424c52893aebecec1e387a50bb6b75fc4fdbed647f45f64736f6c63430006050033`}, - nil, - nil, -} - -// TestBindingV2ConvertedV1Tests regenerates contracts from the v1 binding test cases (using v2 binding mode) and ensures -// that no mutations occurred compared to the expected output included under internal/convertedv1bindtests. +// TestBindingV2ConvertedV1Tests regenerates contracts from the v1 binding test +// cases (using v2 binding mode) and ensures that no mutations occurred compared +// to the expected output included under testdata/v2. func TestBindingV2ConvertedV1Tests(t *testing.T) { for _, tc := range combinedJSONBindTestsV2 { fname := fmt.Sprintf("testdata/v2/%v.go.txt", strings.ToLower(tc.name)) @@ -323,37 +297,6 @@ func TestBindingV2ConvertedV1Tests(t *testing.T) { } } -// TestBindingV2ConvertedV1TestABI regenerates contracts from the v1 binding test cases (using v2 binding mode) and ensures -// that no mutations occurred compared to the expected output included under internal/convertedv1bindtests. Binding generation -// is performed sourcing only the ABI definition as input (this is what the --abi option of abigen does). -func TestBindingV2ConvertedV1TestABI(t *testing.T) { - tc := abiBindTestCase - fname := fmt.Sprintf("testdata/v2/%v-abi.go.txt", strings.ToLower(tc.name)) - t.Run(tc.name, func(t *testing.T) { - if tc.types == nil { - tc.types = []string{tc.name} - } - have, err := bindABI(&tc) - if err != nil { - t.Fatalf("got error from bindCombinedJSON: %v", err) - } - // Set this environment variable to regenerate the test outputs. - if os.Getenv("WRITE_TEST_FILES") != "" { - if err := os.WriteFile((fname), []byte(have), 0666); err != nil { - t.Fatalf("err writing expected output to file: %v\n", err) - } - } - // Verify the generated code - want, err := os.ReadFile(fname) - if err != nil { - t.Fatalf("failed to read file %v", fname) - } - if have != string(want) { - t.Fatalf("wrong output: %v", prettyDiff(have, string(want))) - } - }) -} - func TestNormalizeArgs(t *testing.T) { type normalizeArgsTc struct { inp []string diff --git a/accounts/abi/abigen/source2.go.tpl b/accounts/abi/abigen/source2.go.tpl index 80cbd28d13..b5fe0d3e21 100644 --- a/accounts/abi/abigen/source2.go.tpl +++ b/accounts/abi/abigen/source2.go.tpl @@ -1,10 +1,10 @@ -{{- /* -*- indent-tabs-mode: t -*- */ -}} // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. package {{.Package}} import ( + "bytes" "math/big" "errors" @@ -16,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -74,6 +75,10 @@ var ( } {{ if .Constructor.Inputs }} + // PackConstructor is the Go binding used to pack the parameters required for + // contract deployment. + // + // Solidity: {{.Constructor.String}} func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) PackConstructor({{range .Constructor.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) []byte { enc, err := {{ decapitalise $contract.Type}}.abi.Pack("" {{range .Constructor.Inputs}}, {{.Name}}{{end}}) if err != nil { @@ -81,10 +86,11 @@ var ( } return enc } - {{ end -}} + {{ end }} {{range .Calls}} - // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}. + // {{.Normalized.Name}} is the Go binding used to pack the parameters required for calling + // the contract method 0x{{printf "%x" .Original.ID}}. // // Solidity: {{.Original.String}} func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) []byte { @@ -98,57 +104,75 @@ var ( {{/* Unpack method is needed only when there are return args */}} {{if .Normalized.Outputs }} {{ if .Structured }} + // {{.Normalized.Name}}Output serves as a container for the return parameters of contract + // method {{ .Normalized.Name }}. type {{.Normalized.Name}}Output struct { {{range .Normalized.Outputs}} {{.Name}} {{bindtype .Type $structs}}{{end}} } {{ end }} - func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}(data []byte) ({{if .Structured}} {{.Normalized.Name}}Output,{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}},{{end}}{{end}} error) { + + // Unpack{{.Normalized.Name}} is the Go binding that unpacks the parameters returned + // from invoking the contract method with ID 0x{{printf "%x" .Original.ID}}. + // + // Solidity: {{.Original.String}} + func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}(data []byte) ( + {{- if .Structured}} {{.Normalized.Name}}Output,{{else}} + {{- range .Normalized.Outputs}} {{bindtype .Type $structs}},{{- end }} + {{- end }} error) { out, err := {{ decapitalise $contract.Type}}.abi.Unpack("{{.Original.Name}}", data) - {{if .Structured}} + {{- if .Structured}} outstruct := new({{.Normalized.Name}}Output) if err != nil { return *outstruct, err } - {{range $i, $t := .Normalized.Outputs}} - {{if ispointertype .Type}} + {{- range $i, $t := .Normalized.Outputs}} + {{- if ispointertype .Type}} outstruct.{{.Name}} = abi.ConvertType(out[{{$i}}], new({{underlyingbindtype .Type }})).({{bindtype .Type $structs}}) - {{ else }} + {{- else }} outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}) - {{ end }}{{end}} - + {{- end }} + {{- end }} return *outstruct, err {{else}} if err != nil { return {{range $i, $_ := .Normalized.Outputs}}{{if ispointertype .Type}}new({{underlyingbindtype .Type }}), {{else}}*new({{bindtype .Type $structs}}), {{end}}{{end}} err } - {{range $i, $t := .Normalized.Outputs}} - {{ if ispointertype .Type }} + {{- range $i, $t := .Normalized.Outputs}} + {{- if ispointertype .Type }} out{{$i}} := abi.ConvertType(out[{{$i}}], new({{underlyingbindtype .Type}})).({{bindtype .Type $structs}}) - {{ else }} + {{- else }} out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}) - {{ end }} - {{end}} - + {{- end }} + {{- end}} return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} err - {{end}} + {{- end}} } {{end}} {{end}} {{range .Events}} // {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} event raised by the {{$contract.Type}} contract. - type {{$contract.Type}}{{.Normalized.Name}} struct { {{range .Normalized.Inputs}} - {{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}} + type {{$contract.Type}}{{.Normalized.Name}} struct { + {{- range .Normalized.Inputs}} + {{- capitalise .Name}} + {{- else}} {{bindtype .Type $structs}} + {{- end }} + {{end}} Raw *types.Log // Blockchain specific contextual infos } const {{$contract.Type}}{{.Normalized.Name}}EventName = "{{.Original.Name}}" + // ContractEventName returns the user-defined event name. func ({{$contract.Type}}{{.Normalized.Name}}) ContractEventName() string { return {{$contract.Type}}{{.Normalized.Name}}EventName } + // Unpack{{.Normalized.Name}}Event is the Go binding that unpacks the event data emitted + // by contract. + // + // Solidity: {{.Original.String}} func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}Event(log *types.Log) (*{{$contract.Type}}{{.Normalized.Name}}, error) { event := "{{.Original.Name}}" if log.Topics[0] != {{ decapitalise $contract.Type}}.abi.Events[event].ID { @@ -175,25 +199,17 @@ var ( {{end}} {{ if .Errors }} - func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) UnpackError(raw []byte) any { - // TODO: we should be able to discern the error type from the selector, instead of trying each possible type - // strip off the error type selector - raw = raw[4:] - {{$i := 0}} - {{range $k, $v := .Errors}} - {{ if eq $i 0 }} - if val, err := {{ decapitalise $contract.Type}}.Unpack{{.Normalized.Name}}Error(raw); err == nil { - return val - {{ else }} - } else if val, err := {{ decapitalise $contract.Type}}.Unpack{{.Normalized.Name}}Error(raw); err == nil { - return val - {{ end -}} - {{$i = add $i 1}} - {{end -}} - } - return nil + // UnpackError attempts to decode the provided error data using user-defined + // error definitions. + func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) UnpackError(raw []byte) (any, error) { + {{- range $k, $v := .Errors}} + if bytes.Equal(raw[:4], {{ decapitalise $contract.Type}}.abi.Errors["{{.Normalized.Name}}"].ID.Bytes()[:4]) { + return {{ decapitalise $contract.Type}}.Unpack{{.Normalized.Name}}Error(raw[4:]) + } + {{- end }} + return nil, errors.New("Unknown error") } - {{ end -}} + {{ end }} {{range .Errors}} // {{$contract.Type}}{{.Normalized.Name}} represents a {{.Normalized.Name}} error raised by the {{$contract.Type}} contract. @@ -201,14 +217,20 @@ var ( {{capitalise .Name}} {{if .Indexed}}{{bindtopictype .Type $structs}}{{else}}{{bindtype .Type $structs}}{{end}}; {{end}} } + // ErrorID returns the hash of canonical representation of the error's signature. + // + // Solidity: {{.Original.String}} func {{$contract.Type}}{{.Normalized.Name}}ErrorID() common.Hash { return common.HexToHash("{{.Original.ID}}") } + // Unpack{{.Normalized.Name}}Error is the Go binding used to decode the provided + // error data into the corresponding Go error struct. + // + // Solidity: {{.Original.String}} func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}Error(raw []byte) (*{{$contract.Type}}{{.Normalized.Name}}, error) { - errName := "{{.Normalized.Name}}" out := new({{$contract.Type}}{{.Normalized.Name}}) - if err := {{ decapitalise $contract.Type}}.abi.UnpackIntoInterface(out, errName, raw); err != nil { + if err := {{ decapitalise $contract.Type}}.abi.UnpackIntoInterface(out, "{{.Normalized.Name}}", raw); err != nil { return nil, err } return out, nil diff --git a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt index 34e43fa90a..076da5909f 100644 --- a/accounts/abi/abigen/testdata/v2/callbackparam.go.txt +++ b/accounts/abi/abigen/testdata/v2/callbackparam.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *CallbackParam) Instance(backend bind.ContractBackend, addr common.Addre return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Test is a free data retrieval call binding the contract method 0xd7a5aba2. +// Test is the Go binding used to pack the parameters required for calling +// the contract method 0xd7a5aba2. // // Solidity: function test(function callback) returns() func (callbackParam *CallbackParam) PackTest(Callback [24]byte) []byte { diff --git a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt index eec6449b5f..c8c5f0890f 100644 --- a/accounts/abi/abigen/testdata/v2/crowdsale.go.txt +++ b/accounts/abi/abigen/testdata/v2/crowdsale.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,6 +51,10 @@ func (c *Crowdsale) Instance(backend bind.ContractBackend, addr common.Address) return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(address ifSuccessfulSendTo, uint256 fundingGoalInEthers, uint256 durationInMinutes, uint256 etherCostOfEachToken, address addressOfTokenUsedAsReward) returns() func (crowdsale *Crowdsale) PackConstructor(ifSuccessfulSendTo common.Address, fundingGoalInEthers *big.Int, durationInMinutes *big.Int, etherCostOfEachToken *big.Int, addressOfTokenUsedAsReward common.Address) []byte { enc, err := crowdsale.abi.Pack("", ifSuccessfulSendTo, fundingGoalInEthers, durationInMinutes, etherCostOfEachToken, addressOfTokenUsedAsReward) if err != nil { @@ -57,7 +63,8 @@ func (crowdsale *Crowdsale) PackConstructor(ifSuccessfulSendTo common.Address, f return enc } -// AmountRaised is a free data retrieval call binding the contract method 0x7b3e5e7b. +// AmountRaised is the Go binding used to pack the parameters required for calling +// the contract method 0x7b3e5e7b. // // Solidity: function amountRaised() returns(uint256) func (crowdsale *Crowdsale) PackAmountRaised() []byte { @@ -68,20 +75,21 @@ func (crowdsale *Crowdsale) PackAmountRaised() []byte { return enc } +// UnpackAmountRaised is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x7b3e5e7b. +// +// Solidity: function amountRaised() returns(uint256) func (crowdsale *Crowdsale) UnpackAmountRaised(data []byte) (*big.Int, error) { out, err := crowdsale.abi.Unpack("amountRaised", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Beneficiary is a free data retrieval call binding the contract method 0x38af3eed. +// Beneficiary is the Go binding used to pack the parameters required for calling +// the contract method 0x38af3eed. // // Solidity: function beneficiary() returns(address) func (crowdsale *Crowdsale) PackBeneficiary() []byte { @@ -92,20 +100,21 @@ func (crowdsale *Crowdsale) PackBeneficiary() []byte { return enc } +// UnpackBeneficiary is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x38af3eed. +// +// Solidity: function beneficiary() returns(address) func (crowdsale *Crowdsale) UnpackBeneficiary(data []byte) (common.Address, error) { out, err := crowdsale.abi.Unpack("beneficiary", data) - if err != nil { return *new(common.Address), err } - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - return out0, err - } -// CheckGoalReached is a free data retrieval call binding the contract method 0x01cb3b20. +// CheckGoalReached is the Go binding used to pack the parameters required for calling +// the contract method 0x01cb3b20. // // Solidity: function checkGoalReached() returns() func (crowdsale *Crowdsale) PackCheckGoalReached() []byte { @@ -116,7 +125,8 @@ func (crowdsale *Crowdsale) PackCheckGoalReached() []byte { return enc } -// Deadline is a free data retrieval call binding the contract method 0x29dcb0cf. +// Deadline is the Go binding used to pack the parameters required for calling +// the contract method 0x29dcb0cf. // // Solidity: function deadline() returns(uint256) func (crowdsale *Crowdsale) PackDeadline() []byte { @@ -127,20 +137,21 @@ func (crowdsale *Crowdsale) PackDeadline() []byte { return enc } +// UnpackDeadline is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x29dcb0cf. +// +// Solidity: function deadline() returns(uint256) func (crowdsale *Crowdsale) UnpackDeadline(data []byte) (*big.Int, error) { out, err := crowdsale.abi.Unpack("deadline", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Funders is a free data retrieval call binding the contract method 0xdc0d3dff. +// Funders is the Go binding used to pack the parameters required for calling +// the contract method 0xdc0d3dff. // // Solidity: function funders(uint256 ) returns(address addr, uint256 amount) func (crowdsale *Crowdsale) PackFunders(Arg0 *big.Int) []byte { @@ -151,28 +162,31 @@ func (crowdsale *Crowdsale) PackFunders(Arg0 *big.Int) []byte { return enc } +// FundersOutput serves as a container for the return parameters of contract +// method Funders. type FundersOutput struct { Addr common.Address Amount *big.Int } +// UnpackFunders is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xdc0d3dff. +// +// Solidity: function funders(uint256 ) returns(address addr, uint256 amount) func (crowdsale *Crowdsale) UnpackFunders(data []byte) (FundersOutput, error) { out, err := crowdsale.abi.Unpack("funders", data) - outstruct := new(FundersOutput) if err != nil { return *outstruct, err } - outstruct.Addr = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.Amount = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// FundingGoal is a free data retrieval call binding the contract method 0x7a3a0e84. +// FundingGoal is the Go binding used to pack the parameters required for calling +// the contract method 0x7a3a0e84. // // Solidity: function fundingGoal() returns(uint256) func (crowdsale *Crowdsale) PackFundingGoal() []byte { @@ -183,20 +197,21 @@ func (crowdsale *Crowdsale) PackFundingGoal() []byte { return enc } +// UnpackFundingGoal is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x7a3a0e84. +// +// Solidity: function fundingGoal() returns(uint256) func (crowdsale *Crowdsale) UnpackFundingGoal(data []byte) (*big.Int, error) { out, err := crowdsale.abi.Unpack("fundingGoal", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Price is a free data retrieval call binding the contract method 0xa035b1fe. +// Price is the Go binding used to pack the parameters required for calling +// the contract method 0xa035b1fe. // // Solidity: function price() returns(uint256) func (crowdsale *Crowdsale) PackPrice() []byte { @@ -207,20 +222,21 @@ func (crowdsale *Crowdsale) PackPrice() []byte { return enc } +// UnpackPrice is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xa035b1fe. +// +// Solidity: function price() returns(uint256) func (crowdsale *Crowdsale) UnpackPrice(data []byte) (*big.Int, error) { out, err := crowdsale.abi.Unpack("price", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// TokenReward is a free data retrieval call binding the contract method 0x6e66f6e9. +// TokenReward is the Go binding used to pack the parameters required for calling +// the contract method 0x6e66f6e9. // // Solidity: function tokenReward() returns(address) func (crowdsale *Crowdsale) PackTokenReward() []byte { @@ -231,17 +247,17 @@ func (crowdsale *Crowdsale) PackTokenReward() []byte { return enc } +// UnpackTokenReward is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6e66f6e9. +// +// Solidity: function tokenReward() returns(address) func (crowdsale *Crowdsale) UnpackTokenReward(data []byte) (common.Address, error) { out, err := crowdsale.abi.Unpack("tokenReward", data) - if err != nil { return *new(common.Address), err } - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - return out0, err - } // CrowdsaleFundTransfer represents a FundTransfer event raised by the Crowdsale contract. @@ -249,15 +265,21 @@ type CrowdsaleFundTransfer struct { Backer common.Address Amount *big.Int IsContribution bool - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const CrowdsaleFundTransferEventName = "FundTransfer" +// ContractEventName returns the user-defined event name. func (CrowdsaleFundTransfer) ContractEventName() string { return CrowdsaleFundTransferEventName } +// UnpackFundTransferEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event FundTransfer(address backer, uint256 amount, bool isContribution) func (crowdsale *Crowdsale) UnpackFundTransferEvent(log *types.Log) (*CrowdsaleFundTransfer, error) { event := "FundTransfer" if log.Topics[0] != crowdsale.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/dao.go.txt b/accounts/abi/abigen/testdata/v2/dao.go.txt index 0800541255..32ad1a40a3 100644 --- a/accounts/abi/abigen/testdata/v2/dao.go.txt +++ b/accounts/abi/abigen/testdata/v2/dao.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,6 +51,10 @@ func (c *DAO) Instance(backend bind.ContractBackend, addr common.Address) *bind. return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority, address congressLeader) returns() func (dAO *DAO) PackConstructor(minimumQuorumForProposals *big.Int, minutesForDebate *big.Int, marginOfVotesForMajority *big.Int, congressLeader common.Address) []byte { enc, err := dAO.abi.Pack("", minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority, congressLeader) if err != nil { @@ -57,7 +63,8 @@ func (dAO *DAO) PackConstructor(minimumQuorumForProposals *big.Int, minutesForDe return enc } -// ChangeMembership is a free data retrieval call binding the contract method 0x9644fcbd. +// ChangeMembership is the Go binding used to pack the parameters required for calling +// the contract method 0x9644fcbd. // // Solidity: function changeMembership(address targetMember, bool canVote, string memberName) returns() func (dAO *DAO) PackChangeMembership(TargetMember common.Address, CanVote bool, MemberName string) []byte { @@ -68,7 +75,8 @@ func (dAO *DAO) PackChangeMembership(TargetMember common.Address, CanVote bool, return enc } -// ChangeVotingRules is a free data retrieval call binding the contract method 0xbcca1fd3. +// ChangeVotingRules is the Go binding used to pack the parameters required for calling +// the contract method 0xbcca1fd3. // // Solidity: function changeVotingRules(uint256 minimumQuorumForProposals, uint256 minutesForDebate, int256 marginOfVotesForMajority) returns() func (dAO *DAO) PackChangeVotingRules(MinimumQuorumForProposals *big.Int, MinutesForDebate *big.Int, MarginOfVotesForMajority *big.Int) []byte { @@ -79,7 +87,8 @@ func (dAO *DAO) PackChangeVotingRules(MinimumQuorumForProposals *big.Int, Minute return enc } -// CheckProposalCode is a free data retrieval call binding the contract method 0xeceb2945. +// CheckProposalCode is the Go binding used to pack the parameters required for calling +// the contract method 0xeceb2945. // // Solidity: function checkProposalCode(uint256 proposalNumber, address beneficiary, uint256 etherAmount, bytes transactionBytecode) returns(bool codeChecksOut) func (dAO *DAO) PackCheckProposalCode(ProposalNumber *big.Int, Beneficiary common.Address, EtherAmount *big.Int, TransactionBytecode []byte) []byte { @@ -90,20 +99,21 @@ func (dAO *DAO) PackCheckProposalCode(ProposalNumber *big.Int, Beneficiary commo return enc } +// UnpackCheckProposalCode is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xeceb2945. +// +// Solidity: function checkProposalCode(uint256 proposalNumber, address beneficiary, uint256 etherAmount, bytes transactionBytecode) returns(bool codeChecksOut) func (dAO *DAO) UnpackCheckProposalCode(data []byte) (bool, error) { out, err := dAO.abi.Unpack("checkProposalCode", data) - if err != nil { return *new(bool), err } - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - return out0, err - } -// DebatingPeriodInMinutes is a free data retrieval call binding the contract method 0x69bd3436. +// DebatingPeriodInMinutes is the Go binding used to pack the parameters required for calling +// the contract method 0x69bd3436. // // Solidity: function debatingPeriodInMinutes() returns(uint256) func (dAO *DAO) PackDebatingPeriodInMinutes() []byte { @@ -114,20 +124,21 @@ func (dAO *DAO) PackDebatingPeriodInMinutes() []byte { return enc } +// UnpackDebatingPeriodInMinutes is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x69bd3436. +// +// Solidity: function debatingPeriodInMinutes() returns(uint256) func (dAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("debatingPeriodInMinutes", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// ExecuteProposal is a free data retrieval call binding the contract method 0x237e9492. +// ExecuteProposal is the Go binding used to pack the parameters required for calling +// the contract method 0x237e9492. // // Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result) func (dAO *DAO) PackExecuteProposal(ProposalNumber *big.Int, TransactionBytecode []byte) []byte { @@ -138,20 +149,21 @@ func (dAO *DAO) PackExecuteProposal(ProposalNumber *big.Int, TransactionBytecode return enc } +// UnpackExecuteProposal is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x237e9492. +// +// Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result) func (dAO *DAO) UnpackExecuteProposal(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("executeProposal", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// MajorityMargin is a free data retrieval call binding the contract method 0xaa02a90f. +// MajorityMargin is the Go binding used to pack the parameters required for calling +// the contract method 0xaa02a90f. // // Solidity: function majorityMargin() returns(int256) func (dAO *DAO) PackMajorityMargin() []byte { @@ -162,20 +174,21 @@ func (dAO *DAO) PackMajorityMargin() []byte { return enc } +// UnpackMajorityMargin is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xaa02a90f. +// +// Solidity: function majorityMargin() returns(int256) func (dAO *DAO) UnpackMajorityMargin(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("majorityMargin", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// MemberId is a free data retrieval call binding the contract method 0x39106821. +// MemberId is the Go binding used to pack the parameters required for calling +// the contract method 0x39106821. // // Solidity: function memberId(address ) returns(uint256) func (dAO *DAO) PackMemberId(Arg0 common.Address) []byte { @@ -186,20 +199,21 @@ func (dAO *DAO) PackMemberId(Arg0 common.Address) []byte { return enc } +// UnpackMemberId is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x39106821. +// +// Solidity: function memberId(address ) returns(uint256) func (dAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("memberId", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Members is a free data retrieval call binding the contract method 0x5daf08ca. +// Members is the Go binding used to pack the parameters required for calling +// the contract method 0x5daf08ca. // // Solidity: function members(uint256 ) returns(address member, bool canVote, string name, uint256 memberSince) func (dAO *DAO) PackMembers(Arg0 *big.Int) []byte { @@ -210,6 +224,8 @@ func (dAO *DAO) PackMembers(Arg0 *big.Int) []byte { return enc } +// MembersOutput serves as a container for the return parameters of contract +// method Members. type MembersOutput struct { Member common.Address CanVote bool @@ -217,27 +233,26 @@ type MembersOutput struct { MemberSince *big.Int } +// UnpackMembers is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x5daf08ca. +// +// Solidity: function members(uint256 ) returns(address member, bool canVote, string name, uint256 memberSince) func (dAO *DAO) UnpackMembers(data []byte) (MembersOutput, error) { out, err := dAO.abi.Unpack("members", data) - outstruct := new(MembersOutput) if err != nil { return *outstruct, err } - outstruct.Member = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.CanVote = *abi.ConvertType(out[1], new(bool)).(*bool) - outstruct.Name = *abi.ConvertType(out[2], new(string)).(*string) - outstruct.MemberSince = abi.ConvertType(out[3], new(big.Int)).(*big.Int) - return *outstruct, err } -// MinimumQuorum is a free data retrieval call binding the contract method 0x8160f0b5. +// MinimumQuorum is the Go binding used to pack the parameters required for calling +// the contract method 0x8160f0b5. // // Solidity: function minimumQuorum() returns(uint256) func (dAO *DAO) PackMinimumQuorum() []byte { @@ -248,20 +263,21 @@ func (dAO *DAO) PackMinimumQuorum() []byte { return enc } +// UnpackMinimumQuorum is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x8160f0b5. +// +// Solidity: function minimumQuorum() returns(uint256) func (dAO *DAO) UnpackMinimumQuorum(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("minimumQuorum", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// NewProposal is a free data retrieval call binding the contract method 0xb1050da5. +// NewProposal is the Go binding used to pack the parameters required for calling +// the contract method 0xb1050da5. // // Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID) func (dAO *DAO) PackNewProposal(Beneficiary common.Address, EtherAmount *big.Int, JobDescription string, TransactionBytecode []byte) []byte { @@ -272,20 +288,21 @@ func (dAO *DAO) PackNewProposal(Beneficiary common.Address, EtherAmount *big.Int return enc } +// UnpackNewProposal is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xb1050da5. +// +// Solidity: function newProposal(address beneficiary, uint256 etherAmount, string JobDescription, bytes transactionBytecode) returns(uint256 proposalID) func (dAO *DAO) UnpackNewProposal(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("newProposal", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// NumProposals is a free data retrieval call binding the contract method 0x400e3949. +// NumProposals is the Go binding used to pack the parameters required for calling +// the contract method 0x400e3949. // // Solidity: function numProposals() returns(uint256) func (dAO *DAO) PackNumProposals() []byte { @@ -296,20 +313,21 @@ func (dAO *DAO) PackNumProposals() []byte { return enc } +// UnpackNumProposals is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x400e3949. +// +// Solidity: function numProposals() returns(uint256) func (dAO *DAO) UnpackNumProposals(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("numProposals", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Owner is a free data retrieval call binding the contract method 0x8da5cb5b. +// Owner is the Go binding used to pack the parameters required for calling +// the contract method 0x8da5cb5b. // // Solidity: function owner() returns(address) func (dAO *DAO) PackOwner() []byte { @@ -320,20 +338,21 @@ func (dAO *DAO) PackOwner() []byte { return enc } +// UnpackOwner is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x8da5cb5b. +// +// Solidity: function owner() returns(address) func (dAO *DAO) UnpackOwner(data []byte) (common.Address, error) { out, err := dAO.abi.Unpack("owner", data) - if err != nil { return *new(common.Address), err } - out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - return out0, err - } -// Proposals is a free data retrieval call binding the contract method 0x013cf08b. +// Proposals is the Go binding used to pack the parameters required for calling +// the contract method 0x013cf08b. // // Solidity: function proposals(uint256 ) returns(address recipient, uint256 amount, string description, uint256 votingDeadline, bool executed, bool proposalPassed, uint256 numberOfVotes, int256 currentResult, bytes32 proposalHash) func (dAO *DAO) PackProposals(Arg0 *big.Int) []byte { @@ -344,6 +363,8 @@ func (dAO *DAO) PackProposals(Arg0 *big.Int) []byte { return enc } +// ProposalsOutput serves as a container for the return parameters of contract +// method Proposals. type ProposalsOutput struct { Recipient common.Address Amount *big.Int @@ -356,37 +377,31 @@ type ProposalsOutput struct { ProposalHash [32]byte } +// UnpackProposals is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x013cf08b. +// +// Solidity: function proposals(uint256 ) returns(address recipient, uint256 amount, string description, uint256 votingDeadline, bool executed, bool proposalPassed, uint256 numberOfVotes, int256 currentResult, bytes32 proposalHash) func (dAO *DAO) UnpackProposals(data []byte) (ProposalsOutput, error) { out, err := dAO.abi.Unpack("proposals", data) - outstruct := new(ProposalsOutput) if err != nil { return *outstruct, err } - outstruct.Recipient = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) - outstruct.Amount = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Description = *abi.ConvertType(out[2], new(string)).(*string) - outstruct.VotingDeadline = abi.ConvertType(out[3], new(big.Int)).(*big.Int) - outstruct.Executed = *abi.ConvertType(out[4], new(bool)).(*bool) - outstruct.ProposalPassed = *abi.ConvertType(out[5], new(bool)).(*bool) - outstruct.NumberOfVotes = abi.ConvertType(out[6], new(big.Int)).(*big.Int) - outstruct.CurrentResult = abi.ConvertType(out[7], new(big.Int)).(*big.Int) - outstruct.ProposalHash = *abi.ConvertType(out[8], new([32]byte)).(*[32]byte) - return *outstruct, err } -// TransferOwnership is a free data retrieval call binding the contract method 0xf2fde38b. +// TransferOwnership is the Go binding used to pack the parameters required for calling +// the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() func (dAO *DAO) PackTransferOwnership(NewOwner common.Address) []byte { @@ -397,7 +412,8 @@ func (dAO *DAO) PackTransferOwnership(NewOwner common.Address) []byte { return enc } -// Vote is a free data retrieval call binding the contract method 0xd3c0715b. +// Vote is the Go binding used to pack the parameters required for calling +// the contract method 0xd3c0715b. // // Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID) func (dAO *DAO) PackVote(ProposalNumber *big.Int, SupportsProposal bool, JustificationText string) []byte { @@ -408,17 +424,17 @@ func (dAO *DAO) PackVote(ProposalNumber *big.Int, SupportsProposal bool, Justifi return enc } +// UnpackVote is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xd3c0715b. +// +// Solidity: function vote(uint256 proposalNumber, bool supportsProposal, string justificationText) returns(uint256 voteID) func (dAO *DAO) UnpackVote(data []byte) (*big.Int, error) { out, err := dAO.abi.Unpack("vote", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // DAOChangeOfRules represents a ChangeOfRules event raised by the DAO contract. @@ -426,15 +442,21 @@ type DAOChangeOfRules struct { MinimumQuorum *big.Int DebatingPeriodInMinutes *big.Int MajorityMargin *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DAOChangeOfRulesEventName = "ChangeOfRules" +// ContractEventName returns the user-defined event name. func (DAOChangeOfRules) ContractEventName() string { return DAOChangeOfRulesEventName } +// UnpackChangeOfRulesEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event ChangeOfRules(uint256 minimumQuorum, uint256 debatingPeriodInMinutes, int256 majorityMargin) func (dAO *DAO) UnpackChangeOfRulesEvent(log *types.Log) (*DAOChangeOfRules, error) { event := "ChangeOfRules" if log.Topics[0] != dAO.abi.Events[event].ID { @@ -463,15 +485,21 @@ func (dAO *DAO) UnpackChangeOfRulesEvent(log *types.Log) (*DAOChangeOfRules, err type DAOMembershipChanged struct { Member common.Address IsMember bool - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DAOMembershipChangedEventName = "MembershipChanged" +// ContractEventName returns the user-defined event name. func (DAOMembershipChanged) ContractEventName() string { return DAOMembershipChangedEventName } +// UnpackMembershipChangedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event MembershipChanged(address member, bool isMember) func (dAO *DAO) UnpackMembershipChangedEvent(log *types.Log) (*DAOMembershipChanged, error) { event := "MembershipChanged" if log.Topics[0] != dAO.abi.Events[event].ID { @@ -502,15 +530,21 @@ type DAOProposalAdded struct { Recipient common.Address Amount *big.Int Description string - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DAOProposalAddedEventName = "ProposalAdded" +// ContractEventName returns the user-defined event name. func (DAOProposalAdded) ContractEventName() string { return DAOProposalAddedEventName } +// UnpackProposalAddedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event ProposalAdded(uint256 proposalID, address recipient, uint256 amount, string description) func (dAO *DAO) UnpackProposalAddedEvent(log *types.Log) (*DAOProposalAdded, error) { event := "ProposalAdded" if log.Topics[0] != dAO.abi.Events[event].ID { @@ -541,15 +575,21 @@ type DAOProposalTallied struct { Result *big.Int Quorum *big.Int Active bool - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DAOProposalTalliedEventName = "ProposalTallied" +// ContractEventName returns the user-defined event name. func (DAOProposalTallied) ContractEventName() string { return DAOProposalTalliedEventName } +// UnpackProposalTalliedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event ProposalTallied(uint256 proposalID, int256 result, uint256 quorum, bool active) func (dAO *DAO) UnpackProposalTalliedEvent(log *types.Log) (*DAOProposalTallied, error) { event := "ProposalTallied" if log.Topics[0] != dAO.abi.Events[event].ID { @@ -580,15 +620,21 @@ type DAOVoted struct { Position bool Voter common.Address Justification string - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DAOVotedEventName = "Voted" +// ContractEventName returns the user-defined event name. func (DAOVoted) ContractEventName() string { return DAOVotedEventName } +// UnpackVotedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event Voted(uint256 proposalID, bool position, address voter, string justification) func (dAO *DAO) UnpackVotedEvent(log *types.Log) (*DAOVoted, error) { event := "Voted" if log.Topics[0] != dAO.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt index ccbafd2e2c..69b26b30c9 100644 --- a/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt +++ b/accounts/abi/abigen/testdata/v2/deeplynestedarray.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *DeeplyNestedArray) Instance(backend bind.ContractBackend, addr common.A return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// DeepUint64Array is a free data retrieval call binding the contract method 0x98ed1856. +// DeepUint64Array is the Go binding used to pack the parameters required for calling +// the contract method 0x98ed1856. // // Solidity: function deepUint64Array(uint256 , uint256 , uint256 ) view returns(uint64) func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(Arg0 *big.Int, Arg1 *big.Int, Arg2 *big.Int) []byte { @@ -60,20 +63,21 @@ func (deeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(Arg0 *big.Int, A return enc } +// UnpackDeepUint64Array is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x98ed1856. +// +// Solidity: function deepUint64Array(uint256 , uint256 , uint256 ) view returns(uint64) func (deeplyNestedArray *DeeplyNestedArray) UnpackDeepUint64Array(data []byte) (uint64, error) { out, err := deeplyNestedArray.abi.Unpack("deepUint64Array", data) - if err != nil { return *new(uint64), err } - out0 := *abi.ConvertType(out[0], new(uint64)).(*uint64) - return out0, err - } -// RetrieveDeepArray is a free data retrieval call binding the contract method 0x8ed4573a. +// RetrieveDeepArray is the Go binding used to pack the parameters required for calling +// the contract method 0x8ed4573a. // // Solidity: function retrieveDeepArray() view returns(uint64[3][4][5]) func (deeplyNestedArray *DeeplyNestedArray) PackRetrieveDeepArray() []byte { @@ -84,20 +88,21 @@ func (deeplyNestedArray *DeeplyNestedArray) PackRetrieveDeepArray() []byte { return enc } +// UnpackRetrieveDeepArray is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x8ed4573a. +// +// Solidity: function retrieveDeepArray() view returns(uint64[3][4][5]) func (deeplyNestedArray *DeeplyNestedArray) UnpackRetrieveDeepArray(data []byte) ([5][4][3]uint64, error) { out, err := deeplyNestedArray.abi.Unpack("retrieveDeepArray", data) - if err != nil { return *new([5][4][3]uint64), err } - out0 := *abi.ConvertType(out[0], new([5][4][3]uint64)).(*[5][4][3]uint64) - return out0, err - } -// StoreDeepUintArray is a free data retrieval call binding the contract method 0x34424855. +// StoreDeepUintArray is the Go binding used to pack the parameters required for calling +// the contract method 0x34424855. // // Solidity: function storeDeepUintArray(uint64[3][4][5] arr) returns() func (deeplyNestedArray *DeeplyNestedArray) PackStoreDeepUintArray(Arr [5][4][3]uint64) []byte { diff --git a/accounts/abi/abigen/testdata/v2/empty.go.txt b/accounts/abi/abigen/testdata/v2/empty.go.txt index 68b3d335c3..7082e20799 100644 --- a/accounts/abi/abigen/testdata/v2/empty.go.txt +++ b/accounts/abi/abigen/testdata/v2/empty.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 diff --git a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt index 6ca2b6e236..5507115063 100644 --- a/accounts/abi/abigen/testdata/v2/eventchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/eventchecker.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -54,15 +56,21 @@ type EventCheckerDynamic struct { IdxDat common.Hash Str string Dat []byte - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const EventCheckerDynamicEventName = "dynamic" +// ContractEventName returns the user-defined event name. func (EventCheckerDynamic) ContractEventName() string { return EventCheckerDynamicEventName } +// UnpackDynamicEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event dynamic(string indexed idxStr, bytes indexed idxDat, string str, bytes dat) func (eventChecker *EventChecker) UnpackDynamicEvent(log *types.Log) (*EventCheckerDynamic, error) { event := "dynamic" if log.Topics[0] != eventChecker.abi.Events[event].ID { @@ -94,10 +102,15 @@ type EventCheckerEmpty struct { const EventCheckerEmptyEventName = "empty" +// ContractEventName returns the user-defined event name. func (EventCheckerEmpty) ContractEventName() string { return EventCheckerEmptyEventName } +// UnpackEmptyEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event empty() func (eventChecker *EventChecker) UnpackEmptyEvent(log *types.Log) (*EventCheckerEmpty, error) { event := "empty" if log.Topics[0] != eventChecker.abi.Events[event].ID { @@ -126,15 +139,21 @@ func (eventChecker *EventChecker) UnpackEmptyEvent(log *types.Log) (*EventChecke type EventCheckerIndexed struct { Addr common.Address Num *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const EventCheckerIndexedEventName = "indexed" +// ContractEventName returns the user-defined event name. func (EventCheckerIndexed) ContractEventName() string { return EventCheckerIndexedEventName } +// UnpackIndexedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event indexed(address indexed addr, int256 indexed num) func (eventChecker *EventChecker) UnpackIndexedEvent(log *types.Log) (*EventCheckerIndexed, error) { event := "indexed" if log.Topics[0] != eventChecker.abi.Events[event].ID { @@ -163,15 +182,21 @@ func (eventChecker *EventChecker) UnpackIndexedEvent(log *types.Log) (*EventChec type EventCheckerMixed struct { Addr common.Address Num *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const EventCheckerMixedEventName = "mixed" +// ContractEventName returns the user-defined event name. func (EventCheckerMixed) ContractEventName() string { return EventCheckerMixedEventName } +// UnpackMixedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event mixed(address indexed addr, int256 num) func (eventChecker *EventChecker) UnpackMixedEvent(log *types.Log) (*EventCheckerMixed, error) { event := "mixed" if log.Topics[0] != eventChecker.abi.Events[event].ID { @@ -200,15 +225,21 @@ func (eventChecker *EventChecker) UnpackMixedEvent(log *types.Log) (*EventChecke type EventCheckerUnnamed struct { Arg0 *big.Int Arg1 *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const EventCheckerUnnamedEventName = "unnamed" +// ContractEventName returns the user-defined event name. func (EventCheckerUnnamed) ContractEventName() string { return EventCheckerUnnamedEventName } +// UnpackUnnamedEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event unnamed(uint256 indexed arg0, uint256 indexed arg1) func (eventChecker *EventChecker) UnpackUnnamedEvent(log *types.Log) (*EventCheckerUnnamed, error) { event := "unnamed" if log.Topics[0] != eventChecker.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/getter.go.txt b/accounts/abi/abigen/testdata/v2/getter.go.txt index 18b57a55e6..ae014799f5 100644 --- a/accounts/abi/abigen/testdata/v2/getter.go.txt +++ b/accounts/abi/abigen/testdata/v2/getter.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *Getter) Instance(backend bind.ContractBackend, addr common.Address) *bi return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Getter is a free data retrieval call binding the contract method 0x993a04b7. +// Getter is the Go binding used to pack the parameters required for calling +// the contract method 0x993a04b7. // // Solidity: function getter() returns(string, int256, bytes32) func (getter *Getter) PackGetter() []byte { @@ -60,26 +63,27 @@ func (getter *Getter) PackGetter() []byte { return enc } +// GetterOutput serves as a container for the return parameters of contract +// method Getter. type GetterOutput struct { Arg0 string Arg1 *big.Int Arg2 [32]byte } +// UnpackGetter is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x993a04b7. +// +// Solidity: function getter() returns(string, int256, bytes32) func (getter *Getter) UnpackGetter(data []byte) (GetterOutput, error) { out, err := getter.abi.Unpack("getter", data) - outstruct := new(GetterOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Arg2 = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) - return *outstruct, err } diff --git a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt index 7a8248b421..d6785344f0 100644 --- a/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt +++ b/accounts/abi/abigen/testdata/v2/identifiercollision.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *IdentifierCollision) Instance(backend bind.ContractBackend, addr common return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// MyVar is a free data retrieval call binding the contract method 0x4ef1f0ad. +// MyVar is the Go binding used to pack the parameters required for calling +// the contract method 0x4ef1f0ad. // // Solidity: function MyVar() view returns(uint256) func (identifierCollision *IdentifierCollision) PackMyVar() []byte { @@ -60,20 +63,21 @@ func (identifierCollision *IdentifierCollision) PackMyVar() []byte { return enc } +// UnpackMyVar is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x4ef1f0ad. +// +// Solidity: function MyVar() view returns(uint256) func (identifierCollision *IdentifierCollision) UnpackMyVar(data []byte) (*big.Int, error) { out, err := identifierCollision.abi.Unpack("MyVar", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// PubVar is a free data retrieval call binding the contract method 0x01ad4d87. +// PubVar is the Go binding used to pack the parameters required for calling +// the contract method 0x01ad4d87. // // Solidity: function _myVar() view returns(uint256) func (identifierCollision *IdentifierCollision) PackPubVar() []byte { @@ -84,15 +88,15 @@ func (identifierCollision *IdentifierCollision) PackPubVar() []byte { return enc } +// UnpackPubVar is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x01ad4d87. +// +// Solidity: function _myVar() view returns(uint256) func (identifierCollision *IdentifierCollision) UnpackPubVar(data []byte) (*big.Int, error) { out, err := identifierCollision.abi.Unpack("_myVar", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } diff --git a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt index 16f554dcf4..d13e77d8d4 100644 --- a/accounts/abi/abigen/testdata/v2/inputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/inputchecker.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -48,7 +50,8 @@ func (c *InputChecker) Instance(backend bind.ContractBackend, addr common.Addres return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// AnonInput is a free data retrieval call binding the contract method 0x3e708e82. +// AnonInput is the Go binding used to pack the parameters required for calling +// the contract method 0x3e708e82. // // Solidity: function anonInput(string ) returns() func (inputChecker *InputChecker) PackAnonInput(Arg0 string) []byte { @@ -59,7 +62,8 @@ func (inputChecker *InputChecker) PackAnonInput(Arg0 string) []byte { return enc } -// AnonInputs is a free data retrieval call binding the contract method 0x28160527. +// AnonInputs is the Go binding used to pack the parameters required for calling +// the contract method 0x28160527. // // Solidity: function anonInputs(string , string ) returns() func (inputChecker *InputChecker) PackAnonInputs(Arg0 string, Arg1 string) []byte { @@ -70,7 +74,8 @@ func (inputChecker *InputChecker) PackAnonInputs(Arg0 string, Arg1 string) []byt return enc } -// MixedInputs is a free data retrieval call binding the contract method 0xc689ebdc. +// MixedInputs is the Go binding used to pack the parameters required for calling +// the contract method 0xc689ebdc. // // Solidity: function mixedInputs(string , string str) returns() func (inputChecker *InputChecker) PackMixedInputs(Arg0 string, Str string) []byte { @@ -81,7 +86,8 @@ func (inputChecker *InputChecker) PackMixedInputs(Arg0 string, Str string) []byt return enc } -// NamedInput is a free data retrieval call binding the contract method 0x0d402005. +// NamedInput is the Go binding used to pack the parameters required for calling +// the contract method 0x0d402005. // // Solidity: function namedInput(string str) returns() func (inputChecker *InputChecker) PackNamedInput(Str string) []byte { @@ -92,7 +98,8 @@ func (inputChecker *InputChecker) PackNamedInput(Str string) []byte { return enc } -// NamedInputs is a free data retrieval call binding the contract method 0x63c796ed. +// NamedInputs is the Go binding used to pack the parameters required for calling +// the contract method 0x63c796ed. // // Solidity: function namedInputs(string str1, string str2) returns() func (inputChecker *InputChecker) PackNamedInputs(Str1 string, Str2 string) []byte { @@ -103,7 +110,8 @@ func (inputChecker *InputChecker) PackNamedInputs(Str1 string, Str2 string) []by return enc } -// NoInput is a free data retrieval call binding the contract method 0x53539029. +// NoInput is the Go binding used to pack the parameters required for calling +// the contract method 0x53539029. // // Solidity: function noInput() returns() func (inputChecker *InputChecker) PackNoInput() []byte { diff --git a/accounts/abi/abigen/testdata/v2/interactor.go.txt b/accounts/abi/abigen/testdata/v2/interactor.go.txt index 0fe38bed35..35b305e902 100644 --- a/accounts/abi/abigen/testdata/v2/interactor.go.txt +++ b/accounts/abi/abigen/testdata/v2/interactor.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,6 +51,10 @@ func (c *Interactor) Instance(backend bind.ContractBackend, addr common.Address) return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(string str) returns() func (interactor *Interactor) PackConstructor(str string) []byte { enc, err := interactor.abi.Pack("", str) if err != nil { @@ -57,7 +63,8 @@ func (interactor *Interactor) PackConstructor(str string) []byte { return enc } -// DeployString is a free data retrieval call binding the contract method 0x6874e809. +// DeployString is the Go binding used to pack the parameters required for calling +// the contract method 0x6874e809. // // Solidity: function deployString() returns(string) func (interactor *Interactor) PackDeployString() []byte { @@ -68,20 +75,21 @@ func (interactor *Interactor) PackDeployString() []byte { return enc } +// UnpackDeployString is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6874e809. +// +// Solidity: function deployString() returns(string) func (interactor *Interactor) UnpackDeployString(data []byte) (string, error) { out, err := interactor.abi.Unpack("deployString", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } -// Transact is a free data retrieval call binding the contract method 0xd736c513. +// Transact is the Go binding used to pack the parameters required for calling +// the contract method 0xd736c513. // // Solidity: function transact(string str) returns() func (interactor *Interactor) PackTransact(Str string) []byte { @@ -92,7 +100,8 @@ func (interactor *Interactor) PackTransact(Str string) []byte { return enc } -// TransactString is a free data retrieval call binding the contract method 0x0d86a0e1. +// TransactString is the Go binding used to pack the parameters required for calling +// the contract method 0x0d86a0e1. // // Solidity: function transactString() returns(string) func (interactor *Interactor) PackTransactString() []byte { @@ -103,15 +112,15 @@ func (interactor *Interactor) PackTransactString() []byte { return enc } +// UnpackTransactString is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x0d86a0e1. +// +// Solidity: function transactString() returns(string) func (interactor *Interactor) UnpackTransactString(data []byte) (string, error) { out, err := interactor.abi.Unpack("transactString", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } diff --git a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt index f42efdb71a..ed4f78c401 100644 --- a/accounts/abi/abigen/testdata/v2/nameconflict.go.txt +++ b/accounts/abi/abigen/testdata/v2/nameconflict.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -55,7 +57,8 @@ func (c *NameConflict) Instance(backend bind.ContractBackend, addr common.Addres return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// AddRequest is a free data retrieval call binding the contract method 0xcce7b048. +// AddRequest is the Go binding used to pack the parameters required for calling +// the contract method 0xcce7b048. // // Solidity: function addRequest((bytes,bytes) req) pure returns() func (nameConflict *NameConflict) PackAddRequest(Req Oraclerequest) []byte { @@ -66,7 +69,8 @@ func (nameConflict *NameConflict) PackAddRequest(Req Oraclerequest) []byte { return enc } -// GetRequest is a free data retrieval call binding the contract method 0xc2bb515f. +// GetRequest is the Go binding used to pack the parameters required for calling +// the contract method 0xc2bb515f. // // Solidity: function getRequest() pure returns((bytes,bytes)) func (nameConflict *NameConflict) PackGetRequest() []byte { @@ -77,32 +81,38 @@ func (nameConflict *NameConflict) PackGetRequest() []byte { return enc } +// UnpackGetRequest is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xc2bb515f. +// +// Solidity: function getRequest() pure returns((bytes,bytes)) func (nameConflict *NameConflict) UnpackGetRequest(data []byte) (Oraclerequest, error) { out, err := nameConflict.abi.Unpack("getRequest", data) - if err != nil { return *new(Oraclerequest), err } - out0 := *abi.ConvertType(out[0], new(Oraclerequest)).(*Oraclerequest) - return out0, err - } // NameConflictLog represents a Log event raised by the NameConflict contract. type NameConflictLog struct { Msg *big.Int Msg0 *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const NameConflictLogEventName = "log" +// ContractEventName returns the user-defined event name. func (NameConflictLog) ContractEventName() string { return NameConflictLogEventName } +// UnpackLogEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event log(int256 msg, int256 _msg) func (nameConflict *NameConflict) UnpackLogEvent(log *types.Log) (*NameConflictLog, error) { event := "log" if log.Topics[0] != nameConflict.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt index dfc15b336b..75addb45e2 100644 --- a/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt +++ b/accounts/abi/abigen/testdata/v2/numericmethodname.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *NumericMethodName) Instance(backend bind.ContractBackend, addr common.A return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// E1test is a free data retrieval call binding the contract method 0xffa02795. +// E1test is the Go binding used to pack the parameters required for calling +// the contract method 0xffa02795. // // Solidity: function _1test() pure returns() func (numericMethodName *NumericMethodName) PackE1test() []byte { @@ -60,7 +63,8 @@ func (numericMethodName *NumericMethodName) PackE1test() []byte { return enc } -// E1test0 is a free data retrieval call binding the contract method 0xd02767c7. +// E1test0 is the Go binding used to pack the parameters required for calling +// the contract method 0xd02767c7. // // Solidity: function __1test() pure returns() func (numericMethodName *NumericMethodName) PackE1test0() []byte { @@ -71,7 +75,8 @@ func (numericMethodName *NumericMethodName) PackE1test0() []byte { return enc } -// E2test is a free data retrieval call binding the contract method 0x9d993132. +// E2test is the Go binding used to pack the parameters required for calling +// the contract method 0x9d993132. // // Solidity: function __2test() pure returns() func (numericMethodName *NumericMethodName) PackE2test() []byte { @@ -85,15 +90,21 @@ func (numericMethodName *NumericMethodName) PackE2test() []byte { // NumericMethodNameE1TestEvent represents a E1TestEvent event raised by the NumericMethodName contract. type NumericMethodNameE1TestEvent struct { Param common.Address - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const NumericMethodNameE1TestEventEventName = "_1TestEvent" +// ContractEventName returns the user-defined event name. func (NumericMethodNameE1TestEvent) ContractEventName() string { return NumericMethodNameE1TestEventEventName } +// UnpackE1TestEventEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event _1TestEvent(address _param) func (numericMethodName *NumericMethodName) UnpackE1TestEventEvent(log *types.Log) (*NumericMethodNameE1TestEvent, error) { event := "_1TestEvent" if log.Topics[0] != numericMethodName.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt index 6f333f2f35..a68dfe0775 100644 --- a/accounts/abi/abigen/testdata/v2/outputchecker.go.txt +++ b/accounts/abi/abigen/testdata/v2/outputchecker.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -48,7 +50,8 @@ func (c *OutputChecker) Instance(backend bind.ContractBackend, addr common.Addre return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// AnonOutput is a free data retrieval call binding the contract method 0x008bda05. +// AnonOutput is the Go binding used to pack the parameters required for calling +// the contract method 0x008bda05. // // Solidity: function anonOutput() returns(string) func (outputChecker *OutputChecker) PackAnonOutput() []byte { @@ -59,20 +62,21 @@ func (outputChecker *OutputChecker) PackAnonOutput() []byte { return enc } +// UnpackAnonOutput is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x008bda05. +// +// Solidity: function anonOutput() returns(string) func (outputChecker *OutputChecker) UnpackAnonOutput(data []byte) (string, error) { out, err := outputChecker.abi.Unpack("anonOutput", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } -// AnonOutputs is a free data retrieval call binding the contract method 0x3c401115. +// AnonOutputs is the Go binding used to pack the parameters required for calling +// the contract method 0x3c401115. // // Solidity: function anonOutputs() returns(string, string) func (outputChecker *OutputChecker) PackAnonOutputs() []byte { @@ -83,28 +87,31 @@ func (outputChecker *OutputChecker) PackAnonOutputs() []byte { return enc } +// AnonOutputsOutput serves as a container for the return parameters of contract +// method AnonOutputs. type AnonOutputsOutput struct { Arg0 string Arg1 string } +// UnpackAnonOutputs is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x3c401115. +// +// Solidity: function anonOutputs() returns(string, string) func (outputChecker *OutputChecker) UnpackAnonOutputs(data []byte) (AnonOutputsOutput, error) { out, err := outputChecker.abi.Unpack("anonOutputs", data) - outstruct := new(AnonOutputsOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Arg1 = *abi.ConvertType(out[1], new(string)).(*string) - return *outstruct, err } -// CollidingOutputs is a free data retrieval call binding the contract method 0xeccbc1ee. +// CollidingOutputs is the Go binding used to pack the parameters required for calling +// the contract method 0xeccbc1ee. // // Solidity: function collidingOutputs() returns(string str, string Str) func (outputChecker *OutputChecker) PackCollidingOutputs() []byte { @@ -115,28 +122,31 @@ func (outputChecker *OutputChecker) PackCollidingOutputs() []byte { return enc } +// CollidingOutputsOutput serves as a container for the return parameters of contract +// method CollidingOutputs. type CollidingOutputsOutput struct { Str string Str0 string } +// UnpackCollidingOutputs is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xeccbc1ee. +// +// Solidity: function collidingOutputs() returns(string str, string Str) func (outputChecker *OutputChecker) UnpackCollidingOutputs(data []byte) (CollidingOutputsOutput, error) { out, err := outputChecker.abi.Unpack("collidingOutputs", data) - outstruct := new(CollidingOutputsOutput) if err != nil { return *outstruct, err } - outstruct.Str = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Str0 = *abi.ConvertType(out[1], new(string)).(*string) - return *outstruct, err } -// MixedOutputs is a free data retrieval call binding the contract method 0x21b77b44. +// MixedOutputs is the Go binding used to pack the parameters required for calling +// the contract method 0x21b77b44. // // Solidity: function mixedOutputs() returns(string, string str) func (outputChecker *OutputChecker) PackMixedOutputs() []byte { @@ -147,28 +157,31 @@ func (outputChecker *OutputChecker) PackMixedOutputs() []byte { return enc } +// MixedOutputsOutput serves as a container for the return parameters of contract +// method MixedOutputs. type MixedOutputsOutput struct { Arg0 string Str string } +// UnpackMixedOutputs is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x21b77b44. +// +// Solidity: function mixedOutputs() returns(string, string str) func (outputChecker *OutputChecker) UnpackMixedOutputs(data []byte) (MixedOutputsOutput, error) { out, err := outputChecker.abi.Unpack("mixedOutputs", data) - outstruct := new(MixedOutputsOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Str = *abi.ConvertType(out[1], new(string)).(*string) - return *outstruct, err } -// NamedOutput is a free data retrieval call binding the contract method 0x5e632bd5. +// NamedOutput is the Go binding used to pack the parameters required for calling +// the contract method 0x5e632bd5. // // Solidity: function namedOutput() returns(string str) func (outputChecker *OutputChecker) PackNamedOutput() []byte { @@ -179,20 +192,21 @@ func (outputChecker *OutputChecker) PackNamedOutput() []byte { return enc } +// UnpackNamedOutput is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x5e632bd5. +// +// Solidity: function namedOutput() returns(string str) func (outputChecker *OutputChecker) UnpackNamedOutput(data []byte) (string, error) { out, err := outputChecker.abi.Unpack("namedOutput", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } -// NamedOutputs is a free data retrieval call binding the contract method 0x7970a189. +// NamedOutputs is the Go binding used to pack the parameters required for calling +// the contract method 0x7970a189. // // Solidity: function namedOutputs() returns(string str1, string str2) func (outputChecker *OutputChecker) PackNamedOutputs() []byte { @@ -203,28 +217,31 @@ func (outputChecker *OutputChecker) PackNamedOutputs() []byte { return enc } +// NamedOutputsOutput serves as a container for the return parameters of contract +// method NamedOutputs. type NamedOutputsOutput struct { Str1 string Str2 string } +// UnpackNamedOutputs is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x7970a189. +// +// Solidity: function namedOutputs() returns(string str1, string str2) func (outputChecker *OutputChecker) UnpackNamedOutputs(data []byte) (NamedOutputsOutput, error) { out, err := outputChecker.abi.Unpack("namedOutputs", data) - outstruct := new(NamedOutputsOutput) if err != nil { return *outstruct, err } - outstruct.Str1 = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Str2 = *abi.ConvertType(out[1], new(string)).(*string) - return *outstruct, err } -// NoOutput is a free data retrieval call binding the contract method 0x625f0306. +// NoOutput is the Go binding used to pack the parameters required for calling +// the contract method 0x625f0306. // // Solidity: function noOutput() returns() func (outputChecker *OutputChecker) PackNoOutput() []byte { diff --git a/accounts/abi/abigen/testdata/v2/overload.go.txt b/accounts/abi/abigen/testdata/v2/overload.go.txt index 853e98b03e..68e5f146bc 100644 --- a/accounts/abi/abigen/testdata/v2/overload.go.txt +++ b/accounts/abi/abigen/testdata/v2/overload.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *Overload) Instance(backend bind.ContractBackend, addr common.Address) * return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Foo is a free data retrieval call binding the contract method 0x04bc52f8. +// Foo is the Go binding used to pack the parameters required for calling +// the contract method 0x04bc52f8. // // Solidity: function foo(uint256 i, uint256 j) returns() func (overload *Overload) PackFoo(I *big.Int, J *big.Int) []byte { @@ -60,7 +63,8 @@ func (overload *Overload) PackFoo(I *big.Int, J *big.Int) []byte { return enc } -// Foo0 is a free data retrieval call binding the contract method 0x2fbebd38. +// Foo0 is the Go binding used to pack the parameters required for calling +// the contract method 0x2fbebd38. // // Solidity: function foo(uint256 i) returns() func (overload *Overload) PackFoo0(I *big.Int) []byte { @@ -73,16 +77,22 @@ func (overload *Overload) PackFoo0(I *big.Int) []byte { // OverloadBar represents a Bar event raised by the Overload contract. type OverloadBar struct { - I *big.Int + I *big.Int + Raw *types.Log // Blockchain specific contextual infos } const OverloadBarEventName = "bar" +// ContractEventName returns the user-defined event name. func (OverloadBar) ContractEventName() string { return OverloadBarEventName } +// UnpackBarEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event bar(uint256 i) func (overload *Overload) UnpackBarEvent(log *types.Log) (*OverloadBar, error) { event := "bar" if log.Topics[0] != overload.abi.Events[event].ID { @@ -109,17 +119,23 @@ func (overload *Overload) UnpackBarEvent(log *types.Log) (*OverloadBar, error) { // OverloadBar0 represents a Bar0 event raised by the Overload contract. type OverloadBar0 struct { - I *big.Int - J *big.Int + I *big.Int + J *big.Int + Raw *types.Log // Blockchain specific contextual infos } const OverloadBar0EventName = "bar0" +// ContractEventName returns the user-defined event name. func (OverloadBar0) ContractEventName() string { return OverloadBar0EventName } +// UnpackBar0Event is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event bar(uint256 i, uint256 j) func (overload *Overload) UnpackBar0Event(log *types.Log) (*OverloadBar0, error) { event := "bar0" if log.Topics[0] != overload.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt index 5033b743be..c4fec53053 100644 --- a/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt +++ b/accounts/abi/abigen/testdata/v2/rangekeyword.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *RangeKeyword) Instance(backend bind.ContractBackend, addr common.Addres return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// FunctionWithKeywordParameter is a free data retrieval call binding the contract method 0x527a119f. +// FunctionWithKeywordParameter is the Go binding used to pack the parameters required for calling +// the contract method 0x527a119f. // // Solidity: function functionWithKeywordParameter(uint256 range) pure returns() func (rangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(Arg0 *big.Int) []byte { diff --git a/accounts/abi/abigen/testdata/v2/slicer.go.txt b/accounts/abi/abigen/testdata/v2/slicer.go.txt index 68d900f68d..fcef58b8ea 100644 --- a/accounts/abi/abigen/testdata/v2/slicer.go.txt +++ b/accounts/abi/abigen/testdata/v2/slicer.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *Slicer) Instance(backend bind.ContractBackend, addr common.Address) *bi return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// EchoAddresses is a free data retrieval call binding the contract method 0xbe1127a3. +// EchoAddresses is the Go binding used to pack the parameters required for calling +// the contract method 0xbe1127a3. // // Solidity: function echoAddresses(address[] input) returns(address[] output) func (slicer *Slicer) PackEchoAddresses(Input []common.Address) []byte { @@ -60,20 +63,21 @@ func (slicer *Slicer) PackEchoAddresses(Input []common.Address) []byte { return enc } +// UnpackEchoAddresses is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xbe1127a3. +// +// Solidity: function echoAddresses(address[] input) returns(address[] output) func (slicer *Slicer) UnpackEchoAddresses(data []byte) ([]common.Address, error) { out, err := slicer.abi.Unpack("echoAddresses", data) - if err != nil { return *new([]common.Address), err } - out0 := *abi.ConvertType(out[0], new([]common.Address)).(*[]common.Address) - return out0, err - } -// EchoBools is a free data retrieval call binding the contract method 0xf637e589. +// EchoBools is the Go binding used to pack the parameters required for calling +// the contract method 0xf637e589. // // Solidity: function echoBools(bool[] input) returns(bool[] output) func (slicer *Slicer) PackEchoBools(Input []bool) []byte { @@ -84,20 +88,21 @@ func (slicer *Slicer) PackEchoBools(Input []bool) []byte { return enc } +// UnpackEchoBools is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xf637e589. +// +// Solidity: function echoBools(bool[] input) returns(bool[] output) func (slicer *Slicer) UnpackEchoBools(data []byte) ([]bool, error) { out, err := slicer.abi.Unpack("echoBools", data) - if err != nil { return *new([]bool), err } - out0 := *abi.ConvertType(out[0], new([]bool)).(*[]bool) - return out0, err - } -// EchoFancyInts is a free data retrieval call binding the contract method 0xd88becc0. +// EchoFancyInts is the Go binding used to pack the parameters required for calling +// the contract method 0xd88becc0. // // Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output) func (slicer *Slicer) PackEchoFancyInts(Input [23]*big.Int) []byte { @@ -108,20 +113,21 @@ func (slicer *Slicer) PackEchoFancyInts(Input [23]*big.Int) []byte { return enc } +// UnpackEchoFancyInts is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xd88becc0. +// +// Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output) func (slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*big.Int, error) { out, err := slicer.abi.Unpack("echoFancyInts", data) - if err != nil { return *new([23]*big.Int), err } - out0 := *abi.ConvertType(out[0], new([23]*big.Int)).(*[23]*big.Int) - return out0, err - } -// EchoInts is a free data retrieval call binding the contract method 0xe15a3db7. +// EchoInts is the Go binding used to pack the parameters required for calling +// the contract method 0xe15a3db7. // // Solidity: function echoInts(int256[] input) returns(int256[] output) func (slicer *Slicer) PackEchoInts(Input []*big.Int) []byte { @@ -132,15 +138,15 @@ func (slicer *Slicer) PackEchoInts(Input []*big.Int) []byte { return enc } +// UnpackEchoInts is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xe15a3db7. +// +// Solidity: function echoInts(int256[] input) returns(int256[] output) func (slicer *Slicer) UnpackEchoInts(data []byte) ([]*big.Int, error) { out, err := slicer.abi.Unpack("echoInts", data) - if err != nil { return *new([]*big.Int), err } - out0 := *abi.ConvertType(out[0], new([]*big.Int)).(*[]*big.Int) - return out0, err - } diff --git a/accounts/abi/abigen/testdata/v2/structs-abi.go.txt b/accounts/abi/abigen/testdata/v2/structs-abi.go.txt index 8fef657d7c..aab6242707 100644 --- a/accounts/abi/abigen/testdata/v2/structs-abi.go.txt +++ b/accounts/abi/abigen/testdata/v2/structs-abi.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package v1bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -48,66 +50,67 @@ func NewStructs() *Structs { } // Instance creates a wrapper for a deployed contract instance at the given address. +<<<<<<< HEAD // Use this to create the instance object passed to abigen v2 library functions Call, Transact, etc. func (c *Structs) Instance(backend bind.ContractBackend, addr common.Address) *bind.BoundContract { return bind.NewBoundContract(addr, c.abi, backend, backend, backend) +======= +// Use this to create the instance object passed to abigen v2 library functions Call, +// Transact, etc. +func (c *Structs) Instance(backend bind.ContractBackend, addr common.Address) bind.BoundContract { + return bind.NewBoundContract(backend, addr, c.abi) +>>>>>>> 854c25e086 (accounts/abi/abigen: improve v2 template) } -// F is a free data retrieval call binding the contract method 0x28811f59. +// F is the Go binding used to pack the parameters required for calling +// the contract method 0x28811f59. // // Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d) -func (structs *Structs) PackF() []byte { - enc, err := structs.abi.Pack("F") - if err != nil { - panic(err) - } - return enc +func (structs *Structs) PackF() ([]byte, error) { + return structs.abi.Pack("F") } +// FOutput serves as a container for the return parameters of contract +// method F. type FOutput struct { A []Struct0 C []*big.Int D []bool } -func (structs *Structs) UnpackF(data []byte) (FOutput, error) { +// UnpackF is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x28811f59. +// +// Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d) +func (structs *Structs) UnpackF(data []byte) (*FOutput, error) { out, err := structs.abi.Unpack("F", data) - - outstruct := new(FOutput) if err != nil { - return *outstruct, err + return nil, err } - - outstruct.A = *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) - - outstruct.C = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) - - outstruct.D = *abi.ConvertType(out[2], new([]bool)).(*[]bool) - - return *outstruct, err - + ret := new(FOutput) + ret.A = *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) + ret.C = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) + ret.D = *abi.ConvertType(out[2], new([]bool)).(*[]bool) + return ret, nil } -// G is a free data retrieval call binding the contract method 0x6fecb623. +// G is the Go binding used to pack the parameters required for calling +// the contract method 0x6fecb623. // // Solidity: function G() view returns((bytes32)[] a) -func (structs *Structs) PackG() []byte { - enc, err := structs.abi.Pack("G") - if err != nil { - panic(err) - } - return enc +func (structs *Structs) PackG() ([]byte, error) { + return structs.abi.Pack("G") } -func (structs *Structs) UnpackG(data []byte) ([]Struct0, error) { +// UnpackG is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6fecb623. +// +// Solidity: function G() view returns((bytes32)[] a) +func (structs *Structs) UnpackG(data []byte) (*[]Struct0, error) { out, err := structs.abi.Unpack("G", data) - if err != nil { - return *new([]Struct0), err + return nil, err } - out0 := *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) - - return out0, err - + return &out0, nil } diff --git a/accounts/abi/abigen/testdata/v2/structs.go.txt b/accounts/abi/abigen/testdata/v2/structs.go.txt index 2f1505cd57..413f3a93f6 100644 --- a/accounts/abi/abigen/testdata/v2/structs.go.txt +++ b/accounts/abi/abigen/testdata/v2/structs.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -54,7 +56,8 @@ func (c *Structs) Instance(backend bind.ContractBackend, addr common.Address) *b return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// F is a free data retrieval call binding the contract method 0x28811f59. +// F is the Go binding used to pack the parameters required for calling +// the contract method 0x28811f59. // // Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d) func (structs *Structs) PackF() []byte { @@ -65,31 +68,33 @@ func (structs *Structs) PackF() []byte { return enc } +// FOutput serves as a container for the return parameters of contract +// method F. type FOutput struct { A []Struct0 C []*big.Int D []bool } +// UnpackF is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x28811f59. +// +// Solidity: function F() view returns((bytes32)[] a, uint256[] c, bool[] d) func (structs *Structs) UnpackF(data []byte) (FOutput, error) { out, err := structs.abi.Unpack("F", data) - outstruct := new(FOutput) if err != nil { return *outstruct, err } - outstruct.A = *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) - outstruct.C = *abi.ConvertType(out[1], new([]*big.Int)).(*[]*big.Int) - outstruct.D = *abi.ConvertType(out[2], new([]bool)).(*[]bool) - return *outstruct, err } -// G is a free data retrieval call binding the contract method 0x6fecb623. +// G is the Go binding used to pack the parameters required for calling +// the contract method 0x6fecb623. // // Solidity: function G() view returns((bytes32)[] a) func (structs *Structs) PackG() []byte { @@ -100,15 +105,15 @@ func (structs *Structs) PackG() []byte { return enc } +// UnpackG is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6fecb623. +// +// Solidity: function G() view returns((bytes32)[] a) func (structs *Structs) UnpackG(data []byte) ([]Struct0, error) { out, err := structs.abi.Unpack("G", data) - if err != nil { return *new([]Struct0), err } - out0 := *abi.ConvertType(out[0], new([]Struct0)).(*[]Struct0) - return out0, err - } diff --git a/accounts/abi/abigen/testdata/v2/token.go.txt b/accounts/abi/abigen/testdata/v2/token.go.txt index ba543cab2d..6ff348427e 100644 --- a/accounts/abi/abigen/testdata/v2/token.go.txt +++ b/accounts/abi/abigen/testdata/v2/token.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,6 +51,10 @@ func (c *Token) Instance(backend bind.ContractBackend, addr common.Address) *bin return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(uint256 initialSupply, string tokenName, uint8 decimalUnits, string tokenSymbol) returns() func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, decimalUnits uint8, tokenSymbol string) []byte { enc, err := token.abi.Pack("", initialSupply, tokenName, decimalUnits, tokenSymbol) if err != nil { @@ -57,7 +63,8 @@ func (token *Token) PackConstructor(initialSupply *big.Int, tokenName string, de return enc } -// Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. +// Allowance is the Go binding used to pack the parameters required for calling +// the contract method 0xdd62ed3e. // // Solidity: function allowance(address , address ) returns(uint256) func (token *Token) PackAllowance(Arg0 common.Address, Arg1 common.Address) []byte { @@ -68,20 +75,21 @@ func (token *Token) PackAllowance(Arg0 common.Address, Arg1 common.Address) []by return enc } +// UnpackAllowance is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xdd62ed3e. +// +// Solidity: function allowance(address , address ) returns(uint256) func (token *Token) UnpackAllowance(data []byte) (*big.Int, error) { out, err := token.abi.Unpack("allowance", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// ApproveAndCall is a free data retrieval call binding the contract method 0xcae9ca51. +// ApproveAndCall is the Go binding used to pack the parameters required for calling +// the contract method 0xcae9ca51. // // Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) func (token *Token) PackApproveAndCall(Spender common.Address, Value *big.Int, ExtraData []byte) []byte { @@ -92,20 +100,21 @@ func (token *Token) PackApproveAndCall(Spender common.Address, Value *big.Int, E return enc } +// UnpackApproveAndCall is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xcae9ca51. +// +// Solidity: function approveAndCall(address _spender, uint256 _value, bytes _extraData) returns(bool success) func (token *Token) UnpackApproveAndCall(data []byte) (bool, error) { out, err := token.abi.Unpack("approveAndCall", data) - if err != nil { return *new(bool), err } - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - return out0, err - } -// BalanceOf is a free data retrieval call binding the contract method 0x70a08231. +// BalanceOf is the Go binding used to pack the parameters required for calling +// the contract method 0x70a08231. // // Solidity: function balanceOf(address ) returns(uint256) func (token *Token) PackBalanceOf(Arg0 common.Address) []byte { @@ -116,20 +125,21 @@ func (token *Token) PackBalanceOf(Arg0 common.Address) []byte { return enc } +// UnpackBalanceOf is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x70a08231. +// +// Solidity: function balanceOf(address ) returns(uint256) func (token *Token) UnpackBalanceOf(data []byte) (*big.Int, error) { out, err := token.abi.Unpack("balanceOf", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Decimals is a free data retrieval call binding the contract method 0x313ce567. +// Decimals is the Go binding used to pack the parameters required for calling +// the contract method 0x313ce567. // // Solidity: function decimals() returns(uint8) func (token *Token) PackDecimals() []byte { @@ -140,20 +150,21 @@ func (token *Token) PackDecimals() []byte { return enc } +// UnpackDecimals is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x313ce567. +// +// Solidity: function decimals() returns(uint8) func (token *Token) UnpackDecimals(data []byte) (uint8, error) { out, err := token.abi.Unpack("decimals", data) - if err != nil { return *new(uint8), err } - out0 := *abi.ConvertType(out[0], new(uint8)).(*uint8) - return out0, err - } -// Name is a free data retrieval call binding the contract method 0x06fdde03. +// Name is the Go binding used to pack the parameters required for calling +// the contract method 0x06fdde03. // // Solidity: function name() returns(string) func (token *Token) PackName() []byte { @@ -164,20 +175,21 @@ func (token *Token) PackName() []byte { return enc } +// UnpackName is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x06fdde03. +// +// Solidity: function name() returns(string) func (token *Token) UnpackName(data []byte) (string, error) { out, err := token.abi.Unpack("name", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } -// SpentAllowance is a free data retrieval call binding the contract method 0xdc3080f2. +// SpentAllowance is the Go binding used to pack the parameters required for calling +// the contract method 0xdc3080f2. // // Solidity: function spentAllowance(address , address ) returns(uint256) func (token *Token) PackSpentAllowance(Arg0 common.Address, Arg1 common.Address) []byte { @@ -188,20 +200,21 @@ func (token *Token) PackSpentAllowance(Arg0 common.Address, Arg1 common.Address) return enc } +// UnpackSpentAllowance is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xdc3080f2. +// +// Solidity: function spentAllowance(address , address ) returns(uint256) func (token *Token) UnpackSpentAllowance(data []byte) (*big.Int, error) { out, err := token.abi.Unpack("spentAllowance", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// Symbol is a free data retrieval call binding the contract method 0x95d89b41. +// Symbol is the Go binding used to pack the parameters required for calling +// the contract method 0x95d89b41. // // Solidity: function symbol() returns(string) func (token *Token) PackSymbol() []byte { @@ -212,20 +225,21 @@ func (token *Token) PackSymbol() []byte { return enc } +// UnpackSymbol is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x95d89b41. +// +// Solidity: function symbol() returns(string) func (token *Token) UnpackSymbol(data []byte) (string, error) { out, err := token.abi.Unpack("symbol", data) - if err != nil { return *new(string), err } - out0 := *abi.ConvertType(out[0], new(string)).(*string) - return out0, err - } -// Transfer is a free data retrieval call binding the contract method 0xa9059cbb. +// Transfer is the Go binding used to pack the parameters required for calling +// the contract method 0xa9059cbb. // // Solidity: function transfer(address _to, uint256 _value) returns() func (token *Token) PackTransfer(To common.Address, Value *big.Int) []byte { @@ -236,7 +250,8 @@ func (token *Token) PackTransfer(To common.Address, Value *big.Int) []byte { return enc } -// TransferFrom is a free data retrieval call binding the contract method 0x23b872dd. +// TransferFrom is the Go binding used to pack the parameters required for calling +// the contract method 0x23b872dd. // // Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) func (token *Token) PackTransferFrom(From common.Address, To common.Address, Value *big.Int) []byte { @@ -247,17 +262,17 @@ func (token *Token) PackTransferFrom(From common.Address, To common.Address, Val return enc } +// UnpackTransferFrom is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x23b872dd. +// +// Solidity: function transferFrom(address _from, address _to, uint256 _value) returns(bool success) func (token *Token) UnpackTransferFrom(data []byte) (bool, error) { out, err := token.abi.Unpack("transferFrom", data) - if err != nil { return *new(bool), err } - out0 := *abi.ConvertType(out[0], new(bool)).(*bool) - return out0, err - } // TokenTransfer represents a Transfer event raised by the Token contract. @@ -265,15 +280,21 @@ type TokenTransfer struct { From common.Address To common.Address Value *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const TokenTransferEventName = "Transfer" +// ContractEventName returns the user-defined event name. func (TokenTransfer) ContractEventName() string { return TokenTransferEventName } +// UnpackTransferEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event Transfer(address indexed from, address indexed to, uint256 value) func (token *Token) UnpackTransferEvent(log *types.Log) (*TokenTransfer, error) { event := "Transfer" if log.Topics[0] != token.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/tuple.go.txt b/accounts/abi/abigen/testdata/v2/tuple.go.txt index 9764bd435e..680d5eaba0 100644 --- a/accounts/abi/abigen/testdata/v2/tuple.go.txt +++ b/accounts/abi/abigen/testdata/v2/tuple.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -74,7 +76,8 @@ func (c *Tuple) Instance(backend bind.ContractBackend, addr common.Address) *bin return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Func1 is a free data retrieval call binding the contract method 0x443c79b4. +// Func1 is the Go binding used to pack the parameters required for calling +// the contract method 0x443c79b4. // // Solidity: function func1((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) pure returns((uint256,uint256[],(uint256,uint256)[]), (uint256,uint256)[2][], (uint256,uint256)[][2], (uint256,uint256[],(uint256,uint256)[])[], uint256[]) func (tuple *Tuple) PackFunc1(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS, E []*big.Int) []byte { @@ -85,6 +88,8 @@ func (tuple *Tuple) PackFunc1(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS return enc } +// Func1Output serves as a container for the return parameters of contract +// method Func1. type Func1Output struct { Arg0 TupleS Arg1 [][2]TupleT @@ -93,29 +98,27 @@ type Func1Output struct { Arg4 []*big.Int } +// UnpackFunc1 is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x443c79b4. +// +// Solidity: function func1((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) pure returns((uint256,uint256[],(uint256,uint256)[]), (uint256,uint256)[2][], (uint256,uint256)[][2], (uint256,uint256[],(uint256,uint256)[])[], uint256[]) func (tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { out, err := tuple.abi.Unpack("func1", data) - outstruct := new(Func1Output) if err != nil { return *outstruct, err } - outstruct.Arg0 = *abi.ConvertType(out[0], new(TupleS)).(*TupleS) - outstruct.Arg1 = *abi.ConvertType(out[1], new([][2]TupleT)).(*[][2]TupleT) - outstruct.Arg2 = *abi.ConvertType(out[2], new([2][]TupleT)).(*[2][]TupleT) - outstruct.Arg3 = *abi.ConvertType(out[3], new([]TupleS)).(*[]TupleS) - outstruct.Arg4 = *abi.ConvertType(out[4], new([]*big.Int)).(*[]*big.Int) - return *outstruct, err } -// Func2 is a free data retrieval call binding the contract method 0xd0062cdd. +// Func2 is the Go binding used to pack the parameters required for calling +// the contract method 0xd0062cdd. // // Solidity: function func2((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) returns() func (tuple *Tuple) PackFunc2(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS, E []*big.Int) []byte { @@ -126,7 +129,8 @@ func (tuple *Tuple) PackFunc2(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS return enc } -// Func3 is a free data retrieval call binding the contract method 0xe4d9a43b. +// Func3 is the Go binding used to pack the parameters required for calling +// the contract method 0xe4d9a43b. // // Solidity: function func3((uint16,uint16)[] ) pure returns() func (tuple *Tuple) PackFunc3(Arg0 []TupleQ) []byte { @@ -139,20 +143,26 @@ func (tuple *Tuple) PackFunc3(Arg0 []TupleQ) []byte { // TupleTupleEvent represents a TupleEvent event raised by the Tuple contract. type TupleTupleEvent struct { - A TupleS - B [][2]TupleT - C [2][]TupleT - D []TupleS - E []*big.Int + A TupleS + B [][2]TupleT + C [2][]TupleT + D []TupleS + E []*big.Int + Raw *types.Log // Blockchain specific contextual infos } const TupleTupleEventEventName = "TupleEvent" +// ContractEventName returns the user-defined event name. func (TupleTupleEvent) ContractEventName() string { return TupleTupleEventEventName } +// UnpackTupleEventEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event TupleEvent((uint256,uint256[],(uint256,uint256)[]) a, (uint256,uint256)[2][] b, (uint256,uint256)[][2] c, (uint256,uint256[],(uint256,uint256)[])[] d, uint256[] e) func (tuple *Tuple) UnpackTupleEventEvent(log *types.Log) (*TupleTupleEvent, error) { event := "TupleEvent" if log.Topics[0] != tuple.abi.Events[event].ID { @@ -180,15 +190,21 @@ func (tuple *Tuple) UnpackTupleEventEvent(log *types.Log) (*TupleTupleEvent, err // TupleTupleEvent2 represents a TupleEvent2 event raised by the Tuple contract. type TupleTupleEvent2 struct { Arg0 []TupleP - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const TupleTupleEvent2EventName = "TupleEvent2" +// ContractEventName returns the user-defined event name. func (TupleTupleEvent2) ContractEventName() string { return TupleTupleEvent2EventName } +// UnpackTupleEvent2Event is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event TupleEvent2((uint8,uint8)[] arg0) func (tuple *Tuple) UnpackTupleEvent2Event(log *types.Log) (*TupleTupleEvent2, error) { event := "TupleEvent2" if log.Topics[0] != tuple.abi.Events[event].ID { diff --git a/accounts/abi/abigen/testdata/v2/tupler.go.txt b/accounts/abi/abigen/testdata/v2/tupler.go.txt index 5ee60a55e0..e9bb1aabf7 100644 --- a/accounts/abi/abigen/testdata/v2/tupler.go.txt +++ b/accounts/abi/abigen/testdata/v2/tupler.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *Tupler) Instance(backend bind.ContractBackend, addr common.Address) *bi return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Tuple is a free data retrieval call binding the contract method 0x3175aae2. +// Tuple is the Go binding used to pack the parameters required for calling +// the contract method 0x3175aae2. // // Solidity: function tuple() returns(string a, int256 b, bytes32 c) func (tupler *Tupler) PackTuple() []byte { @@ -60,26 +63,27 @@ func (tupler *Tupler) PackTuple() []byte { return enc } +// TupleOutput serves as a container for the return parameters of contract +// method Tuple. type TupleOutput struct { A string B *big.Int C [32]byte } +// UnpackTuple is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x3175aae2. +// +// Solidity: function tuple() returns(string a, int256 b, bytes32 c) func (tupler *Tupler) UnpackTuple(data []byte) (TupleOutput, error) { out, err := tupler.abi.Unpack("tuple", data) - outstruct := new(TupleOutput) if err != nil { return *outstruct, err } - outstruct.A = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.B = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.C = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) - return *outstruct, err } diff --git a/accounts/abi/abigen/testdata/v2/underscorer.go.txt b/accounts/abi/abigen/testdata/v2/underscorer.go.txt index 7ff6d1dc5b..fe14d27ab8 100644 --- a/accounts/abi/abigen/testdata/v2/underscorer.go.txt +++ b/accounts/abi/abigen/testdata/v2/underscorer.go.txt @@ -1,9 +1,10 @@ // Code generated via abigen V2 - DO NOT EDIT. // This file is a generated binding and any manual changes will be lost. -package convertedv1bindtests +package bindtests import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *Underscorer) Instance(backend bind.ContractBackend, addr common.Address return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// AllPurelyUnderscoredOutput is a free data retrieval call binding the contract method 0xb564b34d. +// AllPurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling +// the contract method 0xb564b34d. // // Solidity: function AllPurelyUnderscoredOutput() view returns(int256 _, int256 __) func (underscorer *Underscorer) PackAllPurelyUnderscoredOutput() []byte { @@ -60,28 +63,31 @@ func (underscorer *Underscorer) PackAllPurelyUnderscoredOutput() []byte { return enc } +// AllPurelyUnderscoredOutputOutput serves as a container for the return parameters of contract +// method AllPurelyUnderscoredOutput. type AllPurelyUnderscoredOutputOutput struct { Arg0 *big.Int Arg1 *big.Int } +// UnpackAllPurelyUnderscoredOutput is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xb564b34d. +// +// Solidity: function AllPurelyUnderscoredOutput() view returns(int256 _, int256 __) func (underscorer *Underscorer) UnpackAllPurelyUnderscoredOutput(data []byte) (AllPurelyUnderscoredOutputOutput, error) { out, err := underscorer.abi.Unpack("AllPurelyUnderscoredOutput", data) - outstruct := new(AllPurelyUnderscoredOutputOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// LowerLowerCollision is a free data retrieval call binding the contract method 0xe409ca45. +// LowerLowerCollision is the Go binding used to pack the parameters required for calling +// the contract method 0xe409ca45. // // Solidity: function LowerLowerCollision() view returns(int256 _res, int256 res) func (underscorer *Underscorer) PackLowerLowerCollision() []byte { @@ -92,28 +98,31 @@ func (underscorer *Underscorer) PackLowerLowerCollision() []byte { return enc } +// LowerLowerCollisionOutput serves as a container for the return parameters of contract +// method LowerLowerCollision. type LowerLowerCollisionOutput struct { Res *big.Int Res0 *big.Int } +// UnpackLowerLowerCollision is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xe409ca45. +// +// Solidity: function LowerLowerCollision() view returns(int256 _res, int256 res) func (underscorer *Underscorer) UnpackLowerLowerCollision(data []byte) (LowerLowerCollisionOutput, error) { out, err := underscorer.abi.Unpack("LowerLowerCollision", data) - outstruct := new(LowerLowerCollisionOutput) if err != nil { return *outstruct, err } - outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// LowerUpperCollision is a free data retrieval call binding the contract method 0x03a59213. +// LowerUpperCollision is the Go binding used to pack the parameters required for calling +// the contract method 0x03a59213. // // Solidity: function LowerUpperCollision() view returns(int256 _res, int256 Res) func (underscorer *Underscorer) PackLowerUpperCollision() []byte { @@ -124,28 +133,31 @@ func (underscorer *Underscorer) PackLowerUpperCollision() []byte { return enc } +// LowerUpperCollisionOutput serves as a container for the return parameters of contract +// method LowerUpperCollision. type LowerUpperCollisionOutput struct { Res *big.Int Res0 *big.Int } +// UnpackLowerUpperCollision is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x03a59213. +// +// Solidity: function LowerUpperCollision() view returns(int256 _res, int256 Res) func (underscorer *Underscorer) UnpackLowerUpperCollision(data []byte) (LowerUpperCollisionOutput, error) { out, err := underscorer.abi.Unpack("LowerUpperCollision", data) - outstruct := new(LowerUpperCollisionOutput) if err != nil { return *outstruct, err } - outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// PurelyUnderscoredOutput is a free data retrieval call binding the contract method 0x9df48485. +// PurelyUnderscoredOutput is the Go binding used to pack the parameters required for calling +// the contract method 0x9df48485. // // Solidity: function PurelyUnderscoredOutput() view returns(int256 _, int256 res) func (underscorer *Underscorer) PackPurelyUnderscoredOutput() []byte { @@ -156,28 +168,31 @@ func (underscorer *Underscorer) PackPurelyUnderscoredOutput() []byte { return enc } +// PurelyUnderscoredOutputOutput serves as a container for the return parameters of contract +// method PurelyUnderscoredOutput. type PurelyUnderscoredOutputOutput struct { Arg0 *big.Int Res *big.Int } +// UnpackPurelyUnderscoredOutput is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x9df48485. +// +// Solidity: function PurelyUnderscoredOutput() view returns(int256 _, int256 res) func (underscorer *Underscorer) UnpackPurelyUnderscoredOutput(data []byte) (PurelyUnderscoredOutputOutput, error) { out, err := underscorer.abi.Unpack("PurelyUnderscoredOutput", data) - outstruct := new(PurelyUnderscoredOutputOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Res = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// UnderscoredOutput is a free data retrieval call binding the contract method 0x67e6633d. +// UnderscoredOutput is the Go binding used to pack the parameters required for calling +// the contract method 0x67e6633d. // // Solidity: function UnderscoredOutput() view returns(int256 _int, string _string) func (underscorer *Underscorer) PackUnderscoredOutput() []byte { @@ -188,28 +203,31 @@ func (underscorer *Underscorer) PackUnderscoredOutput() []byte { return enc } +// UnderscoredOutputOutput serves as a container for the return parameters of contract +// method UnderscoredOutput. type UnderscoredOutputOutput struct { Int *big.Int String string } +// UnpackUnderscoredOutput is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x67e6633d. +// +// Solidity: function UnderscoredOutput() view returns(int256 _int, string _string) func (underscorer *Underscorer) UnpackUnderscoredOutput(data []byte) (UnderscoredOutputOutput, error) { out, err := underscorer.abi.Unpack("UnderscoredOutput", data) - outstruct := new(UnderscoredOutputOutput) if err != nil { return *outstruct, err } - outstruct.Int = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.String = *abi.ConvertType(out[1], new(string)).(*string) - return *outstruct, err } -// UpperLowerCollision is a free data retrieval call binding the contract method 0xaf7486ab. +// UpperLowerCollision is the Go binding used to pack the parameters required for calling +// the contract method 0xaf7486ab. // // Solidity: function UpperLowerCollision() view returns(int256 _Res, int256 res) func (underscorer *Underscorer) PackUpperLowerCollision() []byte { @@ -220,28 +238,31 @@ func (underscorer *Underscorer) PackUpperLowerCollision() []byte { return enc } +// UpperLowerCollisionOutput serves as a container for the return parameters of contract +// method UpperLowerCollision. type UpperLowerCollisionOutput struct { Res *big.Int Res0 *big.Int } +// UnpackUpperLowerCollision is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xaf7486ab. +// +// Solidity: function UpperLowerCollision() view returns(int256 _Res, int256 res) func (underscorer *Underscorer) UnpackUpperLowerCollision(data []byte) (UpperLowerCollisionOutput, error) { out, err := underscorer.abi.Unpack("UpperLowerCollision", data) - outstruct := new(UpperLowerCollisionOutput) if err != nil { return *outstruct, err } - outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// UpperUpperCollision is a free data retrieval call binding the contract method 0xe02ab24d. +// UpperUpperCollision is the Go binding used to pack the parameters required for calling +// the contract method 0xe02ab24d. // // Solidity: function UpperUpperCollision() view returns(int256 _Res, int256 Res) func (underscorer *Underscorer) PackUpperUpperCollision() []byte { @@ -252,28 +273,31 @@ func (underscorer *Underscorer) PackUpperUpperCollision() []byte { return enc } +// UpperUpperCollisionOutput serves as a container for the return parameters of contract +// method UpperUpperCollision. type UpperUpperCollisionOutput struct { Res *big.Int Res0 *big.Int } +// UnpackUpperUpperCollision is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xe02ab24d. +// +// Solidity: function UpperUpperCollision() view returns(int256 _Res, int256 Res) func (underscorer *Underscorer) UnpackUpperUpperCollision(data []byte) (UpperUpperCollisionOutput, error) { out, err := underscorer.abi.Unpack("UpperUpperCollision", data) - outstruct := new(UpperUpperCollisionOutput) if err != nil { return *outstruct, err } - outstruct.Res = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Res0 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - return *outstruct, err } -// UnderScoredFunc is a free data retrieval call binding the contract method 0x46546dbe. +// UnderScoredFunc is the Go binding used to pack the parameters required for calling +// the contract method 0x46546dbe. // // Solidity: function _under_scored_func() view returns(int256 _int) func (underscorer *Underscorer) PackUnderScoredFunc() []byte { @@ -284,15 +308,15 @@ func (underscorer *Underscorer) PackUnderScoredFunc() []byte { return enc } +// UnpackUnderScoredFunc is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x46546dbe. +// +// Solidity: function _under_scored_func() view returns(int256 _int) func (underscorer *Underscorer) UnpackUnderScoredFunc(data []byte) (*big.Int, error) { out, err := underscorer.abi.Unpack("_under_scored_func", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } diff --git a/accounts/abi/bind/v2/internal/contracts/db/bindings.go b/accounts/abi/bind/v2/internal/contracts/db/bindings.go index 59cb910b78..c51b058e3b 100644 --- a/accounts/abi/bind/v2/internal/contracts/db/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/db/bindings.go @@ -4,6 +4,7 @@ package db import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -56,7 +58,8 @@ func (c *DB) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Get is a free data retrieval call binding the contract method 0x9507d39a. +// Get is the Go binding used to pack the parameters required for calling +// the contract method 0x9507d39a. // // Solidity: function get(uint256 k) returns(uint256) func (dB *DB) PackGet(K *big.Int) []byte { @@ -67,20 +70,21 @@ func (dB *DB) PackGet(K *big.Int) []byte { return enc } +// UnpackGet is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x9507d39a. +// +// Solidity: function get(uint256 k) returns(uint256) func (dB *DB) UnpackGet(data []byte) (*big.Int, error) { out, err := dB.abi.Unpack("get", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } -// GetNamedStatParams is a free data retrieval call binding the contract method 0xe369ba3b. +// GetNamedStatParams is the Go binding used to pack the parameters required for calling +// the contract method 0xe369ba3b. // // Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods) func (dB *DB) PackGetNamedStatParams() []byte { @@ -91,31 +95,33 @@ func (dB *DB) PackGetNamedStatParams() []byte { return enc } +// GetNamedStatParamsOutput serves as a container for the return parameters of contract +// method GetNamedStatParams. type GetNamedStatParamsOutput struct { Gets *big.Int Inserts *big.Int Mods *big.Int } +// UnpackGetNamedStatParams is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xe369ba3b. +// +// Solidity: function getNamedStatParams() view returns(uint256 gets, uint256 inserts, uint256 mods) func (dB *DB) UnpackGetNamedStatParams(data []byte) (GetNamedStatParamsOutput, error) { out, err := dB.abi.Unpack("getNamedStatParams", data) - outstruct := new(GetNamedStatParamsOutput) if err != nil { return *outstruct, err } - outstruct.Gets = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Inserts = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Mods = abi.ConvertType(out[2], new(big.Int)).(*big.Int) - return *outstruct, err } -// GetStatParams is a free data retrieval call binding the contract method 0x6fcb9c70. +// GetStatParams is the Go binding used to pack the parameters required for calling +// the contract method 0x6fcb9c70. // // Solidity: function getStatParams() view returns(uint256, uint256, uint256) func (dB *DB) PackGetStatParams() []byte { @@ -126,31 +132,33 @@ func (dB *DB) PackGetStatParams() []byte { return enc } +// GetStatParamsOutput serves as a container for the return parameters of contract +// method GetStatParams. type GetStatParamsOutput struct { Arg0 *big.Int Arg1 *big.Int Arg2 *big.Int } +// UnpackGetStatParams is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6fcb9c70. +// +// Solidity: function getStatParams() view returns(uint256, uint256, uint256) func (dB *DB) UnpackGetStatParams(data []byte) (GetStatParamsOutput, error) { out, err := dB.abi.Unpack("getStatParams", data) - outstruct := new(GetStatParamsOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int) - return *outstruct, err } -// GetStatsStruct is a free data retrieval call binding the contract method 0xee8161e0. +// GetStatsStruct is the Go binding used to pack the parameters required for calling +// the contract method 0xee8161e0. // // Solidity: function getStatsStruct() view returns((uint256,uint256,uint256)) func (dB *DB) PackGetStatsStruct() []byte { @@ -161,20 +169,21 @@ func (dB *DB) PackGetStatsStruct() []byte { return enc } +// UnpackGetStatsStruct is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xee8161e0. +// +// Solidity: function getStatsStruct() view returns((uint256,uint256,uint256)) func (dB *DB) UnpackGetStatsStruct(data []byte) (DBStats, error) { out, err := dB.abi.Unpack("getStatsStruct", data) - if err != nil { return *new(DBStats), err } - out0 := *abi.ConvertType(out[0], new(DBStats)).(*DBStats) - return out0, err - } -// Insert is a free data retrieval call binding the contract method 0x1d834a1b. +// Insert is the Go binding used to pack the parameters required for calling +// the contract method 0x1d834a1b. // // Solidity: function insert(uint256 k, uint256 v) returns(uint256) func (dB *DB) PackInsert(K *big.Int, V *big.Int) []byte { @@ -185,17 +194,17 @@ func (dB *DB) PackInsert(K *big.Int, V *big.Int) []byte { return enc } +// UnpackInsert is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x1d834a1b. +// +// Solidity: function insert(uint256 k, uint256 v) returns(uint256) func (dB *DB) UnpackInsert(data []byte) (*big.Int, error) { out, err := dB.abi.Unpack("insert", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // DBInsert represents a Insert event raised by the DB contract. @@ -203,15 +212,21 @@ type DBInsert struct { Key *big.Int Value *big.Int Length *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DBInsertEventName = "Insert" +// ContractEventName returns the user-defined event name. func (DBInsert) ContractEventName() string { return DBInsertEventName } +// UnpackInsertEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event Insert(uint256 key, uint256 value, uint256 length) func (dB *DB) UnpackInsertEvent(log *types.Log) (*DBInsert, error) { event := "Insert" if log.Topics[0] != dB.abi.Events[event].ID { @@ -240,15 +255,21 @@ func (dB *DB) UnpackInsertEvent(log *types.Log) (*DBInsert, error) { type DBKeyedInsert struct { Key *big.Int Value *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const DBKeyedInsertEventName = "KeyedInsert" +// ContractEventName returns the user-defined event name. func (DBKeyedInsert) ContractEventName() string { return DBKeyedInsertEventName } +// UnpackKeyedInsertEvent is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event KeyedInsert(uint256 indexed key, uint256 value) func (dB *DB) UnpackKeyedInsertEvent(log *types.Log) (*DBKeyedInsert, error) { event := "KeyedInsert" if log.Topics[0] != dB.abi.Events[event].ID { diff --git a/accounts/abi/bind/v2/internal/contracts/events/bindings.go b/accounts/abi/bind/v2/internal/contracts/events/bindings.go index 6454caadc0..748f649d59 100644 --- a/accounts/abi/bind/v2/internal/contracts/events/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/events/bindings.go @@ -4,6 +4,7 @@ package events import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -55,7 +57,8 @@ func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.Bo return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// DoSomethingWithManyArgs is a free data retrieval call binding the contract method 0x6fd8b968. +// DoSomethingWithManyArgs is the Go binding used to pack the parameters required for calling +// the contract method 0x6fd8b968. // // Solidity: function DoSomethingWithManyArgs() pure returns(uint256, uint256, uint256, bool) func (c *C) PackDoSomethingWithManyArgs() []byte { @@ -66,6 +69,8 @@ func (c *C) PackDoSomethingWithManyArgs() []byte { return enc } +// DoSomethingWithManyArgsOutput serves as a container for the return parameters of contract +// method DoSomethingWithManyArgs. type DoSomethingWithManyArgsOutput struct { Arg0 *big.Int Arg1 *big.Int @@ -73,27 +78,26 @@ type DoSomethingWithManyArgsOutput struct { Arg3 bool } +// UnpackDoSomethingWithManyArgs is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x6fd8b968. +// +// Solidity: function DoSomethingWithManyArgs() pure returns(uint256, uint256, uint256, bool) func (c *C) UnpackDoSomethingWithManyArgs(data []byte) (DoSomethingWithManyArgsOutput, error) { out, err := c.abi.Unpack("DoSomethingWithManyArgs", data) - outstruct := new(DoSomethingWithManyArgsOutput) if err != nil { return *outstruct, err } - outstruct.Arg0 = abi.ConvertType(out[0], new(big.Int)).(*big.Int) - outstruct.Arg1 = abi.ConvertType(out[1], new(big.Int)).(*big.Int) - outstruct.Arg2 = abi.ConvertType(out[2], new(big.Int)).(*big.Int) - outstruct.Arg3 = *abi.ConvertType(out[3], new(bool)).(*bool) - return *outstruct, err } -// DoSomethingWithPoint is a free data retrieval call binding the contract method 0xedcdc894. +// DoSomethingWithPoint is the Go binding used to pack the parameters required for calling +// the contract method 0xedcdc894. // // Solidity: function DoSomethingWithPoint((uint256,uint256) p) pure returns((uint256,uint256)) func (c *C) PackDoSomethingWithPoint(P CPoint) []byte { @@ -104,20 +108,21 @@ func (c *C) PackDoSomethingWithPoint(P CPoint) []byte { return enc } +// UnpackDoSomethingWithPoint is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xedcdc894. +// +// Solidity: function DoSomethingWithPoint((uint256,uint256) p) pure returns((uint256,uint256)) func (c *C) UnpackDoSomethingWithPoint(data []byte) (CPoint, error) { out, err := c.abi.Unpack("DoSomethingWithPoint", data) - if err != nil { return *new(CPoint), err } - out0 := *abi.ConvertType(out[0], new(CPoint)).(*CPoint) - return out0, err - } -// EmitMulti is a free data retrieval call binding the contract method 0xcb493749. +// EmitMulti is the Go binding used to pack the parameters required for calling +// the contract method 0xcb493749. // // Solidity: function EmitMulti() returns() func (c *C) PackEmitMulti() []byte { @@ -128,7 +133,8 @@ func (c *C) PackEmitMulti() []byte { return enc } -// EmitOne is a free data retrieval call binding the contract method 0xe8e49a71. +// EmitOne is the Go binding used to pack the parameters required for calling +// the contract method 0xe8e49a71. // // Solidity: function EmitOne() returns() func (c *C) PackEmitOne() []byte { @@ -143,15 +149,21 @@ func (c *C) PackEmitOne() []byte { type CBasic1 struct { Id *big.Int Data *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const CBasic1EventName = "basic1" +// ContractEventName returns the user-defined event name. func (CBasic1) ContractEventName() string { return CBasic1EventName } +// UnpackBasic1Event is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event basic1(uint256 indexed id, uint256 data) func (c *C) UnpackBasic1Event(log *types.Log) (*CBasic1, error) { event := "basic1" if log.Topics[0] != c.abi.Events[event].ID { @@ -180,15 +192,21 @@ func (c *C) UnpackBasic1Event(log *types.Log) (*CBasic1, error) { type CBasic2 struct { Flag bool Data *big.Int - Raw *types.Log // Blockchain specific contextual infos + + Raw *types.Log // Blockchain specific contextual infos } const CBasic2EventName = "basic2" +// ContractEventName returns the user-defined event name. func (CBasic2) ContractEventName() string { return CBasic2EventName } +// UnpackBasic2Event is the Go binding that unpacks the event data emitted +// by contract. +// +// Solidity: event basic2(bool indexed flag, uint256 data) func (c *C) UnpackBasic2Event(log *types.Log) (*CBasic2, error) { event := "basic2" if log.Topics[0] != c.abi.Events[event].ID { diff --git a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go index 6b101e9a50..34c387e3b0 100644 --- a/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go @@ -4,6 +4,7 @@ package nested_libraries import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -53,6 +55,10 @@ func (c *C1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(uint256 v1, uint256 v2) returns() func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { enc, err := c1.abi.Pack("", v1, v2) if err != nil { @@ -61,7 +67,8 @@ func (c1 *C1) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { return enc } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) func (c1 *C1) PackDo(Val *big.Int) []byte { @@ -72,17 +79,17 @@ func (c1 *C1) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256 res) func (c1 *C1) UnpackDo(data []byte) (*big.Int, error) { out, err := c1.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // C2MetaData contains all meta data concerning the C2 contract. @@ -116,6 +123,10 @@ func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } +// PackConstructor is the Go binding used to pack the parameters required for +// contract deployment. +// +// Solidity: constructor(uint256 v1, uint256 v2) returns() func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { enc, err := c2.abi.Pack("", v1, v2) if err != nil { @@ -124,7 +135,8 @@ func (c2 *C2) PackConstructor(v1 *big.Int, v2 *big.Int) []byte { return enc } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256 res) func (c2 *C2) PackDo(Val *big.Int) []byte { @@ -135,17 +147,17 @@ func (c2 *C2) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256 res) func (c2 *C2) UnpackDo(data []byte) (*big.Int, error) { out, err := c2.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L1MetaData contains all meta data concerning the L1 contract. @@ -175,7 +187,8 @@ func (c *L1) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l1 *L1) PackDo(Val *big.Int) []byte { @@ -186,17 +199,17 @@ func (l1 *L1) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l1 *L1) UnpackDo(data []byte) (*big.Int, error) { out, err := l1.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L2MetaData contains all meta data concerning the L2 contract. @@ -229,7 +242,8 @@ func (c *L2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l2 *L2) PackDo(Val *big.Int) []byte { @@ -240,17 +254,17 @@ func (l2 *L2) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l2 *L2) UnpackDo(data []byte) (*big.Int, error) { out, err := l2.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L2bMetaData contains all meta data concerning the L2b contract. @@ -283,7 +297,8 @@ func (c *L2b) Instance(backend bind.ContractBackend, addr common.Address) *bind. return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l2b *L2b) PackDo(Val *big.Int) []byte { @@ -294,17 +309,17 @@ func (l2b *L2b) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l2b *L2b) UnpackDo(data []byte) (*big.Int, error) { out, err := l2b.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L3MetaData contains all meta data concerning the L3 contract. @@ -334,7 +349,8 @@ func (c *L3) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l3 *L3) PackDo(Val *big.Int) []byte { @@ -345,17 +361,17 @@ func (l3 *L3) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l3 *L3) UnpackDo(data []byte) (*big.Int, error) { out, err := l3.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L4MetaData contains all meta data concerning the L4 contract. @@ -389,7 +405,8 @@ func (c *L4) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l4 *L4) PackDo(Val *big.Int) []byte { @@ -400,17 +417,17 @@ func (l4 *L4) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l4 *L4) UnpackDo(data []byte) (*big.Int, error) { out, err := l4.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } // L4bMetaData contains all meta data concerning the L4b contract. @@ -443,7 +460,8 @@ func (c *L4b) Instance(backend bind.ContractBackend, addr common.Address) *bind. return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Do is a free data retrieval call binding the contract method 0x2ad11272. +// Do is the Go binding used to pack the parameters required for calling +// the contract method 0x2ad11272. // // Solidity: function Do(uint256 val) pure returns(uint256) func (l4b *L4b) PackDo(Val *big.Int) []byte { @@ -454,15 +472,15 @@ func (l4b *L4b) PackDo(Val *big.Int) []byte { return enc } +// UnpackDo is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0x2ad11272. +// +// Solidity: function Do(uint256 val) pure returns(uint256) func (l4b *L4b) UnpackDo(data []byte) (*big.Int, error) { out, err := l4b.abi.Unpack("Do", data) - if err != nil { return new(big.Int), err } - out0 := abi.ConvertType(out[0], new(big.Int)).(*big.Int) - return out0, err - } diff --git a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go index 03d2c1d5d5..8d10ea3a3c 100644 --- a/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go @@ -4,6 +4,7 @@ package solc_errors import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *C) Instance(backend bind.ContractBackend, addr common.Address) *bind.Bo return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Bar is a free data retrieval call binding the contract method 0xb0a378b0. +// Bar is the Go binding used to pack the parameters required for calling +// the contract method 0xb0a378b0. // // Solidity: function Bar() pure returns() func (c *C) PackBar() []byte { @@ -60,7 +63,8 @@ func (c *C) PackBar() []byte { return enc } -// Foo is a free data retrieval call binding the contract method 0xbfb4ebcf. +// Foo is the Go binding used to pack the parameters required for calling +// the contract method 0xbfb4ebcf. // // Solidity: function Foo() pure returns() func (c *C) PackFoo() []byte { @@ -71,19 +75,16 @@ func (c *C) PackFoo() []byte { return enc } -func (c *C) UnpackError(raw []byte) any { - // TODO: we should be able to discern the error type from the selector, instead of trying each possible type - // strip off the error type selector - raw = raw[4:] - - if val, err := c.UnpackBadThingError(raw); err == nil { - return val - - } else if val, err := c.UnpackBadThing2Error(raw); err == nil { - return val - +// UnpackError attempts to decode the provided error data using user-defined +// error definitions. +func (c *C) UnpackError(raw []byte) (any, error) { + if bytes.Equal(raw[:4], c.abi.Errors["BadThing"].ID.Bytes()[:4]) { + return c.UnpackBadThingError(raw[4:]) } - return nil + if bytes.Equal(raw[:4], c.abi.Errors["BadThing2"].ID.Bytes()[:4]) { + return c.UnpackBadThing2Error(raw[4:]) + } + return nil, errors.New("Unknown error") } // CBadThing represents a BadThing error raised by the C contract. @@ -94,14 +95,20 @@ type CBadThing struct { Arg4 bool } +// ErrorID returns the hash of canonical representation of the error's signature. +// +// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) func CBadThingErrorID() common.Hash { return common.HexToHash("0xbb6a82f123854747ef4381e30e497f934a3854753fec99a69c35c30d4b46714d") } +// UnpackBadThingError is the Go binding used to decode the provided +// error data into the corresponding Go error struct. +// +// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) func (c *C) UnpackBadThingError(raw []byte) (*CBadThing, error) { - errName := "BadThing" out := new(CBadThing) - if err := c.abi.UnpackIntoInterface(out, errName, raw); err != nil { + if err := c.abi.UnpackIntoInterface(out, "BadThing", raw); err != nil { return nil, err } return out, nil @@ -115,14 +122,20 @@ type CBadThing2 struct { Arg4 *big.Int } +// ErrorID returns the hash of canonical representation of the error's signature. +// +// Solidity: error BadThing2(uint256 arg1, uint256 arg2, uint256 arg3, uint256 arg4) func CBadThing2ErrorID() common.Hash { return common.HexToHash("0xd233a24f02271fe7c9470e060d0fda6447a142bf12ab31fed7ab65affd546175") } +// UnpackBadThing2Error is the Go binding used to decode the provided +// error data into the corresponding Go error struct. +// +// Solidity: error BadThing2(uint256 arg1, uint256 arg2, uint256 arg3, uint256 arg4) func (c *C) UnpackBadThing2Error(raw []byte) (*CBadThing2, error) { - errName := "BadThing2" out := new(CBadThing2) - if err := c.abi.UnpackIntoInterface(out, errName, raw); err != nil { + if err := c.abi.UnpackIntoInterface(out, "BadThing2", raw); err != nil { return nil, err } return out, nil @@ -155,7 +168,8 @@ func (c *C2) Instance(backend bind.ContractBackend, addr common.Address) *bind.B return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// Foo is a free data retrieval call binding the contract method 0xbfb4ebcf. +// Foo is the Go binding used to pack the parameters required for calling +// the contract method 0xbfb4ebcf. // // Solidity: function Foo() pure returns() func (c2 *C2) PackFoo() []byte { @@ -166,16 +180,13 @@ func (c2 *C2) PackFoo() []byte { return enc } -func (c2 *C2) UnpackError(raw []byte) any { - // TODO: we should be able to discern the error type from the selector, instead of trying each possible type - // strip off the error type selector - raw = raw[4:] - - if val, err := c2.UnpackBadThingError(raw); err == nil { - return val - +// UnpackError attempts to decode the provided error data using user-defined +// error definitions. +func (c2 *C2) UnpackError(raw []byte) (any, error) { + if bytes.Equal(raw[:4], c2.abi.Errors["BadThing"].ID.Bytes()[:4]) { + return c2.UnpackBadThingError(raw[4:]) } - return nil + return nil, errors.New("Unknown error") } // C2BadThing represents a BadThing error raised by the C2 contract. @@ -186,14 +197,20 @@ type C2BadThing struct { Arg4 bool } +// ErrorID returns the hash of canonical representation of the error's signature. +// +// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) func C2BadThingErrorID() common.Hash { return common.HexToHash("0xbb6a82f123854747ef4381e30e497f934a3854753fec99a69c35c30d4b46714d") } +// UnpackBadThingError is the Go binding used to decode the provided +// error data into the corresponding Go error struct. +// +// Solidity: error BadThing(uint256 arg1, uint256 arg2, uint256 arg3, bool arg4) func (c2 *C2) UnpackBadThingError(raw []byte) (*C2BadThing, error) { - errName := "BadThing" out := new(C2BadThing) - if err := c2.abi.UnpackIntoInterface(out, errName, raw); err != nil { + if err := c2.abi.UnpackIntoInterface(out, "BadThing", raw); err != nil { return nil, err } return out, nil diff --git a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go index 6261cec297..69e0ba0227 100644 --- a/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go +++ b/accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go @@ -4,6 +4,7 @@ package uint256arrayreturn import ( + "bytes" "errors" "math/big" @@ -15,6 +16,7 @@ import ( // Reference imports to suppress errors if they are not otherwise used. var ( + _ = bytes.Equal _ = errors.New _ = big.NewInt _ = common.Big1 @@ -49,7 +51,8 @@ func (c *MyContract) Instance(backend bind.ContractBackend, addr common.Address) return bind.NewBoundContract(addr, c.abi, backend, backend, backend) } -// GetNums is a free data retrieval call binding the contract method 0xbd6d1007. +// GetNums is the Go binding used to pack the parameters required for calling +// the contract method 0xbd6d1007. // // Solidity: function GetNums() pure returns(uint256[5]) func (myContract *MyContract) PackGetNums() []byte { @@ -60,15 +63,15 @@ func (myContract *MyContract) PackGetNums() []byte { return enc } +// UnpackGetNums is the Go binding that unpacks the parameters returned +// from invoking the contract method with ID 0xbd6d1007. +// +// Solidity: function GetNums() pure returns(uint256[5]) func (myContract *MyContract) UnpackGetNums(data []byte) ([5]*big.Int, error) { out, err := myContract.abi.Unpack("GetNums", data) - if err != nil { return *new([5]*big.Int), err } - out0 := *abi.ConvertType(out[0], new([5]*big.Int)).(*[5]*big.Int) - return out0, err - } diff --git a/accounts/abi/bind/v2/lib_test.go b/accounts/abi/bind/v2/lib_test.go index 5cbc0374b5..e0d454e56c 100644 --- a/accounts/abi/bind/v2/lib_test.go +++ b/accounts/abi/bind/v2/lib_test.go @@ -330,8 +330,8 @@ func TestErrors(t *testing.T) { if !hasRevertErrorData { t.Fatalf("expected call error to contain revert error data.") } - rawUnpackedErr := c.UnpackError(raw) - if rawUnpackedErr == nil { + rawUnpackedErr, err := c.UnpackError(raw) + if err != nil { t.Fatalf("expected to unpack error") }