diff --git a/app/components/home/transaction-list/transaction-list-item.tsx b/app/components/home/transaction-list/transaction-list-item.tsx index 4842e7c65..e62ec1e41 100644 --- a/app/components/home/transaction-list/transaction-list-item.tsx +++ b/app/components/home/transaction-list/transaction-list-item.tsx @@ -21,6 +21,7 @@ import { isDelegatedStackingTx, inferSendManyTransferOperation, isSendManyTx, + getMemoForTx, } from '@utils/tx-utils'; import { toHumanReadableStx } from '@utils/unit-convert'; import React, { @@ -106,12 +107,8 @@ export const TransactionListItem: FC = props => { }, [direction, poxInfo?.contract_id, tx]); const sumPrefix = direction === 'sent' && !isStackingTx(tx, poxInfo?.contract_id) ? '−' : ''; - const memo = - tx.tx_type === 'token_transfer' && - Buffer.from( - tx.token_transfer.memo.replace('0x', '').replace(/^(0{2})+|(0{2})+$/g, ''), - 'hex' - ).toString('utf8'); + const memo = getMemoForTx(tx, direction); + const txDate = new Date(tx.burn_block_time_iso || (tx as any).parent_burn_block_time_iso); const txDateShort = txDate.toLocaleString(); diff --git a/app/utils/tx-utils.ts b/app/utils/tx-utils.ts index e17d4caca..c80952b95 100644 --- a/app/utils/tx-utils.ts +++ b/app/utils/tx-utils.ts @@ -112,3 +112,16 @@ export const truncateMiddle = (input: string, offset = 5): string => { return `${start}…${end}`; } }; + +export const getMemoForTx = (tx: Transaction, direction: StxTxDirection) => { + if (tx.tx_type !== 'token_transfer' || direction !== 'sent') { + return undefined; + } + + const utf8Memo = Buffer.from( + tx.token_transfer.memo.replace('0x', '').replace(/^(0{2})+|(0{2})+$/g, ''), + 'hex' + ).toString('utf8'); + + return utf8Memo; +};