Skip to content

Commit cfc7d06

Browse files
authored
signer/core/apitypes: use slices.Contains (#29474)
1 parent 0dc09da commit cfc7d06

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

log/handler.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func JSONHandler(wr io.Writer) slog.Handler {
118118
return JSONHandlerWithLevel(wr, levelMaxVerbosity)
119119
}
120120

121-
// JSONHandler returns a handler which prints records in JSON format that are less than or equal to
121+
// JSONHandlerWithLevel returns a handler which prints records in JSON format that are less than or equal to
122122
// the specified verbosity level.
123123
func JSONHandlerWithLevel(wr io.Writer, level slog.Level) slog.Handler {
124124
return slog.NewJSONHandler(wr, &slog.HandlerOptions{

signer/core/apitypes/types.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"math/big"
2626
"reflect"
2727
"regexp"
28+
"slices"
2829
"sort"
2930
"strconv"
3031
"strings"
@@ -386,16 +387,8 @@ func (typedData *TypedData) HashStruct(primaryType string, data TypedDataMessage
386387
// Dependencies returns an array of custom types ordered by their hierarchical reference tree
387388
func (typedData *TypedData) Dependencies(primaryType string, found []string) []string {
388389
primaryType = strings.TrimSuffix(primaryType, "[]")
389-
includes := func(arr []string, str string) bool {
390-
for _, obj := range arr {
391-
if obj == str {
392-
return true
393-
}
394-
}
395-
return false
396-
}
397390

398-
if includes(found, primaryType) {
391+
if slices.Contains(found, primaryType) {
399392
return found
400393
}
401394
if typedData.Types[primaryType] == nil {
@@ -404,7 +397,7 @@ func (typedData *TypedData) Dependencies(primaryType string, found []string) []s
404397
found = append(found, primaryType)
405398
for _, field := range typedData.Types[primaryType] {
406399
for _, dep := range typedData.Dependencies(field.Type, found) {
407-
if !includes(found, dep) {
400+
if !slices.Contains(found, dep) {
408401
found = append(found, dep)
409402
}
410403
}

0 commit comments

Comments
 (0)