From 343ee961208c68f42397d6591f73f14d2c74891e Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 30 Jul 2024 12:07:06 -0500 Subject: [PATCH] address feedback + cleanup --- app/scripts/controllers/mmi-controller.ts | 14 +- app/scripts/metamask-controller.js | 2 - .../index.js | 1 - .../signature-request-original-warning.js | 128 ------------------ ...nature-request-original-warning.stories.js | 31 ----- .../signature-request-original.component.js | 26 +--- 6 files changed, 6 insertions(+), 196 deletions(-) delete mode 100644 ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/index.js delete mode 100644 ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.js delete mode 100644 ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.stories.js diff --git a/app/scripts/controllers/mmi-controller.ts b/app/scripts/controllers/mmi-controller.ts index 55e556ddac78..5530f876786d 100644 --- a/app/scripts/controllers/mmi-controller.ts +++ b/app/scripts/controllers/mmi-controller.ts @@ -791,15 +791,10 @@ export default class MMIController extends EventEmitter { const updatedMsgParams = { ...msgParams, deferSetAsSigned: isCustodial }; if ( - req.method !== 'eth_signTypedData' && - req.method !== 'eth_signTypedData_v3' && - req.method !== 'eth_signTypedData_v4' && - req.method !== 'personal_sign' + req.method === 'eth_signTypedData' || + req.method === 'eth_signTypedData_v3' || + req.method === 'eth_signTypedData_v4' ) { - throw new Error('Unexpected method'); - } - - if (req.method.includes('eth_signTypedData')) { return await this.signatureController.newUnsignedTypedMessage( updatedMsgParams as PersonalMessageParams, req as OriginalRequest, @@ -812,7 +807,8 @@ export default class MMIController extends EventEmitter { req as OriginalRequest, ); } - return undefined; + + throw new Error('Unexpected method'); } async handleSigningEvents( diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d09390b22588..6a1e01c47a03 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -1798,8 +1798,6 @@ export default class MetamaskController extends EventEmitter { `${this.loggingController.name}:add`, ], }), - // TODO remove this option - isEthSignEnabled: () => false, getAllState: this.getState.bind(this), getCurrentChainId: () => this.networkController.state.providerConfig.chainId, diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/index.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/index.js deleted file mode 100644 index 546d0194aadc..000000000000 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './signature-request-original-warning'; diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.js deleted file mode 100644 index 3e356e77b8a3..000000000000 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.js +++ /dev/null @@ -1,128 +0,0 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { useI18nContext } from '../../../../../hooks/useI18nContext'; - -import { - IconColor, - Display, - FlexDirection, - JustifyContent, - TextColor, - TextVariant, - AlignItems, - TextAlign, - BlockSize, -} from '../../../../../helpers/constants/design-system'; -import { shortenAddress } from '../../../../../helpers/utils/util'; -import { - Icon, - IconName, - Box, - Text, - ButtonVariant, - Modal, - ModalContent, - ModalFooter, - ModalBody, - ModalHeader, - AvatarAccount, - AvatarAccountSize, - IconSize, - ModalOverlay, -} from '../../../../../components/component-library'; - -const SignatureRequestOriginalWarning = ({ - senderAddress, - name, - onSubmit, - onCancel, -}) => { - const t = useI18nContext(); - - return ( - - - - - - - {t('yourFundsMayBeAtRisk')} - - - - - - - {name} {` (${shortenAddress(senderAddress)})`} - - - - {t('signatureRequestWarning', [ - - {t('learnMoreUpperCase')} - , - ])} - - - - - - ); -}; - -SignatureRequestOriginalWarning.propTypes = { - senderAddress: PropTypes.string, - name: PropTypes.string, - onSubmit: PropTypes.func, - onCancel: PropTypes.func, -}; - -export default SignatureRequestOriginalWarning; diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.stories.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.stories.js deleted file mode 100644 index 56c1cc8c98c9..000000000000 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original-warning/signature-request-original-warning.stories.js +++ /dev/null @@ -1,31 +0,0 @@ -import React from 'react'; -import SignatureRequestOriginalWarning from './signature-request-original-warning'; - -export default { - title: 'Confirmations/Components/SignatureRequestOriginalWarning', - component: SignatureRequestOriginalWarning, - argTypes: { - senderAddress: { - control: 'text', - }, - name: { - control: 'text', - }, - onSubmit: { - action: 'onSubmit', - }, - onCancel: { - action: 'onCancel', - }, - }, - args: { - senderAddress: '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1', - name: 'John Doe', - }, -}; - -export const DefaultStory = (args) => ( - -); - -DefaultStory.storyName = 'Default'; diff --git a/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js b/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js index 154958962290..d16d5d27fb38 100644 --- a/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js +++ b/ui/pages/confirmations/components/signature-request-original/signature-request-original.component.js @@ -51,7 +51,6 @@ import SnapLegacyAuthorshipHeader from '../../../../components/app/snaps/snap-le import InsightWarnings from '../../../../components/app/snaps/insight-warnings'; import { BlockaidResultType } from '../../../../../shared/constants/security-provider'; import { QueuedRequestsBannerAlert } from '../../confirmation/components/queued-requests-banner-alert'; -import SignatureRequestOriginalWarning from './signature-request-original-warning'; export default class SignatureRequestOriginal extends Component { static contextTypes = { @@ -87,7 +86,6 @@ export default class SignatureRequestOriginal extends Component { }; state = { - showSignatureRequestWarning: false, showSignatureInsights: false, }; @@ -350,13 +348,7 @@ export default class SignatureRequestOriginal extends Component { }; render = () => { - const { - messagesCount, - fromAccount: { address, name }, - txData, - warnings, - } = this.props; - const { showSignatureRequestWarning } = this.state; + const { messagesCount, txData, warnings } = this.props; const { t } = this.context; const rejectNText = t('rejectRequestsN', [messagesCount]); @@ -375,23 +367,7 @@ export default class SignatureRequestOriginal extends Component { ) : null} - {showSignatureRequestWarning && ( - { - if (warnings?.length >= 1) { - return this.setState({ - showSignatureInsights: true, - showSignatureRequestWarning: false, - }); - } - return await this.onSubmit(); - }} - onCancel={async (event) => await this.onCancel(event)} - /> - )} {this.state.showSignatureInsights && (