@metamask/network-controller
Advanced tools
| "use strict"; | ||
| /** | ||
| * This file is auto generated. | ||
| * Do not edit manually. | ||
| */ | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| //# sourceMappingURL=NetworkController-method-action-types.cjs.map |
| {"version":3,"file":"NetworkController-method-action-types.cjs","sourceRoot":"","sources":["../src/NetworkController-method-action-types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkController } from './NetworkController';\n\n/**\n * Returns the EthQuery instance for the currently selected network.\n *\n * @returns The EthQuery instance, or undefined if the provider has not been\n * initialized.\n */\nexport type NetworkControllerGetEthQueryAction = {\n type: `NetworkController:getEthQuery`;\n handler: NetworkController['getEthQuery'];\n};\n\n/**\n * Enables the RPC failover functionality. That is, if any RPC endpoints are\n * configured with failover URLs, then traffic will automatically be diverted\n * to them if those RPC endpoints are unavailable.\n */\nexport type NetworkControllerEnableRpcFailoverAction = {\n type: `NetworkController:enableRpcFailover`;\n handler: NetworkController['enableRpcFailover'];\n};\n\n/**\n * Disables the RPC failover functionality. That is, even if any RPC endpoints\n * are configured with failover URLs, then traffic will not automatically be\n * diverted to them if those RPC endpoints are unavailable.\n */\nexport type NetworkControllerDisableRpcFailoverAction = {\n type: `NetworkController:disableRpcFailover`;\n handler: NetworkController['disableRpcFailover'];\n};\n\n/**\n * Accesses the provider and block tracker for the currently selected network.\n *\n * @returns The proxy and block tracker proxies.\n * @deprecated This method has been replaced by `getSelectedNetworkClient` (which has a more easily used return type) and will be removed in a future release.\n */\nexport type NetworkControllerGetProviderAndBlockTrackerAction = {\n type: `NetworkController:getProviderAndBlockTracker`;\n handler: NetworkController['getProviderAndBlockTracker'];\n};\n\n/**\n * Accesses the provider and block tracker for the currently selected network.\n *\n * @returns an object with the provider and block tracker proxies for the currently selected network.\n */\nexport type NetworkControllerGetSelectedNetworkClientAction = {\n type: `NetworkController:getSelectedNetworkClient`;\n handler: NetworkController['getSelectedNetworkClient'];\n};\n\n/**\n * Accesses the chain ID from the selected network client.\n *\n * @returns The chain ID of the selected network client in hex format or undefined if there is no network client.\n */\nexport type NetworkControllerGetSelectedChainIdAction = {\n type: `NetworkController:getSelectedChainId`;\n handler: NetworkController['getSelectedChainId'];\n};\n\n/**\n * Internally, the Infura and custom network clients are categorized by type\n * so that when accessing either kind of network client, TypeScript knows\n * which type to assign to the network client. For some cases it's more useful\n * to be able to access network clients by ID instead of by type and then ID,\n * so this function makes that possible.\n *\n * @returns The network clients registered so far, keyed by ID.\n */\nexport type NetworkControllerGetNetworkClientRegistryAction = {\n type: `NetworkController:getNetworkClientRegistry`;\n handler: NetworkController['getNetworkClientRegistry'];\n};\n\n/**\n * Returns the Infura network client with the given ID.\n *\n * @param infuraNetworkClientId - An Infura network client ID.\n * @returns The Infura network client.\n * @throws If an Infura network client does not exist with the given ID.\n */\nexport type NetworkControllerGetNetworkClientByIdAction = {\n type: `NetworkController:getNetworkClientById`;\n handler: NetworkController['getNetworkClientById'];\n};\n\n/**\n * Creates proxies for accessing the global network client and its block\n * tracker. You must call this method in order to use\n * `getProviderAndBlockTracker` (or its replacement,\n * `getSelectedNetworkClient`).\n *\n * @param options - Optional arguments.\n * @param options.lookupNetwork - Usually, metadata for the global network\n * will be populated via a call to `lookupNetwork` after creating the provider\n * and block tracker proxies. This allows for responding to the status of the\n * global network after initializing this controller; however, it requires\n * making a request to the network to do so. In the clients, where controllers\n * are initialized before the UI is shown, this may be undesirable, as it\n * means that if the user has just installed MetaMask, their IP address may be\n * shared with a third party before they have a chance to finish onboarding.\n * You can pass `false` if you'd like to disable this request and call\n * `lookupNetwork` yourself.\n */\nexport type NetworkControllerInitializeProviderAction = {\n type: `NetworkController:initializeProvider`;\n handler: NetworkController['initializeProvider'];\n};\n\n/**\n * Uses a request for the latest block to gather the following information on\n * the given or selected network, persisting it to state:\n *\n * - The connectivity status: whether it is available, geo-blocked (Infura\n * only), unavailable, or unknown\n * - The capabilities status: whether it supports EIP-1559, whether it does\n * not, or whether it is unknown\n *\n * @param networkClientId - The ID of the network client to inspect.\n * If no ID is provided, uses the currently selected network.\n */\nexport type NetworkControllerLookupNetworkAction = {\n type: `NetworkController:lookupNetwork`;\n handler: NetworkController['lookupNetwork'];\n};\n\n/**\n * Uses a request for the latest block to gather the following information on\n * the given network, persisting it to state:\n *\n * - The connectivity status: whether the network is available, geo-blocked\n * (Infura only), unavailable, or unknown\n * - The feature compatibility status: whether the network supports EIP-1559,\n * whether it does not, or whether it is unknown\n *\n * @param networkClientId - The ID of the network client to inspect.\n * @deprecated Please use `lookupNetwork` and pass a network client ID\n * instead. This method will be removed in a future major version.\n */\nexport type NetworkControllerLookupNetworkByClientIdAction = {\n type: `NetworkController:lookupNetworkByClientId`;\n handler: NetworkController['lookupNetworkByClientId'];\n};\n\n/**\n * Convenience method to update provider network type settings.\n *\n * @param type - Human readable network name.\n * @deprecated This has been replaced by `setActiveNetwork`, and will be\n * removed in a future release\n */\nexport type NetworkControllerSetProviderTypeAction = {\n type: `NetworkController:setProviderType`;\n handler: NetworkController['setProviderType'];\n};\n\n/**\n * Changes the selected network.\n *\n * @param networkClientId - The ID of a network client that will be used to\n * make requests.\n * @param options - Options for this method.\n * @param options.updateState - Allows for updating state.\n * @throws if no network client is associated with the given\n * network client ID.\n */\nexport type NetworkControllerSetActiveNetworkAction = {\n type: `NetworkController:setActiveNetwork`;\n handler: NetworkController['setActiveNetwork'];\n};\n\n/**\n * Determines whether the network supports EIP-1559 by checking whether the\n * latest block has a `baseFeePerGas` property, then updates state\n * appropriately.\n *\n * @param networkClientId - The networkClientId to fetch the correct provider against which to check 1559 compatibility.\n * @returns A promise that resolves to true if the network supports EIP-1559\n * , false otherwise, or `undefined` if unable to determine the compatibility.\n */\nexport type NetworkControllerGetEIP1559CompatibilityAction = {\n type: `NetworkController:getEIP1559Compatibility`;\n handler: NetworkController['getEIP1559Compatibility'];\n};\n\nexport type NetworkControllerGet1559CompatibilityWithNetworkClientIdAction = {\n type: `NetworkController:get1559CompatibilityWithNetworkClientId`;\n handler: NetworkController['get1559CompatibilityWithNetworkClientId'];\n};\n\n/**\n * Ensures that the provider and block tracker proxies are pointed to the\n * currently selected network and refreshes the metadata for the\n */\nexport type NetworkControllerResetConnectionAction = {\n type: `NetworkController:resetConnection`;\n handler: NetworkController['resetConnection'];\n};\n\n/**\n * Returns the network configuration that has been filed under the given chain\n * ID.\n *\n * @param chainId - The chain ID to use as a key.\n * @returns The network configuration if one exists, or undefined.\n */\nexport type NetworkControllerGetNetworkConfigurationByChainIdAction = {\n type: `NetworkController:getNetworkConfigurationByChainId`;\n handler: NetworkController['getNetworkConfigurationByChainId'];\n};\n\n/**\n * Returns the network configuration that contains an RPC endpoint with the\n * given network client ID.\n *\n * @param networkClientId - The network client ID to use as a key.\n * @returns The network configuration if one exists, or undefined.\n */\nexport type NetworkControllerGetNetworkConfigurationByNetworkClientIdAction = {\n type: `NetworkController:getNetworkConfigurationByNetworkClientId`;\n handler: NetworkController['getNetworkConfigurationByNetworkClientId'];\n};\n\n/**\n * Creates and registers network clients for the collection of Infura and\n * custom RPC endpoints that can be used to make requests for a particular\n * chain, storing the given configuration object in state for later reference.\n *\n * @param fields - The object that describes the new network/chain and lists\n * the RPC endpoints which front that chain.\n * @returns The newly added network configuration.\n * @throws if any part of `fields` would produce invalid state.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerAddNetworkAction = {\n type: `NetworkController:addNetwork`;\n handler: NetworkController['addNetwork'];\n};\n\n/**\n * Updates the configuration for a previously stored network filed under the\n * given chain ID, creating + registering new network clients to represent RPC\n * endpoints that have been added and destroying + unregistering existing\n * network clients for RPC endpoints that have been removed.\n *\n * Note that if `chainId` is changed, then all network clients associated with\n * that chain will be removed and re-added, even if none of the RPC endpoints\n * have changed.\n *\n * @param chainId - The chain ID associated with an existing network.\n * @param fields - The object that describes the updates to the network/chain,\n * including the new set of RPC endpoints which should front that chain.\n * @param options - Options to provide.\n * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot\n * remove an RPC endpoint that is being represented by the currently selected\n * network client. This option allows you to specify another RPC endpoint\n * (either an existing one or a new one) that should be used to select a new\n * network instead.\n * @returns The updated network configuration.\n * @throws if `chainId` does not refer to an existing network configuration,\n * if any part of `fields` would produce invalid state, etc.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerUpdateNetworkAction = {\n type: `NetworkController:updateNetwork`;\n handler: NetworkController['updateNetwork'];\n};\n\n/**\n * Destroys and unregisters the network identified by the given chain ID, also\n * removing the associated network configuration from state.\n *\n * @param chainId - The chain ID associated with an existing network.\n * @throws if `chainId` does not refer to an existing network configuration,\n * or if the currently selected network is being removed.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerRemoveNetworkAction = {\n type: `NetworkController:removeNetwork`;\n handler: NetworkController['removeNetwork'];\n};\n\n/**\n * Assuming that the network has been previously switched, switches to this\n * new network.\n *\n * If the network has not been previously switched, this method is equivalent\n * to {@link resetConnection}.\n */\nexport type NetworkControllerRollbackToPreviousProviderAction = {\n type: `NetworkController:rollbackToPreviousProvider`;\n handler: NetworkController['rollbackToPreviousProvider'];\n};\n\n/**\n * Merges the given backup data into controller state.\n *\n * @param backup - The data that has been backed up.\n * @param backup.networkConfigurationsByChainId - Network configurations,\n * keyed by chain ID.\n */\nexport type NetworkControllerLoadBackupAction = {\n type: `NetworkController:loadBackup`;\n handler: NetworkController['loadBackup'];\n};\n\n/**\n * Searches for the default RPC endpoint configured for the given chain and\n * returns its network client ID. This can then be passed to\n * {@link getNetworkClientById} to retrieve the network client.\n *\n * @param chainId - Chain ID to search for.\n * @returns The ID of the network client created for the chain's default RPC\n * endpoint.\n */\nexport type NetworkControllerFindNetworkClientIdByChainIdAction = {\n type: `NetworkController:findNetworkClientIdByChainId`;\n handler: NetworkController['findNetworkClientIdByChainId'];\n};\n\n/**\n * Union of all NetworkController action types.\n */\nexport type NetworkControllerMethodActions =\n | NetworkControllerGetEthQueryAction\n | NetworkControllerEnableRpcFailoverAction\n | NetworkControllerDisableRpcFailoverAction\n | NetworkControllerGetProviderAndBlockTrackerAction\n | NetworkControllerGetSelectedNetworkClientAction\n | NetworkControllerGetSelectedChainIdAction\n | NetworkControllerGetNetworkClientRegistryAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerInitializeProviderAction\n | NetworkControllerLookupNetworkAction\n | NetworkControllerLookupNetworkByClientIdAction\n | NetworkControllerSetProviderTypeAction\n | NetworkControllerSetActiveNetworkAction\n | NetworkControllerGetEIP1559CompatibilityAction\n | NetworkControllerGet1559CompatibilityWithNetworkClientIdAction\n | NetworkControllerResetConnectionAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | NetworkControllerGetNetworkConfigurationByNetworkClientIdAction\n | NetworkControllerAddNetworkAction\n | NetworkControllerUpdateNetworkAction\n | NetworkControllerRemoveNetworkAction\n | NetworkControllerRollbackToPreviousProviderAction\n | NetworkControllerLoadBackupAction\n | NetworkControllerFindNetworkClientIdByChainIdAction;\n"]} |
| /** | ||
| * This file is auto generated. | ||
| * Do not edit manually. | ||
| */ | ||
| import type { NetworkController } from "./NetworkController.cjs"; | ||
| /** | ||
| * Returns the EthQuery instance for the currently selected network. | ||
| * | ||
| * @returns The EthQuery instance, or undefined if the provider has not been | ||
| * initialized. | ||
| */ | ||
| export type NetworkControllerGetEthQueryAction = { | ||
| type: `NetworkController:getEthQuery`; | ||
| handler: NetworkController['getEthQuery']; | ||
| }; | ||
| /** | ||
| * Enables the RPC failover functionality. That is, if any RPC endpoints are | ||
| * configured with failover URLs, then traffic will automatically be diverted | ||
| * to them if those RPC endpoints are unavailable. | ||
| */ | ||
| export type NetworkControllerEnableRpcFailoverAction = { | ||
| type: `NetworkController:enableRpcFailover`; | ||
| handler: NetworkController['enableRpcFailover']; | ||
| }; | ||
| /** | ||
| * Disables the RPC failover functionality. That is, even if any RPC endpoints | ||
| * are configured with failover URLs, then traffic will not automatically be | ||
| * diverted to them if those RPC endpoints are unavailable. | ||
| */ | ||
| export type NetworkControllerDisableRpcFailoverAction = { | ||
| type: `NetworkController:disableRpcFailover`; | ||
| handler: NetworkController['disableRpcFailover']; | ||
| }; | ||
| /** | ||
| * Accesses the provider and block tracker for the currently selected network. | ||
| * | ||
| * @returns The proxy and block tracker proxies. | ||
| * @deprecated This method has been replaced by `getSelectedNetworkClient` (which has a more easily used return type) and will be removed in a future release. | ||
| */ | ||
| export type NetworkControllerGetProviderAndBlockTrackerAction = { | ||
| type: `NetworkController:getProviderAndBlockTracker`; | ||
| handler: NetworkController['getProviderAndBlockTracker']; | ||
| }; | ||
| /** | ||
| * Accesses the provider and block tracker for the currently selected network. | ||
| * | ||
| * @returns an object with the provider and block tracker proxies for the currently selected network. | ||
| */ | ||
| export type NetworkControllerGetSelectedNetworkClientAction = { | ||
| type: `NetworkController:getSelectedNetworkClient`; | ||
| handler: NetworkController['getSelectedNetworkClient']; | ||
| }; | ||
| /** | ||
| * Accesses the chain ID from the selected network client. | ||
| * | ||
| * @returns The chain ID of the selected network client in hex format or undefined if there is no network client. | ||
| */ | ||
| export type NetworkControllerGetSelectedChainIdAction = { | ||
| type: `NetworkController:getSelectedChainId`; | ||
| handler: NetworkController['getSelectedChainId']; | ||
| }; | ||
| /** | ||
| * Internally, the Infura and custom network clients are categorized by type | ||
| * so that when accessing either kind of network client, TypeScript knows | ||
| * which type to assign to the network client. For some cases it's more useful | ||
| * to be able to access network clients by ID instead of by type and then ID, | ||
| * so this function makes that possible. | ||
| * | ||
| * @returns The network clients registered so far, keyed by ID. | ||
| */ | ||
| export type NetworkControllerGetNetworkClientRegistryAction = { | ||
| type: `NetworkController:getNetworkClientRegistry`; | ||
| handler: NetworkController['getNetworkClientRegistry']; | ||
| }; | ||
| /** | ||
| * Returns the Infura network client with the given ID. | ||
| * | ||
| * @param infuraNetworkClientId - An Infura network client ID. | ||
| * @returns The Infura network client. | ||
| * @throws If an Infura network client does not exist with the given ID. | ||
| */ | ||
| export type NetworkControllerGetNetworkClientByIdAction = { | ||
| type: `NetworkController:getNetworkClientById`; | ||
| handler: NetworkController['getNetworkClientById']; | ||
| }; | ||
| /** | ||
| * Creates proxies for accessing the global network client and its block | ||
| * tracker. You must call this method in order to use | ||
| * `getProviderAndBlockTracker` (or its replacement, | ||
| * `getSelectedNetworkClient`). | ||
| * | ||
| * @param options - Optional arguments. | ||
| * @param options.lookupNetwork - Usually, metadata for the global network | ||
| * will be populated via a call to `lookupNetwork` after creating the provider | ||
| * and block tracker proxies. This allows for responding to the status of the | ||
| * global network after initializing this controller; however, it requires | ||
| * making a request to the network to do so. In the clients, where controllers | ||
| * are initialized before the UI is shown, this may be undesirable, as it | ||
| * means that if the user has just installed MetaMask, their IP address may be | ||
| * shared with a third party before they have a chance to finish onboarding. | ||
| * You can pass `false` if you'd like to disable this request and call | ||
| * `lookupNetwork` yourself. | ||
| */ | ||
| export type NetworkControllerInitializeProviderAction = { | ||
| type: `NetworkController:initializeProvider`; | ||
| handler: NetworkController['initializeProvider']; | ||
| }; | ||
| /** | ||
| * Uses a request for the latest block to gather the following information on | ||
| * the given or selected network, persisting it to state: | ||
| * | ||
| * - The connectivity status: whether it is available, geo-blocked (Infura | ||
| * only), unavailable, or unknown | ||
| * - The capabilities status: whether it supports EIP-1559, whether it does | ||
| * not, or whether it is unknown | ||
| * | ||
| * @param networkClientId - The ID of the network client to inspect. | ||
| * If no ID is provided, uses the currently selected network. | ||
| */ | ||
| export type NetworkControllerLookupNetworkAction = { | ||
| type: `NetworkController:lookupNetwork`; | ||
| handler: NetworkController['lookupNetwork']; | ||
| }; | ||
| /** | ||
| * Uses a request for the latest block to gather the following information on | ||
| * the given network, persisting it to state: | ||
| * | ||
| * - The connectivity status: whether the network is available, geo-blocked | ||
| * (Infura only), unavailable, or unknown | ||
| * - The feature compatibility status: whether the network supports EIP-1559, | ||
| * whether it does not, or whether it is unknown | ||
| * | ||
| * @param networkClientId - The ID of the network client to inspect. | ||
| * @deprecated Please use `lookupNetwork` and pass a network client ID | ||
| * instead. This method will be removed in a future major version. | ||
| */ | ||
| export type NetworkControllerLookupNetworkByClientIdAction = { | ||
| type: `NetworkController:lookupNetworkByClientId`; | ||
| handler: NetworkController['lookupNetworkByClientId']; | ||
| }; | ||
| /** | ||
| * Convenience method to update provider network type settings. | ||
| * | ||
| * @param type - Human readable network name. | ||
| * @deprecated This has been replaced by `setActiveNetwork`, and will be | ||
| * removed in a future release | ||
| */ | ||
| export type NetworkControllerSetProviderTypeAction = { | ||
| type: `NetworkController:setProviderType`; | ||
| handler: NetworkController['setProviderType']; | ||
| }; | ||
| /** | ||
| * Changes the selected network. | ||
| * | ||
| * @param networkClientId - The ID of a network client that will be used to | ||
| * make requests. | ||
| * @param options - Options for this method. | ||
| * @param options.updateState - Allows for updating state. | ||
| * @throws if no network client is associated with the given | ||
| * network client ID. | ||
| */ | ||
| export type NetworkControllerSetActiveNetworkAction = { | ||
| type: `NetworkController:setActiveNetwork`; | ||
| handler: NetworkController['setActiveNetwork']; | ||
| }; | ||
| /** | ||
| * Determines whether the network supports EIP-1559 by checking whether the | ||
| * latest block has a `baseFeePerGas` property, then updates state | ||
| * appropriately. | ||
| * | ||
| * @param networkClientId - The networkClientId to fetch the correct provider against which to check 1559 compatibility. | ||
| * @returns A promise that resolves to true if the network supports EIP-1559 | ||
| * , false otherwise, or `undefined` if unable to determine the compatibility. | ||
| */ | ||
| export type NetworkControllerGetEIP1559CompatibilityAction = { | ||
| type: `NetworkController:getEIP1559Compatibility`; | ||
| handler: NetworkController['getEIP1559Compatibility']; | ||
| }; | ||
| export type NetworkControllerGet1559CompatibilityWithNetworkClientIdAction = { | ||
| type: `NetworkController:get1559CompatibilityWithNetworkClientId`; | ||
| handler: NetworkController['get1559CompatibilityWithNetworkClientId']; | ||
| }; | ||
| /** | ||
| * Ensures that the provider and block tracker proxies are pointed to the | ||
| * currently selected network and refreshes the metadata for the | ||
| */ | ||
| export type NetworkControllerResetConnectionAction = { | ||
| type: `NetworkController:resetConnection`; | ||
| handler: NetworkController['resetConnection']; | ||
| }; | ||
| /** | ||
| * Returns the network configuration that has been filed under the given chain | ||
| * ID. | ||
| * | ||
| * @param chainId - The chain ID to use as a key. | ||
| * @returns The network configuration if one exists, or undefined. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByChainIdAction = { | ||
| type: `NetworkController:getNetworkConfigurationByChainId`; | ||
| handler: NetworkController['getNetworkConfigurationByChainId']; | ||
| }; | ||
| /** | ||
| * Returns the network configuration that contains an RPC endpoint with the | ||
| * given network client ID. | ||
| * | ||
| * @param networkClientId - The network client ID to use as a key. | ||
| * @returns The network configuration if one exists, or undefined. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientIdAction = { | ||
| type: `NetworkController:getNetworkConfigurationByNetworkClientId`; | ||
| handler: NetworkController['getNetworkConfigurationByNetworkClientId']; | ||
| }; | ||
| /** | ||
| * Creates and registers network clients for the collection of Infura and | ||
| * custom RPC endpoints that can be used to make requests for a particular | ||
| * chain, storing the given configuration object in state for later reference. | ||
| * | ||
| * @param fields - The object that describes the new network/chain and lists | ||
| * the RPC endpoints which front that chain. | ||
| * @returns The newly added network configuration. | ||
| * @throws if any part of `fields` would produce invalid state. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerAddNetworkAction = { | ||
| type: `NetworkController:addNetwork`; | ||
| handler: NetworkController['addNetwork']; | ||
| }; | ||
| /** | ||
| * Updates the configuration for a previously stored network filed under the | ||
| * given chain ID, creating + registering new network clients to represent RPC | ||
| * endpoints that have been added and destroying + unregistering existing | ||
| * network clients for RPC endpoints that have been removed. | ||
| * | ||
| * Note that if `chainId` is changed, then all network clients associated with | ||
| * that chain will be removed and re-added, even if none of the RPC endpoints | ||
| * have changed. | ||
| * | ||
| * @param chainId - The chain ID associated with an existing network. | ||
| * @param fields - The object that describes the updates to the network/chain, | ||
| * including the new set of RPC endpoints which should front that chain. | ||
| * @param options - Options to provide. | ||
| * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot | ||
| * remove an RPC endpoint that is being represented by the currently selected | ||
| * network client. This option allows you to specify another RPC endpoint | ||
| * (either an existing one or a new one) that should be used to select a new | ||
| * network instead. | ||
| * @returns The updated network configuration. | ||
| * @throws if `chainId` does not refer to an existing network configuration, | ||
| * if any part of `fields` would produce invalid state, etc. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerUpdateNetworkAction = { | ||
| type: `NetworkController:updateNetwork`; | ||
| handler: NetworkController['updateNetwork']; | ||
| }; | ||
| /** | ||
| * Destroys and unregisters the network identified by the given chain ID, also | ||
| * removing the associated network configuration from state. | ||
| * | ||
| * @param chainId - The chain ID associated with an existing network. | ||
| * @throws if `chainId` does not refer to an existing network configuration, | ||
| * or if the currently selected network is being removed. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerRemoveNetworkAction = { | ||
| type: `NetworkController:removeNetwork`; | ||
| handler: NetworkController['removeNetwork']; | ||
| }; | ||
| /** | ||
| * Assuming that the network has been previously switched, switches to this | ||
| * new network. | ||
| * | ||
| * If the network has not been previously switched, this method is equivalent | ||
| * to {@link resetConnection}. | ||
| */ | ||
| export type NetworkControllerRollbackToPreviousProviderAction = { | ||
| type: `NetworkController:rollbackToPreviousProvider`; | ||
| handler: NetworkController['rollbackToPreviousProvider']; | ||
| }; | ||
| /** | ||
| * Merges the given backup data into controller state. | ||
| * | ||
| * @param backup - The data that has been backed up. | ||
| * @param backup.networkConfigurationsByChainId - Network configurations, | ||
| * keyed by chain ID. | ||
| */ | ||
| export type NetworkControllerLoadBackupAction = { | ||
| type: `NetworkController:loadBackup`; | ||
| handler: NetworkController['loadBackup']; | ||
| }; | ||
| /** | ||
| * Searches for the default RPC endpoint configured for the given chain and | ||
| * returns its network client ID. This can then be passed to | ||
| * {@link getNetworkClientById} to retrieve the network client. | ||
| * | ||
| * @param chainId - Chain ID to search for. | ||
| * @returns The ID of the network client created for the chain's default RPC | ||
| * endpoint. | ||
| */ | ||
| export type NetworkControllerFindNetworkClientIdByChainIdAction = { | ||
| type: `NetworkController:findNetworkClientIdByChainId`; | ||
| handler: NetworkController['findNetworkClientIdByChainId']; | ||
| }; | ||
| /** | ||
| * Union of all NetworkController action types. | ||
| */ | ||
| export type NetworkControllerMethodActions = NetworkControllerGetEthQueryAction | NetworkControllerEnableRpcFailoverAction | NetworkControllerDisableRpcFailoverAction | NetworkControllerGetProviderAndBlockTrackerAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetSelectedChainIdAction | NetworkControllerGetNetworkClientRegistryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerInitializeProviderAction | NetworkControllerLookupNetworkAction | NetworkControllerLookupNetworkByClientIdAction | NetworkControllerSetProviderTypeAction | NetworkControllerSetActiveNetworkAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerGet1559CompatibilityWithNetworkClientIdAction | NetworkControllerResetConnectionAction | NetworkControllerGetNetworkConfigurationByChainIdAction | NetworkControllerGetNetworkConfigurationByNetworkClientIdAction | NetworkControllerAddNetworkAction | NetworkControllerUpdateNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerRollbackToPreviousProviderAction | NetworkControllerLoadBackupAction | NetworkControllerFindNetworkClientIdByChainIdAction; | ||
| //# sourceMappingURL=NetworkController-method-action-types.d.cts.map |
| {"version":3,"file":"NetworkController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NetworkController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gCAA4B;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,CAA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CAAC"} |
| /** | ||
| * This file is auto generated. | ||
| * Do not edit manually. | ||
| */ | ||
| import type { NetworkController } from "./NetworkController.mjs"; | ||
| /** | ||
| * Returns the EthQuery instance for the currently selected network. | ||
| * | ||
| * @returns The EthQuery instance, or undefined if the provider has not been | ||
| * initialized. | ||
| */ | ||
| export type NetworkControllerGetEthQueryAction = { | ||
| type: `NetworkController:getEthQuery`; | ||
| handler: NetworkController['getEthQuery']; | ||
| }; | ||
| /** | ||
| * Enables the RPC failover functionality. That is, if any RPC endpoints are | ||
| * configured with failover URLs, then traffic will automatically be diverted | ||
| * to them if those RPC endpoints are unavailable. | ||
| */ | ||
| export type NetworkControllerEnableRpcFailoverAction = { | ||
| type: `NetworkController:enableRpcFailover`; | ||
| handler: NetworkController['enableRpcFailover']; | ||
| }; | ||
| /** | ||
| * Disables the RPC failover functionality. That is, even if any RPC endpoints | ||
| * are configured with failover URLs, then traffic will not automatically be | ||
| * diverted to them if those RPC endpoints are unavailable. | ||
| */ | ||
| export type NetworkControllerDisableRpcFailoverAction = { | ||
| type: `NetworkController:disableRpcFailover`; | ||
| handler: NetworkController['disableRpcFailover']; | ||
| }; | ||
| /** | ||
| * Accesses the provider and block tracker for the currently selected network. | ||
| * | ||
| * @returns The proxy and block tracker proxies. | ||
| * @deprecated This method has been replaced by `getSelectedNetworkClient` (which has a more easily used return type) and will be removed in a future release. | ||
| */ | ||
| export type NetworkControllerGetProviderAndBlockTrackerAction = { | ||
| type: `NetworkController:getProviderAndBlockTracker`; | ||
| handler: NetworkController['getProviderAndBlockTracker']; | ||
| }; | ||
| /** | ||
| * Accesses the provider and block tracker for the currently selected network. | ||
| * | ||
| * @returns an object with the provider and block tracker proxies for the currently selected network. | ||
| */ | ||
| export type NetworkControllerGetSelectedNetworkClientAction = { | ||
| type: `NetworkController:getSelectedNetworkClient`; | ||
| handler: NetworkController['getSelectedNetworkClient']; | ||
| }; | ||
| /** | ||
| * Accesses the chain ID from the selected network client. | ||
| * | ||
| * @returns The chain ID of the selected network client in hex format or undefined if there is no network client. | ||
| */ | ||
| export type NetworkControllerGetSelectedChainIdAction = { | ||
| type: `NetworkController:getSelectedChainId`; | ||
| handler: NetworkController['getSelectedChainId']; | ||
| }; | ||
| /** | ||
| * Internally, the Infura and custom network clients are categorized by type | ||
| * so that when accessing either kind of network client, TypeScript knows | ||
| * which type to assign to the network client. For some cases it's more useful | ||
| * to be able to access network clients by ID instead of by type and then ID, | ||
| * so this function makes that possible. | ||
| * | ||
| * @returns The network clients registered so far, keyed by ID. | ||
| */ | ||
| export type NetworkControllerGetNetworkClientRegistryAction = { | ||
| type: `NetworkController:getNetworkClientRegistry`; | ||
| handler: NetworkController['getNetworkClientRegistry']; | ||
| }; | ||
| /** | ||
| * Returns the Infura network client with the given ID. | ||
| * | ||
| * @param infuraNetworkClientId - An Infura network client ID. | ||
| * @returns The Infura network client. | ||
| * @throws If an Infura network client does not exist with the given ID. | ||
| */ | ||
| export type NetworkControllerGetNetworkClientByIdAction = { | ||
| type: `NetworkController:getNetworkClientById`; | ||
| handler: NetworkController['getNetworkClientById']; | ||
| }; | ||
| /** | ||
| * Creates proxies for accessing the global network client and its block | ||
| * tracker. You must call this method in order to use | ||
| * `getProviderAndBlockTracker` (or its replacement, | ||
| * `getSelectedNetworkClient`). | ||
| * | ||
| * @param options - Optional arguments. | ||
| * @param options.lookupNetwork - Usually, metadata for the global network | ||
| * will be populated via a call to `lookupNetwork` after creating the provider | ||
| * and block tracker proxies. This allows for responding to the status of the | ||
| * global network after initializing this controller; however, it requires | ||
| * making a request to the network to do so. In the clients, where controllers | ||
| * are initialized before the UI is shown, this may be undesirable, as it | ||
| * means that if the user has just installed MetaMask, their IP address may be | ||
| * shared with a third party before they have a chance to finish onboarding. | ||
| * You can pass `false` if you'd like to disable this request and call | ||
| * `lookupNetwork` yourself. | ||
| */ | ||
| export type NetworkControllerInitializeProviderAction = { | ||
| type: `NetworkController:initializeProvider`; | ||
| handler: NetworkController['initializeProvider']; | ||
| }; | ||
| /** | ||
| * Uses a request for the latest block to gather the following information on | ||
| * the given or selected network, persisting it to state: | ||
| * | ||
| * - The connectivity status: whether it is available, geo-blocked (Infura | ||
| * only), unavailable, or unknown | ||
| * - The capabilities status: whether it supports EIP-1559, whether it does | ||
| * not, or whether it is unknown | ||
| * | ||
| * @param networkClientId - The ID of the network client to inspect. | ||
| * If no ID is provided, uses the currently selected network. | ||
| */ | ||
| export type NetworkControllerLookupNetworkAction = { | ||
| type: `NetworkController:lookupNetwork`; | ||
| handler: NetworkController['lookupNetwork']; | ||
| }; | ||
| /** | ||
| * Uses a request for the latest block to gather the following information on | ||
| * the given network, persisting it to state: | ||
| * | ||
| * - The connectivity status: whether the network is available, geo-blocked | ||
| * (Infura only), unavailable, or unknown | ||
| * - The feature compatibility status: whether the network supports EIP-1559, | ||
| * whether it does not, or whether it is unknown | ||
| * | ||
| * @param networkClientId - The ID of the network client to inspect. | ||
| * @deprecated Please use `lookupNetwork` and pass a network client ID | ||
| * instead. This method will be removed in a future major version. | ||
| */ | ||
| export type NetworkControllerLookupNetworkByClientIdAction = { | ||
| type: `NetworkController:lookupNetworkByClientId`; | ||
| handler: NetworkController['lookupNetworkByClientId']; | ||
| }; | ||
| /** | ||
| * Convenience method to update provider network type settings. | ||
| * | ||
| * @param type - Human readable network name. | ||
| * @deprecated This has been replaced by `setActiveNetwork`, and will be | ||
| * removed in a future release | ||
| */ | ||
| export type NetworkControllerSetProviderTypeAction = { | ||
| type: `NetworkController:setProviderType`; | ||
| handler: NetworkController['setProviderType']; | ||
| }; | ||
| /** | ||
| * Changes the selected network. | ||
| * | ||
| * @param networkClientId - The ID of a network client that will be used to | ||
| * make requests. | ||
| * @param options - Options for this method. | ||
| * @param options.updateState - Allows for updating state. | ||
| * @throws if no network client is associated with the given | ||
| * network client ID. | ||
| */ | ||
| export type NetworkControllerSetActiveNetworkAction = { | ||
| type: `NetworkController:setActiveNetwork`; | ||
| handler: NetworkController['setActiveNetwork']; | ||
| }; | ||
| /** | ||
| * Determines whether the network supports EIP-1559 by checking whether the | ||
| * latest block has a `baseFeePerGas` property, then updates state | ||
| * appropriately. | ||
| * | ||
| * @param networkClientId - The networkClientId to fetch the correct provider against which to check 1559 compatibility. | ||
| * @returns A promise that resolves to true if the network supports EIP-1559 | ||
| * , false otherwise, or `undefined` if unable to determine the compatibility. | ||
| */ | ||
| export type NetworkControllerGetEIP1559CompatibilityAction = { | ||
| type: `NetworkController:getEIP1559Compatibility`; | ||
| handler: NetworkController['getEIP1559Compatibility']; | ||
| }; | ||
| export type NetworkControllerGet1559CompatibilityWithNetworkClientIdAction = { | ||
| type: `NetworkController:get1559CompatibilityWithNetworkClientId`; | ||
| handler: NetworkController['get1559CompatibilityWithNetworkClientId']; | ||
| }; | ||
| /** | ||
| * Ensures that the provider and block tracker proxies are pointed to the | ||
| * currently selected network and refreshes the metadata for the | ||
| */ | ||
| export type NetworkControllerResetConnectionAction = { | ||
| type: `NetworkController:resetConnection`; | ||
| handler: NetworkController['resetConnection']; | ||
| }; | ||
| /** | ||
| * Returns the network configuration that has been filed under the given chain | ||
| * ID. | ||
| * | ||
| * @param chainId - The chain ID to use as a key. | ||
| * @returns The network configuration if one exists, or undefined. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByChainIdAction = { | ||
| type: `NetworkController:getNetworkConfigurationByChainId`; | ||
| handler: NetworkController['getNetworkConfigurationByChainId']; | ||
| }; | ||
| /** | ||
| * Returns the network configuration that contains an RPC endpoint with the | ||
| * given network client ID. | ||
| * | ||
| * @param networkClientId - The network client ID to use as a key. | ||
| * @returns The network configuration if one exists, or undefined. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientIdAction = { | ||
| type: `NetworkController:getNetworkConfigurationByNetworkClientId`; | ||
| handler: NetworkController['getNetworkConfigurationByNetworkClientId']; | ||
| }; | ||
| /** | ||
| * Creates and registers network clients for the collection of Infura and | ||
| * custom RPC endpoints that can be used to make requests for a particular | ||
| * chain, storing the given configuration object in state for later reference. | ||
| * | ||
| * @param fields - The object that describes the new network/chain and lists | ||
| * the RPC endpoints which front that chain. | ||
| * @returns The newly added network configuration. | ||
| * @throws if any part of `fields` would produce invalid state. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerAddNetworkAction = { | ||
| type: `NetworkController:addNetwork`; | ||
| handler: NetworkController['addNetwork']; | ||
| }; | ||
| /** | ||
| * Updates the configuration for a previously stored network filed under the | ||
| * given chain ID, creating + registering new network clients to represent RPC | ||
| * endpoints that have been added and destroying + unregistering existing | ||
| * network clients for RPC endpoints that have been removed. | ||
| * | ||
| * Note that if `chainId` is changed, then all network clients associated with | ||
| * that chain will be removed and re-added, even if none of the RPC endpoints | ||
| * have changed. | ||
| * | ||
| * @param chainId - The chain ID associated with an existing network. | ||
| * @param fields - The object that describes the updates to the network/chain, | ||
| * including the new set of RPC endpoints which should front that chain. | ||
| * @param options - Options to provide. | ||
| * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot | ||
| * remove an RPC endpoint that is being represented by the currently selected | ||
| * network client. This option allows you to specify another RPC endpoint | ||
| * (either an existing one or a new one) that should be used to select a new | ||
| * network instead. | ||
| * @returns The updated network configuration. | ||
| * @throws if `chainId` does not refer to an existing network configuration, | ||
| * if any part of `fields` would produce invalid state, etc. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerUpdateNetworkAction = { | ||
| type: `NetworkController:updateNetwork`; | ||
| handler: NetworkController['updateNetwork']; | ||
| }; | ||
| /** | ||
| * Destroys and unregisters the network identified by the given chain ID, also | ||
| * removing the associated network configuration from state. | ||
| * | ||
| * @param chainId - The chain ID associated with an existing network. | ||
| * @throws if `chainId` does not refer to an existing network configuration, | ||
| * or if the currently selected network is being removed. | ||
| * @see {@link NetworkConfiguration} | ||
| */ | ||
| export type NetworkControllerRemoveNetworkAction = { | ||
| type: `NetworkController:removeNetwork`; | ||
| handler: NetworkController['removeNetwork']; | ||
| }; | ||
| /** | ||
| * Assuming that the network has been previously switched, switches to this | ||
| * new network. | ||
| * | ||
| * If the network has not been previously switched, this method is equivalent | ||
| * to {@link resetConnection}. | ||
| */ | ||
| export type NetworkControllerRollbackToPreviousProviderAction = { | ||
| type: `NetworkController:rollbackToPreviousProvider`; | ||
| handler: NetworkController['rollbackToPreviousProvider']; | ||
| }; | ||
| /** | ||
| * Merges the given backup data into controller state. | ||
| * | ||
| * @param backup - The data that has been backed up. | ||
| * @param backup.networkConfigurationsByChainId - Network configurations, | ||
| * keyed by chain ID. | ||
| */ | ||
| export type NetworkControllerLoadBackupAction = { | ||
| type: `NetworkController:loadBackup`; | ||
| handler: NetworkController['loadBackup']; | ||
| }; | ||
| /** | ||
| * Searches for the default RPC endpoint configured for the given chain and | ||
| * returns its network client ID. This can then be passed to | ||
| * {@link getNetworkClientById} to retrieve the network client. | ||
| * | ||
| * @param chainId - Chain ID to search for. | ||
| * @returns The ID of the network client created for the chain's default RPC | ||
| * endpoint. | ||
| */ | ||
| export type NetworkControllerFindNetworkClientIdByChainIdAction = { | ||
| type: `NetworkController:findNetworkClientIdByChainId`; | ||
| handler: NetworkController['findNetworkClientIdByChainId']; | ||
| }; | ||
| /** | ||
| * Union of all NetworkController action types. | ||
| */ | ||
| export type NetworkControllerMethodActions = NetworkControllerGetEthQueryAction | NetworkControllerEnableRpcFailoverAction | NetworkControllerDisableRpcFailoverAction | NetworkControllerGetProviderAndBlockTrackerAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetSelectedChainIdAction | NetworkControllerGetNetworkClientRegistryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerInitializeProviderAction | NetworkControllerLookupNetworkAction | NetworkControllerLookupNetworkByClientIdAction | NetworkControllerSetProviderTypeAction | NetworkControllerSetActiveNetworkAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerGet1559CompatibilityWithNetworkClientIdAction | NetworkControllerResetConnectionAction | NetworkControllerGetNetworkConfigurationByChainIdAction | NetworkControllerGetNetworkConfigurationByNetworkClientIdAction | NetworkControllerAddNetworkAction | NetworkControllerUpdateNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerRollbackToPreviousProviderAction | NetworkControllerLoadBackupAction | NetworkControllerFindNetworkClientIdByChainIdAction; | ||
| //# sourceMappingURL=NetworkController-method-action-types.d.mts.map |
| {"version":3,"file":"NetworkController-method-action-types.d.mts","sourceRoot":"","sources":["../src/NetworkController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,gCAA4B;AAE7D;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG;IAC/C,IAAI,EAAE,+BAA+B,CAAC;IACtC,OAAO,EAAE,iBAAiB,CAAC,aAAa,CAAC,CAAC;CAC3C,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,iBAAiB,CAAC,4BAA4B,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,+CAA+C,GAAG;IAC5D,IAAI,EAAE,4CAA4C,CAAC;IACnD,OAAO,EAAE,iBAAiB,CAAC,0BAA0B,CAAC,CAAC;CACxD,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;;G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8B,CAAC;IACrC,OAAO,EAAE,iBAAiB,CAAC,YAAY,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,mDAAmD,GAAG;IAChE,IAAI,EAAE,gDAAgD,CAAC;IACvD,OAAO,EAAE,iBAAiB,CAAC,8BAA8B,CAAC,CAAC;CAC5D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,8BAA8B,GACtC,kCAAkC,GAClC,wCAAwC,GACxC,yCAAyC,GACzC,iDAAiD,GACjD,+CAA+C,GAC/C,yCAAyC,GACzC,+CAA+C,GAC/C,2CAA2C,GAC3C,yCAAyC,GACzC,oCAAoC,GACpC,8CAA8C,GAC9C,sCAAsC,GACtC,uCAAuC,GACvC,8CAA8C,GAC9C,8DAA8D,GAC9D,sCAAsC,GACtC,uDAAuD,GACvD,+DAA+D,GAC/D,iCAAiC,GACjC,oCAAoC,GACpC,oCAAoC,GACpC,iDAAiD,GACjD,iCAAiC,GACjC,mDAAmD,CAAC"} |
| /** | ||
| * This file is auto generated. | ||
| * Do not edit manually. | ||
| */ | ||
| export {}; | ||
| //# sourceMappingURL=NetworkController-method-action-types.mjs.map |
| {"version":3,"file":"NetworkController-method-action-types.mjs","sourceRoot":"","sources":["../src/NetworkController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { NetworkController } from './NetworkController';\n\n/**\n * Returns the EthQuery instance for the currently selected network.\n *\n * @returns The EthQuery instance, or undefined if the provider has not been\n * initialized.\n */\nexport type NetworkControllerGetEthQueryAction = {\n type: `NetworkController:getEthQuery`;\n handler: NetworkController['getEthQuery'];\n};\n\n/**\n * Enables the RPC failover functionality. That is, if any RPC endpoints are\n * configured with failover URLs, then traffic will automatically be diverted\n * to them if those RPC endpoints are unavailable.\n */\nexport type NetworkControllerEnableRpcFailoverAction = {\n type: `NetworkController:enableRpcFailover`;\n handler: NetworkController['enableRpcFailover'];\n};\n\n/**\n * Disables the RPC failover functionality. That is, even if any RPC endpoints\n * are configured with failover URLs, then traffic will not automatically be\n * diverted to them if those RPC endpoints are unavailable.\n */\nexport type NetworkControllerDisableRpcFailoverAction = {\n type: `NetworkController:disableRpcFailover`;\n handler: NetworkController['disableRpcFailover'];\n};\n\n/**\n * Accesses the provider and block tracker for the currently selected network.\n *\n * @returns The proxy and block tracker proxies.\n * @deprecated This method has been replaced by `getSelectedNetworkClient` (which has a more easily used return type) and will be removed in a future release.\n */\nexport type NetworkControllerGetProviderAndBlockTrackerAction = {\n type: `NetworkController:getProviderAndBlockTracker`;\n handler: NetworkController['getProviderAndBlockTracker'];\n};\n\n/**\n * Accesses the provider and block tracker for the currently selected network.\n *\n * @returns an object with the provider and block tracker proxies for the currently selected network.\n */\nexport type NetworkControllerGetSelectedNetworkClientAction = {\n type: `NetworkController:getSelectedNetworkClient`;\n handler: NetworkController['getSelectedNetworkClient'];\n};\n\n/**\n * Accesses the chain ID from the selected network client.\n *\n * @returns The chain ID of the selected network client in hex format or undefined if there is no network client.\n */\nexport type NetworkControllerGetSelectedChainIdAction = {\n type: `NetworkController:getSelectedChainId`;\n handler: NetworkController['getSelectedChainId'];\n};\n\n/**\n * Internally, the Infura and custom network clients are categorized by type\n * so that when accessing either kind of network client, TypeScript knows\n * which type to assign to the network client. For some cases it's more useful\n * to be able to access network clients by ID instead of by type and then ID,\n * so this function makes that possible.\n *\n * @returns The network clients registered so far, keyed by ID.\n */\nexport type NetworkControllerGetNetworkClientRegistryAction = {\n type: `NetworkController:getNetworkClientRegistry`;\n handler: NetworkController['getNetworkClientRegistry'];\n};\n\n/**\n * Returns the Infura network client with the given ID.\n *\n * @param infuraNetworkClientId - An Infura network client ID.\n * @returns The Infura network client.\n * @throws If an Infura network client does not exist with the given ID.\n */\nexport type NetworkControllerGetNetworkClientByIdAction = {\n type: `NetworkController:getNetworkClientById`;\n handler: NetworkController['getNetworkClientById'];\n};\n\n/**\n * Creates proxies for accessing the global network client and its block\n * tracker. You must call this method in order to use\n * `getProviderAndBlockTracker` (or its replacement,\n * `getSelectedNetworkClient`).\n *\n * @param options - Optional arguments.\n * @param options.lookupNetwork - Usually, metadata for the global network\n * will be populated via a call to `lookupNetwork` after creating the provider\n * and block tracker proxies. This allows for responding to the status of the\n * global network after initializing this controller; however, it requires\n * making a request to the network to do so. In the clients, where controllers\n * are initialized before the UI is shown, this may be undesirable, as it\n * means that if the user has just installed MetaMask, their IP address may be\n * shared with a third party before they have a chance to finish onboarding.\n * You can pass `false` if you'd like to disable this request and call\n * `lookupNetwork` yourself.\n */\nexport type NetworkControllerInitializeProviderAction = {\n type: `NetworkController:initializeProvider`;\n handler: NetworkController['initializeProvider'];\n};\n\n/**\n * Uses a request for the latest block to gather the following information on\n * the given or selected network, persisting it to state:\n *\n * - The connectivity status: whether it is available, geo-blocked (Infura\n * only), unavailable, or unknown\n * - The capabilities status: whether it supports EIP-1559, whether it does\n * not, or whether it is unknown\n *\n * @param networkClientId - The ID of the network client to inspect.\n * If no ID is provided, uses the currently selected network.\n */\nexport type NetworkControllerLookupNetworkAction = {\n type: `NetworkController:lookupNetwork`;\n handler: NetworkController['lookupNetwork'];\n};\n\n/**\n * Uses a request for the latest block to gather the following information on\n * the given network, persisting it to state:\n *\n * - The connectivity status: whether the network is available, geo-blocked\n * (Infura only), unavailable, or unknown\n * - The feature compatibility status: whether the network supports EIP-1559,\n * whether it does not, or whether it is unknown\n *\n * @param networkClientId - The ID of the network client to inspect.\n * @deprecated Please use `lookupNetwork` and pass a network client ID\n * instead. This method will be removed in a future major version.\n */\nexport type NetworkControllerLookupNetworkByClientIdAction = {\n type: `NetworkController:lookupNetworkByClientId`;\n handler: NetworkController['lookupNetworkByClientId'];\n};\n\n/**\n * Convenience method to update provider network type settings.\n *\n * @param type - Human readable network name.\n * @deprecated This has been replaced by `setActiveNetwork`, and will be\n * removed in a future release\n */\nexport type NetworkControllerSetProviderTypeAction = {\n type: `NetworkController:setProviderType`;\n handler: NetworkController['setProviderType'];\n};\n\n/**\n * Changes the selected network.\n *\n * @param networkClientId - The ID of a network client that will be used to\n * make requests.\n * @param options - Options for this method.\n * @param options.updateState - Allows for updating state.\n * @throws if no network client is associated with the given\n * network client ID.\n */\nexport type NetworkControllerSetActiveNetworkAction = {\n type: `NetworkController:setActiveNetwork`;\n handler: NetworkController['setActiveNetwork'];\n};\n\n/**\n * Determines whether the network supports EIP-1559 by checking whether the\n * latest block has a `baseFeePerGas` property, then updates state\n * appropriately.\n *\n * @param networkClientId - The networkClientId to fetch the correct provider against which to check 1559 compatibility.\n * @returns A promise that resolves to true if the network supports EIP-1559\n * , false otherwise, or `undefined` if unable to determine the compatibility.\n */\nexport type NetworkControllerGetEIP1559CompatibilityAction = {\n type: `NetworkController:getEIP1559Compatibility`;\n handler: NetworkController['getEIP1559Compatibility'];\n};\n\nexport type NetworkControllerGet1559CompatibilityWithNetworkClientIdAction = {\n type: `NetworkController:get1559CompatibilityWithNetworkClientId`;\n handler: NetworkController['get1559CompatibilityWithNetworkClientId'];\n};\n\n/**\n * Ensures that the provider and block tracker proxies are pointed to the\n * currently selected network and refreshes the metadata for the\n */\nexport type NetworkControllerResetConnectionAction = {\n type: `NetworkController:resetConnection`;\n handler: NetworkController['resetConnection'];\n};\n\n/**\n * Returns the network configuration that has been filed under the given chain\n * ID.\n *\n * @param chainId - The chain ID to use as a key.\n * @returns The network configuration if one exists, or undefined.\n */\nexport type NetworkControllerGetNetworkConfigurationByChainIdAction = {\n type: `NetworkController:getNetworkConfigurationByChainId`;\n handler: NetworkController['getNetworkConfigurationByChainId'];\n};\n\n/**\n * Returns the network configuration that contains an RPC endpoint with the\n * given network client ID.\n *\n * @param networkClientId - The network client ID to use as a key.\n * @returns The network configuration if one exists, or undefined.\n */\nexport type NetworkControllerGetNetworkConfigurationByNetworkClientIdAction = {\n type: `NetworkController:getNetworkConfigurationByNetworkClientId`;\n handler: NetworkController['getNetworkConfigurationByNetworkClientId'];\n};\n\n/**\n * Creates and registers network clients for the collection of Infura and\n * custom RPC endpoints that can be used to make requests for a particular\n * chain, storing the given configuration object in state for later reference.\n *\n * @param fields - The object that describes the new network/chain and lists\n * the RPC endpoints which front that chain.\n * @returns The newly added network configuration.\n * @throws if any part of `fields` would produce invalid state.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerAddNetworkAction = {\n type: `NetworkController:addNetwork`;\n handler: NetworkController['addNetwork'];\n};\n\n/**\n * Updates the configuration for a previously stored network filed under the\n * given chain ID, creating + registering new network clients to represent RPC\n * endpoints that have been added and destroying + unregistering existing\n * network clients for RPC endpoints that have been removed.\n *\n * Note that if `chainId` is changed, then all network clients associated with\n * that chain will be removed and re-added, even if none of the RPC endpoints\n * have changed.\n *\n * @param chainId - The chain ID associated with an existing network.\n * @param fields - The object that describes the updates to the network/chain,\n * including the new set of RPC endpoints which should front that chain.\n * @param options - Options to provide.\n * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot\n * remove an RPC endpoint that is being represented by the currently selected\n * network client. This option allows you to specify another RPC endpoint\n * (either an existing one or a new one) that should be used to select a new\n * network instead.\n * @returns The updated network configuration.\n * @throws if `chainId` does not refer to an existing network configuration,\n * if any part of `fields` would produce invalid state, etc.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerUpdateNetworkAction = {\n type: `NetworkController:updateNetwork`;\n handler: NetworkController['updateNetwork'];\n};\n\n/**\n * Destroys and unregisters the network identified by the given chain ID, also\n * removing the associated network configuration from state.\n *\n * @param chainId - The chain ID associated with an existing network.\n * @throws if `chainId` does not refer to an existing network configuration,\n * or if the currently selected network is being removed.\n * @see {@link NetworkConfiguration}\n */\nexport type NetworkControllerRemoveNetworkAction = {\n type: `NetworkController:removeNetwork`;\n handler: NetworkController['removeNetwork'];\n};\n\n/**\n * Assuming that the network has been previously switched, switches to this\n * new network.\n *\n * If the network has not been previously switched, this method is equivalent\n * to {@link resetConnection}.\n */\nexport type NetworkControllerRollbackToPreviousProviderAction = {\n type: `NetworkController:rollbackToPreviousProvider`;\n handler: NetworkController['rollbackToPreviousProvider'];\n};\n\n/**\n * Merges the given backup data into controller state.\n *\n * @param backup - The data that has been backed up.\n * @param backup.networkConfigurationsByChainId - Network configurations,\n * keyed by chain ID.\n */\nexport type NetworkControllerLoadBackupAction = {\n type: `NetworkController:loadBackup`;\n handler: NetworkController['loadBackup'];\n};\n\n/**\n * Searches for the default RPC endpoint configured for the given chain and\n * returns its network client ID. This can then be passed to\n * {@link getNetworkClientById} to retrieve the network client.\n *\n * @param chainId - Chain ID to search for.\n * @returns The ID of the network client created for the chain's default RPC\n * endpoint.\n */\nexport type NetworkControllerFindNetworkClientIdByChainIdAction = {\n type: `NetworkController:findNetworkClientIdByChainId`;\n handler: NetworkController['findNetworkClientIdByChainId'];\n};\n\n/**\n * Union of all NetworkController action types.\n */\nexport type NetworkControllerMethodActions =\n | NetworkControllerGetEthQueryAction\n | NetworkControllerEnableRpcFailoverAction\n | NetworkControllerDisableRpcFailoverAction\n | NetworkControllerGetProviderAndBlockTrackerAction\n | NetworkControllerGetSelectedNetworkClientAction\n | NetworkControllerGetSelectedChainIdAction\n | NetworkControllerGetNetworkClientRegistryAction\n | NetworkControllerGetNetworkClientByIdAction\n | NetworkControllerInitializeProviderAction\n | NetworkControllerLookupNetworkAction\n | NetworkControllerLookupNetworkByClientIdAction\n | NetworkControllerSetProviderTypeAction\n | NetworkControllerSetActiveNetworkAction\n | NetworkControllerGetEIP1559CompatibilityAction\n | NetworkControllerGet1559CompatibilityWithNetworkClientIdAction\n | NetworkControllerResetConnectionAction\n | NetworkControllerGetNetworkConfigurationByChainIdAction\n | NetworkControllerGetNetworkConfigurationByNetworkClientIdAction\n | NetworkControllerAddNetworkAction\n | NetworkControllerUpdateNetworkAction\n | NetworkControllerRemoveNetworkAction\n | NetworkControllerRollbackToPreviousProviderAction\n | NetworkControllerLoadBackupAction\n | NetworkControllerFindNetworkClientIdByChainIdAction;\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA6CA,6DAM6B;AAL3B,qIAAA,gCAAgC,OAAA;AAChC,oIAAA,+BAA+B,OAAA;AAC/B,gHAAA,WAAW,OAAA;AACX,sHAAA,iBAAiB,OAAA;AACjB,oHAAA,eAAe,OAAA;AAEjB,kDAA4B;AAO5B,qCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAK1B,qEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,6DAA8D;AAArD,gHAAA,iBAAiB,OAAA","sourcesContent":["export type { AutoManagedNetworkClient } from './create-auto-managed-network-client';\nexport type {\n Block,\n NetworkMetadata,\n NetworkConfiguration,\n BuiltInNetworkClientId,\n CustomNetworkClientId,\n NetworkClientId,\n NetworksMetadata,\n NetworkState,\n BlockTrackerProxy,\n ProviderProxy,\n AddNetworkFields,\n UpdateNetworkFields,\n NetworkControllerStateChangeEvent,\n NetworkControllerNetworkWillChangeEvent,\n NetworkControllerNetworkDidChangeEvent,\n NetworkControllerInfuraIsBlockedEvent,\n NetworkControllerInfuraIsUnblockedEvent,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerEvents,\n NetworkControllerGetStateAction,\n NetworkControllerGetEthQueryAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetSelectedNetworkClientAction,\n NetworkControllerGetSelectedChainIdAction,\n NetworkControllerGetEIP1559CompatibilityAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerSetProviderTypeAction,\n NetworkControllerSetActiveNetworkAction,\n NetworkControllerAddNetworkAction,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientId,\n NetworkControllerActions,\n NetworkControllerMessenger,\n NetworkControllerOptions,\n NetworkControllerRpcEndpointChainUnavailableEvent,\n NetworkControllerRpcEndpointUnavailableEvent,\n NetworkControllerRpcEndpointChainDegradedEvent,\n NetworkControllerRpcEndpointDegradedEvent,\n NetworkControllerRpcEndpointChainAvailableEvent,\n NetworkControllerRpcEndpointRetriedEvent,\n} from './NetworkController';\nexport {\n getDefaultNetworkControllerState,\n selectAvailableNetworkClientIds,\n knownKeysOf,\n NetworkController,\n RpcEndpointType,\n} from './NetworkController';\nexport * from './constants';\nexport type { BlockTracker, Provider } from './types';\nexport type {\n NetworkClientConfiguration,\n InfuraNetworkClientConfiguration,\n CustomNetworkClientConfiguration,\n} from './types';\nexport { NetworkClientType } from './types';\nexport type { NetworkClient } from './create-network-client';\nexport type { AbstractRpcService } from './rpc-service/abstract-rpc-service';\nexport type { RpcServiceRequestable } from './rpc-service/rpc-service-requestable';\nexport type { DegradedEventType, RetryReason } from './create-network-client';\nexport { classifyRetryReason } from './create-network-client';\nexport { isConnectionError } from './rpc-service/rpc-service';\n"]} | ||
| {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAkCA,6DAM6B;AAL3B,qIAAA,gCAAgC,OAAA;AAChC,oIAAA,+BAA+B,OAAA;AAC/B,gHAAA,WAAW,OAAA;AACX,sHAAA,iBAAiB,OAAA;AACjB,oHAAA,eAAe,OAAA;AAEjB,kDAA4B;AAO5B,qCAA4C;AAAnC,0GAAA,iBAAiB,OAAA;AAK1B,qEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,6DAA8D;AAArD,gHAAA,iBAAiB,OAAA","sourcesContent":["export type { AutoManagedNetworkClient } from './create-auto-managed-network-client';\nexport type {\n Block,\n NetworkMetadata,\n NetworkConfiguration,\n BuiltInNetworkClientId,\n CustomNetworkClientId,\n NetworkClientId,\n NetworksMetadata,\n NetworkState,\n BlockTrackerProxy,\n ProviderProxy,\n AddNetworkFields,\n UpdateNetworkFields,\n NetworkControllerStateChangeEvent,\n NetworkControllerNetworkWillChangeEvent,\n NetworkControllerNetworkDidChangeEvent,\n NetworkControllerInfuraIsBlockedEvent,\n NetworkControllerInfuraIsUnblockedEvent,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerEvents,\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientId,\n NetworkControllerActions,\n NetworkControllerMessenger,\n NetworkControllerOptions,\n NetworkControllerRpcEndpointChainUnavailableEvent,\n NetworkControllerRpcEndpointUnavailableEvent,\n NetworkControllerRpcEndpointChainDegradedEvent,\n NetworkControllerRpcEndpointDegradedEvent,\n NetworkControllerRpcEndpointChainAvailableEvent,\n NetworkControllerRpcEndpointRetriedEvent,\n} from './NetworkController';\nexport {\n getDefaultNetworkControllerState,\n selectAvailableNetworkClientIds,\n knownKeysOf,\n NetworkController,\n RpcEndpointType,\n} from './NetworkController';\nexport * from './constants';\nexport type { BlockTracker, Provider } from './types';\nexport type {\n NetworkClientConfiguration,\n InfuraNetworkClientConfiguration,\n CustomNetworkClientConfiguration,\n} from './types';\nexport { NetworkClientType } from './types';\nexport type { NetworkClient } from './create-network-client';\nexport type { AbstractRpcService } from './rpc-service/abstract-rpc-service';\nexport type { RpcServiceRequestable } from './rpc-service/rpc-service-requestable';\nexport type { DegradedEventType, RetryReason } from './create-network-client';\nexport { classifyRetryReason } from './create-network-client';\nexport { isConnectionError } from './rpc-service/rpc-service';\nexport type {\n NetworkControllerGetEthQueryAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetSelectedNetworkClientAction,\n NetworkControllerGetSelectedChainIdAction,\n NetworkControllerGetEIP1559CompatibilityAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerSetProviderTypeAction,\n NetworkControllerSetActiveNetworkAction,\n NetworkControllerGetNetworkConfigurationByChainIdAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientIdAction,\n NetworkControllerAddNetworkAction,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n NetworkControllerEnableRpcFailoverAction,\n NetworkControllerDisableRpcFailoverAction,\n NetworkControllerGetProviderAndBlockTrackerAction,\n NetworkControllerGetNetworkClientRegistryAction,\n NetworkControllerInitializeProviderAction,\n NetworkControllerLookupNetworkAction,\n NetworkControllerLookupNetworkByClientIdAction,\n NetworkControllerGet1559CompatibilityWithNetworkClientIdAction,\n NetworkControllerResetConnectionAction,\n NetworkControllerRollbackToPreviousProviderAction,\n NetworkControllerLoadBackupAction,\n} from './NetworkController-method-action-types';\n"]} |
+2
-1
| export type { AutoManagedNetworkClient } from "./create-auto-managed-network-client.cjs"; | ||
| export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, AddNetworkFields, UpdateNetworkFields, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerNetworkAddedEvent, NetworkControllerNetworkRemovedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetSelectedChainIdAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerAddNetworkAction, NetworkControllerRemoveNetworkAction, NetworkControllerUpdateNetworkAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, NetworkControllerRpcEndpointChainUnavailableEvent, NetworkControllerRpcEndpointUnavailableEvent, NetworkControllerRpcEndpointChainDegradedEvent, NetworkControllerRpcEndpointDegradedEvent, NetworkControllerRpcEndpointChainAvailableEvent, NetworkControllerRpcEndpointRetriedEvent, } from "./NetworkController.cjs"; | ||
| export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, AddNetworkFields, UpdateNetworkFields, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerNetworkAddedEvent, NetworkControllerNetworkRemovedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, NetworkControllerRpcEndpointChainUnavailableEvent, NetworkControllerRpcEndpointUnavailableEvent, NetworkControllerRpcEndpointChainDegradedEvent, NetworkControllerRpcEndpointDegradedEvent, NetworkControllerRpcEndpointChainAvailableEvent, NetworkControllerRpcEndpointRetriedEvent, } from "./NetworkController.cjs"; | ||
| export { getDefaultNetworkControllerState, selectAvailableNetworkClientIds, knownKeysOf, NetworkController, RpcEndpointType, } from "./NetworkController.cjs"; | ||
@@ -14,2 +14,3 @@ export * from "./constants.cjs"; | ||
| export { isConnectionError } from "./rpc-service/rpc-service.cjs"; | ||
| export type { NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetSelectedChainIdAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerGetNetworkConfigurationByChainIdAction, NetworkControllerGetNetworkConfigurationByNetworkClientIdAction, NetworkControllerAddNetworkAction, NetworkControllerRemoveNetworkAction, NetworkControllerUpdateNetworkAction, NetworkControllerEnableRpcFailoverAction, NetworkControllerDisableRpcFailoverAction, NetworkControllerGetProviderAndBlockTrackerAction, NetworkControllerGetNetworkClientRegistryAction, NetworkControllerInitializeProviderAction, NetworkControllerLookupNetworkAction, NetworkControllerLookupNetworkByClientIdAction, NetworkControllerGet1559CompatibilityWithNetworkClientIdAction, NetworkControllerResetConnectionAction, NetworkControllerRollbackToPreviousProviderAction, NetworkControllerLoadBackupAction, } from "./NetworkController-method-action-types.cjs"; | ||
| //# sourceMappingURL=index.d.cts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,iDAA6C;AACrF,YAAY,EACV,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,qCAAqC,EACrC,uCAAuC,EACvC,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,EACvB,+BAA+B,EAC/B,kCAAkC,EAClC,2CAA2C,EAC3C,+CAA+C,EAC/C,yCAAyC,EACzC,8CAA8C,EAC9C,mDAAmD,EACnD,sCAAsC,EACtC,uCAAuC,EACvC,iCAAiC,EACjC,oCAAoC,EACpC,oCAAoC,EACpC,yDAAyD,EACzD,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,iDAAiD,EACjD,4CAA4C,EAC5C,8CAA8C,EAC9C,yCAAyC,EACzC,+CAA+C,EAC/C,wCAAwC,GACzC,gCAA4B;AAC7B,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,gCAA4B;AAC7B,gCAA4B;AAC5B,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAgB;AACtD,YAAY,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,GACjC,oBAAgB;AACjB,OAAO,EAAE,iBAAiB,EAAE,oBAAgB;AAC5C,YAAY,EAAE,aAAa,EAAE,oCAAgC;AAC7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AgC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,oCAAgC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,sCAAkC;AAC9D,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,+CAA+C,EAC/C,yCAAyC,EACzC,8CAA8C,EAC9C,mDAAmD,EACnD,sCAAsC,EACtC,uCAAuC,EACvC,uDAAuD,EACvD,+DAA+D,EAC/D,iCAAiC,EACjC,oCAAoC,EACpC,oCAAoC,EACpC,wCAAwC,EACxC,yCAAyC,EACzC,iDAAiD,EACjD,+CAA+C,EAC/C,yCAAyC,EACzC,oCAAoC,EACpC,8CAA8C,EAC9C,8DAA8D,EAC9D,sCAAsC,EACtC,iDAAiD,EACjD,iCAAiC,GAClC,oDAAgD"} |
+2
-1
| export type { AutoManagedNetworkClient } from "./create-auto-managed-network-client.mjs"; | ||
| export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, AddNetworkFields, UpdateNetworkFields, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerNetworkAddedEvent, NetworkControllerNetworkRemovedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetSelectedChainIdAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerAddNetworkAction, NetworkControllerRemoveNetworkAction, NetworkControllerUpdateNetworkAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, NetworkControllerRpcEndpointChainUnavailableEvent, NetworkControllerRpcEndpointUnavailableEvent, NetworkControllerRpcEndpointChainDegradedEvent, NetworkControllerRpcEndpointDegradedEvent, NetworkControllerRpcEndpointChainAvailableEvent, NetworkControllerRpcEndpointRetriedEvent, } from "./NetworkController.mjs"; | ||
| export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, AddNetworkFields, UpdateNetworkFields, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerNetworkAddedEvent, NetworkControllerNetworkRemovedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, NetworkControllerRpcEndpointChainUnavailableEvent, NetworkControllerRpcEndpointUnavailableEvent, NetworkControllerRpcEndpointChainDegradedEvent, NetworkControllerRpcEndpointDegradedEvent, NetworkControllerRpcEndpointChainAvailableEvent, NetworkControllerRpcEndpointRetriedEvent, } from "./NetworkController.mjs"; | ||
| export { getDefaultNetworkControllerState, selectAvailableNetworkClientIds, knownKeysOf, NetworkController, RpcEndpointType, } from "./NetworkController.mjs"; | ||
@@ -14,2 +14,3 @@ export * from "./constants.mjs"; | ||
| export { isConnectionError } from "./rpc-service/rpc-service.mjs"; | ||
| export type { NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetSelectedChainIdAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerGetNetworkConfigurationByChainIdAction, NetworkControllerGetNetworkConfigurationByNetworkClientIdAction, NetworkControllerAddNetworkAction, NetworkControllerRemoveNetworkAction, NetworkControllerUpdateNetworkAction, NetworkControllerEnableRpcFailoverAction, NetworkControllerDisableRpcFailoverAction, NetworkControllerGetProviderAndBlockTrackerAction, NetworkControllerGetNetworkClientRegistryAction, NetworkControllerInitializeProviderAction, NetworkControllerLookupNetworkAction, NetworkControllerLookupNetworkByClientIdAction, NetworkControllerGet1559CompatibilityWithNetworkClientIdAction, NetworkControllerResetConnectionAction, NetworkControllerRollbackToPreviousProviderAction, NetworkControllerLoadBackupAction, } from "./NetworkController-method-action-types.mjs"; | ||
| //# sourceMappingURL=index.d.mts.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,iDAA6C;AACrF,YAAY,EACV,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,mBAAmB,EACnB,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,qCAAqC,EACrC,uCAAuC,EACvC,kCAAkC,EAClC,oCAAoC,EACpC,uBAAuB,EACvB,+BAA+B,EAC/B,kCAAkC,EAClC,2CAA2C,EAC3C,+CAA+C,EAC/C,yCAAyC,EACzC,8CAA8C,EAC9C,mDAAmD,EACnD,sCAAsC,EACtC,uCAAuC,EACvC,iCAAiC,EACjC,oCAAoC,EACpC,oCAAoC,EACpC,yDAAyD,EACzD,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,EACxB,iDAAiD,EACjD,4CAA4C,EAC5C,8CAA8C,EAC9C,yCAAyC,EACzC,+CAA+C,EAC/C,wCAAwC,GACzC,gCAA4B;AAC7B,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,gCAA4B;AAC7B,gCAA4B;AAC5B,YAAY,EAAE,YAAY,EAA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BAAgB;AAC5C,YAAY,EAAE,aAAa,EAAE,oCAAgC;AAC7D,YAAY,EAAE,kBAAkB,EAAE,+CAA2C;AAC7E,YAAY,EAAE,qBAAqB,EAAE,kDAA8C;AACnF,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,oCAAgC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,oCAAgC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,sCAAkC;AAC9D,YAAY,EACV,kCAAkC,EAClC,2CAA2C,EAC3C,+CAA+C,EAC/C,yCAAyC,EACzC,8CAA8C,EAC9C,mDAAmD,EACnD,sCAAsC,EACtC,uCAAuC,EACvC,uDAAuD,EACvD,+DAA+D,EAC/D,iCAAiC,EACjC,oCAAoC,EACpC,oCAAoC,EACpC,wCAAwC,EACxC,yCAAyC,EACzC,iDAAiD,EACjD,+CAA+C,EAC/C,yCAAyC,EACzC,oCAAoC,EACpC,8CAA8C,EAC9C,8DAA8D,EAC9D,sCAAsC,EACtC,iDAAiD,EACjD,iCAAiC,GAClC,oDAAgD"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6CA,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,WAAW,EACX,iBAAiB,EACjB,eAAe,EAChB,gCAA4B;AAC7B,gCAA4B;AAO5B,OAAO,EAAE,iBAAiB,EAAE,oBAAgB;AAK5C,OAAO,EAAE,mBAAmB,EAAE,oCAAgC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,sCAAkC","sourcesContent":["export type { AutoManagedNetworkClient } from './create-auto-managed-network-client';\nexport type {\n Block,\n NetworkMetadata,\n NetworkConfiguration,\n BuiltInNetworkClientId,\n CustomNetworkClientId,\n NetworkClientId,\n NetworksMetadata,\n NetworkState,\n BlockTrackerProxy,\n ProviderProxy,\n AddNetworkFields,\n UpdateNetworkFields,\n NetworkControllerStateChangeEvent,\n NetworkControllerNetworkWillChangeEvent,\n NetworkControllerNetworkDidChangeEvent,\n NetworkControllerInfuraIsBlockedEvent,\n NetworkControllerInfuraIsUnblockedEvent,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerEvents,\n NetworkControllerGetStateAction,\n NetworkControllerGetEthQueryAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetSelectedNetworkClientAction,\n NetworkControllerGetSelectedChainIdAction,\n NetworkControllerGetEIP1559CompatibilityAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerSetProviderTypeAction,\n NetworkControllerSetActiveNetworkAction,\n NetworkControllerAddNetworkAction,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientId,\n NetworkControllerActions,\n NetworkControllerMessenger,\n NetworkControllerOptions,\n NetworkControllerRpcEndpointChainUnavailableEvent,\n NetworkControllerRpcEndpointUnavailableEvent,\n NetworkControllerRpcEndpointChainDegradedEvent,\n NetworkControllerRpcEndpointDegradedEvent,\n NetworkControllerRpcEndpointChainAvailableEvent,\n NetworkControllerRpcEndpointRetriedEvent,\n} from './NetworkController';\nexport {\n getDefaultNetworkControllerState,\n selectAvailableNetworkClientIds,\n knownKeysOf,\n NetworkController,\n RpcEndpointType,\n} from './NetworkController';\nexport * from './constants';\nexport type { BlockTracker, Provider } from './types';\nexport type {\n NetworkClientConfiguration,\n InfuraNetworkClientConfiguration,\n CustomNetworkClientConfiguration,\n} from './types';\nexport { NetworkClientType } from './types';\nexport type { NetworkClient } from './create-network-client';\nexport type { AbstractRpcService } from './rpc-service/abstract-rpc-service';\nexport type { RpcServiceRequestable } from './rpc-service/rpc-service-requestable';\nexport type { DegradedEventType, RetryReason } from './create-network-client';\nexport { classifyRetryReason } from './create-network-client';\nexport { isConnectionError } from './rpc-service/rpc-service';\n"]} | ||
| {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkCA,OAAO,EACL,gCAAgC,EAChC,+BAA+B,EAC/B,WAAW,EACX,iBAAiB,EACjB,eAAe,EAChB,gCAA4B;AAC7B,gCAA4B;AAO5B,OAAO,EAAE,iBAAiB,EAAE,oBAAgB;AAK5C,OAAO,EAAE,mBAAmB,EAAE,oCAAgC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,sCAAkC","sourcesContent":["export type { AutoManagedNetworkClient } from './create-auto-managed-network-client';\nexport type {\n Block,\n NetworkMetadata,\n NetworkConfiguration,\n BuiltInNetworkClientId,\n CustomNetworkClientId,\n NetworkClientId,\n NetworksMetadata,\n NetworkState,\n BlockTrackerProxy,\n ProviderProxy,\n AddNetworkFields,\n UpdateNetworkFields,\n NetworkControllerStateChangeEvent,\n NetworkControllerNetworkWillChangeEvent,\n NetworkControllerNetworkDidChangeEvent,\n NetworkControllerInfuraIsBlockedEvent,\n NetworkControllerInfuraIsUnblockedEvent,\n NetworkControllerNetworkAddedEvent,\n NetworkControllerNetworkRemovedEvent,\n NetworkControllerEvents,\n NetworkControllerGetStateAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientId,\n NetworkControllerActions,\n NetworkControllerMessenger,\n NetworkControllerOptions,\n NetworkControllerRpcEndpointChainUnavailableEvent,\n NetworkControllerRpcEndpointUnavailableEvent,\n NetworkControllerRpcEndpointChainDegradedEvent,\n NetworkControllerRpcEndpointDegradedEvent,\n NetworkControllerRpcEndpointChainAvailableEvent,\n NetworkControllerRpcEndpointRetriedEvent,\n} from './NetworkController';\nexport {\n getDefaultNetworkControllerState,\n selectAvailableNetworkClientIds,\n knownKeysOf,\n NetworkController,\n RpcEndpointType,\n} from './NetworkController';\nexport * from './constants';\nexport type { BlockTracker, Provider } from './types';\nexport type {\n NetworkClientConfiguration,\n InfuraNetworkClientConfiguration,\n CustomNetworkClientConfiguration,\n} from './types';\nexport { NetworkClientType } from './types';\nexport type { NetworkClient } from './create-network-client';\nexport type { AbstractRpcService } from './rpc-service/abstract-rpc-service';\nexport type { RpcServiceRequestable } from './rpc-service/rpc-service-requestable';\nexport type { DegradedEventType, RetryReason } from './create-network-client';\nexport { classifyRetryReason } from './create-network-client';\nexport { isConnectionError } from './rpc-service/rpc-service';\nexport type {\n NetworkControllerGetEthQueryAction,\n NetworkControllerGetNetworkClientByIdAction,\n NetworkControllerGetSelectedNetworkClientAction,\n NetworkControllerGetSelectedChainIdAction,\n NetworkControllerGetEIP1559CompatibilityAction,\n NetworkControllerFindNetworkClientIdByChainIdAction,\n NetworkControllerSetProviderTypeAction,\n NetworkControllerSetActiveNetworkAction,\n NetworkControllerGetNetworkConfigurationByChainIdAction,\n NetworkControllerGetNetworkConfigurationByNetworkClientIdAction,\n NetworkControllerAddNetworkAction,\n NetworkControllerRemoveNetworkAction,\n NetworkControllerUpdateNetworkAction,\n NetworkControllerEnableRpcFailoverAction,\n NetworkControllerDisableRpcFailoverAction,\n NetworkControllerGetProviderAndBlockTrackerAction,\n NetworkControllerGetNetworkClientRegistryAction,\n NetworkControllerInitializeProviderAction,\n NetworkControllerLookupNetworkAction,\n NetworkControllerLookupNetworkByClientIdAction,\n NetworkControllerGet1559CompatibilityWithNetworkClientIdAction,\n NetworkControllerResetConnectionAction,\n NetworkControllerRollbackToPreviousProviderAction,\n NetworkControllerLoadBackupAction,\n} from './NetworkController-method-action-types';\n"]} |
@@ -16,2 +16,3 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller"; | ||
| import type { DegradedEventType, RetryReason } from "./create-network-client.cjs"; | ||
| import type { NetworkControllerGetNetworkConfigurationByNetworkClientIdAction, NetworkControllerMethodActions } from "./NetworkController-method-action-types.cjs"; | ||
| import type { RpcServiceOptions } from "./rpc-service/rpc-service.cjs"; | ||
@@ -523,62 +524,12 @@ import { NetworkClientType } from "./types.cjs"; | ||
| export type NetworkControllerGetStateAction = ControllerGetStateAction<typeof controllerName, NetworkState>; | ||
| export type NetworkControllerGetEthQueryAction = { | ||
| type: `NetworkController:getEthQuery`; | ||
| handler: () => EthQuery | undefined; | ||
| }; | ||
| export type NetworkControllerGetNetworkClientByIdAction = { | ||
| type: `NetworkController:getNetworkClientById`; | ||
| handler: NetworkController['getNetworkClientById']; | ||
| }; | ||
| export type NetworkControllerGetSelectedNetworkClientAction = { | ||
| type: `NetworkController:getSelectedNetworkClient`; | ||
| handler: NetworkController['getSelectedNetworkClient']; | ||
| }; | ||
| export type NetworkControllerGetSelectedChainIdAction = { | ||
| type: 'NetworkController:getSelectedChainId'; | ||
| handler: NetworkController['getSelectedChainId']; | ||
| }; | ||
| export type NetworkControllerGetEIP1559CompatibilityAction = { | ||
| type: `NetworkController:getEIP1559Compatibility`; | ||
| handler: NetworkController['getEIP1559Compatibility']; | ||
| }; | ||
| export type NetworkControllerFindNetworkClientIdByChainIdAction = { | ||
| type: `NetworkController:findNetworkClientIdByChainId`; | ||
| handler: NetworkController['findNetworkClientIdByChainId']; | ||
| }; | ||
| /** | ||
| * Change the currently selected network to the given built-in network type. | ||
| * | ||
| * @deprecated This action has been replaced by `setActiveNetwork`, and will be | ||
| * removed in a future release. | ||
| * All actions that {@link NetworkController} registers, to be called | ||
| * externally. | ||
| */ | ||
| export type NetworkControllerSetProviderTypeAction = { | ||
| type: `NetworkController:setProviderType`; | ||
| handler: NetworkController['setProviderType']; | ||
| }; | ||
| export type NetworkControllerSetActiveNetworkAction = { | ||
| type: `NetworkController:setActiveNetwork`; | ||
| handler: NetworkController['setActiveNetwork']; | ||
| }; | ||
| export type NetworkControllerGetNetworkConfigurationByChainId = { | ||
| type: `NetworkController:getNetworkConfigurationByChainId`; | ||
| handler: NetworkController['getNetworkConfigurationByChainId']; | ||
| }; | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientId = { | ||
| type: `NetworkController:getNetworkConfigurationByNetworkClientId`; | ||
| handler: NetworkController['getNetworkConfigurationByNetworkClientId']; | ||
| }; | ||
| export type NetworkControllerAddNetworkAction = { | ||
| type: 'NetworkController:addNetwork'; | ||
| handler: NetworkController['addNetwork']; | ||
| }; | ||
| export type NetworkControllerRemoveNetworkAction = { | ||
| type: 'NetworkController:removeNetwork'; | ||
| handler: NetworkController['removeNetwork']; | ||
| }; | ||
| export type NetworkControllerUpdateNetworkAction = { | ||
| type: 'NetworkController:updateNetwork'; | ||
| handler: NetworkController['updateNetwork']; | ||
| }; | ||
| export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerGetEthQueryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetSelectedChainIdAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerSetActiveNetworkAction | NetworkControllerSetProviderTypeAction | NetworkControllerGetNetworkConfigurationByChainId | NetworkControllerGetNetworkConfigurationByNetworkClientId | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction; | ||
| export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerMethodActions; | ||
| /** | ||
| * @deprecated Use {@link NetworkControllerGetNetworkConfigurationByNetworkClientIdAction} instead. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientId = NetworkControllerGetNetworkConfigurationByNetworkClientIdAction; | ||
| /** | ||
| * All actions that {@link NetworkController} calls internally. | ||
@@ -762,2 +713,9 @@ */ | ||
| /** | ||
| * Returns the EthQuery instance for the currently selected network. | ||
| * | ||
| * @returns The EthQuery instance, or undefined if the provider has not been | ||
| * initialized. | ||
| */ | ||
| getEthQuery(): EthQuery | undefined; | ||
| /** | ||
| * Enables the RPC failover functionality. That is, if any RPC endpoints are | ||
@@ -764,0 +722,0 @@ * configured with failover URLs, then traffic will automatically be diverted |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"NetworkController.d.cts","sourceRoot":"","sources":["../src/NetworkController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,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AC;IAsPhC;;;;;;;;OAQG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI;IAoDjC;;;;;;OAMG;IACG,0BAA0B,IAAI,OAAO,CAAC,IAAI,CAAC;IAIjD;;;;OAIG;IAGG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;;;;OAMG;IACH,UAAU,CAAC,EACT,8BAA8B,GAC/B,EAAE,IAAI,CAAC,YAAY,EAAE,gCAAgC,CAAC,GAAG,IAAI;IAS9D;;;;;;;;OAQG;IACH,4BAA4B,CAAC,OAAO,EAAE,GAAG,GAAG,eAAe;CAmpB5D"} |
@@ -16,2 +16,3 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent } from "@metamask/base-controller"; | ||
| import type { DegradedEventType, RetryReason } from "./create-network-client.mjs"; | ||
| import type { NetworkControllerGetNetworkConfigurationByNetworkClientIdAction, NetworkControllerMethodActions } from "./NetworkController-method-action-types.mjs"; | ||
| import type { RpcServiceOptions } from "./rpc-service/rpc-service.mjs"; | ||
@@ -523,62 +524,12 @@ import { NetworkClientType } from "./types.mjs"; | ||
| export type NetworkControllerGetStateAction = ControllerGetStateAction<typeof controllerName, NetworkState>; | ||
| export type NetworkControllerGetEthQueryAction = { | ||
| type: `NetworkController:getEthQuery`; | ||
| handler: () => EthQuery | undefined; | ||
| }; | ||
| export type NetworkControllerGetNetworkClientByIdAction = { | ||
| type: `NetworkController:getNetworkClientById`; | ||
| handler: NetworkController['getNetworkClientById']; | ||
| }; | ||
| export type NetworkControllerGetSelectedNetworkClientAction = { | ||
| type: `NetworkController:getSelectedNetworkClient`; | ||
| handler: NetworkController['getSelectedNetworkClient']; | ||
| }; | ||
| export type NetworkControllerGetSelectedChainIdAction = { | ||
| type: 'NetworkController:getSelectedChainId'; | ||
| handler: NetworkController['getSelectedChainId']; | ||
| }; | ||
| export type NetworkControllerGetEIP1559CompatibilityAction = { | ||
| type: `NetworkController:getEIP1559Compatibility`; | ||
| handler: NetworkController['getEIP1559Compatibility']; | ||
| }; | ||
| export type NetworkControllerFindNetworkClientIdByChainIdAction = { | ||
| type: `NetworkController:findNetworkClientIdByChainId`; | ||
| handler: NetworkController['findNetworkClientIdByChainId']; | ||
| }; | ||
| /** | ||
| * Change the currently selected network to the given built-in network type. | ||
| * | ||
| * @deprecated This action has been replaced by `setActiveNetwork`, and will be | ||
| * removed in a future release. | ||
| * All actions that {@link NetworkController} registers, to be called | ||
| * externally. | ||
| */ | ||
| export type NetworkControllerSetProviderTypeAction = { | ||
| type: `NetworkController:setProviderType`; | ||
| handler: NetworkController['setProviderType']; | ||
| }; | ||
| export type NetworkControllerSetActiveNetworkAction = { | ||
| type: `NetworkController:setActiveNetwork`; | ||
| handler: NetworkController['setActiveNetwork']; | ||
| }; | ||
| export type NetworkControllerGetNetworkConfigurationByChainId = { | ||
| type: `NetworkController:getNetworkConfigurationByChainId`; | ||
| handler: NetworkController['getNetworkConfigurationByChainId']; | ||
| }; | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientId = { | ||
| type: `NetworkController:getNetworkConfigurationByNetworkClientId`; | ||
| handler: NetworkController['getNetworkConfigurationByNetworkClientId']; | ||
| }; | ||
| export type NetworkControllerAddNetworkAction = { | ||
| type: 'NetworkController:addNetwork'; | ||
| handler: NetworkController['addNetwork']; | ||
| }; | ||
| export type NetworkControllerRemoveNetworkAction = { | ||
| type: 'NetworkController:removeNetwork'; | ||
| handler: NetworkController['removeNetwork']; | ||
| }; | ||
| export type NetworkControllerUpdateNetworkAction = { | ||
| type: 'NetworkController:updateNetwork'; | ||
| handler: NetworkController['updateNetwork']; | ||
| }; | ||
| export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerGetEthQueryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetSelectedChainIdAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerSetActiveNetworkAction | NetworkControllerSetProviderTypeAction | NetworkControllerGetNetworkConfigurationByChainId | NetworkControllerGetNetworkConfigurationByNetworkClientId | NetworkControllerAddNetworkAction | NetworkControllerRemoveNetworkAction | NetworkControllerUpdateNetworkAction; | ||
| export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerMethodActions; | ||
| /** | ||
| * @deprecated Use {@link NetworkControllerGetNetworkConfigurationByNetworkClientIdAction} instead. | ||
| */ | ||
| export type NetworkControllerGetNetworkConfigurationByNetworkClientId = NetworkControllerGetNetworkConfigurationByNetworkClientIdAction; | ||
| /** | ||
| * All actions that {@link NetworkController} calls internally. | ||
@@ -762,2 +713,9 @@ */ | ||
| /** | ||
| * Returns the EthQuery instance for the currently selected network. | ||
| * | ||
| * @returns The EthQuery instance, or undefined if the provider has not been | ||
| * initialized. | ||
| */ | ||
| getEthQuery(): EthQuery | undefined; | ||
| /** | ||
| * Enables the RPC failover functionality. That is, if any RPC endpoints are | ||
@@ -764,0 +722,0 @@ * configured with failover URLs, then traffic will automatically be diverted |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"NetworkController.d.mts","sourceRoot":"","sources":["../src/NetworkController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC3B,kCAAkC;AACnC,OAAO,EAAE,cAAc,EAAE,kCAAkC;AAC3D,OAAO,KAAK,EAAE,oCAAoC,EAAE,0CAA0C;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,mCAAmC;AAC7D,OAAO,EACL,iBAAiB,EAUlB,mCAAmC;AACpC,OAAO,KAAK,EAAE,0BAA0B,EAAE,oCAAoC;AAC9E,OAAO,QAAQ,4BAA4B;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B;AAMrD,OAAO,KAAK,EAAE,cAAc,EAAE,sCAAsC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,wBAAwB;AAG3C,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc;AAGnC,OAAO,KAAK,E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stract-rpc-service.cjs","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { RpcServiceRequestable } from './rpc-service-requestable';\n\n/**\n * The interface for a service class responsible for making a request to an RPC\n * endpoint or a group of RPC endpoints.\n */\nexport type AbstractRpcService = RpcServiceRequestable & {\n /**\n * The URL of the RPC endpoint.\n */\n endpointUrl: URL;\n};\n"]} | ||
| {"version":3,"file":"abstract-rpc-service.cjs","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { RpcServiceRequestable } from './rpc-service-requestable';\n\n/**\n * The interface for a service class responsible for making a request to an RPC\n * endpoint or a group of RPC endpoints.\n *\n * @deprecated Don't use this interface (it will be removed in an upcoming major\n * version). If you need to take an \"RPC-service-like\" argument, it's best to\n * declare which properties you're interested in rather than accepting the\n * entire RPC service interface.\n */\nexport type AbstractRpcService = RpcServiceRequestable & {\n /**\n * The URL of the RPC endpoint.\n */\n endpointUrl: URL;\n};\n"]} |
@@ -5,2 +5,7 @@ import type { RpcServiceRequestable } from "./rpc-service-requestable.cjs"; | ||
| * endpoint or a group of RPC endpoints. | ||
| * | ||
| * @deprecated Don't use this interface (it will be removed in an upcoming major | ||
| * version). If you need to take an "RPC-service-like" argument, it's best to | ||
| * declare which properties you're interested in rather than accepting the | ||
| * entire RPC service interface. | ||
| */ | ||
@@ -7,0 +12,0 @@ export type AbstractRpcService = RpcServiceRequestable & { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"abstract-rpc-service.d.cts","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AAEvE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG;IACvD;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC"} | ||
| {"version":3,"file":"abstract-rpc-service.d.cts","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AAEvE;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG;IACvD;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC"} |
@@ -5,2 +5,7 @@ import type { RpcServiceRequestable } from "./rpc-service-requestable.mjs"; | ||
| * endpoint or a group of RPC endpoints. | ||
| * | ||
| * @deprecated Don't use this interface (it will be removed in an upcoming major | ||
| * version). If you need to take an "RPC-service-like" argument, it's best to | ||
| * declare which properties you're interested in rather than accepting the | ||
| * entire RPC service interface. | ||
| */ | ||
@@ -7,0 +12,0 @@ export type AbstractRpcService = RpcServiceRequestable & { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"abstract-rpc-service.d.mts","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AAEvE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG;IACvD;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC"} | ||
| {"version":3,"file":"abstract-rpc-service.d.mts","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAkC;AAEvE;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,qBAAqB,GAAG;IACvD;;OAEG;IACH,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"abstract-rpc-service.mjs","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { RpcServiceRequestable } from './rpc-service-requestable';\n\n/**\n * The interface for a service class responsible for making a request to an RPC\n * endpoint or a group of RPC endpoints.\n */\nexport type AbstractRpcService = RpcServiceRequestable & {\n /**\n * The URL of the RPC endpoint.\n */\n endpointUrl: URL;\n};\n"]} | ||
| {"version":3,"file":"abstract-rpc-service.mjs","sourceRoot":"","sources":["../../src/rpc-service/abstract-rpc-service.ts"],"names":[],"mappings":"","sourcesContent":["import type { RpcServiceRequestable } from './rpc-service-requestable';\n\n/**\n * The interface for a service class responsible for making a request to an RPC\n * endpoint or a group of RPC endpoints.\n *\n * @deprecated Don't use this interface (it will be removed in an upcoming major\n * version). If you need to take an \"RPC-service-like\" argument, it's best to\n * declare which properties you're interested in rather than accepting the\n * entire RPC service interface.\n */\nexport type AbstractRpcService = RpcServiceRequestable & {\n /**\n * The URL of the RPC endpoint.\n */\n endpointUrl: URL;\n};\n"]} |
@@ -17,4 +17,4 @@ "use strict"; | ||
| const controller_utils_1 = require("@metamask/controller-utils"); | ||
| const logger_1 = require("../logger.cjs"); | ||
| const rpc_service_1 = require("./rpc-service.cjs"); | ||
| const logger_1 = require("../logger.cjs"); | ||
| const log = (0, logger_1.createModuleLogger)(logger_1.projectLogger, 'RpcServiceChain'); | ||
@@ -21,0 +21,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-chain.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAGoC;AASpC,mDAA2C;AAQ3C,0CAA8D;AAE9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,iBAAiB,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAOX;;;;;GAKG;AACH,MAAa,eAAe;IA8C1B;;;;;;OAMG;IACH,YACE,wBAAqE;QArDvE;;WAEG;QACM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E,uCAAuC;gBACvC,GAAG,CACD,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC,oBAAoB,CACjF,CAAC;gBACF,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,wEAAwE;YACxE,kEAAkE;YAClE,qEAAqE;YACrE,uEAAuE;YACvE,oEAAoE;YACpE,EAAE;YACF,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;gBACxC,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,uBAAA,IAAI,iCAAU,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAC5D,qBAAqB,GAAG,CAAC,CAC1B,EAAE,CAAC;oBACF,GAAG,CAAC,iCAAiC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAC/C,OAAO,CAAC,WAAW,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,4EAA4E;QAC5E,2EAA2E;QAC3E,+CAA+C;QAC/C,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;CACF;AAnbD,0CAmbC","sourcesContent":["import {\n CircuitState,\n CockatielEventEmitter,\n} from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { IDisposable } from 'cockatiel';\n\nimport { RpcService } from './rpc-service';\nimport type { RpcServiceOptions } from './rpc-service';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\nimport { projectLogger, createModuleLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'RpcServiceChain');\n\n/**\n * Statuses that the RPC service chain can be in.\n */\nconst STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unknown: 'unknown',\n Unavailable: 'unavailable',\n} as const;\n\n/**\n * Statuses that the RPC service chain can be in.\n */\ntype Status = (typeof STATUSES)[keyof typeof STATUSES];\n\n/**\n * This class constructs and manages requests to a chain of RpcService objects\n * which represent RPC endpoints with which to access a particular network. The\n * first service in the chain is intended to be the primary way of hitting the\n * network and the remaining services are used as failovers.\n */\nexport class RpcServiceChain {\n /**\n * The event emitter for the `onAvailable` event.\n */\n readonly #onAvailableEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onBreak` event.\n */\n readonly #onBreakEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onDegraded` event.\n */\n readonly #onDegradedEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The first RPC service that requests will be sent to.\n */\n readonly #primaryService: RpcService;\n\n /**\n * The RPC services in the chain.\n */\n readonly #services: RpcService[];\n\n /**\n * The status of the RPC service chain.\n */\n #status: Status;\n\n /**\n * Constructs a new RpcServiceChain object.\n *\n * @param rpcServiceConfigurations - The options for the RPC services\n * that you want to construct. Each object in this array is the same as\n * {@link RpcServiceOptions}.\n */\n constructor(\n rpcServiceConfigurations: [RpcServiceOptions, ...RpcServiceOptions[]],\n ) {\n this.#services = rpcServiceConfigurations.map(\n (rpcServiceConfiguration) => new RpcService(rpcServiceConfiguration),\n );\n this.#primaryService = this.#services[0];\n\n this.#status = STATUSES.Unknown;\n this.#onBreakEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >();\n\n this.#onDegradedEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onDegraded((data) => {\n if (this.#status !== STATUSES.Degraded) {\n log('Updating status to \"degraded\"', data);\n this.#status = STATUSES.Degraded;\n const { endpointUrl, ...rest } = data;\n this.#onDegradedEventEmitter.emit(rest);\n }\n });\n }\n\n this.#onAvailableEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onAvailable((data) => {\n if (this.#status !== STATUSES.Available) {\n log('Updating status to \"available\"', data);\n this.#status = STATUSES.Available;\n const { endpointUrl, ...rest } = data;\n this.#onAvailableEventEmitter.emit(rest);\n }\n });\n }\n }\n\n /**\n * Calls the provided callback when any of the RPC services is retried.\n *\n * This is mainly useful for tests.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the event listener.\n */\n onServiceRetry(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onRetry'],\n { primaryEndpointUrl: string }\n >,\n ): { dispose(): void } {\n const disposables = this.#services.map((service) =>\n service.onRetry((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback only when the maximum number of failed\n * consecutive attempts to receive a 2xx response has been reached for all\n * RPC services in the chain, and all services' underlying circuits have\n * broken.\n *\n * The callback will not be called if a service's circuit breaks but its\n * failover does not. Use `onServiceBreak` if you'd like a lower level of\n * granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onBreakEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time when, for *any* of the RPC services\n * in this chain, the maximum number of failed consecutive attempts to receive\n * a 2xx response has been reached and the underlying circuit has broken. A\n * more granular version of `onBreak`.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceBreak(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onBreak'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onBreak((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback if no requests have been initiated yet or\n * all requests to RPC services in this chain have responded successfully in a\n * timely fashion, and then one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * Also note this callback will only be called if the RPC service chain as a\n * whole is in a \"degraded\" state, and will then only be called once (e.g., it\n * will not be called if a failover service falls into a degraded state, then\n * the primary comes back online, but it is slow). Use `onServiceDegraded` if\n * you'd like a lower level of granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onDegraded(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onDegradedEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * This is a more granular version of `onDegraded`. The callback will be\n * called for each slow request to an RPC service. It may also be called again\n * if a failover service falls into a degraded state, then the primary comes\n * back online, but it is slow.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceDegraded(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onDegraded'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onDegraded((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback in one of the following two conditions:\n *\n * 1. The first time that a 2xx request is made to any of the RPC services in\n * this chain.\n * 2. When requests to any the failover RPC services in this chain were\n * failing such that they were degraded or their underyling circuits broke,\n * but the first request to the primary succeeds again.\n *\n * Note this callback will only be called if the RPC service chain as a whole\n * is in an \"available\" state.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onAvailable(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onAvailableEventEmitter.addListener(listener);\n }\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>> & {\n method: 'eth_getBlockByNumber';\n },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n // Start with the primary (first) service and switch to failovers as the\n // need arises. This is a bit confusing, so keep reading for more on how\n // this works.\n\n let availableServiceIndex: number | undefined;\n let response: JsonRpcResponse<Result> | undefined;\n\n for (const [i, service] of this.#services.entries()) {\n log(`Trying service #${i + 1}...`);\n const previousCircuitState = service.getCircuitState();\n\n try {\n // Try making the request through the service.\n response = await service.request<Params, Result>(\n jsonRpcRequest,\n fetchOptions,\n );\n log('Service successfully received request.');\n availableServiceIndex = i;\n break;\n } catch (error) {\n // Oops, that didn't work.\n // Capture this error so that we can handle it later.\n\n const { lastError } = service;\n const isCircuitOpen = service.getCircuitState() === CircuitState.Open;\n\n log('Service failed! error =', error, 'lastError = ', lastError);\n\n if (isCircuitOpen) {\n if (i < this.#services.length - 1) {\n log(\n \"This service's circuit is open. Proceeding to next service...\",\n );\n continue;\n }\n\n if (\n previousCircuitState !== CircuitState.Open &&\n this.#status !== STATUSES.Unavailable &&\n lastError !== undefined\n ) {\n // If the service's circuit just broke and it's the last one in the\n // chain, then trigger the onBreak event. (But if for some reason we\n // have already done this, then don't do it.)\n log(\n 'This service\\'s circuit just opened and it is the last service. Updating status to \"unavailable\" and triggering onBreak.',\n );\n this.#status = STATUSES.Unavailable;\n this.#onBreakEventEmitter.emit({\n error: lastError,\n });\n }\n }\n\n // The service failed, and we throw whatever the error is. The calling\n // code can try again if it so desires.\n log(\n `${isCircuitOpen ? '' : \"This service's circuit is closed. \"}Re-throwing error.`,\n );\n throw error;\n }\n }\n\n if (response) {\n // If one of the services is available, reset all of the circuits of the\n // following services. If we didn't do this and the service became\n // unavailable in the future, and any of the failovers' circuits were\n // open (due to previous failures), we would receive a \"circuit broken\"\n // error when we attempted to divert traffic to the failovers again.\n //\n if (availableServiceIndex !== undefined) {\n for (const [i, service] of [...this.#services.entries()].slice(\n availableServiceIndex + 1,\n )) {\n log(`Resetting policy for service #${i + 1}.`);\n service.resetPolicy();\n }\n }\n\n return response;\n }\n\n // The only way we can end up here is if there are no services to loop over.\n // That is not possible due to the types on the constructor, but TypeScript\n // doesn't know this, so we have to appease it.\n throw new Error('Nothing to return');\n }\n}\n"]} | ||
| {"version":3,"file":"rpc-service-chain.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iEAGoC;AASpC,0CAA8D;AAC9D,mDAA2C;AAS3C,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,iBAAiB,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,WAAW,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CAAqB,CAAC,IAAI,CAAC;4BAC7B,KAAK,EAAE,SAAS;yBACjB,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBAED,sEAAsE;gBACtE,uCAAuC;gBACvC,GAAG,CACD,GAAG,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,oCAAoC,oBAAoB,CACjF,CAAC;gBACF,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QAED,IAAI,QAAQ,EAAE,CAAC;YACb,wEAAwE;YACxE,kEAAkE;YAClE,qEAAqE;YACrE,uEAAuE;YACvE,oEAAoE;YACpE,EAAE;YACF,IAAI,qBAAqB,KAAK,SAAS,EAAE,CAAC;gBACxC,KAAK,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,uBAAA,IAAI,iCAAU,CAAC,OAAO,EAAE,CAAC,CAAC,KAAK,CAC5D,qBAAqB,GAAG,CAAC,CAC1B,EAAE,CAAC;oBACF,GAAG,CAAC,iCAAiC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAC/C,OAAO,CAAC,WAAW,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,4EAA4E;QAC5E,2EAA2E;QAC3E,+CAA+C;QAC/C,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;CACF;AAnbD,0CAmbC","sourcesContent":["import {\n CircuitState,\n CockatielEventEmitter,\n} from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { IDisposable } from 'cockatiel';\n\nimport { projectLogger, createModuleLogger } from '../logger';\nimport { RpcService } from './rpc-service';\nimport type { RpcServiceOptions } from './rpc-service';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\nconst log = createModuleLogger(projectLogger, 'RpcServiceChain');\n\n/**\n * Statuses that the RPC service chain can be in.\n */\nconst STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unknown: 'unknown',\n Unavailable: 'unavailable',\n} as const;\n\n/**\n * Statuses that the RPC service chain can be in.\n */\ntype Status = (typeof STATUSES)[keyof typeof STATUSES];\n\n/**\n * This class constructs and manages requests to a chain of RpcService objects\n * which represent RPC endpoints with which to access a particular network. The\n * first service in the chain is intended to be the primary way of hitting the\n * network and the remaining services are used as failovers.\n */\nexport class RpcServiceChain {\n /**\n * The event emitter for the `onAvailable` event.\n */\n readonly #onAvailableEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onBreak` event.\n */\n readonly #onBreakEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onDegraded` event.\n */\n readonly #onDegradedEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The first RPC service that requests will be sent to.\n */\n readonly #primaryService: RpcService;\n\n /**\n * The RPC services in the chain.\n */\n readonly #services: RpcService[];\n\n /**\n * The status of the RPC service chain.\n */\n #status: Status;\n\n /**\n * Constructs a new RpcServiceChain object.\n *\n * @param rpcServiceConfigurations - The options for the RPC services\n * that you want to construct. Each object in this array is the same as\n * {@link RpcServiceOptions}.\n */\n constructor(\n rpcServiceConfigurations: [RpcServiceOptions, ...RpcServiceOptions[]],\n ) {\n this.#services = rpcServiceConfigurations.map(\n (rpcServiceConfiguration) => new RpcService(rpcServiceConfiguration),\n );\n this.#primaryService = this.#services[0];\n\n this.#status = STATUSES.Unknown;\n this.#onBreakEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >();\n\n this.#onDegradedEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onDegraded((data) => {\n if (this.#status !== STATUSES.Degraded) {\n log('Updating status to \"degraded\"', data);\n this.#status = STATUSES.Degraded;\n const { endpointUrl, ...rest } = data;\n this.#onDegradedEventEmitter.emit(rest);\n }\n });\n }\n\n this.#onAvailableEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onAvailable((data) => {\n if (this.#status !== STATUSES.Available) {\n log('Updating status to \"available\"', data);\n this.#status = STATUSES.Available;\n const { endpointUrl, ...rest } = data;\n this.#onAvailableEventEmitter.emit(rest);\n }\n });\n }\n }\n\n /**\n * Calls the provided callback when any of the RPC services is retried.\n *\n * This is mainly useful for tests.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the event listener.\n */\n onServiceRetry(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onRetry'],\n { primaryEndpointUrl: string }\n >,\n ): { dispose(): void } {\n const disposables = this.#services.map((service) =>\n service.onRetry((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback only when the maximum number of failed\n * consecutive attempts to receive a 2xx response has been reached for all\n * RPC services in the chain, and all services' underlying circuits have\n * broken.\n *\n * The callback will not be called if a service's circuit breaks but its\n * failover does not. Use `onServiceBreak` if you'd like a lower level of\n * granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onBreakEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time when, for *any* of the RPC services\n * in this chain, the maximum number of failed consecutive attempts to receive\n * a 2xx response has been reached and the underlying circuit has broken. A\n * more granular version of `onBreak`.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceBreak(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onBreak'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onBreak((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback if no requests have been initiated yet or\n * all requests to RPC services in this chain have responded successfully in a\n * timely fashion, and then one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * Also note this callback will only be called if the RPC service chain as a\n * whole is in a \"degraded\" state, and will then only be called once (e.g., it\n * will not be called if a failover service falls into a degraded state, then\n * the primary comes back online, but it is slow). Use `onServiceDegraded` if\n * you'd like a lower level of granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onDegraded(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onDegradedEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * This is a more granular version of `onDegraded`. The callback will be\n * called for each slow request to an RPC service. It may also be called again\n * if a failover service falls into a degraded state, then the primary comes\n * back online, but it is slow.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceDegraded(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onDegraded'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onDegraded((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback in one of the following two conditions:\n *\n * 1. The first time that a 2xx request is made to any of the RPC services in\n * this chain.\n * 2. When requests to any the failover RPC services in this chain were\n * failing such that they were degraded or their underyling circuits broke,\n * but the first request to the primary succeeds again.\n *\n * Note this callback will only be called if the RPC service chain as a whole\n * is in an \"available\" state.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onAvailable(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onAvailableEventEmitter.addListener(listener);\n }\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>> & {\n method: 'eth_getBlockByNumber';\n },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n // Start with the primary (first) service and switch to failovers as the\n // need arises. This is a bit confusing, so keep reading for more on how\n // this works.\n\n let availableServiceIndex: number | undefined;\n let response: JsonRpcResponse<Result> | undefined;\n\n for (const [i, service] of this.#services.entries()) {\n log(`Trying service #${i + 1}...`);\n const previousCircuitState = service.getCircuitState();\n\n try {\n // Try making the request through the service.\n response = await service.request<Params, Result>(\n jsonRpcRequest,\n fetchOptions,\n );\n log('Service successfully received request.');\n availableServiceIndex = i;\n break;\n } catch (error) {\n // Oops, that didn't work.\n // Capture this error so that we can handle it later.\n\n const { lastError } = service;\n const isCircuitOpen = service.getCircuitState() === CircuitState.Open;\n\n log('Service failed! error =', error, 'lastError = ', lastError);\n\n if (isCircuitOpen) {\n if (i < this.#services.length - 1) {\n log(\n \"This service's circuit is open. Proceeding to next service...\",\n );\n continue;\n }\n\n if (\n previousCircuitState !== CircuitState.Open &&\n this.#status !== STATUSES.Unavailable &&\n lastError !== undefined\n ) {\n // If the service's circuit just broke and it's the last one in the\n // chain, then trigger the onBreak event. (But if for some reason we\n // have already done this, then don't do it.)\n log(\n 'This service\\'s circuit just opened and it is the last service. Updating status to \"unavailable\" and triggering onBreak.',\n );\n this.#status = STATUSES.Unavailable;\n this.#onBreakEventEmitter.emit({\n error: lastError,\n });\n }\n }\n\n // The service failed, and we throw whatever the error is. The calling\n // code can try again if it so desires.\n log(\n `${isCircuitOpen ? '' : \"This service's circuit is closed. \"}Re-throwing error.`,\n );\n throw error;\n }\n }\n\n if (response) {\n // If one of the services is available, reset all of the circuits of the\n // following services. If we didn't do this and the service became\n // unavailable in the future, and any of the failovers' circuits were\n // open (due to previous failures), we would receive a \"circuit broken\"\n // error when we attempted to divert traffic to the failovers again.\n //\n if (availableServiceIndex !== undefined) {\n for (const [i, service] of [...this.#services.entries()].slice(\n availableServiceIndex + 1,\n )) {\n log(`Resetting policy for service #${i + 1}.`);\n service.resetPolicy();\n }\n }\n\n return response;\n }\n\n // The only way we can end up here is if there are no services to loop over.\n // That is not possible due to the types on the constructor, but TypeScript\n // doesn't know this, so we have to appease it.\n throw new Error('Nothing to return');\n }\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-chain.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AACzB,OAAO,EAAE,WAAW,EAAE,kBAAkB;AAExC,OAAO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AE,kBAAkB,EAAE,MAAM,CAAA;KAAE,CAC/B,GACA,WAAW;IAiBd;;;;;;;;;;;;;;;OAeG;IACH,WAAW,CACT,QAAQ,EAAE,CACR,IAAI,EAAE,yBAAyB,CAC7B,yBAAyB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC,EACpD,aAAa,CACd,KACE,IAAI,GACR,WAAW;IAId;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG;QACjD,MAAM,EAAE,sBAAsB,CAAC;KAChC,EACD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IAE3D;;;;;;;;;;;;;;;;;OAiBG;IACG,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EAC7D,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CA8FpC"} |
@@ -14,4 +14,4 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { | ||
| import { CircuitState, CockatielEventEmitter } from "@metamask/controller-utils"; | ||
| import { projectLogger, createModuleLogger } from "../logger.mjs"; | ||
| import { RpcService } from "./rpc-service.mjs"; | ||
| import { projectLogger, createModuleLogger } from "../logger.mjs"; | ||
| const log = createModuleLogger(projectLogger, 'RpcServiceChain'); | ||
@@ -18,0 +18,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-chain.mjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,YAAY,EACZ,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metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { IDisposable } from 'cockatiel';\n\nimport { RpcService } from './rpc-service';\nimport type { RpcServiceOptions } from './rpc-service';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\nimport { projectLogger, createModuleLogger } from '../logger';\n\nconst log = createModuleLogger(projectLogger, 'RpcServiceChain');\n\n/**\n * Statuses that the RPC service chain can be in.\n */\nconst STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unknown: 'unknown',\n Unavailable: 'unavailable',\n} as const;\n\n/**\n * Statuses that the RPC service chain can be in.\n */\ntype Status = (typeof STATUSES)[keyof typeof STATUSES];\n\n/**\n * This class constructs and manages requests to a chain of RpcService objects\n * which represent RPC endpoints with which to access a particular network. The\n * first service in the chain is intended to be the primary way of hitting the\n * network and the remaining services are used as failovers.\n */\nexport class RpcServiceChain {\n /**\n * The event emitter for the `onAvailable` event.\n */\n readonly #onAvailableEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onBreak` event.\n */\n readonly #onBreakEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onDegraded` event.\n */\n readonly #onDegradedEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The first RPC service that requests will be sent to.\n */\n readonly #primaryService: RpcService;\n\n /**\n * The RPC services in the chain.\n */\n readonly #services: RpcService[];\n\n /**\n * The status of the RPC service chain.\n */\n #status: Status;\n\n /**\n * Constructs a new RpcServiceChain object.\n *\n * @param rpcServiceConfigurations - The options for the RPC services\n * that you want to construct. Each object in this array is the same as\n * {@link RpcServiceOptions}.\n */\n constructor(\n rpcServiceConfigurations: [RpcServiceOptions, ...RpcServiceOptions[]],\n ) {\n this.#services = rpcServiceConfigurations.map(\n (rpcServiceConfiguration) => new RpcService(rpcServiceConfiguration),\n );\n this.#primaryService = this.#services[0];\n\n this.#status = STATUSES.Unknown;\n this.#onBreakEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >();\n\n this.#onDegradedEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onDegraded((data) => {\n if (this.#status !== STATUSES.Degraded) {\n log('Updating status to \"degraded\"', data);\n this.#status = STATUSES.Degraded;\n const { endpointUrl, ...rest } = data;\n this.#onDegradedEventEmitter.emit(rest);\n }\n });\n }\n\n this.#onAvailableEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onAvailable((data) => {\n if (this.#status !== STATUSES.Available) {\n log('Updating status to \"available\"', data);\n this.#status = STATUSES.Available;\n const { endpointUrl, ...rest } = data;\n this.#onAvailableEventEmitter.emit(rest);\n }\n });\n }\n }\n\n /**\n * Calls the provided callback when any of the RPC services is retried.\n *\n * This is mainly useful for tests.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the event listener.\n */\n onServiceRetry(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onRetry'],\n { primaryEndpointUrl: string }\n >,\n ): { dispose(): void } {\n const disposables = this.#services.map((service) =>\n service.onRetry((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback only when the maximum number of failed\n * consecutive attempts to receive a 2xx response has been reached for all\n * RPC services in the chain, and all services' underlying circuits have\n * broken.\n *\n * The callback will not be called if a service's circuit breaks but its\n * failover does not. Use `onServiceBreak` if you'd like a lower level of\n * granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onBreakEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time when, for *any* of the RPC services\n * in this chain, the maximum number of failed consecutive attempts to receive\n * a 2xx response has been reached and the underlying circuit has broken. A\n * more granular version of `onBreak`.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceBreak(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onBreak'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onBreak((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback if no requests have been initiated yet or\n * all requests to RPC services in this chain have responded successfully in a\n * timely fashion, and then one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * Also note this callback will only be called if the RPC service chain as a\n * whole is in a \"degraded\" state, and will then only be called once (e.g., it\n * will not be called if a failover service falls into a degraded state, then\n * the primary comes back online, but it is slow). Use `onServiceDegraded` if\n * you'd like a lower level of granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onDegraded(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onDegradedEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * This is a more granular version of `onDegraded`. The callback will be\n * called for each slow request to an RPC service. It may also be called again\n * if a failover service falls into a degraded state, then the primary comes\n * back online, but it is slow.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceDegraded(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onDegraded'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onDegraded((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback in one of the following two conditions:\n *\n * 1. The first time that a 2xx request is made to any of the RPC services in\n * this chain.\n * 2. When requests to any the failover RPC services in this chain were\n * failing such that they were degraded or their underyling circuits broke,\n * but the first request to the primary succeeds again.\n *\n * Note this callback will only be called if the RPC service chain as a whole\n * is in an \"available\" state.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onAvailable(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onAvailableEventEmitter.addListener(listener);\n }\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>> & {\n method: 'eth_getBlockByNumber';\n },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n // Start with the primary (first) service and switch to failovers as the\n // need arises. This is a bit confusing, so keep reading for more on how\n // this works.\n\n let availableServiceIndex: number | undefined;\n let response: JsonRpcResponse<Result> | undefined;\n\n for (const [i, service] of this.#services.entries()) {\n log(`Trying service #${i + 1}...`);\n const previousCircuitState = service.getCircuitState();\n\n try {\n // Try making the request through the service.\n response = await service.request<Params, Result>(\n jsonRpcRequest,\n fetchOptions,\n );\n log('Service successfully received request.');\n availableServiceIndex = i;\n break;\n } catch (error) {\n // Oops, that didn't work.\n // Capture this error so that we can handle it later.\n\n const { lastError } = service;\n const isCircuitOpen = service.getCircuitState() === CircuitState.Open;\n\n log('Service failed! error =', error, 'lastError = ', lastError);\n\n if (isCircuitOpen) {\n if (i < this.#services.length - 1) {\n log(\n \"This service's circuit is open. Proceeding to next service...\",\n );\n continue;\n }\n\n if (\n previousCircuitState !== CircuitState.Open &&\n this.#status !== STATUSES.Unavailable &&\n lastError !== undefined\n ) {\n // If the service's circuit just broke and it's the last one in the\n // chain, then trigger the onBreak event. (But if for some reason we\n // have already done this, then don't do it.)\n log(\n 'This service\\'s circuit just opened and it is the last service. Updating status to \"unavailable\" and triggering onBreak.',\n );\n this.#status = STATUSES.Unavailable;\n this.#onBreakEventEmitter.emit({\n error: lastError,\n });\n }\n }\n\n // The service failed, and we throw whatever the error is. The calling\n // code can try again if it so desires.\n log(\n `${isCircuitOpen ? '' : \"This service's circuit is closed. \"}Re-throwing error.`,\n );\n throw error;\n }\n }\n\n if (response) {\n // If one of the services is available, reset all of the circuits of the\n // following services. If we didn't do this and the service became\n // unavailable in the future, and any of the failovers' circuits were\n // open (due to previous failures), we would receive a \"circuit broken\"\n // error when we attempted to divert traffic to the failovers again.\n //\n if (availableServiceIndex !== undefined) {\n for (const [i, service] of [...this.#services.entries()].slice(\n availableServiceIndex + 1,\n )) {\n log(`Resetting policy for service #${i + 1}.`);\n service.resetPolicy();\n }\n }\n\n return response;\n }\n\n // The only way we can end up here is if there are no services to loop over.\n // That is not possible due to the types on the constructor, but TypeScript\n // doesn't know this, so we have to appease it.\n throw new Error('Nothing to return');\n }\n}\n"]} | ||
| {"version":3,"file":"rpc-service-chain.mjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-chain.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EACL,YAAY,EACZ,qBAAqB,EACtB,mCAAmC;AASpC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAkB;AAC9D,OAAO,EAAE,UAAU,EAAE,0BAAsB;AAS3C,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAC;AAEjE;;GAEG;AACH,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,WAAW;IACtB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,WAAW,EAAE,aAAa;CAClB,CAAC;AAOX;;;;;GAKG;AACH,MAAM,OAAO,eAAe;IA8C1B;;;;;;OAMG;IACH,YACE,wBAAqE;QArDvE;;WAEG;QACM,2DAKP;QAEF;;WAEG;QACM,uDAKP;QAEF;;WAEG;QACM,0DAKP;QAEF;;WAEG;QACM,kDAA4B;QAErC;;WAEG;QACM,4CAAwB;QAEjC;;WAEG;QACH,0CAAgB;QAYd,uBAAA,IAAI,6BAAa,wBAAwB,CAAC,GAAG,CAC3C,CAAC,uBAAuB,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC,uBAAuB,CAAC,CACrE,MAAA,CAAC;QACF,uBAAA,IAAI,mCAAmB,uBAAA,IAAI,iCAAU,CAAC,CAAC,CAAC,MAAA,CAAC;QAEzC,uBAAA,IAAI,2BAAW,QAAQ,CAAC,OAAO,MAAA,CAAC;QAChC,uBAAA,IAAI,wCAAwB,IAAI,qBAAqB,EAKlD,MAAA,CAAC;QAEJ,uBAAA,IAAI,2CAA2B,IAAI,qBAAqB,EAKrD,MAAA,CAAC;QACJ,KAAK,MAAM,OAAO,IAAI,uBAAA,IAAI,iCAAU,EAAE,CAAC;YACrC,OAAO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,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,4EAA4E;QAC5E,2EAA2E;QAC3E,+CAA+C;QAC/C,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACvC,CAAC;CACF","sourcesContent":["import {\n CircuitState,\n CockatielEventEmitter,\n} from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { IDisposable } from 'cockatiel';\n\nimport { projectLogger, createModuleLogger } from '../logger';\nimport { RpcService } from './rpc-service';\nimport type { RpcServiceOptions } from './rpc-service';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\nconst log = createModuleLogger(projectLogger, 'RpcServiceChain');\n\n/**\n * Statuses that the RPC service chain can be in.\n */\nconst STATUSES = {\n Available: 'available',\n Degraded: 'degraded',\n Unknown: 'unknown',\n Unavailable: 'unavailable',\n} as const;\n\n/**\n * Statuses that the RPC service chain can be in.\n */\ntype Status = (typeof STATUSES)[keyof typeof STATUSES];\n\n/**\n * This class constructs and manages requests to a chain of RpcService objects\n * which represent RPC endpoints with which to access a particular network. The\n * first service in the chain is intended to be the primary way of hitting the\n * network and the remaining services are used as failovers.\n */\nexport class RpcServiceChain {\n /**\n * The event emitter for the `onAvailable` event.\n */\n readonly #onAvailableEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onBreak` event.\n */\n readonly #onBreakEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The event emitter for the `onDegraded` event.\n */\n readonly #onDegradedEventEmitter: CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >;\n\n /**\n * The first RPC service that requests will be sent to.\n */\n readonly #primaryService: RpcService;\n\n /**\n * The RPC services in the chain.\n */\n readonly #services: RpcService[];\n\n /**\n * The status of the RPC service chain.\n */\n #status: Status;\n\n /**\n * Constructs a new RpcServiceChain object.\n *\n * @param rpcServiceConfigurations - The options for the RPC services\n * that you want to construct. Each object in this array is the same as\n * {@link RpcServiceOptions}.\n */\n constructor(\n rpcServiceConfigurations: [RpcServiceOptions, ...RpcServiceOptions[]],\n ) {\n this.#services = rpcServiceConfigurations.map(\n (rpcServiceConfiguration) => new RpcService(rpcServiceConfiguration),\n );\n this.#primaryService = this.#services[0];\n\n this.#status = STATUSES.Unknown;\n this.#onBreakEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >\n >();\n\n this.#onDegradedEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onDegraded((data) => {\n if (this.#status !== STATUSES.Degraded) {\n log('Updating status to \"degraded\"', data);\n this.#status = STATUSES.Degraded;\n const { endpointUrl, ...rest } = data;\n this.#onDegradedEventEmitter.emit(rest);\n }\n });\n }\n\n this.#onAvailableEventEmitter = new CockatielEventEmitter<\n ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >\n >();\n for (const service of this.#services) {\n service.onAvailable((data) => {\n if (this.#status !== STATUSES.Available) {\n log('Updating status to \"available\"', data);\n this.#status = STATUSES.Available;\n const { endpointUrl, ...rest } = data;\n this.#onAvailableEventEmitter.emit(rest);\n }\n });\n }\n }\n\n /**\n * Calls the provided callback when any of the RPC services is retried.\n *\n * This is mainly useful for tests.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the event listener.\n */\n onServiceRetry(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onRetry'],\n { primaryEndpointUrl: string }\n >,\n ): { dispose(): void } {\n const disposables = this.#services.map((service) =>\n service.onRetry((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback only when the maximum number of failed\n * consecutive attempts to receive a 2xx response has been reached for all\n * RPC services in the chain, and all services' underlying circuits have\n * broken.\n *\n * The callback will not be called if a service's circuit breaks but its\n * failover does not. Use `onServiceBreak` if you'd like a lower level of\n * granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onBreak']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onBreakEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time when, for *any* of the RPC services\n * in this chain, the maximum number of failed consecutive attempts to receive\n * a 2xx response has been reached and the underlying circuit has broken. A\n * more granular version of `onBreak`.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceBreak(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onBreak'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onBreak((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback if no requests have been initiated yet or\n * all requests to RPC services in this chain have responded successfully in a\n * timely fashion, and then one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * Also note this callback will only be called if the RPC service chain as a\n * whole is in a \"degraded\" state, and will then only be called once (e.g., it\n * will not be called if a failover service falls into a degraded state, then\n * the primary comes back online, but it is slow). Use `onServiceDegraded` if\n * you'd like a lower level of granularity.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onDegraded(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onDegraded']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onDegradedEventEmitter.addListener(listener);\n }\n\n /**\n * Calls the provided callback each time one of the two conditions apply:\n *\n * 1. When a retriable error is encountered making a request to an RPC\n * service, and the request is retried until a set maximum is reached.\n * 2. When a RPC service responds successfully, but the request takes longer\n * than a set number of seconds to complete.\n *\n * Note that the callback will be called even if there are local connectivity\n * issues which prevent requests from being initiated. This is intentional.\n *\n * This is a more granular version of `onDegraded`. The callback will be\n * called for each slow request to an RPC service. It may also be called again\n * if a failover service falls into a degraded state, then the primary comes\n * back online, but it is slow.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onServiceDegraded(\n listener: CockatielEventToEventListenerWithData<\n RpcService['onDegraded'],\n { primaryEndpointUrl: string }\n >,\n ): IDisposable {\n const disposables = this.#services.map((service) =>\n service.onDegraded((data) => {\n listener({\n ...data,\n primaryEndpointUrl: this.#primaryService.endpointUrl.toString(),\n });\n }),\n );\n\n return {\n dispose(): void {\n disposables.forEach((disposable) => disposable.dispose());\n },\n };\n }\n\n /**\n * Calls the provided callback in one of the following two conditions:\n *\n * 1. The first time that a 2xx request is made to any of the RPC services in\n * this chain.\n * 2. When requests to any the failover RPC services in this chain were\n * failing such that they were degraded or their underyling circuits broke,\n * but the first request to the primary succeeds again.\n *\n * Note this callback will only be called if the RPC service chain as a whole\n * is in an \"available\" state.\n *\n * @param listener - The callback to be called.\n * @returns An object with a `dispose` method which can be used to unregister\n * the callback.\n */\n onAvailable(\n listener: (\n data: ExcludeCockatielEventData<\n ExtractCockatielEventData<RpcService['onAvailable']>,\n 'endpointUrl'\n >,\n ) => void,\n ): IDisposable {\n return this.#onAvailableEventEmitter.addListener(listener);\n }\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>> & {\n method: 'eth_getBlockByNumber';\n },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Uses the RPC services in the chain to make a request, using each service\n * after the first as a fallback to the previous one as necessary.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws A 401 error if the response status is 401.\n * @throws A \"rate limiting\" error if the response HTTP status is 429.\n * @throws A \"resource unavailable\" error if the response status is 402, 404, or any 5xx.\n * @throws A generic HTTP client error (-32100) for any other 4xx status codes.\n * @throws A \"parse\" error if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n // Start with the primary (first) service and switch to failovers as the\n // need arises. This is a bit confusing, so keep reading for more on how\n // this works.\n\n let availableServiceIndex: number | undefined;\n let response: JsonRpcResponse<Result> | undefined;\n\n for (const [i, service] of this.#services.entries()) {\n log(`Trying service #${i + 1}...`);\n const previousCircuitState = service.getCircuitState();\n\n try {\n // Try making the request through the service.\n response = await service.request<Params, Result>(\n jsonRpcRequest,\n fetchOptions,\n );\n log('Service successfully received request.');\n availableServiceIndex = i;\n break;\n } catch (error) {\n // Oops, that didn't work.\n // Capture this error so that we can handle it later.\n\n const { lastError } = service;\n const isCircuitOpen = service.getCircuitState() === CircuitState.Open;\n\n log('Service failed! error =', error, 'lastError = ', lastError);\n\n if (isCircuitOpen) {\n if (i < this.#services.length - 1) {\n log(\n \"This service's circuit is open. Proceeding to next service...\",\n );\n continue;\n }\n\n if (\n previousCircuitState !== CircuitState.Open &&\n this.#status !== STATUSES.Unavailable &&\n lastError !== undefined\n ) {\n // If the service's circuit just broke and it's the last one in the\n // chain, then trigger the onBreak event. (But if for some reason we\n // have already done this, then don't do it.)\n log(\n 'This service\\'s circuit just opened and it is the last service. Updating status to \"unavailable\" and triggering onBreak.',\n );\n this.#status = STATUSES.Unavailable;\n this.#onBreakEventEmitter.emit({\n error: lastError,\n });\n }\n }\n\n // The service failed, and we throw whatever the error is. The calling\n // code can try again if it so desires.\n log(\n `${isCircuitOpen ? '' : \"This service's circuit is closed. \"}Re-throwing error.`,\n );\n throw error;\n }\n }\n\n if (response) {\n // If one of the services is available, reset all of the circuits of the\n // following services. If we didn't do this and the service became\n // unavailable in the future, and any of the failovers' circuits were\n // open (due to previous failures), we would receive a \"circuit broken\"\n // error when we attempted to divert traffic to the failovers again.\n //\n if (availableServiceIndex !== undefined) {\n for (const [i, service] of [...this.#services.entries()].slice(\n availableServiceIndex + 1,\n )) {\n log(`Resetting policy for service #${i + 1}.`);\n service.resetPolicy();\n }\n }\n\n return response;\n }\n\n // The only way we can end up here is if there are no services to loop over.\n // That is not possible due to the types on the constructor, but TypeScript\n // doesn't know this, so we have to appease it.\n throw new Error('Nothing to return');\n }\n}\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-requestable.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * The interface for a service class responsible for making a request to a\n * target, whether that is a single RPC endpoint or an RPC endpoint in an RPC\n * service chain.\n */\nexport type RpcServiceRequestable = {\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']>;\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']>;\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']>;\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']>;\n\n /**\n * Makes a request to the target.\n */\n request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result | null>>;\n};\n"]} | ||
| {"version":3,"file":"rpc-service-requestable.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * The interface for a service class responsible for making a request to a\n * target, whether that is a single RPC endpoint or an RPC endpoint in an RPC\n * service chain.\n *\n * @deprecated Don't use this interface (it will be removed in an upcoming major\n * version). If you need to take an \"RPC-service-like\" argument, it's best to\n * declare which properties you're interested in rather than accepting the\n * entire RPC service interface.\n */\nexport type RpcServiceRequestable = {\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']>;\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']>;\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']>;\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']>;\n\n /**\n * Makes a request to the target.\n */\n request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result | null>>;\n};\n"]} |
@@ -8,2 +8,7 @@ import type { ServicePolicy } from "@metamask/controller-utils"; | ||
| * service chain. | ||
| * | ||
| * @deprecated Don't use this interface (it will be removed in an upcoming major | ||
| * version). If you need to take an "RPC-service-like" argument, it's best to | ||
| * declare which properties you're interested in rather than accepting the | ||
| * entire RPC service interface. | ||
| */ | ||
@@ -10,0 +15,0 @@ export type RpcServiceRequestable = { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-requestable.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,KAAK,EACV,qCAAqC,EACrC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACb,qBAAiB;AAElB;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;OAMG;IACH,OAAO,CACL,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,SAAS,CAAC,EACxB;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,OAAO,CACL,QAAQ,EAAE,CACR,IAAI,EAAE,yBAAyB,CAC7B,wBAAwB,CACtB,yBAAyB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EACnD;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,EACD,UAAU,CACX,KACE,IAAI,GACR,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,UAAU,CACR,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,YAAY,CAAC,EAC3B;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAC/C,GACA,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,WAAW,CACT,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,aAAa,CAAC,EAC5B;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5C;;OAEG;IACH,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5C,CAAC"} | ||
| {"version":3,"file":"rpc-service-requestable.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,KAAK,EACV,qCAAqC,EACrC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACb,qBAAiB;AAElB;;;;;;;;;GASG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;OAMG;IACH,OAAO,CACL,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,SAAS,CAAC,EACxB;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,OAAO,CACL,QAAQ,EAAE,CACR,IAAI,EAAE,yBAAyB,CAC7B,wBAAwB,CACtB,yBAAyB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EACnD;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,EACD,UAAU,CACX,KACE,IAAI,GACR,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,UAAU,CACR,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,YAAY,CAAC,EAC3B;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAC/C,GACA,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,WAAW,CACT,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,aAAa,CAAC,EAC5B;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5C;;OAEG;IACH,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5C,CAAC"} |
@@ -8,2 +8,7 @@ import type { ServicePolicy } from "@metamask/controller-utils"; | ||
| * service chain. | ||
| * | ||
| * @deprecated Don't use this interface (it will be removed in an upcoming major | ||
| * version). If you need to take an "RPC-service-like" argument, it's best to | ||
| * declare which properties you're interested in rather than accepting the | ||
| * entire RPC service interface. | ||
| */ | ||
@@ -10,0 +15,0 @@ export type RpcServiceRequestable = { |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-requestable.d.mts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,KAAK,EACV,qCAAqC,EACrC,yBAAyB,EACzB,wBAAwB,EACxB,yBAAyB,EACzB,YAAY,EACb,qBAAiB;AAElB;;;;GAIG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;;;OAMG;IACH,OAAO,CACL,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,SAAS,CAAC,EACxB;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,OAAO,CACL,QAAQ,EAAE,CACR,IAAI,EAAE,yBAAyB,CAC7B,wBAAwB,CACtB,yBAAyB,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EACnD;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,EACD,UAAU,CACX,KACE,IAAI,GACR,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC;IAExC;;;;;;;OAOG;IACH,UAAU,CACR,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,YAAY,CAAC,EAC3B;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE,CAC/C,GACA,UAAU,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC;IAE3C;;;;;;OAMG;IACH,WAAW,CACT,QAAQ,EAAE,qCAAqC,CAC7C,aAAa,CAAC,aAAa,CAAC,EAC5B;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CACxB,GACA,UAAU,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IAE5C;;OAEG;IACH,OAAO,CAAC,MAAM,SAAS,aAAa,EAAE,MAAM,SAAS,IAAI,EACvD,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,EAChD,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;CAC5C,CAAC"} | ||
| {"version":3,"file":"rpc-service-requestable.d.mts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mCAAmC;AAChE,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AAEzB,OAAO,KAAK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;CAC5C,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service-requestable.mjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * The interface for a service class responsible for making a request to a\n * target, whether that is a single RPC endpoint or an RPC endpoint in an RPC\n * service chain.\n */\nexport type RpcServiceRequestable = {\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']>;\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']>;\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']>;\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']>;\n\n /**\n * Makes a request to the target.\n */\n request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result | null>>;\n};\n"]} | ||
| {"version":3,"file":"rpc-service-requestable.mjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service-requestable.ts"],"names":[],"mappings":"","sourcesContent":["import type { ServicePolicy } from '@metamask/controller-utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\n\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * The interface for a service class responsible for making a request to a\n * target, whether that is a single RPC endpoint or an RPC endpoint in an RPC\n * service chain.\n *\n * @deprecated Don't use this interface (it will be removed in an upcoming major\n * version). If you need to take an \"RPC-service-like\" argument, it's best to\n * declare which properties you're interested in rather than accepting the\n * entire RPC service interface.\n */\nexport type RpcServiceRequestable = {\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']>;\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']>;\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']>;\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']>;\n\n /**\n * Makes a request to the target.\n */\n request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result | null>>;\n};\n"]} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,iEAKoC;AACpC,qDAA+D;AAC/D,2CAAyE;AAOzE,yCAAsD;AACtD,0DAAkC;AAKlC,0CAA8D;AA2C9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,YAAY,CAAC,CAAC;AAE5D;;;GAGG;AACU,QAAA,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,CAAC,CAAC,GAAG,2BAAmB,CAAC,GAAG,CAAC,CAAC;AAE9E;;;;;GAKG;AACU,QAAA,iBAAiB,GAAG;IAC/B,SAAS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AM,CACN,CAAC,4BAA4B,IAAI,uBAAA,IAAI,0BAAQ,CAAC,oBAAoB,CAAC;gBACjE,gBAAQ,CAAC,MAAM,CAClB,CAAC;YACF,MAAM,sBAAS,CAAC,mBAAmB,CAAC;gBAClC,OAAO,EAAE,sDAAsD,qCAAqC,oDAAoD;aACzJ,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport {\n BrokenCircuitError,\n HttpError,\n createServicePolicy,\n handleWhen,\n} from '@metamask/controller-utils';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport { Duration, getErrorMessage, hasProperty } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { CircuitState, IDisposable } from 'cockatiel';\nimport deepmerge from 'deepmerge';\nimport type { Logger } from 'loglevel';\n\nimport type { AbstractRpcService } from './abstract-rpc-service';\nimport type { FetchOptions } from './shared';\nimport { projectLogger, createModuleLogger } from '../logger';\n\n/**\n * Options for the RpcService constructor.\n */\nexport type RpcServiceOptions = {\n /**\n * A function that can be used to convert a binary string into a\n * base64-encoded ASCII string. Used to encode authorization credentials.\n */\n btoa: typeof btoa;\n /**\n * The URL of the RPC endpoint to hit.\n */\n endpointUrl: URL | string;\n /**\n * A function that can be used to make an HTTP request. If your JavaScript\n * environment supports `fetch` natively, you'll probably want to pass that;\n * otherwise you can pass an equivalent (such as `fetch` via `node-fetch`).\n */\n fetch: typeof fetch;\n /**\n * A common set of options that will be used to make every request. Can be\n * overridden on the request level (e.g. to add headers).\n */\n fetchOptions?: FetchOptions;\n /**\n * A `loglevel` logger.\n */\n logger?: Pick<Logger, 'warn'>;\n /**\n * Options to pass to `createServicePolicy`. Note that `retryFilterPolicy` is\n * not accepted, as it is overwritten. See {@link createServicePolicy}.\n */\n policyOptions?: Omit<CreateServicePolicyOptions, 'retryFilterPolicy'>;\n /**\n * A function that checks if the user is currently offline. If it returns true,\n * connection errors will not be retried, preventing degraded and break\n * callbacks from being triggered.\n */\n isOffline: () => boolean;\n};\n\nconst log = createModuleLogger(projectLogger, 'RpcService');\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 = 4;\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 list of error messages that represent a failure to connect to the network.\n *\n * This list was derived from Sindre Sorhus's `is-network-error` package:\n * <https://github.com/sindresorhus/is-network-error/blob/7bbfa8be9482ce1427a21fbff60e3ee1650dd091/index.js>\n */\nexport const CONNECTION_ERRORS = [\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /network error/u,\n },\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /Failed to fetch/u,\n },\n // Firefox\n {\n constructorName: 'TypeError',\n pattern: /NetworkError when attempting to fetch resource\\./u,\n },\n // Safari 16\n {\n constructorName: 'TypeError',\n pattern: /The Internet connection appears to be offline\\./u,\n },\n // Safari 17+\n {\n constructorName: 'TypeError',\n pattern: /Load failed/u,\n },\n // `cross-fetch`\n {\n constructorName: 'TypeError',\n pattern: /Network request failed/u,\n },\n // `node-fetch`\n {\n constructorName: 'FetchError',\n pattern: /request to (.+) failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /fetch failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /terminated/u,\n },\n];\n\n/**\n * Custom JSON-RPC error codes for specific cases.\n *\n * These should be moved to `@metamask/rpc-errors` eventually.\n */\nexport const CUSTOM_RPC_ERRORS = {\n unauthorized: -32006,\n httpClientError: -32080,\n} as const;\n\n/**\n * Determines whether the given error represents a failure to reach the network\n * after request parameters have been validated.\n *\n * This is somewhat difficult to verify because JavaScript engines (and in\n * some cases libraries) produce slightly different error messages for this\n * particular scenario, and we need to account for this.\n *\n * @param error - The error.\n * @returns True if the error indicates that the network cannot be connected to,\n * and false otherwise.\n */\nexport function isConnectionError(error: unknown): boolean {\n if (!(typeof error === 'object' && error !== null && 'message' in error)) {\n return false;\n }\n\n const { message } = error;\n\n return (\n typeof message === 'string' &&\n !isNockError(message) &&\n CONNECTION_ERRORS.some(({ constructorName, pattern }) => {\n return (\n error.constructor.name === constructorName && pattern.test(message)\n );\n })\n );\n}\n\n/**\n * Determines whether the given error message refers to a Nock error.\n *\n * It's important that if we failed to mock a request in a test, the resulting\n * error does not cause the request to be retried so that we can see it right\n * away.\n *\n * @param message - The error message to test.\n * @returns True if the message indicates a missing Nock mock, false otherwise.\n */\nfunction isNockError(message: string): boolean {\n return message.includes('Nock:');\n}\n\n/**\n * Determine whether the given error message indicates a failure to parse JSON.\n *\n * This is different in tests vs. implementation code because it may manifest as\n * a FetchError or a SyntaxError.\n *\n * @param error - The error object to test.\n * @returns True if the error indicates a JSON parse error, false otherwise.\n */\nexport function isJsonParseError(error: unknown): boolean {\n return (\n error instanceof SyntaxError ||\n /invalid json/iu.test(getErrorMessage(error))\n );\n}\n\n/**\n * Determines whether the given error represents a HTTP server error\n * (502, 503, or 504) that should be retried.\n *\n * @param error - The error object to test.\n * @returns True if the error has an httpStatus of 502, 503, or 504.\n */\nexport function isHttpServerError(error: Error): boolean {\n return (\n 'httpStatus' in error &&\n (error.httpStatus === 502 ||\n error.httpStatus === 503 ||\n error.httpStatus === 504)\n );\n}\n\n/**\n * Determines whether the given error has a `code` property of `ETIMEDOUT`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ETIMEDOUT`.\n */\nexport function isTimeoutError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ETIMEDOUT';\n}\n\n/**\n * Determines whether the given error has a `code` property of `ECONNRESET`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ECONNRESET`.\n */\nexport function isConnectionResetError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ECONNRESET';\n}\n\n/**\n * Guarantees a URL, even given a string. This is useful for checking components\n * of that URL.\n *\n * @param endpointUrlOrUrlString - Either a URL object or a string that\n * represents the URL of an endpoint.\n * @returns A URL object.\n */\nfunction getNormalizedEndpointUrl(endpointUrlOrUrlString: URL | string): URL {\n return endpointUrlOrUrlString instanceof URL\n ? endpointUrlOrUrlString\n : new URL(endpointUrlOrUrlString);\n}\n\n/**\n * Strips username and password from a URL.\n *\n * @param url - The URL to strip credentials from.\n * @returns A new URL object with credentials removed.\n */\nfunction stripCredentialsFromUrl(url: URL): URL {\n const strippedUrl = new URL(url.toString());\n strippedUrl.username = '';\n strippedUrl.password = '';\n return strippedUrl;\n}\n\n/**\n * This class is responsible for making a request to an endpoint that implements\n * the JSON-RPC protocol. It is designed to gracefully handle network and server\n * failures, retrying requests using exponential backoff. It also offers a hook\n * which can used to respond to slow requests.\n */\nexport class RpcService implements AbstractRpcService {\n /**\n * The URL of the RPC endpoint.\n */\n readonly endpointUrl: URL;\n\n /**\n * The last error that the retry policy captured (or `undefined` if the last\n * execution of the service was successful).\n */\n lastError: Error | undefined;\n\n /**\n * The RPC method name of the current request being processed. This is passed\n * to `onDegraded` event listeners.\n *\n * Initialised to `''` so the type is `string` throughout the event chain.\n * The empty string is unreachable in practice because the method name is\n * guaranteed to be set after the current request is completed but before\n * any `onDegraded` callbacks are called.\n */\n #currentRpcMethodName = '';\n\n /**\n * The function used to make an HTTP request.\n */\n readonly #fetch: typeof fetch;\n\n /**\n * A common set of options that the request options will extend.\n */\n readonly #fetchOptions: FetchOptions;\n\n /**\n * A `loglevel` logger.\n */\n readonly #logger: RpcServiceOptions['logger'];\n\n /**\n * The policy that wraps the request.\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new RpcService object.\n *\n * @param options - The options. See {@link RpcServiceOptions}.\n */\n constructor(options: RpcServiceOptions) {\n const {\n btoa: givenBtoa,\n endpointUrl,\n fetch: givenFetch,\n logger,\n fetchOptions = {},\n policyOptions = {},\n isOffline,\n } = options;\n\n this.#fetch = givenFetch;\n const normalizedUrl = getNormalizedEndpointUrl(endpointUrl);\n this.#fetchOptions = this.#getDefaultFetchOptions(\n normalizedUrl,\n fetchOptions,\n givenBtoa,\n );\n this.endpointUrl = stripCredentialsFromUrl(normalizedUrl);\n this.#logger = logger;\n\n this.#policy = createServicePolicy({\n maxRetries: DEFAULT_MAX_RETRIES,\n maxConsecutiveFailures: DEFAULT_MAX_CONSECUTIVE_FAILURES,\n ...policyOptions,\n retryFilterPolicy: handleWhen((error) => {\n // If user is offline, don't retry any errors\n // This prevents degraded/break callbacks from being triggered\n if (isOffline()) {\n return false;\n }\n\n return (\n // Ignore errors where the request failed to establish\n isConnectionError(error) ||\n // Ignore server sent HTML error pages or truncated JSON responses\n isJsonParseError(error) ||\n // Ignore server overload errors\n isHttpServerError(error) ||\n // Ignore timeout errors\n isTimeoutError(error) ||\n // Ignore connection reset errors\n isConnectionResetError(error)\n );\n }),\n });\n }\n\n /**\n * Resets the underlying composite Cockatiel policy.\n *\n * This is useful in a collection of RpcServices where some act as failovers\n * for others where you effectively want to invalidate the failovers when the\n * primary recovers.\n */\n resetPolicy(): void {\n this.#policy.reset();\n }\n\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState(): CircuitState {\n return this.#policy.getCircuitState();\n }\n\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(listener: Parameters<AbstractRpcService['onRetry']>[0]): IDisposable {\n return this.#policy.onRetry((data) => {\n listener({ ...data, endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row, causing the underlying circuit to break.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(listener: Parameters<AbstractRpcService['onBreak']>[0]): IDisposable {\n return this.#policy.onBreak((data) => {\n // `{ isolated: true }` is a special object that shows up when `isolate`\n // is called on the circuit breaker. Usually `isolate` is used to hold the\n // circuit open, but we (ab)use this method in `createServicePolicy` to\n // reset the circuit breaker policy. When we do this, we don't want to\n // call `onBreak` handlers, because then it causes\n // `NetworkController:rpcEndpointUnavailable` and\n // `NetworkController:rpcEndpointChainUnavailable` to be published. So we\n // have to ignore that object here. The consequence is that `isolate`\n // doesn't function the way it is intended, at least in the context of an\n // RpcService. However, we are making a bet that we won't need to use it\n // other than how we are already using it.\n if (!('isolated' in data)) {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: Parameters<AbstractRpcService['onDegraded']>[0],\n ): IDisposable {\n return this.#policy.onDegraded((data) => {\n if (data === undefined) {\n listener({\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n } else {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onAvailable} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: Parameters<AbstractRpcService['onAvailable']>[0],\n ): IDisposable {\n return this.#policy.onAvailable(() => {\n listener({ endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params> & { method: 'eth_getBlockByNumber' },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n // The request object may be frozen and must not be mutated.\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n const completeFetchOptions = this.#getCompleteFetchOptions(\n jsonRpcRequest,\n fetchOptions,\n );\n return await this.#executeAndProcessRequest<Result>(\n completeFetchOptions,\n jsonRpcRequest.method,\n );\n }\n\n /**\n * Constructs a default set of options to `fetch`.\n *\n * If a username and password are present in the URL, they are extracted to an\n * Authorization header.\n *\n * @param endpointUrl - The endpoint URL.\n * @param fetchOptions - The options to `fetch`.\n * @param givenBtoa - An implementation of `btoa`.\n * @returns The default fetch options.\n */\n #getDefaultFetchOptions(\n endpointUrl: URL,\n fetchOptions: FetchOptions,\n givenBtoa: (stringToEncode: string) => string,\n ): FetchOptions {\n if (endpointUrl.username && endpointUrl.password) {\n const authString = `${endpointUrl.username}:${endpointUrl.password}`;\n const encodedCredentials = givenBtoa(authString);\n return deepmerge(fetchOptions, {\n headers: { Authorization: `Basic ${encodedCredentials}` },\n });\n }\n\n return fetchOptions;\n }\n\n /**\n * Constructs a final set of options to pass to `fetch`. Note that the method\n * defaults to `post`, and the JSON-RPC request is automatically JSON-encoded.\n *\n * @param jsonRpcRequest - The JSON-RPC request.\n * @param fetchOptions - Custom `fetch` options.\n * @returns The complete set of `fetch` options.\n */\n #getCompleteFetchOptions<Params extends JsonRpcParams>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions,\n ): FetchOptions {\n const defaultOptions = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n };\n const mergedOptions = deepmerge(\n defaultOptions,\n deepmerge(this.#fetchOptions, fetchOptions),\n );\n\n const { id, jsonrpc, method, params } = jsonRpcRequest;\n const body = JSON.stringify({\n id,\n jsonrpc,\n method,\n params,\n });\n\n return { ...mergedOptions, body };\n }\n\n /**\n * Makes the request using the Cockatiel policy that this service creates.\n *\n * @param fetchOptions - The options for `fetch`; will be combined with the\n * fetch options passed to the constructor\n * @param rpcMethodName - The JSON-RPC method name of the current request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async #executeAndProcessRequest<Result extends Json>(\n fetchOptions: FetchOptions,\n rpcMethodName: string,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>> {\n let response: Response | undefined;\n try {\n log(\n `[${this.endpointUrl}] Circuit state`,\n this.#policy.getCircuitState(),\n );\n const jsonDecodedResponse = await this.#policy.execute(\n async (context) => {\n try {\n log(\n 'REQUEST INITIATED:',\n this.endpointUrl.toString(),\n '::',\n fetchOptions,\n // @ts-expect-error This property _is_ here, the type of\n // ServicePolicy is just wrong.\n `(attempt ${context.attempt + 1})`,\n );\n response = await this.#fetch(this.endpointUrl, fetchOptions);\n if (!response.ok) {\n throw new HttpError(response.status);\n }\n log(\n 'REQUEST SUCCESSFUL:',\n this.endpointUrl.toString(),\n response.status,\n );\n return await response.json();\n } finally {\n // Track the RPC method for the request that has just taken place.\n // We pass this property to `onDegraded` event listeners.\n //\n // We set this property after the request completes and not before\n // the request starts to account for race conditions. That is, if\n // there are two requests that are being performed concurrently, and\n // the second request fails fast but the first request succeeds\n // slowly, when `onDegraded` is called we want it to include the\n // first request as the RPC method, not the second.\n //\n // Also, we set this property within a `finally` block inside of the\n // function passed to `policy.execute` to ensure that it is set\n // before `onDegraded` gets called, no matter the outcome of the\n // request.\n this.#currentRpcMethodName = rpcMethodName;\n }\n },\n );\n this.lastError = undefined;\n return jsonDecodedResponse;\n } catch (error) {\n log('REQUEST ERROR:', this.endpointUrl.toString(), error);\n\n this.lastError =\n error instanceof Error ? error : new Error(getErrorMessage(error));\n\n if (error instanceof HttpError) {\n const status = error.httpStatus;\n if (status === 401) {\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.unauthorized,\n 'Unauthorized.',\n {\n httpStatus: status,\n },\n );\n }\n if (status === 429) {\n throw rpcErrors.limitExceeded({\n message: 'Request is being rate limited.',\n data: {\n httpStatus: status,\n },\n });\n }\n if (status >= 500 || status === 402 || status === 404) {\n throw rpcErrors.resourceUnavailable({\n message: 'RPC endpoint not found or unavailable.',\n data: {\n httpStatus: status,\n },\n });\n }\n\n // Handle all other 4xx errors as generic HTTP client errors\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.httpClientError,\n 'RPC endpoint returned HTTP client error.',\n {\n httpStatus: status,\n },\n );\n } else if (isJsonParseError(error)) {\n throw rpcErrors.parse({\n message: 'RPC endpoint did not return JSON.',\n });\n } else if (error instanceof BrokenCircuitError) {\n this.#logger?.warn(error);\n const remainingCircuitOpenDuration =\n this.#policy.getRemainingCircuitOpenDuration();\n const formattedRemainingCircuitOpenDuration = Intl.NumberFormat(\n undefined,\n { maximumFractionDigits: 2 },\n ).format(\n (remainingCircuitOpenDuration ?? this.#policy.circuitBreakDuration) /\n Duration.Minute,\n );\n throw rpcErrors.resourceUnavailable({\n message: `RPC endpoint returned too many errors, retrying in ${formattedRemainingCircuitOpenDuration} minutes. Consider using a different RPC endpoint.`,\n });\n }\n throw error;\n }\n }\n}\n"]} | ||
| {"version":3,"file":"rpc-service.cjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,iEAKoC;AACpC,qDAA+D;AAC/D,2CAAyE;AAOzE,yCAAyC;AACzC,0DAAkC;AAGlC,0CAA8D;AAkD9D,MAAM,GAAG,GAAG,IAAA,2BAAkB,EAAC,sBAAa,EAAE,YAAY,CAAC,CAAC;AAE5D;;;GAGG;AACU,QAAA,mBAAmB,GAAG,CAAC,CAAC;AAErC;;;;;GAKG;AACU,QAAA,gCAAgC,GAAG,CAAC,CAAC,GAAG,2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Y,CAC7D,SAAS,EACT,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAC7B,CAAC,MAAM,CACN,CAAC,4BAA4B,IAAI,uBAAA,IAAI,0BAAQ,CAAC,oBAAoB,CAAC;gBACjE,gBAAQ,CAAC,MAAM,CAClB,CAAC;YACF,MAAM,sBAAS,CAAC,mBAAmB,CAAC;gBAClC,OAAO,EAAE,sDAAsD,qCAAqC,oDAAoD;aACzJ,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport {\n BrokenCircuitError,\n HttpError,\n createServicePolicy,\n handleWhen,\n} from '@metamask/controller-utils';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport { Duration, getErrorMessage, hasProperty } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { CircuitState } from 'cockatiel';\nimport deepmerge from 'deepmerge';\nimport type { Logger } from 'loglevel';\n\nimport { projectLogger, createModuleLogger } from '../logger';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * Options for the RpcService constructor.\n */\nexport type RpcServiceOptions = {\n /**\n * A function that can be used to convert a binary string into a\n * base64-encoded ASCII string. Used to encode authorization credentials.\n */\n btoa: typeof btoa;\n /**\n * The URL of the RPC endpoint to hit.\n */\n endpointUrl: URL | string;\n /**\n * A function that can be used to make an HTTP request. If your JavaScript\n * environment supports `fetch` natively, you'll probably want to pass that;\n * otherwise you can pass an equivalent (such as `fetch` via `node-fetch`).\n */\n fetch: typeof fetch;\n /**\n * A common set of options that will be used to make every request. Can be\n * overridden on the request level (e.g. to add headers).\n */\n fetchOptions?: FetchOptions;\n /**\n * A `loglevel` logger.\n */\n logger?: Pick<Logger, 'warn'>;\n /**\n * Options to pass to `createServicePolicy`. Note that `retryFilterPolicy` is\n * not accepted, as it is overwritten. See {@link createServicePolicy}.\n */\n policyOptions?: Omit<CreateServicePolicyOptions, 'retryFilterPolicy'>;\n /**\n * A function that checks if the user is currently offline. If it returns true,\n * connection errors will not be retried, preventing degraded and break\n * callbacks from being triggered.\n */\n isOffline: () => boolean;\n};\n\nconst log = createModuleLogger(projectLogger, 'RpcService');\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 = 4;\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 list of error messages that represent a failure to connect to the network.\n *\n * This list was derived from Sindre Sorhus's `is-network-error` package:\n * <https://github.com/sindresorhus/is-network-error/blob/7bbfa8be9482ce1427a21fbff60e3ee1650dd091/index.js>\n */\nexport const CONNECTION_ERRORS = [\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /network error/u,\n },\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /Failed to fetch/u,\n },\n // Firefox\n {\n constructorName: 'TypeError',\n pattern: /NetworkError when attempting to fetch resource\\./u,\n },\n // Safari 16\n {\n constructorName: 'TypeError',\n pattern: /The Internet connection appears to be offline\\./u,\n },\n // Safari 17+\n {\n constructorName: 'TypeError',\n pattern: /Load failed/u,\n },\n // `cross-fetch`\n {\n constructorName: 'TypeError',\n pattern: /Network request failed/u,\n },\n // `node-fetch`\n {\n constructorName: 'FetchError',\n pattern: /request to (.+) failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /fetch failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /terminated/u,\n },\n];\n\n/**\n * Custom JSON-RPC error codes for specific cases.\n *\n * These should be moved to `@metamask/rpc-errors` eventually.\n */\nexport const CUSTOM_RPC_ERRORS = {\n unauthorized: -32006,\n httpClientError: -32080,\n} as const;\n\n/**\n * Determines whether the given error represents a failure to reach the network\n * after request parameters have been validated.\n *\n * This is somewhat difficult to verify because JavaScript engines (and in\n * some cases libraries) produce slightly different error messages for this\n * particular scenario, and we need to account for this.\n *\n * @param error - The error.\n * @returns True if the error indicates that the network cannot be connected to,\n * and false otherwise.\n */\nexport function isConnectionError(error: unknown): boolean {\n if (!(typeof error === 'object' && error !== null && 'message' in error)) {\n return false;\n }\n\n const { message } = error;\n\n return (\n typeof message === 'string' &&\n !isNockError(message) &&\n CONNECTION_ERRORS.some(({ constructorName, pattern }) => {\n return (\n error.constructor.name === constructorName && pattern.test(message)\n );\n })\n );\n}\n\n/**\n * Determines whether the given error message refers to a Nock error.\n *\n * It's important that if we failed to mock a request in a test, the resulting\n * error does not cause the request to be retried so that we can see it right\n * away.\n *\n * @param message - The error message to test.\n * @returns True if the message indicates a missing Nock mock, false otherwise.\n */\nfunction isNockError(message: string): boolean {\n return message.includes('Nock:');\n}\n\n/**\n * Determine whether the given error message indicates a failure to parse JSON.\n *\n * This is different in tests vs. implementation code because it may manifest as\n * a FetchError or a SyntaxError.\n *\n * @param error - The error object to test.\n * @returns True if the error indicates a JSON parse error, false otherwise.\n */\nexport function isJsonParseError(error: unknown): boolean {\n return (\n error instanceof SyntaxError ||\n /invalid json/iu.test(getErrorMessage(error))\n );\n}\n\n/**\n * Determines whether the given error represents a HTTP server error\n * (502, 503, or 504) that should be retried.\n *\n * @param error - The error object to test.\n * @returns True if the error has an httpStatus of 502, 503, or 504.\n */\nexport function isHttpServerError(error: Error): boolean {\n return (\n 'httpStatus' in error &&\n (error.httpStatus === 502 ||\n error.httpStatus === 503 ||\n error.httpStatus === 504)\n );\n}\n\n/**\n * Determines whether the given error has a `code` property of `ETIMEDOUT`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ETIMEDOUT`.\n */\nexport function isTimeoutError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ETIMEDOUT';\n}\n\n/**\n * Determines whether the given error has a `code` property of `ECONNRESET`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ECONNRESET`.\n */\nexport function isConnectionResetError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ECONNRESET';\n}\n\n/**\n * Guarantees a URL, even given a string. This is useful for checking components\n * of that URL.\n *\n * @param endpointUrlOrUrlString - Either a URL object or a string that\n * represents the URL of an endpoint.\n * @returns A URL object.\n */\nfunction getNormalizedEndpointUrl(endpointUrlOrUrlString: URL | string): URL {\n return endpointUrlOrUrlString instanceof URL\n ? endpointUrlOrUrlString\n : new URL(endpointUrlOrUrlString);\n}\n\n/**\n * Strips username and password from a URL.\n *\n * @param url - The URL to strip credentials from.\n * @returns A new URL object with credentials removed.\n */\nfunction stripCredentialsFromUrl(url: URL): URL {\n const strippedUrl = new URL(url.toString());\n strippedUrl.username = '';\n strippedUrl.password = '';\n return strippedUrl;\n}\n\n/**\n * This class is responsible for making a request to an endpoint that implements\n * the JSON-RPC protocol. It is designed to gracefully handle network and server\n * failures, retrying requests using exponential backoff. It also offers a hook\n * which can used to respond to slow requests.\n */\nexport class RpcService {\n /**\n * The URL of the RPC endpoint.\n */\n readonly endpointUrl: URL;\n\n /**\n * The last error that the retry policy captured (or `undefined` if the last\n * execution of the service was successful).\n */\n lastError: Error | undefined;\n\n /**\n * The RPC method name of the current request being processed. This is passed\n * to `onDegraded` event listeners.\n *\n * Initialised to `''` so the type is `string` throughout the event chain.\n * The empty string is unreachable in practice because the method name is\n * guaranteed to be set after the current request is completed but before\n * any `onDegraded` callbacks are called.\n */\n #currentRpcMethodName = '';\n\n /**\n * The function used to make an HTTP request.\n */\n readonly #fetch: typeof fetch;\n\n /**\n * A common set of options that the request options will extend.\n */\n readonly #fetchOptions: FetchOptions;\n\n /**\n * A `loglevel` logger.\n */\n readonly #logger: RpcServiceOptions['logger'];\n\n /**\n * The policy that wraps the request.\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new RpcService object.\n *\n * @param options - The options. See {@link RpcServiceOptions}.\n */\n constructor(options: RpcServiceOptions) {\n const {\n btoa: givenBtoa,\n endpointUrl,\n fetch: givenFetch,\n logger,\n fetchOptions = {},\n policyOptions = {},\n isOffline,\n } = options;\n\n this.#fetch = givenFetch;\n const normalizedUrl = getNormalizedEndpointUrl(endpointUrl);\n this.#fetchOptions = this.#getDefaultFetchOptions(\n normalizedUrl,\n fetchOptions,\n givenBtoa,\n );\n this.endpointUrl = stripCredentialsFromUrl(normalizedUrl);\n this.#logger = logger;\n\n this.#policy = createServicePolicy({\n maxRetries: DEFAULT_MAX_RETRIES,\n maxConsecutiveFailures: DEFAULT_MAX_CONSECUTIVE_FAILURES,\n ...policyOptions,\n retryFilterPolicy: handleWhen((error) => {\n // If user is offline, don't retry any errors\n // This prevents degraded/break callbacks from being triggered\n if (isOffline()) {\n return false;\n }\n\n return (\n // Ignore errors where the request failed to establish\n isConnectionError(error) ||\n // Ignore server sent HTML error pages or truncated JSON responses\n isJsonParseError(error) ||\n // Ignore server overload errors\n isHttpServerError(error) ||\n // Ignore timeout errors\n isTimeoutError(error) ||\n // Ignore connection reset errors\n isConnectionResetError(error)\n );\n }),\n });\n }\n\n /**\n * Resets the underlying composite Cockatiel policy.\n *\n * This is useful in a collection of RpcServices where some act as failovers\n * for others where you effectively want to invalidate the failovers when the\n * primary recovers.\n */\n resetPolicy(): void {\n this.#policy.reset();\n }\n\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState(): CircuitState {\n return this.#policy.getCircuitState();\n }\n\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry((data) => {\n listener({ ...data, endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row, causing the underlying circuit to break.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak((data) => {\n // `{ isolated: true }` is a special object that shows up when `isolate`\n // is called on the circuit breaker. Usually `isolate` is used to hold the\n // circuit open, but we (ab)use this method in `createServicePolicy` to\n // reset the circuit breaker policy. When we do this, we don't want to\n // call `onBreak` handlers, because then it causes\n // `NetworkController:rpcEndpointUnavailable` and\n // `NetworkController:rpcEndpointChainUnavailable` to be published. So we\n // have to ignore that object here. The consequence is that `isolate`\n // doesn't function the way it is intended, at least in the context of an\n // RpcService. However, we are making a bet that we won't need to use it\n // other than how we are already using it.\n if (!('isolated' in data)) {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded((data) => {\n if (data === undefined) {\n listener({\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n } else {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onAvailable} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']> {\n return this.#policy.onAvailable(() => {\n listener({ endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params> & { method: 'eth_getBlockByNumber' },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n // The request object may be frozen and must not be mutated.\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n const completeFetchOptions = this.#getCompleteFetchOptions(\n jsonRpcRequest,\n fetchOptions,\n );\n return await this.#executeAndProcessRequest<Result>(\n completeFetchOptions,\n jsonRpcRequest.method,\n );\n }\n\n /**\n * Constructs a default set of options to `fetch`.\n *\n * If a username and password are present in the URL, they are extracted to an\n * Authorization header.\n *\n * @param endpointUrl - The endpoint URL.\n * @param fetchOptions - The options to `fetch`.\n * @param givenBtoa - An implementation of `btoa`.\n * @returns The default fetch options.\n */\n #getDefaultFetchOptions(\n endpointUrl: URL,\n fetchOptions: FetchOptions,\n givenBtoa: (stringToEncode: string) => string,\n ): FetchOptions {\n if (endpointUrl.username && endpointUrl.password) {\n const authString = `${endpointUrl.username}:${endpointUrl.password}`;\n const encodedCredentials = givenBtoa(authString);\n return deepmerge(fetchOptions, {\n headers: { Authorization: `Basic ${encodedCredentials}` },\n });\n }\n\n return fetchOptions;\n }\n\n /**\n * Constructs a final set of options to pass to `fetch`. Note that the method\n * defaults to `post`, and the JSON-RPC request is automatically JSON-encoded.\n *\n * @param jsonRpcRequest - The JSON-RPC request.\n * @param fetchOptions - Custom `fetch` options.\n * @returns The complete set of `fetch` options.\n */\n #getCompleteFetchOptions<Params extends JsonRpcParams>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions,\n ): FetchOptions {\n const defaultOptions = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n };\n const mergedOptions = deepmerge(\n defaultOptions,\n deepmerge(this.#fetchOptions, fetchOptions),\n );\n\n const { id, jsonrpc, method, params } = jsonRpcRequest;\n const body = JSON.stringify({\n id,\n jsonrpc,\n method,\n params,\n });\n\n return { ...mergedOptions, body };\n }\n\n /**\n * Makes the request using the Cockatiel policy that this service creates.\n *\n * @param fetchOptions - The options for `fetch`; will be combined with the\n * fetch options passed to the constructor\n * @param rpcMethodName - The JSON-RPC method name of the current request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async #executeAndProcessRequest<Result extends Json>(\n fetchOptions: FetchOptions,\n rpcMethodName: string,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>> {\n let response: Response | undefined;\n try {\n log(\n `[${this.endpointUrl}] Circuit state`,\n this.#policy.getCircuitState(),\n );\n const jsonDecodedResponse = await this.#policy.execute(\n async (context) => {\n try {\n log(\n 'REQUEST INITIATED:',\n this.endpointUrl.toString(),\n '::',\n fetchOptions,\n // @ts-expect-error This property _is_ here, the type of\n // ServicePolicy is just wrong.\n `(attempt ${context.attempt + 1})`,\n );\n response = await this.#fetch(this.endpointUrl, fetchOptions);\n if (!response.ok) {\n throw new HttpError(response.status);\n }\n log(\n 'REQUEST SUCCESSFUL:',\n this.endpointUrl.toString(),\n response.status,\n );\n return await response.json();\n } finally {\n // Track the RPC method for the request that has just taken place.\n // We pass this property to `onDegraded` event listeners.\n //\n // We set this property after the request completes and not before\n // the request starts to account for race conditions. That is, if\n // there are two requests that are being performed concurrently, and\n // the second request fails fast but the first request succeeds\n // slowly, when `onDegraded` is called we want it to include the\n // first request as the RPC method, not the second.\n //\n // Also, we set this property within a `finally` block inside of the\n // function passed to `policy.execute` to ensure that it is set\n // before `onDegraded` gets called, no matter the outcome of the\n // request.\n this.#currentRpcMethodName = rpcMethodName;\n }\n },\n );\n this.lastError = undefined;\n return jsonDecodedResponse;\n } catch (error) {\n log('REQUEST ERROR:', this.endpointUrl.toString(), error);\n\n this.lastError =\n error instanceof Error ? error : new Error(getErrorMessage(error));\n\n if (error instanceof HttpError) {\n const status = error.httpStatus;\n if (status === 401) {\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.unauthorized,\n 'Unauthorized.',\n {\n httpStatus: status,\n },\n );\n }\n if (status === 429) {\n throw rpcErrors.limitExceeded({\n message: 'Request is being rate limited.',\n data: {\n httpStatus: status,\n },\n });\n }\n if (status >= 500 || status === 402 || status === 404) {\n throw rpcErrors.resourceUnavailable({\n message: 'RPC endpoint not found or unavailable.',\n data: {\n httpStatus: status,\n },\n });\n }\n\n // Handle all other 4xx errors as generic HTTP client errors\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.httpClientError,\n 'RPC endpoint returned HTTP client error.',\n {\n httpStatus: status,\n },\n );\n } else if (isJsonParseError(error)) {\n throw rpcErrors.parse({\n message: 'RPC endpoint did not return JSON.',\n });\n } else if (error instanceof BrokenCircuitError) {\n this.#logger?.warn(error);\n const remainingCircuitOpenDuration =\n this.#policy.getRemainingCircuitOpenDuration();\n const formattedRemainingCircuitOpenDuration = Intl.NumberFormat(\n undefined,\n { maximumFractionDigits: 2 },\n ).format(\n (remainingCircuitOpenDuration ?? this.#policy.circuitBreakDuration) /\n Duration.Minute,\n );\n throw rpcErrors.resourceUnavailable({\n message: `RPC endpoint returned too many errors, retrying in ${formattedRemainingCircuitOpenDuration} minutes. Consider using a different RPC endpoint.`,\n });\n }\n throw error;\n }\n }\n}\n"]} |
@@ -1,7 +0,6 @@ | ||
| import type { CreateServicePolicyOptions } from "@metamask/controller-utils"; | ||
| import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils"; | ||
| import type { Json, JsonRpcParams, JsonRpcRequest, JsonRpcResponse } from "@metamask/utils"; | ||
| import { CircuitState, IDisposable } from "cockatiel"; | ||
| import { CircuitState } from "cockatiel"; | ||
| import type { Logger } from "loglevel"; | ||
| import type { AbstractRpcService } from "./abstract-rpc-service.cjs"; | ||
| import type { FetchOptions } from "./shared.cjs"; | ||
| import type { CockatielEventToEventListenerWithData, ExcludeCockatielEventData, ExtendCockatielEventData, ExtractCockatielEventData, FetchOptions } from "./shared.cjs"; | ||
| /** | ||
@@ -129,3 +128,3 @@ * Options for the RpcService constructor. | ||
| */ | ||
| export declare class RpcService implements AbstractRpcService { | ||
| export declare class RpcService { | ||
| #private; | ||
@@ -166,3 +165,5 @@ /** | ||
| */ | ||
| onRetry(listener: Parameters<AbstractRpcService['onRetry']>[0]): IDisposable; | ||
| onRetry(listener: CockatielEventToEventListenerWithData<ServicePolicy['onRetry'], { | ||
| endpointUrl: string; | ||
| }>): ReturnType<ServicePolicy['onRetry']>; | ||
| /** | ||
@@ -176,3 +177,5 @@ * Listens for when the RPC service retries the request too many times in a | ||
| */ | ||
| onBreak(listener: Parameters<AbstractRpcService['onBreak']>[0]): IDisposable; | ||
| onBreak(listener: (data: ExcludeCockatielEventData<ExtendCockatielEventData<ExtractCockatielEventData<ServicePolicy['onBreak']>, { | ||
| endpointUrl: string; | ||
| }>, 'isolated'>) => void): ReturnType<ServicePolicy['onBreak']>; | ||
| /** | ||
@@ -186,3 +189,6 @@ * Listens for when the policy underlying this RPC service detects a slow | ||
| */ | ||
| onDegraded(listener: Parameters<AbstractRpcService['onDegraded']>[0]): IDisposable; | ||
| onDegraded(listener: CockatielEventToEventListenerWithData<ServicePolicy['onDegraded'], { | ||
| endpointUrl: string; | ||
| rpcMethodName: string; | ||
| }>): ReturnType<ServicePolicy['onDegraded']>; | ||
| /** | ||
@@ -195,3 +201,5 @@ * Listens for when the policy underlying this RPC service is available. | ||
| */ | ||
| onAvailable(listener: Parameters<AbstractRpcService['onAvailable']>[0]): IDisposable; | ||
| onAvailable(listener: CockatielEventToEventListenerWithData<ServicePolicy['onAvailable'], { | ||
| endpointUrl: string; | ||
| }>): ReturnType<ServicePolicy['onAvailable']>; | ||
| /** | ||
@@ -198,0 +206,0 @@ * Makes a request to the RPC endpoint. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service.d.cts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAE3B,mCAAmC;AASpC,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AACzB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAA+B;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAG7C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,GAAG,GAAG,MAAM,CAAC;IAC1B;;;;OAIG;IACH,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,mBAAmB,CAAC,CAAC;IACtE;;;;OAIG;IACH,SAAS,EAAE,MAAM,OAAO,CAAC;CAC1B,CAAC;AAIF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AA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E,cAAc,CAAC,MAAM,CAAC,EACtC,YAAY,CAAC,EAAE,YAAY,GAC1B,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;CAiNpC"} |
@@ -1,7 +0,6 @@ | ||
| import type { CreateServicePolicyOptions } from "@metamask/controller-utils"; | ||
| import type { CreateServicePolicyOptions, ServicePolicy } from "@metamask/controller-utils"; | ||
| import type { Json, JsonRpcParams, JsonRpcRequest, JsonRpcResponse } from "@metamask/utils"; | ||
| import { CircuitState, IDisposable } from "cockatiel"; | ||
| import { CircuitState } from "cockatiel"; | ||
| import type { Logger } from "loglevel"; | ||
| import type { AbstractRpcService } from "./abstract-rpc-service.mjs"; | ||
| import type { FetchOptions } from "./shared.mjs"; | ||
| import type { CockatielEventToEventListenerWithData, ExcludeCockatielEventData, ExtendCockatielEventData, ExtractCockatielEventData, FetchOptions } from "./shared.mjs"; | ||
| /** | ||
@@ -129,3 +128,3 @@ * Options for the RpcService constructor. | ||
| */ | ||
| export declare class RpcService implements AbstractRpcService { | ||
| export declare class RpcService { | ||
| #private; | ||
@@ -166,3 +165,5 @@ /** | ||
| */ | ||
| onRetry(listener: Parameters<AbstractRpcService['onRetry']>[0]): IDisposable; | ||
| onRetry(listener: CockatielEventToEventListenerWithData<ServicePolicy['onRetry'], { | ||
| endpointUrl: string; | ||
| }>): ReturnType<ServicePolicy['onRetry']>; | ||
| /** | ||
@@ -176,3 +177,5 @@ * Listens for when the RPC service retries the request too many times in a | ||
| */ | ||
| onBreak(listener: Parameters<AbstractRpcService['onBreak']>[0]): IDisposable; | ||
| onBreak(listener: (data: ExcludeCockatielEventData<ExtendCockatielEventData<ExtractCockatielEventData<ServicePolicy['onBreak']>, { | ||
| endpointUrl: string; | ||
| }>, 'isolated'>) => void): ReturnType<ServicePolicy['onBreak']>; | ||
| /** | ||
@@ -186,3 +189,6 @@ * Listens for when the policy underlying this RPC service detects a slow | ||
| */ | ||
| onDegraded(listener: Parameters<AbstractRpcService['onDegraded']>[0]): IDisposable; | ||
| onDegraded(listener: CockatielEventToEventListenerWithData<ServicePolicy['onDegraded'], { | ||
| endpointUrl: string; | ||
| rpcMethodName: string; | ||
| }>): ReturnType<ServicePolicy['onDegraded']>; | ||
| /** | ||
@@ -195,3 +201,5 @@ * Listens for when the policy underlying this RPC service is available. | ||
| */ | ||
| onAvailable(listener: Parameters<AbstractRpcService['onAvailable']>[0]): IDisposable; | ||
| onAvailable(listener: CockatielEventToEventListenerWithData<ServicePolicy['onAvailable'], { | ||
| endpointUrl: string; | ||
| }>): ReturnType<ServicePolicy['onAvailable']>; | ||
| /** | ||
@@ -198,0 +206,0 @@ * Makes a request to the RPC endpoint. |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"rpc-service.d.mts","sourceRoot":"","sources":["../../src/rpc-service/rpc-service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,0BAA0B,EAE3B,mCAAmC;AASpC,OAAO,KAAK,EACV,IAAI,EACJ,aAAa,EACb,cAAc,EACd,eAAe,EAChB,wBAAwB;AACzB,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,kBAAkB;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB;AAEvC,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAA+B;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,qBAAiB;AAG7C;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,IAAI,EAAE,OAAO,IAAI,CAAC;IAClB;;OAEG;IACH,WAAW,EAAE,GAAG,GAAG,MAAM,CAAC;IAC1B;;;;OAIG;IACH,KAAK,EAAE,OAAO,KAAK,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;OAEG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,IAAI,CAAC,0BAA0B,EAAE,mBAAmB,C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BACJ,UAAU,EAAE,MAAM;qBACnB;iBACF,CAAC,CAAC;YACL,CAAC;YACD,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,EAAE,CAAC;gBACtD,MAAM,SAAS,CAAC,mBAAmB,CAAC;oBAClC,OAAO,EAAE,wCAAwC;oBACjD,IAAI,EAAE;wBACJ,UAAU,EAAE,MAAM;qBACnB;iBACF,CAAC,CAAC;YACL,CAAC;YAED,4DAA4D;YAC5D,MAAM,IAAI,YAAY,CACpB,iBAAiB,CAAC,eAAe,EACjC,0CAA0C,EAC1C;gBACE,UAAU,EAAE,MAAM;aACnB,CACF,CAAC;QACJ,CAAC;aAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,MAAM,SAAS,CAAC,KAAK,CAAC;gBACpB,OAAO,EAAE,mCAAmC;aAC7C,CAAC,CAAC;QACL,CAAC;aAAM,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;YAC/C,uBAAA,IAAI,0BAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;YAC1B,MAAM,4BAA4B,GAChC,uBAAA,IAAI,0BAAQ,CAAC,+BAA+B,EAAE,CAAC;YACjD,MAAM,qCAAqC,GAAG,IAAI,CAAC,YAAY,CAC7D,SAAS,EACT,EAAE,qBAAqB,EAAE,CAAC,EAAE,CAC7B,CAAC,MAAM,CACN,CAAC,4BAA4B,IAAI,uBAAA,IAAI,0BAAQ,CAAC,oBAAoB,CAAC;gBACjE,QAAQ,CAAC,MAAM,CAClB,CAAC;YACF,MAAM,SAAS,CAAC,mBAAmB,CAAC;gBAClC,OAAO,EAAE,sDAAsD,qCAAqC,oDAAoD;aACzJ,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport {\n BrokenCircuitError,\n HttpError,\n createServicePolicy,\n handleWhen,\n} from '@metamask/controller-utils';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport { Duration, getErrorMessage, hasProperty } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { CircuitState, IDisposable } from 'cockatiel';\nimport deepmerge from 'deepmerge';\nimport type { Logger } from 'loglevel';\n\nimport type { AbstractRpcService } from './abstract-rpc-service';\nimport type { FetchOptions } from './shared';\nimport { projectLogger, createModuleLogger } from '../logger';\n\n/**\n * Options for the RpcService constructor.\n */\nexport type RpcServiceOptions = {\n /**\n * A function that can be used to convert a binary string into a\n * base64-encoded ASCII string. Used to encode authorization credentials.\n */\n btoa: typeof btoa;\n /**\n * The URL of the RPC endpoint to hit.\n */\n endpointUrl: URL | string;\n /**\n * A function that can be used to make an HTTP request. If your JavaScript\n * environment supports `fetch` natively, you'll probably want to pass that;\n * otherwise you can pass an equivalent (such as `fetch` via `node-fetch`).\n */\n fetch: typeof fetch;\n /**\n * A common set of options that will be used to make every request. Can be\n * overridden on the request level (e.g. to add headers).\n */\n fetchOptions?: FetchOptions;\n /**\n * A `loglevel` logger.\n */\n logger?: Pick<Logger, 'warn'>;\n /**\n * Options to pass to `createServicePolicy`. Note that `retryFilterPolicy` is\n * not accepted, as it is overwritten. See {@link createServicePolicy}.\n */\n policyOptions?: Omit<CreateServicePolicyOptions, 'retryFilterPolicy'>;\n /**\n * A function that checks if the user is currently offline. If it returns true,\n * connection errors will not be retried, preventing degraded and break\n * callbacks from being triggered.\n */\n isOffline: () => boolean;\n};\n\nconst log = createModuleLogger(projectLogger, 'RpcService');\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 = 4;\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 list of error messages that represent a failure to connect to the network.\n *\n * This list was derived from Sindre Sorhus's `is-network-error` package:\n * <https://github.com/sindresorhus/is-network-error/blob/7bbfa8be9482ce1427a21fbff60e3ee1650dd091/index.js>\n */\nexport const CONNECTION_ERRORS = [\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /network error/u,\n },\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /Failed to fetch/u,\n },\n // Firefox\n {\n constructorName: 'TypeError',\n pattern: /NetworkError when attempting to fetch resource\\./u,\n },\n // Safari 16\n {\n constructorName: 'TypeError',\n pattern: /The Internet connection appears to be offline\\./u,\n },\n // Safari 17+\n {\n constructorName: 'TypeError',\n pattern: /Load failed/u,\n },\n // `cross-fetch`\n {\n constructorName: 'TypeError',\n pattern: /Network request failed/u,\n },\n // `node-fetch`\n {\n constructorName: 'FetchError',\n pattern: /request to (.+) failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /fetch failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /terminated/u,\n },\n];\n\n/**\n * Custom JSON-RPC error codes for specific cases.\n *\n * These should be moved to `@metamask/rpc-errors` eventually.\n */\nexport const CUSTOM_RPC_ERRORS = {\n unauthorized: -32006,\n httpClientError: -32080,\n} as const;\n\n/**\n * Determines whether the given error represents a failure to reach the network\n * after request parameters have been validated.\n *\n * This is somewhat difficult to verify because JavaScript engines (and in\n * some cases libraries) produce slightly different error messages for this\n * particular scenario, and we need to account for this.\n *\n * @param error - The error.\n * @returns True if the error indicates that the network cannot be connected to,\n * and false otherwise.\n */\nexport function isConnectionError(error: unknown): boolean {\n if (!(typeof error === 'object' && error !== null && 'message' in error)) {\n return false;\n }\n\n const { message } = error;\n\n return (\n typeof message === 'string' &&\n !isNockError(message) &&\n CONNECTION_ERRORS.some(({ constructorName, pattern }) => {\n return (\n error.constructor.name === constructorName && pattern.test(message)\n );\n })\n );\n}\n\n/**\n * Determines whether the given error message refers to a Nock error.\n *\n * It's important that if we failed to mock a request in a test, the resulting\n * error does not cause the request to be retried so that we can see it right\n * away.\n *\n * @param message - The error message to test.\n * @returns True if the message indicates a missing Nock mock, false otherwise.\n */\nfunction isNockError(message: string): boolean {\n return message.includes('Nock:');\n}\n\n/**\n * Determine whether the given error message indicates a failure to parse JSON.\n *\n * This is different in tests vs. implementation code because it may manifest as\n * a FetchError or a SyntaxError.\n *\n * @param error - The error object to test.\n * @returns True if the error indicates a JSON parse error, false otherwise.\n */\nexport function isJsonParseError(error: unknown): boolean {\n return (\n error instanceof SyntaxError ||\n /invalid json/iu.test(getErrorMessage(error))\n );\n}\n\n/**\n * Determines whether the given error represents a HTTP server error\n * (502, 503, or 504) that should be retried.\n *\n * @param error - The error object to test.\n * @returns True if the error has an httpStatus of 502, 503, or 504.\n */\nexport function isHttpServerError(error: Error): boolean {\n return (\n 'httpStatus' in error &&\n (error.httpStatus === 502 ||\n error.httpStatus === 503 ||\n error.httpStatus === 504)\n );\n}\n\n/**\n * Determines whether the given error has a `code` property of `ETIMEDOUT`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ETIMEDOUT`.\n */\nexport function isTimeoutError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ETIMEDOUT';\n}\n\n/**\n * Determines whether the given error has a `code` property of `ECONNRESET`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ECONNRESET`.\n */\nexport function isConnectionResetError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ECONNRESET';\n}\n\n/**\n * Guarantees a URL, even given a string. This is useful for checking components\n * of that URL.\n *\n * @param endpointUrlOrUrlString - Either a URL object or a string that\n * represents the URL of an endpoint.\n * @returns A URL object.\n */\nfunction getNormalizedEndpointUrl(endpointUrlOrUrlString: URL | string): URL {\n return endpointUrlOrUrlString instanceof URL\n ? endpointUrlOrUrlString\n : new URL(endpointUrlOrUrlString);\n}\n\n/**\n * Strips username and password from a URL.\n *\n * @param url - The URL to strip credentials from.\n * @returns A new URL object with credentials removed.\n */\nfunction stripCredentialsFromUrl(url: URL): URL {\n const strippedUrl = new URL(url.toString());\n strippedUrl.username = '';\n strippedUrl.password = '';\n return strippedUrl;\n}\n\n/**\n * This class is responsible for making a request to an endpoint that implements\n * the JSON-RPC protocol. It is designed to gracefully handle network and server\n * failures, retrying requests using exponential backoff. It also offers a hook\n * which can used to respond to slow requests.\n */\nexport class RpcService implements AbstractRpcService {\n /**\n * The URL of the RPC endpoint.\n */\n readonly endpointUrl: URL;\n\n /**\n * The last error that the retry policy captured (or `undefined` if the last\n * execution of the service was successful).\n */\n lastError: Error | undefined;\n\n /**\n * The RPC method name of the current request being processed. This is passed\n * to `onDegraded` event listeners.\n *\n * Initialised to `''` so the type is `string` throughout the event chain.\n * The empty string is unreachable in practice because the method name is\n * guaranteed to be set after the current request is completed but before\n * any `onDegraded` callbacks are called.\n */\n #currentRpcMethodName = '';\n\n /**\n * The function used to make an HTTP request.\n */\n readonly #fetch: typeof fetch;\n\n /**\n * A common set of options that the request options will extend.\n */\n readonly #fetchOptions: FetchOptions;\n\n /**\n * A `loglevel` logger.\n */\n readonly #logger: RpcServiceOptions['logger'];\n\n /**\n * The policy that wraps the request.\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new RpcService object.\n *\n * @param options - The options. See {@link RpcServiceOptions}.\n */\n constructor(options: RpcServiceOptions) {\n const {\n btoa: givenBtoa,\n endpointUrl,\n fetch: givenFetch,\n logger,\n fetchOptions = {},\n policyOptions = {},\n isOffline,\n } = options;\n\n this.#fetch = givenFetch;\n const normalizedUrl = getNormalizedEndpointUrl(endpointUrl);\n this.#fetchOptions = this.#getDefaultFetchOptions(\n normalizedUrl,\n fetchOptions,\n givenBtoa,\n );\n this.endpointUrl = stripCredentialsFromUrl(normalizedUrl);\n this.#logger = logger;\n\n this.#policy = createServicePolicy({\n maxRetries: DEFAULT_MAX_RETRIES,\n maxConsecutiveFailures: DEFAULT_MAX_CONSECUTIVE_FAILURES,\n ...policyOptions,\n retryFilterPolicy: handleWhen((error) => {\n // If user is offline, don't retry any errors\n // This prevents degraded/break callbacks from being triggered\n if (isOffline()) {\n return false;\n }\n\n return (\n // Ignore errors where the request failed to establish\n isConnectionError(error) ||\n // Ignore server sent HTML error pages or truncated JSON responses\n isJsonParseError(error) ||\n // Ignore server overload errors\n isHttpServerError(error) ||\n // Ignore timeout errors\n isTimeoutError(error) ||\n // Ignore connection reset errors\n isConnectionResetError(error)\n );\n }),\n });\n }\n\n /**\n * Resets the underlying composite Cockatiel policy.\n *\n * This is useful in a collection of RpcServices where some act as failovers\n * for others where you effectively want to invalidate the failovers when the\n * primary recovers.\n */\n resetPolicy(): void {\n this.#policy.reset();\n }\n\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState(): CircuitState {\n return this.#policy.getCircuitState();\n }\n\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(listener: Parameters<AbstractRpcService['onRetry']>[0]): IDisposable {\n return this.#policy.onRetry((data) => {\n listener({ ...data, endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row, causing the underlying circuit to break.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(listener: Parameters<AbstractRpcService['onBreak']>[0]): IDisposable {\n return this.#policy.onBreak((data) => {\n // `{ isolated: true }` is a special object that shows up when `isolate`\n // is called on the circuit breaker. Usually `isolate` is used to hold the\n // circuit open, but we (ab)use this method in `createServicePolicy` to\n // reset the circuit breaker policy. When we do this, we don't want to\n // call `onBreak` handlers, because then it causes\n // `NetworkController:rpcEndpointUnavailable` and\n // `NetworkController:rpcEndpointChainUnavailable` to be published. So we\n // have to ignore that object here. The consequence is that `isolate`\n // doesn't function the way it is intended, at least in the context of an\n // RpcService. However, we are making a bet that we won't need to use it\n // other than how we are already using it.\n if (!('isolated' in data)) {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: Parameters<AbstractRpcService['onDegraded']>[0],\n ): IDisposable {\n return this.#policy.onDegraded((data) => {\n if (data === undefined) {\n listener({\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n } else {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onAvailable} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: Parameters<AbstractRpcService['onAvailable']>[0],\n ): IDisposable {\n return this.#policy.onAvailable(() => {\n listener({ endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params> & { method: 'eth_getBlockByNumber' },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n // The request object may be frozen and must not be mutated.\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n const completeFetchOptions = this.#getCompleteFetchOptions(\n jsonRpcRequest,\n fetchOptions,\n );\n return await this.#executeAndProcessRequest<Result>(\n completeFetchOptions,\n jsonRpcRequest.method,\n );\n }\n\n /**\n * Constructs a default set of options to `fetch`.\n *\n * If a username and password are present in the URL, they are extracted to an\n * Authorization header.\n *\n * @param endpointUrl - The endpoint URL.\n * @param fetchOptions - The options to `fetch`.\n * @param givenBtoa - An implementation of `btoa`.\n * @returns The default fetch options.\n */\n #getDefaultFetchOptions(\n endpointUrl: URL,\n fetchOptions: FetchOptions,\n givenBtoa: (stringToEncode: string) => string,\n ): FetchOptions {\n if (endpointUrl.username && endpointUrl.password) {\n const authString = `${endpointUrl.username}:${endpointUrl.password}`;\n const encodedCredentials = givenBtoa(authString);\n return deepmerge(fetchOptions, {\n headers: { Authorization: `Basic ${encodedCredentials}` },\n });\n }\n\n return fetchOptions;\n }\n\n /**\n * Constructs a final set of options to pass to `fetch`. Note that the method\n * defaults to `post`, and the JSON-RPC request is automatically JSON-encoded.\n *\n * @param jsonRpcRequest - The JSON-RPC request.\n * @param fetchOptions - Custom `fetch` options.\n * @returns The complete set of `fetch` options.\n */\n #getCompleteFetchOptions<Params extends JsonRpcParams>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions,\n ): FetchOptions {\n const defaultOptions = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n };\n const mergedOptions = deepmerge(\n defaultOptions,\n deepmerge(this.#fetchOptions, fetchOptions),\n );\n\n const { id, jsonrpc, method, params } = jsonRpcRequest;\n const body = JSON.stringify({\n id,\n jsonrpc,\n method,\n params,\n });\n\n return { ...mergedOptions, body };\n }\n\n /**\n * Makes the request using the Cockatiel policy that this service creates.\n *\n * @param fetchOptions - The options for `fetch`; will be combined with the\n * fetch options passed to the constructor\n * @param rpcMethodName - The JSON-RPC method name of the current request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async #executeAndProcessRequest<Result extends Json>(\n fetchOptions: FetchOptions,\n rpcMethodName: string,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>> {\n let response: Response | undefined;\n try {\n log(\n `[${this.endpointUrl}] Circuit state`,\n this.#policy.getCircuitState(),\n );\n const jsonDecodedResponse = await this.#policy.execute(\n async (context) => {\n try {\n log(\n 'REQUEST INITIATED:',\n this.endpointUrl.toString(),\n '::',\n fetchOptions,\n // @ts-expect-error This property _is_ here, the type of\n // ServicePolicy is just wrong.\n `(attempt ${context.attempt + 1})`,\n );\n response = await this.#fetch(this.endpointUrl, fetchOptions);\n if (!response.ok) {\n throw new HttpError(response.status);\n }\n log(\n 'REQUEST SUCCESSFUL:',\n this.endpointUrl.toString(),\n response.status,\n );\n return await response.json();\n } finally {\n // Track the RPC method for the request that has just taken place.\n // We pass this property to `onDegraded` event listeners.\n //\n // We set this property after the request completes and not before\n // the request starts to account for race conditions. That is, if\n // there are two requests that are being performed concurrently, and\n // the second request fails fast but the first request succeeds\n // slowly, when `onDegraded` is called we want it to include the\n // first request as the RPC method, not the second.\n //\n // Also, we set this property within a `finally` block inside of the\n // function passed to `policy.execute` to ensure that it is set\n // before `onDegraded` gets called, no matter the outcome of the\n // request.\n this.#currentRpcMethodName = rpcMethodName;\n }\n },\n );\n this.lastError = undefined;\n return jsonDecodedResponse;\n } catch (error) {\n log('REQUEST ERROR:', this.endpointUrl.toString(), error);\n\n this.lastError =\n error instanceof Error ? error : new Error(getErrorMessage(error));\n\n if (error instanceof HttpError) {\n const status = error.httpStatus;\n if (status === 401) {\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.unauthorized,\n 'Unauthorized.',\n {\n httpStatus: status,\n },\n );\n }\n if (status === 429) {\n throw rpcErrors.limitExceeded({\n message: 'Request is being rate limited.',\n data: {\n httpStatus: status,\n },\n });\n }\n if (status >= 500 || status === 402 || status === 404) {\n throw rpcErrors.resourceUnavailable({\n message: 'RPC endpoint not found or unavailable.',\n data: {\n httpStatus: status,\n },\n });\n }\n\n // Handle all other 4xx errors as generic HTTP client errors\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.httpClientError,\n 'RPC endpoint returned HTTP client error.',\n {\n httpStatus: status,\n },\n );\n } else if (isJsonParseError(error)) {\n throw rpcErrors.parse({\n message: 'RPC endpoint did not return JSON.',\n });\n } else if (error instanceof BrokenCircuitError) {\n this.#logger?.warn(error);\n const remainingCircuitOpenDuration =\n this.#policy.getRemainingCircuitOpenDuration();\n const formattedRemainingCircuitOpenDuration = Intl.NumberFormat(\n undefined,\n { maximumFractionDigits: 2 },\n ).format(\n (remainingCircuitOpenDuration ?? this.#policy.circuitBreakDuration) /\n Duration.Minute,\n );\n throw rpcErrors.resourceUnavailable({\n message: `RPC endpoint returned too many errors, retrying in ${formattedRemainingCircuitOpenDuration} minutes. Consider using a different RPC endpoint.`,\n });\n }\n throw error;\n }\n }\n}\n"]} | ||
| {"version":3,"file":"rpc-service.mjs","sourceRoot":"","sources":["../../src/rpc-service/rpc-service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAIA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,mBAAmB,EACnB,UAAU,EACX,mCAAmC;AACpC,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,6BAA6B;AAC/D,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAE,wBAAwB;AAOzE,OAAO,EAAE,YAAY,EAAE,kBAAkB;AACzC,OAAO,UAAS,kBAAkB;;AAGlC,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,sBAAkB;AAkD9D,MAAM,GAAG,GAAG,kBAAkB,CAAC,aAAa,EAAE,YAAY,CAAC,CAAC;AAE5D;;;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;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS;IACT;QACE,eAAe,EA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AClC,OAAO,EAAE,sDAAsD,qCAAqC,oDAAoD;aACzJ,CAAC,CAAC;QACL,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type {\n CreateServicePolicyOptions,\n ServicePolicy,\n} from '@metamask/controller-utils';\nimport {\n BrokenCircuitError,\n HttpError,\n createServicePolicy,\n handleWhen,\n} from '@metamask/controller-utils';\nimport { JsonRpcError, rpcErrors } from '@metamask/rpc-errors';\nimport { Duration, getErrorMessage, hasProperty } from '@metamask/utils';\nimport type {\n Json,\n JsonRpcParams,\n JsonRpcRequest,\n JsonRpcResponse,\n} from '@metamask/utils';\nimport { CircuitState } from 'cockatiel';\nimport deepmerge from 'deepmerge';\nimport type { Logger } from 'loglevel';\n\nimport { projectLogger, createModuleLogger } from '../logger';\nimport type {\n CockatielEventToEventListenerWithData,\n ExcludeCockatielEventData,\n ExtendCockatielEventData,\n ExtractCockatielEventData,\n FetchOptions,\n} from './shared';\n\n/**\n * Options for the RpcService constructor.\n */\nexport type RpcServiceOptions = {\n /**\n * A function that can be used to convert a binary string into a\n * base64-encoded ASCII string. Used to encode authorization credentials.\n */\n btoa: typeof btoa;\n /**\n * The URL of the RPC endpoint to hit.\n */\n endpointUrl: URL | string;\n /**\n * A function that can be used to make an HTTP request. If your JavaScript\n * environment supports `fetch` natively, you'll probably want to pass that;\n * otherwise you can pass an equivalent (such as `fetch` via `node-fetch`).\n */\n fetch: typeof fetch;\n /**\n * A common set of options that will be used to make every request. Can be\n * overridden on the request level (e.g. to add headers).\n */\n fetchOptions?: FetchOptions;\n /**\n * A `loglevel` logger.\n */\n logger?: Pick<Logger, 'warn'>;\n /**\n * Options to pass to `createServicePolicy`. Note that `retryFilterPolicy` is\n * not accepted, as it is overwritten. See {@link createServicePolicy}.\n */\n policyOptions?: Omit<CreateServicePolicyOptions, 'retryFilterPolicy'>;\n /**\n * A function that checks if the user is currently offline. If it returns true,\n * connection errors will not be retried, preventing degraded and break\n * callbacks from being triggered.\n */\n isOffline: () => boolean;\n};\n\nconst log = createModuleLogger(projectLogger, 'RpcService');\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 = 4;\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 list of error messages that represent a failure to connect to the network.\n *\n * This list was derived from Sindre Sorhus's `is-network-error` package:\n * <https://github.com/sindresorhus/is-network-error/blob/7bbfa8be9482ce1427a21fbff60e3ee1650dd091/index.js>\n */\nexport const CONNECTION_ERRORS = [\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /network error/u,\n },\n // Chrome\n {\n constructorName: 'TypeError',\n pattern: /Failed to fetch/u,\n },\n // Firefox\n {\n constructorName: 'TypeError',\n pattern: /NetworkError when attempting to fetch resource\\./u,\n },\n // Safari 16\n {\n constructorName: 'TypeError',\n pattern: /The Internet connection appears to be offline\\./u,\n },\n // Safari 17+\n {\n constructorName: 'TypeError',\n pattern: /Load failed/u,\n },\n // `cross-fetch`\n {\n constructorName: 'TypeError',\n pattern: /Network request failed/u,\n },\n // `node-fetch`\n {\n constructorName: 'FetchError',\n pattern: /request to (.+) failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /fetch failed/u,\n },\n // Undici (Node.js)\n {\n constructorName: 'TypeError',\n pattern: /terminated/u,\n },\n];\n\n/**\n * Custom JSON-RPC error codes for specific cases.\n *\n * These should be moved to `@metamask/rpc-errors` eventually.\n */\nexport const CUSTOM_RPC_ERRORS = {\n unauthorized: -32006,\n httpClientError: -32080,\n} as const;\n\n/**\n * Determines whether the given error represents a failure to reach the network\n * after request parameters have been validated.\n *\n * This is somewhat difficult to verify because JavaScript engines (and in\n * some cases libraries) produce slightly different error messages for this\n * particular scenario, and we need to account for this.\n *\n * @param error - The error.\n * @returns True if the error indicates that the network cannot be connected to,\n * and false otherwise.\n */\nexport function isConnectionError(error: unknown): boolean {\n if (!(typeof error === 'object' && error !== null && 'message' in error)) {\n return false;\n }\n\n const { message } = error;\n\n return (\n typeof message === 'string' &&\n !isNockError(message) &&\n CONNECTION_ERRORS.some(({ constructorName, pattern }) => {\n return (\n error.constructor.name === constructorName && pattern.test(message)\n );\n })\n );\n}\n\n/**\n * Determines whether the given error message refers to a Nock error.\n *\n * It's important that if we failed to mock a request in a test, the resulting\n * error does not cause the request to be retried so that we can see it right\n * away.\n *\n * @param message - The error message to test.\n * @returns True if the message indicates a missing Nock mock, false otherwise.\n */\nfunction isNockError(message: string): boolean {\n return message.includes('Nock:');\n}\n\n/**\n * Determine whether the given error message indicates a failure to parse JSON.\n *\n * This is different in tests vs. implementation code because it may manifest as\n * a FetchError or a SyntaxError.\n *\n * @param error - The error object to test.\n * @returns True if the error indicates a JSON parse error, false otherwise.\n */\nexport function isJsonParseError(error: unknown): boolean {\n return (\n error instanceof SyntaxError ||\n /invalid json/iu.test(getErrorMessage(error))\n );\n}\n\n/**\n * Determines whether the given error represents a HTTP server error\n * (502, 503, or 504) that should be retried.\n *\n * @param error - The error object to test.\n * @returns True if the error has an httpStatus of 502, 503, or 504.\n */\nexport function isHttpServerError(error: Error): boolean {\n return (\n 'httpStatus' in error &&\n (error.httpStatus === 502 ||\n error.httpStatus === 503 ||\n error.httpStatus === 504)\n );\n}\n\n/**\n * Determines whether the given error has a `code` property of `ETIMEDOUT`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ETIMEDOUT`.\n */\nexport function isTimeoutError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ETIMEDOUT';\n}\n\n/**\n * Determines whether the given error has a `code` property of `ECONNRESET`.\n *\n * @param error - The error object to test.\n * @returns True if the error code is `ECONNRESET`.\n */\nexport function isConnectionResetError(error: Error): boolean {\n return hasProperty(error, 'code') && error.code === 'ECONNRESET';\n}\n\n/**\n * Guarantees a URL, even given a string. This is useful for checking components\n * of that URL.\n *\n * @param endpointUrlOrUrlString - Either a URL object or a string that\n * represents the URL of an endpoint.\n * @returns A URL object.\n */\nfunction getNormalizedEndpointUrl(endpointUrlOrUrlString: URL | string): URL {\n return endpointUrlOrUrlString instanceof URL\n ? endpointUrlOrUrlString\n : new URL(endpointUrlOrUrlString);\n}\n\n/**\n * Strips username and password from a URL.\n *\n * @param url - The URL to strip credentials from.\n * @returns A new URL object with credentials removed.\n */\nfunction stripCredentialsFromUrl(url: URL): URL {\n const strippedUrl = new URL(url.toString());\n strippedUrl.username = '';\n strippedUrl.password = '';\n return strippedUrl;\n}\n\n/**\n * This class is responsible for making a request to an endpoint that implements\n * the JSON-RPC protocol. It is designed to gracefully handle network and server\n * failures, retrying requests using exponential backoff. It also offers a hook\n * which can used to respond to slow requests.\n */\nexport class RpcService {\n /**\n * The URL of the RPC endpoint.\n */\n readonly endpointUrl: URL;\n\n /**\n * The last error that the retry policy captured (or `undefined` if the last\n * execution of the service was successful).\n */\n lastError: Error | undefined;\n\n /**\n * The RPC method name of the current request being processed. This is passed\n * to `onDegraded` event listeners.\n *\n * Initialised to `''` so the type is `string` throughout the event chain.\n * The empty string is unreachable in practice because the method name is\n * guaranteed to be set after the current request is completed but before\n * any `onDegraded` callbacks are called.\n */\n #currentRpcMethodName = '';\n\n /**\n * The function used to make an HTTP request.\n */\n readonly #fetch: typeof fetch;\n\n /**\n * A common set of options that the request options will extend.\n */\n readonly #fetchOptions: FetchOptions;\n\n /**\n * A `loglevel` logger.\n */\n readonly #logger: RpcServiceOptions['logger'];\n\n /**\n * The policy that wraps the request.\n */\n readonly #policy: ServicePolicy;\n\n /**\n * Constructs a new RpcService object.\n *\n * @param options - The options. See {@link RpcServiceOptions}.\n */\n constructor(options: RpcServiceOptions) {\n const {\n btoa: givenBtoa,\n endpointUrl,\n fetch: givenFetch,\n logger,\n fetchOptions = {},\n policyOptions = {},\n isOffline,\n } = options;\n\n this.#fetch = givenFetch;\n const normalizedUrl = getNormalizedEndpointUrl(endpointUrl);\n this.#fetchOptions = this.#getDefaultFetchOptions(\n normalizedUrl,\n fetchOptions,\n givenBtoa,\n );\n this.endpointUrl = stripCredentialsFromUrl(normalizedUrl);\n this.#logger = logger;\n\n this.#policy = createServicePolicy({\n maxRetries: DEFAULT_MAX_RETRIES,\n maxConsecutiveFailures: DEFAULT_MAX_CONSECUTIVE_FAILURES,\n ...policyOptions,\n retryFilterPolicy: handleWhen((error) => {\n // If user is offline, don't retry any errors\n // This prevents degraded/break callbacks from being triggered\n if (isOffline()) {\n return false;\n }\n\n return (\n // Ignore errors where the request failed to establish\n isConnectionError(error) ||\n // Ignore server sent HTML error pages or truncated JSON responses\n isJsonParseError(error) ||\n // Ignore server overload errors\n isHttpServerError(error) ||\n // Ignore timeout errors\n isTimeoutError(error) ||\n // Ignore connection reset errors\n isConnectionResetError(error)\n );\n }),\n });\n }\n\n /**\n * Resets the underlying composite Cockatiel policy.\n *\n * This is useful in a collection of RpcServices where some act as failovers\n * for others where you effectively want to invalidate the failovers when the\n * primary recovers.\n */\n resetPolicy(): void {\n this.#policy.reset();\n }\n\n /**\n * @returns The state of the underlying circuit.\n */\n getCircuitState(): CircuitState {\n return this.#policy.getCircuitState();\n }\n\n /**\n * Listens for when the RPC service retries the request.\n *\n * @param listener - The callback to be called when the retry occurs.\n * @returns What {@link ServicePolicy.onRetry} returns.\n * @see {@link createServicePolicy}\n */\n onRetry(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onRetry'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onRetry']> {\n return this.#policy.onRetry((data) => {\n listener({ ...data, endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Listens for when the RPC service retries the request too many times in a\n * row, causing the underlying circuit to break.\n *\n * @param listener - The callback to be called when the circuit is broken.\n * @returns What {@link ServicePolicy.onBreak} returns.\n * @see {@link createServicePolicy}\n */\n onBreak(\n listener: (\n data: ExcludeCockatielEventData<\n ExtendCockatielEventData<\n ExtractCockatielEventData<ServicePolicy['onBreak']>,\n { endpointUrl: string }\n >,\n 'isolated'\n >,\n ) => void,\n ): ReturnType<ServicePolicy['onBreak']> {\n return this.#policy.onBreak((data) => {\n // `{ isolated: true }` is a special object that shows up when `isolate`\n // is called on the circuit breaker. Usually `isolate` is used to hold the\n // circuit open, but we (ab)use this method in `createServicePolicy` to\n // reset the circuit breaker policy. When we do this, we don't want to\n // call `onBreak` handlers, because then it causes\n // `NetworkController:rpcEndpointUnavailable` and\n // `NetworkController:rpcEndpointChainUnavailable` to be published. So we\n // have to ignore that object here. The consequence is that `isolate`\n // doesn't function the way it is intended, at least in the context of an\n // RpcService. However, we are making a bet that we won't need to use it\n // other than how we are already using it.\n if (!('isolated' in data)) {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service detects a slow\n * request.\n *\n * @param listener - The callback to be called when the request is slow.\n * @returns What {@link ServicePolicy.onDegraded} returns.\n * @see {@link createServicePolicy}\n */\n onDegraded(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onDegraded'],\n { endpointUrl: string; rpcMethodName: string }\n >,\n ): ReturnType<ServicePolicy['onDegraded']> {\n return this.#policy.onDegraded((data) => {\n if (data === undefined) {\n listener({\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n } else {\n listener({\n ...data,\n endpointUrl: this.endpointUrl.toString(),\n rpcMethodName: this.#currentRpcMethodName,\n });\n }\n });\n }\n\n /**\n * Listens for when the policy underlying this RPC service is available.\n *\n * @param listener - The callback to be called when the request is available.\n * @returns What {@link ServicePolicy.onAvailable} returns.\n * @see {@link createServicePolicy}\n */\n onAvailable(\n listener: CockatielEventToEventListenerWithData<\n ServicePolicy['onAvailable'],\n { endpointUrl: string }\n >,\n ): ReturnType<ServicePolicy['onAvailable']> {\n return this.#policy.onAvailable(() => {\n listener({ endpointUrl: this.endpointUrl.toString() });\n });\n }\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is specifically designed for `eth_getBlockByNumber`, which\n * can return a `result` of `null` despite an expected `Result` being\n * provided.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params> & { method: 'eth_getBlockByNumber' },\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>>;\n\n /**\n * Makes a request to the RPC endpoint.\n *\n * This overload is designed for all RPC methods except for\n * `eth_getBlockByNumber`, which are expected to return a `result` of the\n * expected `Result`.\n *\n * @param jsonRpcRequest - The JSON-RPC request to send to the endpoint.\n * @param fetchOptions - An options bag for {@link fetch} which further\n * specifies the request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async request<Params extends JsonRpcParams, Result extends Json>(\n jsonRpcRequest: JsonRpcRequest<Params>,\n fetchOptions?: FetchOptions,\n ): Promise<JsonRpcResponse<Result>>;\n\n async request<Params extends JsonRpcParams, Result extends Json>(\n // The request object may be frozen and must not be mutated.\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions = {},\n ): Promise<JsonRpcResponse<Result | null>> {\n const completeFetchOptions = this.#getCompleteFetchOptions(\n jsonRpcRequest,\n fetchOptions,\n );\n return await this.#executeAndProcessRequest<Result>(\n completeFetchOptions,\n jsonRpcRequest.method,\n );\n }\n\n /**\n * Constructs a default set of options to `fetch`.\n *\n * If a username and password are present in the URL, they are extracted to an\n * Authorization header.\n *\n * @param endpointUrl - The endpoint URL.\n * @param fetchOptions - The options to `fetch`.\n * @param givenBtoa - An implementation of `btoa`.\n * @returns The default fetch options.\n */\n #getDefaultFetchOptions(\n endpointUrl: URL,\n fetchOptions: FetchOptions,\n givenBtoa: (stringToEncode: string) => string,\n ): FetchOptions {\n if (endpointUrl.username && endpointUrl.password) {\n const authString = `${endpointUrl.username}:${endpointUrl.password}`;\n const encodedCredentials = givenBtoa(authString);\n return deepmerge(fetchOptions, {\n headers: { Authorization: `Basic ${encodedCredentials}` },\n });\n }\n\n return fetchOptions;\n }\n\n /**\n * Constructs a final set of options to pass to `fetch`. Note that the method\n * defaults to `post`, and the JSON-RPC request is automatically JSON-encoded.\n *\n * @param jsonRpcRequest - The JSON-RPC request.\n * @param fetchOptions - Custom `fetch` options.\n * @returns The complete set of `fetch` options.\n */\n #getCompleteFetchOptions<Params extends JsonRpcParams>(\n jsonRpcRequest: Readonly<JsonRpcRequest<Params>>,\n fetchOptions: FetchOptions,\n ): FetchOptions {\n const defaultOptions = {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n };\n const mergedOptions = deepmerge(\n defaultOptions,\n deepmerge(this.#fetchOptions, fetchOptions),\n );\n\n const { id, jsonrpc, method, params } = jsonRpcRequest;\n const body = JSON.stringify({\n id,\n jsonrpc,\n method,\n params,\n });\n\n return { ...mergedOptions, body };\n }\n\n /**\n * Makes the request using the Cockatiel policy that this service creates.\n *\n * @param fetchOptions - The options for `fetch`; will be combined with the\n * fetch options passed to the constructor\n * @param rpcMethodName - The JSON-RPC method name of the current request.\n * @returns The decoded JSON-RPC response from the endpoint.\n * @throws An \"authorized\" JSON-RPC error (code -32006) if the response HTTP status is 401.\n * @throws A \"rate limiting\" JSON-RPC error (code -32005) if the response HTTP status is 429.\n * @throws A \"resource unavailable\" JSON-RPC error (code -32002) if the response HTTP status is 402, 404, or any 5xx.\n * @throws A generic HTTP client JSON-RPC error (code -32050) for any other 4xx HTTP status codes.\n * @throws A \"parse\" JSON-RPC error (code -32700) if the response is not valid JSON.\n */\n async #executeAndProcessRequest<Result extends Json>(\n fetchOptions: FetchOptions,\n rpcMethodName: string,\n ): Promise<JsonRpcResponse<Result> | JsonRpcResponse<null>> {\n let response: Response | undefined;\n try {\n log(\n `[${this.endpointUrl}] Circuit state`,\n this.#policy.getCircuitState(),\n );\n const jsonDecodedResponse = await this.#policy.execute(\n async (context) => {\n try {\n log(\n 'REQUEST INITIATED:',\n this.endpointUrl.toString(),\n '::',\n fetchOptions,\n // @ts-expect-error This property _is_ here, the type of\n // ServicePolicy is just wrong.\n `(attempt ${context.attempt + 1})`,\n );\n response = await this.#fetch(this.endpointUrl, fetchOptions);\n if (!response.ok) {\n throw new HttpError(response.status);\n }\n log(\n 'REQUEST SUCCESSFUL:',\n this.endpointUrl.toString(),\n response.status,\n );\n return await response.json();\n } finally {\n // Track the RPC method for the request that has just taken place.\n // We pass this property to `onDegraded` event listeners.\n //\n // We set this property after the request completes and not before\n // the request starts to account for race conditions. That is, if\n // there are two requests that are being performed concurrently, and\n // the second request fails fast but the first request succeeds\n // slowly, when `onDegraded` is called we want it to include the\n // first request as the RPC method, not the second.\n //\n // Also, we set this property within a `finally` block inside of the\n // function passed to `policy.execute` to ensure that it is set\n // before `onDegraded` gets called, no matter the outcome of the\n // request.\n this.#currentRpcMethodName = rpcMethodName;\n }\n },\n );\n this.lastError = undefined;\n return jsonDecodedResponse;\n } catch (error) {\n log('REQUEST ERROR:', this.endpointUrl.toString(), error);\n\n this.lastError =\n error instanceof Error ? error : new Error(getErrorMessage(error));\n\n if (error instanceof HttpError) {\n const status = error.httpStatus;\n if (status === 401) {\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.unauthorized,\n 'Unauthorized.',\n {\n httpStatus: status,\n },\n );\n }\n if (status === 429) {\n throw rpcErrors.limitExceeded({\n message: 'Request is being rate limited.',\n data: {\n httpStatus: status,\n },\n });\n }\n if (status >= 500 || status === 402 || status === 404) {\n throw rpcErrors.resourceUnavailable({\n message: 'RPC endpoint not found or unavailable.',\n data: {\n httpStatus: status,\n },\n });\n }\n\n // Handle all other 4xx errors as generic HTTP client errors\n throw new JsonRpcError(\n CUSTOM_RPC_ERRORS.httpClientError,\n 'RPC endpoint returned HTTP client error.',\n {\n httpStatus: status,\n },\n );\n } else if (isJsonParseError(error)) {\n throw rpcErrors.parse({\n message: 'RPC endpoint did not return JSON.',\n });\n } else if (error instanceof BrokenCircuitError) {\n this.#logger?.warn(error);\n const remainingCircuitOpenDuration =\n this.#policy.getRemainingCircuitOpenDuration();\n const formattedRemainingCircuitOpenDuration = Intl.NumberFormat(\n undefined,\n { maximumFractionDigits: 2 },\n ).format(\n (remainingCircuitOpenDuration ?? this.#policy.circuitBreakDuration) /\n Duration.Minute,\n );\n throw rpcErrors.resourceUnavailable({\n message: `RPC endpoint returned too many errors, retrying in ${formattedRemainingCircuitOpenDuration} minutes. Consider using a different RPC endpoint.`,\n });\n }\n throw error;\n }\n }\n}\n"]} |
+21
-18
| { | ||
| "name": "@metamask/network-controller", | ||
| "version": "30.0.1", | ||
| "version": "30.1.0", | ||
| "description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object", | ||
| "keywords": [ | ||
| "MetaMask", | ||
| "Ethereum" | ||
| "Ethereum", | ||
| "MetaMask" | ||
| ], | ||
@@ -13,2 +13,3 @@ "homepage": "https://github.com/MetaMask/core/tree/main/packages/network-controller#readme", | ||
| }, | ||
| "license": "MIT", | ||
| "repository": { | ||
@@ -18,4 +19,8 @@ "type": "git", | ||
| }, | ||
| "license": "MIT", | ||
| "files": [ | ||
| "dist/" | ||
| ], | ||
| "sideEffects": false, | ||
| "main": "./dist/index.cjs", | ||
| "types": "./dist/index.d.cts", | ||
| "exports": { | ||
@@ -34,7 +39,6 @@ ".": { | ||
| }, | ||
| "main": "./dist/index.cjs", | ||
| "types": "./dist/index.d.cts", | ||
| "files": [ | ||
| "dist/" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "registry": "https://registry.npmjs.org/" | ||
| }, | ||
| "scripts": { | ||
@@ -46,2 +50,4 @@ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references", | ||
| "changelog:validate": "../../scripts/validate-changelog.sh @metamask/network-controller", | ||
| "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check", | ||
| "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate", | ||
| "since-latest-release": "../../scripts/since-latest-release.sh", | ||
@@ -54,12 +60,12 @@ "test": "NODE_OPTIONS=--experimental-vm-modules jest --reporters=jest-silent-reporter", | ||
| "dependencies": { | ||
| "@metamask/base-controller": "^9.0.1", | ||
| "@metamask/base-controller": "^9.1.0", | ||
| "@metamask/connectivity-controller": "^0.2.0", | ||
| "@metamask/controller-utils": "^11.19.0", | ||
| "@metamask/controller-utils": "^11.20.0", | ||
| "@metamask/eth-block-tracker": "^15.0.1", | ||
| "@metamask/eth-json-rpc-infura": "^10.3.0", | ||
| "@metamask/eth-json-rpc-middleware": "^23.1.1", | ||
| "@metamask/eth-json-rpc-middleware": "^23.1.3", | ||
| "@metamask/eth-json-rpc-provider": "^6.0.1", | ||
| "@metamask/eth-query": "^4.0.0", | ||
| "@metamask/json-rpc-engine": "^10.2.4", | ||
| "@metamask/messenger": "^1.0.0", | ||
| "@metamask/messenger": "^1.2.0", | ||
| "@metamask/rpc-errors": "^7.0.2", | ||
@@ -78,3 +84,3 @@ "@metamask/swappable-obj-proxy": "^2.3.0", | ||
| "@json-rpc-specification/meta-schema": "^1.0.6", | ||
| "@metamask/auto-changelog": "^3.4.4", | ||
| "@metamask/auto-changelog": "^6.1.0", | ||
| "@ts-bridge/cli": "^0.6.4", | ||
@@ -96,2 +102,3 @@ "@types/deep-freeze-strict": "^1.1.0", | ||
| "ts-jest": "^29.2.5", | ||
| "tsx": "^4.20.5", | ||
| "typedoc": "^0.25.13", | ||
@@ -103,7 +110,3 @@ "typedoc-plugin-missing-exports": "^2.0.0", | ||
| "node": "^18.18 || >=20" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "registry": "https://registry.npmjs.org/" | ||
| } | ||
| } |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
1206483
5.08%108
8%6035
0.89%51
-3.77%22
4.76%42
5%