Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/controller-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Add 4 networks to supported Infura networks list ([#7875](https://github.com/MetaMask/core/pull/7875))
- Add `avalanche-mainnet` to `InfuraNetworkType`, `NetworksTicker`, `BlockExplorerUrl` and `NetworkNickname`.
- Add `monad-mainnet` to `InfuraNetworkType`, `NetworksTicker`, `BlockExplorerUrl` and `NetworkNickname`.
- Add `hyperevm-mainnet` to `InfuraNetworkType`, `NetworksTicker`, `BlockExplorerUrl` and `NetworkNickname`.
- Add `megaeth-mainnet` to `InfuraNetworkType`, `NetworksTicker`, `BlockExplorerUrl` and `NetworkNickname`.

## [11.18.0]

### Changed
Expand Down
26 changes: 26 additions & 0 deletions packages/controller-utils/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export const InfuraNetworkType = {
'bsc-mainnet': 'bsc-mainnet',
'optimism-mainnet': 'optimism-mainnet',
'polygon-mainnet': 'polygon-mainnet',
'avalanche-mainnet': 'avalanche-mainnet',
'sei-mainnet': 'sei-mainnet',
'monad-mainnet': 'monad-mainnet',
'hyperevm-mainnet': 'hyperevm-mainnet',
'megaeth-mainnet': 'megaeth-mainnet',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New Infura networks missing from BUILT_IN_NETWORKS constant

Medium Severity

The four new Infura networks (avalanche-mainnet, monad-mainnet, hyperevm-mainnet, megaeth-mainnet) are added to InfuraNetworkType, BuiltInNetworkName, ChainId, NetworksTicker, BlockExplorerUrl, and NetworkNickname, but are not added to the BUILT_IN_NETWORKS constant in constants.ts. Every previous network addition also updated BUILT_IN_NETWORKS. This exported object is used by consumers and test helpers (e.g., BUILT_IN_NETWORKS[infuraNetwork].chainId) to look up network metadata — accessing the new networks there will return undefined and cause runtime errors.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will need to investigate more. Original idea was just to add networks into InfuraNetworkType but then other objects depended on it. I don't want to risk a regression and so I'll have to audit it

} as const;

export type InfuraNetworkType =
Expand Down Expand Up @@ -98,6 +102,10 @@ export enum BuiltInNetworkName {
OptimismMainnet = 'optimism-mainnet',
PolygonMainnet = 'polygon-mainnet',
SeiMainnet = 'sei-mainnet',
AvalancheMainnet = 'avalanche-mainnet',
MonadMainnet = 'monad-mainnet',
HyperevmMainnet = 'hyperevm-mainnet',
MegaETHMainnet = 'megaeth-mainnet',
}

/**
Expand Down Expand Up @@ -125,6 +133,10 @@ export const ChainId = {
[BuiltInNetworkName.OptimismMainnet]: '0xa', // toHex(10)
[BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)
[BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)
[BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)
[BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)
[BuiltInNetworkName.HyperevmMainnet]: '0x3e7', // toHex(999)
[BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)
} as const;
export type ChainId = (typeof ChainId)[keyof typeof ChainId];

Expand Down Expand Up @@ -154,6 +166,12 @@ export enum NetworksTicker {
'optimism-mainnet' = 'ETH',
'polygon-mainnet' = 'POL',
'sei-mainnet' = 'SEI',
'avalanche-mainnet' = 'AVAX',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
'monad-mainnet' = 'MON',
'hyperevm-mainnet' = 'HYPE',
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
'megaeth-mainnet' = 'ETH',
rpc = '',
}
/* eslint-enable @typescript-eslint/naming-convention */
Expand All @@ -178,6 +196,10 @@ export const BlockExplorerUrl = {
[BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',
[BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',
[BuiltInNetworkName.SeiMainnet]: 'https://seitrace.com',
[BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',
[BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',
[BuiltInNetworkName.HyperevmMainnet]: 'https://hyperevmscan.io',
[BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',
} as const satisfies Record<BuiltInNetworkType, string>;
export type BlockExplorerUrl =
(typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
Expand All @@ -201,6 +223,10 @@ export const NetworkNickname = {
[BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',
[BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',
[BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',
[BuiltInNetworkName.AvalancheMainnet]: 'Avalanche',
[BuiltInNetworkName.MonadMainnet]: 'Monad',
[BuiltInNetworkName.HyperevmMainnet]: 'HyperEVM',
[BuiltInNetworkName.MegaETHMainnet]: 'MegaETH',
} as const satisfies Record<BuiltInNetworkType, string>;
export type NetworkNickname =
(typeof NetworkNickname)[keyof typeof NetworkNickname];
Expand Down
Loading