@metamask-previews/controller-utils 11.20.0-preview-bd0d4d2e9 → 11.20.0-preview-f60a0b769
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 +4 -0
- package/dist/constants.cjs +28 -0
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +28 -0
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.mts +28 -0
- package/dist/constants.d.mts.map +1 -1
- package/dist/constants.mjs +28 -0
- package/dist/constants.mjs.map +1 -1
- package/dist/create-service-policy.cjs +1 -1
- package/dist/create-service-policy.cjs.map +1 -1
- package/dist/create-service-policy.d.cts +3 -1
- package/dist/create-service-policy.d.cts.map +1 -1
- package/dist/create-service-policy.d.mts +3 -1
- package/dist/create-service-policy.d.mts.map +1 -1
- package/dist/create-service-policy.mjs +1 -1
- package/dist/create-service-policy.mjs.map +1 -1
- package/dist/types.cjs +25 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +27 -1
- package/dist/types.d.cts.map +1 -1
- package/dist/types.d.mts +27 -1
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +25 -0
- package/dist/types.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,8 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Changed
|
|
11
11
|
|
|
12
|
+
- **BREAKING:** The `ServicePolicy` type's `onDegraded` event now emits `{ duration: number }` instead of `void` when the service succeeds but takes longer than the `degradedThreshold` ([#8455](https://github.com/MetaMask/core/pull/8455))
|
|
13
|
+
- `void` has been removed from the event's type union. Listeners that checked for `undefined` data should now check for the `duration` property instead.
|
|
14
|
+
- The event still emits a `FailureReason` when retries are exhausted.
|
|
12
15
|
- Update `normalizeEnsName` regex to allow ENS names with 3 or more characters (previously required 7 or more) ([#8510](https://github.com/MetaMask/core/pull/8510))
|
|
13
16
|
- Update default Sei Mainnet block explorer URL from `seitrace.com` to `seiscan.io` ([#8545](https://github.com/MetaMask/core/pull/8545))
|
|
17
|
+
- Update `BUILT_IN_NETWORKS`, `InfuraNetworkType`, `ChainId`, `NetworksTicker`, `BlockExplorerUrl`, `NetworkNickname` to include missing Infura networks ([#8680](https://github.com/MetaMask/core/pull/8680), [#8713](https://github.com/MetaMask/core/pull/8713))
|
|
14
18
|
|
|
15
19
|
## [11.20.0]
|
|
16
20
|
|
package/dist/constants.cjs
CHANGED
|
@@ -166,6 +166,34 @@ exports.BUILT_IN_NETWORKS = {
|
|
|
166
166
|
blockExplorerUrl: types_1.BlockExplorerUrl['sei-mainnet'],
|
|
167
167
|
},
|
|
168
168
|
},
|
|
169
|
+
[types_1.NetworkType['monad-mainnet']]: {
|
|
170
|
+
chainId: types_1.ChainId['monad-mainnet'],
|
|
171
|
+
ticker: types_1.NetworksTicker['monad-mainnet'],
|
|
172
|
+
rpcPrefs: {
|
|
173
|
+
blockExplorerUrl: types_1.BlockExplorerUrl['monad-mainnet'],
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
[types_1.NetworkType['zksync-mainnet']]: {
|
|
177
|
+
chainId: types_1.ChainId['zksync-mainnet'],
|
|
178
|
+
ticker: types_1.NetworksTicker['zksync-mainnet'],
|
|
179
|
+
rpcPrefs: {
|
|
180
|
+
blockExplorerUrl: types_1.BlockExplorerUrl['zksync-mainnet'],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
[types_1.NetworkType['megaeth-mainnet']]: {
|
|
184
|
+
chainId: types_1.ChainId['megaeth-mainnet'],
|
|
185
|
+
ticker: types_1.NetworksTicker['megaeth-mainnet'],
|
|
186
|
+
rpcPrefs: {
|
|
187
|
+
blockExplorerUrl: types_1.BlockExplorerUrl['megaeth-mainnet'],
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
[types_1.NetworkType['avalanche-mainnet']]: {
|
|
191
|
+
chainId: types_1.ChainId['avalanche-mainnet'],
|
|
192
|
+
ticker: types_1.NetworksTicker['avalanche-mainnet'],
|
|
193
|
+
rpcPrefs: {
|
|
194
|
+
blockExplorerUrl: types_1.BlockExplorerUrl['avalanche-mainnet'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
169
197
|
[types_1.NetworkType.rpc]: {
|
|
170
198
|
chainId: undefined,
|
|
171
199
|
blockExplorerUrl: undefined,
|
package/dist/constants.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,uCAMiB;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,CAAC;AAClB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,KAAK,GAAG,OAAO,CAAC;AAE7B,sBAAsB;AACT,QAAA,mBAAmB,GAAG,YAAY,CAAC;AACnC,QAAA,4BAA4B,GAAG,YAAY,CAAC;AAC5C,QAAA,8BAA8B,GAAG,YAAY,CAAC;AAC9C,QAAA,oBAAoB,GAAG,YAAY,CAAC;AACpC,QAAA,iCAAiC,GAAG,YAAY,CAAC;AACjD,QAAA,mCAAmC,GAAG,YAAY,CAAC;AAEhE,QAAQ;AACK,QAAA,IAAI,GAAG,MAAM,CAAC;AAE3B,cAAc;AACD,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,iBAAiB;AACJ,QAAA,sBA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AAkB,CAAC,YAAY;IAC3D,CAAC,eAAO,CAAC,eAAe,CAAC,CAAC,EAAE,0BAAkB,CAAC,YAAY;IAC3D,CAAC,eAAO,CAAC,MAAM,CAAC,EAAE,0BAAkB,CAAC,MAAM;CAC5C,CAAC;AAEF;;GAEG;AACU,QAAA,MAAM,GAAG,IAAI,CAAC;AAE3B;;GAEG;AACU,QAAA,OAAO,GAAG,cAAM,CAAC;AAE9B;;GAEG;AACU,QAAA,MAAM,GAAG,eAAO,GAAG,EAAE,CAAC;AAEnC;;GAEG;AACU,QAAA,OAAO,GAAG,cAAM,CAAC;AAE9B;;GAEG;AACU,QAAA,IAAI,GAAG,eAAO,GAAG,EAAE,CAAC;AAEjC;;GAEG;AACU,QAAA,KAAK,GAAG,YAAI,CAAC;AAE1B;;GAEG;AACU,QAAA,GAAG,GAAG,aAAK,GAAG,EAAE,CAAC;AAE9B;;GAEG;AACU,QAAA,IAAI,GAAG,WAAG,CAAC;AAExB;;;;;GAKG;AACU,QAAA,8BAA8B,GAAG;IAC5C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n BlockExplorerUrl,\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 LINEA_SEPOLIA: 'LineaETH',\n MEGAETH_TESTNET: 'MegaETH',\n MEGAETH_TESTNET_V2: 'MegaETH',\n};\n\n/**\n * Map of all built-in custom networks to their RPC endpoints.\n */\nexport const BUILT_IN_CUSTOM_NETWORKS_RPC = {\n /**\n * @deprecated Please use `megaeth-testnet` instead.\n */\n MEGAETH_TESTNET: 'https://carrot.megaeth.com/rpc',\n /**\n * @deprecated Please use `megaeth-testnet-v2` instead.\n */\n 'megaeth-testnet': 'https://carrot.megaeth.com/rpc',\n 'megaeth-testnet-v2': 'https://carrot.megaeth.com/rpc',\n 'monad-testnet': 'https://testnet-rpc.monad.xyz',\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: BlockExplorerUrl.goerli,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.sepolia,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.mainnet,\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-goerli'],\n },\n },\n [NetworkType['linea-sepolia']]: {\n chainId: ChainId['linea-sepolia'],\n ticker: NetworksTicker['linea-sepolia'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-sepolia'],\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-mainnet'],\n },\n },\n [NetworkType['megaeth-testnet']]: {\n chainId: ChainId['megaeth-testnet'],\n ticker: NetworksTicker['megaeth-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet'],\n },\n },\n [NetworkType['megaeth-testnet-v2']]: {\n chainId: ChainId['megaeth-testnet-v2'],\n ticker: NetworksTicker['megaeth-testnet-v2'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet-v2'],\n },\n },\n [NetworkType['monad-testnet']]: {\n chainId: ChainId['monad-testnet'],\n ticker: NetworksTicker['monad-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-testnet'],\n },\n },\n [NetworkType['base-mainnet']]: {\n chainId: ChainId['base-mainnet'],\n ticker: NetworksTicker['base-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['base-mainnet'],\n },\n },\n [NetworkType['arbitrum-mainnet']]: {\n chainId: ChainId['arbitrum-mainnet'],\n ticker: NetworksTicker['arbitrum-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['arbitrum-mainnet'],\n },\n },\n [NetworkType['bsc-mainnet']]: {\n chainId: ChainId['bsc-mainnet'],\n ticker: NetworksTicker['bsc-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['bsc-mainnet'],\n },\n },\n [NetworkType['optimism-mainnet']]: {\n chainId: ChainId['optimism-mainnet'],\n ticker: NetworksTicker['optimism-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['optimism-mainnet'],\n },\n },\n [NetworkType['polygon-mainnet']]: {\n chainId: ChainId['polygon-mainnet'],\n ticker: NetworksTicker['polygon-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['polygon-mainnet'],\n },\n },\n [NetworkType['sei-mainnet']]: {\n chainId: ChainId['sei-mainnet'],\n ticker: NetworksTicker['sei-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['sei-mainnet'],\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n ticker: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n/**\n * When a user adds a custom network to MetaMask, we perform some basic\n * validations on the network. For instance, usually a network cannot share the\n * same chain as another. In some cases, however, we want to allow networks that\n * would normally be invalid. This mapping contains networks that should bypass\n * validation.\n */\nexport const NETWORKS_BYPASSING_VALIDATION = {\n // HyperEVM uses the same chain ID as Wanchain\n '0x3e7': {\n name: 'HyperEVM',\n symbol: 'HYPE',\n rpcUrl: 'https://rpc.hyperliquid.xyz',\n },\n};\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';\n\nexport const NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';\n\nexport const NFT_API_VERSION = '1';\n\nexport const NFT_API_TIMEOUT = 15000;\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 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 SnapDialogDefault = 'snap_dialog',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n TransactionBatch = 'transaction_batch',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\n/**\n * Mapping of chain IDs to their network names for ENS functionality.\n * Note: MegaETH-testnet is intentionally excluded from this mapping as it doesn't support ENS.\n */\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n string,\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-sepolia']]: BuiltInNetworkName.LineaSepolia,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECOND = 1000;\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECONDS = SECOND;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTE = SECONDS * 60;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTES = MINUTE;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOUR = MINUTES * 60;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOURS = HOUR;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAY = HOURS * 24;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAYS = DAY;\n\n/**\n * Special \"EVM-ish\" chains with no native tokens.\n * Created for Tempo, but can be extended to others.\n * - For hidding the native token from the token list and Send list.\n * - For excluding the native token from the total wallet value calculation.\n */\nexport const CHAIN_IDS_WITH_NO_NATIVE_TOKEN = [\n 'eip155:42431', // Tempo Testnet\n 'eip155:4217', // Tempo Mainnet\n] as const;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.cjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";;;AAAA,uCAMiB;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,CAAC;AAClB,QAAA,OAAO,GAAG,SAAS,CAAC;AACpB,QAAA,KAAK,GAAG,OAAO,CAAC;AAE7B,sBAAsB;AACT,QAAA,mBAAmB,GAAG,YAAY,CAAC;AACnC,QAAA,4BAA4B,GAAG,YAAY,CAAC;AAC5C,QAAA,8BAA8B,GAAG,YAAY,CAAC;AAC9C,QAAA,oBAAoB,GAAG,YAAY,CAAC;AACpC,QAAA,iCAAiC,GAAG,YAAY,CAAC;AACjD,QAAA,mCAAmC,GAAG,YAAY,CAAC;AAEhE,QAAQ;AACK,QAAA,IAAI,GAAG,MAAM,CAAC;AAE3B,cAAc;AACD,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,OAAO,EAAE,SAAS;CACnB,CAAC;AAEF,iBAAiB;AACJ,QAAA,sBAAsB,GAAG;IACpC,MAAM,EAAE,WAAW;IACnB,O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GAAG,eAAO,GAAG,EAAE,CAAC;AAEjC;;GAEG;AACU,QAAA,KAAK,GAAG,YAAI,CAAC;AAE1B;;GAEG;AACU,QAAA,GAAG,GAAG,aAAK,GAAG,EAAE,CAAC;AAE9B;;GAEG;AACU,QAAA,IAAI,GAAG,WAAG,CAAC;AAExB;;;;;GAKG;AACU,QAAA,8BAA8B,GAAG;IAC5C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n BlockExplorerUrl,\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 LINEA_SEPOLIA: 'LineaETH',\n MEGAETH_TESTNET: 'MegaETH',\n MEGAETH_TESTNET_V2: 'MegaETH',\n};\n\n/**\n * Map of all built-in custom networks to their RPC endpoints.\n */\nexport const BUILT_IN_CUSTOM_NETWORKS_RPC = {\n /**\n * @deprecated Please use `megaeth-testnet` instead.\n */\n MEGAETH_TESTNET: 'https://carrot.megaeth.com/rpc',\n /**\n * @deprecated Please use `megaeth-testnet-v2` instead.\n */\n 'megaeth-testnet': 'https://carrot.megaeth.com/rpc',\n 'megaeth-testnet-v2': 'https://carrot.megaeth.com/rpc',\n 'monad-testnet': 'https://testnet-rpc.monad.xyz',\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: BlockExplorerUrl.goerli,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.sepolia,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.mainnet,\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-goerli'],\n },\n },\n [NetworkType['linea-sepolia']]: {\n chainId: ChainId['linea-sepolia'],\n ticker: NetworksTicker['linea-sepolia'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-sepolia'],\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-mainnet'],\n },\n },\n [NetworkType['megaeth-testnet']]: {\n chainId: ChainId['megaeth-testnet'],\n ticker: NetworksTicker['megaeth-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet'],\n },\n },\n [NetworkType['megaeth-testnet-v2']]: {\n chainId: ChainId['megaeth-testnet-v2'],\n ticker: NetworksTicker['megaeth-testnet-v2'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet-v2'],\n },\n },\n [NetworkType['monad-testnet']]: {\n chainId: ChainId['monad-testnet'],\n ticker: NetworksTicker['monad-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-testnet'],\n },\n },\n [NetworkType['base-mainnet']]: {\n chainId: ChainId['base-mainnet'],\n ticker: NetworksTicker['base-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['base-mainnet'],\n },\n },\n [NetworkType['arbitrum-mainnet']]: {\n chainId: ChainId['arbitrum-mainnet'],\n ticker: NetworksTicker['arbitrum-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['arbitrum-mainnet'],\n },\n },\n [NetworkType['bsc-mainnet']]: {\n chainId: ChainId['bsc-mainnet'],\n ticker: NetworksTicker['bsc-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['bsc-mainnet'],\n },\n },\n [NetworkType['optimism-mainnet']]: {\n chainId: ChainId['optimism-mainnet'],\n ticker: NetworksTicker['optimism-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['optimism-mainnet'],\n },\n },\n [NetworkType['polygon-mainnet']]: {\n chainId: ChainId['polygon-mainnet'],\n ticker: NetworksTicker['polygon-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['polygon-mainnet'],\n },\n },\n [NetworkType['sei-mainnet']]: {\n chainId: ChainId['sei-mainnet'],\n ticker: NetworksTicker['sei-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['sei-mainnet'],\n },\n },\n [NetworkType['monad-mainnet']]: {\n chainId: ChainId['monad-mainnet'],\n ticker: NetworksTicker['monad-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-mainnet'],\n },\n },\n [NetworkType['zksync-mainnet']]: {\n chainId: ChainId['zksync-mainnet'],\n ticker: NetworksTicker['zksync-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['zksync-mainnet'],\n },\n },\n [NetworkType['megaeth-mainnet']]: {\n chainId: ChainId['megaeth-mainnet'],\n ticker: NetworksTicker['megaeth-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-mainnet'],\n },\n },\n [NetworkType['avalanche-mainnet']]: {\n chainId: ChainId['avalanche-mainnet'],\n ticker: NetworksTicker['avalanche-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['avalanche-mainnet'],\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n ticker: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n/**\n * When a user adds a custom network to MetaMask, we perform some basic\n * validations on the network. For instance, usually a network cannot share the\n * same chain as another. In some cases, however, we want to allow networks that\n * would normally be invalid. This mapping contains networks that should bypass\n * validation.\n */\nexport const NETWORKS_BYPASSING_VALIDATION = {\n // HyperEVM uses the same chain ID as Wanchain\n '0x3e7': {\n name: 'HyperEVM',\n symbol: 'HYPE',\n rpcUrl: 'https://rpc.hyperliquid.xyz',\n },\n};\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';\n\nexport const NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';\n\nexport const NFT_API_VERSION = '1';\n\nexport const NFT_API_TIMEOUT = 15000;\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 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 SnapDialogDefault = 'snap_dialog',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n TransactionBatch = 'transaction_batch',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\n/**\n * Mapping of chain IDs to their network names for ENS functionality.\n * Note: MegaETH-testnet is intentionally excluded from this mapping as it doesn't support ENS.\n */\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n string,\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-sepolia']]: BuiltInNetworkName.LineaSepolia,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECOND = 1000;\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECONDS = SECOND;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTE = SECONDS * 60;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTES = MINUTE;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOUR = MINUTES * 60;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOURS = HOUR;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAY = HOURS * 24;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAYS = DAY;\n\n/**\n * Special \"EVM-ish\" chains with no native tokens.\n * Created for Tempo, but can be extended to others.\n * - For hidding the native token from the token list and Send list.\n * - For excluding the native token from the total wallet value calculation.\n */\nexport const CHAIN_IDS_WITH_NO_NATIVE_TOKEN = [\n 'eip155:42431', // Tempo Testnet\n 'eip155:4217', // Tempo Mainnet\n] as const;\n"]}
|
package/dist/constants.d.cts
CHANGED
|
@@ -156,6 +156,34 @@ export declare const BUILT_IN_NETWORKS: {
|
|
|
156
156
|
readonly blockExplorerUrl: "https://seiscan.io";
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
|
+
readonly "monad-mainnet": {
|
|
160
|
+
readonly chainId: "0x8f";
|
|
161
|
+
readonly ticker: (typeof NetworksTicker)["monad-testnet"];
|
|
162
|
+
readonly rpcPrefs: {
|
|
163
|
+
readonly blockExplorerUrl: "https://monadscan.com";
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
readonly "zksync-mainnet": {
|
|
167
|
+
readonly chainId: "0x144";
|
|
168
|
+
readonly ticker: NetworksTicker.mainnet;
|
|
169
|
+
readonly rpcPrefs: {
|
|
170
|
+
readonly blockExplorerUrl: "https://explorer.zksync.io";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
readonly "megaeth-mainnet": {
|
|
174
|
+
readonly chainId: "0x10e6";
|
|
175
|
+
readonly ticker: NetworksTicker.mainnet;
|
|
176
|
+
readonly rpcPrefs: {
|
|
177
|
+
readonly blockExplorerUrl: "https://megaeth.blockscout.com";
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
readonly "avalanche-mainnet": {
|
|
181
|
+
readonly chainId: "0xa86a";
|
|
182
|
+
readonly ticker: (typeof NetworksTicker)["avalanche-mainnet"];
|
|
183
|
+
readonly rpcPrefs: {
|
|
184
|
+
readonly blockExplorerUrl: "https://snowtrace.io";
|
|
185
|
+
};
|
|
186
|
+
};
|
|
159
187
|
readonly rpc: {
|
|
160
188
|
readonly chainId: undefined;
|
|
161
189
|
readonly blockExplorerUrl: undefined;
|
package/dist/constants.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.cts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAEd,kBAAkB,EAEnB,oBAAgB;AAEjB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,wBAAwB,sCAAsC,CAAC;AAI5E,eAAO,MAAM,gBAAgB,UAAU,CAAC;AACxC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAGlD,eAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,eAAO,MAAM,OAAO,YAAY,CAAC;AACjC,eAAO,MAAM,KAAK,UAAU,CAAC;AAG7B,eAAO,MAAM,mBAAmB,eAAe,CAAC;AAChD,eAAO,MAAM,4BAA4B,eAAe,CAAC;AACzD,eAAO,MAAM,8BAA8B,eAAe,CAAC;AAC3D,eAAO,MAAM,oBAAoB,eAAe,CAAC;AACjD,eAAO,MAAM,iCAAiC,eAAe,CAAC;AAC9D,eAAO,MAAM,mCAAmC,eAAe,CAAC;AAGhE,eAAO,MAAM,IAAI,SAAS,CAAC;AAG3B,eAAO,MAAM,WAAW;;;;;CAKvB,CAAC;AAGF,eAAO,MAAM,sBAAsB;;;;;;;CAOlC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B;IACvC;;OAEG;;IAEH;;OAEG;;;;CAIJ,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"const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CAAC;AAEjE,eAAO,MAAM,eAAe,MAAM,CAAC;AAEnC,eAAO,MAAM,eAAe,QAAQ,CAAC;AAGrC,eAAO,MAAM,eAAe,aAAa,CAAC;AAE1C;;;;GAIG;AACH,oBAAY,YAAY;IACtB,gBAAgB,4BAA4B;IAC5C,eAAe,qBAAqB;IACpC,UAAU,gBAAgB;IAC1B,yBAAyB,+BAA+B;IACxD,gBAAgB,sBAAsB;IACtC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,gBAAgB,uBAAuB;IACvC,iBAAiB,gBAAgB;IACjC,mBAAmB,+BAA+B;IAClD,WAAW,gBAAgB;IAC3B,gBAAgB,sBAAsB;IACtC,MAAM,WAAW;IACjB,aAAa,mBAAmB;IAChC,wBAAwB,8BAA8B;IACtD,UAAU,sBAAsB;CACjC;AAED;;;GAGG;AACH,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,MAAM,EACN,kBAAkB,CASnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,OAAO,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,OAAO,OAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,OAAO,QAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI,QAAe,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,KAAK,QAAO,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,GAAG,QAAa,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI,QAAM,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,0CAGjC,CAAC"}
|
package/dist/constants.d.mts
CHANGED
|
@@ -156,6 +156,34 @@ export declare const BUILT_IN_NETWORKS: {
|
|
|
156
156
|
readonly blockExplorerUrl: "https://seiscan.io";
|
|
157
157
|
};
|
|
158
158
|
};
|
|
159
|
+
readonly "monad-mainnet": {
|
|
160
|
+
readonly chainId: "0x8f";
|
|
161
|
+
readonly ticker: (typeof NetworksTicker)["monad-testnet"];
|
|
162
|
+
readonly rpcPrefs: {
|
|
163
|
+
readonly blockExplorerUrl: "https://monadscan.com";
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
readonly "zksync-mainnet": {
|
|
167
|
+
readonly chainId: "0x144";
|
|
168
|
+
readonly ticker: NetworksTicker.mainnet;
|
|
169
|
+
readonly rpcPrefs: {
|
|
170
|
+
readonly blockExplorerUrl: "https://explorer.zksync.io";
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
readonly "megaeth-mainnet": {
|
|
174
|
+
readonly chainId: "0x10e6";
|
|
175
|
+
readonly ticker: NetworksTicker.mainnet;
|
|
176
|
+
readonly rpcPrefs: {
|
|
177
|
+
readonly blockExplorerUrl: "https://megaeth.blockscout.com";
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
readonly "avalanche-mainnet": {
|
|
181
|
+
readonly chainId: "0xa86a";
|
|
182
|
+
readonly ticker: (typeof NetworksTicker)["avalanche-mainnet"];
|
|
183
|
+
readonly rpcPrefs: {
|
|
184
|
+
readonly blockExplorerUrl: "https://snowtrace.io";
|
|
185
|
+
};
|
|
186
|
+
};
|
|
159
187
|
readonly rpc: {
|
|
160
188
|
readonly chainId: undefined;
|
|
161
189
|
readonly blockExplorerUrl: undefined;
|
package/dist/constants.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.mts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAEd,kBAAkB,EAEnB,oBAAgB;AAEjB,eAAO,MAAM,GAAG,QAAQ,CAAC;AACzB,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAC3C,eAAO,MAAM,wBAAwB,sCAAsC,CAAC;AAI5E,eAAO,MA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AwB,8BAA8B;IACtD,UAAU,sBAAsB;CACjC;AAED;;;GAGG;AACH,eAAO,MAAM,mCAAmC,EAAE,MAAM,CACtD,MAAM,EACN,kBAAkB,CASnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,MAAM,OAAO,CAAC;AAE3B;;GAEG;AACH,eAAO,MAAM,OAAO,OAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,MAAM,QAAe,CAAC;AAEnC;;GAEG;AACH,eAAO,MAAM,OAAO,QAAS,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI,QAAe,CAAC;AAEjC;;GAEG;AACH,eAAO,MAAM,KAAK,QAAO,CAAC;AAE1B;;GAEG;AACH,eAAO,MAAM,GAAG,QAAa,CAAC;AAE9B;;GAEG;AACH,eAAO,MAAM,IAAI,QAAM,CAAC;AAExB;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,0CAGjC,CAAC"}
|
package/dist/constants.mjs
CHANGED
|
@@ -163,6 +163,34 @@ export const BUILT_IN_NETWORKS = {
|
|
|
163
163
|
blockExplorerUrl: BlockExplorerUrl['sei-mainnet'],
|
|
164
164
|
},
|
|
165
165
|
},
|
|
166
|
+
[NetworkType['monad-mainnet']]: {
|
|
167
|
+
chainId: ChainId['monad-mainnet'],
|
|
168
|
+
ticker: NetworksTicker['monad-mainnet'],
|
|
169
|
+
rpcPrefs: {
|
|
170
|
+
blockExplorerUrl: BlockExplorerUrl['monad-mainnet'],
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
[NetworkType['zksync-mainnet']]: {
|
|
174
|
+
chainId: ChainId['zksync-mainnet'],
|
|
175
|
+
ticker: NetworksTicker['zksync-mainnet'],
|
|
176
|
+
rpcPrefs: {
|
|
177
|
+
blockExplorerUrl: BlockExplorerUrl['zksync-mainnet'],
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
[NetworkType['megaeth-mainnet']]: {
|
|
181
|
+
chainId: ChainId['megaeth-mainnet'],
|
|
182
|
+
ticker: NetworksTicker['megaeth-mainnet'],
|
|
183
|
+
rpcPrefs: {
|
|
184
|
+
blockExplorerUrl: BlockExplorerUrl['megaeth-mainnet'],
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
[NetworkType['avalanche-mainnet']]: {
|
|
188
|
+
chainId: ChainId['avalanche-mainnet'],
|
|
189
|
+
ticker: NetworksTicker['avalanche-mainnet'],
|
|
190
|
+
rpcPrefs: {
|
|
191
|
+
blockExplorerUrl: BlockExplorerUrl['avalanche-mainnet'],
|
|
192
|
+
},
|
|
193
|
+
},
|
|
166
194
|
[NetworkType.rpc]: {
|
|
167
195
|
chainId: undefined,
|
|
168
196
|
blockExplorerUrl: undefined,
|
package/dist/constants.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EACjB,oBAAgB;AAEjB,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,mCAAmC,CAAC;AAE5E,cAAc;AACd,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,CAAC,cAAc;AACvD;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,gBAAgB,CAAC;AAElD,kBAAkB;AAClB,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,KAAK,GAAG,OAAO,CAAC;AAE7B,sBAAsB;AACtB,MAAM,CAAC,MAAM,mBAAmB,GAAG,YAAY,CAAC;AAChD,MAAM,CAAC,MAAM,4BAA4B,GAAG,YAAY,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AG,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n BlockExplorerUrl,\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 LINEA_SEPOLIA: 'LineaETH',\n MEGAETH_TESTNET: 'MegaETH',\n MEGAETH_TESTNET_V2: 'MegaETH',\n};\n\n/**\n * Map of all built-in custom networks to their RPC endpoints.\n */\nexport const BUILT_IN_CUSTOM_NETWORKS_RPC = {\n /**\n * @deprecated Please use `megaeth-testnet` instead.\n */\n MEGAETH_TESTNET: 'https://carrot.megaeth.com/rpc',\n /**\n * @deprecated Please use `megaeth-testnet-v2` instead.\n */\n 'megaeth-testnet': 'https://carrot.megaeth.com/rpc',\n 'megaeth-testnet-v2': 'https://carrot.megaeth.com/rpc',\n 'monad-testnet': 'https://testnet-rpc.monad.xyz',\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: BlockExplorerUrl.goerli,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.sepolia,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.mainnet,\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-goerli'],\n },\n },\n [NetworkType['linea-sepolia']]: {\n chainId: ChainId['linea-sepolia'],\n ticker: NetworksTicker['linea-sepolia'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-sepolia'],\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-mainnet'],\n },\n },\n [NetworkType['megaeth-testnet']]: {\n chainId: ChainId['megaeth-testnet'],\n ticker: NetworksTicker['megaeth-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet'],\n },\n },\n [NetworkType['megaeth-testnet-v2']]: {\n chainId: ChainId['megaeth-testnet-v2'],\n ticker: NetworksTicker['megaeth-testnet-v2'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet-v2'],\n },\n },\n [NetworkType['monad-testnet']]: {\n chainId: ChainId['monad-testnet'],\n ticker: NetworksTicker['monad-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-testnet'],\n },\n },\n [NetworkType['base-mainnet']]: {\n chainId: ChainId['base-mainnet'],\n ticker: NetworksTicker['base-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['base-mainnet'],\n },\n },\n [NetworkType['arbitrum-mainnet']]: {\n chainId: ChainId['arbitrum-mainnet'],\n ticker: NetworksTicker['arbitrum-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['arbitrum-mainnet'],\n },\n },\n [NetworkType['bsc-mainnet']]: {\n chainId: ChainId['bsc-mainnet'],\n ticker: NetworksTicker['bsc-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['bsc-mainnet'],\n },\n },\n [NetworkType['optimism-mainnet']]: {\n chainId: ChainId['optimism-mainnet'],\n ticker: NetworksTicker['optimism-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['optimism-mainnet'],\n },\n },\n [NetworkType['polygon-mainnet']]: {\n chainId: ChainId['polygon-mainnet'],\n ticker: NetworksTicker['polygon-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['polygon-mainnet'],\n },\n },\n [NetworkType['sei-mainnet']]: {\n chainId: ChainId['sei-mainnet'],\n ticker: NetworksTicker['sei-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['sei-mainnet'],\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n ticker: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n/**\n * When a user adds a custom network to MetaMask, we perform some basic\n * validations on the network. For instance, usually a network cannot share the\n * same chain as another. In some cases, however, we want to allow networks that\n * would normally be invalid. This mapping contains networks that should bypass\n * validation.\n */\nexport const NETWORKS_BYPASSING_VALIDATION = {\n // HyperEVM uses the same chain ID as Wanchain\n '0x3e7': {\n name: 'HyperEVM',\n symbol: 'HYPE',\n rpcUrl: 'https://rpc.hyperliquid.xyz',\n },\n};\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';\n\nexport const NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';\n\nexport const NFT_API_VERSION = '1';\n\nexport const NFT_API_TIMEOUT = 15000;\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 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 SnapDialogDefault = 'snap_dialog',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n TransactionBatch = 'transaction_batch',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\n/**\n * Mapping of chain IDs to their network names for ENS functionality.\n * Note: MegaETH-testnet is intentionally excluded from this mapping as it doesn't support ENS.\n */\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n string,\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-sepolia']]: BuiltInNetworkName.LineaSepolia,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECOND = 1000;\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECONDS = SECOND;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTE = SECONDS * 60;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTES = MINUTE;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOUR = MINUTES * 60;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOURS = HOUR;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAY = HOURS * 24;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAYS = DAY;\n\n/**\n * Special \"EVM-ish\" chains with no native tokens.\n * Created for Tempo, but can be extended to others.\n * - For hidding the native token from the token list and Send list.\n * - For excluding the native token from the total wallet value calculation.\n */\nexport const CHAIN_IDS_WITH_NO_NATIVE_TOKEN = [\n 'eip155:42431', // Tempo Testnet\n 'eip155:4217', // Tempo Mainnet\n] as const;\n"]}
|
|
1
|
+
{"version":3,"file":"constants.mjs","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,cAAc,EACd,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EACjB,oBAAgB;AAEjB,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;AACzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAC3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,mCAAmC,CAAC;A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C;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,CAAC;AAExB;;;;;GAKG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,cAAc,EAAE,gBAAgB;IAChC,aAAa,EAAE,gBAAgB;CACvB,CAAC","sourcesContent":["import {\n NetworkType,\n NetworksTicker,\n ChainId,\n BuiltInNetworkName,\n BlockExplorerUrl,\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 LINEA_SEPOLIA: 'LineaETH',\n MEGAETH_TESTNET: 'MegaETH',\n MEGAETH_TESTNET_V2: 'MegaETH',\n};\n\n/**\n * Map of all built-in custom networks to their RPC endpoints.\n */\nexport const BUILT_IN_CUSTOM_NETWORKS_RPC = {\n /**\n * @deprecated Please use `megaeth-testnet` instead.\n */\n MEGAETH_TESTNET: 'https://carrot.megaeth.com/rpc',\n /**\n * @deprecated Please use `megaeth-testnet-v2` instead.\n */\n 'megaeth-testnet': 'https://carrot.megaeth.com/rpc',\n 'megaeth-testnet-v2': 'https://carrot.megaeth.com/rpc',\n 'monad-testnet': 'https://testnet-rpc.monad.xyz',\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: BlockExplorerUrl.goerli,\n },\n },\n [NetworkType.sepolia]: {\n chainId: ChainId.sepolia,\n ticker: NetworksTicker.sepolia,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.sepolia,\n },\n },\n [NetworkType.mainnet]: {\n chainId: ChainId.mainnet,\n ticker: NetworksTicker.mainnet,\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl.mainnet,\n },\n },\n [NetworkType['linea-goerli']]: {\n chainId: ChainId['linea-goerli'],\n ticker: NetworksTicker['linea-goerli'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-goerli'],\n },\n },\n [NetworkType['linea-sepolia']]: {\n chainId: ChainId['linea-sepolia'],\n ticker: NetworksTicker['linea-sepolia'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-sepolia'],\n },\n },\n [NetworkType['linea-mainnet']]: {\n chainId: ChainId['linea-mainnet'],\n ticker: NetworksTicker['linea-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['linea-mainnet'],\n },\n },\n [NetworkType['megaeth-testnet']]: {\n chainId: ChainId['megaeth-testnet'],\n ticker: NetworksTicker['megaeth-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet'],\n },\n },\n [NetworkType['megaeth-testnet-v2']]: {\n chainId: ChainId['megaeth-testnet-v2'],\n ticker: NetworksTicker['megaeth-testnet-v2'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-testnet-v2'],\n },\n },\n [NetworkType['monad-testnet']]: {\n chainId: ChainId['monad-testnet'],\n ticker: NetworksTicker['monad-testnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-testnet'],\n },\n },\n [NetworkType['base-mainnet']]: {\n chainId: ChainId['base-mainnet'],\n ticker: NetworksTicker['base-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['base-mainnet'],\n },\n },\n [NetworkType['arbitrum-mainnet']]: {\n chainId: ChainId['arbitrum-mainnet'],\n ticker: NetworksTicker['arbitrum-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['arbitrum-mainnet'],\n },\n },\n [NetworkType['bsc-mainnet']]: {\n chainId: ChainId['bsc-mainnet'],\n ticker: NetworksTicker['bsc-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['bsc-mainnet'],\n },\n },\n [NetworkType['optimism-mainnet']]: {\n chainId: ChainId['optimism-mainnet'],\n ticker: NetworksTicker['optimism-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['optimism-mainnet'],\n },\n },\n [NetworkType['polygon-mainnet']]: {\n chainId: ChainId['polygon-mainnet'],\n ticker: NetworksTicker['polygon-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['polygon-mainnet'],\n },\n },\n [NetworkType['sei-mainnet']]: {\n chainId: ChainId['sei-mainnet'],\n ticker: NetworksTicker['sei-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['sei-mainnet'],\n },\n },\n [NetworkType['monad-mainnet']]: {\n chainId: ChainId['monad-mainnet'],\n ticker: NetworksTicker['monad-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['monad-mainnet'],\n },\n },\n [NetworkType['zksync-mainnet']]: {\n chainId: ChainId['zksync-mainnet'],\n ticker: NetworksTicker['zksync-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['zksync-mainnet'],\n },\n },\n [NetworkType['megaeth-mainnet']]: {\n chainId: ChainId['megaeth-mainnet'],\n ticker: NetworksTicker['megaeth-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['megaeth-mainnet'],\n },\n },\n [NetworkType['avalanche-mainnet']]: {\n chainId: ChainId['avalanche-mainnet'],\n ticker: NetworksTicker['avalanche-mainnet'],\n rpcPrefs: {\n blockExplorerUrl: BlockExplorerUrl['avalanche-mainnet'],\n },\n },\n [NetworkType.rpc]: {\n chainId: undefined,\n blockExplorerUrl: undefined,\n ticker: undefined,\n rpcPrefs: undefined,\n },\n} as const;\n\n/**\n * When a user adds a custom network to MetaMask, we perform some basic\n * validations on the network. For instance, usually a network cannot share the\n * same chain as another. In some cases, however, we want to allow networks that\n * would normally be invalid. This mapping contains networks that should bypass\n * validation.\n */\nexport const NETWORKS_BYPASSING_VALIDATION = {\n // HyperEVM uses the same chain ID as Wanchain\n '0x3e7': {\n name: 'HyperEVM',\n symbol: 'HYPE',\n rpcUrl: 'https://rpc.hyperliquid.xyz',\n },\n};\n\n// APIs\nexport const OPENSEA_PROXY_URL =\n 'https://proxy.api.cx.metamask.io/opensea/v1/api/v2';\n\nexport const NFT_API_BASE_URL = 'https://nft.api.cx.metamask.io';\n\nexport const NFT_API_VERSION = '1';\n\nexport const NFT_API_TIMEOUT = 15000;\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 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 SnapDialogDefault = 'snap_dialog',\n SwitchEthereumChain = 'wallet_switchEthereumChain',\n Transaction = 'transaction',\n TransactionBatch = 'transaction_batch',\n Unlock = 'unlock',\n WalletConnect = 'wallet_connect',\n WalletRequestPermissions = 'wallet_requestPermissions',\n WatchAsset = 'wallet_watchAsset',\n}\n\n/**\n * Mapping of chain IDs to their network names for ENS functionality.\n * Note: MegaETH-testnet is intentionally excluded from this mapping as it doesn't support ENS.\n */\nexport const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP: Record<\n string,\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-sepolia']]: BuiltInNetworkName.LineaSepolia,\n [ChainId['linea-mainnet']]: BuiltInNetworkName.LineaMainnet,\n [ChainId.aurora]: BuiltInNetworkName.Aurora,\n};\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECOND = 1000;\n\n/**\n * The number of milliseconds in a second.\n */\nexport const SECONDS = SECOND;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTE = SECONDS * 60;\n\n/**\n * The number of milliseconds in a minute.\n */\nexport const MINUTES = MINUTE;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOUR = MINUTES * 60;\n\n/**\n * The number of milliseconds in a hour.\n */\nexport const HOURS = HOUR;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAY = HOURS * 24;\n\n/**\n * The number of milliseconds in a day.\n */\nexport const DAYS = DAY;\n\n/**\n * Special \"EVM-ish\" chains with no native tokens.\n * Created for Tempo, but can be extended to others.\n * - For hidding the native token from the token list and Send list.\n * - For excluding the native token from the total wallet value calculation.\n */\nexport const CHAIN_IDS_WITH_NO_NATIVE_TOKEN = [\n 'eip155:42431', // Tempo Testnet\n 'eip155:4217', // Tempo Mainnet\n] as const;\n"]}
|
|
@@ -166,7 +166,7 @@ function createServicePolicy(options = {}) {
|
|
|
166
166
|
if (circuitBreakerPolicy.state === cockatiel_1.CircuitState.Closed) {
|
|
167
167
|
if (duration > degradedThreshold) {
|
|
168
168
|
availabilityStatus = AVAILABILITY_STATUSES.Degraded;
|
|
169
|
-
onDegradedEventEmitter.emit();
|
|
169
|
+
onDegradedEventEmitter.emit({ duration });
|
|
170
170
|
}
|
|
171
171
|
else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {
|
|
172
172
|
availabilityStatus = AVAILABILITY_STATUSES.Available;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-policy.cjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":";;;AAAA,yCAYmB;AAYjB,mGAvBA,8BAAkB,OAuBA;AAElB,6FAxBA,wBAAY,OAwBA;AADZ,sGAtBgB,wBAAqB,OAsBhB;AAGrB,mGAvBA,8BAAkB,OAuBA;AADlB,gGArBA,2BAAe,OAqBA;AAEf,0FArBA,qBAAS,OAqBA;AACT,2FArBA,sBAAU,OAqBA;AAmHZ;;;;GAIG;AACH,MAAM,qBAAqB,GAAG;IAC5B,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;CACV,CAAC;AAUX;;;GAGG;AACU,QAAA,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,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ACzC,OAAO,oBAAoB,CAAC,KAAK,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,4EAA4E;QAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACnD,8BAA8B;QAC9B,OAAO,EAAE,CAAC;QAEV,2CAA2C;QAC3C,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAE7B,2EAA2E;QAC3E,2DAA2D;QAC3D,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,oBAAoB;QACpB,eAAe;QACf,+BAA+B;QAC/B,KAAK;QACL,WAAW;QACX,OAAO;QACP,UAAU;QACV,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC;AAtID,kDAsIC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n ConstantBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n FailureReason,\n IBackoffFactory,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport {\n BrokenCircuitError,\n CockatielEventEmitter,\n CircuitState,\n ConstantBackoff,\n ExponentialBackoff,\n handleAll,\n handleWhen,\n};\n\nexport type { CockatielEvent, FailureReason as CockatielFailureReason };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The backoff strategy to use. Mainly useful for testing so that a constant\n * backoff can be used when mocking timers. Defaults to an instance of\n * ExponentialBackoff.\n */\n backoff?: IBackoffFactory<unknown>;\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The amount of time to pause requests to the service if the number of\n * maximum consecutive failures is reached.\n */\n circuitBreakDuration: number;\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState: () => CircuitState;\n /**\n * If the circuit is open and ongoing requests are paused, returns the number\n * of milliseconds before the requests will be attempted again. If the circuit\n * is not open, returns null.\n */\n getRemainingCircuitOpenDuration: () => number | null;\n /**\n * Resets the internal circuit breaker policy (if it is open, it will now be\n * closed).\n */\n reset: () => void;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<FailureReason<unknown> | void>;\n /**\n * A function which is called when the service succeeds for the first time,\n * or when the service fails enough times to cause the circuit to break and\n * then recovers.\n */\n onAvailable: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * Parts of the circuit breaker's internal and external state as necessary in\n * order to compute the time remaining before the circuit will reopen.\n */\ntype InternalCircuitState =\n | {\n state: CircuitState.Open;\n openedAt: number;\n }\n | { state: Exclude<CircuitState, CircuitState.Open> };\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\nconst AVAILABILITY_STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unavailable: 'unavailable',\n Unknown: 'unknown',\n} as const;\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\ntype AvailabilityStatus =\n (typeof AVAILABILITY_STATUSES)[keyof typeof AVAILABILITY_STATUSES];\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\nconst isServiceFailure = (error: unknown): boolean => {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'httpStatus' in error &&\n typeof error.httpStatus === 'number'\n ) {\n return error.httpStatus >= 500;\n }\n\n // If the error is not an object, or doesn't have a numeric code property,\n // consider it a service failure (e.g., network errors, timeouts, etc.)\n return true;\n};\n\n/**\n * The circuit breaker policy inside of the Cockatiel library exposes some of\n * its state, but not all of it. Notably, the time that the circuit opened is\n * not publicly accessible. So we have to record this ourselves.\n *\n * This function therefore allows us to obtain the circuit breaker state that we\n * wish we could access.\n *\n * @param state - The public state of a circuit breaker policy.\n * @returns if the circuit is open, the state of the circuit breaker policy plus\n * the time that it opened, otherwise just the circuit state.\n */\nfunction getInternalCircuitState(state: CircuitState): InternalCircuitState {\n if (state === CircuitState.Open) {\n return { state, openedAt: Date.now() };\n }\n return { state };\n}\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function. See\n * {@link CreateServicePolicyOptions}.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy(\n options: CreateServicePolicyOptions = {},\n): ServicePolicy {\n const {\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n backoff = new ExponentialBackoff(),\n } = options;\n\n let availabilityStatus: AvailabilityStatus = AVAILABILITY_STATUSES.Unknown;\n\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff,\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const consecutiveBreaker = new ConsecutiveBreaker(maxConsecutiveFailures);\n const circuitBreakerPolicy = circuitBreaker(handleWhen(isServiceFailure), {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: consecutiveBreaker,\n });\n\n let internalCircuitState: InternalCircuitState = getInternalCircuitState(\n circuitBreakerPolicy.state,\n );\n circuitBreakerPolicy.onStateChange((state) => {\n internalCircuitState = getInternalCircuitState(state);\n });\n\n circuitBreakerPolicy.onBreak(() => {\n availabilityStatus = AVAILABILITY_STATUSES.Unavailable;\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter =\n new CockatielEventEmitter<FailureReason<unknown> | void>();\n const onDegraded = onDegradedEventEmitter.addListener;\n\n const onAvailableEventEmitter = new CockatielEventEmitter<void>();\n const onAvailable = onAvailableEventEmitter.addListener;\n\n retryPolicy.onGiveUp((data) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit(data);\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n if (duration > degradedThreshold) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit();\n } else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {\n availabilityStatus = AVAILABILITY_STATUSES.Available;\n onAvailableEventEmitter.emit();\n }\n }\n });\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n //\n // Calling:\n //\n // policy.execute(() => {\n // // do what the service does\n // })\n //\n // is equivalent to:\n //\n // retryPolicy.execute(() => {\n // circuitBreakerPolicy.execute(() => {\n // // do what the service does\n // });\n // });\n //\n // So if the retry policy succeeds or fails, it is because the circuit breaker\n // policy succeeded or failed. And if there are any event listeners registered\n // on the retry policy, by the time they are called, the state of the circuit\n // breaker will have already changed.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n const getRemainingCircuitOpenDuration = (): number | null => {\n if (internalCircuitState.state === CircuitState.Open) {\n return internalCircuitState.openedAt + circuitBreakDuration - Date.now();\n }\n return null;\n };\n\n const getCircuitState = (): CircuitState => {\n return circuitBreakerPolicy.state;\n };\n\n const reset = (): void => {\n // Set the state of the policy to \"isolated\" regardless of its current state\n const { dispose } = circuitBreakerPolicy.isolate();\n // Reset the state to \"closed\"\n dispose();\n\n // Reset the counter on the breaker as well\n consecutiveBreaker.success();\n\n // Re-initialize the availability status so that if the service is executed\n // successfully, onAvailable listeners will be called again\n availabilityStatus = AVAILABILITY_STATUSES.Unknown;\n };\n\n return {\n ...policy,\n circuitBreakerPolicy,\n circuitBreakDuration,\n getCircuitState,\n getRemainingCircuitOpenDuration,\n reset,\n retryPolicy,\n onBreak,\n onDegraded,\n onAvailable,\n onRetry,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-service-policy.cjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":";;;AAAA,yCAYmB;AAYjB,mGAvBA,8BAAkB,OAuBA;AAElB,6FAxBA,wBAAY,OAwBA;AADZ,sGAtBgB,wBAAqB,OAsBhB;AAGrB,mGAvBA,8BAAkB,OAuBA;AADlB,gGArBA,2BAAe,OAqBA;AAE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,WAAW,EAAE,oBAAoB,CAAC,CAAC;IAEvD,MAAM,+BAA+B,GAAG,GAAkB,EAAE;QAC1D,IAAI,oBAAoB,CAAC,KAAK,KAAK,wBAAY,CAAC,IAAI,EAAE,CAAC;YACrD,OAAO,oBAAoB,CAAC,QAAQ,GAAG,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,GAAiB,EAAE;QACzC,OAAO,oBAAoB,CAAC,KAAK,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,4EAA4E;QAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACnD,8BAA8B;QAC9B,OAAO,EAAE,CAAC;QAEV,2CAA2C;QAC3C,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAE7B,2EAA2E;QAC3E,2DAA2D;QAC3D,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,oBAAoB;QACpB,eAAe;QACf,+BAA+B;QAC/B,KAAK;QACL,WAAW;QACX,OAAO;QACP,UAAU;QACV,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC;AAvID,kDAuIC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n ConstantBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n FailureReason,\n IBackoffFactory,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport {\n BrokenCircuitError,\n CockatielEventEmitter,\n CircuitState,\n ConstantBackoff,\n ExponentialBackoff,\n handleAll,\n handleWhen,\n};\n\nexport type { CockatielEvent, FailureReason as CockatielFailureReason };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The backoff strategy to use. Mainly useful for testing so that a constant\n * backoff can be used when mocking timers. Defaults to an instance of\n * ExponentialBackoff.\n */\n backoff?: IBackoffFactory<unknown>;\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The amount of time to pause requests to the service if the number of\n * maximum consecutive failures is reached.\n */\n circuitBreakDuration: number;\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState: () => CircuitState;\n /**\n * If the circuit is open and ongoing requests are paused, returns the number\n * of milliseconds before the requests will be attempted again. If the circuit\n * is not open, returns null.\n */\n getRemainingCircuitOpenDuration: () => number | null;\n /**\n * Resets the internal circuit breaker policy (if it is open, it will now be\n * closed).\n */\n reset: () => void;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<FailureReason<unknown> | { duration: number }>;\n /**\n * A function which is called when the service succeeds for the first time,\n * or when the service fails enough times to cause the circuit to break and\n * then recovers.\n */\n onAvailable: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * Parts of the circuit breaker's internal and external state as necessary in\n * order to compute the time remaining before the circuit will reopen.\n */\ntype InternalCircuitState =\n | {\n state: CircuitState.Open;\n openedAt: number;\n }\n | { state: Exclude<CircuitState, CircuitState.Open> };\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\nconst AVAILABILITY_STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unavailable: 'unavailable',\n Unknown: 'unknown',\n} as const;\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\ntype AvailabilityStatus =\n (typeof AVAILABILITY_STATUSES)[keyof typeof AVAILABILITY_STATUSES];\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\nconst isServiceFailure = (error: unknown): boolean => {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'httpStatus' in error &&\n typeof error.httpStatus === 'number'\n ) {\n return error.httpStatus >= 500;\n }\n\n // If the error is not an object, or doesn't have a numeric code property,\n // consider it a service failure (e.g., network errors, timeouts, etc.)\n return true;\n};\n\n/**\n * The circuit breaker policy inside of the Cockatiel library exposes some of\n * its state, but not all of it. Notably, the time that the circuit opened is\n * not publicly accessible. So we have to record this ourselves.\n *\n * This function therefore allows us to obtain the circuit breaker state that we\n * wish we could access.\n *\n * @param state - The public state of a circuit breaker policy.\n * @returns if the circuit is open, the state of the circuit breaker policy plus\n * the time that it opened, otherwise just the circuit state.\n */\nfunction getInternalCircuitState(state: CircuitState): InternalCircuitState {\n if (state === CircuitState.Open) {\n return { state, openedAt: Date.now() };\n }\n return { state };\n}\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function. See\n * {@link CreateServicePolicyOptions}.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy(\n options: CreateServicePolicyOptions = {},\n): ServicePolicy {\n const {\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n backoff = new ExponentialBackoff(),\n } = options;\n\n let availabilityStatus: AvailabilityStatus = AVAILABILITY_STATUSES.Unknown;\n\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff,\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const consecutiveBreaker = new ConsecutiveBreaker(maxConsecutiveFailures);\n const circuitBreakerPolicy = circuitBreaker(handleWhen(isServiceFailure), {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: consecutiveBreaker,\n });\n\n let internalCircuitState: InternalCircuitState = getInternalCircuitState(\n circuitBreakerPolicy.state,\n );\n circuitBreakerPolicy.onStateChange((state) => {\n internalCircuitState = getInternalCircuitState(state);\n });\n\n circuitBreakerPolicy.onBreak(() => {\n availabilityStatus = AVAILABILITY_STATUSES.Unavailable;\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter = new CockatielEventEmitter<\n FailureReason<unknown> | { duration: number }\n >();\n const onDegraded = onDegradedEventEmitter.addListener;\n\n const onAvailableEventEmitter = new CockatielEventEmitter<void>();\n const onAvailable = onAvailableEventEmitter.addListener;\n\n retryPolicy.onGiveUp((data) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit(data);\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n if (duration > degradedThreshold) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit({ duration });\n } else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {\n availabilityStatus = AVAILABILITY_STATUSES.Available;\n onAvailableEventEmitter.emit();\n }\n }\n });\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n //\n // Calling:\n //\n // policy.execute(() => {\n // // do what the service does\n // })\n //\n // is equivalent to:\n //\n // retryPolicy.execute(() => {\n // circuitBreakerPolicy.execute(() => {\n // // do what the service does\n // });\n // });\n //\n // So if the retry policy succeeds or fails, it is because the circuit breaker\n // policy succeeded or failed. And if there are any event listeners registered\n // on the retry policy, by the time they are called, the state of the circuit\n // breaker will have already changed.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n const getRemainingCircuitOpenDuration = (): number | null => {\n if (internalCircuitState.state === CircuitState.Open) {\n return internalCircuitState.openedAt + circuitBreakDuration - Date.now();\n }\n return null;\n };\n\n const getCircuitState = (): CircuitState => {\n return circuitBreakerPolicy.state;\n };\n\n const reset = (): void => {\n // Set the state of the policy to \"isolated\" regardless of its current state\n const { dispose } = circuitBreakerPolicy.isolate();\n // Reset the state to \"closed\"\n dispose();\n\n // Reset the counter on the breaker as well\n consecutiveBreaker.success();\n\n // Re-initialize the availability status so that if the service is executed\n // successfully, onAvailable listeners will be called again\n availabilityStatus = AVAILABILITY_STATUSES.Unknown;\n };\n\n return {\n ...policy,\n circuitBreakerPolicy,\n circuitBreakDuration,\n getCircuitState,\n getRemainingCircuitOpenDuration,\n reset,\n retryPolicy,\n onBreak,\n onDegraded,\n onAvailable,\n onRetry,\n };\n}\n"]}
|
|
@@ -85,7 +85,9 @@ export type ServicePolicy = IPolicy & {
|
|
|
85
85
|
* never succeeds before the retry policy gives up and before the maximum
|
|
86
86
|
* number of consecutive failures has been reached.
|
|
87
87
|
*/
|
|
88
|
-
onDegraded: CockatielEvent<FailureReason<unknown> |
|
|
88
|
+
onDegraded: CockatielEvent<FailureReason<unknown> | {
|
|
89
|
+
duration: number;
|
|
90
|
+
}>;
|
|
89
91
|
/**
|
|
90
92
|
* A function which is called when the service succeeds for the first time,
|
|
91
93
|
* or when the service fails enough times to cause the circuit to break and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-policy.d.cts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EAErC,kBAAkB,EAClB,eAAe,EAEf,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,aAAa,EACb,eAAe,EACf,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACpC;;;OAGG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC;;;;OAIG;IACH,+BAA+B,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACrD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,UAAU,EAAE,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"create-service-policy.d.cts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EAErC,kBAAkB,EAClB,eAAe,EAEf,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,aAAa,EACb,eAAe,EACf,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC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;;;;;;;;;;;;GAiDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAqIf"}
|
|
@@ -85,7 +85,9 @@ export type ServicePolicy = IPolicy & {
|
|
|
85
85
|
* never succeeds before the retry policy gives up and before the maximum
|
|
86
86
|
* number of consecutive failures has been reached.
|
|
87
87
|
*/
|
|
88
|
-
onDegraded: CockatielEvent<FailureReason<unknown> |
|
|
88
|
+
onDegraded: CockatielEvent<FailureReason<unknown> | {
|
|
89
|
+
duration: number;
|
|
90
|
+
}>;
|
|
89
91
|
/**
|
|
90
92
|
* A function which is called when the service succeeds for the first time,
|
|
91
93
|
* or when the service fails enough times to cause the circuit to break and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-policy.d.mts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EAErC,kBAAkB,EAClB,eAAe,EAEf,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,aAAa,EACb,eAAe,EACf,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACnC;;;OAGG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG;IACpC;;;OAGG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAC3C;;;OAGG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;OAEG;IACH,eAAe,EAAE,MAAM,YAAY,CAAC;IACpC;;;;OAIG;IACH,+BAA+B,EAAE,MAAM,MAAM,GAAG,IAAI,CAAC;IACrD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;OAGG;IACH,OAAO,EAAE,oBAAoB,CAAC,SAAS,CAAC,CAAC;IACzC;;;;;;OAMG;IACH,UAAU,EAAE,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"create-service-policy.d.mts","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EAErC,kBAAkB,EAClB,eAAe,EAEf,SAAS,EACT,UAAU,EAGX,kBAAkB;AACnB,OAAO,KAAK,EACV,oBAAoB,EACpB,KAAK,IAAI,cAAc,EACvB,aAAa,EACb,eAAe,EACf,OAAO,EACP,MAAM,EACN,WAAW,EACZ,kBAAkB;AAEnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,GACX,CAAC;AAEF,YAAY,EAAE,cAAc,EAAE,aAAa,IAAI,sBAAsB,EAAE,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO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;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,GAAE,0BAA+B,GACvC,aAAa,CAqIf"}
|
|
@@ -157,7 +157,7 @@ export function createServicePolicy(options = {}) {
|
|
|
157
157
|
if (circuitBreakerPolicy.state === CircuitState.Closed) {
|
|
158
158
|
if (duration > degradedThreshold) {
|
|
159
159
|
availabilityStatus = AVAILABILITY_STATUSES.Degraded;
|
|
160
|
-
onDegradedEventEmitter.emit();
|
|
160
|
+
onDegradedEventEmitter.emit({ duration });
|
|
161
161
|
}
|
|
162
162
|
else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {
|
|
163
163
|
availabilityStatus = AVAILABILITY_STATUSES.Available;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-service-policy.mjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EACrC,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACL,kBAAkB;AAWnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,EACX,CAAC;AAkHF;;;;GAIG;AACH,MAAM,qBAAqB,GAAG;IAC5B,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;CACV,CAAC;AAUX;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC,GAAG,mBAAmB,CAAC,GAAG,CAAC,CAAC;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,EAAE,GAAG,EAAE,GAAG,I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E,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACnD,8BAA8B;QAC9B,OAAO,EAAE,CAAC;QAEV,2CAA2C;QAC3C,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAE7B,2EAA2E;QAC3E,2DAA2D;QAC3D,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,oBAAoB;QACpB,eAAe;QACf,+BAA+B;QAC/B,KAAK;QACL,WAAW;QACX,OAAO;QACP,UAAU;QACV,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n ConstantBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n FailureReason,\n IBackoffFactory,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport {\n BrokenCircuitError,\n CockatielEventEmitter,\n CircuitState,\n ConstantBackoff,\n ExponentialBackoff,\n handleAll,\n handleWhen,\n};\n\nexport type { CockatielEvent, FailureReason as CockatielFailureReason };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The backoff strategy to use. Mainly useful for testing so that a constant\n * backoff can be used when mocking timers. Defaults to an instance of\n * ExponentialBackoff.\n */\n backoff?: IBackoffFactory<unknown>;\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The amount of time to pause requests to the service if the number of\n * maximum consecutive failures is reached.\n */\n circuitBreakDuration: number;\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState: () => CircuitState;\n /**\n * If the circuit is open and ongoing requests are paused, returns the number\n * of milliseconds before the requests will be attempted again. If the circuit\n * is not open, returns null.\n */\n getRemainingCircuitOpenDuration: () => number | null;\n /**\n * Resets the internal circuit breaker policy (if it is open, it will now be\n * closed).\n */\n reset: () => void;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<FailureReason<unknown> | void>;\n /**\n * A function which is called when the service succeeds for the first time,\n * or when the service fails enough times to cause the circuit to break and\n * then recovers.\n */\n onAvailable: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * Parts of the circuit breaker's internal and external state as necessary in\n * order to compute the time remaining before the circuit will reopen.\n */\ntype InternalCircuitState =\n | {\n state: CircuitState.Open;\n openedAt: number;\n }\n | { state: Exclude<CircuitState, CircuitState.Open> };\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\nconst AVAILABILITY_STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unavailable: 'unavailable',\n Unknown: 'unknown',\n} as const;\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\ntype AvailabilityStatus =\n (typeof AVAILABILITY_STATUSES)[keyof typeof AVAILABILITY_STATUSES];\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\nconst isServiceFailure = (error: unknown): boolean => {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'httpStatus' in error &&\n typeof error.httpStatus === 'number'\n ) {\n return error.httpStatus >= 500;\n }\n\n // If the error is not an object, or doesn't have a numeric code property,\n // consider it a service failure (e.g., network errors, timeouts, etc.)\n return true;\n};\n\n/**\n * The circuit breaker policy inside of the Cockatiel library exposes some of\n * its state, but not all of it. Notably, the time that the circuit opened is\n * not publicly accessible. So we have to record this ourselves.\n *\n * This function therefore allows us to obtain the circuit breaker state that we\n * wish we could access.\n *\n * @param state - The public state of a circuit breaker policy.\n * @returns if the circuit is open, the state of the circuit breaker policy plus\n * the time that it opened, otherwise just the circuit state.\n */\nfunction getInternalCircuitState(state: CircuitState): InternalCircuitState {\n if (state === CircuitState.Open) {\n return { state, openedAt: Date.now() };\n }\n return { state };\n}\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function. See\n * {@link CreateServicePolicyOptions}.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy(\n options: CreateServicePolicyOptions = {},\n): ServicePolicy {\n const {\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n backoff = new ExponentialBackoff(),\n } = options;\n\n let availabilityStatus: AvailabilityStatus = AVAILABILITY_STATUSES.Unknown;\n\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff,\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const consecutiveBreaker = new ConsecutiveBreaker(maxConsecutiveFailures);\n const circuitBreakerPolicy = circuitBreaker(handleWhen(isServiceFailure), {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: consecutiveBreaker,\n });\n\n let internalCircuitState: InternalCircuitState = getInternalCircuitState(\n circuitBreakerPolicy.state,\n );\n circuitBreakerPolicy.onStateChange((state) => {\n internalCircuitState = getInternalCircuitState(state);\n });\n\n circuitBreakerPolicy.onBreak(() => {\n availabilityStatus = AVAILABILITY_STATUSES.Unavailable;\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter =\n new CockatielEventEmitter<FailureReason<unknown> | void>();\n const onDegraded = onDegradedEventEmitter.addListener;\n\n const onAvailableEventEmitter = new CockatielEventEmitter<void>();\n const onAvailable = onAvailableEventEmitter.addListener;\n\n retryPolicy.onGiveUp((data) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit(data);\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n if (duration > degradedThreshold) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit();\n } else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {\n availabilityStatus = AVAILABILITY_STATUSES.Available;\n onAvailableEventEmitter.emit();\n }\n }\n });\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n //\n // Calling:\n //\n // policy.execute(() => {\n // // do what the service does\n // })\n //\n // is equivalent to:\n //\n // retryPolicy.execute(() => {\n // circuitBreakerPolicy.execute(() => {\n // // do what the service does\n // });\n // });\n //\n // So if the retry policy succeeds or fails, it is because the circuit breaker\n // policy succeeded or failed. And if there are any event listeners registered\n // on the retry policy, by the time they are called, the state of the circuit\n // breaker will have already changed.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n const getRemainingCircuitOpenDuration = (): number | null => {\n if (internalCircuitState.state === CircuitState.Open) {\n return internalCircuitState.openedAt + circuitBreakDuration - Date.now();\n }\n return null;\n };\n\n const getCircuitState = (): CircuitState => {\n return circuitBreakerPolicy.state;\n };\n\n const reset = (): void => {\n // Set the state of the policy to \"isolated\" regardless of its current state\n const { dispose } = circuitBreakerPolicy.isolate();\n // Reset the state to \"closed\"\n dispose();\n\n // Reset the counter on the breaker as well\n consecutiveBreaker.success();\n\n // Re-initialize the availability status so that if the service is executed\n // successfully, onAvailable listeners will be called again\n availabilityStatus = AVAILABILITY_STATUSES.Unknown;\n };\n\n return {\n ...policy,\n circuitBreakerPolicy,\n circuitBreakDuration,\n getCircuitState,\n getRemainingCircuitOpenDuration,\n reset,\n retryPolicy,\n onBreak,\n onDegraded,\n onAvailable,\n onRetry,\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"create-service-policy.mjs","sourceRoot":"","sources":["../src/create-service-policy.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,YAAY,IAAI,qBAAqB,EACrC,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,SAAS,EACT,UAAU,EACV,KAAK,EACL,IAAI,EACL,kBAAkB;AAWnB,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,SAAS,EACT,UAAU,EACX,CAAC;AAkHF;;;;GAIG;AACH,MAAM,qBAAqB,G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AAE;QAC1D,IAAI,oBAAoB,CAAC,KAAK,KAAK,YAAY,CAAC,IAAI,EAAE,CAAC;YACrD,OAAO,oBAAoB,CAAC,QAAQ,GAAG,oBAAoB,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC3E,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,MAAM,eAAe,GAAG,GAAiB,EAAE;QACzC,OAAO,oBAAoB,CAAC,KAAK,CAAC;IACpC,CAAC,CAAC;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,4EAA4E;QAC5E,MAAM,EAAE,OAAO,EAAE,GAAG,oBAAoB,CAAC,OAAO,EAAE,CAAC;QACnD,8BAA8B;QAC9B,OAAO,EAAE,CAAC;QAEV,2CAA2C;QAC3C,kBAAkB,CAAC,OAAO,EAAE,CAAC;QAE7B,2EAA2E;QAC3E,2DAA2D;QAC3D,kBAAkB,GAAG,qBAAqB,CAAC,OAAO,CAAC;IACrD,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,MAAM;QACT,oBAAoB;QACpB,oBAAoB;QACpB,eAAe;QACf,+BAA+B;QAC/B,KAAK;QACL,WAAW;QACX,OAAO;QACP,UAAU;QACV,WAAW;QACX,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n BrokenCircuitError,\n CircuitState,\n EventEmitter as CockatielEventEmitter,\n ConsecutiveBreaker,\n ExponentialBackoff,\n ConstantBackoff,\n circuitBreaker,\n handleAll,\n handleWhen,\n retry,\n wrap,\n} from 'cockatiel';\nimport type {\n CircuitBreakerPolicy,\n Event as CockatielEvent,\n FailureReason,\n IBackoffFactory,\n IPolicy,\n Policy,\n RetryPolicy,\n} from 'cockatiel';\n\nexport {\n BrokenCircuitError,\n CockatielEventEmitter,\n CircuitState,\n ConstantBackoff,\n ExponentialBackoff,\n handleAll,\n handleWhen,\n};\n\nexport type { CockatielEvent, FailureReason as CockatielFailureReason };\n\n/**\n * The options for `createServicePolicy`.\n */\nexport type CreateServicePolicyOptions = {\n /**\n * The backoff strategy to use. Mainly useful for testing so that a constant\n * backoff can be used when mocking timers. Defaults to an instance of\n * ExponentialBackoff.\n */\n backoff?: IBackoffFactory<unknown>;\n /**\n * The length of time (in milliseconds) to pause retries of the action after\n * the number of failures reaches `maxConsecutiveFailures`.\n */\n circuitBreakDuration?: number;\n /**\n * The length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\n degradedThreshold?: number;\n /**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries.\n */\n maxConsecutiveFailures?: number;\n /**\n * The maximum number of times that a failing service should be re-invoked\n * before giving up.\n */\n maxRetries?: number;\n /**\n * The policy used to control when the service should be retried based on\n * either the result of the service or an error that it throws. For instance,\n * you could use this to retry only certain errors. See `handleWhen` and\n * friends from Cockatiel for more.\n */\n retryFilterPolicy?: Policy;\n};\n\n/**\n * The service policy object.\n */\nexport type ServicePolicy = IPolicy & {\n /**\n * The Cockatiel circuit breaker policy that the service policy uses\n * internally.\n */\n circuitBreakerPolicy: CircuitBreakerPolicy;\n /**\n * The amount of time to pause requests to the service if the number of\n * maximum consecutive failures is reached.\n */\n circuitBreakDuration: number;\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState: () => CircuitState;\n /**\n * If the circuit is open and ongoing requests are paused, returns the number\n * of milliseconds before the requests will be attempted again. If the circuit\n * is not open, returns null.\n */\n getRemainingCircuitOpenDuration: () => number | null;\n /**\n * Resets the internal circuit breaker policy (if it is open, it will now be\n * closed).\n */\n reset: () => void;\n /**\n * The Cockatiel retry policy that the service policy uses internally.\n */\n retryPolicy: RetryPolicy;\n /**\n * A function which is called when the number of times that the service fails\n * in a row meets the set maximum number of consecutive failures.\n */\n onBreak: CircuitBreakerPolicy['onBreak'];\n /**\n * A function which is called in two circumstances: 1) when the service\n * succeeds before the maximum number of consecutive failures is reached, but\n * takes more time than the `degradedThreshold` to run, or 2) if the service\n * never succeeds before the retry policy gives up and before the maximum\n * number of consecutive failures has been reached.\n */\n onDegraded: CockatielEvent<FailureReason<unknown> | { duration: number }>;\n /**\n * A function which is called when the service succeeds for the first time,\n * or when the service fails enough times to cause the circuit to break and\n * then recovers.\n */\n onAvailable: CockatielEvent<void>;\n /**\n * A function which will be called by the retry policy each time the service\n * fails and the policy kicks off a timer to re-run the service. This is\n * primarily useful in tests where we are mocking timers.\n */\n onRetry: RetryPolicy['onRetry'];\n};\n\n/**\n * Parts of the circuit breaker's internal and external state as necessary in\n * order to compute the time remaining before the circuit will reopen.\n */\ntype InternalCircuitState =\n | {\n state: CircuitState.Open;\n openedAt: number;\n }\n | { state: Exclude<CircuitState, CircuitState.Open> };\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\nconst AVAILABILITY_STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unavailable: 'unavailable',\n Unknown: 'unknown',\n} as const;\n\n/**\n * Availability statuses that the service can be in.\n *\n * Used to keep track of whether the `onAvailable` event should be fired.\n */\ntype AvailabilityStatus =\n (typeof AVAILABILITY_STATUSES)[keyof typeof AVAILABILITY_STATUSES];\n\n/**\n * The maximum number of times that a failing service should be re-run before\n * giving up.\n */\nexport const DEFAULT_MAX_RETRIES = 3;\n\n/**\n * The maximum number of times that the service is allowed to fail before\n * pausing further retries. This is set to a value such that if given a\n * service that continually fails, the policy needs to be executed 3 times\n * before further retries are paused.\n */\nexport const DEFAULT_MAX_CONSECUTIVE_FAILURES = (1 + DEFAULT_MAX_RETRIES) * 3;\n\n/**\n * The default length of time (in milliseconds) to temporarily pause retries of\n * the service after enough consecutive failures.\n */\nexport const DEFAULT_CIRCUIT_BREAK_DURATION = 30 * 60 * 1000;\n\n/**\n * The default length of time (in milliseconds) that governs when the service is\n * regarded as degraded (affecting when `onDegraded` is called).\n */\nexport const DEFAULT_DEGRADED_THRESHOLD = 5_000;\n\nconst isServiceFailure = (error: unknown): boolean => {\n if (\n typeof error === 'object' &&\n error !== null &&\n 'httpStatus' in error &&\n typeof error.httpStatus === 'number'\n ) {\n return error.httpStatus >= 500;\n }\n\n // If the error is not an object, or doesn't have a numeric code property,\n // consider it a service failure (e.g., network errors, timeouts, etc.)\n return true;\n};\n\n/**\n * The circuit breaker policy inside of the Cockatiel library exposes some of\n * its state, but not all of it. Notably, the time that the circuit opened is\n * not publicly accessible. So we have to record this ourselves.\n *\n * This function therefore allows us to obtain the circuit breaker state that we\n * wish we could access.\n *\n * @param state - The public state of a circuit breaker policy.\n * @returns if the circuit is open, the state of the circuit breaker policy plus\n * the time that it opened, otherwise just the circuit state.\n */\nfunction getInternalCircuitState(state: CircuitState): InternalCircuitState {\n if (state === CircuitState.Open) {\n return { state, openedAt: Date.now() };\n }\n return { state };\n}\n\n/**\n * Constructs an object exposing an `execute` method which, given a function —\n * hereafter called the \"service\" — will retry that service with ever increasing\n * delays until it succeeds. If the policy detects too many consecutive\n * failures, it will block further retries until a designated time period has\n * passed; this particular behavior is primarily designed for services that wrap\n * API calls so as not to make needless HTTP requests when the API is down and\n * to be able to recover when the API comes back up. In addition, hooks allow\n * for responding to certain events, one of which can be used to detect when an\n * HTTP request is performing slowly.\n *\n * Internally, this function makes use of the retry and circuit breaker policies\n * from the [Cockatiel](https://www.npmjs.com/package/cockatiel) library; see\n * there for more.\n *\n * @param options - The options to this function. See\n * {@link CreateServicePolicyOptions}.\n * @returns The service policy.\n * @example\n * This function is designed to be used in the context of a service class like\n * this:\n * ``` ts\n * class Service {\n * constructor() {\n * this.#policy = createServicePolicy({\n * maxRetries: 3,\n * retryFilterPolicy: handleWhen((error) => {\n * return error.message.includes('oops');\n * }),\n * maxConsecutiveFailures: 3,\n * circuitBreakDuration: 5000,\n * degradedThreshold: 2000,\n * onBreak: () => {\n * console.log('Circuit broke');\n * },\n * onDegraded: () => {\n * console.log('Service is degraded');\n * },\n * });\n * }\n *\n * async fetch() {\n * return await this.#policy.execute(async () => {\n * const response = await fetch('https://some/url');\n * return await response.json();\n * });\n * }\n * }\n * ```\n */\nexport function createServicePolicy(\n options: CreateServicePolicyOptions = {},\n): ServicePolicy {\n const {\n maxRetries = DEFAULT_MAX_RETRIES,\n retryFilterPolicy = handleAll,\n maxConsecutiveFailures = DEFAULT_MAX_CONSECUTIVE_FAILURES,\n circuitBreakDuration = DEFAULT_CIRCUIT_BREAK_DURATION,\n degradedThreshold = DEFAULT_DEGRADED_THRESHOLD,\n backoff = new ExponentialBackoff(),\n } = options;\n\n let availabilityStatus: AvailabilityStatus = AVAILABILITY_STATUSES.Unknown;\n\n const retryPolicy = retry(retryFilterPolicy, {\n // Note that although the option here is called \"max attempts\", it's really\n // maximum number of *retries* (attempts past the initial attempt).\n maxAttempts: maxRetries,\n // Retries of the service will be executed following ever increasing delays,\n // determined by a backoff formula.\n backoff,\n });\n const onRetry = retryPolicy.onRetry.bind(retryPolicy);\n\n const consecutiveBreaker = new ConsecutiveBreaker(maxConsecutiveFailures);\n const circuitBreakerPolicy = circuitBreaker(handleWhen(isServiceFailure), {\n // While the circuit is open, any additional invocations of the service\n // passed to the policy (either via automatic retries or by manually\n // executing the policy again) will result in a BrokenCircuitError. This\n // will remain the case until `circuitBreakDuration` passes, after which the\n // service will be allowed to run again. If the service succeeds, the\n // circuit will close, otherwise it will remain open.\n halfOpenAfter: circuitBreakDuration,\n breaker: consecutiveBreaker,\n });\n\n let internalCircuitState: InternalCircuitState = getInternalCircuitState(\n circuitBreakerPolicy.state,\n );\n circuitBreakerPolicy.onStateChange((state) => {\n internalCircuitState = getInternalCircuitState(state);\n });\n\n circuitBreakerPolicy.onBreak(() => {\n availabilityStatus = AVAILABILITY_STATUSES.Unavailable;\n });\n const onBreak = circuitBreakerPolicy.onBreak.bind(circuitBreakerPolicy);\n\n const onDegradedEventEmitter = new CockatielEventEmitter<\n FailureReason<unknown> | { duration: number }\n >();\n const onDegraded = onDegradedEventEmitter.addListener;\n\n const onAvailableEventEmitter = new CockatielEventEmitter<void>();\n const onAvailable = onAvailableEventEmitter.addListener;\n\n retryPolicy.onGiveUp((data) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit(data);\n }\n });\n retryPolicy.onSuccess(({ duration }) => {\n if (circuitBreakerPolicy.state === CircuitState.Closed) {\n if (duration > degradedThreshold) {\n availabilityStatus = AVAILABILITY_STATUSES.Degraded;\n onDegradedEventEmitter.emit({ duration });\n } else if (availabilityStatus !== AVAILABILITY_STATUSES.Available) {\n availabilityStatus = AVAILABILITY_STATUSES.Available;\n onAvailableEventEmitter.emit();\n }\n }\n });\n\n // Every time the retry policy makes an attempt, it executes the circuit\n // breaker policy, which executes the service.\n //\n // Calling:\n //\n // policy.execute(() => {\n // // do what the service does\n // })\n //\n // is equivalent to:\n //\n // retryPolicy.execute(() => {\n // circuitBreakerPolicy.execute(() => {\n // // do what the service does\n // });\n // });\n //\n // So if the retry policy succeeds or fails, it is because the circuit breaker\n // policy succeeded or failed. And if there are any event listeners registered\n // on the retry policy, by the time they are called, the state of the circuit\n // breaker will have already changed.\n const policy = wrap(retryPolicy, circuitBreakerPolicy);\n\n const getRemainingCircuitOpenDuration = (): number | null => {\n if (internalCircuitState.state === CircuitState.Open) {\n return internalCircuitState.openedAt + circuitBreakDuration - Date.now();\n }\n return null;\n };\n\n const getCircuitState = (): CircuitState => {\n return circuitBreakerPolicy.state;\n };\n\n const reset = (): void => {\n // Set the state of the policy to \"isolated\" regardless of its current state\n const { dispose } = circuitBreakerPolicy.isolate();\n // Reset the state to \"closed\"\n dispose();\n\n // Reset the counter on the breaker as well\n consecutiveBreaker.success();\n\n // Re-initialize the availability status so that if the service is executed\n // successfully, onAvailable listeners will be called again\n availabilityStatus = AVAILABILITY_STATUSES.Unknown;\n };\n\n return {\n ...policy,\n circuitBreakerPolicy,\n circuitBreakDuration,\n getCircuitState,\n getRemainingCircuitOpenDuration,\n reset,\n retryPolicy,\n onBreak,\n onDegraded,\n onAvailable,\n onRetry,\n };\n}\n"]}
|
package/dist/types.cjs
CHANGED
|
@@ -17,6 +17,10 @@ exports.InfuraNetworkType = {
|
|
|
17
17
|
'optimism-mainnet': 'optimism-mainnet',
|
|
18
18
|
'polygon-mainnet': 'polygon-mainnet',
|
|
19
19
|
'sei-mainnet': 'sei-mainnet',
|
|
20
|
+
'monad-mainnet': 'monad-mainnet',
|
|
21
|
+
'megaeth-mainnet': 'megaeth-mainnet',
|
|
22
|
+
'avalanche-mainnet': 'avalanche-mainnet',
|
|
23
|
+
'zksync-mainnet': 'zksync-mainnet',
|
|
20
24
|
};
|
|
21
25
|
/**
|
|
22
26
|
* Custom network types that are not part of Infura.
|
|
@@ -86,6 +90,9 @@ var BuiltInNetworkName;
|
|
|
86
90
|
BuiltInNetworkName["PolygonMainnet"] = "polygon-mainnet";
|
|
87
91
|
BuiltInNetworkName["SeiMainnet"] = "sei-mainnet";
|
|
88
92
|
BuiltInNetworkName["MegaETHMainnet"] = "megaeth-mainnet";
|
|
93
|
+
BuiltInNetworkName["MonadMainnet"] = "monad-mainnet";
|
|
94
|
+
BuiltInNetworkName["AvalancheMainnet"] = "avalanche-mainnet";
|
|
95
|
+
BuiltInNetworkName["ZksyncMainnet"] = "zksync-mainnet";
|
|
89
96
|
})(BuiltInNetworkName || (exports.BuiltInNetworkName = BuiltInNetworkName = {}));
|
|
90
97
|
/**
|
|
91
98
|
* Decimal string chain IDs of built-in networks, by name.
|
|
@@ -113,6 +120,9 @@ exports.ChainId = {
|
|
|
113
120
|
[BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)
|
|
114
121
|
[BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)
|
|
115
122
|
[BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)
|
|
123
|
+
[BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)
|
|
124
|
+
[BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)
|
|
125
|
+
[BuiltInNetworkName.ZksyncMainnet]: '0x144', // toHex(324)
|
|
116
126
|
};
|
|
117
127
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
118
128
|
var NetworksTicker;
|
|
@@ -141,6 +151,13 @@ var NetworksTicker;
|
|
|
141
151
|
NetworksTicker["optimism-mainnet"] = "ETH";
|
|
142
152
|
NetworksTicker["polygon-mainnet"] = "POL";
|
|
143
153
|
NetworksTicker["sei-mainnet"] = "SEI";
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
155
|
+
NetworksTicker["megaeth-mainnet"] = "ETH";
|
|
156
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
157
|
+
NetworksTicker["monad-mainnet"] = "MON";
|
|
158
|
+
NetworksTicker["avalanche-mainnet"] = "AVAX";
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
160
|
+
NetworksTicker["zksync-mainnet"] = "ETH";
|
|
144
161
|
NetworksTicker["rpc"] = "";
|
|
145
162
|
})(NetworksTicker || (exports.NetworksTicker = NetworksTicker = {}));
|
|
146
163
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -163,6 +180,10 @@ exports.BlockExplorerUrl = {
|
|
|
163
180
|
[BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',
|
|
164
181
|
[BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',
|
|
165
182
|
[BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',
|
|
183
|
+
[BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',
|
|
184
|
+
[BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',
|
|
185
|
+
[BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',
|
|
186
|
+
[BuiltInNetworkName.ZksyncMainnet]: 'https://explorer.zksync.io',
|
|
166
187
|
};
|
|
167
188
|
exports.NetworkNickname = {
|
|
168
189
|
[BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',
|
|
@@ -183,5 +204,9 @@ exports.NetworkNickname = {
|
|
|
183
204
|
[BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',
|
|
184
205
|
[BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',
|
|
185
206
|
[BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',
|
|
207
|
+
[BuiltInNetworkName.MegaETHMainnet]: 'MegaETH Mainnet',
|
|
208
|
+
[BuiltInNetworkName.MonadMainnet]: 'Monad Mainnet',
|
|
209
|
+
[BuiltInNetworkName.AvalancheMainnet]: 'Avalanche Mainnet',
|
|
210
|
+
[BuiltInNetworkName.ZksyncMainnet]: 'ZKsync Era',
|
|
186
211
|
};
|
|
187
212
|
//# sourceMappingURL=types.cjs.map
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IAC9B,kBAAkB,EAAE,kBAAkB;IACtC,aAAa,EAAE,aAAa;IAC5B,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,iBAAiB;IACpC,aAAa,EAAE,aAAa;CACpB,CAAC;AAKX;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B;;OAEG;IACH,iBAAiB,EAAE,iBAAiB;IACpC,oBAAoB,EAAE,oBAAoB;IAC1C,eAAe,EAAE,eAAe;CACxB,CAAC;AASX;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,GAAG,yBAAiB;IACpB,GAAG,yBAAiB;IACpB,GAAG,EAAE,KAAK;CACF,CAAC;AAIX;;;;;GAKG;AACH,SAAgB,aA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AC1C;;OAEG;IACH,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,cAAc;IACnD,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,iBAAiB;IACxD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC9C,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,kBAAkB;IACxD,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACtD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;CACO,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n 'base-mainnet': 'base-mainnet',\n 'arbitrum-mainnet': 'arbitrum-mainnet',\n 'bsc-mainnet': 'bsc-mainnet',\n 'optimism-mainnet': 'optimism-mainnet',\n 'polygon-mainnet': 'polygon-mainnet',\n 'sei-mainnet': 'sei-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet': 'megaeth-testnet',\n 'megaeth-testnet-v2': 'megaeth-testnet-v2',\n 'monad-testnet': 'monad-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n MegaETHTestnet = 'megaeth-testnet',\n MegaETHTestnetV2 = 'megaeth-testnet-v2',\n MonadTestnet = 'monad-testnet',\n BaseMainnet = 'base-mainnet',\n ArbitrumOne = 'arbitrum-mainnet',\n BscMainnet = 'bsc-mainnet',\n OptimismMainnet = 'optimism-mainnet',\n PolygonMainnet = 'polygon-mainnet',\n SeiMainnet = 'sei-mainnet',\n MegaETHMainnet = 'megaeth-mainnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n [BuiltInNetworkName.MegaETHTestnetV2]: '0x18c7', // toHex(6343)\n [BuiltInNetworkName.MonadTestnet]: '0x279f', // toHex(10143)\n [BuiltInNetworkName.BaseMainnet]: '0x2105', // toHex(8453)\n [BuiltInNetworkName.ArbitrumOne]: '0xa4b1', // toHex(42161)\n [BuiltInNetworkName.BscMainnet]: '0x38', // toHex(56)\n [BuiltInNetworkName.OptimismMainnet]: '0xa', // toHex(10)\n [BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)\n [BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)\n [BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum NetworksTicker {\n mainnet = 'ETH',\n goerli = 'GoerliETH',\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-sepolia' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-mainnet' = 'ETH',\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet' = 'MegaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-testnet-v2' = 'MegaETH',\n 'monad-testnet' = 'MON',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'base-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'arbitrum-mainnet' = 'ETH',\n 'bsc-mainnet' = 'BNB',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'optimism-mainnet' = 'ETH',\n 'polygon-mainnet' = 'POL',\n 'sei-mainnet' = 'SEI',\n rpc = '',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n [BuiltInNetworkName.MegaETHTestnetV2]:\n 'https://megaeth-testnet-v2.blockscout.com',\n [BuiltInNetworkName.MonadTestnet]: 'https://testnet.monadexplorer.com',\n [BuiltInNetworkName.BaseMainnet]: 'https://basescan.org',\n [BuiltInNetworkName.ArbitrumOne]: 'https://arbiscan.io',\n [BuiltInNetworkName.BscMainnet]: 'https://bscscan.com',\n [BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',\n [BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',\n [BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n [BuiltInNetworkName.MegaETHTestnetV2]: 'MegaETH Testnet',\n [BuiltInNetworkName.MonadTestnet]: 'Monad Testnet',\n [BuiltInNetworkName.BaseMainnet]: 'Base Mainnet',\n [BuiltInNetworkName.ArbitrumOne]: 'Arbitrum One',\n [BuiltInNetworkName.BscMainnet]: 'BSC Mainnet',\n [BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',\n [BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',\n [BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n *\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.cjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IAC9B,kBAAkB,EAAE,kBAAkB;IACtC,aAAa,EAAE,aAAa;IAC5B,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,iBAAiB;IACpC,aAAa,EAAE,aAAa;IAC5B,eAAe,EAAE,eAAe;IAChC,iBAAiB,EAAE,iBAAiB;IACpC,mBAAmB,EAAE,mBAAmB;IACxC,gBAAgB,EAAE,gBAAgB;CAC1B,CAAC;AAKX;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B;;OAEG;IACH,iBAAiB,EAAE,iBAAiB;IACpC,oBAAoB,EAAE,oBAAoB;IAC1C,eAAe,EAAE,eAAe;CACxB,CAAC;AASX;;GAEG;AACU,QAAA,WAAW,GAAG;IACzB,GAAG,yBAAiB;IACpB,GAAG,yBAAiB;IACpB,GAAG,EAAE,KAAK;CACF,CAAC;AAIX;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,GAAW;IACvC,OAAO,MAAM,CAAC,MAAM,CAAC,mBAAW,CAAC,CAAC,QAAQ,CAAC,GAAkB,CAAC,CAAC;AACjE,CAAC;AAFD,sCAEC;AAED;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,KAAc;IAEd,MAAM,kBAAkB,GAAc,MAAM,CAAC,IAAI,CAAC,yBAAiB,CAAC,CAAC;IACrE,OAAO,kBAAkB,CAAC,QAAQ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AAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;IAC1C;;OAEG;IACH,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,cAAc;IACnD,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,iBAAiB;IACxD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC9C,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,kBAAkB;IACxD,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACtD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC9C,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACtD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,mBAAmB;IAC1D,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,YAAY;CACK,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n 'base-mainnet': 'base-mainnet',\n 'arbitrum-mainnet': 'arbitrum-mainnet',\n 'bsc-mainnet': 'bsc-mainnet',\n 'optimism-mainnet': 'optimism-mainnet',\n 'polygon-mainnet': 'polygon-mainnet',\n 'sei-mainnet': 'sei-mainnet',\n 'monad-mainnet': 'monad-mainnet',\n 'megaeth-mainnet': 'megaeth-mainnet',\n 'avalanche-mainnet': 'avalanche-mainnet',\n 'zksync-mainnet': 'zksync-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet': 'megaeth-testnet',\n 'megaeth-testnet-v2': 'megaeth-testnet-v2',\n 'monad-testnet': 'monad-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n MegaETHTestnet = 'megaeth-testnet',\n MegaETHTestnetV2 = 'megaeth-testnet-v2',\n MonadTestnet = 'monad-testnet',\n BaseMainnet = 'base-mainnet',\n ArbitrumOne = 'arbitrum-mainnet',\n BscMainnet = 'bsc-mainnet',\n OptimismMainnet = 'optimism-mainnet',\n PolygonMainnet = 'polygon-mainnet',\n SeiMainnet = 'sei-mainnet',\n MegaETHMainnet = 'megaeth-mainnet',\n MonadMainnet = 'monad-mainnet',\n AvalancheMainnet = 'avalanche-mainnet',\n ZksyncMainnet = 'zksync-mainnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n [BuiltInNetworkName.MegaETHTestnetV2]: '0x18c7', // toHex(6343)\n [BuiltInNetworkName.MonadTestnet]: '0x279f', // toHex(10143)\n [BuiltInNetworkName.BaseMainnet]: '0x2105', // toHex(8453)\n [BuiltInNetworkName.ArbitrumOne]: '0xa4b1', // toHex(42161)\n [BuiltInNetworkName.BscMainnet]: '0x38', // toHex(56)\n [BuiltInNetworkName.OptimismMainnet]: '0xa', // toHex(10)\n [BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)\n [BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)\n [BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)\n [BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)\n [BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)\n [BuiltInNetworkName.ZksyncMainnet]: '0x144', // toHex(324)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum NetworksTicker {\n mainnet = 'ETH',\n goerli = 'GoerliETH',\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-sepolia' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-mainnet' = 'ETH',\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet' = 'MegaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-testnet-v2' = 'MegaETH',\n 'monad-testnet' = 'MON',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'base-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'arbitrum-mainnet' = 'ETH',\n 'bsc-mainnet' = 'BNB',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'optimism-mainnet' = 'ETH',\n 'polygon-mainnet' = 'POL',\n 'sei-mainnet' = 'SEI',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'monad-mainnet' = 'MON',\n 'avalanche-mainnet' = 'AVAX',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'zksync-mainnet' = 'ETH',\n rpc = '',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n [BuiltInNetworkName.MegaETHTestnetV2]:\n 'https://megaeth-testnet-v2.blockscout.com',\n [BuiltInNetworkName.MonadTestnet]: 'https://testnet.monadexplorer.com',\n [BuiltInNetworkName.BaseMainnet]: 'https://basescan.org',\n [BuiltInNetworkName.ArbitrumOne]: 'https://arbiscan.io',\n [BuiltInNetworkName.BscMainnet]: 'https://bscscan.com',\n [BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',\n [BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',\n [BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',\n [BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',\n [BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',\n [BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',\n [BuiltInNetworkName.ZksyncMainnet]: 'https://explorer.zksync.io',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n [BuiltInNetworkName.MegaETHTestnetV2]: 'MegaETH Testnet',\n [BuiltInNetworkName.MonadTestnet]: 'Monad Testnet',\n [BuiltInNetworkName.BaseMainnet]: 'Base Mainnet',\n [BuiltInNetworkName.ArbitrumOne]: 'Arbitrum One',\n [BuiltInNetworkName.BscMainnet]: 'BSC Mainnet',\n [BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',\n [BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',\n [BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',\n [BuiltInNetworkName.MegaETHMainnet]: 'MegaETH Mainnet',\n [BuiltInNetworkName.MonadMainnet]: 'Monad Mainnet',\n [BuiltInNetworkName.AvalancheMainnet]: 'Avalanche Mainnet',\n [BuiltInNetworkName.ZksyncMainnet]: 'ZKsync Era',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n *\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
|
package/dist/types.d.cts
CHANGED
|
@@ -14,6 +14,10 @@ export declare const InfuraNetworkType: {
|
|
|
14
14
|
readonly 'optimism-mainnet': "optimism-mainnet";
|
|
15
15
|
readonly 'polygon-mainnet': "polygon-mainnet";
|
|
16
16
|
readonly 'sei-mainnet': "sei-mainnet";
|
|
17
|
+
readonly 'monad-mainnet': "monad-mainnet";
|
|
18
|
+
readonly 'megaeth-mainnet': "megaeth-mainnet";
|
|
19
|
+
readonly 'avalanche-mainnet': "avalanche-mainnet";
|
|
20
|
+
readonly 'zksync-mainnet': "zksync-mainnet";
|
|
17
21
|
};
|
|
18
22
|
export type InfuraNetworkType = (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];
|
|
19
23
|
/**
|
|
@@ -55,6 +59,10 @@ export declare const NetworkType: {
|
|
|
55
59
|
readonly 'optimism-mainnet': "optimism-mainnet";
|
|
56
60
|
readonly 'polygon-mainnet': "polygon-mainnet";
|
|
57
61
|
readonly 'sei-mainnet': "sei-mainnet";
|
|
62
|
+
readonly 'monad-mainnet': "monad-mainnet";
|
|
63
|
+
readonly 'megaeth-mainnet': "megaeth-mainnet";
|
|
64
|
+
readonly 'avalanche-mainnet': "avalanche-mainnet";
|
|
65
|
+
readonly 'zksync-mainnet': "zksync-mainnet";
|
|
58
66
|
};
|
|
59
67
|
export type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];
|
|
60
68
|
/**
|
|
@@ -97,7 +105,10 @@ export declare enum BuiltInNetworkName {
|
|
|
97
105
|
OptimismMainnet = "optimism-mainnet",
|
|
98
106
|
PolygonMainnet = "polygon-mainnet",
|
|
99
107
|
SeiMainnet = "sei-mainnet",
|
|
100
|
-
MegaETHMainnet = "megaeth-mainnet"
|
|
108
|
+
MegaETHMainnet = "megaeth-mainnet",
|
|
109
|
+
MonadMainnet = "monad-mainnet",
|
|
110
|
+
AvalancheMainnet = "avalanche-mainnet",
|
|
111
|
+
ZksyncMainnet = "zksync-mainnet"
|
|
101
112
|
}
|
|
102
113
|
/**
|
|
103
114
|
* Decimal string chain IDs of built-in networks, by name.
|
|
@@ -125,6 +136,9 @@ export declare const ChainId: {
|
|
|
125
136
|
readonly "polygon-mainnet": "0x89";
|
|
126
137
|
readonly "sei-mainnet": "0x531";
|
|
127
138
|
readonly "megaeth-mainnet": "0x10e6";
|
|
139
|
+
readonly "monad-mainnet": "0x8f";
|
|
140
|
+
readonly "avalanche-mainnet": "0xa86a";
|
|
141
|
+
readonly "zksync-mainnet": "0x144";
|
|
128
142
|
};
|
|
129
143
|
export type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
130
144
|
export declare enum NetworksTicker {
|
|
@@ -146,6 +160,10 @@ export declare enum NetworksTicker {
|
|
|
146
160
|
'optimism-mainnet' = "ETH",
|
|
147
161
|
'polygon-mainnet' = "POL",
|
|
148
162
|
'sei-mainnet' = "SEI",
|
|
163
|
+
'megaeth-mainnet' = "ETH",
|
|
164
|
+
'monad-mainnet' = "MON",
|
|
165
|
+
'avalanche-mainnet' = "AVAX",
|
|
166
|
+
'zksync-mainnet' = "ETH",
|
|
149
167
|
rpc = ""
|
|
150
168
|
}
|
|
151
169
|
export declare const BlockExplorerUrl: {
|
|
@@ -167,6 +185,10 @@ export declare const BlockExplorerUrl: {
|
|
|
167
185
|
readonly "optimism-mainnet": "https://optimistic.etherscan.io";
|
|
168
186
|
readonly "polygon-mainnet": "https://polygonscan.com";
|
|
169
187
|
readonly "sei-mainnet": "https://seiscan.io";
|
|
188
|
+
readonly "megaeth-mainnet": "https://megaeth.blockscout.com";
|
|
189
|
+
readonly "monad-mainnet": "https://monadscan.com";
|
|
190
|
+
readonly "avalanche-mainnet": "https://snowtrace.io";
|
|
191
|
+
readonly "zksync-mainnet": "https://explorer.zksync.io";
|
|
170
192
|
};
|
|
171
193
|
export type BlockExplorerUrl = (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
|
|
172
194
|
export declare const NetworkNickname: {
|
|
@@ -188,6 +210,10 @@ export declare const NetworkNickname: {
|
|
|
188
210
|
readonly "optimism-mainnet": "Optimism Mainnet";
|
|
189
211
|
readonly "polygon-mainnet": "Polygon Mainnet";
|
|
190
212
|
readonly "sei-mainnet": "Sei Mainnet";
|
|
213
|
+
readonly "megaeth-mainnet": "MegaETH Mainnet";
|
|
214
|
+
readonly "monad-mainnet": "Monad Mainnet";
|
|
215
|
+
readonly "avalanche-mainnet": "Avalanche Mainnet";
|
|
216
|
+
readonly "zksync-mainnet": "ZKsync Era";
|
|
191
217
|
};
|
|
192
218
|
export type NetworkNickname = (typeof NetworkNickname)[keyof typeof NetworkNickname];
|
|
193
219
|
/**
|
package/dist/types.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAiBpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;;;CAIK,CAAC;AACX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,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AE7B,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAClD,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,UAAU;AACrC,wDAAwD;AACxD,OAAO,EAAE,YAAY;AAErB;;;;;GAKG;AACH,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,UAAU,KACxC,OAAO,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/types.d.mts
CHANGED
|
@@ -14,6 +14,10 @@ export declare const InfuraNetworkType: {
|
|
|
14
14
|
readonly 'optimism-mainnet': "optimism-mainnet";
|
|
15
15
|
readonly 'polygon-mainnet': "polygon-mainnet";
|
|
16
16
|
readonly 'sei-mainnet': "sei-mainnet";
|
|
17
|
+
readonly 'monad-mainnet': "monad-mainnet";
|
|
18
|
+
readonly 'megaeth-mainnet': "megaeth-mainnet";
|
|
19
|
+
readonly 'avalanche-mainnet': "avalanche-mainnet";
|
|
20
|
+
readonly 'zksync-mainnet': "zksync-mainnet";
|
|
17
21
|
};
|
|
18
22
|
export type InfuraNetworkType = (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];
|
|
19
23
|
/**
|
|
@@ -55,6 +59,10 @@ export declare const NetworkType: {
|
|
|
55
59
|
readonly 'optimism-mainnet': "optimism-mainnet";
|
|
56
60
|
readonly 'polygon-mainnet': "polygon-mainnet";
|
|
57
61
|
readonly 'sei-mainnet': "sei-mainnet";
|
|
62
|
+
readonly 'monad-mainnet': "monad-mainnet";
|
|
63
|
+
readonly 'megaeth-mainnet': "megaeth-mainnet";
|
|
64
|
+
readonly 'avalanche-mainnet': "avalanche-mainnet";
|
|
65
|
+
readonly 'zksync-mainnet': "zksync-mainnet";
|
|
58
66
|
};
|
|
59
67
|
export type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];
|
|
60
68
|
/**
|
|
@@ -97,7 +105,10 @@ export declare enum BuiltInNetworkName {
|
|
|
97
105
|
OptimismMainnet = "optimism-mainnet",
|
|
98
106
|
PolygonMainnet = "polygon-mainnet",
|
|
99
107
|
SeiMainnet = "sei-mainnet",
|
|
100
|
-
MegaETHMainnet = "megaeth-mainnet"
|
|
108
|
+
MegaETHMainnet = "megaeth-mainnet",
|
|
109
|
+
MonadMainnet = "monad-mainnet",
|
|
110
|
+
AvalancheMainnet = "avalanche-mainnet",
|
|
111
|
+
ZksyncMainnet = "zksync-mainnet"
|
|
101
112
|
}
|
|
102
113
|
/**
|
|
103
114
|
* Decimal string chain IDs of built-in networks, by name.
|
|
@@ -125,6 +136,9 @@ export declare const ChainId: {
|
|
|
125
136
|
readonly "polygon-mainnet": "0x89";
|
|
126
137
|
readonly "sei-mainnet": "0x531";
|
|
127
138
|
readonly "megaeth-mainnet": "0x10e6";
|
|
139
|
+
readonly "monad-mainnet": "0x8f";
|
|
140
|
+
readonly "avalanche-mainnet": "0xa86a";
|
|
141
|
+
readonly "zksync-mainnet": "0x144";
|
|
128
142
|
};
|
|
129
143
|
export type ChainId = (typeof ChainId)[keyof typeof ChainId];
|
|
130
144
|
export declare enum NetworksTicker {
|
|
@@ -146,6 +160,10 @@ export declare enum NetworksTicker {
|
|
|
146
160
|
'optimism-mainnet' = "ETH",
|
|
147
161
|
'polygon-mainnet' = "POL",
|
|
148
162
|
'sei-mainnet' = "SEI",
|
|
163
|
+
'megaeth-mainnet' = "ETH",
|
|
164
|
+
'monad-mainnet' = "MON",
|
|
165
|
+
'avalanche-mainnet' = "AVAX",
|
|
166
|
+
'zksync-mainnet' = "ETH",
|
|
149
167
|
rpc = ""
|
|
150
168
|
}
|
|
151
169
|
export declare const BlockExplorerUrl: {
|
|
@@ -167,6 +185,10 @@ export declare const BlockExplorerUrl: {
|
|
|
167
185
|
readonly "optimism-mainnet": "https://optimistic.etherscan.io";
|
|
168
186
|
readonly "polygon-mainnet": "https://polygonscan.com";
|
|
169
187
|
readonly "sei-mainnet": "https://seiscan.io";
|
|
188
|
+
readonly "megaeth-mainnet": "https://megaeth.blockscout.com";
|
|
189
|
+
readonly "monad-mainnet": "https://monadscan.com";
|
|
190
|
+
readonly "avalanche-mainnet": "https://snowtrace.io";
|
|
191
|
+
readonly "zksync-mainnet": "https://explorer.zksync.io";
|
|
170
192
|
};
|
|
171
193
|
export type BlockExplorerUrl = (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];
|
|
172
194
|
export declare const NetworkNickname: {
|
|
@@ -188,6 +210,10 @@ export declare const NetworkNickname: {
|
|
|
188
210
|
readonly "optimism-mainnet": "Optimism Mainnet";
|
|
189
211
|
readonly "polygon-mainnet": "Polygon Mainnet";
|
|
190
212
|
readonly "sei-mainnet": "Sei Mainnet";
|
|
213
|
+
readonly "megaeth-mainnet": "MegaETH Mainnet";
|
|
214
|
+
readonly "monad-mainnet": "Monad Mainnet";
|
|
215
|
+
readonly "avalanche-mainnet": "Avalanche Mainnet";
|
|
216
|
+
readonly "zksync-mainnet": "ZKsync Era";
|
|
191
217
|
};
|
|
192
218
|
export type NetworkNickname = (typeof NetworkNickname)[keyof typeof NetworkNickname];
|
|
193
219
|
/**
|
package/dist/types.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB
|
|
1
|
+
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;CAiBpB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,iBAAiB;IAC5B;;OAEG;;;;CAIK,CAAC;AACX,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO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Y,CAAC;IAE7B,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC;CAClD,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,aAAa,GAAG,CAAC,UAAU;AACrC,wDAAwD;AACxD,OAAO,EAAE,YAAY;AAErB;;;;;GAKG;AACH,EAAE,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE,YAAY,KAAK,UAAU,KACxC,OAAO,CAAC,UAAU,CAAC,CAAC"}
|
package/dist/types.mjs
CHANGED
|
@@ -14,6 +14,10 @@ export const InfuraNetworkType = {
|
|
|
14
14
|
'optimism-mainnet': 'optimism-mainnet',
|
|
15
15
|
'polygon-mainnet': 'polygon-mainnet',
|
|
16
16
|
'sei-mainnet': 'sei-mainnet',
|
|
17
|
+
'monad-mainnet': 'monad-mainnet',
|
|
18
|
+
'megaeth-mainnet': 'megaeth-mainnet',
|
|
19
|
+
'avalanche-mainnet': 'avalanche-mainnet',
|
|
20
|
+
'zksync-mainnet': 'zksync-mainnet',
|
|
17
21
|
};
|
|
18
22
|
/**
|
|
19
23
|
* Custom network types that are not part of Infura.
|
|
@@ -81,6 +85,9 @@ export var BuiltInNetworkName;
|
|
|
81
85
|
BuiltInNetworkName["PolygonMainnet"] = "polygon-mainnet";
|
|
82
86
|
BuiltInNetworkName["SeiMainnet"] = "sei-mainnet";
|
|
83
87
|
BuiltInNetworkName["MegaETHMainnet"] = "megaeth-mainnet";
|
|
88
|
+
BuiltInNetworkName["MonadMainnet"] = "monad-mainnet";
|
|
89
|
+
BuiltInNetworkName["AvalancheMainnet"] = "avalanche-mainnet";
|
|
90
|
+
BuiltInNetworkName["ZksyncMainnet"] = "zksync-mainnet";
|
|
84
91
|
})(BuiltInNetworkName || (BuiltInNetworkName = {}));
|
|
85
92
|
/**
|
|
86
93
|
* Decimal string chain IDs of built-in networks, by name.
|
|
@@ -108,6 +115,9 @@ export const ChainId = {
|
|
|
108
115
|
[BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)
|
|
109
116
|
[BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)
|
|
110
117
|
[BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)
|
|
118
|
+
[BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)
|
|
119
|
+
[BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)
|
|
120
|
+
[BuiltInNetworkName.ZksyncMainnet]: '0x144', // toHex(324)
|
|
111
121
|
};
|
|
112
122
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
113
123
|
export var NetworksTicker;
|
|
@@ -136,6 +146,13 @@ export var NetworksTicker;
|
|
|
136
146
|
NetworksTicker["optimism-mainnet"] = "ETH";
|
|
137
147
|
NetworksTicker["polygon-mainnet"] = "POL";
|
|
138
148
|
NetworksTicker["sei-mainnet"] = "SEI";
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
150
|
+
NetworksTicker["megaeth-mainnet"] = "ETH";
|
|
151
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
152
|
+
NetworksTicker["monad-mainnet"] = "MON";
|
|
153
|
+
NetworksTicker["avalanche-mainnet"] = "AVAX";
|
|
154
|
+
// eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
|
|
155
|
+
NetworksTicker["zksync-mainnet"] = "ETH";
|
|
139
156
|
NetworksTicker["rpc"] = "";
|
|
140
157
|
})(NetworksTicker || (NetworksTicker = {}));
|
|
141
158
|
/* eslint-enable @typescript-eslint/naming-convention */
|
|
@@ -158,6 +175,10 @@ export const BlockExplorerUrl = {
|
|
|
158
175
|
[BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',
|
|
159
176
|
[BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',
|
|
160
177
|
[BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',
|
|
178
|
+
[BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',
|
|
179
|
+
[BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',
|
|
180
|
+
[BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',
|
|
181
|
+
[BuiltInNetworkName.ZksyncMainnet]: 'https://explorer.zksync.io',
|
|
161
182
|
};
|
|
162
183
|
export const NetworkNickname = {
|
|
163
184
|
[BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',
|
|
@@ -178,5 +199,9 @@ export const NetworkNickname = {
|
|
|
178
199
|
[BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',
|
|
179
200
|
[BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',
|
|
180
201
|
[BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',
|
|
202
|
+
[BuiltInNetworkName.MegaETHMainnet]: 'MegaETH Mainnet',
|
|
203
|
+
[BuiltInNetworkName.MonadMainnet]: 'Monad Mainnet',
|
|
204
|
+
[BuiltInNetworkName.AvalancheMainnet]: 'Avalanche Mainnet',
|
|
205
|
+
[BuiltInNetworkName.ZksyncMainnet]: 'ZKsync Era',
|
|
181
206
|
};
|
|
182
207
|
//# sourceMappingURL=types.mjs.map
|
package/dist/types.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IAC9B,kBAAkB,EAAE,kBAAkB;IACtC,aAAa,EAAE,aAAa;IAC5B,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,iBAAiB;IACpC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UAAU,CAAC,EAAE,oBAAoB;CACA,CAAC;AAIxD,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,kBAAkB;IAChD,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,QAAQ;IACrC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,SAAS;IACvC,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,OAAO;IAC1C;;OAEG;IACH,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,cAAc;IACnD,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,iBAAiB;IACxD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,WAAW,CAAC,EAAE,cAAc;IAChD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;IAC9C,CAAC,kBAAkB,CAAC,eAAe,CAAC,EAAE,kBAAkB;IACxD,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACtD,CAAC,kBAAkB,CAAC,UAAU,CAAC,EAAE,aAAa;CACO,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n 'base-mainnet': 'base-mainnet',\n 'arbitrum-mainnet': 'arbitrum-mainnet',\n 'bsc-mainnet': 'bsc-mainnet',\n 'optimism-mainnet': 'optimism-mainnet',\n 'polygon-mainnet': 'polygon-mainnet',\n 'sei-mainnet': 'sei-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet': 'megaeth-testnet',\n 'megaeth-testnet-v2': 'megaeth-testnet-v2',\n 'monad-testnet': 'monad-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n MegaETHTestnet = 'megaeth-testnet',\n MegaETHTestnetV2 = 'megaeth-testnet-v2',\n MonadTestnet = 'monad-testnet',\n BaseMainnet = 'base-mainnet',\n ArbitrumOne = 'arbitrum-mainnet',\n BscMainnet = 'bsc-mainnet',\n OptimismMainnet = 'optimism-mainnet',\n PolygonMainnet = 'polygon-mainnet',\n SeiMainnet = 'sei-mainnet',\n MegaETHMainnet = 'megaeth-mainnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n [BuiltInNetworkName.MegaETHTestnetV2]: '0x18c7', // toHex(6343)\n [BuiltInNetworkName.MonadTestnet]: '0x279f', // toHex(10143)\n [BuiltInNetworkName.BaseMainnet]: '0x2105', // toHex(8453)\n [BuiltInNetworkName.ArbitrumOne]: '0xa4b1', // toHex(42161)\n [BuiltInNetworkName.BscMainnet]: '0x38', // toHex(56)\n [BuiltInNetworkName.OptimismMainnet]: '0xa', // toHex(10)\n [BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)\n [BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)\n [BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum NetworksTicker {\n mainnet = 'ETH',\n goerli = 'GoerliETH',\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-sepolia' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-mainnet' = 'ETH',\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet' = 'MegaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-testnet-v2' = 'MegaETH',\n 'monad-testnet' = 'MON',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'base-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'arbitrum-mainnet' = 'ETH',\n 'bsc-mainnet' = 'BNB',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'optimism-mainnet' = 'ETH',\n 'polygon-mainnet' = 'POL',\n 'sei-mainnet' = 'SEI',\n rpc = '',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n [BuiltInNetworkName.MegaETHTestnetV2]:\n 'https://megaeth-testnet-v2.blockscout.com',\n [BuiltInNetworkName.MonadTestnet]: 'https://testnet.monadexplorer.com',\n [BuiltInNetworkName.BaseMainnet]: 'https://basescan.org',\n [BuiltInNetworkName.ArbitrumOne]: 'https://arbiscan.io',\n [BuiltInNetworkName.BscMainnet]: 'https://bscscan.com',\n [BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',\n [BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',\n [BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n [BuiltInNetworkName.MegaETHTestnetV2]: 'MegaETH Testnet',\n [BuiltInNetworkName.MonadTestnet]: 'Monad Testnet',\n [BuiltInNetworkName.BaseMainnet]: 'Base Mainnet',\n [BuiltInNetworkName.ArbitrumOne]: 'Arbitrum One',\n [BuiltInNetworkName.BscMainnet]: 'BSC Mainnet',\n [BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',\n [BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',\n [BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n *\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,OAAO,EAAE,SAAS;IAClB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,SAAS;IAClB,cAAc,EAAE,cAAc;IAC9B,eAAe,EAAE,eAAe;IAChC,eAAe,EAAE,eAAe;IAChC,cAAc,EAAE,cAAc;IAC9B,kBAAkB,EAAE,kBAAkB;IACtC,aAAa,EAAE,aAAa;IAC5B,kBAAkB,EAAE,kBAAkB;IACtC,iBAAiB,EAAE,iBAAiB;IACpC,aAAa,EAAE,aAAa;IAC5B,eAAe,EAAE,eAAe;IAChC,iBAAiB,EAAE,iBAAiB;IACpC,mBAAmB,EAAE,mBAAmB;IACxC,gBAAgB,EAAE,gBAAgB;CAC1B,CAAC;AAKX;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B;;OAEG;IACH,iBAAiB,EAAE,iBAAiB;IACpC,oBAAoB,EAAE,oBAAoB;IAC1C,eAAe,EAAE,eAAe;CACxB,CAAC;AASX;;GAEG;AACH,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AAU,CAAC,EAAE,aAAa;IAC9C,CAAC,kBAAkB,CAAC,cAAc,CAAC,EAAE,iBAAiB;IACtD,CAAC,kBAAkB,CAAC,YAAY,CAAC,EAAE,eAAe;IAClD,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,mBAAmB;IAC1D,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,YAAY;CACK,CAAC","sourcesContent":["/**\n * The names of built-in Infura networks\n */\nexport const InfuraNetworkType = {\n mainnet: 'mainnet',\n goerli: 'goerli',\n sepolia: 'sepolia',\n 'linea-goerli': 'linea-goerli',\n 'linea-sepolia': 'linea-sepolia',\n 'linea-mainnet': 'linea-mainnet',\n 'base-mainnet': 'base-mainnet',\n 'arbitrum-mainnet': 'arbitrum-mainnet',\n 'bsc-mainnet': 'bsc-mainnet',\n 'optimism-mainnet': 'optimism-mainnet',\n 'polygon-mainnet': 'polygon-mainnet',\n 'sei-mainnet': 'sei-mainnet',\n 'monad-mainnet': 'monad-mainnet',\n 'megaeth-mainnet': 'megaeth-mainnet',\n 'avalanche-mainnet': 'avalanche-mainnet',\n 'zksync-mainnet': 'zksync-mainnet',\n} as const;\n\nexport type InfuraNetworkType =\n (typeof InfuraNetworkType)[keyof typeof InfuraNetworkType];\n\n/**\n * Custom network types that are not part of Infura.\n */\nexport const CustomNetworkType = {\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet': 'megaeth-testnet',\n 'megaeth-testnet-v2': 'megaeth-testnet-v2',\n 'monad-testnet': 'monad-testnet',\n} as const;\nexport type CustomNetworkType =\n (typeof CustomNetworkType)[keyof typeof CustomNetworkType];\n\n/**\n * Network types supported including both Infura networks and other networks.\n */\nexport type BuiltInNetworkType = InfuraNetworkType | CustomNetworkType;\n\n/**\n * The \"network type\"; either the name of a built-in network, or \"rpc\" for custom networks.\n */\nexport const NetworkType = {\n ...InfuraNetworkType,\n ...CustomNetworkType,\n rpc: 'rpc',\n} as const;\n\nexport type NetworkType = (typeof NetworkType)[keyof typeof NetworkType];\n\n/**\n * A helper to determine whether a given input is NetworkType.\n *\n * @param val - the value to check whether it is NetworkType or not.\n * @returns boolean indicating whether or not the argument is NetworkType.\n */\nexport function isNetworkType(val: string): val is NetworkType {\n return Object.values(NetworkType).includes(val as NetworkType);\n}\n\n/**\n * A type guard to determine whether the input is an InfuraNetworkType.\n *\n * @param value - The value to check.\n * @returns True if the given value is within the InfuraNetworkType enum,\n * false otherwise.\n */\nexport function isInfuraNetworkType(\n value: unknown,\n): value is InfuraNetworkType {\n const infuraNetworkTypes: unknown[] = Object.keys(InfuraNetworkType);\n return infuraNetworkTypes.includes(value);\n}\n\n/**\n * Names of networks built into the wallet.\n *\n * This includes both Infura and non-Infura networks.\n */\nexport enum BuiltInNetworkName {\n Mainnet = 'mainnet',\n Goerli = 'goerli',\n Sepolia = 'sepolia',\n LineaGoerli = 'linea-goerli',\n LineaSepolia = 'linea-sepolia',\n LineaMainnet = 'linea-mainnet',\n Aurora = 'aurora',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n MegaETHTestnet = 'megaeth-testnet',\n MegaETHTestnetV2 = 'megaeth-testnet-v2',\n MonadTestnet = 'monad-testnet',\n BaseMainnet = 'base-mainnet',\n ArbitrumOne = 'arbitrum-mainnet',\n BscMainnet = 'bsc-mainnet',\n OptimismMainnet = 'optimism-mainnet',\n PolygonMainnet = 'polygon-mainnet',\n SeiMainnet = 'sei-mainnet',\n MegaETHMainnet = 'megaeth-mainnet',\n MonadMainnet = 'monad-mainnet',\n AvalancheMainnet = 'avalanche-mainnet',\n ZksyncMainnet = 'zksync-mainnet',\n}\n\n/**\n * Decimal string chain IDs of built-in networks, by name.\n *\n * `toHex` not invoked to avoid cyclic dependency\n */\nexport const ChainId = {\n [BuiltInNetworkName.Mainnet]: '0x1', // toHex(1)\n [BuiltInNetworkName.Goerli]: '0x5', // toHex(5)\n [BuiltInNetworkName.Sepolia]: '0xaa36a7', // toHex(11155111)\n [BuiltInNetworkName.Aurora]: '0x4e454152', // toHex(1313161554)\n [BuiltInNetworkName.LineaGoerli]: '0xe704', // toHex(59140)\n [BuiltInNetworkName.LineaSepolia]: '0xe705', // toHex(59141)\n [BuiltInNetworkName.LineaMainnet]: '0xe708', // toHex(59144)\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: '0x18c6', // toHex(6342)\n [BuiltInNetworkName.MegaETHTestnetV2]: '0x18c7', // toHex(6343)\n [BuiltInNetworkName.MonadTestnet]: '0x279f', // toHex(10143)\n [BuiltInNetworkName.BaseMainnet]: '0x2105', // toHex(8453)\n [BuiltInNetworkName.ArbitrumOne]: '0xa4b1', // toHex(42161)\n [BuiltInNetworkName.BscMainnet]: '0x38', // toHex(56)\n [BuiltInNetworkName.OptimismMainnet]: '0xa', // toHex(10)\n [BuiltInNetworkName.PolygonMainnet]: '0x89', // toHex(137)\n [BuiltInNetworkName.SeiMainnet]: '0x531', // toHex(1329)\n [BuiltInNetworkName.MegaETHMainnet]: '0x10e6', // toHex(4326)\n [BuiltInNetworkName.MonadMainnet]: '0x8f', // toHex(143)\n [BuiltInNetworkName.AvalancheMainnet]: '0xa86a', // toHex(43114)\n [BuiltInNetworkName.ZksyncMainnet]: '0x144', // toHex(324)\n} as const;\nexport type ChainId = (typeof ChainId)[keyof typeof ChainId];\n\n/* eslint-disable @typescript-eslint/naming-convention */\nexport enum NetworksTicker {\n mainnet = 'ETH',\n goerli = 'GoerliETH',\n sepolia = 'SepoliaETH',\n 'linea-goerli' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-sepolia' = 'LineaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'linea-mainnet' = 'ETH',\n /**\n * @deprecated `megaeth-testnet` is migrated to `megaeth-testnet-v2`.\n */\n 'megaeth-testnet' = 'MegaETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-testnet-v2' = 'MegaETH',\n 'monad-testnet' = 'MON',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'base-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'arbitrum-mainnet' = 'ETH',\n 'bsc-mainnet' = 'BNB',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'optimism-mainnet' = 'ETH',\n 'polygon-mainnet' = 'POL',\n 'sei-mainnet' = 'SEI',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'megaeth-mainnet' = 'ETH',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'monad-mainnet' = 'MON',\n 'avalanche-mainnet' = 'AVAX',\n // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values\n 'zksync-mainnet' = 'ETH',\n rpc = '',\n}\n/* eslint-enable @typescript-eslint/naming-convention */\n\nexport const BlockExplorerUrl = {\n [BuiltInNetworkName.Mainnet]: 'https://etherscan.io',\n [BuiltInNetworkName.Goerli]: 'https://goerli.etherscan.io',\n [BuiltInNetworkName.Sepolia]: 'https://sepolia.etherscan.io',\n [BuiltInNetworkName.LineaGoerli]: 'https://goerli.lineascan.build',\n [BuiltInNetworkName.LineaSepolia]: 'https://sepolia.lineascan.build',\n [BuiltInNetworkName.LineaMainnet]: 'https://lineascan.build',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'https://megaexplorer.xyz',\n [BuiltInNetworkName.MegaETHTestnetV2]:\n 'https://megaeth-testnet-v2.blockscout.com',\n [BuiltInNetworkName.MonadTestnet]: 'https://testnet.monadexplorer.com',\n [BuiltInNetworkName.BaseMainnet]: 'https://basescan.org',\n [BuiltInNetworkName.ArbitrumOne]: 'https://arbiscan.io',\n [BuiltInNetworkName.BscMainnet]: 'https://bscscan.com',\n [BuiltInNetworkName.OptimismMainnet]: 'https://optimistic.etherscan.io',\n [BuiltInNetworkName.PolygonMainnet]: 'https://polygonscan.com',\n [BuiltInNetworkName.SeiMainnet]: 'https://seiscan.io',\n [BuiltInNetworkName.MegaETHMainnet]: 'https://megaeth.blockscout.com',\n [BuiltInNetworkName.MonadMainnet]: 'https://monadscan.com',\n [BuiltInNetworkName.AvalancheMainnet]: 'https://snowtrace.io',\n [BuiltInNetworkName.ZksyncMainnet]: 'https://explorer.zksync.io',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type BlockExplorerUrl =\n (typeof BlockExplorerUrl)[keyof typeof BlockExplorerUrl];\n\nexport const NetworkNickname = {\n [BuiltInNetworkName.Mainnet]: 'Ethereum Mainnet',\n [BuiltInNetworkName.Goerli]: 'Goerli',\n [BuiltInNetworkName.Sepolia]: 'Sepolia',\n [BuiltInNetworkName.LineaGoerli]: 'Linea Goerli',\n [BuiltInNetworkName.LineaSepolia]: 'Linea Sepolia',\n [BuiltInNetworkName.LineaMainnet]: 'Linea',\n /**\n * @deprecated `MegaETHTestnet` is migrated to `MegaETHTestnetV2`.\n */\n [BuiltInNetworkName.MegaETHTestnet]: 'Mega Testnet',\n [BuiltInNetworkName.MegaETHTestnetV2]: 'MegaETH Testnet',\n [BuiltInNetworkName.MonadTestnet]: 'Monad Testnet',\n [BuiltInNetworkName.BaseMainnet]: 'Base Mainnet',\n [BuiltInNetworkName.ArbitrumOne]: 'Arbitrum One',\n [BuiltInNetworkName.BscMainnet]: 'BSC Mainnet',\n [BuiltInNetworkName.OptimismMainnet]: 'Optimism Mainnet',\n [BuiltInNetworkName.PolygonMainnet]: 'Polygon Mainnet',\n [BuiltInNetworkName.SeiMainnet]: 'Sei Mainnet',\n [BuiltInNetworkName.MegaETHMainnet]: 'MegaETH Mainnet',\n [BuiltInNetworkName.MonadMainnet]: 'Monad Mainnet',\n [BuiltInNetworkName.AvalancheMainnet]: 'Avalanche Mainnet',\n [BuiltInNetworkName.ZksyncMainnet]: 'ZKsync Era',\n} as const satisfies Record<BuiltInNetworkType, string>;\nexport type NetworkNickname =\n (typeof NetworkNickname)[keyof typeof NetworkNickname];\n\n/**\n * Makes a selection of keys in a Record optional.\n *\n * @template Type - The Record that you want to operate on.\n * @template Key - The union of keys you want to make optional.\n */\n// TODO: Move to @metamask/utils\nexport type Partialize<Type, Key extends keyof Type> = Omit<Type, Key> &\n Partial<Pick<Type, Key>>;\n\n/** A context in which to execute a trace, in order to generate nested timings. */\nexport type TraceContext = unknown;\n\n/** Request to trace an operation. */\nexport type TraceRequest = {\n /** Additional data to include in the trace. */\n data?: Record<string, number | string | boolean>;\n\n /** Name of the operation. */\n name: string;\n\n /**\n * Unique identifier for the trace.\n * Required if starting a trace and not providing a callback.\n */\n id?: string;\n\n /** Trace context in which to execute the operation. */\n parentContext?: TraceContext;\n\n /** Additional tags to include in the trace to filter results. */\n tags?: Record<string, number | string | boolean>;\n};\n\n/** Callback that traces the performance of an operation. */\nexport type TraceCallback = <ReturnType>(\n /** Request to trace the performance of an operation. */\n request: TraceRequest,\n\n /**\n * Callback to trace.\n * Thrown errors will not be caught, but the trace will still be recorded.\n *\n * @param context - The context in which the operation is running.\n */\n fn?: (context?: TraceContext) => ReturnType,\n) => Promise<ReturnType>;\n"]}
|
package/package.json
CHANGED