Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding experimental flag for blockaid #19819

Merged
merged 76 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
be06ef7
Integrating ppom-validator with extension
jpuri Jun 8, 2023
3bde08e
Cleanup
jpuri Jun 8, 2023
f2ac25d
Merge branch 'develop' into integrate_ppom
jpuri Jun 8, 2023
4725f55
Fix
jpuri Jun 8, 2023
94d2f9c
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 8, 2023
e6eefd3
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jpuri Jun 9, 2023
6dd4fb5
Updates
jpuri Jun 9, 2023
ef555f3
Updates
jpuri Jun 9, 2023
de5b2aa
Update
jpuri Jun 13, 2023
fb7785c
Merge
jpuri Jun 14, 2023
ec8ca21
Update
jpuri Jun 14, 2023
e221853
Merge branch 'develop' into integrate_ppom
jpuri Jun 15, 2023
f2508e4
Update
jpuri Jun 15, 2023
e2bc18c
Merge branch 'develop' into integrate_ppom
jpuri Jun 15, 2023
ed4cee4
Fix build
jpuri Jun 16, 2023
0e3586b
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 16, 2023
779af11
Merge branch 'develop' into integrate_ppom
jpuri Jun 16, 2023
9490821
Fix build
jpuri Jun 16, 2023
26061d4
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 16, 2023
f327502
fix
jpuri Jun 16, 2023
ae55e26
Lavamoat update
jpuri Jun 16, 2023
9831e2c
Merge branch 'develop' into integrate_ppom
jpuri Jun 16, 2023
7ef885a
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jpuri Jun 20, 2023
2399ce0
Update
jpuri Jun 20, 2023
ad990b7
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 20, 2023
ed12d1a
Merge branch 'develop' into integrate_ppom
jpuri Jun 20, 2023
c4b2da6
Update
jpuri Jun 20, 2023
a46d077
Merge branch 'develop' into integrate_ppom
jpuri Jun 20, 2023
36bf3df
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 20, 2023
3952fca
Update
jpuri Jun 20, 2023
a2805de
Fix
jpuri Jun 22, 2023
683f978
Fix
jpuri Jun 22, 2023
8d23a5b
Fix
jpuri Jun 22, 2023
5889612
Update
jpuri Jun 23, 2023
29a98cc
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jpuri Jun 23, 2023
72ca68f
Update
jpuri Jun 23, 2023
40ff545
Merge branch 'develop' into integrate_ppom
jpuri Jun 23, 2023
c59ef57
Merge branch 'develop' into integrate_ppom
jpuri Jun 26, 2023
5cc769c
fix
jpuri Jun 26, 2023
0ac19ec
Merge branch 'develop' into integrate_ppom
jpuri Jun 26, 2023
62f7315
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jpuri Jun 26, 2023
dd896b6
Update
jpuri Jun 26, 2023
e4d9ee1
Merge
jpuri Jun 27, 2023
8e3a587
Merge
jpuri Jun 27, 2023
4377ae9
Merge
jpuri Jun 27, 2023
6aed845
Merge
jpuri Jun 27, 2023
5e6b274
Merge
jpuri Jun 27, 2023
45d63ee
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jpuri Jun 27, 2023
1bc9e45
Merge
jpuri Jun 27, 2023
eac4271
Merge branch 'develop' into integrate_ppom
jpuri Jun 27, 2023
5d1a51a
Merge
jpuri Jun 27, 2023
b4f40cb
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 27, 2023
43f7dad
Merge
jpuri Jun 27, 2023
467972d
Merge
jpuri Jun 27, 2023
6cfc892
Merge
jpuri Jun 27, 2023
83e72a1
Merge
jpuri Jun 27, 2023
5a756d1
Merge
jpuri Jun 27, 2023
1df10db
Update
jpuri Jun 27, 2023
cede4f5
Build fix
jpuri Jun 27, 2023
64b421e
Merge branch 'develop' into integrate_ppom
jpuri Jun 27, 2023
1d38469
chages
jpuri Jun 27, 2023
15a7786
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jun 27, 2023
9ad9967
Fix code fencing and revert changes to policy
FrederikBolding Jun 27, 2023
7e58163
Fix lint
FrederikBolding Jun 27, 2023
22629c6
Improvement
jpuri Jun 27, 2023
c479d64
Merge branch 'develop' into integrate_ppom
jpuri Jun 27, 2023
e0af11b
update
jpuri Jul 4, 2023
5c117f4
Merge branch 'develop' into integrate_ppom
jpuri Jul 4, 2023
bde6e56
update
jpuri Jul 4, 2023
2c9cf8d
Merge branch 'integrate_ppom' of github.com:MetaMask/metamask-extensi…
jpuri Jul 4, 2023
8e2a2af
Adding experimental flag for blockaid
jpuri Jun 27, 2023
d7957a3
Fixes
jpuri Jul 13, 2023
70f6b5d
Merge
jpuri Jul 14, 2023
401db2f
fix
jpuri Jul 14, 2023
784d950
fix
jpuri Jul 14, 2023
30cbd77
Merge branch 'develop' into adding_blockaid_preference
jpuri Jul 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions app/scripts/controllers/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export default class PreferencesController {
useNftDetection: false,
useCurrencyRateCheck: true,
openSeaEnabled: false,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
securityAlertsEnabled: false,
matthewwalsh0 marked this conversation as resolved.
Show resolved Hide resolved
///: END:ONLY_INCLUDE_IN
advancedGasFee: null,

// WARNING: Do not use feature flags for security-sensitive things.
Expand Down Expand Up @@ -185,6 +188,19 @@ export default class PreferencesController {
});
}

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
/**
* Setter for the `securityAlertsEnabled` property
*
* @param {boolean} securityAlertsEnabled - Whether or not the user prefers to use the security alerts.
*/
setSecurityAlertsEnabled(securityAlertsEnabled) {
this.store.updateState({
securityAlertsEnabled,
});
}
///: END:ONLY_INCLUDE_IN

/**
* Setter for the `advancedGasFee` property
*
Expand Down
14 changes: 14 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,11 @@ export default class MetamaskController extends EventEmitter {
networkControllerMessenger,
'NetworkController:stateChange',
),
securityAlertsEnabled:
this.preferencesController.store.getState().securityAlertsEnabled,
onPreferencesChange: this.preferencesController.store.subscribe.bind(
this.preferencesController.store,
),
});
///: END:ONLY_INCLUDE_IN

Expand Down Expand Up @@ -1596,6 +1601,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 @@ -2153,6 +2161,12 @@ export default class MetamaskController extends EventEmitter {
setOpenSeaEnabled: preferencesController.setOpenSeaEnabled.bind(
preferencesController,
),
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
setSecurityAlertsEnabled:
preferencesController.setSecurityAlertsEnabled.bind(
preferencesController,
),
///: END:ONLY_INCLUDE_IN
setIpfsGateway: preferencesController.setIpfsGateway.bind(
preferencesController,
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,96 @@ exports[`ExperimentalTab with desktop enabled renders ExperimentalTab component
<div
class="settings-page__body"
>
<h4
class="box mm-text mm-text--heading-sm box--margin-bottom-2 box--flex-direction-row box--color-text-alternative"
>
Security
</h4>
<div
class="settings-page__content-row settings-page__content-row-experimental"
>
<div
class="settings-page__content-item"
>
<span>
Security alerts
</span>
<div
class="settings-page__content-description"
>
<p
class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative"
>
Enable this to have your transactions and signature requests reviewed locally (no data shared with third parties) and warnings displayed when malicious activity is detected.
</p>
<p
class="box mm-text mm-text--body-sm box--flex-direction-row box--color-text-alternative"
>
Always be sure to do your own due diligence before approving any requests. There's no guarantee all mailcious activity will be detected by this feature.
</p>
<p
class="box mm-text mm-text--body-sm box--margin-top-3 box--margin-bottom-1 box--flex-direction-row box--color-text-alternative"
>
Select providers:
</p>
<div
class="settings-page__content-item-col settings-page__content-item-col-open-sea"
>
<p
class="box mm-text mm-text--body-md box--flex-direction-row box--color-text-default"
>
Blockaid
</p>
<label
class="toggle-button toggle-button--off"
tabindex="0"
>
<div
style="display: flex; width: 52px; align-items: center; justify-content: flex-start; position: relative; cursor: pointer; background-color: transparent; border: 0px; padding: 0px; user-select: none;"
>
<div
style="width: 40px; height: 24px; padding: 0px; border-radius: 26px; display: flex; align-items: center; justify-content: center; background-color: rgb(242, 244, 246);"
>
<div
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgb(250, 250, 250); margin-top: auto; margin-bottom: auto; line-height: 0; opacity: 0; width: 26px; height: 20px; left: 4px;"
/>
<div
style="font-size: 11px; display: flex; align-items: center; justify-content: center; font-family: 'Helvetica Neue', Helvetica, sans-serif; position: relative; color: rgba(255, 255, 255, 0.6); bottom: 0px; margin-top: auto; margin-bottom: auto; padding-right: 5px; line-height: 0; width: 26px; height: 20px; opacity: 1;"
/>
</div>
<div
style="position: absolute; height: 100%; top: 0px; left: 0px; display: flex; flex: 1; align-self: stretch; align-items: center; justify-content: flex-start;"
>
<div
style="width: 18px; height: 18px; display: flex; align-self: center; box-shadow: none; border-radius: 50%; box-sizing: border-box; position: relative; background-color: rgb(106, 115, 125); left: 3px;"
/>
</div>
<input
style="border: 0px; height: 1px; margin: -1px; overflow: hidden; padding: 0px; position: absolute; width: 1px;"
type="checkbox"
value="false"
/>
</div>
<div
class="toggle-button__status"
>
<span
class="toggle-button__label-off"
/>
<span
class="toggle-button__label-on"
/>
</div>
</label>
</div>
<p
class="box mm-text mm-text--body-md box--margin-top-2 box--flex-direction-row box--color-text-muted"
>
More coming soon...
</p>
</div>
</div>
</div>
<h4
class="box box--margin-top-1 box--margin-bottom-2 box--flex-direction-row typography typography--h4 typography--weight-bold typography--style-normal typography--color-text-alternative"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import { Text } from '../../../components/component-library/text/deprecated';
import {
FONT_WEIGHT,
TextColor,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
TextVariant,
///: END:ONLY_INCLUDE_IN
TypographyVariant,
} from '../../../helpers/constants/design-system';
///: BEGIN:ONLY_INCLUDE_IN(desktop)
Expand All @@ -30,6 +33,10 @@ export default class ExperimentalTab extends PureComponent {
openSeaEnabled: PropTypes.bool,
transactionSecurityCheckEnabled: PropTypes.bool,
setTransactionSecurityCheckEnabled: PropTypes.func,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
securityAlertsEnabled: PropTypes.bool,
setSecurityAlertsEnabled: PropTypes.func,
///: END:ONLY_INCLUDE_IN
};

settingsRefs = Array(
Expand All @@ -53,6 +60,87 @@ export default class ExperimentalTab extends PureComponent {
handleSettingsRefs(t, t('experimental'), this.settingsRefs);
}

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
renderSecurityAlertsToggle() {
const { t } = this.context;

const { securityAlertsEnabled, setSecurityAlertsEnabled } = this.props;

return (
<>
<Text
variant={TextVariant.headingSm}
color={TextColor.textAlternative}
marginBottom={2}
>
{t('security')}
</Text>
<div
ref={this.settingsRefs[1]}
className="settings-page__content-row settings-page__content-row-experimental"
>
<div className="settings-page__content-item">
<span>{t('securityAlerts')}</span>
<div className="settings-page__content-description">
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
>
{t('securityAlertsDescription1')}
</Text>
<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
>
{t('securityAlertsDescription2')}
</Text>

<Text
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
marginTop={3}
marginBottom={1}
>
{t('selectProvider')}
</Text>
<div className="settings-page__content-item-col settings-page__content-item-col-open-sea">
<Text
variant={TextVariant.bodyMd}
color={TextColor.textDefault}
marginBottom={0}
>
{t('blockaid')}
</Text>
<ToggleButton
value={securityAlertsEnabled}
onToggle={(value) => {
this.context.trackEvent({
category: MetaMetricsEventCategory.Settings,
event: 'Enabled/Disable security_alerts_enabled',
properties: {
action: 'Enabled/Disable security_alerts_enabled',
legacy_event: true,
},
});
setSecurityAlertsEnabled(!value || false);
}}
/>
</div>
<Text
variant={TextVariant.bodyMd}
color={TextColor.textMuted}
marginTop={2}
>
{t('moreComingSoon')}
</Text>
</div>
</div>
</div>
</>
);
}
///: END:ONLY_INCLUDE_IN

renderOpenSeaEnabledToggle() {
const { t } = this.context;
const {
Expand Down Expand Up @@ -261,6 +349,11 @@ export default class ExperimentalTab extends PureComponent {
render() {
return (
<div className="settings-page__body">
{
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
this.renderSecurityAlertsToggle()
///: END:ONLY_INCLUDE_IN
}
{this.renderTransactionSecurityCheckToggle()}
{this.renderOpenSeaEnabledToggle()}
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import {
setUseNftDetection,
setOpenSeaEnabled,
setTransactionSecurityCheckEnabled,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
setSecurityAlertsEnabled,
///: END:ONLY_INCLUDE_IN
} from '../../../store/actions';
import {
getUseNftDetection,
getOpenSeaEnabled,
getIsTransactionSecurityCheckEnabled,
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
getIsSecurityAlertsEnabled,
///: END:ONLY_INCLUDE_IN
} from '../../../selectors';
import ExperimentalTab from './experimental-tab.component';

Expand All @@ -19,6 +25,9 @@ const mapStateToProps = (state) => {
openSeaEnabled: getOpenSeaEnabled(state),
transactionSecurityCheckEnabled:
getIsTransactionSecurityCheckEnabled(state),
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
securityAlertsEnabled: getIsSecurityAlertsEnabled(state),
///: END:ONLY_INCLUDE_IN
};
};

Expand All @@ -28,6 +37,9 @@ const mapDispatchToProps = (dispatch) => {
setOpenSeaEnabled: (val) => dispatch(setOpenSeaEnabled(val)),
setTransactionSecurityCheckEnabled: (val) =>
dispatch(setTransactionSecurityCheckEnabled(val)),
///: BEGIN:ONLY_INCLUDE_IN(blockaid)
setSecurityAlertsEnabled: (val) => setSecurityAlertsEnabled(val),
///: END:ONLY_INCLUDE_IN
};
};

Expand Down
12 changes: 12 additions & 0 deletions ui/selectors/selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,18 @@ export function getIsTransactionSecurityCheckEnabled(state) {
return state.metamask.transactionSecurityCheckEnabled;
}

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
/**
* To get the `getIsSecurityAlertsEnabled` value which determines whether security check is enabled
*
* @param {*} state
* @returns Boolean
*/
export function getIsSecurityAlertsEnabled(state) {
return state.metamask.securityAlertsEnabled;
}
///: END:ONLY_INCLUDE_IN

export function getIsCustomNetwork(state) {
const chainId = getCurrentChainId(state);

Expand Down
10 changes: 10 additions & 0 deletions ui/store/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4344,6 +4344,16 @@ export function setTransactionSecurityCheckEnabled(
};
}

///: BEGIN:ONLY_INCLUDE_IN(blockaid)
export function setSecurityAlertsEnabled(val: boolean): void {
try {
submitRequestToBackground('setSecurityAlertsEnabled', [val]);
} catch (error) {
logErrorWithMessage(error);
}
}
///: END:ONLY_INCLUDE_IN

export function setFirstTimeUsedNetwork(chainId: string) {
return submitRequestToBackground('setFirstTimeUsedNetwork', [chainId]);
}
Expand Down