-
Notifications
You must be signed in to change notification settings - Fork 5.4k
feat: price API v3 upgrade #37741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: price API v3 upgrade #37741
Conversation
|
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. |
Builds ready [1b01012]
UI Startup Metrics (1234 ± 96 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
1b01012 to
2bc2dc4
Compare
Builds ready [2bc2dc4]
UI Startup Metrics (1217 ± 81 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [bfcc40a]
UI Startup Metrics (1242 ± 98 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [14efbd0]
UI Startup Metrics (1235 ± 90 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
df6d02e to
d784cd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There changes should not affect anything. This hook is used purely to start polling, the return result is not used and therefore it is not needed.
Builds ready [85dbc1a]
UI Startup Metrics (1251 ± 111 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [95fdf3f]
UI Startup Metrics (1211 ± 90 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [72877b1]
UI Startup Metrics (1273 ± 94 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> Upgrade to Price API v3 Preview PR for extension: MetaMask/metamask-extension#37741 Preview PR for mobile: MetaMask/metamask-mobile#22876 ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> Fixes https://consensyssoftware.atlassian.net/browse/ASSETS-1746 ## Checklist - [X] I've updated the test suite for new or updated code as appropriate - [X] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [X] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [X] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Upgrades token price fetching to Price API v3, updates service/types and controllers to new assets-based API, and removes legacy polling paths. > > - **Price API Integration (v3)** > - `CodefiTokenPricesServiceV2`: add v3 `/v3/spot-prices` with CAIP-19 `assetId`, fallback to v2 per-chain endpoint; expand `SUPPORTED_CURRENCIES`; introduce `SPOT_PRICES_SUPPORT_INFO`; handle native token addresses; circuit-breaker/degraded handling retained. > - **Types/Interfaces**: > - BREAKING: `AbstractTokenPricesService.fetchTokenPrices` now accepts `assets: { chainId, tokenAddress }[]` and returns `EvmAssetWithMarketData[]` (replaces address->object map and adds `assetId`). > - Add `EvmAssetAddressWithChain`, `EvmAssetWithId`, `EvmAssetWithMarketData`. > - **Controllers**: > - `TokenRatesController`: fetch prices grouped by native currency; support unsupported native currencies via USD conversion; include native token in queries; remove legacy polling/state/event deps; handle network deletions; enable/disable gating maintained. > - `CurrencyRateController`: on API failure, fallback to spot prices via `fetchTokenPrices` using native token asset; map multiple networks by native currency. > - `TokenSearchDiscoveryDataController`: adapt to new `fetchTokenPrices` response (array) and asset inputs. > - **Utils**: > - `assetsUtil.fetchTokenContractExchangeRates`: switch to assets-based batching (includes native token) and map array response. > - **Tests/Changelog**: > - Update tests to new arguments/returns and behaviors; changelog notes BREAKING changes and polling cleanup. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit e306214. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Builds ready [831ebf2]
UI Startup Metrics (1276 ± 125 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [363b3dc]
UI Startup Metrics (1217 ± 96 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [d6cc6a1]
UI Startup Metrics (1210 ± 106 ms)
📊 Page Load Benchmark ResultsCurrent Commit: 📄 Localhost MetaMask Test DappSamples: 100 Summary
📈 Detailed Results
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Description
Upgrade assets-controllers to start using Price API v3 spot-prices endpoint.
Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-1575
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Migrates token price fetching to Price API v3 with new assetIds, updates assets selectors/polling, bumps @metamask/assets-controllers and related deps, and adjusts mocks/tests and LavaMoat policies.
@metamask/assets-controllersto^91.0.0and related packages (controller-utils,polling-controller), withyarn.lockupdates.TokenRatesControllermessenger toTokensController:getStateandNetworkController:getStateand their state change events.v2/chains/{id}/spot-pricestov3/spot-pricesusingassetIds(e.g.,eip155:1/slip44:60,eip155:1/erc20:<address>), updating all mocks, queries, and responses.mockSpotPrices,mockEmptyPrices) to the new endpoint/signatures.useTokenRatesPolling: simplify to only control polling (remove returned market/exchange data).getAssetsBySelectedAccountGroup: delegate directly to assets-controllers; addgetAssetsBySelectedAccountGroupWithTronResourcespassing{ filterTronStakedTokens: false }.@metamask/assets-controllers>@metamask/polling-controllerand related globals/packages; removebridge-controllermapping.Written by Cursor Bugbot for commit d6cc6a1. This will update automatically on new commits. Configure here.