@metamask-previews/network-controller 20.2.0-preview-e8f9512d → 20.2.0-preview-b59ee0c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -0
- package/dist/NetworkController.js +4 -2
- package/dist/NetworkController.mjs +5 -3
- package/dist/chunk-IMWDJG6M.js +1467 -0
- package/dist/chunk-IMWDJG6M.js.map +1 -0
- package/dist/chunk-YJXBTFAE.mjs +1467 -0
- package/dist/chunk-YJXBTFAE.mjs.map +1 -0
- package/dist/index.js +4 -2
- package/dist/index.mjs +5 -3
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/NetworkController.d.ts +295 -99
- package/dist/types/NetworkController.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/chunk-BEL2VMHN.js +0 -968
- package/dist/chunk-BEL2VMHN.js.map +0 -1
- package/dist/chunk-RTMQACMX.mjs +0 -968
- package/dist/chunk-RTMQACMX.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,51 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **BREAKING:** Add `networkConfigurationsByChainId` to `NetworkState` (type: `Record<Hex, NetworkConfiguration>`) ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
13
|
+
- This property replaces `networkConfigurations`, and, as its name implies, organizes network configurations by chain ID rather than network client ID.
|
|
14
|
+
- If no initial state or this property is not included in initial state, the default value of this property will now include configurations for known Infura networks (Mainnet, Goerli, Sepolia, Linea Goerli, Linea Sepolia, and Linea Mainnet) by default.
|
|
15
|
+
- Add `getNetworkConfigurationByChainId` method, `NetworkController:getNetworkConfigurationByChainId` messenger action, and `NetworkControllerGetNetworkConfigurationByNetworkClientId` type ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
16
|
+
- Add `addNetwork`, which replaces one half of `upsertNetworkConfiguration` and can be used to add new network clients for a chain ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
17
|
+
- It's worth noting that this method now publishes a `NetworkController:networkAdded` event instead of calling a `trackMetaMetricsEvent` callback. It is expected that you will subscribe to this event and create a MetaMetrics event yourself.
|
|
18
|
+
- Add `updateNetwork`, which replaces one half of `upsertNetworkConfiguration` and can be used to recreate the network clients for an existing chain based on an updated configuration ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
19
|
+
- Note that it is not possible to remove the RPC endpoint from a network configuration that is currently represented by the globally selected network client. To prevent an error, you'll need to detect when such a removal is occurring and pass the `replacementSelectedRpcEndpointIndex` to `updateNetwork`. It will then switch to the designated RPC endpoint's network client on your behalf.
|
|
20
|
+
- Add `removeNetwork`, which replaces `removeNetworkConfiguration` and can be used to remove existing network clients for a chain ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
21
|
+
- Add `getDefaultNetworkControllerState` function, which replaces `defaultState` and matches patterns in other controllers ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
22
|
+
- Add `RpcEndpointType`, `AddNetworkFields`, and `UpdateNetworkFields` types ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **BREAKING:** Replace `NetworkConfiguration` type with a new definition ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
27
|
+
- A network configuration no longer represents a single RPC endpoint but rather a collection of RPC endpoints that can all be used to interface with a single chain.
|
|
28
|
+
- The only property that has brought over to this type unchanged is `chainId`.
|
|
29
|
+
- `ticker` has been renamed to `nativeCurrency`.
|
|
30
|
+
- `nickname` has been renamed to `name`.
|
|
31
|
+
- `rpcEndpoints` has been added. This is an an array of objects, where each object has properties `name` (optional), `networkClientId` (optional), `type`, and `url`.
|
|
32
|
+
- `defaultRpcEndpointIndex` has been added. This must point to an entry in `rpcEndpoints`.
|
|
33
|
+
- The block explorer URL is no longer located in `rpcPrefs` and is no longer restricted to one: `blockExplorerUrls` has been added along with a corresponding property `defaultBlockExplorerUrlIndex`, which must point to an entry in `blockExplorerUrls`.
|
|
34
|
+
- `id` has been removed. Previously, this represented the ID of the network client associated with the network configuration. Since network clients are now created from RPC endpoints, the equivalent to this is the `networkClientId` property on an `RpcEndpoint`.
|
|
35
|
+
- **BREAKING:** The network controller messenger must now allow the action `NetworkController:getNetworkConfigurationByChainId` ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
36
|
+
- **BREAKING:** The network controller messenger must now allow the event `NetworkController:networkAdded` ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
37
|
+
- **BREAKING:** The `NetworkController` constructor will now throw if the initial state provided is invalid ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
38
|
+
- `networkConfigurationsByChainId` cannot be empty.
|
|
39
|
+
- The `chainId` of a network configuration in `networkConfigurationsByChainId` must match the chain ID it is filed under.
|
|
40
|
+
- The `defaultRpcEndpointIndex` of a network configuration in `networkConfigurationsByChainId` must point to an entry in its `rpcEndpoints`.
|
|
41
|
+
- The `defaultBlockExplorerUrlIndex` of a network configuration in `networkConfigurationsByChainId` must point to an entry in its `blockExplorerUrls`.
|
|
42
|
+
- `selectedNetworkClientId` must match the `networkClientId` of an RPC endpoint in `networkConfigurationsByChainId`.
|
|
43
|
+
- **BREAKING:** Update `getNetworkConfigurationByNetworkClientId` so that when given an Infura network name (that is, a value from `InfuraNetworkType`), it will return a masked version of the RPC endpoint URL for the associated Infura network ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
44
|
+
- If you want the unmasked version, you'll need the `url` property from the network _client_ configuration, which you can get by calling `getNetworkClientById` and then accessing the `configuration` property off of the network client.
|
|
45
|
+
- **BREAKING:** Update `loadBackup` to take and update `networkConfigurationsByChainId` instead of `networkConfigurations` ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
46
|
+
|
|
47
|
+
### Removed
|
|
48
|
+
|
|
49
|
+
- **BREAKING:** Remove `networkConfigurations` from `NetworkState`, which has been replaced with `networkConfigurationsByChainId` ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
50
|
+
- **BREAKING:** Remove `upsertNetworkConfiguration` and `removeNetworkConfiguration`, which have been replaced with `addNetwork`, `updateNetwork`, and `removeNetwork` ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
51
|
+
- **BREAKING:** Remove `defaultState` variable, which has been replaced with a `getDefaultNetworkControllerState` function ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
52
|
+
- **BREAKING:** Remove `trackMetaMetricsEvent` option from the NetworkController constructor ([#4268](https://github.com/MetaMask/core/pull/4286))
|
|
53
|
+
- Previously, this was used in `upsertNetworkConfiguration` to create a MetaMetrics event when a new network was added. This can now be achieved by subscribing to the `NetworkController:networkAdded` event and creating the event inside of the event handler.
|
|
54
|
+
|
|
10
55
|
## [20.2.0]
|
|
11
56
|
|
|
12
57
|
### Changed
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
var _chunkIMWDJG6Mjs = require('./chunk-IMWDJG6M.js');
|
|
6
7
|
require('./chunk-ZKNI7MD3.js');
|
|
7
8
|
require('./chunk-LLMZDA4Q.js');
|
|
8
9
|
require('./chunk-E4V6XEBR.js');
|
|
@@ -13,5 +14,6 @@ require('./chunk-Z4BLTVTB.js');
|
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
|
|
18
|
+
exports.NetworkController = _chunkIMWDJG6Mjs.NetworkController; exports.RpcEndpointType = _chunkIMWDJG6Mjs.RpcEndpointType; exports.getDefaultNetworkControllerState = _chunkIMWDJG6Mjs.getDefaultNetworkControllerState; exports.knownKeysOf = _chunkIMWDJG6Mjs.knownKeysOf;
|
|
17
19
|
//# sourceMappingURL=NetworkController.js.map
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NetworkController,
|
|
3
|
-
|
|
3
|
+
RpcEndpointType,
|
|
4
|
+
getDefaultNetworkControllerState,
|
|
4
5
|
knownKeysOf
|
|
5
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-YJXBTFAE.mjs";
|
|
6
7
|
import "./chunk-2QJYHWIP.mjs";
|
|
7
8
|
import "./chunk-TZA3CBEI.mjs";
|
|
8
9
|
import "./chunk-U43RY4MY.mjs";
|
|
@@ -11,7 +12,8 @@ import "./chunk-AU4UVIPZ.mjs";
|
|
|
11
12
|
import "./chunk-XUI43LEZ.mjs";
|
|
12
13
|
export {
|
|
13
14
|
NetworkController,
|
|
14
|
-
|
|
15
|
+
RpcEndpointType,
|
|
16
|
+
getDefaultNetworkControllerState,
|
|
15
17
|
knownKeysOf
|
|
16
18
|
};
|
|
17
19
|
//# sourceMappingURL=NetworkController.mjs.map
|