@metamask-previews/network-enablement-controller 4.0.0-preview-f075c1f → 4.0.0-preview-821afcb8

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 +56 -161
  3. package/dist/NetworkEnablementController.cjs.map +1 -1
  4. package/dist/NetworkEnablementController.d.cts +1 -51
  5. package/dist/NetworkEnablementController.d.cts.map +1 -1
  6. package/dist/NetworkEnablementController.d.mts +1 -51
  7. package/dist/NetworkEnablementController.d.mts.map +1 -1
  8. package/dist/NetworkEnablementController.mjs +56 -161
  9. package/dist/NetworkEnablementController.mjs.map +1 -1
  10. package/dist/index.cjs +1 -3
  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 -82
  20. package/dist/services/Slip44Service.cjs.map +0 -1
  21. package/dist/services/Slip44Service.d.cts +0 -46
  22. package/dist/services/Slip44Service.d.cts.map +0 -1
  23. package/dist/services/Slip44Service.d.mts +0 -46
  24. package/dist/services/Slip44Service.d.mts.map +0 -1
  25. package/dist/services/Slip44Service.mjs +0 -75
  26. package/dist/services/Slip44Service.mjs.map +0 -1
  27. package/dist/services/index.cjs +0 -6
  28. package/dist/services/index.cjs.map +0 -1
  29. package/dist/services/index.d.cts +0 -3
  30. package/dist/services/index.d.cts.map +0 -1
  31. package/dist/services/index.d.mts +0 -3
  32. package/dist/services/index.d.mts.map +0 -1
  33. package/dist/services/index.mjs +0 -2
  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,7 +116,7 @@ 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
  *
@@ -150,30 +124,6 @@ export declare class NetworkEnablementController extends BaseController<typeof c
150
124
  * have been initialized and their configurations are available.
151
125
  */
152
126
  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;
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,EAC/B,kCAAk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GAAG,IAAI;IAShD;;;;;;;OAOG;IACH,gBAAgB,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;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+C,GAAG;IAC5D,IAAI,EAAE,GAAG,OAAO,cAAc,iB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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,7 +116,7 @@ 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
  *
@@ -150,30 +124,6 @@ export declare class NetworkEnablementController extends BaseController<typeof c
150
124
  * have been initialized and their configurations are available.
151
125
  */
152
126
  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;
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":"AAAA,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,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,IAAI;IAiDZ;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,0BAA0B,CAAC,QAAQ,EAAE,aAAa,EAAE,GAAG,IAAI;IAuB3D;;;;;;;;;;;;;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,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,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AI;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"}
@@ -3,25 +3,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
3
3
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
4
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
5
  };
6
- var _NetworkEnablementController_instances, _NetworkEnablementController_onNetworkControllerStateChange, _NetworkEnablementController_ensureNamespaceBucket, _NetworkEnablementController_updateNativeAssetIdentifier, _NetworkEnablementController_isInPopularNetworksMode, _NetworkEnablementController_removeNetworkEntry, _NetworkEnablementController_onAddNetwork;
6
+ var _NetworkEnablementController_instances, _NetworkEnablementController_ensureNamespaceBucket, _NetworkEnablementController_isInPopularNetworksMode, _NetworkEnablementController_removeNetworkEntry, _NetworkEnablementController_onAddNetwork;
7
7
  import { BaseController } from "@metamask/base-controller";
8
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,15 +82,12 @@ export class NetworkEnablementController extends BaseController {
102
82
  },
103
83
  });
104
84
  _NetworkEnablementController_instances.add(this);
105
- messenger.subscribe('NetworkController:networkAdded', ({ chainId, nativeCurrency }) => {
106
- __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);
107
87
  });
108
88
  messenger.subscribe('NetworkController:networkRemoved', ({ chainId }) => {
109
89
  __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_removeNetworkEntry).call(this, chainId);
110
90
  });
