From dd88bd82c9453b01e5d8b659bf59e44396a1f572 Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Thu, 7 May 2020 09:24:10 +0200 Subject: [PATCH] accounts/abi/bind: add void if no return args specified (#21002) * accounts/abi/bind: add void if no return args specified Currently the java generator generates invalid input on pure/view functions that have no return type. e.g. `function f(uint u) view public {}` This is not a problem in practice as people rarely ever write functions like this. * accounts/abi/bind: use elseif instead of nested if --- accounts/abi/bind/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accounts/abi/bind/template.go b/accounts/abi/bind/template.go index 555c1803ea..ec36409c28 100644 --- a/accounts/abi/bind/template.go +++ b/accounts/abi/bind/template.go @@ -624,7 +624,7 @@ import java.util.*; // {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}. // // Solidity: {{.Original.String}} - public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception { + public {{if gt (len .Normalized.Outputs) 1}}{{capitalise .Normalized.Name}}Results{{else if eq (len .Normalized.Outputs) 0}}void{{else}}{{range .Normalized.Outputs}}{{bindtype .Type $structs}}{{end}}{{end}} {{.Normalized.Name}}(CallOpts opts{{range .Normalized.Inputs}}, {{bindtype .Type $structs}} {{.Name}}{{end}}) throws Exception { Interfaces args = Geth.newInterfaces({{(len .Normalized.Inputs)}}); {{range $index, $item := .Normalized.Inputs}}Interface arg{{$index}} = Geth.newInterface();arg{{$index}}.set{{namedtype (bindtype .Type $structs) .Type}}({{.Name}});args.set({{$index}},arg{{$index}}); {{end}}