Added alphabetical sorting to type dependencies

This commit is contained in:
Paul Berg 2018-11-09 21:00:07 +02:00 committed by Martin Holst Swende
parent 98eb62e625
commit 89348aaf1e
No known key found for this signature in database
GPG key ID: 683B438C05A5DDF0

View file

@ -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