@metamask-previews/network-enablement-controller 4.0.0-preview-f8cdcfc2 → 4.0.0-preview-319540cb

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.
Files changed (34) hide show
  1. package/CHANGELOG.md +0 -7
  2. package/dist/NetworkEnablementController.cjs +59 -188
  3. package/dist/NetworkEnablementController.cjs.map +1 -1
  4. package/dist/NetworkEnablementController.d.cts +2 -52
  5. package/dist/NetworkEnablementController.d.cts.map +1 -1
  6. package/dist/NetworkEnablementController.d.mts +2 -52
  7. package/dist/NetworkEnablementController.d.mts.map +1 -1
  8. package/dist/NetworkEnablementController.mjs +59 -188
  9. package/dist/NetworkEnablementController.mjs.map +1 -1
  10. package/dist/index.cjs +1 -5
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +1 -3
  13. package/dist/index.d.cts.map +1 -1
  14. package/dist/index.d.mts +1 -3
  15. package/dist/index.d.mts.map +1 -1
  16. package/dist/index.mjs +0 -1
  17. package/dist/index.mjs.map +1 -1
  18. package/package.json +1 -2
  19. package/dist/services/Slip44Service.cjs +0 -176
  20. package/dist/services/Slip44Service.cjs.map +0 -1
  21. package/dist/services/Slip44Service.d.cts +0 -74
  22. package/dist/services/Slip44Service.d.cts.map +0 -1
  23. package/dist/services/Slip44Service.d.mts +0 -74
  24. package/dist/services/Slip44Service.d.mts.map +0 -1
  25. package/dist/services/Slip44Service.mjs +0 -169
  26. package/dist/services/Slip44Service.mjs.map +0 -1
  27. package/dist/services/index.cjs +0 -9
  28. package/dist/services/index.cjs.map +0 -1
  29. package/dist/services/index.d.cts +0 -6
  30. package/dist/services/index.d.cts.map +0 -1
  31. package/dist/services/index.d.mts +0 -6
  32. package/dist/services/index.d.mts.map +0 -1
  33. package/dist/services/index.mjs +0 -6
  34. package/dist/services/index.mjs.map +0 -1
