From c403d4ece3272e4ca2ea5d70425bfedb369b60f3 Mon Sep 17 00:00:00 2001 From: VSaric Date: Fri, 6 Jan 2023 13:39:49 +0100 Subject: [PATCH] Added navigation between multiple sign prompts and reject all sign prompts --- ...irm-page-container-navigation.component.js | 18 ++++- .../signature-request-original.test.js.snap | 70 +++++++++++++++++++ .../app/signature-request-original/index.scss | 5 +- .../signature-request-original.component.js | 5 ++ .../signature-request-original.test.js | 6 ++ .../app/signature-request/index.scss | 7 +- .../signature-request.component.js | 44 +++++++++++- .../signature-request.container.js | 47 ++++++++++++- .../signature-request.container.test.js | 1 + .../confirm-transaction.container.js | 8 ++- 10 files changed, 200 insertions(+), 11 deletions(-) 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 fe201a507792..6acfd71eb160 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 @@ -5,10 +5,14 @@ import PropTypes from 'prop-types'; import { getCurrentChainId, getUnapprovedTransactions, + unconfirmedMessagesHashSelector, } 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/lib/metamask-controller-utils'; @@ -18,8 +22,10 @@ const ConfirmPageContainerNavigation = ({ txData }) => { const history = useHistory(); const unapprovedTxs = useSelector(getUnapprovedTransactions); + const unconfirmedMessages = useSelector(unconfirmedMessagesHashSelector); const currentChainId = useSelector(getCurrentChainId); const network = hexToDecimal(currentChainId); + const isUnapprovedTxsEmpty = Object.keys(unapprovedTxs).length === 0; const currentNetworkUnapprovedTxs = Object.keys(unapprovedTxs) .filter((key) => @@ -27,7 +33,9 @@ const ConfirmPageContainerNavigation = ({ txData }) => { ) .reduce((acc, key) => ({ ...acc, [key]: unapprovedTxs[key] }), {}); - const enumUnapprovedTxs = Object.keys(currentNetworkUnapprovedTxs); + const enumUnapprovedTxs = Object.keys( + isUnapprovedTxsEmpty ? unconfirmedMessages : currentNetworkUnapprovedTxs, + ); const currentPosition = enumUnapprovedTxs.indexOf( txData.id ? txData.id.toString() : '', ); @@ -43,7 +51,11 @@ const ConfirmPageContainerNavigation = ({ txData }) => { const onNextTx = (txId) => { if (txId) { dispatch(clearConfirmTransaction()); - history.push(`${CONFIRM_TRANSACTION_ROUTE}/${txId}`); + history.push( + isUnapprovedTxsEmpty + ? `${CONFIRM_TRANSACTION_ROUTE}/${txId}${SIGNATURE_REQUEST_PATH}` + : `${CONFIRM_TRANSACTION_ROUTE}/${txId}`, + ); } }; 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 38b691b7d563..1006d738dcc8 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`] = `
+
+ +