fix: avoid making unnecessary api calls#7811
Merged
Conversation
Member
Author
|
@cursor update the assets Changelog to cater for the changes in my PR |
|
I've successfully updated the assets-controllers changelog to document the changes from your PR. Here's what I added: Updated: Added to [Unreleased] section:
The changelog entry properly documents the performance optimizations your PR introduces, including the deduplication of concurrent API calls, improved caching behavior, and the new reset functionality. The changes have been committed and pushed to the |
Co-authored-by: juan.gutierrez <juan.gutierrez@consensys.net>
salimtb
reviewed
Feb 9, 2026
packages/assets-controllers/src/token-prices-service/codefi-v2.ts
Outdated
Show resolved
Hide resolved
salimtb
previously approved these changes
Feb 9, 2026
salimtb
approved these changes
Feb 9, 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
Updated the code so that we do not make subsequent API calls to the same endpoint with the same params and so that we cache the response to avoid unnecessary re-fetching
References
https://consensyssoftware.atlassian.net/browse/ASSETS-2582
Checklist
Note
Low Risk
Low risk: changes are limited to caching/deduping logic around Price API metadata fetches and adds a targeted unit test; main risk is stale supported-network/currency lists if cache invalidation expectations change.
Overview
Improves Price API performance by deduplicating concurrent calls to
/v2/supportedNetworksvia an in-flight promise cache infetchSupportedNetworks(), and clearing that promise on completion.Reduces background traffic by only triggering the non-blocking refresh in
fetchTokenPrices()andfetchExchangeRates()when the supported networks/currencies caches are empty, and updates tests to assert concurrent-call deduplication.Written by Cursor Bugbot for commit 0ebef38. This will update automatically on new commits. Configure here.