@metamask-previews/network-enablement-controller 4.0.0-preview-e6f8648b → 4.0.0-preview-22f11ed5

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.
@@ -6,7 +6,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
6
6
  };
7
7
  var _NetworkEnablementController_instances, _NetworkEnablementController_onNetworkControllerStateChange, _NetworkEnablementController_ensureNamespaceBucket, _NetworkEnablementController_updateNativeAssetIdentifier, _NetworkEnablementController_isInPopularNetworksMode, _NetworkEnablementController_removeNetworkEntry, _NetworkEnablementController_onAddNetwork;
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.NetworkEnablementController = exports.initNativeAssetIdentifiers = void 0;
9
+ exports.NetworkEnablementController = void 0;
10
10
  const base_controller_1 = require("@metamask/base-controller");
11
11
  const controller_utils_1 = require("@metamask/controller-utils");
12
12
  const keyring_api_1 = require("@metamask/keyring-api");
@@ -25,41 +25,6 @@ const controllerName = 'NetworkEnablementController';
25
25
  function buildNativeAssetIdentifier(caipChainId, slip44CoinType) {
26
26
  return `${caipChainId}/slip44:${slip44CoinType}`;
27
27
  }
28
- /**
29
- * Initializes the native asset identifiers map from network configurations.
30
- * This function should be called from the client during controller initialization
31
- * to populate the nativeAssetIdentifiers state based on actual network configurations.
32
- *
33
- * @param networks - Array of network configurations with chainId and nativeCurrency
34
- * @returns A map of CAIP-2 chain IDs to their native asset identifiers
35
- * @example
36
- * ```typescript
37
- * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
38
- * .map(config => ({
39
- * chainId: toEvmCaipChainId(config.chainId),
40
- * nativeCurrency: config.nativeCurrency,
41
- * }));
42
- *
43
- * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
44
- * .map(config => ({
45
- * chainId: config.chainId,
46
- * nativeCurrency: config.nativeCurrency,
47
- * }));
48
- *
49
- * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
50
- * ```
51
- */
52
- function initNativeAssetIdentifiers(networks) {
53
- const result = {};
54
- for (const { chainId, nativeCurrency } of networks) {
55
- const slip44CoinType = services_1.Slip44Service.getSlip44BySymbol(nativeCurrency);
56
- if (slip44CoinType !== undefined) {
57
- result[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);
58
- }
59
- }
60
- return result;
61
- }
62
- exports.initNativeAssetIdentifiers = initNativeAssetIdentifiers;
63
28
  /**
64
29
  * Gets the default state for the NetworkEnablementController.
65
30
  *
@@ -322,6 +287,39 @@ class NetworkEnablementController extends base_controller_1.BaseController {
322
287
  });
323
288
  });
324
289
  }
290
+ /**
291
+ * Initializes the native asset identifiers from network configurations.
292
+ * This method should be called from the client during controller initialization
293
+ * to populate the nativeAssetIdentifiers state based on actual network configurations.
294
+ *
295
+ * @param networks - Array of network configurations with chainId and nativeCurrency
296
+ * @example
297
+ * ```typescript
298
+ * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
299
+ * .map(config => ({
300
+ * chainId: toEvmCaipChainId(config.chainId),
301
+ * nativeCurrency: config.nativeCurrency,
302
+ * }));
303
+ *
304
+ * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
305
+ * .map(config => ({
306
+ * chainId: config.chainId,
307
+ * nativeCurrency: config.nativeCurrency,
308
+ * }));
309
+ *
310
+ * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
311
+ * ```
312
+ */
313
+ initNativeAssetIdentifiers(networks) {
314
+ this.update((state) => {
315
+ for (const { chainId, nativeCurrency } of networks) {
316
+ const slip44CoinType = services_1.Slip44Service.getSlip44BySymbol(nativeCurrency);
317
+ if (slip44CoinType !== undefined) {
318
+ state.nativeAssetIdentifiers[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);
319
+ }
320
+ }
321
+ });
322
+ }
325
323
  /**
326
324
  * Disables a network for the user.
327
325
  *
@@ -1 +1 @@
1
- {"version":3,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W,CAAC,GAAG,0BAA0B,CACpE,WAAW,EACX,cAAc,CACf,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BuiltInNetworkName, ChainId } from '@metamask/controller-utils';\nimport { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { Messenger } from '@metamask/messenger';\nimport type { MultichainNetworkControllerGetStateAction } from '@metamask/multichain-network-controller';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { TransactionControllerTransactionSubmittedEvent } from '@metamask/transaction-controller';\nimport type { CaipChainId, CaipNamespace, Hex } from '@metamask/utils';\nimport { KnownCaipNamespace } from '@metamask/utils';\n\nimport { POPULAR_NETWORKS } from './constants';\nimport { Slip44Service } from './services';\nimport {\n deriveKeys,\n isOnlyNetworkEnabledInNamespace,\n isPopularNetwork,\n} from './utils';\n\nconst controllerName = 'NetworkEnablementController';\n\n/**\n * Information about an ordered network.\n */\nexport type NetworksInfo = {\n /**\n * The network's chain id\n */\n networkId: CaipChainId;\n};\n\n/**\n * A map of enabled networks by CAIP namespace and chain ID.\n * For EIP-155 networks, the keys are Hex chain IDs.\n * For other networks, the keys are CAIP chain IDs.\n */\ntype EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;\n\n/**\n * A native asset identifier in CAIP-19-like format.\n * Format: `{caip2ChainId}/slip44:{coinType}`\n *\n * @example\n * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)\n * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)\n * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)\n */\nexport type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers.\n * Uses CAIP-19-like format to identify the native asset for each chain.\n *\n * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md\n */\nexport type NativeAssetIdentifiersMap = Record<\n CaipChainId,\n NativeAssetIdentifier\n>;\n\n// State shape for NetworkEnablementController\nexport type NetworkEnablementControllerState = {\n enabledNetworkMap: EnabledMap;\n nativeAssetIdentifiers: NativeAssetIdentifiersMap;\n};\n\nexport type NetworkEnablementControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerSetEnabledNetworksAction = {\n type: `${typeof controllerName}:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `${typeof controllerName}:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * All actions that {@link NetworkEnablementController} calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetStateAction\n | MultichainNetworkControllerGetStateAction;\n\nexport type NetworkEnablementControllerActions =\n | NetworkEnablementControllerGetStateAction\n | NetworkEnablementControllerSetEnabledNetworksAction\n | NetworkEnablementControllerDisableNetworkAction;\n\nexport type NetworkEnablementControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerEvents =\n NetworkEnablementControllerStateChangeEvent;\n\n/**\n * All events that {@link NetworkEnablementController} subscribes to internally.\n */\nexport type AllowedEvents =\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkRemovedEvent\n | NetworkControllerStateChangeEvent\n | TransactionControllerTransactionSubmittedEvent;\n\nexport type NetworkEnablementControllerMessenger = Messenger<\n typeof controllerName,\n NetworkEnablementControllerActions | AllowedActions,\n NetworkEnablementControllerEvents | AllowedEvents\n>;\n\n/**\n * Builds a native asset identifier in CAIP-19-like format.\n *\n * @param caipChainId - The CAIP-2 chain ID (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')\n * @param slip44CoinType - The SLIP-44 coin type number\n * @returns The native asset identifier string (e.g., 'eip155:1/slip44:60')\n */\nfunction buildNativeAssetIdentifier(\n caipChainId: CaipChainId,\n slip44CoinType: number,\n): NativeAssetIdentifier {\n return `${caipChainId}/slip44:${slip44CoinType}`;\n}\n\n/**\n * Network configuration with chain ID and native currency symbol.\n * Used to initialize native asset identifiers.\n */\nexport type NetworkConfig = {\n chainId: CaipChainId;\n nativeCurrency: string;\n};\n\n/**\n * Initializes the native asset identifiers map from network configurations.\n * This function 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 * @returns A map of CAIP-2 chain IDs to their native asset identifiers\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 * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport function initNativeAssetIdentifiers(\n networks: NetworkConfig[],\n): NativeAssetIdentifiersMap {\n const result: NativeAssetIdentifiersMap = {};\n\n for (const { chainId, nativeCurrency } of networks) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n if (slip44CoinType !== undefined) {\n result[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);\n }\n }\n\n return result;\n}\n\n/**\n * Gets the default state for the NetworkEnablementController.\n *\n * @returns The default state with pre-enabled networks.\n */\nconst getDefaultNetworkEnablementControllerState =\n (): NetworkEnablementControllerState => ({\n enabledNetworkMap: {\n [KnownCaipNamespace.Eip155]: {\n [ChainId[BuiltInNetworkName.Mainnet]]: true,\n [ChainId[BuiltInNetworkName.LineaMainnet]]: true,\n [ChainId[BuiltInNetworkName.BaseMainnet]]: true,\n [ChainId[BuiltInNetworkName.ArbitrumOne]]: true,\n [ChainId[BuiltInNetworkName.BscMainnet]]: true,\n [ChainId[BuiltInNetworkName.OptimismMainnet]]: true,\n [ChainId[BuiltInNetworkName.PolygonMainnet]]: true,\n [ChainId[BuiltInNetworkName.SeiMainnet]]: true,\n },\n [KnownCaipNamespace.Solana]: {\n [SolScope.Mainnet]: true,\n [SolScope.Testnet]: false,\n [SolScope.Devnet]: false,\n },\n [KnownCaipNamespace.Bip122]: {\n [BtcScope.Mainnet]: true,\n [BtcScope.Testnet]: false,\n [BtcScope.Signet]: false,\n },\n [KnownCaipNamespace.Tron]: {\n [TrxScope.Mainnet]: true,\n [TrxScope.Nile]: false,\n [TrxScope.Shasta]: false,\n },\n },\n // nativeAssetIdentifiers is initialized as empty and should be populated\n // by the client using initNativeAssetIdentifiers() during controller init\n nativeAssetIdentifiers: {},\n });\n\n// Metadata for the controller state\nconst metadata = {\n enabledNetworkMap: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n nativeAssetIdentifiers: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n};\n\n/**\n * Controller responsible for managing network enablement state across different blockchain networks.\n *\n * This controller tracks which networks are enabled/disabled for the user and provides methods\n * to toggle network states. It supports both EVM (EIP-155) and non-EVM networks like Solana.\n *\n * The controller maintains a map of enabled networks organized by namespace (e.g., 'eip155', 'solana')\n * and provides methods to query and modify network enablement states.\n */\nexport class NetworkEnablementController extends BaseController<\n typeof controllerName,\n NetworkEnablementControllerState,\n NetworkEnablementControllerMessenger\n> {\n /**\n * Creates a NetworkEnablementController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with BaseV2 controller.\n * @param args.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: NetworkEnablementControllerMessenger;\n state?: Partial<NetworkEnablementControllerState>;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: {\n ...getDefaultNetworkEnablementControllerState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'NetworkController:networkAdded',\n ({ chainId, nativeCurrency }) => {\n this.#onAddNetwork(chainId, nativeCurrency);\n },\n );\n\n messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {\n this.#removeNetworkEntry(chainId);\n });\n\n messenger.subscribe(\n 'NetworkController:stateChange',\n (_newState, patches) => {\n this.#onNetworkControllerStateChange(patches);\n },\n );\n }\n\n /**\n * Handles NetworkController state changes to detect symbol updates.\n *\n * @param patches - The patches describing what changed\n */\n #onNetworkControllerStateChange(\n patches: { op: string; path: (string | number)[]; value?: unknown }[],\n ): void {\n // Look for patches that replace a network configuration\n // Path format: ['networkConfigurationsByChainId', chainId]\n for (const patch of patches) {\n if (\n patch.path.length === 2 &&\n patch.path[0] === 'networkConfigurationsByChainId' &&\n patch.op === 'replace' &&\n patch.value &&\n typeof patch.value === 'object' &&\n 'nativeCurrency' in patch.value\n ) {\n const chainId = patch.path[1] as Hex;\n const networkConfig = patch.value as { nativeCurrency: string };\n this.#updateNativeAssetIdentifier(\n chainId,\n networkConfig.nativeCurrency,\n );\n }\n }\n }\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 */\n enableNetwork(chainId: Hex | CaipChainId): void {\n const { namespace, storageKey } = deriveKeys(chainId);\n\n this.update((state) => {\n // disable all networks in all namespaces first\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // if the namespace bucket does not exist, return\n // new nemespace are added only when a new network is added\n if (!state.enabledNetworkMap[namespace]) {\n return;\n }\n\n // enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableNetworkInNamespace(\n chainId: Hex | CaipChainId,\n namespace: CaipNamespace,\n ): void {\n const { namespace: derivedNamespace, storageKey } = deriveKeys(chainId);\n\n // Validate that the derived namespace matches the provided namespace\n if (derivedNamespace !== namespace) {\n throw new Error(\n `Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`,\n );\n }\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Disable all networks in the specified namespace first\n if (state.enabledNetworkMap[namespace]) {\n Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {\n state.enabledNetworkMap[namespace][key as CaipChainId | Hex] = false;\n });\n }\n\n // Enable the target network in the specified namespace\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableAllPopularNetworks(): void {\n this.update((state) => {\n // First disable all networks across all namespaces\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // Get current network configurations to check if networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Enable all popular EVM networks that exist in NetworkController configurations\n POPULAR_NETWORKS.forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n\n // Check if network exists in NetworkController configurations\n if (\n networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n // Enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n });\n\n // Enable Solana mainnet if it exists in MultichainNetworkController configurations\n const solanaKeys = deriveKeys(SolScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n SolScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, solanaKeys.namespace);\n // Enable Solana mainnet\n state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =\n true;\n }\n\n // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations\n const bitcoinKeys = deriveKeys(BtcScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n BtcScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, bitcoinKeys.namespace);\n // Enable Bitcoin mainnet\n state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =\n true;\n }\n\n // Enable Tron mainnet if it exists in MultichainNetworkController configurations\n const tronKeys = deriveKeys(TrxScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n TrxScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, tronKeys.namespace);\n // Enable Tron mainnet\n state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;\n }\n });\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 */\n init(): void {\n this.update((state) => {\n // Get network configurations from NetworkController (EVM networks)\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Get network configurations from MultichainNetworkController (all networks)\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Initialize namespace buckets for EVM networks from NetworkController\n Object.entries(\n networkControllerState.networkConfigurationsByChainId,\n ).forEach(([chainId, config]) => {\n const { namespace, storageKey, caipChainId } = deriveKeys(\n chainId as Hex,\n );\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n\n // Sync nativeAssetIdentifiers using the nativeCurrency symbol\n if (state.nativeAssetIdentifiers[caipChainId] === undefined) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(\n config.nativeCurrency,\n );\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] =\n buildNativeAssetIdentifier(caipChainId, slip44CoinType);\n }\n }\n });\n\n // Initialize namespace buckets for all networks from MultichainNetworkController\n Object.keys(\n multichainState.multichainNetworkConfigurationsByChainId,\n ).forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as CaipChainId);\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n });\n });\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 */\n disableNetwork(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n\n this.update((state) => {\n state.enabledNetworkMap[namespace][storageKey] = false;\n });\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 */\n isNetworkEnabled(chainId: Hex | CaipChainId): boolean {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;\n }\n\n /**\n * Ensures that a namespace bucket exists in the state.\n *\n * This method creates the namespace entry in the enabledNetworkMap if it doesn't\n * already exist. This is used to prepare the state structure before adding\n * network entries.\n *\n * @param state - The current controller state\n * @param ns - The CAIP namespace to ensure exists\n */\n #ensureNamespaceBucket(\n state: NetworkEnablementControllerState,\n ns: CaipNamespace,\n ): void {\n if (!state.enabledNetworkMap[ns]) {\n state.enabledNetworkMap[ns] = {};\n }\n }\n\n /**\n * Updates the native asset identifier for a network based on its symbol.\n *\n * This method looks up the SLIP-44 coin type for the given symbol using the\n * Slip44Service and updates the nativeAssetIdentifiers state with the full\n * CAIP-19-like identifier.\n *\n * @param chainId - The chain ID of the network (Hex or CAIP-2 format)\n * @param symbol - The native currency symbol of the network (e.g., 'ETH', 'BTC')\n */\n #updateNativeAssetIdentifier(\n chainId: Hex | CaipChainId,\n symbol: string,\n ): void {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(symbol);\n const { caipChainId } = deriveKeys(chainId);\n\n this.update((state) => {\n if (slip44CoinType === undefined) {\n // Remove the entry if no SLIP-44 mapping exists for the symbol\n delete state.nativeAssetIdentifiers[caipChainId];\n return;\n }\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n });\n }\n\n /**\n * Checks if popular networks mode is active (more than 2 popular networks enabled).\n *\n * This method counts how many networks defined in POPULAR_NETWORKS are currently\n * enabled in the state and returns true if more than 2 are enabled. It only checks\n * networks that actually exist in the NetworkController configurations.\n *\n * @returns True if more than 2 popular networks are enabled, false otherwise\n */\n #isInPopularNetworksMode(): boolean {\n // Get current network configurations to check which popular networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Count how many popular networks are enabled\n const enabledPopularNetworksCount = POPULAR_NETWORKS.reduce(\n (count, chainId) => {\n // Only check networks that actually exist in NetworkController configurations\n if (\n !networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n return count; // Skip networks that don't exist\n }\n\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n const isEnabled = this.state.enabledNetworkMap[namespace]?.[storageKey];\n return isEnabled ? count + 1 : count;\n },\n 0,\n );\n\n // Return true if more than 2 popular networks are enabled\n return enabledPopularNetworksCount > 1;\n }\n\n /**\n * Removes a network entry from the state.\n *\n * This method is called when a network is removed from the system. It cleans up\n * the network entry from both enabledNetworkMap and nativeAssetIdentifiers, and ensures that\n * at least one network remains enabled.\n *\n * @param chainId - The chain ID to remove (Hex or CAIP-2 format)\n */\n #removeNetworkEntry(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey, caipChainId } = derivedKeys;\n\n this.update((state) => {\n // fallback and enable ethereum mainnet\n if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {\n state.enabledNetworkMap[namespace][\n ChainId[BuiltInNetworkName.Mainnet]\n ] = true;\n }\n\n if (namespace in state.enabledNetworkMap) {\n delete state.enabledNetworkMap[namespace][storageKey];\n }\n\n // Remove from nativeAssetIdentifiers as well\n delete state.nativeAssetIdentifiers[caipChainId];\n });\n }\n\n /**\n * Handles the addition of a new network to the controller.\n *\n * @param chainId - The chain ID to add (Hex or CAIP-2 format)\n * @param nativeCurrency - The native currency symbol of the network (e.g., 'ETH')\n *\n * @description\n * - If in popular networks mode (>2 popular networks enabled) AND adding a popular network:\n * - Keep current selection (add but don't enable the new network)\n * - Otherwise:\n * - Switch to the newly added network (disable all others, enable this one)\n * - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier\n */\n #onAddNetwork(chainId: Hex | CaipChainId, nativeCurrency: string): void {\n const { namespace, storageKey, reference, caipChainId } =\n deriveKeys(chainId);\n\n // Look up the SLIP-44 coin type for the native currency\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Check if popular networks mode is active (>2 popular networks enabled)\n const inPopularNetworksMode = this.#isInPopularNetworksMode();\n\n // Check if the network being added is a popular network\n const isAddedNetworkPopular = isPopularNetwork(reference);\n\n // Keep current selection only if in popular networks mode AND adding a popular network\n const shouldKeepCurrentSelection =\n inPopularNetworksMode && isAddedNetworkPopular;\n\n if (shouldKeepCurrentSelection) {\n // Add the popular network but don't enable it (keep current selection)\n state.enabledNetworkMap[namespace][storageKey] = true;\n } else {\n // Switch to the newly added network (disable all others, enable this one)\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n // Enable the newly added network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n\n // Update nativeAssetIdentifiers with the CAIP-19-like identifier\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"NetworkEnablementController.cjs","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+DAA2D;AAK3D,iEAAyE;AACzE,uDAAqE;AAWrE,2CAAqD;AAErD,+CAA+C;AAC/C,mDAA2C;AAC3C,uCAIiB;AAEjB,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAmGrD;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,WAAwB,EACxB,cAAsB;IAEtB,OAAO,GAAG,WAAW,WAAW,cAAc,EAAE,CAAC;AACnD,CAAC;AAWD;;;;GAIG;AACH,MAAM,0CAA0C,GAC9C,GAAqC,EAAE,CAAC,CAAC;IACvC,iBAAiB,EAAE;QACjB,CAAC,0BAAkB,CAAC,MAAM,CAAC,EAAE;YAC3B,CAAC,0BAAO,CAAC,qCAAkB,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI;YAC3C,CAAC,0BAAO,CAAC,qCAAkB,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI;YAChD,CAAC,0BAAO,CAAC,qCAAkB,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI;YAC/C,CAAC,0BAAO,CAAC,qCAAkB,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI;YAC/C,CAAC,0BAAO,CAAC,qCAAkB,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI;YAC9C,CAAC,0BAAO,CA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CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;oBACvD,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAwB,CAAC,GAAG,KAAK,CAAC;gBAChE,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,iCAAiC;YACjC,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QACxD,CAAC;QAED,iEAAiE;QACjE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,GAAG,0BAA0B,CACpE,WAAW,EACX,cAAc,CACf,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BuiltInNetworkName, ChainId } from '@metamask/controller-utils';\nimport { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { Messenger } from '@metamask/messenger';\nimport type { MultichainNetworkControllerGetStateAction } from '@metamask/multichain-network-controller';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { TransactionControllerTransactionSubmittedEvent } from '@metamask/transaction-controller';\nimport type { CaipChainId, CaipNamespace, Hex } from '@metamask/utils';\nimport { KnownCaipNamespace } from '@metamask/utils';\n\nimport { POPULAR_NETWORKS } from './constants';\nimport { Slip44Service } from './services';\nimport {\n deriveKeys,\n isOnlyNetworkEnabledInNamespace,\n isPopularNetwork,\n} from './utils';\n\nconst controllerName = 'NetworkEnablementController';\n\n/**\n * Information about an ordered network.\n */\nexport type NetworksInfo = {\n /**\n * The network's chain id\n */\n networkId: CaipChainId;\n};\n\n/**\n * A map of enabled networks by CAIP namespace and chain ID.\n * For EIP-155 networks, the keys are Hex chain IDs.\n * For other networks, the keys are CAIP chain IDs.\n */\ntype EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;\n\n/**\n * A native asset identifier in CAIP-19-like format.\n * Format: `{caip2ChainId}/slip44:{coinType}`\n *\n * @example\n * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)\n * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)\n * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)\n */\nexport type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers.\n * Uses CAIP-19-like format to identify the native asset for each chain.\n *\n * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md\n */\nexport type NativeAssetIdentifiersMap = Record<\n CaipChainId,\n NativeAssetIdentifier\n>;\n\n// State shape for NetworkEnablementController\nexport type NetworkEnablementControllerState = {\n enabledNetworkMap: EnabledMap;\n nativeAssetIdentifiers: NativeAssetIdentifiersMap;\n};\n\nexport type NetworkEnablementControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerSetEnabledNetworksAction = {\n type: `${typeof controllerName}:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `${typeof controllerName}:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * All actions that {@link NetworkEnablementController} calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetStateAction\n | MultichainNetworkControllerGetStateAction;\n\nexport type NetworkEnablementControllerActions =\n | NetworkEnablementControllerGetStateAction\n | NetworkEnablementControllerSetEnabledNetworksAction\n | NetworkEnablementControllerDisableNetworkAction;\n\nexport type NetworkEnablementControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerEvents =\n NetworkEnablementControllerStateChangeEvent;\n\n/**\n * All events that {@link NetworkEnablementController} subscribes to internally.\n */\nexport type AllowedEvents =\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkRemovedEvent\n | NetworkControllerStateChangeEvent\n | TransactionControllerTransactionSubmittedEvent;\n\nexport type NetworkEnablementControllerMessenger = Messenger<\n typeof controllerName,\n NetworkEnablementControllerActions | AllowedActions,\n NetworkEnablementControllerEvents | AllowedEvents\n>;\n\n/**\n * Builds a native asset identifier in CAIP-19-like format.\n *\n * @param caipChainId - The CAIP-2 chain ID (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')\n * @param slip44CoinType - The SLIP-44 coin type number\n * @returns The native asset identifier string (e.g., 'eip155:1/slip44:60')\n */\nfunction buildNativeAssetIdentifier(\n caipChainId: CaipChainId,\n slip44CoinType: number,\n): NativeAssetIdentifier {\n return `${caipChainId}/slip44:${slip44CoinType}`;\n}\n\n/**\n * Network configuration with chain ID and native currency symbol.\n * Used to initialize native asset identifiers.\n */\nexport type NetworkConfig = {\n chainId: CaipChainId;\n nativeCurrency: string;\n};\n\n/**\n * Gets the default state for the NetworkEnablementController.\n *\n * @returns The default state with pre-enabled networks.\n */\nconst getDefaultNetworkEnablementControllerState =\n (): NetworkEnablementControllerState => ({\n enabledNetworkMap: {\n [KnownCaipNamespace.Eip155]: {\n [ChainId[BuiltInNetworkName.Mainnet]]: true,\n [ChainId[BuiltInNetworkName.LineaMainnet]]: true,\n [ChainId[BuiltInNetworkName.BaseMainnet]]: true,\n [ChainId[BuiltInNetworkName.ArbitrumOne]]: true,\n [ChainId[BuiltInNetworkName.BscMainnet]]: true,\n [ChainId[BuiltInNetworkName.OptimismMainnet]]: true,\n [ChainId[BuiltInNetworkName.PolygonMainnet]]: true,\n [ChainId[BuiltInNetworkName.SeiMainnet]]: true,\n },\n [KnownCaipNamespace.Solana]: {\n [SolScope.Mainnet]: true,\n [SolScope.Testnet]: false,\n [SolScope.Devnet]: false,\n },\n [KnownCaipNamespace.Bip122]: {\n [BtcScope.Mainnet]: true,\n [BtcScope.Testnet]: false,\n [BtcScope.Signet]: false,\n },\n [KnownCaipNamespace.Tron]: {\n [TrxScope.Mainnet]: true,\n [TrxScope.Nile]: false,\n [TrxScope.Shasta]: false,\n },\n },\n // nativeAssetIdentifiers is initialized as empty and should be populated\n // by the client using initNativeAssetIdentifiers() during controller init\n nativeAssetIdentifiers: {},\n });\n\n// Metadata for the controller state\nconst metadata = {\n enabledNetworkMap: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n nativeAssetIdentifiers: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n};\n\n/**\n * Controller responsible for managing network enablement state across different blockchain networks.\n *\n * This controller tracks which networks are enabled/disabled for the user and provides methods\n * to toggle network states. It supports both EVM (EIP-155) and non-EVM networks like Solana.\n *\n * The controller maintains a map of enabled networks organized by namespace (e.g., 'eip155', 'solana')\n * and provides methods to query and modify network enablement states.\n */\nexport class NetworkEnablementController extends BaseController<\n typeof controllerName,\n NetworkEnablementControllerState,\n NetworkEnablementControllerMessenger\n> {\n /**\n * Creates a NetworkEnablementController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with BaseV2 controller.\n * @param args.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: NetworkEnablementControllerMessenger;\n state?: Partial<NetworkEnablementControllerState>;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: {\n ...getDefaultNetworkEnablementControllerState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'NetworkController:networkAdded',\n ({ chainId, nativeCurrency }) => {\n this.#onAddNetwork(chainId, nativeCurrency);\n },\n );\n\n messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {\n this.#removeNetworkEntry(chainId);\n });\n\n messenger.subscribe(\n 'NetworkController:stateChange',\n (_newState, patches) => {\n this.#onNetworkControllerStateChange(patches);\n },\n );\n }\n\n /**\n * Handles NetworkController state changes to detect symbol updates.\n *\n * @param patches - The patches describing what changed\n */\n #onNetworkControllerStateChange(\n patches: { op: string; path: (string | number)[]; value?: unknown }[],\n ): void {\n // Look for patches that replace a network configuration\n // Path format: ['networkConfigurationsByChainId', chainId]\n for (const patch of patches) {\n if (\n patch.path.length === 2 &&\n patch.path[0] === 'networkConfigurationsByChainId' &&\n patch.op === 'replace' &&\n patch.value &&\n typeof patch.value === 'object' &&\n 'nativeCurrency' in patch.value\n ) {\n const chainId = patch.path[1] as Hex;\n const networkConfig = patch.value as { nativeCurrency: string };\n this.#updateNativeAssetIdentifier(\n chainId,\n networkConfig.nativeCurrency,\n );\n }\n }\n }\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 */\n enableNetwork(chainId: Hex | CaipChainId): void {\n const { namespace, storageKey } = deriveKeys(chainId);\n\n this.update((state) => {\n // disable all networks in all namespaces first\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // if the namespace bucket does not exist, return\n // new nemespace are added only when a new network is added\n if (!state.enabledNetworkMap[namespace]) {\n return;\n }\n\n // enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableNetworkInNamespace(\n chainId: Hex | CaipChainId,\n namespace: CaipNamespace,\n ): void {\n const { namespace: derivedNamespace, storageKey } = deriveKeys(chainId);\n\n // Validate that the derived namespace matches the provided namespace\n if (derivedNamespace !== namespace) {\n throw new Error(\n `Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`,\n );\n }\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Disable all networks in the specified namespace first\n if (state.enabledNetworkMap[namespace]) {\n Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {\n state.enabledNetworkMap[namespace][key as CaipChainId | Hex] = false;\n });\n }\n\n // Enable the target network in the specified namespace\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableAllPopularNetworks(): void {\n this.update((state) => {\n // First disable all networks across all namespaces\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // Get current network configurations to check if networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Enable all popular EVM networks that exist in NetworkController configurations\n POPULAR_NETWORKS.forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n\n // Check if network exists in NetworkController configurations\n if (\n networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n // Enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n });\n\n // Enable Solana mainnet if it exists in MultichainNetworkController configurations\n const solanaKeys = deriveKeys(SolScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n SolScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, solanaKeys.namespace);\n // Enable Solana mainnet\n state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =\n true;\n }\n\n // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations\n const bitcoinKeys = deriveKeys(BtcScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n BtcScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, bitcoinKeys.namespace);\n // Enable Bitcoin mainnet\n state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =\n true;\n }\n\n // Enable Tron mainnet if it exists in MultichainNetworkController configurations\n const tronKeys = deriveKeys(TrxScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n TrxScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, tronKeys.namespace);\n // Enable Tron mainnet\n state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;\n }\n });\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 */\n init(): void {\n this.update((state) => {\n // Get network configurations from NetworkController (EVM networks)\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Get network configurations from MultichainNetworkController (all networks)\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Initialize namespace buckets for EVM networks from NetworkController\n Object.entries(\n networkControllerState.networkConfigurationsByChainId,\n ).forEach(([chainId, config]) => {\n const { namespace, storageKey, caipChainId } = deriveKeys(\n chainId as Hex,\n );\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n\n // Sync nativeAssetIdentifiers using the nativeCurrency symbol\n if (state.nativeAssetIdentifiers[caipChainId] === undefined) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(\n config.nativeCurrency,\n );\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] =\n buildNativeAssetIdentifier(caipChainId, slip44CoinType);\n }\n }\n });\n\n // Initialize namespace buckets for all networks from MultichainNetworkController\n Object.keys(\n multichainState.multichainNetworkConfigurationsByChainId,\n ).forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as CaipChainId);\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n });\n });\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 * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\n initNativeAssetIdentifiers(networks: NetworkConfig[]): void {\n this.update((state) => {\n for (const { chainId, nativeCurrency } of networks) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[chainId] = buildNativeAssetIdentifier(\n chainId,\n slip44CoinType,\n );\n }\n }\n });\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 */\n disableNetwork(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n\n this.update((state) => {\n state.enabledNetworkMap[namespace][storageKey] = false;\n });\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 */\n isNetworkEnabled(chainId: Hex | CaipChainId): boolean {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;\n }\n\n /**\n * Ensures that a namespace bucket exists in the state.\n *\n * This method creates the namespace entry in the enabledNetworkMap if it doesn't\n * already exist. This is used to prepare the state structure before adding\n * network entries.\n *\n * @param state - The current controller state\n * @param ns - The CAIP namespace to ensure exists\n */\n #ensureNamespaceBucket(\n state: NetworkEnablementControllerState,\n ns: CaipNamespace,\n ): void {\n if (!state.enabledNetworkMap[ns]) {\n state.enabledNetworkMap[ns] = {};\n }\n }\n\n /**\n * Updates the native asset identifier for a network based on its symbol.\n *\n * This method looks up the SLIP-44 coin type for the given symbol using the\n * Slip44Service and updates the nativeAssetIdentifiers state with the full\n * CAIP-19-like identifier.\n *\n * @param chainId - The chain ID of the network (Hex or CAIP-2 format)\n * @param symbol - The native currency symbol of the network (e.g., 'ETH', 'BTC')\n */\n #updateNativeAssetIdentifier(\n chainId: Hex | CaipChainId,\n symbol: string,\n ): void {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(symbol);\n const { caipChainId } = deriveKeys(chainId);\n\n this.update((state) => {\n if (slip44CoinType === undefined) {\n // Remove the entry if no SLIP-44 mapping exists for the symbol\n delete state.nativeAssetIdentifiers[caipChainId];\n return;\n }\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n });\n }\n\n /**\n * Checks if popular networks mode is active (more than 2 popular networks enabled).\n *\n * This method counts how many networks defined in POPULAR_NETWORKS are currently\n * enabled in the state and returns true if more than 2 are enabled. It only checks\n * networks that actually exist in the NetworkController configurations.\n *\n * @returns True if more than 2 popular networks are enabled, false otherwise\n */\n #isInPopularNetworksMode(): boolean {\n // Get current network configurations to check which popular networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Count how many popular networks are enabled\n const enabledPopularNetworksCount = POPULAR_NETWORKS.reduce(\n (count, chainId) => {\n // Only check networks that actually exist in NetworkController configurations\n if (\n !networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n return count; // Skip networks that don't exist\n }\n\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n const isEnabled = this.state.enabledNetworkMap[namespace]?.[storageKey];\n return isEnabled ? count + 1 : count;\n },\n 0,\n );\n\n // Return true if more than 2 popular networks are enabled\n return enabledPopularNetworksCount > 1;\n }\n\n /**\n * Removes a network entry from the state.\n *\n * This method is called when a network is removed from the system. It cleans up\n * the network entry from both enabledNetworkMap and nativeAssetIdentifiers, and ensures that\n * at least one network remains enabled.\n *\n * @param chainId - The chain ID to remove (Hex or CAIP-2 format)\n */\n #removeNetworkEntry(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey, caipChainId } = derivedKeys;\n\n this.update((state) => {\n // fallback and enable ethereum mainnet\n if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {\n state.enabledNetworkMap[namespace][\n ChainId[BuiltInNetworkName.Mainnet]\n ] = true;\n }\n\n if (namespace in state.enabledNetworkMap) {\n delete state.enabledNetworkMap[namespace][storageKey];\n }\n\n // Remove from nativeAssetIdentifiers as well\n delete state.nativeAssetIdentifiers[caipChainId];\n });\n }\n\n /**\n * Handles the addition of a new network to the controller.\n *\n * @param chainId - The chain ID to add (Hex or CAIP-2 format)\n * @param nativeCurrency - The native currency symbol of the network (e.g., 'ETH')\n *\n * @description\n * - If in popular networks mode (>2 popular networks enabled) AND adding a popular network:\n * - Keep current selection (add but don't enable the new network)\n * - Otherwise:\n * - Switch to the newly added network (disable all others, enable this one)\n * - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier\n */\n #onAddNetwork(chainId: Hex | CaipChainId, nativeCurrency: string): void {\n const { namespace, storageKey, reference, caipChainId } =\n deriveKeys(chainId);\n\n // Look up the SLIP-44 coin type for the native currency\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Check if popular networks mode is active (>2 popular networks enabled)\n const inPopularNetworksMode = this.#isInPopularNetworksMode();\n\n // Check if the network being added is a popular network\n const isAddedNetworkPopular = isPopularNetwork(reference);\n\n // Keep current selection only if in popular networks mode AND adding a popular network\n const shouldKeepCurrentSelection =\n inPopularNetworksMode && isAddedNetworkPopular;\n\n if (shouldKeepCurrentSelection) {\n // Add the popular network but don't enable it (keep current selection)\n state.enabledNetworkMap[namespace][storageKey] = true;\n } else {\n // Switch to the newly added network (disable all others, enable this one)\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n // Enable the newly added network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n\n // Update nativeAssetIdentifiers with the CAIP-19-like identifier\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n }\n });\n }\n}\n"]}
@@ -71,31 +71,6 @@ export type NetworkConfig = {
71
71
  chainId: CaipChainId;
72
72
  nativeCurrency: string;
73
73
  };
