Skip to content

Commit

Permalink
fix: add sorting of EIP712 msg types (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
pythonberg1997 authored Jun 8, 2023
1 parent 45d9192 commit a19185c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions x/auth/tx/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"math/big"
"reflect"
"sort"
"strings"
"time"

Expand Down Expand Up @@ -148,12 +149,12 @@ func GetMsgTypes(signerData signing.SignerData, tx sdk.Tx, typedChainID *big.Int
"Fee": {
{Name: "amount", Type: "Coin[]"},
{Name: "gas_limit", Type: "uint256"},
{Name: "payer", Type: "string"},
{Name: "granter", Type: "string"},
{Name: "payer", Type: "string"},
},
"Coin": {
{Name: "denom", Type: "string"},
{Name: "amount", Type: "uint256"},
{Name: "denom", Type: "string"},
},
}
for i, msg := range protoTx.GetMsgs() {
Expand Down Expand Up @@ -233,6 +234,13 @@ func WrapTxToTypedData(
}
delete(txData, "msgs")

// sort the msg types
for _, val := range msgTypes {
sort.Slice(val, func(i, j int) bool {
return val[i].Name < val[j].Name
})
}

tempDomain := *domain
tempDomain.ChainId = math.NewHexOrDecimal256(int64(chainID))
typedData := apitypes.TypedData{
Expand Down

0 comments on commit a19185c

Please sign in to comment.