feat: integrate Celo (42220) as second-class Relay chain#11939
feat: integrate Celo (42220) as second-class Relay chain#11939gomesalexandre merged 20 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. 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughAdds comprehensive support for the Celo blockchain to the platform. Includes environment configuration, CAIP constants, chain adapters, HDWallet capability flags, Viem/Ethers clients, CoingeckoAsset mappings, asset generation scripts, plugin registration, and feature-flag gating throughout the application infrastructure. Changes
Sequence Diagram(s)sequenceDiagram
participant App as Application
participant PluginMgr as Plugin Manager
participant ChainAdapter as Celo Chain<br/>Adapter
participant AssetService as Asset Service
participant HDWallet as HDWallet
participant RPC as Celo RPC
App->>PluginMgr: Load Celo plugin (if feature enabled)
PluginMgr->>ChainAdapter: Instantiate with config
ChainAdapter->>AssetService: getKnownTokens()
AssetService->>AssetService: Filter for celoChainId<br/>+ erc20 namespace
AssetService-->>ChainAdapter: Return ERC20 tokens
ChainAdapter-->>PluginMgr: Adapter ready
App->>App: Derive accounts (EVM flow)
App->>HDWallet: Check supportsCelo(wallet)
alt Celo supported
App->>ChainAdapter: Derive accounts<br/>with BIP44 (CELO)
ChainAdapter->>RPC: Query balances/state
RPC-->>ChainAdapter: Account data
ChainAdapter-->>App: Accounts with metadata
else Celo not supported
App->>App: Skip Celo derivation
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related PRs
Suggested labels
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 |
CELO's native token also exists as ERC20 at 0x471ece3750da237f93b8e339c536989b8978a438. Relay may return CELO using the ERC20 address, so we need both mappings for proper CoinGecko price resolution.
This reverts commit cf836ba.
…o-relay # Conflicts: # .env # .env.development # headers/csps/index.ts # packages/caip/src/adapters/coingecko/generated/index.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/index.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/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 # scripts/generateAssetData/coingecko.ts # scripts/generateAssetData/generateAssetData.ts # src/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsx # src/config.ts # src/constants/chains.ts # src/context/PluginProvider/PluginProvider.tsx # src/hooks/useWalletSupportsChain/useWalletSupportsChain.ts # src/lib/account/evm.ts # src/lib/asset-service/service/AssetService.ts # src/lib/coingecko/utils.ts # src/pages/Markets/components/MarketsRow.tsx # src/plugins/activePlugins.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
CELO's native token also exists as ERC20 at 0x471ece3750da237f93b8e339c536989b8978a438. Relay may return CELO using the ERC20 address, so we need both mappings for proper CoinGecko price resolution.
This reverts commit 3da5a02.
This reverts commit 9bbf3a9.
There was a problem hiding this comment.
Actionable comments posted: 1
> [!CAUTION]
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)packages/caip/src/constants.ts (1)
265-305:⚠️ Potential issue | 🔴 Critical
CHAIN_REFERENCE.CeloMainnetis missing fromVALID_CHAIN_IDS.
CeloMainnetis defined (line 180) and included inFEE_ASSET_IDS(line 355), but it is not inVALID_CHAIN_IDS[CHAIN_NAMESPACE.Evm]. This causestoChainId()/fromChainId()validation to rejecteip155:42220, breaking Celo chain ID validation throughout the system.Add
CHAIN_REFERENCE.CeloMainnetbetweenBnbSmartChainMainnetandPolygonMainnetto match the order inFEE_ASSET_IDS:Correct placement
CHAIN_REFERENCE.BnbSmartChainMainnet, + CHAIN_REFERENCE.CeloMainnet, CHAIN_REFERENCE.PolygonMainnet,🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/caip/src/constants.ts` around lines 265 - 305, VALID_CHAIN_IDS for CHAIN_NAMESPACE.Evm is missing CHAIN_REFERENCE.CeloMainnet which causes eip155:42220 to be rejected; update the array in the VALID_CHAIN_IDS constant (the CHAIN_NAMESPACE.Evm entry) to insert CHAIN_REFERENCE.CeloMainnet between CHAIN_REFERENCE.BnbSmartChainMainnet and CHAIN_REFERENCE.PolygonMainnet so the ordering matches FEE_ASSET_IDS and to allow toChainId()/fromChainId() to validate Celo.
🤖 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:
- Line 14: Remove the duplicated environment variables VITE_FEATURE_CELO and
VITE_CELO_NODE_URL from the development-specific env file; these are already
defined globally in the base env so delete the VITE_FEATURE_CELO and
VITE_CELO_NODE_URL entries in .env.development to avoid redundancy and rely on
the base definitions instead.
---
Outside diff comments:
In `@packages/caip/src/constants.ts`:
- Around line 265-305: VALID_CHAIN_IDS for CHAIN_NAMESPACE.Evm is missing
CHAIN_REFERENCE.CeloMainnet which causes eip155:42220 to be rejected; update the
array in the VALID_CHAIN_IDS constant (the CHAIN_NAMESPACE.Evm entry) to insert
CHAIN_REFERENCE.CeloMainnet between CHAIN_REFERENCE.BnbSmartChainMainnet and
CHAIN_REFERENCE.PolygonMainnet so the ordering matches FEE_ASSET_IDS and to
allow toChainId()/fromChainId() to validate Celo.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled
You can enable these sources in your CodeRabbit configuration.
⛔ Files ignored due to path filters (41)
packages/caip/src/adapters/coincap/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_10/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_137/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_42161/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_43114/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_56/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/eip155_8453/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coincap/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_1/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_130/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_137/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_146/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_1514/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_1868/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_25/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_324/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_34443/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_42161/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_42220/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_43111/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_43114/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_480/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_5000/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_56/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_59144/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_60808/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_747/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_80094/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_81457/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_8453/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_98866/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/eip155_999/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/index.tsis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/solana_5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp/adapter.jsonis excluded by!**/generated/**packages/caip/src/adapters/coingecko/generated/sui_35834a8a/adapter.jsonis excluded by!**/generated/**public/generated/asset-manifest.jsonis excluded by!**/generated/**public/generated/asset-manifest.json.bris excluded by!**/generated/**public/generated/asset-manifest.json.gzis excluded by!**/*.gz,!**/generated/**public/generated/generatedAssetData.jsonis excluded by!**/generated/**public/generated/generatedAssetData.json.bris excluded by!**/generated/**public/generated/generatedAssetData.json.gzis excluded by!**/*.gz,!**/generated/**
📒 Files selected for processing (56)
.env.env.developmentheaders/csps/chains/celo.tsheaders/csps/index.tspackages/caip/src/adapters/coingecko/index.test.tspackages/caip/src/adapters/coingecko/index.tspackages/caip/src/adapters/coingecko/utils.test.tspackages/caip/src/adapters/coingecko/utils.tspackages/caip/src/constants.tspackages/chain-adapters/src/evm/EvmBaseAdapter.tspackages/chain-adapters/src/evm/celo/CeloChainAdapter.tspackages/chain-adapters/src/evm/celo/index.tspackages/chain-adapters/src/evm/index.tspackages/chain-adapters/src/types.tspackages/contracts/src/ethersProviderSingleton.tspackages/contracts/src/viemClient.tspackages/hdwallet-coinbase/src/coinbase.tspackages/hdwallet-core/src/ethereum.tspackages/hdwallet-core/src/wallet.tspackages/hdwallet-gridplus/src/gridplus.tspackages/hdwallet-keepkey/src/keepkey.tspackages/hdwallet-ledger/src/ledger.tspackages/hdwallet-metamask-multichain/src/shapeshift-multichain.tspackages/hdwallet-native/src/ethereum.tspackages/hdwallet-phantom/src/phantom.tspackages/hdwallet-trezor/src/trezor.tspackages/hdwallet-vultisig/src/vultisig.tspackages/hdwallet-walletconnectv2/src/walletconnectV2.tspackages/swapper/src/swappers/RelaySwapper/constant.tspackages/swapper/src/swappers/RelaySwapper/utils/relayTokenToAssetId.tspackages/types/src/base.tspackages/types/src/zerion.tspackages/utils/src/assetData/baseAssets.tspackages/utils/src/assetData/getBaseAsset.tspackages/utils/src/chainIdToFeeAssetId.tspackages/utils/src/getAssetNamespaceFromChainId.tspackages/utils/src/getChainShortName.tspackages/utils/src/getNativeFeeAssetReference.tsscripts/generateAssetData/celo/index.tsscripts/generateAssetData/coingecko.tsscripts/generateAssetData/generateAssetData.tssrc/components/TradeAssetSearch/hooks/useGetPopularAssetsQuery.tsxsrc/config.tssrc/constants/chains.tssrc/context/PluginProvider/PluginProvider.tsxsrc/hooks/useWalletSupportsChain/useWalletSupportsChain.tssrc/lib/account/evm.tssrc/lib/asset-service/service/AssetService.tssrc/lib/coingecko/constants.tssrc/lib/coingecko/utils.tssrc/pages/Markets/components/MarketsRow.tsxsrc/plugins/activePlugins.tssrc/plugins/celo/index.tsxsrc/state/slices/portfolioSlice/utils/index.tssrc/state/slices/preferencesSlice/preferencesSlice.tssrc/test/mocks/store.ts
- add VITE_CELO_NODE_URL + VITE_FEATURE_CELO to vite-env.d.ts - move VITE_FEATURE_FLOWEVM to correct section (adjacent to node url) - add celoChainId import + WCELO to SecondClassEvmAdapter - add celo to .env.production - use ankr rpc (0.030s) over forno (0.080s) across all envs Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Description
Add support for Celo (EVM chain, chainId 42220) as a second-class citizen. Celo is an EVM-compatible Layer 1 blockchain focused on mobile-first DeFi, with CELO as its native token.
This is PR 15 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:
Implements: CAIP constants, chain adapter (SecondClassEvmAdapter), plugin, feature flag, Relay swapper mapping, HDWallet support flags, CSP headers, asset generation script, viem/ethers client configuration, CoinGecko price feed integration, Zerion portfolio tracking, and all required shared-file entries.
Issue (if applicable)
Part of #11902
Risk
Low - All changes are behind the
Celofeature flag (VITE_FEATURE_CELO), disabled by default in production.No new on-chain transactions or contract interactions. Standard EVM chain support using existing SecondClassEvmAdapter pattern.
Testing
Engineering
VITE_FEATURE_CELO=truein.env.developmentyarn devyarn lint— passes with 0 errorsyarn type-check— verify no new type errorsOperations
Screenshots (if applicable)
N/A - Behind feature flag, no visual changes until enabled.
Summary by CodeRabbit
New Features
Chores