From 53135ea981c380cd294be17b3d54a838e0859714 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 20 Aug 2024 11:00:47 +0100 Subject: [PATCH 01/11] chore: wip --- .../components/confirm/footer/footer.tsx | 45 +++++++++++++++++++ .../confirm-transaction.component.js | 6 +-- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/footer/footer.tsx b/ui/pages/confirmations/components/confirm/footer/footer.tsx index a3d3e1bbc71d..f5a750cde8e8 100644 --- a/ui/pages/confirmations/components/confirm/footer/footer.tsx +++ b/ui/pages/confirmations/components/confirm/footer/footer.tsx @@ -105,6 +105,44 @@ const Footer = () => { const { mmiOnSignCallback, mmiSubmitDisabled } = useMMIConfirmations(); ///: END:ONLY_INCLUDE_IF + + ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) + const mmiApprovalFlow = () => { + if (accountType === AccountType.CUSTODY) { + fullTxData.custodyStatus = CustodyStatus.CREATED; + fullTxData.metadata = fullTxData.metadata || {}; + + dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(true)); + + const txId = fullTxData.id; + const fromAddress = fullTxData.txParams.from; + const closeNotification = false; + dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => { + showCustodianDeepLink({ + dispatch, + mmiActions, + txId, + fromAddress, + closeNotification, + onDeepLinkFetched: () => undefined, + onDeepLinkShown: () => { + dispatch(clearConfirmTransaction()); + history.push(mostRecentOverviewPage); + }, + showCustodyConfirmLink, + }); + history.push(mostRecentOverviewPage); + }); + } else { + // Non Custody accounts follow normal flow + dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => { + dispatch(clearConfirmTransaction()); + history.push(mostRecentOverviewPage); + }); + } + }; + ///: END:ONLY_INCLUDE_IF + const hardwareWalletRequiresConnection = useSelector((state) => { if (from) { return doesAddressRequireLedgerHidConnection(state, from); @@ -143,7 +181,14 @@ const Footer = () => { currentConfirmation as TransactionMeta, ); + ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) + mmiApprovalFlow(); + ///: END:ONLY_INCLUDE_IF + + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) dispatch(updateAndApproveTx(updatedTx, true, '')); + ///: END:ONLY_INCLUDE_IF + } else { dispatch(resolvePendingApproval(currentConfirmation.id, undefined)); diff --git a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js index 27b1e59fbe7a..25ad97d1216a 100644 --- a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js @@ -164,9 +164,9 @@ const ConfirmTransaction = () => { // It takes care to render component for confirmations of type Personal Sign. // Once we migrate all confirmations to new designs we can get rid of this code // and render component for all confirmation requests. - if (currentConfirmation) { - return ; - } + // if (currentConfirmation) { + // return ; + // } if (isValidTokenMethod && isValidTransactionId) { return ; From 217dd16e78d23a42517c0f7efa515dade843c5e5 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 20 Aug 2024 15:12:11 +0100 Subject: [PATCH 02/11] chore: adds back the current UI for MMI --- .../components/confirm/footer/footer.tsx | 45 ------------------- .../confirm-transaction.component.js | 12 +++-- 2 files changed, 9 insertions(+), 48 deletions(-) diff --git a/ui/pages/confirmations/components/confirm/footer/footer.tsx b/ui/pages/confirmations/components/confirm/footer/footer.tsx index f5a750cde8e8..a3d3e1bbc71d 100644 --- a/ui/pages/confirmations/components/confirm/footer/footer.tsx +++ b/ui/pages/confirmations/components/confirm/footer/footer.tsx @@ -105,44 +105,6 @@ const Footer = () => { const { mmiOnSignCallback, mmiSubmitDisabled } = useMMIConfirmations(); ///: END:ONLY_INCLUDE_IF - - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - const mmiApprovalFlow = () => { - if (accountType === AccountType.CUSTODY) { - fullTxData.custodyStatus = CustodyStatus.CREATED; - fullTxData.metadata = fullTxData.metadata || {}; - - dispatch(mmiActions.setWaitForConfirmDeepLinkDialog(true)); - - const txId = fullTxData.id; - const fromAddress = fullTxData.txParams.from; - const closeNotification = false; - dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => { - showCustodianDeepLink({ - dispatch, - mmiActions, - txId, - fromAddress, - closeNotification, - onDeepLinkFetched: () => undefined, - onDeepLinkShown: () => { - dispatch(clearConfirmTransaction()); - history.push(mostRecentOverviewPage); - }, - showCustodyConfirmLink, - }); - history.push(mostRecentOverviewPage); - }); - } else { - // Non Custody accounts follow normal flow - dispatch(updateAndApproveTx(customNonceMerge(fullTxData))).then(() => { - dispatch(clearConfirmTransaction()); - history.push(mostRecentOverviewPage); - }); - } - }; - ///: END:ONLY_INCLUDE_IF - const hardwareWalletRequiresConnection = useSelector((state) => { if (from) { return doesAddressRequireLedgerHidConnection(state, from); @@ -181,14 +143,7 @@ const Footer = () => { currentConfirmation as TransactionMeta, ); - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - mmiApprovalFlow(); - ///: END:ONLY_INCLUDE_IF - - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) dispatch(updateAndApproveTx(updatedTx, true, '')); - ///: END:ONLY_INCLUDE_IF - } else { dispatch(resolvePendingApproval(currentConfirmation.id, undefined)); diff --git a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js index 25ad97d1216a..49ca662efef9 100644 --- a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js @@ -41,8 +41,10 @@ import ConfirmDeployContract from '../confirm-deploy-contract'; import ConfirmSendEther from '../confirm-send-ether'; import ConfirmSignatureRequest from '../confirm-signature-request'; import ConfirmTransactionSwitch from '../confirm-transaction-switch'; +///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import Confirm from '../confirm/confirm'; import useCurrentConfirmation from '../hooks/useCurrentConfirmation'; +///: END:ONLY_INCLUDE_IF import ConfirmTokenTransactionSwitch from './confirm-token-transaction-switch'; const ConfirmTransaction = () => { @@ -70,7 +72,9 @@ const ConfirmTransaction = () => { ]); const [transaction, setTransaction] = useState(getTransaction); const use4ByteResolution = useSelector(use4ByteResolutionSelector); + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const { currentConfirmation } = useCurrentConfirmation(); + ///: END:ONLY_INCLUDE_IF useEffect(() => { const tx = getTransaction(); @@ -164,9 +168,11 @@ const ConfirmTransaction = () => { // It takes care to render component for confirmations of type Personal Sign. // Once we migrate all confirmations to new designs we can get rid of this code // and render component for all confirmation requests. - // if (currentConfirmation) { - // return ; - // } + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) + if (currentConfirmation) { + return ; + } + ///: END:ONLY_INCLUDE_IF if (isValidTokenMethod && isValidTransactionId) { return ; From fde615b02cb3c3e82c7bcd0aaf4c34e111e2c7b6 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 20 Aug 2024 15:49:16 +0100 Subject: [PATCH 03/11] chore: better yet --- .../confirm-transaction.component.js | 6 ------ .../confirmations/hooks/useCurrentConfirmation.ts | 11 ++++++++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js index 49ca662efef9..27b1e59fbe7a 100644 --- a/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js +++ b/ui/pages/confirmations/confirm-transaction/confirm-transaction.component.js @@ -41,10 +41,8 @@ import ConfirmDeployContract from '../confirm-deploy-contract'; import ConfirmSendEther from '../confirm-send-ether'; import ConfirmSignatureRequest from '../confirm-signature-request'; import ConfirmTransactionSwitch from '../confirm-transaction-switch'; -///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import Confirm from '../confirm/confirm'; import useCurrentConfirmation from '../hooks/useCurrentConfirmation'; -///: END:ONLY_INCLUDE_IF import ConfirmTokenTransactionSwitch from './confirm-token-transaction-switch'; const ConfirmTransaction = () => { @@ -72,9 +70,7 @@ const ConfirmTransaction = () => { ]); const [transaction, setTransaction] = useState(getTransaction); const use4ByteResolution = useSelector(use4ByteResolutionSelector); - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const { currentConfirmation } = useCurrentConfirmation(); - ///: END:ONLY_INCLUDE_IF useEffect(() => { const tx = getTransaction(); @@ -168,11 +164,9 @@ const ConfirmTransaction = () => { // It takes care to render component for confirmations of type Personal Sign. // Once we migrate all confirmations to new designs we can get rid of this code // and render component for all confirmation requests. - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) if (currentConfirmation) { return ; } - ///: END:ONLY_INCLUDE_IF if (isValidTokenMethod && isValidTransactionId) { return ; diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index 2403622f5a0e..be092675553e 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -82,8 +82,17 @@ const useCurrentConfirmation = () => { // facing feature toggles for signature or transactions are enabled, we show // only confirmations that shipped (contained in `REDESIGN_APPROVAL_TYPES` and // `REDESIGN_TRANSACTION_TYPES` respectively). - const shouldUseRedesign = + let shouldUseRedesign; + + ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) + shouldUseRedesign = + shouldUseRedesignForSignatures; + ///: END:ONLY_INCLUDE_IF + + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) + shouldUseRedesign = shouldUseRedesignForSignatures || shouldUseRedesignForTransactions; + ///: END:ONLY_INCLUDE_IF return useMemo(() => { if (!shouldUseRedesign) { From 6f6a575f2fa196fd54a306dfe8a3383ebf11fcd2 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 20 Aug 2024 16:42:12 +0100 Subject: [PATCH 04/11] chore: update and lint --- .../hooks/useCurrentConfirmation.ts | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index be092675553e..4571bb4914a6 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -10,12 +10,19 @@ import { ApprovalsMetaMaskState, getIsRedesignedConfirmationsDeveloperEnabled, getRedesignedConfirmationsEnabled, + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) getRedesignedTransactionsEnabled, getUnapprovedTransaction, + ///: END:ONLY_INCLUDE_IF latestPendingConfirmationSelector, selectPendingApproval, } from '../../../selectors'; -import { REDESIGN_APPROVAL_TYPES, REDESIGN_TRANSACTION_TYPES } from '../utils'; +import { + REDESIGN_APPROVAL_TYPES, + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) + REDESIGN_TRANSACTION_TYPES, + ///: END:ONLY_INCLUDE_IF +} from '../utils'; import { selectUnapprovedMessage } from '../../../selectors/signatures'; /** @@ -35,9 +42,11 @@ const useCurrentConfirmation = () => { getRedesignedConfirmationsEnabled, ); + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const isRedesignedTransactionsUserSettingEnabled = useSelector( getRedesignedTransactionsEnabled, ); + ///: END:ONLY_INCLUDE_IF const isRedesignedConfirmationsDeveloperEnabled = useSelector( getIsRedesignedConfirmationsDeveloperEnabled, @@ -51,18 +60,20 @@ const useCurrentConfirmation = () => { selectPendingApproval(state as ApprovalsMetaMaskState, confirmationId), ); + const signatureMessage = useSelector((state) => + selectUnapprovedMessage(state, confirmationId), + ); + + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const transactionMetadata = useSelector((state) => // eslint-disable-next-line @typescript-eslint/no-explicit-any (getUnapprovedTransaction as any)(state, confirmationId), ) as TransactionMeta | undefined; - const signatureMessage = useSelector((state) => - selectUnapprovedMessage(state, confirmationId), - ); - const isCorrectTransactionType = REDESIGN_TRANSACTION_TYPES.includes( transactionMetadata?.type as TransactionType, ); + ///: END:ONLY_INCLUDE_IF const isCorrectApprovalType = REDESIGN_APPROVAL_TYPES.includes( pendingApproval?.type as ApprovalType, @@ -72,10 +83,12 @@ const useCurrentConfirmation = () => { (isRedesignedSignaturesUserSettingEnabled && isCorrectApprovalType) || (isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectApprovalType); + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const shouldUseRedesignForTransactions = (isRedesignedTransactionsUserSettingEnabled && isCorrectTransactionType) || (isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectTransactionType); + ///: END:ONLY_INCLUDE_IF // If the developer toggle or the build time environment variable are enabled, // all the signatures and transactions in development are shown. If the user @@ -85,8 +98,7 @@ const useCurrentConfirmation = () => { let shouldUseRedesign; ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - shouldUseRedesign = - shouldUseRedesignForSignatures; + shouldUseRedesign = shouldUseRedesignForSignatures; ///: END:ONLY_INCLUDE_IF ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) From 4d3f85932688fdfdccc7724441b9215d80d47cef Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Tue, 20 Aug 2024 16:52:43 +0100 Subject: [PATCH 05/11] chore: update and lint --- ui/pages/confirmations/hooks/useCurrentConfirmation.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index 4571bb4914a6..22bfeb0f4f0d 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -1,9 +1,11 @@ import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import { TransactionMeta, TransactionType, } from '@metamask/transaction-controller'; +///: END:ONLY_INCLUDE_IF import { ApprovalType } from '@metamask/controller-utils'; import { useMemo } from 'react'; import { From 567318f345cdfddf69573af6a56917092e3c320e Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 21 Aug 2024 10:52:28 +0100 Subject: [PATCH 06/11] chore: update code fences --- ui/pages/confirmations/hooks/useCurrentConfirmation.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index 22bfeb0f4f0d..dd2d0d1adf9c 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -1,6 +1,6 @@ import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) +///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import { TransactionMeta, TransactionType, @@ -14,8 +14,8 @@ import { getRedesignedConfirmationsEnabled, ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) getRedesignedTransactionsEnabled, - getUnapprovedTransaction, ///: END:ONLY_INCLUDE_IF + getUnapprovedTransaction, latestPendingConfirmationSelector, selectPendingApproval, } from '../../../selectors'; @@ -66,12 +66,12 @@ const useCurrentConfirmation = () => { selectUnapprovedMessage(state, confirmationId), ); - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const transactionMetadata = useSelector((state) => // eslint-disable-next-line @typescript-eslint/no-explicit-any (getUnapprovedTransaction as any)(state, confirmationId), ) as TransactionMeta | undefined; + ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const isCorrectTransactionType = REDESIGN_TRANSACTION_TYPES.includes( transactionMetadata?.type as TransactionType, ); From 90495fac1659766e9efbff484e70298cee7181e3 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 21 Aug 2024 15:22:16 +0100 Subject: [PATCH 07/11] chore: test update --- test/e2e/playwright/mmi/specs/extension.visual.spec.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/playwright/mmi/specs/extension.visual.spec.ts b/test/e2e/playwright/mmi/specs/extension.visual.spec.ts index 8a9aa0c6fff3..5516459b0c9b 100644 --- a/test/e2e/playwright/mmi/specs/extension.visual.spec.ts +++ b/test/e2e/playwright/mmi/specs/extension.visual.spec.ts @@ -105,6 +105,8 @@ test.describe('MMI extension', () => { 'Custody Account R', 'Custody Account S', 'Custody Account T', + 'TR', + 'TR2' ]; // Getting extension id of MMI From cc79b12bfc163ee7e09a45cab25536557a2015f0 Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Wed, 21 Aug 2024 15:33:36 +0100 Subject: [PATCH 08/11] chore: prettier --- test/e2e/playwright/mmi/specs/extension.visual.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/playwright/mmi/specs/extension.visual.spec.ts b/test/e2e/playwright/mmi/specs/extension.visual.spec.ts index 5516459b0c9b..c9f6717b26ec 100644 --- a/test/e2e/playwright/mmi/specs/extension.visual.spec.ts +++ b/test/e2e/playwright/mmi/specs/extension.visual.spec.ts @@ -106,7 +106,7 @@ test.describe('MMI extension', () => { 'Custody Account S', 'Custody Account T', 'TR', - 'TR2' + 'TR2', ]; // Getting extension id of MMI From 4843b8f138f0f1e2d487a61005f29a62a443498f Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Thu, 22 Aug 2024 11:37:36 +0100 Subject: [PATCH 09/11] chore: adds isMMI method approach --- ui/helpers/utils/build-types.js | 4 ++ .../hooks/useCurrentConfirmation.test.ts | 27 ++++++++++++ .../hooks/useCurrentConfirmation.ts | 42 ++++++------------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/ui/helpers/utils/build-types.js b/ui/helpers/utils/build-types.js index af004297d3ae..e0b003527ccb 100644 --- a/ui/helpers/utils/build-types.js +++ b/ui/helpers/utils/build-types.js @@ -31,6 +31,10 @@ export function isBeta() { return process.env.METAMASK_BUILD_TYPE === 'beta'; } +export function isMMI() { + return process.env.METAMASK_BUILD_TYPE === 'mmi'; +} + // Returns a specific version of an asset based on // the current metamask version (i.e. main, beta, etc.) export function getBuildSpecificAsset(assetName) { diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts index a71b14c13ce9..54b7b298f16b 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.test.ts @@ -309,4 +309,31 @@ describe('useCurrentConfirmation', () => { expect(currentConfirmation).toBeUndefined(); }); }); + + describe('useCurrentConfirmation with MM build type env var (MMI)', () => { + beforeAll(() => { + jest.resetModules(); + process.env.METAMASK_BUILD_TYPE = 'mmi'; + }); + + afterAll(() => { + process.env.METAMASK_BUILD_TYPE = 'main'; + }); + + it('returns undefined if build type is MMI, user setting is enabled and transaction has correct type', () => { + const currentConfirmation = runHook({ + pendingApprovals: [ + { ...APPROVAL_MOCK, type: ApprovalType.Transaction }, + ], + redesignedConfirmationsEnabled: true, + transaction: { + ...TRANSACTION_MOCK, + type: TransactionType.contractInteraction, + }, + isRedesignedConfirmationsDeveloperEnabled: false, + }); + + expect(currentConfirmation).toBeUndefined(); + }); + }); }); diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index dd2d0d1adf9c..2b4f1c0bb689 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -1,31 +1,23 @@ import { useSelector } from 'react-redux'; import { useParams } from 'react-router-dom'; -///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) import { TransactionMeta, TransactionType, } from '@metamask/transaction-controller'; -///: END:ONLY_INCLUDE_IF import { ApprovalType } from '@metamask/controller-utils'; import { useMemo } from 'react'; import { ApprovalsMetaMaskState, getIsRedesignedConfirmationsDeveloperEnabled, getRedesignedConfirmationsEnabled, - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) getRedesignedTransactionsEnabled, - ///: END:ONLY_INCLUDE_IF getUnapprovedTransaction, latestPendingConfirmationSelector, selectPendingApproval, } from '../../../selectors'; -import { - REDESIGN_APPROVAL_TYPES, - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) - REDESIGN_TRANSACTION_TYPES, - ///: END:ONLY_INCLUDE_IF -} from '../utils'; +import { REDESIGN_APPROVAL_TYPES, REDESIGN_TRANSACTION_TYPES } from '../utils'; import { selectUnapprovedMessage } from '../../../selectors/signatures'; +import { isMMI } from '../../../helpers/utils/build-types'; /** * Determine the current confirmation based on the pending approvals and controller state. @@ -44,11 +36,9 @@ const useCurrentConfirmation = () => { getRedesignedConfirmationsEnabled, ); - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) const isRedesignedTransactionsUserSettingEnabled = useSelector( getRedesignedTransactionsEnabled, ); - ///: END:ONLY_INCLUDE_IF const isRedesignedConfirmationsDeveloperEnabled = useSelector( getIsRedesignedConfirmationsDeveloperEnabled, @@ -62,20 +52,18 @@ const useCurrentConfirmation = () => { selectPendingApproval(state as ApprovalsMetaMaskState, confirmationId), ); - const signatureMessage = useSelector((state) => - selectUnapprovedMessage(state, confirmationId), - ); - const transactionMetadata = useSelector((state) => // eslint-disable-next-line @typescript-eslint/no-explicit-any (getUnapprovedTransaction as any)(state, confirmationId), ) as TransactionMeta | undefined; - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) + const signatureMessage = useSelector((state) => + selectUnapprovedMessage(state, confirmationId), + ); + const isCorrectTransactionType = REDESIGN_TRANSACTION_TYPES.includes( transactionMetadata?.type as TransactionType, ); - ///: END:ONLY_INCLUDE_IF const isCorrectApprovalType = REDESIGN_APPROVAL_TYPES.includes( pendingApproval?.type as ApprovalType, @@ -85,28 +73,22 @@ const useCurrentConfirmation = () => { (isRedesignedSignaturesUserSettingEnabled && isCorrectApprovalType) || (isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectApprovalType); - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) + console.log(!isMMI()); + const shouldUseRedesignForTransactions = - (isRedesignedTransactionsUserSettingEnabled && isCorrectTransactionType) || + (!isMMI() && + isRedesignedTransactionsUserSettingEnabled && + isCorrectTransactionType) || (isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectTransactionType); - ///: END:ONLY_INCLUDE_IF // If the developer toggle or the build time environment variable are enabled, // all the signatures and transactions in development are shown. If the user // facing feature toggles for signature or transactions are enabled, we show // only confirmations that shipped (contained in `REDESIGN_APPROVAL_TYPES` and // `REDESIGN_TRANSACTION_TYPES` respectively). - let shouldUseRedesign; - - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) - shouldUseRedesign = shouldUseRedesignForSignatures; - ///: END:ONLY_INCLUDE_IF - - ///: BEGIN:ONLY_INCLUDE_IF(build-main,build-beta,build-flask) - shouldUseRedesign = + const shouldUseRedesign = shouldUseRedesignForSignatures || shouldUseRedesignForTransactions; - ///: END:ONLY_INCLUDE_IF return useMemo(() => { if (!shouldUseRedesign) { From 6e148ae0dfe6b2d23d6f98e38790fa86d62513ab Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Thu, 22 Aug 2024 11:39:28 +0100 Subject: [PATCH 10/11] chore: clean up --- ui/pages/confirmations/hooks/useCurrentConfirmation.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts index 2b4f1c0bb689..184f4cf0b194 100644 --- a/ui/pages/confirmations/hooks/useCurrentConfirmation.ts +++ b/ui/pages/confirmations/hooks/useCurrentConfirmation.ts @@ -73,8 +73,6 @@ const useCurrentConfirmation = () => { (isRedesignedSignaturesUserSettingEnabled && isCorrectApprovalType) || (isRedesignedConfirmationsDeveloperSettingEnabled && isCorrectApprovalType); - console.log(!isMMI()); - const shouldUseRedesignForTransactions = (!isMMI() && isRedesignedTransactionsUserSettingEnabled && From 7428e1e5a05a6acbd54f7a723ebdfcf08c580c1b Mon Sep 17 00:00:00 2001 From: Antonio Regadas Date: Thu, 22 Aug 2024 12:14:34 +0100 Subject: [PATCH 11/11] chore: update test while at it --- test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts b/test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts index 761fb8684de7..c8c304412936 100644 --- a/test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts +++ b/test/e2e/playwright/mmi/pageObjects/mmi-auth0-page.ts @@ -45,6 +45,7 @@ export class Auth0Page { .locator('#password') .fill(process.env.MMI_E2E_E2E_AUTH0_PASSWORD as string); await this.page.getByRole('button', { name: /continue/iu }).click(); + await this.page.getByRole('button', { name: /E2E Organization/iu }).click(); await expect(this.page).toHaveURL(portfolio); } }