74
- /**
75
- * Initializes the native asset identifiers map from network configurations.
76
- * This function should be called from the client during controller initialization
77
- * to populate the nativeAssetIdentifiers state based on actual network configurations.
78
- *
79
- * @param networks - Array of network configurations with chainId and nativeCurrency
80
- * @returns A map of CAIP-2 chain IDs to their native asset identifiers
81
- * @example
82
- * ```typescript
83
- * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
84
- * .map(config => ({
85
- * chainId: toEvmCaipChainId(config.chainId),
86
- * nativeCurrency: config.nativeCurrency,
87
- * }));
88
- *
89
- * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
90
- * .map(config => ({
91
- * chainId: config.chainId,
92
- * nativeCurrency: config.nativeCurrency,
93
- * }));
94
- *
95
- * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
96
- * ```
97
- */
98
- export declare function initNativeAssetIdentifiers(networks: NetworkConfig[]): NativeAssetIdentifiersMap;
99
74
  /**
100
75
  * Controller responsible for managing network enablement state across different blockchain networks.
101
76
  *
@@ -175,6 +150,30 @@ export declare class NetworkEnablementController extends BaseController<typeof c
175
150
  * have been initialized and their configurations are available.
176
151
  */
177
152
  init(): void;
153
+ /**
154
+ * Initializes the native asset identifiers from network configurations.
155
+ * This method should be called from the client during controller initialization
156
+ * to populate the nativeAssetIdentifiers state based on actual network configurations.
157
+ *
158
+ * @param networks - Array of network configurations with chainId and nativeCurrency
159
+ * @example
160
+ * ```typescript
161
+ * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
162
+ * .map(config => ({
163
+ * chainId: toEvmCaipChainId(config.chainId),
164
+ * nativeCurrency: config.nativeCurrency,
165
+ * }));
166
+ *
167
+ * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
168
+ * .map(config => ({
169
+ * chainId: config.chainId,
170
+ * nativeCurrency: config.nativeCurrency,
171
+ * }));
172
+ *
173
+ * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
174
+ * ```
175
+ */
176
+ initNativeAssetIdentifiers(networks: NetworkConfig[]): void;
178
177
  /**
179
178
  * Disables a network for the user.
180
179
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkEnablementController.d.cts","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,gDAAgD;AACzG,OAAO,KAAK,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,oCAAoC,EACpC,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,K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B,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAkLtD"}
1
+ {"version":3,"file":"NetworkEnablementController.d.cts","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,gDAAgD;AACzG,OAAO,KAAK,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,oCAAoC,EACpC,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,KAAK,EAAE,8CAA8C,EAAE,yCAAyC;AACvG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,wBAAwB;AAWvE,QAAA,MAAM,cAAc,gCAAgC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB;;OAEG;IACH,SAAS,EAAE,WAAW,CAAC;CACxB,CAAC;AAEF;;;;GAIG;AACH,KAAK,UAAU,GAAG,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,WAAW,GAAG,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG,GAAG,WAAW,WAAW,MAAM,EAAE,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,MAAM,CAC5C,WAAW,EACX,qBAAqB,CACtB,CAAC;AAGF,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iBAAiB,EAAE,UAAU,CAAC;IAC9B,sBAAsB,EAAE,yBAAyB,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,yCAAyC,GACnD,wBAAwB,CACtB,OAAO,cAAc,EACrB,gCAAgC,CACjC,CAAC;AAEJ,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,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sB/C;;;;;;;;;;;;;;;OAeG;IACH,wBAAwB,CACtB,OAAO,EAAE,GAAG,GAAG,WAAW,EAC1B,SAAS,EAAE,aAAa,GACvB,IAAI;IA0BP;;;;;;;;;OASG;IACH,wBAAwB,IAAI,IAAI;IA2EhC;;;;;;;;;;OAUG;IACH,IAAI,IAAI,IAAI;IAiDZ;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,0BAA0B,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI;IAc3D;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAkLtD"}
@@ -71,31 +71,6 @@ export type NetworkConfig = {
71
71
  chainId: CaipChainId;
72
72
  nativeCurrency: string;
73
73
  };
74
- /**
75
- * Initializes the native asset identifiers map from network configurations.
76
- * This function should be called from the client during controller initialization
77
- * to populate the nativeAssetIdentifiers state based on actual network configurations.
78
- *
79
- * @param networks - Array of network configurations with chainId and nativeCurrency
80
- * @returns A map of CAIP-2 chain IDs to their native asset identifiers
81
- * @example
82
- * ```typescript
83
- * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
84
- * .map(config => ({
85
- * chainId: toEvmCaipChainId(config.chainId),
86
- * nativeCurrency: config.nativeCurrency,
87
- * }));
88
- *
89
- * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
90
- * .map(config => ({
91
- * chainId: config.chainId,
92
- * nativeCurrency: config.nativeCurrency,
93
- * }));
94
- *
95
- * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
96
- * ```
97
- */
98
- export declare function initNativeAssetIdentifiers(networks: NetworkConfig[]): NativeAssetIdentifiersMap;
99
74
  /**
100
75
  * Controller responsible for managing network enablement state across different blockchain networks.
101
76
  *
@@ -175,6 +150,30 @@ export declare class NetworkEnablementController extends BaseController<typeof c
175
150
  * have been initialized and their configurations are available.
176
151
  */
177
152
  init(): void;
153
+ /**
154
+ * Initializes the native asset identifiers from network configurations.
155
+ * This method should be called from the client during controller initialization
156
+ * to populate the nativeAssetIdentifiers state based on actual network configurations.
157
+ *
158
+ * @param networks - Array of network configurations with chainId and nativeCurrency
159
+ * @example
160
+ * ```typescript
161
+ * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
162
+ * .map(config => ({
163
+ * chainId: toEvmCaipChainId(config.chainId),
164
+ * nativeCurrency: config.nativeCurrency,
165
+ * }));
166
+ *
167
+ * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
168
+ * .map(config => ({
169
+ * chainId: config.chainId,
170
+ * nativeCurrency: config.nativeCurrency,
171
+ * }));
172
+ *
173
+ * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
174
+ * ```
175
+ */
176
+ initNativeAssetIdentifiers(networks: NetworkConfig[]): void;
178
177
  /**
179
178
  * Disables a network for the user.
180
179
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkEnablementController.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AAGnC,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AACrD,OAAO,KAAK,EAAE,yCAAyC,EAAE,gDAAgD;AACzG,OAAO,KAAK,EACV,+BAA+B,EAC/B,kCAAkC,EAClC,oCAAoC,EACpC,iCAAiC,EAClC,qCAAqC;AACtC,OAAO,KAAK,EAAE,8CAA8C,EAAE,yCAAyC;AACvG,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,EAAE,wBAAwB;AAWvE,QAAA,MAAM,cAAc,gCAAgC,CAAC;AAErD;;GAEG;AACH,MAAM,MAAM,YAA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GACjC,8CAA8C,CAAC;AAEnD,MAAM,MAAM,oCAAoC,GAAG,SAAS,CAC1D,OAAO,cAAc,EACrB,kCAAkC,GAAG,cAAc,EACnD,iCAAiC,GAAG,aAAa,CAClD,CAAC;AAgBF;;;GAGG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,WAAW,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EAAE,GACxB,yBAAyB,CAW3B;AAyDD;;;;;;;;GAQG;AACH,qBAAa,2BAA4B,SAAQ,cAAc,CAC7D,OAAO,cAAc,EACrB,gCAAgC,EAChC,oCAAoC,CACrC;;IACC;;;;;;OAMG;gBACS,EACV,SAAS,EACT,KAAK,GACN,EAAE;QACD,SAAS,EAAE,oCAAoC,CAAC;QAChD,KAAK,CAAC,EAAE,OAAO,CAAC,gCAAgC,CAAC,CAAC;KACnD;IA2DD;;;;;;;;;;;;;;;OAeG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAsB/C;;;;;;;;;;;;;;;OAeG;IACH,wBAAwB,CACtB,OAAO,EAAE,GAAG,GAAG,WAAW,EAC1B,SAAS,EAAE,aAAa,GACvB,IAAI;IA0BP;;;;;;;;;OASG;IACH,wBAAwB,IAAI,IAAI;IA2EhC;;;;;;;;;;OAUG;IACH,IAAI,IAAI,IAAI;IAiDZ;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAkLtD"}
1
+ {"version":3,"file":"NetworkEnablementController.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,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;;;;;OAUG;IACH,IAAI,IAAI,IAAI;IAiDZ;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,0BAA0B,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI;IAc3D;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAkLtD"}
@@ -22,40 +22,6 @@ const controllerName = 'NetworkEnablementController';
22
22
  function buildNativeAssetIdentifier(caipChainId, slip44CoinType) {
23
23
  return `${caipChainId}/slip44:${slip44CoinType}`;
24
24
  }
25
- /**
26
- * Initializes the native asset identifiers map from network configurations.
27
- * This function should be called from the client during controller initialization
28
- * to populate the nativeAssetIdentifiers state based on actual network configurations.
29
- *
30
- * @param networks - Array of network configurations with chainId and nativeCurrency
31
- * @returns A map of CAIP-2 chain IDs to their native asset identifiers
32
- * @example
33
- * ```typescript
34
- * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
35
- * .map(config => ({
36
- * chainId: toEvmCaipChainId(config.chainId),
37
- * nativeCurrency: config.nativeCurrency,
38
- * }));
39
- *
40
- * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
41
- * .map(config => ({
42
- * chainId: config.chainId,
43
- * nativeCurrency: config.nativeCurrency,
44
- * }));
45
- *
46
- * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
47
- * ```
48
- */
49
- export function initNativeAssetIdentifiers(networks) {
50
- const result = {};
51
- for (const { chainId, nativeCurrency } of networks) {
52
- const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);
53
- if (slip44CoinType !== undefined) {
54
- result[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);
55
- }
56
- }
57
- return result;
58
- }
59
25
  /**
60
26
  * Gets the default state for the NetworkEnablementController.
61
27
  *
@@ -318,6 +284,39 @@ export class NetworkEnablementController extends BaseController {
318
284
  });
319
285
  });
320
286
  }
287
+ /**
288
+ * Initializes the native asset identifiers from network configurations.
289
+ * This method should be called from the client during controller initialization
290
+ * to populate the nativeAssetIdentifiers state based on actual network configurations.
291
+ *
292
+ * @param networks - Array of network configurations with chainId and nativeCurrency
293
+ * @example
294
+ * ```typescript
295
+ * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
296
+ * .map(config => ({
297
+ * chainId: toEvmCaipChainId(config.chainId),
298
+ * nativeCurrency: config.nativeCurrency,
299
+ * }));
300
+ *
301
+ * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
302
+ * .map(config => ({
303
+ * chainId: config.chainId,
304
+ * nativeCurrency: config.nativeCurrency,
305
+ * }));
306
+ *
307
+ * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
308
+ * ```
309
+ */
310
+ initNativeAssetIdentifiers(networks) {
311
+ this.update((state) => {
312
+ for (const { chainId, nativeCurrency } of networks) {
313
+ const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);
314
+ if (slip44CoinType !== undefined) {
315
+ state.nativeAssetIdentifiers[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);
316
+ }
317
+ }
318
+ });
319
+ }
321
320
  /**
322
321
  * Disables a network for the user.
323
322
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkEnablementController.mjs","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,mCAAmC;AACzE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAWrE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAC/C,OAAO,EAAE,aAAa,EAAE,6BAAm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9C,yEAAyE;QACzE,MAAM,qBAAqB,GAAG,uBAAA,IAAI,oGAAyB,MAA7B,IAAI,CAA2B,CAAC;QAE9D,wDAAwD;QACxD,MAAM,qBAAqB,GAAG,gBAAgB,CAAC,SAAS,CAAC,CAAC;QAE1D,uFAAuF;QACvF,MAAM,0BAA0B,GAC9B,qBAAqB,IAAI,qBAAqB,CAAC;QAEjD,IAAI,0BAA0B,EAAE,CAAC;YAC/B,uEAAuE;YACvE,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,0EAA0E;YAC1E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;gBAClD,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;oBACvD,KAAK,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC,GAAwB,CAAC,GAAG,KAAK,CAAC;gBAChE,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,iCAAiC;YACjC,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QACxD,CAAC;QAED,iEAAiE;QACjE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,GAAG,0BAA0B,CACpE,WAAW,EACX,cAAc,CACf,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BuiltInNetworkName, ChainId } from '@metamask/controller-utils';\nimport { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { Messenger } from '@metamask/messenger';\nimport type { MultichainNetworkControllerGetStateAction } from '@metamask/multichain-network-controller';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { TransactionControllerTransactionSubmittedEvent } from '@metamask/transaction-controller';\nimport type { CaipChainId, CaipNamespace, Hex } from '@metamask/utils';\nimport { KnownCaipNamespace } from '@metamask/utils';\n\nimport { POPULAR_NETWORKS } from './constants';\nimport { Slip44Service } from './services';\nimport {\n deriveKeys,\n isOnlyNetworkEnabledInNamespace,\n isPopularNetwork,\n} from './utils';\n\nconst controllerName = 'NetworkEnablementController';\n\n/**\n * Information about an ordered network.\n */\nexport type NetworksInfo = {\n /**\n * The network's chain id\n */\n networkId: CaipChainId;\n};\n\n/**\n * A map of enabled networks by CAIP namespace and chain ID.\n * For EIP-155 networks, the keys are Hex chain IDs.\n * For other networks, the keys are CAIP chain IDs.\n */\ntype EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;\n\n/**\n * A native asset identifier in CAIP-19-like format.\n * Format: `{caip2ChainId}/slip44:{coinType}`\n *\n * @example\n * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)\n * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)\n * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)\n */\nexport type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers.\n * Uses CAIP-19-like format to identify the native asset for each chain.\n *\n * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md\n */\nexport type NativeAssetIdentifiersMap = Record<\n CaipChainId,\n NativeAssetIdentifier\n>;\n\n// State shape for NetworkEnablementController\nexport type NetworkEnablementControllerState = {\n enabledNetworkMap: EnabledMap;\n nativeAssetIdentifiers: NativeAssetIdentifiersMap;\n};\n\nexport type NetworkEnablementControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerSetEnabledNetworksAction = {\n type: `${typeof controllerName}:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `${typeof controllerName}:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * All actions that {@link NetworkEnablementController} calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetStateAction\n | MultichainNetworkControllerGetStateAction;\n\nexport type NetworkEnablementControllerActions =\n | NetworkEnablementControllerGetStateAction\n | NetworkEnablementControllerSetEnabledNetworksAction\n | NetworkEnablementControllerDisableNetworkAction;\n\nexport type NetworkEnablementControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerEvents =\n NetworkEnablementControllerStateChangeEvent;\n\n/**\n * All events that {@link NetworkEnablementController} subscribes to internally.\n */\nexport type AllowedEvents =\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkRemovedEvent\n | NetworkControllerStateChangeEvent\n | TransactionControllerTransactionSubmittedEvent;\n\nexport type NetworkEnablementControllerMessenger = Messenger<\n typeof controllerName,\n NetworkEnablementControllerActions | AllowedActions,\n NetworkEnablementControllerEvents | AllowedEvents\n>;\n\n/**\n * Builds a native asset identifier in CAIP-19-like format.\n *\n * @param caipChainId - The CAIP-2 chain ID (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')\n * @param slip44CoinType - The SLIP-44 coin type number\n * @returns The native asset identifier string (e.g., 'eip155:1/slip44:60')\n */\nfunction buildNativeAssetIdentifier(\n caipChainId: CaipChainId,\n slip44CoinType: number,\n): NativeAssetIdentifier {\n return `${caipChainId}/slip44:${slip44CoinType}`;\n}\n\n/**\n * Network configuration with chain ID and native currency symbol.\n * Used to initialize native asset identifiers.\n */\nexport type NetworkConfig = {\n chainId: CaipChainId;\n nativeCurrency: string;\n};\n\n/**\n * Initializes the native asset identifiers map from network configurations.\n * This function 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 * @returns A map of CAIP-2 chain IDs to their native asset identifiers\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 * const nativeAssetIdentifiers = initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport function initNativeAssetIdentifiers(\n networks: NetworkConfig[],\n): NativeAssetIdentifiersMap {\n const result: NativeAssetIdentifiersMap = {};\n\n for (const { chainId, nativeCurrency } of networks) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n if (slip44CoinType !== undefined) {\n result[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);\n }\n }\n\n return result;\n}\n\n/**\n * Gets the default state for the NetworkEnablementController.\n *\n * @returns The default state with pre-enabled networks.\n */\nconst getDefaultNetworkEnablementControllerState =\n (): NetworkEnablementControllerState => ({\n enabledNetworkMap: {\n [KnownCaipNamespace.Eip155]: {\n [ChainId[BuiltInNetworkName.Mainnet]]: true,\n [ChainId[BuiltInNetworkName.LineaMainnet]]: true,\n [ChainId[BuiltInNetworkName.BaseMainnet]]: true,\n [ChainId[BuiltInNetworkName.ArbitrumOne]]: true,\n [ChainId[BuiltInNetworkName.BscMainnet]]: true,\n [ChainId[BuiltInNetworkName.OptimismMainnet]]: true,\n [ChainId[BuiltInNetworkName.PolygonMainnet]]: true,\n [ChainId[BuiltInNetworkName.SeiMainnet]]: true,\n },\n [KnownCaipNamespace.Solana]: {\n [SolScope.Mainnet]: true,\n [SolScope.Testnet]: false,\n [SolScope.Devnet]: false,\n },\n [KnownCaipNamespace.Bip122]: {\n [BtcScope.Mainnet]: true,\n [BtcScope.Testnet]: false,\n [BtcScope.Signet]: false,\n },\n [KnownCaipNamespace.Tron]: {\n [TrxScope.Mainnet]: true,\n [TrxScope.Nile]: false,\n [TrxScope.Shasta]: false,\n },\n },\n // nativeAssetIdentifiers is initialized as empty and should be populated\n // by the client using initNativeAssetIdentifiers() during controller init\n nativeAssetIdentifiers: {},\n });\n\n// Metadata for the controller state\nconst metadata = {\n enabledNetworkMap: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n nativeAssetIdentifiers: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n};\n\n/**\n * Controller responsible for managing network enablement state across different blockchain networks.\n *\n * This controller tracks which networks are enabled/disabled for the user and provides methods\n * to toggle network states. It supports both EVM (EIP-155) and non-EVM networks like Solana.\n *\n * The controller maintains a map of enabled networks organized by namespace (e.g., 'eip155', 'solana')\n * and provides methods to query and modify network enablement states.\n */\nexport class NetworkEnablementController extends BaseController<\n typeof controllerName,\n NetworkEnablementControllerState,\n NetworkEnablementControllerMessenger\n> {\n /**\n * Creates a NetworkEnablementController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with BaseV2 controller.\n * @param args.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: NetworkEnablementControllerMessenger;\n state?: Partial<NetworkEnablementControllerState>;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: {\n ...getDefaultNetworkEnablementControllerState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'NetworkController:networkAdded',\n ({ chainId, nativeCurrency }) => {\n this.#onAddNetwork(chainId, nativeCurrency);\n },\n );\n\n messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {\n this.#removeNetworkEntry(chainId);\n });\n\n messenger.subscribe(\n 'NetworkController:stateChange',\n (_newState, patches) => {\n this.#onNetworkControllerStateChange(patches);\n },\n );\n }\n\n /**\n * Handles NetworkController state changes to detect symbol updates.\n *\n * @param patches - The patches describing what changed\n */\n #onNetworkControllerStateChange(\n patches: { op: string; path: (string | number)[]; value?: unknown }[],\n ): void {\n // Look for patches that replace a network configuration\n // Path format: ['networkConfigurationsByChainId', chainId]\n for (const patch of patches) {\n if (\n patch.path.length === 2 &&\n patch.path[0] === 'networkConfigurationsByChainId' &&\n patch.op === 'replace' &&\n patch.value &&\n typeof patch.value === 'object' &&\n 'nativeCurrency' in patch.value\n ) {\n const chainId = patch.path[1] as Hex;\n const networkConfig = patch.value as { nativeCurrency: string };\n this.#updateNativeAssetIdentifier(\n chainId,\n networkConfig.nativeCurrency,\n );\n }\n }\n }\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 */\n enableNetwork(chainId: Hex | CaipChainId): void {\n const { namespace, storageKey } = deriveKeys(chainId);\n\n this.update((state) => {\n // disable all networks in all namespaces first\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // if the namespace bucket does not exist, return\n // new nemespace are added only when a new network is added\n if (!state.enabledNetworkMap[namespace]) {\n return;\n }\n\n // enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableNetworkInNamespace(\n chainId: Hex | CaipChainId,\n namespace: CaipNamespace,\n ): void {\n const { namespace: derivedNamespace, storageKey } = deriveKeys(chainId);\n\n // Validate that the derived namespace matches the provided namespace\n if (derivedNamespace !== namespace) {\n throw new Error(\n `Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`,\n );\n }\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Disable all networks in the specified namespace first\n if (state.enabledNetworkMap[namespace]) {\n Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {\n state.enabledNetworkMap[namespace][key as CaipChainId | Hex] = false;\n });\n }\n\n // Enable the target network in the specified namespace\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableAllPopularNetworks(): void {\n this.update((state) => {\n // First disable all networks across all namespaces\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // Get current network configurations to check if networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Enable all popular EVM networks that exist in NetworkController configurations\n POPULAR_NETWORKS.forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n\n // Check if network exists in NetworkController configurations\n if (\n networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n // Enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n });\n\n // Enable Solana mainnet if it exists in MultichainNetworkController configurations\n const solanaKeys = deriveKeys(SolScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n SolScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, solanaKeys.namespace);\n // Enable Solana mainnet\n state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =\n true;\n }\n\n // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations\n const bitcoinKeys = deriveKeys(BtcScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n BtcScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, bitcoinKeys.namespace);\n // Enable Bitcoin mainnet\n state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =\n true;\n }\n\n // Enable Tron mainnet if it exists in MultichainNetworkController configurations\n const tronKeys = deriveKeys(TrxScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n TrxScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, tronKeys.namespace);\n // Enable Tron mainnet\n state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;\n }\n });\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 */\n init(): void {\n this.update((state) => {\n // Get network configurations from NetworkController (EVM networks)\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Get network configurations from MultichainNetworkController (all networks)\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Initialize namespace buckets for EVM networks from NetworkController\n Object.entries(\n networkControllerState.networkConfigurationsByChainId,\n ).forEach(([chainId, config]) => {\n const { namespace, storageKey, caipChainId } = deriveKeys(\n chainId as Hex,\n );\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n\n // Sync nativeAssetIdentifiers using the nativeCurrency symbol\n if (state.nativeAssetIdentifiers[caipChainId] === undefined) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(\n config.nativeCurrency,\n );\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] =\n buildNativeAssetIdentifier(caipChainId, slip44CoinType);\n }\n }\n });\n\n // Initialize namespace buckets for all networks from MultichainNetworkController\n Object.keys(\n multichainState.multichainNetworkConfigurationsByChainId,\n ).forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as CaipChainId);\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n });\n });\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 */\n disableNetwork(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n\n this.update((state) => {\n state.enabledNetworkMap[namespace][storageKey] = false;\n });\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 */\n isNetworkEnabled(chainId: Hex | CaipChainId): boolean {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;\n }\n\n /**\n * Ensures that a namespace bucket exists in the state.\n *\n * This method creates the namespace entry in the enabledNetworkMap if it doesn't\n * already exist. This is used to prepare the state structure before adding\n * network entries.\n *\n * @param state - The current controller state\n * @param ns - The CAIP namespace to ensure exists\n */\n #ensureNamespaceBucket(\n state: NetworkEnablementControllerState,\n ns: CaipNamespace,\n ): void {\n if (!state.enabledNetworkMap[ns]) {\n state.enabledNetworkMap[ns] = {};\n }\n }\n\n /**\n * Updates the native asset identifier for a network based on its symbol.\n *\n * This method looks up the SLIP-44 coin type for the given symbol using the\n * Slip44Service and updates the nativeAssetIdentifiers state with the full\n * CAIP-19-like identifier.\n *\n * @param chainId - The chain ID of the network (Hex or CAIP-2 format)\n * @param symbol - The native currency symbol of the network (e.g., 'ETH', 'BTC')\n */\n #updateNativeAssetIdentifier(\n chainId: Hex | CaipChainId,\n symbol: string,\n ): void {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(symbol);\n const { caipChainId } = deriveKeys(chainId);\n\n this.update((state) => {\n if (slip44CoinType === undefined) {\n // Remove the entry if no SLIP-44 mapping exists for the symbol\n delete state.nativeAssetIdentifiers[caipChainId];\n return;\n }\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n });\n }\n\n /**\n * Checks if popular networks mode is active (more than 2 popular networks enabled).\n *\n * This method counts how many networks defined in POPULAR_NETWORKS are currently\n * enabled in the state and returns true if more than 2 are enabled. It only checks\n * networks that actually exist in the NetworkController configurations.\n *\n * @returns True if more than 2 popular networks are enabled, false otherwise\n */\n #isInPopularNetworksMode(): boolean {\n // Get current network configurations to check which popular networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Count how many popular networks are enabled\n const enabledPopularNetworksCount = POPULAR_NETWORKS.reduce(\n (count, chainId) => {\n // Only check networks that actually exist in NetworkController configurations\n if (\n !networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n return count; // Skip networks that don't exist\n }\n\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n const isEnabled = this.state.enabledNetworkMap[namespace]?.[storageKey];\n return isEnabled ? count + 1 : count;\n },\n 0,\n );\n\n // Return true if more than 2 popular networks are enabled\n return enabledPopularNetworksCount > 1;\n }\n\n /**\n * Removes a network entry from the state.\n *\n * This method is called when a network is removed from the system. It cleans up\n * the network entry from both enabledNetworkMap and nativeAssetIdentifiers, and ensures that\n * at least one network remains enabled.\n *\n * @param chainId - The chain ID to remove (Hex or CAIP-2 format)\n */\n #removeNetworkEntry(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey, caipChainId } = derivedKeys;\n\n this.update((state) => {\n // fallback and enable ethereum mainnet\n if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {\n state.enabledNetworkMap[namespace][\n ChainId[BuiltInNetworkName.Mainnet]\n ] = true;\n }\n\n if (namespace in state.enabledNetworkMap) {\n delete state.enabledNetworkMap[namespace][storageKey];\n }\n\n // Remove from nativeAssetIdentifiers as well\n delete state.nativeAssetIdentifiers[caipChainId];\n });\n }\n\n /**\n * Handles the addition of a new network to the controller.\n *\n * @param chainId - The chain ID to add (Hex or CAIP-2 format)\n * @param nativeCurrency - The native currency symbol of the network (e.g., 'ETH')\n *\n * @description\n * - If in popular networks mode (>2 popular networks enabled) AND adding a popular network:\n * - Keep current selection (add but don't enable the new network)\n * - Otherwise:\n * - Switch to the newly added network (disable all others, enable this one)\n * - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier\n */\n #onAddNetwork(chainId: Hex | CaipChainId, nativeCurrency: string): void {\n const { namespace, storageKey, reference, caipChainId } =\n deriveKeys(chainId);\n\n // Look up the SLIP-44 coin type for the native currency\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Check if popular networks mode is active (>2 popular networks enabled)\n const inPopularNetworksMode = this.#isInPopularNetworksMode();\n\n // Check if the network being added is a popular network\n const isAddedNetworkPopular = isPopularNetwork(reference);\n\n // Keep current selection only if in popular networks mode AND adding a popular network\n const shouldKeepCurrentSelection =\n inPopularNetworksMode && isAddedNetworkPopular;\n\n if (shouldKeepCurrentSelection) {\n // Add the popular network but don't enable it (keep current selection)\n state.enabledNetworkMap[namespace][storageKey] = true;\n } else {\n // Switch to the newly added network (disable all others, enable this one)\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n // Enable the newly added network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n\n // Update nativeAssetIdentifiers with the CAIP-19-like identifier\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n }\n });\n }\n}\n"]}
1
+ {"version":3,"file":"NetworkEnablementController.mjs","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAK3D,OAAO,EAAE,kBAAkB,EAAE,OAAO,EAAE,mCAAmC;AACzE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,8BAA8B;AAWrE,OAAO,EAAE,kBAAkB,EAAE,wBAAwB;AAErD,OAAO,EAAE,gBAAgB,EAAE,wBAAoB;AAC/C,OAAO,EAAE,aAAa,EAAE,6BAAmB;AAC3C,OAAO,EACL,UAAU,EACV,+BAA+B,EAC/B,gBAAgB,EACjB,oBAAgB;AAEjB,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAmGrD;;;;;;GAMG;AACH,SAAS,0BAA0B,CACjC,WAAwB,EACxB,cAAsB;IAEtB,OAAO,GAAG,WAAW,WAAW,cAAc,EAAE,CAAC;AACnD,CAAC;AAWD;;;;GAIG;AACH,MAAM,0CAA0C,GAC9C,GAAqC,EAAE,CAAC,CAAC;IACvC,iBAAiB,EAAE;QACjB,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE;YAC3B,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI;YAC3C,CAAC,OAAO,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI;YAChD,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI;YAC/C,CAAC,OAAO,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI;YAC/C,CAAC,OAAO,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,EAAE,IAAI;YAC9C,CAAC,OAAO,CAAC,kBAAkB,CAAC,eAAe,CAAC,CAAC,EAAE,IAAI;YACnD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CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;QACxD,CAAC;QAED,iEAAiE;QACjE,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,KAAK,CAAC,sBAAsB,CAAC,WAAW,CAAC,GAAG,0BAA0B,CACpE,WAAW,EACX,cAAc,CACf,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { BaseController } from '@metamask/base-controller';\nimport type {\n ControllerGetStateAction,\n ControllerStateChangeEvent,\n} from '@metamask/base-controller';\nimport { BuiltInNetworkName, ChainId } from '@metamask/controller-utils';\nimport { BtcScope, SolScope, TrxScope } from '@metamask/keyring-api';\nimport type { Messenger } from '@metamask/messenger';\nimport type { MultichainNetworkControllerGetStateAction } from '@metamask/multichain-network-controller';\nimport type {\n NetworkControllerGetStateAction,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerStateChangeEvent,\n} from '@metamask/network-controller';\nimport type { TransactionControllerTransactionSubmittedEvent } from '@metamask/transaction-controller';\nimport type { CaipChainId, CaipNamespace, Hex } from '@metamask/utils';\nimport { KnownCaipNamespace } from '@metamask/utils';\n\nimport { POPULAR_NETWORKS } from './constants';\nimport { Slip44Service } from './services';\nimport {\n deriveKeys,\n isOnlyNetworkEnabledInNamespace,\n isPopularNetwork,\n} from './utils';\n\nconst controllerName = 'NetworkEnablementController';\n\n/**\n * Information about an ordered network.\n */\nexport type NetworksInfo = {\n /**\n * The network's chain id\n */\n networkId: CaipChainId;\n};\n\n/**\n * A map of enabled networks by CAIP namespace and chain ID.\n * For EIP-155 networks, the keys are Hex chain IDs.\n * For other networks, the keys are CAIP chain IDs.\n */\ntype EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;\n\n/**\n * A native asset identifier in CAIP-19-like format.\n * Format: `{caip2ChainId}/slip44:{coinType}`\n *\n * @example\n * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)\n * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)\n * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)\n */\nexport type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;\n\n/**\n * A map of CAIP-2 chain IDs to their native asset identifiers.\n * Uses CAIP-19-like format to identify the native asset for each chain.\n *\n * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md\n */\nexport type NativeAssetIdentifiersMap = Record<\n CaipChainId,\n NativeAssetIdentifier\n>;\n\n// State shape for NetworkEnablementController\nexport type NetworkEnablementControllerState = {\n enabledNetworkMap: EnabledMap;\n nativeAssetIdentifiers: NativeAssetIdentifiersMap;\n};\n\nexport type NetworkEnablementControllerGetStateAction =\n ControllerGetStateAction<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerSetEnabledNetworksAction = {\n type: `${typeof controllerName}:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `${typeof controllerName}:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * All actions that {@link NetworkEnablementController} calls internally.\n */\nexport type AllowedActions =\n | NetworkControllerGetStateAction\n | MultichainNetworkControllerGetStateAction;\n\nexport type NetworkEnablementControllerActions =\n | NetworkEnablementControllerGetStateAction\n | NetworkEnablementControllerSetEnabledNetworksAction\n | NetworkEnablementControllerDisableNetworkAction;\n\nexport type NetworkEnablementControllerStateChangeEvent =\n ControllerStateChangeEvent<\n typeof controllerName,\n NetworkEnablementControllerState\n >;\n\nexport type NetworkEnablementControllerEvents =\n NetworkEnablementControllerStateChangeEvent;\n\n/**\n * All events that {@link NetworkEnablementController} subscribes to internally.\n */\nexport type AllowedEvents =\n | NetworkControllerNetworkAddedEvent\n | NetworkControllerNetworkRemovedEvent\n | NetworkControllerStateChangeEvent\n | TransactionControllerTransactionSubmittedEvent;\n\nexport type NetworkEnablementControllerMessenger = Messenger<\n typeof controllerName,\n NetworkEnablementControllerActions | AllowedActions,\n NetworkEnablementControllerEvents | AllowedEvents\n>;\n\n/**\n * Builds a native asset identifier in CAIP-19-like format.\n *\n * @param caipChainId - The CAIP-2 chain ID (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')\n * @param slip44CoinType - The SLIP-44 coin type number\n * @returns The native asset identifier string (e.g., 'eip155:1/slip44:60')\n */\nfunction buildNativeAssetIdentifier(\n caipChainId: CaipChainId,\n slip44CoinType: number,\n): NativeAssetIdentifier {\n return `${caipChainId}/slip44:${slip44CoinType}`;\n}\n\n/**\n * Network configuration with chain ID and native currency symbol.\n * Used to initialize native asset identifiers.\n */\nexport type NetworkConfig = {\n chainId: CaipChainId;\n nativeCurrency: string;\n};\n\n/**\n * Gets the default state for the NetworkEnablementController.\n *\n * @returns The default state with pre-enabled networks.\n */\nconst getDefaultNetworkEnablementControllerState =\n (): NetworkEnablementControllerState => ({\n enabledNetworkMap: {\n [KnownCaipNamespace.Eip155]: {\n [ChainId[BuiltInNetworkName.Mainnet]]: true,\n [ChainId[BuiltInNetworkName.LineaMainnet]]: true,\n [ChainId[BuiltInNetworkName.BaseMainnet]]: true,\n [ChainId[BuiltInNetworkName.ArbitrumOne]]: true,\n [ChainId[BuiltInNetworkName.BscMainnet]]: true,\n [ChainId[BuiltInNetworkName.OptimismMainnet]]: true,\n [ChainId[BuiltInNetworkName.PolygonMainnet]]: true,\n [ChainId[BuiltInNetworkName.SeiMainnet]]: true,\n },\n [KnownCaipNamespace.Solana]: {\n [SolScope.Mainnet]: true,\n [SolScope.Testnet]: false,\n [SolScope.Devnet]: false,\n },\n [KnownCaipNamespace.Bip122]: {\n [BtcScope.Mainnet]: true,\n [BtcScope.Testnet]: false,\n [BtcScope.Signet]: false,\n },\n [KnownCaipNamespace.Tron]: {\n [TrxScope.Mainnet]: true,\n [TrxScope.Nile]: false,\n [TrxScope.Shasta]: false,\n },\n },\n // nativeAssetIdentifiers is initialized as empty and should be populated\n // by the client using initNativeAssetIdentifiers() during controller init\n nativeAssetIdentifiers: {},\n });\n\n// Metadata for the controller state\nconst metadata = {\n enabledNetworkMap: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n nativeAssetIdentifiers: {\n includeInStateLogs: true,\n persist: true,\n includeInDebugSnapshot: true,\n usedInUi: true,\n },\n};\n\n/**\n * Controller responsible for managing network enablement state across different blockchain networks.\n *\n * This controller tracks which networks are enabled/disabled for the user and provides methods\n * to toggle network states. It supports both EVM (EIP-155) and non-EVM networks like Solana.\n *\n * The controller maintains a map of enabled networks organized by namespace (e.g., 'eip155', 'solana')\n * and provides methods to query and modify network enablement states.\n */\nexport class NetworkEnablementController extends BaseController<\n typeof controllerName,\n NetworkEnablementControllerState,\n NetworkEnablementControllerMessenger\n> {\n /**\n * Creates a NetworkEnablementController instance.\n *\n * @param args - The arguments to this function.\n * @param args.messenger - Messenger used to communicate with BaseV2 controller.\n * @param args.state - Initial state to set on this controller.\n */\n constructor({\n messenger,\n state,\n }: {\n messenger: NetworkEnablementControllerMessenger;\n state?: Partial<NetworkEnablementControllerState>;\n }) {\n super({\n messenger,\n metadata,\n name: controllerName,\n state: {\n ...getDefaultNetworkEnablementControllerState(),\n ...state,\n },\n });\n\n messenger.subscribe(\n 'NetworkController:networkAdded',\n ({ chainId, nativeCurrency }) => {\n this.#onAddNetwork(chainId, nativeCurrency);\n },\n );\n\n messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {\n this.#removeNetworkEntry(chainId);\n });\n\n messenger.subscribe(\n 'NetworkController:stateChange',\n (_newState, patches) => {\n this.#onNetworkControllerStateChange(patches);\n },\n );\n }\n\n /**\n * Handles NetworkController state changes to detect symbol updates.\n *\n * @param patches - The patches describing what changed\n */\n #onNetworkControllerStateChange(\n patches: { op: string; path: (string | number)[]; value?: unknown }[],\n ): void {\n // Look for patches that replace a network configuration\n // Path format: ['networkConfigurationsByChainId', chainId]\n for (const patch of patches) {\n if (\n patch.path.length === 2 &&\n patch.path[0] === 'networkConfigurationsByChainId' &&\n patch.op === 'replace' &&\n patch.value &&\n typeof patch.value === 'object' &&\n 'nativeCurrency' in patch.value\n ) {\n const chainId = patch.path[1] as Hex;\n const networkConfig = patch.value as { nativeCurrency: string };\n this.#updateNativeAssetIdentifier(\n chainId,\n networkConfig.nativeCurrency,\n );\n }\n }\n }\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 */\n enableNetwork(chainId: Hex | CaipChainId): void {\n const { namespace, storageKey } = deriveKeys(chainId);\n\n this.update((state) => {\n // disable all networks in all namespaces first\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // if the namespace bucket does not exist, return\n // new nemespace are added only when a new network is added\n if (!state.enabledNetworkMap[namespace]) {\n return;\n }\n\n // enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableNetworkInNamespace(\n chainId: Hex | CaipChainId,\n namespace: CaipNamespace,\n ): void {\n const { namespace: derivedNamespace, storageKey } = deriveKeys(chainId);\n\n // Validate that the derived namespace matches the provided namespace\n if (derivedNamespace !== namespace) {\n throw new Error(\n `Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`,\n );\n }\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Disable all networks in the specified namespace first\n if (state.enabledNetworkMap[namespace]) {\n Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {\n state.enabledNetworkMap[namespace][key as CaipChainId | Hex] = false;\n });\n }\n\n // Enable the target network in the specified namespace\n state.enabledNetworkMap[namespace][storageKey] = true;\n });\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 */\n enableAllPopularNetworks(): void {\n this.update((state) => {\n // First disable all networks across all namespaces\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n\n // Get current network configurations to check if networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Enable all popular EVM networks that exist in NetworkController configurations\n POPULAR_NETWORKS.forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n\n // Check if network exists in NetworkController configurations\n if (\n networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n // Enable the network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n });\n\n // Enable Solana mainnet if it exists in MultichainNetworkController configurations\n const solanaKeys = deriveKeys(SolScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n SolScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, solanaKeys.namespace);\n // Enable Solana mainnet\n state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =\n true;\n }\n\n // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations\n const bitcoinKeys = deriveKeys(BtcScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n BtcScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, bitcoinKeys.namespace);\n // Enable Bitcoin mainnet\n state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =\n true;\n }\n\n // Enable Tron mainnet if it exists in MultichainNetworkController configurations\n const tronKeys = deriveKeys(TrxScope.Mainnet as CaipChainId);\n if (\n multichainState.multichainNetworkConfigurationsByChainId[\n TrxScope.Mainnet\n ]\n ) {\n // Ensure namespace bucket exists\n this.#ensureNamespaceBucket(state, tronKeys.namespace);\n // Enable Tron mainnet\n state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;\n }\n });\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 */\n init(): void {\n this.update((state) => {\n // Get network configurations from NetworkController (EVM networks)\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Get network configurations from MultichainNetworkController (all networks)\n const multichainState = this.messenger.call(\n 'MultichainNetworkController:getState',\n );\n\n // Initialize namespace buckets for EVM networks from NetworkController\n Object.entries(\n networkControllerState.networkConfigurationsByChainId,\n ).forEach(([chainId, config]) => {\n const { namespace, storageKey, caipChainId } = deriveKeys(\n chainId as Hex,\n );\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n\n // Sync nativeAssetIdentifiers using the nativeCurrency symbol\n if (state.nativeAssetIdentifiers[caipChainId] === undefined) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(\n config.nativeCurrency,\n );\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] =\n buildNativeAssetIdentifier(caipChainId, slip44CoinType);\n }\n }\n });\n\n // Initialize namespace buckets for all networks from MultichainNetworkController\n Object.keys(\n multichainState.multichainNetworkConfigurationsByChainId,\n ).forEach((chainId) => {\n const { namespace, storageKey } = deriveKeys(chainId as CaipChainId);\n this.#ensureNamespaceBucket(state, namespace);\n\n // Only add network if it doesn't already exist in state (preserves user settings)\n state.enabledNetworkMap[namespace][storageKey] ??= false;\n });\n });\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 * controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\n initNativeAssetIdentifiers(networks: NetworkConfig[]): void {\n this.update((state) => {\n for (const { chainId, nativeCurrency } of networks) {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[chainId] = buildNativeAssetIdentifier(\n chainId,\n slip44CoinType,\n );\n }\n }\n });\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 */\n disableNetwork(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n\n this.update((state) => {\n state.enabledNetworkMap[namespace][storageKey] = false;\n });\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 */\n isNetworkEnabled(chainId: Hex | CaipChainId): boolean {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey } = derivedKeys;\n return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;\n }\n\n /**\n * Ensures that a namespace bucket exists in the state.\n *\n * This method creates the namespace entry in the enabledNetworkMap if it doesn't\n * already exist. This is used to prepare the state structure before adding\n * network entries.\n *\n * @param state - The current controller state\n * @param ns - The CAIP namespace to ensure exists\n */\n #ensureNamespaceBucket(\n state: NetworkEnablementControllerState,\n ns: CaipNamespace,\n ): void {\n if (!state.enabledNetworkMap[ns]) {\n state.enabledNetworkMap[ns] = {};\n }\n }\n\n /**\n * Updates the native asset identifier for a network based on its symbol.\n *\n * This method looks up the SLIP-44 coin type for the given symbol using the\n * Slip44Service and updates the nativeAssetIdentifiers state with the full\n * CAIP-19-like identifier.\n *\n * @param chainId - The chain ID of the network (Hex or CAIP-2 format)\n * @param symbol - The native currency symbol of the network (e.g., 'ETH', 'BTC')\n */\n #updateNativeAssetIdentifier(\n chainId: Hex | CaipChainId,\n symbol: string,\n ): void {\n const slip44CoinType = Slip44Service.getSlip44BySymbol(symbol);\n const { caipChainId } = deriveKeys(chainId);\n\n this.update((state) => {\n if (slip44CoinType === undefined) {\n // Remove the entry if no SLIP-44 mapping exists for the symbol\n delete state.nativeAssetIdentifiers[caipChainId];\n return;\n }\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n });\n }\n\n /**\n * Checks if popular networks mode is active (more than 2 popular networks enabled).\n *\n * This method counts how many networks defined in POPULAR_NETWORKS are currently\n * enabled in the state and returns true if more than 2 are enabled. It only checks\n * networks that actually exist in the NetworkController configurations.\n *\n * @returns True if more than 2 popular networks are enabled, false otherwise\n */\n #isInPopularNetworksMode(): boolean {\n // Get current network configurations to check which popular networks exist\n const networkControllerState = this.messenger.call(\n 'NetworkController:getState',\n );\n\n // Count how many popular networks are enabled\n const enabledPopularNetworksCount = POPULAR_NETWORKS.reduce(\n (count, chainId) => {\n // Only check networks that actually exist in NetworkController configurations\n if (\n !networkControllerState.networkConfigurationsByChainId[chainId as Hex]\n ) {\n return count; // Skip networks that don't exist\n }\n\n const { namespace, storageKey } = deriveKeys(chainId as Hex);\n const isEnabled = this.state.enabledNetworkMap[namespace]?.[storageKey];\n return isEnabled ? count + 1 : count;\n },\n 0,\n );\n\n // Return true if more than 2 popular networks are enabled\n return enabledPopularNetworksCount > 1;\n }\n\n /**\n * Removes a network entry from the state.\n *\n * This method is called when a network is removed from the system. It cleans up\n * the network entry from both enabledNetworkMap and nativeAssetIdentifiers, and ensures that\n * at least one network remains enabled.\n *\n * @param chainId - The chain ID to remove (Hex or CAIP-2 format)\n */\n #removeNetworkEntry(chainId: Hex | CaipChainId): void {\n const derivedKeys = deriveKeys(chainId);\n const { namespace, storageKey, caipChainId } = derivedKeys;\n\n this.update((state) => {\n // fallback and enable ethereum mainnet\n if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {\n state.enabledNetworkMap[namespace][\n ChainId[BuiltInNetworkName.Mainnet]\n ] = true;\n }\n\n if (namespace in state.enabledNetworkMap) {\n delete state.enabledNetworkMap[namespace][storageKey];\n }\n\n // Remove from nativeAssetIdentifiers as well\n delete state.nativeAssetIdentifiers[caipChainId];\n });\n }\n\n /**\n * Handles the addition of a new network to the controller.\n *\n * @param chainId - The chain ID to add (Hex or CAIP-2 format)\n * @param nativeCurrency - The native currency symbol of the network (e.g., 'ETH')\n *\n * @description\n * - If in popular networks mode (>2 popular networks enabled) AND adding a popular network:\n * - Keep current selection (add but don't enable the new network)\n * - Otherwise:\n * - Switch to the newly added network (disable all others, enable this one)\n * - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier\n */\n #onAddNetwork(chainId: Hex | CaipChainId, nativeCurrency: string): void {\n const { namespace, storageKey, reference, caipChainId } =\n deriveKeys(chainId);\n\n // Look up the SLIP-44 coin type for the native currency\n const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);\n\n this.update((state) => {\n // Ensure the namespace bucket exists\n this.#ensureNamespaceBucket(state, namespace);\n\n // Check if popular networks mode is active (>2 popular networks enabled)\n const inPopularNetworksMode = this.#isInPopularNetworksMode();\n\n // Check if the network being added is a popular network\n const isAddedNetworkPopular = isPopularNetwork(reference);\n\n // Keep current selection only if in popular networks mode AND adding a popular network\n const shouldKeepCurrentSelection =\n inPopularNetworksMode && isAddedNetworkPopular;\n\n if (shouldKeepCurrentSelection) {\n // Add the popular network but don't enable it (keep current selection)\n state.enabledNetworkMap[namespace][storageKey] = true;\n } else {\n // Switch to the newly added network (disable all others, enable this one)\n Object.keys(state.enabledNetworkMap).forEach((ns) => {\n Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {\n state.enabledNetworkMap[ns][key as CaipChainId | Hex] = false;\n });\n });\n // Enable the newly added network\n state.enabledNetworkMap[namespace][storageKey] = true;\n }\n\n // Update nativeAssetIdentifiers with the CAIP-19-like identifier\n if (slip44CoinType !== undefined) {\n state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(\n caipChainId,\n slip44CoinType,\n );\n }\n });\n }\n}\n"]}
package/dist/index.cjs CHANGED
@@ -1,9 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Slip44Service = exports.selectEnabledSolanaNetworks = exports.selectEnabledEvmNetworks = exports.selectEnabledNetworksCount = exports.selectAllEnabledNetworks = exports.createSelectorForEnabledNetworksForNamespace = exports.selectIsNetworkEnabled = exports.selectEnabledNetworkMap = exports.initNativeAssetIdentifiers = exports.NetworkEnablementController = void 0;
3
+ exports.Slip44Service = exports.selectEnabledSolanaNetworks = exports.selectEnabledEvmNetworks = exports.selectEnabledNetworksCount = exports.selectAllEnabledNetworks = exports.createSelectorForEnabledNetworksForNamespace = exports.selectIsNetworkEnabled = exports.selectEnabledNetworkMap = exports.NetworkEnablementController = void 0;
4
4
  var NetworkEnablementController_1 = require("./NetworkEnablementController.cjs");
5
5
  Object.defineProperty(exports, "NetworkEnablementController", { enumerable: true, get: function () { return NetworkEnablementController_1.NetworkEnablementController; } });
6
- Object.defineProperty(exports, "initNativeAssetIdentifiers", { enumerable: true, get: function () { return NetworkEnablementController_1.initNativeAssetIdentifiers; } });
7
6
  var selectors_1 = require("./selectors.cjs");
8
7
  Object.defineProperty(exports, "selectEnabledNetworkMap", { enumerable: true, get: function () { return selectors_1.selectEnabledNetworkMap; } });
9
8
  Object.defineProperty(exports, "selectIsNetworkEnabled", { enumerable: true, get: function () { return selectors_1.selectIsNetworkEnabled; } });
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iFAGuC;AAFrC,0IAAA,2BAA2B,OAAA;AAC3B,yIAAA,0BAA0B,OAAA;AAc5B,6CAQqB;AAPnB,oHAAA,uBAAuB,OAAA;AACvB,mHAAA,sBAAsB,OAAA;AACtB,yIAAA,4CAA4C,OAAA;AAC5C,qHAAA,wBAAwB,OAAA;AACxB,uHAAA,0BAA0B,OAAA;AAC1B,qHAAA,wBAAwB,OAAA;AACxB,wHAAA,2BAA2B,OAAA;AAG7B,iDAA2C;AAAlC,yGAAA,aAAa,OAAA","sourcesContent":["export {\n NetworkEnablementController,\n initNativeAssetIdentifiers,\n} from './NetworkEnablementController';\n\nexport type {\n NetworkEnablementControllerState,\n NetworkEnablementControllerGetStateAction,\n NetworkEnablementControllerActions,\n NetworkEnablementControllerEvents,\n NetworkEnablementControllerMessenger,\n NativeAssetIdentifier,\n NativeAssetIdentifiersMap,\n NetworkConfig,\n} from './NetworkEnablementController';\n\nexport {\n selectEnabledNetworkMap,\n selectIsNetworkEnabled,\n createSelectorForEnabledNetworksForNamespace,\n selectAllEnabledNetworks,\n selectEnabledNetworksCount,\n selectEnabledEvmNetworks,\n selectEnabledSolanaNetworks,\n} from './selectors';\n\nexport { Slip44Service } from './services';\nexport type { Slip44Entry } from './services';\n"]}
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iFAA4E;AAAnE,0IAAA,2BAA2B,OAAA;AAapC,6CAQqB;AAPnB,oHAAA,uBAAuB,OAAA;AACvB,mHAAA,sBAAsB,OAAA;AACtB,yIAAA,4CAA4C,OAAA;AAC5C,qHAAA,wBAAwB,OAAA;AACxB,uHAAA,0BAA0B,OAAA;AAC1B,qHAAA,wBAAwB,OAAA;AACxB,wHAAA,2BAA2B,OAAA;AAG7B,iDAA2C;AAAlC,yGAAA,aAAa,OAAA","sourcesContent":["export { NetworkEnablementController } from './NetworkEnablementController';\n\nexport type {\n NetworkEnablementControllerState,\n NetworkEnablementControllerGetStateAction,\n NetworkEnablementControllerActions,\n NetworkEnablementControllerEvents,\n NetworkEnablementControllerMessenger,\n NativeAssetIdentifier,\n NativeAssetIdentifiersMap,\n NetworkConfig,\n} from './NetworkEnablementController';\n\nexport {\n selectEnabledNetworkMap,\n selectIsNetworkEnabled,\n createSelectorForEnabledNetworksForNamespace,\n selectAllEnabledNetworks,\n selectEnabledNetworksCount,\n selectEnabledEvmNetworks,\n selectEnabledSolanaNetworks,\n} from './selectors';\n\nexport { Slip44Service } from './services';\nexport type { Slip44Entry } from './services';\n"]}
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { NetworkEnablementController, initNativeAssetIdentifiers, } from "./NetworkEnablementController.cjs";
1
+ export { NetworkEnablementController } from "./NetworkEnablementController.cjs";
2
2
  export type { NetworkEnablementControllerState, NetworkEnablementControllerGetStateAction, NetworkEnablementControllerActions, NetworkEnablementControllerEvents, NetworkEnablementControllerMessenger, NativeAssetIdentifier, NativeAssetIdentifiersMap, NetworkConfig, } from "./NetworkEnablementController.cjs";
