Skip to content

Console errors for deprecated chain IDs in default token list #465

@gabitoesmiapodo

Description

@gabitoesmiapodo

Description

Loading the app surfaces Error: Native token not found for chain ID: 3 and Error: Native token not found for chain ID: 4 in the browser console. Chains 3 and 4 (Ropsten, Rinkeby) are deprecated testnets that viem/chains no longer ships, but @uniswap/default-token-list still includes tokens for them. combineTokenLists catches the buildNativeToken throw but calls console.error(err) before ignoring it, producing the noise on every cold load.

Origin trace: buildNativeToken (src/hooks/useTokenLists.ts:214) -> combineTokenLists (src/hooks/useTokenLists.ts:131) -> useTokenLists (src/hooks/useTokenLists.ts:63) -> home page TokenInput demo (src/components/pageComponents/home/Examples/demos/TokenInput/index.tsx:57).

Steps to reproduce

  1. cp .env.example .env.local (leaves PUBLIC_USE_DEFAULT_TOKENS=true, the default)
  2. pnpm install && pnpm dev
  3. Open the app on the home page (the TokenInput demo calls useTokenLists)
  4. Open the browser devtools console

Expected vs actual behavior

Expected: No console errors when the fallback branch is intentional (the catch block already comments "ignore the error").

Actual: Two Error: Native token not found for chain ID: 3 and ... chain ID: 4 entries logged via console.error on every cold load.

Environment

@uniswap/default-token-list: 18.13.0
viem: per current pnpm-lock.yaml
Config: default .env.example (PUBLIC_USE_DEFAULT_TOKENS=true)

Additional context

The bundled list contains 4 tokens for chainId 3 and 227 for chainId 4, all unreachable because the app does not configure Ropsten/Rinkeby. Current impact is cosmetic (2 console errors), but the map also ends up with empty tokensByChainId[3] and tokensByChainId[4] buckets populated with unusable tokens.

Suggested fix paths:

  • Option A (minimal): Drop the console.error(err) at src/hooks/useTokenLists.ts:137. The branch already states "ignore the error" and falls back to an empty array; the log is inconsistent with that intent. Tradeoff: tokensByChainId[3] / tokensByChainId[4] still get populated with unusable tokens from the default list.
  • Option B (recommended): Extend the filter at src/hooks/useTokenLists.ts:115-119 to also drop tokens whose chainId is not present in viem/chains. Mirrors the existing non-EVM drop, removes the error at source, and keeps the map free of unreachable chain buckets. Add a test to src/hooks/useTokenLists.test.ts covering a token with a chainId absent from viem/chains.

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.

Metadata

Metadata

Labels

bugSomething isn't workingseverity: lowCosmetic or minor inconvenience

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions