New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@metamask-previews/controller-utils

Package Overview
Dependencies
Maintainers
2
Versions
522
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 4.3.2-preview.c338244 to 4.3.2-preview.f71e42f

19

dist/constants.d.ts

@@ -1,2 +0,3 @@

import { NetworkType, NetworksTicker, NetworkId } from './types';
import type { Hex } from '@metamask/utils';
import { NetworksTicker, ChainId, BuiltInNetworkName } from './types';
export declare const RPC = "rpc";

@@ -106,3 +107,17 @@ export declare const FALL_BACK_VS_CURRENCY = "ETH";

}
export declare const NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<NetworkId, NetworkType>;
export declare const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<ChainId, BuiltInNetworkName>;
/**
* Compiled from https://chainid.network/chains.json
* A mapping of network ID to chain IDs for all chains
* that have mismatched network ID and chain ID. Most
* notably ETC has a network ID of 1 but chain ID of 61.
*/
export declare const NON_MATCHING_NETWORK_ID_TO_CHAIN_IDS: Record<string, Hex[]>;
/**
* Compiled from https://chainid.network/chains.json
* A mapping of chain ID to network ID for all chains
* that have mismatched network ID and chain ID. Most
* notably ETC has a network ID of 1 but chain ID of 61.
*/
export declare const NON_MATCHING_CHAIN_ID_TO_NETWORK_ID: Record<Hex, string>;
//# sourceMappingURL=constants.d.ts.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP = exports.ApprovalType = exports.ORIGIN_METAMASK = exports.OPENSEA_TEST_API_URL = exports.OPENSEA_API_URL = exports.OPENSEA_PROXY_URL = exports.BUILT_IN_NETWORKS = exports.TESTNET_TICKER_SYMBOLS = exports.ASSET_TYPES = exports.GWEI = exports.ERC1155_TOKEN_RECEIVER_INTERFACE_ID = exports.ERC1155_METADATA_URI_INTERFACE_ID = exports.ERC1155_INTERFACE_ID = exports.ERC721_ENUMERABLE_INTERFACE_ID = exports.ERC721_METADATA_INTERFACE_ID = exports.ERC721_INTERFACE_ID = exports.ERC20 = exports.ERC1155 = exports.ERC721 = exports.MAX_SAFE_CHAIN_ID = exports.GANACHE_CHAIN_ID = exports.IPFS_DEFAULT_GATEWAY_URL = exports.FALL_BACK_VS_CURRENCY = exports.RPC = void 0;
exports.NON_MATCHING_CHAIN_ID_TO_NETWORK_ID = exports.NON_MATCHING_NETWORK_ID_TO_CHAIN_IDS = exports.CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = exports.ApprovalType = exports.ORIGIN_METAMASK = exports.OPENSEA_TEST_API_URL = exports.OPENSEA_API_URL = exports.OPENSEA_PROXY_URL = exports.BUILT_IN_NETWORKS = exports.TESTNET_TICKER_SYMBOLS = exports.ASSET_TYPES = exports.GWEI = exports.ERC1155_TOKEN_RECEIVER_INTERFACE_ID = exports.ERC1155_METADATA_URI_INTERFACE_ID = exports.ERC1155_INTERFACE_ID = exports.ERC721_ENUMERABLE_INTERFACE_ID = exports.ERC721_METADATA_INTERFACE_ID = exports.ERC721_INTERFACE_ID = exports.ERC20 = exports.ERC1155 = exports.ERC721 = exports.MAX_SAFE_CHAIN_ID = exports.GANACHE_CHAIN_ID = exports.IPFS_DEFAULT_GATEWAY_URL = exports.FALL_BACK_VS_CURRENCY = exports.RPC = void 0;
const types_1 = require("./types");

