Skip to content

feat: Add support for data services extending BaseDataService#27921

Merged
FrederikBolding merged 3 commits into
mainfrom
fb/base-data-service-impl
Mar 27, 2026
Merged

feat: Add support for data services extending BaseDataService#27921
FrederikBolding merged 3 commits into
mainfrom
fb/base-data-service-impl

Conversation

@FrederikBolding

@FrederikBolding FrederikBolding commented Mar 25, 2026

Copy link
Copy Markdown
Member

Description

Replace the default QueryClient with a custom QueryClient from createUIQueryClient. This establishes the query client required for using the BaseDataService pattern from the core repo, which handles cache syncing. Existing UI-only queries should work as they did previously.

Changelog

CHANGELOG entry: null

Related issues

https://consensyssoftware.atlassian.net/browse/WPC-445


Note

Medium Risk
Moderate risk because it changes how the global React Query QueryClient is constructed and introduces messenger-backed call/subscribe plumbing that could affect caching and network behavior across the app.

Overview
Switches ReactQueryService to build its queryClient via @metamask/react-data-query’s createUIQueryClient, passing an Engine messenger adapter to support data services and cache syncing while keeping the existing default query options.

Adds a DATA_SERVICES registry (currently empty) for wiring in available data services, updates unit tests to validate the new client defaults and cache clearing behavior, and adds the new @metamask/react-data-query dependency (plus lockfile updates).

Written by Cursor Bugbot for commit 088a264. This will update automatically on new commits. Configure here.

@metamaskbot metamaskbot added the team-core-platform Core Platform team label Mar 25, 2026
Comment thread package.json
@@ -350,7 +351,7 @@
"@sentry/react-native": "~6.15.0",
"@shopify/flash-list": "2.0.3",
"@solana/addresses": "2.0.0",
"@tanstack/react-query": "^5.90.20",
"@tanstack/react-query": "^4.43.0",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary downgrade until React 18 is introduced on extension.

@socket-security

socket-security Bot commented Mar 25, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​react-data-query@​0.2.0721007392100

View full report

@socket-security

socket-security Bot commented Mar 25, 2026

Copy link
Copy Markdown

All alerts resolved. Learn more about Socket for GitHub.

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring alerts on:

  • npm/@metamask/base-data-service@0.1.1

View full report

@FrederikBolding

Copy link
Copy Markdown
Member Author

@SocketSecurity ignore npm/@metamask/base-data-service@0.1.0

False positive, this package does not have access to the fetch global on its own. Nevertheless we own the package.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Mar 26, 2026
@FrederikBolding FrederikBolding force-pushed the fb/base-data-service-impl branch from cb60f36 to bd2ab08 Compare March 26, 2026 20:21
@FrederikBolding

Copy link
Copy Markdown
Member Author

@SocketSecurity ignore npm/@metamask/base-data-service@0.1.1

False positive, this package does not have access to the fetch global on its own. Nevertheless we own the package.

@FrederikBolding FrederikBolding marked this pull request as ready for review March 27, 2026 09:41
@FrederikBolding FrederikBolding force-pushed the fb/base-data-service-impl branch from 28aec95 to 088a264 Compare March 27, 2026 09:41
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeRamps, SmokeWalletPlatform, SmokeConfirmations, SmokeTrade
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 72%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes modify the ReactQueryService, which is a core infrastructure component that wraps the entire app via QueryClientProvider in Root/index.tsx. The key change replaces new QueryClient() with createUIQueryClient() from the new @metamask/react-data-query package, adding an adapter that bridges Engine's controllerMessenger to the query client.

Key observations:

  1. Root-level impact: ReactQueryService is instantiated at app root (Root/index.tsx), so any behavioral difference in QueryClient initialization could affect all features.
  2. DATA_SERVICES is empty: The new DATA_SERVICES constant is an empty array, meaning no actual data services are registered yet. This is foundational scaffolding.
  3. Ramp dependency: ReactQueryService is explicitly imported in app/components/UI/Ramp/routes.tsx, making Ramp flows a direct consumer.
  4. QueryClient options preserved: The same staleTime, retry, and cacheTime options are passed through, but createUIQueryClient may add a default queryFn (visible in test assertions: queryFn: expect.any(Function)), which could affect queries that don't specify their own queryFn.
  5. New package: Adding @metamask/react-data-query@^0.2.0 introduces a new dependency that needs validation.

Selected tags rationale:

  • SmokeRamps: Direct consumer of ReactQueryService in Ramp routes; most likely to be affected by query client changes.
  • SmokeWalletPlatform: Core wallet features that use React Query for data fetching (transaction history, trending, etc.).
  • SmokeConfirmations: Transaction flows that may use React Query for data fetching.
  • SmokeTrade: Swap/bridge flows that use React Query for quote fetching and token data.

Not selecting all tags because DATA_SERVICES is empty (no new data service behavior), the QueryClient options are preserved, and the change is primarily infrastructure scaffolding with low likelihood of breaking existing query patterns.

Performance Test Selection:
The ReactQueryService change replaces QueryClient initialization with createUIQueryClient, but DATA_SERVICES is empty so no new data fetching behavior is introduced. The QueryClient options (staleTime, retry, cacheTime) are preserved. While this is a data layer change, it doesn't introduce new rendering paths, list components, or critical flow changes that would meaningfully impact measured performance metrics. No performance tests are warranted.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
18 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@FrederikBolding FrederikBolding added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Mar 27, 2026
@FrederikBolding FrederikBolding added this pull request to the merge queue Mar 27, 2026
Merged via the queue into main with commit 18af7ab Mar 27, 2026
204 of 208 checks passed
@FrederikBolding FrederikBolding deleted the fb/base-data-service-impl branch March 27, 2026 11:19
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 27, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Mar 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

INVALID-PR-TEMPLATE PR's body doesn't match template release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-S skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-core-platform Core Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants