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
bf752cf6e2
commit
9364b324d3
1 changed files with 4 additions and 7 deletions
|
|
@ -24,6 +24,7 @@ import (
|
||||||
"math/big"
|
"math/big"
|
||||||
"mime"
|
"mime"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"unicode"
|
"unicode"
|
||||||
|
|
@ -329,13 +330,9 @@ func (typedData *TypedData) Dependencies(primaryType string, found []string) []s
|
||||||
func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes {
|
func (typedData *TypedData) EncodeType(primaryType string) hexutil.Bytes {
|
||||||
// Get dependencies primary first, then alphabetical
|
// Get dependencies primary first, then alphabetical
|
||||||
deps := typedData.Dependencies(primaryType, []string{})
|
deps := typedData.Dependencies(primaryType, []string{})
|
||||||
for i, dep := range deps {
|
slicedDeps := deps[1:]
|
||||||
if dep == primaryType {
|
sort.Strings(slicedDeps)
|
||||||
deps = append(deps[:i], deps[i+1:]...)
|
deps = append([]string{primaryType}, slicedDeps...)
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
deps = append([]string{primaryType}, deps...)
|
|
||||||
|
|
||||||
// Format as a string with fields
|
// Format as a string with fields
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue