Skip to content

Commit af73098

Browse files
authored
Merge branch 'main' into 3922-re-simulate-transactions-for-every-new-block
2 parents c56aaad + 8d2d603 commit af73098

29 files changed

+672
-45
lines changed

Diff for: app/_locales/en/messages.json

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: app/_locales/en_GB/messages.json

+13-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: app/scripts/metamask-controller.js

+11
Original file line numberDiff line numberDiff line change
@@ -3469,6 +3469,7 @@ export default class MetamaskController extends EventEmitter {
34693469
getOpenMetamaskTabsIds: this.getOpenMetamaskTabsIds,
34703470
markNotificationPopupAsAutomaticallyClosed: () =>
34713471
this.notificationManager.markAsAutomaticallyClosed(),
3472+
getCode: this.getCode.bind(this),
34723473

34733474
// primary keyring management
34743475
addNewAccount: this.addNewAccount.bind(this),
@@ -7665,6 +7666,16 @@ export default class MetamaskController extends EventEmitter {
76657666
});
76667667
}
76677668

7669+
async getCode(address, networkClientId) {
7670+
const { provider } =
7671+
this.networkController.getNetworkClientById(networkClientId);
7672+
7673+
return await provider.request({
7674+
method: 'eth_getCode',
7675+
params: [address],
7676+
});
7677+
}
7678+
76687679
async _onAccountChange(newAddress) {
76697680
const permittedAccountsMap = getPermittedAccountsByOrigin(
76707681
this.permissionController.state,

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
"@metamask/post-message-stream": "^9.0.0",
309309
"@metamask/ppom-validator": "0.36.0",
310310
"@metamask/preinstalled-example-snap": "^0.3.0",
311-
"@metamask/profile-sync-controller": "^10.0.0",
311+
"@metamask/profile-sync-controller": "^10.1.0",
312312
"@metamask/providers": "^20.0.0",
313313
"@metamask/queued-request-controller": "^7.0.1",
314314
"@metamask/rate-limit-controller": "^6.0.3",

Diff for: privacy-snapshot.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,6 @@
8484
"unresponsive-rpc.url",
8585
"user-storage.api.cx.metamask.io",
8686
"verify.walletconnect.com",
87-
"www.4byte.directory"
87+
"www.4byte.directory",
88+
"api.web3modal.org"
8889
]

Diff for: shared/lib/confirmation.utils.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const REDESIGN_USER_TRANSACTION_TYPES = [
1414
TransactionType.batch,
1515
TransactionType.contractInteraction,
1616
TransactionType.deployContract,
17+
TransactionType.revokeDelegation,
1718
TransactionType.tokenMethodApprove,
1819
TransactionType.tokenMethodIncreaseAllowance,
1920
TransactionType.tokenMethodSetApprovalForAll,

Diff for: test/e2e/tests/bridge/bridge-test-utils.ts

+11-11
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { SMART_CONTRACTS } from '../../seeder/smart-contracts';
99
import { CHAIN_IDS } from '../../../../shared/constants/network';
1010
import { Driver } from '../../webdriver/driver';
1111
import type { FeatureFlagResponse } from '../../../../shared/types/bridge';
12+
import { emptyHtmlPage } from '../../mock-e2e';
1213
import {
1314
DEFAULT_FEATURE_FLAGS_RESPONSE,
1415
ETH_CONVERSION_RATE_USD,
@@ -62,7 +63,7 @@ export class BridgePage {
6263
};
6364

6465
verifyPortfolioTab = async () => {
65-
await this.driver.switchToWindowWithTitle('MetaMask Portfolio - Bridge');
66+
await this.driver.switchToWindowWithTitle('E2E Test Page');
6667
await this.driver.waitForUrlContaining({
6768
url: 'portfolio.metamask.io/bridge',
6869
});
@@ -101,16 +102,15 @@ const mockServer =
101102
};
102103
}),
103104
);
104-
const portfolioMock = async () =>
105-
await mockServer_
106-
.forGet('https://portfolio.metamask.io/bridge')
107-
.always()
108-
.thenCallback(() => {
109-
return {
110-
statusCode: 200,
111-
json: {},
112-
};
113-
});
105+
const portfolioMock = mockServer_
106+
.forGet(`https://portfolio.metamask.io/bridge`)
107+
.always()
108+
.thenCallback(() => {
109+
return {
110+
statusCode: 200,
111+
body: emptyHtmlPage(),
112+
};
113+
});
114114
return Promise.all([...featureFlagMocks, portfolioMock]);
115115
};
116116

Diff for: test/e2e/tests/phishing-controller/mocks.js

+10
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ async function setupPhishingDetectionMocks(
112112
body: emptyHtmlPage(blockProvider),
113113
};
114114
});
115+
116+
await mockServer
117+
.forGet(`https://portfolio.metamask.io`)
118+
.always()
119+
.thenCallback(() => {
120+
return {
121+
statusCode: 200,
122+
body: emptyHtmlPage(),
123+
};
124+
});
115125
}
116126

