From b0258add1ae169a285b4b9bc4a4fefd7abe35e8c Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 23 May 2024 15:20:09 -0500 Subject: [PATCH] remove disabledRpcMethodPreferences, need migration --- app/scripts/controllers/preferences.js | 24 --------- .../lib/createRPCMethodTrackingMiddleware.js | 53 ++----------------- app/scripts/lib/setupSentry.js | 1 - app/scripts/metamask-controller.js | 4 -- test/data/mock-send-state.json | 3 -- test/e2e/accounts/common.ts | 5 -- .../tests/metrics/signature-approved.spec.js | 5 -- ...rs-after-init-opt-in-background-state.json | 1 - .../errors-after-init-opt-in-ui-state.json | 1 - test/e2e/tests/signature/eth-sign.spec.js | 10 ---- ui/components/app/modals/modal.js | 13 ----- .../advanced-tab/advanced-tab.container.js | 6 --- ui/selectors/selectors.js | 4 -- ui/store/actions.ts | 14 ----- 14 files changed, 3 insertions(+), 141 deletions(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index d2748ec0e15a..48dbbe403de7 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -47,7 +47,6 @@ export default class PreferencesController { useNonceField: false, usePhishDetect: true, dismissSeedBackUpReminder: false, - disabledRpcMethodPreferences: {}, useMultiAccountBalanceChecker: true, hasDismissedOpenSeaToBlockaidBanner: false, useSafeChainsListValidation: true, @@ -558,25 +557,6 @@ export default class PreferencesController { }); } - /** - * A setter for the user preference to enable/disable rpc methods - * - * @param {string} methodName - The RPC method name to change the setting of - * @param {bool} isEnabled - true to enable the rpc method - */ - async setDisabledRpcMethodPreference(methodName, isEnabled) { - const currentRpcMethodPreferences = - this.store.getState().disabledRpcMethodPreferences; - const updatedRpcMethodPreferences = { - ...currentRpcMethodPreferences, - [methodName]: isEnabled, - }; - - this.store.updateState({ - disabledRpcMethodPreferences: updatedRpcMethodPreferences, - }); - } - /** * A setter for the incomingTransactions in preference to be updated * @@ -593,10 +573,6 @@ export default class PreferencesController { this.store.updateState({ enableMV3TimestampSave: value }); } - getRpcMethodPreferences() { - return this.store.getState().disabledRpcMethodPreferences; - } - ///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps) setSnapsAddSnapAccountModalDismissed(value) { this.store.updateState({ snapsAddSnapAccountModalDismissed: value }); diff --git a/app/scripts/lib/createRPCMethodTrackingMiddleware.js b/app/scripts/lib/createRPCMethodTrackingMiddleware.js index 195f9c05fed5..1b1a24630695 100644 --- a/app/scripts/lib/createRPCMethodTrackingMiddleware.js +++ b/app/scripts/lib/createRPCMethodTrackingMiddleware.js @@ -17,11 +17,7 @@ import { } from '../../../shared/constants/security-provider'; ///: BEGIN:ONLY_INCLUDE_IF(blockaid) -import { - EIP712_PRIMARY_TYPE_PERMIT, - SIGNING_METHODS, -} from '../../../shared/constants/transaction'; -import { getBlockaidMetricsProps } from '../../../ui/helpers/utils/metrics'; +import { EIP712_PRIMARY_TYPE_PERMIT } from '../../../shared/constants/transaction'; ///: END:ONLY_INCLUDE_IF import { REDESIGN_APPROVAL_TYPES } from '../../../ui/pages/confirmations/utils/confirm'; import { getSnapAndHardwareInfoForMetrics } from './snap-keyring/metrics'; @@ -42,7 +38,6 @@ const RATE_LIMIT_TYPES = { * default is RANDOM_SAMPLE */ const RATE_LIMIT_MAP = { - [MESSAGE_TYPE.ETH_SIGN]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V3]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, [MESSAGE_TYPE.ETH_SIGN_TYPED_DATA_V4]: RATE_LIMIT_TYPES.NON_RATE_LIMITED, @@ -154,7 +149,6 @@ let globalRateLimitCount = 0; * @param {Function} opts.getDeviceModel * @param {Function} opts.isConfirmationRedesignEnabled * @param {RestrictedControllerMessenger} opts.snapAndHardwareMessenger - * @param {AppStateController} opts.appStateController * @param {number} [opts.globalRateLimitTimeout] - time, in milliseconds, of the sliding * time window that should limit the number of method calls tracked to globalRateLimitMaxAmount. * @param {number} [opts.globalRateLimitMaxAmount] - max number of method calls that should @@ -174,9 +168,6 @@ export default function createRPCMethodTrackingMiddleware({ getDeviceModel, isConfirmationRedesignEnabled, snapAndHardwareMessenger, - ///: BEGIN:ONLY_INCLUDE_IF(blockaid) - appStateController, - ///: END:ONLY_INCLUDE_IF }) { return async function rpcMethodTrackingMiddleware( /** @type {any} */ req, @@ -355,18 +346,8 @@ export default function createRPCMethodTrackingMiddleware({ return callback(); } - // The rpc error methodNotFound implies that 'eth_sign' is disabled in Advanced Settings - const isDisabledEthSignAdvancedSetting = - method === MESSAGE_TYPE.ETH_SIGN && - res.error?.code === errorCodes.rpc.methodNotFound; - - const isDisabledRPCMethod = isDisabledEthSignAdvancedSetting; - let event; - if (isDisabledRPCMethod) { - event = eventType.FAILED; - eventProperties.error = res.error; - } else if (res.error?.code === errorCodes.provider.userRejectedRequest) { + if (res.error?.code === errorCodes.provider.userRejectedRequest) { event = eventType.REJECTED; } else if ( res.error?.code === errorCodes.rpc.internal && @@ -379,41 +360,13 @@ export default function createRPCMethodTrackingMiddleware({ event = eventType.APPROVED; } - let blockaidMetricProps = {}; - - ///: BEGIN:ONLY_INCLUDE_IF(blockaid) - if (!isDisabledRPCMethod) { - if (SIGNING_METHODS.includes(method)) { - const securityAlertResponse = - appStateController.getSignatureSecurityAlertResponse( - req.securityAlertResponse?.securityAlertId, - ); - - blockaidMetricProps = getBlockaidMetricsProps({ - securityAlertResponse, - }); - } - } - ///: END:ONLY_INCLUDE_IF - - const properties = { - ...eventProperties, - ...blockaidMetricProps, - // if security_alert_response from blockaidMetricProps is Benign, force set security_alert_reason to empty string - security_alert_reason: - blockaidMetricProps.security_alert_response === - BlockaidResultType.Benign - ? '' - : blockaidMetricProps.security_alert_reason, - }; - trackEvent({ event, category: MetaMetricsEventCategory.InpageProvider, referrer: { url: origin, }, - properties, + properties: eventProperties, }); return callback(); diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 92173fc5f72c..27bdcc76644d 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -224,7 +224,6 @@ export const SENTRY_BACKGROUND_STATE = { PreferencesController: { advancedGasFee: true, currentLocale: true, - disabledRpcMethodPreferences: true, dismissSeedBackUpReminder: true, featureFlags: true, forgottenPassword: true, diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 9f86b3d5237a..de0e8e882ead 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3249,10 +3249,6 @@ export default class MetamaskController extends EventEmitter { preferencesController.setDismissSeedBackUpReminder.bind( preferencesController, ), - setDisabledRpcMethodPreference: - preferencesController.setDisabledRpcMethodPreference.bind( - preferencesController, - ), getRpcMethodPreferences: preferencesController.getRpcMethodPreferences.bind( preferencesController, diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json index c8604c96c055..f2e89766a207 100644 --- a/test/data/mock-send-state.json +++ b/test/data/mock-send-state.json @@ -64,9 +64,6 @@ "metamask": { "ipfsGateway": "", "dismissSeedBackUpReminder": false, - "disabledRpcMethodPreferences": { - "eth_sign": false - }, "usePhishDetect": true, "participateInMetaMetrics": false, "gasEstimateType": "fee-market", diff --git a/test/e2e/accounts/common.ts b/test/e2e/accounts/common.ts index f4039d6b6533..f5be90564143 100644 --- a/test/e2e/accounts/common.ts +++ b/test/e2e/accounts/common.ts @@ -29,11 +29,6 @@ export const accountSnapFixtures = (title: string | undefined) => { dapp: true, fixtures: new FixtureBuilder() .withPermissionControllerConnectedToTestDapp(false) - .withPreferencesController({ - disabledRpcMethodPreferences: { - eth_sign: true, - }, - }) .build(), ganacheOptions: multipleGanacheOptions, title, diff --git a/test/e2e/tests/metrics/signature-approved.spec.js b/test/e2e/tests/metrics/signature-approved.spec.js index c5b4a2ac1165..a175f049ee61 100644 --- a/test/e2e/tests/metrics/signature-approved.spec.js +++ b/test/e2e/tests/metrics/signature-approved.spec.js @@ -244,11 +244,6 @@ describe('Signature Approved Event @no-mmi', function () { dapp: true, fixtures: new FixtureBuilder() .withPermissionControllerConnectedToTestDapp() - .withPreferencesController({ - disabledRpcMethodPreferences: { - eth_sign: true, - }, - }) .withMetaMetricsController({ metaMetricsId: 'fake-metrics-id', participateInMetaMetrics: true, diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 534d5e4d606a..160b56f2e289 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -171,7 +171,6 @@ "useNonceField": false, "usePhishDetect": true, "dismissSeedBackUpReminder": true, - "disabledRpcMethodPreferences": { "eth_sign": false }, "useMultiAccountBalanceChecker": true, "hasDismissedOpenSeaToBlockaidBanner": false, "useSafeChainsListValidation": "boolean", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 7bcbd81bf539..b0a9d63995d5 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -106,7 +106,6 @@ "useNonceField": false, "usePhishDetect": true, "dismissSeedBackUpReminder": true, - "disabledRpcMethodPreferences": { "eth_sign": false }, "useMultiAccountBalanceChecker": true, "hasDismissedOpenSeaToBlockaidBanner": false, "useSafeChainsListValidation": true, diff --git a/test/e2e/tests/signature/eth-sign.spec.js b/test/e2e/tests/signature/eth-sign.spec.js index c62869efe0f1..42e50a840671 100644 --- a/test/e2e/tests/signature/eth-sign.spec.js +++ b/test/e2e/tests/signature/eth-sign.spec.js @@ -45,11 +45,6 @@ describe('Eth sign', function () { { dapp: true, fixtures: new FixtureBuilder() - .withPreferencesController({ - disabledRpcMethodPreferences: { - eth_sign: true, - }, - }) .withPermissionControllerConnectedToTestDapp() .build(), ganacheOptions: defaultGanacheOptions, @@ -99,11 +94,6 @@ describe('Eth sign', function () { { dapp: true, fixtures: new FixtureBuilder() - .withPreferencesController({ - disabledRpcMethodPreferences: { - eth_sign: true, - }, - }) .withPermissionControllerConnectedToTestDapp() .build(), ganacheOptions: defaultGanacheOptions, diff --git a/ui/components/app/modals/modal.js b/ui/components/app/modals/modal.js index f3eb1a950a40..c0b00d981e03 100644 --- a/ui/components/app/modals/modal.js +++ b/ui/components/app/modals/modal.js @@ -29,7 +29,6 @@ import ConfirmDeleteNetwork from './confirm-delete-network'; import ConvertTokenToNftModal from './convert-token-to-nft-modal/convert-token-to-nft-modal'; import CustomizeNonceModal from './customize-nonce'; import EditApprovalPermission from './edit-approval-permission'; -import EthSignModal from './eth-sign-modal/eth-sign-modal'; import FadeModal from './fade-modal'; import NewAccountModal from './new-account-modal'; import RejectTransactions from './reject-transactions'; @@ -179,18 +178,6 @@ const MODALS = { }, }, - ETH_SIGN: { - contents: , - mobileModalStyle: { - ...modalContainerMobileStyle, - }, - laptopModalStyle: { - ...modalContainerLaptopStyle, - }, - contentStyle: { - borderRadius: '8px', - }, - }, CONFIRM_REMOVE_ACCOUNT: { contents: , mobileModalStyle: { diff --git a/ui/pages/settings/advanced-tab/advanced-tab.container.js b/ui/pages/settings/advanced-tab/advanced-tab.container.js index a0dcd4a7bcc3..ebcda74d6755 100644 --- a/ui/pages/settings/advanced-tab/advanced-tab.container.js +++ b/ui/pages/settings/advanced-tab/advanced-tab.container.js @@ -8,7 +8,6 @@ import { displayWarning, restoreUserData, setAutoLockTimeLimit, - setDisabledRpcMethodPreference, setDismissSeedBackUpReminder, setFeatureFlag, setShowExtensionInFullSizeView, @@ -27,7 +26,6 @@ export const mapStateToProps = (state) => { } = state; const { featureFlags: { sendHexData } = {}, - disabledRpcMethodPreferences, useNonceField, dismissSeedBackUpReminder, } = metamask; @@ -49,7 +47,6 @@ export const mapStateToProps = (state) => { autoLockTimeLimit, useNonceField, dismissSeedBackUpReminder, - disabledRpcMethodPreferences, }; }; @@ -82,9 +79,6 @@ export const mapDispatchToProps = (dispatch) => { setDismissSeedBackUpReminder: (value) => { return dispatch(setDismissSeedBackUpReminder(value)); }, - setDisabledRpcMethodPreference: (methodName, isEnabled) => { - return dispatch(setDisabledRpcMethodPreference(methodName, isEnabled)); - }, }; }; diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 73f4af5637d7..a0758fd7844a 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -913,10 +913,6 @@ export function getTestNetworkBackgroundColor(state) { } } -export function getDisabledRpcMethodPreferences(state) { - return state.metamask.disabledRpcMethodPreferences; -} - export function getShouldShowFiat(state) { const isMainNet = getIsMainnet(state); const isLineaMainNet = getIsLineaMainnet(state); diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 5b417a9a5e98..6b0cf385c3aa 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4227,20 +4227,6 @@ export function setDismissSeedBackUpReminder( }; } -export function setDisabledRpcMethodPreference( - methodName: string, - value: number, -): ThunkAction { - return async (dispatch: MetaMaskReduxDispatch) => { - dispatch(showLoadingIndication()); - await submitRequestToBackground('setDisabledRpcMethodPreference', [ - methodName, - value, - ]); - dispatch(hideLoadingIndication()); - }; -} - export function getRpcMethodPreferences(): ThunkAction< void, MetaMaskReduxState,