From 9045a26b8483580191b33abba4ab15a3901ff751 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Fri, 17 Nov 2023 12:01:01 -0700 Subject: [PATCH 01/17] Release 93.0.0 --- package.json | 2 +- packages/accounts-controller/CHANGELOG.md | 9 +- packages/accounts-controller/package.json | 8 +- packages/address-book-controller/CHANGELOG.md | 10 +- packages/address-book-controller/package.json | 6 +- packages/announcement-controller/CHANGELOG.md | 8 +- packages/announcement-controller/package.json | 4 +- packages/approval-controller/CHANGELOG.md | 9 +- packages/approval-controller/package.json | 4 +- packages/assets-controllers/CHANGELOG.md | 29 +- packages/assets-controllers/package.json | 20 +- packages/base-controller/CHANGELOG.md | 21 +- packages/base-controller/package.json | 2 +- packages/composable-controller/CHANGELOG.md | 8 +- packages/composable-controller/package.json | 4 +- packages/controller-utils/CHANGELOG.md | 13 +- packages/controller-utils/package.json | 2 +- packages/ens-controller/CHANGELOG.md | 10 +- packages/ens-controller/package.json | 10 +- packages/gas-fee-controller/CHANGELOG.md | 11 +- packages/gas-fee-controller/package.json | 12 +- packages/keyring-controller/CHANGELOG.md | 10 +- packages/keyring-controller/package.json | 10 +- packages/logging-controller/CHANGELOG.md | 9 +- packages/logging-controller/package.json | 6 +- packages/message-manager/CHANGELOG.md | 10 +- packages/message-manager/package.json | 6 +- packages/name-controller/CHANGELOG.md | 9 +- packages/name-controller/package.json | 4 +- packages/network-controller/CHANGELOG.md | 9 +- packages/network-controller/package.json | 6 +- packages/notification-controller/CHANGELOG.md | 9 +- packages/notification-controller/package.json | 4 +- packages/permission-controller/CHANGELOG.md | 10 +- packages/permission-controller/package.json | 10 +- .../permission-log-controller/package.json | 2 +- packages/phishing-controller/CHANGELOG.md | 9 +- packages/phishing-controller/package.json | 6 +- packages/polling-controller/CHANGELOG.md | 10 +- packages/polling-controller/package.json | 10 +- packages/preferences-controller/CHANGELOG.md | 16 +- packages/preferences-controller/package.json | 6 +- .../queued-request-controller/CHANGELOG.md | 11 +- .../queued-request-controller/package.json | 16 +- packages/rate-limit-controller/CHANGELOG.md | 9 +- packages/rate-limit-controller/package.json | 4 +- .../selected-network-controller/CHANGELOG.md | 9 +- .../selected-network-controller/package.json | 8 +- packages/signature-controller/CHANGELOG.md | 13 +- packages/signature-controller/package.json | 20 +- packages/transaction-controller/CHANGELOG.md | 13 +- packages/transaction-controller/package.json | 18 +- yarn.lock | 265 ++++++++++++------ 53 files changed, 536 insertions(+), 223 deletions(-) diff --git a/package.json b/package.json index e09c881acc..0d646be478 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/core-monorepo", - "version": "92.0.0", + "version": "93.0.0", "private": true, "description": "Monorepo for packages shared between MetaMask clients", "repository": { diff --git a/packages/accounts-controller/CHANGELOG.md b/packages/accounts-controller/CHANGELOG.md index b051ebb997..d01717fe3d 100644 --- a/packages/accounts-controller/CHANGELOG.md +++ b/packages/accounts-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/keyring-controller` to ^10.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [5.0.0] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/keyring-controller` to ^9.0.0 @@ -46,7 +52,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release ([#1637](https://github.com/MetaMask/core/pull/1637)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@5.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@6.0.0...HEAD +[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@5.0.0...@metamask/accounts-controller@6.0.0 [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@4.0.0...@metamask/accounts-controller@5.0.0 [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@3.0.0...@metamask/accounts-controller@4.0.0 [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/accounts-controller@2.0.2...@metamask/accounts-controller@3.0.0 diff --git a/packages/accounts-controller/package.json b/packages/accounts-controller/package.json index 3e6d2753e6..6c9275aaa0 100644 --- a/packages/accounts-controller/package.json +++ b/packages/accounts-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/accounts-controller", - "version": "5.0.0", + "version": "6.0.0", "description": "Manages internal accounts", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/eth-snap-keyring": "^2.0.0", "@metamask/keyring-api": "^1.1.0", "@metamask/snaps-utils": "^3.2.0", @@ -42,7 +42,7 @@ }, "devDependencies": { "@metamask/auto-changelog": "^3.4.3", - "@metamask/keyring-controller": "^9.0.0", + "@metamask/keyring-controller": "^10.0.0", "@metamask/snaps-controllers": "^3.2.0", "@types/jest": "^27.4.1", "@types/readable-stream": "^2.3.0", @@ -53,7 +53,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/keyring-controller": "^9.0.0" + "@metamask/keyring-controller": "^10.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/address-book-controller/CHANGELOG.md b/packages/address-book-controller/CHANGELOG.md index 9bef1b08c6..3af21bfd08 100644 --- a/packages/address-book-controller/CHANGELOG.md +++ b/packages/address-book-controller/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [3.1.5] +### Changed +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) +- Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is not a breaking change because this controller still inherits from BaseController v1. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [3.1.4] ### Changed - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639)) @@ -61,7 +68,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.4...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.5...HEAD +[3.1.5]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.4...@metamask/address-book-controller@3.1.5 [3.1.4]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.3...@metamask/address-book-controller@3.1.4 [3.1.3]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.2...@metamask/address-book-controller@3.1.3 [3.1.2]: https://github.com/MetaMask/core/compare/@metamask/address-book-controller@3.1.1...@metamask/address-book-controller@3.1.2 diff --git a/packages/address-book-controller/package.json b/packages/address-book-controller/package.json index 3d12e67146..63c9923046 100644 --- a/packages/address-book-controller/package.json +++ b/packages/address-book-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/address-book-controller", - "version": "3.1.4", + "version": "3.1.5", "description": "Manages a list of recipient addresses associated with nicknames", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/utils": "^8.2.0" }, "devDependencies": { diff --git a/packages/announcement-controller/CHANGELOG.md b/packages/announcement-controller/CHANGELOG.md index 2d882c6ee7..76c7eed599 100644 --- a/packages/announcement-controller/CHANGELOG.md +++ b/packages/announcement-controller/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. + ## [4.0.3] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -65,7 +70,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@4.0.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@5.0.0...HEAD +[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@4.0.3...@metamask/announcement-controller@5.0.0 [4.0.3]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@4.0.2...@metamask/announcement-controller@4.0.3 [4.0.2]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@4.0.1...@metamask/announcement-controller@4.0.2 [4.0.1]: https://github.com/MetaMask/core/compare/@metamask/announcement-controller@4.0.0...@metamask/announcement-controller@4.0.1 diff --git a/packages/announcement-controller/package.json b/packages/announcement-controller/package.json index 5d3fe2f92e..af395df2c2 100644 --- a/packages/announcement-controller/package.json +++ b/packages/announcement-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/announcement-controller", - "version": "4.0.3", + "version": "5.0.0", "description": "Manages in-app announcements", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3" + "@metamask/base-controller": "^4.0.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.3", diff --git a/packages/approval-controller/CHANGELOG.md b/packages/approval-controller/CHANGELOG.md index ea3df7430e..ada134284a 100644 --- a/packages/approval-controller/CHANGELOG.md +++ b/packages/approval-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 (TODO: THIS PR) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) + ## [4.1.0] ### Added - Add `show` option for `startFlow` ([#1886](https://github.com/MetaMask/core/pull/1886)) @@ -91,7 +97,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@4.1.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@5.0.0...HEAD +[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@4.1.0...@metamask/approval-controller@5.0.0 [4.1.0]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@4.0.1...@metamask/approval-controller@4.1.0 [4.0.1]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@4.0.0...@metamask/approval-controller@4.0.1 [4.0.0]: https://github.com/MetaMask/core/compare/@metamask/approval-controller@3.5.2...@metamask/approval-controller@4.0.0 diff --git a/packages/approval-controller/package.json b/packages/approval-controller/package.json index 2c6fcc5e4e..97550dee93 100644 --- a/packages/approval-controller/package.json +++ b/packages/approval-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/approval-controller", - "version": "4.1.0", + "version": "5.0.0", "description": "Manages requests that require user approval", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/rpc-errors": "^6.1.0", "@metamask/utils": "^8.2.0", "nanoid": "^3.1.31" diff --git a/packages/assets-controllers/CHANGELOG.md b/packages/assets-controllers/CHANGELOG.md index 4908fe541f..4a77d29c5a 100644 --- a/packages/assets-controllers/CHANGELOG.md +++ b/packages/assets-controllers/CHANGELOG.md @@ -6,6 +6,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [20.0.0] +### Added +- **BREAKING**: `TokenRatesControllerState` now has required `contractExchangeRatesByChainId` property which an object keyed by `chainId` and `nativeCurrency` ([#2015](https://github.com/MetaMask/core/pull/2015)) +- **BREAKING**: `TokenRatesController` constructor params now requires `getNetworkClientById` ([#2015](https://github.com/MetaMask/core/pull/2015)) +- Add types `CurrencyRateControllerEvents` and `CurrencyRateControllerActions` ([#2029](https://github.com/MetaMask/core/pull/2029)) +- Add polling-related methods to TokenRatesController ([#2015](https://github.com/MetaMask/core/pull/2015)) + - `startPollingByNetworkClientId` + - `stopPollingByPollingToken` + - `stopAllPolling` + - `_executePoll` +- Add `updateExchangeRatesByChainId` method to TokenRatesController ([#2015](https://github.com/MetaMask/core/pull/2015)) + - This is a lower-level version of `updateExchangeRates` that takes chain ID, native currency, and token addresses. +- `TokenRatesController` constructor params now accepts optional `interval` and `threshold` ([#2015](https://github.com/MetaMask/core/pull/2015)) +- `TokenRatesController.fetchExchangeRate()` now accepts an optional `tokenAddresses` as the last parameter ([#2015](https://github.com/MetaMask/core/pull/2015)) +- `TokenRatesController.getChainSlug()` now accepts an optional `chainId` parameter ([#2015](https://github.com/MetaMask/core/pull/2015)) +- `TokenRatesController.fetchAndMapExchangeRates()` now accepts an optional `tokenAddresses` as the last parameter ([#2015](https://github.com/MetaMask/core/pull/2015)) + +### Changed +- **BREAKING:** Bump dependency on `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/polling-controller` to ^2.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/preferences-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [19.0.0] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -383,7 +409,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Use Ethers for AssetsContractController ([#845](https://github.com/MetaMask/core/pull/845)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@19.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@20.0.0...HEAD +[20.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@19.0.0...@metamask/assets-controllers@20.0.0 [19.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@18.0.0...@metamask/assets-controllers@19.0.0 [18.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@17.0.0...@metamask/assets-controllers@18.0.0 [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/assets-controllers@16.0.0...@metamask/assets-controllers@17.0.0 diff --git a/packages/assets-controllers/package.json b/packages/assets-controllers/package.json index 373f7fbb03..23ad1c9e8a 100644 --- a/packages/assets-controllers/package.json +++ b/packages/assets-controllers/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/assets-controllers", - "version": "19.0.0", + "version": "20.0.0", "description": "Controllers which manage interactions involving ERC-20, ERC-721, and ERC-1155 tokens (including NFTs)", "keywords": [ "MetaMask", @@ -35,15 +35,15 @@ "@ethersproject/contracts": "^5.7.0", "@ethersproject/providers": "^5.7.0", "@metamask/abi-utils": "^2.0.2", - "@metamask/approval-controller": "^4.1.0", - "@metamask/base-controller": "^3.2.3", + "@metamask/approval-controller": "^5.0.0", + "@metamask/base-controller": "^4.0.0", "@metamask/contract-metadata": "^2.4.0", - "@metamask/controller-utils": "^5.0.2", + "@metamask/controller-utils": "^6.0.0", "@metamask/eth-query": "^4.0.0", "@metamask/metamask-eth-abis": "3.0.0", - "@metamask/network-controller": "^16.0.0", - "@metamask/polling-controller": "^1.0.2", - "@metamask/preferences-controller": "^4.4.3", + "@metamask/network-controller": "^17.0.0", + "@metamask/polling-controller": "^2.0.0", + "@metamask/preferences-controller": "^5.0.0", "@metamask/rpc-errors": "^6.1.0", "@metamask/utils": "^8.2.0", "@types/uuid": "^8.3.0", @@ -69,9 +69,9 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/approval-controller": "^4.1.0", - "@metamask/network-controller": "^16.0.0", - "@metamask/preferences-controller": "^4.4.3" + "@metamask/approval-controller": "^5.0.0", + "@metamask/network-controller": "^17.0.0", + "@metamask/preferences-controller": "^5.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 485aad9898..f0a4453ad6 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Added +- Add `ControllerGetStateAction` and `ControllerStateChangeEvent` types ([#1890](https://github.com/MetaMask/core/pull/1890), [#2029](https://github.com/MetaMask/core/pull/2029)) +- Add `NamespacedName` type ([#1890](https://github.com/MetaMask/core/pull/1890)) + - This is the narrowest supertype of all names defined within a given namespace. + +### Changed +- **BREAKING:** Narrow controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) + - This type is now defined as the universal supertype of all action handlers, meaning any functions can be safely assigned to it, regardless of argument types, number of arguments, or return value type. +- **BREAKING:** Alter controller messenger `ActionHandler` type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Alter controller messenger `ExtractActionParameters` utility type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Alter controller messenger `ExtractEventHandler` utility type so `Event` type parameter must satisfy `EventConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Alter controller messenger `ExtractEventPayload` utility type so `Event` type parameter must satisfy `EventConstraint` and `Event['payload']` must be an array (to match behavior of `ExtractEventHandler`) ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Alter `controller messenger SelectorFunction` type so its `Event` parameter must satisfy `EventConstraint`, and so it returns a function whose arguments satisfy an event payload via `ExtractEventPayload` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- The restricted controller messenger now allows calling all internal events and actions ([#2050](https://github.com/MetaMask/core/pull/2050)) + - Previously internal events and actions were only usable if they were listed as "allowed". They are still permitted to be listed as "allowed" now, but it is no longer necessary. +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) + ## [3.2.3] ### Changed - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639)) @@ -73,7 +91,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/base-controller@3.2.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/base-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/base-controller@3.2.3...@metamask/base-controller@4.0.0 [3.2.3]: https://github.com/MetaMask/core/compare/@metamask/base-controller@3.2.2...@metamask/base-controller@3.2.3 [3.2.2]: https://github.com/MetaMask/core/compare/@metamask/base-controller@3.2.1...@metamask/base-controller@3.2.2 [3.2.1]: https://github.com/MetaMask/core/compare/@metamask/base-controller@3.2.0...@metamask/base-controller@3.2.1 diff --git a/packages/base-controller/package.json b/packages/base-controller/package.json index 1197743585..b9e96696b2 100644 --- a/packages/base-controller/package.json +++ b/packages/base-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/base-controller", - "version": "3.2.3", + "version": "4.0.0", "description": "Provides scaffolding for controllers as well a communication system for all controllers", "keywords": [ "MetaMask", diff --git a/packages/composable-controller/CHANGELOG.md b/packages/composable-controller/CHANGELOG.md index ca14172c27..b759c02157 100644 --- a/packages/composable-controller/CHANGELOG.md +++ b/packages/composable-controller/CHANGELOG.md @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. + ## [3.0.3] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -45,7 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@3.0.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@3.0.3...@metamask/composable-controller@4.0.0 [3.0.3]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@3.0.2...@metamask/composable-controller@3.0.3 [3.0.2]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@3.0.1...@metamask/composable-controller@3.0.2 [3.0.1]: https://github.com/MetaMask/core/compare/@metamask/composable-controller@3.0.0...@metamask/composable-controller@3.0.1 diff --git a/packages/composable-controller/package.json b/packages/composable-controller/package.json index 0006b03970..50afea72d9 100644 --- a/packages/composable-controller/package.json +++ b/packages/composable-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/composable-controller", - "version": "3.0.3", + "version": "4.0.0", "description": "Consolidates the state from multiple controllers into one", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3" + "@metamask/base-controller": "^4.0.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.3", diff --git a/packages/controller-utils/CHANGELOG.md b/packages/controller-utils/CHANGELOG.md index 87637f475f..cc485f46ab 100644 --- a/packages/controller-utils/CHANGELOG.md +++ b/packages/controller-utils/CHANGELOG.md @@ -5,8 +5,16 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [6.0.0] ### Changed -- Bump dependency `@metamask/eth-query` from ^3.0.1 to ^4.0.0 ([#2028](https://github.com/MetaMask/core/pull/2028)) +- **BREAKING:** Bump `@metamask/eth-query` to ^4.0.0 ([#2028](https://github.com/MetaMask/core/pull/2028)) + - This affects `query`: the `sendAsync` method on the given EthQuery must now have a narrower type +- Bump `@metamask/utils` from ^8.1.0 to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) +- Change `BUILT_IN_NETWORKS` so that `rpc` entry now has a dummy `ticker` ([#1794](https://github.com/MetaMask/core/pull/1794)) + +### Fixed +- Move `@metamask/eth-query` from a development dependency to a runtime dependency ([#1815](https://github.com/MetaMask/core/pull/1815)) ## [5.0.2] ### Changed @@ -169,7 +177,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@5.0.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@6.0.0...HEAD +[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@5.0.2...@metamask/controller-utils@6.0.0 [5.0.2]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@5.0.1...@metamask/controller-utils@5.0.2 [5.0.1]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@5.0.0...@metamask/controller-utils@5.0.1 [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/controller-utils@4.3.2...@metamask/controller-utils@5.0.0 diff --git a/packages/controller-utils/package.json b/packages/controller-utils/package.json index 2300e11e73..23e82390de 100644 --- a/packages/controller-utils/package.json +++ b/packages/controller-utils/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/controller-utils", - "version": "5.0.2", + "version": "6.0.0", "description": "Data and convenience functions shared by multiple packages", "keywords": [ "MetaMask", diff --git a/packages/ens-controller/CHANGELOG.md b/packages/ens-controller/CHANGELOG.md index e592300a04..7cbd01e78e 100644 --- a/packages/ens-controller/CHANGELOG.md +++ b/packages/ens-controller/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [6.0.1] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -86,7 +93,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@6.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@7.0.0...HEAD +[7.0.0]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@6.0.1...@metamask/ens-controller@7.0.0 [6.0.1]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@6.0.0...@metamask/ens-controller@6.0.1 [6.0.0]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@5.0.2...@metamask/ens-controller@6.0.0 [5.0.2]: https://github.com/MetaMask/core/compare/@metamask/ens-controller@5.0.1...@metamask/ens-controller@5.0.2 diff --git a/packages/ens-controller/package.json b/packages/ens-controller/package.json index 9371005e60..a8f69c3af7 100644 --- a/packages/ens-controller/package.json +++ b/packages/ens-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/ens-controller", - "version": "6.0.1", + "version": "7.0.0", "description": "Maps ENS names to their resolved addresses by chain id", "keywords": [ "MetaMask", @@ -31,9 +31,9 @@ }, "dependencies": { "@ethersproject/providers": "^5.7.0", - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", - "@metamask/network-controller": "^16.0.0", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", + "@metamask/network-controller": "^17.0.0", "@metamask/utils": "^8.2.0", "ethereum-ens-network-map": "^1.0.2", "punycode": "^2.1.1" @@ -49,7 +49,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/network-controller": "^16.0.0" + "@metamask/network-controller": "^17.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/gas-fee-controller/CHANGELOG.md b/packages/gas-fee-controller/CHANGELOG.md index e7fc07ce9e..4271506d25 100644 --- a/packages/gas-fee-controller/CHANGELOG.md +++ b/packages/gas-fee-controller/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [11.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/polling-controller` to ^2.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [10.0.1] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -125,7 +133,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@10.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@11.0.0...HEAD +[11.0.0]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@10.0.1...@metamask/gas-fee-controller@11.0.0 [10.0.1]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@10.0.0...@metamask/gas-fee-controller@10.0.1 [10.0.0]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@9.0.0...@metamask/gas-fee-controller@10.0.0 [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/gas-fee-controller@8.0.0...@metamask/gas-fee-controller@9.0.0 diff --git a/packages/gas-fee-controller/package.json b/packages/gas-fee-controller/package.json index 2c0dbd5783..98d0e9d6ec 100644 --- a/packages/gas-fee-controller/package.json +++ b/packages/gas-fee-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/gas-fee-controller", - "version": "10.0.1", + "version": "11.0.0", "description": "Periodically calculates gas fee estimates based on various gas limits as well as other data displayed on transaction confirm screens", "keywords": [ "MetaMask", @@ -30,11 +30,11 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/eth-query": "^4.0.0", - "@metamask/network-controller": "^16.0.0", - "@metamask/polling-controller": "^1.0.2", + "@metamask/network-controller": "^17.0.0", + "@metamask/polling-controller": "^2.0.0", "@metamask/utils": "^8.2.0", "@types/uuid": "^8.3.0", "ethereumjs-util": "^7.0.10", @@ -56,7 +56,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/network-controller": "^16.0.0" + "@metamask/network-controller": "^17.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/keyring-controller/CHANGELOG.md b/packages/keyring-controller/CHANGELOG.md index edde5b3428..401c023089 100644 --- a/packages/keyring-controller/CHANGELOG.md +++ b/packages/keyring-controller/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [10.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/message-manager` to ^7.3.6 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/preferences-controller` to ^4.5.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [9.0.0] ### Added - Add `KeyringController:persistAllKeyrings` messenger action ([#1965](https://github.com/MetaMask/core/pull/1965)) @@ -233,7 +240,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@9.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@10.0.0...HEAD +[10.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@9.0.0...@metamask/keyring-controller@10.0.0 [9.0.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.1.0...@metamask/keyring-controller@9.0.0 [8.1.0]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.3...@metamask/keyring-controller@8.1.0 [8.0.3]: https://github.com/MetaMask/core/compare/@metamask/keyring-controller@8.0.2...@metamask/keyring-controller@8.0.3 diff --git a/packages/keyring-controller/package.json b/packages/keyring-controller/package.json index d3af495315..05a3cd86b5 100644 --- a/packages/keyring-controller/package.json +++ b/packages/keyring-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/keyring-controller", - "version": "9.0.0", + "version": "10.0.0", "description": "Stores identities seen in the wallet and manages interactions such as signing", "keywords": [ "MetaMask", @@ -31,10 +31,10 @@ }, "dependencies": { "@keystonehq/metamask-airgapped-keyring": "^0.13.1", - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/eth-keyring-controller": "^15.0.0", - "@metamask/message-manager": "^7.3.5", - "@metamask/preferences-controller": "^4.4.3", + "@metamask/message-manager": "^7.3.6", + "@metamask/preferences-controller": "^5.0.0", "@metamask/utils": "^8.2.0", "async-mutex": "^0.2.6", "ethereumjs-util": "^7.0.10", @@ -60,7 +60,7 @@ "uuid": "^8.3.2" }, "peerDependencies": { - "@metamask/preferences-controller": "^4.4.3" + "@metamask/preferences-controller": "^5.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/logging-controller/CHANGELOG.md b/packages/logging-controller/CHANGELOG.md index 5dd4951540..e72fbc216a 100644 --- a/packages/logging-controller/CHANGELOG.md +++ b/packages/logging-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [1.0.4] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -29,7 +35,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial Release - Add logging controller ([#1089](https://github.com/MetaMask/core.git/pull/1089)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.4...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@2.0.0...HEAD +[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.4...@metamask/logging-controller@2.0.0 [1.0.4]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.3...@metamask/logging-controller@1.0.4 [1.0.3]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.2...@metamask/logging-controller@1.0.3 [1.0.2]: https://github.com/MetaMask/core/compare/@metamask/logging-controller@1.0.1...@metamask/logging-controller@1.0.2 diff --git a/packages/logging-controller/package.json b/packages/logging-controller/package.json index bfc80f1e58..9c2eca87c9 100644 --- a/packages/logging-controller/package.json +++ b/packages/logging-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/logging-controller", - "version": "1.0.4", + "version": "2.0.0", "description": "Manages logging data to assist users and support staff", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "uuid": "^8.3.2" }, "devDependencies": { diff --git a/packages/message-manager/CHANGELOG.md b/packages/message-manager/CHANGELOG.md index a67e05a7f2..5e367f9213 100644 --- a/packages/message-manager/CHANGELOG.md +++ b/packages/message-manager/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [7.3.6] +### Changed +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) +- Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is not breaking because the message managers still inherit from BaseController v1. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [7.3.5] ### Changed - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639)) @@ -126,7 +133,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.5...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.6...HEAD +[7.3.6]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.5...@metamask/message-manager@7.3.6 [7.3.5]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.4...@metamask/message-manager@7.3.5 [7.3.4]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.3...@metamask/message-manager@7.3.4 [7.3.3]: https://github.com/MetaMask/core/compare/@metamask/message-manager@7.3.2...@metamask/message-manager@7.3.3 diff --git a/packages/message-manager/package.json b/packages/message-manager/package.json index ae05fc7caf..b689f8748d 100644 --- a/packages/message-manager/package.json +++ b/packages/message-manager/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/message-manager", - "version": "7.3.5", + "version": "7.3.6", "description": "Stores and manages interactions with signing requests", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/eth-sig-util": "^7.0.0", "@metamask/utils": "^8.2.0", "@types/uuid": "^8.3.0", diff --git a/packages/name-controller/CHANGELOG.md b/packages/name-controller/CHANGELOG.md index ab833a00de..f7094a2395 100644 --- a/packages/name-controller/CHANGELOG.md +++ b/packages/name-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) + ## [3.0.1] ### Changed - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639)) @@ -37,7 +43,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial Release ([#1647](https://github.com/MetaMask/core/pull/1647)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/name-controller@3.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/name-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/name-controller@3.0.1...@metamask/name-controller@4.0.0 [3.0.1]: https://github.com/MetaMask/core/compare/@metamask/name-controller@3.0.0...@metamask/name-controller@3.0.1 [3.0.0]: https://github.com/MetaMask/core/compare/@metamask/name-controller@2.0.0...@metamask/name-controller@3.0.0 [2.0.0]: https://github.com/MetaMask/core/compare/@metamask/name-controller@1.0.0...@metamask/name-controller@2.0.0 diff --git a/packages/name-controller/package.json b/packages/name-controller/package.json index 93e6cc9112..95a858e847 100644 --- a/packages/name-controller/package.json +++ b/packages/name-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/name-controller", - "version": "3.0.1", + "version": "4.0.0", "description": "Stores and suggests names for values such as Ethereum addresses", "keywords": [ "MetaMask", @@ -31,7 +31,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/utils": "^8.2.0", "async-mutex": "^0.2.6" }, diff --git a/packages/network-controller/CHANGELOG.md b/packages/network-controller/CHANGELOG.md index c883961a29..275e475daf 100644 --- a/packages/network-controller/CHANGELOG.md +++ b/packages/network-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [17.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [16.0.0] ### Changed - **BREAKING:** Bump dependency `@metamask/eth-query` from ^3.0.1 to ^4.0.0 ([#2028](https://github.com/MetaMask/core/pull/2028)) @@ -309,7 +315,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@16.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/network-controller@17.0.0...HEAD +[17.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@16.0.0...@metamask/network-controller@17.0.0 [16.0.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@15.2.0...@metamask/network-controller@16.0.0 [15.2.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@15.1.0...@metamask/network-controller@15.2.0 [15.1.0]: https://github.com/MetaMask/core/compare/@metamask/network-controller@15.0.0...@metamask/network-controller@15.1.0 diff --git a/packages/network-controller/package.json b/packages/network-controller/package.json index d23b1b6922..a57e717056 100644 --- a/packages/network-controller/package.json +++ b/packages/network-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/network-controller", - "version": "16.0.0", + "version": "17.0.0", "description": "Provides an interface to the currently selected network via a MetaMask-compatible provider object", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/eth-json-rpc-infura": "^9.0.0", "@metamask/eth-json-rpc-middleware": "^12.0.1", "@metamask/eth-json-rpc-provider": "^2.3.0", diff --git a/packages/notification-controller/CHANGELOG.md b/packages/notification-controller/CHANGELOG.md index 74466e9b94..2b7cfdfb35 100644 --- a/packages/notification-controller/CHANGELOG.md +++ b/packages/notification-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) + ## [3.1.3] ### Changed - Bump dependency on `@metamask/utils` to ^8.1.0 ([#1639](https://github.com/MetaMask/core/pull/1639)) @@ -50,7 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@3.1.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@3.1.3...@metamask/notification-controller@4.0.0 [3.1.3]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@3.1.2...@metamask/notification-controller@3.1.3 [3.1.2]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@3.1.1...@metamask/notification-controller@3.1.2 [3.1.1]: https://github.com/MetaMask/core/compare/@metamask/notification-controller@3.1.0...@metamask/notification-controller@3.1.1 diff --git a/packages/notification-controller/package.json b/packages/notification-controller/package.json index a3aa97dd3f..b84aff4535 100644 --- a/packages/notification-controller/package.json +++ b/packages/notification-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/notification-controller", - "version": "3.1.3", + "version": "4.0.0", "description": "Manages display of notifications within MetaMask", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/utils": "^8.2.0", "nanoid": "^3.1.31" }, diff --git a/packages/permission-controller/CHANGELOG.md b/packages/permission-controller/CHANGELOG.md index 8aeaadc006..1b2a950fcd 100644 --- a/packages/permission-controller/CHANGELOG.md +++ b/packages/permission-controller/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [6.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [5.0.1] ### Changed - Bump `@metamask/json-rpc-engine` from `^7.1.0` to `^7.2.0` ([#1895](https://github.com/MetaMask/core/pull/1895)) @@ -102,7 +109,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@5.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@6.0.0...HEAD +[6.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@5.0.1...@metamask/permission-controller@6.0.0 [5.0.1]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@5.0.0...@metamask/permission-controller@5.0.1 [5.0.0]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@4.1.2...@metamask/permission-controller@5.0.0 [4.1.2]: https://github.com/MetaMask/core/compare/@metamask/permission-controller@4.1.1...@metamask/permission-controller@4.1.2 diff --git a/packages/permission-controller/package.json b/packages/permission-controller/package.json index aa76075980..54c96910e7 100644 --- a/packages/permission-controller/package.json +++ b/packages/permission-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/permission-controller", - "version": "5.0.1", + "version": "6.0.0", "description": "Mediates access to JSON-RPC methods, used to interact with pieces of the MetaMask stack, via middleware for json-rpc-engine", "keywords": [ "MetaMask", @@ -30,9 +30,9 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/approval-controller": "^4.1.0", - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/approval-controller": "^5.0.0", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/json-rpc-engine": "^7.3.0", "@metamask/rpc-errors": "^6.1.0", "@metamask/utils": "^8.2.0", @@ -52,7 +52,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/approval-controller": "^4.1.0" + "@metamask/approval-controller": "^5.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/permission-log-controller/package.json b/packages/permission-log-controller/package.json index 2558a2d55b..650cd4d767 100644 --- a/packages/permission-log-controller/package.json +++ b/packages/permission-log-controller/package.json @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/json-rpc-engine": "^7.3.0", "@metamask/utils": "^8.2.0" }, diff --git a/packages/phishing-controller/CHANGELOG.md b/packages/phishing-controller/CHANGELOG.md index 2aac6cab84..cf6f630775 100644 --- a/packages/phishing-controller/CHANGELOG.md +++ b/packages/phishing-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [8.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [7.0.1] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -97,7 +103,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@7.0.1...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@8.0.0...HEAD +[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@7.0.1...@metamask/phishing-controller@8.0.0 [7.0.1]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@7.0.0...@metamask/phishing-controller@7.0.1 [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@6.0.2...@metamask/phishing-controller@7.0.0 [6.0.2]: https://github.com/MetaMask/core/compare/@metamask/phishing-controller@6.0.1...@metamask/phishing-controller@6.0.2 diff --git a/packages/phishing-controller/package.json b/packages/phishing-controller/package.json index f74cf3c47e..2924187f80 100644 --- a/packages/phishing-controller/package.json +++ b/packages/phishing-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/phishing-controller", - "version": "7.0.1", + "version": "8.0.0", "description": "Maintains a periodically updated list of approved and unapproved website origins", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@types/punycode": "^2.1.0", "eth-phishing-detect": "^1.2.0", "punycode": "^2.1.1" diff --git a/packages/polling-controller/CHANGELOG.md b/packages/polling-controller/CHANGELOG.md index 23be47d73c..278a6f4d3e 100644 --- a/packages/polling-controller/CHANGELOG.md +++ b/packages/polling-controller/CHANGELOG.md @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [2.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [1.0.2] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -39,7 +46,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@1.0.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@2.0.0...HEAD +[2.0.0]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@1.0.2...@metamask/polling-controller@2.0.0 [1.0.2]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@1.0.1...@metamask/polling-controller@1.0.2 [1.0.1]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@1.0.0...@metamask/polling-controller@1.0.1 [1.0.0]: https://github.com/MetaMask/core/compare/@metamask/polling-controller@0.2.0...@metamask/polling-controller@1.0.0 diff --git a/packages/polling-controller/package.json b/packages/polling-controller/package.json index c39071efcf..60f8f1ef2f 100644 --- a/packages/polling-controller/package.json +++ b/packages/polling-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/polling-controller", - "version": "1.0.2", + "version": "2.0.0", "description": "Polling Controller is the base for controllers that polling by networkClientId", "keywords": [ "MetaMask", @@ -30,9 +30,9 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", - "@metamask/network-controller": "^16.0.0", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", + "@metamask/network-controller": "^17.0.0", "@metamask/utils": "^8.2.0", "@types/uuid": "^8.3.0", "fast-json-stable-stringify": "^2.1.0", @@ -50,7 +50,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/network-controller": "^16.0.0" + "@metamask/network-controller": "^17.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/preferences-controller/CHANGELOG.md b/packages/preferences-controller/CHANGELOG.md index 6ca35f2f31..d7f7876412 100644 --- a/packages/preferences-controller/CHANGELOG.md +++ b/packages/preferences-controller/CHANGELOG.md @@ -6,6 +6,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [5.0.0] +### Added +- **BREAKING** Add required property `showIncomingTransactions` to `PreferencesState` ([#1659](https://github.com/MetaMask/core/pull/1659)) +- Add types `EtherscanSupportedChains`, `EtherscanSupportedHexChainId` ([#1659](https://github.com/MetaMask/core/pull/1659)) +- Add constant `ETHERSCAN_SUPPORTED_CHAIN_IDS` ([#1659](https://github.com/MetaMask/core/pull/1659)) +- Add `setEnabledNetworkIncomingTransactions` method ([#1659](https://github.com/MetaMask/core/pull/1659)) + - This can be used to set the `showIncomingTransactions` preference for the given chain ID. + +### Changed +- Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is not breaking because this controller still inherits from BaseController v1. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [4.4.3] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -76,7 +89,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@5.0.0...HEAD +[5.0.0]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.3...@metamask/preferences-controller@5.0.0 [4.4.3]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.2...@metamask/preferences-controller@4.4.3 [4.4.2]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.1...@metamask/preferences-controller@4.4.2 [4.4.1]: https://github.com/MetaMask/core/compare/@metamask/preferences-controller@4.4.0...@metamask/preferences-controller@4.4.1 diff --git a/packages/preferences-controller/package.json b/packages/preferences-controller/package.json index 1ba9e98799..ceebdaf90a 100644 --- a/packages/preferences-controller/package.json +++ b/packages/preferences-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/preferences-controller", - "version": "4.4.3", + "version": "5.0.0", "description": "Manages user-configurable settings for MetaMask", "keywords": [ "MetaMask", @@ -30,8 +30,8 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2" + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0" }, "devDependencies": { "@metamask/auto-changelog": "^3.4.3", diff --git a/packages/queued-request-controller/CHANGELOG.md b/packages/queued-request-controller/CHANGELOG.md index 275398a9e4..2f23b75121 100644 --- a/packages/queued-request-controller/CHANGELOG.md +++ b/packages/queued-request-controller/CHANGELOG.md @@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.2.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/selected-network-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [0.1.4] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -32,7 +40,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.1.4...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.2.0...HEAD +[0.2.0]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.1.4...@metamask/queued-request-controller@0.2.0 [0.1.4]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.1.3...@metamask/queued-request-controller@0.1.4 [0.1.3]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.1.2...@metamask/queued-request-controller@0.1.3 [0.1.2]: https://github.com/MetaMask/core/compare/@metamask/queued-request-controller@0.1.1...@metamask/queued-request-controller@0.1.2 diff --git a/packages/queued-request-controller/package.json b/packages/queued-request-controller/package.json index 1b4d900164..0902efa8a5 100644 --- a/packages/queued-request-controller/package.json +++ b/packages/queued-request-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/queued-request-controller", - "version": "0.1.4", + "version": "0.2.0", "description": "Includes a controller and middleware that implements a request queue", "keywords": [ "MetaMask", @@ -30,17 +30,17 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/json-rpc-engine": "^7.3.0", - "@metamask/network-controller": "^16.0.0", + "@metamask/network-controller": "^17.0.0", "@metamask/rpc-errors": "^6.1.0", - "@metamask/selected-network-controller": "^3.1.2", + "@metamask/selected-network-controller": "^4.0.0", "@metamask/swappable-obj-proxy": "^2.1.0", "@metamask/utils": "^8.2.0" }, "devDependencies": { - "@metamask/approval-controller": "^4.1.0", + "@metamask/approval-controller": "^5.0.0", "@metamask/auto-changelog": "^3.4.3", "@types/jest": "^27.4.1", "deepmerge": "^4.2.2", @@ -55,8 +55,8 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/network-controller": "^16.0.0", - "@metamask/selected-network-controller": "^3.1.2" + "@metamask/network-controller": "^17.0.0", + "@metamask/selected-network-controller": "^4.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/rate-limit-controller/CHANGELOG.md b/packages/rate-limit-controller/CHANGELOG.md index 38d67814f1..15a7cb8d1a 100644 --- a/packages/rate-limit-controller/CHANGELOG.md +++ b/packages/rate-limit-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Changed +- **BREAKING:** Enforce that `RateLimitedApi['method']` matches action handler type instead of using `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. + ## [3.0.3] ### Changed - Bump dependency on `@metamask/base-controller` to ^3.2.3 ([#1747](https://github.com/MetaMask/core/pull/1747)) @@ -51,7 +57,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@3.0.3...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@3.0.3...@metamask/rate-limit-controller@4.0.0 [3.0.3]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@3.0.2...@metamask/rate-limit-controller@3.0.3 [3.0.2]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@3.0.1...@metamask/rate-limit-controller@3.0.2 [3.0.1]: https://github.com/MetaMask/core/compare/@metamask/rate-limit-controller@3.0.0...@metamask/rate-limit-controller@3.0.1 diff --git a/packages/rate-limit-controller/package.json b/packages/rate-limit-controller/package.json index c83b8e364f..d3a06b0750 100644 --- a/packages/rate-limit-controller/package.json +++ b/packages/rate-limit-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/rate-limit-controller", - "version": "3.0.3", + "version": "4.0.0", "description": "Contains logic for rate-limiting API endpoints by requesting origin", "keywords": [ "MetaMask", @@ -30,7 +30,7 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/rpc-errors": "^6.1.0" }, "devDependencies": { diff --git a/packages/selected-network-controller/CHANGELOG.md b/packages/selected-network-controller/CHANGELOG.md index 86ed3cdb96..40135d7bda 100644 --- a/packages/selected-network-controller/CHANGELOG.md +++ b/packages/selected-network-controller/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [4.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [3.1.2] ### Changed - **BREAKING:** Bump dependency and peer dependency on `@metamask/network-controller` to ^16.0.0 @@ -44,7 +50,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial Release ([#1643](https://github.com/MetaMask/core/pull/1643)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@3.1.2...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@4.0.0...HEAD +[4.0.0]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@3.1.2...@metamask/selected-network-controller@4.0.0 [3.1.2]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@3.1.1...@metamask/selected-network-controller@3.1.2 [3.1.1]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@3.1.0...@metamask/selected-network-controller@3.1.1 [3.1.0]: https://github.com/MetaMask/core/compare/@metamask/selected-network-controller@3.0.0...@metamask/selected-network-controller@3.1.0 diff --git a/packages/selected-network-controller/package.json b/packages/selected-network-controller/package.json index ea14a4175f..d3f447452c 100644 --- a/packages/selected-network-controller/package.json +++ b/packages/selected-network-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/selected-network-controller", - "version": "3.1.2", + "version": "4.0.0", "description": "Provides an interface to the currently selected networkClientId for a given domain", "keywords": [ "MetaMask", @@ -30,9 +30,9 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/base-controller": "^3.2.3", + "@metamask/base-controller": "^4.0.0", "@metamask/json-rpc-engine": "^7.3.0", - "@metamask/network-controller": "^16.0.0", + "@metamask/network-controller": "^17.0.0", "@metamask/swappable-obj-proxy": "^2.1.0" }, "devDependencies": { @@ -50,7 +50,7 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/network-controller": "^16.0.0" + "@metamask/network-controller": "^17.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/signature-controller/CHANGELOG.md b/packages/signature-controller/CHANGELOG.md index 422021d846..7a34e57db3 100644 --- a/packages/signature-controller/CHANGELOG.md +++ b/packages/signature-controller/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [8.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/keyring-controller` to ^10.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/logging-controller` to ^2.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/message-manager` to ^7.3.6 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [7.0.0] ### Changed - **BREAKING**: Add `@metamask/keyring-controller` as a dependency and peer dependency @@ -102,7 +112,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Initial release ([#1214](https://github.com/MetaMask/core/pull/1214)) -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@7.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@8.0.0...HEAD +[8.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@7.0.0...@metamask/signature-controller@8.0.0 [7.0.0]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@6.1.3...@metamask/signature-controller@7.0.0 [6.1.3]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@6.1.2...@metamask/signature-controller@6.1.3 [6.1.2]: https://github.com/MetaMask/core/compare/@metamask/signature-controller@6.1.1...@metamask/signature-controller@6.1.2 diff --git a/packages/signature-controller/package.json b/packages/signature-controller/package.json index 83026ba5cb..b97190e113 100644 --- a/packages/signature-controller/package.json +++ b/packages/signature-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/signature-controller", - "version": "7.0.0", + "version": "8.0.0", "description": "Processes signing requests in order to sign arbitrary and typed data", "keywords": [ "MetaMask", @@ -30,12 +30,12 @@ "test:watch": "jest --watch" }, "dependencies": { - "@metamask/approval-controller": "^4.1.0", - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", - "@metamask/keyring-controller": "^9.0.0", - "@metamask/logging-controller": "^1.0.4", - "@metamask/message-manager": "^7.3.5", + "@metamask/approval-controller": "^5.0.0", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", + "@metamask/keyring-controller": "^10.0.0", + "@metamask/logging-controller": "^2.0.0", + "@metamask/message-manager": "^7.3.6", "@metamask/rpc-errors": "^6.1.0", "@metamask/utils": "^8.2.0", "ethereumjs-util": "^7.0.10", @@ -52,9 +52,9 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/approval-controller": "^4.1.0", - "@metamask/keyring-controller": "^9.0.0", - "@metamask/logging-controller": "^1.0.4" + "@metamask/approval-controller": "^5.0.0", + "@metamask/keyring-controller": "^10.0.0", + "@metamask/logging-controller": "^2.0.0" }, "engines": { "node": ">=16.0.0" diff --git a/packages/transaction-controller/CHANGELOG.md b/packages/transaction-controller/CHANGELOG.md index b48f5d092d..71efaf57a8 100644 --- a/packages/transaction-controller/CHANGELOG.md +++ b/packages/transaction-controller/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [18.0.0] +### Changed +- **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Bump `nonce-tracker` to ^3.0.0 ([#2040](https://github.com/MetaMask/core/pull/2040)) +- Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/gas-fee-controller` to ^11.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) +- Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) + ## [17.0.0] ### Added - **BREAKING:** Add additional support swaps support ([#1877](https://github.com/MetaMask/core/pull/1877)) @@ -288,7 +298,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 All changes listed after this point were applied to this package following the monorepo conversion. -[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@17.0.0...HEAD +[Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@18.0.0...HEAD +[18.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@17.0.0...@metamask/transaction-controller@18.0.0 [17.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@16.0.0...@metamask/transaction-controller@17.0.0 [16.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@15.0.0...@metamask/transaction-controller@16.0.0 [15.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@14.0.0...@metamask/transaction-controller@15.0.0 diff --git a/packages/transaction-controller/package.json b/packages/transaction-controller/package.json index 0f75fd3eee..54a59ddf34 100644 --- a/packages/transaction-controller/package.json +++ b/packages/transaction-controller/package.json @@ -1,6 +1,6 @@ { "name": "@metamask/transaction-controller", - "version": "17.0.0", + "version": "18.0.0", "description": "Stores transactions alongside their periodically updated statuses and manages interactions such as approval and cancellation", "keywords": [ "MetaMask", @@ -33,13 +33,13 @@ "@ethereumjs/common": "^3.2.0", "@ethereumjs/tx": "^4.2.0", "@ethersproject/abi": "^5.7.0", - "@metamask/approval-controller": "^4.1.0", - "@metamask/base-controller": "^3.2.3", - "@metamask/controller-utils": "^5.0.2", + "@metamask/approval-controller": "^5.0.0", + "@metamask/base-controller": "^4.0.0", + "@metamask/controller-utils": "^6.0.0", "@metamask/eth-query": "^4.0.0", - "@metamask/gas-fee-controller": "^10.0.1", + "@metamask/gas-fee-controller": "^11.0.0", "@metamask/metamask-eth-abis": "^3.0.0", - "@metamask/network-controller": "^16.0.0", + "@metamask/network-controller": "^17.0.0", "@metamask/rpc-errors": "^6.1.0", "@metamask/utils": "^8.2.0", "async-mutex": "^0.2.6", @@ -65,9 +65,9 @@ "typescript": "~4.8.4" }, "peerDependencies": { - "@metamask/approval-controller": "^4.1.0", - "@metamask/gas-fee-controller": "^10.0.1", - "@metamask/network-controller": "^16.0.0", + "@metamask/approval-controller": "^5.0.0", + "@metamask/gas-fee-controller": "^11.0.0", + "@metamask/network-controller": "^17.0.0", "babel-runtime": "^6.26.0" }, "engines": { diff --git a/yarn.lock b/yarn.lock index f0c1e1a039..8972e84bed 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1370,10 +1370,10 @@ __metadata: resolution: "@metamask/accounts-controller@workspace:packages/accounts-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/eth-snap-keyring": ^2.0.0 "@metamask/keyring-api": ^1.1.0 - "@metamask/keyring-controller": ^9.0.0 + "@metamask/keyring-controller": ^10.0.0 "@metamask/snaps-controllers": ^3.2.0 "@metamask/snaps-utils": ^3.2.0 "@metamask/utils": ^8.2.0 @@ -1389,7 +1389,7 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/keyring-controller": ^9.0.0 + "@metamask/keyring-controller": ^10.0.0 languageName: unknown linkType: soft @@ -1409,8 +1409,8 @@ __metadata: resolution: "@metamask/address-book-controller@workspace:packages/address-book-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -1427,7 +1427,7 @@ __metadata: resolution: "@metamask/announcement-controller@workspace:packages/announcement-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 jest: ^27.5.1 @@ -1438,12 +1438,12 @@ __metadata: languageName: unknown linkType: soft -"@metamask/approval-controller@^4.0.0, @metamask/approval-controller@^4.1.0, @metamask/approval-controller@workspace:packages/approval-controller": +"@metamask/approval-controller@^5.0.0, @metamask/approval-controller@workspace:packages/approval-controller": version: 0.0.0-use.local resolution: "@metamask/approval-controller@workspace:packages/approval-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/rpc-errors": ^6.1.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -1458,6 +1458,19 @@ __metadata: languageName: unknown linkType: soft +"@metamask/approval-controller@npm:^4.0.0, @metamask/approval-controller@npm:^4.1.0": + version: 4.1.0 + resolution: "@metamask/approval-controller@npm:4.1.0" + dependencies: + "@metamask/base-controller": ^3.2.3 + "@metamask/rpc-errors": ^6.1.0 + "@metamask/utils": ^8.1.0 + immer: ^9.0.6 + nanoid: ^3.1.31 + checksum: b75c900fc656cfc141f8954ccb48346970d561ba83852ec1d27cecddb6606033e03ea560d7253847bd09dfb8317548c9be9cb92c50d906e55134d892d3785806 + languageName: node + linkType: hard + "@metamask/assets-controllers@workspace:packages/assets-controllers": version: 0.0.0-use.local resolution: "@metamask/assets-controllers@workspace:packages/assets-controllers" @@ -1467,16 +1480,16 @@ __metadata: "@ethersproject/contracts": ^5.7.0 "@ethersproject/providers": ^5.7.0 "@metamask/abi-utils": ^2.0.2 - "@metamask/approval-controller": ^4.1.0 + "@metamask/approval-controller": ^5.0.0 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/contract-metadata": ^2.4.0 - "@metamask/controller-utils": ^5.0.2 + "@metamask/controller-utils": ^6.0.0 "@metamask/eth-query": ^4.0.0 "@metamask/metamask-eth-abis": 3.0.0 - "@metamask/network-controller": ^16.0.0 - "@metamask/polling-controller": ^1.0.2 - "@metamask/preferences-controller": ^4.4.3 + "@metamask/network-controller": ^17.0.0 + "@metamask/polling-controller": ^2.0.0 + "@metamask/preferences-controller": ^5.0.0 "@metamask/rpc-errors": ^6.1.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -1498,9 +1511,9 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/approval-controller": ^4.1.0 - "@metamask/network-controller": ^16.0.0 - "@metamask/preferences-controller": ^4.4.3 + "@metamask/approval-controller": ^5.0.0 + "@metamask/network-controller": ^17.0.0 + "@metamask/preferences-controller": ^5.0.0 languageName: unknown linkType: soft @@ -1519,7 +1532,7 @@ __metadata: languageName: node linkType: hard -"@metamask/base-controller@^3.2.0, @metamask/base-controller@^3.2.3, @metamask/base-controller@workspace:packages/base-controller": +"@metamask/base-controller@^4.0.0, @metamask/base-controller@workspace:packages/base-controller": version: 0.0.0-use.local resolution: "@metamask/base-controller@workspace:packages/base-controller" dependencies: @@ -1538,6 +1551,16 @@ __metadata: languageName: unknown linkType: soft +"@metamask/base-controller@npm:^3.2.0, @metamask/base-controller@npm:^3.2.3": + version: 3.2.3 + resolution: "@metamask/base-controller@npm:3.2.3" + dependencies: + "@metamask/utils": ^8.1.0 + immer: ^9.0.6 + checksum: f49fcf2bf892ec25657c2d72a50b3c4f3cad59acb1b74d9fdcdf564107b8f38f73647c696aaa9699d94828b5797d8f1479dab44a2dbcda987c268b0088bb3b76 + languageName: node + linkType: hard + "@metamask/browser-passworder@npm:^4.2.0": version: 4.2.0 resolution: "@metamask/browser-passworder@npm:4.2.0" @@ -1552,7 +1575,7 @@ __metadata: resolution: "@metamask/composable-controller@workspace:packages/composable-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 immer: ^9.0.6 @@ -1572,7 +1595,7 @@ __metadata: languageName: node linkType: hard -"@metamask/controller-utils@^5.0.2, @metamask/controller-utils@workspace:packages/controller-utils": +"@metamask/controller-utils@^6.0.0, @metamask/controller-utils@workspace:packages/controller-utils": version: 0.0.0-use.local resolution: "@metamask/controller-utils@workspace:packages/controller-utils" dependencies: @@ -1595,6 +1618,21 @@ __metadata: languageName: unknown linkType: soft +"@metamask/controller-utils@npm:^5.0.2": + version: 5.0.2 + resolution: "@metamask/controller-utils@npm:5.0.2" + dependencies: + "@metamask/eth-query": ^3.0.1 + "@metamask/utils": ^8.1.0 + "@spruceid/siwe-parser": 1.1.3 + eth-ens-namehash: ^2.0.8 + ethereumjs-util: ^7.0.10 + ethjs-unit: ^0.1.6 + fast-deep-equal: ^3.1.3 + checksum: 2345ab9ee0ba900fe2249d80009acfcf458bc60b30418234d00f5f04247b1182a585050572237f8ab09aa23032a24b99ad96399fc0798a0e9a114a29c3bf90d6 + languageName: node + linkType: hard + "@metamask/core-monorepo@workspace:.": version: 0.0.0-use.local resolution: "@metamask/core-monorepo@workspace:." @@ -1660,9 +1698,9 @@ __metadata: dependencies: "@ethersproject/providers": ^5.7.0 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 - "@metamask/network-controller": ^16.0.0 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 + "@metamask/network-controller": ^17.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -1674,7 +1712,7 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 languageName: unknown linkType: soft @@ -1805,6 +1843,16 @@ __metadata: languageName: node linkType: hard +"@metamask/eth-query@npm:^3.0.1": + version: 3.0.1 + resolution: "@metamask/eth-query@npm:3.0.1" + dependencies: + json-rpc-random-id: ^1.0.0 + xtend: ^4.0.1 + checksum: b9a323dff67328eace7d54fc8b0bc4dd763bf15760870656cbd5aad5380d1ee4489fb5c59506290d5f77cf55e74e530ee97b52702a329f1090ec03a6158434b7 + languageName: node + linkType: hard + "@metamask/eth-query@npm:^4.0.0": version: 4.0.0 resolution: "@metamask/eth-query@npm:4.0.0" @@ -1859,16 +1907,16 @@ __metadata: languageName: node linkType: hard -"@metamask/gas-fee-controller@^10.0.1, @metamask/gas-fee-controller@workspace:packages/gas-fee-controller": +"@metamask/gas-fee-controller@^11.0.0, @metamask/gas-fee-controller@workspace:packages/gas-fee-controller": version: 0.0.0-use.local resolution: "@metamask/gas-fee-controller@workspace:packages/gas-fee-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/eth-query": ^4.0.0 - "@metamask/network-controller": ^16.0.0 - "@metamask/polling-controller": ^1.0.2 + "@metamask/network-controller": ^17.0.0 + "@metamask/polling-controller": ^2.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 "@types/jest-when": ^2.7.3 @@ -1886,7 +1934,7 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 languageName: unknown linkType: soft @@ -1963,7 +2011,7 @@ __metadata: languageName: node linkType: hard -"@metamask/keyring-controller@^9.0.0, @metamask/keyring-controller@workspace:packages/keyring-controller": +"@metamask/keyring-controller@^10.0.0, @metamask/keyring-controller@workspace:packages/keyring-controller": version: 0.0.0-use.local resolution: "@metamask/keyring-controller@workspace:packages/keyring-controller" dependencies: @@ -1972,11 +2020,11 @@ __metadata: "@keystonehq/bc-ur-registry-eth": ^0.9.0 "@keystonehq/metamask-airgapped-keyring": ^0.13.1 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/eth-keyring-controller": ^15.0.0 "@metamask/eth-sig-util": ^7.0.0 - "@metamask/message-manager": ^7.3.5 - "@metamask/preferences-controller": ^4.4.3 + "@metamask/message-manager": ^7.3.6 + "@metamask/preferences-controller": ^5.0.0 "@metamask/scure-bip39": ^2.1.1 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -1994,17 +2042,17 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/preferences-controller": ^4.4.3 + "@metamask/preferences-controller": ^5.0.0 languageName: unknown linkType: soft -"@metamask/logging-controller@^1.0.4, @metamask/logging-controller@workspace:packages/logging-controller": +"@metamask/logging-controller@^2.0.0, @metamask/logging-controller@workspace:packages/logging-controller": version: 0.0.0-use.local resolution: "@metamask/logging-controller@workspace:packages/logging-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 jest: ^27.5.1 @@ -2016,13 +2064,13 @@ __metadata: languageName: unknown linkType: soft -"@metamask/message-manager@^7.3.5, @metamask/message-manager@workspace:packages/message-manager": +"@metamask/message-manager@^7.3.6, @metamask/message-manager@workspace:packages/message-manager": version: 0.0.0-use.local resolution: "@metamask/message-manager@workspace:packages/message-manager" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/eth-sig-util": ^7.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -2051,7 +2099,7 @@ __metadata: resolution: "@metamask/name-controller@workspace:packages/name-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 async-mutex: ^0.2.6 @@ -2064,14 +2112,14 @@ __metadata: languageName: unknown linkType: soft -"@metamask/network-controller@^16.0.0, @metamask/network-controller@workspace:packages/network-controller": +"@metamask/network-controller@^17.0.0, @metamask/network-controller@workspace:packages/network-controller": version: 0.0.0-use.local resolution: "@metamask/network-controller@workspace:packages/network-controller" dependencies: "@json-rpc-specification/meta-schema": ^1.0.6 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/eth-json-rpc-infura": ^9.0.0 "@metamask/eth-json-rpc-middleware": ^12.0.1 "@metamask/eth-json-rpc-provider": ^2.3.0 @@ -2105,7 +2153,7 @@ __metadata: resolution: "@metamask/notification-controller@workspace:packages/notification-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -2149,18 +2197,38 @@ __metadata: languageName: node linkType: hard -"@metamask/permission-controller@^5.0.0, @metamask/permission-controller@workspace:packages/permission-controller": - version: 0.0.0-use.local - resolution: "@metamask/permission-controller@workspace:packages/permission-controller" +"@metamask/permission-controller@npm:^5.0.0": + version: 5.0.1 + resolution: "@metamask/permission-controller@npm:5.0.1" dependencies: "@metamask/approval-controller": ^4.1.0 - "@metamask/auto-changelog": ^3.4.3 "@metamask/base-controller": ^3.2.3 "@metamask/controller-utils": ^5.0.2 "@metamask/json-rpc-engine": ^7.3.0 "@metamask/rpc-errors": ^6.1.0 "@metamask/utils": ^8.2.0 "@types/deep-freeze-strict": ^1.1.0 + deep-freeze-strict: ^1.1.1 + immer: ^9.0.6 + nanoid: ^3.1.31 + peerDependencies: + "@metamask/approval-controller": ^4.1.0 + checksum: fc61df3f5532b35b9ec26ca712848d680d616103e3d06470691412ee8b5a4b70e27d530065f601b64e0a5c2022aa129b8e6ddcc7c3e8325720aa0f639e3e10ba + languageName: node + linkType: hard + +"@metamask/permission-controller@workspace:packages/permission-controller": + version: 0.0.0-use.local + resolution: "@metamask/permission-controller@workspace:packages/permission-controller" + dependencies: + "@metamask/approval-controller": ^5.0.0 + "@metamask/auto-changelog": ^3.4.3 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 + "@metamask/json-rpc-engine": ^7.3.0 + "@metamask/rpc-errors": ^6.1.0 + "@metamask/utils": ^8.2.0 + "@types/deep-freeze-strict": ^1.1.0 "@types/jest": ^27.4.1 deep-freeze-strict: ^1.1.1 deepmerge: ^4.2.2 @@ -2172,7 +2240,7 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/approval-controller": ^4.1.0 + "@metamask/approval-controller": ^5.0.0 languageName: unknown linkType: soft @@ -2181,7 +2249,7 @@ __metadata: resolution: "@metamask/permission-log-controller@workspace:packages/permission-log-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/json-rpc-engine": ^7.3.0 "@metamask/utils": ^8.2.0 "@types/deep-freeze-strict": ^1.1.0 @@ -2198,13 +2266,26 @@ __metadata: languageName: unknown linkType: soft -"@metamask/phishing-controller@^7.0.0, @metamask/phishing-controller@workspace:packages/phishing-controller": +"@metamask/phishing-controller@npm:^7.0.0": + version: 7.0.1 + resolution: "@metamask/phishing-controller@npm:7.0.1" + dependencies: + "@metamask/base-controller": ^3.2.3 + "@metamask/controller-utils": ^5.0.2 + "@types/punycode": ^2.1.0 + eth-phishing-detect: ^1.2.0 + punycode: ^2.1.1 + checksum: 9d7b4db829ce78163bc308ef520382a4d3eb43597acf05b56e1f712c56dfc60b504f61f532ebdc656f9fbeb8c26f62b7cf075aef3c5d8263b993c628cc485d81 + languageName: node + linkType: hard + +"@metamask/phishing-controller@workspace:packages/phishing-controller": version: 0.0.0-use.local resolution: "@metamask/phishing-controller@workspace:packages/phishing-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@types/jest": ^27.4.1 "@types/punycode": ^2.1.0 deepmerge: ^4.2.2 @@ -2220,14 +2301,14 @@ __metadata: languageName: unknown linkType: soft -"@metamask/polling-controller@^1.0.2, @metamask/polling-controller@workspace:packages/polling-controller": +"@metamask/polling-controller@^2.0.0, @metamask/polling-controller@workspace:packages/polling-controller": version: 0.0.0-use.local resolution: "@metamask/polling-controller@workspace:packages/polling-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 - "@metamask/network-controller": ^16.0.0 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 + "@metamask/network-controller": ^17.0.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 "@types/uuid": ^8.3.0 @@ -2241,7 +2322,7 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 languageName: unknown linkType: soft @@ -2255,13 +2336,13 @@ __metadata: languageName: node linkType: hard -"@metamask/preferences-controller@^4.4.3, @metamask/preferences-controller@workspace:packages/preferences-controller": +"@metamask/preferences-controller@^5.0.0, @metamask/preferences-controller@workspace:packages/preferences-controller": version: 0.0.0-use.local resolution: "@metamask/preferences-controller@workspace:packages/preferences-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 jest: ^27.5.1 @@ -2295,14 +2376,14 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/queued-request-controller@workspace:packages/queued-request-controller" dependencies: - "@metamask/approval-controller": ^4.1.0 + "@metamask/approval-controller": ^5.0.0 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/json-rpc-engine": ^7.3.0 - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 "@metamask/rpc-errors": ^6.1.0 - "@metamask/selected-network-controller": ^3.1.2 + "@metamask/selected-network-controller": ^4.0.0 "@metamask/swappable-obj-proxy": ^2.1.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -2317,8 +2398,8 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/network-controller": ^16.0.0 - "@metamask/selected-network-controller": ^3.1.2 + "@metamask/network-controller": ^17.0.0 + "@metamask/selected-network-controller": ^4.0.0 languageName: unknown linkType: soft @@ -2327,7 +2408,7 @@ __metadata: resolution: "@metamask/rate-limit-controller@workspace:packages/rate-limit-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/rpc-errors": ^6.1.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -2373,14 +2454,14 @@ __metadata: languageName: node linkType: hard -"@metamask/selected-network-controller@^3.1.2, @metamask/selected-network-controller@workspace:packages/selected-network-controller": +"@metamask/selected-network-controller@^4.0.0, @metamask/selected-network-controller@workspace:packages/selected-network-controller": version: 0.0.0-use.local resolution: "@metamask/selected-network-controller@workspace:packages/selected-network-controller" dependencies: "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 + "@metamask/base-controller": ^4.0.0 "@metamask/json-rpc-engine": ^7.3.0 - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 "@metamask/swappable-obj-proxy": ^2.1.0 "@types/jest": ^27.4.1 deepmerge: ^4.2.2 @@ -2394,7 +2475,7 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 languageName: unknown linkType: soft @@ -2402,13 +2483,13 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/signature-controller@workspace:packages/signature-controller" dependencies: - "@metamask/approval-controller": ^4.1.0 + "@metamask/approval-controller": ^5.0.0 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 - "@metamask/keyring-controller": ^9.0.0 - "@metamask/logging-controller": ^1.0.4 - "@metamask/message-manager": ^7.3.5 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 + "@metamask/keyring-controller": ^10.0.0 + "@metamask/logging-controller": ^2.0.0 + "@metamask/message-manager": ^7.3.6 "@metamask/rpc-errors": ^6.1.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -2421,9 +2502,9 @@ __metadata: typedoc-plugin-missing-exports: ^2.0.0 typescript: ~4.8.4 peerDependencies: - "@metamask/approval-controller": ^4.1.0 - "@metamask/keyring-controller": ^9.0.0 - "@metamask/logging-controller": ^1.0.4 + "@metamask/approval-controller": ^5.0.0 + "@metamask/keyring-controller": ^10.0.0 + "@metamask/logging-controller": ^2.0.0 languageName: unknown linkType: soft @@ -2543,14 +2624,14 @@ __metadata: "@ethereumjs/common": ^3.2.0 "@ethereumjs/tx": ^4.2.0 "@ethersproject/abi": ^5.7.0 - "@metamask/approval-controller": ^4.1.0 + "@metamask/approval-controller": ^5.0.0 "@metamask/auto-changelog": ^3.4.3 - "@metamask/base-controller": ^3.2.3 - "@metamask/controller-utils": ^5.0.2 + "@metamask/base-controller": ^4.0.0 + "@metamask/controller-utils": ^6.0.0 "@metamask/eth-query": ^4.0.0 - "@metamask/gas-fee-controller": ^10.0.1 + "@metamask/gas-fee-controller": ^11.0.0 "@metamask/metamask-eth-abis": ^3.0.0 - "@metamask/network-controller": ^16.0.0 + "@metamask/network-controller": ^17.0.0 "@metamask/rpc-errors": ^6.1.0 "@metamask/utils": ^8.2.0 "@types/jest": ^27.4.1 @@ -2572,9 +2653,9 @@ __metadata: typescript: ~4.8.4 uuid: ^8.3.2 peerDependencies: - "@metamask/approval-controller": ^4.1.0 - "@metamask/gas-fee-controller": ^10.0.1 - "@metamask/network-controller": ^16.0.0 + "@metamask/approval-controller": ^5.0.0 + "@metamask/gas-fee-controller": ^11.0.0 + "@metamask/network-controller": ^17.0.0 babel-runtime: ^6.26.0 languageName: unknown linkType: soft From 9cbf9497c55e803398c42b7b88b1698655074ebf Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 21 Nov 2023 11:10:43 -0700 Subject: [PATCH 02/17] Add changes from PR 2064 --- packages/controller-utils/CHANGELOG.md | 1 + packages/gas-fee-controller/CHANGELOG.md | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/controller-utils/CHANGELOG.md b/packages/controller-utils/CHANGELOG.md index cc485f46ab..f2e1e45595 100644 --- a/packages/controller-utils/CHANGELOG.md +++ b/packages/controller-utils/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - This affects `query`: the `sendAsync` method on the given EthQuery must now have a narrower type - Bump `@metamask/utils` from ^8.1.0 to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) - Change `BUILT_IN_NETWORKS` so that `rpc` entry now has a dummy `ticker` ([#1794](https://github.com/MetaMask/core/pull/1794)) +- Replace `ethjs-unit` ^0.1.6 with `@metamask/ethjs-unit` ^0.2.1 ([#2064](https://github.com/MetaMask/core/pull/2064)) ### Fixed - Move `@metamask/eth-query` from a development dependency to a runtime dependency ([#1815](https://github.com/MetaMask/core/pull/1815)) diff --git a/packages/gas-fee-controller/CHANGELOG.md b/packages/gas-fee-controller/CHANGELOG.md index 4271506d25..dd44d614bf 100644 --- a/packages/gas-fee-controller/CHANGELOG.md +++ b/packages/gas-fee-controller/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- Replace `ethjs-unit` ^0.1.6 with `@metamask/ethjs-unit` ^0.2.1 ([#2064](https://github.com/MetaMask/core/pull/2064)) - Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/network-controller` to ^17.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/polling-controller` to ^2.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) From f87b187700af73f164997bd91d61918c64b9a63e Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 21 Nov 2023 11:19:34 -0700 Subject: [PATCH 03/17] Add changes from PR 2027 --- packages/transaction-controller/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/transaction-controller/CHANGELOG.md b/packages/transaction-controller/CHANGELOG.md index 71efaf57a8..e481cb68fd 100644 --- a/packages/transaction-controller/CHANGELOG.md +++ b/packages/transaction-controller/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. - Bump `nonce-tracker` to ^3.0.0 ([#2040](https://github.com/MetaMask/core/pull/2040)) +- The controller now emits a `transaction-status-update` event each time the status of a transaction changes (e.g. submitted, rejected, etc.) ([#2027](https://github.com/MetaMask/core/pull/2027)) - Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/gas-fee-controller` to ^11.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) From f509f5655998e745ec5b2f2f62f4dcbb19663be3 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 21 Nov 2023 11:52:21 -0700 Subject: [PATCH 04/17] Add changes from PR 2056 --- packages/transaction-controller/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/transaction-controller/CHANGELOG.md b/packages/transaction-controller/CHANGELOG.md index e481cb68fd..06641f9243 100644 --- a/packages/transaction-controller/CHANGELOG.md +++ b/packages/transaction-controller/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [18.0.0] +### Added +- Add `updateEditableParams` method ([#2056](https://github.com/MetaMask/core/pull/2056)) + ### Changed - **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. From 8890d0a44d390b4c07f27cbd231f8a43d20c60fc Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Tue, 21 Nov 2023 11:59:52 -0700 Subject: [PATCH 05/17] Add changes for PR 1889 --- packages/permission-controller/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/permission-controller/CHANGELOG.md b/packages/permission-controller/CHANGELOG.md index 1b2a950fcd..2b3fbc7bf0 100644 --- a/packages/permission-controller/CHANGELOG.md +++ b/packages/permission-controller/CHANGELOG.md @@ -7,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ## [6.0.0] +### Added +- Add new handler to `permissionRpcMethods.handlers` for `wallet_revokePermissions` RPC method ([#1889](https://github.com/MetaMask/core/pull/1889)) + ### Changed - **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- **BREAKING:** Update `PermittedRpcMethodHooks` type so it must support signature for `wallet_revokePermission` hook ([#1889](https://github.com/MetaMask/core/pull/1889)) - Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) From fbca88235473462c5ce8114c0289a8f262e00093 Mon Sep 17 00:00:00 2001 From: Matthew Walsh Date: Wed, 22 Nov 2023 13:07:01 +0000 Subject: [PATCH 06/17] Add method to get transactions (#2065) Re-add initApprovals method to allow client to finish initialisation before creating approvals. Remove unnecessary gas property update during initialisation since transactions are not added to the state until gas properties are updated. Normalise the gas fee values provided to speedUpTransaction and stopTransaction to support the extension arguments. Update the transaction after the afterSign hook to persist any updated properties. Report success to the result callback after publish is skipped to unblock the UI during the MMI flows. Set the value parameter to 0x0 if not specified. Limit properties updated by updateCustodianTransaction so it can initially be used for hash and status updates only, with more general MMI updates continuing to use updateTransaction. Align nonce logic with mobile. Update post transaction balance of swaps transactions after internal transactions. --- .../transaction-controller/jest.config.js | 8 +- .../src/TransactionController.test.ts | 940 +++++++++++------- .../src/TransactionController.ts | 353 ++++--- packages/transaction-controller/src/types.ts | 9 +- .../transaction-controller/src/utils/swaps.ts | 25 +- .../src/utils/utils.test.ts | 72 +- .../transaction-controller/src/utils/utils.ts | 36 +- 7 files changed, 947 insertions(+), 496 deletions(-) diff --git a/packages/transaction-controller/jest.config.js b/packages/transaction-controller/jest.config.js index c4759f83db..8f5e60f8c2 100644 --- a/packages/transaction-controller/jest.config.js +++ b/packages/transaction-controller/jest.config.js @@ -17,10 +17,10 @@ module.exports = merge(baseConfig, { // An object that configures minimum threshold enforcement for coverage results coverageThreshold: { global: { - branches: 88.48, - functions: 94, - lines: 98.5, - statements: 98, + branches: 88.78, + functions: 94.14, + lines: 98.29, + statements: 98.25, }, }, diff --git a/packages/transaction-controller/src/TransactionController.test.ts b/packages/transaction-controller/src/TransactionController.test.ts index d76b97f283..edca4a9ce7 100644 --- a/packages/transaction-controller/src/TransactionController.test.ts +++ b/packages/transaction-controller/src/TransactionController.test.ts @@ -625,269 +625,6 @@ describe('TransactionController', () => { updateGasFeesMock.mockReset(); }); - it('creates approvals for all unapproved transaction', async () => { - const mockTransactionMeta = { - from: ACCOUNT_MOCK, - chainId: toHex(5), - status: TransactionStatus.unapproved, - txParams: { - from: ACCOUNT_MOCK, - to: ACCOUNT_2_MOCK, - }, - }; - - const mockedTransactions = [ - { - id: '123', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '123' }], - }, - { - id: '1234', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '1234' }], - }, - ]; - - const mockedControllerState = { - transactions: mockedTransactions, - methodData: {}, - lastFetchedBlockNumbers: {}, - }; - - newController({ - state: mockedControllerState as any, - }); - - expect(delayMessengerMock.call).toHaveBeenCalledTimes(2); - expect(delayMessengerMock.call).toHaveBeenCalledWith( - 'ApprovalController:addRequest', - { - expectsResult: true, - id: '123', - origin: 'metamask', - requestData: { txId: '123' }, - type: 'transaction', - }, - false, - ); - expect(delayMessengerMock.call).toHaveBeenCalledWith( - 'ApprovalController:addRequest', - { - expectsResult: true, - id: '1234', - origin: 'metamask', - requestData: { txId: '1234' }, - type: 'transaction', - }, - false, - ); - }); - - it('catches error without code property in error object while creating approval', async () => { - const mockTransactionMeta = { - from: ACCOUNT_MOCK, - chainId: toHex(5), - status: TransactionStatus.unapproved, - txParams: { - from: ACCOUNT_MOCK, - to: ACCOUNT_2_MOCK, - }, - }; - - const mockedTransactions = [ - { - id: '123', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '123' }], - }, - { - id: '1234', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '1234' }], - }, - ]; - - const mockedControllerState = { - transactions: mockedTransactions, - methodData: {}, - lastFetchedBlockNumbers: {}, - }; - - const mockedErrorMessage = 'mocked error'; - - // Expect both calls to throw error, one with code property to check if it is handled - (delayMessengerMock.call as jest.MockedFunction) - .mockImplementationOnce(() => { - // eslint-disable-next-line @typescript-eslint/no-throw-literal - throw { message: mockedErrorMessage }; - }) - .mockImplementationOnce(() => { - // eslint-disable-next-line @typescript-eslint/no-throw-literal - throw { - message: mockedErrorMessage, - code: errorCodes.provider.userRejectedRequest, - }; - }); - const consoleSpy = jest.spyOn(console, 'error').mockImplementation(); - - newController({ - state: mockedControllerState as any, - }); - - await flushPromises(); - - expect(consoleSpy).toHaveBeenCalledTimes(1); - expect(consoleSpy).toHaveBeenCalledWith( - 'Error during persisted transaction approval', - new Error(mockedErrorMessage), - ); - expect(delayMessengerMock.call).toHaveBeenCalledTimes(2); - }); - - it('does not create any approval when there is no unapproved transaction', async () => { - newController(); - expect(delayMessengerMock.call).not.toHaveBeenCalled(); - }); - - it('updates gas values of unapproved transactions', async () => { - const mockTransactionMeta = { - from: ACCOUNT_MOCK, - chainId: toHex(5), - status: TransactionStatus.unapproved, - txParams: { - from: ACCOUNT_MOCK, - to: ACCOUNT_2_MOCK, - }, - }; - const mockGasPrice = '0x2'; - const mockGas = '0x1'; - const mockedTransactions = [ - { - id: '123', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '123' }], - }, - { - id: '1234', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '1234' }], - }, - ]; - - const mockedControllerState = { - transactions: mockedTransactions, - methodData: {}, - lastFetchedBlockNumbers: {}, - }; - - updateGasFeesMock.mockImplementation(({ txMeta }) => { - // Assume this is a sample update - txMeta.txParams.gasPrice = mockGasPrice; - return Promise.resolve(); - }); - - updateGasMock.mockImplementation(({ txMeta }) => { - // Assume this is a sample update - txMeta.txParams.gas = mockGas; - return Promise.resolve(); - }); - - const controller = newController({ - state: mockedControllerState as any, - }); - - await flushPromises(); - - [updateGasMock, updateGasFeesMock].forEach((mockedGasFn) => { - expect(mockedGasFn).toHaveBeenCalledTimes(2); - expect(mockedGasFn.mock.calls[0][0]).toStrictEqual( - expect.objectContaining({ - txMeta: expect.objectContaining({ - id: '123', - }), - }), - ); - expect(mockedGasFn.mock.calls[1][0]).toStrictEqual( - expect.objectContaining({ - txMeta: expect.objectContaining({ - id: '1234', - }), - }), - ); - }); - - const { transactions } = controller.state; - - expect(transactions[0].txParams.gasPrice).toBe(mockGasPrice); - expect(transactions[1].txParams.gasPrice).toBe(mockGasPrice); - }); - - it('updates transaction as failed if failes to update gas fees', async () => { - const mockGasPrice = '0x1'; - const mockGas = '0x1'; - - const mockTransactionMeta = { - from: ACCOUNT_MOCK, - chainId: toHex(5), - status: TransactionStatus.unapproved, - txParams: { - from: ACCOUNT_MOCK, - to: ACCOUNT_2_MOCK, - }, - }; - const mockedTransactions = [ - { - id: '123', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '123' }], - }, - { - id: '1234', - ...mockTransactionMeta, - history: [{ ...mockTransactionMeta, id: '1234' }], - }, - ]; - - const mockedControllerState = { - transactions: mockedTransactions, - methodData: {}, - lastFetchedBlockNumbers: {}, - }; - - // Let the first update pass and fail the second one - // to test the failure case - updateGasFeesMock - .mockImplementationOnce(({ txMeta }) => { - // Assume this is a sample update - txMeta.txParams.gasPrice = mockGasPrice; - return Promise.resolve(); - }) - .mockImplementationOnce(() => { - return Promise.reject(new Error('unexpected failure')); - }); - - updateGasMock.mockImplementation(({ txMeta }) => { - // Assume this is a sample update - txMeta.txParams.gasPrice = mockGas; - return Promise.resolve(); - }); - - // Second gas update will fail, in order to keep the console clean during test mock console.error once - jest.spyOn(console, 'error').mockImplementation(); - - const controller = newController({ - state: mockedControllerState as any, - }); - - await flushPromises(); - - const { transactions } = controller.state; - - expect(transactions[0].status).toBe(TransactionStatus.unapproved); - expect(transactions[1].status).toBe(TransactionStatus.failed); - }); - it('submits an approved transaction', async () => { const mockTransactionMeta = { from: ACCOUNT_MOCK, @@ -2534,6 +2271,11 @@ describe('TransactionController', () => { path: '/txParams/gasUsed', timestamp: expect.any(Number), }, + { + op: 'add', + path: '/txParams/value', + value: '0x0', + }, { op: 'add', path: '/txReceipt', @@ -3544,10 +3286,15 @@ describe('TransactionController', () => { }); describe('with hooks', () => { - const txMeta = { + const paramsMock = { from: ACCOUNT_MOCK, to: ACCOUNT_MOCK, }; + + const metadataMock = { + txParams: paramsMock, + }; + it('adds a transaction, signs and update status to `approved`', async () => { const controller = newController({ options: { @@ -3555,14 +3302,14 @@ describe('TransactionController', () => { afterSign: () => false, beforeApproveOnInit: () => false, beforePublish: () => false, - getAdditionalSignArguments: () => [txMeta], + getAdditionalSignArguments: () => [metadataMock], }, }, }); const signSpy = jest.spyOn(controller, 'sign' as any); const updateTransactionSpy = jest.spyOn(controller, 'updateTransaction'); - await controller.addTransaction(txMeta, { + await controller.addTransaction(paramsMock, { origin: 'origin', actionId: ACTION_ID_MOCK, }); @@ -3571,14 +3318,23 @@ describe('TransactionController', () => { await wait(0); const transactionMeta = controller.state.transactions[0]; + expect(signSpy).toHaveBeenCalledTimes(1); - expect(updateTransactionSpy).toHaveBeenCalledTimes(1); + + expect(updateTransactionSpy).toHaveBeenCalledTimes(2); expect(updateTransactionSpy).toHaveBeenCalledWith( expect.objectContaining({ - txParams: expect.objectContaining(txMeta), + txParams: expect.objectContaining(paramsMock), }), 'TransactionController#approveTransaction - Transaction approved', ); + expect(updateTransactionSpy).toHaveBeenCalledWith( + expect.objectContaining({ + txParams: expect.objectContaining(paramsMock), + }), + 'TransactionController#signTransaction - Update after sign', + ); + expect(transactionMeta.status).toBe(TransactionStatus.approved); }); @@ -3589,7 +3345,7 @@ describe('TransactionController', () => { afterSign: () => false, beforeApproveOnInit: () => false, beforePublish: () => false, - getAdditionalSignArguments: () => [txMeta], + getAdditionalSignArguments: () => [metadataMock], }, }, config: { sign: async () => undefined }, @@ -3597,7 +3353,7 @@ describe('TransactionController', () => { const signSpy = jest.spyOn(controller, 'sign' as any); const updateTransactionSpy = jest.spyOn(controller, 'updateTransaction'); - await controller.addTransaction(txMeta, { + await controller.addTransaction(paramsMock, { origin: 'origin', actionId: ACTION_ID_MOCK, }); @@ -3615,14 +3371,14 @@ describe('TransactionController', () => { hooks: { beforePublish: undefined, afterSign: () => false, - getAdditionalSignArguments: () => [txMeta], + getAdditionalSignArguments: () => [metadataMock], }, }, }); const signSpy = jest.spyOn(controller, 'sign' as any); const updateTransactionSpy = jest.spyOn(controller, 'updateTransaction'); - await controller.addTransaction(txMeta, { + await controller.addTransaction(paramsMock, { origin: 'origin', actionId: ACTION_ID_MOCK, }); @@ -3631,13 +3387,20 @@ describe('TransactionController', () => { await wait(0); expect(signSpy).toHaveBeenCalledTimes(1); - expect(updateTransactionSpy).toHaveBeenCalledTimes(1); + + expect(updateTransactionSpy).toHaveBeenCalledTimes(2); expect(updateTransactionSpy).toHaveBeenCalledWith( expect.objectContaining({ - txParams: expect.objectContaining(txMeta), + txParams: expect.objectContaining(paramsMock), }), 'TransactionController#approveTransaction - Transaction approved', ); + expect(updateTransactionSpy).toHaveBeenCalledWith( + expect.objectContaining({ + txParams: expect.objectContaining(paramsMock), + }), + 'TransactionController#signTransaction - Update after sign', + ); }); }); @@ -3738,119 +3501,560 @@ describe('TransactionController', () => { 'Cannot update security alert response as no transaction metadata found', ); }); - }); - describe('updateCustodialTransaction', () => { - const transactionId = '1'; - const statusMock = TransactionStatus.unapproved as const; - const baseTransaction = { - id: transactionId, - chainId: toHex(5), - status: statusMock, - time: 123456789, - txParams: { - from: ACCOUNT_MOCK, - to: ACCOUNT_2_MOCK, - }, - }; - const transactionMeta: TransactionMeta = { - ...baseTransaction, - custodyId: '123', - history: [{ ...baseTransaction }], - }; - it.each([ - { - newStatus: TransactionStatus.signed, - }, - { - newStatus: TransactionStatus.submitted, - }, - { - newStatus: TransactionStatus.failed, - errorMessage: 'Error mock', - }, - ])( - 'updates transaction status to $newStatus', - async ({ newStatus, errorMessage }) => { - const newHash = '1234'; - const newCustodyStatus = 'submitted'; + describe('updateCustodialTransaction', () => { + const transactionId = '1'; + const statusMock = TransactionStatus.unapproved as const; + const baseTransaction = { + id: transactionId, + chainId: toHex(5), + status: statusMock, + time: 123456789, + txParams: { + from: ACCOUNT_MOCK, + to: ACCOUNT_2_MOCK, + }, + }; + const transactionMeta: TransactionMeta = { + ...baseTransaction, + custodyId: '123', + history: [{ ...baseTransaction }], + }; + it.each([ + { + newStatus: TransactionStatus.signed, + }, + { + newStatus: TransactionStatus.submitted, + }, + { + newStatus: TransactionStatus.failed, + errorMessage: 'Error mock', + }, + ])( + 'updates transaction status to $newStatus', + async ({ newStatus, errorMessage }) => { + const newHash = '1234'; + const controller = newController(); + controller.state.transactions.push(transactionMeta); + + controller.updateCustodialTransaction(transactionId, { + status: newStatus, + hash: newHash, + errorMessage, + }); + + const updatedTransaction = controller.state.transactions[0]; + + expect(updatedTransaction?.status).toStrictEqual(newStatus); + expect(updatedTransaction?.hash).toStrictEqual(newHash); + }, + ); + + it('throws if custodial transaction does not exists', async () => { + const nonExistentId = 'nonExistentId'; + const newStatus = TransactionStatus.approved as const; + const controller = newController(); + + expect(() => + controller.updateCustodialTransaction(nonExistentId, { + status: newStatus, + }), + ).toThrow( + 'Cannot update custodial transaction as no transaction metadata found', + ); + }); + + it('throws if transaction is not a custodial transaction', async () => { + const nonCustodialTransaction: TransactionMeta = { + ...baseTransaction, + history: [{ ...baseTransaction }], + }; + const newStatus = TransactionStatus.approved as const; + const controller = newController(); + controller.state.transactions.push(nonCustodialTransaction); + + expect(() => + controller.updateCustodialTransaction(nonCustodialTransaction.id, { + status: newStatus, + }), + ).toThrow('Transaction must be a custodian transaction'); + }); + + it('throws if status is invalid', async () => { + const newStatus = TransactionStatus.approved as const; const controller = newController(); controller.state.transactions.push(transactionMeta); - controller.updateCustodialTransaction(transactionId, { - status: newStatus, - hash: newHash, - custodyStatus: newCustodyStatus, - errorMessage, - }); + expect(() => + controller.updateCustodialTransaction(transactionMeta.id, { + status: newStatus, + }), + ).toThrow( + `Cannot update custodial transaction with status: ${newStatus}`, + ); + }); + + it('no property was updated', async () => { + const controller = newController(); + controller.state.transactions.push(transactionMeta); + + controller.updateCustodialTransaction(transactionId, {}); const updatedTransaction = controller.state.transactions[0]; - expect(updatedTransaction?.status).toStrictEqual(newStatus); - expect(updatedTransaction?.hash).toStrictEqual(newHash); - expect(updatedTransaction?.custodyStatus).toStrictEqual( - newCustodyStatus, + expect(updatedTransaction?.status).toStrictEqual( + transactionMeta.status, ); - }, - ); + expect(updatedTransaction?.hash).toStrictEqual(transactionMeta.hash); + }); + }); - it('throws if custodial transaction does not exists', async () => { - const nonExistentId = 'nonExistentId'; - const newStatus = TransactionStatus.approved as const; - const controller = newController(); + describe('initApprovals', () => { + it('creates approvals for all unapproved transaction', async () => { + const mockTransactionMeta = { + from: ACCOUNT_MOCK, + chainId: toHex(5), + status: TransactionStatus.unapproved, + txParams: { + from: ACCOUNT_MOCK, + to: ACCOUNT_2_MOCK, + }, + }; - expect(() => - controller.updateCustodialTransaction(nonExistentId, { - status: newStatus, - }), - ).toThrow( - 'Cannot update custodial transaction as no transaction metadata found', - ); - }); + const mockedTransactions = [ + { + id: '123', + ...mockTransactionMeta, + history: [{ ...mockTransactionMeta, id: '123' }], + }, + { + id: '1234', + ...mockTransactionMeta, + history: [{ ...mockTransactionMeta, id: '1234' }], + }, + ]; - it('throws if transaction is not a custodial transaction', async () => { - const nonCustodialTransaction: TransactionMeta = { - ...baseTransaction, - history: [{ ...baseTransaction }], - }; - const newStatus = TransactionStatus.approved as const; - const controller = newController(); - controller.state.transactions.push(nonCustodialTransaction); + const mockedControllerState = { + transactions: mockedTransactions, + methodData: {}, + lastFetchedBlockNumbers: {}, + }; - expect(() => - controller.updateCustodialTransaction(nonCustodialTransaction.id, { - status: newStatus, - }), - ).toThrow('Transaction must be a custodian transaction'); - }); + const controller = newController({ + state: mockedControllerState as any, + }); - it('throws if status is invalid', async () => { - const newStatus = TransactionStatus.approved as const; - const controller = newController(); - controller.state.transactions.push(transactionMeta); + controller.initApprovals(); + await flushPromises(); - expect(() => - controller.updateCustodialTransaction(transactionMeta.id, { - status: newStatus, - }), - ).toThrow( - `Cannot update custodial transaction with status: ${newStatus}`, - ); + expect(delayMessengerMock.call).toHaveBeenCalledTimes(2); + expect(delayMessengerMock.call).toHaveBeenCalledWith( + 'ApprovalController:addRequest', + { + expectsResult: true, + id: '123', + origin: 'metamask', + requestData: { txId: '123' }, + type: 'transaction', + }, + false, + ); + expect(delayMessengerMock.call).toHaveBeenCalledWith( + 'ApprovalController:addRequest', + { + expectsResult: true, + id: '1234', + origin: 'metamask', + requestData: { txId: '1234' }, + type: 'transaction', + }, + false, + ); + }); + + it('catches error without code property in error object while creating approval', async () => { + const mockTransactionMeta = { + from: ACCOUNT_MOCK, + chainId: toHex(5), + status: TransactionStatus.unapproved, + txParams: { + from: ACCOUNT_MOCK, + to: ACCOUNT_2_MOCK, + }, + }; + + const mockedTransactions = [ + { + id: '123', + ...mockTransactionMeta, + history: [{ ...mockTransactionMeta, id: '123' }], + }, + { + id: '1234', + ...mockTransactionMeta, + history: [{ ...mockTransactionMeta, id: '1234' }], + }, + ]; + + const mockedControllerState = { + transactions: mockedTransactions, + methodData: {}, + lastFetchedBlockNumbers: {}, + }; + + const mockedErrorMessage = 'mocked error'; + + // Expect both calls to throw error, one with code property to check if it is handled + (delayMessengerMock.call as jest.MockedFunction) + .mockImplementationOnce(() => { + // eslint-disable-next-line @typescript-eslint/no-throw-literal + throw { message: mockedErrorMessage }; + }) + .mockImplementationOnce(() => { + // eslint-disable-next-line @typescript-eslint/no-throw-literal + throw { + message: mockedErrorMessage, + code: errorCodes.provider.userRejectedRequest, + }; + }); + const consoleSpy = jest.spyOn(console, 'error').mockImplementation(); + + const controller = newController({ + state: mockedControllerState as any, + }); + + controller.initApprovals(); + + await flushPromises(); + + expect(consoleSpy).toHaveBeenCalledTimes(1); + expect(consoleSpy).toHaveBeenCalledWith( + 'Error during persisted transaction approval', + new Error(mockedErrorMessage), + ); + expect(delayMessengerMock.call).toHaveBeenCalledTimes(2); + }); + + it('does not create any approval when there is no unapproved transaction', async () => { + const controller = newController(); + controller.initApprovals(); + await flushPromises(); + expect(delayMessengerMock.call).not.toHaveBeenCalled(); + }); }); - it('no property was updated', async () => { - const controller = newController(); - controller.state.transactions.push(transactionMeta); + describe('getTransactions', () => { + it('returns transactions matching values in search criteria', () => { + const controller = newController(); - controller.updateCustodialTransaction(transactionId, {}); + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 1, + txParams: { from: '0x3' }, + }, + ]; - const updatedTransaction = controller.state.transactions[0]; + controller.state.transactions = transactions; - expect(updatedTransaction?.status).toStrictEqual(transactionMeta.status); - expect(updatedTransaction?.custodyStatus).toStrictEqual( - transactionMeta.custodyStatus, - ); - expect(updatedTransaction?.hash).toStrictEqual(transactionMeta.hash); + expect( + controller.getTransactions({ + searchCriteria: { time: 1 }, + filterToCurrentNetwork: false, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns transactions matching param values in search criteria', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 3, + txParams: { from: '0x1' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + searchCriteria: { from: '0x1' }, + filterToCurrentNetwork: false, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns transactions matching multiple values in search criteria', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 1, + txParams: { from: '0x1' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + searchCriteria: { from: '0x1', time: 1 }, + filterToCurrentNetwork: false, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns transactions matching function in search criteria', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 1, + txParams: { from: '0x3' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + searchCriteria: { time: (v: any) => v === 1 }, + filterToCurrentNetwork: false, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns transactions matching current network', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: MOCK_NETWORK.state.providerConfig.chainId, + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x2', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: MOCK_NETWORK.state.providerConfig.chainId, + id: 'testId3', + status: TransactionStatus.submitted, + time: 1, + txParams: { from: '0x3' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + filterToCurrentNetwork: true, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns transactions from specified list', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 1, + txParams: { from: '0x3' }, + }, + ]; + + expect( + controller.getTransactions({ + searchCriteria: { time: 1 }, + initialList: transactions, + filterToCurrentNetwork: false, + }), + ).toStrictEqual([transactions[0], transactions[2]]); + }); + + it('returns limited number of transactions sorted by ascending time', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1', nonce: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + status: TransactionStatus.confirmed, + time: 2, + txParams: { from: '0x1', nonce: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.unapproved, + time: 3, + txParams: { from: '0x2', nonce: '0x3' }, + }, + { + chainId: '0x1', + id: 'testId4', + status: TransactionStatus.submitted, + time: 4, + txParams: { from: '0x1', nonce: '0x4' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + searchCriteria: { from: '0x1' }, + filterToCurrentNetwork: false, + limit: 2, + }), + ).toStrictEqual([transactions[1], transactions[3]]); + }); + + it('returns limited number of transactions except for duplicate nonces', () => { + const controller = newController(); + + const transactions: TransactionMeta[] = [ + { + chainId: '0x1', + id: 'testId1', + status: TransactionStatus.confirmed, + time: 1, + txParams: { from: '0x1', nonce: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId2', + + status: TransactionStatus.unapproved, + time: 2, + txParams: { from: '0x2', nonce: '0x2' }, + }, + { + chainId: '0x1', + id: 'testId3', + status: TransactionStatus.submitted, + time: 3, + txParams: { from: '0x1', nonce: '0x1' }, + }, + { + chainId: '0x1', + id: 'testId4', + status: TransactionStatus.submitted, + time: 4, + txParams: { from: '0x1', nonce: '0x3' }, + }, + ]; + + controller.state.transactions = transactions; + + expect( + controller.getTransactions({ + searchCriteria: { from: '0x1' }, + filterToCurrentNetwork: false, + limit: 2, + }), + ).toStrictEqual([transactions[0], transactions[2], transactions[3]]); + }); }); }); diff --git a/packages/transaction-controller/src/TransactionController.ts b/packages/transaction-controller/src/TransactionController.ts index 7a61c0089b..63b1499ed1 100644 --- a/packages/transaction-controller/src/TransactionController.ts +++ b/packages/transaction-controller/src/TransactionController.ts @@ -33,7 +33,7 @@ import { Mutex } from 'async-mutex'; import MethodRegistry from 'eth-method-registry'; import { addHexPrefix, bufferToHex } from 'ethereumjs-util'; import { EventEmitter } from 'events'; -import { merge, pickBy } from 'lodash'; +import { mapValues, merge, pickBy, sortBy } from 'lodash'; import { NonceTracker } from 'nonce-tracker'; import type { NonceLock } from 'nonce-tracker'; import { v1 as random } from 'uuid'; @@ -82,6 +82,7 @@ import { validateIfTransactionUnapproved, validateMinimumIncrease, normalizeTxError, + normalizeGasFeeValues, } from './utils/utils'; import { validateTransactionOrigin, @@ -382,7 +383,7 @@ export class TransactionController extends BaseController< disableSendFlowHistory: boolean; disableSwaps: boolean; getSavedGasFees?: (chainId: Hex) => SavedGasFees | undefined; - getCurrentAccountEIP1559Compatibility: () => Promise; + getCurrentAccountEIP1559Compatibility?: () => Promise; getCurrentNetworkEIP1559Compatibility: () => Promise; getGasFeeEstimates?: () => Promise; getNetworkState: () => NetworkState; @@ -443,7 +444,7 @@ export class TransactionController extends BaseController< this.registry = new MethodRegistry({ provider }); this.getSavedGasFees = getSavedGasFees ?? ((_chainId) => undefined); this.getCurrentAccountEIP1559Compatibility = - getCurrentAccountEIP1559Compatibility; + getCurrentAccountEIP1559Compatibility ?? (() => Promise.resolve(true)); this.getCurrentNetworkEIP1559Compatibility = getCurrentNetworkEIP1559Compatibility; this.getGasFeeEstimates = @@ -466,18 +467,14 @@ export class TransactionController extends BaseController< // @ts-expect-error provider types misaligned: SafeEventEmitterProvider vs Record provider, blockTracker, - getPendingTransactions: (address) => - getAndFormatTransactionsForNonceTracker( - address, - TransactionStatus.submitted, - this.state.transactions, - ), - getConfirmedTransactions: (address) => - getAndFormatTransactionsForNonceTracker( - address, - TransactionStatus.confirmed, - this.state.transactions, - ), + getPendingTransactions: this.getNonceTrackerTransactions.bind( + this, + TransactionStatus.submitted, + ), + getConfirmedTransactions: this.getNonceTrackerTransactions.bind( + this, + TransactionStatus.confirmed, + ), }); this.incomingTransactionHelper = new IncomingTransactionHelper({ @@ -605,10 +602,14 @@ export class TransactionController extends BaseController< type?: TransactionType; } = {}, ): Promise { - const chainId = this.getChainId(); + log('Adding transaction', txParams); + txParams = normalizeTxParams(txParams); + const isEIP1559Compatible = await this.getEIP1559Compatibility(); + validateTxParams(txParams, isEIP1559Compatible); + if (origin) { await validateTransactionOrigin( await this.getPermittedAccounts(origin), @@ -627,6 +628,8 @@ export class TransactionController extends BaseController< type ?? (await determineTransactionType(txParams, this.ethQuery)).type; const existingTransactionMeta = this.getTransactionWithActionId(actionId); + const chainId = this.getChainId(); + // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it. const transactionMeta: TransactionMeta = existingTransactionMeta || { // Add actionId to txMeta to check if same actionId is seen again @@ -722,8 +725,11 @@ export class TransactionController extends BaseController< } if (gasValues) { + // Not good practice to reassign a parameter but temporarily avoiding a larger refactor. + gasValues = normalizeGasFeeValues(gasValues); validateGasValues(gasValues); } + const transactionMeta = this.getTransaction(transactionId); if (!transactionMeta) { return; @@ -783,7 +789,7 @@ export class TransactionController extends BaseController< gasLimit: transactionMeta.txParams.gas, maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas, - type: '2', + type: TransactionEnvelopeType.feeMarket, nonce: transactionMeta.txParams.nonce, to: transactionMeta.txParams.from, value: '0x0', @@ -859,8 +865,11 @@ export class TransactionController extends BaseController< } if (gasValues) { + // Not good practice to reassign a parameter but temporarily avoiding a larger refactor. + gasValues = normalizeGasFeeValues(gasValues); validateGasValues(gasValues); } + const transactionMeta = this.state.transactions.find( ({ id }) => id === transactionId, ); @@ -924,7 +933,7 @@ export class TransactionController extends BaseController< gasLimit: transactionMeta.txParams.gas, maxFeePerGas: newMaxFeePerGas, maxPriorityFeePerGas: newMaxPriorityFeePerGas, - type: '2', + type: TransactionEnvelopeType.feeMarket, } : { ...transactionMeta.txParams, @@ -1146,28 +1155,15 @@ export class TransactionController extends BaseController< ); this.onTransactionStatusChange(transactionMeta); - if (transactionMeta.type === TransactionType.swap) { - updatePostTransactionBalance(transactionMeta, { - ethQuery: this.ethQuery, - getTransaction: this.getTransaction.bind(this), - updateTransaction: this.updateTransaction.bind(this), - }) - .then(({ updatedTransactionMeta, approvalTransactionMeta }) => { - this.hub.emit('post-transaction-balance-updated', { - transactionMeta: updatedTransactionMeta, - approvalTransactionMeta, - }); - }) - .catch((error) => { - /* istanbul ignore next */ - log('Error while updating post transaction balance', error); - }); - } + // Intentional given potential duration of process. + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this.updatePostBalance(transactionMeta); + this.hub.emit('transaction-confirmed', { transactionMeta, }); } catch (error) { - console.error(error); + console.error('Failed to confirm external transaction', error); } } @@ -1506,7 +1502,6 @@ export class TransactionController extends BaseController< * * @param transactionId - The ID of the transaction to update. * @param options - The custodial transaction options to update. - * @param options.custodyStatus - The new custody status value to be assigned. * @param options.errorMessage - The error message to be assigned in case transaction status update to failed. * @param options.hash - The new hash value to be assigned. * @param options.status - The new status value to be assigned. @@ -1514,19 +1509,16 @@ export class TransactionController extends BaseController< updateCustodialTransaction( transactionId: string, { - custodyStatus, errorMessage, hash, status, }: { - custodyStatus?: string; errorMessage?: string; hash?: string; status?: TransactionStatus; }, ) { - let transactionMeta; - transactionMeta = this.getTransaction(transactionId); + const transactionMeta = this.getTransaction(transactionId); if (!transactionMeta) { throw new Error( @@ -1550,35 +1542,142 @@ export class TransactionController extends BaseController< `Cannot update custodial transaction with status: ${status}`, ); } - if (status === TransactionStatus.signed) { - transactionMeta.status = status; - } + + const updatedTransactionMeta = merge( + transactionMeta, + pickBy({ hash, status }), + ); if (status === TransactionStatus.submitted) { - transactionMeta.submittedTime = new Date().getTime(); - transactionMeta.status = status; + updatedTransactionMeta.submittedTime = new Date().getTime(); } if (status === TransactionStatus.failed) { - transactionMeta = { - ...transactionMeta, - error: normalizeTxError(new Error(errorMessage)), - status: TransactionStatus.failed, - }; + updatedTransactionMeta.error = normalizeTxError(new Error(errorMessage)); } - if (custodyStatus) { - transactionMeta.custodyStatus = custodyStatus; - } + this.updateTransaction( + updatedTransactionMeta, + `TransactionController:updateCustodialTransaction - Custodial transaction updated`, + ); + } - if (hash) { - transactionMeta.hash = hash; + /** + * Creates approvals for all unapproved transactions persisted. + */ + initApprovals() { + const chainId = this.getChainId(); + const unapprovedTxs = this.state.transactions.filter( + (transaction) => + transaction.status === TransactionStatus.unapproved && + transaction.chainId === chainId, + ); + + for (const txMeta of unapprovedTxs) { + this.processApproval(txMeta, { + shouldShowRequest: false, + }).catch((error) => { + if (error?.code === errorCodes.provider.userRejectedRequest) { + return; + } + console.error('Error during persisted transaction approval', error); + }); } + } - this.updateTransaction( - transactionMeta, - `TransactionController:updateCustodialTransaction - Custodial transaction updated`, + /** + * Search transaction metadata for matching entries. + * + * @param opts - Options bag. + * @param opts.searchCriteria - An object containing values or functions for transaction properties to filter transactions with. + * @param opts.initialList - The transactions to search. Defaults to the current state. + * @param opts.filterToCurrentNetwork - Whether to filter the results to the current network. Defaults to true. + * @param opts.limit - The maximum number of transactions to return. No limit by default. + * @returns An array of transactions matching the provided options. + */ + getTransactions({ + searchCriteria = {}, + initialList, + filterToCurrentNetwork = true, + limit, + }: { + searchCriteria?: any; + initialList?: TransactionMeta[]; + filterToCurrentNetwork?: boolean; + limit?: number; + } = {}): TransactionMeta[] { + const chainId = this.getChainId(); + // searchCriteria is an object that might have values that aren't predicate + // methods. When providing any other value type (string, number, etc), we + // consider this shorthand for "check the value at key for strict equality + // with the provided value". To conform this object to be only methods, we + // mapValues (lodash) such that every value on the object is a method that + // returns a boolean. + const predicateMethods = mapValues(searchCriteria, (predicate) => { + return typeof predicate === 'function' + ? predicate + : (v: any) => v === predicate; + }); + + const transactionsToFilter = initialList ?? this.state.transactions; + + // Combine sortBy and pickBy to transform our state object into an array of + // matching transactions that are sorted by time. + const filteredTransactions = sortBy( + pickBy(transactionsToFilter, (transaction) => { + if (filterToCurrentNetwork && transaction.chainId !== chainId) { + return false; + } + // iterate over the predicateMethods keys to check if the transaction + // matches the searchCriteria + for (const [key, predicate] of Object.entries(predicateMethods)) { + // We return false early as soon as we know that one of the specified + // search criteria do not match the transaction. This prevents + // needlessly checking all criteria when we already know the criteria + // are not fully satisfied. We check both txParams and the base + // object as predicate keys can be either. + if (key in transaction.txParams) { + if (predicate((transaction.txParams as any)[key]) === false) { + return false; + } + } else if (predicate((transaction as any)[key]) === false) { + return false; + } + } + + return true; + }), + 'time', ); + if (limit !== undefined) { + // We need to have all transactions of a given nonce in order to display + // necessary details in the UI. We use the size of this set to determine + // whether we have reached the limit provided, thus ensuring that all + // transactions of nonces we include will be sent to the UI. + const nonces = new Set(); + const txs = []; + // By default, the transaction list we filter from is sorted by time ASC. + // To ensure that filtered results prefers the newest transactions we + // iterate from right to left, inserting transactions into front of a new + // array. The original order is preserved, but we ensure that newest txs + // are preferred. + for (let i = filteredTransactions.length - 1; i > -1; i--) { + const txMeta = filteredTransactions[i]; + const { nonce } = txMeta.txParams; + if (!nonces.has(nonce)) { + if (nonces.size < limit) { + nonces.add(nonce); + } else { + continue; + } + } + // Push transaction into the beginning of our array to ensure the + // original order is preserved. + txs.unshift(txMeta); + } + return txs; + } + return filteredTransactions; } private async signExternalTransaction( @@ -1629,7 +1728,10 @@ export class TransactionController extends BaseController< } private async updateGasProperties(transactionMeta: TransactionMeta) { - const isEIP1559Compatible = await this.getEIP1559Compatibility(); + const isEIP1559Compatible = + (await this.getEIP1559Compatibility()) && + transactionMeta.txParams.type !== TransactionEnvelopeType.legacy; + const chainId = this.getChainId(); await updateGas({ @@ -1656,8 +1758,6 @@ export class TransactionController extends BaseController< } private onBootCleanup() { - this.createApprovalsForUnapprovedTransactions(); - this.loadGasValuesForUnapprovedTransactions(); this.submitApprovedTransactions(); } @@ -1682,38 +1782,6 @@ export class TransactionController extends BaseController< } } - /** - * Update the gas values of all unapproved transactions on current chain. - */ - private async loadGasValuesForUnapprovedTransactions() { - const unapprovedTransactions = this.getCurrentChainTransactionsByStatus( - TransactionStatus.unapproved, - ); - - const results = await Promise.allSettled( - unapprovedTransactions.map(async (transactionMeta) => { - await this.updateGasProperties(transactionMeta); - this.updateTransaction( - transactionMeta, - 'TransactionController:loadGasValuesForUnapprovedTransactions - Gas values updated', - ); - }), - ); - - for (const [index, result] of results.entries()) { - if (result.status === 'rejected') { - const transactionMeta = unapprovedTransactions[index]; - this.failTransaction(transactionMeta, result.reason); - /* istanbul ignore next */ - console.error( - 'Error while loading gas values for persisted transaction id: ', - transactionMeta.id, - result.reason, - ); - } - } - } - /** * Force to submit approved transactions on current chain. */ @@ -1758,7 +1826,17 @@ export class TransactionController extends BaseController< const acceptResult = await this.requestApproval(transactionMeta, { shouldShowRequest, }); + resultCallbacks = acceptResult.resultCallbacks; + + if (resultCallbacks) { + this.hub.once(`${transactionId}:publish-skip`, () => { + resultCallbacks?.success(); + + // Remove the reference to prevent additional reports once submitted. + resultCallbacks = undefined; + }); + } } const { isCompleted: isTxCompleted } = @@ -1867,10 +1945,12 @@ export class TransactionController extends BaseController< ...transactionMeta.txParams, gasLimit: transactionMeta.txParams.gas, }; + this.updateTransaction( transactionMeta, 'TransactionController#approveTransaction - Transaction approved', ); + this.onTransactionStatusChange(transactionMeta); const isEIP1559 = isEIP1559Transaction(transactionMeta.txParams); @@ -1878,23 +1958,16 @@ export class TransactionController extends BaseController< const txParams: TransactionParams = isEIP1559 ? { ...baseTxParams, - maxFeePerGas: transactionMeta.txParams.maxFeePerGas, - maxPriorityFeePerGas: transactionMeta.txParams.maxPriorityFeePerGas, estimatedBaseFee: transactionMeta.txParams.estimatedBaseFee, - // specify type 2 if maxFeePerGas and maxPriorityFeePerGas are set - type: '2', + type: TransactionEnvelopeType.feeMarket, } : baseTxParams; - // delete gasPrice if maxFeePerGas and maxPriorityFeePerGas are set - if (isEIP1559) { - delete txParams.gasPrice; - } - - const rawTx = await this.signTransaction(transactionMeta); + const rawTx = await this.signTransaction(transactionMeta, txParams); if (!this.beforePublish(transactionMeta)) { log('Skipping publishing transaction based on hook'); + this.hub.emit(`${transactionMeta.id}:publish-skip`, transactionMeta); return; } @@ -2204,7 +2277,7 @@ export class TransactionController extends BaseController< * * @param transactionMeta - Nominated external transaction to be added to state. */ - private async addExternalTransaction(transactionMeta: TransactionMeta) { + private addExternalTransaction(transactionMeta: TransactionMeta) { const chainId = this.getChainId(); const { transactions } = this.state; const fromAddress = transactionMeta?.txParams?.from; @@ -2341,8 +2414,9 @@ export class TransactionController extends BaseController< private async getEIP1559Compatibility() { const currentNetworkIsEIP1559Compatible = await this.getCurrentNetworkEIP1559Compatibility(); + const currentAccountIsEIP1559Compatible = - this.getCurrentAccountEIP1559Compatibility?.() ?? true; + await this.getCurrentAccountEIP1559Compatibility(); return ( currentNetworkIsEIP1559Compatible && currentAccountIsEIP1559Compatible @@ -2352,11 +2426,7 @@ export class TransactionController extends BaseController< private addPendingTransactionTrackerListeners() { this.pendingTransactionTracker.hub.on( 'transaction-confirmed', - (transactionMeta: TransactionMeta) => { - this.hub.emit('transaction-confirmed', { transactionMeta }); - this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta); - this.onTransactionStatusChange(transactionMeta); - }, + this.onConfirmedTransaction.bind(this), ); this.pendingTransactionTracker.hub.on( @@ -2377,8 +2447,9 @@ export class TransactionController extends BaseController< private async signTransaction( transactionMeta: TransactionMeta, + txParams: TransactionParams, ): Promise { - const { txParams } = transactionMeta; + log('Signing transaction', txParams); const unsignedEthTx = this.prepareUnsignedEthTx(txParams); this.inProcessOfSigning.add(transactionMeta.id); @@ -2394,7 +2465,13 @@ export class TransactionController extends BaseController< } if (!this.afterSign(transactionMeta, signedTx)) { + this.updateTransaction( + transactionMeta, + 'TransactionController#signTransaction - Update after sign', + ); + log('Skipping signed status based on hook'); + return undefined; } @@ -2418,6 +2495,54 @@ export class TransactionController extends BaseController< private onTransactionStatusChange(transactionMeta: TransactionMeta) { this.hub.emit('transaction-status-update', { transactionMeta }); } -} -export default TransactionController; + private getNonceTrackerTransactions( + status: TransactionStatus, + address: string, + ) { + const currentChainId = this.getChainId(); + + return getAndFormatTransactionsForNonceTracker( + currentChainId, + address, + status, + this.state.transactions, + ); + } + + private onConfirmedTransaction(transactionMeta: TransactionMeta) { + log('Processing confirmed transaction', transactionMeta.id); + + this.hub.emit('transaction-confirmed', { transactionMeta }); + this.hub.emit(`${transactionMeta.id}:confirmed`, transactionMeta); + + this.onTransactionStatusChange(transactionMeta); + + // Intentional given potential duration of process. + // eslint-disable-next-line @typescript-eslint/no-floating-promises + this.updatePostBalance(transactionMeta); + } + + private async updatePostBalance(transactionMeta: TransactionMeta) { + try { + if (transactionMeta.type !== TransactionType.swap) { + return; + } + + const { updatedTransactionMeta, approvalTransactionMeta } = + await updatePostTransactionBalance(transactionMeta, { + ethQuery: this.ethQuery, + getTransaction: this.getTransaction.bind(this), + updateTransaction: this.updateTransaction.bind(this), + }); + + this.hub.emit('post-transaction-balance-updated', { + transactionMeta: updatedTransactionMeta, + approvalTransactionMeta, + }); + } catch (error) { + /* istanbul ignore next */ + log('Error while updating post transaction balance', error); + } + } +} diff --git a/packages/transaction-controller/src/types.ts b/packages/transaction-controller/src/types.ts index 986968e2de..d6d96babaa 100644 --- a/packages/transaction-controller/src/types.ts +++ b/packages/transaction-controller/src/types.ts @@ -33,8 +33,9 @@ export type Events = { { transactionMeta: TransactionMeta; actionId?: string }, ]; ['unapprovedTransaction']: [transactionMeta: TransactionMeta]; - [key: `${string}:finished`]: [transactionMeta: TransactionMeta]; [key: `${string}:confirmed`]: [transactionMeta: TransactionMeta]; + [key: `${string}:finished`]: [transactionMeta: TransactionMeta]; + [key: `${string}:publish-skip`]: [tansactionMeta: TransactionMeta]; [key: `${string}:speedup`]: [transactionMeta: TransactionMeta]; }; @@ -321,7 +322,7 @@ type TransactionMetaBase = { /** * The metadata of the swap transaction. */ - swapMetaData?: Record; + swapMetaData?: Record; /** * The value of the token being swapped. @@ -689,9 +690,9 @@ export interface TransactionReceipt { status?: string; /** - * The index of this transaction in the list of transactions included in the block this transaction was mined in. + * The hexadecimal index of this transaction in the list of transactions included in the block this transaction was mined in. */ - transactionIndex?: number; + transactionIndex?: string; } /** diff --git a/packages/transaction-controller/src/utils/swaps.ts b/packages/transaction-controller/src/utils/swaps.ts index 9ead7ecdcc..1aa1bdac1c 100644 --- a/packages/transaction-controller/src/utils/swaps.ts +++ b/packages/transaction-controller/src/utils/swaps.ts @@ -3,10 +3,13 @@ import type EthQuery from '@metamask/eth-query'; import { merge, pickBy } from 'lodash'; import { CHAIN_IDS } from '../constants'; +import { createModuleLogger, projectLogger } from '../logger'; import type { Events, TransactionMeta } from '../types'; import { TransactionType } from '../types'; import { validateIfTransactionUnapproved } from './utils'; +const log = createModuleLogger(projectLogger, 'swaps'); + /** * Interval in milliseconds between checks of post transaction balance */ @@ -205,19 +208,26 @@ export async function updatePostTransactionBalance( updatedTransactionMeta: TransactionMeta; approvalTransactionMeta?: TransactionMeta; }> { - const transactionId = transactionMeta.id; + log('Updating post transaction balance', transactionMeta.id); + const transactionId = transactionMeta.id; let latestTransactionMeta, approvalTransactionMeta; + for (let i = 0; i < UPDATE_POST_TX_BALANCE_ATTEMPTS; i++) { + log('Querying balance', { attempt: i }); + const postTransactionBalance = await query(ethQuery, 'getBalance', [ transactionMeta.txParams.from, ]); + latestTransactionMeta = getTransaction(transactionId) as TransactionMeta; + approvalTransactionMeta = latestTransactionMeta.approvalTxId ? getTransaction(latestTransactionMeta.approvalTxId) : undefined; latestTransactionMeta.postTxBalance = postTransactionBalance.toString(16); + const isDefaultTokenAddress = isSwapsDefaultTokenAddress( transactionMeta.destinationTokenAddress as string, transactionMeta.chainId, @@ -227,9 +237,19 @@ export async function updatePostTransactionBalance( !isDefaultTokenAddress || transactionMeta.preTxBalance !== latestTransactionMeta.postTxBalance ) { + log('Finishing post balance update', { + isDefaultTokenAddress, + preTxBalance: transactionMeta.preTxBalance, + postTxBalance: latestTransactionMeta.postTxBalance, + }); + break; } + log('Waiting for balance to update', { + delay: UPDATE_POST_TX_BALANCE_TIMEOUT, + }); + await sleep(UPDATE_POST_TX_BALANCE_TIMEOUT); } @@ -237,6 +257,9 @@ export async function updatePostTransactionBalance( latestTransactionMeta as TransactionMeta, 'TransactionController#updatePostTransactionBalance - Add post transaction balance', ); + + log('Completed post balance update', latestTransactionMeta?.postTxBalance); + return { updatedTransactionMeta: latestTransactionMeta as TransactionMeta, approvalTransactionMeta, diff --git a/packages/transaction-controller/src/utils/utils.test.ts b/packages/transaction-controller/src/utils/utils.test.ts index e65f7c69cc..a4d13f7ce2 100644 --- a/packages/transaction-controller/src/utils/utils.test.ts +++ b/packages/transaction-controller/src/utils/utils.test.ts @@ -50,6 +50,7 @@ describe('utils', () => { estimatedBaseFee: '0xestimatedBaseFee', }); }); + it('normalizeTransaction if type is zero', () => { const normalized = util.normalizeTxParams({ ...commonInput, @@ -69,6 +70,13 @@ describe('utils', () => { type: '0x0', }); }); + + it('sets value if not specified', () => { + expect(util.normalizeTxParams({ from: '0xfrom' })).toStrictEqual({ + from: '0xfrom', + value: '0x0', + }); + }); }); describe('isEIP1559Transaction', () => { @@ -177,7 +185,7 @@ describe('utils', () => { }); describe('getAndFormatTransactionsForNonceTracker', () => { - it('should return an array of formatted NonceTrackerTransaction objects filtered by fromAddress and transactionStatus', () => { + it('returns formatted transactions filtered by chain, from, isTransfer, and status', () => { const fromAddress = '0x123'; const inputTransactions: TransactionMeta[] = [ { @@ -216,6 +224,31 @@ describe('utils', () => { }, status: TransactionStatus.approved, }, + { + id: '4', + chainId: '0x2', + time: 123459, + txParams: { + from: fromAddress, + gas: '0x103', + value: '0x203', + nonce: '0x4', + }, + status: TransactionStatus.confirmed, + }, + { + id: '5', + chainId: '0x2', + isTransfer: true, + time: 123460, + txParams: { + from: fromAddress, + gas: '0x104', + value: '0x204', + nonce: '0x5', + }, + status: TransactionStatus.confirmed, + }, ]; const expectedResult: NonceTrackerTransaction[] = [ @@ -224,18 +257,20 @@ describe('utils', () => { history: [{}], txParams: { from: fromAddress, - gas: '0x100', - value: '0x200', - nonce: '0x1', + gas: '0x103', + value: '0x203', + nonce: '0x4', }, }, ]; const result = util.getAndFormatTransactionsForNonceTracker( + '0x2', fromAddress, TransactionStatus.confirmed, inputTransactions, ); + expect(result).toStrictEqual(expectedResult); }); }); @@ -272,4 +307,33 @@ describe('utils', () => { }); }); }); + + describe('normalizeGasFeeValues', () => { + it('returns normalized object if legacy gas fees', () => { + expect( + util.normalizeGasFeeValues({ gasPrice: '1A', test: 'value' } as any), + ).toStrictEqual({ gasPrice: '0x1A' }); + }); + + it('returns normalized object if 1559 gas fees', () => { + expect( + util.normalizeGasFeeValues({ + maxFeePerGas: '1A', + maxPriorityFeePerGas: '2B3C', + test: 'value', + } as any), + ).toStrictEqual({ maxFeePerGas: '0x1A', maxPriorityFeePerGas: '0x2B3C' }); + }); + + it('returns empty 1559 object if missing gas fees', () => { + expect( + util.normalizeGasFeeValues({ + test: 'value', + } as any), + ).toStrictEqual({ + maxFeePerGas: undefined, + maxPriorityFeePerGas: undefined, + }); + }); + }); }); diff --git a/packages/transaction-controller/src/utils/utils.ts b/packages/transaction-controller/src/utils/utils.ts index e13fa2972f..cee98ca71f 100644 --- a/packages/transaction-controller/src/utils/utils.ts +++ b/packages/transaction-controller/src/utils/utils.ts @@ -41,11 +41,17 @@ const NORMALIZERS: { [param in keyof TransactionParams]: any } = { */ export function normalizeTxParams(txParams: TransactionParams) { const normalizedTxParams: TransactionParams = { from: '' }; + for (const key of getKnownPropertyNames(NORMALIZERS)) { if (txParams[key]) { normalizedTxParams[key] = NORMALIZERS[key](txParams[key]); } } + + if (!normalizedTxParams.value) { + normalizedTxParams.value = '0x0'; + } + return normalizedTxParams; } @@ -120,19 +126,23 @@ export function validateMinimumIncrease(proposed: string, min: string) { /** * Helper function to filter and format transactions for the nonce tracker. * + * @param currentChainId - Chain ID of the current network. * @param fromAddress - Address of the account from which the transactions to filter from are sent. * @param transactionStatus - Status of the transactions for which to filter. * @param transactions - Array of transactionMeta objects that have been prefiltered. * @returns Array of transactions formatted for the nonce tracker. */ export function getAndFormatTransactionsForNonceTracker( + currentChainId: string, fromAddress: string, transactionStatus: TransactionStatus, transactions: TransactionMeta[], ): NonceTrackerTransaction[] { return transactions .filter( - ({ status, txParams: { from } }) => + ({ chainId, isTransfer, status, txParams: { from } }) => + !isTransfer && + chainId === currentChainId && status === transactionStatus && from.toLowerCase() === fromAddress.toLowerCase(), ) @@ -189,3 +199,27 @@ export function normalizeTxError( rpc: error?.value, }; } + +/** + * Normalize an object containing gas fee values. + * + * @param gasFeeValues - An object containing gas fee values. + * @returns An object containing normalized gas fee values. + */ +export function normalizeGasFeeValues( + gasFeeValues: GasPriceValue | FeeMarketEIP1559Values, +): GasPriceValue | FeeMarketEIP1559Values { + const normalize = (value: any) => + typeof value === 'string' ? addHexPrefix(value) : value; + + if ('gasPrice' in gasFeeValues) { + return { + gasPrice: normalize(gasFeeValues.gasPrice), + }; + } + + return { + maxFeePerGas: normalize(gasFeeValues.maxFeePerGas), + maxPriorityFeePerGas: normalize(gasFeeValues.maxPriorityFeePerGas), + }; +} From 04e00a575c17bcc5b81fd97fb93b47e840cfd335 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Wed, 22 Nov 2023 06:54:07 -0800 Subject: [PATCH 07/17] Deprecate `BaseControllerV1` and use `BaseControllerV2` as default (#2078) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Motivation The controller-messenger pattern implemented by `BaseControllerV2` is intended to be used by all of our controllers. Currently, the default `BaseController` name points to the older base controller implementation, which needs to be deprecated and only used for temporary backwards compatibility while all controllers are brought up-to-date. ## Explanation In this commit, we export `BaseControllerV2` as the default `BaseController`, and add a `@deprecated` tsdoc tag to the old `BaseController` class as well as export it under the new name `BaseControllerV1` to discourage future usage. This aligns with the `PollingController` naming scheme, where the up-to-date version is the default, and outdated mixins are named with qualifiers (`PollingControllerOnly`, `PollingControllerV1`). ## Impact Existing controller classes in core that extend from the old base controller are not affected — they now simply extend from `BaseControllerV1` instead of `BaseController`. External packages will need to update any instances of `extends BaseController` to `extends BaseControllerV1` and `extends BaseControllerV2` to `extends BaseController`, along with accompanying changes to import statements. --------- Co-authored-by: Elliot Winkler --- .../src/AccountsController.ts | 4 ++-- .../src/AddressBookController.ts | 4 ++-- .../src/AnnouncementController.ts | 4 ++-- .../src/ApprovalController.ts | 4 ++-- .../src/AccountTrackerController.ts | 4 ++-- .../src/AssetsContractController.ts | 4 ++-- .../assets-controllers/src/NftController.ts | 4 ++-- .../src/TokenBalancesController.ts | 4 ++-- .../src/TokensController.ts | 4 ++-- ...oller.test.ts => BaseControllerV1.test.ts} | 4 ++-- ...{BaseController.ts => BaseControllerV1.ts} | 8 +++++--- packages/base-controller/src/index.ts | 10 +++++----- .../src/ComposableController.test.ts | 20 +++++++++---------- .../src/ComposableController.ts | 20 +++++++++---------- packages/ens-controller/src/EnsController.ts | 4 ++-- .../src/KeyringController.ts | 4 ++-- .../src/LoggingController.ts | 4 ++-- .../src/AbstractMessageManager.ts | 4 ++-- .../name-controller/src/NameController.ts | 4 ++-- .../src/NetworkController.ts | 4 ++-- .../src/NotificationController.ts | 4 ++-- .../src/PermissionController.ts | 6 +++--- .../src/SubjectMetadataController.ts | 4 ++-- .../src/PermissionLogController.ts | 4 ++-- .../src/PhishingController.ts | 2 +- .../src/PollingController.ts | 6 +++--- .../src/PreferencesController.ts | 4 ++-- .../src/QueuedRequestController.ts | 4 ++-- .../src/RateLimitController.ts | 2 +- .../src/SelectedNetworkController.ts | 4 ++-- .../src/SignatureController.ts | 4 ++-- .../src/TransactionController.ts | 6 +++--- 32 files changed, 87 insertions(+), 85 deletions(-) rename packages/base-controller/src/{BaseController.test.ts => BaseControllerV1.test.ts} (94%) rename packages/base-controller/src/{BaseController.ts => BaseControllerV1.ts} (93%) diff --git a/packages/accounts-controller/src/AccountsController.ts b/packages/accounts-controller/src/AccountsController.ts index 9bd9d8425a..e64792a4fa 100644 --- a/packages/accounts-controller/src/AccountsController.ts +++ b/packages/accounts-controller/src/AccountsController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { SnapKeyring } from '@metamask/eth-snap-keyring'; import type { InternalAccount } from '@metamask/keyring-api'; import { EthAccountType } from '@metamask/keyring-api'; @@ -133,7 +133,7 @@ const defaultState: AccountsControllerState = { * The accounts controller also listens for snap state changes and updates the internal accounts accordingly. * */ -export class AccountsController extends BaseControllerV2< +export class AccountsController extends BaseController< typeof controllerName, AccountsControllerState, AccountsControllerMessenger diff --git a/packages/address-book-controller/src/AddressBookController.ts b/packages/address-book-controller/src/AddressBookController.ts index ee163098d6..830e642f4d 100644 --- a/packages/address-book-controller/src/AddressBookController.ts +++ b/packages/address-book-controller/src/AddressBookController.ts @@ -1,5 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { normalizeEnsName, isValidHexAddress, @@ -70,7 +70,7 @@ export interface AddressBookState extends BaseState { /** * Controller that manages a list of recipient addresses associated with nicknames. */ -export class AddressBookController extends BaseController< +export class AddressBookController extends BaseControllerV1< BaseConfig, AddressBookState > { diff --git a/packages/announcement-controller/src/AnnouncementController.ts b/packages/announcement-controller/src/AnnouncementController.ts index 9db079f8a5..f3022c1134 100644 --- a/packages/announcement-controller/src/AnnouncementController.ts +++ b/packages/announcement-controller/src/AnnouncementController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; type ViewedAnnouncement = { [id: number]: boolean; @@ -77,7 +77,7 @@ export type AnnouncementControllerMessenger = RestrictedControllerMessenger< /** * Controller for managing in-app announcements. */ -export class AnnouncementController extends BaseControllerV2< +export class AnnouncementController extends BaseController< typeof controllerName, AnnouncementControllerState, AnnouncementControllerMessenger diff --git a/packages/approval-controller/src/ApprovalController.ts b/packages/approval-controller/src/ApprovalController.ts index 43de0133f6..8a880a7370 100644 --- a/packages/approval-controller/src/ApprovalController.ts +++ b/packages/approval-controller/src/ApprovalController.ts @@ -1,6 +1,6 @@ import type { ControllerGetStateAction } from '@metamask/base-controller'; import { - BaseControllerV2, + BaseController, type ControllerStateChangeEvent, type RestrictedControllerMessenger, } from '@metamask/base-controller'; @@ -338,7 +338,7 @@ export type ApprovalControllerActions = * Adding a request returns a promise that resolves or rejects when the request * is approved or denied, respectively. */ -export class ApprovalController extends BaseControllerV2< +export class ApprovalController extends BaseController< typeof controllerName, ApprovalControllerState, ApprovalControllerMessenger diff --git a/packages/assets-controllers/src/AccountTrackerController.ts b/packages/assets-controllers/src/AccountTrackerController.ts index 9d2da54baf..fa4c19cea2 100644 --- a/packages/assets-controllers/src/AccountTrackerController.ts +++ b/packages/assets-controllers/src/AccountTrackerController.ts @@ -1,5 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { BNToHex, query, @@ -54,7 +54,7 @@ export interface AccountTrackerState extends BaseState { /** * Controller that tracks the network balances for all user accounts. */ -export class AccountTrackerController extends BaseController< +export class AccountTrackerController extends BaseControllerV1< AccountTrackerConfig, AccountTrackerState > { diff --git a/packages/assets-controllers/src/AssetsContractController.ts b/packages/assets-controllers/src/AssetsContractController.ts index e6d237a6f2..887934b94c 100644 --- a/packages/assets-controllers/src/AssetsContractController.ts +++ b/packages/assets-controllers/src/AssetsContractController.ts @@ -1,7 +1,7 @@ import { Contract } from '@ethersproject/contracts'; import { Web3Provider } from '@ethersproject/providers'; import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { IPFS_DEFAULT_GATEWAY_URL } from '@metamask/controller-utils'; import type { NetworkClientId, @@ -75,7 +75,7 @@ export interface BalanceMap { /** * Controller that interacts with contracts on mainnet through web3 */ -export class AssetsContractController extends BaseController< +export class AssetsContractController extends BaseControllerV1< AssetsContractConfig, BaseState > { diff --git a/packages/assets-controllers/src/NftController.ts b/packages/assets-controllers/src/NftController.ts index 1ec393d6d8..301673cb61 100644 --- a/packages/assets-controllers/src/NftController.ts +++ b/packages/assets-controllers/src/NftController.ts @@ -5,7 +5,7 @@ import type { BaseState, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { safelyExecute, handleFetch, @@ -226,7 +226,7 @@ export type NftControllerMessenger = RestrictedControllerMessenger< /** * Controller that stores assets and exposes convenience methods */ -export class NftController extends BaseController { +export class NftController extends BaseControllerV1 { private readonly mutex = new Mutex(); private readonly messagingSystem: NftControllerMessenger; diff --git a/packages/assets-controllers/src/TokenBalancesController.ts b/packages/assets-controllers/src/TokenBalancesController.ts index 87febe5190..bca6cfa90d 100644 --- a/packages/assets-controllers/src/TokenBalancesController.ts +++ b/packages/assets-controllers/src/TokenBalancesController.ts @@ -1,5 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { safelyExecute } from '@metamask/controller-utils'; import type { PreferencesState } from '@metamask/preferences-controller'; import { BN } from 'ethereumjs-util'; @@ -43,7 +43,7 @@ export interface TokenBalancesState extends BaseState { * Controller that passively polls on a set interval token balances * for tokens stored in the TokensController */ -export class TokenBalancesController extends BaseController< +export class TokenBalancesController extends BaseControllerV1< TokenBalancesConfig, TokenBalancesState > { diff --git a/packages/assets-controllers/src/TokensController.ts b/packages/assets-controllers/src/TokensController.ts index 668a60347e..814ecabd1b 100644 --- a/packages/assets-controllers/src/TokensController.ts +++ b/packages/assets-controllers/src/TokensController.ts @@ -6,7 +6,7 @@ import type { BaseState, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import contractsMap from '@metamask/contract-metadata'; import { toChecksumHexAddress, @@ -124,7 +124,7 @@ export type TokensControllerMessenger = RestrictedControllerMessenger< /** * Controller that stores assets and exposes convenience methods */ -export class TokensController extends BaseController< +export class TokensController extends BaseControllerV1< TokensConfig, TokensState > { diff --git a/packages/base-controller/src/BaseController.test.ts b/packages/base-controller/src/BaseControllerV1.test.ts similarity index 94% rename from packages/base-controller/src/BaseController.test.ts rename to packages/base-controller/src/BaseControllerV1.test.ts index 33db173025..eb3d64c846 100644 --- a/packages/base-controller/src/BaseController.test.ts +++ b/packages/base-controller/src/BaseControllerV1.test.ts @@ -1,7 +1,7 @@ import * as sinon from 'sinon'; -import type { BaseConfig, BaseState } from './BaseController'; -import { BaseController } from './BaseController'; +import type { BaseConfig, BaseState } from './BaseControllerV1'; +import { BaseControllerV1 as BaseController } from './BaseControllerV1'; const STATE = { name: 'foo' }; const CONFIG = { disabled: true }; diff --git a/packages/base-controller/src/BaseController.ts b/packages/base-controller/src/BaseControllerV1.ts similarity index 93% rename from packages/base-controller/src/BaseController.ts rename to packages/base-controller/src/BaseControllerV1.ts index bd79016154..52312ac912 100644 --- a/packages/base-controller/src/BaseController.ts +++ b/packages/base-controller/src/BaseControllerV1.ts @@ -30,13 +30,15 @@ export interface BaseState { } /** + * @deprecated This class has been renamed to BaseControllerV1 and is no longer recommended for use for controllers. Please use BaseController (formerly BaseControllerV2) instead. + * * Controller class that provides configuration, state management, and subscriptions. * * The core purpose of every controller is to maintain an internal data object * called "state". Each controller is responsible for its own state, and all global wallet state * is tracked in a controller as state. */ -export class BaseController { +export class BaseControllerV1 { /** * Default options used to configure this controller */ @@ -68,7 +70,7 @@ export class BaseController { private readonly internalListeners: Listener[] = []; /** - * Creates a BaseController instance. Both initial state and initial + * Creates a BaseControllerV1 instance. Both initial state and initial * configuration options are merged with defaults upon initialization. * * @param config - Initial options used to configure this controller. @@ -190,4 +192,4 @@ export class BaseController { } } -export default BaseController; +export default BaseControllerV1; diff --git a/packages/base-controller/src/index.ts b/packages/base-controller/src/index.ts index 058db4076a..748110e2c1 100644 --- a/packages/base-controller/src/index.ts +++ b/packages/base-controller/src/index.ts @@ -1,17 +1,17 @@ -export type { BaseConfig, BaseState, Listener } from './BaseController'; -export { BaseController } from './BaseController'; +export type { BaseConfig, BaseState, Listener } from './BaseControllerV1'; +export { BaseControllerV1 } from './BaseControllerV1'; export type { Listener as ListenerV2, StateDeriver, StateMetadata, StatePropertyMetadata, + ControllerGetStateAction, + ControllerStateChangeEvent, } from './BaseControllerV2'; export { - BaseController as BaseControllerV2, + BaseController, getAnonymizedState, getPersistentState, - type ControllerGetStateAction, - type ControllerStateChangeEvent, } from './BaseControllerV2'; export * from './ControllerMessenger'; export * from './RestrictedControllerMessenger'; diff --git a/packages/composable-controller/src/ComposableController.test.ts b/packages/composable-controller/src/ComposableController.test.ts index f701a215e0..4c141633d9 100644 --- a/packages/composable-controller/src/ComposableController.test.ts +++ b/packages/composable-controller/src/ComposableController.test.ts @@ -4,7 +4,7 @@ import type { } from '@metamask/base-controller'; import { BaseController, - BaseControllerV2, + BaseControllerV1, ControllerMessenger, } from '@metamask/base-controller'; import type { Patch } from 'immer'; @@ -12,7 +12,7 @@ import * as sinon from 'sinon'; import { ComposableController } from './ComposableController'; -// Mock BaseControllerV2 classes +// Mock BaseController classes type FooControllerState = { foo: string; @@ -37,7 +37,7 @@ const fooControllerStateMetadata = { }, }; -class FooController extends BaseControllerV2< +class FooController extends BaseController< 'FooController', FooControllerState, FooMessenger @@ -58,13 +58,13 @@ class FooController extends BaseControllerV2< } } -// Mock BaseController classes +// Mock BaseControllerV1 classes type BarControllerState = BaseState & { bar: string; }; -class BarController extends BaseController { +class BarController extends BaseControllerV1 { defaultState = { bar: 'bar', }; @@ -85,7 +85,7 @@ type BazControllerState = BaseState & { baz: string; }; -class BazController extends BaseController { +class BazController extends BaseControllerV1 { defaultState = { baz: 'baz', }; @@ -103,7 +103,7 @@ describe('ComposableController', () => { sinon.restore(); }); - describe('BaseController', () => { + describe('BaseControllerV1', () => { it('should compose controller state', () => { const composableMessenger = new ControllerMessenger().getRestricted< 'ComposableController', @@ -264,7 +264,7 @@ describe('ComposableController', () => { }); }); - describe('Mixed BaseController and BaseControllerV2', () => { + describe('Mixed BaseControllerV1 and BaseControllerV2', () => { it('should compose controller state', () => { const barController = new BarController(); const controllerMessenger = new ControllerMessenger< @@ -329,7 +329,7 @@ describe('ComposableController', () => { }); }); - it('should notify listeners of BaseController state change', () => { + it('should notify listeners of BaseControllerV1 state change', () => { const barController = new BarController(); const controllerMessenger = new ControllerMessenger< never, @@ -430,7 +430,7 @@ describe('ComposableController', () => { expect( () => new ComposableController([barController, fooController]), ).toThrow( - 'Messaging system required if any BaseControllerV2 controllers are used', + 'Messaging system required if any BaseController controllers are used', ); }); }); diff --git a/packages/composable-controller/src/ComposableController.ts b/packages/composable-controller/src/ComposableController.ts index fb5eec1d14..bc599e0028 100644 --- a/packages/composable-controller/src/ComposableController.ts +++ b/packages/composable-controller/src/ComposableController.ts @@ -1,17 +1,17 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; /** * List of child controller instances * - * This type encompasses controllers based up either BaseController or - * BaseControllerV2. The BaseControllerV2 type can't be included directly + * This type encompasses controllers based up either BaseControllerV1 or + * BaseController. The BaseController type can't be included directly * because the generic parameters it expects require knowing the exact state - * shape, so instead we look for an object with the BaseControllerV2 properties + * shape, so instead we look for an object with the BaseController properties * that we use in the ComposableController (name and state). */ export type ControllerList = ( - | BaseController + | BaseControllerV1 | { name: string; state: Record } )[]; @@ -21,7 +21,7 @@ export type ComposableControllerRestrictedMessenger = /** * Controller that can be used to compose multiple controllers together. */ -export class ComposableController extends BaseController { +export class ComposableController extends BaseControllerV1 { private readonly controllers: ControllerList = []; private readonly messagingSystem?: ComposableControllerRestrictedMessenger; @@ -35,7 +35,7 @@ export class ComposableController extends BaseController { * Creates a ComposableController instance. * * @param controllers - Map of names to controller instances. - * @param messenger - The controller messaging system, used for communicating with BaseControllerV2 controllers. + * @param messenger - The controller messaging system, used for communicating with BaseController controllers. */ constructor( controllers: ControllerList, @@ -53,8 +53,8 @@ export class ComposableController extends BaseController { this.messagingSystem = messenger; this.controllers.forEach((controller) => { const { name } = controller; - if ((controller as BaseController).subscribe !== undefined) { - (controller as BaseController).subscribe((state) => { + if ((controller as BaseControllerV1).subscribe !== undefined) { + (controller as BaseControllerV1).subscribe((state) => { this.update({ [name]: state }); }); } else if (this.messagingSystem) { @@ -66,7 +66,7 @@ export class ComposableController extends BaseController { ); } else { throw new Error( - `Messaging system required if any BaseControllerV2 controllers are used`, + `Messaging system required if any BaseController controllers are used`, ); } }); diff --git a/packages/ens-controller/src/EnsController.ts b/packages/ens-controller/src/EnsController.ts index e65ebcd20f..340e7bcf1e 100644 --- a/packages/ens-controller/src/EnsController.ts +++ b/packages/ens-controller/src/EnsController.ts @@ -4,7 +4,7 @@ import type { } from '@ethersproject/providers'; import { Web3Provider } from '@ethersproject/providers'; import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import type { ChainId } from '@metamask/controller-utils'; import { normalizeEnsName, @@ -77,7 +77,7 @@ const ZERO_X_ERROR_ADDRESS = '0x'; * Controller that manages a list ENS names and their resolved addresses * by chainId. A null address indicates an unresolved ENS name. */ -export class EnsController extends BaseControllerV2< +export class EnsController extends BaseController< typeof name, EnsControllerState, EnsControllerMessenger diff --git a/packages/keyring-controller/src/KeyringController.ts b/packages/keyring-controller/src/KeyringController.ts index 92d63164cd..9743d28bb1 100644 --- a/packages/keyring-controller/src/KeyringController.ts +++ b/packages/keyring-controller/src/KeyringController.ts @@ -4,7 +4,7 @@ import type { IKeyringState as IQRKeyringState, } from '@keystonehq/metamask-airgapped-keyring'; import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { KeyringController as EthKeyringController } from '@metamask/eth-keyring-controller'; import type { ExportableKeyEncryptor, @@ -254,7 +254,7 @@ function assertHasUint8ArrayMnemonic( * with the internal keyring controller and handling certain complex operations that involve the * keyrings. */ -export class KeyringController extends BaseControllerV2< +export class KeyringController extends BaseController< typeof name, KeyringControllerState, KeyringControllerMessenger diff --git a/packages/logging-controller/src/LoggingController.ts b/packages/logging-controller/src/LoggingController.ts index 6d5ef19900..150711afd4 100644 --- a/packages/logging-controller/src/LoggingController.ts +++ b/packages/logging-controller/src/LoggingController.ts @@ -1,5 +1,5 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { v1 as random } from 'uuid'; import type { Log } from './logTypes'; @@ -61,7 +61,7 @@ const defaultState = { /** * Controller that manages a list of logs for signature requests. */ -export class LoggingController extends BaseControllerV2< +export class LoggingController extends BaseController< typeof name, LoggingControllerState, LoggingControllerMessenger diff --git a/packages/message-manager/src/AbstractMessageManager.ts b/packages/message-manager/src/AbstractMessageManager.ts index 4cbae637d9..849d9799f6 100644 --- a/packages/message-manager/src/AbstractMessageManager.ts +++ b/packages/message-manager/src/AbstractMessageManager.ts @@ -1,5 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import type { Hex, Json } from '@metamask/utils'; import { EventEmitter } from 'events'; @@ -109,7 +109,7 @@ export abstract class AbstractMessageManager< M extends AbstractMessage, P extends AbstractMessageParams, PM extends AbstractMessageParamsMetamask, -> extends BaseController> { +> extends BaseControllerV1> { protected messages: M[]; protected getCurrentChainId: getCurrentChainId | undefined; diff --git a/packages/name-controller/src/NameController.ts b/packages/name-controller/src/NameController.ts index e6dafffdd9..3a2529bde3 100644 --- a/packages/name-controller/src/NameController.ts +++ b/packages/name-controller/src/NameController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import type { NameProvider, @@ -104,7 +104,7 @@ export type SetNameRequest = { /** * Controller for storing and deriving names for values such as Ethereum addresses. */ -export class NameController extends BaseControllerV2< +export class NameController extends BaseController< typeof controllerName, NameControllerState, NameControllerMessenger diff --git a/packages/network-controller/src/NetworkController.ts b/packages/network-controller/src/NetworkController.ts index ffb535ad0d..10232782fe 100644 --- a/packages/network-controller/src/NetworkController.ts +++ b/packages/network-controller/src/NetworkController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { BUILT_IN_NETWORKS, NetworksTicker, @@ -532,7 +532,7 @@ type AutoManagedNetworkClientRegistry = { /** * Controller that creates and manages an Ethereum network provider. */ -export class NetworkController extends BaseControllerV2< +export class NetworkController extends BaseController< typeof name, NetworkState, NetworkControllerMessenger diff --git a/packages/notification-controller/src/NotificationController.ts b/packages/notification-controller/src/NotificationController.ts index e978c668f4..afe8b28a1d 100644 --- a/packages/notification-controller/src/NotificationController.ts +++ b/packages/notification-controller/src/NotificationController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { hasProperty } from '@metamask/utils'; import { nanoid } from 'nanoid'; @@ -89,7 +89,7 @@ const defaultState = { /** * Controller that handles storing notifications and showing them to the user */ -export class NotificationController extends BaseControllerV2< +export class NotificationController extends BaseController< typeof name, NotificationControllerState, NotificationControllerMessenger diff --git a/packages/permission-controller/src/PermissionController.ts b/packages/permission-controller/src/PermissionController.ts index addb0057b1..fc682e5112 100644 --- a/packages/permission-controller/src/PermissionController.ts +++ b/packages/permission-controller/src/PermissionController.ts @@ -13,7 +13,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import type { NonEmptyArray } from '@metamask/controller-utils'; import { isNonEmptyArray, @@ -511,7 +511,7 @@ export type PermissionControllerOptions< export class PermissionController< ControllerPermissionSpecification extends PermissionSpecificationConstraint, ControllerCaveatSpecification extends CaveatSpecificationConstraint, -> extends BaseControllerV2< +> extends BaseController< typeof controllerName, PermissionControllerState< ExtractPermission< @@ -565,7 +565,7 @@ export class PermissionController< * @param options.unrestrictedMethods - The callable names of all JSON-RPC * methods ignored by the new controller. * @param options.messenger - The controller messenger. See - * {@link BaseControllerV2} for more information. + * {@link BaseController} for more information. * @param options.state - Existing state to hydrate the controller with at * initialization. */ diff --git a/packages/permission-controller/src/SubjectMetadataController.ts b/packages/permission-controller/src/SubjectMetadataController.ts index e96a6822be..2915aa53da 100644 --- a/packages/permission-controller/src/SubjectMetadataController.ts +++ b/packages/permission-controller/src/SubjectMetadataController.ts @@ -3,7 +3,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import type { Json } from '@metamask/utils'; import type { @@ -97,7 +97,7 @@ type SubjectMetadataControllerOptions = { * A controller for storing metadata associated with permission subjects. More * or less, a cache. */ -export class SubjectMetadataController extends BaseControllerV2< +export class SubjectMetadataController extends BaseController< typeof controllerName, SubjectMetadataControllerState, SubjectMetadataControllerMessenger diff --git a/packages/permission-log-controller/src/PermissionLogController.ts b/packages/permission-log-controller/src/PermissionLogController.ts index b8445bc8c7..b9ac74d486 100644 --- a/packages/permission-log-controller/src/PermissionLogController.ts +++ b/packages/permission-log-controller/src/PermissionLogController.ts @@ -1,5 +1,5 @@ import { - BaseControllerV2, + BaseController, type RestrictedControllerMessenger, } from '@metamask/base-controller'; import type { JsonRpcMiddleware } from '@metamask/json-rpc-engine'; @@ -93,7 +93,7 @@ const name = 'PermissionLogController'; * Controller with middleware for logging requests and responses to restricted * and permissions-related methods. */ -export class PermissionLogController extends BaseControllerV2< +export class PermissionLogController extends BaseController< typeof name, PermissionLogControllerState, PermissionLogControllerMessenger diff --git a/packages/phishing-controller/src/PhishingController.ts b/packages/phishing-controller/src/PhishingController.ts index 2c95e86587..52ad9fe36a 100644 --- a/packages/phishing-controller/src/PhishingController.ts +++ b/packages/phishing-controller/src/PhishingController.ts @@ -1,5 +1,5 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 as BaseController } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { safelyExecute } from '@metamask/controller-utils'; import PhishingDetector from 'eth-phishing-detect/src/detector'; import { toASCII } from 'punycode/'; diff --git a/packages/polling-controller/src/PollingController.ts b/packages/polling-controller/src/PollingController.ts index 6cdad16519..0327a7806e 100644 --- a/packages/polling-controller/src/PollingController.ts +++ b/packages/polling-controller/src/PollingController.ts @@ -1,4 +1,4 @@ -import { BaseController, BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController, BaseControllerV1 } from '@metamask/base-controller'; import type { NetworkClientId } from '@metamask/network-controller'; import type { Json } from '@metamask/utils'; import stringify from 'fast-json-stable-stringify'; @@ -190,5 +190,5 @@ function PollingControllerMixin(Base: TBase) { class Empty {} export const PollingControllerOnly = PollingControllerMixin(Empty); -export const PollingController = PollingControllerMixin(BaseControllerV2); -export const PollingControllerV1 = PollingControllerMixin(BaseController); +export const PollingController = PollingControllerMixin(BaseController); +export const PollingControllerV1 = PollingControllerMixin(BaseControllerV1); diff --git a/packages/preferences-controller/src/PreferencesController.ts b/packages/preferences-controller/src/PreferencesController.ts index 490e7effce..e04f41bdaf 100644 --- a/packages/preferences-controller/src/PreferencesController.ts +++ b/packages/preferences-controller/src/PreferencesController.ts @@ -1,5 +1,5 @@ import type { BaseConfig, BaseState } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { toChecksumHexAddress } from '@metamask/controller-utils'; import { ETHERSCAN_SUPPORTED_CHAIN_IDS } from './constants'; @@ -62,7 +62,7 @@ export interface PreferencesState extends BaseState { /** * Controller that stores shared settings and exposes convenience methods */ -export class PreferencesController extends BaseController< +export class PreferencesController extends BaseControllerV1< BaseConfig, PreferencesState > { diff --git a/packages/queued-request-controller/src/QueuedRequestController.ts b/packages/queued-request-controller/src/QueuedRequestController.ts index 6f6abbfa2b..d28035c3eb 100644 --- a/packages/queued-request-controller/src/QueuedRequestController.ts +++ b/packages/queued-request-controller/src/QueuedRequestController.ts @@ -1,5 +1,5 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; const controllerName = 'QueuedRequestController'; @@ -53,7 +53,7 @@ export type QueuedRequestControllerOptions = { * an `enqueueRequest` method for adding requests to the queue. The controller initializes with a count of zero and * registers message handlers for request enqueuing. It also publishes count changes to inform external observers. */ -export class QueuedRequestController extends BaseControllerV2< +export class QueuedRequestController extends BaseController< typeof controllerName, QueuedRequestControllerState, QueuedRequestControllerMessenger diff --git a/packages/rate-limit-controller/src/RateLimitController.ts b/packages/rate-limit-controller/src/RateLimitController.ts index 613dcc360a..271bec95ce 100644 --- a/packages/rate-limit-controller/src/RateLimitController.ts +++ b/packages/rate-limit-controller/src/RateLimitController.ts @@ -4,7 +4,7 @@ import type { ControllerGetStateAction, ControllerStateChangeEvent, } from '@metamask/base-controller'; -import { BaseControllerV2 as BaseController } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { rpcErrors } from '@metamask/rpc-errors'; /** diff --git a/packages/selected-network-controller/src/SelectedNetworkController.ts b/packages/selected-network-controller/src/SelectedNetworkController.ts index 6f695309f9..b8336798e3 100644 --- a/packages/selected-network-controller/src/SelectedNetworkController.ts +++ b/packages/selected-network-controller/src/SelectedNetworkController.ts @@ -1,5 +1,5 @@ import type { RestrictedControllerMessenger } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import type { BlockTrackerProxy, NetworkClientId, @@ -97,7 +97,7 @@ export type NetworkProxy = { /** * Controller for getting and setting the network for a particular domain. */ -export class SelectedNetworkController extends BaseControllerV2< +export class SelectedNetworkController extends BaseController< typeof controllerName, SelectedNetworkControllerState, SelectedNetworkControllerMessenger diff --git a/packages/signature-controller/src/SignatureController.ts b/packages/signature-controller/src/SignatureController.ts index b07c1cb163..7e9c5a8bad 100644 --- a/packages/signature-controller/src/SignatureController.ts +++ b/packages/signature-controller/src/SignatureController.ts @@ -8,7 +8,7 @@ import type { ControllerStateChangeEvent, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseControllerV2 } from '@metamask/base-controller'; +import { BaseController } from '@metamask/base-controller'; import { ApprovalType, ORIGIN_METAMASK } from '@metamask/controller-utils'; import type { KeyringControllerSignMessageAction, @@ -134,7 +134,7 @@ export type SignatureControllerOptions = { /** * Controller for creating signing requests requiring user approval. */ -export class SignatureController extends BaseControllerV2< +export class SignatureController extends BaseController< typeof controllerName, SignatureControllerState, SignatureControllerMessenger diff --git a/packages/transaction-controller/src/TransactionController.ts b/packages/transaction-controller/src/TransactionController.ts index 63b1499ed1..387acc7bb0 100644 --- a/packages/transaction-controller/src/TransactionController.ts +++ b/packages/transaction-controller/src/TransactionController.ts @@ -11,7 +11,7 @@ import type { BaseState, RestrictedControllerMessenger, } from '@metamask/base-controller'; -import { BaseController } from '@metamask/base-controller'; +import { BaseControllerV1 } from '@metamask/base-controller'; import { query, NetworkType, @@ -211,7 +211,7 @@ export interface TransactionControllerEventEmitter extends EventEmitter { /** * Controller responsible for submitting and managing transactions. */ -export class TransactionController extends BaseController< +export class TransactionController extends BaseControllerV1< TransactionConfig, TransactionState > { @@ -2040,7 +2040,7 @@ export class TransactionController extends BaseController< * representation, this function will not break apart transactions with the * same nonce, created on the same day, per network. Not accounting for transactions of the same * nonce, same day and network combo can result in confusing or broken experiences - * in the UI. The transactions are then updated using the BaseController update. + * in the UI. The transactions are then updated using the BaseControllerV1 update. * * @param transactions - The transactions to be applied to the state. * @returns The trimmed list of transactions. From c5b014c99853a8d7edc7dc6cfdb401aa4893b582 Mon Sep 17 00:00:00 2001 From: Jongsun Suh Date: Wed, 22 Nov 2023 07:17:12 -0800 Subject: [PATCH 08/17] [`base-controller`] Enforce that `RestrictedControllerMessenger` is not initialized with internal actions/events in allow lists (#2051) ## Explanation - `RestrictedControllerMessenger` constructor and `ControllerMessenger.getRestricted()` method now raise a type error if an internal action is passed into `allowedActions`, or an internal event into `allowedEvents`. - ` Type 'string' is not assignable to type 'never'.` - `Type '"SomeController:internalAction"' is not assignable to type '"OtherController:externalAction1" | "OtherController:externalAction2"'.` - Fixes breaking tests in downstream controllers in core repo. ## Impact - The `allowed{Actions,Events}` arrays in `ControllerMessenger.getRestricted()` now align with the `Allowed{Actions,Events}` generic params of `RestrictedControllerMessenger`: Both only enumerate external actions/events. - This commit disallows `allowed{Actions,Events}` arrays that contain an incomplete list of internal actions/events. - A partial list doesn't provide any useful information as all internal actions/events will be available to the messenger regardless of whether any of them are allowlisted. - A partial list also gives the confusing impression that some internal actions/events can be *disallowed* through omission, which is not true as of https://github.com/MetaMask/core/pull/2050. --------- Co-authored-by: Elliot Winkler --- .../src/AccountsController.test.ts | 6 ---- .../src/AssetsContractController.test.ts | 5 ---- .../src/NftController.test.ts | 1 - .../src/TokenBalancesController.test.ts | 2 -- .../src/TokenDetectionController.test.ts | 5 +--- .../src/TokenListController.test.ts | 5 +--- .../src/TokensController.test.ts | 1 - .../src/ControllerMessenger.ts | 23 ++++++++++---- .../src/RestrictedControllerMessenger.ts | 30 +++++++++++++------ .../src/GasFeeController.test.ts | 11 ++----- .../src/KeyringController.test.ts | 19 ------------ .../tests/NetworkController.test.ts | 11 ------- .../src/PermissionController.test.ts | 4 +-- .../src/SubjectMetadataController.test.ts | 9 ++---- .../queued-request-controller/tests/utils.ts | 6 ---- .../src/RateLimitController.test.ts | 7 +---- .../tests/utils.ts | 6 +--- 17 files changed, 50 insertions(+), 101 deletions(-) diff --git a/packages/accounts-controller/src/AccountsController.test.ts b/packages/accounts-controller/src/AccountsController.test.ts index 06e17660f4..d2ccc1ef62 100644 --- a/packages/accounts-controller/src/AccountsController.test.ts +++ b/packages/accounts-controller/src/AccountsController.test.ts @@ -194,12 +194,6 @@ function buildAccountsControllerMessenger(messenger = buildMessenger()) { 'KeyringController:getAccounts', 'KeyringController:getKeyringForAccount', 'KeyringController:getKeyringsByType', - 'AccountsController:listAccounts', - 'AccountsController:setAccountName', - 'AccountsController:setSelectedAccount', - 'AccountsController:updateAccounts', - 'AccountsController:getSelectedAccount', - 'AccountsController:getAccountByAddress', ], }); } diff --git a/packages/assets-controllers/src/AssetsContractController.test.ts b/packages/assets-controllers/src/AssetsContractController.test.ts index 0b463d130c..d16d6fbcb0 100644 --- a/packages/assets-controllers/src/AssetsContractController.test.ts +++ b/packages/assets-controllers/src/AssetsContractController.test.ts @@ -52,11 +52,6 @@ async function setupAssetContractControllers() { const messenger: NetworkControllerMessenger = new ControllerMessenger().getRestricted({ name: 'NetworkController', - allowedEvents: [ - 'NetworkController:stateChange', - 'NetworkController:networkDidChange', - ], - allowedActions: [], }); const network = new NetworkController({ infuraProjectId: networkClientConfiguration.infuraProjectId, diff --git a/packages/assets-controllers/src/NftController.test.ts b/packages/assets-controllers/src/NftController.test.ts index 2bba7d4326..f2f5360206 100644 --- a/packages/assets-controllers/src/NftController.test.ts +++ b/packages/assets-controllers/src/NftController.test.ts @@ -165,7 +165,6 @@ function setupController({ const approvalControllerMessenger = messenger.getRestricted({ name: 'ApprovalController', - allowedActions: ['ApprovalController:addRequest'], }); const approvalController = new ApprovalController({ diff --git a/packages/assets-controllers/src/TokenBalancesController.test.ts b/packages/assets-controllers/src/TokenBalancesController.test.ts index 3a95197fc0..4764844f25 100644 --- a/packages/assets-controllers/src/TokenBalancesController.test.ts +++ b/packages/assets-controllers/src/TokenBalancesController.test.ts @@ -123,8 +123,6 @@ describe('TokenBalancesController', () => { const messenger: NetworkControllerMessenger = new ControllerMessenger().getRestricted({ name: 'NetworkController', - allowedEvents: ['NetworkController:stateChange'], - allowedActions: [], }); new NetworkController({ diff --git a/packages/assets-controllers/src/TokenDetectionController.test.ts b/packages/assets-controllers/src/TokenDetectionController.test.ts index 40a030a54b..6eba6e1c9d 100644 --- a/packages/assets-controllers/src/TokenDetectionController.test.ts +++ b/packages/assets-controllers/src/TokenDetectionController.test.ts @@ -109,10 +109,7 @@ const setupTokenListController = ( const tokenListMessenger = controllerMessenger.getRestricted({ name: 'TokenListController', allowedActions: [], - allowedEvents: [ - 'TokenListController:stateChange', - 'NetworkController:stateChange', - ], + allowedEvents: ['NetworkController:stateChange'], }); const tokenList = new TokenListController({ diff --git a/packages/assets-controllers/src/TokenListController.test.ts b/packages/assets-controllers/src/TokenListController.test.ts index 3c2bc8884e..8cfb70add4 100644 --- a/packages/assets-controllers/src/TokenListController.test.ts +++ b/packages/assets-controllers/src/TokenListController.test.ts @@ -591,10 +591,7 @@ const getRestrictedMessenger = ( const messenger = controllerMessenger.getRestricted({ name, allowedActions: ['NetworkController:getNetworkClientById'], - allowedEvents: [ - 'TokenListController:stateChange', - 'NetworkController:stateChange', - ], + allowedEvents: ['NetworkController:stateChange'], }); return messenger; diff --git a/packages/assets-controllers/src/TokensController.test.ts b/packages/assets-controllers/src/TokensController.test.ts index 9f841cb58d..9f4f9073b3 100644 --- a/packages/assets-controllers/src/TokensController.test.ts +++ b/packages/assets-controllers/src/TokensController.test.ts @@ -69,7 +69,6 @@ describe('TokensController', () => { const approvalControllerMessenger = messenger.getRestricted({ name: 'ApprovalController', - allowedActions: ['ApprovalController:addRequest'], }); const approvalController = new ApprovalController({ diff --git a/packages/base-controller/src/ControllerMessenger.ts b/packages/base-controller/src/ControllerMessenger.ts index 3e0b1e98f2..398005f060 100644 --- a/packages/base-controller/src/ControllerMessenger.ts +++ b/packages/base-controller/src/ControllerMessenger.ts @@ -86,11 +86,16 @@ type EventSubscriptionMap< * @template Namespace - The namespace we're checking for. * @template Name - The full string, including the namespace. */ -export type Namespaced< +export type NamespacedBy< Namespace extends string, Name, > = Name extends `${Namespace}:${string}` ? Name : never; +export type NotNamespacedBy< + Namespace extends string, + Name, +> = Name extends `${Namespace}:${string}` ? never : Name; + export type NamespacedName = `${Namespace}:${string}`; @@ -379,21 +384,29 @@ export class ControllerMessenger< * module that this messenger has been created for. The authority to publish events and register * actions under this namespace is granted to this restricted messenger instance. * @template AllowedAction - A type union of the 'type' string for any allowed actions. + * This must not include internal actions that are in the messenger's namespace. * @template AllowedEvent - A type union of the 'type' string for any allowed events. + * This must not include internal events that are in the messenger's namespace. * @returns The restricted controller messenger. */ getRestricted< Namespace extends string, - AllowedAction extends string, - AllowedEvent extends string, + AllowedAction extends NotNamespacedBy, + AllowedEvent extends NotNamespacedBy, >({ name, allowedActions, allowedEvents, }: { name: Namespace; - allowedActions?: Extract[]; - allowedEvents?: Extract[]; + allowedActions?: NotNamespacedBy< + Namespace, + Extract + >[]; + allowedEvents?: NotNamespacedBy< + Namespace, + Extract + >[]; }): RestrictedControllerMessenger< Namespace, | NarrowToNamespace diff --git a/packages/base-controller/src/RestrictedControllerMessenger.ts b/packages/base-controller/src/RestrictedControllerMessenger.ts index c19bc57cd8..d22e7b3ea8 100644 --- a/packages/base-controller/src/RestrictedControllerMessenger.ts +++ b/packages/base-controller/src/RestrictedControllerMessenger.ts @@ -8,6 +8,7 @@ import type { ExtractEventHandler, ExtractEventPayload, NamespacedName, + NotNamespacedBy, SelectorEventHandler, SelectorFunction, } from './ControllerMessenger'; @@ -24,7 +25,9 @@ import type { * @template Action - A type union of all Action types. * @template Event - A type union of all Event types. * @template AllowedAction - A type union of the 'type' string for any allowed actions. + * This must not include internal actions that are in the messenger's namespace. * @template AllowedEvent - A type union of the 'type' string for any allowed events. + * This must not include internal events that are in the messenger's namespace. */ export class RestrictedControllerMessenger< Namespace extends string, @@ -40,9 +43,9 @@ export class RestrictedControllerMessenger< readonly #controllerName: Namespace; - readonly #allowedActions: AllowedAction[] | null; + readonly #allowedActions: NotNamespacedBy[] | null; - readonly #allowedEvents: AllowedEvent[] | null; + readonly #allowedEvents: NotNamespacedBy[] | null; /** * Constructs a restricted controller messenger @@ -70,13 +73,13 @@ export class RestrictedControllerMessenger< }: { controllerMessenger: ControllerMessenger; name: Namespace; - allowedActions?: AllowedAction[]; - allowedEvents?: AllowedEvent[]; + allowedActions?: NotNamespacedBy[]; + allowedEvents?: NotNamespacedBy[]; }) { this.#controllerMessenger = controllerMessenger; this.#controllerName = name; - this.#allowedActions = allowedActions || null; - this.#allowedEvents = allowedEvents || null; + this.#allowedActions = allowedActions ?? null; + this.#allowedEvents = allowedEvents ?? null; } /** @@ -226,6 +229,7 @@ export class RestrictedControllerMessenger< * @param selector - The selector function used to select relevant data from * the event payload. The type of the parameters for this selector must match * the type of the payload for this event type. + * @throws Will throw if the given event is not an allowed event for this controller messenger. * @template EventType - A type union of Event type strings. * @template SelectorReturnValue - The selector return value. */ @@ -275,7 +279,7 @@ export class RestrictedControllerMessenger< * * @param event - The event type. This is a unique identifier for this event. * @param handler - The event handler to unregister. - * @throws Will throw when the given event is not an allowed event for this controller messenger. + * @throws Will throw if the given event is not an allowed event for this controller messenger. * @template EventType - A type union of allowed Event type strings. */ unsubscribe< @@ -319,7 +323,11 @@ export class RestrictedControllerMessenger< * @param eventType - The event type to check. * @returns Whether the event type is allowed. */ - #isAllowedEvent(eventType: Event['type']): eventType is AllowedEvent { + #isAllowedEvent( + eventType: Event['type'], + ): eventType is + | NamespacedName + | NotNamespacedBy { // Safely upcast to allow runtime check const allowedEvents: string[] | null = this.#allowedEvents; return ( @@ -336,7 +344,11 @@ export class RestrictedControllerMessenger< * @param actionType - The action type to check. * @returns Whether the action type is allowed. */ - #isAllowedAction(actionType: Action['type']): actionType is AllowedAction { + #isAllowedAction( + actionType: Action['type'], + ): actionType is + | NamespacedName + | NotNamespacedBy { // Safely upcast to allow runtime check const allowedActions: string[] | null = this.#allowedActions; return ( diff --git a/packages/gas-fee-controller/src/GasFeeController.test.ts b/packages/gas-fee-controller/src/GasFeeController.test.ts index 6cd2b3433a..e2f34c6d27 100644 --- a/packages/gas-fee-controller/src/GasFeeController.test.ts +++ b/packages/gas-fee-controller/src/GasFeeController.test.ts @@ -71,15 +71,8 @@ const setupNetworkController = async ({ }) => { const restrictedMessenger = unrestrictedMessenger.getRestricted({ name: 'NetworkController', - allowedActions: [ - 'NetworkController:getState', - 'NetworkController:getNetworkClientById', - 'NetworkController:getEIP1559Compatibility', - ], - allowedEvents: [ - 'NetworkController:stateChange', - 'NetworkController:networkDidChange', - ], + allowedActions: [], + allowedEvents: [], }); const networkController = new NetworkController({ diff --git a/packages/keyring-controller/src/KeyringController.test.ts b/packages/keyring-controller/src/KeyringController.test.ts index 45b21ba19f..827560b2e0 100644 --- a/packages/keyring-controller/src/KeyringController.test.ts +++ b/packages/keyring-controller/src/KeyringController.test.ts @@ -2306,25 +2306,6 @@ function buildMessenger() { function buildKeyringControllerMessenger(messenger = buildMessenger()) { return messenger.getRestricted({ name: 'KeyringController', - allowedActions: [ - 'KeyringController:getState', - 'KeyringController:signMessage', - 'KeyringController:signPersonalMessage', - 'KeyringController:signTypedMessage', - 'KeyringController:decryptMessage', - 'KeyringController:getEncryptionPublicKey', - 'KeyringController:getKeyringsByType', - 'KeyringController:getKeyringForAccount', - 'KeyringController:getAccounts', - 'KeyringController:persistAllKeyrings', - ], - allowedEvents: [ - 'KeyringController:stateChange', - 'KeyringController:lock', - 'KeyringController:unlock', - 'KeyringController:accountRemoved', - 'KeyringController:qrKeyringStateChange', - ], }); } diff --git a/packages/network-controller/tests/NetworkController.test.ts b/packages/network-controller/tests/NetworkController.test.ts index 36f7567ec9..ef4c7f08f3 100644 --- a/packages/network-controller/tests/NetworkController.test.ts +++ b/packages/network-controller/tests/NetworkController.test.ts @@ -7069,17 +7069,6 @@ function buildMessenger() { function buildNetworkControllerMessenger(messenger = buildMessenger()) { return messenger.getRestricted({ name: 'NetworkController', - allowedActions: [ - 'NetworkController:getProviderConfig', - 'NetworkController:getEthQuery', - ], - allowedEvents: [ - 'NetworkController:stateChange', - 'NetworkController:infuraIsBlocked', - 'NetworkController:infuraIsUnblocked', - 'NetworkController:networkDidChange', - 'NetworkController:networkWillChange', - ], }); } diff --git a/packages/permission-controller/src/PermissionController.test.ts b/packages/permission-controller/src/PermissionController.test.ts index 29a62805e6..511def4eb0 100644 --- a/packages/permission-controller/src/PermissionController.test.ts +++ b/packages/permission-controller/src/PermissionController.test.ts @@ -476,8 +476,8 @@ function getPermissionControllerMessenger( ) { return messenger.getRestricted< typeof controllerName, - PermissionControllerActions['type'] | AllowedActions['type'], - PermissionControllerEvents['type'] + AllowedActions['type'], + never >({ name: controllerName, allowedActions: [ diff --git a/packages/permission-controller/src/SubjectMetadataController.test.ts b/packages/permission-controller/src/SubjectMetadataController.test.ts index de67b769dc..6c23a93819 100644 --- a/packages/permission-controller/src/SubjectMetadataController.test.ts +++ b/packages/permission-controller/src/SubjectMetadataController.test.ts @@ -34,14 +34,11 @@ function getSubjectMetadataControllerMessenger() { return [ controllerMessenger.getRestricted< typeof controllerName, - SubjectMetadataControllerActions['type'] | HasPermissions['type'], - SubjectMetadataControllerEvents['type'] + HasPermissions['type'], + never >({ name: controllerName, - allowedActions: [ - 'PermissionController:hasPermissions', - 'SubjectMetadataController:getState', - ], + allowedActions: ['PermissionController:hasPermissions'], }) as SubjectMetadataControllerMessenger, hasPermissionsSpy, ] as const; diff --git a/packages/queued-request-controller/tests/utils.ts b/packages/queued-request-controller/tests/utils.ts index 37fb94939b..3ff7bc3785 100644 --- a/packages/queued-request-controller/tests/utils.ts +++ b/packages/queued-request-controller/tests/utils.ts @@ -4,10 +4,6 @@ import type { QueuedRequestControllerActions, QueuedRequestControllerEvents, } from '../src/QueuedRequestController'; -import { - QueuedRequestControllerActionTypes, - QueuedRequestControllerEventTypes, -} from '../src/QueuedRequestController'; /** * Build a controller messenger that includes all events used by the selected network @@ -32,7 +28,5 @@ export function buildQueuedRequestControllerMessenger( ) { return messenger.getRestricted({ name: 'QueuedRequestController', - allowedActions: [...Object.values(QueuedRequestControllerActionTypes)], - allowedEvents: [...Object.values(QueuedRequestControllerEventTypes)], }); } diff --git a/packages/rate-limit-controller/src/RateLimitController.test.ts b/packages/rate-limit-controller/src/RateLimitController.test.ts index 2dc2a77244..1159e878aa 100644 --- a/packages/rate-limit-controller/src/RateLimitController.test.ts +++ b/packages/rate-limit-controller/src/RateLimitController.test.ts @@ -43,13 +43,8 @@ function getUnrestrictedMessenger() { function getRestrictedMessenger( controllerMessenger = getUnrestrictedMessenger(), ) { - return controllerMessenger.getRestricted< - typeof name, - RateLimitControllerActions['type'], - never - >({ + return controllerMessenger.getRestricted({ name, - allowedActions: ['RateLimitController:call'], }) as RateLimitMessenger; } diff --git a/packages/selected-network-controller/tests/utils.ts b/packages/selected-network-controller/tests/utils.ts index 043c407bb5..6837fb3981 100644 --- a/packages/selected-network-controller/tests/utils.ts +++ b/packages/selected-network-controller/tests/utils.ts @@ -5,7 +5,6 @@ import type { SelectedNetworkControllerAction, SelectedNetworkControllerEvent, } from '../src/SelectedNetworkController'; -import { SelectedNetworkControllerActionTypes } from '../src/SelectedNetworkController'; /** * Build a controller messenger that includes all events used by the selected network @@ -37,10 +36,7 @@ export function buildSelectedNetworkControllerMessenger( ); return messenger.getRestricted({ name: 'SelectedNetworkController', - allowedActions: [ - ...Object.values(SelectedNetworkControllerActionTypes), - 'NetworkController:getNetworkClientById', - ], + allowedActions: ['NetworkController:getNetworkClientById'], allowedEvents: ['NetworkController:stateChange'], }); } From d1d8dd93dbce281298dc305d6dd8f583238ee807 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:18:31 -0700 Subject: [PATCH 09/17] Log changes from PR 2065 --- packages/transaction-controller/CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/packages/transaction-controller/CHANGELOG.md b/packages/transaction-controller/CHANGELOG.md index 06641f9243..4769e7c544 100644 --- a/packages/transaction-controller/CHANGELOG.md +++ b/packages/transaction-controller/CHANGELOG.md @@ -9,12 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [18.0.0] ### Added - Add `updateEditableParams` method ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Add `initApprovals` method to trigger the approval flow for any pending transactions during initialisation ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Add `getTransactions` method to search transactions using the given criteria and options ([#2056](https://github.com/MetaMask/core/pull/2056)) ### Changed - **BREAKING:** Bump `@metamask/base-controller` to ^4.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - This is breaking because the type of the `messenger` has backward-incompatible changes. See the changelog for this package for more. +- **BREAKING:** Add `finished` and `publish-skip` events to `Events` type +- **BREAKING:** Update `TransactionReceipt` type so `transactionIndex` is now a string rather than a number ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `nonce-tracker` to ^3.0.0 ([#2040](https://github.com/MetaMask/core/pull/2040)) - The controller now emits a `transaction-status-update` event each time the status of a transaction changes (e.g. submitted, rejected, etc.) ([#2027](https://github.com/MetaMask/core/pull/2027)) +- Make `getCurrentAccountEIP1559Compatibility` constructor parameter optional ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Normalize the gas values provided to the `speedUpTransaction` and `stopTransaction` methods ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Persist any property changes performed by the `afterSign` hook ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Report success to the approver if publishing is skipped by the `beforePublish` hook ([#2056](https://github.com/MetaMask/core/pull/2056)) +- Update `postTxBalance` after all swap transactions ([#2056](https://github.com/MetaMask/core/pull/2056)) - Bump `@metamask/approval-controller` to ^5.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/controller-utils` to ^6.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) - Bump `@metamask/gas-fee-controller` to ^11.0.0 ([#2063](https://github.com/MetaMask/core/pull/2063)) From 848a7579e0430fbf5a3ddd068bc7892f4d2aa5d8 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:26:08 -0700 Subject: [PATCH 10/17] Incorporate changes from PR 2078 --- packages/base-controller/CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index f0a4453ad6..129ec2cd0c 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -20,6 +20,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **BREAKING:** Alter controller messenger `ExtractEventHandler` utility type so `Event` type parameter must satisfy `EventConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractEventPayload` utility type so `Event` type parameter must satisfy `EventConstraint` and `Event['payload']` must be an array (to match behavior of `ExtractEventHandler`) ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter `controller messenger SelectorFunction` type so its `Event` parameter must satisfy `EventConstraint`, and so it returns a function whose arguments satisfy an event payload via `ExtractEventPayload` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** `BaseController` is now renamed to `BaseControllerV1` and has been deprecated; `BaseController` now points to what was previously called `BaseControllerV2` ([#2078](https://github.com/MetaMask/core/pull/2078)) + - This should encourage use of `BaseController` v2 for new controllers going forward. + - If your controller is importing `BaseControllerV2`, you will need to import `BaseController` instead. + - If your controller is still importing `BaseController` v1, you will need to import and use `BaseControllerV1` instead. That said, please consider migrating your controller to v2. - The restricted controller messenger now allows calling all internal events and actions ([#2050](https://github.com/MetaMask/core/pull/2050)) - Previously internal events and actions were only usable if they were listed as "allowed". They are still permitted to be listed as "allowed" now, but it is no longer necessary. - Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) From c2f90a17d6f7d105c40406884f468e34945aaea8 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:34:27 -0700 Subject: [PATCH 11/17] Log changes for PR 2051 --- packages/base-controller/CHANGELOG.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 129ec2cd0c..7a49d85c22 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -24,8 +24,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - This should encourage use of `BaseController` v2 for new controllers going forward. - If your controller is importing `BaseControllerV2`, you will need to import `BaseController` instead. - If your controller is still importing `BaseController` v1, you will need to import and use `BaseControllerV1` instead. That said, please consider migrating your controller to v2. -- The restricted controller messenger now allows calling all internal events and actions ([#2050](https://github.com/MetaMask/core/pull/2050)) - - Previously internal events and actions were only usable if they were listed as "allowed". They are still permitted to be listed as "allowed" now, but it is no longer necessary. +- **BREAKING:** The restricted controller messenger now allows calling all internal events and actions by default and prohibits explicitly allowlisting any of them ([#2050](https://github.com/MetaMask/core/pull/2050), [#2078](https://github.com/MetaMask/core/pull/2078)) + - Previously internal events and actions were only usable if they were listed as "allowed" via the `allowedActions` or `allowedEvents` options to the `RestrictedControllerMessenger` constructor or `ControllerMessenger.getRestricted()`. Now this works implicitly. + - In fact, attempting to allowlist any of them will raise a type error, as otherwise, it would be possible to specify a partial list of allowed actions or events, and that would be misleading, since all of them are allowed anyway. - Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) ## [3.2.3] From 5dd37b96a00a893937f565c40dd584e56b49f812 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:38:54 -0700 Subject: [PATCH 12/17] Fix PR number --- packages/base-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 7a49d85c22..4b8e299859 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -24,7 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - This should encourage use of `BaseController` v2 for new controllers going forward. - If your controller is importing `BaseControllerV2`, you will need to import `BaseController` instead. - If your controller is still importing `BaseController` v1, you will need to import and use `BaseControllerV1` instead. That said, please consider migrating your controller to v2. -- **BREAKING:** The restricted controller messenger now allows calling all internal events and actions by default and prohibits explicitly allowlisting any of them ([#2050](https://github.com/MetaMask/core/pull/2050), [#2078](https://github.com/MetaMask/core/pull/2078)) +- **BREAKING:** The restricted controller messenger now allows calling all internal events and actions by default and prohibits explicitly allowlisting any of them ([#2050](https://github.com/MetaMask/core/pull/2050), [#2051](https://github.com/MetaMask/core/pull/2051)) - Previously internal events and actions were only usable if they were listed as "allowed" via the `allowedActions` or `allowedEvents` options to the `RestrictedControllerMessenger` constructor or `ControllerMessenger.getRestricted()`. Now this works implicitly. - In fact, attempting to allowlist any of them will raise a type error, as otherwise, it would be possible to specify a partial list of allowed actions or events, and that would be misleading, since all of them are allowed anyway. - Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) From 68ac7c46c9776723959eb731c2dcc72710479793 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:42:43 -0700 Subject: [PATCH 13/17] Log additional changes in PR 2051 --- packages/base-controller/CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 4b8e299859..0084dcd02d 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `ControllerGetStateAction` and `ControllerStateChangeEvent` types ([#1890](https://github.com/MetaMask/core/pull/1890), [#2029](https://github.com/MetaMask/core/pull/2029)) - Add `NamespacedName` type ([#1890](https://github.com/MetaMask/core/pull/1890)) - This is the narrowest supertype of all names defined within a given namespace. +- Add `NotNamespacedBy` type, which matches a non-namespaced action/event name ([#2051](https://github.com/MetaMask/core/pull/2051)) ### Changed - **BREAKING:** Narrow controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) @@ -27,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **BREAKING:** The restricted controller messenger now allows calling all internal events and actions by default and prohibits explicitly allowlisting any of them ([#2050](https://github.com/MetaMask/core/pull/2050), [#2051](https://github.com/MetaMask/core/pull/2051)) - Previously internal events and actions were only usable if they were listed as "allowed" via the `allowedActions` or `allowedEvents` options to the `RestrictedControllerMessenger` constructor or `ControllerMessenger.getRestricted()`. Now this works implicitly. - In fact, attempting to allowlist any of them will raise a type error, as otherwise, it would be possible to specify a partial list of allowed actions or events, and that would be misleading, since all of them are allowed anyway. +- **BREAKING:** Rename `Namespaced` type to `NamespacedBy` ([#2051](https://github.com/MetaMask/core/pull/2051)) - Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) ## [3.2.3] From a2e54bc1074b344c2836dfb3a6db111ca7051854 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:45:32 -0700 Subject: [PATCH 14/17] Tweak wording for SelectorFunction Co-authored-by: Jongsun Suh --- packages/base-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 0084dcd02d..caf0a34106 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -20,7 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **BREAKING:** Alter controller messenger `ExtractActionParameters` utility type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractEventHandler` utility type so `Event` type parameter must satisfy `EventConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractEventPayload` utility type so `Event` type parameter must satisfy `EventConstraint` and `Event['payload']` must be an array (to match behavior of `ExtractEventHandler`) ([#1890](https://github.com/MetaMask/core/pull/1890)) -- **BREAKING:** Alter `controller messenger SelectorFunction` type so its `Event` parameter must satisfy `EventConstraint`, and so it returns a function whose arguments satisfy an event payload via `ExtractEventPayload` ([#1890](https://github.com/MetaMask/core/pull/1890)) +- **BREAKING:** Alter controller messenger `SelectorFunction` type so that its generic parameter `Args` is replaced by `Event`, which must satisfy `EventConstraint`, and it returns a function whose arguments satisfy the event payload type specified by `Event` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** `BaseController` is now renamed to `BaseControllerV1` and has been deprecated; `BaseController` now points to what was previously called `BaseControllerV2` ([#2078](https://github.com/MetaMask/core/pull/2078)) - This should encourage use of `BaseController` v2 for new controllers going forward. - If your controller is importing `BaseControllerV2`, you will need to import `BaseController` instead. From 839ae72c7ffdc9837161982d2d319d8a8abbaf99 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:48:04 -0700 Subject: [PATCH 15/17] Change to ActionConstraint['handler'] is not actually breaking Co-authored-by: Jongsun Suh --- packages/base-controller/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index caf0a34106..2b659a046b 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -14,8 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `NotNamespacedBy` type, which matches a non-namespaced action/event name ([#2051](https://github.com/MetaMask/core/pull/2051)) ### Changed -- **BREAKING:** Narrow controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) - - This type is now defined as the universal supertype of all action handlers, meaning any functions can be safely assigned to it, regardless of argument types, number of arguments, or return value type. +- Alter controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) + - This type is now defined as the universal supertype of all functions, meaning any function can be safely assigned as an action handler, regardless of argument types, number of arguments, or return value type. - **BREAKING:** Alter controller messenger `ActionHandler` type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractActionParameters` utility type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractEventHandler` utility type so `Event` type parameter must satisfy `EventConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) From a469108a6976a1160e669594660628de68a08276 Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 10:49:28 -0700 Subject: [PATCH 16/17] Move entry for ActionConstraint['handler'] down --- packages/base-controller/CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index 2b659a046b..f311c678d2 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -14,8 +14,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `NotNamespacedBy` type, which matches a non-namespaced action/event name ([#2051](https://github.com/MetaMask/core/pull/2051)) ### Changed -- Alter controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) - - This type is now defined as the universal supertype of all functions, meaning any function can be safely assigned as an action handler, regardless of argument types, number of arguments, or return value type. - **BREAKING:** Alter controller messenger `ActionHandler` type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractActionParameters` utility type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) - **BREAKING:** Alter controller messenger `ExtractEventHandler` utility type so `Event` type parameter must satisfy `EventConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890)) @@ -29,6 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Previously internal events and actions were only usable if they were listed as "allowed" via the `allowedActions` or `allowedEvents` options to the `RestrictedControllerMessenger` constructor or `ControllerMessenger.getRestricted()`. Now this works implicitly. - In fact, attempting to allowlist any of them will raise a type error, as otherwise, it would be possible to specify a partial list of allowed actions or events, and that would be misleading, since all of them are allowed anyway. - **BREAKING:** Rename `Namespaced` type to `NamespacedBy` ([#2051](https://github.com/MetaMask/core/pull/2051)) +- Alter controller messenger `ActionConstraint['handler']` type to remove usage of `any` ([#1890](https://github.com/MetaMask/core/pull/1890)) + - This type is now defined as the universal supertype of all functions, meaning any function can be safely assigned as an action handler, regardless of argument types, number of arguments, or return value type. - Bump `@metamask/utils` to ^8.2.0 ([#1957](https://github.com/MetaMask/core/pull/1957)) ## [3.2.3] From 47ef4c69141574191e159d263e400379daefd1bc Mon Sep 17 00:00:00 2001 From: Elliot Winkler Date: Wed, 22 Nov 2023 12:30:05 -0700 Subject: [PATCH 17/17] Fix wording for `NotNamespacedBy` Co-authored-by: Jongsun Suh --- packages/base-controller/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base-controller/CHANGELOG.md b/packages/base-controller/CHANGELOG.md index f311c678d2..28ab65d269 100644 --- a/packages/base-controller/CHANGELOG.md +++ b/packages/base-controller/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `ControllerGetStateAction` and `ControllerStateChangeEvent` types ([#1890](https://github.com/MetaMask/core/pull/1890), [#2029](https://github.com/MetaMask/core/pull/2029)) - Add `NamespacedName` type ([#1890](https://github.com/MetaMask/core/pull/1890)) - This is the narrowest supertype of all names defined within a given namespace. -- Add `NotNamespacedBy` type, which matches a non-namespaced action/event name ([#2051](https://github.com/MetaMask/core/pull/2051)) +- Add `NotNamespacedBy` type, which matches an action/event name if and only if it is not prefixed by a given namespace ([#2051](https://github.com/MetaMask/core/pull/2051)) ### Changed - **BREAKING:** Alter controller messenger `ActionHandler` type so `Action` type parameter must satisfy (updated) `ActionConstraint` ([#1890](https://github.com/MetaMask/core/pull/1890))