Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Refactor to use sender hex not bech32
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidNix committed Sep 14, 2023
1 parent f2b813b commit b793094
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion x/mailbox/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (k Keeper) Dispatch(goCtx context.Context, msg *types.MsgDispatch) (*types.
sdk.NewAttribute(types.AttributeKeyNonce, strconv.FormatUint(uint64(nonce), 10)),
sdk.NewAttribute(types.AttributeKeyOrigin, strconv.FormatUint(uint64(origin), 10)),
sdk.NewAttribute(types.AttributeKeyRecipientAddress, msg.RecipientAddress),
sdk.NewAttribute(types.AttributeKeySender, msg.Sender),
sdk.NewAttribute(types.AttributeKeySender, hexutil.Encode(sender)),
sdk.NewAttribute(types.AttributeKeyVersion, strconv.FormatUint(0, 10)), // TODO(nix): How to determine version?
),
sdk.NewEvent(
Expand Down
13 changes: 6 additions & 7 deletions x/mailbox/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (suite *KeeperTestSuite) TestDispatch() {
id = "0x806d81a5b017cc51297bb545bc037f39ceecefab8041766c9b733900c9a01242"
sender := "cosmos14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s4hmalr"
senderBytes := sdk.MustAccAddressFromBech32(sender).Bytes()
senderHex = hexutil.Encode(senderBytes)
senderHex = hexutil.Encode(senderBytes) // no padding

recipientBech32 := "cosmos10qa7yajp3fp869mdegtpap5zg056exja3chkw5"
recipientBytes := sdk.MustAccAddressFromBech32(recipientBech32).Bytes()
Expand All @@ -104,9 +104,8 @@ func (suite *KeeperTestSuite) TestDispatch() {
"success with account as sender",
func() {
id = "0x0c4024fb3262d8852b1fc5caa9f73f91b9375a1cbe51f6da52d192d272623fd1"
sender := "cosmos17lklk2z0gevmdx4tvjac7g7t9prqczg6p6nuw9"
senderBytes := sdk.MustAccAddressFromBech32(sender).Bytes()
senderHex = hexutil.Encode(senderBytes)
senderHex = "0x000000000000000000000000f7edfb284f4659b69aab64bb8f23cb28460c091a"
sender := sdk.MustBech32ifyAddressBytes("cosmos", hexutil.MustDecode(senderHex))

recipientBech32 := "cosmos10qa7yajp3fp869mdegtpap5zg056exja3chkw5"
recipientBytes := sdk.MustAccAddressFromBech32(recipientBech32).Bytes()
Expand Down Expand Up @@ -138,7 +137,7 @@ func (suite *KeeperTestSuite) TestDispatch() {
"success with hyperlane explorer data w/o sender/recipient padding",
func() {
id = "0x82fbf348d68e34903627d1f57fa3227211e35134e2a613ce6b78ce2d42e17198"
senderHex = "0x2b0860e52244f03e59f12cfe413d6a29bc30b893"
senderHex = "0x0000000000000000000000002b0860e52244f03e59f12cfe413d6a29bc30b893"
senderBytes := hexutil.MustDecode(senderHex)
senderBech32 := sdk.MustBech32ifyAddressBytes("cosmos", senderBytes)
recipient := "0x76a2f655352752af6ce9b03932b9090009dc5d0c"
Expand All @@ -153,7 +152,7 @@ func (suite *KeeperTestSuite) TestDispatch() {
"fails with wrong id match",
func() {
id = "0x82fbf348d68e34903627d1f57fa3227211e35134e2a613ce6b78ce2d42e17198"
senderHex = "0x2b0860e52244f03e59f12cfe413d6a29bc30b893"
senderHex = "0x0000000000000000000000002b0860e52244f03e59f12cfe413d6a29bc30b893"
senderBytes := hexutil.MustDecode(senderHex)
senderBech32 := sdk.MustBech32ifyAddressBytes("cosmos", senderBytes)
recipient := "0x76a2f655352752af6ce9b03932b9090009dc5d0c"
Expand Down Expand Up @@ -197,7 +196,7 @@ func (suite *KeeperTestSuite) TestDispatch() {
sdk.NewAttribute(types.AttributeKeyNonce, "0"), // TODO: Nonce is always zero
sdk.NewAttribute(types.AttributeKeyOrigin, strconv.FormatUint(testOriginDomain, 10)),
sdk.NewAttribute(types.AttributeKeyRecipientAddress, msg.RecipientAddress),
sdk.NewAttribute(types.AttributeKeySender, msg.Sender),
sdk.NewAttribute(types.AttributeKeySender, senderHex),
sdk.NewAttribute(types.AttributeKeyVersion, "0"), // TODO(nix): Figure out version
),
sdk.NewEvent(
Expand Down

0 comments on commit b793094

Please sign in to comment.