@metamask-previews/network-controller 22.2.1-preview-def92ff7 → 22.2.1-preview-edbe12d8

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
@@ -17,11 +17,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
17
17
  - The request returns a non-200 response
18
18
  - Use exponential backoff / jitter when retrying requests to Infura and custom RPC endpoints ([#5290](https://github.com/MetaMask/core/pull/5290))
19
19
  - As requests are retried, the delay between retries will increase exponentially (using random variance to prevent bursts)
20
+ - Add support for automatic failover when Infura is down ([#5630](https://github.com/MetaMask/core/pull/5630))
21
+ - An Infura RPC endpoint can now be configured with a list of failover URLs via `failoverUrls`.
22
+ - If, after many attempts, an Infura network is perceived to be down, the list of failover URLs will be tried in turn.
20
23
 
21
24
  ### Changed
22
25
 
23
26
  - **BREAKING:** `NetworkController` constructor now takes two required options, `fetch` and `btoa` ([#5290](https://github.com/MetaMask/core/pull/5290))
24
- - These are passed along to functions that create the JSON-RPC middleware
27
+ - These are passed along to functions that create the JSON-RPC middleware.
28
+ - **BREAKING:** Add required property `failoverUrls` to `RpcEndpoint` ([#5630](https://github.com/MetaMask/core/pull/5630))
29
+ - **BREAKING:** Add required property `failoverRpcUrls` to `NetworkClientConfiguration` ([#5630](https://github.com/MetaMask/core/pull/5630))
25
30
  - Synchronize retry logic and error handling behavior between Infura and custom RPC endpoints ([#5290](https://github.com/MetaMask/core/pull/5290))
26
31
  - A request to a custom endpoint that returns a 418 response will no longer return a JSON-RPC response with the error "Request is being rate limited"
27
32
  - A request to a custom endpoint that returns a 429 response now returns a JSON-RPC response with the error "Request is being rate limited"
@@ -123,6 +123,7 @@ function getDefaultNetworkConfigurationsByChainId() {
123
123
  nativeCurrency: controller_utils_1.NetworksTicker[infuraNetworkType],
124
124
  rpcEndpoints: [
125
125
  {
126
+ failoverUrls: [],
126
127
  networkClientId: infuraNetworkType,
127
128
  type: RpcEndpointType.Infura,
128
129
  url: rpcEndpointUrl,
@@ -464,7 +465,8 @@ class NetworkController extends base_controller_1.BaseController {
464
465
  let updatedNetworkStatus;
465
466
  let updatedIsEIP1559Compatible;
466
467
  try {
467
- updatedIsEIP1559Compatible = await __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this, networkClientId);
468
+ updatedIsEIP1559Compatible =
469
+ await __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this, networkClientId);
468
470
  updatedNetworkStatus = constants_1.NetworkStatus.Available;
469
471
  }
470
472
  catch (error) {
@@ -1321,6 +1323,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1321
1323
  type: types_1.NetworkClientType.Infura,
1322
1324
  chainId: networkFields.chainId,
1323
1325
  network: addedRpcEndpoint.networkClientId,
1326
+ failoverRpcUrls: addedRpcEndpoint.failoverUrls,
1324
1327
  infuraProjectId: __classPrivateFieldGet(this, _NetworkController_infuraProjectId, "f"),
1325
1328
  ticker: networkFields.nativeCurrency,
1326
1329
  },
@@ -1333,6 +1336,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1333
1336
  networkClientConfiguration: {
1334
1337
  type: types_1.NetworkClientType.Custom,
1335
1338
  chainId: networkFields.chainId,
1339
+ failoverRpcUrls: addedRpcEndpoint.failoverUrls,
1336
1340
  rpcUrl: addedRpcEndpoint.url,
1337
1341
  ticker: networkFields.nativeCurrency,
1338
1342
  },
@@ -1388,6 +1392,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1388
1392
  networkClientConfiguration: {
1389
1393
  type: types_1.NetworkClientType.Infura,
1390
1394
  network: infuraNetworkName,
1395
+ failoverRpcUrls: rpcEndpoint.failoverUrls,
1391
1396
  infuraProjectId: __classPrivateFieldGet(this, _NetworkController_infuraProjectId, "f"),
1392
1397
  chainId: networkConfiguration.chainId,
1393
1398
  ticker: networkConfiguration.nativeCurrency,
@@ -1403,6 +1408,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
1403
1408
  networkClientConfiguration: {
1404
1409
  type: types_1.NetworkClientType.Custom,
1405
1410
  chainId: networkConfiguration.chainId,
1411
+ failoverRpcUrls: rpcEndpoint.failoverUrls,
1406
1412
  rpcUrl: rpcEndpoint.url,
1407
1413
  ticker: networkConfiguration.nativeCurrency,
1408
1414
  },