mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 02:42:27 +00:00
Added alphabetical sorting to type dependencies
This commit is contained in:
parent
98eb62e625
commit
89348aaf1e
1 changed files with 4 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ import (
|
|||
"math/big"
|
||||
"mime"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
|
@ -329,13 +330,9 @@ func (typedData *TypedData) Dependencies(primaryType string, found []string) []s
|
|||
func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes {
|
||||
// Get dependencies primary first, then alphabetical
|
||||
deps := typedData.Dependencies(primaryType, []string{})
|
||||
for i, dep := range deps {
|
||||
if dep == primaryType {
|
||||
deps = append(deps[:i], deps[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
deps = append([]string{primaryType}, deps...)
|
||||
slicedDeps := deps[1:]
|
||||
sort.Strings(slicedDeps)
|
||||
deps = append([]string{primaryType}, slicedDeps...)
|
||||
|
||||
// Format as a string with fields
|
||||
var buffer bytes.Buffer
|
||||
|
|
|
|||
Loading…
Reference in a new issue