@metamask-previews/network-enablement-controller 6.0.5-preview-8bfa290fb → 7.0.0-preview-0a30e47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -2
- package/dist/{NetworkEnablementController-method-action-types.d.mts → NetworkEnablementController-method-action-types.d.ts} +2 -2
- package/dist/NetworkEnablementController-method-action-types.d.ts.map +1 -0
- package/dist/{NetworkEnablementController-method-action-types.mjs → NetworkEnablementController-method-action-types.js} +1 -1
- package/dist/NetworkEnablementController-method-action-types.js.map +1 -0
- package/dist/{NetworkEnablementController.d.cts → NetworkEnablementController.d.ts} +10 -10
- package/dist/NetworkEnablementController.d.ts.map +1 -0
- package/dist/{NetworkEnablementController.mjs → NetworkEnablementController.js} +167 -131
- package/dist/NetworkEnablementController.js.map +1 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/{constants.mjs → constants.js} +1 -1
- package/dist/constants.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +6 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/{selectors.d.cts → selectors.d.ts} +18 -30
- package/dist/selectors.d.ts.map +1 -0
- package/dist/{selectors.mjs → selectors.js} +4 -4
- package/dist/selectors.js.map +1 -0
- package/dist/services/{Slip44Service.d.cts → Slip44Service.d.ts} +1 -1
- package/dist/services/Slip44Service.d.ts.map +1 -0
- package/dist/services/Slip44Service.js +167 -0
- package/dist/services/Slip44Service.js.map +1 -0
- package/dist/services/{index.d.cts → index.d.ts} +2 -2
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/{index.mjs → index.js} +2 -2
- package/dist/services/index.js.map +1 -0
- package/dist/{utils.d.mts → utils.d.ts} +3 -3
- package/dist/utils.d.ts.map +1 -0
- package/dist/{utils.mjs → utils.js} +4 -4
- package/dist/utils.js.map +1 -0
- package/package.json +19 -23
- package/dist/NetworkEnablementController-method-action-types.cjs +0 -7
- package/dist/NetworkEnablementController-method-action-types.cjs.map +0 -1
- package/dist/NetworkEnablementController-method-action-types.d.cts +0 -185
- package/dist/NetworkEnablementController-method-action-types.d.cts.map +0 -1
- package/dist/NetworkEnablementController-method-action-types.d.mts.map +0 -1
- package/dist/NetworkEnablementController-method-action-types.mjs.map +0 -1
- package/dist/NetworkEnablementController.cjs +0 -590
- package/dist/NetworkEnablementController.cjs.map +0 -1
- package/dist/NetworkEnablementController.d.cts.map +0 -1
- package/dist/NetworkEnablementController.d.mts +0 -234
- package/dist/NetworkEnablementController.d.mts.map +0 -1
- package/dist/NetworkEnablementController.mjs.map +0 -1
- package/dist/constants.cjs +0 -22
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.d.cts +0 -3
- package/dist/constants.d.cts.map +0 -1
- package/dist/constants.d.mts +0 -3
- package/dist/constants.d.mts.map +0 -1
- package/dist/constants.mjs.map +0 -1
- package/dist/index.cjs +0 -18
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts +0 -6
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +0 -1
- package/dist/selectors.cjs +0 -87
- package/dist/selectors.cjs.map +0 -1
- package/dist/selectors.d.cts.map +0 -1
- package/dist/selectors.d.mts +0 -280
- package/dist/selectors.d.mts.map +0 -1
- package/dist/selectors.mjs.map +0 -1
- package/dist/services/Slip44Service.cjs +0 -182
- package/dist/services/Slip44Service.cjs.map +0 -1
- package/dist/services/Slip44Service.d.cts.map +0 -1
- package/dist/services/Slip44Service.d.mts +0 -63
- package/dist/services/Slip44Service.d.mts.map +0 -1
- package/dist/services/Slip44Service.mjs +0 -175
- package/dist/services/Slip44Service.mjs.map +0 -1
- package/dist/services/index.cjs +0 -11
- package/dist/services/index.cjs.map +0 -1
- package/dist/services/index.d.cts.map +0 -1
- package/dist/services/index.d.mts +0 -5
- package/dist/services/index.d.mts.map +0 -1
- package/dist/services/index.mjs.map +0 -1
- package/dist/utils.cjs +0 -62
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.cts +0 -36
- package/dist/utils.d.cts.map +0 -1
- package/dist/utils.d.mts.map +0 -1
- package/dist/utils.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { toHex } from
|
|
2
|
-
import { toEvmCaipChainId } from
|
|
3
|
-
import { isCaipChainId, isHexString, KnownCaipNamespace, parseCaipChainId } from
|
|
1
|
+
import { toHex } from '@metamask/controller-utils';
|
|
2
|
+
import { toEvmCaipChainId } from '@metamask/multichain-network-controller';
|
|
3
|
+
import { isCaipChainId, isHexString, KnownCaipNamespace, parseCaipChainId, } from '@metamask/utils';
|
|
4
4
|
/**
|
|
5
5
|
* Derives the namespace, storage key, and CAIP chain ID from a given chain ID.
|
|
6
6
|
*
|
|
@@ -54,4 +54,4 @@ export function isOnlyNetworkEnabledInNamespace(state, derivedKeys) {
|
|
|
54
54
|
// Return false if there are zero or multiple enabled networks
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
|
-
//# sourceMappingURL=utils.
|
|
57
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAE3E,OAAO,EACL,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AAczB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,UAAU,CAAC,OAA0B;IACnD,MAAM,WAAW,GAAG,aAAa,CAAC,OAAO,CAAC;QACxC,CAAC,CAAC,OAAO;QACT,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAE9B,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,gBAAgB,CAAC,WAAW,CAAC,CAAC;IAC/D,IAAI,UAAU,CAAC;IACf,IAAI,SAAS,KAAM,kBAAkB,CAAC,MAAiB,EAAE,CAAC;QACxD,UAAU,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;SAAM,CAAC;QACN,UAAU,GAAG,WAAW,CAAC;IAC3B,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,+BAA+B,CAC7C,KAAuC,EACvC,WAAwB;IAExB,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,WAAW,CAAC;IAE9C,0CAA0C;IAC1C,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAEpD,6CAA6C;IAC7C,MAAM,eAAe,GAAG,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,CACrD,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,CAC1B,CAAC;IAEF,yEAAyE;IACzE,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,cAAc,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,CAAC;QAC5C,OAAO,cAAc,KAAK,UAAU,CAAC;IACvC,CAAC;IAED,8DAA8D;IAC9D,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { toHex } from '@metamask/controller-utils';\nimport { toEvmCaipChainId } from '@metamask/multichain-network-controller';\nimport type { CaipChainId, CaipNamespace, Hex } from '@metamask/utils';\nimport {\n isCaipChainId,\n isHexString,\n KnownCaipNamespace,\n parseCaipChainId,\n} from '@metamask/utils';\n\nimport type { NetworkEnablementControllerState } from './NetworkEnablementController.js';\n\n/**\n * Represents the parsed keys derived from a chain ID.\n */\nexport type DerivedKeys = {\n namespace: CaipNamespace;\n storageKey: Hex | CaipChainId;\n caipChainId: CaipChainId;\n reference: string;\n};\n\n/**\n * Derives the namespace, storage key, and CAIP chain ID from a given chain ID.\n *\n * This utility function handles the conversion between different chain ID formats.\n * For EVM networks, it converts Hex chain IDs to CAIP-2 format and determines\n * the appropriate storage key. For non-EVM networks, it parses the CAIP-2 chain ID\n * and uses the full chain ID as the storage key.\n *\n * @param chainId - The chain ID to derive keys from (Hex or CAIP-2 format)\n * @returns An object containing namespace, storageKey, and caipId\n * @throws Error if the chain ID cannot be parsed\n */\nexport function deriveKeys(chainId: Hex | CaipChainId): DerivedKeys {\n const caipChainId = isCaipChainId(chainId)\n ? chainId\n : toEvmCaipChainId(chainId);\n\n const { namespace, reference } = parseCaipChainId(caipChainId);\n let storageKey;\n if (namespace === (KnownCaipNamespace.Eip155 as string)) {\n storageKey = isHexString(chainId) ? chainId : toHex(reference);\n } else {\n storageKey = caipChainId;\n }\n return { namespace, storageKey, caipChainId, reference };\n}\n\n/**\n * Checks if the specified network is the only enabled network in its namespace.\n *\n * This function is used to prevent unnecessary state updates when trying to enable\n * This method is used to prevent the last network in a namespace from being removed.\n *\n * @param state - The current controller state\n * @param derivedKeys - The parsed keys object containing namespace and storageKey\n * @returns True if the network is the only enabled network in the namespace, false otherwise\n */\nexport function isOnlyNetworkEnabledInNamespace(\n state: NetworkEnablementControllerState,\n derivedKeys: DerivedKeys,\n): boolean {\n const { namespace, storageKey } = derivedKeys;\n\n // Early return if namespace doesn't exist\n if (!state.enabledNetworkMap[namespace]) {\n return false;\n }\n\n const networks = state.enabledNetworkMap[namespace];\n\n // Get all enabled networks in this namespace\n const enabledNetworks = Object.entries(networks).filter(\n ([_, enabled]) => enabled,\n );\n\n // Check if there's exactly one enabled network and it matches our target\n if (enabledNetworks.length === 1) {\n const [onlyEnabledKey] = enabledNetworks[0];\n return onlyEnabledKey === storageKey;\n }\n\n // Return false if there are zero or multiple enabled networks\n return false;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@metamask-previews/network-enablement-controller",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-preview-0a30e47",
|
|
4
4
|
"description": "Provides an interface to the currently enabled network using a MetaMask-compatible provider object",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ethereum",
|
|
@@ -18,19 +18,12 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"dist/"
|
|
20
20
|
],
|
|
21
|
+
"type": "module",
|
|
21
22
|
"sideEffects": false,
|
|
22
|
-
"main": "./dist/index.cjs",
|
|
23
|
-
"types": "./dist/index.d.cts",
|
|
24
23
|
"exports": {
|
|
25
24
|
".": {
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
"default": "./dist/index.mjs"
|
|
29
|
-
},
|
|
30
|
-
"require": {
|
|
31
|
-
"types": "./dist/index.d.cts",
|
|
32
|
-
"default": "./dist/index.cjs"
|
|
33
|
-
}
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
34
27
|
},
|
|
35
28
|
"./package.json": "./package.json"
|
|
36
29
|
},
|
|
@@ -39,9 +32,11 @@
|
|
|
39
32
|
"registry": "https://registry.npmjs.org/"
|
|
40
33
|
},
|
|
41
34
|
"scripts": {
|
|
42
|
-
"build": "
|
|
43
|
-
"build:all": "
|
|
35
|
+
"build": "tsc --project tsconfig.build.json",
|
|
36
|
+
"build:all": "tsc --build tsconfig.build.json --verbose",
|
|
37
|
+
"build:clean": "yarn build:only-clean && yarn build",
|
|
44
38
|
"build:docs": "typedoc",
|
|
39
|
+
"build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
|
|
45
40
|
"changelog:update": "../../scripts/update-changelog.sh @metamask/network-enablement-controller",
|
|
46
41
|
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/network-enablement-controller",
|
|
47
42
|
"lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
|
|
@@ -55,31 +50,32 @@
|
|
|
55
50
|
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
|
|
56
51
|
},
|
|
57
52
|
"dependencies": {
|
|
58
|
-
"@metamask/base-controller": "^
|
|
59
|
-
"@metamask/config-registry-controller": "^
|
|
60
|
-
"@metamask/controller-utils": "^
|
|
53
|
+
"@metamask/base-controller": "^10.0.0",
|
|
54
|
+
"@metamask/config-registry-controller": "^4.0.0",
|
|
55
|
+
"@metamask/controller-utils": "^13.0.0",
|
|
61
56
|
"@metamask/keyring-api": "^24.0.0",
|
|
62
|
-
"@metamask/messenger": "^
|
|
63
|
-
"@metamask/multichain-network-controller": "^
|
|
64
|
-
"@metamask/network-controller": "^
|
|
57
|
+
"@metamask/messenger": "^3.0.0",
|
|
58
|
+
"@metamask/multichain-network-controller": "^4.0.0",
|
|
59
|
+
"@metamask/network-controller": "^37.0.0",
|
|
65
60
|
"@metamask/slip44": "^4.3.0",
|
|
66
|
-
"@metamask/transaction-controller": "^
|
|
61
|
+
"@metamask/transaction-controller": "^70.0.0",
|
|
67
62
|
"@metamask/utils": "^11.12.0",
|
|
68
63
|
"reselect": "^5.1.1"
|
|
69
64
|
},
|
|
70
65
|
"devDependencies": {
|
|
71
66
|
"@metamask/auto-changelog": "^6.1.0",
|
|
72
|
-
"@ts-bridge/cli": "^0.6.4",
|
|
73
67
|
"@types/jest": "^30.0.0",
|
|
68
|
+
"@typescript/native": "npm:typescript@^7.0.2",
|
|
74
69
|
"deepmerge": "^4.2.2",
|
|
75
70
|
"jest": "^30.4.2",
|
|
71
|
+
"rimraf": "^5.0.5",
|
|
76
72
|
"ts-jest": "^29.4.11",
|
|
77
73
|
"tsx": "^4.20.5",
|
|
78
74
|
"typedoc": "^0.25.13",
|
|
79
75
|
"typedoc-plugin-missing-exports": "^2.0.0",
|
|
80
|
-
"typescript": "
|
|
76
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2"
|
|
81
77
|
},
|
|
82
78
|
"engines": {
|
|
83
|
-
"node": "^
|
|
79
|
+
"node": "^22.14.0 || ^24"
|
|
84
80
|
}
|
|
85
81
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.cjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController.js';\n\n/**\n * Enables or disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally. This dual parameter support allows for backward\n * compatibility with existing EVM chain ID formats while supporting newer\n * multi-chain standards.\n *\n * When enabling a non-popular network, this method will disable all other networks\n * to ensure only one network is active at a time (exclusive mode).\n *\n * @param chainId - The chain ID of the network to enable or disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerEnableNetworkAction = {\n type: `NetworkEnablementController:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\n/**\n * Enables a network for the user within a specific namespace.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network) and enables it within the specified namespace.\n * The method validates that the chainId belongs to the specified namespace for safety.\n *\n * Before enabling the target network, this method disables all other networks\n * in the same namespace to ensure exclusive behavior within the namespace.\n *\n * @param chainId - The chain ID of the network to enable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @param namespace - The CAIP namespace where the network should be enabled\n * @throws Error if the chainId's derived namespace doesn't match the provided namespace\n */\nexport type NetworkEnablementControllerEnableNetworkInNamespaceAction = {\n type: `NetworkEnablementController:enableNetworkInNamespace`;\n handler: NetworkEnablementController['enableNetworkInNamespace'];\n};\n\n/**\n * Enables all popular networks and Solana mainnet.\n *\n * This method first disables all networks across all namespaces, then enables\n * all networks defined in POPULAR_NETWORKS (EVM networks), Solana mainnet, and\n * Bitcoin mainnet. This provides exclusive behavior - only popular networks will\n * be enabled after calling this method.\n *\n * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.\n */\nexport type NetworkEnablementControllerEnableAllPopularNetworksAction = {\n type: `NetworkEnablementController:enableAllPopularNetworks`;\n handler: NetworkEnablementController['enableAllPopularNetworks'];\n};\n\n/**\n * Initializes the network enablement state from network controller configurations.\n *\n * This method reads the current network configurations from both NetworkController\n * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.\n * It ensures proper namespace buckets exist for all configured networks and only\n * adds missing networks with a default value of false, preserving existing user settings.\n *\n * This method should be called after the NetworkController and MultichainNetworkController\n * have been initialized and their configurations are available.\n */\nexport type NetworkEnablementControllerInitAction = {\n type: `NetworkEnablementController:init`;\n handler: NetworkEnablementController['init'];\n};\n\n/**\n * Initializes the native asset identifiers from network configurations.\n * This method should be called from the client during controller initialization\n * to populate the nativeAssetIdentifiers state based on actual network configurations.\n *\n * @param networks - Array of network configurations with chainId and nativeCurrency\n * @example\n * ```typescript\n * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)\n * .map(config => ({\n * chainId: toEvmCaipChainId(config.chainId),\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)\n * .map(config => ({\n * chainId: config.chainId,\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport type NetworkEnablementControllerInitNativeAssetIdentifiersAction = {\n type: `NetworkEnablementController:initNativeAssetIdentifiers`;\n handler: NetworkEnablementController['initNativeAssetIdentifiers'];\n};\n\n/**\n * Disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally.\n *\n * Note: This method will prevent disabling the last remaining enabled network\n * to ensure at least one network is always available.\n *\n * @param chainId - The chain ID of the network to disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `NetworkEnablementController:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * Restores the enabled network map to a previously snapshotted state.\n *\n * Not a general merge API: only updates keys already present in the current\n * map. Missing snapshot values default to `false`. Intended for callers with\n * direct controller access (e.g. extension) to undo `#onAddNetwork` filter\n * switches when adding a network without changing the active selection.\n *\n * @param enabledNetworkMap - Previously snapshotted enabledNetworkMap.\n */\nexport type NetworkEnablementControllerRestoreEnabledNetworkMapAction = {\n type: `NetworkEnablementController:restoreEnabledNetworkMap`;\n handler: NetworkEnablementController['restoreEnabledNetworkMap'];\n};\n\n/**\n * Checks if a network is enabled.\n *\n * @param chainId - The chain ID of the network to check. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @returns True if the network is enabled, false otherwise\n */\nexport type NetworkEnablementControllerIsNetworkEnabledAction = {\n type: `NetworkEnablementController:isNetworkEnabled`;\n handler: NetworkEnablementController['isNetworkEnabled'];\n};\n\n/**\n * Returns popular EVM network chain IDs in hex form, restricted to networks\n * that exist in NetworkController (networkConfigurationsByChainId). Source is\n * the bundled `POPULAR_NETWORKS` unioned with registry-featured EVM chains.\n *\n * @returns Hex chain IDs for popular EVM networks that are configured.\n */\nexport type NetworkEnablementControllerListPopularEvmNetworksAction = {\n type: `NetworkEnablementController:listPopularEvmNetworks`;\n handler: NetworkEnablementController['listPopularEvmNetworks'];\n};\n\n/**\n * Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in\n * CAIP-2 form, restricted to networks that exist in MultichainNetworkController\n * (multichainNetworkConfigurationsByChainId).\n *\n * @returns CAIP-2 chain IDs for Bitcoin, Solana, Tron, and Stellar mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularMultichainNetworksAction = {\n type: `NetworkEnablementController:listPopularMultichainNetworks`;\n handler: NetworkEnablementController['listPopularMultichainNetworks'];\n};\n\n/**\n * Returns the list of popular network chain IDs in CAIP-2 form, restricted to\n * networks that exist in NetworkController (networkConfigurationsByChainId) and\n * MultichainNetworkController (multichainNetworkConfigurationsByChainId). EVM\n * popular networks come from POPULAR_NETWORKS; multichain popular are Bitcoin,\n * Solana, Tron, and Stellar mainnets.\n *\n * @returns CAIP-2 chain IDs for popular EVM networks and multichain mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularNetworksAction = {\n type: `NetworkEnablementController:listPopularNetworks`;\n handler: NetworkEnablementController['listPopularNetworks'];\n};\n\n/**\n * Union of all NetworkEnablementController action types.\n */\nexport type NetworkEnablementControllerMethodActions =\n | NetworkEnablementControllerEnableNetworkAction\n | NetworkEnablementControllerEnableNetworkInNamespaceAction\n | NetworkEnablementControllerEnableAllPopularNetworksAction\n | NetworkEnablementControllerInitAction\n | NetworkEnablementControllerInitNativeAssetIdentifiersAction\n | NetworkEnablementControllerDisableNetworkAction\n | NetworkEnablementControllerRestoreEnabledNetworkMapAction\n | NetworkEnablementControllerIsNetworkEnabledAction\n | NetworkEnablementControllerListPopularEvmNetworksAction\n | NetworkEnablementControllerListPopularMultichainNetworksAction\n | NetworkEnablementControllerListPopularNetworksAction;\n"]}
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file is auto generated.
|
|
3
|
-
* Do not edit manually.
|
|
4
|
-
*/
|
|
5
|
-
import type { NetworkEnablementController } from "./NetworkEnablementController.cjs";
|
|
6
|
-
/**
|
|
7
|
-
* Enables or disables a network for the user.
|
|
8
|
-
*
|
|
9
|
-
* This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID
|
|
10
|
-
* (for any blockchain network). The method will automatically convert Hex chain IDs
|
|
11
|
-
* to CAIP-2 format internally. This dual parameter support allows for backward
|
|
12
|
-
* compatibility with existing EVM chain ID formats while supporting newer
|
|
13
|
-
* multi-chain standards.
|
|
14
|
-
*
|
|
15
|
-
* When enabling a non-popular network, this method will disable all other networks
|
|
16
|
-
* to ensure only one network is active at a time (exclusive mode).
|
|
17
|
-
*
|
|
18
|
-
* @param chainId - The chain ID of the network to enable or disable. Can be either:
|
|
19
|
-
* - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks
|
|
20
|
-
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
21
|
-
*/
|
|
22
|
-
export type NetworkEnablementControllerEnableNetworkAction = {
|
|
23
|
-
type: `NetworkEnablementController:enableNetwork`;
|
|
24
|
-
handler: NetworkEnablementController['enableNetwork'];
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Enables a network for the user within a specific namespace.
|
|
28
|
-
*
|
|
29
|
-
* This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID
|
|
30
|
-
* (for any blockchain network) and enables it within the specified namespace.
|
|
31
|
-
* The method validates that the chainId belongs to the specified namespace for safety.
|
|
32
|
-
*
|
|
33
|
-
* Before enabling the target network, this method disables all other networks
|
|
34
|
-
* in the same namespace to ensure exclusive behavior within the namespace.
|
|
35
|
-
*
|
|
36
|
-
* @param chainId - The chain ID of the network to enable. Can be either:
|
|
37
|
-
* - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks
|
|
38
|
-
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
39
|
-
* @param namespace - The CAIP namespace where the network should be enabled
|
|
40
|
-
* @throws Error if the chainId's derived namespace doesn't match the provided namespace
|
|
41
|
-
*/
|
|
42
|
-
export type NetworkEnablementControllerEnableNetworkInNamespaceAction = {
|
|
43
|
-
type: `NetworkEnablementController:enableNetworkInNamespace`;
|
|
44
|
-
handler: NetworkEnablementController['enableNetworkInNamespace'];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Enables all popular networks and Solana mainnet.
|
|
48
|
-
*
|
|
49
|
-
* This method first disables all networks across all namespaces, then enables
|
|
50
|
-
* all networks defined in POPULAR_NETWORKS (EVM networks), Solana mainnet, and
|
|
51
|
-
* Bitcoin mainnet. This provides exclusive behavior - only popular networks will
|
|
52
|
-
* be enabled after calling this method.
|
|
53
|
-
*
|
|
54
|
-
* Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.
|
|
55
|
-
*/
|
|
56
|
-
export type NetworkEnablementControllerEnableAllPopularNetworksAction = {
|
|
57
|
-
type: `NetworkEnablementController:enableAllPopularNetworks`;
|
|
58
|
-
handler: NetworkEnablementController['enableAllPopularNetworks'];
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Initializes the network enablement state from network controller configurations.
|
|
62
|
-
*
|
|
63
|
-
* This method reads the current network configurations from both NetworkController
|
|
64
|
-
* and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.
|
|
65
|
-
* It ensures proper namespace buckets exist for all configured networks and only
|
|
66
|
-
* adds missing networks with a default value of false, preserving existing user settings.
|
|
67
|
-
*
|
|
68
|
-
* This method should be called after the NetworkController and MultichainNetworkController
|
|
69
|
-
* have been initialized and their configurations are available.
|
|
70
|
-
*/
|
|
71
|
-
export type NetworkEnablementControllerInitAction = {
|
|
72
|
-
type: `NetworkEnablementController:init`;
|
|
73
|
-
handler: NetworkEnablementController['init'];
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* Initializes the native asset identifiers from network configurations.
|
|
77
|
-
* This method should be called from the client during controller initialization
|
|
78
|
-
* to populate the nativeAssetIdentifiers state based on actual network configurations.
|
|
79
|
-
*
|
|
80
|
-
* @param networks - Array of network configurations with chainId and nativeCurrency
|
|
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
|
-
* await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
|
-
export type NetworkEnablementControllerInitNativeAssetIdentifiersAction = {
|
|
99
|
-
type: `NetworkEnablementController:initNativeAssetIdentifiers`;
|
|
100
|
-
handler: NetworkEnablementController['initNativeAssetIdentifiers'];
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* Disables a network for the user.
|
|
104
|
-
*
|
|
105
|
-
* This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID
|
|
106
|
-
* (for any blockchain network). The method will automatically convert Hex chain IDs
|
|
107
|
-
* to CAIP-2 format internally.
|
|
108
|
-
*
|
|
109
|
-
* Note: This method will prevent disabling the last remaining enabled network
|
|
110
|
-
* to ensure at least one network is always available.
|
|
111
|
-
*
|
|
112
|
-
* @param chainId - The chain ID of the network to disable. Can be either:
|
|
113
|
-
* - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks
|
|
114
|
-
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
115
|
-
*/
|
|
116
|
-
export type NetworkEnablementControllerDisableNetworkAction = {
|
|
117
|
-
type: `NetworkEnablementController:disableNetwork`;
|
|
118
|
-
handler: NetworkEnablementController['disableNetwork'];
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Restores the enabled network map to a previously snapshotted state.
|
|
122
|
-
*
|
|
123
|
-
* Not a general merge API: only updates keys already present in the current
|
|
124
|
-
* map. Missing snapshot values default to `false`. Intended for callers with
|
|
125
|
-
* direct controller access (e.g. extension) to undo `#onAddNetwork` filter
|
|
126
|
-
* switches when adding a network without changing the active selection.
|
|
127
|
-
*
|
|
128
|
-
* @param enabledNetworkMap - Previously snapshotted enabledNetworkMap.
|
|
129
|
-
*/
|
|
130
|
-
export type NetworkEnablementControllerRestoreEnabledNetworkMapAction = {
|
|
131
|
-
type: `NetworkEnablementController:restoreEnabledNetworkMap`;
|
|
132
|
-
handler: NetworkEnablementController['restoreEnabledNetworkMap'];
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Checks if a network is enabled.
|
|
136
|
-
*
|
|
137
|
-
* @param chainId - The chain ID of the network to check. Can be either:
|
|
138
|
-
* - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks
|
|
139
|
-
* - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)
|
|
140
|
-
* @returns True if the network is enabled, false otherwise
|
|
141
|
-
*/
|
|
142
|
-
export type NetworkEnablementControllerIsNetworkEnabledAction = {
|
|
143
|
-
type: `NetworkEnablementController:isNetworkEnabled`;
|
|
144
|
-
handler: NetworkEnablementController['isNetworkEnabled'];
|
|
145
|
-
};
|
|
146
|
-
/**
|
|
147
|
-
* Returns popular EVM network chain IDs in hex form, restricted to networks
|
|
148
|
-
* that exist in NetworkController (networkConfigurationsByChainId). Source is
|
|
149
|
-
* the bundled `POPULAR_NETWORKS` unioned with registry-featured EVM chains.
|
|
150
|
-
*
|
|
151
|
-
* @returns Hex chain IDs for popular EVM networks that are configured.
|
|
152
|
-
*/
|
|
153
|
-
export type NetworkEnablementControllerListPopularEvmNetworksAction = {
|
|
154
|
-
type: `NetworkEnablementController:listPopularEvmNetworks`;
|
|
155
|
-
handler: NetworkEnablementController['listPopularEvmNetworks'];
|
|
156
|
-
};
|
|
157
|
-
/**
|
|
158
|
-
* Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in
|
|
159
|
-
* CAIP-2 form, restricted to networks that exist in MultichainNetworkController
|
|
160
|
-
* (multichainNetworkConfigurationsByChainId).
|
|
161
|
-
*
|
|
162
|
-
* @returns CAIP-2 chain IDs for Bitcoin, Solana, Tron, and Stellar mainnets that are configured.
|
|
163
|
-
*/
|
|
164
|
-
export type NetworkEnablementControllerListPopularMultichainNetworksAction = {
|
|
165
|
-
type: `NetworkEnablementController:listPopularMultichainNetworks`;
|
|
166
|
-
handler: NetworkEnablementController['listPopularMultichainNetworks'];
|
|
167
|
-
};
|
|
168
|
-
/**
|
|
169
|
-
* Returns the list of popular network chain IDs in CAIP-2 form, restricted to
|
|
170
|
-
* networks that exist in NetworkController (networkConfigurationsByChainId) and
|
|
171
|
-
* MultichainNetworkController (multichainNetworkConfigurationsByChainId). EVM
|
|
172
|
-
* popular networks come from POPULAR_NETWORKS; multichain popular are Bitcoin,
|
|
173
|
-
* Solana, Tron, and Stellar mainnets.
|
|
174
|
-
*
|
|
175
|
-
* @returns CAIP-2 chain IDs for popular EVM networks and multichain mainnets that are configured.
|
|
176
|
-
*/
|
|
177
|
-
export type NetworkEnablementControllerListPopularNetworksAction = {
|
|
178
|
-
type: `NetworkEnablementController:listPopularNetworks`;
|
|
179
|
-
handler: NetworkEnablementController['listPopularNetworks'];
|
|
180
|
-
};
|
|
181
|
-
/**
|
|
182
|
-
* Union of all NetworkEnablementController action types.
|
|
183
|
-
*/
|
|
184
|
-
export type NetworkEnablementControllerMethodActions = NetworkEnablementControllerEnableNetworkAction | NetworkEnablementControllerEnableNetworkInNamespaceAction | NetworkEnablementControllerEnableAllPopularNetworksAction | NetworkEnablementControllerInitAction | NetworkEnablementControllerInitNativeAssetIdentifiersAction | NetworkEnablementControllerDisableNetworkAction | NetworkEnablementControllerRestoreEnabledNetworkMapAction | NetworkEnablementControllerIsNetworkEnabledAction | NetworkEnablementControllerListPopularEvmNetworksAction | NetworkEnablementControllerListPopularMultichainNetworksAction | NetworkEnablementControllerListPopularNetworksAction;
|
|
185
|
-
//# sourceMappingURL=NetworkEnablementController-method-action-types.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,0CAAyC;AAEpF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;CAC7D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,8CAA8C,GAC9C,yDAAyD,GACzD,yDAAyD,GACzD,qCAAqC,GACrC,2DAA2D,GAC3D,+CAA+C,GAC/C,yDAAyD,GACzD,iDAAiD,GACjD,uDAAuD,GACvD,8DAA8D,GAC9D,oDAAoD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,2BAA2B,EAAE,0CAAyC;AAEpF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,8CAA8C,GAAG;IAC3D,IAAI,EAAE,2CAA2C,CAAC;IAClD,OAAO,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;CACvD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,2BAA2B,CAAC,MAAM,CAAC,CAAC;CAC9C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,2DAA2D,GAAG;IACxE,IAAI,EAAE,wDAAwD,CAAC;IAC/D,OAAO,EAAE,2BAA2B,CAAC,4BAA4B,CAAC,CAAC;CACpE,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,2BAA2B,CAAC,gBAAgB,CAAC,CAAC;CACxD,CAAC;AAEF;;;;;;;;;GASG;AACH,MAAM,MAAM,yDAAyD,GAAG;IACtE,IAAI,EAAE,sDAAsD,CAAC;IAC7D,OAAO,EAAE,2BAA2B,CAAC,0BAA0B,CAAC,CAAC;CAClE,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,2BAA2B,CAAC,kBAAkB,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,uDAAuD,GAAG;IACpE,IAAI,EAAE,oDAAoD,CAAC;IAC3D,OAAO,EAAE,2BAA2B,CAAC,wBAAwB,CAAC,CAAC;CAChE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,8DAA8D,GAAG;IAC3E,IAAI,EAAE,2DAA2D,CAAC;IAClE,OAAO,EAAE,2BAA2B,CAAC,+BAA+B,CAAC,CAAC;CACvE,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,oDAAoD,GAAG;IACjE,IAAI,EAAE,iDAAiD,CAAC;IACxD,OAAO,EAAE,2BAA2B,CAAC,qBAAqB,CAAC,CAAC;CAC7D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wCAAwC,GAChD,8CAA8C,GAC9C,yDAAyD,GACzD,yDAAyD,GACzD,qCAAqC,GACrC,2DAA2D,GAC3D,+CAA+C,GAC/C,yDAAyD,GACzD,iDAAiD,GACjD,uDAAuD,GACvD,8DAA8D,GAC9D,oDAAoD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkEnablementController-method-action-types.mjs","sourceRoot":"","sources":["../src/NetworkEnablementController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkEnablementController } from './NetworkEnablementController.js';\n\n/**\n * Enables or disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally. This dual parameter support allows for backward\n * compatibility with existing EVM chain ID formats while supporting newer\n * multi-chain standards.\n *\n * When enabling a non-popular network, this method will disable all other networks\n * to ensure only one network is active at a time (exclusive mode).\n *\n * @param chainId - The chain ID of the network to enable or disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerEnableNetworkAction = {\n type: `NetworkEnablementController:enableNetwork`;\n handler: NetworkEnablementController['enableNetwork'];\n};\n\n/**\n * Enables a network for the user within a specific namespace.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network) and enables it within the specified namespace.\n * The method validates that the chainId belongs to the specified namespace for safety.\n *\n * Before enabling the target network, this method disables all other networks\n * in the same namespace to ensure exclusive behavior within the namespace.\n *\n * @param chainId - The chain ID of the network to enable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @param namespace - The CAIP namespace where the network should be enabled\n * @throws Error if the chainId's derived namespace doesn't match the provided namespace\n */\nexport type NetworkEnablementControllerEnableNetworkInNamespaceAction = {\n type: `NetworkEnablementController:enableNetworkInNamespace`;\n handler: NetworkEnablementController['enableNetworkInNamespace'];\n};\n\n/**\n * Enables all popular networks and Solana mainnet.\n *\n * This method first disables all networks across all namespaces, then enables\n * all networks defined in POPULAR_NETWORKS (EVM networks), Solana mainnet, and\n * Bitcoin mainnet. This provides exclusive behavior - only popular networks will\n * be enabled after calling this method.\n *\n * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.\n */\nexport type NetworkEnablementControllerEnableAllPopularNetworksAction = {\n type: `NetworkEnablementController:enableAllPopularNetworks`;\n handler: NetworkEnablementController['enableAllPopularNetworks'];\n};\n\n/**\n * Initializes the network enablement state from network controller configurations.\n *\n * This method reads the current network configurations from both NetworkController\n * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.\n * It ensures proper namespace buckets exist for all configured networks and only\n * adds missing networks with a default value of false, preserving existing user settings.\n *\n * This method should be called after the NetworkController and MultichainNetworkController\n * have been initialized and their configurations are available.\n */\nexport type NetworkEnablementControllerInitAction = {\n type: `NetworkEnablementController:init`;\n handler: NetworkEnablementController['init'];\n};\n\n/**\n * Initializes the native asset identifiers from network configurations.\n * This method should be called from the client during controller initialization\n * to populate the nativeAssetIdentifiers state based on actual network configurations.\n *\n * @param networks - Array of network configurations with chainId and nativeCurrency\n * @example\n * ```typescript\n * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)\n * .map(config => ({\n * chainId: toEvmCaipChainId(config.chainId),\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)\n * .map(config => ({\n * chainId: config.chainId,\n * nativeCurrency: config.nativeCurrency,\n * }));\n *\n * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);\n * ```\n */\nexport type NetworkEnablementControllerInitNativeAssetIdentifiersAction = {\n type: `NetworkEnablementController:initNativeAssetIdentifiers`;\n handler: NetworkEnablementController['initNativeAssetIdentifiers'];\n};\n\n/**\n * Disables a network for the user.\n *\n * This method accepts either a Hex chain ID (for EVM networks) or a CAIP-2 chain ID\n * (for any blockchain network). The method will automatically convert Hex chain IDs\n * to CAIP-2 format internally.\n *\n * Note: This method will prevent disabling the last remaining enabled network\n * to ensure at least one network is always available.\n *\n * @param chainId - The chain ID of the network to disable. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n */\nexport type NetworkEnablementControllerDisableNetworkAction = {\n type: `NetworkEnablementController:disableNetwork`;\n handler: NetworkEnablementController['disableNetwork'];\n};\n\n/**\n * Restores the enabled network map to a previously snapshotted state.\n *\n * Not a general merge API: only updates keys already present in the current\n * map. Missing snapshot values default to `false`. Intended for callers with\n * direct controller access (e.g. extension) to undo `#onAddNetwork` filter\n * switches when adding a network without changing the active selection.\n *\n * @param enabledNetworkMap - Previously snapshotted enabledNetworkMap.\n */\nexport type NetworkEnablementControllerRestoreEnabledNetworkMapAction = {\n type: `NetworkEnablementController:restoreEnabledNetworkMap`;\n handler: NetworkEnablementController['restoreEnabledNetworkMap'];\n};\n\n/**\n * Checks if a network is enabled.\n *\n * @param chainId - The chain ID of the network to check. Can be either:\n * - A Hex string (e.g., '0x1' for Ethereum mainnet) for EVM networks\n * - A CAIP-2 chain ID (e.g., 'eip155:1' for Ethereum mainnet, 'solana:mainnet' for Solana)\n * @returns True if the network is enabled, false otherwise\n */\nexport type NetworkEnablementControllerIsNetworkEnabledAction = {\n type: `NetworkEnablementController:isNetworkEnabled`;\n handler: NetworkEnablementController['isNetworkEnabled'];\n};\n\n/**\n * Returns popular EVM network chain IDs in hex form, restricted to networks\n * that exist in NetworkController (networkConfigurationsByChainId). Source is\n * the bundled `POPULAR_NETWORKS` unioned with registry-featured EVM chains.\n *\n * @returns Hex chain IDs for popular EVM networks that are configured.\n */\nexport type NetworkEnablementControllerListPopularEvmNetworksAction = {\n type: `NetworkEnablementController:listPopularEvmNetworks`;\n handler: NetworkEnablementController['listPopularEvmNetworks'];\n};\n\n/**\n * Returns popular multichain (Bitcoin, Solana, Tron, Stellar) mainnet chain IDs in\n * CAIP-2 form, restricted to networks that exist in MultichainNetworkController\n * (multichainNetworkConfigurationsByChainId).\n *\n * @returns CAIP-2 chain IDs for Bitcoin, Solana, Tron, and Stellar mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularMultichainNetworksAction = {\n type: `NetworkEnablementController:listPopularMultichainNetworks`;\n handler: NetworkEnablementController['listPopularMultichainNetworks'];\n};\n\n/**\n * Returns the list of popular network chain IDs in CAIP-2 form, restricted to\n * networks that exist in NetworkController (networkConfigurationsByChainId) and\n * MultichainNetworkController (multichainNetworkConfigurationsByChainId). EVM\n * popular networks come from POPULAR_NETWORKS; multichain popular are Bitcoin,\n * Solana, Tron, and Stellar mainnets.\n *\n * @returns CAIP-2 chain IDs for popular EVM networks and multichain mainnets that are configured.\n */\nexport type NetworkEnablementControllerListPopularNetworksAction = {\n type: `NetworkEnablementController:listPopularNetworks`;\n handler: NetworkEnablementController['listPopularNetworks'];\n};\n\n/**\n * Union of all NetworkEnablementController action types.\n */\nexport type NetworkEnablementControllerMethodActions =\n | NetworkEnablementControllerEnableNetworkAction\n | NetworkEnablementControllerEnableNetworkInNamespaceAction\n | NetworkEnablementControllerEnableAllPopularNetworksAction\n | NetworkEnablementControllerInitAction\n | NetworkEnablementControllerInitNativeAssetIdentifiersAction\n | NetworkEnablementControllerDisableNetworkAction\n | NetworkEnablementControllerRestoreEnabledNetworkMapAction\n | NetworkEnablementControllerIsNetworkEnabledAction\n | NetworkEnablementControllerListPopularEvmNetworksAction\n | NetworkEnablementControllerListPopularMultichainNetworksAction\n | NetworkEnablementControllerListPopularNetworksAction;\n"]}
|