Skip to content

Conversation

juanmigdr
Copy link
Member

@juanmigdr juanmigdr commented Oct 1, 2025

Explanation

Background

While investigating ASSETS-1346 to improve NFT detection performance in Mobile and Extension, I identified a significant performance bottleneck in our API call pattern.

Current Implementation Issues

Our NFT detection process was making inefficient API calls:

  • 1 API call to tokens endpoint → returns ~100 tokens per request
  • 5 API calls to collections endpoint → batched requests of 20 collections each
  • Total: 6 API calls per 100 tokens (6x API overhead)

Analysis

The collections API calls were used to append the following data to token responses:

openseaVerificationStatus: found?.openseaVerificationStatus,
contractDeployedAt: found.contractDeployedAt,
creator: found?.creator,
ownerCount: found.ownerCount,
topBid: found.topBid,

However, due to our recent provider migration, only 3 of these 5 fields are currently utilized:

contractDeployedAt: found.contractDeployedAt,
creator: found?.creator,
topBid: found.topBid,

Solution

After discussion with @Prithpal-Sooriya and @alfeng6, we determined that removing the collections API calls provides significant performance benefits that outweigh the loss of these 3 data fields.

Impact

  • 83% reduction in API calls (from 6 calls to 1 call per 100 tokens)
  • Faster NFT detection in Mobile and Extension
  • ⚠️ Loss of 3 collection fields: contractDeployedAt, creator, and topBid

This change prioritizes performance optimization over supplementary metadata that has limited current usage.

References

Issue: https://consensyssoftware.atlassian.net/browse/ASSETS-1346

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, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

Note

Eliminates collection endpoint requests in NFT detection, simplifying logic and tests while updating the changelog to note the performance optimization and removed collection metadata fields.

  • Assets Controllers
    • NFT Detection: Simplifies NftDetectionController by removing collection fetches (/collections) and related batching logic; stops enriching tokens with collection fields and drops MAX_GET_COLLECTION_BATCH_SIZE.
    • Tests: Remove collection API mocks and all getCollections-related test cases; adjust expectations to not rely on collection metadata.
    • Changelog: Add entry noting performance optimization (removal of collection calls) and removal of unused fields (contractDeployedAt, creator, topBid).
  • Misc
    • Update ESLint warning thresholds for packages/assets-controllers/src/NftDetectionController.test.ts.

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

@juanmigdr juanmigdr requested a review from a team as a code owner October 1, 2025 09:48
@juanmigdr juanmigdr marked this pull request as draft October 1, 2025 09:48
@juanmigdr juanmigdr changed the title chore: improve nft detection by removing collection calls chore: remove collection API calls from NFT detection process Oct 6, 2025
@juanmigdr juanmigdr marked this pull request as ready for review October 6, 2025 15:02
@juanmigdr juanmigdr requested a review from a team as a code owner October 6, 2025 15:02
cursor[bot]

This comment was marked as outdated.

@juanmigdr juanmigdr enabled auto-merge (squash) October 8, 2025 11:22
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.

1 participant