Skip to content

Commit

Permalink
wip: update e2e test for debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
boodyvo committed Nov 4, 2024
1 parent 42abf87 commit 8eda2c9
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions ethereum/eip712/eip712.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,20 @@ import (
evmtypes "github.com/evmos/ethermint/x/evm/types"
)

// Deprecated: please delete this code eventually.
func mustSortJSON(bz []byte) []byte {
var c any
err := json.Unmarshal(bz, &c)
if err != nil {
panic(err)
}
js, err := json.Marshal(c)
if err != nil {
panic(err)
}
return js
}

// ConstructUntypedEIP712Data returns the bytes to sign for a transaction.
func ConstructUntypedEIP712Data(
chainID string,
Expand All @@ -48,19 +62,25 @@ func ConstructUntypedEIP712Data(
panic(err)
}

fmt.Println("ConstructUntypedEIP712Data inInterface", inInterface)

// remove msgs from the sign doc since we will be adding them as separate fields
delete(inInterface, "msgs")

// Add messages as separate fields
for i := 0; i < len(msgs); i++ {
fmt.Println("ConstructUntypedEIP712Data msg", msgs[i])
msg := msgs[i]
legacyMsg, ok := msg.(legacytx.LegacyMsg)
if !ok {
panic(fmt.Errorf("expected %T when using amino JSON", (*legacytx.LegacyMsg)(nil)))
}
msgsBytes := json.RawMessage(legacyMsg.GetSignBytes())
inInterface[fmt.Sprintf("msg%d", i+1)] = msgsBytes

bz := legacytx.RegressionTestingAminoCodec.MustMarshalJSON(msg)
msgBytes := mustSortJSON(bz)

//legacyMsg, ok := msg.(legacytx.LegacyMsg)
//if !ok {
// panic(fmt.Errorf("expected %T when using amino JSON", (*legacytx.LegacyMsg)(nil)))
//}
//msgsBytes := json.RawMessage(legacyMsg.GetSignBytes())
inInterface[fmt.Sprintf("msg%d", i+1)] = msgBytes
}

bz, err := json.Marshal(inInterface)
Expand Down

0 comments on commit 8eda2c9

Please sign in to comment.