From 8aa3263b82ea4b38868b9d52abc67552daf4073f Mon Sep 17 00:00:00 2001 From: Vladimir Saric <92527393+VSaric@users.noreply.github.com> Date: Tue, 31 Jan 2023 16:29:23 +0100 Subject: [PATCH] Added navigation between multiple sign prompts and reject all sign prompts (#17093) * Fixed navigation through multiple unapproved transactions for ERC20 tokens * Fixed tx details activity-log currency * Fixed e2e test failure * Added navigation between multiple sign prompts and reject all sign prompts * Resolving conflicts * Creating SignatureRequestNavigation component and extracting the UI rendering part into a single component * Fixing e2e tests and updating snapshot * Using single component for navigation which shows both messages and transactions requests * Fixing test-unit-jest-main * Added more unit tests * Fixing test-storybook * Fixing test-storybook --------- Co-authored-by: Filip Sekulic --- ui/components/app/app-components.scss | 2 +- ...irm-page-container-navigation.component.js | 45 +++-- .../index.scss | 0 .../signature-request-original.test.js.snap | 70 ++++++++ .../app/signature-request-original/index.scss | 5 +- .../signature-request-original.component.js | 4 + .../signature-request-original.test.js | 6 + .../signature-request.component.test.js.snap | 66 ++++++++ .../app/signature-request/index.scss | 7 +- .../signature-request.component.js | 45 ++++- .../signature-request.component.test.js | 160 ++++++++++++++++++ .../signature-request.container.js | 47 ++++- .../signature-request.container.test.js | 15 ++ .../confirm-transaction.container.js | 8 +- 14 files changed, 456 insertions(+), 24 deletions(-) mode change 100755 => 100644 ui/components/app/confirm-page-container/confirm-page-container-navigation/index.scss diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss index b59623b29279..314a6c76bba1 100644 --- a/ui/components/app/app-components.scss +++ b/ui/components/app/app-components.scss @@ -103,4 +103,4 @@ @import 'detected-token/detected-token-selection-popover/index'; @import 'network-account-balance-header/index'; @import 'approve-content-card/index'; -@import 'transaction-alerts/transaction-alerts' +@import 'transaction-alerts/transaction-alerts'; diff --git a/ui/components/app/confirm-page-container/confirm-page-container-navigation/confirm-page-container-navigation.component.js b/ui/components/app/confirm-page-container/confirm-page-container-navigation/confirm-page-container-navigation.component.js index 0f3c3de616bf..d116109de731 100755 --- a/ui/components/app/confirm-page-container/confirm-page-container-navigation/confirm-page-container-navigation.component.js +++ b/ui/components/app/confirm-page-container/confirm-page-container-navigation/confirm-page-container-navigation.component.js @@ -2,14 +2,16 @@ import React, { useContext } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory, useParams } from 'react-router-dom'; import { - getCurrentChainId, - getUnapprovedTransactions, + unconfirmedTransactionsHashSelector, + unapprovedDecryptMsgsSelector, + unapprovedEncryptionPublicKeyMsgsSelector, } from '../../../../selectors'; -import { transactionMatchesNetwork } from '../../../../../shared/modules/transaction.utils'; import { I18nContext } from '../../../../contexts/i18n'; -import { CONFIRM_TRANSACTION_ROUTE } from '../../../../helpers/constants/routes'; +import { + CONFIRM_TRANSACTION_ROUTE, + SIGNATURE_REQUEST_PATH, +} from '../../../../helpers/constants/routes'; import { clearConfirmTransaction } from '../../../../ducks/confirm-transaction/confirm-transaction.duck'; -import { hexToDecimal } from '../../../../../shared/modules/conversion.utils'; const ConfirmPageContainerNavigation = () => { const t = useContext(I18nContext); @@ -17,17 +19,26 @@ const ConfirmPageContainerNavigation = () => { const history = useHistory(); const { id } = useParams(); - const unapprovedTxs = useSelector(getUnapprovedTransactions); - const currentChainId = useSelector(getCurrentChainId); - const network = hexToDecimal(currentChainId); + const unapprovedDecryptMsgs = useSelector(unapprovedDecryptMsgsSelector); + const unapprovedEncryptionPublicKeyMsgs = useSelector( + unapprovedEncryptionPublicKeyMsgsSelector, + ); + const uncofirmedTransactions = useSelector( + unconfirmedTransactionsHashSelector, + ); - const currentNetworkUnapprovedTxs = Object.keys(unapprovedTxs) - .filter((key) => - transactionMatchesNetwork(unapprovedTxs[key], currentChainId, network), - ) - .reduce((acc, key) => ({ ...acc, [key]: unapprovedTxs[key] }), {}); + const enumUnapprovedDecryptMsgsKey = Object.keys(unapprovedDecryptMsgs); + const enumUnapprovedEncryptMsgsKey = Object.keys( + unapprovedEncryptionPublicKeyMsgs, + ); + const enumDecryptAndEncryptMsgs = [ + ...enumUnapprovedDecryptMsgsKey, + ...enumUnapprovedEncryptMsgsKey, + ]; - const enumUnapprovedTxs = Object.keys(currentNetworkUnapprovedTxs); + const enumUnapprovedTxs = Object.keys(uncofirmedTransactions).filter( + (key) => enumDecryptAndEncryptMsgs.includes(key) === false, + ); const currentPosition = enumUnapprovedTxs.indexOf(id); @@ -42,7 +53,11 @@ const ConfirmPageContainerNavigation = () => { const onNextTx = (txId) => { if (txId) { dispatch(clearConfirmTransaction()); - history.push(`${CONFIRM_TRANSACTION_ROUTE}/${txId}`); + history.push( + uncofirmedTransactions[txId]?.msgParams + ? `${CONFIRM_TRANSACTION_ROUTE}/${txId}${SIGNATURE_REQUEST_PATH}` + : `${CONFIRM_TRANSACTION_ROUTE}/${txId}`, + ); } }; diff --git a/ui/components/app/confirm-page-container/confirm-page-container-navigation/index.scss b/ui/components/app/confirm-page-container/confirm-page-container-navigation/index.scss old mode 100755 new mode 100644 diff --git a/ui/components/app/signature-request-original/__snapshots__/signature-request-original.test.js.snap b/ui/components/app/signature-request-original/__snapshots__/signature-request-original.test.js.snap index 74fc606276cc..a6f34832fcf0 100644 --- a/ui/components/app/signature-request-original/__snapshots__/signature-request-original.test.js.snap +++ b/ui/components/app/signature-request-original/__snapshots__/signature-request-original.test.js.snap @@ -5,6 +5,76 @@ exports[`SignatureRequestOriginal should match snapshot 1`] = `
+
+ +