@metamask/network-controller 20.1.0 → 21.0.0

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[];
160
+ };
161
+ /**
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).
168
+ */
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)[];
46
179
  };
47
180
  /**
48
- * The collection of network configurations in state.
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.
49
196
  */
50
- type NetworkConfigurations = Record<NetworkConfigurationId, NetworkConfiguration & {
51
- id: NetworkConfigurationId;
52
- }>;
197
+ export 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,86 @@ 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;
373
+ /**
374
+ * Get a list of all network configurations.
375
+ *
376
+ * @param state - NetworkController state
377
+ * @returns A list of all available network configurations
378
+ */
379
+ export declare function getNetworkConfigurations(state: NetworkState): NetworkConfiguration[];
380
+ /**
381
+ * Get a list of all available client IDs from a list of
382
+ * network configurations
383
+ * @param networkConfigurations - The array of network configurations
384
+ * @returns A list of all available client IDs
385
+ */
386
+ export declare function getAvailableNetworkClientIds(networkConfigurations: NetworkConfiguration[]): string[];
387
+ export declare const selectAvailableNetworkClientIds: ((state: NetworkState) => string[]) & {
388
+ clearCache: () => void;
389
+ resultsCount: () => number;
390
+ resetResultsCount: () => void;
391
+ } & {
392
+ resultFunc: (resultFuncArgs_0: NetworkConfiguration[]) => string[];
393
+ memoizedResultFunc: ((resultFuncArgs_0: NetworkConfiguration[]) => string[]) & {
394
+ clearCache: () => void;
395
+ resultsCount: () => number;
396
+ resetResultsCount: () => void;
397
+ };
398
+ lastResult: () => string[];
399
+ dependencies: [typeof getNetworkConfigurations];
400
+ recomputations: () => number;
401
+ resetRecomputations: () => void;
402
+ dependencyRecomputations: () => number;
403
+ resetDependencyRecomputations: () => void;
404
+ } & {
405
+ argsMemoize: typeof import("reselect").weakMapMemoize;
406
+ memoize: typeof import("reselect").weakMapMemoize;
407
+ };
201
408
  /**
202
409
  * The collection of auto-managed network clients that map to Infura networks.
203
410
  */
204
- type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
411
+ export type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
205
412
  /**
206
413
  * The collection of auto-managed network clients that map to Infura networks.
207
414
  */
208
- type AutoManagedCustomNetworkClientRegistry = Record<CustomNetworkClientId, AutoManagedNetworkClient<CustomNetworkClientConfiguration>>;
415
+ export type AutoManagedCustomNetworkClientRegistry = Record<CustomNetworkClientId, AutoManagedNetworkClient<CustomNetworkClientConfiguration>>;
416
+ /**
417
+ * The collection of auto-managed network clients that map to Infura networks
418
+ * as well as custom networks that users have added.
419
+ */
420
+ export type AutoManagedNetworkClientRegistry = {
421
+ [NetworkClientType.Infura]: AutoManagedBuiltInNetworkClientRegistry;
422
+ [NetworkClientType.Custom]: AutoManagedCustomNetworkClientRegistry;
423
+ };
209
424
  /**
210
425
  * Controller that creates and manages an Ethereum network provider.
211
426
  */
212
- export declare class NetworkController extends BaseController<typeof name, NetworkState, NetworkControllerMessenger> {
427
+ export declare class NetworkController extends BaseController<typeof controllerName, NetworkState, NetworkControllerMessenger> {
213
428
  #private;
214
- constructor({ messenger, state, infuraProjectId, trackMetaMetricsEvent, log, }: NetworkControllerOptions);
429
+ constructor({ messenger, state, infuraProjectId, log, }: NetworkControllerOptions);
215
430
  /**
216
431
  * Accesses the provider and block tracker for the currently selected network.
217
432
  * @returns The proxy and block tracker proxies.
@@ -231,12 +446,13 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
231
446
  blockTracker: SwappableProxy<ProxyWithAccessibleTarget<BlockTracker>>;
232
447
  } | undefined;
233
448
  /**
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.
449
+ * Internally, the Infura and custom network clients are categorized by type
450
+ * so that when accessing either kind of network client, TypeScript knows
451
+ * which type to assign to the network client. For some cases it's more useful
452
+ * to be able to access network clients by ID instead of by type and then ID,
453
+ * so this function makes that possible.
238
454
  *
239
- * @returns The list of known network clients.
455
+ * @returns The network clients registered so far, keyed by ID.
240
456
  */
241
457
  getNetworkClientRegistry(): AutoManagedBuiltInNetworkClientRegistry & AutoManagedCustomNetworkClientRegistry;
242
458
  /**
@@ -256,8 +472,9 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
256
472
  */
257
473
  getNetworkClientById(customNetworkClientId: CustomNetworkClientId): AutoManagedNetworkClient<CustomNetworkClientConfiguration>;
258
474
  /**
259
- * Creates network clients for built-in and custom networks, then establishes
260
- * the currently selected network client based on state.
475
+ * Ensures that network clients for Infura and custom RPC endpoints have been
476
+ * created. Then, consulting state, initializes and establishes the currently
477
+ * selected network client.
261
478
  */
262
479
  initializeProvider(): Promise<void>;
263
480
  /**
@@ -294,13 +511,16 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
294
511
  /**
295
512
  * Changes the selected network.
296
513
  *
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).
514
+ * @param networkClientId - The ID of a network client that will be used to
515
+ * make requests.
516
+ * @param options - Options for this method.
517
+ * @param options.updateState - Allows for updating state.
300
518
  * @throws if no network client is associated with the given
301
- * `networkClientId`.
519
+ * network client ID.
302
520
  */
303
- setActiveNetwork(networkClientId: string): Promise<void>;
521
+ setActiveNetwork(networkClientId: string, options?: {
522
+ updateState?: (state: Draft<NetworkState>) => void;
523
+ }): Promise<void>;
304
524
  /**
305
525
  * Determines whether the network supports EIP-1559 by checking whether the
306
526
  * latest block has a `baseFeePerGas` property, then updates state
@@ -318,56 +538,70 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
318
538
  */
319
539
  resetConnection(): Promise<void>;
320
540
  /**
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.
541
+ * Returns the network configuration that has been filed under the given chain
542
+ * ID.
325
543
  *
326
- * @param networkClientId - The network client ID.
327
- * @returns The configuration for the referenced network if one exists, or
328
- * undefined otherwise.
544
+ * @param chainId - The chain ID to use as a key.
545
+ * @returns The network configuration if one exists, or undefined.
329
546
  */
330
- getNetworkConfigurationByNetworkClientId(networkClientId: NetworkClientId): NetworkConfiguration | undefined;
547
+ getNetworkConfigurationByChainId(chainId: Hex): NetworkConfiguration | undefined;
331
548
  /**
332
- * Adds a new custom network or updates the information for an existing
333
- * network.
549
+ * Returns the network configuration that contains an RPC endpoint with the
550
+ * given network client ID.
334
551
  *
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:
552
+ * @param networkClientId - The network client ID to use as a key.
553
+ * @returns The network configuration if one exists, or undefined.
554
+ */
555
+ getNetworkConfigurationByNetworkClientId(networkClientId: NetworkClientId): NetworkConfiguration | undefined;
556
+ /**
557
+ * Creates and registers network clients for the collection of Infura and
558
+ * custom RPC endpoints that can be used to make requests for a particular
559
+ * chain, storing the given configuration object in state for later reference.
339
560
  *
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.
561
+ * @param fields - The object that describes the new network/chain and lists
562
+ * the RPC endpoints which front that chain.
563
+ * @returns The newly added network configuration.
564
+ * @throws if any part of `fields` would produce invalid state.
565
+ * @see {@link NetworkConfiguration}
566
+ */
567
+ addNetwork(fields: AddNetworkFields): NetworkConfiguration;
568
+ /**
569
+ * Updates the configuration for a previously stored network filed under the
570
+ * given chain ID, creating + registering new network clients to represent RPC
571
+ * endpoints that have been added and destroying + unregistering existing
572
+ * network clients for RPC endpoints that have been removed.
347
573
  *
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.
574
+ * Note that if `chainId` is changed, then all network clients associated with
575
+ * that chain will be removed and re-added, even if none of the RPC endpoints
576
+ * have changed.
362
577
  *
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.
578
+ * @param chainId - The chain ID associated with an existing network.
579
+ * @param fields - The object that describes the updates to the network/chain,
580
+ * including the new set of RPC endpoints which should front that chain.
581
+ * @param options - Options to provide.
582
+ * @param options.replacementSelectedRpcEndpointIndex - Usually you cannot
583
+ * remove an RPC endpoint that is being represented by the currently selected
584
+ * network client. This option allows you to specify another RPC endpoint
585
+ * (either an existing one or a new one) that should be used to select a new
586
+ * network instead.
587
+ * @returns The updated network configuration.
588
+ * @throws if `chainId` does not refer to an existing network configuration,
589
+ * if any part of `fields` would produce invalid state, etc.
590
+ * @see {@link NetworkConfiguration}
591
+ */
592
+ updateNetwork(chainId: Hex, fields: UpdateNetworkFields, { replacementSelectedRpcEndpointIndex, }?: {
593
+ replacementSelectedRpcEndpointIndex?: number;
594
+ }): Promise<NetworkConfiguration>;
595
+ /**
596
+ * Destroys and unregisters the network identified by the given chain ID, also
597
+ * removing the associated network configuration from state.
366
598
  *
367
- * @param networkConfigurationId - The ID of an existing network
368
- * configuration.
599
+ * @param chainId - The chain ID associated with an existing network.
600
+ * @throws if `chainId` does not refer to an existing network configuration,
601
+ * or if the currently selected network is being removed.
602
+ * @see {@link NetworkConfiguration}
369
603
  */
370
- removeNetworkConfiguration(networkConfigurationId: string): void;
604
+ removeNetwork(chainId: Hex): void;
371
605
  /**
372
606
  * Assuming that the network has been previously switched, switches to this
373
607
  * new network.
@@ -383,14 +617,13 @@ export declare class NetworkController extends BaseController<typeof name, Netwo
383
617
  */
384
618
  destroy(): Promise<void>;
385
619
  /**
386
- * Updates the controller using the given backup data.
620
+ * Merges the given backup data into controller state.
387
621
  *
388
622
  * @param backup - The data that has been backed up.
389
- * @param backup.networkConfigurations - Network configurations in the backup.
623
+ * @param backup.networkConfigurationsByChainId - Network configurations,
624
+ * keyed by chain ID.
390
625
  */
391
- loadBackup({ networkConfigurations, }: {
392
- networkConfigurations: NetworkState['networkConfigurations'];
393
- }): void;
626
+ loadBackup({ networkConfigurationsByChainId, }: Pick<NetworkState, 'networkConfigurationsByChainId'>): void;
394
627
  /**
395
628
  * Searches for a network configuration ID with the given ChainID and returns it.
396
629
  *
@@ -1 +1 @@
1
- {"version":3,"file":"NetworkController.d.ts","sourceRoot":"","sources":["../../src/NetworkController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EAC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eAAe,EAAE,MAAM,EACvB,OAAO,GAAE;QACP,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,KAAK,IAAI,CAAC;KAC/C;IAsCR;;;;;;;;OAQG;IACG,uBAAuB,CAAC,eAAe,CAAC,EAAE,eAAe;IA2BzD,uCAAuC,CAC3C,eAAe,EAAE,eAAe;IAkClC;;;OAGG;IACG,eAAe;IAIrB;;;;;;OAMG;IACH,gCAAgC,CAC9B,OAAO,EAAE,GAAG,GACX,oBAAoB,GAAG,SAAS;IAInC;;;;;;OAMG;IACH,wCAAwC,CACtC,eAAe,EAAE,eAAe,GAC/B,oBAAoB,GAAG,SAAS;IAInC;;;;;;;;;;OAUG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB;IA4D1D;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,aAAa,CACjB,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,mBAAmB,EAC3B,EACE,mCAAmC,GACpC,GAAE;QAAE,mCAAmC,CAAC,EAAE,MAAM,CAAA;KAAO,GACvD,OAAO,CAAC,oBAAoB,CAAC;IA+PhC;;;;;;;;OAQG;IACH,aAAa,CAAC,OAAO,EAAE,GAAG;IAgD1B;;;;;;OAMG;IACG,0BAA0B;IAIhC;;;;OAIG;IACG,OAAO;IAIb;;;;;;OAMG;IACH,UAAU,CAAC,EACT,8BAA8B,GAC/B,EAAE,IAAI,CAAC,YAAY,EAAE,gCAAgC,CAAC,GAAG,IAAI;IAS9D;;;;;OAKG;IACH,4BAA4B,CAAC,OAAO,EAAE,GAAG,GAAG,eAAe;CAsnB5D"}
@@ -1,5 +1,6 @@
1
1
  export type { AutoManagedNetworkClient } from './create-auto-managed-network-client';
2
- export * from './NetworkController';
2
+ export type { Block, NetworkMetadata, NetworkConfiguration, BuiltInNetworkClientId, CustomNetworkClientId, NetworkClientId, NetworksMetadata, NetworkState, BlockTrackerProxy, ProviderProxy, AddNetworkFields, UpdateNetworkFields, NetworkControllerStateChangeEvent, NetworkControllerNetworkWillChangeEvent, NetworkControllerNetworkDidChangeEvent, NetworkControllerInfuraIsBlockedEvent, NetworkControllerInfuraIsUnblockedEvent, NetworkControllerEvents, NetworkControllerGetStateAction, NetworkControllerGetEthQueryAction, NetworkControllerGetNetworkClientByIdAction, NetworkControllerGetSelectedNetworkClientAction, NetworkControllerGetEIP1559CompatibilityAction, NetworkControllerFindNetworkClientIdByChainIdAction, NetworkControllerSetProviderTypeAction, NetworkControllerSetActiveNetworkAction, NetworkControllerGetNetworkConfigurationByNetworkClientId, NetworkControllerActions, NetworkControllerMessenger, NetworkControllerOptions, } from './NetworkController';
3
+ export { getDefaultNetworkControllerState, selectAvailableNetworkClientIds, knownKeysOf, NetworkController, RpcEndpointType, } from './NetworkController';
3
4
  export * from './constants';
4
5
  export type { BlockTracker, Provider } from './types';
5
6
  export type { NetworkClientConfiguration, InfuraNetworkClientConfiguration, CustomNetworkClientConfiguration, } from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACtD,YAAY,EACV,0BAA0B,EAC1B,gCAAgC,EAChC,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,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,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AACrF,YAAY,EACV,KAAK,EACL,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,qBA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