Skip to content

Commit

Permalink
fix render msg
Browse files Browse the repository at this point in the history
  • Loading branch information
haunv3 committed Apr 15, 2024
1 parent bcd3818 commit a6e5797
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/components/Tx/TxData/TxMessage/TxMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,15 @@ const TxMessage = ({ key, msg, data, ind }) => {
return !data ? null : getInfoPriceRow(label, data.value, denom);
};

const getRawLog = rawLog => {
const getRawLog = (rawLog, index) => {
let messageParse = [];
try {
messageParse = tryParseMessage(JSON.parse(rawLog));
} catch (error) {
messageParse = [{ error: rawLog }];
} finally {
if (!index) messageParse = [messageParse[0]];
else messageParse = messageParse.filter(msg => msg.msg_index === index);
return (
<InfoRow label='RawLog'>
{!isLargeScreen ? (
Expand Down Expand Up @@ -501,6 +503,15 @@ const TxMessage = ({ key, msg, data, ind }) => {
return storageData?.[address]?.name;
};

const getTotalTransfer = (label, msg) => {
const totalAmount = msg.reduce((acc, cur) => acc + +cur.msg.transfer.amount, 0);
return (
<InfoRow label={label}>
<span className={cx("text")}>{_.isNil(totalAmount) ? "-" : formatOrai(totalAmount)}</span> <span className={cx("text")}>{}</span>
</InfoRow>
);
};

const getAddressRow = (label, address, name, isSmartContract = false) => (
<InfoRow label={label}>
<Address name={name ?? getNameByAddress(address)} address={address} showCopyIcon={true} size='lg' isSmartContract={isSmartContract} />
Expand Down Expand Up @@ -925,6 +936,7 @@ const TxMessage = ({ key, msg, data, ind }) => {
value={value}
memo={memo}
getTxTypeNew={getTxTypeNew}
getTotalTransfer={getTotalTransfer}
getAddressRow={getAddressRow}
getCurrencyRowFromObject={getCurrencyRowFromObject}
getCurrencyRowFromString={getCurrencyRowFromString}
Expand Down
7 changes: 3 additions & 4 deletions src/components/Tx/TxData/TxMessage/TxMessageContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const TxMessageContent = ({
getMultiRoyaltyRow,
getSubmitProposalContent,
getInfoRowThreeDots,
getTotalTransfer,
tryParseMessageBinary,
activeThemeId,
themeIds,
Expand Down Expand Up @@ -355,12 +356,12 @@ const TxMessageContent = ({
{getInfoRow("Contract Address", getContractAddress(data?.raw_log))}
</>
)}

{/* update 23/3/2023: add IBC progress for MsgExecute */}
{compareTypeMessage(type, [txTypes.COSMOS_SDK.EXECUTE_CONTRACT, txTypes.COSMOS_SDK_NEW_VERSION.EXECUTE_CONTRACT]) && (
<>
{getAddressRow("Contract", value?.contract, "", true)}
{getAddressRow("Sender", value?.sender, value?.sender_tag)}
{getTotalTransfer("Total Amount", data?.messages)}
{getInfoRowFromRawData(wasmAttributes, "pair", "Pair")}
{getPriceInfoFromRawData(wasmAttributes, "take_profit", "Take profit", quote)}
{getPriceInfoFromRawData(wasmAttributes, "stop_loss", "Stop loss", quote)}
Expand All @@ -382,9 +383,7 @@ const TxMessageContent = ({
{checkAttributeEvents(data?.raw_log, "send_packet") && getIBCProgressRow("IBC Progress", data)}
</>
)}

{/* add IBC Progress */}

{compareTypeMessage(type, [txTypes.COSMOS_SDK.MSG_IBC_TRANSFER, txTypes.COSMOS_SDK_NEW_VERSION.MSG_IBC_TRANSFER]) && (
<>
{getInfoRow("Source Port", value?.source_port)}
Expand Down Expand Up @@ -623,7 +622,7 @@ const TxMessageContent = ({
</InfoRow>
</>
)}
{getRawLog(data?.raw_log)}
{getRawLog(data?.raw_log, ind)}
</div>
</>
);
Expand Down

0 comments on commit a6e5797

Please sign in to comment.