-
-
Notifications
You must be signed in to change notification settings - Fork 252
feat: add infura supported networks #6972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
||
| ### Added | ||
|
|
||
| - Arbitrum, BSC, Optimism, Polygon, and Sei networks to Infura networks ([#6972](https://github.com/MetaMask/core/pull/6972)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mark this as a breaking change?
Technically this is an addition, however I remember adding base-mainnet as a default network caused cascading changes on other controllers/clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that these changes look innocuous. Also these changes make it so that these can be used as default networks but don't change the set of default networks themselves. I would expect that we would do that by changing network-controller. Do we anticipate also doing that in a separate PR?
That said, if have concerns, perhaps we could confirm by publishing a preview build and updating the clients as a preemptive measure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcmire this has been tested on the client side already , a PR for it has been merged MetaMask/metamask-extension#37172 using a patch , it was test by QA and all works as expected
let me know if this answer your concerns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we applied a patch since core releases was blocked, and we needed this change to be included in the current release cut.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh perfect, okay, no problem then!
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** The goal of this PR is to add popular networks by default for both new and existing users, but only those supported by the accounts API v4. core PR: MetaMask/core#6972 This implementation adds 6 popular networks (Arbitrum, BSC, Optimism, Polygon, Sei, and Base) to MetaMask by default, making them immediately available to users without requiring manual addition. The feature works for both new users during onboarding and existing users through a migration. Networks are filtered to only include those supported by the accounts API v4. **Key changes:** 1. **For new users**: Added `_addPopularNetworks()` and `_enableDefaultNetwork()` methods to the MetaMask controller that automatically add and enable popular networks after onboarding completion 2. **For existing users**: Created migration `182` that adds supported FEATURED_RPCS networks to existing users' network configurations, filtered by `SUPPORTED_NETWORKS_ACCOUNTS_API_V4` 3. **Network enablement**: Popular networks are automatically enabled based on environment (test vs production) after onboarding 4. **API compatibility**: Only networks supported by accounts API v4 are added to ensure compatibility <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [](https://codespaces.new/MetaMask/metamask-extension/pull/37172?quickstart=1) ## **Changelog** CHANGELOG entry: Added popular networks (Arbitrum, BSC, Optimism, Polygon, Sei, and Base) by default for all users, filtered to only include networks supported by accounts API v4 ## **Related issues** Fixes: ## **Manual testing steps** 1. **For new users:** - Create a fresh MetaMask installation - Complete the onboarding process - Verify that supported popular networks are automatically added and available in the network dropdown - Check that networks are enabled and can be switched to - Verify that unsupported networks (Linea, Avalanche, zkSync Era) are not added 2. **For existing users:** - Open MetaMask with an existing wallet - Verify that supported popular networks are automatically added after the migration runs - Check that existing custom networks are preserved - Verify that only supported networks appear in the network list - Confirm that unsupported networks are not added 3. **Network functionality:** - Switch to each supported popular network and verify connection - Check that block explorer URLs are correctly configured - Verify that native currency symbols are displayed correctly ## **Screenshots/Recordings** ### **Before** <!-- [screenshots/recordings] --> - Users had to manually add popular networks through the "Add Network" flow - Only Ethereum mainnet was available by default ### **After** <!-- [screenshots/recordings] --> <img width="1142" height="980" alt="Screenshot 2025-10-24 at 11 44 35" src="https://github.com/user-attachments/assets/bf1d90be-ce6e-4b09-9e6b-445d2771098e" /> - Supported popular networks are automatically available in the network dropdown - Users can immediately switch to supported popular networks without manual configuration - Networks are pre-configured with correct RPC endpoints and block explorers - Only networks compatible with accounts API v4 are included ## **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/main/.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/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds Arbitrum, BSC, Optimism, Polygon, and Sei as built‑in/default networks (with failovers) and migrates existing users to include them; updates tests, package patches, and endpoints. > > - **Network defaults & failover**: > - Include `arbitrum-mainnet`, `bsc-mainnet`, `optimism-mainnet`, `polygon-mainnet`, `sei-mainnet` in built‑in networks with `chainId`, `ticker`, and `blockExplorerUrl` in `@metamask/controller-utils` (patched). > - Initialize failover URLs for new Infura networks in `app/scripts/controller-init/network-controller-init.ts`. > - **Migration**: > - Add migration `182` to insert supported FEATURED_RPCS (`0xa4b1`, `0x38`, `0xa`, `0x89`, `0x531`) into `NetworkController.networkConfigurationsByChainId` if missing, preserving existing configs. > - **Tests**: > - Update unit/e2e tests to reflect new default networks, failover expectations, network counts, and selection flows; add helpers (`selectNetworkByChainId`). > - **Build/Config**: > - Patch and pin `@metamask/controller-utils` in `package.json`/`yarn.lock`; register migration in `migrations/index.js`. > - **Privacy/Endpoints**: > - Extend `privacy-snapshot.json` with new Infura endpoints for added networks. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8170ef4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** The goal of this PR is to add popular networks by default for both new and existing users, but only those supported by the accounts API v4. core PR: MetaMask/core#6972 This implementation adds 6 popular networks (Arbitrum, BSC, Optimism, Polygon, Sei, and Base) to MetaMask by default, making them immediately available to users without requiring manual addition. The feature works for both new users during onboarding and existing users through a migration. Networks are filtered to only include those supported by the accounts API v4. **Key changes:** 1. **For new users**: Added `_addPopularNetworks()` and `_enableDefaultNetwork()` methods to the MetaMask controller that automatically add and enable popular networks after onboarding completion 2. **For existing users**: Created migration `182` that adds supported FEATURED_RPCS networks to existing users' network configurations, filtered by `SUPPORTED_NETWORKS_ACCOUNTS_API_V4` 3. **Network enablement**: Popular networks are automatically enabled based on environment (test vs production) after onboarding 4. **API compatibility**: Only networks supported by accounts API v4 are added to ensure compatibility <!-- Write a short description of the changes included in this pull request, also include relevant motivation and context. Have in mind the following questions: 1. What is the reason for the change? 2. What is the improvement/solution? --> [](https://codespaces.new/MetaMask/metamask-extension/pull/37172?quickstart=1) ## **Changelog** CHANGELOG entry: Added popular networks (Arbitrum, BSC, Optimism, Polygon, Sei, and Base) by default for all users, filtered to only include networks supported by accounts API v4 ## **Related issues** Fixes: ## **Manual testing steps** 1. **For new users:** - Create a fresh MetaMask installation - Complete the onboarding process - Verify that supported popular networks are automatically added and available in the network dropdown - Check that networks are enabled and can be switched to - Verify that unsupported networks (Linea, Avalanche, zkSync Era) are not added 2. **For existing users:** - Open MetaMask with an existing wallet - Verify that supported popular networks are automatically added after the migration runs - Check that existing custom networks are preserved - Verify that only supported networks appear in the network list - Confirm that unsupported networks are not added 3. **Network functionality:** - Switch to each supported popular network and verify connection - Check that block explorer URLs are correctly configured - Verify that native currency symbols are displayed correctly ## **Screenshots/Recordings** ### **Before** <!-- [screenshots/recordings] --> - Users had to manually add popular networks through the "Add Network" flow - Only Ethereum mainnet was available by default ### **After** <!-- [screenshots/recordings] --> <img width="1142" height="980" alt="Screenshot 2025-10-24 at 11 44 35" src="https://github.com/user-attachments/assets/bf1d90be-ce6e-4b09-9e6b-445d2771098e" /> - Supported popular networks are automatically available in the network dropdown - Users can immediately switch to supported popular networks without manual configuration - Networks are pre-configured with correct RPC endpoints and block explorers - Only networks compatible with accounts API v4 are included ## **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/main/.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/main/.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. <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds Arbitrum, BSC, Optimism, Polygon, and Sei as built‑in/default networks (with failovers) and migrates existing users to include them; updates tests, package patches, and endpoints. > > - **Network defaults & failover**: > - Include `arbitrum-mainnet`, `bsc-mainnet`, `optimism-mainnet`, `polygon-mainnet`, `sei-mainnet` in built‑in networks with `chainId`, `ticker`, and `blockExplorerUrl` in `@metamask/controller-utils` (patched). > - Initialize failover URLs for new Infura networks in `app/scripts/controller-init/network-controller-init.ts`. > - **Migration**: > - Add migration `182` to insert supported FEATURED_RPCS (`0xa4b1`, `0x38`, `0xa`, `0x89`, `0x531`) into `NetworkController.networkConfigurationsByChainId` if missing, preserving existing configs. > - **Tests**: > - Update unit/e2e tests to reflect new default networks, failover expectations, network counts, and selection flows; add helpers (`selectNetworkByChainId`). > - **Build/Config**: > - Patch and pin `@metamask/controller-utils` in `package.json`/`yarn.lock`; register migration in `migrations/index.js`. > - **Privacy/Endpoints**: > - Extend `privacy-snapshot.json` with new Infura endpoints for added networks. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8170ef4. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
| 'monad-testnet' = 'MON', | ||
| // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values | ||
| 'base-mainnet' = 'ETH', | ||
| // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, this rule is not very useful, is it. I will look into disabling this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 on this , i don't think it's really useful actually
|
|
||
| ### Added | ||
|
|
||
| - Arbitrum, BSC, Optimism, Polygon, and Sei networks to Infura networks ([#6972](https://github.com/MetaMask/core/pull/6972)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that these changes look innocuous. Also these changes make it so that these can be used as default networks but don't change the set of default networks themselves. I would expect that we would do that by changing network-controller. Do we anticipate also doing that in a separate PR?
That said, if have concerns, perhaps we could confirm by publishing a preview build and updating the clients as a preemptive measure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Explanation
This PR adds support for five additional networks to MetaMask Core's Infura network types: Arbitrum, BSC (Binance Smart Chain), Optimism, Polygon, and Sei. These networks are now available as built-in Infura networks across the MetaMask ecosystem.
Changes Made:
Core Network Definitions (
@metamask/controller-utils):InfuraNetworkTypeandBUILT_IN_NETWORKSBuiltInNetworkNameenum with new entriesToken Detection Support (
@metamask/assets-controllers):TokenDetectionControllerto support token tracking on these networksNetwork Controller (
@metamask/network-controller):Network Enablement (
@metamask/network-enablement-controller):enableAllPopularNetworks()Impact:
This change expands MetaMask's multi-chain capabilities by making these popular L1 and L2 networks available as built-in options, improving the user experience for accessing DeFi and Web3 applications across these ecosystems.
References
Related to the initiative to expand MetaMask's multi-chain support and provide better out-of-the-box network coverage for users.
Checklist
Note
Add Arbitrum, BSC, Optimism, Polygon, and Sei as built-in Infura networks and update related constants, configs, and tests across packages.
BUILT_IN_NETWORKS,InfuraNetworkType,BuiltInNetworkName,ChainId,NetworksTicker,BlockExplorerUrl, andNetworkNicknamewith Arbitrum, BSC, Optimism, Polygon, and Sei (chain IDs:0xa4b1,0x38,0xa,0x89,0x531).CHANGELOG.mddocumenting the additions.TokenDetectionControllertests to include the new networks in the token detection chain ID set.Written by Cursor Bugbot for commit fea7391. This will update automatically on new commits. Configure here.