Skip to content

Commit

Permalink
Handle ibc transfer on SignDocAmountConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Thunnini committed Jan 10, 2024
1 parent 535ceb3 commit ed6e9b5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions packages/hooks/src/sign-doc/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Msg } from "@keplr-wallet/types";
import { AnyWithUnpacked, UnknownMessage } from "@keplr-wallet/cosmos";
import { MsgSend } from "@keplr-wallet/proto-types/cosmos/bank/v1beta1/tx";
import { MsgDelegate } from "@keplr-wallet/proto-types/cosmos/staking/v1beta1/tx";
import { MsgTransfer } from "@keplr-wallet/proto-types/ibc/applications/transfer/v1/tx";

// This config helps the fee config to calculate that the fee is enough to send with considering
// the amount in the sign doc.
Expand Down Expand Up @@ -107,6 +108,26 @@ export class SignDocAmountConfig
}
}
break;
case "cosmos-sdk/MsgTransfer": {
if (
msg.value.sender &&
msg.value.sender === this.senderConfig.sender
) {
if (
msg.value.token &&
msg.value.token.amount &&
msg.value.token.denom
) {
amount.push(
new CoinPretty(
this.chainInfo.forceFindCurrency(msg.value.token.denom),
msg.value.token.amount
)
);
}
}
break;
}
}
} catch (e) {
console.log(
Expand Down Expand Up @@ -161,6 +182,25 @@ export class SignDocAmountConfig
}
break;
}
case "/ibc.applications.transfer.v1.MsgTransfer": {
const ibcTransferMsg = msg.unpacked as MsgTransfer;
if (
ibcTransferMsg.sender &&
ibcTransferMsg.sender === this.senderConfig.sender
) {
if (ibcTransferMsg.token) {
amount.push(
new CoinPretty(
this.chainInfo.forceFindCurrency(
ibcTransferMsg.token.denom
),
ibcTransferMsg.token.amount
)
);
}
}
break;
}
}
}
} catch (e) {
Expand Down

0 comments on commit ed6e9b5

Please sign in to comment.