diff --git a/packages/stargate/src/aminotypes.ts b/packages/stargate/src/aminotypes.ts index d4b31872..646a7d8b 100644 --- a/packages/stargate/src/aminotypes.ts +++ b/packages/stargate/src/aminotypes.ts @@ -3,6 +3,7 @@ import { AminoMsg, decodeBech32Pubkey, encodeBech32Pubkey } from "@cosmjs/amino" import { fromBase64, toBase64 } from "@cosmjs/encoding"; import { EncodeObject } from "@cosmjs/proto-signing"; import { assertDefinedAndNotNull } from "@cosmjs/utils"; +import Long from "long"; import { AminoMsgBeginRedelegate, @@ -13,6 +14,7 @@ import { AminoMsgMultiSend, AminoMsgSend, AminoMsgSetWithdrawAddress, + AminoMsgTransfer, AminoMsgUndelegate, AminoMsgWithdrawDelegatorReward, AminoMsgWithdrawValidatorCommission, @@ -31,6 +33,7 @@ import { MsgEditValidator, MsgUndelegate, } from "./codec/cosmos/staking/v1beta1/tx"; +import { MsgTransfer } from "./codec/ibc/applications/transfer/v1/tx"; export interface AminoConverter { readonly aminoType: string; @@ -324,6 +327,53 @@ function createDefaultTypes(prefix: string): Record { amount: amount, }), }, + "/ibc.applications.transfer.v1.MsgTransfer": { + aminoType: "cosmos-sdk/MsgTransfer", + toAmino: ({ + sourcePort, + sourceChannel, + token, + sender, + receiver, + timeoutHeight, + timeoutTimestamp, + }: MsgTransfer): AminoMsgTransfer["value"] => ({ + source_port: sourcePort, + source_channel: sourceChannel, + token: token, + sender: sender, + receiver: receiver, + timeout_height: timeoutHeight + ? { + revision_height: timeoutHeight.revisionHeight.toNumber(), + revision_number: timeoutHeight.revisionNumber.toNumber(), + } + : undefined, + timeout_timestamp: timeoutTimestamp.toNumber(), + }), + fromAmino: ({ + source_port, + source_channel, + token, + sender, + receiver, + timeout_height, + timeout_timestamp, + }: AminoMsgTransfer["value"]): MsgTransfer => ({ + sourcePort: source_port, + sourceChannel: source_channel, + token: token, + sender: sender, + receiver: receiver, + timeoutHeight: timeout_height + ? { + revisionHeight: Long.fromNumber(timeout_height.revision_height, true), + revisionNumber: Long.fromNumber(timeout_height.revision_number, true), + } + : undefined, + timeoutTimestamp: Long.fromNumber(timeout_timestamp, true), + }), + }, }; }