From 41a0cfff690d74475dfcca278f4a143df6c9086c Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Mon, 6 Jan 2025 15:53:25 +0700 Subject: [PATCH] accounts/abi/bind: deduplicate logic to normalize struct elements, event/error/method arguments/results. fix for case where normalization of name '_' would return an empty string --- accounts/abi/bind/bindv2.go | 37 +++++------------ accounts/abi/bind/bindv2_test.go | 26 ++++++------ .../convertedv1bindtests/callbackparam.go | 4 +- .../convertedv1bindtests/crowdsale.go | 4 +- .../v2/internal/convertedv1bindtests/dao.go | 40 +++++++++---------- .../convertedv1bindtests/deeplynestedarray.go | 8 ++-- .../internal/convertedv1bindtests/getter.go | 12 +++--- .../convertedv1bindtests/inputchecker.go | 20 +++++----- .../convertedv1bindtests/interactor.go | 4 +- .../convertedv1bindtests/nameconflict.go | 4 +- .../convertedv1bindtests/outputchecker.go | 18 ++++----- .../internal/convertedv1bindtests/overload.go | 8 ++-- .../convertedv1bindtests/rangekeyword.go | 4 +- .../internal/convertedv1bindtests/slicer.go | 16 ++++---- .../v2/internal/convertedv1bindtests/token.go | 24 +++++------ .../v2/internal/convertedv1bindtests/tuple.go | 32 +++++++-------- .../convertedv1bindtests/underscorer.go | 36 ++++++++--------- 17 files changed, 142 insertions(+), 155 deletions(-) diff --git a/accounts/abi/bind/bindv2.go b/accounts/abi/bind/bindv2.go index bc458750de..2ed8ad1a90 100644 --- a/accounts/abi/bind/bindv2.go +++ b/accounts/abi/bind/bindv2.go @@ -74,18 +74,13 @@ func (cb *contractBinder) bindMethod(original abi.Method) error { } normalized.Name = normalizedName - normalized.Inputs = make([]abi.Argument, len(original.Inputs)) - copy(normalized.Inputs, original.Inputs) - for j, input := range normalized.Inputs { - if input.Name == "" || isKeyWord(input.Name) { - normalized.Inputs[j].Name = fmt.Sprintf("arg%d", j) - } + normalized.Inputs = normalizeArgs(original.Inputs) + for _, input := range normalized.Inputs { if hasStruct(input.Type) { cb.binder.BindStructType(input.Type) } } - normalized.Outputs = make([]abi.Argument, len(original.Outputs)) - copy(normalized.Outputs, original.Outputs) + normalized.Outputs = normalizeArgs(original.Outputs) for j, output := range normalized.Outputs { if output.Name != "" { normalized.Outputs[j].Name = abi.ToCamelCase(output.Name) @@ -97,22 +92,6 @@ func (cb *contractBinder) bindMethod(original abi.Method) error { isStructured := structured(original.Outputs) // if the call returns multiple values, coallesce them into a struct if len(normalized.Outputs) > 1 { - // Build up dictionary of existing arg names. - keys := make(map[string]struct{}) - for _, o := range normalized.Outputs { - if o.Name != "" { - keys[strings.ToLower(o.Name)] = struct{}{} - } - } - // Assign names to anonymous fields. - for i, o := range normalized.Outputs { - if o.Name != "" { - continue - } - o.Name = abi.ToCamelCase(abi.ResolveNameConflict("arg", func(name string) bool { _, ok := keys[name]; return ok })) - normalized.Outputs[i] = o - keys[strings.ToLower(o.Name)] = struct{}{} - } isStructured = true } @@ -120,15 +99,20 @@ func (cb *contractBinder) bindMethod(original abi.Method) error { return nil } +// normalize a set of arguments by stripping underscores, giving a generic name in the case where +// the arg name collides with a reserved Go keyword, and finally converting to camel-case. func normalizeArgs(args abi.Arguments) abi.Arguments { args = slices.Clone(args) used := make(map[string]bool) for i, input := range args { - if input.Name == "" || isKeyWord(input.Name) { - args[i].Name = fmt.Sprintf("arg%d", i) + if isKeyWord(input.Name) { + args[i].Name = fmt.Sprintf("Arg%d", i) } args[i].Name = abi.ToCamelCase(args[i].Name) + if args[i].Name == "" { + args[i].Name = fmt.Sprintf("Arg%d", i) + } for index := 0; ; index++ { if !used[args[i].Name] { used[args[i].Name] = true @@ -212,6 +196,7 @@ func BindV2(types []string, abis []string, bytecodes []string, pkg string, libs return "", err } + // TODO: normalize these args, add unit tests that fail in the current commit. for _, input := range evmABI.Constructor.Inputs { if hasStruct(input.Type) { bindStructType(input.Type, b.structs) diff --git a/accounts/abi/bind/bindv2_test.go b/accounts/abi/bind/bindv2_test.go index f743d669c7..d3fdb96ba8 100644 --- a/accounts/abi/bind/bindv2_test.go +++ b/accounts/abi/bind/bindv2_test.go @@ -6,7 +6,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/crypto" "os" - "strings" "testing" ) @@ -343,20 +342,21 @@ func TestBindingV2(t *testing.T) { t.Fatalf("got error from bind: %v", err) } - if err := os.WriteFile(fmt.Sprintf("convertedv1bindtests/%s.go", strings.ToLower(tc.name)), []byte(code), 0666); err != nil { - t.Fatalf("err writing expected output to file: %v\n", err) - } + // TODO: remove these before merging abigen2 PR. these are for convenience if I need to regenerate the converted bindings or add a new one. + /* + if err := os.WriteFile(fmt.Sprintf("convertedv1bindtests/%s.go", strings.ToLower(tc.name)), []byte(code), 0666); err != nil { + t.Fatalf("err writing expected output to file: %v\n", err) + } + */ /* fmt.Printf("//go:embed v2/internal/convertedv1bindtests/%s.go\n", strings.ToLower(tc.name)) fmt.Printf("var v1TestBinding%s string\n", tc.name) fmt.Println() */ - /* - if code != tc.expectedBindings { - //t.Fatalf("name mismatch for %s", tc.name) - t.Fatalf("'%s'\n!=\n'%s'\n", code, tc.expectedBindings) - } - */ + if code != tc.expectedBindings { + //t.Fatalf("name mismatch for %s", tc.name) + t.Fatalf("'%s'\n!=\n'%s'\n", code, tc.expectedBindings) + } }) } } @@ -369,7 +369,9 @@ func TestNormalizeArgs(t *testing.T) { for i, tc := range []normalizeArgsTc{ {[]string{"arg1", "Arg1"}, []string{"Arg1", "Arg10"}}, {[]string{"", ""}, []string{"Arg0", "Arg1"}}, - {[]string{"var", "const"}, []string{"Arg0", "Arg1"}}} { + {[]string{"var", "const"}, []string{"Arg0", "Arg1"}}, + {[]string{"_res", "Res"}, []string{"Res", "Res0"}}, + {[]string{"_", "__"}, []string{"Arg0", "Arg1"}}} { var inpArgs abi.Arguments for _, inpArgName := range tc.inp { inpArgs = append(inpArgs, abi.Argument{ @@ -379,7 +381,7 @@ func TestNormalizeArgs(t *testing.T) { res := normalizeArgs(inpArgs) for j, resArg := range res { if resArg.Name != tc.expected[j] { - t.Fatalf("mismatch for test index %d, arg index %d: expected %v. got %v", i, j, resArg.Name, tc.expected[j]) + t.Fatalf("mismatch for test index %d, arg index %d: expected %v. got %v", i, j, tc.expected[j], resArg.Name) } } } diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/callbackparam.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/callbackparam.go index 6e951829b6..cdf889a8ef 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/callbackparam.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/callbackparam.go @@ -53,6 +53,6 @@ func (_CallbackParam *CallbackParam) PackConstructor() []byte { // Test is a free data retrieval call binding the contract method 0xd7a5aba2. // // Solidity: function test(function callback) returns() -func (_CallbackParam *CallbackParam) PackTest(callback [24]byte) ([]byte, error) { - return _CallbackParam.abi.Pack("test", callback) +func (_CallbackParam *CallbackParam) PackTest(Callback [24]byte) ([]byte, error) { + return _CallbackParam.abi.Pack("test", Callback) } diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/crowdsale.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/crowdsale.go index 66c17fff01..59ff84aad7 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/crowdsale.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/crowdsale.go @@ -120,8 +120,8 @@ func (_Crowdsale *Crowdsale) UnpackDeadline(data []byte) (*big.Int, error) { // Funders is a free data retrieval call binding the contract method 0xdc0d3dff. // // Solidity: function funders(uint256 ) returns(address addr, uint256 amount) -func (_Crowdsale *Crowdsale) PackFunders(arg0 *big.Int) ([]byte, error) { - return _Crowdsale.abi.Pack("funders", arg0) +func (_Crowdsale *Crowdsale) PackFunders(Arg0 *big.Int) ([]byte, error) { + return _Crowdsale.abi.Pack("funders", Arg0) } type FundersOutput struct { diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/dao.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/dao.go index 0d6b6e2f3b..99e0e5709d 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/dao.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/dao.go @@ -53,22 +53,22 @@ func (_DAO *DAO) PackConstructor(minimumQuorumForProposals *big.Int, minutesForD // ChangeMembership is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("changeMembership", targetMember, canVote, memberName) +func (_DAO *DAO) PackChangeMembership(TargetMember common.Address, CanVote bool, MemberName string) ([]byte, error) { + return _DAO.abi.Pack("changeMembership", TargetMember, CanVote, MemberName) } // ChangeVotingRules is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("changeVotingRules", minimumQuorumForProposals, minutesForDebate, marginOfVotesForMajority) +func (_DAO *DAO) PackChangeVotingRules(MinimumQuorumForProposals *big.Int, MinutesForDebate *big.Int, MarginOfVotesForMajority *big.Int) ([]byte, error) { + return _DAO.abi.Pack("changeVotingRules", MinimumQuorumForProposals, MinutesForDebate, MarginOfVotesForMajority) } // CheckProposalCode is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("checkProposalCode", proposalNumber, beneficiary, etherAmount, transactionBytecode) +func (_DAO *DAO) PackCheckProposalCode(ProposalNumber *big.Int, Beneficiary common.Address, EtherAmount *big.Int, TransactionBytecode []byte) ([]byte, error) { + return _DAO.abi.Pack("checkProposalCode", ProposalNumber, Beneficiary, EtherAmount, TransactionBytecode) } func (_DAO *DAO) UnpackCheckProposalCode(data []byte) (bool, error) { @@ -107,8 +107,8 @@ func (_DAO *DAO) UnpackDebatingPeriodInMinutes(data []byte) (*big.Int, error) { // ExecuteProposal is a free data retrieval call binding the contract method 0x237e9492. // // Solidity: function executeProposal(uint256 proposalNumber, bytes transactionBytecode) returns(int256 result) -func (_DAO *DAO) PackExecuteProposal(proposalNumber *big.Int, transactionBytecode []byte) ([]byte, error) { - return _DAO.abi.Pack("executeProposal", proposalNumber, transactionBytecode) +func (_DAO *DAO) PackExecuteProposal(ProposalNumber *big.Int, TransactionBytecode []byte) ([]byte, error) { + return _DAO.abi.Pack("executeProposal", ProposalNumber, TransactionBytecode) } func (_DAO *DAO) UnpackExecuteProposal(data []byte) (*big.Int, error) { @@ -147,8 +147,8 @@ func (_DAO *DAO) UnpackMajorityMargin(data []byte) (*big.Int, error) { // MemberId is a free data retrieval call binding the contract method 0x39106821. // // Solidity: function memberId(address ) returns(uint256) -func (_DAO *DAO) PackMemberId(arg0 common.Address) ([]byte, error) { - return _DAO.abi.Pack("memberId", arg0) +func (_DAO *DAO) PackMemberId(Arg0 common.Address) ([]byte, error) { + return _DAO.abi.Pack("memberId", Arg0) } func (_DAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) { @@ -167,8 +167,8 @@ func (_DAO *DAO) UnpackMemberId(data []byte) (*big.Int, error) { // Members is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("members", arg0) +func (_DAO *DAO) PackMembers(Arg0 *big.Int) ([]byte, error) { + return _DAO.abi.Pack("members", Arg0) } type MembersOutput struct { @@ -218,8 +218,8 @@ func (_DAO *DAO) UnpackMinimumQuorum(data []byte) (*big.Int, error) { // NewProposal is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("newProposal", beneficiary, etherAmount, JobDescription, transactionBytecode) +func (_DAO *DAO) PackNewProposal(Beneficiary common.Address, EtherAmount *big.Int, JobDescription string, TransactionBytecode []byte) ([]byte, error) { + return _DAO.abi.Pack("newProposal", Beneficiary, EtherAmount, JobDescription, TransactionBytecode) } func (_DAO *DAO) UnpackNewProposal(data []byte) (*big.Int, error) { @@ -278,8 +278,8 @@ func (_DAO *DAO) UnpackOwner(data []byte) (common.Address, error) { // Proposals is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("proposals", arg0) +func (_DAO *DAO) PackProposals(Arg0 *big.Int) ([]byte, error) { + return _DAO.abi.Pack("proposals", Arg0) } type ProposalsOutput struct { @@ -319,15 +319,15 @@ func (_DAO *DAO) UnpackProposals(data []byte) (ProposalsOutput, error) { // TransferOwnership is a free data retrieval call binding the contract method 0xf2fde38b. // // Solidity: function transferOwnership(address newOwner) returns() -func (_DAO *DAO) PackTransferOwnership(newOwner common.Address) ([]byte, error) { - return _DAO.abi.Pack("transferOwnership", newOwner) +func (_DAO *DAO) PackTransferOwnership(NewOwner common.Address) ([]byte, error) { + return _DAO.abi.Pack("transferOwnership", NewOwner) } // Vote is a free data retrieval call binding 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, error) { - return _DAO.abi.Pack("vote", proposalNumber, supportsProposal, justificationText) +func (_DAO *DAO) PackVote(ProposalNumber *big.Int, SupportsProposal bool, JustificationText string) ([]byte, error) { + return _DAO.abi.Pack("vote", ProposalNumber, SupportsProposal, JustificationText) } func (_DAO *DAO) UnpackVote(data []byte) (*big.Int, error) { diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/deeplynestedarray.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/deeplynestedarray.go index ab2cd5574a..5de467a788 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/deeplynestedarray.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/deeplynestedarray.go @@ -53,8 +53,8 @@ func (_DeeplyNestedArray *DeeplyNestedArray) PackConstructor() []byte { // DeepUint64Array is a free data retrieval call binding 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, error) { - return _DeeplyNestedArray.abi.Pack("deepUint64Array", arg0, arg1, arg2) +func (_DeeplyNestedArray *DeeplyNestedArray) PackDeepUint64Array(Arg0 *big.Int, Arg1 *big.Int, Arg2 *big.Int) ([]byte, error) { + return _DeeplyNestedArray.abi.Pack("deepUint64Array", Arg0, Arg1, Arg2) } func (_DeeplyNestedArray *DeeplyNestedArray) UnpackDeepUint64Array(data []byte) (uint64, error) { @@ -93,6 +93,6 @@ func (_DeeplyNestedArray *DeeplyNestedArray) UnpackRetrieveDeepArray(data []byte // StoreDeepUintArray is a free data retrieval call binding the contract method 0x34424855. // // Solidity: function storeDeepUintArray(uint64[3][4][5] arr) returns() -func (_DeeplyNestedArray *DeeplyNestedArray) PackStoreDeepUintArray(arr [5][4][3]uint64) ([]byte, error) { - return _DeeplyNestedArray.abi.Pack("storeDeepUintArray", arr) +func (_DeeplyNestedArray *DeeplyNestedArray) PackStoreDeepUintArray(Arr [5][4][3]uint64) ([]byte, error) { + return _DeeplyNestedArray.abi.Pack("storeDeepUintArray", Arr) } diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/getter.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/getter.go index 067dc21af8..dc859dcedc 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/getter.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/getter.go @@ -58,9 +58,9 @@ func (_Getter *Getter) PackGetter() ([]byte, error) { } type GetterOutput struct { - Arg string - Arg0 *big.Int - Arg1 [32]byte + Arg0 string + Arg1 *big.Int + Arg2 [32]byte } func (_Getter *Getter) UnpackGetter(data []byte) (GetterOutput, error) { @@ -71,9 +71,9 @@ func (_Getter *Getter) UnpackGetter(data []byte) (GetterOutput, error) { return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Arg0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) - outstruct.Arg1 = *abi.ConvertType(out[2], new([32]byte)).(*[32]byte) + 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/bind/v2/internal/convertedv1bindtests/inputchecker.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/inputchecker.go index 5966466936..075ee817c9 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/inputchecker.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/inputchecker.go @@ -52,36 +52,36 @@ func (_InputChecker *InputChecker) PackConstructor() []byte { // AnonInput is a free data retrieval call binding the contract method 0x3e708e82. // // Solidity: function anonInput(string ) returns() -func (_InputChecker *InputChecker) PackAnonInput(arg0 string) ([]byte, error) { - return _InputChecker.abi.Pack("anonInput", arg0) +func (_InputChecker *InputChecker) PackAnonInput(Arg0 string) ([]byte, error) { + return _InputChecker.abi.Pack("anonInput", Arg0) } // AnonInputs is a free data retrieval call binding the contract method 0x28160527. // // Solidity: function anonInputs(string , string ) returns() -func (_InputChecker *InputChecker) PackAnonInputs(arg0 string, arg1 string) ([]byte, error) { - return _InputChecker.abi.Pack("anonInputs", arg0, arg1) +func (_InputChecker *InputChecker) PackAnonInputs(Arg0 string, Arg1 string) ([]byte, error) { + return _InputChecker.abi.Pack("anonInputs", Arg0, Arg1) } // MixedInputs is a free data retrieval call binding the contract method 0xc689ebdc. // // Solidity: function mixedInputs(string , string str) returns() -func (_InputChecker *InputChecker) PackMixedInputs(arg0 string, str string) ([]byte, error) { - return _InputChecker.abi.Pack("mixedInputs", arg0, str) +func (_InputChecker *InputChecker) PackMixedInputs(Arg0 string, Str string) ([]byte, error) { + return _InputChecker.abi.Pack("mixedInputs", Arg0, Str) } // NamedInput is a free data retrieval call binding the contract method 0x0d402005. // // Solidity: function namedInput(string str) returns() -func (_InputChecker *InputChecker) PackNamedInput(str string) ([]byte, error) { - return _InputChecker.abi.Pack("namedInput", str) +func (_InputChecker *InputChecker) PackNamedInput(Str string) ([]byte, error) { + return _InputChecker.abi.Pack("namedInput", Str) } // NamedInputs is a free data retrieval call binding the contract method 0x63c796ed. // // Solidity: function namedInputs(string str1, string str2) returns() -func (_InputChecker *InputChecker) PackNamedInputs(str1 string, str2 string) ([]byte, error) { - return _InputChecker.abi.Pack("namedInputs", str1, str2) +func (_InputChecker *InputChecker) PackNamedInputs(Str1 string, Str2 string) ([]byte, error) { + return _InputChecker.abi.Pack("namedInputs", Str1, Str2) } // NoInput is a free data retrieval call binding the contract method 0x53539029. diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/interactor.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/interactor.go index d921c9031b..2d0e145238 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/interactor.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/interactor.go @@ -73,8 +73,8 @@ func (_Interactor *Interactor) UnpackDeployString(data []byte) (string, error) { // Transact is a free data retrieval call binding the contract method 0xd736c513. // // Solidity: function transact(string str) returns() -func (_Interactor *Interactor) PackTransact(str string) ([]byte, error) { - return _Interactor.abi.Pack("transact", str) +func (_Interactor *Interactor) PackTransact(Str string) ([]byte, error) { + return _Interactor.abi.Pack("transact", Str) } // TransactString is a free data retrieval call binding the contract method 0x0d86a0e1. diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/nameconflict.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/nameconflict.go index 8046fd67cc..cbd8dfead5 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/nameconflict.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/nameconflict.go @@ -59,8 +59,8 @@ func (_NameConflict *NameConflict) PackConstructor() []byte { // AddRequest is a free data retrieval call binding the contract method 0xcce7b048. // // Solidity: function addRequest((bytes,bytes) req) pure returns() -func (_NameConflict *NameConflict) PackAddRequest(req Oraclerequest) ([]byte, error) { - return _NameConflict.abi.Pack("addRequest", req) +func (_NameConflict *NameConflict) PackAddRequest(Req Oraclerequest) ([]byte, error) { + return _NameConflict.abi.Pack("addRequest", Req) } // GetRequest is a free data retrieval call binding the contract method 0xc2bb515f. diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/outputchecker.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/outputchecker.go index b1487461ad..dc5c94be97 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/outputchecker.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/outputchecker.go @@ -77,8 +77,8 @@ func (_OutputChecker *OutputChecker) PackAnonOutputs() ([]byte, error) { } type AnonOutputsOutput struct { - Arg string Arg0 string + Arg1 string } func (_OutputChecker *OutputChecker) UnpackAnonOutputs(data []byte) (AnonOutputsOutput, error) { @@ -89,8 +89,8 @@ func (_OutputChecker *OutputChecker) UnpackAnonOutputs(data []byte) (AnonOutputs return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Arg0 = *abi.ConvertType(out[1], new(string)).(*string) + outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Arg1 = *abi.ConvertType(out[1], new(string)).(*string) return *outstruct, err @@ -104,8 +104,8 @@ func (_OutputChecker *OutputChecker) PackCollidingOutputs() ([]byte, error) { } type CollidingOutputsOutput struct { - Str string - Str string + Str string + Str0 string } func (_OutputChecker *OutputChecker) UnpackCollidingOutputs(data []byte) (CollidingOutputsOutput, error) { @@ -117,7 +117,7 @@ func (_OutputChecker *OutputChecker) UnpackCollidingOutputs(data []byte) (Collid } outstruct.Str = *abi.ConvertType(out[0], new(string)).(*string) - outstruct.Str = *abi.ConvertType(out[1], new(string)).(*string) + outstruct.Str0 = *abi.ConvertType(out[1], new(string)).(*string) return *outstruct, err @@ -131,8 +131,8 @@ func (_OutputChecker *OutputChecker) PackMixedOutputs() ([]byte, error) { } type MixedOutputsOutput struct { - Arg string - Str string + Arg0 string + Str string } func (_OutputChecker *OutputChecker) UnpackMixedOutputs(data []byte) (MixedOutputsOutput, error) { @@ -143,7 +143,7 @@ func (_OutputChecker *OutputChecker) UnpackMixedOutputs(data []byte) (MixedOutpu return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(string)).(*string) + outstruct.Arg0 = *abi.ConvertType(out[0], new(string)).(*string) outstruct.Str = *abi.ConvertType(out[1], new(string)).(*string) return *outstruct, err diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/overload.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/overload.go index 93894f3401..26048b1b09 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/overload.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/overload.go @@ -53,15 +53,15 @@ func (_Overload *Overload) PackConstructor() []byte { // Foo is a free data retrieval call binding the contract method 0x04bc52f8. // // Solidity: function foo(uint256 i, uint256 j) returns() -func (_Overload *Overload) PackFoo(i *big.Int, j *big.Int) ([]byte, error) { - return _Overload.abi.Pack("foo", i, j) +func (_Overload *Overload) PackFoo(I *big.Int, J *big.Int) ([]byte, error) { + return _Overload.abi.Pack("foo", I, J) } // Foo0 is a free data retrieval call binding the contract method 0x2fbebd38. // // Solidity: function foo(uint256 i) returns() -func (_Overload *Overload) PackFoo0(i *big.Int) ([]byte, error) { - return _Overload.abi.Pack("foo0", i) +func (_Overload *Overload) PackFoo0(I *big.Int) ([]byte, error) { + return _Overload.abi.Pack("foo0", I) } // OverloadBar represents a Bar event raised by the Overload contract. diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/rangekeyword.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/rangekeyword.go index e9a957d66c..1529e0663b 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/rangekeyword.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/rangekeyword.go @@ -53,6 +53,6 @@ func (_RangeKeyword *RangeKeyword) PackConstructor() []byte { // FunctionWithKeywordParameter is a free data retrieval call binding the contract method 0x527a119f. // // Solidity: function functionWithKeywordParameter(uint256 range) pure returns() -func (_RangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(arg0 *big.Int) ([]byte, error) { - return _RangeKeyword.abi.Pack("functionWithKeywordParameter", arg0) +func (_RangeKeyword *RangeKeyword) PackFunctionWithKeywordParameter(Arg0 *big.Int) ([]byte, error) { + return _RangeKeyword.abi.Pack("functionWithKeywordParameter", Arg0) } diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/slicer.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/slicer.go index 8deb68d012..a055278372 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/slicer.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/slicer.go @@ -53,8 +53,8 @@ func (_Slicer *Slicer) PackConstructor() []byte { // EchoAddresses is a free data retrieval call binding the contract method 0xbe1127a3. // // Solidity: function echoAddresses(address[] input) returns(address[] output) -func (_Slicer *Slicer) PackEchoAddresses(input []common.Address) ([]byte, error) { - return _Slicer.abi.Pack("echoAddresses", input) +func (_Slicer *Slicer) PackEchoAddresses(Input []common.Address) ([]byte, error) { + return _Slicer.abi.Pack("echoAddresses", Input) } func (_Slicer *Slicer) UnpackEchoAddresses(data []byte) ([]common.Address, error) { @@ -73,8 +73,8 @@ func (_Slicer *Slicer) UnpackEchoAddresses(data []byte) ([]common.Address, error // EchoBools is a free data retrieval call binding the contract method 0xf637e589. // // Solidity: function echoBools(bool[] input) returns(bool[] output) -func (_Slicer *Slicer) PackEchoBools(input []bool) ([]byte, error) { - return _Slicer.abi.Pack("echoBools", input) +func (_Slicer *Slicer) PackEchoBools(Input []bool) ([]byte, error) { + return _Slicer.abi.Pack("echoBools", Input) } func (_Slicer *Slicer) UnpackEchoBools(data []byte) ([]bool, error) { @@ -93,8 +93,8 @@ func (_Slicer *Slicer) UnpackEchoBools(data []byte) ([]bool, error) { // EchoFancyInts is a free data retrieval call binding the contract method 0xd88becc0. // // Solidity: function echoFancyInts(uint24[23] input) returns(uint24[23] output) -func (_Slicer *Slicer) PackEchoFancyInts(input [23]*big.Int) ([]byte, error) { - return _Slicer.abi.Pack("echoFancyInts", input) +func (_Slicer *Slicer) PackEchoFancyInts(Input [23]*big.Int) ([]byte, error) { + return _Slicer.abi.Pack("echoFancyInts", Input) } func (_Slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*big.Int, error) { @@ -113,8 +113,8 @@ func (_Slicer *Slicer) UnpackEchoFancyInts(data []byte) ([23]*big.Int, error) { // EchoInts is a free data retrieval call binding the contract method 0xe15a3db7. // // Solidity: function echoInts(int256[] input) returns(int256[] output) -func (_Slicer *Slicer) PackEchoInts(input []*big.Int) ([]byte, error) { - return _Slicer.abi.Pack("echoInts", input) +func (_Slicer *Slicer) PackEchoInts(Input []*big.Int) ([]byte, error) { + return _Slicer.abi.Pack("echoInts", Input) } func (_Slicer *Slicer) UnpackEchoInts(data []byte) ([]*big.Int, error) { diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/token.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/token.go index 27452999bd..bf12176b1d 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/token.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/token.go @@ -53,8 +53,8 @@ func (_Token *Token) PackConstructor(initialSupply *big.Int, tokenName string, d // Allowance is a free data retrieval call binding the contract method 0xdd62ed3e. // // Solidity: function allowance(address , address ) returns(uint256) -func (_Token *Token) PackAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) { - return _Token.abi.Pack("allowance", arg0, arg1) +func (_Token *Token) PackAllowance(Arg0 common.Address, Arg1 common.Address) ([]byte, error) { + return _Token.abi.Pack("allowance", Arg0, Arg1) } func (_Token *Token) UnpackAllowance(data []byte) (*big.Int, error) { @@ -73,8 +73,8 @@ func (_Token *Token) UnpackAllowance(data []byte) (*big.Int, error) { // ApproveAndCall is a free data retrieval call binding 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, error) { - return _Token.abi.Pack("approveAndCall", _spender, _value, _extraData) +func (_Token *Token) PackApproveAndCall(Spender common.Address, Value *big.Int, ExtraData []byte) ([]byte, error) { + return _Token.abi.Pack("approveAndCall", Spender, Value, ExtraData) } func (_Token *Token) UnpackApproveAndCall(data []byte) (bool, error) { @@ -93,8 +93,8 @@ func (_Token *Token) UnpackApproveAndCall(data []byte) (bool, error) { // BalanceOf is a free data retrieval call binding the contract method 0x70a08231. // // Solidity: function balanceOf(address ) returns(uint256) -func (_Token *Token) PackBalanceOf(arg0 common.Address) ([]byte, error) { - return _Token.abi.Pack("balanceOf", arg0) +func (_Token *Token) PackBalanceOf(Arg0 common.Address) ([]byte, error) { + return _Token.abi.Pack("balanceOf", Arg0) } func (_Token *Token) UnpackBalanceOf(data []byte) (*big.Int, error) { @@ -153,8 +153,8 @@ func (_Token *Token) UnpackName(data []byte) (string, error) { // SpentAllowance is a free data retrieval call binding the contract method 0xdc3080f2. // // Solidity: function spentAllowance(address , address ) returns(uint256) -func (_Token *Token) PackSpentAllowance(arg0 common.Address, arg1 common.Address) ([]byte, error) { - return _Token.abi.Pack("spentAllowance", arg0, arg1) +func (_Token *Token) PackSpentAllowance(Arg0 common.Address, Arg1 common.Address) ([]byte, error) { + return _Token.abi.Pack("spentAllowance", Arg0, Arg1) } func (_Token *Token) UnpackSpentAllowance(data []byte) (*big.Int, error) { @@ -193,15 +193,15 @@ func (_Token *Token) UnpackSymbol(data []byte) (string, error) { // Transfer is a free data retrieval call binding the contract method 0xa9059cbb. // // Solidity: function transfer(address _to, uint256 _value) returns() -func (_Token *Token) PackTransfer(_to common.Address, _value *big.Int) ([]byte, error) { - return _Token.abi.Pack("transfer", _to, _value) +func (_Token *Token) PackTransfer(To common.Address, Value *big.Int) ([]byte, error) { + return _Token.abi.Pack("transfer", To, Value) } // TransferFrom is a free data retrieval call binding 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, error) { - return _Token.abi.Pack("transferFrom", _from, _to, _value) +func (_Token *Token) PackTransferFrom(From common.Address, To common.Address, Value *big.Int) ([]byte, error) { + return _Token.abi.Pack("transferFrom", From, To, Value) } func (_Token *Token) UnpackTransferFrom(data []byte) (bool, error) { diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/tuple.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/tuple.go index 602a3d8887..f8f658c160 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/tuple.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/tuple.go @@ -78,16 +78,16 @@ func (_Tuple *Tuple) PackConstructor() []byte { // Func1 is a free data retrieval call binding 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, error) { - return _Tuple.abi.Pack("func1", a, b, c, d, e) +func (_Tuple *Tuple) PackFunc1(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS, E []*big.Int) ([]byte, error) { + return _Tuple.abi.Pack("func1", A, B, C, D, E) } type Func1Output struct { - Arg TupleS - Arg0 [][2]TupleT - Arg1 [2][]TupleT - Arg2 []TupleS - Arg3 []*big.Int + Arg0 TupleS + Arg1 [][2]TupleT + Arg2 [2][]TupleT + Arg3 []TupleS + Arg4 []*big.Int } func (_Tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { @@ -98,11 +98,11 @@ func (_Tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(TupleS)).(*TupleS) - outstruct.Arg0 = *abi.ConvertType(out[1], new([][2]TupleT)).(*[][2]TupleT) - outstruct.Arg1 = *abi.ConvertType(out[2], new([2][]TupleT)).(*[2][]TupleT) - outstruct.Arg2 = *abi.ConvertType(out[3], new([]TupleS)).(*[]TupleS) - outstruct.Arg3 = *abi.ConvertType(out[4], new([]*big.Int)).(*[]*big.Int) + 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 @@ -111,15 +111,15 @@ func (_Tuple *Tuple) UnpackFunc1(data []byte) (Func1Output, error) { // Func2 is a free data retrieval call binding 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, error) { - return _Tuple.abi.Pack("func2", a, b, c, d, e) +func (_Tuple *Tuple) PackFunc2(A TupleS, B [][2]TupleT, C [2][]TupleT, D []TupleS, E []*big.Int) ([]byte, error) { + return _Tuple.abi.Pack("func2", A, B, C, D, E) } // Func3 is a free data retrieval call binding the contract method 0xe4d9a43b. // // Solidity: function func3((uint16,uint16)[] ) pure returns() -func (_Tuple *Tuple) PackFunc3(arg0 []TupleQ) ([]byte, error) { - return _Tuple.abi.Pack("func3", arg0) +func (_Tuple *Tuple) PackFunc3(Arg0 []TupleQ) ([]byte, error) { + return _Tuple.abi.Pack("func3", Arg0) } // TupleTupleEvent represents a TupleEvent event raised by the Tuple contract. diff --git a/accounts/abi/bind/v2/internal/convertedv1bindtests/underscorer.go b/accounts/abi/bind/v2/internal/convertedv1bindtests/underscorer.go index 0ad5c5e3e9..7967b21423 100644 --- a/accounts/abi/bind/v2/internal/convertedv1bindtests/underscorer.go +++ b/accounts/abi/bind/v2/internal/convertedv1bindtests/underscorer.go @@ -58,8 +58,8 @@ func (_Underscorer *Underscorer) PackAllPurelyUnderscoredOutput() ([]byte, error } type AllPurelyUnderscoredOutputOutput struct { - Arg *big.Int Arg0 *big.Int + Arg1 *big.Int } func (_Underscorer *Underscorer) UnpackAllPurelyUnderscoredOutput(data []byte) (AllPurelyUnderscoredOutputOutput, error) { @@ -70,8 +70,8 @@ func (_Underscorer *Underscorer) UnpackAllPurelyUnderscoredOutput(data []byte) ( return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.Arg0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + 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 @@ -85,8 +85,8 @@ func (_Underscorer *Underscorer) PackLowerLowerCollision() ([]byte, error) { } type LowerLowerCollisionOutput struct { - Res *big.Int - Res *big.Int + Res *big.Int + Res0 *big.Int } func (_Underscorer *Underscorer) UnpackLowerLowerCollision(data []byte) (LowerLowerCollisionOutput, error) { @@ -98,7 +98,7 @@ func (_Underscorer *Underscorer) UnpackLowerLowerCollision(data []byte) (LowerLo } outstruct.Res = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.Res = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Res0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) return *outstruct, err @@ -112,8 +112,8 @@ func (_Underscorer *Underscorer) PackLowerUpperCollision() ([]byte, error) { } type LowerUpperCollisionOutput struct { - Res *big.Int - Res *big.Int + Res *big.Int + Res0 *big.Int } func (_Underscorer *Underscorer) UnpackLowerUpperCollision(data []byte) (LowerUpperCollisionOutput, error) { @@ -125,7 +125,7 @@ func (_Underscorer *Underscorer) UnpackLowerUpperCollision(data []byte) (LowerUp } outstruct.Res = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.Res = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Res0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) return *outstruct, err @@ -139,8 +139,8 @@ func (_Underscorer *Underscorer) PackPurelyUnderscoredOutput() ([]byte, error) { } type PurelyUnderscoredOutputOutput struct { - Arg *big.Int - Res *big.Int + Arg0 *big.Int + Res *big.Int } func (_Underscorer *Underscorer) UnpackPurelyUnderscoredOutput(data []byte) (PurelyUnderscoredOutputOutput, error) { @@ -151,7 +151,7 @@ func (_Underscorer *Underscorer) UnpackPurelyUnderscoredOutput(data []byte) (Pur return *outstruct, err } - outstruct.Arg = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + 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 @@ -193,8 +193,8 @@ func (_Underscorer *Underscorer) PackUpperLowerCollision() ([]byte, error) { } type UpperLowerCollisionOutput struct { - Res *big.Int - Res *big.Int + Res *big.Int + Res0 *big.Int } func (_Underscorer *Underscorer) UnpackUpperLowerCollision(data []byte) (UpperLowerCollisionOutput, error) { @@ -206,7 +206,7 @@ func (_Underscorer *Underscorer) UnpackUpperLowerCollision(data []byte) (UpperLo } outstruct.Res = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.Res = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Res0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) return *outstruct, err @@ -220,8 +220,8 @@ func (_Underscorer *Underscorer) PackUpperUpperCollision() ([]byte, error) { } type UpperUpperCollisionOutput struct { - Res *big.Int - Res *big.Int + Res *big.Int + Res0 *big.Int } func (_Underscorer *Underscorer) UnpackUpperUpperCollision(data []byte) (UpperUpperCollisionOutput, error) { @@ -233,7 +233,7 @@ func (_Underscorer *Underscorer) UnpackUpperUpperCollision(data []byte) (UpperUp } outstruct.Res = *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) - outstruct.Res = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) + outstruct.Res0 = *abi.ConvertType(out[1], new(*big.Int)).(**big.Int) return *outstruct, err