Skip to content

Commit 804525a

Browse files
aaronbuchwaldblakehhuynh
authored andcommitted
Replace fmt.Errorf with errors.New in abi argument (ethereum#25181)
Replace unnecessary fmt.Errorf with errors.New in accounts/abi/argument.go
1 parent a3f1387 commit 804525a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: accounts/abi/argument.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package abi
1818

1919
import (
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"reflect"
2324
"strings"
@@ -79,7 +80,7 @@ func (arguments Arguments) isTuple() bool {
7980
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
8081
if len(data) == 0 {
8182
if len(arguments.NonIndexed()) != 0 {
82-
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
83+
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
8384
}
8485
return make([]interface{}, 0), nil
8586
}
@@ -90,11 +91,11 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
9091
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
9192
// Make sure map is not nil
9293
if v == nil {
93-
return fmt.Errorf("abi: cannot unpack into a nil map")
94+
return errors.New("abi: cannot unpack into a nil map")
9495
}
9596
if len(data) == 0 {
9697
if len(arguments.NonIndexed()) != 0 {
97-
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
98+
return errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
9899
}
99100
return nil // Nothing to unmarshal, return
100101
}
@@ -116,7 +117,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
116117
}
117118
if len(values) == 0 {
118119
if len(arguments.NonIndexed()) != 0 {
119-
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
120+
return errors.New("abi: attempting to copy no values while arguments are expected")
120121
}
121122
return nil // Nothing to copy, return
122123
}

0 commit comments

Comments
 (0)