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
464
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.c338244 to 12.1.2-preview.f71e42f

1

dist/create-network-client.js

@@ -99,3 +99,2 @@ "use strict";

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

@@ -102,0 +101,0 @@ }

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

/**
* The network ID of a network.
*/
export declare type NetworkId = `${number}`;
/**
* @type NetworkState

@@ -123,3 +119,2 @@ *

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

@@ -126,0 +121,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: {

@@ -356,11 +331,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),
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this),
]);
const isEIP1559Compatible = yield __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_determineEIP1559Compatibility).call(this);
updatedNetworkStatus = constants_1.NetworkStatus.Available;
updatedNetworkId = networkId;
updatedIsEIP1559Compatible = isEIP1559Compatible;

@@ -404,3 +374,2 @@ }

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

@@ -692,5 +661,2 @@ meta.status = updatedNetworkStatus;

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

@@ -700,20 +666,2 @@ this.messagingSystem.publish('NetworkController:networkDidChange');

});
}, _NetworkController_getNetworkId = function _NetworkController_getNetworkId() {
return __awaiter(this, void 0, void 0, function* () {
const possibleNetworkId = yield new Promise((resolve, reject) => {
if (!__classPrivateFieldGet(this, _NetworkController_ethQuery, "f")) {
throw new Error('Provider has not been initialized');
}
__classPrivateFieldGet(this, _NetworkController_ethQuery, "f").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() {

@@ -720,0 +668,0 @@ return new Promise((resolve, reject) => {

2

package.json
{
"name": "@metamask-previews/network-controller",
"version": "12.1.2-preview.c338244",
"version": "12.1.2-preview.f71e42f",
"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