@@ -21,26 +21,8 @@ export type NetworksInfo = {
21
21
  * For other networks, the keys are CAIP chain IDs.
22
22
  */
23
23
  type EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;
24
- /**
25
- * A native asset identifier in CAIP-19-like format.
26
- * Format: `{caip2ChainId}/slip44:{coinType}`
27
- *
28
- * @example
29
- * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)
30
- * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)
31
- * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)
32
- */
33
- export type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;
34
- /**
35
- * A map of CAIP-2 chain IDs to their native asset identifiers.
36
- * Uses CAIP-19-like format to identify the native asset for each chain.
37
- *
38
- * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
39
- */
40
- export type NativeAssetIdentifiersMap = Record<CaipChainId, NativeAssetIdentifier>;
41
24
  export type NetworkEnablementControllerState = {
42
25
  enabledNetworkMap: EnabledMap;
43
- nativeAssetIdentifiers: NativeAssetIdentifiersMap;
44
26
  };
45
27
  export type NetworkEnablementControllerGetStateAction = ControllerGetStateAction<typeof controllerName, NetworkEnablementControllerState>;
46
28
  export type NetworkEnablementControllerSetEnabledNetworksAction = {
@@ -63,14 +45,6 @@ export type NetworkEnablementControllerEvents = NetworkEnablementControllerState
63
45
  */
64
46
  export type AllowedEvents = NetworkControllerNetworkAddedEvent | NetworkControllerNetworkRemovedEvent | NetworkControllerStateChangeEvent | TransactionControllerTransactionSubmittedEvent;
65
47
  export type NetworkEnablementControllerMessenger = Messenger<typeof controllerName, NetworkEnablementControllerActions | AllowedActions, NetworkEnablementControllerEvents | AllowedEvents>;
66
- /**
67
- * Network configuration with chain ID and native currency symbol.
68
- * Used to initialize native asset identifiers.
69
- */
70
- export type NetworkConfig = {
71
- chainId: CaipChainId;
72
- nativeCurrency: string;
73
- };
74
48
  /**
75
49
  * Controller responsible for managing network enablement state across different blockchain networks.
76
50
  *
@@ -142,38 +116,14 @@ export declare class NetworkEnablementController extends BaseController<typeof c
142
116
  * Initializes the network enablement state from network controller configurations.
143
117
  *
144
118
  * This method reads the current network configurations from both NetworkController
145
- * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.
119
+ * and MultichainNetworkController and syncs the enabled network map accordingly.
146
120
  * It ensures proper namespace buckets exist for all configured networks and only
147
121
  * adds missing networks with a default value of false, preserving existing user settings.
148
122
  *
149
123
  * This method should be called after the NetworkController and MultichainNetworkController
150
124
  * have been initialized and their configurations are available.
151
125
  */
152
- init(): Promise<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
- * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
174
- * ```
175
- */
176
- initNativeAssetIdentifiers(networks: NetworkConfig[]): Promise<void>;
126
+ init(): void;
177
127
  /**
178
128
  * Disables a network for the user.
179
129
  *
@@ -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,E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;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CA0JtD"}
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;AAUvE,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;AAG5E,MAAM,MAAM,gCAAgC,GAAG;IAC7C,iBAAiB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,yCAAyC,GACnD,wBAAwB,CACtB,OAAO,cAAc,EACrB,gCAAgC,CACjC,CAAC;AAEJ,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,GAAG,OAAO,cAAc,gBAAgB,CAAC;IAC/C,OAAO,EAAE,2BAA2B,CAAC,eAAe,CAAC,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,+CAA+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cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAiItD"}
@@ -21,26 +21,8 @@ export type NetworksInfo = {
21
21
  * For other networks, the keys are CAIP chain IDs.
22
22
  */
23
23
  type EnabledMap = Record<CaipNamespace, Record<CaipChainId | Hex, boolean>>;
24
- /**
25
- * A native asset identifier in CAIP-19-like format.
26
- * Format: `{caip2ChainId}/slip44:{coinType}`
27
- *
28
- * @example
29
- * - `eip155:1/slip44:60` for Ethereum mainnet (ETH)
30
- * - `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/slip44:501` for Solana mainnet (SOL)
31
- * - `bip122:000000000019d6689c085ae165831e93/slip44:0` for Bitcoin mainnet (BTC)
32
- */
33
- export type NativeAssetIdentifier = `${CaipChainId}/slip44:${number}`;
34
- /**
35
- * A map of CAIP-2 chain IDs to their native asset identifiers.
36
- * Uses CAIP-19-like format to identify the native asset for each chain.
37
- *
38
- * @see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
39
- */
40
- export type NativeAssetIdentifiersMap = Record<CaipChainId, NativeAssetIdentifier>;
41
24
  export type NetworkEnablementControllerState = {
42
25
  enabledNetworkMap: EnabledMap;
43
- nativeAssetIdentifiers: NativeAssetIdentifiersMap;
44
26
  };
45
27
  export type NetworkEnablementControllerGetStateAction = ControllerGetStateAction<typeof controllerName, NetworkEnablementControllerState>;
46
28
  export type NetworkEnablementControllerSetEnabledNetworksAction = {
@@ -63,14 +45,6 @@ export type NetworkEnablementControllerEvents = NetworkEnablementControllerState
63
45
  */
64
46
  export type AllowedEvents = NetworkControllerNetworkAddedEvent | NetworkControllerNetworkRemovedEvent | NetworkControllerStateChangeEvent | TransactionControllerTransactionSubmittedEvent;
65
47
  export type NetworkEnablementControllerMessenger = Messenger<typeof controllerName, NetworkEnablementControllerActions | AllowedActions, NetworkEnablementControllerEvents | AllowedEvents>;
66
- /**
67
- * Network configuration with chain ID and native currency symbol.
68
- * Used to initialize native asset identifiers.
69
- */
70
- export type NetworkConfig = {
71
- chainId: CaipChainId;
72
- nativeCurrency: string;
73
- };
74
48
  /**
75
49
  * Controller responsible for managing network enablement state across different blockchain networks.
76
50
  *
@@ -142,38 +116,14 @@ export declare class NetworkEnablementController extends BaseController<typeof c
142
116
  * Initializes the network enablement state from network controller configurations.
143
117
  *
144
118
  * This method reads the current network configurations from both NetworkController
145
- * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.
119
+ * and MultichainNetworkController and syncs the enabled network map accordingly.
146
120
  * It ensures proper namespace buckets exist for all configured networks and only
147
121
  * adds missing networks with a default value of false, preserving existing user settings.
148
122
  *
149
123
  * This method should be called after the NetworkController and MultichainNetworkController
150
124
  * have been initialized and their configurations are available.
151
125
  */
152
- init(): Promise<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
- * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
174
- * ```
175
- */
176
- initNativeAssetIdentifiers(networks: NetworkConfig[]): Promise<void>;
126
+ init(): void;
177
127
  /**
178
128
  * Disables a network for the user.
179
129
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkEnablementController.d.mts","sourceRoot":"","sources":["../src/NetworkEnablementController.ts"],"names":[],"mappings":"A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;;;OAeG;IACH,wBAAwB,CACtB,OAAO,EAAE,GAAG,GAAG,WAAW,EAC1B,SAAS,EAAE,aAAa,GACvB,IAAI;IA0BP;;;;;;;;;OASG;IACH,wBAAwB,IAAI,IAAI;IA0EhC;;;;;;;;;;OAUG;IACH,IAAI,IAAI,IAAI;IAwCZ;;;;;;;;;;;;;OAaG;IACH,cAAc,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,CAAC,OAAO,EAAE,GAAG,GAAG,WAAW,GAAG,OAAO;CAiItD"}
@@ -9,19 +9,8 @@ import { BuiltInNetworkName, ChainId } from "@metamask/controller-utils";
9
9
  import { BtcScope, SolScope, TrxScope } from "@metamask/keyring-api";
10
10
  import { KnownCaipNamespace } from "@metamask/utils";
11
11
  import { POPULAR_NETWORKS } from "./constants.mjs";
12
- import { Slip44Service } from "./services/index.mjs";
13
12
  import { deriveKeys, isOnlyNetworkEnabledInNamespace, isPopularNetwork } from "./utils.mjs";
14
13
  const controllerName = 'NetworkEnablementController';
15
- /**
16
- * Builds a native asset identifier in CAIP-19-like format.
17
- *
18
- * @param caipChainId - The CAIP-2 chain ID (e.g., 'eip155:1', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp')
19
- * @param slip44CoinType - The SLIP-44 coin type number
20
- * @returns The native asset identifier string (e.g., 'eip155:1/slip44:60')
21
- */
22
- function buildNativeAssetIdentifier(caipChainId, slip44CoinType) {
23
- return `${caipChainId}/slip44:${slip44CoinType}`;
24
- }
25
14
  /**
26
15
  * Gets the default state for the NetworkEnablementController.
27
16
  *
@@ -55,9 +44,6 @@ const getDefaultNetworkEnablementControllerState = () => ({
55
44
  [TrxScope.Shasta]: false,
56
45
  },
57
46
  },
58
- // nativeAssetIdentifiers is initialized as empty and should be populated
59
- // by the client using initNativeAssetIdentifiers() during controller init
60
- nativeAssetIdentifiers: {},
61
47
  });
62
48
  // Metadata for the controller state
63
49
  const metadata = {
@@ -67,12 +53,6 @@ const metadata = {
67
53
  includeInDebugSnapshot: true,
68
54
  usedInUi: true,
69
55
  },
70
- nativeAssetIdentifiers: {
71
- includeInStateLogs: true,
72
- persist: true,
73
- includeInDebugSnapshot: true,
74
- usedInUi: true,
75
- },
76
56
  };
77
57
  /**
78
58
  * Controller responsible for managing network enablement state across different blockchain networks.
@@ -102,9 +82,8 @@ export class NetworkEnablementController extends BaseController {
102
82
  },
103
83
  });
104
84
  _NetworkEnablementController_instances.add(this);
105
- messenger.subscribe('NetworkController:networkAdded', ({ chainId, nativeCurrency }) => {
106
- // eslint-disable-next-line no-void
107
- void __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_onAddNetwork).call(this, chainId, nativeCurrency);
85
+ messenger.subscribe('NetworkController:networkAdded', ({ chainId }) => {
86
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_onAddNetwork).call(this, chainId);
108
87
  });
109
88
  messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {
110
89
  __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_removeNetworkEntry).call(this, chainId);
@@ -128,20 +107,20 @@ export class NetworkEnablementController extends BaseController {
128
107
  */
129
108
  enableNetwork(chainId) {
130
109
  const { namespace, storageKey } = deriveKeys(chainId);
131
- this.update((state) => {
110
+ this.update((s) => {
132
111
  // disable all networks in all namespaces first
133
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
134
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
135
- state.enabledNetworkMap[ns][key] = false;
112
+ Object.keys(s.enabledNetworkMap).forEach((ns) => {
113
+ Object.keys(s.enabledNetworkMap[ns]).forEach((key) => {
114
+ s.enabledNetworkMap[ns][key] = false;
136
115
  });
137
116
  });
138
117
  // if the namespace bucket does not exist, return
139
118
  // new nemespace are added only when a new network is added
140
- if (!state.enabledNetworkMap[namespace]) {
119
+ if (!s.enabledNetworkMap[namespace]) {
141
120
  return;
142
121
  }
143
122
  // enable the network
144
- state.enabledNetworkMap[namespace][storageKey] = true;
123
+ s.enabledNetworkMap[namespace][storageKey] = true;
145
124
  });
146
125
  }
147
126
  /**
@@ -166,17 +145,17 @@ export class NetworkEnablementController extends BaseController {
166
145
  if (derivedNamespace !== namespace) {
167
146
  throw new Error(`Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`);
168
147
  }
169
- this.update((state) => {
148
+ this.update((s) => {
170
149
  // Ensure the namespace bucket exists
171
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
150
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
172
151
  // Disable all networks in the specified namespace first
173
- if (state.enabledNetworkMap[namespace]) {
174
- Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {
175
- state.enabledNetworkMap[namespace][key] = false;
152
+ if (s.enabledNetworkMap[namespace]) {
153
+ Object.keys(s.enabledNetworkMap[namespace]).forEach((key) => {
154
+ s.enabledNetworkMap[namespace][key] = false;
176
155
  });
177
156
  }
178
157
  // Enable the target network in the specified namespace
179
- state.enabledNetworkMap[namespace][storageKey] = true;
158
+ s.enabledNetworkMap[namespace][storageKey] = true;
180
159
  });
181
160
  }
182
161
  /**
@@ -190,11 +169,11 @@ export class NetworkEnablementController extends BaseController {
190
169
  * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.
191
170
  */
192
171
  enableAllPopularNetworks() {
193
- this.update((state) => {
172
+ this.update((s) => {
194
173
  // First disable all networks across all namespaces
195
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
196
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
197
- state.enabledNetworkMap[ns][key] = false;
174
+ Object.keys(s.enabledNetworkMap).forEach((ns) => {
175
+ Object.keys(s.enabledNetworkMap[ns]).forEach((key) => {
176
+ s.enabledNetworkMap[ns][key] = false;
198
177
  });
199
178
  });
200
179
  // Get current network configurations to check if networks exist
@@ -206,36 +185,35 @@ export class NetworkEnablementController extends BaseController {
206
185
  // Check if network exists in NetworkController configurations
207
186
  if (networkControllerState.networkConfigurationsByChainId[chainId]) {
208
187
  // Ensure namespace bucket exists
209
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
188
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
210
189
  // Enable the network
211
- state.enabledNetworkMap[namespace][storageKey] = true;
190
+ s.enabledNetworkMap[namespace][storageKey] = true;
212
191
  }
213
192
  });
214
193
  // Enable Solana mainnet if it exists in MultichainNetworkController configurations
215
194
  const solanaKeys = deriveKeys(SolScope.Mainnet);
216
195
  if (multichainState.multichainNetworkConfigurationsByChainId[SolScope.Mainnet]) {
217
196
  // Ensure namespace bucket exists
218
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, solanaKeys.namespace);
197
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, solanaKeys.namespace);
219
198
  // Enable Solana mainnet
220
- state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =
221
- true;
199
+ s.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] = true;
222
200
  }
223
201
  // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations
224
202
  const bitcoinKeys = deriveKeys(BtcScope.Mainnet);
225
203
  if (multichainState.multichainNetworkConfigurationsByChainId[BtcScope.Mainnet]) {
226
204
  // Ensure namespace bucket exists
227
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, bitcoinKeys.namespace);
205
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, bitcoinKeys.namespace);
228
206
  // Enable Bitcoin mainnet
229
- state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =
207
+ s.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =
230
208
  true;
231
209
  }
232
210
  // Enable Tron mainnet if it exists in MultichainNetworkController configurations
233
211
  const tronKeys = deriveKeys(TrxScope.Mainnet);
234
212
  if (multichainState.multichainNetworkConfigurationsByChainId[TrxScope.Mainnet]) {
235
213
  // Ensure namespace bucket exists
236
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, tronKeys.namespace);
214
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, tronKeys.namespace);
237
215
  // Enable Tron mainnet
238
- state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;
216
+ s.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;
239
217
  }
240
218
  });
