@metamask-previews/network-controller 23.2.0-preview-3a413f88 → 23.2.0-preview-3fadbce0

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.
@@ -396,6 +396,7 @@ class NetworkController extends base_controller_1.BaseController {
396
396
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
397
397
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
398
398
  `${this.name}:getNetworkClientById`, this.getNetworkClientById.bind(this));
399
+ this.messagingSystem.registerActionHandler(`${this.name}:getNetworkClientIdByChainId`, this.getNetworkClientIdByChainId.bind(this));
399
400
  this.messagingSystem.registerActionHandler(
400
401
  // TODO: Either fix this lint violation or explain why it's necessary to ignore.
401
402
  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
@@ -812,6 +813,13 @@ class NetworkController extends base_controller_1.BaseController {
812
813
  getNetworkConfigurationByChainId(chainId) {
813
814
  return this.state.networkConfigurationsByChainId[chainId];
814
815
  }
816
+ getNetworkClientIdByChainId(chainId) {
817
+ const networkConfiguration = this.getNetworkConfigurationByChainId(chainId);
818
+ if (networkConfiguration) {
819
+ return networkConfiguration.rpcEndpoints[networkConfiguration.defaultRpcEndpointIndex]?.networkClientId;
820
+ }
821
+ return undefined;
822
+ }
815
823
  /**
816
824
  * Returns the network configuration that contains an RPC endpoint with the
817
825
  * given network client ID.