Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add sorting of EIP712 msg types #218

Merged
merged 1 commit into from
Jun 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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