Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/network-enablement-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Remove Sei Mainnet (`0x531`) from the default-enabled EVM network map, fixing a crash in consumers that call `findNetworkClientIdByChainId` for chains with no built-in `NetworkController` client ([#9542](https://github.com/MetaMask/core/pull/9542))

## [5.6.0]

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -255,7 +254,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
'0xa86a': true, // Avalanche network added and enabled (keeps current selection)
},
Expand Down Expand Up @@ -324,7 +322,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -433,7 +430,6 @@ describe('NetworkEnablementController', () => {
controller.disableNetwork('0x38'); // BSC Mainnet
controller.disableNetwork('0xa'); // Optimism Mainnet
controller.disableNetwork('0x89'); // Polygon Mainnet
controller.disableNetwork('0x531'); // Sei Mainnet
controller.disableNetwork('0x8f'); // Monad Mainnet

// Publish an update with linea network removed
Expand Down Expand Up @@ -471,7 +467,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -576,7 +571,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1227,7 +1221,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1266,7 +1259,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false, // Not in mocked config
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false, // Not in mocked config
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false, // Not in mocked config
[ChainId[BuiltInNetworkName.SeiMainnet]]: false, // Not in mocked config
[ChainId[BuiltInNetworkName.MonadMainnet]]: false, // Not in mocked config
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1538,7 +1530,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1577,7 +1568,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1636,7 +1626,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1679,7 +1668,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1722,7 +1710,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1776,7 +1763,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1827,7 +1813,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1881,7 +1866,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: false,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: false,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: false,
[ChainId[BuiltInNetworkName.SeiMainnet]]: false,
[ChainId[BuiltInNetworkName.MonadMainnet]]: false,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1932,7 +1916,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down Expand Up @@ -1985,7 +1968,6 @@ describe('NetworkEnablementController', () => {
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ export type NetworkConfig = {
const getDefaultNetworkEnablementControllerState =
(): NetworkEnablementControllerState => ({
enabledNetworkMap: {
// Each chain ID here must have a built-in client in NetworkController

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I feel like it shouldn't be on the maintainers of this controller to manually keep the list of enableable networks up to date with NetworkController. Also, at some point in the future we are going to remove the concept of default / built-in networks from NetworkController — since built-in networks will come from ConfigRegistryController — so this comment will fall out of date when that happens. Plus, we're not calling findNetworkClientIdByChainId here, we're calling that in the clients, so the knowledge that we are referring to is somewhere else, and a maintainer would have to know where to look.

Removing Sei is fine here, but I wonder if we could also add an init method that reads NetworkController state and then automatically removes enabled networks that aren't listed. What do you think about that solution?

// (see DEFAULT_INFURA_NETWORKS). A missing client causes
// findNetworkClientIdByChainId to throw silently in consumers.
[KnownCaipNamespace.Eip155]: {
[ChainId[BuiltInNetworkName.Mainnet]]: true,
[ChainId[BuiltInNetworkName.LineaMainnet]]: true,
Expand All @@ -166,7 +169,6 @@ const getDefaultNetworkEnablementControllerState =
[ChainId[BuiltInNetworkName.BscMainnet]]: true,
[ChainId[BuiltInNetworkName.OptimismMainnet]]: true,
[ChainId[BuiltInNetworkName.PolygonMainnet]]: true,
[ChainId[BuiltInNetworkName.SeiMainnet]]: true,
[ChainId[BuiltInNetworkName.MonadMainnet]]: true,
},
[KnownCaipNamespace.Solana]: {
Expand Down