Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@metamask-previews/network-controller

Package Overview
Dependencies
Maintainers
2
Versions
445
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask-previews/network-controller - npm Package Compare versions

Comparing version 17.1.0-preview.fa529884 to 17.2.0-preview.2431602

16

CHANGELOG.md

@@ -9,2 +9,15 @@ # Changelog

## [17.2.0]
### Changed
- The `setActiveNetwork` method and action now supports built-in network types ([#3764](https://github.com/MetaMask/core/pull/3764))
- Previously this would only accept a network configuration ID. Now it will accept the type of a built-in network as well, using it like an ID. This lets you switch to a built-in or custom network with a single method/action.
- Deprecate the `setProviderType` method and action ([#3764](https://github.com/MetaMask/core/pull/3764))
- Use `setActiveNetwork` instead
- Bump `@metamask/swappable-obj-proxy` to `^2.2.0` ([#3784](https://github.com/MetaMask/core/pull/3784))
- Bump `@metamask/utils` to `^8.3.0` ([#3769](https://github.com/MetaMask/core/pull/3769))
- Bump `@metamask/base-controller` to `^4.1.1` ([#3760](https://github.com/MetaMask/core/pull/3760), [#3821](https://github.com/MetaMask/core/pull/3821))
- Bump `@metamask/controller-utils` to `^8.0.2` ([#3821](https://github.com/MetaMask/core/pull/3821))
- Bump `@metamask/eth-json-rpc-provider` to `^2.3.2` ([#3821](https://github.com/MetaMask/core/pull/3821))
- Bump `@metamask/json-rpc-engine` to `^7.3.2` ([#3821](https://github.com/MetaMask/core/pull/3821))
## [17.1.0]

@@ -334,3 +347,4 @@ ### Added

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.1.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.2.0...HEAD
[17.2.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.1.0...@metamask/network-controller@17.2.0
[17.1.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.0.0...@metamask/network-controller@17.1.0

@@ -337,0 +351,0 @@ [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@16.0.0...@metamask/network-controller@17.0.0

@@ -195,2 +195,8 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from '@metamask/base-controller';

};
/**
* Change the currently selected network to the given built-in network type.
*
* @deprecated This action has been replaced by `setActiveNetwork`, and will be
* removed in a future release.
*/
export declare type NetworkControllerSetProviderTypeAction = {

@@ -296,2 +302,4 @@ type: `NetworkController:setProviderType`;

* @param type - Human readable network name.
* @deprecated This has been replaced by `setActiveNetwork`, and will be
* removed in a future release
*/

@@ -302,5 +310,6 @@ setProviderType(type: InfuraNetworkType): Promise<void>;

*
* @param networkConfigurationId - The unique id for the network configuration to set as the active provider.
* @param networkConfigurationIdOrType - The unique id for the network configuration to set as the active provider,
* or the type of a built-in network.
*/
setActiveNetwork(networkConfigurationId: string): Promise<void>;
setActiveNetwork(networkConfigurationIdOrType: string): Promise<void>;
/**

@@ -307,0 +316,0 @@ * Determines whether the network supports EIP-1559 by checking whether the

59

dist/NetworkController.js

@@ -25,3 +25,3 @@ "use strict";

};
var _NetworkController_instances, _NetworkController_ethQuery, _NetworkController_infuraProjectId, _NetworkController_trackMetaMetricsEvent, _NetworkController_previousProviderConfig, _NetworkController_providerProxy, _NetworkController_provider, _NetworkController_blockTrackerProxy, _NetworkController_autoManagedNetworkClientRegistry, _NetworkController_refreshNetwork, _NetworkController_getLatestBlock, _NetworkController_determineEIP1559Compatibility, _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated, _NetworkController_createAutoManagedNetworkClientRegistry, _NetworkController_buildIdentifiedInfuraNetworkClientConfigurations, _NetworkController_buildIdentifiedCustomNetworkClientConfigurations, _NetworkController_buildIdentifiedNetworkClientConfigurationsFromProviderConfig, _NetworkController_applyNetworkSelection;
var _NetworkController_instances, _NetworkController_ethQuery, _NetworkController_infuraProjectId, _NetworkController_trackMetaMetricsEvent, _NetworkController_previousProviderConfig, _NetworkController_providerProxy, _NetworkController_blockTrackerProxy, _NetworkController_autoManagedNetworkClientRegistry, _NetworkController_refreshNetwork, _NetworkController_getLatestBlock, _NetworkController_determineEIP1559Compatibility, _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated, _NetworkController_createAutoManagedNetworkClientRegistry, _NetworkController_buildIdentifiedInfuraNetworkClientConfigurations, _NetworkController_buildIdentifiedCustomNetworkClientConfigurations, _NetworkController_buildIdentifiedNetworkClientConfigurationsFromProviderConfig, _NetworkController_applyNetworkSelection;
Object.defineProperty(exports, "__esModule", { value: true });

@@ -230,3 +230,2 @@ exports.NetworkController = exports.defaultState = exports.knownKeysOf = void 0;

_NetworkController_providerProxy.set(this, void 0);
_NetworkController_provider.set(this, void 0);
_NetworkController_blockTrackerProxy.set(this, void 0);

@@ -474,2 +473,4 @@ _NetworkController_autoManagedNetworkClientRegistry.set(this, void 0);

* @param type - Human readable network name.
* @deprecated This has been replaced by `setActiveNetwork`, and will be
* removed in a future release
*/

@@ -480,18 +481,3 @@ setProviderType(type) {

assert_1.strict.ok((0, controller_utils_1.isInfuraNetworkType)(type), `Unknown Infura provider type "${type}".`);
__classPrivateFieldSet(this, _NetworkController_previousProviderConfig, this.state.providerConfig, "f");
// If testnet the ticker symbol should use a testnet prefix
const ticker = type in controller_utils_1.NetworksTicker && controller_utils_1.NetworksTicker[type].length > 0
? controller_utils_1.NetworksTicker[type]
: 'ETH';
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated).call(this);
this.update((state) => {
state.providerConfig.type = type;
state.providerConfig.ticker = ticker;
state.providerConfig.chainId = controller_utils_1.ChainId[type];
state.providerConfig.rpcPrefs = controller_utils_1.BUILT_IN_NETWORKS[type].rpcPrefs;
state.providerConfig.rpcUrl = undefined;
state.providerConfig.nickname = undefined;
state.providerConfig.id = undefined;
});
yield __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_refreshNetwork).call(this);
yield this.setActiveNetwork(type);
});

@@ -502,20 +488,30 @@ }

*
* @param networkConfigurationId - The unique id for the network configuration to set as the active provider.
* @param networkConfigurationIdOrType - The unique id for the network configuration to set as the active provider,
* or the type of a built-in network.
*/
setActiveNetwork(networkConfigurationId) {
setActiveNetwork(networkConfigurationIdOrType) {
return __awaiter(this, void 0, void 0, function* () {
__classPrivateFieldSet(this, _NetworkController_previousProviderConfig, this.state.providerConfig, "f");
const targetNetwork = this.state.networkConfigurations[networkConfigurationId];
if (!targetNetwork) {
throw new Error(`networkConfigurationId ${networkConfigurationId} does not match a configured networkConfiguration`);
let targetNetwork;
if ((0, controller_utils_1.isInfuraNetworkType)(networkConfigurationIdOrType)) {
const ticker = controller_utils_1.NetworksTicker[networkConfigurationIdOrType];
targetNetwork = {
chainId: controller_utils_1.ChainId[networkConfigurationIdOrType],
id: undefined,
rpcPrefs: controller_utils_1.BUILT_IN_NETWORKS[networkConfigurationIdOrType].rpcPrefs,
rpcUrl: undefined,
nickname: undefined,
ticker,
type: networkConfigurationIdOrType,
};
}
else {
if (!Object.keys(this.state.networkConfigurations).includes(networkConfigurationIdOrType)) {
throw new Error(`networkConfigurationId ${networkConfigurationIdOrType} does not match a configured networkConfiguration or built-in network type`);
}
targetNetwork = Object.assign(Object.assign({}, this.state.networkConfigurations[networkConfigurationIdOrType]), { type: controller_utils_1.NetworkType.rpc });
}
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated).call(this);
this.update((state) => {
state.providerConfig.type = controller_utils_1.NetworkType.rpc;
state.providerConfig.rpcUrl = targetNetwork.rpcUrl;
state.providerConfig.chainId = targetNetwork.chainId;
state.providerConfig.ticker = targetNetwork.ticker;
state.providerConfig.nickname = targetNetwork.nickname;
state.providerConfig.rpcPrefs = targetNetwork.rpcPrefs;
state.providerConfig.id = targetNetwork.id;
state.providerConfig = targetNetwork;
});

@@ -767,3 +763,3 @@ yield __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_refreshNetwork).call(this);

exports.NetworkController = NetworkController;
_NetworkController_ethQuery = new WeakMap(), _NetworkController_infuraProjectId = new WeakMap(), _NetworkController_trackMetaMetricsEvent = new WeakMap(), _NetworkController_previousProviderConfig = new WeakMap(), _NetworkController_providerProxy = new WeakMap(), _NetworkController_provider = new WeakMap(), _NetworkController_blockTrackerProxy = new WeakMap(), _NetworkController_autoManagedNetworkClientRegistry = new WeakMap(), _NetworkController_instances = new WeakSet(), _NetworkController_refreshNetwork = function _NetworkController_refreshNetwork() {
_NetworkController_ethQuery = new WeakMap(), _NetworkController_infuraProjectId = new WeakMap(), _NetworkController_trackMetaMetricsEvent = new WeakMap(), _NetworkController_previousProviderConfig = new WeakMap(), _NetworkController_providerProxy = new WeakMap(), _NetworkController_blockTrackerProxy = new WeakMap(), _NetworkController_autoManagedNetworkClientRegistry = new WeakMap(), _NetworkController_instances = new WeakSet(), _NetworkController_refreshNetwork = function _NetworkController_refreshNetwork() {
return __awaiter(this, void 0, void 0, function* () {

@@ -922,3 +918,2 @@ this.messagingSystem.publish('NetworkController:networkWillChange', this.state);

}
__classPrivateFieldSet(this, _NetworkController_provider, provider, "f");
if (__classPrivateFieldGet(this, _NetworkController_blockTrackerProxy, "f")) {

@@ -925,0 +920,0 @@ __classPrivateFieldGet(this, _NetworkController_blockTrackerProxy, "f").setTarget(blockTracker);

{
"name": "@metamask-previews/network-controller",
"version": "17.1.0-preview.fa529884",
"version": "17.2.0-preview.2431602",
"description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object",

@@ -34,12 +34,12 @@ "keywords": [

"dependencies": {
"@metamask/base-controller": "^4.0.1",
"@metamask/controller-utils": "^8.0.1",
"@metamask/base-controller": "^4.1.1",
"@metamask/controller-utils": "^8.0.2",
"@metamask/eth-json-rpc-infura": "^9.0.0",
"@metamask/eth-json-rpc-middleware": "^12.0.1",
"@metamask/eth-json-rpc-provider": "^2.3.1",
"@metamask/eth-json-rpc-middleware": "^12.1.0",
"@metamask/eth-json-rpc-provider": "^2.3.2",
"@metamask/eth-query": "^4.0.0",
"@metamask/json-rpc-engine": "^7.3.1",
"@metamask/json-rpc-engine": "^7.3.2",
"@metamask/rpc-errors": "^6.1.0",
"@metamask/swappable-obj-proxy": "^2.1.0",
"@metamask/utils": "^8.2.0",
"@metamask/swappable-obj-proxy": "^2.2.0",
"@metamask/utils": "^8.3.0",
"async-mutex": "^0.2.6",

@@ -46,0 +46,0 @@ "eth-block-tracker": "^8.0.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc