@metamask-previews/network-controller 32.0.0-preview-6cc5f3961 → 32.0.0-preview-45710f449
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 +2 -0
- package/dist/NetworkController.cjs +11 -7
- package/dist/NetworkController.cjs.map +1 -1
- package/dist/NetworkController.d.cts +4 -0
- package/dist/NetworkController.d.cts.map +1 -1
- package/dist/NetworkController.d.mts +4 -0
- package/dist/NetworkController.d.mts.map +1 -1
- package/dist/NetworkController.mjs +11 -7
- package/dist/NetworkController.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -16,6 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
16
|
- The default `policyOptions.circuitBreakDuration` is now `30` seconds.
|
|
17
17
|
- The default `pollingInterval` for the block tracker is now `20` seconds.
|
|
18
18
|
- The default `retryTimeout` for the block tracker is now `20` seconds.
|
|
19
|
+
- Add `failoverUrls` constructor argument ([#9140](https://github.com/MetaMask/core/pull/9140))
|
|
20
|
+
- These will override `failoverUrls` from state during network client creation.
|
|
19
21
|
|
|
20
22
|
### Changed
|
|
21
23
|
|
|
@@ -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_previouslySelectedNetworkClientId, _NetworkController_providerProxy, _NetworkController_blockTrackerProxy, _NetworkController_autoManagedNetworkClientRegistry, _NetworkController_autoManagedNetworkClient, _NetworkController_log, _NetworkController_getRpcServiceOptions, _NetworkController_getBlockTrackerOptions, _NetworkController_networkConfigurationsByNetworkClientId, _NetworkController_isRpcFailoverEnabled, _NetworkController_updateRpcFailoverEnabled, _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;
|
|
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_networkConfigurationsByNetworkClientId, _NetworkController_isRpcFailoverEnabled, _NetworkController_updateRpcFailoverEnabled, _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");
|
|
@@ -394,7 +394,7 @@ class NetworkController extends base_controller_1.BaseController {
|
|
|
394
394
|
* @param options - The options; see {@link NetworkControllerOptions}.
|
|
395
395
|
*/
|
|
396
396
|
constructor(options) {
|
|
397
|
-
const { messenger, state, infuraProjectId, log, getRpcServiceOptions, getBlockTrackerOptions, } = options;
|
|
397
|
+
const { messenger, state, infuraProjectId, failoverUrls, log, getRpcServiceOptions, getBlockTrackerOptions, } = options;
|
|
398
398
|
const initialState = {
|
|
399
399
|
...getDefaultNetworkControllerState(),
|
|
400
400
|
...state,
|
|
@@ -432,6 +432,7 @@ class NetworkController extends base_controller_1.BaseController {
|
|
|
432
432
|
_NetworkController_instances.add(this);
|
|
433
433
|
_NetworkController_ethQuery.set(this, void 0);
|
|
434
434
|
_NetworkController_infuraProjectId.set(this, void 0);
|
|
435
|
+
_NetworkController_failoverUrls.set(this, void 0);
|
|
435
436
|
_NetworkController_previouslySelectedNetworkClientId.set(this, void 0);
|
|
436
437
|
_NetworkController_providerProxy.set(this, void 0);
|
|
437
438
|
_NetworkController_blockTrackerProxy.set(this, void 0);
|
|
@@ -443,6 +444,7 @@ class NetworkController extends base_controller_1.BaseController {
|
|
|
443
444
|
_NetworkController_networkConfigurationsByNetworkClientId.set(this, void 0);
|
|
444
445
|
_NetworkController_isRpcFailoverEnabled.set(this, false);
|
|
445
446
|
__classPrivateFieldSet(this, _NetworkController_infuraProjectId, infuraProjectId, "f");
|
|
447
|
+
__classPrivateFieldSet(this, _NetworkController_failoverUrls, failoverUrls, "f");
|
|
446
448
|
__classPrivateFieldSet(this, _NetworkController_log, log, "f");
|
|
447
449
|
__classPrivateFieldSet(this, _NetworkController_getRpcServiceOptions, getRpcServiceOptions, "f");
|
|
448
450
|
__classPrivateFieldSet(this, _NetworkController_getBlockTrackerOptions, getBlockTrackerOptions, "f");
|
|
@@ -1062,7 +1064,7 @@ class NetworkController extends base_controller_1.BaseController {
|
|
|
1062
1064
|
}
|
|
1063
1065
|
}
|
|
1064
1066
|
exports.NetworkController = NetworkController;
|
|
1065
|
-
_NetworkController_ethQuery = new WeakMap(), _NetworkController_infuraProjectId = new WeakMap(), _NetworkController_previouslySelectedNetworkClientId = new WeakMap(), _NetworkController_providerProxy = new WeakMap(), _NetworkController_blockTrackerProxy = new WeakMap(), _NetworkController_autoManagedNetworkClientRegistry = new WeakMap(), _NetworkController_autoManagedNetworkClient = new WeakMap(), _NetworkController_log = new WeakMap(), _NetworkController_getRpcServiceOptions = new WeakMap(), _NetworkController_getBlockTrackerOptions = new WeakMap(), _NetworkController_networkConfigurationsByNetworkClientId = new WeakMap(), _NetworkController_isRpcFailoverEnabled = new WeakMap(), _NetworkController_instances = new WeakSet(), _NetworkController_updateRpcFailoverEnabled = function _NetworkController_updateRpcFailoverEnabled(newIsRpcFailoverEnabled) {
|
|
1067
|
+
_NetworkController_ethQuery = new WeakMap(), _NetworkController_infuraProjectId = new WeakMap(), _NetworkController_failoverUrls = new WeakMap(), _NetworkController_previouslySelectedNetworkClientId = new WeakMap(), _NetworkController_providerProxy = new WeakMap(), _NetworkController_blockTrackerProxy = new WeakMap(), _NetworkController_autoManagedNetworkClientRegistry = new WeakMap(), _NetworkController_autoManagedNetworkClient = new WeakMap(), _NetworkController_log = new WeakMap(), _NetworkController_getRpcServiceOptions = new WeakMap(), _NetworkController_getBlockTrackerOptions = new WeakMap(), _NetworkController_networkConfigurationsByNetworkClientId = new WeakMap(), _NetworkController_isRpcFailoverEnabled = new WeakMap(), _NetworkController_instances = new WeakSet(), _NetworkController_updateRpcFailoverEnabled = function _NetworkController_updateRpcFailoverEnabled(newIsRpcFailoverEnabled) {
|
|
1066
1068
|
if (__classPrivateFieldGet(this, _NetworkController_isRpcFailoverEnabled, "f") === newIsRpcFailoverEnabled) {
|
|
1067
1069
|
return;
|
|
1068
1070
|
}
|
|
@@ -1435,6 +1437,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1435
1437
|
return networkClientOperation.type === 'replace';
|
|
1436
1438
|
})
|
|
1437
1439
|
.map((networkClientOperation) => networkClientOperation.newRpcEndpoint));
|
|
1440
|
+
const defaultFailoverUrls = __classPrivateFieldGet(this, _NetworkController_failoverUrls, "f")?.[networkFields.chainId];
|
|
1438
1441
|
for (const addedRpcEndpoint of addedRpcEndpoints) {
|
|
1439
1442
|
if (addedRpcEndpoint.type === RpcEndpointType.Infura) {
|
|
1440
1443
|
autoManagedNetworkClientRegistry[types_1.NetworkClientType.Infura][addedRpcEndpoint.networkClientId] = (0, create_auto_managed_network_client_1.createAutoManagedNetworkClient)({
|
|
@@ -1443,7 +1446,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1443
1446
|
type: types_1.NetworkClientType.Infura,
|
|
1444
1447
|
chainId: networkFields.chainId,
|
|
1445
1448
|
network: addedRpcEndpoint.networkClientId,
|
|
1446
|
-
failoverRpcUrls: addedRpcEndpoint.failoverUrls,
|
|
1449
|
+
failoverRpcUrls: defaultFailoverUrls ?? addedRpcEndpoint.failoverUrls,
|
|
1447
1450
|
infuraProjectId: __classPrivateFieldGet(this, _NetworkController_infuraProjectId, "f"),
|
|
1448
1451
|
ticker: networkFields.nativeCurrency,
|
|
1449
1452
|
},
|
|
@@ -1460,7 +1463,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1460
1463
|
networkClientConfiguration: {
|
|
1461
1464
|
type: types_1.NetworkClientType.Custom,
|
|
1462
1465
|
chainId: networkFields.chainId,
|
|
1463
|
-
failoverRpcUrls: addedRpcEndpoint.failoverUrls,
|
|
1466
|
+
failoverRpcUrls: defaultFailoverUrls ?? addedRpcEndpoint.failoverUrls,
|
|
1464
1467
|
rpcUrl: addedRpcEndpoint.url,
|
|
1465
1468
|
ticker: networkFields.nativeCurrency,
|
|
1466
1469
|
},
|
|
@@ -1510,6 +1513,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1510
1513
|
const chainIds = knownKeysOf(this.state.networkConfigurationsByChainId);
|
|
1511
1514
|
const networkClientsWithIds = chainIds.flatMap((chainId) => {
|
|
1512
1515
|
const networkConfiguration = this.state.networkConfigurationsByChainId[chainId];
|
|
1516
|
+
const defaultFailoverUrls = __classPrivateFieldGet(this, _NetworkController_failoverUrls, "f")?.[chainId];
|
|
1513
1517
|
return networkConfiguration.rpcEndpoints.map((rpcEndpoint) => {
|
|
1514
1518
|
if (rpcEndpoint.type === RpcEndpointType.Infura) {
|
|
1515
1519
|
const infuraNetworkName = deriveInfuraNetworkNameFromRpcEndpointUrl(rpcEndpoint.url);
|
|
@@ -1520,7 +1524,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1520
1524
|
networkClientConfiguration: {
|
|
1521
1525
|
type: types_1.NetworkClientType.Infura,
|
|
1522
1526
|
network: infuraNetworkName,
|
|
1523
|
-
failoverRpcUrls: rpcEndpoint.failoverUrls,
|
|
1527
|
+
failoverRpcUrls: defaultFailoverUrls ?? rpcEndpoint.failoverUrls,
|
|
1524
1528
|
infuraProjectId: __classPrivateFieldGet(this, _NetworkController_infuraProjectId, "f"),
|
|
1525
1529
|
chainId: networkConfiguration.chainId,
|
|
1526
1530
|
ticker: networkConfiguration.nativeCurrency,
|
|
@@ -1540,7 +1544,7 @@ async function _NetworkController_determineEIP1559Compatibility(networkClientId)
|
|
|
1540
1544
|
networkClientConfiguration: {
|
|
1541
1545
|
type: types_1.NetworkClientType.Custom,
|
|
1542
1546
|
chainId: networkConfiguration.chainId,
|
|
1543
|
-
failoverRpcUrls: rpcEndpoint.failoverUrls,
|
|
1547
|
+
failoverRpcUrls: defaultFailoverUrls ?? rpcEndpoint.failoverUrls,
|
|
1544
1548
|
rpcUrl: rpcEndpoint.url,
|
|
1545
1549
|
ticker: networkConfiguration.nativeCurrency,
|
|
1546
1550
|
},
|