Skip to content

Commit a4afaa1

Browse files
authored
chore: add missing Infura networks (MetaMask#8680)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Adding networks to `controller-utils` that are included in the dynamic registry but were missing from the package Infura networks list. This addition is necessary to get passed the validation checks in `NetworkController` when adding these networks from the dynamic registry (https://client-config.api.cx.metamask.io/v1/config/networks). ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Moderate risk because it expands the set of built-in Infura networks (chain IDs, tickers, explorer URLs, nicknames), which can affect network validation and default network configuration behavior for consumers. > > **Overview** > Adds missing Infura-supported mainnet networks to `controller-utils` by extending `InfuraNetworkType` and related constants (`BuiltInNetworkName`, `ChainId`, `NetworksTicker`, `BlockExplorerUrl`, `NetworkNickname`) for `megaeth-mainnet`, `monad-mainnet`, `avalanche-mainnet`, and `zksync-mainnet`. > > Updates `NetworkController` test snapshots/expectations so these networks are included in default state/config and corresponding Infura network clients, and records the change in the `controller-utils` changelog. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit bd05e8d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 8f9effb commit a4afaa1

3 files changed

Lines changed: 386 additions & 0 deletions

File tree

packages/controller-utils/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1414
- The event still emits a `FailureReason` when retries are exhausted.
1515
- Update `normalizeEnsName` regex to allow ENS names with 3 or more characters (previously required 7 or more) ([#8510](https://github.com/MetaMask/core/pull/8510))
1616
- Update default Sei Mainnet block explorer URL from `seitrace.com` to `seiscan.io` ([#8545](https://github.com/MetaMask/core/pull/8545))
17+
- Update `InfuraNetworkType`, `ChainId`, `NetworksTicker`, `BlockExplorerUrl`, and `NetworkNickname` to include missing Infura networks ([#8680](https://github.com/MetaMask/core/pull/8680))
1718

1819
## [11.20.0]
1920

packages/controller-utils/src/types.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export const InfuraNetworkType = {
1414
'optimism-mainnet': 'optimism-mainnet',
1515
'polygon-mainnet': 'polygon-mainnet',
1616
'sei-mainnet': 'sei-mainnet',
17+
'monad-mainnet': 'monad-mainnet',
18+
'megaeth-mainnet': 'megaeth-mainnet',
19+
'avalanche-mainnet': 'avalanche-mainnet',
20+
'zksync-mainnet': 'zksync-mainnet',
1721
} as const;
1822

1923
export type InfuraNetworkType =
@@ -99,6 +103,9 @@ export enum BuiltInNetworkName {
99103
PolygonMainnet = 'polygon-mainnet',
100104
SeiMainnet = 'sei-mainnet',
101105
MegaETHMainnet = 'megaeth-mainnet',
106+
MonadMainnet = 'monad-mainnet',
107+
AvalancheMainnet = 'avalanche-mainnet',
108+
ZksyncMainnet = 'zksync-mainnet',
102109
}
103110

104111
/**
@@ -127,6 +134,9 @@ export const ChainId = {
127134
[BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)
128135
[BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)
129136
[BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)
137+
[BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)
138+
[BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)
139+
[BuiltInNetworkName.ZksyncMainnet]: '0x144', // toHex(324)
130140
} as const;
131141
export type ChainId = (typeof ChainId)[keyof typeof ChainId];
132142

@@ -156,6 +166,13 @@ export enum NetworksTicker {
156166
'optimism-mainnet' = 'ETH',
157167
'polygon-mainnet' = 'POL',
158168
'sei-mainnet' = 'SEI',
169+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
170+
'megaeth-mainnet' = 'ETH',
171+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
172+
'monad-mainnet' = 'MON',
173+
'avalanche-mainnet' = 'AVAX',
174+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
175+
'zksync-mainnet' = 'ETH',
159176
rpc = '',
160177
}
161178
/* eslint-enable @typescript-eslint/naming-convention */
@@ -180,6 +197,10 @@ export const BlockExplorerUrl = {
180197
[BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',
181198
[BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',
182199
[BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',
200+
[BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',
201+
[BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',
202+
[BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',
203+
[BuiltInNetworkName.ZksyncMainnet]: 'https://explorer.zksync.io',
183204
} as const satisfies Record<BuiltInNetworkType, string>;
184205
export type BlockExplorerUrl =
185206
(typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
@@ -203,6 +224,10 @@ export const NetworkNickname = {
203224
[BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',
204225
[BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',
205226
[BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',
227+
[BuiltInNetworkName.MegaETHMainnet]: 'MegaETH Mainnet',
228+
[BuiltInNetworkName.MonadMainnet]: 'Monad Mainnet',
229+
[BuiltInNetworkName.AvalancheMainnet]: 'Avalanche Mainnet',
230+
[BuiltInNetworkName.ZksyncMainnet]: 'ZKsync Era',
206231
} as const satisfies Record<BuiltInNetworkType, string>;
207232
export type NetworkNickname =
208233
(typeof NetworkNickname)[keyof typeof NetworkNickname];

0 commit comments

Comments
 (0)