Skip to content

fix(token-lists): drop tokens whose chainId is absent from viem/chains#468

Closed
gabitoesmiapodo wants to merge 1 commit into
developfrom
fix/465
Closed

fix(token-lists): drop tokens whose chainId is absent from viem/chains#468
gabitoesmiapodo wants to merge 1 commit into
developfrom
fix/465

Conversation

@gabitoesmiapodo
Copy link
Copy Markdown
Collaborator

Summary

@uniswap/default-token-list 18.13.0 still ships tokens for Ropsten (chainId 3, 4 tokens) and Rinkeby (chainId 4, 227 tokens), both removed from viem/chains. combineTokenLists caught the buildNativeToken throw but logged it via console.error before ignoring it, producing Error: Native token not found for chain ID: 3 and ... chain ID: 4 on every cold load of the home page.

Closes #465

Changes

  • Added a module-scope supportedChainIds = new Set<number>(Object.values(chains).map((c) => c.id)) in src/hooks/useTokenLists.ts, co-located with buildNativeToken since both depend on the viem/chains import.
  • Extended the existing safeParse filter to also drop tokens whose chainId is not in that set, mirroring the existing non-EVM drop. This removes the throw at source, so the try/catch around buildNativeToken becomes defensive only, and tokensByChainId no longer gets [3] / [4] buckets populated with unreachable tokens.
  • Added a test in src/hooks/useTokenLists.test.ts that feeds a Ropsten token (chainId 3) and asserts it is filtered out, no tokensByChainId[3] bucket is created, and console.error is not called.

Acceptance criteria

  • No Native token not found errors logged when loading the app with default config.
  • tokensByChainId contains only chains supported by viem/chains.
  • Tests cover the unsupported-chainId case.
  • pnpm lint, pnpm test, pnpm build all pass.

Test plan

  • pnpm lint — clean.
  • pnpm test — 199/199 pass across 35 files, 12/12 in useTokenLists.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 no Native token not found entries in the devtools console; TokenInput demo continues to render tokens for supported chains.

Breaking changes

None.

Checklist

  • Self-reviewed my own diff
  • Tests added or updated
  • Docs updated (if applicable) — no behavior in docs changed
  • No unrelated changes bundled in

@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
Copilot AI review requested due to automatic review settings April 21, 2026 14:54
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
components.dappbooster Ready Ready Preview, Comment Apr 21, 2026 2:55pm
demo.dappbooster Ready Ready Preview, Comment Apr 21, 2026 2:55pm
docs.dappbooster Ready Ready Preview, Comment Apr 21, 2026 2:55pm

Request Review

@gabitoesmiapodo
Copy link
Copy Markdown
Collaborator Author

Closing - opened without explicit approval. Work preserved on branch fix/465.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 supportedChainIds set derived from viem/chains.
  • Extend the existing schema-validation filter to also drop tokens whose chainId is not in supportedChainIds.
  • Add a unit test ensuring unsupported-chain tokens are filtered, no tokensByChainId[3] bucket is created, and console.error is 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console errors for deprecated chain IDs in default token list

2 participants