feat: megaeth support#11887
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdds MegaETH support across the app: env vars and validators, CSP entry, viem chain/client, chain adapter and plugin, asset/Coingecko mappings and generators, wallet capability flags and guards, feature-flag gating, tx-status RPC helper, tests, and generated data updates. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as Client/UI
participant Plugin as PluginRegistry
participant Adapter as MegaEthChainAdapter
participant Node as MegaETH RPC (VITE_MEGAETH_NODE_URL)
participant Wallet as HDWallet
UI->>Plugin: initialize (featureFlag MegaEth)
Plugin-->>Adapter: construct(rpcUrl, getKnownTokens)
UI->>Wallet: request send tx
Wallet->>Adapter: signAndSend(tx)
Adapter->>Node: eth_sendRawTransaction
Node-->>Adapter: txHash
UI->>Adapter: poll tx status
Adapter->>Node: eth_getTransactionReceipt
Node-->>Adapter: receipt (status)
Adapter-->>UI: TxStatus (Confirmed/Failed/Pending)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 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 |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add MegaEthMainnet to SECOND_CLASS_CHAINS and knownChainIds filter - Add feature flag check in PluginProvider _supportedChains - Add wallet support check in account derivation (evm.ts) - Add CoinGecko adapter: platform enum, chainId mappings, asset parsing - Add CoinGecko generated adapter data for eip155:4326 - Add asset generation script and orchestrator entry - Add Relay swapper support (MegaETH confirmed on Relay API) - Add MegaETH to popular assets for discoverability Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add getMegaEthTransactionStatus utility for send action polling - Add MegaEthMainnet case in useSendActionSubscriber switch - Add MegaEth feature flag filter in MarketsRow Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e742b7b to
fd7b739
Compare
|
fixed in d065ece |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@packages/caip/src/constants.ts`:
- Line 265: The FEE_ASSET_IDS array is missing hyperEvmAssetId, plasmaAssetId,
and katanaAssetId causing native-asset filtering bugs; update the FEE_ASSET_IDS
constant to include hyperEvmAssetId, plasmaAssetId, and katanaAssetId alongside
megaethAssetId so portfolioSlice selectors and generateAssetData treat these
chains as native fee assets (locate FEE_ASSET_IDS in constants.ts and add the
three asset id symbols).
🧹 Nitpick comments (2)
src/lib/utils/megaeth.ts (2)
16-45: Consider adding a timeout to the fetch call.If the MegaETH RPC endpoint becomes unresponsive, this
fetchwill hang indefinitely since there's noAbortSignalwith a timeout. Since this is used for transaction status polling, a stalled request could block the polling loop.♻️ Suggested fix
export const getMegaEthTransactionStatus = async (txHash: string): Promise<TxStatus> => { const rpcUrl = getConfig().VITE_MEGAETH_NODE_URL try { - const response = await fetch(rpcUrl, { + const response = await fetch(rpcUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', method: 'eth_getTransactionReceipt', params: [txHash], id: 1, }), + signal: AbortSignal.timeout(10_000), })
33-34: Untyped JSON response.
response.json()returnsany. Consider adding a minimal type for the expected JSON-RPC response shape to improve type safety.
d065ece to
b43bd80
Compare
|
fixed in b43bd80 |
NeOMakinG
left a comment
There was a problem hiding this comment.
Adding an evm chain is straightfoward those days, nothing to notice here, testing looks good: https://jam.dev/c/e65b26df-23c4-4e32-9a00-2191b771779c
Yeet it
There was a problem hiding this comment.
🧹 Nitpick comments (4)
.env (2)
158-158: LGTM! Node URL correctly configured for production.The URL matches
.env.developmentand points to the MegaETH mainnet RPC endpoint, consistent with the mainnet launch on Feb 9, 2026.📝 Optional: alphabetical ordering
Static analysis suggests placing this before
VITE_MONAD_NODE_URLfor alphabetical ordering:VITE_BASE_NODE_URL=https://api.base.shapeshift.com/api/v1/jsonrpc +VITE_MEGAETH_NODE_URL=https://mainnet.megaeth.com/rpc VITE_MONAD_NODE_URL=https://rpc.monad.xyz VITE_PLASMA_NODE_URL=https://rpc.plasma.to -VITE_MEGAETH_NODE_URL=https://mainnet.megaeth.com/rpc🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env at line 158, Move the VITE_MEGAETH_NODE_URL entry so environment variables are alphabetically ordered: locate the VITE_MEGAETH_NODE_URL line and place it before the VITE_MONAD_NODE_URL entry in the .env file to satisfy the suggested static-analysis ordering.
304-304: LGTM! Feature flag correctly disabled for production.Setting this to
falsein the base.envensures MegaETH is disabled in production by default while allowing.env.developmentto enable it for testing, which aligns with the PR's low-risk rollout strategy.📝 Optional: alphabetical ordering
Static analysis suggests reordering for better maintainability:
VITE_FEATURE_HYPEREVM=true +VITE_FEATURE_MEGAETH=false VITE_FEATURE_NEAR=true VITE_FEATURE_KATANA=true -VITE_FEATURE_MEGAETH=falseThis would group it alphabetically with other chain feature flags, though the current placement near KATANA (another second-class chain) is also logical.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env at line 304, Move the VITE_FEATURE_MEGAETH flag into the alphabetical group of chain feature flags for maintainability; locate the VITE_FEATURE_MEGAETH entry in the .env file and reposition it among the other VITE_FEATURE_* chain flags (e.g., near KATANA or wherever the alphabetical ordering of those keys would place it) so the list is sorted by key name..env.development (2)
65-65: LGTM! MegaETH node URL correctly configured.The node URL follows the established pattern for second-class EVM chains and points to the MegaETH mainnet RPC endpoint.
📝 Optional: alphabetical ordering
Static analysis suggests placing this before
VITE_MONAD_NODE_URLfor alphabetical ordering:VITE_BASE_NODE_URL=https://dev-api.base.shapeshift.com/api/v1/jsonrpc +VITE_MEGAETH_NODE_URL=https://mainnet.megaeth.com/rpc VITE_MONAD_NODE_URL=https://rpc.monad.xyz VITE_PLASMA_NODE_URL=https://rpc.plasma.to VITE_KATANA_NODE_URL=https://rpc.katana.network VITE_HYPEREVM_NODE_URL=https://rpc.hyperliquid.xyz/evm -VITE_MEGAETH_NODE_URL=https://mainnet.megaeth.com/rpc🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env.development at line 65, Move the VITE_MEGAETH_NODE_URL entry so it appears before VITE_MONAD_NODE_URL to maintain alphabetical ordering of environment variables; locate the two keys (VITE_MEGAETH_NODE_URL and VITE_MONAD_NODE_URL) in the .env file and swap their positions so MEGAETH comes before MONAD.
97-97: LGTM! Feature flag correctly enabled for development.The flag is intentionally set to
truein development while remainingfalsein the base.env(production), which aligns with the PR's low-risk rollout strategy.📝 Optional: alphabetical ordering
Static analysis suggests reordering for alphabetical consistency. Since this section appears to mix feature categories, this is purely cosmetic:
VITE_FEATURE_WC_DIRECT_CONNECTION=true VITE_FEATURE_CETUS_SWAP=true +VITE_FEATURE_MEGAETH=true VITE_FEATURE_KATANA=true VITE_FEATURE_TON=true VITE_FEATURE_STONFI_SWAP=true VITE_FEATURE_ACROSS_SWAP=true -VITE_FEATURE_MEGAETH=trueHowever, the current placement near other chain-specific feature flags (KATANA, TON) is also reasonable.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.env.development at line 97, The VITE_FEATURE_MEGAETH flag is set to true for development and approved; if you want cosmetic consistency, reorder the VITE_FEATURE_* entries alphabetically in the .env.development file so VITE_FEATURE_MEGAETH is placed according to alphabetical order with the other feature flags (search for existing VITE_FEATURE_KATANA, VITE_FEATURE_TON, etc.), otherwise leave VITE_FEATURE_MEGAETH=true as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.env:
- Line 158: Move the VITE_MEGAETH_NODE_URL entry so environment variables are
alphabetically ordered: locate the VITE_MEGAETH_NODE_URL line and place it
before the VITE_MONAD_NODE_URL entry in the .env file to satisfy the suggested
static-analysis ordering.
- Line 304: Move the VITE_FEATURE_MEGAETH flag into the alphabetical group of
chain feature flags for maintainability; locate the VITE_FEATURE_MEGAETH entry
in the .env file and reposition it among the other VITE_FEATURE_* chain flags
(e.g., near KATANA or wherever the alphabetical ordering of those keys would
place it) so the list is sorted by key name.
In @.env.development:
- Line 65: Move the VITE_MEGAETH_NODE_URL entry so it appears before
VITE_MONAD_NODE_URL to maintain alphabetical ordering of environment variables;
locate the two keys (VITE_MEGAETH_NODE_URL and VITE_MONAD_NODE_URL) in the .env
file and swap their positions so MEGAETH comes before MONAD.
- Line 97: The VITE_FEATURE_MEGAETH flag is set to true for development and
approved; if you want cosmetic consistency, reorder the VITE_FEATURE_* entries
alphabetically in the .env.development file so VITE_FEATURE_MEGAETH is placed
according to alphabetical order with the other feature flags (search for
existing VITE_FEATURE_KATANA, VITE_FEATURE_TON, etc.), otherwise leave
VITE_FEATURE_MEGAETH=true as-is.
Description
Does what it says on the box — full MegaETH chain integration, including hdwallet support flags + chain adapter + web integration.
Supersedes:
MegaETH mainnet went live Feb 9, 2026, so the original testnet blocker is gone.
Changes
_supportsMegaEthflags across all wallet implementationsMegaEthMainnetchain ID (eip155:4326) in caip/typesMegaEthChainAdapter(SecondClassEvmAdapter)Risk
Low — new chain, under feature flag (
VITE_FEATURE_MEGAETH). Enabled in dev, disabled in prod.Testing
Engineering
Toggle
VITE_FEATURE_MEGAETH=trueand verify MegaETH appears as a supported chain.Operations
Screenshots
https://jam.dev/c/224ccfbb-3b20-48c0-8b8e-61a76df77481
🤖 Generated with Claude Code
Summary by CodeRabbit