Skip to content

Commit

Permalink
Merge pull request #1477 from cosmos/add-ibc-memo-simon
Browse files Browse the repository at this point in the history
Add memo field to AminoMsgTransfer
  • Loading branch information
webmaster128 authored Sep 20, 2023
2 parents 1f97ee6 + c66efe5 commit 6423add
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
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 Amino JSON representation of
`MsgTransfer` and adapt converters. ([#1456])

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

### Changed

- Drop support for Node.js 14 and add support for Node.js 20. ([#1421])
Expand Down
3 changes: 3 additions & 0 deletions packages/stargate/src/modules/ibc/aminomessages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe("AminoTypes", () => {
revision_number: "456",
},
timeout_timestamp: "789",
memo: undefined,
},
};
expect(aminoMsg).toEqual(expected);
Expand Down Expand Up @@ -77,6 +78,7 @@ describe("AminoTypes", () => {
revision_number: undefined,
},
timeout_timestamp: undefined,
memo: undefined,
},
};
expect(aminoMsg).toEqual(expected);
Expand Down Expand Up @@ -107,6 +109,7 @@ describe("AminoTypes", () => {
receiver: "cosmos10dyr9899g6t0pelew4nvf4j5c3jcgv0r73qga5",
timeout_height: {},
timeout_timestamp: undefined,
memo: undefined,
},
};
expect(aminoMsg).toEqual(expected);
Expand Down
5 changes: 4 additions & 1 deletion packages/stargate/src/modules/ibc/aminomessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface AminoHeight {
readonly revision_height?: string;
}

// https://github.com/cosmos/ibc-go/blob/07b6a97b67d17fd214a83764cbdb2c2c3daef445/modules/apps/transfer/types/tx.pb.go#L33-L53
// https://github.com/cosmos/ibc-go/blob/a4ca39c59f770a0b6948947d5178d5f0914c3a17/modules/apps/transfer/types/tx.pb.go#L37-L56
/** Transfers fungible tokens (i.e Coins) between ICS20 enabled chains */
export interface AminoMsgTransfer extends AminoMsg {
readonly type: "cosmos-sdk/MsgTransfer";
Expand All @@ -38,6 +38,7 @@ export interface AminoMsgTransfer extends AminoMsg {
* 0 values must be omitted (https://github.com/cosmos/cosmos-sdk/blob/v0.42.7/x/ibc/applications/transfer/types/tx.pb.go#L52).
*/
readonly timeout_timestamp?: string;
readonly memo?: string;
};
}

Expand Down Expand Up @@ -73,6 +74,7 @@ export function createIbcAminoConverters(): AminoConverters {
receiver,
timeoutHeight,
timeoutTimestamp,
memo,
}: MsgTransfer): AminoMsgTransfer["value"] => ({
source_port: sourcePort,
source_channel: sourceChannel,
Expand All @@ -86,6 +88,7 @@ export function createIbcAminoConverters(): AminoConverters {
}
: {},
timeout_timestamp: omitDefault(timeoutTimestamp)?.toString(),
memo: omitDefault(memo)?.toString(),
}),
fromAmino: ({
source_port,
Expand Down

0 comments on commit 6423add

Please sign in to comment.