Skip to content

Commit

Permalink
Merge pull request #1207 from friedger/fix/1192
Browse files Browse the repository at this point in the history
Fix/1192 memo abuse
  • Loading branch information
friedger authored Jun 22, 2023
2 parents 6433664 + bbfeb04 commit bdfea4e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 7 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# [4.10.0](https://github.com/blockstack/stacks-wallet/compare/v4.9.1...v4.10.0) (2023-05-25)


### Bug Fixes

* display all types of btc pox addresses ([d16a023](https://github.com/blockstack/stacks-wallet/commit/d16a023feedaab26e5036c37917fa077dbbff7f6))


### Features

* update stacks.js ([bfc60ec](https://github.com/blockstack/stacks-wallet/commit/bfc60ec7a45ae87f539c8141f5c58b6a5da472ed))

# [4.10.0-dev.1](https://github.com/blockstack/stacks-wallet/compare/v4.9.1...v4.10.0-dev.1) (2023-05-25)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
isDelegatedStackingTx,
inferSendManyTransferOperation,
isSendManyTx,
getMemoForTx,
} from '@utils/tx-utils';
import { toHumanReadableStx } from '@utils/unit-convert';
import React, {
Expand Down Expand Up @@ -106,12 +107,8 @@ export const TransactionListItem: FC<TransactionListItemProps> = 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();

Expand Down
13 changes: 13 additions & 0 deletions app/utils/tx-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stacks-wallet",
"version": "4.10.0-dev.1",
"version": "4.10.0",
"description": "Hiro Wallet 2.0 — Stacking",
"prettier": "@stacks/prettier-config",
"homepage": "https://hiro.so/wallet",
Expand Down

0 comments on commit bdfea4e

Please sign in to comment.