Skip to content

[DON'T MERGE] Use data service to fetch historical prices from Price API#41522

Draft
mcmire wants to merge 1 commit intomainfrom
use-data-service-for-price-api
Draft

[DON'T MERGE] Use data service to fetch historical prices from Price API#41522
mcmire wants to merge 1 commit intomainfrom
use-data-service-for-price-api

Conversation

@mcmire
Copy link
Copy Markdown
Contributor

@mcmire mcmire commented Apr 7, 2026

Description

This PR demonstrates how useQuery from @metamask/react-data-query can be used to fetch data through a data service, which makes a request, instead of making a request directly in the UI.

See corresponding core PR: MetaMask/core#8393

Changelog

CHANGELOG entry:

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-core-platform Core Platform team label Apr 7, 2026
@github-actions github-actions bot added the size-M label Apr 7, 2026
@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 7, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask-previews/​price-api@​0.0.0-preview-f1592e178731007387100

View full report

mcmire added a commit to MetaMask/core that referenced this pull request Apr 7, 2026
This PR demonstrates what a data service class to hit the Accounts API
would look like. It's designed to fetch the list of transactions in the
extension. For more, see:
<MetaMask/metamask-extension#41522>

Please note this PR is only intended for demo purposes. For a living
example of a data service, including tests, please see:
<https://github.com/MetaMask/core/blob/main/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts>
mcmire added a commit to MetaMask/core that referenced this pull request Apr 7, 2026
This PR demonstrates what a data service class to hit the Accounts API
would look like. It's designed to fetch the list of transactions in the
extension. For more, see:
<MetaMask/metamask-extension#41522>

Please note this PR is only intended for demo purposes. For a living
example of a data service, including tests, please see:
<https://github.com/MetaMask/core/blob/main/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts>
@mcmire mcmire force-pushed the use-data-service-for-price-api branch from c480d29 to f3f503c Compare April 7, 2026 20:44
@socket-security
Copy link
Copy Markdown

Caution

MetaMask internal reviewing guidelines:

  • Do not ignore-all
  • Each alert has instructions on how to review if you don't know what it means. If lost, ask your Security Liaison or the supply-chain group
  • Copy-paste ignore lines for specific packages or a group of one kind with a note on what research you did to deem it safe.
    @SocketSecurity ignore npm/PACKAGE@VERSION
Action Severity Alert  (click "▶" to expand/collapse)
Block Medium
Network access: npm @metamask-previews/price-api in module globalThis["fetch"]

Module: globalThis["fetch"]

Location: Package overview

From: package.jsonnpm/@metamask-previews/price-api@0.0.0-preview-f1592e178

ℹ Read more on: This package | This alert | What is network access?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should remove all network access that is functionally unnecessary. Consumers should audit network access to ensure legitimate use.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@metamask-previews/price-api@0.0.0-preview-f1592e178. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

@metamaskbotv2
Copy link
Copy Markdown
Contributor

metamaskbotv2 bot commented Apr 7, 2026

Builds ready [f3f503c]
⚡ Performance Benchmarks (Total: 🟢 8 pass · 🟡 1 warn · 🔴 0 fail)

Baseline (latest main): f34f804 | Date: 9/10/58222 | Pipeline: 24103572274 | Baseline logs

Interaction Benchmarks · Samples: 5
Benchmarkchrome-browserify
loadNewAccount🟢 [Show logs]
confirmTx🟢 [Show logs]
bridgeUserActions🟢 [Show logs]
Startup Benchmarks · Samples: 100
Benchmarkchrome-webpack
startupStandardHome🟢 [Show logs]
startupPowerUserHome🟡 [Show logs]

📈 Results compared to the previous 5 runs on main

  • startupStandardHome/uiStartup: -10%
  • startupStandardHome/load: -11%
  • startupStandardHome/domContentLoaded: -11%
  • startupStandardHome/backgroundConnect: -32%
  • startupStandardHome/firstReactRender: -20%
  • startupStandardHome/loadScripts: -10%
  • startupStandardHome/numNetworkReqs: -29%
  • startupPowerUserHome/numNetworkReqs: +43%

🌐 Core Web Vitals — 🟢 good · 🟡 needs improvement · 🔴 poor (web.dev thresholds)

  • 🔴 startupPowerUserHome/INP: p75 584ms
User Journey Benchmarks · Samples: 5 · mock API

⚠️ Missing data: chrome/browserify/userJourneyAssets, chrome/browserify/userJourneyTransactions

Benchmarkchrome-browserify
onboardingImportWallet🟢 [Show logs]
onboardingNewWallet🟢 [Show logs]
importSrpHome🟢 [Show logs]
Dapp Page Load Benchmarks · Samples: 100
Benchmarkchrome-browserify
dappPageLoad🟢 [Show logs]
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 44.53 KiB (0.8%)
  • ui: -46.65 KiB (-0.55%)
  • common: 52.57 KiB (0.42%)

mcmire added a commit to MetaMask/core that referenced this pull request Apr 7, 2026
This PR demonstrates what a data service class to hit the Accounts API
would look like. It's designed to fetch the list of transactions in the
extension. For more, see:
<MetaMask/metamask-extension#41522>

Please note this PR is only intended for demo purposes. For a living
example of a data service, including tests, please see:
<https://github.com/MetaMask/core/blob/main/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts>
mcmire added a commit to MetaMask/core that referenced this pull request Apr 7, 2026
This PR demonstrates what a data service class to hit the Accounts API
would look like. It's designed to fetch the list of transactions in the
extension. For more, see:
<MetaMask/metamask-extension#41522>

Please note this PR is only intended for demo purposes. For a living
example of a data service, including tests, please see:
<https://github.com/MetaMask/core/blob/main/packages/sample-controllers/src/sample-gas-prices-service/sample-gas-prices-service.ts>
This PR demonstrates how `useQuery` from `@metamask/react-data-query`
can be used to fetch data through a data service, which makes a
request, instead of making a request directly in the UI.

Also see: MetaMask/core#8393
@mcmire mcmire force-pushed the use-data-service-for-price-api branch from f3f503c to 516df84 Compare April 8, 2026 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants