From 947bfde75b718a4e98ec3b9f9596cc7d2f05c1fa Mon Sep 17 00:00:00 2001 From: Jyoti Puri Date: Fri, 30 Jun 2023 22:26:17 +0530 Subject: [PATCH] Update --- app/scripts/controllers/preferences.js | 10 +++++----- app/scripts/metamask-controller.js | 15 +++++++-------- .../experimental-tab.component.js | 15 +++++++-------- .../experimental-tab.container.js | 9 ++++----- ui/selectors/selectors.js | 6 +++--- ui/store/actions.ts | 2 +- 6 files changed, 27 insertions(+), 30 deletions(-) diff --git a/app/scripts/controllers/preferences.js b/app/scripts/controllers/preferences.js index 35a1d61ef7ba..2ce5d7e726ae 100644 --- a/app/scripts/controllers/preferences.js +++ b/app/scripts/controllers/preferences.js @@ -42,7 +42,7 @@ export default class PreferencesController { useCurrencyRateCheck: true, openSeaEnabled: false, ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - blockaidSecurityCheckEnabled: false, + securityAlertsEnabled: false, ///: END:ONLY_INCLUDE_IN advancedGasFee: null, @@ -194,13 +194,13 @@ export default class PreferencesController { ///: BEGIN:ONLY_INCLUDE_IN(blockaid) /** - * Setter for the `blockaidSecurityCheckEnabled` property + * Setter for the `securityAlertsEnabled` property * - * @param {boolean} blockaidSecurityCheckEnabled - Whether or not the user prefers to use the blockaid for security alerts. + * @param {boolean} securityAlertsEnabled - Whether or not the user prefers to use the security alerts. */ - setBlockaidSecurityCheckEnabled(blockaidSecurityCheckEnabled) { + setSecurityAlertsEnabled(securityAlertsEnabled) { this.store.updateState({ - blockaidSecurityCheckEnabled, + securityAlertsEnabled, }); } ///: END:ONLY_INCLUDE_IN diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index fa386290ca55..2488e0a0a83c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -637,9 +637,8 @@ export default class MetamaskController extends EventEmitter { networkControllerMessenger, 'NetworkController:stateChange', ), - blockaidSecurityCheckEnabled: - this.preferencesController.store.getState() - .blockaidSecurityCheckEnabled, + securityAlertsEnabled: + this.preferencesController.store.getState().securityAlertsEnabled, onPreferencesChange: this.preferencesController.store.subscribe.bind( this.preferencesController.store, ), @@ -1565,6 +1564,9 @@ export default class MetamaskController extends EventEmitter { this.institutionalFeaturesController.store, MmiConfigurationController: this.mmiConfigurationController.store, ///: END:ONLY_INCLUDE_IN + ///: BEGIN:ONLY_INCLUDE_IN(blockaid) + PPOMController: this.ppomController, + ///: END:ONLY_INCLUDE_IN ...resetOnRestartStore, }); @@ -1608,9 +1610,6 @@ export default class MetamaskController extends EventEmitter { this.institutionalFeaturesController.store, MmiConfigurationController: this.mmiConfigurationController.store, ///: END:ONLY_INCLUDE_IN - ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - PPOMController: this.PPOMController.store, - ///: END:ONLY_INCLUDE_IN ...resetOnRestartStore, }, controllerMessenger: this.controllerMessenger, @@ -2092,8 +2091,8 @@ export default class MetamaskController extends EventEmitter { preferencesController, ), ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - setBlockaidSecurityCheckEnabled: - preferencesController.setBlockaidSecurityCheckEnabled.bind( + setSecurityAlertsEnabled: + preferencesController.setSecurityAlertsEnabled.bind( preferencesController, ), ///: END:ONLY_INCLUDE_IN diff --git a/ui/pages/settings/experimental-tab/experimental-tab.component.js b/ui/pages/settings/experimental-tab/experimental-tab.component.js index 9fcf70131f9f..c3d24125e3ee 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.component.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.component.js @@ -34,8 +34,8 @@ export default class ExperimentalTab extends PureComponent { transactionSecurityCheckEnabled: PropTypes.bool, setTransactionSecurityCheckEnabled: PropTypes.func, ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - blockaidSecurityCheckEnabled: PropTypes.bool, - setBlockaidSecurityCheckEnabled: PropTypes.func, + securityAlertsEnabled: PropTypes.bool, + setSecurityAlertsEnabled: PropTypes.func, ///: END:ONLY_INCLUDE_IN }; @@ -64,8 +64,7 @@ export default class ExperimentalTab extends PureComponent { renderSecurityAlertsToggle() { const { t } = this.context; - const { blockaidSecurityCheckEnabled, setBlockaidSecurityCheckEnabled } = - this.props; + const { securityAlertsEnabled, setSecurityAlertsEnabled } = this.props; return ( <> @@ -113,17 +112,17 @@ export default class ExperimentalTab extends PureComponent { {t('blockaid')} { this.context.trackEvent({ category: MetaMetricsEventCategory.Settings, - event: 'Enabled/Disable BlockaidSecurityCheckEnabled', + event: 'Enabled/Disable security_alerts_enabled', properties: { - action: 'Enabled/Disable BlockaidSecurityCheckEnabled', + action: 'Enabled/Disable security_alerts_enabled', legacy_event: true, }, }); - setBlockaidSecurityCheckEnabled(!value); + setSecurityAlertsEnabled(!value); }} /> diff --git a/ui/pages/settings/experimental-tab/experimental-tab.container.js b/ui/pages/settings/experimental-tab/experimental-tab.container.js index a36a9d6bf40f..24b412bdeea2 100644 --- a/ui/pages/settings/experimental-tab/experimental-tab.container.js +++ b/ui/pages/settings/experimental-tab/experimental-tab.container.js @@ -6,7 +6,7 @@ import { setOpenSeaEnabled, setTransactionSecurityCheckEnabled, ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - setBlockaidSecurityCheckEnabled, + setSecurityAlertsEnabled, ///: END:ONLY_INCLUDE_IN } from '../../../store/actions'; import { @@ -14,7 +14,7 @@ import { getOpenSeaEnabled, getIsTransactionSecurityCheckEnabled, ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - getIsBlockaidSecurityCheckEnabled, + getIsSecurityAlertsEnabled, ///: END:ONLY_INCLUDE_IN } from '../../../selectors'; import ExperimentalTab from './experimental-tab.component'; @@ -26,7 +26,7 @@ const mapStateToProps = (state) => { transactionSecurityCheckEnabled: getIsTransactionSecurityCheckEnabled(state), ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - blockaidSecurityCheckEnabled: getIsBlockaidSecurityCheckEnabled(state), + securityAlertsEnabled: getIsSecurityAlertsEnabled(state), ///: END:ONLY_INCLUDE_IN }; }; @@ -38,8 +38,7 @@ const mapDispatchToProps = (dispatch) => { setTransactionSecurityCheckEnabled: (val) => dispatch(setTransactionSecurityCheckEnabled(val)), ///: BEGIN:ONLY_INCLUDE_IN(blockaid) - setBlockaidSecurityCheckEnabled: (val) => - setBlockaidSecurityCheckEnabled(val), + setSecurityAlertsEnabled: (val) => setSecurityAlertsEnabled(val), ///: END:ONLY_INCLUDE_IN }; }; diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index bbd3aa444824..c3bea113f938 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -1401,13 +1401,13 @@ export function getIsTransactionSecurityCheckEnabled(state) { ///: BEGIN:ONLY_INCLUDE_IN(blockaid) /** - * To get the `getIsBlockaidSecurityCheckEnabled` value which determines whether blockaid security check is enabled + * To get the `getIsSecurityAlertsEnabled` value which determines whether security check is enabled * * @param {*} state * @returns Boolean */ -export function getIsBlockaidSecurityCheckEnabled(state) { - return state.metamask.blockaidSecurityCheckEnabled; +export function getIsSecurityAlertsEnabled(state) { + return state.metamask.securityAlertsEnabled; } ///: END:ONLY_INCLUDE_IN diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 2eaccfd6e9e6..0ceca00658ee 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -4245,7 +4245,7 @@ export function setTransactionSecurityCheckEnabled( } ///: BEGIN:ONLY_INCLUDE_IN(blockaid) -export function setBlockaidSecurityCheckEnabled(val: boolean): void { +export function setSecurityAlertsEnabled(val: boolean): void { try { submitRequestToBackground('setTransactionSecurityCheckEnabled', [[val]]); } catch (error) {