@metamask-previews/network-enablement-controller 5.6.0-preview-ec4680201 → 5.6.0-preview-40d5fb1e2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +0 -6
- package/dist/NetworkEnablementController-method-action-types.cjs.map +1 -1
- package/dist/NetworkEnablementController-method-action-types.d.cts +2 -2
- package/dist/NetworkEnablementController-method-action-types.d.cts.map +1 -1
- package/dist/NetworkEnablementController-method-action-types.d.mts +2 -2
- package/dist/NetworkEnablementController-method-action-types.d.mts.map +1 -1
- package/dist/NetworkEnablementController-method-action-types.mjs.map +1 -1
- package/dist/NetworkEnablementController.cjs +30 -50
- package/dist/NetworkEnablementController.cjs.map +1 -1
- package/dist/NetworkEnablementController.d.cts +3 -4
- package/dist/NetworkEnablementController.d.cts.map +1 -1
- package/dist/NetworkEnablementController.d.mts +3 -4
- package/dist/NetworkEnablementController.d.mts.map +1 -1
- package/dist/NetworkEnablementController.mjs +10 -30
- package/dist/NetworkEnablementController.mjs.map +1 -1
- package/dist/index.cjs +14 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/selectors.cjs +2 -2
- package/dist/selectors.cjs.map +1 -1
- package/dist/selectors.d.cts.map +1 -1
- package/dist/selectors.d.mts.map +1 -1
- package/dist/selectors.mjs.map +1 -1
- package/dist/services/index.cjs +4 -4
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts.map +1 -1
- package/dist/services/index.d.mts.map +1 -1
- package/dist/services/index.mjs.map +1 -1
- package/dist/utils.cjs +19 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +7 -0
- package/dist/utils.d.cts.map +1 -1
- package/dist/utils.d.mts +7 -0
- package/dist/utils.d.mts.map +1 -1
- package/dist/utils.mjs +17 -0
- package/dist/utils.mjs.map +1 -1
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -7,12 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
### Changed
|
|
11
|
-
|
|
12
|
-
- **BREAKING:** Popular-network classification is now augmented by `ConfigRegistryController` ([#9611](https://github.com/MetaMask/core/pull/9611))
|
|
13
|
-
- `NetworkEnablementControllerMessenger` now requires the `ConfigRegistryController:getState` action to be available.
|
|
14
|
-
- Bump `@metamask/transaction-controller` from `^69.0.0` to `^69.2.1` ([#9568](https://github.com/MetaMask/core/pull/9568), [#9589](https://github.com/MetaMask/core/pull/9589), [#9593](https://github.com/MetaMask/core/pull/9593))
|
|
15
|
-
|
|
16
10
|
## [5.6.0]
|
|
17
11
|
|
|
18
12
|
### Added
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.cjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController
|
|
1
|
+
{"version":3,"file":"NetworkEnablementController-method-action-types.cjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController';\n\n/**\n * Enables or disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally. This dual parameter support allows for backward\n * compatibility with existing EVM chain ID formats while supporting newer\n * multi-chain standards.\n *\n * When enabling a non-popular network, this method will disable all other networks\n * to ensure only one network is active at a time (exclusive mode).\n *\n * @param chainId - The chain ID of the network to enable or disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerEnableNetworkAction = {\n type: `NetworkEnablementController:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\n/**\n * Enables a network for the user within a specific namespace.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network) and enables it within the specified namespace.\n * The method validates that the chainId belongs to the specified namespace for safety.\n *\n * Before enabling the target network, this method disables all other networks\n * in the same namespace to ensure exclusive behavior within the namespace.\n *\n * @param chainId - The chain ID of the network to enable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @param namespace - The CAIP namespace where the network should be enabled\n * @throws Error if the chainId's derived namespace doesn't match the provided namespace\n */\nexport type NetworkEnablementControllerEnableNetworkInNamespaceAction = {\n type: `NetworkEnablementController:enableNetworkInNamespace`;\n handler: NetworkEnablementController['enableNetworkInNamespace'];\n};\n\n/**\n * Enables all popular networks and Solana mainnet.\n *\n * This method first disables all networks across all namespaces, then enables\n * all networks defined in POPULAR_NETWORKS (EVM networks), Solana mainnet, and\n * Bitcoin mainnet. This provides exclusive behavior - only popular networks will\n * be enabled after calling this method.\n *\n * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.\n */\nexport type NetworkEnablementControllerEnableAllPopularNetworksAction = {\n type: `NetworkEnablementController:enableAllPopularNetworks`;\n handler: NetworkEnablementController['enableAllPopularNetworks'];\n};\n\n/**\n * Initializes the network enablement state from network controller configurations.\n *\n * This method reads the current network configurations from both NetworkController\n * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.\n * It ensures proper namespace buckets exist for all configured networks and only\n * adds missing networks with a default value of false, preserving existing user settings.\n *\n * This method should be called after the NetworkController and MultichainNetworkController\n * have been initialized and their configurations are available.\n */\nexport type NetworkEnablementControllerInitAction = {\n type: `NetworkEnablementController:init`;\n handler: NetworkEnablementController['init'];\n};\n\n/**\n * Initializes the native asset identifiers from network configurations.\n * This method should be called from the client during controller initialization\n * to populate the nativeAssetIdentifiers state based on actual network configurations.\n *\n * @param networks - Array of network configurations with chainId and nativeCurrency\n * @example\n * ```typescript\n * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)\n * .map(config => ({\n * chainId: toEvmCaipChainId(config.chainId),\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)\n * .map(config => ({\n * chainId: config.chainId,\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport type NetworkEnablementControllerInitNativeAssetIdentifiersAction = {\n type: `NetworkEnablementController:initNativeAssetIdentifiers`;\n handler: NetworkEnablementController['initNativeAssetIdentifiers'];\n};\n\n/**\n * Disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally.\n *\n * Note: This method will prevent disabling the last remaining enabled network\n * to ensure at least one network is always available.\n *\n * @param chainId - The chain ID of the network to disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `NetworkEnablementController:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * Checks if a network is enabled.\n *\n * @param chainId - The chain ID of the network to check. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @returns True if the network is enabled, false otherwise\n */\nexport type NetworkEnablementControllerIsNetworkEnabledAction = {\n type: `NetworkEnablementController:isNetworkEnabled`;\n handler: NetworkEnablementController['isNetworkEnabled'];\n};\n\n/**\n * Returns popular EVM network chain IDs in hex form, restricted to networks\n * that exist in NetworkController (networkConfigurationsByChainId). Source list\n * is POPULAR_NETWORKS.\n *\n * @returns Hex chain IDs for popular EVM networks that are configured.\n */\nexport type NetworkEnablementControllerListPopularEvmNetworksAction = {\n type: `NetworkEnablementController:listPopularEvmNetworks`;\n handler: NetworkEnablementController['listPopularEvmNetworks'];\n};\n\n/**\n * Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in\n * CAIP-2 form, restricted to networks that exist in MultichainNetworkController\n * (multichainNetworkConfigurationsByChainId).\n *\n * @returns CAIP-2 chain IDs for Bitcoin, Solana, Tron, and Stellar mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularMultichainNetworksAction = {\n type: `NetworkEnablementController:listPopularMultichainNetworks`;\n handler: NetworkEnablementController['listPopularMultichainNetworks'];\n};\n\n/**\n * Returns the list of popular network chain IDs in CAIP-2 form, restricted to\n * networks that exist in NetworkController (networkConfigurationsByChainId) and\n * MultichainNetworkController (multichainNetworkConfigurationsByChainId). EVM\n * popular networks come from POPULAR_NETWORKS; multichain popular are Bitcoin,\n * Solana, Tron, and Stellar mainnets.\n *\n * @returns CAIP-2 chain IDs for popular EVM networks and multichain mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularNetworksAction = {\n type: `NetworkEnablementController:listPopularNetworks`;\n handler: NetworkEnablementController['listPopularNetworks'];\n};\n\n/**\n * Union of all NetworkEnablementController action types.\n */\nexport type NetworkEnablementControllerMethodActions =\n | NetworkEnablementControllerEnableNetworkAction\n | NetworkEnablementControllerEnableNetworkInNamespaceAction\n | NetworkEnablementControllerEnableAllPopularNetworksAction\n | NetworkEnablementControllerInitAction\n | NetworkEnablementControllerInitNativeAssetIdentifiersAction\n | NetworkEnablementControllerDisableNetworkAction\n | NetworkEnablementControllerIsNetworkEnabledAction\n | NetworkEnablementControllerListPopularEvmNetworksAction\n | NetworkEnablementControllerListPopularMultichainNetworksAction\n | NetworkEnablementControllerListPopularNetworksAction;\n"]}
|
|
@@ -131,8 +131,8 @@ export type NetworkEnablementControllerIsNetworkEnabledAction = {
|
|
|
131
131
|
};
|
|
132
132
|
/**
|
|
133
133
|
* Returns popular EVM network chain IDs in hex form, restricted to networks
|
|
134
|
-
* that exist in NetworkController (networkConfigurationsByChainId). Source
|
|
135
|
-
*
|
|
134
|
+
* that exist in NetworkController (networkConfigurationsByChainId). Source list
|
|
135
|
+
* is POPULAR_NETWORKS.
|
|
136
136
|
*
|
|
137
137
|
* @returns Hex chain IDs for popular EVM networks that are configured.
|
|
138
138
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"NetworkEnablementController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,0CAAsC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;CAC7D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,8CAA8C,GAC9C,yDAAyD,GACzD,yDAAyD,GACzD,qCAAqC,GACrC,2DAA2D,GAC3D,+CAA+C,GAC/C,iDAAiD,GACjD,uDAAuD,GACvD,8DAA8D,GAC9D,oDAAoD,CAAC"}
|
|
@@ -131,8 +131,8 @@ export type NetworkEnablementControllerIsNetworkEnabledAction = {
|
|
|
131
131
|
};
|
|
132
132
|
/**
|
|
133
133
|
* Returns popular EVM network chain IDs in hex form, restricted to networks
|
|
134
|
-
* that exist in NetworkController (networkConfigurationsByChainId). Source
|
|
135
|
-
*
|
|
134
|
+
* that exist in NetworkController (networkConfigurationsByChainId). Source list
|
|
135
|
+
* is POPULAR_NETWORKS.
|
|
136
136
|
*
|
|
137
137
|
* @returns Hex chain IDs for popular EVM networks that are configured.
|
|
138
138
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,
|
|
1
|
+
{"version":3,"file":"NetworkEnablementController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,0CAAsC;AAEjF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;CAC7D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,8CAA8C,GAC9C,yDAAyD,GACzD,yDAAyD,GACzD,qCAAqC,GACrC,2DAA2D,GAC3D,+CAA+C,GAC/C,iDAAiD,GACjD,uDAAuD,GACvD,8DAA8D,GAC9D,oDAAoD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.mjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController
|
|
1
|
+
{"version":3,"file":"NetworkEnablementController-method-action-types.mjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController';\n\n/**\n * Enables or disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally. This dual parameter support allows for backward\n * compatibility with existing EVM chain ID formats while supporting newer\n * multi-chain standards.\n *\n * When enabling a non-popular network, this method will disable all other networks\n * to ensure only one network is active at a time (exclusive mode).\n *\n * @param chainId - The chain ID of the network to enable or disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerEnableNetworkAction = {\n type: `NetworkEnablementController:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\n/**\n * Enables a network for the user within a specific namespace.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network) and enables it within the specified namespace.\n * The method validates that the chainId belongs to the specified namespace for safety.\n *\n * Before enabling the target network, this method disables all other networks\n * in the same namespace to ensure exclusive behavior within the namespace.\n *\n * @param chainId - The chain ID of the network to enable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @param namespace - The CAIP namespace where the network should be enabled\n * @throws Error if the chainId's derived namespace doesn't match the provided namespace\n */\nexport type NetworkEnablementControllerEnableNetworkInNamespaceAction = {\n type: `NetworkEnablementController:enableNetworkInNamespace`;\n handler: NetworkEnablementController['enableNetworkInNamespace'];\n};\n\n/**\n * Enables all popular networks and Solana mainnet.\n *\n * This method first disables all networks across all namespaces, then enables\n * all networks defined in POPULAR_NETWORKS (EVM networks), Solana mainnet, and\n * Bitcoin mainnet. This provides exclusive behavior - only popular networks will\n * be enabled after calling this method.\n *\n * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.\n */\nexport type NetworkEnablementControllerEnableAllPopularNetworksAction = {\n type: `NetworkEnablementController:enableAllPopularNetworks`;\n handler: NetworkEnablementController['enableAllPopularNetworks'];\n};\n\n/**\n * Initializes the network enablement state from network controller configurations.\n *\n * This method reads the current network configurations from both NetworkController\n * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.\n * It ensures proper namespace buckets exist for all configured networks and only\n * adds missing networks with a default value of false, preserving existing user settings.\n *\n * This method should be called after the NetworkController and MultichainNetworkController\n * have been initialized and their configurations are available.\n */\nexport type NetworkEnablementControllerInitAction = {\n type: `NetworkEnablementController:init`;\n handler: NetworkEnablementController['init'];\n};\n\n/**\n * Initializes the native asset identifiers from network configurations.\n * This method should be called from the client during controller initialization\n * to populate the nativeAssetIdentifiers state based on actual network configurations.\n *\n * @param networks - Array of network configurations with chainId and nativeCurrency\n * @example\n * ```typescript\n * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)\n * .map(config => ({\n * chainId: toEvmCaipChainId(config.chainId),\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)\n * .map(config => ({\n * chainId: config.chainId,\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport type NetworkEnablementControllerInitNativeAssetIdentifiersAction = {\n type: `NetworkEnablementController:initNativeAssetIdentifiers`;\n handler: NetworkEnablementController['initNativeAssetIdentifiers'];\n};\n\n/**\n * Disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally.\n *\n * Note: This method will prevent disabling the last remaining enabled network\n * to ensure at least one network is always available.\n *\n * @param chainId - The chain ID of the network to disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `NetworkEnablementController:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * Checks if a network is enabled.\n *\n * @param chainId - The chain ID of the network to check. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @returns True if the network is enabled, false otherwise\n */\nexport type NetworkEnablementControllerIsNetworkEnabledAction = {\n type: `NetworkEnablementController:isNetworkEnabled`;\n handler: NetworkEnablementController['isNetworkEnabled'];\n};\n\n/**\n * Returns popular EVM network chain IDs in hex form, restricted to networks\n * that exist in NetworkController (networkConfigurationsByChainId). Source list\n * is POPULAR_NETWORKS.\n *\n * @returns Hex chain IDs for popular EVM networks that are configured.\n */\nexport type NetworkEnablementControllerListPopularEvmNetworksAction = {\n type: `NetworkEnablementController:listPopularEvmNetworks`;\n handler: NetworkEnablementController['listPopularEvmNetworks'];\n};\n\n/**\n * Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in\n * CAIP-2 form, restricted to networks that exist in MultichainNetworkController\n * (multichainNetworkConfigurationsByChainId).\n *\n * @returns CAIP-2 chain IDs for Bitcoin, Solana, Tron, and Stellar mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularMultichainNetworksAction = {\n type: `NetworkEnablementController:listPopularMultichainNetworks`;\n handler: NetworkEnablementController['listPopularMultichainNetworks'];\n};\n\n/**\n * Returns the list of popular network chain IDs in CAIP-2 form, restricted to\n * networks that exist in NetworkController (networkConfigurationsByChainId) and\n * MultichainNetworkController (multichainNetworkConfigurationsByChainId). EVM\n * popular networks come from POPULAR_NETWORKS; multichain popular are Bitcoin,\n * Solana, Tron, and Stellar mainnets.\n *\n * @returns CAIP-2 chain IDs for popular EVM networks and multichain mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularNetworksAction = {\n type: `NetworkEnablementController:listPopularNetworks`;\n handler: NetworkEnablementController['listPopularNetworks'];\n};\n\n/**\n * Union of all NetworkEnablementController action types.\n */\nexport type NetworkEnablementControllerMethodActions =\n | NetworkEnablementControllerEnableNetworkAction\n | NetworkEnablementControllerEnableNetworkInNamespaceAction\n | NetworkEnablementControllerEnableAllPopularNetworksAction\n | NetworkEnablementControllerInitAction\n | NetworkEnablementControllerInitNativeAssetIdentifiersAction\n | NetworkEnablementControllerDisableNetworkAction\n | NetworkEnablementControllerIsNetworkEnabledAction\n | NetworkEnablementControllerListPopularEvmNetworksAction\n | NetworkEnablementControllerListPopularMultichainNetworksAction\n | NetworkEnablementControllerListPopularNetworksAction;\n"]}
|
|
@@ -4,7 +4,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
4
4
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
5
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
6
|
};
|
|
7
|
-
var _NetworkEnablementController_instances, _NetworkEnablementController_ensureNamespaceBucket, _NetworkEnablementController_isInPopularNetworksMode, _NetworkEnablementController_removeNetworkEntry, _NetworkEnablementController_onAddNetwork
|
|
7
|
+
var _NetworkEnablementController_instances, _NetworkEnablementController_ensureNamespaceBucket, _NetworkEnablementController_isInPopularNetworksMode, _NetworkEnablementController_removeNetworkEntry, _NetworkEnablementController_onAddNetwork;
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.NetworkEnablementController = void 0;
|
|
10
10
|
const base_controller_1 = require("@metamask/base-controller");
|
|
@@ -12,9 +12,9 @@ const controller_utils_1 = require("@metamask/controller-utils");
|
|
|
12
12
|
const keyring_api_1 = require("@metamask/keyring-api");
|
|
13
13
|
const multichain_network_controller_1 = require("@metamask/multichain-network-controller");
|
|
14
14
|
const utils_1 = require("@metamask/utils");
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
15
|
+
const constants_1 = require("./constants.cjs");
|
|
16
|
+
const services_1 = require("./services/index.cjs");
|
|
17
|
+
const utils_2 = require("./utils.cjs");
|
|
18
18
|
const controllerName = 'NetworkEnablementController';
|
|
19
19
|
const MESSENGER_EXPOSED_METHODS = [
|
|
20
20
|
'init',
|
|
@@ -149,7 +149,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
149
149
|
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
150
150
|
*/
|
|
151
151
|
enableNetwork(chainId) {
|
|
152
|
-
const { namespace, storageKey } = (0,
|
|
152
|
+
const { namespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
153
153
|
this.update((state) => {
|
|
154
154
|
// disable all networks in all namespaces first
|
|
155
155
|
Object.keys(state.enabledNetworkMap).forEach((ns) => {
|
|
@@ -183,7 +183,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
183
183
|
* @throws Error if the chainId's derived namespace doesn't match the provided namespace
|
|
184
184
|
*/
|
|
185
185
|
enableNetworkInNamespace(chainId, namespace) {
|
|
186
|
-
const { namespace: derivedNamespace, storageKey } = (0,
|
|
186
|
+
const { namespace: derivedNamespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
187
187
|
// Validate that the derived namespace matches the provided namespace
|
|
188
188
|
if (derivedNamespace !== namespace) {
|
|
189
189
|
throw new Error(`Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`);
|
|
@@ -223,8 +223,8 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
223
223
|
const networkControllerState = this.messenger.call('NetworkController:getState');
|
|
224
224
|
const multichainState = this.messenger.call('MultichainNetworkController:getState');
|
|
225
225
|
// Enable all popular EVM networks that exist in NetworkController configurations
|
|
226
|
-
|
|
227
|
-
const { namespace, storageKey } = (0,
|
|
226
|
+
constants_1.POPULAR_NETWORKS.forEach((chainId) => {
|
|
227
|
+
const { namespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
228
228
|
// Check if network exists in NetworkController configurations
|
|
229
229
|
if (networkControllerState.networkConfigurationsByChainId[chainId]) {
|
|
230
230
|
// Ensure namespace bucket exists
|
|
@@ -234,7 +234,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
234
234
|
}
|
|
235
235
|
});
|
|
236
236
|
// Enable Solana mainnet if it exists in MultichainNetworkController configurations
|
|
237
|
-
const solanaKeys = (0,
|
|
237
|
+
const solanaKeys = (0, utils_2.deriveKeys)(keyring_api_1.SolScope.Mainnet);
|
|
238
238
|
if (multichainState.multichainNetworkConfigurationsByChainId[keyring_api_1.SolScope.Mainnet]) {
|
|
239
239
|
// Ensure namespace bucket exists
|
|
240
240
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, solanaKeys.namespace);
|
|
@@ -243,7 +243,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
243
243
|
true;
|
|
244
244
|
}
|
|
245
245
|
// Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations
|
|
246
|
-
const bitcoinKeys = (0,
|
|
246
|
+
const bitcoinKeys = (0, utils_2.deriveKeys)(keyring_api_1.BtcScope.Mainnet);
|
|
247
247
|
if (multichainState.multichainNetworkConfigurationsByChainId[keyring_api_1.BtcScope.Mainnet]) {
|
|
248
248
|
// Ensure namespace bucket exists
|
|
249
249
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, bitcoinKeys.namespace);
|
|
@@ -252,7 +252,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
252
252
|
true;
|
|
253
253
|
}
|
|
254
254
|
// Enable Tron mainnet if it exists in MultichainNetworkController configurations
|
|
255
|
-
const tronKeys = (0,
|
|
255
|
+
const tronKeys = (0, utils_2.deriveKeys)(keyring_api_1.TrxScope.Mainnet);
|
|
256
256
|
if (multichainState.multichainNetworkConfigurationsByChainId[keyring_api_1.TrxScope.Mainnet]) {
|
|
257
257
|
// Ensure namespace bucket exists
|
|
258
258
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, tronKeys.namespace);
|
|
@@ -260,7 +260,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
260
260
|
state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;
|
|
261
261
|
}
|
|
262
262
|
// Enable Stellar mainnet if it exists in MultichainNetworkController configurations
|
|
263
|
-
const stellarKeys = (0,
|
|
263
|
+
const stellarKeys = (0, utils_2.deriveKeys)(keyring_api_1.XlmScope.Pubnet);
|
|
264
264
|
if (multichainState.multichainNetworkConfigurationsByChainId[keyring_api_1.XlmScope.Pubnet]) {
|
|
265
265
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, stellarKeys.namespace);
|
|
266
266
|
state.enabledNetworkMap[stellarKeys.namespace][stellarKeys.storageKey] =
|
|
@@ -287,7 +287,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
287
287
|
// Build nativeAssetIdentifiers for EVM networks using chainid.network
|
|
288
288
|
const evmNativeAssetUpdates = [];
|
|
289
289
|
for (const [chainId] of Object.entries(networkControllerState.networkConfigurationsByChainId)) {
|
|
290
|
-
const { caipChainId } = (0,
|
|
290
|
+
const { caipChainId } = (0, utils_2.deriveKeys)(chainId);
|
|
291
291
|
// Skip if already in state
|
|
292
292
|
if (this.state.nativeAssetIdentifiers[caipChainId] !== undefined) {
|
|
293
293
|
continue;
|
|
@@ -295,7 +295,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
295
295
|
// Parse hex chainId to number for chainid.network lookup
|
|
296
296
|
const numericChainId = parseInt(chainId, 16);
|
|
297
297
|
// EVM networks: use getEvmSlip44 (chainid.network data)
|
|
298
|
-
const slip44CoinType = await
|
|
298
|
+
const slip44CoinType = await services_1.Slip44Service.getEvmSlip44(numericChainId);
|
|
299
299
|
evmNativeAssetUpdates.push({
|
|
300
300
|
caipChainId,
|
|
301
301
|
identifier: buildNativeAssetIdentifier(caipChainId, slip44CoinType),
|
|
@@ -306,7 +306,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
306
306
|
// Initialize namespace buckets for EVM networks from NetworkController
|
|
307
307
|
Object.entries(networkControllerState.networkConfigurationsByChainId).forEach(([chainId]) => {
|
|
308
308
|
var _a;
|
|
309
|
-
const { namespace, storageKey } = (0,
|
|
309
|
+
const { namespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
310
310
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
|
|
311
311
|
// Only add network if it doesn't already exist in state (preserves user settings)
|
|
312
312
|
(_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
|
|
@@ -318,7 +318,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
318
318
|
// Initialize namespace buckets for all networks from MultichainNetworkController
|
|
319
319
|
Object.keys(multichainState.multichainNetworkConfigurationsByChainId).forEach((chainId) => {
|
|
320
320
|
var _a;
|
|
321
|
-
const { namespace, storageKey } = (0,
|
|
321
|
+
const { namespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
322
322
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
|
|
323
323
|
// Only add network if it doesn't already exist in state (preserves user settings)
|
|
324
324
|
(_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
|
|
@@ -367,11 +367,11 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
367
367
|
if (namespace === 'eip155') {
|
|
368
368
|
// EVM networks: use getEvmSlip44 (chainid.network data)
|
|
369
369
|
const numericChainId = parseInt(reference, 10);
|
|
370
|
-
slip44CoinType = await
|
|
370
|
+
slip44CoinType = await services_1.Slip44Service.getEvmSlip44(numericChainId);
|
|
371
371
|
}
|
|
372
372
|
else {
|
|
373
373
|
// Non-EVM networks: use getSlip44BySymbol (@metamask/slip44 package)
|
|
374
|
-
slip44CoinType =
|
|
374
|
+
slip44CoinType = services_1.Slip44Service.getSlip44BySymbol(nativeCurrency);
|
|
375
375
|
}
|
|
376
376
|
if (slip44CoinType !== undefined) {
|
|
377
377
|
updates.push({
|
|
@@ -402,7 +402,7 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
402
402
|
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
403
403
|
*/
|
|
404
404
|
disableNetwork(chainId) {
|
|
405
|
-
const derivedKeys = (0,
|
|
405
|
+
const derivedKeys = (0, utils_2.deriveKeys)(chainId);
|
|
406
406
|
const { namespace, storageKey } = derivedKeys;
|
|
407
407
|
this.update((state) => {
|
|
408
408
|
state.enabledNetworkMap[namespace][storageKey] = false;
|
|
@@ -439,20 +439,20 @@ class NetworkEnablementController extends base_controller_1.BaseController {
|
|
|
439
439
|
* @returns True if the network is enabled, false otherwise
|
|
440
440
|
*/
|
|
441
441
|
isNetworkEnabled(chainId) {
|
|
442
|
-
const derivedKeys = (0,
|
|
442
|
+
const derivedKeys = (0, utils_2.deriveKeys)(chainId);
|
|
443
443
|
const { namespace, storageKey } = derivedKeys;
|
|
444
444
|
return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;
|
|
445
445
|
}
|
|
446
446
|
/**
|
|
447
447
|
* Returns popular EVM network chain IDs in hex form, restricted to networks
|
|
448
|
-
* that exist in NetworkController (networkConfigurationsByChainId). Source
|
|
449
|
-
*
|
|
448
|
+
* that exist in NetworkController (networkConfigurationsByChainId). Source list
|
|
449
|
+
* is POPULAR_NETWORKS.
|
|
450
450
|
*
|
|
451
451
|
* @returns Hex chain IDs for popular EVM networks that are configured.
|
|
452
452
|
*/
|
|
453
453
|
listPopularEvmNetworks() {
|
|
454
454
|
const networkControllerState = this.messenger.call('NetworkController:getState');
|
|
455
|
-
return
|
|
455
|
+
return constants_1.POPULAR_NETWORKS.filter((chainIdHex) => networkControllerState.networkConfigurationsByChainId[chainIdHex]);
|
|
456
456
|
}
|
|
457
457
|
/**
|
|
458
458
|
* Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in
|
|
@@ -495,23 +495,23 @@ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementContro
|
|
|
495
495
|
// Get current network configurations to check which popular networks exist
|
|
496
496
|
const networkControllerState = this.messenger.call('NetworkController:getState');
|
|
497
497
|
// Count how many popular networks are enabled
|
|
498
|
-
const enabledPopularNetworksCount =
|
|
498
|
+
const enabledPopularNetworksCount = constants_1.POPULAR_NETWORKS.reduce((count, chainId) => {
|
|
499
499
|
// Only check networks that actually exist in NetworkController configurations
|
|
500
500
|
if (!networkControllerState.networkConfigurationsByChainId[chainId]) {
|
|
501
501
|
return count; // Skip networks that don't exist
|
|
502
502
|
}
|
|
503
|
-
const { namespace, storageKey } = (0,
|
|
503
|
+
const { namespace, storageKey } = (0, utils_2.deriveKeys)(chainId);
|
|
504
504
|
const isEnabled = this.state.enabledNetworkMap[namespace]?.[storageKey];
|
|
505
505
|
return isEnabled ? count + 1 : count;
|
|
506
506
|
}, 0);
|
|
507
507
|
// Return true if more than 2 popular networks are enabled
|
|
508
508
|
return enabledPopularNetworksCount > 1;
|
|
509
509
|
}, _NetworkEnablementController_removeNetworkEntry = function _NetworkEnablementController_removeNetworkEntry(chainId) {
|
|
510
|
-
const derivedKeys = (0,
|
|
510
|
+
const derivedKeys = (0, utils_2.deriveKeys)(chainId);
|
|
511
511
|
const { namespace, storageKey, caipChainId } = derivedKeys;
|
|
512
512
|
this.update((state) => {
|
|
513
513
|
// fallback and enable ethereum mainnet
|
|
514
|
-
if ((0,
|
|
514
|
+
if ((0, utils_2.isOnlyNetworkEnabledInNamespace)(this.state, derivedKeys)) {
|
|
515
515
|
state.enabledNetworkMap[namespace][controller_utils_1.ChainId[controller_utils_1.BuiltInNetworkName.Mainnet]] = true;
|
|
516
516
|
}
|
|
517
517
|
if (namespace in state.enabledNetworkMap) {
|
|
@@ -534,18 +534,18 @@ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementContro
|
|
|
534
534
|
* - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier
|
|
535
535
|
*/
|
|
536
536
|
async function _NetworkEnablementController_onAddNetwork(chainId) {
|
|
537
|
-
const { namespace, storageKey, reference, caipChainId } = (0,
|
|
537
|
+
const { namespace, storageKey, reference, caipChainId } = (0, utils_2.deriveKeys)(chainId);
|
|
538
538
|
// Parse reference (decimal string from CAIP-2) to number for chainid.network lookup
|
|
539
539
|
const numericChainId = parseInt(reference, 10);
|
|
540
540
|
// EVM networks: use getEvmSlip44 (chainid.network data)
|
|
541
|
-
const slip44CoinType = await
|
|
541
|
+
const slip44CoinType = await services_1.Slip44Service.getEvmSlip44(numericChainId);
|
|
542
542
|
this.update((state) => {
|
|
543
543
|
// Ensure the namespace bucket exists
|
|
544
544
|
__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
|
|
545
545
|
// Check if popular networks mode is active (>2 popular networks enabled)
|
|
546
546
|
const inPopularNetworksMode = __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_isInPopularNetworksMode).call(this);
|
|
547
547
|
// Check if the network being added is a popular network
|
|
548
|
-
const isAddedNetworkPopular =
|
|
548
|
+
const isAddedNetworkPopular = (0, utils_2.isPopularNetwork)(reference);
|
|
549
549
|
// Keep current selection only if in popular networks mode AND adding a popular network
|
|
550
550
|
const shouldKeepCurrentSelection = inPopularNetworksMode && isAddedNetworkPopular;
|
|
551
551
|
if (shouldKeepCurrentSelection) {
|
|
@@ -565,25 +565,5 @@ async function _NetworkEnablementController_onAddNetwork(chainId) {
|
|
|
565
565
|
// Update nativeAssetIdentifiers with the CAIP-19-like identifier
|
|
566
566
|
state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(caipChainId, slip44CoinType);
|
|
567
567
|
});
|
|
568
|
-
}, _NetworkEnablementController_getRegistryPopularEvmChainIds = function _NetworkEnablementController_getRegistryPopularEvmChainIds() {
|
|
569
|
-
const { configs: { networks }, } = this.messenger.call('ConfigRegistryController:getState');
|
|
570
|
-
return Object.values(networks).reduce((popularChains, network) => {
|
|
571
|
-
if (network.config.isFeatured &&
|
|
572
|
-
network.config.isActive &&
|
|
573
|
-
!network.config.isTestnet &&
|
|
574
|
-
network.chainId.startsWith('eip155:')) {
|
|
575
|
-
const hexChainId = (0, controller_utils_1.toHex)((0, utils_1.parseCaipChainId)(network.chainId).reference);
|
|
576
|
-
popularChains.push(hexChainId);
|
|
577
|
-
}
|
|
578
|
-
return popularChains;
|
|
579
|
-
}, []);
|
|
580
|
-
}, _NetworkEnablementController_getPopularEvmChainIds = function _NetworkEnablementController_getPopularEvmChainIds() {
|
|
581
|
-
return [
|
|
582
|
-
...new Set([
|
|
583
|
-
// `toHex` is used to normalize chain IDs from the bundled POPULAR_NETWORKS.
|
|
584
|
-
...constants_js_1.POPULAR_NETWORKS.map((chainId) => (0, controller_utils_1.toHex)(chainId)),
|
|
585
|
-
...__classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_getRegistryPopularEvmChainIds).call(this),
|
|
586
|
-
]),
|
|
587
|
-
];
|
|
588
568
|
};
|
|
589
569
|
//# sourceMappingURL=NetworkEnablementController.cjs.map
|