Replace fmt.Errorf with errors.New in abi argument (#25181)

Replace unnecessary fmt.Errorf with errors.New in accounts/abi/argument.go
pull/25230/head
aaronbuchwald 2 years ago committed by GitHub
parent de1cecb22e
commit 953a29f5fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      accounts/abi/argument.go

@ -18,6 +18,7 @@ package abi
import (
"encoding/json"
"errors"
"fmt"
"reflect"
"strings"
@ -79,7 +80,7 @@ func (arguments Arguments) isTuple() bool {
func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
if len(data) == 0 {
if len(arguments.NonIndexed()) != 0 {
return nil, fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
return nil, errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
return make([]interface{}, 0), nil
}
@ -90,11 +91,11 @@ func (arguments Arguments) Unpack(data []byte) ([]interface{}, error) {
func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error {
// Make sure map is not nil
if v == nil {
return fmt.Errorf("abi: cannot unpack into a nil map")
return errors.New("abi: cannot unpack into a nil map")
}
if len(data) == 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to unmarshall an empty string while arguments are expected")
return errors.New("abi: attempting to unmarshall an empty string while arguments are expected")
}
return nil // Nothing to unmarshal, return
}
@ -116,7 +117,7 @@ func (arguments Arguments) Copy(v interface{}, values []interface{}) error {
}
if len(values) == 0 {
if len(arguments.NonIndexed()) != 0 {
return fmt.Errorf("abi: attempting to copy no values while arguments are expected")
return errors.New("abi: attempting to copy no values while arguments are expected")
}
return nil // Nothing to copy, return
}

Loading…
Cancel
Save