feat(ai-controllers): add fetchFrontPageItem to fetch a market overview front page by id#9394
Merged
Merged
Conversation
…ew front page by id Adds `AiDigestController.fetchFrontPageItem(id)` and the underlying `AiDigestService.fetchFrontPageItem`, which fetch a single market overview "front page" by id from `GET /market-overview/front-page/:id`. The endpoint returns one item sharing the same schema as an individual market overview item, so clients can render an older item that has dropped out of the latest `/market-overview` report. - Expose the method via the `AiDigestController:fetchFrontPageItem` messenger action. - Add `MarketOverviewFrontPage` and `MarketOverviewItem` types. - Validate and normalize the response (missing `caip19` -> `[]`) with superstruct, mirroring `fetchMarketOverview`.
Contributor
Author
|
@metamaskbot publish-previews |
Contributor
|
Preview builds have been published. Learn how to use preview builds in other projects. Expand for full list of packages and versions. |
3 tasks
zone-live
approved these changes
Jul 7, 2026
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 What's Happening / market overview feature (
AiDigestController.fetchMarketOverview()) only ever returns the latest items fromGET /market-overview. Older items drop out of that report, so there is currently no way for a client to render a specific older item.The digest API added a new endpoint:
It returns a single "front page" row whose
itemshares the exact same schema as an individual market overview item (a trend entry), plus call-to-action copy. This PR adds first-class support for it in@metamask/ai-controllers.References
Changelog
@metamask/ai-controllersAiDigestController.fetchFrontPageItem(id)andAiDigestService.fetchFrontPageItem(id), which fetch a single market overview front page by id fromGET /market-overview/front-page/:id, exposed via theAiDigestController:fetchFrontPageItemmessenger action.MarketOverviewFrontPageandMarketOverviewItemtypes.Details
AiDigestService.fetchFrontPageItemmirrorsfetchMarketOverview: it validates the response with superstruct (reusingMarketOverviewTrendStructforitem), normalizes missingcaip19to[], returnsnullon404, and throws on other non-OK responses or an invalid schema.AiDigestController.fetchFrontPageItemis a thin pass-through (no caching — a single item by id does not need the report cache) that throws on an empty id.messenger-action-types:generate.Checklist
yarn lint, build, andyarn validate:changelogpassNote
Low Risk
Additive read-only API client and controller method following existing
fetchMarketOverviewpatterns; no auth, persistence, or caching behavior changes beyond new exports.Overview
Adds support for loading a single What's Happening / market overview front page by UUID when it is no longer in the latest
fetchMarketOverviewreport (e.g. deep links).AiDigestService.fetchFrontPageItem(id)callsGET /market-overview/front-page/:id(URL-encoded id), validates with superstruct (reusing the market-overview trend schema foritem), normalizes missingcaip19on related assets to[], returnsnullon 404, and throws on other errors or invalid payloads.AiDigestController.fetchFrontPageItemdelegates to the service with no controller cache, rejects empty ids, and is exposed asAiDigestController:fetchFrontPageItem.New public types
MarketOverviewFrontPageandMarketOverviewItemare exported;DigestServiceand package changelog are updated. Market overview normalization is refactored to sharenormalizeItemRelatedAssetsbetween report and front-page responses.Reviewed by Cursor Bugbot for commit 8980fa5. Bugbot is set up for automated code reviews on this repo. Configure here.