111
- messenger.subscribe('NetworkController:stateChange', (_newState, patches) => {
112
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_onNetworkControllerStateChange).call(this, patches);
113
- });
114
91
  }
115
92
  /**
116
93
  * Enables or disables a network for the user.
@@ -130,20 +107,20 @@ export class NetworkEnablementController extends BaseController {
130
107
  */
131
108
  enableNetwork(chainId) {
132
109
  const { namespace, storageKey } = deriveKeys(chainId);
133
- this.update((state) => {
110
+ this.update((s) => {
134
111
  // disable all networks in all namespaces first
135
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
136
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
137
- 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;
138
115
  });
139
116
  });
140
117
  // if the namespace bucket does not exist, return
141
118
  // new nemespace are added only when a new network is added
142
- if (!state.enabledNetworkMap[namespace]) {
119
+ if (!s.enabledNetworkMap[namespace]) {
143
120
  return;
144
121
  }
145
122
  // enable the network
146
- state.enabledNetworkMap[namespace][storageKey] = true;
123
+ s.enabledNetworkMap[namespace][storageKey] = true;
147
124
  });
148
125
  }
149
126
  /**
@@ -168,17 +145,17 @@ export class NetworkEnablementController extends BaseController {
168
145
  if (derivedNamespace !== namespace) {
169
146
  throw new Error(`Chain ID ${chainId} belongs to namespace ${derivedNamespace}, but namespace ${namespace} was specified`);
170
147
  }
171
- this.update((state) => {
148
+ this.update((s) => {
172
149
  // Ensure the namespace bucket exists
173
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
150
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
174
151
  // Disable all networks in the specified namespace first
175
- if (state.enabledNetworkMap[namespace]) {
176
- Object.keys(state.enabledNetworkMap[namespace]).forEach((key) => {
177
- state.enabledNetworkMap[namespace][key] = false;
152
+ if (s.enabledNetworkMap[namespace]) {
153
+ Object.keys(s.enabledNetworkMap[namespace]).forEach((key) => {
154
+ s.enabledNetworkMap[namespace][key] = false;
178
155
  });
179
156
  }
180
157
  // Enable the target network in the specified namespace
181
- state.enabledNetworkMap[namespace][storageKey] = true;
158
+ s.enabledNetworkMap[namespace][storageKey] = true;
182
159
  });
183
160
  }
184
161
  /**
@@ -192,11 +169,11 @@ export class NetworkEnablementController extends BaseController {
192
169
  * Popular networks that don't exist in NetworkController or MultichainNetworkController configurations will be skipped silently.
193
170
  */
194
171
  enableAllPopularNetworks() {
195
- this.update((state) => {
172
+ this.update((s) => {
196
173
  // First disable all networks across all namespaces
197
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
198
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
199
- 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;
200
177
  });
201
178
  });
202
179
  // Get current network configurations to check if networks exist
@@ -208,36 +185,35 @@ export class NetworkEnablementController extends BaseController {
208
185
  // Check if network exists in NetworkController configurations
209
186
  if (networkControllerState.networkConfigurationsByChainId[chainId]) {
210
187
  // Ensure namespace bucket exists
211
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
188
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
212
189
  // Enable the network
213
- state.enabledNetworkMap[namespace][storageKey] = true;
190
+ s.enabledNetworkMap[namespace][storageKey] = true;
214
191
  }
215
192
  });
216
193
  // Enable Solana mainnet if it exists in MultichainNetworkController configurations
217
194
  const solanaKeys = deriveKeys(SolScope.Mainnet);
218
195
  if (multichainState.multichainNetworkConfigurationsByChainId[SolScope.Mainnet]) {
219
196
  // Ensure namespace bucket exists
220
- __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);
221
198
  // Enable Solana mainnet
222
- state.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] =
223
- true;
199
+ s.enabledNetworkMap[solanaKeys.namespace][solanaKeys.storageKey] = true;
224
200
  }
225
201
  // Enable Bitcoin mainnet if it exists in MultichainNetworkController configurations
226
202
  const bitcoinKeys = deriveKeys(BtcScope.Mainnet);
227
203
  if (multichainState.multichainNetworkConfigurationsByChainId[BtcScope.Mainnet]) {
228
204
  // Ensure namespace bucket exists
229
- __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);
230
206
  // Enable Bitcoin mainnet
231
- state.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =
207
+ s.enabledNetworkMap[bitcoinKeys.namespace][bitcoinKeys.storageKey] =
232
208
  true;
233
209
  }
234
210
  // Enable Tron mainnet if it exists in MultichainNetworkController configurations
235
211
  const tronKeys = deriveKeys(TrxScope.Mainnet);
236
212
  if (multichainState.multichainNetworkConfigurationsByChainId[TrxScope.Mainnet]) {
237
213
  // Ensure namespace bucket exists
238
- __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);
239
215
  // Enable Tron mainnet
240
- state.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;
216
+ s.enabledNetworkMap[tronKeys.namespace][tronKeys.storageKey] = true;
241
217
  }
242
218
  });
243
219
  }
@@ -245,7 +221,7 @@ export class NetworkEnablementController extends BaseController {
245
221
  * Initializes the network enablement state from network controller configurations.
246
222
  *
247
223
  * This method reads the current network configurations from both NetworkController
248
- * and MultichainNetworkController and syncs the enabled network map and nativeAssetIdentifiers accordingly.
224
+ * and MultichainNetworkController and syncs the enabled network map accordingly.
249
225
  * It ensures proper namespace buckets exist for all configured networks and only
250
226
  * adds missing networks with a default value of false, preserving existing user settings.
251
227
  *
@@ -253,77 +229,29 @@ export class NetworkEnablementController extends BaseController {
253
229
  * have been initialized and their configurations are available.
254
230
  */
255
231
  init() {
256
- this.update((state) => {
232
+ this.update((s) => {
257
233
  // Get network configurations from NetworkController (EVM networks)
258
234
  const networkControllerState = this.messenger.call('NetworkController:getState');
259
235
  // Get network configurations from MultichainNetworkController (all networks)
260
236
  const multichainState = this.messenger.call('MultichainNetworkController:getState');
261
237
  // Initialize namespace buckets for EVM networks from NetworkController
262
- Object.entries(networkControllerState.networkConfigurationsByChainId).forEach(([chainId, config]) => {
263
- var _a;
264
- const { namespace, storageKey, caipChainId } = deriveKeys(chainId);
265
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
238
+ Object.keys(networkControllerState.networkConfigurationsByChainId).forEach((chainId) => {
239
+ const { namespace, storageKey } = deriveKeys(chainId);
240
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
266
241
  // Only add network if it doesn't already exist in state (preserves user settings)
267
- (_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
268
- // Sync nativeAssetIdentifiers using the nativeCurrency symbol
269
- if (state.nativeAssetIdentifiers[caipChainId] === undefined) {
270
- const slip44CoinType = Slip44Service.getSlip44BySymbol(config.nativeCurrency);
271
- if (slip44CoinType !== undefined) {
272
- state.nativeAssetIdentifiers[caipChainId] =
273
- buildNativeAssetIdentifier(caipChainId, slip44CoinType);
274
- }
242
+ if (s.enabledNetworkMap[namespace][storageKey] === undefined) {
243
+ s.enabledNetworkMap[namespace][storageKey] = false;
275
244
  }
276
245
  });
277
246
  // Initialize namespace buckets for all networks from MultichainNetworkController
278
247
  Object.keys(multichainState.multichainNetworkConfigurationsByChainId).forEach((chainId) => {
279
- var _a;
280
248
  const { namespace, storageKey } = deriveKeys(chainId);
281
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
249
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
282
250
  // Only add network if it doesn't already exist in state (preserves user settings)
283
- (_a = state.enabledNetworkMap[namespace])[storageKey] ?? (_a[storageKey] = false);
284
- });
285
- });
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
- // Check if nativeCurrency is already in CAIP-19 format (e.g., "bip122:.../slip44:0")
314
- // Non-EVM networks from MultichainNetworkController use this format
315
- if (nativeCurrency.includes('/slip44:')) {
316
- state.nativeAssetIdentifiers[chainId] =
317
- nativeCurrency;
318
- }
319
- else {
320
- // EVM networks use simple symbols like "ETH", "BNB"
321
- const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);
322
- if (slip44CoinType !== undefined) {
323
- state.nativeAssetIdentifiers[chainId] = buildNativeAssetIdentifier(chainId, slip44CoinType);
324
- }
251
+ if (s.enabledNetworkMap[namespace][storageKey] === undefined) {
252
+ s.enabledNetworkMap[namespace][storageKey] = false;
325
253
  }
326
- }
254
+ });
327
255
  });
328
256
  }
329
257
  /**
@@ -343,8 +271,8 @@ export class NetworkEnablementController extends BaseController {
343
271
  disableNetwork(chainId) {
344
272
  const derivedKeys = deriveKeys(chainId);
345
273
  const { namespace, storageKey } = derivedKeys;
346
- this.update((state) => {
347
- state.enabledNetworkMap[namespace][storageKey] = false;
274
+ this.update((s) => {
275
+ s.enabledNetworkMap[namespace][storageKey] = false;
348
276
  });
349
277
  }
350
278
  /**
@@ -361,36 +289,10 @@ export class NetworkEnablementController extends BaseController {
361
289
  return this.state.enabledNetworkMap[namespace]?.[storageKey] ?? false;
362
290
  }
363
291
  }
364
- _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementController_onNetworkControllerStateChange = function _NetworkEnablementController_onNetworkControllerStateChange(patches) {
365
- // Look for patches that replace a network configuration
366
- // Path format: ['networkConfigurationsByChainId', chainId]
367
- for (const patch of patches) {
368
- if (patch.path.length === 2 &&
369
- patch.path[0] === 'networkConfigurationsByChainId' &&
370
- patch.op === 'replace' &&
371
- patch.value &&
372
- typeof patch.value === 'object' &&
373
- 'nativeCurrency' in patch.value) {
374
- const chainId = patch.path[1];
375
- const networkConfig = patch.value;
376
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_updateNativeAssetIdentifier).call(this, chainId, networkConfig.nativeCurrency);
377
- }
378
- }
379
- }, _NetworkEnablementController_ensureNamespaceBucket = function _NetworkEnablementController_ensureNamespaceBucket(state, ns) {
292
+ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementController_ensureNamespaceBucket = function _NetworkEnablementController_ensureNamespaceBucket(state, ns) {
380
293
  if (!state.enabledNetworkMap[ns]) {
381
294
  state.enabledNetworkMap[ns] = {};
382
295
  }
383
- }, _NetworkEnablementController_updateNativeAssetIdentifier = function _NetworkEnablementController_updateNativeAssetIdentifier(chainId, symbol) {
384
- const slip44CoinType = Slip44Service.getSlip44BySymbol(symbol);
385
- const { caipChainId } = deriveKeys(chainId);
386
- this.update((state) => {
387
- if (slip44CoinType === undefined) {
388
- // Remove the entry if no SLIP-44 mapping exists for the symbol
389
- delete state.nativeAssetIdentifiers[caipChainId];
390
- return;
391
- }
392
- state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(caipChainId, slip44CoinType);
393
- });
394
296
  }, _NetworkEnablementController_isInPopularNetworksMode = function _NetworkEnablementController_isInPopularNetworksMode() {
395
297
  // Get current network configurations to check which popular networks exist
396
298
  const networkControllerState = this.messenger.call('NetworkController:getState');
@@ -408,25 +310,22 @@ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementContro
408
310
  return enabledPopularNetworksCount > 1;
409
311
  }, _NetworkEnablementController_removeNetworkEntry = function _NetworkEnablementController_removeNetworkEntry(chainId) {
410
312
  const derivedKeys = deriveKeys(chainId);
411
- const { namespace, storageKey, caipChainId } = derivedKeys;
412
- this.update((state) => {
313
+ const { namespace, storageKey } = derivedKeys;
314
+ this.update((s) => {
413
315
  // fallback and enable ethereum mainnet
414
316
  if (isOnlyNetworkEnabledInNamespace(this.state, derivedKeys)) {
415
- state.enabledNetworkMap[namespace][ChainId[BuiltInNetworkName.Mainnet]] = true;
317
+ s.enabledNetworkMap[namespace][ChainId[BuiltInNetworkName.Mainnet]] =
318
+ true;
416
319
  }
417
- if (namespace in state.enabledNetworkMap) {
418
- delete state.enabledNetworkMap[namespace][storageKey];
320
+ if (namespace in s.enabledNetworkMap) {
321
+ delete s.enabledNetworkMap[namespace][storageKey];
419
322
  }
420
- // Remove from nativeAssetIdentifiers as well
421
- delete state.nativeAssetIdentifiers[caipChainId];
422
323
  });
423
- }, _NetworkEnablementController_onAddNetwork = function _NetworkEnablementController_onAddNetwork(chainId, nativeCurrency) {
424
- const { namespace, storageKey, reference, caipChainId } = deriveKeys(chainId);
425
- // Look up the SLIP-44 coin type for the native currency
426
- const slip44CoinType = Slip44Service.getSlip44BySymbol(nativeCurrency);
427
- this.update((state) => {
324
+ }, _NetworkEnablementController_onAddNetwork = function _NetworkEnablementController_onAddNetwork(chainId) {
325
+ const { namespace, storageKey, reference } = deriveKeys(chainId);
326
+ this.update((s) => {
428
327
  // Ensure the namespace bucket exists
429
- __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, state, namespace);
328
+ __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_ensureNamespaceBucket).call(this, s, namespace);
430
329
  // Check if popular networks mode is active (>2 popular networks enabled)
431
330
  const inPopularNetworksMode = __classPrivateFieldGet(this, _NetworkEnablementController_instances, "m", _NetworkEnablementController_isInPopularNetworksMode).call(this);
432
331
  // Check if the network being added is a popular network
@@ -435,21 +334,17 @@ _NetworkEnablementController_instances = new WeakSet(), _NetworkEnablementContro
435
334
  const shouldKeepCurrentSelection = inPopularNetworksMode && isAddedNetworkPopular;
436
335
  if (shouldKeepCurrentSelection) {
437
336
  // Add the popular network but don't enable it (keep current selection)
438
- state.enabledNetworkMap[namespace][storageKey] = true;
337
+ s.enabledNetworkMap[namespace][storageKey] = true;
439
338
  }
440
339
  else {
441
340
  // Switch to the newly added network (disable all others, enable this one)
442
- Object.keys(state.enabledNetworkMap).forEach((ns) => {
443
- Object.keys(state.enabledNetworkMap[ns]).forEach((key) => {
444
- 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;
445
344
  });
446
345
  });
447
346
  // Enable the newly added network
448
- state.enabledNetworkMap[namespace][storageKey] = true;
449
- }
450
- // Update nativeAssetIdentifiers with the CAIP-19-like identifier
451
- if (slip44CoinType !== undefined) {
452
- state.nativeAssetIdentifiers[caipChainId] = buildNativeAssetIdentifier(caipChainId, slip44CoinType);
347
+ s.enabledNetworkMap[namespace][storageKey] = true;
453
348
  }
454
349
  });
455
350
  };