@metamask-previews/network-controller 20.0.0-preview-5ba43a24 → 20.0.0-preview-e4ec85f

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,15 +1,12 @@
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';
4
3
  import { InfuraNetworkType } from '@metamask/controller-utils';
5
4
  import EthQuery from '@metamask/eth-query';
6
5
  import type { SwappableProxy } from '@metamask/swappable-obj-proxy';
7
6
  import type { Hex } from '@metamask/utils';
8
- import type { Draft } from 'immer';
9
7
  import type { Logger } from 'loglevel';
10
8
  import { NetworkStatus } from './constants';
11
9
  import type { AutoManagedNetworkClient, ProxyWithAccessibleTarget } from './create-auto-managed-network-client';
12
- import { NetworkClientType } from './types';
13
10
  import type { BlockTracker, Provider, CustomNetworkClientConfiguration, InfuraNetworkClientConfiguration } from './types';
14
11
  export type Block = {
15
12
  baseFeePerGas?: string;
@@ -30,173 +27,29 @@ export type NetworkMetadata = {
30
27
  status: NetworkStatus;
31
28
  };
32
29
  /**
33
- * The type of an RPC endpoint.
30
+ * Custom RPC network information
34
31
  *
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.
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.
122
37
  */
123
38
  export type NetworkConfiguration = {
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
- */
39
+ rpcUrl: string;
134
40
  chainId: Hex;
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)[];
41
+ ticker: string;
42
+ nickname?: string;
43
+ rpcPrefs?: {
44
+ blockExplorerUrl: string;
45
+ };
179
46
  };
180
47
  /**
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).
48
+ * The collection of network configurations in state.
187
49
  */
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
- };
50
+ type NetworkConfigurations = Record<NetworkConfigurationId, NetworkConfiguration & {
51
+ id: NetworkConfigurationId;
52
+ }>;
200
53
  /**
201
54
  * `Object.keys()` is intentionally generic: it returns the keys of an object,
202
55
  * but it cannot make guarantees about the contents of that object, so the type
@@ -224,33 +77,24 @@ export type CustomNetworkClientId = string;
224
77
  */
225
78
  export type NetworkClientId = BuiltInNetworkClientId | CustomNetworkClientId;
226
79
  /**
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.
80
+ * Information about networks not held by any other part of state.
229
81
  */
230
- export type NetworksMetadata = Record<NetworkClientId, NetworkMetadata>;
82
+ export type NetworksMetadata = {
83
+ [networkClientId: NetworkClientId]: NetworkMetadata;
84
+ };
231
85
  /**
232
- * The state that NetworkController stores.
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.
233
91
  */
234
92
  export type NetworkState = {
235
- /**
236
- * The ID of the network client that the proxies returned by
237
- * `getSelectedNetworkClient` currently point to.
238
- */
239
93
  selectedNetworkClientId: NetworkClientId;
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
- */
94
+ networkConfigurations: NetworkConfigurations;
251
95
  networksMetadata: NetworksMetadata;
252
96
  };
253
- declare const controllerName = "NetworkController";
97
+ declare const name = "NetworkController";
254
98
  /**
255
99
  * Represents the block tracker for the currently selected network. (Note that
256
100
  * this is a proxy around a proxy: the inner one exists so that the block
@@ -267,7 +111,7 @@ export type BlockTrackerProxy = SwappableProxy<ProxyWithAccessibleTarget<BlockTr
267
111
  * reference to that network.)
268
112
  */
269
113
  export type ProviderProxy = SwappableProxy<ProxyWithAccessibleTarget<Provider>>;
