From db4386f6e25c8a96bd2510588c9ba462a51d9ca1 Mon Sep 17 00:00:00 2001 From: Frederik Bolding Date: Fri, 29 Nov 2024 11:31:07 +0100 Subject: [PATCH 001/175] fix: Correct preferences controller usage for `isOnPhishingList` hook (#28803) ## **Description** In [this commit](https://github.com/MetaMask/metamask-extension/commit/cedabc62e45601c77871689425320c54d717275e) the preferences controller was converted to `BaseControllerV2`, however the `isOnPhishingList` hook was not corrected to reference the state properly. The hook will currently always throw which means that link validation fails for Snaps notifications, making them unable to display. This PR corrects that mistake. Note: This is an edge-case of the Snaps API that doesn't have good E2E coverage yet. We should prioritize that. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28803?quickstart=1) ## **Manual testing steps** The following Snap should work correctly and display a notification: ``` export const onRpcRequest: OnRpcRequestHandler = async ({ origin, request, }) => { switch (request.method) { case 'hello': return snap.request({ method: 'snap_notify', params: { type: 'inApp', message: 'Hello! [metamask.io](https://metamask.io)', }, }); default: throw new Error('Method not found.'); } }; ``` --- app/scripts/metamask-controller.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 992302983baf..d60d937e1c3c 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -2897,8 +2897,7 @@ export default class MetamaskController extends EventEmitter { ); }, isOnPhishingList: (url) => { - const { usePhishDetect } = - this.preferencesController.store.getState(); + const { usePhishDetect } = this.preferencesController.state; if (!usePhishDetect) { return false; From 5e52a7d6d05db865fefdb7e7fdab82b090089911 Mon Sep 17 00:00:00 2001 From: chloeYue <105063779+chloeYue@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:14:33 +0100 Subject: [PATCH 002/175] test: [POM] fix change language flaky tests and migrate tests to Page Object Model (#28777) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** - Fix change language flaky tests. There are multiple reasons for the flakiness, including taking actions during the loading spinner and excessive misuse of refresh page - Migrate change language e2e tests to Page Object Model - Created base pages for advanced settings page and general settings page - For some special language-related locators, as they are only used in this specific test, I didn't migrate them to POM methods. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/27155?quickstart=1) ## **Related issues** Fixes:https://github.com/MetaMask/metamask-extension/issues/27904 https://github.com/MetaMask/metamask-extension/issues/28698 https://github.com/MetaMask/metamask-extension/issues/27390 ## **Manual testing steps** Check code readability, make sure tests pass. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [x] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [x] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- test/e2e/page-objects/common.ts | 5 +- .../pages/settings/advanced-settings.ts | 32 ++++ .../pages/settings/general-settings.ts | 61 +++++++ .../tests/settings/change-language.spec.ts | 153 +++++++++--------- 4 files changed, 175 insertions(+), 76 deletions(-) create mode 100644 test/e2e/page-objects/pages/settings/advanced-settings.ts create mode 100644 test/e2e/page-objects/pages/settings/general-settings.ts diff --git a/test/e2e/page-objects/common.ts b/test/e2e/page-objects/common.ts index b1f678b80cca..5bf1a91e1859 100644 --- a/test/e2e/page-objects/common.ts +++ b/test/e2e/page-objects/common.ts @@ -1 +1,4 @@ -export type RawLocator = string | { css: string; text: string }; +export type RawLocator = + | string + | { css?: string; text?: string } + | { tag: string; text: string }; diff --git a/test/e2e/page-objects/pages/settings/advanced-settings.ts b/test/e2e/page-objects/pages/settings/advanced-settings.ts new file mode 100644 index 000000000000..b93f29b58736 --- /dev/null +++ b/test/e2e/page-objects/pages/settings/advanced-settings.ts @@ -0,0 +1,32 @@ +import { Driver } from '../../../webdriver/driver'; + +class AdvancedSettings { + private readonly driver: Driver; + + private readonly downloadDataButton = '[data-testid="export-data-button"]'; + + private readonly downloadStateLogsButton = + '[data-testid="advanced-setting-state-logs"]'; + + constructor(driver: Driver) { + this.driver = driver; + } + + async check_pageIsLoaded(): Promise { + try { + await this.driver.waitForMultipleSelectors([ + this.downloadStateLogsButton, + this.downloadDataButton, + ]); + } catch (e) { + console.log( + 'Timeout while waiting for Advanced Settings page to be loaded', + e, + ); + throw e; + } + console.log('Advanced Settings page is loaded'); + } +} + +export default AdvancedSettings; diff --git a/test/e2e/page-objects/pages/settings/general-settings.ts b/test/e2e/page-objects/pages/settings/general-settings.ts new file mode 100644 index 000000000000..0db61a03a23f --- /dev/null +++ b/test/e2e/page-objects/pages/settings/general-settings.ts @@ -0,0 +1,61 @@ +import { Driver } from '../../../webdriver/driver'; + +class GeneralSettings { + private readonly driver: Driver; + + private readonly generalSettingsPageTitle = { + text: 'General', + tag: 'h4', + }; + + private readonly loadingOverlaySpinner = '.loading-overlay__spinner'; + + private readonly selectLanguageField = '[data-testid="locale-select"]'; + + constructor(driver: Driver) { + this.driver = driver; + } + + async check_pageIsLoaded(): Promise { + try { + await this.check_noLoadingOverlaySpinner(); + await this.driver.waitForMultipleSelectors([ + this.generalSettingsPageTitle, + this.selectLanguageField, + ]); + } catch (e) { + console.log( + 'Timeout while waiting for General Settings page to be loaded', + e, + ); + throw e; + } + console.log('General Settings page is loaded'); + } + + /** + * Change the language of MM on General Settings page + * + * @param languageToSelect - The language to select + */ + async changeLanguage(languageToSelect: string): Promise { + console.log( + 'Changing language to ', + languageToSelect, + 'on general settings page', + ); + await this.check_noLoadingOverlaySpinner(); + await this.driver.clickElement(this.selectLanguageField); + await this.driver.clickElement({ + text: languageToSelect, + tag: 'option', + }); + await this.check_noLoadingOverlaySpinner(); + } + + async check_noLoadingOverlaySpinner(): Promise { + await this.driver.assertElementNotPresent(this.loadingOverlaySpinner); + } +} + +export default GeneralSettings; diff --git a/test/e2e/tests/settings/change-language.spec.ts b/test/e2e/tests/settings/change-language.spec.ts index 1bd9915a33da..469ad3ceec30 100644 --- a/test/e2e/tests/settings/change-language.spec.ts +++ b/test/e2e/tests/settings/change-language.spec.ts @@ -1,21 +1,17 @@ import { strict as assert } from 'assert'; import { Suite } from 'mocha'; - import { Driver } from '../../webdriver/driver'; -import { - defaultGanacheOptions, - withFixtures, - unlockWallet, -} from '../../helpers'; +import { withFixtures } from '../../helpers'; import FixtureBuilder from '../../fixture-builder'; +import AdvancedSettings from '../../page-objects/pages/settings/advanced-settings'; +import GeneralSettings from '../../page-objects/pages/settings/general-settings'; +import HeaderNavbar from '../../page-objects/pages/header-navbar'; +import Homepage from '../../page-objects/pages/homepage'; +import SendTokenPage from '../../page-objects/pages/send/send-token-page'; +import SettingsPage from '../../page-objects/pages/settings/settings-page'; +import { loginWithBalanceValidation } from '../../page-objects/flows/login.flow'; const selectors = { - accountOptionsMenuButton: '[data-testid="account-options-menu-button"]', - settingsOption: { text: 'Settings', tag: 'div' }, - localeSelect: '[data-testid="locale-select"]', - ethOverviewSend: '[data-testid="eth-overview-send"]', - ensInput: '[data-testid="ens-input"]', - nftsTab: '[data-testid="account-overview__nfts-tab"]', labelSpanish: { tag: 'p', text: 'Idioma actual' }, currentLanguageLabel: { tag: 'p', text: 'Current language' }, advanceText: { text: 'Avanceret', tag: 'div' }, @@ -29,50 +25,37 @@ const selectors = { headerText: { text: 'الإعدادات', tag: 'h3' }, }; -async function changeLanguage(driver: Driver, languageIndex: number) { - await driver.clickElement(selectors.accountOptionsMenuButton); - await driver.clickElement(selectors.settingsOption); - - const dropdownElement = await driver.findElement(selectors.localeSelect); - await dropdownElement.click(); - - const options = await dropdownElement.findElements({ css: 'option' }); - await options[languageIndex].click(); -} - describe('Settings - general tab @no-mmi', function (this: Suite) { it('validate the change language functionality', async function () { - let languageIndex = 10; - await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await changeLanguage(driver, languageIndex); + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); - // Validate the label changes to Spanish + // Change language to Spanish and validate that the word has changed correctly + await generalSettings.changeLanguage('Español'); const isLanguageLabelChanged = await driver.isElementPresent( selectors.labelSpanish, ); assert.equal(isLanguageLabelChanged, true, 'Language did not change'); + // Refresh the page and validate that the language is still Spanish await driver.refresh(); - - // Change back to English and verify that the word is correctly changed back to English - languageIndex = 9; - - const dropdownElement = await driver.findElement( - selectors.localeSelect, + await generalSettings.check_pageIsLoaded(); + assert.equal( + await driver.isElementPresent(selectors.labelSpanish), + true, + 'Language did not change after refresh', ); - await dropdownElement.click(); - const options = await dropdownElement.findElements({ css: 'option' }); - await options[languageIndex].click(); + // Change language back to English and validate that the word has changed correctly + await generalSettings.changeLanguage('English'); const isLabelTextChanged = await driver.isElementPresent( selectors.currentLanguageLabel, ); @@ -82,21 +65,22 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { }); it('validate "Dansk" language on page navigation', async function () { - const languageIndex = 6; await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await changeLanguage(driver, languageIndex); - - await driver.assertElementNotPresent('.loading-overlay__spinner'); + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); + // Select "Dansk" language + await generalSettings.changeLanguage('Dansk'); await driver.clickElement(selectors.advanceText); + const advancedSettings = new AdvancedSettings(driver); + await advancedSettings.check_pageIsLoaded(); // Confirm that the language change is reflected in search box water text const isWaterTextChanged = await driver.isElementPresent( @@ -132,22 +116,30 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { }); it('validate "Deutsch" language on error messages', async function () { - const languageIndex = 7; await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await changeLanguage(driver, languageIndex); - await driver.navigate(); - await driver.clickElement(selectors.ethOverviewSend); - await driver.pasteIntoField( - selectors.ensInput, - // use wrong checksum address; other inputs don't show error until snaps name-lookup has happened + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); + + // Select "Deutsch" language + await generalSettings.changeLanguage('Deutsch'); + await new SettingsPage(driver).closeSettingsPage(); + + const homepage = new Homepage(driver); + await homepage.check_pageIsLoaded(); + await homepage.check_expectedBalanceIsDisplayed(); + await homepage.startSendFlow(); + + const sendToPage = new SendTokenPage(driver); + await sendToPage.check_pageIsLoaded(); + // use wrong address for recipient to allow error message to show + await sendToPage.fillRecipient( '0xAAAA6BF26964aF9D7eEd9e03E53415D37aA96045', ); @@ -165,18 +157,23 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { }); it('validate "मानक हिन्दी" language on tooltips', async function () { - const languageIndex = 19; await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await changeLanguage(driver, languageIndex); - await driver.navigate(); + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); + + // Select "मानक हिन्दी" language + await generalSettings.changeLanguage('मानक हिन्दी'); + await new SettingsPage(driver).closeSettingsPage(); + const homepage = new Homepage(driver); + await homepage.check_pageIsLoaded(); + await homepage.check_expectedBalanceIsDisplayed(); // Validate the account tooltip const isAccountTooltipChanged = await driver.isElementPresent( @@ -202,20 +199,24 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { }); it('validate "Magyar" language change on hypertext', async function () { - const languageIndex = 23; await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, - async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - // selects "Magyar" language - await changeLanguage(driver, languageIndex); - await driver.navigate(); - await driver.clickElement(selectors.nftsTab); + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); + + // Select "Magyar" language + await generalSettings.changeLanguage('Magyar'); + await new SettingsPage(driver).closeSettingsPage(); + const homepage = new Homepage(driver); + await homepage.check_pageIsLoaded(); + await homepage.check_expectedBalanceIsDisplayed(); + await homepage.goToNftTab(); // Validate the hypertext const isHyperTextChanged = await driver.isElementPresent( @@ -231,18 +232,20 @@ describe('Settings - general tab @no-mmi', function (this: Suite) { }); it('validate "العربية" language change on page indent', async function () { - const languageIndex = 1; await withFixtures( { fixtures: new FixtureBuilder().build(), - ganacheOptions: defaultGanacheOptions, title: this.test?.fullTitle(), }, async ({ driver }: { driver: Driver }) => { - await unlockWallet(driver); - await changeLanguage(driver, languageIndex); + await loginWithBalanceValidation(driver); + await new HeaderNavbar(driver).openSettingsPage(); + const generalSettings = new GeneralSettings(driver); + await generalSettings.check_pageIsLoaded(); + + // Select "العربية" language and validate that the header text has changed + await generalSettings.changeLanguage('العربية'); - // Validate the header text const isHeaderTextChanged = await driver.isElementPresent( selectors.headerText, ); From 7d252e9ca78e40c7e41034667850f07da8c70ca0 Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Fri, 29 Nov 2024 16:25:29 +0000 Subject: [PATCH 003/175] refactor: remove global network from transaction controller (#28449) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Upgrade `@metamask/transaction-controller` to remove all usages of the global network. Specifically: - Remove deleted constructor options. - Add `getGlobalChainId` and `getGlobalNetworkClientId` private methods in `MetamaskController`. - Remove `TRANSACTION_MULTICHAIN` environment variable. - Add `networkClientId` to test data. - Update calls to: - `addTransaction` - `estimateGasBuffered` - `getNonceLock` - `getTransactions` - `startIncomingTransactionPolling` - `updateIncomingTransactions` - `wipeTransactions` [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28449?quickstart=1) ## **Related issues** Fixes: [#3499](https://github.com/MetaMask/MetaMask-planning/issues/3499) ## **Manual testing steps** Full regression of all transaction flows. ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/scripts/controllers/mmi-controller.ts | 2 +- app/scripts/lib/transaction/metrics.test.ts | 1 + .../transaction/smart-transactions.test.ts | 1 + app/scripts/lib/transaction/util.test.ts | 39 +---- app/scripts/lib/transaction/util.ts | 7 +- app/scripts/metamask-controller.js | 135 +++++++++++------- app/scripts/metamask-controller.test.js | 10 +- builds.yml | 2 - package.json | 2 +- ui/ducks/swaps/swaps.js | 1 + .../useFirstTimeInteractionAlert.test.ts | 1 + .../usePendingTransactionAlerts.test.ts | 1 + .../transactions/useResimulationAlert.test.ts | 1 + .../useSigningOrSubmittingAlerts.test.ts | 1 + ui/store/actions.ts | 1 - yarn.lock | 10 +- 16 files changed, 110 insertions(+), 105 deletions(-) diff --git a/app/scripts/controllers/mmi-controller.ts b/app/scripts/controllers/mmi-controller.ts index 9f2701b2c0b9..f94388aa5e8f 100644 --- a/app/scripts/controllers/mmi-controller.ts +++ b/app/scripts/controllers/mmi-controller.ts @@ -311,7 +311,7 @@ export class MMIController { } } - const txList = this.txStateManager.getTransactions({}, [], false); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/ + const txList = this.txStateManager.getTransactions(); // Includes all transactions, but we are looping through keyrings. Currently filtering is done in updateCustodianTransactions :-/ try { updateCustodianTransactions({ diff --git a/app/scripts/lib/transaction/metrics.test.ts b/app/scripts/lib/transaction/metrics.test.ts index 7dcedd4e467e..c4ddf9d29e5a 100644 --- a/app/scripts/lib/transaction/metrics.test.ts +++ b/app/scripts/lib/transaction/metrics.test.ts @@ -115,6 +115,7 @@ describe('Transaction metrics', () => { type: TransactionType.simpleSend, origin: ORIGIN_METAMASK, chainId: mockChainId, + networkClientId: 'testNetworkClientId', time: 1624408066355, defaultGasEstimates: { gas: '0x7b0d', diff --git a/app/scripts/lib/transaction/smart-transactions.test.ts b/app/scripts/lib/transaction/smart-transactions.test.ts index 1cf266c3e141..25bb409dffa1 100644 --- a/app/scripts/lib/transaction/smart-transactions.test.ts +++ b/app/scripts/lib/transaction/smart-transactions.test.ts @@ -150,6 +150,7 @@ function withRequest( }, type: TransactionType.simpleSend, chainId: CHAIN_IDS.MAINNET, + networkClientId: 'testNetworkClientId', time: 1624408066355, defaultGasEstimates: { gas: '0x7b0d', diff --git a/app/scripts/lib/transaction/util.test.ts b/app/scripts/lib/transaction/util.test.ts index fbbee025381b..4d78ea51cfa5 100644 --- a/app/scripts/lib/transaction/util.test.ts +++ b/app/scripts/lib/transaction/util.test.ts @@ -50,6 +50,7 @@ const TRANSACTION_PARAMS_MOCK: TransactionParams = { const TRANSACTION_OPTIONS_MOCK: AddTransactionOptions = { actionId: 'mockActionId', + networkClientId: 'mockNetworkClientId', origin: 'mockOrigin', requireApproval: false, type: TransactionType.simpleSend, @@ -151,23 +152,6 @@ describe('Transaction Utils', () => { }); }); - it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => { - process.env.TRANSACTION_MULTICHAIN = '1'; - - await addTransaction(request); - - expect( - request.transactionController.addTransaction, - ).toHaveBeenCalledTimes(1); - expect( - request.transactionController.addTransaction, - ).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, { - ...TRANSACTION_OPTIONS_MOCK, - networkClientId: 'mockNetworkClientId', - }); - process.env.TRANSACTION_MULTICHAIN = ''; - }); - it('returns transaction meta', async () => { const transactionMeta = await addTransaction(request); expect(transactionMeta).toStrictEqual(TRANSACTION_META_MOCK); @@ -541,27 +525,6 @@ describe('Transaction Utils', () => { }); }); - it('adds transaction with networkClientId if process.env.TRANSACTION_MULTICHAIN is set', async () => { - process.env.TRANSACTION_MULTICHAIN = '1'; - - await addDappTransaction(dappRequest); - - expect( - request.transactionController.addTransaction, - ).toHaveBeenCalledTimes(1); - expect( - request.transactionController.addTransaction, - ).toHaveBeenCalledWith(TRANSACTION_PARAMS_MOCK, { - ...TRANSACTION_OPTIONS_MOCK, - networkClientId: 'mockNetworkClientId', - method: DAPP_REQUEST_MOCK.method, - requireApproval: true, - securityAlertResponse: DAPP_REQUEST_MOCK.securityAlertResponse, - type: undefined, - }); - process.env.TRANSACTION_MULTICHAIN = ''; - }); - it('returns transaction hash', async () => { const transactionHash = await addDappTransaction(dappRequest); expect(transactionHash).toStrictEqual(TRANSACTION_META_MOCK.hash); diff --git a/app/scripts/lib/transaction/util.ts b/app/scripts/lib/transaction/util.ts index 0bbf93afd8a8..34f27d321e0b 100644 --- a/app/scripts/lib/transaction/util.ts +++ b/app/scripts/lib/transaction/util.ts @@ -46,7 +46,7 @@ type BaseAddTransactionRequest = { }; type FinalAddTransactionRequest = BaseAddTransactionRequest & { - transactionOptions: AddTransactionOptions; + transactionOptions: Partial; }; export type AddTransactionRequest = FinalAddTransactionRequest & { @@ -66,7 +66,7 @@ export async function addDappTransaction( const { id: actionId, method, origin } = dappRequest; const { securityAlertResponse, traceContext } = dappRequest; - const transactionOptions: AddTransactionOptions = { + const transactionOptions: Partial = { actionId, method, origin, @@ -143,10 +143,11 @@ async function addTransactionWithController( transactionParams, networkClientId, } = request; + const { result, transactionMeta } = await transactionController.addTransaction(transactionParams, { ...transactionOptions, - ...(process.env.TRANSACTION_MULTICHAIN ? { networkClientId } : {}), + networkClientId, }); return { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d60d937e1c3c..a1cbabb9bcbe 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -236,10 +236,7 @@ import { TOKEN_TRANSFER_LOG_TOPIC_HASH, TRANSFER_SINFLE_LOG_TOPIC_HASH, } from '../../shared/lib/transactions-controller-utils'; -import { - getCurrentChainId, - getProviderConfig, -} from '../../shared/modules/selectors/networks'; +import { getProviderConfig } from '../../shared/modules/selectors/networks'; import { endTrace, trace } from '../../shared/lib/trace'; // eslint-disable-next-line import/no-restricted-paths import { isSnapId } from '../../ui/helpers/utils/snaps'; @@ -652,7 +649,9 @@ export default class MetamaskController extends EventEmitter { }); this.tokenListController = new TokenListController({ - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId({ + metamask: this.networkController.state, + }), preventPollingOnNetworkRestart: !this.#isTokenListPollingRequired( this.preferencesController.state, ), @@ -676,7 +675,7 @@ export default class MetamaskController extends EventEmitter { }); this.assetsContractController = new AssetsContractController({ messenger: assetsContractControllerMessenger, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), }); const tokensControllerMessenger = this.controllerMessenger.getRestricted({ @@ -699,7 +698,7 @@ export default class MetamaskController extends EventEmitter { state: initState.TokensController, provider: this.provider, messenger: tokensControllerMessenger, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), }); const nftControllerMessenger = this.controllerMessenger.getRestricted({ @@ -725,7 +724,7 @@ export default class MetamaskController extends EventEmitter { this.nftController = new NftController({ state: initState.NftController, messenger: nftControllerMessenger, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), onNftAdded: ({ address, symbol, tokenId, standard, source }) => this.metaMetricsController.trackEvent({ event: MetaMetricsEventName.NftAdded, @@ -760,7 +759,7 @@ export default class MetamaskController extends EventEmitter { this.nftDetectionController = new NftDetectionController({ messenger: nftDetectionControllerMessenger, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), getOpenSeaApiKey: () => this.nftController.openSeaApiKey, getBalancesInSingleCall: this.assetsContractController.getBalancesInSingleCall.bind( @@ -849,13 +848,10 @@ export default class MetamaskController extends EventEmitter { legacyAPIEndpoint: `${gasApiBaseUrl}/networks//gasPrices`, EIP1559APIEndpoint: `${gasApiBaseUrl}/networks//suggestedGasFees`, getCurrentNetworkLegacyGasAPICompatibility: () => { - const chainId = getCurrentChainId({ - metamask: this.networkController.state, - }); + const chainId = this.#getGlobalChainId(); return chainId === CHAIN_IDS.BSC; }, - getChainId: () => - getCurrentChainId({ metamask: this.networkController.state }), + getChainId: () => this.#getGlobalChainId(), }); this.appStateController = new AppStateController({ @@ -950,7 +946,7 @@ export default class MetamaskController extends EventEmitter { ppomInit: () => PPOMModule.default(process.env.PPOM_URI), }, state: initState.PPOMController, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), securityAlertsEnabled: this.preferencesController.state.securityAlertsEnabled, onPreferencesChange: preferencesMessenger.subscribe.bind( @@ -1916,8 +1912,8 @@ export default class MetamaskController extends EventEmitter { ], allowedEvents: [`NetworkController:stateChange`], }); + this.txController = new TransactionController({ - blockTracker: this.blockTracker, getCurrentNetworkEIP1559Compatibility: this.networkController.getEIP1559Compatibility.bind( this.networkController, @@ -1935,10 +1931,10 @@ export default class MetamaskController extends EventEmitter { ), getNetworkState: () => this.networkController.state, getPermittedAccounts: this.getPermittedAccounts.bind(this), - getSavedGasFees: () => - this.preferencesController.state.advancedGasFee[ - getCurrentChainId({ metamask: this.networkController.state }) - ], + getSavedGasFees: () => { + const globalChainId = this.#getGlobalChainId(); + return this.preferencesController.state.advancedGasFee[globalChainId]; + }, incomingTransactions: { etherscanApiKeysByChainId: { [CHAIN_IDS.MAINNET]: process.env.ETHERSCAN_API_KEY, @@ -1946,26 +1942,17 @@ export default class MetamaskController extends EventEmitter { }, includeTokenTransfers: false, isEnabled: () => - Boolean( - this.preferencesController.state.incomingTransactionsPreferences?.[ - getCurrentChainId({ metamask: this.networkController.state }) - ] && this.onboardingController.state.completedOnboarding, - ), + this.preferencesController.state.incomingTransactionsPreferences?.[ + this.#getGlobalChainId() + ] && this.onboardingController.state.completedOnboarding, queryEntireHistory: false, updateTransactions: false, }, isFirstTimeInteractionEnabled: () => this.preferencesController.state.securityAlertsEnabled, - isMultichainEnabled: process.env.TRANSACTION_MULTICHAIN, isSimulationEnabled: () => this.preferencesController.state.useTransactionSimulations, messenger: transactionControllerMessenger, - onNetworkStateChange: (listener) => { - networkControllerMessenger.subscribe( - 'NetworkController:networkDidChange', - () => listener(), - ); - }, pendingTransactions: { isResubmitEnabled: () => { const state = this._getMetaMaskState(); @@ -1975,7 +1962,6 @@ export default class MetamaskController extends EventEmitter { ); }, }, - provider: this.provider, testGasFeeFlows: process.env.TEST_GAS_FEE_FLOWS, trace, hooks: { @@ -2155,12 +2141,12 @@ export default class MetamaskController extends EventEmitter { this.swapsController = new SwapsController( { messenger: swapsControllerMessenger, - // TODO: Remove once TransactionController exports this action type getBufferedGasLimit: async (txMeta, multiplier) => { const { gas: gasLimit, simulationFails } = await this.txController.estimateGasBuffered( txMeta.txParams, multiplier, + this.#getGlobalNetworkClientId(), ); return { gasLimit, simulationFails }; @@ -2223,7 +2209,11 @@ export default class MetamaskController extends EventEmitter { this.smartTransactionsController = new SmartTransactionsController({ supportedChainIds: getAllowedSmartTransactionsChainIds(), clientId: ClientId.Extension, - getNonceLock: this.txController.getNonceLock.bind(this.txController), + getNonceLock: (address) => + this.txController.getNonceLock( + address, + this.#getGlobalNetworkClientId(), + ), confirmExternalTransaction: this.txController.confirmExternalTransaction.bind(this.txController), trackMetaMetricsEvent: this.metaMetricsController.trackEvent.bind( @@ -2704,7 +2694,10 @@ export default class MetamaskController extends EventEmitter { } triggerNetworkrequests() { - this.txController.startIncomingTransactionPolling(); + this.txController.startIncomingTransactionPolling([ + this.#getGlobalNetworkClientId(), + ]); + this.tokenDetectionController.enable(); this.getInfuraFeatureFlags(); } @@ -2942,13 +2935,13 @@ export default class MetamaskController extends EventEmitter { 'PreferencesController:stateChange', previousValueComparator(async (prevState, currState) => { const { currentLocale } = currState; - const chainId = getCurrentChainId({ - metamask: this.networkController.state, - }); + const chainId = this.#getGlobalChainId(); await updateCurrentLocale(currentLocale); if (currState.incomingTransactionsPreferences?.[chainId]) { - this.txController.startIncomingTransactionPolling(); + this.txController.startIncomingTransactionPolling([ + this.#getGlobalNetworkClientId(), + ]); } else { this.txController.stopIncomingTransactionPolling(); } @@ -3018,7 +3011,15 @@ export default class MetamaskController extends EventEmitter { this.controllerMessenger.subscribe( 'NetworkController:networkDidChange', async () => { - await this.txController.updateIncomingTransactions(); + await this.txController.updateIncomingTransactions([ + this.#getGlobalNetworkClientId(), + ]); + + await this.txController.stopIncomingTransactionPolling(); + + await this.txController.startIncomingTransactionPolling([ + this.#getGlobalNetworkClientId(), + ]); }, ); @@ -4520,9 +4521,7 @@ export default class MetamaskController extends EventEmitter { async _addAccountsWithBalance() { try { // Scan accounts until we find an empty one - const chainId = getCurrentChainId({ - metamask: this.networkController.state, - }); + const chainId = this.#getGlobalChainId(); const ethQuery = new EthQuery(this.provider); const accounts = await this.keyringController.getAccounts(); let address = accounts[accounts.length - 1]; @@ -5051,15 +5050,24 @@ export default class MetamaskController extends EventEmitter { async resetAccount() { const selectedAddress = this.accountsController.getSelectedAccount().address; - this.txController.wipeTransactions(false, selectedAddress); + + const globalChainId = this.#getGlobalChainId(); + + this.txController.wipeTransactions({ + address: selectedAddress, + chainId: globalChainId, + }); + this.smartTransactionsController.wipeSmartTransactions({ address: selectedAddress, ignoreNetwork: false, }); + this.bridgeStatusController.wipeBridgeStatus({ address: selectedAddress, ignoreNetwork: false, }); + this.networkController.resetConnection(); return selectedAddress; @@ -5187,8 +5195,7 @@ export default class MetamaskController extends EventEmitter { internalAccounts: this.accountsController.listAccounts(), dappRequest, networkClientId: - dappRequest?.networkClientId ?? - this.networkController.state.selectedNetworkClientId, + dappRequest?.networkClientId ?? this.#getGlobalNetworkClientId(), selectedAccount: this.accountsController.getAccountByAddress( transactionParams.from, ), @@ -5196,7 +5203,7 @@ export default class MetamaskController extends EventEmitter { transactionOptions, transactionParams, userOperationController: this.userOperationController, - chainId: getCurrentChainId({ metamask: this.networkController.state }), + chainId: this.#getGlobalChainId(), ppomController: this.ppomController, securityAlertsEnabled: this.preferencesController.state?.securityAlertsEnabled, @@ -6546,13 +6553,13 @@ export default class MetamaskController extends EventEmitter { * Returns the nonce that will be associated with a transaction once approved * * @param {string} address - The hex string address for the transaction - * @param networkClientId - The optional networkClientId to get the nonce lock with + * @param networkClientId - The networkClientId to get the nonce lock with * @returns {Promise} */ async getPendingNonce(address, networkClientId) { const { nonceDetails, releaseLock } = await this.txController.getNonceLock( address, - process.env.TRANSACTION_MULTICHAIN ? networkClientId : undefined, + networkClientId, ); const pendingNonce = nonceDetails.params.highestSuggested; @@ -6565,13 +6572,13 @@ export default class MetamaskController extends EventEmitter { * Returns the next nonce according to the nonce-tracker * * @param {string} address - The hex string address for the transaction - * @param networkClientId - The optional networkClientId to get the nonce lock with + * @param networkClientId - The networkClientId to get the nonce lock with * @returns {Promise} */ async getNextNonce(address, networkClientId) { const nonceLock = await this.txController.getNonceLock( address, - process.env.TRANSACTION_MULTICHAIN ? networkClientId : undefined, + networkClientId, ); nonceLock.releaseLock(); return nonceLock.nextNonce; @@ -7378,4 +7385,28 @@ export default class MetamaskController extends EventEmitter { return useTokenDetection || petnamesEnabled || useTransactionSimulations; } + + /** + * @deprecated Avoid new references to the global network. + * Will be removed once multi-chain support is fully implemented. + * @returns {string} The chain ID of the currently selected network. + */ + #getGlobalChainId() { + const globalNetworkClientId = this.#getGlobalNetworkClientId(); + + const globalNetworkClient = this.networkController.getNetworkClientById( + globalNetworkClientId, + ); + + return globalNetworkClient.configuration.chainId; + } + + /** + * @deprecated Avoid new references to the global network. + * Will be removed once multi-chain support is fully implemented. + * @returns {string} The network client ID of the currently selected network client. + */ + #getGlobalNetworkClientId() { + return this.networkController.state.selectedNetworkClientId; + } } diff --git a/app/scripts/metamask-controller.test.js b/app/scripts/metamask-controller.test.js index a596277154eb..f7115f9364bd 100644 --- a/app/scripts/metamask-controller.test.js +++ b/app/scripts/metamask-controller.test.js @@ -21,7 +21,10 @@ import { } from '@metamask/keyring-api'; import { ControllerMessenger } from '@metamask/base-controller'; import { LoggingController, LogType } from '@metamask/logging-controller'; -import { TransactionController } from '@metamask/transaction-controller'; +import { + CHAIN_IDS, + TransactionController, +} from '@metamask/transaction-controller'; import { RatesController, TokenListController, @@ -1206,7 +1209,10 @@ describe('MetaMaskController', () => { ).toHaveBeenCalledTimes(1); expect( metamaskController.txController.wipeTransactions, - ).toHaveBeenCalledWith(false, selectedAddressMock); + ).toHaveBeenCalledWith({ + address: selectedAddressMock, + chainId: CHAIN_IDS.MAINNET, + }); expect( metamaskController.smartTransactionsController.wipeSmartTransactions, ).toHaveBeenCalledWith({ diff --git a/builds.yml b/builds.yml index 3963aeda93e5..7985f464b73f 100644 --- a/builds.yml +++ b/builds.yml @@ -276,8 +276,6 @@ env: - NODE_DEBUG: '' # Used by react-devtools-core - EDITOR_URL: '' - # Determines if feature flagged Multichain Transactions should be used - - TRANSACTION_MULTICHAIN: '' # Determines if Barad Dur features should be used - BARAD_DUR: '' # Determines if feature flagged Chain permissions diff --git a/package.json b/package.json index e7827cb6d92b..803853059703 100644 --- a/package.json +++ b/package.json @@ -347,7 +347,7 @@ "@metamask/snaps-sdk": "^6.12.0", "@metamask/snaps-utils": "^8.6.0", "@metamask/solana-wallet-snap": "^0.1.9", - "@metamask/transaction-controller": "^40.1.0", + "@metamask/transaction-controller": "^41.0.0", "@metamask/user-operation-controller": "^16.0.0", "@metamask/utils": "^10.0.1", "@ngraveio/bc-ur": "^1.1.12", diff --git a/ui/ducks/swaps/swaps.js b/ui/ducks/swaps/swaps.js index bc1c675e4d21..e044fdf42b3f 100644 --- a/ui/ducks/swaps/swaps.js +++ b/ui/ducks/swaps/swaps.js @@ -589,6 +589,7 @@ export const fetchSwapsLivenessAndFeatureFlags = () => { await dispatch(fetchSmartTransactionsLiveness()); const transactions = await getTransactions({ searchCriteria: { + chainId, from: getSelectedInternalAccount(state)?.address, }, }); diff --git a/ui/pages/confirmations/hooks/alerts/transactions/useFirstTimeInteractionAlert.test.ts b/ui/pages/confirmations/hooks/alerts/transactions/useFirstTimeInteractionAlert.test.ts index 964b218e8501..6689d6610248 100644 --- a/ui/pages/confirmations/hooks/alerts/transactions/useFirstTimeInteractionAlert.test.ts +++ b/ui/pages/confirmations/hooks/alerts/transactions/useFirstTimeInteractionAlert.test.ts @@ -22,6 +22,7 @@ const CONFIRMATION_MOCK = genUnapprovedContractInteractionConfirmation({ const TRANSACTION_META_MOCK = { id: TRANSACTION_ID_MOCK, chainId: '0x5', + networkClientId: 'testNetworkClientId', status: TransactionStatus.submitted, type: TransactionType.contractInteraction, txParams: { diff --git a/ui/pages/confirmations/hooks/alerts/transactions/usePendingTransactionAlerts.test.ts b/ui/pages/confirmations/hooks/alerts/transactions/usePendingTransactionAlerts.test.ts index 5d2c16a518e5..b9b3d12dc7d0 100644 --- a/ui/pages/confirmations/hooks/alerts/transactions/usePendingTransactionAlerts.test.ts +++ b/ui/pages/confirmations/hooks/alerts/transactions/usePendingTransactionAlerts.test.ts @@ -22,6 +22,7 @@ const CONFIRMATION_MOCK = genUnapprovedContractInteractionConfirmation({ const TRANSACTION_META_MOCK = { id: TRANSACTION_ID_MOCK, chainId: '0x5', + networkClientId: 'testNetworkClientId', status: TransactionStatus.submitted, type: TransactionType.contractInteraction, txParams: { diff --git a/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.test.ts b/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.test.ts index 174b6ec0398a..49209f69df9c 100644 --- a/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.test.ts +++ b/ui/pages/confirmations/hooks/alerts/transactions/useResimulationAlert.test.ts @@ -22,6 +22,7 @@ const CONFIRMATION_MOCK = genUnapprovedContractInteractionConfirmation({ const TRANSACTION_META_MOCK = { id: TRANSACTION_ID_MOCK, chainId: '0x5', + networkClientId: 'testNetworkClientId', status: TransactionStatus.submitted, type: TransactionType.contractInteraction, txParams: { diff --git a/ui/pages/confirmations/hooks/alerts/transactions/useSigningOrSubmittingAlerts.test.ts b/ui/pages/confirmations/hooks/alerts/transactions/useSigningOrSubmittingAlerts.test.ts index d1960827c0b1..08ed8f2aac7d 100644 --- a/ui/pages/confirmations/hooks/alerts/transactions/useSigningOrSubmittingAlerts.test.ts +++ b/ui/pages/confirmations/hooks/alerts/transactions/useSigningOrSubmittingAlerts.test.ts @@ -28,6 +28,7 @@ const CONFIRMATION_MOCK = genUnapprovedContractInteractionConfirmation({ const TRANSACTION_META_MOCK = { id: TRANSACTION_ID_MOCK, chainId: '0x5', + networkClientId: 'testNetworkClientId', status: TransactionStatus.submitted, type: TransactionType.contractInteraction, txParams: { diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 2ad3046e9040..9b402f476a7e 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -1129,7 +1129,6 @@ export function updateAndApproveTx( export async function getTransactions( filters: { - filterToCurrentNetwork?: boolean; searchCriteria?: Partial & Partial; } = {}, ): Promise { diff --git a/yarn.lock b/yarn.lock index 91cc4445c553..c88156929c17 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6431,9 +6431,9 @@ __metadata: languageName: node linkType: hard -"@metamask/transaction-controller@npm:^40.1.0": - version: 40.1.0 - resolution: "@metamask/transaction-controller@npm:40.1.0" +"@metamask/transaction-controller@npm:^41.0.0": + version: 41.0.0 + resolution: "@metamask/transaction-controller@npm:41.0.0" dependencies: "@ethereumjs/common": "npm:^3.2.0" "@ethereumjs/tx": "npm:^4.2.0" @@ -6460,7 +6460,7 @@ __metadata: "@metamask/approval-controller": ^7.0.0 "@metamask/gas-fee-controller": ^22.0.0 "@metamask/network-controller": ^22.0.0 - checksum: 10/1057af5b0da2d51e46e7568fc0e7fdbe6aed34a013cf56a5a35ad694cbedcb726a5823bbe70b980d1dc9560138acf9d82ac5f0e06f7d17e11b46abacd466dc42 + checksum: 10/67a00b2eade35fc4e635a6bcbbcd847b3986b3bdcc9730ff2c8f81234df18ed11149203c13d6bad616e859f7e25879efab36b6dc4be05a4e747b4280ae2f300d languageName: node linkType: hard @@ -26566,7 +26566,7 @@ __metadata: "@metamask/solana-wallet-snap": "npm:^0.1.9" "@metamask/test-bundler": "npm:^1.0.0" "@metamask/test-dapp": "npm:8.13.0" - "@metamask/transaction-controller": "npm:^40.1.0" + "@metamask/transaction-controller": "npm:^41.0.0" "@metamask/user-operation-controller": "npm:^16.0.0" "@metamask/utils": "npm:^10.0.1" "@ngraveio/bc-ur": "npm:^1.1.12" From 7143c9643a11034a2a8b7f5f644f961be71b5e10 Mon Sep 17 00:00:00 2001 From: cryptodev-2s <109512101+cryptodev-2s@users.noreply.github.com> Date: Fri, 29 Nov 2024 18:03:37 +0100 Subject: [PATCH 004/175] chore: remove unused `usedNetworks` state property from `AppStateController` (#28813) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Building on the work done to remove the network modal in [PR](https://github.com/MetaMask/metamask-extension/pull/28765), this PR finalizes the process by completely removing the unused `usedNetworks` state property from `AppStateController`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28813?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/scripts/constants/sentry-state.ts | 1 - .../controllers/app-state-controller.test.ts | 11 ---- .../controllers/app-state-controller.ts | 20 ------ app/scripts/metamask-controller.js | 2 - app/scripts/migrations/134.test.ts | 62 +++++++++++++++++++ app/scripts/migrations/134.ts | 41 ++++++++++++ app/scripts/migrations/index.js | 1 + test/data/mock-send-state.json | 5 -- test/e2e/default-fixture.js | 6 -- test/e2e/fixture-builder.js | 6 -- ...rs-after-init-opt-in-background-state.json | 1 - .../errors-after-init-opt-in-ui-state.json | 1 - ...s-before-init-opt-in-background-state.json | 6 -- .../errors-before-init-opt-in-ui-state.json | 6 -- .../data/integration-init-state.json | 9 --- .../data/onboarding-completion-route.json | 1 - .../ui/new-network-info/new-network-info.js | 2 - ui/pages/routes/routes.component.test.js | 8 --- ui/pages/routes/routes.container.js | 2 - ui/selectors/selectors.js | 7 --- ui/store/actions.ts | 4 -- 21 files changed, 104 insertions(+), 98 deletions(-) create mode 100644 app/scripts/migrations/134.test.ts create mode 100644 app/scripts/migrations/134.ts diff --git a/app/scripts/constants/sentry-state.ts b/app/scripts/constants/sentry-state.ts index f18fb96d85fd..9823b2ada540 100644 --- a/app/scripts/constants/sentry-state.ts +++ b/app/scripts/constants/sentry-state.ts @@ -90,7 +90,6 @@ export const SENTRY_BACKGROUND_STATE = { termsOfUseLastAgreed: true, timeoutMinutes: true, trezorModel: true, - usedNetworks: true, }, MultichainBalancesController: { balances: false, diff --git a/app/scripts/controllers/app-state-controller.test.ts b/app/scripts/controllers/app-state-controller.test.ts index 4bc1cb63e390..f830e0ee1cdf 100644 --- a/app/scripts/controllers/app-state-controller.test.ts +++ b/app/scripts/controllers/app-state-controller.test.ts @@ -374,17 +374,6 @@ describe('AppStateController', () => { }); }); - describe('setFirstTimeUsedNetwork', () => { - it('updates the array of the first time used networks', () => { - const chainId = '0x1'; - - appStateController.setFirstTimeUsedNetwork(chainId); - expect(appStateController.store.getState().usedNetworks[chainId]).toBe( - true, - ); - }); - }); - describe('setLastInteractedConfirmationInfo', () => { it('sets information about last confirmation user has interacted with', () => { const lastInteractedConfirmationInfo = { diff --git a/app/scripts/controllers/app-state-controller.ts b/app/scripts/controllers/app-state-controller.ts index 605f307ec0e4..c506dc329e94 100644 --- a/app/scripts/controllers/app-state-controller.ts +++ b/app/scripts/controllers/app-state-controller.ts @@ -62,7 +62,6 @@ export type AppStateControllerState = { hadAdvancedGasFeesSetPriorToMigration92_3: boolean; qrHardware: Json; nftsDropdownState: Json; - usedNetworks: Record; surveyLinkLastClickedOrClosed: number | null; signatureSecurityAlertResponses: Record; // States used for displaying the changed network toast @@ -138,7 +137,6 @@ type AppStateControllerInitState = Partial< AppStateControllerState, | 'qrHardware' | 'nftsDropdownState' - | 'usedNetworks' | 'surveyLinkLastClickedOrClosed' | 'signatureSecurityAlertResponses' | 'switchedNetworkDetails' @@ -184,11 +182,6 @@ const getDefaultAppStateControllerState = ( ...initState, qrHardware: {}, nftsDropdownState: {}, - usedNetworks: { - '0x1': true, - '0x5': true, - '0x539': true, - }, surveyLinkLastClickedOrClosed: null, signatureSecurityAlertResponses: {}, switchedNetworkDetails: null, @@ -704,19 +697,6 @@ export class AppStateController extends EventEmitter { }); } - /** - * Updates the array of the first time used networks - * - * @param chainId - */ - setFirstTimeUsedNetwork(chainId: string): void { - const currentState = this.store.getState(); - const { usedNetworks } = currentState; - usedNetworks[chainId] = true; - - this.store.updateState({ usedNetworks }); - } - ///: BEGIN:ONLY_INCLUDE_IF(build-mmi) /** * Set the interactive replacement token with a url and the old refresh token diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index a1cbabb9bcbe..1eaf354b4caf 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -3705,8 +3705,6 @@ export default class MetamaskController extends EventEmitter { appStateController.setShowNetworkBanner.bind(appStateController), updateNftDropDownState: appStateController.updateNftDropDownState.bind(appStateController), - setFirstTimeUsedNetwork: - appStateController.setFirstTimeUsedNetwork.bind(appStateController), setSwitchedNetworkDetails: appStateController.setSwitchedNetworkDetails.bind(appStateController), clearSwitchedNetworkDetails: diff --git a/app/scripts/migrations/134.test.ts b/app/scripts/migrations/134.test.ts new file mode 100644 index 000000000000..9b3d31db017f --- /dev/null +++ b/app/scripts/migrations/134.test.ts @@ -0,0 +1,62 @@ +import { cloneDeep } from 'lodash'; +import { migrate, version } from './134'; + +const oldVersion = 133; + +describe(`migration #${version}`, () => { + it('updates the version metadata', async () => { + const oldStorage = { + meta: { version: oldVersion }, + data: {}, + }; + + const newStorage = await migrate(oldStorage); + + expect(newStorage.meta).toStrictEqual({ version }); + }); + + it('Does nothing if `usedNetworks` is not in the `AppStateController` state', async () => { + const oldState = { + AppStateController: { + timeoutMinutes: 0, + }, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: cloneDeep(oldState), + }); + + expect(transformedState.data).toStrictEqual(oldState); + }); + + it('Removes `usedNetworks` from the `AppStateController` state', async () => { + const oldState: { + AppStateController: { + timeoutMinutes: number; + usedNetworks?: Record; + }; + } = { + AppStateController: { + timeoutMinutes: 0, + usedNetworks: { + '0x1': true, + '0x5': true, + '0x539': true, + }, + }, + }; + const expectedState = { + AppStateController: { + timeoutMinutes: 0, + }, + }; + + const transformedState = await migrate({ + meta: { version: oldVersion }, + data: cloneDeep(oldState), + }); + + expect(transformedState.data).toStrictEqual(expectedState); + }); +}); diff --git a/app/scripts/migrations/134.ts b/app/scripts/migrations/134.ts new file mode 100644 index 000000000000..e11b2abd9625 --- /dev/null +++ b/app/scripts/migrations/134.ts @@ -0,0 +1,41 @@ +import { hasProperty, isObject } from '@metamask/utils'; +import { cloneDeep } from 'lodash'; + +type VersionedData = { + meta: { version: number }; + data: Record; +}; + +export const version = 134; + +/** + * This migration removes `usedNetworks` from `AppStateController` state. + * + * @param originalVersionedData - Versioned MetaMask extension state, exactly what we persist to dist. + * @param originalVersionedData.meta - State metadata. + * @param originalVersionedData.meta.version - The current state version. + * @param originalVersionedData.data - The persisted MetaMask state, keyed by controller. + * @returns Updated versioned MetaMask extension state. + */ +export async function migrate( + originalVersionedData: VersionedData, +): Promise { + const versionedData = cloneDeep(originalVersionedData); + versionedData.meta.version = version; + transformState(versionedData.data); + return versionedData; +} + +function transformState( + state: Record, +): Record { + if ( + hasProperty(state, 'AppStateController') && + isObject(state.AppStateController) && + hasProperty(state.AppStateController, 'usedNetworks') + ) { + console.log('Removing usedNetworks from AppStateController'); + delete state.AppStateController.usedNetworks; + } + return state; +} diff --git a/app/scripts/migrations/index.js b/app/scripts/migrations/index.js index e95a9bf7a9da..887732ad9dbc 100644 --- a/app/scripts/migrations/index.js +++ b/app/scripts/migrations/index.js @@ -154,6 +154,7 @@ const migrations = [ require('./131'), require('./132'), require('./133'), + require('./134'), ]; export default migrations; diff --git a/test/data/mock-send-state.json b/test/data/mock-send-state.json index 73468aca6171..f9c602808719 100644 --- a/test/data/mock-send-state.json +++ b/test/data/mock-send-state.json @@ -140,11 +140,6 @@ "isAccountMenuOpen": false, "isUnlocked": true, "completedOnboarding": true, - "usedNetworks": { - "0x1": true, - "0x5": true, - "0x539": true - }, "showTestnetMessageInDropdown": true, "alertEnabledness": { "unconnectedAccount": true diff --git a/test/e2e/default-fixture.js b/test/e2e/default-fixture.js index c2fba9d63424..a6845e40ec4c 100644 --- a/test/e2e/default-fixture.js +++ b/test/e2e/default-fixture.js @@ -115,12 +115,6 @@ function defaultFixture(inputChainId = CHAIN_IDS.LOCALHOST) { trezorModel: null, newPrivacyPolicyToastClickedOrClosed: true, newPrivacyPolicyToastShownDate: Date.now(), - usedNetworks: { - [CHAIN_IDS.MAINNET]: true, - [CHAIN_IDS.LINEA_MAINNET]: true, - [CHAIN_IDS.GOERLI]: true, - [CHAIN_IDS.LOCALHOST]: true, - }, snapsInstallPrivacyWarningShown: true, }, BridgeController: { diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 844c4766db3e..94e515d46ff6 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -40,12 +40,6 @@ function onboardingFixture() { '__FIXTURE_SUBSTITUTION__currentDateInMilliseconds', showTestnetMessageInDropdown: true, trezorModel: null, - usedNetworks: { - [CHAIN_IDS.MAINNET]: true, - [CHAIN_IDS.LINEA_MAINNET]: true, - [CHAIN_IDS.GOERLI]: true, - [CHAIN_IDS.LOCALHOST]: true, - }, }, NetworkController: { ...mockNetworkStateOld({ diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json index 1df430082f3e..8351032761a7 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-background-state.json @@ -45,7 +45,6 @@ "nftsDropdownState": {}, "termsOfUseLastAgreed": "number", "qrHardware": {}, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "snapsInstallPrivacyWarningShown": true, "surveyLinkLastClickedOrClosed": "object", "signatureSecurityAlertResponses": "object", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json index 9988234cac2e..5d79ca5964b8 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-after-init-opt-in-ui-state.json @@ -95,7 +95,6 @@ "nftsDropdownState": {}, "termsOfUseLastAgreed": "number", "qrHardware": {}, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "snapsInstallPrivacyWarningShown": true, "surveyLinkLastClickedOrClosed": "object", "signatureSecurityAlertResponses": "object", diff --git a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json index 07b292d33b3b..1a1009c02c23 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-background-state.json @@ -42,12 +42,6 @@ "trezorModel": null, "newPrivacyPolicyToastClickedOrClosed": "boolean", "newPrivacyPolicyToastShownDate": "number", - "usedNetworks": { - "0x1": true, - "0xe708": true, - "0x5": true, - "0x539": true - }, "snapsInstallPrivacyWarningShown": true }, "CurrencyController": { diff --git a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json index f997b89bcd28..e7fe6fd2a641 100644 --- a/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json +++ b/test/e2e/tests/metrics/state-snapshots/errors-before-init-opt-in-ui-state.json @@ -42,12 +42,6 @@ "trezorModel": null, "newPrivacyPolicyToastClickedOrClosed": "boolean", "newPrivacyPolicyToastShownDate": "number", - "usedNetworks": { - "0x1": true, - "0xe708": true, - "0x5": true, - "0x539": true - }, "snapsInstallPrivacyWarningShown": true }, "BridgeController": { diff --git a/test/integration/data/integration-init-state.json b/test/integration/data/integration-init-state.json index 0c3853035080..ac58306adca8 100644 --- a/test/integration/data/integration-init-state.json +++ b/test/integration/data/integration-init-state.json @@ -2052,15 +2052,6 @@ "useSafeChainsListValidation": true, "useTokenDetection": false, "useTransactionSimulations": true, - "usedNetworks": { - "0xaa36a7": { - "rpcUrl": "https://sepolia.infura.io/v3/dummy_key", - "chainId": "0xaa36a7", - "nickname": "Sepolia Test Network", - "ticker": "ETH", - "blockExplorerUrl": "https://sepolia.etherscan.io" - } - }, "userOperations": {}, "versionFileETag": "W/\"598946a37f16c5b882a0bebbadf4509f\"", "versionInfo": [], diff --git a/test/integration/data/onboarding-completion-route.json b/test/integration/data/onboarding-completion-route.json index b2c19536a138..33d0680ab8a0 100644 --- a/test/integration/data/onboarding-completion-route.json +++ b/test/integration/data/onboarding-completion-route.json @@ -463,7 +463,6 @@ "useSafeChainsListValidation": true, "useTokenDetection": true, "useTransactionSimulations": true, - "usedNetworks": { "0x1": true, "0x5": true, "0x539": true }, "userOperations": {}, "versionFileETag": "", "versionInfo": [], diff --git a/ui/components/ui/new-network-info/new-network-info.js b/ui/components/ui/new-network-info/new-network-info.js index 15a11918afc1..9d4df0ec63ec 100644 --- a/ui/components/ui/new-network-info/new-network-info.js +++ b/ui/components/ui/new-network-info/new-network-info.js @@ -24,7 +24,6 @@ import { getParticipateInMetaMetrics, getDataCollectionForMarketing, } from '../../../selectors'; -import { setFirstTimeUsedNetwork } from '../../../store/actions'; import { PickerNetwork, Text, @@ -56,7 +55,6 @@ export default function NewNetworkInfo() { const onCloseClick = () => { setShowPopup(false); - setFirstTimeUsedNetwork(providerConfig.chainId); }; const checkTokenDetection = useCallback(async () => { diff --git a/ui/pages/routes/routes.component.test.js b/ui/pages/routes/routes.component.test.js index 14490ad6e146..e661099e1aa2 100644 --- a/ui/pages/routes/routes.component.test.js +++ b/ui/pages/routes/routes.component.test.js @@ -225,12 +225,6 @@ describe('Routes Component', () => { }, selectedAccount: account.id, }, - usedNetworks: { - '0x1': true, - '0x5': true, - '0x539': true, - [mockNewlyAddedNetwork.chainId]: false, - }, networkConfigurationsByChainId: { ...mockState.metamask.networkConfigurationsByChainId, [mockNewlyAddedNetwork.chainId]: mockNewlyAddedNetwork, @@ -312,7 +306,6 @@ describe('toast display', () => { announcements: {}, approvalFlows: [], completedOnboarding: true, - usedNetworks: [], pendingApprovals: {}, pendingApprovalCount: 0, preferences: { @@ -341,7 +334,6 @@ describe('toast display', () => { announcements: {}, approvalFlows: [], completedOnboarding: true, - usedNetworks: [], pendingApprovals: {}, pendingApprovalCount: 0, swapsState: { swapsFeatureIsLive: true }, diff --git a/ui/pages/routes/routes.container.js b/ui/pages/routes/routes.container.js index 28f4291ee37c..0342fc2e15d1 100644 --- a/ui/pages/routes/routes.container.js +++ b/ui/pages/routes/routes.container.js @@ -8,7 +8,6 @@ import { } from '../../../shared/modules/selectors/networks'; import { getAllAccountsOnNetworkAreEmpty, - getIsNetworkUsed, getNetworkIdentifier, getPreferences, getTheme, @@ -95,7 +94,6 @@ function mapStateToProps(state) { providerType: getProviderConfig(state).type, theme: getTheme(state), sendStage: getSendStage(state), - isNetworkUsed: getIsNetworkUsed(state), allAccountsOnNetworkAreEmpty: getAllAccountsOnNetworkAreEmpty(state), isTestNet: getIsTestnet(state), showExtensionInFullSizeView: getShowExtensionInFullSizeView(state), diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index 2baaa1a0c931..deb18c1c5309 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -2726,13 +2726,6 @@ export function getBlockExplorerLinkText( return blockExplorerLinkText; } -export function getIsNetworkUsed(state) { - const chainId = getCurrentChainId(state); - const { usedNetworks } = state.metamask; - - return Boolean(usedNetworks[chainId]); -} - export function getAllAccountsOnNetworkAreEmpty(state) { const balances = getMetaMaskCachedBalances(state) ?? {}; const hasNoNativeFundsOnAnyAccounts = Object.values(balances).every( diff --git a/ui/store/actions.ts b/ui/store/actions.ts index 9b402f476a7e..01b8b9e458d9 100644 --- a/ui/store/actions.ts +++ b/ui/store/actions.ts @@ -5201,10 +5201,6 @@ export function setUseTransactionSimulations(val: boolean): void { } } -export function setFirstTimeUsedNetwork(chainId: string) { - return submitRequestToBackground('setFirstTimeUsedNetwork', [chainId]); -} - // QR Hardware Wallets export async function submitQRHardwareCryptoHDKey(cbor: Hex) { await submitRequestToBackground('submitQRHardwareCryptoHDKey', [cbor]); From 5ab288b8587df64bd7a9c0ede2d0d085dfd713ae Mon Sep 17 00:00:00 2001 From: Salim TOUBAL Date: Mon, 2 Dec 2024 10:38:42 +0100 Subject: [PATCH 005/175] fix: fix asset-list e2e test (#28822) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** fix e2e test for the unified list [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28822?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. run `PORTFOLIO_VIEW=1 yarn build:test` 2. Run `PORTFOLIO_VIEW=1 yarn test:e2e:single --browser=chrome test/e2e/tests/multichain/asset-list.spec.ts --debug --leave-running` ## **Screenshots/Recordings** ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- test/e2e/fixture-builder.js | 16 ++++++++++++ test/e2e/tests/multichain/asset-list.spec.ts | 27 ++++++++++---------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/test/e2e/fixture-builder.js b/test/e2e/fixture-builder.js index 94e515d46ff6..7269bda82153 100644 --- a/test/e2e/fixture-builder.js +++ b/test/e2e/fixture-builder.js @@ -299,6 +299,22 @@ class FixtureBuilder { }); } + withNetworkControllerOnPolygon() { + return this.withNetworkController({ + networkConfigurations: { + networkConfigurationId: { + chainId: CHAIN_IDS.POLYGON, + nickname: 'Polygon Mainnet', + rpcPrefs: {}, + rpcUrl: 'https://mainnet.infura.io', + ticker: 'ETH', + networkConfigurationId: 'networkConfigurationId', + id: 'networkConfigurationId', + }, + }, + }); + } + withNetworkControllerDoubleGanache() { const ganacheNetworks = mockNetworkStateOld({ id: '76e9cd59-d8e2-47e7-b369-9c205ccb602c', diff --git a/test/e2e/tests/multichain/asset-list.spec.ts b/test/e2e/tests/multichain/asset-list.spec.ts index 5b210730ef36..d7120a1fcace 100644 --- a/test/e2e/tests/multichain/asset-list.spec.ts +++ b/test/e2e/tests/multichain/asset-list.spec.ts @@ -13,14 +13,15 @@ import AssetListPage from '../../page-objects/pages/asset-list'; const NETWORK_NAME_MAINNET = 'Ethereum Mainnet'; const LINEA_NAME_MAINNET = 'Linea Mainnet'; -const LOCALHOST = 'Localhost 8545'; +const POLYGON_NAME_MAINNET = 'Polygon'; const BALANCE_AMOUNT = '24.9956'; -function buildFixtures(title: string) { +function buildFixtures(title: string, chainId: number = 1337) { return { fixtures: new FixtureBuilder() .withPermissionControllerConnectedToTestDapp() - .withTokensControllerERC20() + .withNetworkControllerOnPolygon() + .withTokensControllerERC20({ chainId }) .build(), ganacheOptions: defaultGanacheOptions, smartContract: SMART_CONTRACTS.HST, @@ -49,7 +50,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.waitUntilAssetListHasItems(3); await assetListPage.openNetworksFilter(); await assetListPage.clickCurrentNetworkOption(); await headerNavbar.clickSwitchNetworkDropDown(); @@ -79,7 +80,7 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.waitUntilAssetListHasItems(3); await driver.clickElement('.multichain-token-list-item'); const coinOverviewElement = await driver.findElement( '[data-testid="coin-overview-buy"]', @@ -97,7 +98,7 @@ describe('Multichain Asset List', function (this: Suite) { }); it('switches networks when clicking on send for a token on another network', async function () { await withFixtures( - buildFixtures(this.test?.fullTitle() as string), + buildFixtures(this.test?.fullTitle() as string, 137), async ({ driver, ganacheServer, @@ -112,10 +113,10 @@ describe('Multichain Asset List', function (this: Suite) { await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); const sendPage = new SendTokenPage(driver); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.waitUntilAssetListHasItems(4); await assetListPage.clickOnAsset('TST'); await driver.clickElement('[data-testid="eth-overview-send"]'); - await sendPage.check_networkChange(LOCALHOST); + await sendPage.check_networkChange(POLYGON_NAME_MAINNET); await sendPage.check_pageIsLoaded(); await sendPage.fillRecipient( '0x2f318C334780961FB129D2a6c30D0763d9a5C970', @@ -132,7 +133,7 @@ describe('Multichain Asset List', function (this: Suite) { }); it('switches networks when clicking on swap for a token on another network', async function () { await withFixtures( - buildFixtures(this.test?.fullTitle() as string), + buildFixtures(this.test?.fullTitle() as string, 137), async ({ driver, ganacheServer, @@ -146,14 +147,14 @@ describe('Multichain Asset List', function (this: Suite) { const assetListPage = new AssetListPage(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(NETWORK_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.waitUntilAssetListHasItems(4); await assetListPage.clickOnAsset('TST'); await driver.clickElement('.mm-box > button:nth-of-type(3)'); const toastTextElement = await driver.findElement('.toast-text'); const toastText = await toastTextElement.getText(); assert.equal( toastText, - `You're now using ${LOCALHOST}`, + `You're now using ${POLYGON_NAME_MAINNET}`, 'Toast text is correct', ); }, @@ -175,7 +176,7 @@ describe('Multichain Asset List', function (this: Suite) { const selectNetworkDialog = new SelectNetwork(driver); await headerNavbar.clickSwitchNetworkDropDown(); await selectNetworkDialog.selectNetworkName(LINEA_NAME_MAINNET); - await assetListPage.waitUntilAssetListHasItems(2); + await assetListPage.waitUntilAssetListHasItems(3); await assetListPage.clickOnAsset('Ethereum'); @@ -187,7 +188,7 @@ describe('Multichain Asset List', function (this: Suite) { const toastText = await toastTextElement.getText(); assert.equal( toastText, - `You're now using ${LOCALHOST}`, + `You're now using Ethereum Mainnet`, 'Toast text is correct', ); const balanceMessageElement = await driver.findElement( From 3ad954a2f6e0def316270b1ded679f02f25a9867 Mon Sep 17 00:00:00 2001 From: seaona <54408225+seaona@users.noreply.github.com> Date: Mon, 2 Dec 2024 14:36:33 +0100 Subject: [PATCH 006/175] chore: accept regex expression for rerun-from-failed trigger from circle ci UI, so we can add multiple triggers following the name convention (#28804) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** In circle ci UI, there is no way to schedule a trigger for different times in a day. Instead you can only scheduled a trigger to run once a day (or multiple times within that scheduled hour). Given that we want to trigger the rerun from failed job, different times within a day, we are now accepting a regex in the trigger name, so we can add as many triggers as we want in the UI, following that pattern (see screenshot below). [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28804?quickstart=1) ## **Related issues** Fixes: ## **Manual testing steps** 1. We can only test this from the UI side, once the PR is merged - I already created different triggers on circle ci ## **Screenshots/Recordings** ![Screenshot from 2024-11-29 11-10-44](https://github.com/user-attachments/assets/0c71c6f9-8673-42d2-a5fd-6d7790be95ac) ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3178a687a617..facf47afbb9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -107,7 +107,9 @@ workflows: - matches: pattern: /^l10n_crowdin_action$/ value: << pipeline.git.branch >> - - equal: [rerun-from-failed, << pipeline.schedule.name >>] + - matches: + pattern: /^rerun-from-failed.*/ + value: << pipeline.schedule.name >> jobs: - create_release_pull_request: <<: *rc_branch_only @@ -361,7 +363,9 @@ workflows: rerun-from-failed: when: - equal: [rerun-from-failed, << pipeline.schedule.name >>] + matches: + pattern: /^rerun-from-failed.*/ + value: << pipeline.schedule.name >> jobs: - prep-deps - rerun-workflows-from-failed: From b6bf219d1a5c883ccf69705f211aacc543e8fd48 Mon Sep 17 00:00:00 2001 From: Mark Stacey Date: Mon, 2 Dec 2024 10:30:46 -0330 Subject: [PATCH 007/175] chore: Rename `develop` to `main` (#28821) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Rename references to the main branch. It will be called `main` rather than `develop`. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28821?quickstart=1) ## **Related issues** Relates to https://github.com/MetaMask/MetaMask-planning/issues/3677/ ## **Manual testing steps** N/A ## **Screenshots/Recordings** N/A ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --------- Co-authored-by: Dan J Miller --- .circleci/config.yml | 24 +++++----- .circleci/scripts/bundle-stats-commit.sh | 4 +- .circleci/scripts/check_mmi_trigger.sh | 2 +- .circleci/scripts/git-diff-develop.ts | 2 +- .../scripts/rerun-ci-workflow-from-failed.ts | 8 ++-- .devcontainer/download-builds.ts | 2 +- .github/CONTRIBUTING.md | 6 +-- .github/guidelines/LABELING_GUIDELINES.md | 2 +- .github/pull-request-template.md | 4 +- .../scripts/check-pr-has-required-labels.ts | 2 +- .../scripts/check-template-and-add-labels.ts | 8 ++-- .../workflows/add-mmi-reviewer-and-notify.yml | 4 +- .github/workflows/add-release-label.yml | 2 +- .github/workflows/check-pr-labels.yml | 2 +- .github/workflows/codeql-analysis.yml | 4 +- .github/workflows/codespaces.yml | 2 +- .github/workflows/crowdin-action.yml | 2 +- .github/workflows/main.yml | 2 +- .github/workflows/security-code-scanner.yml | 4 +- .github/workflows/update-coverage.yml | 2 +- .../validate-conventional-commits.yml | 2 +- README.md | 2 +- app/scripts/lib/setupSentry.js | 4 +- development/build/README.md | 4 +- development/build/utils.js | 2 +- development/fitness-functions/rules/index.ts | 2 +- development/highlights/index.js | 6 +-- development/master-sync.js | 14 +++--- docs/QA_MIGRATIONS_GUIDE.md | 2 +- .../README.md | 8 ++-- .../confirmation-page-structure/README.md | 14 +++--- .../confirmation-pages-routing/README.md | 10 ++-- .../confirmation-state-management/README.md | 16 +++---- .../signature-request/README.md | 46 +++++++++---------- docs/publishing.md | 8 ++-- test/e2e/flask/README.md | 2 +- .../upgrade-testing/upgrade-testing.md | 2 +- ui/components/ui/box/README.mdx | 26 +++++------ ui/hooks/useTransactionInsights.js | 2 +- 39 files changed, 130 insertions(+), 130 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index facf47afbb9b..83c5643400a4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,11 +45,11 @@ rc_branch_only: &rc_branch_only only: - /^Version-v(\d+)[.](\d+)[.](\d+)/ -develop_master_rc_only: &develop_master_rc_only +main_master_rc_only: &main_master_rc_only filters: branches: only: - - develop + - main - master - /^Version-v(\d+)[.](\d+)[.](\d+)/ @@ -174,7 +174,7 @@ workflows: requires: - prep-deps - prep-build-test-flask-mv2: - <<: *develop_master_rc_only + <<: *main_master_rc_only requires: - prep-deps - prep-build-test-mmi: @@ -202,7 +202,7 @@ workflows: requires: - prep-deps - test-e2e-chrome-webpack: - <<: *develop_master_rc_only + <<: *main_master_rc_only requires: - prep-build-test-webpack - get-changed-files-with-git-diff @@ -211,7 +211,7 @@ workflows: - prep-build-test - get-changed-files-with-git-diff - test-e2e-firefox: - <<: *develop_master_rc_only + <<: *main_master_rc_only requires: - prep-build-test-mv2 - get-changed-files-with-git-diff @@ -231,7 +231,7 @@ workflows: - prep-build-test-flask - get-changed-files-with-git-diff - test-e2e-firefox-flask: - <<: *develop_master_rc_only + <<: *main_master_rc_only requires: - prep-build-test-flask-mv2 - test-e2e-chrome-mmi: @@ -252,7 +252,7 @@ workflows: filters: branches: only: - - develop + - main - /^Version-v(\d+)[.](\d+)[.](\d+)/ requires: - prep-build @@ -351,13 +351,13 @@ workflows: - job-publish-storybook: filters: branches: - only: develop + only: main requires: - prep-build-storybook - job-publish-ts-migration-dashboard: filters: branches: - only: develop + only: main requires: - prep-build-ts-migration-dashboard @@ -371,7 +371,7 @@ workflows: - rerun-workflows-from-failed: filters: branches: - only: develop + only: main requires: - prep-deps @@ -481,7 +481,7 @@ jobs: # This job is used for the e2e quality gate. # It must be run before any job which uses the run-all.js script. - # The job is skipped in develop, master or RC branches. + # The job is skipped in main, master or RC branches. get-changed-files-with-git-diff: executor: node-browsers-small steps: @@ -1339,7 +1339,7 @@ jobs: template: basic_fail_1 channel: C01LUJL3T98 - slack/notify: - branch_pattern: develop + branch_pattern: main event: fail mentions: <@antonio.regadas>, @ramon.acitores134 template: basic_fail_1 diff --git a/.circleci/scripts/bundle-stats-commit.sh b/.circleci/scripts/bundle-stats-commit.sh index 14b3604d82ec..1c9f4380f694 100755 --- a/.circleci/scripts/bundle-stats-commit.sh +++ b/.circleci/scripts/bundle-stats-commit.sh @@ -16,9 +16,9 @@ then exit 1 fi -if [[ "${CIRCLE_BRANCH}" != "develop" ]] +if [[ "${CIRCLE_BRANCH}" != "main" ]] then - printf 'This is not develop branch' + printf 'This is not main branch' exit 0 fi diff --git a/.circleci/scripts/check_mmi_trigger.sh b/.circleci/scripts/check_mmi_trigger.sh index c8d6fc44523b..b2a5ca13734d 100755 --- a/.circleci/scripts/check_mmi_trigger.sh +++ b/.circleci/scripts/check_mmi_trigger.sh @@ -9,7 +9,7 @@ if [ -z "$CIRCLE_PULL_REQUEST" ] || [ -z "$GITHUB_TOKEN" ]; then exit 0 fi -if [[ $CIRCLE_BRANCH = 'develop' || $CIRCLE_BRANCH = 'master' || $CIRCLE_BRANCH =~ ^Version-v[0-9.]* ]]; then +if [[ $CIRCLE_BRANCH = 'main' || $CIRCLE_BRANCH = 'master' || $CIRCLE_BRANCH =~ ^Version-v[0-9.]* ]]; then echo "Long-running branch detected, running MMI tests." echo "run_mmi_tests=true" > mmi_trigger.env exit 0 diff --git a/.circleci/scripts/git-diff-develop.ts b/.circleci/scripts/git-diff-develop.ts index f4437d6154db..3800c03d3254 100644 --- a/.circleci/scripts/git-diff-develop.ts +++ b/.circleci/scripts/git-diff-develop.ts @@ -10,7 +10,7 @@ const PR_NUMBER = process.env.CIRCLE_PR_NUMBER || process.env.CIRCLE_PULL_REQUEST?.split('/').pop(); -const MAIN_BRANCH = 'develop'; +const MAIN_BRANCH = 'main'; const SOURCE_BRANCH = `refs/pull/${PR_NUMBER}/head`; const CHANGED_FILES_DIR = 'changed-files'; diff --git a/.circleci/scripts/rerun-ci-workflow-from-failed.ts b/.circleci/scripts/rerun-ci-workflow-from-failed.ts index 84827f11fd13..2863ca5bcda0 100644 --- a/.circleci/scripts/rerun-ci-workflow-from-failed.ts +++ b/.circleci/scripts/rerun-ci-workflow-from-failed.ts @@ -59,7 +59,7 @@ interface WorkflowStatusResponse { * Note: the API returns the first 20 workflows by default. * If we wanted to get older workflows, we would need to use the 'page-token' we would get in the first response * and perform a subsequent request with the 'page-token' parameter. - * This seems unnecessary as of today, as the amount of daily PRs merged to develop is not that high. + * This seems unnecessary as of today, as the amount of daily PRs merged to main is not that high. * * @returns {Promise} A promise that resolves to an array of workflow items. * @throws Will throw an error if the CircleCI token is not defined or if the HTTP request fails. @@ -177,7 +177,7 @@ async function rerunWorkflowById(workflowId: string) { } /** - * Re-runs failed CircleCI workflows from develop branch. + * Re-runs failed CircleCI workflows from main branch. * The workflow will only be re-runed if: * 1. It has the status of 'failed' * 2. It has only been run once @@ -187,8 +187,8 @@ async function rerunWorkflowById(workflowId: string) { * @throws Will throw an error if fetching the workflows or re-running a workflow fails. */ async function rerunFailedWorkflowsFromDevelop() { - console.log('Getting Circle Ci workflows from develop branch...'); - const workflows = await getCircleCiWorkflowsByBranch('develop'); + console.log('Getting Circle Ci workflows from main branch...'); + const workflows = await getCircleCiWorkflowsByBranch('main'); console.log('Assessing if any of the workflows needs to be rerun...'); for (const item of workflows) { diff --git a/.devcontainer/download-builds.ts b/.devcontainer/download-builds.ts index 83e1822379a1..5408bba8d69f 100644 --- a/.devcontainer/download-builds.ts +++ b/.devcontainer/download-builds.ts @@ -7,7 +7,7 @@ function getGitBranch() { const gitOutput = execSync('git status').toString(); const branchRegex = /On branch (?.*)\n/; - return gitOutput.match(branchRegex)?.groups?.branch || 'develop'; + return gitOutput.match(branchRegex)?.groups?.branch || 'main'; } async function getCircleJobs(branch: string) { diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 894c13b90238..41d6433db7d7 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -13,14 +13,14 @@ If you're picking up a bounty or an existing issue, feel free to ask clarifying ### Submitting a pull request When you're done with your project / bugfix / feature and ready to submit a PR, there are a couple guidelines we ask you to follow: -- [ ] **Make sure you followed our [`coding guidelines`](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md)**: These guidelines aim to maintain consistency and readability across the codebase. They help ensure that the code is easy to understand, maintain, and modify, which is particularly important when working with multiple contributors. +- [ ] **Make sure you followed our [`coding guidelines`](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md)**: These guidelines aim to maintain consistency and readability across the codebase. They help ensure that the code is easy to understand, maintain, and modify, which is particularly important when working with multiple contributors. - [ ] **Test it**: For any new programmatic functionality, we like unit tests when possible, so if you can keep your code cleanly isolated, please do add a test file to the `tests` folder. - [ ] **Meet the spec**: Make sure the PR adds functionality that matches the issue you're closing. This is especially important for bounties: sometimes design or implementation details are included in the conversation, so read carefully! - [ ] **Close the issue**: If this PR closes an open issue, fill out the "Related issues" section with `Fixes: #$ISSUE_NUMBER`. Ex. For closing issue 418, include the line `Fixes: #418`. If it doesn't close the issue but addresses it partially, just include a reference to the issue number, like `#418`. - [ ] **Keep it simple**: Try not to include multiple features in a single PR, and don't make extraneous changes outside the scope of your contribution. All those touched files make things harder to review ;) -- [ ] **PR against `develop`**: Submit your PR against the `develop` branch. This is where we merge new features so they get some time to receive extra testing before being pushed to `master` for production. If your PR is a hot-fix that needs to be published urgently, you may submit a PR against the `master` branch, but this PR will receive tighter scrutiny before merging. +- [ ] **PR against `main`**: Submit your PR against the `main` branch. This is where we merge new features so they get some time to receive extra testing before being pushed to `master` for production. If your PR is a hot-fix that needs to be published urgently, you may submit a PR against the `master` branch, but this PR will receive tighter scrutiny before merging. - [ ] **Get reviewed by MetaMask Internal Developers**: All PRs require 2 approvals from MetaMask Internal Developers before merging. -- [ ] **Ensure the PR is correctly labeled.**: More detail about PR labels can be found [here](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md). +- [ ] **Ensure the PR is correctly labeled.**: More detail about PR labels can be found [here](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md). - [ ] **PR Titles**: Must adhere to the [Conventional Commits specification](https://www.conventionalcommits.org) - `[optional scope]: ` - Example: `feat(parser): add ability to parse arrays` diff --git a/.github/guidelines/LABELING_GUIDELINES.md b/.github/guidelines/LABELING_GUIDELINES.md index 02081367bb5e..ea37c2e5f03d 100644 --- a/.github/guidelines/LABELING_GUIDELINES.md +++ b/.github/guidelines/LABELING_GUIDELINES.md @@ -14,7 +14,7 @@ It's essential to ensure that PRs have the appropriate labels before they are co - **regression-RC-x.y.z**: This label is manually added to a bug report issue by release engineers when a bug is found during release regerssion testing phase. The `x.y.z` in the label represents the release candidate (RC) version in which the bug's been discovered. ### Optional labels: -- **regression-develop**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `develop`, but is not yet released in production. +- **regression-main**: This label can manually be added to a bug report issue at the time of its creation if the bug is present on the development branch, i.e., `main`, but is not yet released in production. - **needs-qa**: If the PR includes a new features, complex testing steps, or large refactors, this label must be added to indicated PR requires a full manual QA prior being merged and added to a release. ### Labels prohibited when PR needs to be merged: diff --git a/.github/pull-request-template.md b/.github/pull-request-template.md index 59232248ef51..044f83571fc6 100644 --- a/.github/pull-request-template.md +++ b/.github/pull-request-template.md @@ -38,11 +38,11 @@ Fixes: ## **Pre-merge author checklist** -- [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). +- [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable -- [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. +- [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** diff --git a/.github/scripts/check-pr-has-required-labels.ts b/.github/scripts/check-pr-has-required-labels.ts index 354dc2c2aa7d..fcce4dd23a82 100644 --- a/.github/scripts/check-pr-has-required-labels.ts +++ b/.github/scripts/check-pr-has-required-labels.ts @@ -73,7 +73,7 @@ async function main(): Promise { if (!hasTeamLabel) { errorMessage += 'No team labels found on the PR. '; } - errorMessage += `Please make sure the PR is appropriately labeled before merging it.\n\nSee labeling guidelines for more detail: https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md`; + errorMessage += `Please make sure the PR is appropriately labeled before merging it.\n\nSee labeling guidelines for more detail: https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md`; core.setFailed(errorMessage); process.exit(1); } diff --git a/.github/scripts/check-template-and-add-labels.ts b/.github/scripts/check-template-and-add-labels.ts index ed22e98dc9a1..418174df2a90 100644 --- a/.github/scripts/check-template-and-add-labels.ts +++ b/.github/scripts/check-template-and-add-labels.ts @@ -132,7 +132,7 @@ async function main(): Promise { } else { const errorMessage = - "Issue body does not match any of expected templates ('general-issue.yml' or 'bug-report.yml').\n\nMake sure issue's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/develop/.github/scripts/shared/template.ts#L14-L37"; + "Issue body does not match any of expected templates ('general-issue.yml' or 'bug-report.yml').\n\nMake sure issue's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/main/.github/scripts/shared/template.ts#L14-L37"; console.log(errorMessage); // Add label to indicate issue doesn't match any template @@ -152,7 +152,7 @@ async function main(): Promise { ); } else { const errorMessage = - `PR body does not match template ('pull-request-template.md').\n\nMake sure PR's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/develop/.github/scripts/shared/template.ts#L40-L47`; + `PR body does not match template ('pull-request-template.md').\n\nMake sure PR's body includes all section titles.\n\nSections titles are listed here: https://github.com/MetaMask/metamask-extension/blob/main/.github/scripts/shared/template.ts#L40-L47`; console.log(errorMessage); // Add label to indicate PR body doesn't match template @@ -334,7 +334,7 @@ function craftRegressionLabel(regressionStage: RegressionStage | undefined, rele switch (regressionStage) { case RegressionStage.Development: return { - name: `regression-develop`, + name: `regression-main`, color: '5319E7', // violet description: `Regression bug that was found on development branch, but not yet present in production`, }; @@ -364,7 +364,7 @@ function craftRegressionLabel(regressionStage: RegressionStage | undefined, rele return { name: `regression-*`, color: 'EDEDED', // grey - description: `TODO: Unknown regression stage. Please replace with correct regression label: 'regression-develop', 'regression-RC-x.y.z', or 'regression-prod-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`, + description: `TODO: Unknown regression stage. Please replace with correct regression label: 'regression-main', 'regression-RC-x.y.z', or 'regression-prod-x.y.z' label, where 'x.y.z' is the number of the release where bug was found.`, }; } } diff --git a/.github/workflows/add-mmi-reviewer-and-notify.yml b/.github/workflows/add-mmi-reviewer-and-notify.yml index 8821ccbd36e9..8372217bce70 100644 --- a/.github/workflows/add-mmi-reviewer-and-notify.yml +++ b/.github/workflows/add-mmi-reviewer-and-notify.yml @@ -3,7 +3,7 @@ name: Notify MMI team via Slack on: pull_request_target: branches: - - develop + - main types: - opened - reopened @@ -45,4 +45,4 @@ jobs: ] } env: - SLACK_WEBHOOK_URL: ${{ secrets.MMI_LABEL_SLACK_WEBHOOK_URL }} \ No newline at end of file + SLACK_WEBHOOK_URL: ${{ secrets.MMI_LABEL_SLACK_WEBHOOK_URL }} diff --git a/.github/workflows/add-release-label.yml b/.github/workflows/add-release-label.yml index 94ba76fcefa0..2e34ad491b44 100644 --- a/.github/workflows/add-release-label.yml +++ b/.github/workflows/add-release-label.yml @@ -3,7 +3,7 @@ name: Add release label to PR and linked issues when PR gets merged on: pull_request: branches: - - develop + - main types: - closed diff --git a/.github/workflows/check-pr-labels.yml b/.github/workflows/check-pr-labels.yml index 19c0576feaae..cc492c09319e 100644 --- a/.github/workflows/check-pr-labels.yml +++ b/.github/workflows/check-pr-labels.yml @@ -2,7 +2,7 @@ name: Check PR has required labels on: pull_request: branches: - - develop + - main types: - opened - reopened diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 73670c46d75d..a4b5bef7c9e7 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -13,10 +13,10 @@ name: "CodeQL" on: push: - branches: [ develop, Version-v*, cla-signatures, master, snaps ] + branches: [ main, Version-v*, cla-signatures, master, snaps ] pull_request: # The branches below must be a subset of the branches above - branches: [ develop ] + branches: [ main ] schedule: - cron: '28 12 * * 0' diff --git a/.github/workflows/codespaces.yml b/.github/workflows/codespaces.yml index 3455e2db54d4..5d37ba2d3dc3 100644 --- a/.github/workflows/codespaces.yml +++ b/.github/workflows/codespaces.yml @@ -4,7 +4,7 @@ on: push: branches: - 'codespaces**' - - 'develop' + - 'main' paths: - '**/yarn.lock' diff --git a/.github/workflows/crowdin-action.yml b/.github/workflows/crowdin-action.yml index 94bd8016cd4f..1a902087ad61 100644 --- a/.github/workflows/crowdin-action.yml +++ b/.github/workflows/crowdin-action.yml @@ -7,7 +7,7 @@ permissions: on: push: branches: - - develop + - main schedule: - cron: "0 */12 * * *" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f3cc68bebcec..2554557b9c35 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: Main on: push: branches: - - develop + - main - master pull_request: types: diff --git a/.github/workflows/security-code-scanner.yml b/.github/workflows/security-code-scanner.yml index 7da1773d666c..cf0b60cf84ac 100644 --- a/.github/workflows/security-code-scanner.yml +++ b/.github/workflows/security-code-scanner.yml @@ -2,9 +2,9 @@ name: "MetaMask Security Code Scanner" on: push: - branches: [ 'develop' ] + branches: [ 'main' ] pull_request: - branches: [ 'develop' ] + branches: [ 'main' ] jobs: run-security-scan: diff --git a/.github/workflows/update-coverage.yml b/.github/workflows/update-coverage.yml index fd1b0d5134e3..e65cdcbe978b 100644 --- a/.github/workflows/update-coverage.yml +++ b/.github/workflows/update-coverage.yml @@ -43,4 +43,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.LAVAMOAT_UPDATE_TOKEN }} run: | - gh pr create --title "chore: Update coverage.json" --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%." --base develop --head metamaskbot/update-coverage || gh pr edit --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%." + gh pr create --title "chore: Update coverage.json" --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%." --base main --head metamaskbot/update-coverage || gh pr edit --body "This PR is automatically opened to update the coverage.json file when test coverage increases. Coverage increased from $STORED_COVERAGE% to $CURRENT_COVERAGE%." diff --git a/.github/workflows/validate-conventional-commits.yml b/.github/workflows/validate-conventional-commits.yml index 8cb416844339..b8b5c56eabb6 100644 --- a/.github/workflows/validate-conventional-commits.yml +++ b/.github/workflows/validate-conventional-commits.yml @@ -2,7 +2,7 @@ name: Validate Conventional Commit Title on: pull_request: branches: - - develop + - main types: [opened, edited, reopened, synchronize] jobs: diff --git a/README.md b/README.md index f3e738a40abc..85d1b3f91ba3 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To learn how to develop MetaMask-compatible applications, visit our [Developer D To learn how to contribute to the MetaMask codebase, visit our [Contributor Docs](https://github.com/MetaMask/contributor-docs). -To learn how to contribute to the MetaMask Extension project itself, visit our [Extension Docs](https://github.com/MetaMask/metamask-extension/tree/develop/docs). +To learn how to contribute to the MetaMask Extension project itself, visit our [Extension Docs](https://github.com/MetaMask/metamask-extension/tree/main/docs). ## GitHub Codespaces quickstart diff --git a/app/scripts/lib/setupSentry.js b/app/scripts/lib/setupSentry.js index 72c246826ab5..76d66eba88d2 100644 --- a/app/scripts/lib/setupSentry.js +++ b/app/scripts/lib/setupSentry.js @@ -127,9 +127,9 @@ function getTracesSampleRate(sentryTarget) { } if (flags.circleci) { - // Report very frequently on develop branch, and never on other branches + // Report very frequently on main branch, and never on other branches // (Unless you use a `flags = {"sentry": {"tracesSampleRate": x.xx}}` override) - if (flags.circleci.branch === 'develop') { + if (flags.circleci.branch === 'main') { return 0.015; } return 0; diff --git a/development/build/README.md b/development/build/README.md index 9d5df1e149fc..3aecead0cb25 100644 --- a/development/build/README.md +++ b/development/build/README.md @@ -4,7 +4,7 @@ > Add `--build-type flask` to build Flask, our canary distribution with more experimental features. This directory contains the MetaMask build system, which is used to build the MetaMask Extension such that it can be used in a supported browser. -From the repository root, the build system entry file is located at [`./development/build/index.js`](https://github.com/MetaMask/metamask-extension/blob/develop/development/build/index.js). +From the repository root, the build system entry file is located at [`./development/build/index.js`](https://github.com/MetaMask/metamask-extension/blob/main/development/build/index.js). Several package scripts invoke the build system. For example, `yarn start` creates a watched development build, and `yarn dist` creates a production build. @@ -20,7 +20,7 @@ are written to the `./dist` directory. Our JavaScript source files are transformed using [Babel](https://babeljs.io/), specifically using the [`babelify`](https://npmjs.com/package/babelify) Browserify transform. -Source file bundling tasks are implemented in the [`./development/build/scripts.js`](https://github.com/MetaMask/metamask-extension/blob/develop/development/build/scripts.js). +Source file bundling tasks are implemented in the [`./development/build/scripts.js`](https://github.com/MetaMask/metamask-extension/blob/main/development/build/scripts.js). > Locally implemented Browserify transforms, _some of which affect how we write JavaScript_, are listed and documented [here](./transforms/README.md). diff --git a/development/build/utils.js b/development/build/utils.js index 626aacd588c7..301c998534ad 100644 --- a/development/build/utils.js +++ b/development/build/utils.js @@ -130,7 +130,7 @@ function getEnvironment({ buildTarget }) { /^Version-v(\d+)[.](\d+)[.](\d+)/u.test(process.env.CIRCLE_BRANCH) ) { return ENVIRONMENT.RELEASE_CANDIDATE; - } else if (process.env.CIRCLE_BRANCH === 'develop') { + } else if (process.env.CIRCLE_BRANCH === 'main') { return ENVIRONMENT.STAGING; } else if (process.env.CIRCLE_PULL_REQUEST) { return ENVIRONMENT.PULL_REQUEST; diff --git a/development/fitness-functions/rules/index.ts b/development/fitness-functions/rules/index.ts index 6ba0f1198684..5afb72fa5343 100644 --- a/development/fitness-functions/rules/index.ts +++ b/development/fitness-functions/rules/index.ts @@ -6,7 +6,7 @@ const RULES: IRule[] = [ name: "Don't use `sinon` or `assert` in unit tests", fn: preventSinonAssertSyntax, errorMessage: - '`sinon` or `assert` was detected in the diff. Please use Jest instead. For more info: https://github.com/MetaMask/metamask-extension/blob/develop/docs/testing.md#favor-jest-instead-of-mocha', + '`sinon` or `assert` was detected in the diff. Please use Jest instead. For more info: https://github.com/MetaMask/metamask-extension/blob/main/docs/testing.md#favor-jest-instead-of-mocha', }, { name: "Don't add JS or JSX files", diff --git a/development/highlights/index.js b/development/highlights/index.js index 2b263005fb96..2616d602633e 100644 --- a/development/highlights/index.js +++ b/development/highlights/index.js @@ -6,11 +6,11 @@ module.exports = { getHighlights }; async function getHighlights({ artifactBase }) { let highlights = ''; - // here we assume the PR base branch ("target") is `develop` in lieu of doing + // here we assume the PR base branch ("target") is `main` in lieu of doing // a query against the github api which requires an access token // see https://discuss.circleci.com/t/how-to-retrieve-a-pull-requests-base-branch-name-github/36911 - const changedFiles = await getChangedFiles({ target: 'develop' }); - console.log(`detected changed files vs develop:`); + const changedFiles = await getChangedFiles({ target: 'main' }); + console.log(`detected changed files vs main:`); for (const filename of changedFiles) { console.log(` ${filename}`); } diff --git a/development/master-sync.js b/development/master-sync.js index 548ae6611c2f..dc1d474eaebe 100644 --- a/development/master-sync.js +++ b/development/master-sync.js @@ -51,8 +51,8 @@ async function runGitCommands() { console.log('Executed: git reset --hard origin/master'); try { - await exec('git merge origin/develop'); - console.log('Executed: git merge origin/develop'); + await exec('git merge origin/main'); + console.log('Executed: git merge origin/main'); } catch (error) { // Handle the error but continue script execution if ( @@ -70,11 +70,11 @@ async function runGitCommands() { } await exec('git add .'); - await exec('git restore --source origin/develop .'); - console.log('Executed: it restore --source origin/develop .'); + await exec('git restore --source origin/main .'); + console.log('Executed: it restore --source origin/main .'); - await exec('git checkout origin/develop -- .'); - console.log('Executed: git checkout origin/develop -- .'); + await exec('git checkout origin/main -- .'); + console.log('Executed: git checkout origin/main -- .'); await exec('git checkout origin/master -- CHANGELOG.md'); console.log('Executed: git checkout origin/master -- CHANGELOG.md'); @@ -91,7 +91,7 @@ async function runGitCommands() { await exec('git add .'); console.log('Executed: git add .'); - await exec('git commit -m "Merge origin/develop into master-sync"'); + await exec('git commit -m "Merge origin/main into master-sync"'); console.log('Executed: git commit'); console.log('Your local master-sync branch is now ready to become a PR.'); diff --git a/docs/QA_MIGRATIONS_GUIDE.md b/docs/QA_MIGRATIONS_GUIDE.md index fbd2c38a182a..beb3a239dea8 100644 --- a/docs/QA_MIGRATIONS_GUIDE.md +++ b/docs/QA_MIGRATIONS_GUIDE.md @@ -2,7 +2,7 @@ Migrations are needed to change top-level state data, this can be found in the browser's storage. This can look like removing specific keys/value pairs from state, changing objects to an array of objects, changing the name of a controller, etc. Steps - 1. Create a new MetaMask directory\* folder locally with the source files before the migration, and load it as an unpacked extension in Chrome\*. If the migration is in a pull request, then build the `develop` branch to load. If the migration is already in `develop`, get a commit before the migration was added to build. + 1. Create a new MetaMask directory\* folder locally with the source files before the migration, and load it as an unpacked extension in Chrome\*. If the migration is in a pull request, then build the `main` branch to load. If the migration is already in `main`, get a commit before the migration was added to build. ![Load unpacked extension to chrome](./assets/load-build-chrome.gif) diff --git a/docs/confirmation-refactoring/confirmation-backend-architecture/README.md b/docs/confirmation-refactoring/confirmation-backend-architecture/README.md index a3f30eb88a56..b927b5789801 100644 --- a/docs/confirmation-refactoring/confirmation-backend-architecture/README.md +++ b/docs/confirmation-refactoring/confirmation-backend-architecture/README.md @@ -5,13 +5,13 @@ Current confirmation implementation in the background consists of following pieces: 1. `TransactionController` and utility, helper classes used by it: - `TransactionController` is very important piece in transaction processing. It is described [here](https://github.com/MetaMask/metamask-extension/tree/develop/app/scripts/controllers/transactions#transaction-controller). It consists of 4 important parts: + `TransactionController` is very important piece in transaction processing. It is described [here](https://github.com/MetaMask/metamask-extension/tree/main/app/scripts/controllers/transactions#transaction-controller). It consists of 4 important parts: - `txStateManager`: responsible for the state of a transaction and storing the transaction - `pendingTxTracker`: watching blocks for transactions to be include and emitting confirmed events - `txGasUtil`: gas calculations and safety buffering - `nonceTracker`: calculating nonces 2. `MessageManagers`: - There are 3 different message managers responsible for processing signature requests. These are detailed [here](https://github.com/MetaMask/metamask-extension/tree/develop/docs/refactoring/signature-request#proposed-refactoring). + There are 3 different message managers responsible for processing signature requests. These are detailed [here](https://github.com/MetaMask/metamask-extension/tree/main/docs/refactoring/signature-request#proposed-refactoring). 3. `MetamaskController `: `MetamaskController ` is responsible for gluing together the different pieces in transaction processing. It is responsible to inject dependencies in `TransactionController`, `MessageManagers`, handling different events, responses to DAPP requests, etc. @@ -19,8 +19,8 @@ Current confirmation implementation in the background consists of following piec 1. Migrating to `@metamask/transaction-controller`. `TransactionController` in extension repo should eventually get replaced by core repo [TransactionController](https://github.com/MetaMask/core/tree/main/packages/transaction-controller). This controller is maintained by core team and also used in Metamask Mobile App. 2. Migrating to `@metamask/message-manager`. Message Managers in extension repo should be deprecated in favor of core repo [MessageManagers](https://github.com/MetaMask/core/tree/main/packages/message-manager). -3. Cleanup Code in `MetamaskController`. [Metamaskcontroller](https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/metamask-controller.js) is where `TransactionController` and different `MessageManagers` are initialized. It is responsible for injecting required dependencies. Also, it is responsible for handling incoming DAPP requests and invoking appropriate methods in these background classes. Over the period of time lot of code that should have been part of `TransactionController` and `MessageManagers` has ended up in `MetamaskController`. We need to cleanup this code and move to the appropriate classes. - - Code [here](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L3097) to check if `eth_sign` is enabled in preferences and perform other validation on the incoming request should be part of [MessageManager](https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/lib/message-manager.js) +3. Cleanup Code in `MetamaskController`. [Metamaskcontroller](https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/metamask-controller.js) is where `TransactionController` and different `MessageManagers` are initialized. It is responsible for injecting required dependencies. Also, it is responsible for handling incoming DAPP requests and invoking appropriate methods in these background classes. Over the period of time lot of code that should have been part of `TransactionController` and `MessageManagers` has ended up in `MetamaskController`. We need to cleanup this code and move to the appropriate classes. + - Code [here](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L3097) to check if `eth_sign` is enabled in preferences and perform other validation on the incoming request should be part of [MessageManager](https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/lib/message-manager.js) - Method to sign messages [signMessage](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L3158), [signPersonalMessage](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L3217), [signTypedMessage](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L3470) can be simplified by injecting `KeyringController` into `MessageManagers`. - There are about 11 different methods to `add`, `approve`, `reject` different types of signature requests. These can probably be moved to a helper class, thus reducing lines of code from `MetamaskController `. - This [code](https://github.com/MetaMask/metamask-extension/blob/bc19856d5d9ad1831e1722c84fe6161bed7a0a5a/app/scripts/metamask-controller.js#L959) can better be placed in `TransactionController`. diff --git a/docs/confirmation-refactoring/confirmation-page-structure/README.md b/docs/confirmation-refactoring/confirmation-page-structure/README.md index a0ecc658836d..3ef31d0e0607 100644 --- a/docs/confirmation-refactoring/confirmation-page-structure/README.md +++ b/docs/confirmation-refactoring/confirmation-page-structure/README.md @@ -11,7 +11,7 @@ Currently we have following confirmation pages mapping to confirmation routes: 5. `pages/confirm-token-transaction-base` 6. `pages/confirm-contract-interaction` -![Confirmation Pages structure](https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/docs/confirmation-refactoring/confirmation-page-structure/current.png) +![Confirmation Pages structure](https://raw.githubusercontent.com/MetaMask/metamask-extension/main/docs/confirmation-refactoring/confirmation-page-structure/current.png) `confirm-page-container` component helps to define a structure for confirmation pages it includes: @@ -26,7 +26,7 @@ Other confirmation components listed above map to different types of transaction ## Areas of Refactoring: -1. ### [confirm-transaction-base](https://github.com/MetaMask/metamask-extension/tree/develop/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js) cleanup: +1. ### [confirm-transaction-base](https://github.com/MetaMask/metamask-extension/tree/main/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js) cleanup: The `confirm-transaction-base` component is huge 1200 lines component taking care of lot of complexity. We need to break it down into smaller components and move logic to hooks or utility classes. Layout related part can be moved to `confirm-page-container`. - Extract out code to render data into separate component from [here](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js#L641). - Extract out component to render hex data from [here](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js#L675). @@ -37,11 +37,11 @@ Other confirmation components listed above map to different types of transaction - Code to get error key [getErrorKey](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js#L230) can be moved to a util function. - As new component for gas selection popups is created this code [handleEditGas, handleCloseEditGas](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js#L276) can be moved to it. - Convert `confirm-transaction-base` into a functional components and extract out all of these functions into a hook - `handleEdit`, `handleCancelAll`, `handleCancel`, `handleSubmit`, `handleSetApprovalForAll`, etc. -2. ### [confirm-transaction-base-container](https://github.com/MetaMask/metamask-extension/tree/develop/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js) cleanup: +2. ### [confirm-transaction-base-container](https://github.com/MetaMask/metamask-extension/tree/main/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js) cleanup: This container is doing much work to query and get required transaction related values from state and pass over to `confirm-transaction-base` component. As we refactor state we should get rid of this component. - remove the use of `state.confirmTransaction` from the component - create hook to get values derived from metamask state and active transaction. - State cleanup is detailed more in a separate document [here](https://github.com/MetaMask/metamask-extension/tree/develop/docs/confirmation-refactoring/confirmation-state-management). + State cleanup is detailed more in a separate document [here](https://github.com/MetaMask/metamask-extension/tree/main/docs/confirmation-refactoring/confirmation-state-management). 3. ### [confirm-page-container](https://github.com/MetaMask/metamask-extension/tree/03ccc5366cf31c9fa0fedc2fac533ebc64e6f2b4/ui/components/app/confirm-page-container) cleanup: As described we should continue to have `confirm-page-container` components taking care of layout. Also wherever possible more re-usable smaller layout components for different part of confirmation page like gas details, gas selection popover, etc should be added. `confirm-page-container` defines a layout which is used by most comfirmation pages, but some pages like new token allowance implementation for `ERC20` differ from this layout. We will be able to use more and more of these re-usable components for other confirmation pages layouts also. @@ -53,9 +53,9 @@ Other confirmation components listed above map to different types of transaction There are 2 different versions popovers for gas editing: - - Legacy gas popover - [component](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/edit-gas-popover) - - EIP-1559 V2 gas popover - [component1](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/edit-gas-fee-popover), [component2](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/advanced-gas-fee-popover). - Context [transaction-modal-context](https://github.com/MetaMask/metamask-extension/blob/develop/ui/contexts/transaction-modal.js) is used to show hide EIP-1559 gas popovers. + - Legacy gas popover - [component](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/edit-gas-popover) + - EIP-1559 V2 gas popover - [component1](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/edit-gas-fee-popover), [component2](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/advanced-gas-fee-popover). + Context [transaction-modal-context](https://github.com/MetaMask/metamask-extension/blob/main/ui/contexts/transaction-modal.js) is used to show hide EIP-1559 gas popovers. A parent component can be created for gas editing popover which will wrap both the legacy and EIP-1559 gas popover. Depending on the type of transaction appropriate gas popover can be shown. `transaction-modal-context` can be used to take care to open/close both popovers. This parent component can be added to `confirm-transaction-base` and `token-allowance` components and thus will be available on all confirmation pages using gas editing. diff --git a/docs/confirmation-refactoring/confirmation-pages-routing/README.md b/docs/confirmation-refactoring/confirmation-pages-routing/README.md index ed4d7aef0788..a6abfcaf31ca 100644 --- a/docs/confirmation-refactoring/confirmation-pages-routing/README.md +++ b/docs/confirmation-refactoring/confirmation-pages-routing/README.md @@ -6,7 +6,7 @@ This document details how routing to confirmation pages is currently done and th The current flow of routing to confirmation pages is un-necessarily complicated and have issues. -![Confirmation Pages Routing - Current](https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/docs/confirmation-refactoring/confirmation-pages-routing/current.png) +![Confirmation Pages Routing - Current](https://raw.githubusercontent.com/MetaMask/metamask-extension/main/docs/confirmation-refactoring/confirmation-pages-routing/current.png) - There are 2 ways in which confirmation pages can be opened: 1. User triggers send flow from within Metamask @@ -24,7 +24,7 @@ The current flow of routing to confirmation pages is un-necessarily complicated The proposed routing of confirmation pages looks like. -![Confirmation Pages Routing - Proposed](https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/docs/confirmation-refactoring/confirmation-pages-routing/proposed.png) +![Confirmation Pages Routing - Proposed](https://raw.githubusercontent.com/MetaMask/metamask-extension/main/docs/confirmation-refactoring/confirmation-pages-routing/proposed.png) - There are 2 ways in which confirmation pages can be opened: 1. User triggers send flow from within Metamask @@ -52,14 +52,14 @@ The proposed routing of confirmation pages looks like. ## Areas of code refactoring -Current routing code is complicated, it is also currently tied to state change in confirmation pages that makes it more complicated. State refactoring as discussed in this [document](https://github.com/MetaMask/metamask-extension/tree/develop/docs/confirmation-refactoring/confirmation-state-management) will also help simplify it. +Current routing code is complicated, it is also currently tied to state change in confirmation pages that makes it more complicated. State refactoring as discussed in this [document](https://github.com/MetaMask/metamask-extension/tree/main/docs/confirmation-refactoring/confirmation-state-management) will also help simplify it. -- Any re-usable routing related code should be moved to [useRouting](https://github.com/MetaMask/metamask-extension/blob/develop/ui/hooks/useRouting.js) hook. +- Any re-usable routing related code should be moved to [useRouting](https://github.com/MetaMask/metamask-extension/blob/main/ui/hooks/useRouting.js) hook. - Logic to initially check state and redirect to `/pages/confirm-transaction` can be moved from `/pages/home` to `pages/routes` - All the route mapping code should be moved to `/pages/confirm-transaction`, this will require getting rid of route mappings in `/pages/confirm-transaction/confirm-token-transaction-switch`, `/pages/confirm-transaction-switch`. - `/pages/confirm-transaction-switch` has the code that checks the un-approved transaction / message in the state, and based on its type and asset redirect to a specific route, a utility method can be created to do this mapping and can be included in `/pages/confirm-transaction` component. - During the send flow initiated within metamask user can be redirected to specific confirmations route **`/confirm-transaction/${id}/XXXX`** -- Confirmation components have lot of props passing which needs to be reduced. Values can be obtained from redux state or other contexts directly using hooks. Component [confirm-token-transaction-switch](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction/confirm-token-transaction-switch.js) has a lot of un-necessary props passing which should be removed and will help to further refactor routing. +- Confirmation components have lot of props passing which needs to be reduced. Values can be obtained from redux state or other contexts directly using hooks. Component [confirm-token-transaction-switch](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction/confirm-token-transaction-switch.js) has a lot of un-necessary props passing which should be removed and will help to further refactor routing. - **Routing to mostRecentOverviewPage** Across confirmation pages there is code to re-direct to `mostRecentOverviewPage`. `mostRecentOverviewPage` is equal to default route `/` or `/asset` whichever was last opened. diff --git a/docs/confirmation-refactoring/confirmation-state-management/README.md b/docs/confirmation-refactoring/confirmation-state-management/README.md index a24184154e5a..da9cf143a754 100644 --- a/docs/confirmation-refactoring/confirmation-state-management/README.md +++ b/docs/confirmation-refactoring/confirmation-state-management/README.md @@ -12,11 +12,11 @@ State Management is very important piece to keep frontend confirmation code simp Refactorings: -- There are confirmations related ducks [here](https://github.com/MetaMask/metamask-extension/tree/develop/ui/ducks): - - [confirm-transaction](https://github.com/MetaMask/metamask-extension/tree/develop/ui/ducks/confirm-transaction): this is redundant and we should be able to get rid of it. - - [gas](https://github.com/MetaMask/metamask-extension/tree/develop/ui/ducks/gas): this is not used anywhere and can be removed. - - [send](https://github.com/MetaMask/metamask-extension/tree/develop/ui/ducks/send): this duck is important state machine for send flow and we should continue to maintain. -- [gasFeeContext](https://github.com/MetaMask/metamask-extension/blob/develop/ui/contexts/gasFee.js) is huge context written on top of [gasFeeInput](https://github.com/MetaMask/metamask-extension/tree/develop/ui/hooks/gasFeeInput) hook. The context / hook provides about 20 different values used in different places in confirmation pages. We need to break this down: +- There are confirmations related ducks [here](https://github.com/MetaMask/metamask-extension/tree/main/ui/ducks): + - [confirm-transaction](https://github.com/MetaMask/metamask-extension/tree/main/ui/ducks/confirm-transaction): this is redundant and we should be able to get rid of it. + - [gas](https://github.com/MetaMask/metamask-extension/tree/main/ui/ducks/gas): this is not used anywhere and can be removed. + - [send](https://github.com/MetaMask/metamask-extension/tree/main/ui/ducks/send): this duck is important state machine for send flow and we should continue to maintain. +- [gasFeeContext](https://github.com/MetaMask/metamask-extension/blob/main/ui/contexts/gasFee.js) is huge context written on top of [gasFeeInput](https://github.com/MetaMask/metamask-extension/tree/main/ui/hooks/gasFeeInput) hook. The context / hook provides about 20 different values used in different places in confirmation pages. We need to break this down: - Context is required only to provide temporary UI state for confirmation pages which includes: @@ -38,10 +38,10 @@ Refactorings: - `gasFeeEstimates` - `isNetworkBusy` - `minimumGasLimitDec` is a constant value 21000 should be removed from the context, this can be moved to constants file. - - Create separate hook for transaction functions [here](https://github.com/MetaMask/metamask-extension/blob/develop/ui/hooks/gasFeeInput/useTransactionFunctions.js), this hook can consume GasFeeContext. - - Setters and manual update functions are only used by legacy gas component [edit-gas-fee-popover](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/edit-gas-popover). This component uses useGasFeeInputs hook. We need to create a smaller hook just for this component using the above context and hooks. + - Create separate hook for transaction functions [here](https://github.com/MetaMask/metamask-extension/blob/main/ui/hooks/gasFeeInput/useTransactionFunctions.js), this hook can consume GasFeeContext. + - Setters and manual update functions are only used by legacy gas component [edit-gas-fee-popover](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/edit-gas-popover). This component uses useGasFeeInputs hook. We need to create a smaller hook just for this component using the above context and hooks. -* [confirm-transaction-base.container.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js) and [confirm-transaction-base.component.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js) has a lot of code to derive values from state and selected transactions. This can be simplified by using hooks that will he created. +* [confirm-transaction-base.container.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction-base/confirm-transaction-base.container.js) and [confirm-transaction-base.component.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js) has a lot of code to derive values from state and selected transactions. This can be simplified by using hooks that will he created. * We will have a lot of hooks for transaction related fields, these can be grouped into same file / folder. As we work on the components we will be able to identify more areas of improvement. diff --git a/docs/confirmation-refactoring/signature-request/README.md b/docs/confirmation-refactoring/signature-request/README.md index a80cc046ca6c..3585ef4a9c4e 100644 --- a/docs/confirmation-refactoring/signature-request/README.md +++ b/docs/confirmation-refactoring/signature-request/README.md @@ -6,35 +6,35 @@ This document details the plan to refactor and cleanup Signature Request pages i 1. Simple ETH Signature - + 1. Personal Signature - + 1. Typed Data - V1 - + 1. Typed Data - V3 - + 1. Typed Data - V4 - + 1. SIWE Signature - + ## The current flow of control for Signature Request looks like: -![Signature Request Flow - Current](https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/docs/confirmation-refactoring/signature-request/signature_request_old.png) +![Signature Request Flow - Current](https://raw.githubusercontent.com/MetaMask/metamask-extension/main/docs/confirmation-refactoring/signature-request/signature_request_old.png) ## The proposed flow of control: -![Signature Request Flow - Proposed](https://raw.githubusercontent.com/MetaMask/metamask-extension/develop/docs/confirmation-refactoring/signature-request/signature_request_proposed.png) +![Signature Request Flow - Proposed](https://raw.githubusercontent.com/MetaMask/metamask-extension/main/docs/confirmation-refactoring/signature-request/signature_request_proposed.png) ## Proposed Refactoring: @@ -44,9 +44,9 @@ There are many areas in above flow where the code can be improved upon to cleanu Currently we have 3 different message managers: - - [MessageManager](https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/lib/message-manager.js) - - [PersonalMessageManager](https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/lib/personal-message-manager.js) - - [TypedMessageManager](https://github.com/MetaMask/metamask-extension/blob/develop/app/scripts/lib/typed-message-manager.js) + - [MessageManager](https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/lib/message-manager.js) + - [PersonalMessageManager](https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/lib/personal-message-manager.js) + - [TypedMessageManager](https://github.com/MetaMask/metamask-extension/blob/main/app/scripts/lib/typed-message-manager.js) Above message managers handle different types of message requests sent by DAPP. There is a lot of code duplication between the 3 classes. @@ -56,14 +56,14 @@ There are many areas in above flow where the code can be improved upon to cleanu Current navigation to Signature Request pages is un-necessarily complicated. It can be simplified to great extent. - - To the navigation code in [Home](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/home/home.component.js#L181) component add condition to check if there are unapproved messages and route to path `/singature-request`. - - In [Routes](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/routes/routes.component.js) component render pages/confirm-signature-request for path `/singature-request`. - - Refactor out [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction/conf-tx.js) into pages/confirm-signature-request component. [#17240](https://github.com/MetaMask/metamask-extension/issues/17240) + - To the navigation code in [Home](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/home/home.component.js#L181) component add condition to check if there are unapproved messages and route to path `/singature-request`. + - In [Routes](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/routes/routes.component.js) component render pages/confirm-signature-request for path `/singature-request`. + - Refactor out [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction/conf-tx.js) into pages/confirm-signature-request component. [#17240](https://github.com/MetaMask/metamask-extension/issues/17240) -3. ### Refactoring in [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction/conf-tx.js) +3. ### Refactoring in [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction/conf-tx.js) - - [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction/conf-tx.js) to be renamed to `pages/confirm-signature-request component` - - Get rid of [confirm-transaction](https://github.com/MetaMask/metamask-extension/blob/develop/ui/pages/confirm-transaction/confirm-transaction.component.js) component from signature request routing. Thus, we need to ensure that any required logic from the component is extracted into a reusable hook and included in pages/confirm-signature-request. + - [conf-tx.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction/conf-tx.js) to be renamed to `pages/confirm-signature-request component` + - Get rid of [confirm-transaction](https://github.com/MetaMask/metamask-extension/blob/main/ui/pages/confirm-transaction/confirm-transaction.component.js) component from signature request routing. Thus, we need to ensure that any required logic from the component is extracted into a reusable hook and included in pages/confirm-signature-request. - Convert to functional react component and use selectors to get state and get rid of `mapStateToProps`. [#17239](https://github.com/MetaMask/metamask-extension/issues/17239) - Various callbacks to `sign message`, `cancel request`, etc for different types of messages can be moved to respective child components. - On component `mount/update` if there are no unapproved messages redirect to `mostRecentlyOverviewedPage` as [here](https://github.com/MetaMask/metamask-extension/blob/76a2a9bb8b6ea04025328d36404ac3b59121dfc8/ui/app/pages/confirm-transaction/conf-tx.js#L187). @@ -74,12 +74,12 @@ There are many areas in above flow where the code can be improved upon to cleanu There are 3 different signature request components responsible to render different signature request pages: - 1. [signature-request-original](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/signature-request-original) - ETH sign, personal sign, sign typed data V1 - 2. [signature-request](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/signature-request) - Sign typed data V3, V4 - 3. [signature-request-siwe](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/signature-request-siwe) - SignatureRequestSIWE (Sign-In with Ethereum) + 1. [signature-request-original](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/signature-request-original) - ETH sign, personal sign, sign typed data V1 + 2. [signature-request](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/signature-request) - Sign typed data V3, V4 + 3. [signature-request-siwe](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/signature-request-siwe) - SignatureRequestSIWE (Sign-In with Ethereum) All, the signature request pages (except SIWE) are very similar, the differing part in these pages is the message section. - And there is a lot of code duplication between components - [signature-request-original](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/signature-request-original) and [signature-request](https://github.com/MetaMask/metamask-extension/tree/develop/ui/components/app/signature-request). + And there is a lot of code duplication between components - [signature-request-original](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/signature-request-original) and [signature-request](https://github.com/MetaMask/metamask-extension/tree/main/ui/components/app/signature-request). 5. ### Refactoring in signature-request-original @@ -89,12 +89,12 @@ There are many areas in above flow where the code can be improved upon to cleanu - Move this [metrics event](https://github.com/MetaMask/metamask-extension/blob/71a0bc8b3ff94478e61294c815770e6bc12a72f5/ui/app/components/app/signature-request-original/signature-request-original.component.js#L50) to pages/confirm-signature-request as it is applicable to all the signature requests types. - Header or we can say upper half of the page of all signature request pages (except SIWE) are very similar, this can be extracted into a reusable component used across both signature-request-original and signature-request: - + - [LedgerInstructions](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/components/app/signature-request-original/signature-request-original.component.js#L312) can also be moved to the header. - Create a reuable footer component and use it across all confirmation pages. [#17237](https://github.com/MetaMask/metamask-extension/issues/17237) - + - Create a reusable component for Cancel All requests for use across signature request pages [Code](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/components/app/signature-request-original/signature-request-original.component.js#L326). - Extract [getNetrowkName](https://github.com/MetaMask/metamask-extension/blob/e07ec9dcf3d3f341f83e6b29a29d30edaf7f5b5b/ui/components/app/signature-request-original/signature-request-original.component.js#L60) into a reusable hook / utility method. diff --git a/docs/publishing.md b/docs/publishing.md index fdf1ab1850a7..5915f1873a88 100644 --- a/docs/publishing.md +++ b/docs/publishing.md @@ -30,9 +30,9 @@ In the case that a new release has sensitive changes that cannot be fully verifi ## Building -While we develop on the main `develop` branch, our production version is maintained on the `master` branch. +While we develop on the `main` branch, our production version is maintained on the `master` branch. -With each pull request, the @MetaMaskBot will comment with a build of that new pull request, so after bumping the version on `develop`, open a pull request against `master`, and once the pull request is reviewed and merged, you can download those builds for publication. +With each pull request, the @MetaMaskBot will comment with a build of that new pull request, so after bumping the version on `main`, open a pull request against `master`, and once the pull request is reviewed and merged, you can download those builds for publication. ## Publishing @@ -45,7 +45,7 @@ With each pull request, the @MetaMaskBot will comment with a build of that new p ## Hotfix Differences -Our `develop` branch is usually not yet fully tested for quality assurance, and so should be treated as if it is in an unstable state. +Our `main` branch is usually not yet fully tested for quality assurance, and so should be treated as if it is in an unstable state. For this reason, when an urgent change is needed in production, its pull request should: @@ -53,4 +53,4 @@ For this reason, when an urgent change is needed in production, its pull request - Use a hotfix tag. - Should be proposed against the `master` branch. -The version and changelog bump should then be made off the `master` branch, and then merged to `develop` to bring the two branches back into sync. Further time can be saved by incorporating the version/changelog bump into the PR against `master`, since we rely on @MetaMaskBot to run tests before merging. +The version and changelog bump should then be made off the `master` branch, and then merged to `main` to bring the two branches back into sync. Further time can be saved by incorporating the version/changelog bump into the PR against `master`, since we rely on @MetaMaskBot to run tests before merging. diff --git a/test/e2e/flask/README.md b/test/e2e/flask/README.md index abb07a11e910..42d0e6a28236 100644 --- a/test/e2e/flask/README.md +++ b/test/e2e/flask/README.md @@ -3,4 +3,4 @@ Add `.spec.js` or `.spec.ts` files to run only in flask here. > [!IMPORTANT] > Ensure to update your files in `FLASK_ONLY_TESTS` in -> [`run-all.js`](https://github.com/MetaMask/metamask-extension/blob/develop/test/e2e/run-all.js) \ No newline at end of file +> [`run-all.js`](https://github.com/MetaMask/metamask-extension/blob/main/test/e2e/run-all.js) diff --git a/test/manual-scenarios/upgrade-testing/upgrade-testing.md b/test/manual-scenarios/upgrade-testing/upgrade-testing.md index df5ca3d1fc50..13880f13694b 100644 --- a/test/manual-scenarios/upgrade-testing/upgrade-testing.md +++ b/test/manual-scenarios/upgrade-testing/upgrade-testing.md @@ -8,7 +8,7 @@ To ensure MetaMask extension's upgrade process is seamless and retains user data ### Pre-Upgrade Actions on Master Branch -- **Given** the user checks out the master branch, runs `yarn` and `yarn start` to build locally, and has loaded the MetaMask extension. For instructions on how to load extension on Chrome and Firefox, check the guidelines [here for Chrome](https://github.com/MetaMask/metamask-extension/blob/develop/docs/add-to-chrome.md) and [here for Firefox](https://github.com/MetaMask/metamask-extension/blob/develop/docs/add-to-firefox.md). +- **Given** the user checks out the master branch, runs `yarn` and `yarn start` to build locally, and has loaded the MetaMask extension. For instructions on how to load extension on Chrome and Firefox, check the guidelines [here for Chrome](https://github.com/MetaMask/metamask-extension/blob/main/docs/add-to-chrome.md) and [here for Firefox](https://github.com/MetaMask/metamask-extension/blob/main/docs/add-to-firefox.md). - **And** the user has successfully onboarded. - **And** the user creates two accounts. - **And** the user sends a transaction between these accounts. diff --git a/ui/components/ui/box/README.mdx b/ui/components/ui/box/README.mdx index a70ac7e291fb..08d308db11d5 100644 --- a/ui/components/ui/box/README.mdx +++ b/ui/components/ui/box/README.mdx @@ -49,21 +49,21 @@ Box is a utility component that can be used for layout or as a base for other UI | paddingInline | 0, 1, 2, 4, 6, 8, 9, 10, 12 or array of numbers [1, 2] for responsive props | - | | paddingInlineStart | 0, 1, 2, 4, 6, 8, 9, 10, 12 or array of numbers [1, 2] for responsive props | - | | paddingInlineEnd | 0, 1, 2, 4, 6, 8, 9, 10, 12 or array of numbers [1, 2] for responsive props | - | -| display | Display values or array of Display values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| flexDirection | FlexDirection values or array of FlexDirection values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | FlexDirection.Row | -| flexWrap | FlexWrap values or array of FlexWrap values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| alignItems | AlignItems values or array of AlignItems values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| justifyContent | JustifyContent values or array of JustifyContent values from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | +| display | Display values or array of Display values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| flexDirection | FlexDirection values or array of FlexDirection values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | FlexDirection.Row | +| flexWrap | FlexWrap values or array of FlexWrap values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| alignItems | AlignItems values or array of AlignItems values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| justifyContent | JustifyContent values or array of JustifyContent values from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | | gap | 0, 1, 2, 4, 6, 8, 9, 10, 12 or array of numbers [1, 2] for responsive props | - | -| textAlign | TextAlign values or array of TextAlign values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| width | BlockSize values or array of BlockSize values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| height | BlockSize values or array of BlockSize values for responsive props [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| color | Color values or array of Color values for responsive props [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| backgroundColor | BackgroundColor values or array of BackgroundColor values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| borderColor | BorderColor values or array of BorderColor values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | +| textAlign | TextAlign values or array of TextAlign values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| width | BlockSize values or array of BlockSize values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| height | BlockSize values or array of BlockSize values for responsive props [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| color | Color values or array of Color values for responsive props [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| backgroundColor | BackgroundColor values or array of BackgroundColor values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| borderColor | BorderColor values or array of BorderColor values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | | borderWidth | 0, 1, 2, 4, 6, 8, 9, 10, 12 or array of numbers [1, 2] for responsive props | - | -| borderRadius | BorderRadius values or array of BorderRadius values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | -| borderStyle | BORDER_STYLE values or array of BORDER_STYLE values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/develop/ui/helpers/constants/design-system.js) | - | +| borderRadius | BorderRadius values or array of BorderRadius values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | +| borderStyle | BORDER_STYLE values or array of BORDER_STYLE values for responsive props from [../ui/helpers/constants/design-system.js](https://github.com/MetaMask/metamask-extension/blob/main/ui/helpers/constants/design-system.js) | - | | as | The polymorphic `as` prop allows you to change the root HTML element of the Box component. Defaults to 'div' | 'div' | ## Usage diff --git a/ui/hooks/useTransactionInsights.js b/ui/hooks/useTransactionInsights.js index 997f74061194..13829f17f42e 100644 --- a/ui/hooks/useTransactionInsights.js +++ b/ui/hooks/useTransactionInsights.js @@ -22,7 +22,7 @@ const isAllowedTransactionTypes = (transactionType) => transactionType === TransactionType.tokenMethodTransfer; // A hook was needed to return JSX here as the way Tabs work JSX has to be included in -// https://github.com/MetaMask/metamask-extension/blob/develop/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js#L129 +// https://github.com/MetaMask/metamask-extension/blob/main/ui/components/app/confirm-page-container/confirm-page-container-content/confirm-page-container-content.component.js#L129 // Thus it is not possible to use React Component here const useTransactionInsights = ({ txData }) => { const dispatch = useDispatch(); From e3eab5cade2925f919655bde5499d3fe13e21f47 Mon Sep 17 00:00:00 2001 From: OGPoyraz Date: Mon, 2 Dec 2024 15:24:55 +0100 Subject: [PATCH 008/175] fix: Replace `AvatarAccount` with `Identicon` (#28645) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR fixes icon issue on confirmations mentioned on https://github.com/MetaMask/metamask-extension/issues/28609 [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28645?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28609 ## **Manual testing steps** 1. Go to settings - select Blockies icons 2. Trigger a signature or contract interaction 3. See the addresses there are displayed in Blockies 4. Go to settings - select JazzIcons 5. Trigger a signature or contract interaction 6. See the addresses there are displayed in JazzIcons ## **Screenshots/Recordings** ### **Before** ![before](https://github.com/user-attachments/assets/41727b32-f7c6-411c-9bf4-45b041a059fd) ### **After** ![after](https://github.com/user-attachments/assets/9774f4ec-92ab-4481-81bd-5a70c0f3a90b) ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- .../row/__snapshots__/address.test.tsx.snap | 66 +++------ .../app/confirm/info/row/address.tsx | 15 +- .../components/confirm/header/header-info.tsx | 17 +-- .../info/__snapshots__/info.test.tsx.snap | 65 +++++---- .../__snapshots__/approve.test.tsx.snap | 20 +-- .../base-transaction-info.test.tsx.snap | 10 +- .../native-transfer.test.tsx.snap | 5 +- .../nft-token-transfer.test.tsx.snap | 5 +- .../__snapshots__/personal-sign.test.tsx.snap | 10 +- .../set-approval-for-all-info.test.tsx.snap | 5 +- .../transaction-data.test.tsx.snap | 75 ++++++---- .../transaction-details.test.tsx.snap | 10 +- .../token-details-section.test.tsx.snap | 5 +- .../token-transfer.test.tsx.snap | 5 +- .../transaction-flow-section.test.tsx.snap | 10 +- .../__snapshots__/typed-sign-v1.test.tsx.snap | 5 +- .../__snapshots__/typed-sign.test.tsx.snap | 130 +++++++++++------- .../row/__snapshots__/dataTree.test.tsx.snap | 25 ++-- .../__snapshots__/typedSignData.test.tsx.snap | 30 ++-- .../__snapshots__/confirm.test.tsx.snap | 120 +++++++++------- 20 files changed, 344 insertions(+), 289 deletions(-) diff --git a/ui/components/app/confirm/info/row/__snapshots__/address.test.tsx.snap b/ui/components/app/confirm/info/row/__snapshots__/address.test.tsx.snap index ec2eacb0d44b..87a709c0d80e 100644 --- a/ui/components/app/confirm/info/row/__snapshots__/address.test.tsx.snap +++ b/ui/components/app/confirm/info/row/__snapshots__/address.test.tsx.snap @@ -9,10 +9,11 @@ exports[`ConfirmInfoRowAddress renders appropriately with PetNames disabled with class="mm-box mm-box--display-flex mm-box--flex-direction-row mm-box--align-items-center" >