import React from "react" ; import { AccountSetOpts , CosmosMsgOpts , SecretMsgOpts , } from "@keplr-wallet/stores" ; import { MessageObj , MsgBeginRedelegate , MsgDelegate , MsgSend , MsgTransfer , MsgUndelegate , MsgVote , MsgWithdrawDelegatorReward , renderMsgSend , renderUnknownMessage , renderMsgTransfer , renderMsgBeginRedelegate , renderMsgUndelegate , renderMsgDelegate , renderMsgWithdrawDelegatorReward , renderMsgVote , } from "./messages" ; import { AppCurrency } from "@keplr-wallet/types" ; export function renderAminoMessage ( msgOpts , msg , currencies ) { if ( msg . type === msgOpts . send . native . type ) { const value = msg . value as MsgSend [ "value" ] ; return renderMsgSend ( currencies , value . amount , value . to_address ) ; } if ( msg . type === msgOpts . ibcTransfer . type ) { const value = msg . value as MsgTransfer [ "value" ] ; return renderMsgTransfer ( currencies , value . token , value . receiver , value . source_channel ) ; } if ( msg . type === msgOpts . redelegate . type ) { const value = msg . value as MsgBeginRedelegate [ "value" ] ; return renderMsgBeginRedelegate ( currencies , value . amount , value . validator_src_address , value . validator_dst_address ) ; } if ( msg . type === msgOpts . undelegate . type ) { const value = msg . value as MsgUndelegate [ "value" ] ; return renderMsgUndelegate ( currencies , value . amount , value . validator_address ) ; } if ( msg . type === msgOpts . delegate . type ) { const value = msg . value as MsgDelegate [ "value" ] ; return renderMsgDelegate ( currencies , value . amount , value . validator_address ) ; } if ( msg . type === msgOpts . withdrawRewards . type ) { const value = msg . value as MsgWithdrawDelegatorReward [ "value" ] ; return renderMsgWithdrawDelegatorReward ( value . validator_address ) ; } if ( msg . type === msgOpts . govVote . type ) { const value = msg . value as MsgVote [ "value" ] ; return renderMsgVote ( value . proposal_id , value . option ) ; } return renderUnknownMessage ( msg ) ; }