270
- export type NetworkControllerStateChangeEvent = ControllerStateChangeEvent<typeof controllerName, NetworkState>;
114
+ export type NetworkControllerStateChangeEvent = ControllerStateChangeEvent<typeof name, NetworkState>;
271
115
  /**
272
116
  * `networkWillChange` is published when the current network is about to be
273
117
  * switched, but the new provider has not been created and no state changes have
@@ -303,16 +147,8 @@ export type NetworkControllerInfuraIsUnblockedEvent = {
303
147
  type: 'NetworkController:infuraIsUnblocked';
304
148
  payload: [];
305
149
  };
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>;
150
+ export type NetworkControllerEvents = NetworkControllerStateChangeEvent | NetworkControllerNetworkWillChangeEvent | NetworkControllerNetworkDidChangeEvent | NetworkControllerInfuraIsBlockedEvent | NetworkControllerInfuraIsUnblockedEvent;
151
+ export type NetworkControllerGetStateAction = ControllerGetStateAction<typeof name, NetworkState>;
316
152
  export type NetworkControllerGetEthQueryAction = {
317
153
  type: `NetworkController:getEthQuery`;
318
154
  handler: () => EthQuery | undefined;
@@ -347,51 +183,35 @@ export type NetworkControllerSetActiveNetworkAction = {
347
183
  type: `NetworkController:setActiveNetwork`;
348
184
  handler: NetworkController['setActiveNetwork'];
349
185
  };
350
- export type NetworkControllerGetNetworkConfigurationByChainId = {
351
- type: `NetworkController:getNetworkConfigurationByChainId`;
352
- handler: NetworkController['getNetworkConfigurationByChainId'];
353
- };
354
186
  export type NetworkControllerGetNetworkConfigurationByNetworkClientId = {
355
187
  type: `NetworkController:getNetworkConfigurationByNetworkClientId`;
356
188
  handler: NetworkController['getNetworkConfigurationByNetworkClientId'];
357
189
  };
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>;
190
+ export type NetworkControllerActions = NetworkControllerGetStateAction | NetworkControllerGetEthQueryAction | NetworkControllerGetNetworkClientByIdAction | NetworkControllerGetSelectedNetworkClientAction | NetworkControllerGetEIP1559CompatibilityAction | NetworkControllerFindNetworkClientIdByChainIdAction | NetworkControllerSetActiveNetworkAction | NetworkControllerSetProviderTypeAction | NetworkControllerGetNetworkConfigurationByNetworkClientId;
191
+ export type NetworkControllerMessenger = RestrictedControllerMessenger<typeof name, NetworkControllerActions, NetworkControllerEvents, never, never>;
360
192
  export type NetworkControllerOptions = {
361
193
  messenger: NetworkControllerMessenger;
194
+ trackMetaMetricsEvent: () => void;
362
195
  infuraProjectId: string;
363
196
  state?: Partial<NetworkState>;
364
197
  log?: Logger;
365
198
  };
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;
199
+ export declare const defaultState: NetworkState;
200
+ type NetworkConfigurationId = string;
373
201
  /**
374
202
  * The collection of auto-managed network clients that map to Infura networks.
375
203
  */
376
- export type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
204
+ type AutoManagedBuiltInNetworkClientRegistry = Record<BuiltInNetworkClientId, AutoManagedNetworkClient<InfuraNetworkClientConfiguration>>;
377
205
  /**
378
206
  * The collection of auto-managed network clients that map to Infura networks.
379
207
  */
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
- };
208
+ type AutoManagedCustomNetworkClientRegistry = Record<CustomNetworkClientId, AutoManagedNetworkClient<CustomNetworkClientConfiguration>>;
389
209
  /**
390
210
  * Controller that creates and manages an Ethereum network provider.
391
211
  */
392
- export declare class NetworkController extends BaseController<typeof controllerName, NetworkState, NetworkControllerMessenger> {
212
+ export declare class NetworkController extends BaseController<typeof name, NetworkState, NetworkControllerMessenger> {
393
213
  #private;
394
- constructor({ messenger, state, infuraProjectId, log, }: NetworkControllerOptions);
214
+ constructor({ messenger, state, infuraProjectId, trackMetaMetricsEvent, log, }: NetworkControllerOptions);
395
215
  /**
396
216
  * Accesses the provider and block tracker for the currently selected network.
397
217
  * @returns The proxy and block tracker proxies.
@@ -411,13 +231,12 @@ export declare class NetworkController extends BaseController<typeof controllerN
411
231
  blockTracker: SwappableProxy<ProxyWithAccessibleTarget<BlockTracker>>;
412
232
  } | undefined;
413
233
  /**
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.
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.
419
238
  *
420
- * @returns The network clients registered so far, keyed by ID.
239
+ * @returns The list of known network clients.
421
240
  */
422
241
  getNetworkClientRegistry(): AutoManagedBuiltInNetworkClientRegistry & AutoManagedCustomNetworkClientRegistry;
423
242
  /**
@@ -437,9 +256,8 @@ export declare class NetworkController extends BaseController<typeof controllerN
437
256
  */
438
257
  getNetworkClientById(customNetworkClientId: CustomNetworkClientId): AutoManagedNetworkClient<CustomNetworkClientConfiguration>;
439
258
  /**
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.
259
+ * Creates network clients for built-in and custom networks, then establishes
260
+ * the currently selected network client based on state.
443
261
  */
444
262
  initializeProvider(): Promise<void>;
445
263
  /**
@@ -476,16 +294,13 @@ export declare class NetworkController extends BaseController<typeof controllerN
476
294
  /**
477
295
  * Changes the selected network.
478
296
  *
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.
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).
483
300
  * @throws if no network client is associated with the given
484
- * network client ID.
301
+ * `networkClientId`.
485
302
  */
486
- setActiveNetwork(networkClientId: string, options?: {
487
- updateState?: (state: Draft<NetworkState>) => void;
488
- }): Promise<void>;
303
+ setActiveNetwork(networkClientId: string): Promise<void>;
489
304
  /**
490
305
  * Determines whether the network supports EIP-1559 by checking whether the
491
306
  * latest block has a `baseFeePerGas` property, then updates state
@@ -503,70 +318,56 @@ export declare class NetworkController extends BaseController<typeof controllerN
503
318
  */
504
319
  resetConnection(): Promise<void>;
505
320
  /**
506
- * Returns the network configuration that has been filed under the given chain
507
- * ID.
508
- *
509
- * @param chainId - The chain ID to use as a key.
510
- * @returns The network configuration if one exists, or undefined.
511
- */
512
- getNetworkConfigurationByChainId(chainId: Hex): NetworkConfiguration | undefined;
513
- /**
514
- * Returns the network configuration that contains an RPC endpoint with the
515
- * given network client ID.
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.
516
325
  *
517
- * @param networkClientId - The network client ID to use as a key.
518
- * @returns The network configuration if one exists, or undefined.
326
+ * @param networkClientId - The network client ID.
327
+ * @returns The configuration for the referenced network if one exists, or
328
+ * undefined otherwise.
519
329
  */
520
330
  getNetworkConfigurationByNetworkClientId(networkClientId: NetworkClientId): NetworkConfiguration | undefined;
521
331
  /**
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.
332
+ * Adds a new custom network or updates the information for an existing
333
+ * network.
525
334
  *
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.
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:
538
339
  *
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.
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.
542
347
  *
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.
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.
362
+ *
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.
563
366
  *
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}
367
+ * @param networkConfigurationId - The ID of an existing network
368
+ * configuration.
568
369
  */
569
- removeNetwork(chainId: Hex): void;
370
+ removeNetworkConfiguration(networkConfigurationId: string): void;
570
371
  /**
571
372
  * Assuming that the network has been previously switched, switches to this
572
373
  * new network.
@@ -582,13 +383,14 @@ export declare class NetworkController extends BaseController<typeof controllerN
582
383
  */
583
384
  destroy(): Promise<void>;
584
385
  /**
585
- * Merges the given backup data into controller state.
386
+ * Updates the controller using the given backup data.
586
387
  *
587
388
  * @param backup - The data that has been backed up.
588
- * @param backup.networkConfigurationsByChainId - Network configurations,
589
- * keyed by chain ID.
389
+ * @param backup.networkConfigurations - Network configurations in the backup.
590
390
  */
591
- loadBackup({ networkConfigurationsByChainId, }: Pick<NetworkState, 'networkConfigurationsByChainId'>): void;
391
+ loadBackup({ networkConfigurations, }: {
392
+ networkConfigurations: NetworkState['networkConfigurations'];
393
+ }): void;
592
394
  /**
593
395
  * Searches for a network configuration ID with the given ChainID and returns it.
594
396
  *
@@ -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,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAEL,iBAAiB,EAOlB,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;AAQ3C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAKvC,OAAO,EAAsB,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EACV,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,gCAAgC,EAChC,gCAAgC,EAEjC,MAAM,SAAS,CAAC;AAOjB,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,EAAE,MAAM,GAAG,OAAO,CAAC;KAC9B,CAAC;IACF;;OAEG;IACH,MAAM,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF;;;;;GAKG;AACH,oBAAY,eAAe;IACzB,MA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oHrD;;;;;;OAMG;IACG,eAAe,CAAC,IAAI,EAAE,iBAAiB;IAkB7C;;;;;;;;OAQG;IACG,gBAAgB,CAAC,eAAe,EAAE,MAAM;IAqC9C;;;;;;;;OAQG;IACG,uBAAuB,CAAC,eAAe,CAAC,EAAE,eAAe;IA2BzD,uCAAuC,CAC3C,eAAe,EAAE,eAAe;IAkClC;;;OAGG;IACG,eAAe;IAIrB;;;;;;;;;OASG;IACH,wCAAwC,CACtC,eAAe,EAAE,eAAe,GAC/B,oBAAoB,GAAG,SAAS;IAgBnC;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,0BAA0B,CAC9B,oBAAoB,EAAE,oBAAoB,EAC1C,EACE,QAAQ,EACR,MAAM,EACN,SAAiB,GAClB,EAAE;QACD,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,GACA,OAAO,CAAC,MAAM,CAAC;IA0GlB;;;;;;;;;OASG;IACH,0BAA0B,CAAC,sBAAsB,EAAE,MAAM;IAuBzD;;;;;;OAMG;IACG,0BAA0B;IAIhC;;;;OAIG;IACG,OAAO;IAIb;;;;;OAKG;IACH,UAAU,CAAC,EACT,qBAAqB,GACtB,EAAE;QACD,qBAAqB,EAAE,YAAY,CAAC,uBAAuB,CAAC,CAAC;KAC9D,GAAG,IAAI;IASR;;;;;OAKG;IACH,4BAA4B,CAAC,OAAO,EAAE,GAAG,GAAG,eAAe;CAwM5D"}
@@ -1,5 +1,4 @@
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';
1
+ export * from './NetworkController';
3
2
  export * from './constants';
4
3
  export type { BlockTracker, Provider } from './types';
5
4
  export type { NetworkClientConfiguration } from './types';
@@ -1 +1 @@
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"}
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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/network-controller",
3
- "version": "20.0.0-preview-5ba43a24",
3
+ "version": "20.0.0-preview-e4ec85f",
4
4
  "description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -55,7 +55,6 @@
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",
59
58
  "uuid": "^8.3.2"
60
59
  },
61
60
  "devDependencies": {