117127
/**

Diff for: test/e2e/tests/portfolio/portfolio-site.spec.ts

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import { MockttpServer } from 'mockttp';
22
import { withFixtures } from '../../helpers';
3-
import { PORTFOLIO_PAGE_TITLE, MOCK_META_METRICS_ID } from '../../constants';
3+
import { MOCK_META_METRICS_ID } from '../../constants';
44
import FixtureBuilder from '../../fixture-builder';
55
import { emptyHtmlPage } from '../../mock-e2e';
66
import HomePage from '../../page-objects/pages/home/homepage';
77
import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow';
8+
import MockedPage from '../../page-objects/pages/mocked-page';
89

910
describe('Portfolio site', function () {
1011
async function mockPortfolioSite(mockServer: MockttpServer) {
1112
return await mockServer
1213
.forGet('https://portfolio.metamask.io/')
1314
.withQuery({
1415
metamaskEntry: 'ext_portfolio_button',
15-
metametricsId: 'null',
16+
metametricsId: MOCK_META_METRICS_ID,
17+
metricsEnabled: 'true',
18+
marketingEnabled: 'false',
1619
})
1720
.thenCallback(() => {
1821
return {
@@ -38,12 +41,15 @@ describe('Portfolio site', function () {
3841
async ({ driver }) => {
3942
await loginWithBalanceValidation(driver);
4043
await new HomePage(driver).openPortfolioPage();
41-
await driver.switchToWindowWithTitle(PORTFOLIO_PAGE_TITLE);
44+
await driver.switchToWindowWithTitle('E2E Test Page');
4245

4346
// Verify site
4447
await driver.waitForUrl({
4548
url: `https://portfolio.metamask.io/?metamaskEntry=ext_portfolio_button&metametricsId=${MOCK_META_METRICS_ID}&metricsEnabled=true&marketingEnabled=false`,
4649
});
50+
await new MockedPage(driver).check_displayedMessage(
51+
'Empty page by MetaMask',
52+
);
4753
},
4854
);
4955
});

Diff for: ui/__mocks__/actions.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const {
1010

1111
const ERC20_TOKEN_1_MOCK = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599'; // WBTC
1212
const ERC20_TOKEN_2_MOCK = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'; // USDC
13+
const UPGRADED_ACCOUNT_MOCK = '0x9d0ba4ddac06032527b140912ec808ab9451b788';
1314
const ERC721_TOKEN_MOCK = '0x06012c8cf97bead5deae237070f9587f8e7a266d'; // CryptoKitties
1415

1516
const TOKEN_DETAILS_MOCK = {
@@ -50,7 +51,9 @@ module.exports = {
5051
},
5152

5253
// eslint-disable-next-line no-empty-function
53-
trackMetaMetricsEvent: () => {},
54+
trackMetaMetricsEvent: () => {
55+
// Intentionally empty
56+
},
5457

5558
decodeTransactionData: async (request) => {
5659
const { contractAddress } = request;
@@ -65,4 +68,12 @@ module.exports = {
6568

6669
return undefined;
6770
},
71+
72+
getCode: async (address) => {
73+
if (address === UPGRADED_ACCOUNT_MOCK) {
74+
return '0x1234';
75+
}
76+
77+
return '0x';
78+
},
6879
};

Diff for: ui/components/app/create-new-vault/create-new-vault.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import TextField from '../../ui/text-field';
55
import { ButtonVariant, Button, Checkbox } from '../../component-library';
66
import SrpInput from '../srp-input';
77
import { PASSWORD_MIN_LENGTH } from '../../../helpers/constants/common';
8+
import { useSignOut } from '../../../hooks/identity/useAuthentication';
89

910
export default function CreateNewVault({
1011
disabled = false,
@@ -19,6 +20,8 @@ export default function CreateNewVault({
1920
const [seedPhrase, setSeedPhrase] = useState('');
2021
const [termsChecked, setTermsChecked] = useState(false);
2122

23+
const { signOut } = useSignOut();
24+
2225
const t = useI18nContext();
2326

2427
const onPasswordChange = useCallback(
@@ -73,9 +76,10 @@ export default function CreateNewVault({
7376
return;
7477
}
7578

79+
await signOut();
7680
await onSubmit(password, seedPhrase);
7781
},
78-
[isValid, onSubmit, password, seedPhrase],
82+
[isValid, onSubmit, password, seedPhrase, signOut],
7983
);
8084

8185
const toggleTermsCheck = useCallback(() => {

Diff for: ui/components/app/create-new-vault/create-new-vault.test.js

+13-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { screen, fireEvent } from '@testing-library/react';
2+
import { screen, fireEvent, waitFor } from '@testing-library/react';
33
import { renderWithProvider } from '../../../../test/lib/render-helpers';
44
import configureStore from '../../../store/store';
55
import mockState from '../../../../test/data/mock-state.json';
@@ -14,6 +14,13 @@ const store = configureStore({
1414
},
1515
});
1616

17+
const mockSignOut = jest.fn();
18+
jest.mock('../../../hooks/identity/useAuthentication', () => ({
19+
useSignOut: () => ({
20+
signOut: mockSignOut,
21+
}),
22+
}));
23+
1724
describe('CreateNewVault', () => {
1825
it('renders CreateNewVault component and shows Secret Recovery Phrase text', () => {
1926
renderWithProvider(
@@ -120,7 +127,7 @@ describe('CreateNewVault', () => {
120127
expect(submitButton).toBeDisabled();
121128
});
122129

123-
it('should valid', () => {
130+
it('should sign out the user and submit successfully when password and confirm password match', () => {
124131
const props = {
125132
onSubmit: jest.fn(),
126133
submitText: 'Submit',
@@ -158,7 +165,10 @@ describe('CreateNewVault', () => {
158165

159166
fireEvent.click(submitButton);
160167

161-
expect(props.onSubmit).toHaveBeenCalledWith(password, TEST_SEED);
168+
waitFor(() => {
169+
expect(mockSignOut).toHaveBeenCalled();
170+
expect(props.onSubmit).toHaveBeenCalledWith(password, TEST_SEED);
171+
});
162172
});
163173
});
164174

0 commit comments

Comments
 (0)