-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: update multichain controllers to listen for new update events #5221
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…g type (#4985) ## Explanation return promise value if image starts with 'ipfs://' at `ERC721Standard.ts` ## References ## Changelog ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes --------- Co-authored-by: Elliot Winkler <[email protected]>
The number of Prettier warnings has gone down by 3.
This release centers around reverting changes to the following packages so that a per-dapp selected network is not the default, but rather opt-in. This is required in order to be able to keep Mobile on the latest versions of these packages as it has not yet been updated to support the Per-Dapp Selected Network feature. - `@metamask/queued-request-controller` (8.0.2 -> 9.0.0) - `@metamask/selected-network-controller` (20.0.2 -> 21.0.0)
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> This PR adds a new package to the Core repo, with the new MultichainTransactions controller, it comes from my original [extension PR](MetaMask/metamask-extension#29129), and it's responsibility is to track transactions for non-EVM accounts, with different block times, by using the Solana and Bitcoin snaps as the data source. It shares the same approach/structure with the MultichainBalancesController, given that responsibilities are very similar. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> It relates to the [PR opened in extension](MetaMask/metamask-extension#29129) that will be updated after this one is merged. ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/multichain-transactions-controller` - **ADDED**: New `multichain-transactions-controller` package, with the `MultichainTransactionsController` to track the transactions for non-EVM accounts by using the Solana and Bitcoin snaps as the data source.. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
## Explanation Bump accounts-related dependencies. ## References N/A ## Changelog ### `@metamask/accounts-controller` - **CHANGED**: Bump `@metamask/keyring-api` from `^13.0.0` to `^14.0.0` - **CHANGED**: Bump `@metamask/keyring-internal-api` from `^2.0.0` to `^2.0.1` - **CHANGED**: Bump `@metamask/eth-snap-keyring` from `^8.1.0` to `^8.1.1` ### `@metamask/assets-controller` - **CHANGED**: Bump `@metamask/keyring-api` from `^13.0.0` to `^14.0.0` - **CHANGED**: Bump `@metamask/keyring-internal-api` from `^2.0.0` to `^2.0.1` - **CHANGED**: Bump `@metamask/keyring-snap-client` from `^2.0.0` to `^3.0.0` ### `@metamask/accounts-controller` - **CHANGED**: Bump `@metamask/keyring-api` from `^13.0.0` to `^14.0.0` - **CHANGED**: Bump `@metamask/keyring-internal-api` from `^2.0.0` to `^2.0.1` ### `@metamask/accounts-controller` - **CHANGED**: Bump `@metamask/keyring-api` from `^13.0.0` to `^14.0.0` - **CHANGED**: Bump `@metamask/keyring-internal-api` from `^2.0.0` to `^2.0.1` ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
Just a bump dependencies release to align the `keyring-api` recent changes everywhere.
…#5183) ## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> ## References Fixes a bug in the `@metamask/multichain` package where the `removeScope` mutator was dropping necessary properties from the original caveat value which was making the permission fail in the validator in Extension. ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/multichain` - **FIXED**: Fix `removeScope` to only modify `requiredScopes` and `optionalScopes` values on the caveat where previously it was also dropping `sessionProperties` and `isMultichainOrigin` from the final result. ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
## @metamask/multichain ## [3.0.0] ### Add - Add key Multichain API methods ([#4813](#4813)) - Adds `getInternalScopesObject` and `getSessionScopes` helpers for transforming between `NormalizedScopesObject` and `InternalScopesObject`. - Adds `walletGetSession`, `walletInvokeMethod`, and `walletRevokeSession` handlers. - Adds `multichainMethodCallValidatorMiddleware` for validating Multichain API method params as defined in @metamask/api-specs. - Adds `MultichainMiddlewareManager` to multiplex a request to other middleware based on requested scope. - Adds `MultichainSubscriptionManager` to handle concurrent subscriptions across multiple scopes. - Adds `bucketScopes` which groups the scopes in a `NormalizedScopesObject` based on if the scopes are already supported, could be supported, or are not supportable. - Adds `getSupportedScopeObjects` helper for getting only the supported methods and notifications from each `NormalizedScopeObject` in a `NormalizedScopesObject`. - Fixes `removeScope` mutator incorrectly returning malformed CAIP-25 caveat values ([#5183](#5183)). ### Changed - Bump `@metamask/controller-utils` from `^11.4.4` to `^11.4.5` ([#5012](#5135)) - Bump `@metamask/permission-controller` from `^11.0.4` to `^11.0.5` ([#5012](#5135)) - Bump `@metamask/utils` to `^11.0.1` and `@metamask/rpc-errors` to `^7.0.2` ([#5080](#5080)) --------- Co-authored-by: jiexi <[email protected]>
## `@metamask/multichain` ## [2.1.0] ### Added - Add key Multichain API methods ([#4813](#4813)) - Adds `getInternalScopesObject` and `getSessionScopes` helpers for transforming between `NormalizedScopesObject` and `InternalScopesObject`. - Adds handlers for `wallet_getSession`, `wallet_invokeMethod`, and `wallet_revokeSession` methods. - Adds `multichainMethodCallValidatorMiddleware` for validating Multichain API method params as defined in @metamask/api-specs. - Adds `MultichainMiddlewareManager` to multiplex a request to other middleware based on requested scope. - Adds `MultichainSubscriptionManager` to handle concurrent subscriptions across multiple scopes. - Adds `bucketScopes` which groups the scopes in a `NormalizedScopesObject` based on if the scopes are already supported, could be supported, or are not supportable. - Adds `getSupportedScopeObjects` helper for getting only the supported methods and notifications from each `NormalizedScopeObject` in a `NormalizedScopesObject`. ### Changed - Bump `@metamask/controller-utils` from `^11.4.4` to `^11.4.5` ([#5012](#5135)) - Bump `@metamask/permission-controller` from `^11.0.4` to `^11.0.5` ([#5012](#5135)) - Bump `@metamask/utils` to `^11.0.1` and `@metamask/rpc-errors` to `^7.0.2` ([#5080](#5080)) ### Fixed - Fixes `removeScope` mutator incorrectly returning malformed CAIP-25 caveat values ([#5183](#5183)).
This commit is a continuation of a previous commit which added a utility function for use in service classes which ensures that they follow the circuit breaker and retry patterns. This commit completes the function by adding: - `retryFilterPolicy`, which allows for retrying certain errors and not handling others. - `maxRetries`, which allows for giving up early before the max consecutive failures is reached. Note that because this can combine with `maxConsecutiveFailures`, it adds a bunch of other code paths and so this requires adding a lot of new tests.
Both RetryPolicy and CircuitBreakerPolicy from the Cockatiel library allow for listening for events using `on*` methods. For instance, if you have a retry policy, you can listen for when the function is retried like so: ``` typescript retryPolicy.onRetry(() => { // ... }) ``` Our "service policy" allows for listening to some of the same events as well as the "degraded" event. Instead of exposing `on*` methods, however, `createServicePolicy` takes callbacks in an options bag: ``` typescript createServicePolicy({ // ... onRetry: () => { // ... } ) ``` For parity with Cockatiel — and for easier use in general — this commit changes the API so that the object that `createServicePolicy` returns now includes similar `on*` methods. This way you can say: ``` typescript const policy = createServicePolicy({ ... }); policy.onRetry(() => { // ... }); ```
When running tests, we are seeing the following warning: > An input selector returned a different result when passed same arguments. This means your output selector will likely run more frequently than intended. This is happening because the "input selector" in `selectAvailableNetworkClientIds` returns a new object reference (returned by `getNetworkConfigurations`) each time it is called. This violates the Redux guidelines outlined here: <https://redux.js.org/usage/deriving-data-selectors#optimizing-selectors-with-memoization>. To fix this, we split off the "input selector" into its own selector function which we then memoize.
…rom `cockatiel` (#5192) Expose these exports from `cockatiel` so consumers can use them without needing to depend on the library directly: - `BrokenCircuitError` - `CircuitState` - `handleAll` - `handleWhen` Also, update `createServicePolicy` to expose the retry and circuit breaker policies so that we can access their state in other modules that use this utility function. This is needed to be able to create an RPC service.
In a future commit, we are adding an RpcService class to `network-controller` to handle automatic failovers. This class is different from the existing service classes in a couple of ways: - RpcService will make use of a new `createServicePolicy` function which encapsulates retry and circuit breaker logic. This will relieve any module that consumes RpcService from needing to test this logic. - RpcService will have `onBreak` and `onDegraded` methods instead of taking `onBreak` and `onDegraded` callbacks as constructor options. This is reflected not only in the class but also in the abstract RPC service interface. To these ends, this commit makes the following changes to `CodefiTokenPricesServiceV2` in `assets-controllers` and `ClientConfigApiService` in `remote-feature-flag-controller`: - Refactor service class to use `createServicePolicy` - Update the abstract service class interface to extend `ServicePolicy` from `controller-utils` - Deprecate the `onBreak` and `onDegraded` constructor options, and add methods instead Note that we are not including `TokenSearchApiService` in this commit, even though it is a class, because it does not use the retry or circuit breaker policy.
## Explanation Updates the `firebase` module from `^10.11.0` to `^11.2.0`. This update fixes a undici audit issue (see references). I've checked the v11 update: 1. It resolves the audit issue. (currently) there is no `v10.x.x` firebase package that resolves this audit issue. 2. We only use `firebase/messaging`, which is not a major version bump and has been validated to be work with `v11.x.x` **NOTE:** Ideally it would be nice to just utilise `firebase/messaging`, but the firebase npm recommends the full package. Maybe we can explore a smaller, trimmed down firebase package that doesn't include everything? **TEST:** 1. Navigate to the `notification-services-controller` package. 2. Run `yarn npm audit --recursive --environment production --severity moderate` and see audit logs. ## References Extension PR to fix undici audit: MetaMask/metamask-extension#29914 ## Changelog ### `@metamask/notification-services-controller` - **CHANGEED (BREAKING)**: updated `firebase` module from `^10.11.0` to `^11.2.0`. - It is worth noting that the underlying `firebase/messaging` was not bumped. ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
## Explanation Bumps `@metamask/notification-services-controller` from `0.16.0` to `0.17.0` ## References ## Changelog ``` ### Changed - **BREAKING:** Bump depenency `firebase` from `^10.11.0` to `^11.2.0` ([#5196](#5196)) ``` ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've highlighted breaking changes using the "BREAKING" category above as appropriate - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
ccharly
reviewed
Feb 5, 2025
...ges/assets-controllers/src/MultichainBalancesController/MultichainBalancesController.test.ts
Outdated
Show resolved
Hide resolved
packages/assets-controllers/src/MultichainBalancesController/MultichainBalancesController.ts
Outdated
Show resolved
Hide resolved
packages/multichain-transactions-controller/src/MultichainTransactionsController.test.ts
Outdated
Show resolved
Hide resolved
packages/multichain-transactions-controller/src/MultichainTransactionsController.ts
Show resolved
Hide resolved
packages/multichain-transactions-controller/src/MultichainTransactionsController.ts
Outdated
Show resolved
Hide resolved
packages/multichain-transactions-controller/src/MultichainTransactionsController.ts
Outdated
Show resolved
Hide resolved
ccharly
reviewed
Feb 5, 2025
Co-authored-by: Charly Chevalier <[email protected]>
ccharly
approved these changes
Feb 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💪
sahar-fehri
approved these changes
Feb 5, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
We are updating the
MultichainBalancesController
andMultichainTransactionsController
to listen for the update balances/transactions events fromAccountsController
:AccountsController:accountBalancesUpdated
AccountsController:accountTransactionsUpdated
Also from now own we are changing the approach, to stop doing the polling requests to the snaps, and just listen for these update events, hence removing the associated poll logic.
References
N/A
Changelog
@metamask/multichain-transactions-controller
@metamask/assets-controllers
MultichainBalancesController
Checklist