Skip to content

Commit

Permalink
Merge branch 'develop' into bump-rate-limit-controller
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesposito committed May 8, 2024
2 parents 3c34835 + f1e1ed0 commit 6d6e814
Show file tree
Hide file tree
Showing 26 changed files with 294 additions and 48 deletions.
149 changes: 149 additions & 0 deletions .yarn/patches/@metamask-snaps-controllers-npm-8.0.0-7e59688855.patch

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -756,12 +756,6 @@
"@metamask/obs-store": true
}
},
"@metamask-institutional/portfolio-dashboard": {
"globals": {
"console.log": true,
"fetch": true
}
},
"@metamask-institutional/rpc-allowlist": {
"globals": {
"URL": true
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
"@metamask-institutional/custody-keyring": "^1.1.0",
"@metamask-institutional/extension": "^0.3.21",
"@metamask-institutional/institutional-features": "^1.3.0",
"@metamask-institutional/portfolio-dashboard": "^1.4.0",
"@metamask-institutional/portfolio-dashboard": "^1.4.1",
"@metamask-institutional/rpc-allowlist": "^1.0.3",
"@metamask-institutional/sdk": "^0.1.26",
"@metamask-institutional/transaction-update": "^0.2.0",
Expand Down Expand Up @@ -322,7 +322,7 @@
"@metamask/selected-network-controller": "^13.0.0",
"@metamask/signature-controller": "^12.0.0",
"@metamask/smart-transactions-controller": "^10.0.0",
"@metamask/snaps-controllers": "^8.0.0",
"@metamask/snaps-controllers": "patch:@metamask/snaps-controllers@npm%3A8.0.0#~/.yarn/patches/@metamask-snaps-controllers-npm-8.0.0-7e59688855.patch",
"@metamask/snaps-execution-environments": "^6.0.2",
"@metamask/snaps-rpc-methods": "^8.0.0",
"@metamask/snaps-sdk": "^4.0.1",
Expand Down
11 changes: 10 additions & 1 deletion test/e2e/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,17 @@ const onboardingCompleteWalletCreationWithOptOut = async (driver) => {
await driver.findElement({ text: 'Wallet creation successful', tag: 'h2' });
// opt-out from third party API
await driver.clickElement({ text: 'Advanced configuration', tag: 'a' });
await driver.clickElement(
'[data-testid="basic-functionality-toggle"] .toggle-button',
);
await driver.clickElement('[id="basic-configuration-checkbox"]');
await driver.clickElement({ text: 'Turn off', tag: 'button' });

await Promise.all(
(
await driver.findClickableElements('.toggle-button.toggle-button--on')
await driver.findClickableElements(
'.toggle-button.toggle-button--on:not([data-testid="basic-functionality-toggle"] .toggle-button)',
)
).map((toggle) => toggle.click()),
);
// complete onboarding
Expand Down Expand Up @@ -874,6 +882,7 @@ async function waitForAccountRendered(driver) {

/**
* Unlock the wallet with the default password.
* This method is intended to replace driver.navigate and should not be called after driver.navigate.
*
* @param {WebDriver} driver - The webdriver instance
* @param {object} options - Options for unlocking the wallet
Expand Down
1 change: 1 addition & 0 deletions test/e2e/json-rpc/switchEthereumChain.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('Switch Ethereum Chain for two dapps', function () {
.withNetworkControllerDoubleGanache()
.build(),
dappOptions: { numberOfDapps: 2 },

ganacheOptions: {
...defaultGanacheOptions,
concurrent: [{ port: 8546, chainId: 1338 }],
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/mmi/specs/navigation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ test.describe('MMI Navigation', () => {
context,
mainMenuPage.page,
'learn more',
'https://support.metamask.io/token-swaps/what-is-smart-swaps/',
'https://support.metamask.io',
);

await mainMenuPage.selectSettings('Security & privacy');
Expand Down
1 change: 0 additions & 1 deletion test/e2e/snaps/test-snap-namelookup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('Test Snap Name Lookup', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);

// navigate to test snaps page and connect
Expand Down
1 change: 0 additions & 1 deletion test/e2e/snaps/test-snap-siginsights.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ describe('Test Snap Signature Insights', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);

// navigate to test snaps page and connect
Expand Down
1 change: 0 additions & 1 deletion test/e2e/snaps/test-snap-txinsights-v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('Test Snap TxInsights-v2', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);

// navigate to test snaps page and connect
Expand Down
6 changes: 0 additions & 6 deletions test/e2e/tests/metrics/dapp-viewed.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await connectToDapp(driver);
const events = await getEventPayloads(driver, mockedEndpoints);
Expand All @@ -111,7 +110,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);

await connectToDapp(driver);
Expand Down Expand Up @@ -147,7 +145,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down Expand Up @@ -186,7 +183,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down Expand Up @@ -230,7 +226,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down Expand Up @@ -322,7 +317,6 @@ describe('Dapp viewed Event @no-mmi', function () {
testSpecificMock: mockSegment,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/tests/multichain/connection-page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Connections page', function () {
if (!process.env.MULTICHAIN) {
return;
}
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down Expand Up @@ -103,7 +102,6 @@ describe('Connections page', function () {
if (!process.env.MULTICHAIN) {
return;
}
await driver.navigate();
await unlockWallet(driver);
await waitForAccountRendered(driver);
await connectToDapp(driver);
Expand Down
2 changes: 0 additions & 2 deletions test/e2e/tests/multichain/permission-page.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ describe('Permissions Page', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);
if (!process.env.MULTICHAIN) {
return;
Expand Down Expand Up @@ -54,7 +53,6 @@ describe('Permissions Page', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);
if (!process.env.MULTICHAIN) {
return;
Expand Down
33 changes: 31 additions & 2 deletions test/e2e/tests/onboarding/onboarding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,37 @@ describe('MetaMask onboarding @no-mmi', function () {
);
});

it('User can turn off basic functionality in advanced configurations', async function () {
await withFixtures(
{
fixtures: new FixtureBuilder({ onboarding: true }).build(),
ganacheOptions: defaultGanacheOptions,
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await importSRPOnboardingFlow(
driver,
TEST_SEED_PHRASE,
WALLET_PASSWORD,
);

await driver.clickElement({ text: 'Advanced configuration', tag: 'a' });
await driver.clickElement(
'[data-testid="basic-functionality-toggle"] .toggle-button',
);
await driver.clickElement('[id="basic-configuration-checkbox"]');
await driver.clickElement({ text: 'Turn off', tag: 'button' });
await driver.clickElement({ text: 'Done', tag: 'button' });
// Check that the 'basic functionality is off' banner is displayed on the home screen after onboarding completion
await driver.waitForSelector({
text: 'Basic functionality is off',
css: '.mm-banner-alert',
});
},
);
});

it("doesn't make any network requests to infura before onboarding is completed", async function () {
async function mockInfura(mockServer) {
const infuraUrl =
Expand Down Expand Up @@ -472,8 +503,6 @@ describe('MetaMask onboarding @no-mmi', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();

await unlockWallet(driver);

// First screen we should be on is MetaMetrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Migrate Opensea to Blockaid Banner @no-mmi', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);
await openDapp(driver);

Expand Down Expand Up @@ -64,7 +63,6 @@ describe('Migrate Opensea to Blockaid Banner @no-mmi', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);
await openDapp(driver);

Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/ppom/ppom-blockaid-alert-metrics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ describe('Confirmation Security Alert - Blockaid @no-mmi', function () {
},

async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);
await openDapp(driver);

Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/ppom/ppom-blockaid-toggle-metrics.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ describe('PPOM Blockaid Alert - Metrics @no-mmi', function () {
testSpecificMock: mockServerCalls,
},
async ({ driver, mockedEndpoint: mockedEndpoints }) => {
await driver.navigate();
await unlockWallet(driver);

// toggle on
Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/ppom/ppom-toggle-settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ describe('PPOM Settings @no-mmi', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);

await openDapp(driver);
Expand Down
1 change: 0 additions & 1 deletion test/e2e/tests/request-queuing/enable-queuing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ describe('Toggle Request Queuing Setting', function () {
title: this.test.fullTitle(),
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);

// Open account menu button
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/tests/request-queuing/ui.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ async function openDappAndSwitchChain(driver, dappUrl, chainId) {
params: [{ chainId }],
});

driver.executeScript(
`return window.ethereum.request(${switchChainRequest})`,
await driver.executeScript(
`window.ethereum.request(${switchChainRequest})`,
);

await driver.delay(veryLargeDelayMs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('The provider', function () {
title: this.test.title,
},
async ({ driver }) => {
await driver.navigate();
await unlockWallet(driver);
await openDapp(driver);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import React, { useMemo, useState } from 'react';
import { useLocation } from 'react-router-dom';
import { useDispatch, useSelector } from 'react-redux';
import {
Expand Down Expand Up @@ -43,7 +43,9 @@ export function BasicConfigurationModal() {
const dispatch = useDispatch();
const isExternalServicesEnabled = useSelector(getUseExternalServices);
const { pathname } = useLocation();
const onboardingFlow = pathname === ONBOARDING_PRIVACY_SETTINGS_ROUTE;
const onboardingFlow = useMemo(() => {
return pathname === ONBOARDING_PRIVACY_SETTINGS_ROUTE;
}, [pathname]);

function closeModal() {
dispatch(hideBasicFunctionalityModal());
Expand Down Expand Up @@ -136,9 +138,7 @@ export function BasicConfigurationModal() {
dispatch(onboardingToggleBasicFunctionalityOff());
} else {
closeModal();
isExternalServicesEnabled
? dispatch(toggleExternalServices(false))
: dispatch(toggleExternalServices(true));
dispatch(toggleExternalServices(!isExternalServicesEnabled));
}
}}
danger={isExternalServicesEnabled}
Expand Down
25 changes: 25 additions & 0 deletions ui/pages/confirmations/confirmation/confirmation.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import { ApprovalType } from '@metamask/controller-utils';
///: END:ONLY_INCLUDE_IF
import fetchWithCache from '../../../../shared/lib/fetch-with-cache';
import Box from '../../../components/ui/box';
import {
MetaMetricsEventCategory,
MetaMetricsEventName,
} from '../../../../shared/constants/metametrics';
import MetaMaskTemplateRenderer from '../../../components/app/metamask-template-renderer';
import ConfirmationWarningModal from '../components/confirmation-warning-modal';
import { DEFAULT_ROUTE } from '../../../helpers/constants/routes';
Expand Down Expand Up @@ -456,6 +460,27 @@ export default function ConfirmationPage({
};
const handleSubmit = async () => {
setLoading(true);

if (
pendingConfirmation?.requestData?.fromNetworkConfiguration?.chainId &&
pendingConfirmation?.requestData?.toNetworkConfiguration?.chainId
) {
trackEvent({
category: MetaMetricsEventCategory.Network,
event: MetaMetricsEventName.NavNetworkSwitched,
properties: {
location: 'Switch Modal',
from_network:
pendingConfirmation.requestData.fromNetworkConfiguration.chainId,
to_network:
pendingConfirmation.requestData.toNetworkConfiguration.chainId,
referrer: {
url: window.location.origin,
},
},
});
}

if (templateState[pendingConfirmation.id]?.useWarningModal) {
setShowWarningModal(true);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default function PrivacySettings() {
data-testid="privacy-settings-settings"
>
<Setting
dataTestId="basic-functionality-toggle"
value={externalServicesOnboardingToggleState}
setValue={(toggledValue) => {
if (toggledValue === false) {
Expand Down
3 changes: 3 additions & 0 deletions ui/pages/onboarding-flow/privacy-settings/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const Setting = ({
title,
description,
showToggle = true,
dataTestId,
}) => {
const t = useI18nContext();

Expand All @@ -27,6 +28,7 @@ export const Setting = ({
marginTop={3}
marginBottom={3}
className="privacy-settings__setting__wrapper"
data-testid={dataTestId}
>
<div className="privacy-settings__setting">
<Text variant={TextVariant.bodyMdMedium}>{title}</Text>
Expand Down Expand Up @@ -54,4 +56,5 @@ Setting.propTypes = {
title: PropTypes.string,
description: PropTypes.oneOfType([PropTypes.object, PropTypes.string]),
showToggle: PropTypes.bool,
dataTestId: PropTypes.string,
};

0 comments on commit 6d6e814

Please sign in to comment.