@metamask-previews/network-controller 23.1.0-preview-51a838b → 23.1.0-preview-7d8354f

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.
@@ -129,6 +129,10 @@ function getDefaultNetworkConfigurationsByChainId(additionalDefaultNetworks = []
129
129
  function getDefaultInfuraNetworkConfigurationsByChainId() {
130
130
  return Object.values(controller_utils_1.InfuraNetworkType).reduce((obj, infuraNetworkType) => {
131
131
  const chainId = controller_utils_1.ChainId[infuraNetworkType];
132
+ // Skip deprecated network as default network.
133
+ if (constants_1.DEPRECATED_NETWORKS.has(chainId)) {
134
+ return obj;
135
+ }
132
136
  const rpcEndpointUrl =
133
137
  // This ESLint rule mistakenly produces an error.
134
138
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
@@ -416,10 +420,8 @@ class NetworkController extends base_controller_1.BaseController {
416
420
  // ESLint is mistaken here; `name` is a string.
417
421
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
418
422
  `${this.name}:getNetworkConfigurationByNetworkClientId`, this.getNetworkConfigurationByNetworkClientId.bind(this));
419
- this.messagingSystem.registerActionHandler(
420
- // TODO: Either fix this lint violation or explain why it's necessary to ignore.
421
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
422
- `${this.name}:getSelectedNetworkClient`, this.getSelectedNetworkClient.bind(this));
423
+ this.messagingSystem.registerActionHandler(`${this.name}:getSelectedNetworkClient`, this.getSelectedNetworkClient.bind(this));
424
+ this.messagingSystem.registerActionHandler(`${this.name}:getSelectedChainId`, this.getSelectedChainId.bind(this));
423
425
  this.messagingSystem.registerActionHandler(
424
426
  // ESLint is mistaken here; `name` is a string.
425
427
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
@@ -458,6 +460,15 @@ class NetworkController extends base_controller_1.BaseController {
458
460
  }
459
461
  return undefined;
460
462
  }
463
+ /**
464
+ * Accesses the chain ID from the selected network client.
465
+ *
466
+ * @returns The chain ID of the selected network client in hex format or undefined if there is no network client.
467
+ */
468
+ getSelectedChainId() {
469
+ const networkConfiguration = this.getNetworkConfigurationByNetworkClientId(this.state.selectedNetworkClientId);
470
+ return networkConfiguration?.chainId;
471
+ }
461
472
  /**
462
473
  * Internally, the Infura and custom network clients are categorized by type
463
474
  * so that when accessing either kind of network client, TypeScript knows