## **Description**
Foundation PR (1/5) for the Token Details Page (TDP) advanced charts
work. This splits the original MetaMask#47737 into five reviewable, stacked PRs:
1. **MetaMask#47749 (this PR)** — background/state foundation
2. MetaMask#47751 — chart UI
3. MetaMask#47753 — host-backed OHLCV pagination
4. MetaMask#47771 — chart theming (line/candle colors driven by design tokens)
5. MetaMask#47772 — chart analytics/instrumentation (interaction + empty-state
events)
This PR contains **no user-facing UI on its own**; the advanced chart is
rendered in the UI PR (MetaMask#47751) and stays behind the `AdvancedCharts`
remote feature flag. Landing it first keeps the CODEOWNER-reviewed
surface (background controller wiring, fixtures, privacy/state-logs)
small and isolated.
What it includes:
- **Chart-type preference** on `PreferencesController` (plus
`shared/types/preferences.ts` and `shared/lib/selectors/preferences.ts`
selector) so the TDP can persist the user's candle/line choice.
- **OHLCV service wiring** into the background: the
`@metamask/core-backend` OHLCV service and its messenger are registered
via `app/scripts/messenger-client-init/*` and `metamask-controller.js`.
- **Fixtures & state snapshots** (`default-fixture.json`,
`onboarding-fixture.json`, metrics state snapshots, `state-logs.json`)
updated to reflect the new controller state.
Base branch: `main`.
## **Changelog**
CHANGELOG entry: null
<!--
## **Related issues**
Fixes:
-->
## **Manual testing steps**
Since this PR adds no visible UI, testing is a no-regression smoke
check:
1. Build and run the extension.
2. Complete onboarding / unlock an existing wallet.
3. Confirm the wallet loads normally (home, asset list, settings) with
no errors in the background or UI console.
4. Open a token details page and confirm the existing (legacy) price
chart still renders as before.
<!--
## **Screenshots/Recordings**
### **Before**
### **After**
-->
## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I've included tests if applicable
- [ ] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Touches persisted preferences, background service initialization, and
LavaMoat policies; new OHLCV service may open backend connectivity when
later UI/flags enable it, but this PR alone adds no visible surface.
>
> **Overview**
> Adds **background/state foundation** for Token Details Page advanced
charts (no user-facing UI in this PR).
>
> **Chart preferences** — `PreferencesController` and `Preferences`
types now persist `tdpChartType`, `tdpChartInterval`, and
`tdpChartIndicators`, with shared defaults in
`shared/constants/preferences` and new selectors (`getTdpChartType`,
`getTdpChartInterval`, `getTdpChartIndicators`) so controller defaults
and UI fallbacks stay aligned. Controller tests, fixtures, metrics
snapshots, and state-logs schemas are updated for the new fields.
>
> **OHLCV streaming** — Registers `@metamask/core-backend`
`OHLCVService` in the background via `OHLCVServiceInit`, a restricted
`getOHLCVServiceMessenger` (core allow-lists), and `metamask-controller`
/ messenger factory wiring. LavaMoat webpack policies grant
`AbortController` and `async-mutex` to `core-backend` for this
dependency path.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
7f6d7d4. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
Description
Changelog
CHANGELOG entry:
Related issues
Fixes:
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist