Skip to content

Prevent Li.Fi token request failures from unsupported chains#5

Merged
ffaerber merged 1 commit intomainfrom
claude/fix-token-api-request-19UmP
Apr 16, 2026
Merged

Prevent Li.Fi token request failures from unsupported chains#5
ffaerber merged 1 commit intomainfrom
claude/fix-token-api-request-19UmP

Conversation

@ffaerber
Copy link
Copy Markdown
Owner

Summary

This change prevents the Li.Fi /tokens API request from failing when the application's chain list includes chains that Li.Fi doesn't support. Li.Fi rejects the entire request with a 400 error if any unsupported chain ID is included, so we now validate against supported chains first.

Key Changes

  • Added fetchSupportedChainIds() function that queries the Li.Fi /chains endpoint to get the list of supported EVM chains
  • Modified loadTokens() to filter CHAIN_IDS against the supported chains before making the /tokens request
  • Added early return with empty object if no supported chains remain after filtering
  • Added explanatory comment documenting the Li.Fi API behavior and the rationale for this approach

Implementation Details

  • The supported chains are fetched from Li.Fi's /chains?chainTypes=EVM endpoint
  • We intersect our internal chain list with Li.Fi's supported chains to ensure future unsupported chains (e.g., new networks added to our list) don't break token loading
  • If all chains are filtered out, the function returns an empty cache object rather than making a request that would fail

https://claude.ai/code/session_01BhqRYS2cRAidqcFFxU84Nd

Li.Fi returns 400 Bad Request for the entire /v1/tokens call if any chain
id in the `chains` param is unsupported (currently Fantom/250 and
Zora/7777777). Query /v1/chains once and intersect with CHAIN_IDS before
issuing the /v1/tokens request so unsupported chains silently drop out
instead of wedging token resolution for every chain.
@ffaerber ffaerber merged commit 7b08d1f into main Apr 16, 2026
1 check passed
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.

2 participants