diff --git a/components/data_view/TransactionInfo.js b/components/data_view/TransactionInfo.js index ceeda0c2..55e2e29e 100644 --- a/components/data_view/TransactionInfo.js +++ b/components/data_view/TransactionInfo.js @@ -43,6 +43,7 @@ const TransactionInfo = ({ tx, txHash, chain }) => { jsx = break; case "/cosmos.staking.v1beta1.MsgDelegate": diff --git a/components/data_view/transaction/TransferMsg.js b/components/data_view/transaction/TransferMsg.js index 68dcf9ad..086c4500 100644 --- a/components/data_view/transaction/TransferMsg.js +++ b/components/data_view/transaction/TransferMsg.js @@ -1,4 +1,4 @@ -import { getValueFromDenom, getDisplayDenom, denomShortender } from "../../../libs/stringConvert" +import { getValueFromDenom, getDisplayDenom, denomShortender, getDisplayValueWithChainInfo, getDisplayDenomWithChainInfo } from "../../../libs/stringConvert" import { motion } from "framer-motion" const style = { @@ -14,7 +14,7 @@ const style = { } } -const TransferMsg = ({ parentStyle, msg }) => { +const TransferMsg = ({ parentStyle, msg, chain }) => { return ( <>
{ style.value } > - {`${msg.value.amount.length > 0 && msg.value.amount[0].amount} `} - {msg.value.amount.length > 0 && denomShortender(msg.value.amount[0].denom.toUpperCase())} + {`${msg.value.amount.length > 0 && getDisplayValueWithChainInfo(msg.value.amount[0].amount, msg.value.amount[0].denom, chain)} `} + {msg.value.amount.length > 0 && denomShortender(getDisplayDenomWithChainInfo(msg.value.amount[0].denom, chain).toUpperCase())}
{ const msg = createSendMsg( address, txBody.toAddress, - txBody.amount, + getValueWithChainInfo(txBody.amount, balances[selectedToken].denom, chain), balances[selectedToken].denom ) setMsgs([...msgs, msg]) @@ -121,7 +124,8 @@ const SendMsgForm = ({ address, chain, style, msgs, setMsgs, balances }) => { value={index} key={index} > - {`${balance.amount} ${balance.denom}`} + {`${getDisplayValueWithChainInfo(balance.amount, balance.denom, chain)} + ${getDisplayDenomWithChainInfo(balance.denom, chain)}`} ) }) @@ -146,7 +150,8 @@ const SendMsgForm = ({ address, chain, style, msgs, setMsgs, balances }) => { margin: 0 }} > - {`Amount (${balances.length > 0 && denomShortender(balances[selectedToken].denom).toUpperCase()})`} + {`Amount (${balances.length > 0 + && denomShortender(getDisplayDenomWithChainInfo(balances[selectedToken].denom, chain)).toUpperCase()})`} { } } +export const getDisplayDenomWithChainInfo = (denom, chain) => { + if (denom === chain.denom) { + return chain.displayDenom + } + return denom +} + +export const getDisplayValueWithChainInfo = (value, denom, chain) => { + if (denom === chain.denom) { + return getValueFromDenom(denom, value) + } + return value +} + +export const getValueWithChainInfo = (value, denom, chain) => { + if (denom === chain.denom) { + return convertValueFromDenom(chain.base_denom, value) + } + return value +} + + + export const getValueFromDenom = (denom, value) => { let convertValue if (denom in specialDenom) {