diff --git a/accounts/abi/bind/bind_test.go b/accounts/abi/bind/bind_test.go index 7008ec04ed50..ac88b0c3df47 100644 --- a/accounts/abi/bind/bind_test.go +++ b/accounts/abi/bind/bind_test.go @@ -871,17 +871,8 @@ var bindTests = []struct { } } `, - []string{"60806040523480156100115760006000fd5b50610017565b61016e806100266000396000f3fe60806040526004361061000d575b36610081575b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15b005b34801561008e5760006000fd5b505b606036600082377f9043988963722edecc2099c75b0af0ff76af14ffca42ed6bce059a20a2a9f986816040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fa5780820151818401525b6020810190506100de565b50505050905090810190601f1680156101275780820380516001836020036101000a031916815260200191505b509250505060405180910390a1505b00fea26469706673582212205643ca37f40c2b352dc541f42e9e6720de065de756324b7fcc9fb1d67eda4a7d64736f6c63430006040033"}, - []string{`[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Fallback","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]`}, - ` - "bytes" - "math/big" - - "github.com/ethereum/go-ethereum/accounts/abi/bind" - "github.com/ethereum/go-ethereum/accounts/abi/bind/backends" - "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/crypto" - `, + "60806040523480156100115760006000fd5b50610017565b61016e806100266000396000f3fe60806040526004361061000d575b36610081575b7f88a5966d370b9919b20f3e2c13ff65706f196a4e32cc2c12bf57088f885258743334604051808373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020018281526020019250505060405180910390a15b005b34801561008e5760006000fd5b505b606036600082377f9043988963722edecc2099c75b0af0ff76af14ffca42ed6bce059a20a2a9f986816040518080602001828103825283818151815260200191508051906020019080838360005b838110156100fa5780820151818401525b6020810190506100de565b50505050905090810190601f1680156101275780820380516001836020036101000a031916815260200191505b509250505060405180910390a1505b00fea26469706673582212205643ca37f40c2b352dc541f42e9e6720de065de756324b7fcc9fb1d67eda4a7d64736f6c63430006040033", + `[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"Fallback","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"addr","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Received","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"stateMutability":"payable","type":"receive"}]`, ` key, _ := crypto.GenerateKey() addr := crypto.PubkeyToAddress(key.PublicKey) @@ -937,10 +928,6 @@ var bindTests = []struct { t.Fatal("Expect to receive event emitted by fallback") } `, - nil, - nil, - nil, - nil, }, } diff --git a/accounts/abi/method.go b/accounts/abi/method.go index f8f1d4a1c917..b6bdea915ed4 100644 --- a/accounts/abi/method.go +++ b/accounts/abi/method.go @@ -85,16 +85,18 @@ func (method Method) Sig() string { } func (method Method) String() string { + var ( + outputNames = make([]string, len(method.Outputs)) + ) inputs := make([]string, len(method.Inputs)) for i, input := range method.Inputs { - inputs[i] = fmt.Sprintf("%v %v", input.Name, input.Type) + inputs[i] = fmt.Sprintf("%v %v", input.Type, input.Name) } - outputs := make([]string, len(method.Outputs)) for i, output := range method.Outputs { + outputNames[i] = output.Type.String() if len(output.Name) > 0 { - outputs[i] = fmt.Sprintf("%v ", output.Name) + outputNames[i] += fmt.Sprintf(" %v", output.Name) } - outputs[i] += output.Type.String() } // Extract meaningful state mutability of solidity method. // If it's default value, never print it. @@ -111,7 +113,9 @@ func (method Method) String() string { } else if method.IsReceive { identity = "receive" } - return fmt.Sprintf("%v(%v) %sreturns(%v)", identity, strings.Join(inputs, ", "), state, strings.Join(outputs, ", ")) + + return fmt.Sprintf("%v(%v) %sreturns(%v)", identity, strings.Join(inputs, ", "), state, strings.Join(outputNames, ", ")) + } // ID returns the canonical representation of the method's signature used by the diff --git a/accounts/abi/method_test.go b/accounts/abi/method_test.go index cf41878423a9..9feb3402fcd2 100644 --- a/accounts/abi/method_test.go +++ b/accounts/abi/method_test.go @@ -63,10 +63,7 @@ func TestMethodString(t *testing.T) { method: "tupleSlice", expectation: "function tupleSlice((uint256,uint256)[] a) returns()", }, - { - method: "complexTuple", - expectation: "function complexTuple((uint256,uint256)[5][] a) returns()", - }, + //TODO:enable struct golang binding generation (18491) { method: "fallback", expectation: "fallback() returns()",