@metamask-previews/network-controller 22.2.1-preview-912bed25 → 22.2.1-preview-b4d33c51
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 +4 -0
- package/dist/NetworkController.cjs +11 -8
- package/dist/NetworkController.cjs.map +1 -1
- package/dist/NetworkController.d.cts +6 -3
- package/dist/NetworkController.d.cts.map +1 -1
- package/dist/NetworkController.d.mts +6 -3
- package/dist/NetworkController.d.mts.map +1 -1
- package/dist/NetworkController.mjs +11 -8
- package/dist/NetworkController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -42,6 +42,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
42
42
|
- Bump `@metamask/eth-json-rpc-infura` to `^10.1.0`
|
|
43
43
|
- Bump `@metamask/eth-json-rpc-middleware` to `^15.1.0`
|
|
44
44
|
|
|
45
|
+
### Fixed
|
|
46
|
+
|
|
47
|
+
- Fix `findNetworkClientIdByChainId` to return the network client ID for the chain's configured default RPC endpoint instead of its first listed RPC endpoint ([#5344](https://github.com/MetaMask/core/pull/5344))
|
|
48
|
+
|
|
45
49
|
## [22.2.1]
|
|
46
50
|
|
|
47
51
|
### Changed
|
|
@@ -1094,18 +1094,21 @@ class NetworkController extends base_controller_1.BaseController {
|
|
|
1094
1094
|
});
|
|
1095
1095
|
}
|
|
1096
1096
|
/**
|
|
1097
|
-
* Searches for
|
|
1097
|
+
* Searches for the default RPC endpoint configured for the given chain and
|
|
1098
|
+
* returns its network client ID. This can then be passed to
|
|
1099
|
+
* {@link getNetworkClientById} to retrieve the network client.
|
|
1098
1100
|
*
|
|
1099
|
-
* @param chainId -
|
|
1100
|
-
* @returns
|
|
1101
|
+
* @param chainId - Chain ID to search for.
|
|
1102
|
+
* @returns The ID of the network client created for the chain's default RPC
|
|
1103
|
+
* endpoint.
|
|
1101
1104
|
*/
|
|
1102
1105
|
findNetworkClientIdByChainId(chainId) {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
throw new Error("Couldn't find networkClientId for chainId");
|
|
1106
|
+
const networkConfiguration = this.state.networkConfigurationsByChainId[chainId];
|
|
1107
|
+
if (!networkConfiguration) {
|
|
1108
|
+
throw new Error(`Invalid chain ID "${chainId}"`);
|
|
1107
1109
|
}
|
|
1108
|
-
|
|
1110
|
+
const { networkClientId } = networkConfiguration.rpcEndpoints[networkConfiguration.defaultRpcEndpointIndex];
|
|
1111
|
+
return networkClientId;
|
|
1109
1112
|
}
|
|
1110
1113
|
}
|
|
1111
1114
|
exports.NetworkController = NetworkController;
|