accounts/abi/bind: fixed unpacking error (#22230)

There was a dormant error with structured inputs that failed unpacking.
This commit fixes the error by switching casting to the better abi.ConvertType function.
It also adds a test for calling a view function that returns a struct
This commit is contained in:
Marius van der Wijden
2021-02-10 13:12:13 +01:00
committed by GitHub
parent 27786671d2
commit cb3c7e4319
3 changed files with 68 additions and 1 deletions

View File

@ -308,7 +308,7 @@ var (
return *outstruct, err
}
{{range $i, $t := .Normalized.Outputs}}
outstruct.{{.Name}} = out[{{$i}}].({{bindtype .Type $structs}}){{end}}
outstruct.{{.Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}}){{end}}
return *outstruct, err
{{else}}