Repository navigation
feat(assets-controllers): add searchTokens function - #7004
Merged
Merged
Conversation
salimtb
marked this pull request as ready for review
October 30, 2025 09:29
juanmigdr
reviewed
Oct 30, 2025
| decimals: 6, | ||
| name: 'Tether USD', | ||
| occurrences: 11, | ||
| aggregators: [ |
Member
There was a problem hiding this comment.
Do we need to send this over? Could we minimize the data we return to the UI?
Contributor
Author
There was a problem hiding this comment.
This is required since it’s also part of the tokenList state. However, it’s not actually used in the UI , I just wanted to keep it consistent with the existing tokenList state structure.
juanmigdr
reviewed
Oct 30, 2025
juanmigdr
previously approved these changes
Oct 30, 2025
juanmigdr
approved these changes
Oct 30, 2025
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
What is the current state of things and why does it need to change?
Currently, the assets-controllers package provides functionality to fetch token lists and metadata for individual networks, but lacks the ability to search for tokens across multiple blockchain networks simultaneously. Users and applications need to search for tokens by name, symbol, or address across different chains (Ethereum, Polygon, Solana, etc.) in a unified way, which requires multiple separate API calls with the existing implementation.
What is the solution your changes offer and how does it work?
This PR introduces a new
searchTokensfunction that enables cross-chain token search functionality using CAIP (Chain Agnostic Improvement Proposal) format chain IDs. The solution includes:searchTokensfunction: Accepts an array of CAIP chain IDs (e.g.,['eip155:1', 'eip155:137', 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp']) and a search query stringgetTokenSearchURLfunction that properly encodes chain IDs and query parameters{ count: number, data: unknown[] }format for consistent API responsesThe function makes a single API call to the
/tokens/searchendpoint, making it more efficient than multiple individual network searches.Are there any changes whose purpose might not obvious to those unfamiliar with the domain?
{ count: 0, data: [] }on errors rather than throwing, which prevents search failures from breaking the user experienceReferences
Checklist
Note
Introduces
searchTokensto query tokens across multiple networks using CAIP chain IDs, exports it, and adds comprehensive tests and changelog entry.src/token-service.ts):searchTokens(chainIds: CaipChainId[], query, { limit })using/tokens/searchandhandleFetch; returns{ count, data }with graceful error handling.getTokenSearchURLand CAIP chain ID support; importCaipChainId.searchTokensfromsrc/index.ts.src/token-service.test.ts):limit, query encoding, empty/invalid responses, and network/HTTP errors.searchTokensfor multi-network searches via CAIP IDs.Written by Cursor Bugbot for commit bf6224c. This will update automatically on new commits. Configure here.