@metamask-previews/controller-utils 4.3.1-preview.3dbf14f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,159 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [4.3.1]
10
+ ### Changed
11
+ - Replace `eth-query` ^2.1.2 with `@metamask/eth-query` ^3.0.1 ([#1546](https://github.com/MetaMask/core/pull/1546))
12
+
13
+ ## [4.3.0]
14
+ ### Changed
15
+ - Update `@metamask/utils` to `^6.2.0` ([#1514](https://github.com/MetaMask/core/pull/1514))
16
+ - Remove unnecessary `babel-runtime` dependency ([#1504](https://github.com/MetaMask/core/pull/1504))
17
+
18
+ ## [4.2.0]
19
+ ### Added
20
+ - Add support for Linea networks ([#1423](https://github.com/MetaMask/core/pull/1423))
21
+ - Add `LINEA_GOERLI` to `TESTNET_TICKER_SYMBOLS` map
22
+ - Add `linea-goerli` and `linea-mainnet` to `BUILT_IN_NETWORKS` map, as well as `NetworkType`, `InfuraNetworkType`, `ChainId`, and `NetworkId `enums
23
+ - Add `LineaGoerli` and `LineaMainnet` to `BuiltInNetworkName` enum
24
+
25
+ ## [4.1.0]
26
+ ### Added
27
+ - Add approval types for result pages ([#1442](https://github.com/MetaMask/core/pull/1442))
28
+
29
+ ## [4.0.1]
30
+ ### Changed
31
+ - Add dependencies `eth-query` and `babel-runtime` ([#1447](https://github.com/MetaMask/core/pull/1447))
32
+
33
+ ### Fixed
34
+ - Fix bug where query function failed to call built-in EthQuery methods ([#1447](https://github.com/MetaMask/core/pull/1447))
35
+
36
+ ## [4.0.0]
37
+ ### Added
38
+ - Add constants `BuiltInNetwork` and `ChainId` ([#1354](https://github.com/MetaMask/core/pull/1354))
39
+ - Add Aurora network to the `ChainId` constant ([#1327](https://github.com/MetaMask/core/pull/1327))
40
+ - Add `InfuraNetworkType` enum ([#1264](https://github.com/MetaMask/core/pull/1264))
41
+
42
+ ### Changed
43
+ - **BREAKING:** Bump to Node 16 ([#1262](https://github.com/MetaMask/core/pull/1262))
44
+ - **BREAKING:** The `isSafeChainId` chain ID parameter is now type `Hex` rather than `number` ([#1367](https://github.com/MetaMask/core/pull/1367))
45
+ - **BREAKING:** The `ChainId` enum and the `GANACHE_CHAIN_ID` constant are now formatted as 0x-prefixed hex strings rather than as decimal strings. ([#1367](https://github.com/MetaMask/core/pull/1367))
46
+ - The `query` function has improved type checks for the `ethQuery` argument ([#1266](https://github.com/MetaMask/core/pull/1266))
47
+ - This type change could be breaking, but only if you were passing in an invalid `ethQuery` parameter. In that circumstance this would have thrown an error at runtime anyway. Effectively this should be non-breaking for any usage that isn't already broken.
48
+ - Bump @metamask/utils from 5.0.1 to 5.0.2 ([#1271](https://github.com/MetaMask/core/pull/1271))
49
+
50
+ ### Removed
51
+ - **BREAKING:** Remove `Json` type ([#1370](https://github.com/MetaMask/core/pull/1370))
52
+ - **BREAKING:** Remove `NetworksChainId` constant ([#1354](https://github.com/MetaMask/core/pull/1354))
53
+ - Use the new `ChainId` constant or the pre-existing `NetworkId` constant instead
54
+ - **BREAKING:** Remove localhost network ([#1313](https://github.com/MetaMask/core/pull/1313))
55
+ - Remove the entry for localhost from `BUILT_IN_NETWORKS`, `NetworkType`, `ChainId`, and `NetworksTicker`
56
+ - **BREAKING:** Remove `hasProperty` function ([#1275](https://github.com/MetaMask/core/pull/1275))
57
+ - Use the `hasProperty` function from `@metamask/utils` instead
58
+ - **BREAKING:** Remove constants `MAINNET` and `TESTNET_TICKER_SYMBOLS` ([#1132](https://github.com/MetaMask/core/pull/1132))
59
+ - These were actually removed in v3.1.0, but are listed here again because that release (and the minor releases following it) have been deprecated due to the breaking change
60
+ - We didn't discover this until many releases later, which is why this happened in a minor release
61
+
62
+ ## [3.4.0] [DEPRECATED]
63
+ ### Added
64
+ - add WalletConnect in approval type ([#1240](https://github.com/MetaMask/core/pull/1240))
65
+
66
+ ## [3.3.0] [DEPRECATED]
67
+ ### Added
68
+ - Add Sign-in-with-Ethereum origin validation ([#1163](https://github.com/MetaMask/core/pull/1163))
69
+ - Add `NetworkId` enum and `NETWORK_ID_TO_ETHERS_NETWORK_NAME_MAP` constant that includes entries for each built-in Infura network ([#1170](https://github.com/MetaMask/core/pull/1170))
70
+
71
+ ## [3.2.0] [DEPRECATED]
72
+ ### Added
73
+ - Add `ORIGIN_METAMASK` constant ([#1166](https://github.com/MetaMask/core/pull/1166))
74
+ - Add `ApprovalType` enum ([#1174](https://github.com/MetaMask/core/pull/1174))
75
+
76
+ ### Changed
77
+ - Improve return type of `toHex` ([#1195](https://github.com/MetaMask/core/pull/1195))
78
+
79
+ ## [3.1.0] [DEPRECATED]
80
+ ### Added
81
+ - Add SIWE detection support for PersonalMessageManager ([#1139](https://github.com/MetaMask/core/pull/1139))
82
+ - Add `NetworkType` ([#1132](https://github.com/MetaMask/core/pull/1132))
83
+ - Add `isSafeChainId` ([#1064](https://github.com/MetaMask/core/pull/1064))
84
+
85
+ ### Removed
86
+ - **BREAKING:** Remove constants `MAINNET` and `TESTNET_TICKER_SYMBOLS` ([#1132](https://github.com/MetaMask/core/pull/1132))
87
+ - We didn't discover this until many releases later, which is why this happened in a minor release
88
+
89
+ ## [3.0.0]
90
+ ### Removed
91
+ - **BREAKING:** Remove `isomorphic-fetch` ([#1106](https://github.com/MetaMask/controllers/pull/1106))
92
+ - Consumers must now import `isomorphic-fetch` or another polyfill themselves if they are running in an environment without `fetch`
93
+
94
+ ## [2.0.0]
95
+ ### Added
96
+ - Add Sepolia-related constants ([#1041](https://github.com/MetaMask/controllers/pull/1041))
97
+ - Update `getBuyURL` function to return Sepolia faucet for Sepolia network ([#1041](https://github.com/MetaMask/controllers/pull/1041))
98
+
99
+ ### Changed
100
+ - **BREAKING:**: Migrate from `metaswap` to `metafi` subdomain for OpenSea proxy ([#1060](https://github.com/MetaMask/core/pull/1060))
101
+ - Rename this repository to `core` ([#1031](https://github.com/MetaMask/controllers/pull/1031))
102
+
103
+ ### Removed
104
+ - **BREAKING:** Remove all constants associated with Ropsten, Rinkeby, and Kovan ([#1041](https://github.com/MetaMask/controllers/pull/1041))
105
+ - **BREAKING:** Remove support for Ropsten, Rinkeby, and Kovan from `getBuyUrl` function ([#1041](https://github.com/MetaMask/controllers/pull/1041))
106
+
107
+ ## [1.0.0]
108
+ ### Added
109
+ - Initial release
110
+ - As a result of converting our shared controllers repo into a monorepo ([#831](https://github.com/MetaMask/core/pull/831)), we've created this package from select parts of [`@metamask/controllers` v33.0.0](https://github.com/MetaMask/core/tree/v33.0.0), namely:
111
+ - `src/constants.ts` (but see below)
112
+ - `src/util.ts` (but see below)
113
+ - `src/util.test.ts` (but see below)
114
+ - `NetworkType` and `NetworkChainsId` from `src/network/NetworkController.ts` (via `types.ts`)
115
+ - `ESTIMATE_GAS_ERROR`, which used to be exported by `src/constants.ts`, is now available via the `@metamask/gas-fee-controller` package.
116
+ - A number of functions and types that were previously exported by `src/util.ts` are now available via other packages. Here's a breakdown of these exports and their new locations:
117
+ - `@metamask/assets-controllers`:
118
+ - `SupportedTokenDetectionNetworks`
119
+ - `addUrlProtocolPrefix`
120
+ - `getFormattedIpfsUrl`
121
+ - `getIpfsCIDv1AndPath`
122
+ - `isTokenDetectionSupportedForNetwork`
123
+ - `isTokenListSupportedForNetwork`
124
+ - `removeIpfsProtocolPrefix`
125
+ - `validateTokenToWatch`
126
+ - `@metamask/message-manager`:
127
+ - `normalizeMessageData`
128
+ - `validateSignMessageData`
129
+ - `validateTypedSignMessageDataV1`
130
+ - `validateTypedSignMessageDataV3`
131
+ - `@metamask/transaction-controller`:
132
+ - `getEtherscanApiUrl`
133
+ - `getIncreasedPriceFromExisting`
134
+ - `getIncreasedPriceHex`
135
+ - `handleTransactionFetch`
136
+ - `isEIP1559Transaction`
137
+ - `isFeeMarketEIP1559Values`
138
+ - `isGasPriceValue`
139
+ - `normalizeTransaction`
140
+ - `validateGasValues`
141
+ - `validateMinimumIncrease`
142
+ - `validateTransaction`
143
+
144
+ All changes listed after this point were applied to this package following the monorepo conversion.
145
+
146
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.3.1...HEAD
147
+ [4.3.1]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.3.0...@metamask/controller-utils@4.3.1
148
+ [4.3.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.2.0...@metamask/controller-utils@4.3.0
149
+ [4.2.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.1.0...@metamask/controller-utils@4.2.0
150
+ [4.1.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.0.1...@metamask/controller-utils@4.1.0
151
+ [4.0.1]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.0.0...@metamask/controller-utils@4.0.1
152
+ [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.4.0...@metamask/controller-utils@4.0.0
153
+ [3.4.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.3.0...@metamask/controller-utils@3.4.0
154
+ [3.3.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.2.0...@metamask/controller-utils@3.3.0
155
+ [3.2.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.1.0...@metamask/controller-utils@3.2.0
156
+ [3.1.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@3.0.0...@metamask/controller-utils@3.1.0
157
+ [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@2.0.0...@metamask/controller-utils@3.0.0
158
+ [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@1.0.0...@metamask/controller-utils@2.0.0
159
+ [1.0.0]: https://github.com/MetaMask/core/releases/tag/@metamask/controller-utils@1.0.0
package/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 MetaMask
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
package/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # `@metamask/controller-utils`
2
+
3
+ Data and convenience functions shared by multiple packages.
4
+
5
+ ## Installation
6
+
7
+ `yarn add @metamask/controller-utils`
8
+
9
+ or
10
+
11
+ `npm install @metamask/controller-utils`
12
+
13
+ ## Contributing
14
+
15
+ This package is part of a monorepo. Instructions for contributing can be found in the [monorepo README](https://github.com/MetaMask/core#readme).
@@ -0,0 +1,107 @@
1
+ import { NetworksTicker, ChainId, BuiltInNetworkName } from './types';
2
+ export declare const RPC = "rpc";
3
+ export declare const FALL_BACK_VS_CURRENCY = "ETH";
4
+ export declare const IPFS_DEFAULT_GATEWAY_URL = "https://cloudflare-ipfs.com/ipfs/";
5
+ export declare const GANACHE_CHAIN_ID = "0x539";
6
+ /**
7
+ * The largest possible chain ID we can handle.
8
+ * Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
9
+ */
10
+ export declare const MAX_SAFE_CHAIN_ID = 4503599627370476;
11
+ export declare const ERC721 = "ERC721";
12
+ export declare const ERC1155 = "ERC1155";
13
+ export declare const ERC20 = "ERC20";
14
+ export declare const ERC721_INTERFACE_ID = "0x80ac58cd";
15
+ export declare const ERC721_METADATA_INTERFACE_ID = "0x5b5e139f";
16
+ export declare const ERC721_ENUMERABLE_INTERFACE_ID = "0x780e9d63";
17
+ export declare const ERC1155_INTERFACE_ID = "0xd9b67a26";
18
+ export declare const ERC1155_METADATA_URI_INTERFACE_ID = "0x0e89341c";
19
+ export declare const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = "0x4e2312e0";
20
+ export declare const GWEI = "gwei";
21
+ export declare const ASSET_TYPES: {
22
+ NATIVE: string;
23
+ TOKEN: string;
24
+ NFT: string;
25
+ UNKNOWN: string;
26
+ };
27
+ export declare const TESTNET_TICKER_SYMBOLS: {
28
+ GOERLI: string;
29
+ SEPOLIA: string;
30
+ LINEA_GOERLI: string;
31
+ };
32
+ /**
33
+ * Map of all build-in Infura networks to their network, ticker and chain IDs.
34
+ */
35
+ export declare const BUILT_IN_NETWORKS: {
36
+ readonly goerli: {
37
+ readonly chainId: "0x5";
38
+ readonly ticker: NetworksTicker.goerli;
39
+ readonly rpcPrefs: {
40
+ readonly blockExplorerUrl: "https://goerli.etherscan.io";
41
+ };
42
+ };
43
+ readonly sepolia: {
44
+ readonly chainId: "0xaa36a7";
45
+ readonly ticker: NetworksTicker.sepolia;
46
+ readonly rpcPrefs: {
47
+ readonly blockExplorerUrl: "https://sepolia.etherscan.io";
48
+ };
49
+ };
50
+ readonly mainnet: {
51
+ readonly chainId: "0x1";
52
+ readonly ticker: NetworksTicker.mainnet;
53
+ readonly rpcPrefs: {
54
+ readonly blockExplorerUrl: "https://etherscan.io";
55
+ };
56
+ };
57
+ readonly "linea-goerli": {
58
+ readonly chainId: "0xe704";
59
+ readonly ticker: typeof NetworksTicker["linea-goerli"];
60
+ readonly rpcPrefs: {
61
+ readonly blockExplorerUrl: "https://explorer.goerli.linea.build";
62
+ };
63
+ };
64
+ readonly "linea-mainnet": {
65
+ readonly chainId: "0xe708";
66
+ readonly ticker: NetworksTicker.mainnet;
67
+ readonly rpcPrefs: {
68
+ readonly blockExplorerUrl: "https://lineascan.build";
69
+ };
70
+ };
71
+ readonly rpc: {
72
+ readonly chainId: undefined;
73
+ readonly blockExplorerUrl: undefined;
74
+ readonly rpcPrefs: undefined;
75
+ };
76
+ };
77
+ export declare const OPENSEA_PROXY_URL = "https://proxy.metafi.codefi.network/opensea/v1/api/v1";
78
+ export declare const OPENSEA_API_URL = "https://api.opensea.io/api/v1";
79
+ export declare const OPENSEA_TEST_API_URL = "https://testnets-api.opensea.io/api/v1";
80
+ export declare const ORIGIN_METAMASK = "metamask";
81
+ /**
82
+ * Approval request types for various operations.
83
+ * These types are used by different controllers to create and manage
84
+ * approval requests consistently.
85
+ */
86
+ export declare enum ApprovalType {
87
+ AddEthereumChain = "wallet_addEthereumChain",
88
+ ConnectAccounts = "connect_accounts",
89
+ EthDecrypt = "eth_decrypt",
90
+ EthGetEncryptionPublicKey = "eth_getEncryptionPublicKey",
91
+ EthSign = "eth_sign",
92
+ EthSignTypedData = "eth_signTypedData",
93
+ PersonalSign = "personal_sign",
94
+ ResultError = "result_error",
95
+ ResultSuccess = "result_success",
96
+ SnapDialogAlert = "snap_dialog:alert",
97
+ SnapDialogConfirmation = "snap_dialog:confirmation",
98
+ SnapDialogPrompt = "snap_dialog:prompt",
99
+ SwitchEthereumChain = "wallet_switchEthereumChain",
100
+ Transaction = "transaction",
101
+ Unlock = "unlock",
102
+ WalletConnect = "wallet_connect",
103
+ WalletRequestPermissions = "wallet_requestPermissions",
104
+ WatchAsset = "wallet_watchAsset"
105
+ }
106
+ export declare const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<ChainId, BuiltInNetworkName>;
107
+ //# sourceMappingURL=constants.d.ts.map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OAAO,aAAa;IACpB,gBAAgB,sBAAsB;IACtC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,gBAAgB,uBAAuB;IACvC,mBAAmB,+BAA+B;IAClD,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,wBAAwB,8BAA8B;IACtD,UAAU,sBAAsB;CACjC;AAED,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,OAAO,EACP,kBAAkB,CAQnB,CAAC"}
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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;
4
+ const types_1 = require("./types");
5
+ exports.RPC = 'rpc';
6
+ exports.FALL_BACK_VS_CURRENCY = 'ETH';
7
+ exports.IPFS_DEFAULT_GATEWAY_URL = 'https://cloudflare-ipfs.com/ipfs/';
8
+ // NETWORKS ID
9
+ // `toHex` not invoked to avoid cyclic dependency
10
+ exports.GANACHE_CHAIN_ID = '0x539'; // toHex(1337)
11
+ /**
12
+ * The largest possible chain ID we can handle.
13
+ * Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553
14
+ */
15
+ exports.MAX_SAFE_CHAIN_ID = 4503599627370476;
16
+ // TOKEN STANDARDS
17
+ exports.ERC721 = 'ERC721';
18
+ exports.ERC1155 = 'ERC1155';
19
+ exports.ERC20 = 'ERC20';
20
+ // TOKEN INTERFACE IDS
21
+ exports.ERC721_INTERFACE_ID = '0x80ac58cd';
22
+ exports.ERC721_METADATA_INTERFACE_ID = '0x5b5e139f';
23
+ exports.ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63';
24
+ exports.ERC1155_INTERFACE_ID = '0xd9b67a26';
25
+ exports.ERC1155_METADATA_URI_INTERFACE_ID = '0x0e89341c';
26
+ exports.ERC1155_TOKEN_RECEIVER_INTERFACE_ID = '0x4e2312e0';
27
+ // UNITS
28
+ exports.GWEI = 'gwei';
29
+ // ASSET TYPES
30
+ exports.ASSET_TYPES = {
31
+ NATIVE: 'NATIVE',
32
+ TOKEN: 'TOKEN',
33
+ NFT: 'NFT',
34
+ UNKNOWN: 'UNKNOWN',
35
+ };
36
+ // TICKER SYMBOLS
37
+ exports.TESTNET_TICKER_SYMBOLS = {
38
+ GOERLI: 'GoerliETH',
39
+ SEPOLIA: 'SepoliaETH',
40
+ LINEA_GOERLI: 'LineaETH',
41
+ };
42
+ /**
43
+ * Map of all build-in Infura networks to their network, ticker and chain IDs.
44
+ */
45
+ exports.BUILT_IN_NETWORKS = {
46
+ [types_1.NetworkType.goerli]: {
47
+ chainId: types_1.ChainId.goerli,
48
+ ticker: types_1.NetworksTicker.goerli,
49
+ rpcPrefs: {
50
+ blockExplorerUrl: `https://${types_1.NetworkType.goerli}.etherscan.io`,
51
+ },
52
+ },
53
+ [types_1.NetworkType.sepolia]: {
54
+ chainId: types_1.ChainId.sepolia,
55
+ ticker: types_1.NetworksTicker.sepolia,
56
+ rpcPrefs: {
57
+ blockExplorerUrl: `https://${types_1.NetworkType.sepolia}.etherscan.io`,
58
+ },
59
+ },
60
+ [types_1.NetworkType.mainnet]: {
61
+ chainId: types_1.ChainId.mainnet,
62
+ ticker: types_1.NetworksTicker.mainnet,
63
+ rpcPrefs: {
64
+ blockExplorerUrl: 'https://etherscan.io',
65
+ },
66
+ },
67
+ [types_1.NetworkType['linea-goerli']]: {
68
+ chainId: types_1.ChainId['linea-goerli'],
69
+ ticker: types_1.NetworksTicker['linea-goerli'],
70
+ rpcPrefs: {
71
+ blockExplorerUrl: 'https://explorer.goerli.linea.build',
72
+ },
73
+ },
74
+ [types_1.NetworkType['linea-mainnet']]: {
75
+ chainId: types_1.ChainId['linea-mainnet'],
76
+ ticker: types_1.NetworksTicker['linea-mainnet'],
77
+ rpcPrefs: {
78
+ blockExplorerUrl: 'https://lineascan.build',
79
+ },
80
+ },
81
+ [types_1.NetworkType.rpc]: {
82
+ chainId: undefined,
83
+ blockExplorerUrl: undefined,
84
+ rpcPrefs: undefined,
85
+ },
86
+ };
87
+ // APIs
88
+ exports.OPENSEA_PROXY_URL = 'https://proxy.metafi.codefi.network/opensea/v1/api/v1';
89
+ exports.OPENSEA_API_URL = 'https://api.opensea.io/api/v1';
90
+ exports.OPENSEA_TEST_API_URL = 'https://testnets-api.opensea.io/api/v1';
91
+ // Default origin for controllers
92
+ exports.ORIGIN_METAMASK = 'metamask';
93
+ /**
94
+ * Approval request types for various operations.
95
+ * These types are used by different controllers to create and manage
96
+ * approval requests consistently.
97
+ */
98
+ var ApprovalType;
99
+ (function (ApprovalType) {
100
+ ApprovalType["AddEthereumChain"] = "wallet_addEthereumChain";
101
+ ApprovalType["ConnectAccounts"] = "connect_accounts";
102
+ ApprovalType["EthDecrypt"] = "eth_decrypt";
103
+ ApprovalType["EthGetEncryptionPublicKey"] = "eth_getEncryptionPublicKey";
104
+ ApprovalType["EthSign"] = "eth_sign";
105
+ ApprovalType["EthSignTypedData"] = "eth_signTypedData";
106
+ ApprovalType["PersonalSign"] = "personal_sign";
107
+ ApprovalType["ResultError"] = "result_error";
108
+ ApprovalType["ResultSuccess"] = "result_success";
109
+ ApprovalType["SnapDialogAlert"] = "snap_dialog:alert";
110
+ ApprovalType["SnapDialogConfirmation"] = "snap_dialog:confirmation";
111
+ ApprovalType["SnapDialogPrompt"] = "snap_dialog:prompt";
112
+ ApprovalType["SwitchEthereumChain"] = "wallet_switchEthereumChain";
113
+ ApprovalType["Transaction"] = "transaction";
114
+ ApprovalType["Unlock"] = "unlock";
115
+ ApprovalType["WalletConnect"] = "wallet_connect";
116
+ ApprovalType["WalletRequestPermissions"] = "wallet_requestPermissions";
117
+ ApprovalType["WatchAsset"] = "wallet_watchAsset";
118
+ })(ApprovalType = exports.ApprovalType || (exports.ApprovalType = {}));
119
+ exports.CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = {
120
+ [types_1.ChainId.goerli]: types_1.BuiltInNetworkName.Goerli,
121
+ [types_1.ChainId.sepolia]: types_1.BuiltInNetworkName.Sepolia,
122
+ [types_1.ChainId.mainnet]: types_1.BuiltInNetworkName.Mainnet,
123
+ [types_1.ChainId['linea-goerli']]: types_1.BuiltInNetworkName.LineaGoerli,
124
+ [types_1.ChainId['linea-mainnet']]: types_1.BuiltInNetworkName.LineaMainnet,
125
+ [types_1.ChainId.aurora]: types_1.BuiltInNetworkName.Aurora,
126
+ };
127
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,mCAKiB;AAEJ,QAAA,GAAG,GAAG,KAAK,CAAC;AACZ,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAC9B,QAAA,wBAAwB,GAAG,mCAAmC,CAAC;AAE5E,cAAc;AACd,iDAAiD;AACpC,QAAA,gBAAgB,GAAG,OAAO,CAAC,CAAC,cAAc;AACvD;;;GAGG;AACU,QAAA,iBAAiB,GAAG,gBAAgB,CAAC;AAElD,kBAAkB;AACL,QAAA,MAAM,GAAG,QAAQ,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,mCAAmC,GAG5C;IACF,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,0BAAkB,CAAC,MAAM;IAC3C,CAAC,eAAO,CAAC,OAAO,CAAC,EAAE,0BAAkB,CAAC,OAAO;IAC7C,CAAC,eAAO,CAAC,OAAO,CAAC,EAAE,0BAAkB,CAAC,OAAO;IAC7C,CAAC,eAAO,CAAC,cAAc,CAAC,CAAC,EAAE,0BAAkB,CAAC,WAAW;IACzD,CAAC,eAAO,CAAC,eAAe,CAAC,CAAC,EAAE,0BAAkB,CAAC,YAAY;IAC3D,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,0BAAkB,CAAC,MAAM;CAC5C,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n} from './types';\n\nexport const RPC = 'rpc';\nexport const FALL_BACK_VS_CURRENCY = 'ETH';\nexport const IPFS_DEFAULT_GATEWAY_URL = 'https://cloudflare-ipfs.com/ipfs/';\n\n// NETWORKS ID\n// `toHex` not invoked to avoid cyclic dependency\nexport const GANACHE_CHAIN_ID = '0x539'; // toHex(1337)\n/**\n * The largest possible chain ID we can handle.\n * Explanation: https://gist.github.com/rekmarks/a47bd5f2525936c4b8eee31a16345553\n */\nexport const MAX_SAFE_CHAIN_ID = 4503599627370476;\n\n// TOKEN STANDARDS\nexport const ERC721 = 'ERC721';\nexport const ERC1155 = 'ERC1155';\nexport const ERC20 = 'ERC20';\n\n// TOKEN INTERFACE IDS\nexport const ERC721_INTERFACE_ID = '0x80ac58cd';\nexport const ERC721_METADATA_INTERFACE_ID = '0x5b5e139f';\nexport const ERC721_ENUMERABLE_INTERFACE_ID = '0x780e9d63';\nexport const ERC1155_INTERFACE_ID = '0xd9b67a26';\nexport const ERC1155_METADATA_URI_INTERFACE_ID = '0x0e89341c';\nexport const ERC1155_TOKEN_RECEIVER_INTERFACE_ID = '0x4e2312e0';\n\n// UNITS\nexport const GWEI = 'gwei';\n\n// ASSET TYPES\nexport const ASSET_TYPES = {\n NATIVE: 'NATIVE',\n TOKEN: 'TOKEN',\n NFT: 'NFT',\n UNKNOWN: 'UNKNOWN',\n};\n\n// TICKER SYMBOLS\nexport const TESTNET_TICKER_SYMBOLS = {\n GOERLI: 'GoerliETH',\n SEPOLIA: 'SepoliaETH',\n LINEA_GOERLI: 'LineaETH',\n};\n\n/**\n * Map of all build-in Infura networks to their network, ticker and chain IDs.\n */\nexport const BUILT_IN_NETWORKS = {\n [NetworkType.goerli]: {\n chainId: ChainId.goerli,\n ticker: NetworksTicker.goerli,\n rpcPrefs: {\n blockExplorerUrl: `https://${NetworkType.goerli}.etherscan.io`,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: `https://${NetworkType.sepolia}.etherscan.io`,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: 'https://etherscan.io',\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: 'https://explorer.goerli.linea.build',\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: 'https://lineascan.build',\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.metafi.codefi.network/opensea/v1/api/v1';\nexport const OPENSEA_API_URL = 'https://api.opensea.io/api/v1';\nexport const OPENSEA_TEST_API_URL = 'https://testnets-api.opensea.io/api/v1';\n\n// Default origin for controllers\nexport const ORIGIN_METAMASK = 'metamask';\n\n/**\n * Approval request types for various operations.\n * These types are used by different controllers to create and manage\n * approval requests consistently.\n */\nexport enum ApprovalType {\n AddEthereumChain = 'wallet_addEthereumChain',\n ConnectAccounts = 'connect_accounts',\n EthDecrypt = 'eth_decrypt',\n EthGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',\n EthSign = 'eth_sign',\n EthSignTypedData = 'eth_signTypedData',\n PersonalSign = 'personal_sign',\n ResultError = 'result_error',\n ResultSuccess = 'result_success',\n SnapDialogAlert = 'snap_dialog:alert',\n SnapDialogConfirmation = 'snap_dialog:confirmation',\n SnapDialogPrompt = 'snap_dialog:prompt',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n ChainId,\n BuiltInNetworkName\n> = {\n [ChainId.goerli]: BuiltInNetworkName.Goerli,\n [ChainId.sepolia]: BuiltInNetworkName.Sepolia,\n [ChainId.mainnet]: BuiltInNetworkName.Mainnet,\n [ChainId['linea-goerli']]: BuiltInNetworkName.LineaGoerli,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './constants';
2
+ export * from './util';
3
+ export * from './types';
4
+ export * from './siwe';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./constants"), exports);
18
+ __exportStar(require("./util"), exports);
19
+ __exportStar(require("./types"), exports);
20
+ __exportStar(require("./siwe"), exports);
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,yCAAuB;AACvB,0CAAwB;AACxB,yCAAuB","sourcesContent":["export * from './constants';\nexport * from './util';\nexport * from './types';\nexport * from './siwe';\n"]}
@@ -0,0 +1,5 @@
1
+ /// <reference types="debug" />
2
+ import { createModuleLogger } from '@metamask/utils';
3
+ export declare const projectLogger: import("debug").Debugger;
4
+ export { createModuleLogger };
5
+ //# sourceMappingURL=logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";AAAA,OAAO,EAAuB,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,eAAO,MAAM,aAAa,0BAA0C,CAAC;AAErE,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/logger.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createModuleLogger = exports.projectLogger = void 0;
4
+ const utils_1 = require("@metamask/utils");
5
+ Object.defineProperty(exports, "createModuleLogger", { enumerable: true, get: function () { return utils_1.createModuleLogger; } });
6
+ exports.projectLogger = (0, utils_1.createProjectLogger)('controller-utils');
7
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAIjE,mGAJqB,0BAAkB,OAIrB;AAFd,QAAA,aAAa,GAAG,IAAA,2BAAmB,EAAC,kBAAkB,CAAC,CAAC","sourcesContent":["import { createProjectLogger, createModuleLogger } from '@metamask/utils';\n\nexport const projectLogger = createProjectLogger('controller-utils');\n\nexport { createModuleLogger };\n"]}
package/dist/siwe.d.ts ADDED
@@ -0,0 +1,68 @@
1
+ import { ParsedMessage } from '@spruceid/siwe-parser';
2
+ /**
3
+ * @type WrappedSIWERequest
4
+ *
5
+ * Sign-In With Ethereum (SIWE)(EIP-4361) message with request metadata
6
+ * @property {string} from - Subject account address
7
+ * @property {string} origin - The RFC 3986 originating authority of the signing request, including scheme
8
+ * @property {ParsedMessage} siwe - The data parsed from the message
9
+ */
10
+ export interface WrappedSIWERequest {
11
+ from: string;
12
+ origin: string;
13
+ siwe: SIWEMessage;
14
+ }
15
+ interface DomainParts {
16
+ username?: string;
17
+ hostname: string;
18
+ port?: string;
19
+ }
20
+ /**
21
+ * Parses parts from RFC 3986 authority from EIP-4361 `domain` field.
22
+ *
23
+ * @param domain - input string
24
+ * @param originProtocol - implied protocol from origin
25
+ * @returns parsed parts
26
+ */
27
+ export declare const parseDomainParts: (domain: string, originProtocol: string) => DomainParts;
28
+ /**
29
+ * Validates origin of a Sign-In With Ethereum (SIWE)(EIP-4361) request.
30
+ * As per spec:
31
+ * hostname must match.
32
+ * port and username must match iff specified.
33
+ * Protocol binding and full same-origin are currently not performed.
34
+ *
35
+ * @param req - Signature request
36
+ * @returns true if origin matches domain; false otherwise
37
+ */
38
+ export declare const isValidSIWEOrigin: (req: WrappedSIWERequest) => boolean;
39
+ /**
40
+ * A locally defined object used to provide data to identify a Sign-In With Ethereum (SIWE)(EIP-4361) message and provide the parsed message
41
+ *
42
+ * @typedef SIWEMessage
43
+ * @param {boolean} isSIWEMessage - Does the intercepted message conform to the SIWE specification?
44
+ * @param {ParsedMessage} parsedMessage - The data parsed out of the message
45
+ */
46
+ export declare type SIWEMessage = {
47
+ isSIWEMessage: true;
48
+ parsedMessage: ParsedMessage;
49
+ } | {
50
+ isSIWEMessage: false;
51
+ parsedMessage: null;
52
+ };
53
+ /**
54
+ * This function intercepts a sign message, detects if it's a
55
+ * Sign-In With Ethereum (SIWE)(EIP-4361) message, and returns an object with
56
+ * relevant SIWE data.
57
+ *
58
+ * {@see {@link https://eips.ethereum.org/EIPS/eip-4361}}
59
+ *
60
+ * @param msgParams - The params of the message to sign
61
+ * @param msgParams.data - The data of the message to sign
62
+ * @returns An object with the relevant SIWE data
63
+ */
64
+ export declare const detectSIWE: (msgParams: {
65
+ data: string;
66
+ }) => SIWEMessage;
67
+ export {};
68
+ //# sourceMappingURL=siwe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"siwe.d.ts","sourceRoot":"","sources":["../src/siwe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAqCtD;;;;;;;GAOG;AACH,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,UAAU,WAAW;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAOD;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,WACnB,MAAM,kBACE,MAAM,KACrB,WAKF,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,QAAS,kBAAkB,KAAG,OA4C3D,CAAC;AAEF;;;;;;GAMG;AACH,oBAAY,WAAW,GACnB;IAAE,aAAa,EAAE,IAAI,CAAC;IAAC,aAAa,EAAE,aAAa,CAAA;CAAE,GACrD;IAAE,aAAa,EAAE,KAAK,CAAC;IAAC,aAAa,EAAE,IAAI,CAAA;CAAE,CAAC;AAElD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,UAAU,cAAe;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,KAAG,WAiBxD,CAAC"}