@metamask-previews/network-controller 35.0.1-preview-2c4135ed6 → 35.0.1-preview-fa46676

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 CHANGED
@@ -7,11 +7,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Changed
11
-
12
- - **BREAKING:** `NetworkControllerMessenger` now requires the `ConfigRegistryController:stateChanged` event and `ConfigRegistryController:getNetworkConfigByCaip2ChainId` action to be delegated from the root messenger ([#9879](https://github.com/MetaMask/core/pull/9879))
13
- - `NetworkController` now depends on the `ConfigRegistryController` to auto-enable default networks from the registry.
14
-
15
10
  ## [35.0.1]
16
11
 
17
12
  ### Changed
@@ -36,7 +36,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
36
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
37
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
38
38
  };
39
- var _NetworkController_instances, _NetworkController_ethQuery, _NetworkController_infuraProjectId, _NetworkController_failoverUrls, _NetworkController_previouslySelectedNetworkClientId, _NetworkController_providerProxy, _NetworkController_blockTrackerProxy, _NetworkController_autoManagedNetworkClientRegistry, _NetworkController_autoManagedNetworkClient, _NetworkController_log, _NetworkController_getRpcServiceOptions, _NetworkController_getBlockTrackerOptions, _NetworkController_analyticsOptions, _NetworkController_networkConfigurationsByNetworkClientId, _NetworkController_rpcFailoverMode, _NetworkController_updateRpcFailover, _NetworkController_refreshNetwork, _NetworkController_determineNetworkMetadata, _NetworkController_lookupGivenNetwork, _NetworkController_lookupSelectedNetwork, _NetworkController_updateMetadataForNetwork, _NetworkController_getLatestBlock, _NetworkController_determineEIP1559Compatibility, _NetworkController_validateNetworkFields, _NetworkController_determineNetworkConfigurationToPersist, _NetworkController_registerNetworkClientsAsNeeded, _NetworkController_unregisterNetworkClientsAsNeeded, _NetworkController_updateNetworkConfigurations, _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated, _NetworkController_createAutoManagedNetworkClientRegistry, _NetworkController_applyNetworkSelection, _NetworkController_autoEnableChains;
39
+ var _NetworkController_instances, _NetworkController_ethQuery, _NetworkController_infuraProjectId, _NetworkController_failoverUrls, _NetworkController_previouslySelectedNetworkClientId, _NetworkController_providerProxy, _NetworkController_blockTrackerProxy, _NetworkController_autoManagedNetworkClientRegistry, _NetworkController_autoManagedNetworkClient, _NetworkController_log, _NetworkController_getRpcServiceOptions, _NetworkController_getBlockTrackerOptions, _NetworkController_analyticsOptions, _NetworkController_networkConfigurationsByNetworkClientId, _NetworkController_rpcFailoverMode, _NetworkController_updateRpcFailover, _NetworkController_refreshNetwork, _NetworkController_determineNetworkMetadata, _NetworkController_lookupGivenNetwork, _NetworkController_lookupSelectedNetwork, _NetworkController_updateMetadataForNetwork, _NetworkController_getLatestBlock, _NetworkController_determineEIP1559Compatibility, _NetworkController_validateNetworkFields, _NetworkController_determineNetworkConfigurationToPersist, _NetworkController_registerNetworkClientsAsNeeded, _NetworkController_unregisterNetworkClientsAsNeeded, _NetworkController_updateNetworkConfigurations, _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated, _NetworkController_createAutoManagedNetworkClientRegistry, _NetworkController_applyNetworkSelection;
40
40
  Object.defineProperty(exports, "__esModule", { value: true });
41
41
  exports.NetworkController = exports.selectAvailableNetworkClientIds = exports.getAvailableNetworkClientIds = exports.selectNetworkConfigurations = exports.getNetworkConfigurations = exports.getDefaultNetworkControllerState = exports.knownKeysOf = exports.RpcEndpointType = void 0;
42
42
  const base_controller_1 = require("@metamask/base-controller");
@@ -473,7 +473,6 @@ class NetworkController extends base_controller_1.BaseController {
473
473
  'RemoteFeatureFlagController:stateChange', (rpcFailoverMode) => {
474
474
  __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_updateRpcFailover).call(this, rpcFailoverMode);
475
475
  }, selectors_js_1.getRpcFailoverMode);
