diff --git a/lib/txMsgHelpers.ts b/lib/txMsgHelpers.ts index cd35c2c..7ef92e2 100644 --- a/lib/txMsgHelpers.ts +++ b/lib/txMsgHelpers.ts @@ -5,6 +5,7 @@ import { TxMsgDelegate, TxMsgRedelegate, TxMsgSend, + TxMsgSetWithdrawAddress, TxMsgUndelegate, } from "../types/txMsg"; @@ -58,4 +59,19 @@ const isTxMsgClaimRewards = (msg: TxMsg | EncodeObject): msg is TxMsgClaimReward !!msg.value.delegatorAddress && !!msg.value.validatorAddress; -export { isTxMsgSend, isTxMsgDelegate, isTxMsgUndelegate, isTxMsgRedelegate, isTxMsgClaimRewards }; +const isTxMsgSetWithdrawAddress = (msg: TxMsg | EncodeObject): msg is TxMsgSetWithdrawAddress => + msg.typeUrl === "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress" && + "value" in msg && + "delegatorAddress" in msg.value && + "withdrawAddress" in msg.value && + !!msg.value.delegatorAddress && + !!msg.value.withdrawAddress; + +export { + isTxMsgSend, + isTxMsgDelegate, + isTxMsgUndelegate, + isTxMsgRedelegate, + isTxMsgClaimRewards, + isTxMsgSetWithdrawAddress, +}; diff --git a/types/txMsg.ts b/types/txMsg.ts index b3d2ed4..30dbb4e 100644 --- a/types/txMsg.ts +++ b/types/txMsg.ts @@ -1,11 +1,18 @@ -export type TxType = "send" | "delegate" | "undelegate" | "redelegate" | "claimRewards"; +export type TxType = + | "send" + | "delegate" + | "undelegate" + | "redelegate" + | "claimRewards" + | "setWithdrawAddress"; export type TxMsg = | TxMsgSend | TxMsgDelegate | TxMsgUndelegate | TxMsgRedelegate - | TxMsgClaimRewards; + | TxMsgClaimRewards + | TxMsgSetWithdrawAddress; export interface TxMsgSend { readonly typeUrl: "/cosmos.bank.v1beta1.MsgSend"; @@ -51,3 +58,11 @@ export interface TxMsgClaimRewards { readonly validatorAddress: string; }; } + +export interface TxMsgSetWithdrawAddress { + readonly typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress"; + readonly value: { + readonly delegatorAddress: string; + readonly withdrawAddress: string; + }; +}