feat(money): scaffold a data service package which talks to Money Account API#9278
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 9c5495a. Configure here.
shane-t
previously approved these changes
Jul 7, 2026
Adds the initial package scaffold for the Money Account API data service using `yarn create-package`, along with monorepo registration in CODEOWNERS and teams.json. Co-authored-by: Cursor <cursoragent@cursor.com>
4 tasks
FrederikBolding
approved these changes
Jul 7, 2026
defiQUG
pushed a commit
to defiQUG/core
that referenced
this pull request
Jul 7, 2026
## Explanation The Earn team currently lacks a dedicated data service for fetching user positions, interest accruals, cash-flow history, and vault rate history from the **Money Account API** (vertical app hosted at `money.api.cx.metamask.io`). Follow up to MetaMask#9278 This PR introduces `@metamask/money-account-api-data-service`, a new package that: - Extends `BaseDataService` to leverage TanStack Query caching, service policy (retries + circuit-breaking), and messenger integration out of the box. - Exposes 4 methods via the messenger: `fetchPositions`, `fetchInterest`, `fetchHistory`, `fetchRateHistory`. - Uses `@metamask/superstruct` for runtime response validation, with types derived from structs (`Infer<typeof ...Struct>`) to prevent type/struct drift. - Includes detailed validation error messages (superstruct failure details + error `cause` chain) for easier production debugging. - Uses `fetchInfiniteQuery` for the cursor-paginated history endpoint, giving consumers proper TanStack Query pagination semantics. - Configures `retryFilterPolicy` to skip retrying validation errors (malformed responses won't fix themselves). - Supports environment switching (`dev` / `uat` / `prd`) via an `Env` enum + URL map, following the `claims-controller` pattern. This is architected as an **independent service**. The client calls it directly for API-sourced data, separate from `money-account-balance-service` which handles RPC-based balance fetching. **A future orchestration layer may unify these**. ## 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) - [x] 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 > **Note:** No breaking changes introduced — this is an entirely new package (`v0.0.0`). --- > [!NOTE] > **Low Risk** > New isolated package with no changes to existing controllers; risk is limited to future consumers trusting API-sourced financial display data and external API contract stability. > > **Overview** > Adds **`@metamask/money-account-api-data-service`**, a new Earn-team package that fetches vault positions, interest, cash-flow history, and vault rate history from the Money Account HTTP API (separate from RPC-based `money-account-balance-service`). > > **`MoneyAccountApiDataService`** extends `BaseDataService` with TanStack Query caching, messenger actions (`fetchPositions`, `fetchInterest`, `fetchHistory`, `fetchRateHistory`, `invalidateQueries`), dev/uat/prd base URLs via `Env`, and superstruct-validated responses with **`MoneyAccountApiResponseValidationError`** (no retries on validation failures). History uses **`fetchInfiniteQuery`** for cursor pagination; other endpoints use tuned stale times aligned with server cache TTLs. > > Monorepo wiring updates **CODEOWNERS**, **README**, **teams.json**, root **tsconfig** references, and **yarn.lock** for the new workspace package. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit ae6334b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
This file contains hidden or 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
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
Scaffolds the new
@metamask/money-account-api-data-servicepackage usingyarn create-package. This is the minimal setup required before implementing the service logic (which will follow in a stacked PR).Changes include:
package.json,tsconfig.json,tsconfig.build.json,jest.config.js,typedoc.json,LICENSE,README.md,CHANGELOG.md, placeholdersrc/index.ts)tsconfig.jsonandtsconfig.build.jsonproject referencesCODEOWNERSownership entries for@MetaMask/earnteams.jsonmapping toteam-earnyarn.lockupdateReferences
packages/money-account-balance-serviceChecklist
Note
Low Risk
New package with no production logic or consumer integrations; changes are mostly boilerplate and metadata.
Overview
Adds a new monorepo package
@metamask/money-account-api-data-service, intended (per README) to fetch Money Account API data such as positions, interest, cash-flow history, and vault rate history. This PR is scaffold only: standardcreate-packagelayout (build/test/tsconfig, licenses, changelog) and a placeholdergreeterexport insrc/index.ts—no API client orbase-data-serviceintegration yet.Wires the package into the repo: root
tsconfig.json/tsconfig.build.jsonreferences,READMEpackage list and dependency graph node,CODEOWNERSandteams.json(@MetaMask/earn/team-earn), release ownership entries, andyarn.lock. Also reordersplatform-api-docsin the root tsconfig reference lists (no functional change to that package).Reviewed by Cursor Bugbot for commit d60d162. Bugbot is set up for automated code reviews on this repo. Configure here.