feat: integrate Soneium (chainId: 1868) via Relay#11930
feat: integrate Soneium (chainId: 1868) via Relay#11930gomesalexandre merged 71 commits intodevelopfrom
Conversation
…Relay bridge support Add support for Mantle (MNT native gas) including CAIP constants, chain adapter, plugin, feature flag, Relay swapper mapping, HDWallet support flags, CSP headers, asset generation script, and all required shared-file entries. Part of #11902
…lay bridge support Add support for Cronos (CRO native gas) including CAIP constants, chain adapter, plugin, feature flag, Relay swapper mapping, HDWallet support flags, CSP headers, asset generation script, and all required shared-file entries. Part of #11902
Add src/lib/utils/mantle.ts with getMantleTransactionStatus using eth_getTransactionReceipt via the Mantle RPC. Add KnownChainIds.MantleMainnet case to useSendActionSubscriber.tsx so Mantle transactions resolve in the action center.
Add src/lib/utils/cronos.ts with getCronosTransactionStatus using eth_getTransactionReceipt via the Cronos RPC. Add KnownChainIds.CronosMainnet case to useSendActionSubscriber.tsx so Cronos transactions resolve in the action center. Add CHAIN_REFERENCE.CronosMainnet case to relayTokenToAssetId.ts to prevent runtime crash on Relay swaps involving Cronos.
Address PR review feedback: - Add mantleChainId to getCoingeckoSupportedChainIds (feature-flagged) - Add mantle to ZERION_CHAINS array and ZERION_CHAINS_MAP - Across does not support Mantle, skipped
Address PR review feedback: - Add cronosChainId to getCoingeckoSupportedChainIds (feature-flagged) - Add cronos to ZERION_CHAINS array and ZERION_CHAINS_MAP - Across does not support Cronos, skipped
…ay swapper support
Adds full Unichain support including: - CAIP constants, types, and chain adapter - HDWallet support flags across all wallet implementations - Relay and Across swapper mappings - CoinGecko adapter with unichain platform - Zerion chain mapping - Feature flag, plugin, CSP headers - Portfolio, account, asset service, and market integrations - Asset generation scripts and related asset index (ETH-native) Part of #11902
Mode (eip155:34443) sorts before MegaEth (eip155:4326) in coingeckoToAssetIds. Add missing Mode entry to market-service test destructuring and expected array.
The BOB adapter.json (eip155_60808) was created but not imported/exported from the generated index.ts, causing coingeckoToAssetIds to not return BOB. Also fix ethereum assetId ordering and add BOB to market-service test.
The Unichain adapter.json (eip155_130) was created but not imported/exported from the generated index.ts, causing coingeckoToAssetIds to not return Unichain.
The Sonic adapter.json (eip155_146) was created but not imported/exported from the generated index.ts, preventing CoinGecko mapping for Sonic tokens.
|
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 Soneium (eip155:1868) as a second-class EVM chain across the codebase: env vars and feature flag, CAIP constants, adapters/clients, wallet capability flags, asset generation/mappings, swapper integration, CSP, plugin registration, feature-gated UI and tests. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as User/UI
participant Plugin as PluginProvider (Soneium)
participant Adapter as SoneiumChainAdapter
participant Client as ViemClient
participant RPC as Soneium RPC
UI->>Plugin: register() (reads VITE_SONEIUM_NODE_URL, feature flag)
Plugin->>Adapter: construct(adapter args, getKnownTokens)
UI->>Adapter: submit tx / query status (txHash)
Adapter->>Client: request tx receipt (public client)
Client->>RPC: HTTP JSON-RPC eth_getTransactionReceipt
RPC-->>Client: tx receipt
Client-->>Adapter: return receipt/status
Adapter-->>UI: TxStatus (Confirmed/Failed/Unknown)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
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 |
…tle-relay # Conflicts: # .env # .env.development # 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/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/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/pages/Markets/components/MarketsRow.tsx # src/state/slices/portfolioSlice/utils/index.ts # src/state/slices/preferencesSlice/preferencesSlice.ts # src/test/mocks/store.ts # src/vite-env.d.ts
- Remove duplicate Sonic enum entries (sonic-3 vs sonic) - Remove duplicate Sonic baseAsset icon/networkIcon - Deduplicate ethAssetId related asset arrays - Add soneiumAssetId to generateChainRelatedAssetIndex - Fix coingecko index.test.ts assertion ordering (remove duplicate ethOnBob) - Bump market service test counts (flatten=13, rate limited=12) - Add migration 300 for Soneium - Add VITE_SONEIUM_NODE_URL and VITE_FEATURE_SONEIUM to vite-env.d.ts - Regenerate Soneium chain assets Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Merge all squash-merged chain PRs (Cronos, Sonic, Unichain, BOB, Mode) - Fix duplicate market service test assertions - Regenerate Soneium assets Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
c399854 to
14bfdd7
Compare
…fallback - fix BOB/Unichain/Mode broken network icons (CoinGecko 403s) - rename Sonic to Sonic (S) for searchability - collapse all EVM chain cases in useSendActionSubscriber into generic default - add WETH9 Withdrawal event fallback in parseTx for chains where debug_traceTransaction is unsupported and WETH.withdraw() doesn't emit Transfer-to-zero (OP Stack L2s, Across bridge fills) - regenerate compressed asset data with fixed icons Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The native tokens for Sonic (S) and Cronos (CRO) had relatedAssetKey pointing to their Ethereum ERC20 counterparts (ETH FTM and ETH CRO), making isPrimary=false. This caused them to be excluded from selectPrimaryAssets and missing from "Popular Assets" when filtering by chain. Fix: flip the manual index entries so native chain tokens are the KEY (primary) and ETH ERC20 tokens are values. This makes the native tokens self-referencing (relatedAssetKey === assetId) → isPrimary=true. ETH-native chains (Unichain, Optimism, etc.) are unaffected - they correctly point to ethAssetId as their relatedAssetKey because they ARE ETH, just on a different chain. Also updates the second-class-evm-chain contract to reflect: - Generic tx status handling (no per-chain util files needed) - WETH9 Withdrawal event fallback in parseTx - Critical note about native tokens needing to be KEYS in manual index Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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/adapters/coingecko/index.test.ts (1)
102-121:⚠️ Potential issue | 🔴 CriticalCI failure: generated adapter data not regenerated.
The
coingeckoToAssetIds('ethereum')test expectsethOnSoneium(eip155:1868/slip44:60) to be present but the generated file(s) underpackages/caip/src/adapters/coingecko/generated/haven't been updated, causing the assertion to receive only 10 items. The Soneium entry needs to be committed after running the CoinGecko adapter generation script.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/caip/src/adapters/coingecko/index.test.ts` around lines 102 - 121, The test failure is caused by missing regenerated adapter data: ensure the CoinGecko adapter generation is re-run so the generated adapter files include the ethOnSoneium entry referenced by the test (coingeckoToAssetIds('ethereum') expecting ethOnSoneium/eip155:1868/slip44:60); run the repository's CoinGecko generation script for the adapters, verify coingeckoToAssetIds now returns the full list including ethOnSoneium, and commit the updated generated adapter files (and any updated snapshots) to the PR.
🧹 Nitpick comments (3)
.env (1)
169-169:VITE_SONEIUM_*keys should precede theirVITE_SONIC_*counterparts.Alphabetically
SONEIUM<SONIC(E<Iat the 4th character). BothVITE_SONEIUM_NODE_URL(Line 169) andVITE_FEATURE_SONEIUM(Line 328) should be placed beforeVITE_SONIC_NODE_URL(Line 165) andVITE_FEATURE_SONIC(Line 324), respectively. This is flagged bydotenv-linter.Also applies to: 328-328
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env at line 169, Reorder the environment variable entries so any VITE_SONEIUM_* keys come before their VITE_SONIC_* counterparts: move VITE_SONEIUM_NODE_URL so it appears before VITE_SONIC_NODE_URL and move VITE_FEATURE_SONEIUM so it appears before VITE_FEATURE_SONIC; this resolves dotenv-linter alphabetical ordering (ensure you only change the order of the lines containing VITE_SONEIUM_NODE_URL, VITE_SONIC_NODE_URL, VITE_FEATURE_SONEIUM, and VITE_FEATURE_SONIC and keep their values intact).src/lib/utils/soneium.ts (1)
39-42:console.errorinstead of the project's structured logger.Per coding guidelines, errors should use structured logging with relevant context rather than bare
console.error.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/utils/soneium.ts` around lines 39 - 42, Replace the bare console.error in the catch block of the getTransactionStatus function with the project's structured logger: call the shared logger instance (e.g., logger.error or processLogger.error) and pass a descriptive message plus the caught error object and any available context (transaction hash, network, etc.), then return TxStatus.Unknown as before; update the import/use of the logger in src/lib/utils/soneium.ts if necessary.packages/chain-adapters/src/evm/soneium/SoneiumChainAdapter.ts (1)
40-46: Add explicit return type annotations togetDisplayNameandgetName.Both methods lack return type annotations. Per coding guidelines, all functions must have explicit return types in TypeScript.
♻️ Proposed fix
- getDisplayName() { + getDisplayName(): ChainAdapterDisplayName { return ChainAdapterDisplayName.Soneium } - getName() { + getName(): string { return 'Soneium' }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/chain-adapters/src/evm/soneium/SoneiumChainAdapter.ts` around lines 40 - 46, Add explicit TypeScript return type annotations to the two methods in SoneiumChainAdapter: change getDisplayName to declare a return type of ChainAdapterDisplayName and change getName to declare a return type of string; update the method signatures (getDisplayName(): ChainAdapterDisplayName and getName(): string) to satisfy the coding guideline and ensure the ChainAdapterDisplayName symbol is available/imported if not already.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/chain-adapters/src/evm/soneium/SoneiumChainAdapter.ts`:
- Around line 18-20: The isSoneiumChainAdapter type-guard currently casts
adapter to ChainAdapter and calls getType(), which will throw for
null/undefined; update isSoneiumChainAdapter to first defensively check adapter
!= null and typeof (adapter as ChainAdapter).getType === 'function' before
calling getType(), then compare the returned value to
KnownChainIds.SoneiumMainnet so the function returns false for null/undefined or
non-adapter inputs instead of throwing.
---
Outside diff comments:
In `@packages/caip/src/adapters/coingecko/index.test.ts`:
- Around line 102-121: The test failure is caused by missing regenerated adapter
data: ensure the CoinGecko adapter generation is re-run so the generated adapter
files include the ethOnSoneium entry referenced by the test
(coingeckoToAssetIds('ethereum') expecting ethOnSoneium/eip155:1868/slip44:60);
run the repository's CoinGecko generation script for the adapters, verify
coingeckoToAssetIds now returns the full list including ethOnSoneium, and commit
the updated generated adapter files (and any updated snapshots) to the PR.
---
Nitpick comments:
In @.env:
- Line 169: Reorder the environment variable entries so any VITE_SONEIUM_* keys
come before their VITE_SONIC_* counterparts: move VITE_SONEIUM_NODE_URL so it
appears before VITE_SONIC_NODE_URL and move VITE_FEATURE_SONEIUM so it appears
before VITE_FEATURE_SONIC; this resolves dotenv-linter alphabetical ordering
(ensure you only change the order of the lines containing VITE_SONEIUM_NODE_URL,
VITE_SONIC_NODE_URL, VITE_FEATURE_SONEIUM, and VITE_FEATURE_SONIC and keep their
values intact).
In `@packages/chain-adapters/src/evm/soneium/SoneiumChainAdapter.ts`:
- Around line 40-46: Add explicit TypeScript return type annotations to the two
methods in SoneiumChainAdapter: change getDisplayName to declare a return type
of ChainAdapterDisplayName and change getName to declare a return type of
string; update the method signatures (getDisplayName(): ChainAdapterDisplayName
and getName(): string) to satisfy the coding guideline and ensure the
ChainAdapterDisplayName symbol is available/imported if not already.
In `@src/lib/utils/soneium.ts`:
- Around line 39-42: Replace the bare console.error in the catch block of the
getTransactionStatus function with the project's structured logger: call the
shared logger instance (e.g., logger.error or processLogger.error) and pass a
descriptive message plus the caught error object and any available context
(transaction hash, network, etc.), then return TxStatus.Unknown as before;
update the import/use of the logger in src/lib/utils/soneium.ts if necessary.
gomesalexandre
left a comment
There was a problem hiding this comment.
Happy on all counts for all chains from Mantle through Soneium:
- ✅ Execution price (cross-chain swap via Across/Relay)
- ✅ Outbound native asset Tx history (parseTx with WETH9 Withdrawal fallback)
- ✅ Network icons (BOB, Unichain, Mode fixed)
- ✅ Popular assets initial set (Sonic (S) and CRO now primary)
- ✅ Popular asset search
- ✅ Related assets
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts (1)
476-495:WITHDRAWAL_TOPICshould live at module scopeDefining it inside
parseTx(inside a nestedif) buries it alongside executable logic. Moving it to module level makes it as discoverable asBATCH_SIZEand theERC20_ABIconstant above.♻️ Proposed refactor
+const WETH9_WITHDRAWAL_TOPIC = + '0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65' + const BATCH_SIZE = 500- // Fallback: WETH9 Withdrawal(address indexed src, uint256 wad) event - // On OP Stack L2s and other chains, WETH.withdraw() emits Withdrawal instead of Transfer-to-zero if (internalTxs.length === 0) { - const WITHDRAWAL_TOPIC = - '0x7fcf532c15f0a6db0bd6d0e038bea71d30d808c7d98cb3bf7268a95bf5081b65' const withdrawalLogs = receipt.logs.filter( log => log.address && isAddressEqual(getAddress(log.address), getAddress(wrappedNativeContract)) && - log.topics[0] === WITHDRAWAL_TOPIC, + log.topics[0] === WETH9_WITHDRAWAL_TOPIC, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts` around lines 476 - 495, The WITHDRAWAL_TOPIC constant is declared inside parseTx's fallback block which buries a reusable ABI/topic constant in executable logic; lift the topic declaration to module scope (alongside BATCH_SIZE and ERC20_ABI) as a top-level constant (e.g., export or const WITHDRAWAL_TOPIC = '0x7fcf...b65') and update the code inside SecondClassEvmAdapter.parseTx to reference that top-level WITHDRAWAL_TOPIC when filtering receipt.logs (the logic that checks log.address against wrappedNativeContract and compares log.topics[0] should remain unchanged).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx`:
- Around line 262-271: The early return inside the default branch when
getSecondClassEvmTxStatus(chainId, txHash) returns undefined leaves the interval
running and the pollingKey in pollingIntervalsRef.current; update the default
branch in checkTxStatus to clear the interval and remove its entry from
pollingIntervalsRef.current before returning (use the existing pollingKey /
stored interval id), so the interval stops and the pollingKey is cleaned up to
avoid the Pending action being stuck; reference functions/vars:
getSecondClassEvmTxStatus, checkTxStatus, pollingKey,
pollingIntervalsRef.current.
---
Nitpick comments:
In `@packages/chain-adapters/src/evm/SecondClassEvmAdapter.ts`:
- Around line 476-495: The WITHDRAWAL_TOPIC constant is declared inside
parseTx's fallback block which buries a reusable ABI/topic constant in
executable logic; lift the topic declaration to module scope (alongside
BATCH_SIZE and ERC20_ABI) as a top-level constant (e.g., export or const
WITHDRAWAL_TOPIC = '0x7fcf...b65') and update the code inside
SecondClassEvmAdapter.parseTx to reference that top-level WITHDRAWAL_TOPIC when
filtering receipt.logs (the logic that checks log.address against
wrappedNativeContract and compares log.topics[0] should remain unchanged).
The adapter JSON existed but wasn't imported/exported from the generated
index.ts, causing coingeckoToAssetIds('ethereum') to not include
Soneium's ETH asset ID.
Also updates contract to explicitly call out the generated index file.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Description
Add Soneium (chainId: 1868) as a second-class EVM chain in ShapeShift Web with Relay bridge support.
This is PR 7 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:
Changes:
Soneiumin preferencesSlicesoneium)Chain details:
Issue (if applicable)
Part of #11902
Risk
Low risk — new chain behind feature flag (
Soneium), no existing functionality affected.Testing
Engineering
VITE_FEATURE_SONEIUM=truein .envyarn lint --fix && yarn type-check— must passOperations
Screenshots (if applicable)
N/A — chain integration, no UI changes.
Summary by CodeRabbit