Skip to content

Commit

Permalink
Merge pull request #1212 from hirosystems/release/memo-warnings
Browse files Browse the repository at this point in the history
Release/memo warnings
  • Loading branch information
kyranjamie authored Jul 3, 2023
2 parents c99e4af + f2df060 commit d737357
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/debug-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ jobs:

- uses: actions/setup-python@v4
with:
python-version: '2.7.18'
architecture: x64

#
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [4.10.1-dev.1](https://github.com/blockstack/stacks-wallet/compare/v4.10.0...v4.10.1-dev.1) (2023-06-22)


### Bug Fixes

* only show memo for sent transactions ([bbfeb04](https://github.com/blockstack/stacks-wallet/commit/bbfeb0498f63da50a3ff7141d225f8f13e694071))

# [4.10.0](https://github.com/blockstack/stacks-wallet/compare/v4.9.1...v4.10.0) (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",
"version": "4.10.1-dev.1",
"description": "Hiro Wallet 2.0 — Stacking",
"prettier": "@stacks/prettier-config",
"homepage": "https://hiro.so/wallet",
Expand Down

0 comments on commit d737357

Please sign in to comment.