Repository navigation
Commit 16a605f
feat: add chart-type preference, OHLCV service wiring (#47749)
## **Description**
Foundation PR (1/5) for the Token Details Page (TDP) advanced charts
work. This splits the original #47737 into five reviewable, stacked PRs:
1. **#47749 (this PR)** — background/state foundation
2. #47751 — chart UI
3. #47753 — host-backed OHLCV pagination
4. #47771 — chart theming (line/candle colors driven by design tokens)
5. #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 (#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>1 parent 6df047e commit 16a605f
29 files changed
Lines changed: 318 additions & 1 deletion
File tree
- app/scripts
- controllers
- messenger-client-init
- core-backend
- messengers
- core-backend
- lavamoat/webpack
- mv2
- beta
- experimental
- flask
- main
- mv3
- beta
- experimental
- flask
- main
- test/e2e
- fixtures
- tests
- metrics/state-snapshots
- settings
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
605 | 605 | | |
606 | 606 | | |
607 | 607 | | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
608 | 611 | | |
609 | 612 | | |
610 | 613 | | |
| |||
643 | 646 | | |
644 | 647 | | |
645 | 648 | | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
646 | 652 | | |
647 | 653 | | |
648 | 654 | | |
| |||
1059 | 1065 | | |
1060 | 1066 | | |
1061 | 1067 | | |
| 1068 | + | |
| 1069 | + | |
| 1070 | + | |
1062 | 1071 | | |
1063 | 1072 | | |
1064 | 1073 | | |
| |||
1133 | 1142 | | |
1134 | 1143 | | |
1135 | 1144 | | |
| 1145 | + | |
| 1146 | + | |
| 1147 | + | |
1136 | 1148 | | |
1137 | 1149 | | |
1138 | 1150 | | |
| |||
1221 | 1233 | | |
1222 | 1234 | | |
1223 | 1235 | | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
1224 | 1239 | | |
1225 | 1240 | | |
1226 | 1241 | | |
| |||
1310 | 1325 | | |
1311 | 1326 | | |
1312 | 1327 | | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
1313 | 1331 | | |
1314 | 1332 | | |
1315 | 1333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| |||
202 | 205 | | |
203 | 206 | | |
204 | 207 | | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
205 | 211 | | |
206 | 212 | | |
207 | 213 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| 81 | + | |
81 | 82 | | |
82 | 83 | | |
83 | 84 | | |
| |||
244 | 245 | | |
245 | 246 | | |
246 | 247 | | |
| 248 | + | |
247 | 249 | | |
248 | 250 | | |
249 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
626 | 627 | | |
627 | 628 | | |
628 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
629 | 634 | | |
630 | 635 | | |
631 | 636 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
| 323 | + | |
323 | 324 | | |
324 | 325 | | |
325 | 326 | | |
| |||
570 | 571 | | |
571 | 572 | | |
572 | 573 | | |
| 574 | + | |
573 | 575 | | |
574 | 576 | | |
575 | 577 | | |
| |||
0 commit comments