|
|
@ -25,6 +25,7 @@ import ( |
|
|
|
"math/big" |
|
|
|
"math/big" |
|
|
|
"reflect" |
|
|
|
"reflect" |
|
|
|
"regexp" |
|
|
|
"regexp" |
|
|
|
|
|
|
|
"slices" |
|
|
|
"sort" |
|
|
|
"sort" |
|
|
|
"strconv" |
|
|
|
"strconv" |
|
|
|
"strings" |
|
|
|
"strings" |
|
|
@ -386,16 +387,8 @@ func (typedData *TypedData) HashStruct(primaryType string, data TypedDataMessage |
|
|
|
// Dependencies returns an array of custom types ordered by their hierarchical reference tree
|
|
|
|
// Dependencies returns an array of custom types ordered by their hierarchical reference tree
|
|
|
|
func (typedData *TypedData) Dependencies(primaryType string, found []string) []string { |
|
|
|
func (typedData *TypedData) Dependencies(primaryType string, found []string) []string { |
|
|
|
primaryType = strings.TrimSuffix(primaryType, "[]") |
|
|
|
primaryType = strings.TrimSuffix(primaryType, "[]") |
|
|
|
includes := func(arr []string, str string) bool { |
|
|
|
|
|
|
|
for _, obj := range arr { |
|
|
|
|
|
|
|
if obj == str { |
|
|
|
|
|
|
|
return true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if includes(found, primaryType) { |
|
|
|
if slices.Contains(found, primaryType) { |
|
|
|
return found |
|
|
|
return found |
|
|
|
} |
|
|
|
} |
|
|
|
if typedData.Types[primaryType] == nil { |
|
|
|
if typedData.Types[primaryType] == nil { |
|
|
@ -404,7 +397,7 @@ func (typedData *TypedData) Dependencies(primaryType string, found []string) []s |
|
|
|
found = append(found, primaryType) |
|
|
|
found = append(found, primaryType) |
|
|
|
for _, field := range typedData.Types[primaryType] { |
|
|
|
for _, field := range typedData.Types[primaryType] { |
|
|
|
for _, dep := range typedData.Dependencies(field.Type, found) { |
|
|
|
for _, dep := range typedData.Dependencies(field.Type, found) { |
|
|
|
if !includes(found, dep) { |
|
|
|
if !slices.Contains(found, dep) { |
|
|
|
found = append(found, dep) |
|
|
|
found = append(found, dep) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|