fix(token-lists): drop tokens whose chainId is absent from viem/chains#468
Closed
gabitoesmiapodo wants to merge 1 commit into
Closed
fix(token-lists): drop tokens whose chainId is absent from viem/chains#468gabitoesmiapodo wants to merge 1 commit into
gabitoesmiapodo wants to merge 1 commit into
Conversation
@uniswap/default-token-list still ships tokens for Ropsten (chainId 3) and Rinkeby (chainId 4), both removed from viem/chains. combineTokenLists caught the buildNativeToken throw but logged it via console.error before ignoring it, producing noise on every cold load. Extend the existing safeParse filter to also drop tokens whose chainId is not present in viem/chains, mirroring the existing non-EVM drop. This removes the throw at source and keeps tokensByChainId free of unreachable buckets. Closes #465
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
Closing - opened without explicit approval. Work preserved on branch fix/465. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes console noise and unreachable token buckets by filtering out tokens whose chainId is no longer represented in viem/chains (e.g., deprecated Ropsten/Rinkeby entries still shipped in @uniswap/default-token-list).
Changes:
- Add a module-scope
supportedChainIdsset derived fromviem/chains. - Extend the existing schema-validation filter to also drop tokens whose
chainIdis not insupportedChainIds. - Add a unit test ensuring unsupported-chain tokens are filtered, no
tokensByChainId[3]bucket is created, andconsole.erroris not called.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/hooks/useTokenLists.ts | Filters tokens to only chain IDs present in viem/chains, preventing native-token lookup errors and unreachable buckets. |
| src/hooks/useTokenLists.test.ts | Adds coverage for the unsupported chainId filtering behavior and verifies no error logging occurs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
@uniswap/default-token-list18.13.0 still ships tokens for Ropsten (chainId 3, 4 tokens) and Rinkeby (chainId 4, 227 tokens), both removed fromviem/chains.combineTokenListscaught thebuildNativeTokenthrow but logged it viaconsole.errorbefore ignoring it, producingError: Native token not found for chain ID: 3and... chain ID: 4on every cold load of the home page.Closes #465
Changes
supportedChainIds = new Set<number>(Object.values(chains).map((c) => c.id))insrc/hooks/useTokenLists.ts, co-located withbuildNativeTokensince both depend on theviem/chainsimport.safeParsefilter to also drop tokens whosechainIdis not in that set, mirroring the existing non-EVM drop. This removes the throw at source, so thetry/catcharoundbuildNativeTokenbecomes defensive only, andtokensByChainIdno longer gets[3]/[4]buckets populated with unreachable tokens.src/hooks/useTokenLists.test.tsthat feeds a Ropsten token (chainId 3) and asserts it is filtered out, notokensByChainId[3]bucket is created, andconsole.erroris not called.Acceptance criteria
Native token not founderrors logged when loading the app with default config.tokensByChainIdcontains only chains supported byviem/chains.pnpm lint,pnpm test,pnpm buildall pass.Test plan
pnpm lint— clean.pnpm test— 199/199 pass across 35 files, 12/12 inuseTokenLists.test.ts(includes the new case).pnpm build— succeeds.pnpm tsc --noEmit— clean (also enforced by the pre-push hook).pnpm dev— home page loads with noNative token not foundentries in the devtools console; TokenInput demo continues to render tokens for supported chains.Breaking changes
None.
Checklist