feat(money): add a data service which talks to Money Account API#9278
Open
ffmcgee725 wants to merge 10 commits into
Open
feat(money): add a data service which talks to Money Account API#9278ffmcgee725 wants to merge 10 commits into
ffmcgee725 wants to merge 10 commits into
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.
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
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).This PR introduces
@metamask/money-account-api-data-service, a new package that:BaseDataServiceto leverage TanStack Query caching, service policy (retries + circuit-breaking), and messenger integration out of the box.fetchPositions,fetchInterest,fetchHistory,fetchRateHistory.@metamask/superstructfor runtime response validation, with types derived from structs (Infer<typeof ...Struct>) to prevent type/struct drift.causechain) for easier production debugging.fetchInfiniteQueryfor the cursor-paginated history endpoint, giving consumers proper TanStack Query pagination semantics.retryFilterPolicyto skip retrying validation errors (malformed responses won't fix themselves).dev/uat/prd) via anEnvenum + URL map, following theclaims-controllerpattern.This is architected as an independent service. The client calls it directly for API-sourced data, separate from
money-account-balance-servicewhich handles RPC-based balance fetching. A future orchestration layer may unify these.Checklist
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-basedmoney-account-balance-service).MoneyAccountApiDataServiceextendsBaseDataServicewith TanStack Query caching, messenger actions (fetchPositions,fetchInterest,fetchHistory,fetchRateHistory,invalidateQueries), dev/uat/prd base URLs viaEnv, and superstruct-validated responses withMoneyAccountApiResponseValidationError(no retries on validation failures). History usesfetchInfiniteQueryfor 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.
Reviewed by Cursor Bugbot for commit ae6334b. Bugbot is set up for automated code reviews on this repo. Configure here.