3
3
  export { selectEnabledNetworkMap, selectIsNetworkEnabled, createSelectorForEnabledNetworksForNamespace, selectAllEnabledNetworks, selectEnabledNetworksCount, selectEnabledEvmNetworks, selectEnabledSolanaNetworks, } from "./selectors.cjs";
4
4
  export { Slip44Service } from "./services/index.cjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,0CAAsC;AAEvC,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,GACd,0CAAsC;AAEvC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,GAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB;AAC3C,YAAY,EAAE,WAAW,EAAE,6BAAmB"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,0CAAsC;AAE5E,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,GACd,0CAAsC;AAEvC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,GAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB;AAC3C,YAAY,EAAE,WAAW,EAAE,6BAAmB"}
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { NetworkEnablementController, initNativeAssetIdentifiers, } from "./NetworkEnablementController.mjs";
1
+ export { NetworkEnablementController } from "./NetworkEnablementController.mjs";
2
2
  export type { NetworkEnablementControllerState, NetworkEnablementControllerGetStateAction, NetworkEnablementControllerActions, NetworkEnablementControllerEvents, NetworkEnablementControllerMessenger, NativeAssetIdentifier, NativeAssetIdentifiersMap, NetworkConfig, } from "./NetworkEnablementController.mjs";
3
3
  export { selectEnabledNetworkMap, selectIsNetworkEnabled, createSelectorForEnabledNetworksForNamespace, selectAllEnabledNetworks, selectEnabledNetworksCount, selectEnabledEvmNetworks, selectEnabledSolanaNetworks, } from "./selectors.mjs";
