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
386
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 12.1.2-preview.2f7e793 to 12.1.2-preview.76bc0ab

3

dist/create-network-client.js

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

* @param args.network - The Infura network to use.
* @returns The middleware that implements eth_chainId & net_version methods.
* @returns The middleware that implements the eth_chainId method.
*/

@@ -100,3 +100,2 @@ function createNetworkAndChainIdMiddleware({ network, }) {

eth_chainId: controller_utils_1.ChainId[network],
net_version: controller_utils_1.NetworkId[network],
});

@@ -103,0 +102,0 @@ }

@@ -108,10 +108,5 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller';

/**
* The network ID of a network.
*/
export declare type NetworkId = `${number}`;
/**
* @type NetworkState
*
* Network controller state
* @property network - Network ID as per net_version of the currently connected network
* @property providerConfig - RPC URL and network name provider settings of the currently connected network

@@ -123,3 +118,2 @@ * @property properties - an additional set of network properties for the currently connected network

selectedNetworkClientId: NetworkClientId;
networkId: NetworkId | null;
providerConfig: ProviderConfig;

@@ -126,0 +120,0 @@ networkConfigurations: NetworkConfigurations;

@@ -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_getNetworkId, _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_provider, _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 });

@@ -89,22 +89,2 @@ exports.NetworkController = exports.defaultState = exports.knownKeysOf = void 0;

/**
* Convert the given value into a valid network ID. The ID is accepted
* as either a number, a decimal string, or a 0x-prefixed hex string.
*
* @param value - The network ID to convert, in an unknown format.
* @returns A valid network ID (as a decimal string)
* @throws If the given value cannot be safely parsed.
*/
function convertNetworkId(value) {
if (typeof value === 'number' && !Number.isNaN(value)) {
return `${value}`;
}
else if ((0, utils_1.isStrictHexString)(value)) {
return `${(0, controller_utils_1.convertHexToDecimal)(value)}`;
}
else if (typeof value === 'string' && /^\d+$/u.test(value)) {
return value;
}
throw new Error(`Cannot parse as a valid network ID: '${value}'`);
}
/**
* Type guard for determining whether the given value is an error object with a

@@ -215,3 +195,2 @@ * `code` property, such as an instance of Error.

selectedNetworkClientId: controller_utils_1.NetworkType.mainnet,
networkId: null,
providerConfig: {

@@ -237,6 +216,2 @@ type: controller_utils_1.NetworkType.mainnet,

},
networkId: {
persist: true,
anonymous: false,
},
networksMetadata: {

@@ -431,11 +406,6 @@ persist: true,

let updatedNetworkStatus;
let updatedNetworkId = null;
let updatedIsEIP1559Compatible;
try {
const [networkId, isEIP1559Compatible] = yield Promise.all([
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_getNetworkId).call(this, this.state.selectedNetworkClientId),
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this, this.state.selectedNetworkClientId),
]);
const isEIP1559Compatible = yield __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this, this.state.selectedNetworkClientId);
updatedNetworkStatus = constants_1.NetworkStatus.Available;
updatedNetworkId = networkId;
updatedIsEIP1559Compatible = isEIP1559Compatible;

@@ -479,3 +449,2 @@ }

this.update((state) => {
state.networkId = updatedNetworkId;
const meta = state.networksMetadata[state.selectedNetworkClientId];

@@ -783,5 +752,2 @@ meta.status = updatedNetworkStatus;

this.messagingSystem.publish('NetworkController:networkWillChange');
this.update((state) => {
state.networkId = null;
});
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_applyNetworkSelection).call(this);

@@ -791,25 +757,2 @@ this.messagingSystem.publish('NetworkController:networkDidChange');

});
}, _NetworkController_getNetworkId = function _NetworkController_getNetworkId(networkClientId) {
return __awaiter(this, void 0, void 0, function* () {
const possibleNetworkId = yield new Promise((resolve, reject) => {
let ethQuery = __classPrivateFieldGet(this, _NetworkController_ethQuery, "f");
if (networkClientId) {
const networkClient = this.getNetworkClientById(networkClientId);
ethQuery = new eth_query_1.default(networkClient.provider);
}
if (!ethQuery) {
throw new Error('Provider has not been initialized');
}
ethQuery.sendAsync({ method: 'net_version' }, (error, result) => {
if (error) {
reject(error);
}
else {
// TODO: Validate this type
resolve(result);
}
});
});
return convertNetworkId(possibleNetworkId);
});
}, _NetworkController_getLatestBlock = function _NetworkController_getLatestBlock(networkClientId) {

@@ -816,0 +759,0 @@ if (networkClientId === undefined) {

{
"name": "@metamask-previews/network-controller",
"version": "12.1.2-preview.2f7e793",
"version": "12.1.2-preview.76bc0ab",
"description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

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