From 949e73314fc0f1200e811c99023facd348e5ecb0 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Thu, 2 May 2024 15:43:56 -0230 Subject: [PATCH] fix (cherry-pick): Fix #24322 - Disable edits for all dapp initiated transactions (#24334) (#24354) Cherry picks 4a1853cf7b (#24322) to v11.14.5 Co-authored-by: David Walsh --- .../dapp-interactions/dapp-tx-edit.spec.js | 6 ++-- ...confirm-page-container-header.component.js | 33 +++++++++++-------- ...rm-page-container-header.component.test.js | 3 ++ .../confirm-page-container.component.js | 1 + .../confirm-send-ether.test.js.snap | 18 +--------- 5 files changed, 27 insertions(+), 34 deletions(-) diff --git a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js index 94e4b0084766..df98799a462d 100644 --- a/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js +++ b/test/e2e/tests/dapp-interactions/dapp-tx-edit.spec.js @@ -56,7 +56,7 @@ describe('Editing confirmations of dapp initiated contract interactions', functi ); }); - it('should show an edit button on a simple ETH send initiated by a dapp', async function () { + it('should NOT show an edit button on a simple ETH send initiated by a dapp', async function () { await withFixtures( { dapp: true, @@ -88,8 +88,8 @@ describe('Editing confirmations of dapp initiated contract interactions', functi ); assert.equal( editTransactionButton, - true, - `Edit transaction button should be visible on a contract interaction created by a dapp`, + false, + `Edit transaction button should not be visible on a simple send transaction created by a dapp`, ); }, ); diff --git a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js index 2bbda20bd117..8c3e0ad664de 100644 --- a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js +++ b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { ENVIRONMENT_TYPE_POPUP, ENVIRONMENT_TYPE_NOTIFICATION, + ORIGIN_METAMASK, } from '../../../../../../shared/constants/app'; import { getEnvironmentType } from '../../../../../../app/scripts/lib/util'; import NetworkDisplay from '../../../../../components/app/network-display'; @@ -18,6 +19,7 @@ export default function ConfirmPageContainerHeader({ accountAddress, showAccountInHeader, children, + origin, }) { const t = useI18nContext(); const windowType = getEnvironmentType(); @@ -48,21 +50,23 @@ export default function ConfirmPageContainerHeader({ ) : ( -
- - onEdit()} + origin === ORIGIN_METAMASK && ( +
- {t('edit')} - -
+ + onEdit()} + > + {t('edit')} + +
+ ) )} {isFullScreen ? null : } @@ -77,4 +81,5 @@ ConfirmPageContainerHeader.propTypes = { showEdit: PropTypes.bool, onEdit: PropTypes.func, children: PropTypes.node, + origin: PropTypes.string, }; diff --git a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js index e7043c283d19..6a48d8473a8e 100644 --- a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js +++ b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container-header/confirm-page-container-header.component.test.js @@ -2,6 +2,7 @@ import React from 'react'; import configureStore from 'redux-mock-store'; import { NetworkStatus } from '@metamask/network-controller'; import { NetworkType } from '@metamask/controller-utils'; +import { ORIGIN_METAMASK } from '../../../../../../shared/constants/app'; import { renderWithProvider } from '../../../../../../test/lib/render-helpers'; import { getEnvironmentType } from '../../../../../../app/scripts/lib/util'; import ConfirmPageContainerHeader from '.'; @@ -38,6 +39,7 @@ describe('Confirm Detail Row Component', () => { onEdit: jest.fn(), showAccountInHeader: false, accountAddress: '0xmockAccountAddress', + origin: ORIGIN_METAMASK, }; const { container } = renderWithProvider( @@ -56,6 +58,7 @@ describe('Confirm Detail Row Component', () => { onEdit: jest.fn(), showAccountInHeader: false, accountAddress: '0xmockAccountAddress', + origin: ORIGIN_METAMASK, }; const { container } = renderWithProvider( diff --git a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container.component.js b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container.component.js index 841a12d0e232..ee006040c196 100644 --- a/ui/pages/confirmations/components/confirm-page-container/confirm-page-container.component.js +++ b/ui/pages/confirmations/components/confirm-page-container/confirm-page-container.component.js @@ -219,6 +219,7 @@ const ConfirmPageContainer = (props) => { onEdit={() => onEdit()} showAccountInHeader={showAccountInHeader} accountAddress={fromAddress} + origin={origin} > {hideSenderToRecipient ? null : (
-
- - - Edit - -
-
+ />