4
4
  export { Slip44Service } from "./services/index.mjs";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,GAC3B,0CAAsC;AAEvC,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,GACd,0CAAsC;AAEvC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,GAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB;AAC3C,YAAY,EAAE,WAAW,EAAE,6BAAmB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,0CAAsC;AAE5E,YAAY,EACV,gCAAgC,EAChC,yCAAyC,EACzC,kCAAkC,EAClC,iCAAiC,EACjC,oCAAoC,EACpC,qBAAqB,EACrB,yBAAyB,EACzB,aAAa,GACd,0CAAsC;AAEvC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,GAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB;AAC3C,YAAY,EAAE,WAAW,EAAE,6BAAmB"}
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { NetworkEnablementController, initNativeAssetIdentifiers } from "./NetworkEnablementController.mjs";
1
+ export { NetworkEnablementController } from "./NetworkEnablementController.mjs";
2
2
  export { selectEnabledNetworkMap, selectIsNetworkEnabled, createSelectorForEnabledNetworksForNamespace, selectAllEnabledNetworks, selectEnabledNetworksCount, selectEnabledEvmNetworks, selectEnabledSolanaNetworks } from "./selectors.mjs";
3
3
  export { Slip44Service } from "./services/index.mjs";
4
4
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAC3B,0BAA0B,EAC3B,0CAAsC;AAavC,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB","sourcesContent":["export {\n NetworkEnablementController,\n initNativeAssetIdentifiers,\n} from './NetworkEnablementController';\n\nexport type {\n NetworkEnablementControllerState,\n NetworkEnablementControllerGetStateAction,\n NetworkEnablementControllerActions,\n NetworkEnablementControllerEvents,\n NetworkEnablementControllerMessenger,\n NativeAssetIdentifier,\n NativeAssetIdentifiersMap,\n NetworkConfig,\n} from './NetworkEnablementController';\n\nexport {\n selectEnabledNetworkMap,\n selectIsNetworkEnabled,\n createSelectorForEnabledNetworksForNamespace,\n selectAllEnabledNetworks,\n selectEnabledNetworksCount,\n selectEnabledEvmNetworks,\n selectEnabledSolanaNetworks,\n} from './selectors';\n\nexport { Slip44Service } from './services';\nexport type { Slip44Entry } from './services';\n"]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,0CAAsC;AAa5E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,EACtB,4CAA4C,EAC5C,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,2BAA2B,EAC5B,wBAAoB;AAErB,OAAO,EAAE,aAAa,EAAE,6BAAmB","sourcesContent":["export { NetworkEnablementController } from './NetworkEnablementController';\n\nexport type {\n NetworkEnablementControllerState,\n NetworkEnablementControllerGetStateAction,\n NetworkEnablementControllerActions,\n NetworkEnablementControllerEvents,\n NetworkEnablementControllerMessenger,\n NativeAssetIdentifier,\n NativeAssetIdentifiersMap,\n NetworkConfig,\n} from './NetworkEnablementController';\n\nexport {\n selectEnabledNetworkMap,\n selectIsNetworkEnabled,\n createSelectorForEnabledNetworksForNamespace,\n selectAllEnabledNetworks,\n selectEnabledNetworksCount,\n selectEnabledEvmNetworks,\n selectEnabledSolanaNetworks,\n} from './selectors';\n\nexport { Slip44Service } from './services';\nexport type { Slip44Entry } from './services';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/network-enablement-controller",
3
- "version": "4.0.0-preview-e6f8648b",
3
+ "version": "4.0.0-preview-22f11ed5",
4
4
  "description": "Provides an interface to the currently enabled network using a MetaMask-compatible provider object",
5
5
  "keywords": [
6
6
  "MetaMask",