From 6409caa0814d228e42b005992b96b55b92948431 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Sat, 10 Oct 2020 17:20:20 -0230 Subject: [PATCH] Use initial transaction for settings swap transaction title params (#9543) * Use initial transaction for settings swap transaction title params, and remove addition of swap properties to cancel transcations * Update unit test data * Use token symbol properties from initial transaction for filitering in transaction list --- app/scripts/controllers/transactions/index.js | 5 ----- test/data/transaction-data.json | 2 ++ .../app/transaction-list/transaction-list.component.js | 2 -- ui/app/hooks/useTransactionDisplayData.js | 6 +++--- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 8e38f7bd6..947fc92ef 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -366,11 +366,6 @@ export default class TransactionController extends EventEmitter { type: TRANSACTION_TYPE_CANCEL, }) - if (originalTxMeta.transactionCategory === SWAP) { - newTxMeta.sourceTokenSymbol = originalTxMeta.sourceTokenSymbol - newTxMeta.destinationTokenSymbol = originalTxMeta.destinationTokenSymbol - } - this.addTx(newTxMeta) await this.approveTransaction(newTxMeta.id) return newTxMeta diff --git a/test/data/transaction-data.json b/test/data/transaction-data.json index 552f447f4..e5ae1f5b8 100644 --- a/test/data/transaction-data.json +++ b/test/data/transaction-data.json @@ -512,6 +512,8 @@ "value": "0xde0b6b3a7640000" }, "hash": "0xbcb195f393f4468945b4045cd41bcdbc2f19ad75ae92a32cf153a3004e42009a", + "destinationTokenSymbol": "ABC", + "sourceTokenSymbol": "ETH", "transactionCategory": "swap" }, "primaryTransaction": { diff --git a/ui/app/components/app/transaction-list/transaction-list.component.js b/ui/app/components/app/transaction-list/transaction-list.component.js index 7d5d0b280..9af3afe31 100644 --- a/ui/app/components/app/transaction-list/transaction-list.component.js +++ b/ui/app/components/app/transaction-list/transaction-list.component.js @@ -29,8 +29,6 @@ const getTransactionGroupRecipientAddressFilter = (recipientAddress) => { const tokenTransactionFilter = ({ initialTransaction: { transactionCategory, - }, - primaryTransaction: { destinationTokenSymbol, sourceTokenSymbol, }, diff --git a/ui/app/hooks/useTransactionDisplayData.js b/ui/app/hooks/useTransactionDisplayData.js index b79fda1b2..fa6f5773c 100644 --- a/ui/app/hooks/useTransactionDisplayData.js +++ b/ui/app/hooks/useTransactionDisplayData.js @@ -133,14 +133,14 @@ export function useTransactionDisplayData (transactionGroup) { } else if (transactionCategory === SWAP) { category = TRANSACTION_CATEGORY_SWAP title = t('swapTokenToToken', [ - primaryTransaction.sourceTokenSymbol, - primaryTransaction.destinationTokenSymbol, + initialTransaction.sourceTokenSymbol, + initialTransaction.destinationTokenSymbol, ]) subtitle = origin subtitleContainsOrigin = true primarySuffix = isViewingReceivedTokenFromSwap ? currentAsset.symbol - : primaryTransaction.sourceTokenSymbol + : initialTransaction.sourceTokenSymbol primaryDisplayValue = swapTokenValue secondaryDisplayValue = swapTokenFiatAmount prefix = isViewingReceivedTokenFromSwap ? '+' : '-'