From d5bc5087961d458fbe73fceca3b9316fb84b35bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20Mi=C3=B1o?= Date: Wed, 10 Mar 2021 14:40:23 -0300 Subject: [PATCH] bugfix/transactions filtering (#2365) * fix * logic * Revert "logic" This reverts commit 413ee3acd6499ab5f676d7c5f8922602e82aca78. --- app/components/Views/Asset/index.js | 38 +++++++++++-------- .../Views/TransactionsView/index.js | 15 +++++--- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/components/Views/Asset/index.js b/app/components/Views/Asset/index.js index 1570c80a6a8..629b40f9dd9 100644 --- a/app/components/Views/Asset/index.js +++ b/app/components/Views/Asset/index.js @@ -130,34 +130,40 @@ class Asset extends PureComponent { isTransfer, transferInformation } = tx; - if (isTransfer) - return this.props.tokens.find( - ({ address }) => address.toLowerCase() === transferInformation.contractAddress.toLowerCase() - ); - return ( + + const network = Engine.context.NetworkController.state.network; + if ( (safeToChecksumAddress(from) === selectedAddress || safeToChecksumAddress(to) === selectedAddress) && - chainId === tx.networkID && + (chainId === tx.chainId || (!tx.chainId && network === tx.networkID)) && tx.status !== 'unapproved' - ); + ) { + if (isTransfer) + return this.props.tokens.find( + ({ address }) => address.toLowerCase() === transferInformation.contractAddress.toLowerCase() + ); + return true; + } + return false; }; noEthFilter = tx => { - const { chainId, swapsTransactions } = this.props; + const { chainId, swapsTransactions, selectedAddress } = this.props; const { transaction: { to, from }, isTransfer, transferInformation } = tx; - if (isTransfer) return this.navAddress === transferInformation.contractAddress.toLowerCase(); + const network = Engine.context.NetworkController.state.network; if ( - (from?.toLowerCase() === this.navAddress || to?.toLowerCase() === this.navAddress) && - chainId === tx.networkID && + (safeToChecksumAddress(from) === selectedAddress || safeToChecksumAddress(to) === selectedAddress) && + (chainId === tx.chainId || (!tx.chainId && network === tx.networkID)) && tx.status !== 'unapproved' - ) - return true; - if (swapsTransactions[tx.id] && to?.toLowerCase() === SWAPS_CONTRACT_ADDRESS) { - const { destinationToken, sourceToken } = swapsTransactions[tx.id]; - return destinationToken.address === this.navAddress || sourceToken.address === this.navAddress; + ) { + if (isTransfer) return this.navAddress === transferInformation.contractAddress.toLowerCase(); + if (swapsTransactions[tx.id] && to?.toLowerCase() === SWAPS_CONTRACT_ADDRESS) { + const { destinationToken, sourceToken } = swapsTransactions[tx.id]; + return destinationToken.address === this.navAddress || sourceToken.address === this.navAddress; + } } return false; }; diff --git a/app/components/Views/TransactionsView/index.js b/app/components/Views/TransactionsView/index.js index 08831670647..2505791f026 100644 --- a/app/components/Views/TransactionsView/index.js +++ b/app/components/Views/TransactionsView/index.js @@ -38,15 +38,18 @@ const TransactionsView = ({ isTransfer, transferInformation } = tx; - if (isTransfer) - return tokens.find( - ({ address }) => address.toLowerCase() === transferInformation.contractAddress.toLowerCase() - ); - return ( + if ( (safeToChecksumAddress(from) === selectedAddress || safeToChecksumAddress(to) === selectedAddress) && (chainId === tx.chainId || (!tx.chainId && network === tx.networkID)) && tx.status !== 'unapproved' - ); + ) { + if (isTransfer) + return tokens.find( + ({ address }) => address.toLowerCase() === transferInformation.contractAddress.toLowerCase() + ); + return true; + } + return false; }; const submittedTxs = [];