Skip to content

Commit 2958387

Browse files
committed
fix abigen v2
1 parent 0d9c49c commit 2958387

File tree

6 files changed

+50
-134
lines changed

6 files changed

+50
-134
lines changed

accounts/abi/abigen/source2.go.tpl

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,8 @@ var (
9393
// the contract method with ID 0x{{printf "%x" .Original.ID}}.
9494
//
9595
// Solidity: {{.Original.String}}
96-
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) []byte {
97-
enc, err := {{ decapitalise $contract.Type}}.abi.Pack("{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
98-
if err != nil {
99-
panic(err)
100-
}
101-
return enc
96+
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) ([]byte, error) {
97+
return {{ decapitalise $contract.Type}}.abi.Pack("{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
10298
}
10399

104100
{{/* Unpack method is needed only when there are return args */}}
@@ -117,14 +113,14 @@ var (
117113
//
118114
// Solidity: {{.Original.String}}
119115
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Unpack{{.Normalized.Name}}(data []byte) (
120-
{{- if .Structured}} {{.Normalized.Name}}Output,{{else}}
116+
{{- if .Structured}} *{{.Normalized.Name}}Output,{{else}}
121117
{{- range .Normalized.Outputs}} {{bindtype .Type $structs}},{{- end }}
122118
{{- end }} error) {
123119
out, err := {{ decapitalise $contract.Type}}.abi.Unpack("{{.Original.Name}}", data)
124120
{{- if .Structured}}
125121
outstruct := new({{.Normalized.Name}}Output)
126122
if err != nil {
127-
return *outstruct, err
123+
return outstruct, nil
128124
}
129125
{{- range $i, $t := .Normalized.Outputs}}
130126
{{- if ispointertype .Type}}
@@ -133,8 +129,7 @@ var (
133129
outstruct.{{capitalise .Name}} = *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}})
134130
{{- end }}
135131
{{- end }}
136-
return *outstruct, err
137-
{{else}}
132+
return outstruct, nil{{else}}
138133
if err != nil {
139134
return {{range $i, $_ := .Normalized.Outputs}}{{if ispointertype .Type}}new({{underlyingbindtype .Type }}), {{else}}*new({{bindtype .Type $structs}}), {{end}}{{end}} err
140135
}
@@ -145,8 +140,7 @@ var (
145140
out{{$i}} := *abi.ConvertType(out[{{$i}}], new({{bindtype .Type $structs}})).(*{{bindtype .Type $structs}})
146141
{{- end }}
147142
{{- end}}
148-
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} nil
149-
{{- end}}
143+
return {{range $i, $t := .Normalized.Outputs}}out{{$i}}, {{end}} nil{{- end}}
150144
}
151145
{{end}}
152146
{{end}}

accounts/abi/bind/v2/internal/contracts/db/bindings.go

Lines changed: 16 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts/abi/bind/v2/internal/contracts/events/bindings.go

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts/abi/bind/v2/internal/contracts/nested_libraries/bindings.go

Lines changed: 16 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts/abi/bind/v2/internal/contracts/solc_errors/bindings.go

Lines changed: 6 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

accounts/abi/bind/v2/internal/contracts/uint256arrayreturn/bindings.go

Lines changed: 2 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)