Skip to content

Commit

Permalink
fix: trailing chars in memo string, closes #242
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Sep 25, 2020
1 parent c6f2fa2 commit 0573dc7
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ export const TransactionListItem: FC<TransactionListItemProps> = args => {
const sumPrefix = direction === 'sent' ? '−' : '';
const memo =
tx.tx_type === 'token_transfer' &&
Buffer.from(tx.token_transfer.memo.replace('0x', ''), 'hex').toString('utf8');
Buffer.from(tx.token_transfer.memo.replace('0x', '').replace(/^0+|0+$/g, ''), 'hex').toString(

This comment has been minimized.

Copy link
@zone117x

zone117x Sep 30, 2020

Contributor

This can cause issues with hex char pairs being split up. For example the string stack up -> 0x737461636b207570 -> 0x737461636b20757 -> stack u.

And weirder stuff outside the ascii range:
stack up 🙀 -> stack up �

I think you'd want something like /^(0{2})+|(0{2})+$/g

'utf8'
);
const txDate = new Date(tx.burn_block_time_iso);
const txDateFormatted = new Intl.DateTimeFormat('en-US', dateOptions).format(txDate);

Expand Down

0 comments on commit 0573dc7

Please sign in to comment.