diff options
author | Péter Szilágyi <peterke@gmail.com> | 2016-03-31 17:45:30 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2016-03-31 17:45:30 +0800 |
commit | 787d688c2ff4e272fb7d73fd8f3e611685fe957e (patch) | |
tree | 9024556863aaf0d7c7bb6d410f29a302c3af3736 | |
parent | b813e4d411989a5a1f3606bd69fb888062dbed88 (diff) | |
download | dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar.gz dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar.bz2 dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar.lz dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar.xz dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.tar.zst dexon-787d688c2ff4e272fb7d73fd8f3e611685fe957e.zip |
accounts/abi/bind: use anonymous ephemeral call result structs
-rw-r--r-- | accounts/abi/bind/template.go | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index 01af19248..f1a10137c 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -147,22 +147,17 @@ package {{.Package}} } {{range .Calls}} - {{if .Structured}} - // {{$contract.Type}}{{.Normalized.Name}}Result is the result of the {{.Normalized.Name}} invocation. - type {{$contract.Type}}{{.Normalized.Name}}Result struct { - {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}} - {{end}} - } - {{end}} - // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. // // Solidity: {{.Original.String}} - func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}{{$contract.Type}}{{.Normalized.Name}}Result,{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}},{{end}}{{end}} error) { - var ( - {{if .Structured}}ret = new({{$contract.Type}}{{.Normalized.Name}}Result){{else}}{{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type}}) - {{end}}{{end}} - ) + func (_{{$contract.Type}} *{{$contract.Type}}Caller) {{.Normalized.Name}}(opts *bind.CallOpts {{range .Normalized.Inputs}}, {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} },{{else}}{{range .Normalized.Outputs}}{{bindtype .Type}},{{end}}{{end}} error) { + {{if .Structured}}ret := new(struct{ + {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}} + {{end}} + }){{else}}var ( + {{range $i, $_ := .Normalized.Outputs}}ret{{$i}} = new({{bindtype .Type}}) + {{end}} + ){{end}} out := {{if .Structured}}ret{{else}}{{if eq (len .Normalized.Outputs) 1}}ret0{{else}}[]interface{}{ {{range $i, $_ := .Normalized.Outputs}}ret{{$i}}, {{end}} @@ -174,14 +169,14 @@ package {{.Package}} // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. // // Solidity: {{.Original.String}} - func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}{{$contract.Type}}{{.Normalized.Name}}Result, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { + func (_{{$contract.Type}} *{{$contract.Type}}Session) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) } // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.Id}}. // // Solidity: {{.Original.String}} - func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}{{$contract.Type}}{{.Normalized.Name}}Result, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { + func (_{{$contract.Type}} *{{$contract.Type}}CallerSession) {{.Normalized.Name}}({{range $i, $_ := .Normalized.Inputs}}{{if ne $i 0}},{{end}} {{.Name}} {{bindtype .Type}} {{end}}) ({{if .Structured}}struct{ {{range .Normalized.Outputs}}{{.Name}} {{bindtype .Type}};{{end}} }, {{else}} {{range .Normalized.Outputs}}{{bindtype .Type}},{{end}} {{end}} error) { return _{{$contract.Type}}.Contract.{{.Normalized.Name}}(&_{{$contract.Type}}.CallOpts {{range .Normalized.Inputs}}, {{.Name}}{{end}}) } {{end}} |