Harden fetchAndTestRpcs parsing against DefiLlama format changes and add RPC fallbacks#638
Harden fetchAndTestRpcs parsing against DefiLlama format changes and add RPC fallbacks#638Copilot wants to merge 4 commits into
fetchAndTestRpcs parsing against DefiLlama format changes and add RPC fallbacks#638Conversation
Deploying goodprotocolui with
|
| Latest commit: |
8beaa6a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://196d3774.goodprotocolui.pages.dev |
| Branch Preview URL: | https://copilot-fix-fetch-and-test-r.goodprotocolui.pages.dev |
fetchAndTestRpcs parsing against DefiLlama format changes and add RPC fallbacks
…se reset on failure
|
Handoff — ready for review @L03TJ3 What changed from the Copilot PRThe original implementation fetched a raw
In What was tested
Remaining risks
|
Fixes #637
fetchAndTestRpcswas failing due to brittle parsing of DefiLlama'sextraRpcs.jssource file, which could leave tested RPC sets empty. This update replaces the custom JS parser with a simple JSON fetch and guarantees fallback RPCs when any step fails.What changed
src/hooks/rpcParsing.ts— replaced ~150-line balanced-segment JS parser with afetchRpcsFromChainlist()function that fetcheschainid.network/chains.json(a stable JSON endpoint), filters for required chains (1,122,42220,50), and strips non-HTTP(S) URLs. No custom parsing, noeval(), no regex on JS source.src/hooks/useWeb3.tsx— updatedfetchAndTestRpcsto callfetchRpcsFromChainlist()directly, removed theCHAINLIST_URLconstant andchainMappingobject, and addedrpcInitializationPromise = nullin the catch block so the app can retry on failure without a page reload.src/hooks/rpcParsing.test.ts— updated to test the new API: live fetch againstchainid.networkasserting all 4 chains return valid HTTP(S) URLs, plus a unit test forFALLBACK_RPCS_BY_CHAIN.Test evidence
Full suite: 44 tests passing, 7 pre-existing failures unrelated to this PR (
@sushiswap/sdkpnpm hoisting,@reown/appkitESM — both present onmaster).pnpm lint— clean.pnpm build— fails with pre-existing@ethersproject/bignumberrollup resolution error (pnpm hoisting incompatibility, not introduced by this branch).