From b0c41ab53859ea27a906c2e51b0b8716fb1dd68b Mon Sep 17 00:00:00 2001 From: abefernan <44572727+abefernan@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:23:06 +0200 Subject: [PATCH] Extract TxMsgDetails to use switch --- .../dataViews/TransactionInfo/index.tsx | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/components/dataViews/TransactionInfo/index.tsx b/components/dataViews/TransactionInfo/index.tsx index 776a51f..5986a8e 100644 --- a/components/dataViews/TransactionInfo/index.tsx +++ b/components/dataViews/TransactionInfo/index.tsx @@ -1,3 +1,4 @@ +import { EncodeObject } from "@cosmjs/proto-signing"; import { useAppContext } from "../../../context/AppContext"; import { printableCoins } from "../../../lib/displayHelpers"; import { DbTransaction } from "../../../types"; @@ -12,11 +13,34 @@ import TxMsgSetWithdrawAddressDetails from "./TxMsgSetWithdrawAddressDetails"; import TxMsgTransferDetails from "./TxMsgTransferDetails"; import TxMsgUndelegateDetails from "./TxMsgUndelegateDetails"; -interface Props { +const TxMsgDetails = ({ typeUrl, value: msgValue }: EncodeObject) => { + switch (typeUrl) { + case MsgTypeUrls.Send: + return ; + case MsgTypeUrls.Delegate: + return ; + case MsgTypeUrls.Undelegate: + return ; + case MsgTypeUrls.BeginRedelegate: + return ; + case MsgTypeUrls.WithdrawDelegatorReward: + return ; + case MsgTypeUrls.SetWithdrawAddress: + return ; + case MsgTypeUrls.CreateVestingAccount: + return ; + case MsgTypeUrls.Transfer: + return ; + default: + return null; + } +}; + +interface TransactionInfoProps { readonly tx: DbTransaction; } -const TransactionInfo = ({ tx }: Props) => { +const TransactionInfo = ({ tx }: TransactionInfoProps) => { const { state } = useAppContext(); return ( @@ -46,30 +70,7 @@ const TransactionInfo = ({ tx }: Props) => { {tx.msgs.map((msg, index) => ( - {MsgTypeUrls.Send === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.Delegate === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.Undelegate === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.BeginRedelegate === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.WithdrawDelegatorReward === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.SetWithdrawAddress === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.CreateVestingAccount === msg.typeUrl ? ( - - ) : null} - {MsgTypeUrls.Transfer === msg.typeUrl ? ( - - ) : null} + ))}