@metamask-previews/network-controller 30.0.1-preview-3f3a92d7b → 30.0.1-preview-16512b784
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/NetworkController-method-action-types.cjs +7 -0
- package/dist/NetworkController-method-action-types.cjs.map +1 -0
- package/dist/NetworkController-method-action-types.d.cts +308 -0
- package/dist/NetworkController-method-action-types.d.cts.map +1 -0
- package/dist/NetworkController-method-action-types.d.mts +308 -0
- package/dist/NetworkController-method-action-types.d.mts.map +1 -0
- package/dist/NetworkController-method-action-types.mjs +6 -0
- package/dist/NetworkController-method-action-types.mjs.map +1 -0
- package/dist/NetworkController.cjs +36 -15
- package/dist/NetworkController.cjs.map +1 -1
- package/dist/NetworkController.d.cts +15 -57
- package/dist/NetworkController.d.cts.map +1 -1
- package/dist/NetworkController.d.mts +15 -57
- package/dist/NetworkController.d.mts.map +1 -1
- package/dist/NetworkController.mjs +36 -15
- package/dist/NetworkController.mjs.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Expose missing public `NetworkController` methods through its messenger ([#8350](https://github.com/MetaMask/core/pull/8350))
|
|
13
|
+
- The following actions are now available:
|
|
14
|
+
- `NetworkController:enableRpcFailover`
|
|
15
|
+
- `NetworkController:disableRpcFailover`
|
|
16
|
+
- `NetworkController:getProviderAndBlockTracker`
|
|
17
|
+
- `NetworkController:getNetworkClientRegistry`
|
|
18
|
+
- `NetworkController:initializeProvider`
|
|
19
|
+
- `NetworkController:lookupNetwork`
|
|
20
|
+
- `NetworkController:lookupNetworkByClientId`
|
|
21
|
+
- `NetworkController:get1559CompatibilityWithNetworkClientId`
|
|
22
|
+
- `NetworkController:resetConnection`
|
|
23
|
+
- `NetworkController:rollbackToPreviousProvider`
|
|
24
|
+
- `NetworkController:loadBackup`
|
|
25
|
+
- Corresponding action types are available as well.
|
|
26
|
+
- Add `getEthQuery` method to `NetworkController` ([#8350](https://github.com/MetaMask/core/pull/8350))
|
|
27
|
+
|
|
10
28
|
### Changed
|
|
11
29
|
|
|
12
30
|
- Bump `@metamask/controller-utils` from `^11.19.0` to `^11.20.0` ([#8344](https://github.com/MetaMask/core/pull/8344))
|
|
13
31
|
|
|
32
|
+
### Deprecated
|
|
33
|
+
|
|
34
|
+
- `NetworkControllerGetNetworkConfigurationByNetworkClientId` type is deprecated in favor of `NetworkControllerGetNetworkConfigurationByNetworkClientIdAction` ([#8350](https://github.com/MetaMask/core/pull/8350))
|
|
35
|
+
|
|
14
36
|
## [30.0.1]
|
|
15
37
|
|
|
16
38
|
### Changed
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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"]}
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is auto generated.
|
|
3
|
+
* Do not edit manually.
|
|
4
|
+
*/
|
|
5
|
+
import type { NetworkController } from "./NetworkController.cjs";
|
|
6
|
+
/**
|
|
7
|
+
* Returns the EthQuery instance for the currently selected network.
|
|
8
|
+
*
|
|
9
|
+
* @returns The EthQuery instance, or undefined if the provider has not been
|
|
10
|
+
* initialized.
|
|
11
|
+
*/
|
|
12
|
+
export type NetworkControllerGetEthQueryAction = {
|
|
13
|
+
type: `NetworkController:getEthQuery`;
|
|
14
|
+
handler: NetworkController['getEthQuery'];
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Enables the RPC failover functionality. That is, if any RPC endpoints are
|
|
18
|
+
* configured with failover URLs, then traffic will automatically be diverted
|
|
19
|
+
* to them if those RPC endpoints are unavailable.
|
|
20
|
+
*/
|
|
21
|
+
export type NetworkControllerEnableRpcFailoverAction = {
|
|
22
|
+
type: `NetworkController:enableRpcFailover`;
|
|
23
|
+
handler: NetworkController['enableRpcFailover'];
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Disables the RPC failover functionality. That is, even if any RPC endpoints
|
|
27
|
+
* are configured with failover URLs, then traffic will not automatically be
|
|
28
|
+
* diverted to them if those RPC endpoints are unavailable.
|
|
29
|
+
*/
|
|
30
|
+
export type NetworkControllerDisableRpcFailoverAction = {
|
|
31
|
+
type: `NetworkController:disableRpcFailover`;
|
|
32
|
+
handler: NetworkController['disableRpcFailover'];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Accesses the provider and block tracker for the currently selected network.
|
|
36
|
+
*
|
|
37
|
+
* @returns The proxy and block tracker proxies.
|
|
38
|
+
* @deprecated This method has been replaced by `getSelectedNetworkClient` (which has a more easily used return type) and will be removed in a future release.
|
|
39
|
+
*/
|
|
40
|
+
export type NetworkControllerGetProviderAndBlockTrackerAction = {
|
|
41
|
+
type: `NetworkController:getProviderAndBlockTracker`;
|
|
42
|
+
handler: NetworkController['getProviderAndBlockTracker'];
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Accesses the provider and block tracker for the currently selected network.
|
|
46
|
+
*
|
|
47
|
+
* @returns an object with the provider and block tracker proxies for the currently selected network.
|
|
48
|
+
*/
|
|
49
|
+
export type NetworkControllerGetSelectedNetworkClientAction = {
|
|
50
|
+
type: `NetworkController:getSelectedNetworkClient`;
|
|
51
|
+
handler: NetworkController['getSelectedNetworkClient'];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Accesses the chain ID from the selected network client.
|
|
55
|
+
*
|
|
56
|
+
* @returns The chain ID of the selected network client in hex format or undefined if there is no network client.
|
|
57
|
+
*/
|
|
58
|
+
export type NetworkControllerGetSelectedChainIdAction = {
|
|
59
|
+
type: `NetworkController:getSelectedChainId`;
|
|
60
|
+
handler: NetworkController['getSelectedChainId'];
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Internally, the Infura and custom network clients are categorized by type
|
|
64
|
+
* so that when accessing either kind of network client, TypeScript knows
|
|
65
|
+
* which type to assign to the network client. For some cases it's more useful
|
|
66
|
+
* to be able to access network clients by ID instead of by type and then ID,
|
|
67
|
+
* so this function makes that possible.
|
|
68
|
+
*
|
|
69
|
+
* @returns The network clients registered so far, keyed by ID.
|
|
70
|
+
*/
|
|
71
|
+
export type NetworkControllerGetNetworkClientRegistryAction = {
|
|
72
|
+
type: `NetworkController:getNetworkClientRegistry`;
|
|
73
|
+
handler: NetworkController['getNetworkClientRegistry'];
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns the Infura network client with the given ID.
|
|
77
|
+
*
|
|
78
|
+
* @param infuraNetworkClientId - An Infura network client ID.
|
|
79
|
+
* @returns The Infura network client.
|
|
80
|
+
* @throws If an Infura network client does not exist with the given ID.
|
|
81
|
+
*/
|
|
82
|
+
export type NetworkControllerGetNetworkClientByIdAction = {
|
|
83
|
+
type: `NetworkController:getNetworkClientById`;
|
|
84
|
+
handler: NetworkController['getNetworkClientById'];
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Creates proxies for accessing the global network client and its block
|
|
88
|
+
* tracker. You must call this method in order to use
|
|
89
|
+
* `getProviderAndBlockTracker` (or its replacement,
|
|
90
|
+
* `getSelectedNetworkClient`).
|
|
91
|
+
*
|
|
92
|
+
* @param options - Optional arguments.
|
|
93
|
+
* @param options.lookupNetwork - Usually, metadata for the global network
|
|
94
|
+
* will be populated via a call to `lookupNetwork` after creating the provider
|
|
95
|
+
* and block tracker proxies. This allows for responding to the status of the
|
|
96
|
+
* global network after initializing this controller; however, it requires
|
|
97
|
+
* making a request to the network to do so. In the clients, where controllers
|
|
98
|
+
* are initialized before the UI is shown, this may be undesirable, as it
|
|
99
|
+
* means that if the user has just installed MetaMask, their IP address may be
|
|
100
|
+
* shared with a third party before they have a chance to finish onboarding.
|
|
101
|
+
* You can pass `false` if you'd like to disable this request and call
|
|
102
|
+
* `lookupNetwork` yourself.
|
|
103
|
+
*/
|
|
104
|
+
export type NetworkControllerInitializeProviderAction = {
|
|
105
|
+
type: `NetworkController:initializeProvider`;
|
|
106
|
+
handler: NetworkController['initializeProvider'];
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Uses a request for the latest block to gather the following information on
|
|
110
|
+
* the given or selected network, persisting it to state:
|
|
111
|
+
*
|
|
112
|
+
* - The connectivity status: whether it is available, geo-blocked (Infura
|
|
113
|
+
* only), unavailable, or unknown
|
|
114
|
+
* - The capabilities status: whether it supports EIP-1559, whether it does
|
|
115
|
+
* not, or whether it is unknown
|
|
116
|
+
*
|
|
117
|
+
* @param networkClientId - The ID of the network client to inspect.
|
|
118
|
+
* If no ID is provided, uses the currently selected network.
|
|
119
|
+
*/
|
|
120
|
+
export type NetworkControllerLookupNetworkAction = {
|
|
121
|
+
type: `NetworkController:lookupNetwork`;
|
|
122
|
+
handler: NetworkController['lookupNetwork'];
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Uses a request for the latest block to gather the following information on
|
|
126
|
+
* the given network, persisting it to state:
|
|
127
|
+
*
|
|
128
|
+
* - The connectivity status: whether the network is available, geo-blocked
|
|
129
|
+
* (Infura only), unavailable, or unknown
|
|
130
|
+
* - The feature compatibility status: whether the network supports EIP-1559,
|
|
131
|
+
* whether it does not, or whether it is unknown
|
|
132
|
+
*
|
|
133
|
+
* @param networkClientId - The ID of the network client to inspect.
|
|
134
|
+
* @deprecated Please use `lookupNetwork` and pass a network client ID
|
|
135
|
+
* instead. This method will be removed in a future major version.
|
|
136
|
+
*/
|
|
137
|
+
export type NetworkControllerLookupNetworkByClientIdAction = {
|
|
138
|
+
type: `NetworkController:lookupNetworkByClientId`;
|
|
139
|
+
handler: NetworkController['lookupNetworkByClientId'];
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Convenience method to update provider network type settings.
|
|
143
|
+
*
|
|
144
|
+
* @param type - Human readable network name.
|
|
145
|
+
* @deprecated This has been replaced by `setActiveNetwork`, and will be
|
|
146
|
+
* removed in a future release
|
|
147
|
+
*/
|
|
148
|
+
export type NetworkControllerSetProviderTypeAction = {
|
|
149
|
+
type: `NetworkController:setProviderType`;
|
|
150
|
+
handler: NetworkController['setProviderType'];
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Changes the selected network.
|
|
154
|
+
*
|
|
155
|
+
* @param networkClientId - The ID of a network client that will be used to
|
|
156
|
+
* make requests.
|
|
157
|
+
* @param options - Options for this method.
|
|
158
|
+
* @param options.updateState - Allows for updating state.
|
|
159
|
+
* @throws if no network client is associated with the given
|
|
160
|
+
* network client ID.
|
|
161
|
+
*/
|
|
162
|
+
export type NetworkControllerSetActiveNetworkAction = {
|
|
163
|
+
type: `NetworkController:setActiveNetwork`;
|
|
164
|
+
handler: NetworkController['setActiveNetwork'];
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Determines whether the network supports EIP-1559 by checking whether the
|
|
168
|
+
* latest block has a `baseFeePerGas` property, then updates state
|
|
169
|
+
* appropriately.
|
|
170
|
+
*
|
|
171
|
+
* @param networkClientId - The networkClientId to fetch the correct provider against which to check 1559 compatibility.
|
|
172
|
+
* @returns A promise that resolves to true if the network supports EIP-1559
|
|
173
|
+
* , false otherwise, or `undefined` if unable to determine the compatibility.
|
|
174
|
+
*/
|
|
175
|
+
export type NetworkControllerGetEIP1559CompatibilityAction = {
|
|
176
|
+
type: `NetworkController:getEIP1559Compatibility`;
|
|
177
|
+
handler: NetworkController['getEIP1559Compatibility'];
|
|
178
|
+
};
|
|
179
|
+
export type NetworkControllerGet1559CompatibilityWithNetworkClientIdAction = {
|
|
180
|
+
type: `NetworkController:get1559CompatibilityWithNetworkClientId`;
|
|
181
|
+
handler: NetworkController['get1559CompatibilityWithNetworkClientId'];
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Ensures that the provider and block tracker proxies are pointed to the
|
|
185
|
+
* currently selected network and refreshes the metadata for the
|
|
186
|
+
*/
|
|
187
|
+
export type NetworkControllerResetConnectionAction = {
|
|
188
|
+
type: `NetworkController:resetConnection`;
|
|
189
|
+
handler: NetworkController['resetConnection'];
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Returns the network configuration that has been filed under the given chain
|
|
193
|
+
* ID.
|
|
194
|
+
*
|
|
195
|
+
* @param chainId - The chain ID to use as a key.
|
|
196
|
+
* @returns The network configuration if one exists, or undefined.
|
|
197
|
+
*/
|
|
198
|
+
export type NetworkControllerGetNetworkConfigurationByChainIdAction = {
|
|
199
|
+
type: `NetworkController:getNetworkConfigurationByChainId`;
|
|
200
|
+
handler: NetworkController['getNetworkConfigurationByChainId'];
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* Returns the network configuration that contains an RPC endpoint with the
|
|
204
|
+
* given network client ID.
|
|
205
|
+
*
|
|
206
|
+
* @param networkClientId - The network client ID to use as a key.
|
|
207
|
+
* @returns The network configuration if one exists, or undefined.
|
|
208
|
+
*/
|
|
209
|
+
export type NetworkControllerGetNetworkConfigurationByNetworkClientIdAction = {
|
|
210
|
+
type: `NetworkController:getNetworkConfigurationByNetworkClientId`;
|
|
211
|
+
handler: NetworkController['getNetworkConfigurationByNetworkClientId'];
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Creates and registers network clients for the collection of Infura and
|
|
215
|
+
* custom RPC endpoints that can be used to make requests for a particular
|
|
216
|
+
* chain, storing the given configuration object in state for later reference.
|
|
217
|
+
*
|
|
218
|
+
* @param fields - The object that describes the new network/chain and lists
|
|
219
|
+
* the RPC endpoints which front that chain.
|
|
220
|
+
* @returns The newly added network configuration.
|
|
221
|
+
* @throws if any part of `fields` would produce invalid state.
|
|
222
|
+
* @see {@link NetworkConfiguration}
|
|
223
|
+
*/
|
|
224
|
+
export type NetworkControllerAddNetworkAction = {
|
|
225
|
+
type: `NetworkController:addNetwork`;
|
|
226
|
+
handler: NetworkController['addNetwork'];
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Updates the configuration for a previously stored network filed under the
|
|
230
|
+
* given chain ID, creating + registering new network clients to represent RPC
|
|
231
|
+
* endpoints that have been added and destroying + unregistering existing
|
|
232
|
+
* network clients for RPC endpoints that have been removed.
|
|
233
|
+
*
|
|
234
|
+
* Note that if `chainId` is changed, then all network clients associated with
|
|
235
|
+
* that chain will be removed and re-added, even if none of the RPC endpoints
|
|
236
|
+
* have changed.
|
|
237
|
+
*
|
|
238
|
+
* @param chainId - The chain ID associated with an existing network.
|
|
239
|
+
* @param fields - The object that describes the updates to the network/chain,
|
|
240
|
+
* including the new set of RPC endpoints which should front that chain.
|
|
241
|
+
* @param options - Options to provide.
|
|
242
|
+
* @param options.replacementSelectedRpcEndpointIndex - Usually you cannot
|
|
243
|
+
* remove an RPC endpoint that is being represented by the currently selected
|
|
244
|
+
* network client. This option allows you to specify another RPC endpoint
|
|
245
|
+
* (either an existing one or a new one) that should be used to select a new
|
|
246
|
+
* network instead.
|
|
247
|
+
* @returns The updated network configuration.
|
|
248
|
+
* @throws if `chainId` does not refer to an existing network configuration,
|
|
249
|
+
* if any part of `fields` would produce invalid state, etc.
|
|
250
|
+
* @see {@link NetworkConfiguration}
|
|
251
|
+
*/
|
|
252
|
+
export type NetworkControllerUpdateNetworkAction = {
|
|
253
|
+
type: `NetworkController:updateNetwork`;
|
|
254
|
+
handler: NetworkController['updateNetwork'];
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Destroys and unregisters the network identified by the given chain ID, also
|
|
258
|
+
* removing the associated network configuration from state.
|
|
259
|
+
*
|
|
260
|
+
* @param chainId - The chain ID associated with an existing network.
|
|
261
|
+
* @throws if `chainId` does not refer to an existing network configuration,
|
|
262
|
+
* or if the currently selected network is being removed.
|
|
263
|
+
* @see {@link NetworkConfiguration}
|
|
264
|
+
*/
|
|
265
|
+
export type NetworkControllerRemoveNetworkAction = {
|
|
266
|
+
type: `NetworkController:removeNetwork`;
|
|
267
|
+
handler: NetworkController['removeNetwork'];
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Assuming that the network has been previously switched, switches to this
|
|
271
|
+
* new network.
|
|
272
|
+
*
|
|
273
|
+
* If the network has not been previously switched, this method is equivalent
|
|
274
|
+
* to {@link resetConnection}.
|
|
275
|
+
*/
|
|
276
|
+
export type NetworkControllerRollbackToPreviousProviderAction = {
|
|
277
|
+
type: `NetworkController:rollbackToPreviousProvider`;
|
|
278
|
+
handler: NetworkController['rollbackToPreviousProvider'];
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Merges the given backup data into controller state.
|
|
282
|
+
*
|
|
283
|
+
* @param backup - The data that has been backed up.
|
|
284
|
+
* @param backup.networkConfigurationsByChainId - Network configurations,
|
|
285
|
+
* keyed by chain ID.
|
|
286
|
+
*/
|
|
287
|
+
export type NetworkControllerLoadBackupAction = {
|
|
288
|
+
type: `NetworkController:loadBackup`;
|
|
289
|
+
handler: NetworkController['loadBackup'];
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Searches for the default RPC endpoint configured for the given chain and
|
|
293
|
+
* returns its network client ID. This can then be passed to
|
|
294
|
+
* {@link getNetworkClientById} to retrieve the network client.
|
|
295
|
+
*
|
|
296
|
+
* @param chainId - Chain ID to search for.
|
|
297
|
+
* @returns The ID of the network client created for the chain's default RPC
|
|
298
|
+
* endpoint.
|
|
299
|
+
*/
|
|
300
|
+
export type NetworkControllerFindNetworkClientIdByChainIdAction = {
|
|
301
|
+
type: `NetworkController:findNetworkClientIdByChainId`;
|
|
302
|
+
handler: NetworkController['findNetworkClientIdByChainId'];
|
|
303
|
+
};
|
|
304
|
+
/**
|
|
305
|
+
* Union of all NetworkController action types.
|
|
306
|
+
*/
|
|
307
|
+
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;
|
|
308
|
+
//# sourceMappingURL=NetworkController-method-action-types.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NetworkController-method-action-types.d.cts","sourceRoot":"","sources":["../src/NetworkController-method-action-types.ts"],"names":[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