Skip to content

Commit

Permalink
Add missing memo field to fromAmino implementation for MsgTransfer
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Oct 25, 2023
1 parent 550a9fc commit 9d5aece
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to

## [Unreleased]

### Fixed

- @cosmjs/stargate: Add missing memo field to `fromAmino` implementation for
`MsgTransfer`. ([#1493])

[#1493]: https://github.com/cosmos/cosmjs/issues/1493

## [0.31.2] - 2023-10-24

### Fixed
Expand Down
38 changes: 38 additions & 0 deletions packages/stargate/src/modules/ibc/aminomessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,43 @@ describe("AminoTypes", () => {
});
});

it("works for MsgTransfer with memo", () => {
const aminoMsg: AminoMsgTransfer = {
type: "cosmos-sdk/MsgTransfer",
value: {
source_port: "testport",
source_channel: "testchannel",
token: coin(1234, "utest"),
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeout_height: {
revision_height: "123",
revision_number: "456",
},
timeout_timestamp: "789",
memo: "Hack me",
},
};
const msg = new AminoTypes(createIbcAminoConverters()).fromAmino(aminoMsg);
const expectedValue: MsgTransfer = {
sourcePort: "testport",
sourceChannel: "testchannel",
token: coin(1234, "utest"),
sender: "cosmos1pkptre7fdkl6gfrzlesjjvhxhlc3r4gmmk8rs6",
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeoutHeight: {
revisionHeight: Long.fromString("123", true),
revisionNumber: Long.fromString("456", true),
},
timeoutTimestamp: Long.fromString("789", true),
memo: "Hack me",
};
expect(msg).toEqual({
typeUrl: "/ibc.applications.transfer.v1.MsgTransfer",
value: expectedValue,
});
});

it("works for MsgTransfer with default values", () => {
const aminoMsg: AminoMsgTransfer = {
type: "cosmos-sdk/MsgTransfer",
Expand All @@ -167,6 +204,7 @@ describe("AminoTypes", () => {
// revision_number omitted
},
// timeout_timestamp omitted
// memo omitted
},
};
const msg = new AminoTypes(createIbcAminoConverters()).fromAmino(aminoMsg);
Expand Down
2 changes: 2 additions & 0 deletions packages/stargate/src/modules/ibc/aminomessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export function createIbcAminoConverters(): AminoConverters {
receiver,
timeout_height,
timeout_timestamp,
memo,
}: AminoMsgTransfer["value"]): MsgTransfer =>
MsgTransfer.fromPartial({
sourcePort: source_port,
Expand All @@ -112,6 +113,7 @@ export function createIbcAminoConverters(): AminoConverters {
}
: undefined,
timeoutTimestamp: Long.fromString(timeout_timestamp || "0", true),
memo: memo ?? "",
}),
},
};
Expand Down

0 comments on commit 9d5aece

Please sign in to comment.