@metamask-previews/network-controller 20.0.0-preview-e4ec85f → 20.0.0-preview-ee06f305

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.
@@ -1,12 +1,15 @@
1
1
  import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from '@metamask/base-controller';
2
2
  import { BaseController } from '@metamask/base-controller';
3
+ import type { Partialize } from '@metamask/controller-utils';
3
4
  import { InfuraNetworkType } from '@metamask/controller-utils';
4
5
  import EthQuery from '@metamask/eth-query';
5
6
  import type { SwappableProxy } from '@metamask/swappable-obj-proxy';
6
7
  import type { Hex } from '@metamask/utils';
8
+ import type { Draft } from 'immer';
7
9
  import type { Logger } from 'loglevel';
8
10
  import { NetworkStatus } from './constants';
9
11
  import type { AutoManagedNetworkClient, ProxyWithAccessibleTarget } from './create-auto-managed-network-client';
12
+ import { NetworkClientType } from './types';
10
13
  import type { BlockTracker, Provider, CustomNetworkClientConfiguration, InfuraNetworkClientConfiguration } from './types';
11
14
  export type Block = {
12
15
  baseFeePerGas?: string;
@@ -27,29 +30,173 @@ export type NetworkMetadata = {
27
30
  status: NetworkStatus;
28
31
  };
29
32
  /**
30
- * Custom RPC network information
33
+ * The type of an RPC endpoint.
31
34
  *
32
- * @property rpcUrl - RPC target URL.
33
- * @property chainId - Network ID as per EIP-155
34
- * @property nickname - Personalized network name.
35
- * @property ticker - Currency ticker.
36
- * @property rpcPrefs - Personalized preferences.
35
+ * @see {@link CustomRpcEndpoint}
36
+ * @see {@link InfuraRpcEndpoint}
37
+ */
38
+ export declare enum RpcEndpointType {
39
+ Custom = "custom",
40
+ Infura = "infura"
41
+ }
42
+ /**
43
+ * An Infura RPC endpoint is a reference to a specific network that Infura
44
+ * supports as well as an Infura account we own that we allow users to make use
45
+ * of for free. We need to disambiguate these endpoints from custom RPC
46
+ * endpoints, because while the types for these kinds of object both have the
47
+ * same interface, the URL for an Infura endpoint contains the Infura project
48
+ * ID, and we don't want this to be present in state. We therefore hide it by
49
+ * representing it in the URL as `{infuraProjectId}`, which we replace this when
50
+ * create network clients. But we need to know somehow that we only need to do
51
+ * this replacement for Infura endpoints and not custom endpoints — hence the
52
+ * separate type.
53
+ */
54
+ export type InfuraRpcEndpoint = {
55
+ /**
56
+ * The optional user-facing nickname of the endpoint.
57
+ */
58
+ name?: string;
59
+ /**
60
+ * The identifier for the network client that has been created for this RPC
61
+ * endpoint. This is also used to uniquely identify the RPC endpoint in a
62
+ * set of RPC endpoints as well: once assigned, it is used to determine
63
+ * whether the `name`, `type`, or `url` of the RPC endpoint has changed.
64
+ */
65
+ networkClientId: BuiltInNetworkClientId;
66
+ /**
67
+ * The type of this endpoint, always "default".
68
+ */
69
+ type: RpcEndpointType.Infura;
70
+ /**
71
+ * The URL of the endpoint. Expected to be a template with the string
72
+ * `{infuraProjectId}`, which will get replaced with the Infura project ID
73
+ * when the network client is created.
74
+ */
75
+ url: `https://${InfuraNetworkType}.infura.io/v3/{infuraProjectId}`;
76
+ };
77
+ /**
78
+ * A custom RPC endpoint is a reference to a user-defined server which fronts an
79
+ * EVM chain. It may refer to an Infura network, but only by coincidence.
80
+ */
81
+ export type CustomRpcEndpoint = {
82
+ /**
83
+ * The optional user-facing nickname of the endpoint.
84
+ */
85
+ name?: string;
86
+ /**
87
+ * The identifier for the network client that has been created for this RPC
88
+ * endpoint. This is also used to uniquely identify the RPC endpoint in a
89
+ * set of RPC endpoints as well: once assigned, it is used to determine
90
+ * whether the `name`, `type`, or `url` of the RPC endpoint has changed.
91
+ */
92
+ networkClientId: CustomNetworkClientId;
93
+ /**
94
+ * The type of this endpoint, always "custom".
95
+ */
96
+ type: RpcEndpointType.Custom;
97
+ /**
98
+ * The URL of the endpoint.
99
+ */
100
+ url: string;
101
+ };
102
+ /**
103
+ * An RPC endpoint is a reference to a server which fronts an EVM chain. There
104
+ * are two varieties of RPC endpoints: Infura and custom.
105
+ *
106
+ * @see {@link CustomRpcEndpoint}
107
+ * @see {@link InfuraRpcEndpoint}
108
+ */
109
+ export type RpcEndpoint = InfuraRpcEndpoint | CustomRpcEndpoint;
110
+ /**
111
+ * From a user perspective, a network configuration holds information about a
112
+ * network that a user can select through the client. A "network" in this sense
113
+ * can explicitly refer to an EVM chain that the user explicitly adds or doesn't
114
+ * need to add (because it comes shipped with the client). The properties here
115
+ * therefore directly map to fields that a user sees and can edit for a network
116
+ * within the client.
117
+ *
118
+ * Internally, a network configuration represents a single conceptual EVM chain,
119
+ * which is represented tangibly via multiple RPC endpoints. A "network" is then
120
+ * something for which a network client object is created automatically or
121
+ * created on demand when it is added to the client.
37
122
  */
38
123
  export type NetworkConfiguration = {
39
- rpcUrl: string;
124
+ /**
125
+ * A set of URLs that allows the user to view activity that has occurred on
126
+ * the chain.
127
+ */
128
+ blockExplorerUrls: string[];
129
+ /**
130
+ * The ID of the chain. Represented in hexadecimal format with a leading "0x"
131
+ * instead of decimal format so that when viewed out of context it can be
132
+ * unambiguously interpreted.
133
+ */
40
134
  chainId: Hex;
41
- ticker: string;
42
- nickname?: string;
43
- rpcPrefs?: {
44
- blockExplorerUrl: string;
45
- };
135
+ /**
136
+ * A reference to a URL that the client will use by default to allow the user
137
+ * to view activity that has occurred on the chain. This index must refer to
138
+ * an item in `blockExplorerUrls`.
139
+ */
140
+ defaultBlockExplorerUrlIndex?: number;
141
+ /**
142
+ * A reference to an RPC endpoint that all requests will use by default in order to
143
+ * interact with the chain. This index must refer to an item in
144
+ * `rpcEndpoints`.
145
+ */
146
+ defaultRpcEndpointIndex: number;
147
+ /**
148
+ * The user-facing nickname assigned to the chain.
149
+ */
150
+ name: string;
151
+ /**
152
+ * The name of the currency to use for the chain.
153
+ */
154
+ nativeCurrency: string;
155
+ /**
156
+ * The collection of possible RPC endpoints that the client can use to
157
+ * interact with the chain.
158
+ */
159
+ rpcEndpoints: RpcEndpoint[];
46
160
  };
47
161
  /**
48
- * The collection of network configurations in state.
162
+ * A custom RPC endpoint in a new network configuration, meant to be used in
163
+ * conjunction with `AddNetworkFields`.
164
+ *
165
+ * Custom RPC endpoints do not need a `networkClientId` property because it is
166
+ * assumed that they have not already been added and therefore network clients
167
+ * do not exist for them yet (and hence IDs need to be generated).
49
168
  */
50
- type NetworkConfigurations = Record<NetworkConfigurationId, NetworkConfiguration & {
51
- id: NetworkConfigurationId;
52
- }>;
169
+ export type AddNetworkCustomRpcEndpointFields = Omit<CustomRpcEndpoint, 'networkClientId'>;
170
+ /**
171
+ * A new network configuration that `addNetwork` takes.
172
+ *
173
+ * Custom RPC endpoints do not need a `networkClientId` property because it is
174
+ * assumed that they have not already been added and are not represented by
175
+ * network clients yet.
176
+ */
177
+ export type AddNetworkFields = Omit<NetworkConfiguration, 'rpcEndpoints'> & {
178
+ rpcEndpoints: (InfuraRpcEndpoint | AddNetworkCustomRpcEndpointFields)[];
179
+ };
180
+ /**
181
+ * A custom RPC endpoint in an updated representation of a network
182
+ * configuration, meant to be used in conjunction with `UpdateNetworkFields`.
183
+ *
184
+ * Custom RPC endpoints do not need a `networkClientId` property because it is
185
+ * assumed that they have not already been added and therefore network clients
186
+ * do not exist for them yet (and hence IDs need to be generated).
187
+ */
188
+ export type UpdateNetworkCustomRpcEndpointFields = Partialize<CustomRpcEndpoint, 'networkClientId'>;
189
+ /**
190
+ * An updated representation of an existing network configuration that
191
+ * `updateNetwork` takes.
192
+ *
193
+ * Custom RPC endpoints may or may not have a `networkClientId` property; if
194
+ * they do, then it is assumed that they already exist, and if not, then it is
195
+ * assumed that they are new and are not represented by network clients yet.
196
+ */
197
+ type UpdateNetworkFields = Omit<NetworkConfiguration, 'rpcEndpoints'> & {
198
+ rpcEndpoints: (InfuraRpcEndpoint | UpdateNetworkCustomRpcEndpointFields)[];
199
+ };
53
200
  /**
54
201
  * `Object.keys()` is intentionally generic: it returns the keys of an object,
55
202
  * but it cannot make guarantees about the contents of that object, so the type
@@ -77,24 +224,33 @@ export type CustomNetworkClientId = string;
77
224
  */
78
225
  export type NetworkClientId = BuiltInNetworkClientId | CustomNetworkClientId;
79
226
  /**
80
- * Information about networks not held by any other part of state.
227
+ * Extra information about each network, such as whether it is accessible or
228
+ * blocked and whether it supports EIP-1559, keyed by network client ID.
81
229
  */
82
- export type NetworksMetadata = {
83
- [networkClientId: NetworkClientId]: NetworkMetadata;
84
- };
230
+ export type NetworksMetadata = Record<NetworkClientId, NetworkMetadata>;
85
231
  /**
86
- * @type NetworkState
87
- *
88
- * Network controller state
89
- * @property properties - an additional set of network properties for the currently connected network
90
- * @property networkConfigurations - the full list of configured networks either preloaded or added by the user.
232
+ * The state that NetworkController stores.
91
233
  */
92
234
  export type NetworkState = {
235
+ /**
236
+ * The ID of the network client that the proxies returned by
237
+ * `getSelectedNetworkClient` currently point to.
238
+ */
93
239
  selectedNetworkClientId: NetworkClientId;
94
- networkConfigurations: NetworkConfigurations;
240
+ /**
241
+ * The registry of networks and corresponding RPC endpoints that the
242
+ * controller can use to make requests for various chains.
243
+ *
244
+ * @see {@link NetworkConfiguration}
245
+ */
246
+ networkConfigurationsByChainId: Record<Hex, NetworkConfiguration>;
247
+ /**
248
+ * Extra information about each network, such as whether it is accessible or
249
+ * blocked and whether it supports EIP-1559, keyed by network client ID.
250
+ */
95
251
  networksMetadata: NetworksMetadata;
96
252
  };
97
- declare const name = "NetworkController";
253
+ declare const controllerName = "NetworkController";
98
254
  /**
99
255
  * Represents the block tracker for the currently selected network. (Note that
100
256
  * this is a proxy around a proxy: the inner one exists so that the block
@@ -111,7 +267,7 @@ export type BlockTrackerProxy = SwappableProxy<ProxyWithAccessibleTarget<BlockTr
111
267
  * reference to that network.)
112
268
  */
113
269
  export type ProviderProxy = SwappableProxy<ProxyWithAccessibleTarget<Provider>>;
114
- export type NetworkControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, NetworkState>;
270
+ export type NetworkControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, NetworkState>;
115
271
  /**
116
272
  * `networkWillChange` is published when the current network is about to be
117
273
  * switched, but the new provider has not been created and no state changes have
@@ -147,8 +303,16 @@ export type NetworkControllerInfuraIsUnblockedEvent = {
147
303
  type: 'NetworkController:infuraIsUnblocked';
148
304
  payload: [];
149
305
  };
150
- export type NetworkControllerEvents = NetworkControllerStateChangeEvent | NetworkControllerNetworkWillChangeEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerInfuraIsBlockedEvent | NetworkControllerInfuraIsUnblockedEvent;
151
- export type NetworkControllerGetStateAction = ControllerGetStateAction<typeof name, NetworkState>;
306
+ /**
307
+ * `networkAdded` is published after a network configuration is added to the
308
+ * network configuration registry and network clients are created for it.
309
+ */
310
+ export type NetworkControllerNetworkAddedEvent = {
311
+ type: 'NetworkController:networkAdded';
312
+ payload: [networkConfiguration: NetworkConfiguration];
313
+ };
314
+ export type NetworkControllerEvents = NetworkControllerStateChangeEvent | NetworkControllerNetworkWillChangeEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerInfuraIsBlockedEvent | NetworkControllerInfuraIsUnblockedEvent | NetworkControllerNetworkAddedEvent;
315
+ export type NetworkControllerGetStateAction = ControllerGetStateAction<typeof controllerName, NetworkState>;
152
316
  export type NetworkControllerGetEthQueryAction = {
153
317
  type: `NetworkController:getEthQuery`;
154
318
  handler: () => EthQuery | undefined;
@@ -183,35 +347,51 @@ export type NetworkControllerSetActiveNetworkAction = {
183
347
  type: `NetworkController:setActiveNetwork`;
184
348
  handler: NetworkController['setActiveNetwork'];
185
349
  };
350
+ export type NetworkControllerGetNetworkConfigurationByChainId = {
351
+ type: `NetworkController:getNetworkConfigurationByChainId`;
352
+ handler: NetworkController['getNetworkConfigurationByChainId'];
353
+ };
186
354
  export type NetworkControllerGetNetworkConfigurationByNetworkClientId = {
187
355
  type: `NetworkController:getNetworkConfigurationByNetworkClientId`;
188
356
  handler: NetworkController['getNetworkConfigurationByNetworkClientId'];
189
357
  };
190
- export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerGetEthQueryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerSetActiveNetworkAction | NetworkControllerSetProviderTypeAction | NetworkControllerGetNetworkConfigurationByNetworkClientId;
191
- export type NetworkControllerMessenger = RestrictedControllerMessenger<typeof name, NetworkControllerActions, NetworkControllerEvents, never, never>;
358
+ export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerGetEthQueryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerSetActiveNetworkAction | NetworkControllerSetProviderTypeAction | NetworkControllerGetNetworkConfigurationByChainId | NetworkControllerGetNetworkConfigurationByNetworkClientId;
359
+ export type NetworkControllerMessenger = RestrictedControllerMessenger<typeof controllerName, NetworkControllerActions, NetworkControllerEvents, never, never>;
192
360
  export type NetworkControllerOptions = {
193
361
  messenger: NetworkControllerMessenger;
194
- trackMetaMetricsEvent: () => void;
195
362
  infuraProjectId: string;
196
363
  state?: Partial<NetworkState>;
197
364
  log?: Logger;
198
365
  };
199
- export declare const defaultState: NetworkState;
200
- type NetworkConfigurationId = string;
366
+ /**
367
+ * Constructs properties for the NetworkController state whose values will be
368
+ * used if not provided to the constructor.
369
+ *
370
+ * @returns The default NetworkController state.
371
+ */
372
+ export declare function getDefaultNetworkControllerState(): NetworkState;
201
373
  /**
202
374
  * The collection of auto-managed network clients that map to Infura networks.
203
375
  */
204
- type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
376
+ export type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
205
377
  /**
206
378
  * The collection of auto-managed network clients that map to Infura networks.
207
379
  */
208
- type AutoManagedCustomNetworkClientRegistry = Record<CustomNetworkClientId, AutoManagedNetworkClient<CustomNetworkClientConfiguration>>;
380
+ export type AutoManagedCustomNetworkClientRegistry = Record<CustomNetworkClientId, AutoManagedNetworkClient<CustomNetworkClientConfiguration>>;
381
+ /**
382
+ * The collection of auto-managed network clients that map to Infura networks
383
+ * as well as custom networks that users have added.
384
+ */
385
+ export type AutoManagedNetworkClientRegistry = {
386
+ [NetworkClientType.Infura]: AutoManagedBuiltInNetworkClientRegistry;
387
+ [NetworkClientType.Custom]: AutoManagedCustomNetworkClientRegistry;
388
+ };
209
389
  /**
210
390
  * Controller that creates and manages an Ethereum network provider.
211
391
  */
212
- export declare class NetworkController extends BaseController<typeof name, NetworkState, NetworkControllerMessenger> {
392
+ export declare class NetworkController extends BaseController<typeof controllerName, NetworkState, NetworkControllerMessenger> {
213
393
  #private;
214
- constructor({ messenger, state, infuraProjectId, trackMetaMetricsEvent, log, }: NetworkControllerOptions);
394
+ constructor({ messenger, state, infuraProjectId, log, }: NetworkControllerOptions);
215
395
  /**
216
396
  * Accesses the provider and block tracker for the currently selected network.
217
397
  * @returns The proxy and block tracker proxies.
@@ -231,12 +411,13 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
231
411
  blockTracker: SwappableProxy<ProxyWithAccessibleTarget<BlockTracker>>;
232
412
  } | undefined;
233
413
  /**
234
- * Returns all of the network clients that have been created so far, keyed by
235
- * their identifier in the network client registry. This collection represents
236
- * not only built-in networks but also any custom networks that consumers have
237
- * added.
414
+ * Internally, the Infura and custom network clients are categorized by type
415
+ * so that when accessing either kind of network client, TypeScript knows
416
+ * which type to assign to the network client. For some cases it's more useful
417
+ * to be able to access network clients by ID instead of by type and then ID,
418
+ * so this function makes that possible.
238
419
  *
239
- * @returns The list of known network clients.
420
+ * @returns The network clients registered so far, keyed by ID.
240
421
  */
241
422
  getNetworkClientRegistry(): AutoManagedBuiltInNetworkClientRegistry & AutoManagedCustomNetworkClientRegistry;
242
423
  /**
@@ -256,8 +437,9 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
256
437
  */
257
438
  getNetworkClientById(customNetworkClientId: CustomNetworkClientId): AutoManagedNetworkClient<CustomNetworkClientConfiguration>;
258
439
  /**
259
- * Creates network clients for built-in and custom networks, then establishes
260
- * the currently selected network client based on state.
440
+ * Ensures that network clients for Infura and custom RPC endpoints have been
441
+ * created. Then, consulting state, initializes and establishes the currently
442
+ * selected network client.
261
443
  */
262
444
  initializeProvider(): Promise<void>;
263
445
  /**
@@ -294,13 +476,16 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
294
476
  /**
295
477
  * Changes the selected network.
296
478
  *
297
- * @param networkClientId - The ID of a network client that requests will be
298
- * routed through (either the name of an Infura network or the ID of a custom
299
- * network configuration).
479
+ * @param networkClientId - The ID of a network client that will be used to
480
+ * make requests.
481
+ * @param options - Options for this method.
482
+ * @param options.updateState - Allows for updating state.
300
483
  * @throws if no network client is associated with the given
301
- * `networkClientId`.
484
+ * network client ID.
302
485
  */
303
- setActiveNetwork(networkClientId: string): Promise<void>;
486
+ setActiveNetwork(networkClientId: string, options?: {
487
+ updateState?: (state: Draft<NetworkState>) => void;
488
+ }): Promise<void>;
304
489
  /**
305
490
  * Determines whether the network supports EIP-1559 by checking whether the
306
491
  * latest block has a `baseFeePerGas` property, then updates state
@@ -318,56 +503,70 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
318
503
  */
319
504
  resetConnection(): Promise<void>;
320
505
  /**
321
- * Returns a configuration object for the network identified by the given
322
- * network client ID. If given an Infura network type, constructs one based on
323
- * what we know about the network; otherwise attempts locates a network
324
- * configuration in state that corresponds to the network client ID.
506
+ * Returns the network configuration that has been filed under the given chain
507
+ * ID.
325
508
  *
326
- * @param networkClientId - The network client ID.
327
- * @returns The configuration for the referenced network if one exists, or
328
- * undefined otherwise.
509
+ * @param chainId - The chain ID to use as a key.
510
+ * @returns The network configuration if one exists, or undefined.
329
511
  */
330
- getNetworkConfigurationByNetworkClientId(networkClientId: NetworkClientId): NetworkConfiguration | undefined;
512
+ getNetworkConfigurationByChainId(chainId: Hex): NetworkConfiguration | undefined;
331
513
  /**
332
- * Adds a new custom network or updates the information for an existing
333
- * network.
514
+ * Returns the network configuration that contains an RPC endpoint with the
515
+ * given network client ID.
334
516
  *
335
- * This may involve updating the `networkConfigurations` property in
336
- * state as well and/or adding a new network client to the network client
337
- * registry. The `rpcUrl` and `chainId` of the given object are used to
338
- * determine which action to take:
517
+ * @param networkClientId - The network client ID to use as a key.
518
+ * @returns The network configuration if one exists, or undefined.
519
+ */
520
+ getNetworkConfigurationByNetworkClientId(networkClientId: NetworkClientId): NetworkConfiguration | undefined;
521
+ /**
522
+ * Creates and registers network clients for the collection of Infura and
523
+ * custom RPC endpoints that can be used to make requests for a particular
524
+ * chain, storing the given configuration object in state for later reference.
339
525
  *
340
- * - If the `rpcUrl` corresponds to an existing network configuration
341
- * (case-insensitively), then it is overwritten with the object. Furthermore,
342
- * if the `chainId` is different from the existing network configuration, then
343
- * the existing network client is replaced with a new one.
344
- * - If the `rpcUrl` does not correspond to an existing network configuration
345
- * (case-insensitively), then the object is used to add a new network
346
- * configuration along with a new network client.
526
+ * @param fields - The object that describes the new network/chain and lists
527
+ * the RPC endpoints which front that chain.
528
+ * @returns The newly added network configuration.
529
+ * @throws if any part of `fields` would produce invalid state.
530
+ * @see {@link NetworkConfiguration}
531
+ */
532
+ addNetwork(fields: AddNetworkFields): NetworkConfiguration;
533
+ /**
534
+ * Updates the configuration for a previously stored network filed under the
535
+ * given chain ID, creating + registering new network clients to represent RPC
536
+ * endpoints that have been added and destroying + unregistering existing
537
+ * network clients for RPC endpoints that have been removed.
347
538
  *
348
- * @param networkConfiguration - The network configuration to add or update.
349
- * @param options - Additional configuration options.
350
- * @param options.referrer - Used to create a metrics event; the site from which the call originated, or 'metamask' for internal calls.
351
- * @param options.source - Used to create a metrics event; where the event originated (i.e. from a dapp or from the network form).
352
- * @param options.setActive - If true, switches to the network upon adding or updating it (default: false).
353
- * @returns The ID for the added or updated network configuration.
354
- */
355
- upsertNetworkConfiguration(networkConfiguration: NetworkConfiguration, { referrer, source, setActive, }: {
356
- referrer: string;
357
- source: string;
358
- setActive?: boolean;
359
- }): Promise<string>;
360
- /**
361
- * Removes a custom network from state.
539
+ * Note that if `chainId` is changed, then all network clients associated with
540
+ * that chain will be removed and re-added, even if none of the RPC endpoints
541
+ * have changed.
362
542
  *
363
- * This involves updating the `networkConfigurations` property in state as
364
- * well and removing the network client that corresponds to the network from
365
- * the client registry.
543
+ * @param chainId - The chain ID associated with an existing network.
544
+ * @param fields - The object that describes the updates to the network/chain,
545
+ * including the new set of RPC endpoints which should front that chain.
546
+ * @param options - Options to provide.
547
+ * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot
548
+ * remove an RPC endpoint that is being represented by the currently selected
549
+ * network client. This option allows you to specify another RPC endpoint
550
+ * (either an existing one or a new one) that should be used to select a new
551
+ * network instead.
552
+ * @returns The updated network configuration.
553
+ * @throws if `chainId` does not refer to an existing network configuration,
554
+ * if any part of `fields` would produce invalid state, etc.
555
+ * @see {@link NetworkConfiguration}
556
+ */
557
+ updateNetwork(chainId: Hex, fields: UpdateNetworkFields, { replacementSelectedRpcEndpointIndex, }?: {
558
+ replacementSelectedRpcEndpointIndex?: number;
559
+ }): Promise<NetworkConfiguration>;
560
+ /**
561
+ * Destroys and unregisters the network identified by the given chain ID, also
562
+ * removing the associated network configuration from state.
366
563
  *
367
- * @param networkConfigurationId - The ID of an existing network
368
- * configuration.
564
+ * @param chainId - The chain ID associated with an existing network.
565
+ * @throws if `chainId` does not refer to an existing network configuration,
566
+ * or if the currently selected network is being removed.
567
+ * @see {@link NetworkConfiguration}
369
568
  */
370
- removeNetworkConfiguration(networkConfigurationId: string): void;
569
+ removeNetwork(chainId: Hex): void;
371
570
  /**
372
571
  * Assuming that the network has been previously switched, switches to this
373
572
  * new network.
@@ -383,14 +582,13 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
383
582
  */
384
583
  destroy(): Promise<void>;
385
584
  /**
386
- * Updates the controller using the given backup data.
585
+ * Merges the given backup data into controller state.
387
586
  *
388
587
  * @param backup - The data that has been backed up.
389
- * @param backup.networkConfigurations - Network configurations in the backup.
588
+ * @param backup.networkConfigurationsByChainId - Network configurations,
589
+ * keyed by chain ID.
390
590
  */
391
- loadBackup({ networkConfigurations, }: {
392
- networkConfigurations: NetworkState['networkConfigurations'];
393
- }): void;
591
+ loadBackup({ networkConfigurationsByChainId, }: Pick<NetworkState, 'networkConfigurationsByChainId'>): void;
394
592
  /**
395
593
  * Searches for a network configuration ID with the given ChainID and returns it.
396
594
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkController.d.ts","sourceRoot":"","sources":["../../src/NetworkController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAEL,iBAAiB,EAIlB,MAAM,4BAA4B,CAAC;AACpC,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAG3C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAO3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGvC,OAAO,EAAsB,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAI9C,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,gCAAgC,EAChC,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAIjB,MAAM,MAAM,KAAK,GAAG;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IAGH,IAAI,EAAE;QACJ,CAAC,SAAS,E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5D"}
@@ -1,4 +1,5 @@
1
- export * from './NetworkController';
1
+ export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, } from './NetworkController';
2
+ export { getDefaultNetworkControllerState, knownKeysOf, NetworkController, RpcEndpointType, } from './NetworkController';
2
3
  export * from './constants';
3
4
  export type { BlockTracker, Provider } from './types';
4
5
  export type { NetworkClientConfiguration } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,qBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,iCAAiC,EACjC,uCAAuC,EACvC,sCAAsC,EACtC,qCAAqC,EACrC,uCAAuC,EACvC,uBAAuB,EACvB,+BAA+B,EAC/B,kCAAkC,EAClC,2CAA2C,EAC3C,+CAA+C,EAC/C,8CAA8C,EAC9C,mDAAmD,EACnD,sCAAsC,EACtC,uCAAuC,EACvC,yDAAyD,EACzD,wBAAwB,EACxB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gCAAgC,EAChC,WAAW,EACX,iBAAiB,EACjB,eAAe,GAChB,MAAM,qBAAqB,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/network-controller",
3
- "version": "20.0.0-preview-e4ec85f",
3
+ "version": "20.0.0-preview-ee06f305",
4
4
  "description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -51,10 +51,11 @@
51
51
  "@metamask/json-rpc-engine": "^9.0.1",
52
52
  "@metamask/rpc-errors": "^6.3.1",
53
53
  "@metamask/swappable-obj-proxy": "^2.2.0",
54
- "@metamask/utils": "^9.0.0",
54
+ "@metamask/utils": "^9.1.0",
55
55
  "async-mutex": "^0.5.0",
56
56
  "immer": "^9.0.6",
57
57
  "loglevel": "^1.8.1",
58
+ "uri-js": "^4.4.1",
58
59
  "uuid": "^8.3.2"
59
60
  },
60
61
  "devDependencies": {