241
219
  }
@@ -243,124 +221,39 @@ export class NetworkEnablementController extends BaseController {
243
221
  * Initializes the network enablement state from network controller configurations.
244
222
  *
245
223
  * This method reads the current network configurations from both NetworkController
246
- * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.
224
+ * and MultichainNetworkController and syncs the enabled network map accordingly.
247
225
  * It ensures proper namespace buckets exist for all configured networks and only
248
226
  * adds missing networks with a default value of false, preserving existing user settings.
249
227
  *
250
228
  * This method should be called after the NetworkController and MultichainNetworkController
251
229
  * have been initialized and their configurations are available.
252
230
  */
253
- async init() {
254
- // Get network configurations from NetworkController (EVM networks)
255
- const networkControllerState = this.messenger.call('NetworkController:getState');
256
- // Get network configurations from MultichainNetworkController (all networks)
257
- const multichainState = this.messenger.call('MultichainNetworkController:getState');
258
- // Build nativeAssetIdentifiers for EVM networks using chainid.network
259
- const evmNativeAssetUpdates = [];
260
- for (const [chainId, config] of Object.entries(networkControllerState.networkConfigurationsByChainId)) {
261
- const { caipChainId } = deriveKeys(chainId);
262
- // Skip if already in state
263
- if (this.state.nativeAssetIdentifiers[caipChainId] !== undefined) {
264
- continue;
265
- }
266
- // Parse hex chainId to number for chainid.network lookup
267
- const numericChainId = parseInt(chainId, 16);
268
- // EVM networks: use getSlip44ByChainId (chainid.network data)
269
- // Default to 60 (Ethereum) if no specific mapping is found
270
- const slip44CoinType = (await Slip44Service.getSlip44ByChainId(numericChainId, config.nativeCurrency)) ?? 60;
271
- evmNativeAssetUpdates.push({
272
- caipChainId,
273
- identifier: buildNativeAssetIdentifier(caipChainId, slip44CoinType),
274
- });
275
- }
276
- // Update state synchronously
277
- this.update((state) => {
231
+ init() {
232
+ this.update((s) => {
233
+ // Get network configurations from NetworkController (EVM networks)
234
+ const networkControllerState = this.messenger.call('NetworkController:getState');
235
+ // Get network configurations from MultichainNetworkController (all networks)
236
+ const multichainState = this.messenger.call('MultichainNetworkController:getState');
278
237
  // Initialize namespace buckets for EVM networks from NetworkController
279
- Object.entries(networkControllerState.networkConfigurationsByChainId).forEach(([chainId]) => {
280
- var _a;
238
+ Object.keys(networkControllerState.networkConfigurationsByChainId).forEach((chainId) => {
281
239
  const { namespace, storageKey } = deriveKeys(chainId);
282
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
240
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
283
241
  // Only add network if it doesn't already exist in state (preserves user settings)
284
- (_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
242
+ if (s.enabledNetworkMap[namespace][storageKey] === undefined) {
243
+ s.enabledNetworkMap[namespace][storageKey] = false;
244
+ }
285
245
  });
286
- // Apply nativeAssetIdentifier updates
287
- for (const { caipChainId, identifier } of evmNativeAssetUpdates) {
288
- state.nativeAssetIdentifiers[caipChainId] = identifier;
289
- }
290
246
  // Initialize namespace buckets for all networks from MultichainNetworkController
291
247
  Object.keys(multichainState.multichainNetworkConfigurationsByChainId).forEach((chainId) => {
292
- var _a;
293
248
  const { namespace, storageKey } = deriveKeys(chainId);
294
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
249
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
295
250
  // Only add network if it doesn't already exist in state (preserves user settings)
296
- (_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
251
+ if (s.enabledNetworkMap[namespace][storageKey] === undefined) {
252
+ s.enabledNetworkMap[namespace][storageKey] = false;
253
+ }
297
254
  });
298
255
  });
299
256
  }
300
- /**
301
- * Initializes the native asset identifiers from network configurations.
302
- * This method should be called from the client during controller initialization
303
- * to populate the nativeAssetIdentifiers state based on actual network configurations.
304
- *
305
- * @param networks - Array of network configurations with chainId and nativeCurrency
306
- * @example
307
- * ```typescript
308
- * const evmNetworks = Object.values(networkControllerState.networkConfigurationsByChainId)
309
- * .map(config => ({
310
- * chainId: toEvmCaipChainId(config.chainId),
311
- * nativeCurrency: config.nativeCurrency,
312
- * }));
313
- *
314
- * const multichainNetworks = Object.values(multichainState.multichainNetworkConfigurationsByChainId)
315
- * .map(config => ({
316
- * chainId: config.chainId,
317
- * nativeCurrency: config.nativeCurrency,
318
- * }));
319
- *
320
- * await controller.initNativeAssetIdentifiers([...evmNetworks, ...multichainNetworks]);
321
- * ```
322
- */
323
- async initNativeAssetIdentifiers(networks) {
324
- // Process networks and collect updates
325
- const updates = [];
326
- for (const { chainId, nativeCurrency } of networks) {
327
- // Check if nativeCurrency is already in CAIP-19 format (e.g., "bip122:.../slip44:0")
328
- // Non-EVM networks from MultichainNetworkController use this format
329
- if (nativeCurrency.includes('/slip44:')) {
330
- updates.push({
331
- chainId,
332
- identifier: nativeCurrency,
333
- });
334
- continue;
335
- }
336
- // Extract namespace from CAIP-2 chainId
337
- const [namespace, reference] = chainId.split(':');
338
- let slip44CoinType;
339
- if (namespace === 'eip155') {
340
- // EVM networks: use getSlip44ByChainId (chainid.network data)
341
- // Default to 60 (Ethereum) if no specific mapping is found
342
- const numericChainId = parseInt(reference, 10);
343
- slip44CoinType =
344
- (await Slip44Service.getSlip44ByChainId(numericChainId, nativeCurrency)) ?? 60;
345
- }
346
- else {
347
- // Non-EVM networks: use getSlip44BySymbol (@metamask/slip44 package)
348
- slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);
349
- }
350
- if (slip44CoinType !== undefined) {
351
- updates.push({
352
- chainId,
353
- identifier: buildNativeAssetIdentifier(chainId, slip44CoinType),
354
- });
355
- }
356
- }
357
- // Apply all updates synchronously
358
- this.update((state) => {
359
- for (const { chainId, identifier } of updates) {
360
- state.nativeAssetIdentifiers[chainId] = identifier;
361
- }
362
- });
363
- }
364
257
  /**
365
258
  * Disables a network for the user.
366
259
  *
@@ -378,8 +271,8 @@ export class NetworkEnablementController extends BaseController {
378
271
  disableNetwork(chainId) {
379
272
  const derivedKeys = deriveKeys(chainId);
380
273
  const { namespace, storageKey } = derivedKeys;
381
- this.update((state) => {
382
- state.enabledNetworkMap[namespace][storageKey] = false;
274
+ this.update((s) => {
275
+ s.enabledNetworkMap[namespace][storageKey] = false;
383
276
  });
384
277
  }
385
278
  /**
@@ -417,42 +310,22 @@ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementContro
417
310
  return enabledPopularNetworksCount > 1;
418
311
  }, _NetworkEnablementController_removeNetworkEntry = function _NetworkEnablementController_removeNetworkEntry(chainId) {
419
312
  const derivedKeys = deriveKeys(chainId);
420
- const { namespace, storageKey, caipChainId } = derivedKeys;
421
- this.update((state) => {
313
+ const { namespace, storageKey } = derivedKeys;
314
+ this.update((s) => {
422
315
  // fallback and enable ethereum mainnet
423
316
  if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {
424
- state.enabledNetworkMap[namespace][ChainId[BuiltInNetworkName.Mainnet]] = true;
317
+ s.enabledNetworkMap[namespace][ChainId[BuiltInNetworkName.Mainnet]] =
318
+ true;
425
319
  }
426
- if (namespace in state.enabledNetworkMap) {
427
- delete state.enabledNetworkMap[namespace][storageKey];
320
+ if (namespace in s.enabledNetworkMap) {
321
+ delete s.enabledNetworkMap[namespace][storageKey];
428
322
  }
429
- // Remove from nativeAssetIdentifiers as well
430
- delete state.nativeAssetIdentifiers[caipChainId];
431
323
  });
432
- }, _NetworkEnablementController_onAddNetwork =
433
- /**
434
- * Handles the addition of a new EVM network to the controller.
435
- *
436
- * @param chainId - The chain ID to add (Hex format)
437
- * @param nativeCurrency - The native currency symbol of the network (e.g., 'ETH')
438
- *
439
- * @description
440
- * - If in popular networks mode (>2 popular networks enabled) AND adding a popular network:
441
- * - Keep current selection (add but don't enable the new network)
442
- * - Otherwise:
443
- * - Switch to the newly added network (disable all others, enable this one)
444
- * - Also updates the nativeAssetIdentifiers with the CAIP-19-like identifier
445
- */
446
- async function _NetworkEnablementController_onAddNetwork(chainId, nativeCurrency) {
447
- const { namespace, storageKey, reference, caipChainId } = deriveKeys(chainId);
448
- // Parse hex chainId to number for chainid.network lookup
449
- const numericChainId = parseInt(reference, 16);
450
- // EVM networks: use getSlip44ByChainId (chainid.network data)
451
- // Default to 60 (Ethereum) if no specific mapping is found
452
- const slip44CoinType = (await Slip44Service.getSlip44ByChainId(numericChainId, nativeCurrency)) ?? 60;
453
- this.update((state) => {
324
+ }, _NetworkEnablementController_onAddNetwork = function _NetworkEnablementController_onAddNetwork(chainId) {
325
+ const { namespace, storageKey, reference } = deriveKeys(chainId);
326
+ this.update((s) => {
454
327
  // Ensure the namespace bucket exists
455
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
328
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
456
329
  // Check if popular networks mode is active (>2 popular networks enabled)
457
330
  const inPopularNetworksMode = __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_isInPopularNetworksMode).call(this);
458
331
  // Check if the network being added is a popular network
@@ -461,20 +334,18 @@ async function _NetworkEnablementController_onAddNetwork(chainId, nativeCurrency
461
334
  const shouldKeepCurrentSelection = inPopularNetworksMode && isAddedNetworkPopular;
462
335
  if (shouldKeepCurrentSelection) {
463
336
  // Add the popular network but don't enable it (keep current selection)
464
- state.enabledNetworkMap[namespace][storageKey] = true;
337
+ s.enabledNetworkMap[namespace][storageKey] = true;
465
338
  }
466
339
  else {
467
340
  // Switch to the newly added network (disable all others, enable this one)
468
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
469
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
470
- state.enabledNetworkMap[ns][key] = false;
341
+ Object.keys(s.enabledNetworkMap).forEach((ns) => {
342
+ Object.keys(s.enabledNetworkMap[ns]).forEach((key) => {
343
+ s.enabledNetworkMap[ns][key] = false;
471
344
  });
472
345
  });
473
346
  // Enable the newly added network
474
- state.enabledNetworkMap[namespace][storageKey] = true;
347
+ s.enabledNetworkMap[namespace][storageKey] = true;
475
348
  }
476
- // Update nativeAssetIdentifiers with the CAIP-19-like identifier
477
- state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(caipChainId, slip44CoinType);
478
349
  });
479
350
  };
480
351
  //# sourceMappingURL=NetworkEnablementController.mjs.map