Socket
Socket
Sign inDemoInstall

@metamask/controller-utils

Package Overview
Dependencies
Maintainers
8
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/controller-utils - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

dist/logger.d.ts

9

CHANGELOG.md

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

## [3.1.0]
### Added
- Add SIWE detection support for PersonalMessageManager ([#1139](https://github.com/MetaMask/core/pull/1139))
- Add `NetworkType` ([#1132](https://github.com/MetaMask/core/pull/1132))
- Add `isSafeChainId` ([#1064](https://github.com/MetaMask/core/pull/1064))
## [3.0.0]

@@ -67,5 +73,6 @@ ### Removed

[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.0.0...HEAD
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.1.0...HEAD
[3.1.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.0.0...@metamask/controller-utils@3.1.0
[3.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@2.0.0...@metamask/controller-utils@3.0.0
[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@1.0.0...@metamask/controller-utils@2.0.0
[1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/controller-utils@1.0.0

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

import { NetworkType } from './types';
export declare const MAINNET = "mainnet";
import { NetworksTicker, NetworksChainId } from './types';
export declare const RPC = "rpc";

@@ -7,2 +6,7 @@ export declare const FALL_BACK_VS_CURRENCY = "ETH";

export declare const GANACHE_CHAIN_ID = "1337";
/**
* The largest possible chain ID we can handle.
* Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
*/
export declare const MAX_SAFE_CHAIN_ID = 4503599627370476;
export declare const ERC721 = "ERC721";

@@ -28,4 +32,37 @@ export declare const ERC1155 = "ERC1155";

};
export declare const TESTNET_NETWORK_TYPE_TO_TICKER_SYMBOL: {
[K in NetworkType]: string;
/**
* Map of all build-in Infura networks to their network, ticker and chain IDs.
*/
export declare const BUILT_IN_NETWORKS: {
readonly goerli: {
readonly chainId: NetworksChainId.goerli;
readonly ticker: NetworksTicker.goerli;
readonly rpcPrefs: {
readonly blockExplorerUrl: "https://goerli.etherscan.io";
};
};
readonly sepolia: {
readonly chainId: NetworksChainId.sepolia;
readonly ticker: NetworksTicker.sepolia;
readonly rpcPrefs: {
readonly blockExplorerUrl: "https://sepolia.etherscan.io";
};
};
readonly mainnet: {
readonly chainId: NetworksChainId.mainnet;
readonly ticker: NetworksTicker.mainnet;
readonly rpcPrefs: {
readonly blockExplorerUrl: "https://etherscan.io";
};
};
readonly localhost: {
readonly chainId: NetworksChainId.localhost;
readonly blockExplorerUrl: undefined;
readonly rpcPrefs: undefined;
};
readonly rpc: {
readonly chainId: undefined;
readonly blockExplorerUrl: undefined;
readonly rpcPrefs: undefined;
};
};

@@ -32,0 +69,0 @@ export declare const OPENSEA_PROXY_URL = "https://proxy.metafi.codefi.network/opensea/v1/api/v1";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OPENSEA_TEST_API_URL = exports.OPENSEA_API_URL = exports.OPENSEA_PROXY_URL = exports.TESTNET_NETWORK_TYPE_TO_TICKER_SYMBOL = 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.GANACHE_CHAIN_ID = exports.IPFS_DEFAULT_GATEWAY_URL = exports.FALL_BACK_VS_CURRENCY = exports.RPC = exports.MAINNET = void 0;
exports.MAINNET = 'mainnet';
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");
exports.RPC = 'rpc';

@@ -10,2 +10,7 @@ exports.FALL_BACK_VS_CURRENCY = 'ETH';

exports.GANACHE_CHAIN_ID = '1337';
/**
* The largest possible chain ID we can handle.
* Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
*/
exports.MAX_SAFE_CHAIN_ID = 4503599627370476;
// TOKEN STANDARDS

@@ -36,9 +41,37 @@ exports.ERC721 = 'ERC721';

};
// TYPED NetworkType TICKER SYMBOLS
exports.TESTNET_NETWORK_TYPE_TO_TICKER_SYMBOL = {
goerli: 'GoerliETH',
sepolia: 'SepoliaETH',
mainnet: '',
rpc: '',
localhost: '',
/**
* Map of all build-in Infura networks to their network, ticker and chain IDs.
*/
exports.BUILT_IN_NETWORKS = {
[types_1.NetworkType.goerli]: {
chainId: types_1.NetworksChainId.goerli,
ticker: types_1.NetworksTicker.goerli,
rpcPrefs: {
blockExplorerUrl: `https://${types_1.NetworkType.goerli}.etherscan.io`,
},
},
[types_1.NetworkType.sepolia]: {
chainId: types_1.NetworksChainId.sepolia,
ticker: types_1.NetworksTicker.sepolia,
rpcPrefs: {
blockExplorerUrl: `https://${types_1.NetworkType.sepolia}.etherscan.io`,
},
},
[types_1.NetworkType.mainnet]: {
chainId: types_1.NetworksChainId.mainnet,
ticker: types_1.NetworksTicker.mainnet,
rpcPrefs: {
blockExplorerUrl: 'https://etherscan.io',
},
},
[types_1.NetworkType.localhost]: {
chainId: types_1.NetworksChainId.localhost,
blockExplorerUrl: undefined,
rpcPrefs: undefined,
},
[types_1.NetworkType.rpc]: {
chainId: undefined,
blockExplorerUrl: undefined,
rpcPrefs: undefined,
},
};

@@ -45,0 +78,0 @@ // APIs

export * from './constants';
export * from './util';
export * from './types';
export * from './siwe';

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

__exportStar(require("./types"), exports);
__exportStar(require("./siwe"), exports);
//# sourceMappingURL=index.js.map
/**
* Human-readable network name
*/
export declare type NetworkType = 'localhost' | 'mainnet' | 'goerli' | 'sepolia' | 'rpc';
export declare enum NetworkType {
localhost = "localhost",
mainnet = "mainnet",
goerli = "goerli",
sepolia = "sepolia",
rpc = "rpc"
}
/**
* A helper to determine whether a given input is NetworkType.
*
* @param val - the value to check whether it is NetworkType or not.
* @returns boolean indicating whether or not the argument is NetworkType.
*/
export declare function isNetworkType(val: any): val is NetworkType;
export declare enum NetworksChainId {

@@ -12,4 +25,11 @@ mainnet = "1",

}
export declare enum NetworksTicker {
mainnet = "ETH",
goerli = "GoerliETH",
sepolia = "SepoliaETH",
localhost = "",
rpc = ""
}
export declare type Json = null | boolean | number | string | Json[] | {
[prop: string]: Json;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworksChainId = void 0;
exports.NetworksTicker = exports.NetworksChainId = exports.isNetworkType = exports.NetworkType = void 0;
/**
* Human-readable network name
*/
var NetworkType;
(function (NetworkType) {
NetworkType["localhost"] = "localhost";
NetworkType["mainnet"] = "mainnet";
NetworkType["goerli"] = "goerli";
NetworkType["sepolia"] = "sepolia";
NetworkType["rpc"] = "rpc";
})(NetworkType = exports.NetworkType || (exports.NetworkType = {}));
/**
* A helper to determine whether a given input is NetworkType.
*
* @param val - the value to check whether it is NetworkType or not.
* @returns boolean indicating whether or not the argument is NetworkType.
*/
function isNetworkType(val) {
return Object.values(NetworkType).includes(val);
}
exports.isNetworkType = isNetworkType;
var NetworksChainId;

@@ -12,2 +33,10 @@ (function (NetworksChainId) {

})(NetworksChainId = exports.NetworksChainId || (exports.NetworksChainId = {}));
var NetworksTicker;
(function (NetworksTicker) {
NetworksTicker["mainnet"] = "ETH";
NetworksTicker["goerli"] = "GoerliETH";
NetworksTicker["sepolia"] = "SepoliaETH";
NetworksTicker["localhost"] = "";
NetworksTicker["rpc"] = "";
})(NetworksTicker = exports.NetworksTicker || (exports.NetworksTicker = {}));
//# sourceMappingURL=types.js.map

@@ -5,2 +5,11 @@ /// <reference types="bn.js" />

/**
* Checks whether the given number primitive chain ID is safe.
* Because some cryptographic libraries we use expect the chain ID to be a
* number primitive, it must not exceed a certain size.
*
* @param chainId - The chain ID to check for safety.
* @returns Whether the given chain ID is safe.
*/
export declare function isSafeChainId(chainId: number): boolean;
/**
* Converts a BN object to a hex string with a '0x' prefix.

@@ -7,0 +16,0 @@ *

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidJson = exports.isNonEmptyArray = exports.hasProperty = 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 = void 0;
exports.isValidJson = exports.isNonEmptyArray = exports.hasProperty = 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 ethereumjs_util_1 = require("ethereumjs-util");

@@ -21,4 +21,17 @@ const ethjs_unit_1 = require("ethjs-unit");

const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
const constants_1 = require("./constants");
const TIMEOUT_ERROR = new Error('timeout');
/**
* Checks whether the given number primitive chain ID is safe.
* Because some cryptographic libraries we use expect the chain ID to be a
* number primitive, it must not exceed a certain size.
*
* @param chainId - The chain ID to check for safety.
* @returns Whether the given chain ID is safe.
*/
function isSafeChainId(chainId) {
return (Number.isSafeInteger(chainId) && chainId > 0 && chainId <= constants_1.MAX_SAFE_CHAIN_ID);
}
exports.isSafeChainId = isSafeChainId;
/**
* Converts a BN object to a hex string with a '0x' prefix.

@@ -25,0 +38,0 @@ *

4

package.json
{
"name": "@metamask/controller-utils",
"version": "3.0.0",
"version": "3.1.0",
"description": "Data and convenience functions shared by multiple packages",

@@ -32,2 +32,4 @@ "keywords": [

"dependencies": {
"@metamask/utils": "^3.3.1",
"@spruceid/siwe-parser": "1.1.3",
"eth-ens-namehash": "^2.0.8",

@@ -34,0 +36,0 @@ "eth-rpc-errors": "^4.0.0",

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