feat: add Scroll chain support behind feature flag#11903
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds comprehensive support for the Scroll blockchain network. It introduces chain constants, creates a dedicated EVM chain adapter, adds wallet capability flags, integrates asset data generation, wires CSP headers, and enables feature flag-based gating for controlled rollout. Changes
Sequence DiagramsequenceDiagram
actor User
participant UI as UI Component
participant Plugin as Scroll Plugin
participant Config as Configuration
participant ChainAdapter as Chain Adapter
participant Wallet as Wallet
participant AssetService as Asset Service
participant RPC as RPC Node
User->>UI: Enable Scroll (Feature Flag)
UI->>Plugin: Initialize Scroll support
Plugin->>Config: Load VITE_SCROLL_NODE_URL
Config-->>Plugin: RPC URL
Plugin->>ChainAdapter: Create ScrollChainAdapter
ChainAdapter->>Wallet: Check supportsScroll(wallet)
Wallet-->>ChainAdapter: Wallet capability
alt Wallet Supports Scroll
ChainAdapter->>AssetService: getKnownTokens()
AssetService->>AssetService: Filter Scroll ERC20 assets
AssetService-->>ChainAdapter: Token list
ChainAdapter->>RPC: Initialize client
RPC-->>ChainAdapter: Connected
ChainAdapter-->>UI: Ready for transactions
else Wallet Does Not Support
ChainAdapter-->>UI: Chain unavailable
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
packages/caip/src/adapters/coingecko/utils.ts (1)
294-304: Add explanatory comment to Scroll catch block for consistency.The catch block at line 303 is empty (
catch {}), while all other similar platform parsing blocks in this file include the comment// unable to create assetId, skip token. Update line 303 to match the established pattern for clarity and consistency.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@packages/caip/src/adapters/coingecko/utils.ts` around lines 294 - 304, The empty catch block after attempting to build an assetId for CoingeckoAssetPlatform.Scroll should include the same explanatory comment used elsewhere; update the catch in the block that calls toAssetId (with chainNamespace CHAIN_NAMESPACE.Evm, chainReference CHAIN_REFERENCE.ScrollMainnet, assetNamespace 'erc20' and assetReference platforms[CoingeckoAssetPlatform.Scroll]) to read catch { // unable to create assetId, skip token } so it's consistent with other platform parsing blocks that set prev[scrollChainId][assetId] = id.src/plugins/scroll/index.tsx (1)
22-36: DoublefromAssetIdcall per asset — minor inefficiency.
fromAssetIdis invoked in both thefilter(line 26) andmap(line 31) callbacks for every matching asset. Since this runs once at startup and the PR description notes it's identical to the MegaETH pattern, this is a nit.♻️ Optional: combine filter + map to avoid the extra parse
- const getKnownTokens = () => { - const assetService = getAssetService() - return assetService.assets - .filter(asset => { - const { chainId, assetNamespace } = fromAssetId(asset.assetId) - return chainId === scrollChainId && assetNamespace === 'erc20' - }) - .map(asset => ({ - assetId: asset.assetId, - contractAddress: fromAssetId(asset.assetId).assetReference, - symbol: asset.symbol, - name: asset.name, - precision: asset.precision, - })) + const getKnownTokens = () => { + const assetService = getAssetService() + return assetService.assets.reduce< + { + assetId: string + contractAddress: string + symbol: string + name: string + precision: number + }[] + >((acc, asset) => { + const { chainId, assetNamespace, assetReference } = fromAssetId(asset.assetId) + if (chainId === scrollChainId && assetNamespace === 'erc20') { + acc.push({ + assetId: asset.assetId, + contractAddress: assetReference, + symbol: asset.symbol, + name: asset.name, + precision: asset.precision, + }) + } + return acc + }, []) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/plugins/scroll/index.tsx` around lines 22 - 36, getKnownTokens currently calls fromAssetId twice per asset (once in the filter and again in the map), causing unnecessary repeated parsing; refactor getKnownTokens to parse each assetId once by calling fromAssetId(asset.assetId) in a single pass (e.g., use map to extract parsed fields then filter by chainId === scrollChainId and assetNamespace === 'erc20') and then build the returned object with contractAddress, symbol, name, precision using the saved parsed result; update references to fromAssetId, assetService.assets, and scrollChainId within getKnownTokens accordingly.
🤖 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 66: Remove the trailing slash from the VITE_SCROLL_NODE_URL value so it
matches the other *_NODE_URL entries; locate the VITE_SCROLL_NODE_URL
environment variable and change its value from "https://rpc.scroll.io/" to
"https://rpc.scroll.io" (ensuring any code that concatenates paths remains
consistent without relying on a trailing slash).
---
Nitpick comments:
In `@packages/caip/src/adapters/coingecko/utils.ts`:
- Around line 294-304: The empty catch block after attempting to build an
assetId for CoingeckoAssetPlatform.Scroll should include the same explanatory
comment used elsewhere; update the catch in the block that calls toAssetId (with
chainNamespace CHAIN_NAMESPACE.Evm, chainReference
CHAIN_REFERENCE.ScrollMainnet, assetNamespace 'erc20' and assetReference
platforms[CoingeckoAssetPlatform.Scroll]) to read catch { // unable to create
assetId, skip token } so it's consistent with other platform parsing blocks that
set prev[scrollChainId][assetId] = id.
In `@src/plugins/scroll/index.tsx`:
- Around line 22-36: getKnownTokens currently calls fromAssetId twice per asset
(once in the filter and again in the map), causing unnecessary repeated parsing;
refactor getKnownTokens to parse each assetId once by calling
fromAssetId(asset.assetId) in a single pass (e.g., use map to extract parsed
fields then filter by chainId === scrollChainId and assetNamespace === 'erc20')
and then build the returned object with contractAddress, symbol, name, precision
using the saved parsed result; update references to fromAssetId,
assetService.assets, and scrollChainId within getKnownTokens accordingly.
gomesalexandre
left a comment
There was a problem hiding this comment.
what @gomes-bot said
gomesalexandre
left a comment
There was a problem hiding this comment.
found two more blockers - gomes-bot review coming in hot soon
787739c to
4bb2b26
Compare
7cf957a to
025c28e
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
.env.development (1)
99-99:VITE_FEATURE_SCROLLkey is out of alphabetical order.
dotenv-linterreports thatVITE_FEATURE_SCROLLshould appear beforeVITE_FEATURE_WC_DIRECT_CONNECTIONfor consistent ordering.Proposed fix
VITE_FEATURE_WC_DIRECT_CONNECTION=true VITE_FEATURE_CETUS_SWAP=true VITE_FEATURE_MEGAETH=true -VITE_FEATURE_SCROLL=true VITE_FEATURE_KATANA=true +VITE_FEATURE_SCROLL=true VITE_FEATURE_ACROSS_SWAP=true🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env.development at line 99, Move the VITE_FEATURE_SCROLL entry so the keys are alphabetically ordered: locate the VITE_FEATURE_SCROLL line and place it before the VITE_FEATURE_WC_DIRECT_CONNECTION entry (ensure there is a newline/format preserved and no duplicate keys), so dotenv-linter no longer reports an ordering violation.
🤖 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/caip/src/adapters/coingecko/utils.ts`:
- Around line 294-303: The empty catch block after attempting to build an
assetId for CoingeckoAssetPlatform.Scroll (the try using toAssetId and assigning
prev[scrollChainId][assetId] = id) should include the same standard comment used
in other catch blocks in this file; update the catch to include that comment
(e.g., the existing file-wide marker like "// ignore invalid asset id" or the
project's agreed-upon comment) so the empty catch is intentional and consistent
with other handlers.
In
`@scripts/generateAssetData/generateRelatedAssetIndex/generateRelatedAssetIndex.ts`:
- Around line 45-46: The hardcoded production key assigned to ZERION_API_KEY
must be removed and replaced with environment variable loading: change the
ZERION_API_KEY initialization to read from process.env.ZERION_API_KEY (or a
config loader) and restore the fail-fast guard by throwing an Error when that
environment variable is missing; update any usage sites that reference
ZERION_API_KEY to use the new variable as-is. Ensure no literal API key remains
in the file or diff and confirm the guard (if (!ZERION_API_KEY) throw new
Error(...)) is reachable again. Also record that the exposed key must be rotated
out-of-band immediately.
---
Duplicate comments:
In @.env.development:
- Line 66: The VITE_SCROLL_NODE_URL entry still contains a trailing slash;
update the environment variable value for VITE_SCROLL_NODE_URL to remove the
trailing slash (make it https://rpc.scroll.io) to match the format of other
*_NODE_URL entries and ensure any code that reads VITE_SCROLL_NODE_URL (e.g.,
config loaders or functions referencing VITE_SCROLL_NODE_URL) expects the URL
without a trailing slash.
---
Nitpick comments:
In @.env.development:
- Line 99: Move the VITE_FEATURE_SCROLL entry so the keys are alphabetically
ordered: locate the VITE_FEATURE_SCROLL line and place it before the
VITE_FEATURE_WC_DIRECT_CONNECTION entry (ensure there is a newline/format
preserved and no duplicate keys), so dotenv-linter no longer reports an ordering
violation.
a7a2d61 to
793caa2
Compare
Description
Add support for Scroll (EVM chain, chainId 534352) as a second-class citizen. Scroll is a zkEVM Layer 2 scaling solution for Ethereum, providing fast and low-cost transactions with EVM equivalence.
Implements: CAIP constants, chain adapter (SecondClassEvmAdapter), plugin, feature flag, Relay swapper mapping, HDWallet support flags, CSP headers, asset generation script, viem/ethers client configuration, and all required shared-file entries (chain gating, portfolio, markets, UI).
Issue (if applicable)
Part of #11902
Risk
Low - All changes are behind the
Scrollfeature flag (VITE_FEATURE_SCROLL), disabled by default in production.No new on-chain transactions or contract interactions. Standard EVM chain support using existing SecondClassEvmAdapter pattern (identical to MegaETH integration).
Testing
Engineering
VITE_FEATURE_SCROLL=truein.env.developmentyarn devyarn lint— passes with 0 errorsyarn type-check— verify no new type errorsOperations
Screenshots (if applicable)
https://jam.dev/c/c90e8747-915f-4180-8e99-7fd84bed77ed
N/A - Behind feature flag, no visual changes until enabled.
Summary by CodeRabbit
New Features
Configuration