feat: integrate World Chain (480) as second-class Relay chain#11932
feat: integrate World Chain (480) as second-class Relay chain#11932gomesalexandre merged 11 commits intodevelopfrom
Conversation
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📝 WalkthroughWalkthroughAdds WorldChain (eip155:480) as a gated second‑class EVM chain across configuration, CAIP/constants, adapters, viem/ethers clients, HDWallet capability flags, asset generation, swappers, plugin registration, UI feature‑gating, and utilities. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client(UI)
participant Plugin as WorldChainPlugin
participant AssetSvc as AssetService/Coingecko
participant Adapter as WorldChainChainAdapter
participant Wallet as HDWallet
participant RPC as WorldChain RPC
UI->>Plugin: register() (on startup)
Plugin->>Adapter: construct(rpcUrl)
UI->>AssetSvc: request known tokens (via adapter.getKnownTokens)
Adapter->>AssetSvc: query assets where chainId == worldChainChainId
AssetSvc-->>Adapter: return token list
UI->>Wallet: ask supportsWorldChain?
Wallet-->>UI: true/false
UI->>Adapter: submit tx or check tx status
Adapter->>RPC: eth_getTransactionReceipt (VITE_WORLDCHAIN_NODE_URL)
RPC-->>Adapter: receipt (status)
Adapter-->>UI: mapped TxStatus
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ldchain-relay # Conflicts: # .beads/pr-context.jsonl # .beads/ss-dx5.10.json # .beads/ss-dx5.8.json # .beads/ss-dx5.9.json # .claude/contracts/second-class-evm-chain.md # .env # .env.development # headers/csps/index.ts # packages/caip/src/adapters/coingecko/generated/index.ts # packages/caip/src/adapters/coingecko/index.test.ts # packages/caip/src/adapters/coingecko/index.ts # packages/caip/src/adapters/coingecko/utils.test.ts # packages/caip/src/adapters/coingecko/utils.ts # packages/caip/src/constants.ts # packages/chain-adapters/src/evm/EvmBaseAdapter.ts # packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts # packages/chain-adapters/src/evm/index.ts # packages/chain-adapters/src/evm/mantle/MantleChainAdapter.ts # packages/chain-adapters/src/types.ts # packages/contracts/src/ethersProviderSingleton.ts # packages/contracts/src/viemClient.ts # packages/hdwallet-coinbase/src/coinbase.ts # packages/hdwallet-core/src/ethereum.ts # packages/hdwallet-core/src/wallet.ts # packages/hdwallet-gridplus/src/gridplus.ts # packages/hdwallet-keepkey/src/keepkey.ts # packages/hdwallet-ledger/src/ledger.ts # packages/hdwallet-metamask-multichain/src/shapeshift-multichain.ts # packages/hdwallet-native/src/ethereum.ts # packages/hdwallet-phantom/src/phantom.ts # packages/hdwallet-trezor/src/trezor.ts # packages/hdwallet-vultisig/src/vultisig.ts # packages/hdwallet-walletconnectv2/src/walletconnectV2.ts # packages/swapper/src/swappers/AcrossSwapper/constant.ts # packages/swapper/src/swappers/RelaySwapper/constant.ts # packages/swapper/src/swappers/RelaySwapper/utils/relayTokenToAssetId.ts # packages/types/src/base.ts # packages/types/src/zerion.ts # packages/utils/src/assetData/baseAssets.ts # packages/utils/src/assetData/getBaseAsset.ts # packages/utils/src/chainIdToFeeAssetId.ts # packages/utils/src/getAssetNamespaceFromChainId.ts # packages/utils/src/getChainShortName.ts # packages/utils/src/getNativeFeeAssetReference.ts # public/generated/asset-manifest.json # public/generated/asset-manifest.json.br # public/generated/asset-manifest.json.gz # public/generated/generatedAssetData.json # public/generated/generatedAssetData.json.br # public/generated/generatedAssetData.json.gz # public/generated/relatedAssetIndex.json # public/generated/relatedAssetIndex.json.br # public/generated/relatedAssetIndex.json.gz # scripts/generateAssetData/coingecko.ts # scripts/generateAssetData/generateAssetData.ts # scripts/generateAssetData/generateRelatedAssetIndex/generateChainRelatedAssetIndex.ts # scripts/generateAssetData/generateRelatedAssetIndex/generateRelatedAssetIndex.ts # src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx # src/config.ts # src/constants/chains.ts # src/context/PluginProvider/PluginProvider.tsx # src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx # src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts # src/lib/account/evm.ts # src/lib/asset-service/service/AssetService.ts # src/lib/coingecko/utils.ts # src/lib/market-service/coingecko/coingecko.test.ts # src/pages/Markets/components/MarketsRow.tsx # src/state/migrations/index.ts # src/state/slices/opportunitiesSlice/mappings.ts # src/state/slices/portfolioSlice/utils/index.ts # src/state/slices/preferencesSlice/preferencesSlice.ts # src/test/mocks/store.ts # src/vite-env.d.ts
- yarn generate:chain eip155:480 - 29 tokens discovered - Add worldChainChainId to WRAPPED_NATIVE_CONTRACT_BY_CHAIN_ID - Add worldChainAssetId to generateChainRelatedAssetIndex ETH array - Fix duplicate starknetAssetId import Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Unichain, Bob, Mode had duplicate networkIcon entries from merge conflict resolution. Keep newer develop versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Actionable comments posted: 6
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/lib/market-service/coingecko/coingecko.test.ts (1)
228-269:⚠️ Potential issue | 🔴 CriticalDuplicate destructuring identifiers and duplicate assertion entries — TypeScript error + incorrect assertions.
Lines 234–239 (new additions) introduce bindings already declared by lines 240–248 (pre-existing):
Duplicate name New line Existing line ethOnMegaEthKey235, 237 244 ethOnHemiKey236 241 ethOnLineaKey238 242 ethOnBobKey239 240 TypeScript reports
Duplicate identifierfor duplicate names within the same destructuring binding, so this file will not compile. TheethAssetIdexpected array (lines 256–269) also carries both the new and old occurrences of these names as separate array entries, making the assertion itself incorrect.The fix is to remove or replace the stale (pre-existing) bindings/entries with the new WorldChain-aware ones and keep the array length consistent with the corrected count expectations above.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/market-service/coingecko/coingecko.test.ts` around lines 228 - 269, The test introduces duplicate destructuring identifiers and mismatched expected arrays: clean up the Object.keys(result) destructuring to use unique identifiers (remove the stale pre-existing bindings and keep the WorldChain-aware names such as ethOnWorldChainKey, ethOnMegaEthKey, ethOnHemiKey, ethOnLineaKey, ethOnBobKey, etc.), then update the btcAssetId and ethAssetId expectation arrays to reference exactly those unique destructured variables (no duplicates) so the length and contents align with the keys you actually destructured.
🧹 Nitpick comments (1)
src/lib/utils/worldchain.ts (1)
19-22: Consider caching theJsonRpcProviderto avoid creating a new instance per call.A fresh
JsonRpcProvideris instantiated on every invocation. SincegetWorldChainTransactionStatusis likely called in a polling loop, this allocates a new connection each time.packages/contracts/src/ethersProviderSingleton.ts(already in the import graph for this module) may offer a reusable pattern, or a module-level cached provider keyed onnodeUrlwould avoid the overhead.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/utils/worldchain.ts` around lines 19 - 22, getWorldChainTransactionStatus currently creates a new JsonRpcProvider on every call; change this to reuse a cached provider instance instead (either use the existing ethersProviderSingleton pattern from packages/contracts/src/ethersProviderSingleton.ts or implement a simple module-level Map keyed by nodeUrl that stores JsonRpcProvider instances). Update getWorldChainTransactionStatus to retrieve the provider from that cache (creating and storing it only if missing) rather than instantiating new JsonRpcProvider each invocation, and ensure the cache key is nodeUrl so different nodes get distinct providers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.env.development:
- Line 64: Replace the invalid Tenderly URL value for VITE_WORLDCHAIN_NODE_URL
so it either includes the required Tenderly access key placeholder or, better,
uses the public Alchemy endpoint; specifically update the
VITE_WORLDCHAIN_NODE_URL entry (the environment variable name
VITE_WORLDCHAIN_NODE_URL) to a working URL such as the Alchemy public endpoint
"https://worldchain-mainnet.g.alchemy.com/public" or to the Tenderly pattern
with a placeholder token
("https://worldchain-mainnet.gateway.tenderly.co/$TENDERLY_NODE_ACCESS_KEY") so
developers have a usable default and know where to supply the access key.
- Line 64: Update the VITE_WORLDCHAIN_NODE_URL environment variable value:
replace the current Tenderly gateway URL set in VITE_WORLDCHAIN_NODE_URL with
World Chain's official public RPC endpoint
"https://worldchain-mainnet.g.alchemy.com/public" so the variable
VITE_WORLDCHAIN_NODE_URL points to the official World Chain RPC.
In `@packages/utils/src/assetData/baseAssets.ts`:
- Around line 553-554: In the frozen asset objects unichainChain, bobChain, and
modeChain remove the duplicated networkIcon property so each
Object.freeze({...}) contains only one networkIcon entry; locate the duplicate
keys in baseAssets.ts (the newly added networkIcon lines) and delete those extra
networkIcon lines, leaving the original/correct networkIcon values intact for
unichainChain, bobChain, and modeChain.
In `@src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx`:
- Around line 3-10: The import block in useGetPopularAssetsQuery.tsx contains
duplicate named bindings (berachainAssetId, bobAssetId, cronosAssetId,
hemiAssetId) which causes a TS2300 compile error; open the import statement that
references these identifiers and remove the repeated occurrences so each named
import appears only once, leaving a single berachainAssetId, bobAssetId,
cronosAssetId, and hemiAssetId in the { ... } list.
In `@src/lib/market-service/coingecko/coingecko.test.ts`:
- Around line 172-175: There are duplicate assertions checking
Object.keys(result).length in the same test blocks; remove the stale/earlier
expect calls and keep only the final expected count. In coingecko.test.ts,
inside the test that currently has three expects for Object.keys(result).length
(values 7, 13, 14), delete the two older expects and leave a single
expect(Object.keys(result).length).toEqual(14); do the same in the 'can return
some results if partially rate limited' test (remove the earlier counts and keep
only the final expected value used by that test). Ensure each it block contains
only one length assertion using Object.keys(result).length and the correct final
number.
In `@src/lib/utils/worldchain.ts`:
- Around line 39-41: Replace the direct console.error call in the catch block of
the getTransactionStatus flow with the project's structured logger (e.g.,
logger.error or processLogger.error) so the error goes through ShapeShift's
logging infra; include the caught error object and relevant contextual metadata
(transaction hash/txId, network, and function name) in the structured log, then
continue to return TxStatus.Unknown as before. Ensure you import/obtain the
module logger used elsewhere in this file and use the logger.error method with a
descriptive message plus the error and context fields.
---
Outside diff comments:
In `@src/lib/market-service/coingecko/coingecko.test.ts`:
- Around line 228-269: The test introduces duplicate destructuring identifiers
and mismatched expected arrays: clean up the Object.keys(result) destructuring
to use unique identifiers (remove the stale pre-existing bindings and keep the
WorldChain-aware names such as ethOnWorldChainKey, ethOnMegaEthKey,
ethOnHemiKey, ethOnLineaKey, ethOnBobKey, etc.), then update the btcAssetId and
ethAssetId expectation arrays to reference exactly those unique destructured
variables (no duplicates) so the length and contents align with the keys you
actually destructured.
---
Nitpick comments:
In `@src/lib/utils/worldchain.ts`:
- Around line 19-22: getWorldChainTransactionStatus currently creates a new
JsonRpcProvider on every call; change this to reuse a cached provider instance
instead (either use the existing ethersProviderSingleton pattern from
packages/contracts/src/ethersProviderSingleton.ts or implement a simple
module-level Map keyed by nodeUrl that stores JsonRpcProvider instances). Update
getWorldChainTransactionStatus to retrieve the provider from that cache
(creating and storing it only if missing) rather than instantiating new
JsonRpcProvider each invocation, and ensure the cache key is nodeUrl so
different nodes get distinct providers.
- Replace Tenderly RPC (requires API key) with Alchemy public endpoint - Remove duplicate imports in useGetPopularAssetsQuery - Remove duplicate expect assertions in coingecko market service test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Chainlist.org as fallback RPC source + curl verification step. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge artifact left duplicate ethOnMegaEthKey, ethOnBobKey, ethOnHemiKey, ethOnLineaKey declarations. Correct order: bob, worldchain, hemi, linea. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Remove duplicate destructuring variables from merge - Fix ethOnBob/ethOnWorldChain ordering to match adapter registration - Bump flatten/rate-limited counts for World Chain (+1 each) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
gomesalexandre
left a comment
There was a problem hiding this comment.
all checks green, contract review passes, lgtm
gomesalexandre
left a comment
There was a problem hiding this comment.
all gucci, CI green across the board 🫡
Description
Integrates World Chain (chainId: 480) as a second-class citizen EVM chain via Relay.link.
This is PR 9 of 17 in a sequential chain integration series. These PRs must be reviewed and merged in order, as each builds on the previous one (stacked branches).
PR merge order:
World Chain is an OP Stack L2 with native ETH. This adds full support including:
WorldChainHow to Test
/flagsRelated Issues
Closes part of #11902
Summary by CodeRabbit