accounts/abi/abigen: remove error in v2 Pack function

This error cannot occur because abigen is in charge of selecting the Go types that will be
encoded, and it only ever chooses types which are representable in ABI.
This commit is contained in:
Felix Lange 2025-01-23 13:47:55 +01:00
parent d5323011af
commit dbe60f0b67

View file

@ -79,8 +79,12 @@ var (
// {{.Normalized.Name}} is a free data retrieval call binding the contract method 0x{{printf "%x" .Original.ID}}.
//
// Solidity: {{.Original.String}}
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) ([]byte, error) {
return {{ decapitalise $contract.Type}}.abi.Pack("{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
func ({{ decapitalise $contract.Type}} *{{$contract.Type}}) Pack{{.Normalized.Name}}({{range .Normalized.Inputs}} {{.Name}} {{bindtype .Type $structs}}, {{end}}) []byte {
enc, err := {{ decapitalise $contract.Type}}.abi.Pack("{{.Original.Name}}" {{range .Normalized.Inputs}}, {{.Name}}{{end}})
if err != nil {
panic(err)
}
return enc
}
{{/* Unpack method is needed only when there are return args */}}