@@ -119,9 +119,148 @@ exports.RPC = 'rpc';

})(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
exports.NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP = {
[types_1.NetworkId.goerli]: types_1.NetworkType.goerli,
[types_1.NetworkId.sepolia]: types_1.NetworkType.sepolia,
[types_1.NetworkId.mainnet]: types_1.NetworkType.mainnet,
[types_1.NetworkId['linea-goerli']]: types_1.NetworkType['linea-goerli'],
[types_1.NetworkId['linea-mainnet']]: types_1.NetworkType['linea-mainnet'],
exports.CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = {
[types_1.ChainId.goerli]: types_1.BuiltInNetworkName.Goerli,
[types_1.ChainId.sepolia]: types_1.BuiltInNetworkName.Sepolia,
[types_1.ChainId.mainnet]: types_1.BuiltInNetworkName.Mainnet,
[types_1.ChainId['linea-goerli']]: types_1.BuiltInNetworkName.LineaGoerli,
[types_1.ChainId['linea-mainnet']]: types_1.BuiltInNetworkName.LineaMainnet,
[types_1.ChainId.aurora]: types_1.BuiltInNetworkName.Aurora,
};
/**
* Compiled from https://chainid.network/chains.json
* A mapping of network ID to chain IDs for all chains
* that have mismatched network ID and chain ID. Most
* notably ETC has a network ID of 1 but chain ID of 61.
*/
exports.NON_MATCHING_NETWORK_ID_TO_CHAIN_IDS = {
'0': [
'0x18',
'0xd3',
'0x3d4',
'0x3dd', // toHex(989)
],
'1': [
'0x2',
'0x3d',
'0x65',
'0x8a',
'0x106',
'0x334',
'0x740',
'0x76a',
'0x797e',
'0xa869',
'0x116e1',
'0x192b2',
'0x3113a',
'0x31146',
'0x335f9',
'0x66b3a',
'0x219e2d',
'0x21a9b4',
'0x133edce', // toHex(20180430)
],
'2': [
'0x9',
'0x3e',
'0x335', // toHex(821)
],
'7': [
'0x3f', // toHex(63)
],
'10': [
'0x96f', // toHex(2415)
],
'21': [
'0x85a', // toHex(2138)
],
'79': [
'0x50f9', // toHex(20729)
],
'1000': [
'0x1f4', // toHex(500)
],
'1001': [
'0x1f5', // toHex(501)
],
'1024': [
'0x208', // toHex(520)
],
'1230': [
'0x3012', // toHex(12306)
],
'2048': [
'0x4b2', // toHex(1202)
],
'2221': [
'0xde', // toHex(222)
],
'3344': [
'0x10804', // toHex(67588)
],
'37129': [
'0x5fa4', // toHex(24484)
],
'37480': [
'0x609e', // toHex(24734)
],
'48501': [
'0x14dc9', // toHex(85449)
],
'103090': [
'0x66a44', // toHex(420420)
],
'11235813': [
'0x654', // toHex(1620)
],
};
/**
* Compiled from https://chainid.network/chains.json
* A mapping of chain ID to network ID for all chains
* that have mismatched network ID and chain ID. Most
* notably ETC has a network ID of 1 but chain ID of 61.
*/
exports.NON_MATCHING_CHAIN_ID_TO_NETWORK_ID = {
'0x2': '1',
'0x9': '2',
'0x18': '0',
'0x3d': '1',
'0x3e': '2',
'0x3f': '7',
'0x65': '1',
'0x8a': '1',
'0xd3': '0',
'0xde': '2221',
'0x106': '1',
'0x1f4': '1000',
'0x1f5': '1001',
'0x208': '1024',
'0x334': '1',
'0x335': '2',
'0x3d4': '0',
'0x3dd': '0',
'0x4b2': '2048',
'0x654': '11235813',
'0x740': '1',
'0x76a': '1',
'0x85a': '21',
'0x96f': '10',
'0x3012': '1230',
'0x50f9': '79',
'0x5fa4': '37129',
'0x609e': '37480',
'0x797e': '1',
'0xa869': '1',
'0x10804': '3344',
'0x116e1': '1',
'0x14dc9': '48501',
'0x192b2': '1',
'0x3113a': '1',
'0x31146': '1',
'0x335f9': '1',
'0x66a44': '103090',
'0x66b3a': '1',
'0x219e2d': '1',
'0x21a9b4': '1',
'0x133edce': '1',
};
//# sourceMappingURL=constants.js.map

11

dist/types.d.ts

@@ -58,13 +58,2 @@ /**

export declare type ChainId = (typeof ChainId)[keyof typeof ChainId];
/**
* Decimal string network IDs of built-in Infura networks, by name.
*/
export declare const NetworkId: {
readonly mainnet: "1";
readonly goerli: "5";
readonly sepolia: "11155111";
readonly "linea-goerli": "59140";
readonly "linea-mainnet": "59144";
};
export declare type NetworkId = (typeof NetworkId)[keyof typeof NetworkId];
export declare enum NetworksTicker {

@@ -71,0 +60,0 @@ mainnet = "ETH",

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworksTicker = exports.NetworkId = exports.ChainId = exports.BuiltInNetworkName = exports.isNetworkType = exports.NetworkType = exports.InfuraNetworkType = void 0;
exports.NetworksTicker = exports.ChainId = exports.BuiltInNetworkName = exports.isNetworkType = exports.NetworkType = exports.InfuraNetworkType = void 0;
/**

@@ -55,12 +55,2 @@ * The names of built-in Infura networks

};
/**
* Decimal string network IDs of built-in Infura networks, by name.
*/
exports.NetworkId = {
[exports.InfuraNetworkType.mainnet]: '1',
[exports.InfuraNetworkType.goerli]: '5',
[exports.InfuraNetworkType.sepolia]: '11155111',
[exports.InfuraNetworkType['linea-goerli']]: '59140',
[exports.InfuraNetworkType['linea-mainnet']]: '59144',
};
var NetworksTicker;

@@ -67,0 +57,0 @@ (function (NetworksTicker) {

@@ -220,3 +220,18 @@ /// <reference types="bn.js" />

export declare function isValidJson(value: unknown): value is Json;
/**
* Checks if a networkId matches a chainId
*
* @param networkId - Network ID for the chain.
* @param chainId - Chain ID for the chain.
* @returns Whether the network ID matches the chain ID
*/
export declare function deprecatedNetworkIdMatchesChainId(networkId: string, chainId: Hex): boolean;
/**
* Converts a chainId to networkId
*
* @param chainId - Chain ID for the chain.
* @returns The network ID
*/
export declare function deprecatedConvertChainIdToNetworkId(chainId: Hex): string;
export {};
//# sourceMappingURL=util.d.ts.map

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidJson = exports.isNonEmptyArray = exports.isPlainObject = exports.convertHexToDecimal = exports.query = exports.normalizeEnsName = exports.timeoutFetch = exports.fetchWithErrorHandling = exports.handleFetch = exports.successfulFetch = exports.isSmartContractCode = exports.isValidHexAddress = exports.toChecksumHexAddress = exports.safelyExecuteWithTimeout = exports.safelyExecute = exports.toHex = exports.fromHex = exports.hexToText = exports.hexToBN = exports.getBuyURL = exports.weiHexToGweiDec = exports.gweiDecToWEIBN = exports.fractionBN = exports.BNToHex = exports.isSafeChainId = void 0;
exports.deprecatedConvertChainIdToNetworkId = exports.deprecatedNetworkIdMatchesChainId = exports.isValidJson = exports.isNonEmptyArray = exports.isPlainObject = exports.convertHexToDecimal = exports.query = exports.normalizeEnsName = exports.timeoutFetch = exports.fetchWithErrorHandling = exports.handleFetch = exports.successfulFetch = exports.isSmartContractCode = exports.isValidHexAddress = exports.toChecksumHexAddress = exports.safelyExecuteWithTimeout = exports.safelyExecute = exports.toHex = exports.fromHex = exports.hexToText = exports.hexToBN = exports.getBuyURL = exports.weiHexToGweiDec = exports.gweiDecToWEIBN = exports.fractionBN = exports.BNToHex = exports.isSafeChainId = void 0;
const utils_1 = require("@metamask/utils");

@@ -475,2 +475,35 @@ const eth_ens_namehash_1 = __importDefault(require("eth-ens-namehash"));

/**
* Checks if a networkId matches a chainId
*
* @param networkId - Network ID for the chain.
* @param chainId - Chain ID for the chain.
* @returns Whether the network ID matches the chain ID
*/
function deprecatedNetworkIdMatchesChainId(networkId, chainId) {
let networkIdHex;
try {
networkIdHex = toHex(networkId);
}
catch (err) {
return false;
}
if (networkIdHex === chainId) {
return true;
}
const chainIds = constants_1.NON_MATCHING_NETWORK_ID_TO_CHAIN_IDS[networkId];
return Boolean(chainIds && chainIds.includes(chainId));
}
exports.deprecatedNetworkIdMatchesChainId = deprecatedNetworkIdMatchesChainId;
/**
* Converts a chainId to networkId
*
* @param chainId - Chain ID for the chain.
* @returns The network ID
*/
function deprecatedConvertChainIdToNetworkId(chainId) {
const networkId = constants_1.NON_MATCHING_CHAIN_ID_TO_NETWORK_ID[chainId];
return networkId !== undefined ? networkId : parseInt(chainId, 16).toString();
}
exports.deprecatedConvertChainIdToNetworkId = deprecatedConvertChainIdToNetworkId;
/**
* Utility method to log if error is a common fetch error and otherwise rethrow it.

@@ -477,0 +510,0 @@ *

{
"name": "@metamask-previews/controller-utils",
"version": "4.3.2-preview.c338244",
"version": "4.3.2-preview.f71e42f",
"description": "Data and convenience functions shared by multiple packages",

@@ -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

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