Skip to content

Conversation

@juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Feb 2, 2026

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

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Changes caching/refresh behavior for supported networks/currencies, which could lead to stale capability lists if callers relied on the previous always-refresh-in-background behavior. Concurrency deduping is low risk but touches shared request paths used by price and exchange-rate polling.

Overview
Improves Price API call efficiency by deduplicating concurrent fetchSupportedNetworks() requests via an in-flight promise cache, and clearing that promise on completion/reset.

Reduces background metadata traffic by only triggering non-blocking refreshes of supported networks/currencies from fetchTokenPrices()/fetchExchangeRates() when no cached value exists, and adds a unit test ensuring concurrent supportedNetworks calls collapse to a single HTTP request (plus changelog entry).

Written by Cursor Bugbot for commit 21e4322. This will update automatically on new commits. Configure here.

@juanmigdr juanmigdr requested a review from a team as a code owner February 2, 2026 15:23
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@juanmigdr
Copy link
Member Author

@cursor update the assets Changelog to cater for the changes in my PR

@cursor
Copy link

cursor bot commented Feb 3, 2026

I've successfully updated the assets-controllers changelog to document the changes from your PR. Here's what I added:

Updated: packages/assets-controllers/CHANGELOG.md

Added to [Unreleased] section:

  • Optimize Price API performance by deduplicating concurrent API calls
  • Add in-flight promise caching for fetchSupportedNetworks() to prevent duplicate concurrent requests
  • Update fetchTokenPrices() and fetchExchangeRates() to only refresh supported networks/currencies when no cached value exists
  • Add resetSupportedNetworksCache() method to clear cached promises when needed

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 fix/repeated-api-calls-to-supported-networks branch.

Open in Cursor Open in Web

Co-authored-by: juan.gutierrez <juan.gutierrez@consensys.net>
@cursor cursor bot requested a review from a team as a code owner February 3, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants