@metamask-previews/network-controller
Advanced tools
Comparing version 17.0.0-preview.3fbb6b41 to 17.1.0-preview.1ef189c
@@ -8,2 +8,4 @@ # Changelog | ||
## [Unreleased] | ||
## [17.1.0] | ||
### Added | ||
@@ -13,2 +15,12 @@ - Add `getNetworkConfigurationByNetworkClientId` method which can be used to retrieve details for both custom and built-in networks (using the network configuration object shape) ([#2055](https://github.com/MetaMask/core/pull/2055)) | ||
### Changed | ||
- Bump `@metamask/base-controller` to `^4.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695)) | ||
- Bump `@metamask/controller-utils` to `^8.0.1` ([#3695](https://github.com/MetaMask/core/pull/3695), [#3678](https://github.com/MetaMask/core/pull/3678), [#3667](https://github.com/MetaMask/core/pull/3667), [#3580](https://github.com/MetaMask/core/pull/3580)) | ||
- Bump `@metamask/eth-json-rpc-provider` to `^2.3.1` ([#3695](https://github.com/MetaMask/core/pull/3695)) | ||
- Bump `@metamask/json-rpc-engine` to `^7.3.1` ([#3695](https://github.com/MetaMask/core/pull/3695)) | ||
- Create new network clients before updating `networkConfigurations` state ([#3679](https://github.com/MetaMask/core/pull/3679)) | ||
- This primarily affects subscribers to the `NetworkController:stateChange` event. It's now safe to use a network client for any network that appears in the `networkConfigurations` state, whereas previously it was possible that synchronous attempts to access a network client in response to this event would fail. | ||
- Add `NetworkState` payload to `NetworkController:networkWillChange` and `NetworkController:networkDidChange` ([#3598](https://github.com/MetaMask/core/pull/3598)) | ||
- Both of these events now include `NetworkState` as the first and only item in the payload | ||
## [17.0.0] | ||
@@ -323,3 +335,4 @@ ### Changed | ||
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.0.0...HEAD | ||
[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.1.0...HEAD | ||
[17.1.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.0.0...@metamask/network-controller@17.1.0 | ||
[17.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@16.0.0...@metamask/network-controller@17.0.0 | ||
@@ -326,0 +339,0 @@ [16.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@15.2.0...@metamask/network-controller@16.0.0 |
@@ -34,2 +34,4 @@ "use strict"; | ||
const providerProxy = new Proxy(UNINITIALIZED_TARGET, { | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
get(_target, propertyName, receiver) { | ||
@@ -52,2 +54,4 @@ if (propertyName === REFLECTIVE_PROPERTY_NAME) { | ||
// this allows private properties to be accessed | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return function (...args) { | ||
@@ -64,2 +68,4 @@ // @ts-expect-error We don't care that `this` may not be compatible | ||
}, | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
has(_target, propertyName) { | ||
@@ -75,2 +81,4 @@ if (propertyName === REFLECTIVE_PROPERTY_NAME) { | ||
const blockTrackerProxy = new Proxy(UNINITIALIZED_TARGET, { | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
get(_target, propertyName, receiver) { | ||
@@ -93,2 +101,4 @@ if (propertyName === REFLECTIVE_PROPERTY_NAME) { | ||
// this allows private properties to be accessed | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
return function (...args) { | ||
@@ -105,2 +115,4 @@ // @ts-expect-error We don't care that `this` may not be | ||
}, | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
has(_target, propertyName) { | ||
@@ -107,0 +119,0 @@ if (propertyName === REFLECTIVE_PROPERTY_NAME) { |
@@ -195,2 +195,8 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent, RestrictedControllerMessenger } from '@metamask/base-controller'; | ||
}; | ||
/** | ||
* Change the currently selected network to the given built-in network type. | ||
* | ||
* @deprecated This action has been replaced by `setActiveNetwork`, and will be | ||
* removed in a future release. | ||
*/ | ||
export declare type NetworkControllerSetProviderTypeAction = { | ||
@@ -296,2 +302,4 @@ type: `NetworkController:setProviderType`; | ||
* @param type - Human readable network name. | ||
* @deprecated This has been replaced by `setActiveNetwork`, and will be | ||
* removed in a future release | ||
*/ | ||
@@ -302,5 +310,6 @@ setProviderType(type: InfuraNetworkType): Promise<void>; | ||
* | ||
* @param networkConfigurationId - The unique id for the network configuration to set as the active provider. | ||
* @param networkConfigurationIdOrType - The unique id for the network configuration to set as the active provider, | ||
* or the type of a built-in network. | ||
*/ | ||
setActiveNetwork(networkConfigurationId: string): Promise<void>; | ||
setActiveNetwork(networkConfigurationIdOrType: string): Promise<void>; | ||
/** | ||
@@ -307,0 +316,0 @@ * Determines whether the network supports EIP-1559 by checking whether the |
@@ -54,3 +54,6 @@ "use strict"; | ||
*/ | ||
function knownKeysOf(object) { | ||
function knownKeysOf( | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
object) { | ||
return Object.keys(object); | ||
@@ -81,2 +84,4 @@ } | ||
*/ | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
function pick(object, keys) { | ||
@@ -469,2 +474,4 @@ const pickedObject = keys.reduce((finalObject, key) => { | ||
* @param type - Human readable network name. | ||
* @deprecated This has been replaced by `setActiveNetwork`, and will be | ||
* removed in a future release | ||
*/ | ||
@@ -496,20 +503,30 @@ setProviderType(type) { | ||
* | ||
* @param networkConfigurationId - The unique id for the network configuration to set as the active provider. | ||
* @param networkConfigurationIdOrType - The unique id for the network configuration to set as the active provider, | ||
* or the type of a built-in network. | ||
*/ | ||
setActiveNetwork(networkConfigurationId) { | ||
setActiveNetwork(networkConfigurationIdOrType) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
__classPrivateFieldSet(this, _NetworkController_previousProviderConfig, this.state.providerConfig, "f"); | ||
const targetNetwork = this.state.networkConfigurations[networkConfigurationId]; | ||
if (!targetNetwork) { | ||
throw new Error(`networkConfigurationId ${networkConfigurationId} does not match a configured networkConfiguration`); | ||
let targetNetwork; | ||
if ((0, controller_utils_1.isInfuraNetworkType)(networkConfigurationIdOrType)) { | ||
const ticker = controller_utils_1.NetworksTicker[networkConfigurationIdOrType]; | ||
targetNetwork = { | ||
chainId: controller_utils_1.ChainId[networkConfigurationIdOrType], | ||
id: undefined, | ||
rpcPrefs: controller_utils_1.BUILT_IN_NETWORKS[networkConfigurationIdOrType].rpcPrefs, | ||
rpcUrl: undefined, | ||
nickname: undefined, | ||
ticker, | ||
type: networkConfigurationIdOrType, | ||
}; | ||
} | ||
else { | ||
if (!Object.keys(this.state.networkConfigurations).includes(networkConfigurationIdOrType)) { | ||
throw new Error(`networkConfigurationId ${networkConfigurationIdOrType} does not match a configured networkConfiguration or built-in network type`); | ||
} | ||
targetNetwork = Object.assign(Object.assign({}, this.state.networkConfigurations[networkConfigurationIdOrType]), { type: controller_utils_1.NetworkType.rpc }); | ||
} | ||
__classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_ensureAutoManagedNetworkClientRegistryPopulated).call(this); | ||
this.update((state) => { | ||
state.providerConfig.type = controller_utils_1.NetworkType.rpc; | ||
state.providerConfig.rpcUrl = targetNetwork.rpcUrl; | ||
state.providerConfig.chainId = targetNetwork.chainId; | ||
state.providerConfig.ticker = targetNetwork.ticker; | ||
state.providerConfig.nickname = targetNetwork.nickname; | ||
state.providerConfig.rpcPrefs = targetNetwork.rpcPrefs; | ||
state.providerConfig.id = targetNetwork.id; | ||
state.providerConfig = targetNetwork; | ||
}); | ||
@@ -628,2 +645,4 @@ yield __classPrivateFieldGet(this, _NetworkController_instances, "m", _NetworkController_refreshNetwork).call(this); | ||
new URL(rpcUrl); | ||
// TODO: Replace `any` with type | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
} | ||
@@ -644,5 +663,2 @@ catch (e) { | ||
const networkClientId = buildCustomNetworkClientId(upsertedNetworkConfigurationId); | ||
this.update((state) => { | ||
state.networkConfigurations[upsertedNetworkConfigurationId] = Object.assign({ id: upsertedNetworkConfigurationId }, sanitizedNetworkConfiguration); | ||
}); | ||
const customNetworkClientRegistry = autoManagedNetworkClientRegistry[types_1.NetworkClientType.Custom]; | ||
@@ -665,2 +681,5 @@ const existingAutoManagedNetworkClient = customNetworkClientRegistry[networkClientId]; | ||
} | ||
this.update((state) => { | ||
state.networkConfigurations[upsertedNetworkConfigurationId] = Object.assign({ id: upsertedNetworkConfigurationId }, sanitizedNetworkConfiguration); | ||
}); | ||
if (!existingNetworkConfiguration) { | ||
@@ -667,0 +686,0 @@ __classPrivateFieldGet(this, _NetworkController_trackMetaMetricsEvent, "f").call(this, { |
{ | ||
"name": "@metamask-previews/network-controller", | ||
"version": "17.0.0-preview.3fbb6b41", | ||
"version": "17.1.0-preview.1ef189c", | ||
"description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object", | ||
@@ -25,2 +25,3 @@ "keywords": [ | ||
"build:docs": "typedoc", | ||
"changelog:update": "../../scripts/update-changelog.sh @metamask/network-controller", | ||
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/network-controller", | ||
@@ -34,12 +35,12 @@ "publish:preview": "yarn npm publish --tag preview", | ||
"dependencies": { | ||
"@metamask/base-controller": "^4.0.0", | ||
"@metamask/controller-utils": "^6.1.0", | ||
"@metamask/base-controller": "^4.1.0", | ||
"@metamask/controller-utils": "^8.0.1", | ||
"@metamask/eth-json-rpc-infura": "^9.0.0", | ||
"@metamask/eth-json-rpc-middleware": "^12.0.1", | ||
"@metamask/eth-json-rpc-provider": "^2.3.0", | ||
"@metamask/eth-json-rpc-provider": "^2.3.1", | ||
"@metamask/eth-query": "^4.0.0", | ||
"@metamask/json-rpc-engine": "^7.3.0", | ||
"@metamask/json-rpc-engine": "^7.3.1", | ||
"@metamask/rpc-errors": "^6.1.0", | ||
"@metamask/swappable-obj-proxy": "^2.1.0", | ||
"@metamask/utils": "^8.2.0", | ||
"@metamask/utils": "^8.3.0", | ||
"async-mutex": "^0.2.6", | ||
@@ -52,3 +53,3 @@ "eth-block-tracker": "^8.0.0", | ||
"@json-rpc-specification/meta-schema": "^1.0.6", | ||
"@metamask/auto-changelog": "^3.4.3", | ||
"@metamask/auto-changelog": "^3.4.4", | ||
"@types/jest": "^27.4.1", | ||
@@ -55,0 +56,0 @@ "@types/jest-when": "^2.7.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
235769
1840
+ Added@babel/runtime@7.26.9(transitive)
+ Added@metamask/controller-utils@8.0.4(transitive)
+ Added@metamask/ethjs-unit@0.3.0(transitive)
+ Added@metamask/number-to-bn@1.7.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
- Removed@metamask/controller-utils@6.1.0(transitive)
- Removed@metamask/ethjs-unit@0.2.1(transitive)
- Removed@types/bn.js@5.1.6(transitive)
- Removed@types/node@22.13.5(transitive)
- Removed@types/pbkdf2@3.1.2(transitive)
- Removed@types/secp256k1@4.0.6(transitive)
- Removedbase-x@3.0.10(transitive)
- Removedblakejs@1.2.1(transitive)
- Removedbn.js@4.11.64.12.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbrowserify-aes@1.2.0(transitive)
- Removedbs58@4.0.1(transitive)
- Removedbs58check@2.1.2(transitive)
- Removedbuffer-xor@1.0.3(transitive)
- Removedcipher-base@1.0.6(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedcreate-hmac@1.1.7(transitive)
- Removedelliptic@6.6.1(transitive)
- Removedethereum-cryptography@0.1.3(transitive)
- Removedethereumjs-util@7.1.5(transitive)
- Removedevp_bytestokey@1.0.3(transitive)
- Removedhash-base@3.1.0(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedkeccak@3.0.4(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removednode-addon-api@2.0.25.1.0(transitive)
- Removednode-gyp-build@4.8.4(transitive)
- Removednumber-to-bn@1.7.0(transitive)
- Removedpbkdf2@3.1.2(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedrlp@2.2.7(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedscrypt-js@3.0.1(transitive)
- Removedsecp256k1@4.0.4(transitive)
- Removedsetimmediate@1.0.5(transitive)
- Removedsha.js@2.4.11(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedundici-types@6.20.0(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updated@metamask/utils@^8.3.0