Repository navigation
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
PR template — items to address before "Ready for review"Warnings — informational, address before merging:
See docs/readme/ready-for-review.md for the full Definition of Ready for Review. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Warning MetaMask internal reviewing guidelines:
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Since all changes are either cosmetic (console.log additions) or non-functional metadata (previewBuilds section), no E2E tests need to be run. Performance Test Selection: |
|
…taMask#9324) ## 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? --> Currently, `BaseDataService` has a `fetchQuery` method which is best used for making read-only requests ("queries" in TanStack Query parlance), but does not work as well for requests that change state on the server side ("mutations"). For instance, it makes sense for queries to be cached and retried, but not so much for mutations. This commit adds a separate method, `executeMutation`, which accommodates mutations better. Besides the differences mentioned above, it also uses the mutation cache instead of the query cache. ## 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 --> Closes https://consensyssoftware.atlassian.net/browse/WPC-1118. ## Manual testing I've created MetaMask#10176, which converts `AuthenticatedUserStorageService.setAssetsWatchlist` to use `executeMutation` under the hood, and MetaMask/metamask-mobile#36083, which loads those changes into the mobile app. You can check out the mobile branch and run through the manual testing steps there to confirm that `executeMutation` still exhibits the same basic behavior as `fetchQuery`. ## 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 communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Medium Risk** > Changes shared cache/event contracts (`objectType`, mutation sync) and introduces server-mutating paths; incorrect retry or hydration behavior could cause duplicate writes or stale UI state, though mutations are explicitly non-retried. > > **Overview** > Adds **mutation support** alongside existing query flows in `BaseDataService` and `@metamask/react-data-query`, so write requests no longer go through query-style caching and retries. > > **`BaseDataService`** gains a protected **`executeMutation`** API (plus exported **`MutationKey`**) that runs through TanStack’s mutation cache, optional Superstruct validation via **`processMutationResponse`**, and **no retry policy** (only the circuit breaker runs the request). Mutations can carry a **`globalId`** (default UUID) in `meta` to correlate with the UI client. **`:cacheUpdated`** payloads now include **`objectType: 'query' | 'mutation'`**, and mutation cache lifecycle is wired into persistence, dehydration, and **`destroy()`** (including clearing mutation GC timers). > > **`react-data-query`** exposes **`useMutation`** (retries off by default), routes data-service mutations through the messenger with the UI’s **`globalId`**, and syncs service-side mutation state via **`hydrateMutations`** on **`updated`** cache events only (so idle `added` events do not clobber settled UI results). > > **`@tanstack/query-core`** (and **`@tanstack/react-query`**) are bumped to **`^5.89.0`** across dependent packages; **`uuid`** is added where mutation IDs are minted. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 2bc6446. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->



This PR bumps
@metamask/authenticated-user-storageand@metamask/base-data-serviceto preview versions whereAuthenticatedUserStorageService.setAssetsWatchlistusesexecuteMutation— a new method inBaseDataService— to make the underlying API request.Also see MetaMask/core#9324 for the changes to
BaseDataServicewhich make this possible.This PR will be removed once this smoke test is complete.
Manual testing steps
yarn watch:clean.