Prevent Li.Fi token request failures from unsupported chains#5
Merged
Conversation
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.
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
This change prevents the Li.Fi
/tokensAPI 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
fetchSupportedChainIds()function that queries the Li.Fi/chainsendpoint to get the list of supported EVM chainsloadTokens()to filterCHAIN_IDSagainst the supported chains before making the/tokensrequestImplementation Details
/chains?chainTypes=EVMendpointhttps://claude.ai/code/session_01BhqRYS2cRAidqcFFxU84Nd