476
- this.messenger.subscribe('ConfigRegistryController:stateChanged', (autoEnabledChains) => __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_autoEnableChains).call(this, autoEnabledChains), selectors_js_1.getConfigRegistryEvmAutoEnabledChains);
477
476
  }
478
477
  /**
479
478
  * Returns the EthQuery instance for the currently selected network.
@@ -548,16 +547,14 @@ class NetworkController extends base_controller_1.BaseController {
548
547
  return customNetworkClient;
549
548
  }
550
549
  /**
551
- * Initialize the NetworkController:
552
- * - Apply the RPC failover mode from the `corePlatformRpcFailoverMode` remote feature flag;
553
- * - Apply the network selection.
554
- * - Auto-enable any chains that are configured to be auto-enabled in ConfigRegistryController.
550
+ * Initialize the NetworkController, applying the RPC failover mode from the
551
+ * `corePlatformRpcFailoverMode` remote feature flag and applying the network
552
+ * selection.
555
553
  */
556
554
  init() {
557
555
  const state = this.messenger.call('RemoteFeatureFlagController:getState');
558
556
  __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_updateRpcFailover).call(this, (0, selectors_js_1.getRpcFailoverMode)(state));
559
557
  __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_applyNetworkSelection).call(this, this.state.selectedNetworkClientId);
560
- __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_autoEnableChains).call(this, (0, selectors_js_1.getConfigRegistryEvmAutoEnabledChains)(this.messenger.call('ConfigRegistryController:getState')));
561
558
  }
562
559
  /**
563
560
  * Uses a request for the latest block to gather the following information on
@@ -1558,34 +1555,5 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1558
1555
  }), "f");
1559
1556
  }
1560
1557
  __classPrivateFieldSet(this, _NetworkController_ethQuery, new eth_query_1.default(__classPrivateFieldGet(this, _NetworkController_providerProxy, "f")), "f");
1561
- }, _NetworkController_autoEnableChains = function _NetworkController_autoEnableChains(chainIds) {
1562
- for (const chainId of chainIds) {
1563
- const networkConfiguration = this.messenger.call('ConfigRegistryController:getNetworkConfigByCaip2ChainId', chainId);
1564
- const hexChainId = (0, utils_1.numberToHex)(Number((0, utils_1.parseCaipChainId)(chainId).reference));
1565
- if (!networkConfiguration ||
1566
- this.state.networkConfigurationsByChainId[hexChainId]) {
1567
- return;
1568
- }
1569
- const rpcEndpoint = networkConfiguration.rpcProviders.default.type === 'infura'
1570
- ? {
1571
- type: RpcEndpointType.Infura,
1572
- networkClientId: networkConfiguration.rpcProviders.default.networkClientId,
1573
- url: networkConfiguration.rpcProviders.default
1574
- .url,
1575
- }
1576
- : {
1577
- type: RpcEndpointType.Custom,
1578
- url: networkConfiguration.rpcProviders.default.url,
1579
- };
1580
- this.addNetwork({
1581
- chainId: hexChainId,
1582
- name: networkConfiguration.name,
1583
- nativeCurrency: networkConfiguration.assets.native.symbol,
1584
- rpcEndpoints: [rpcEndpoint],
1585
- defaultRpcEndpointIndex: 0,
1586
- blockExplorerUrls: [networkConfiguration.blockExplorerUrls.default],
1587
- defaultBlockExplorerUrlIndex: 0,
1588
- });
1589
- }
1590
1558
  };
1591
1559
  //# sourceMappingURL=NetworkController.cjs.map