Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
jpuri committed Jun 30, 2023
1 parent baa4191 commit 947bfde
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
10 changes: 5 additions & 5 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
});

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions ui/pages/settings/experimental-tab/experimental-tab.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -113,17 +112,17 @@ export default class ExperimentalTab extends PureComponent {
{t('blockaid')}
</Text>
<ToggleButton
value={blockaidSecurityCheckEnabled}
value={securityAlertsEnabled}
onToggle={(value) => {
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);
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import {
setOpenSeaEnabled,
setTransactionSecurityCheckEnabled,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
setBlockaidSecurityCheckEnabled,
setSecurityAlertsEnabled,
///: END:ONLY_INCLUDE_IN
} from '../../../store/actions';
import {
getUseNftDetection,
getOpenSeaEnabled,
getIsTransactionSecurityCheckEnabled,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
getIsBlockaidSecurityCheckEnabled,
getIsSecurityAlertsEnabled,
///: END:ONLY_INCLUDE_IN
} from '../../../selectors';
import ExperimentalTab from './experimental-tab.component';
Expand All @@ -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
};
};
Expand All @@ -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
};
};
Expand Down
6 changes: 3 additions & 3 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion ui/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 947bfde

Please sign in to comment.