Skip to content

feat: megaeth support#11887

Merged
NeOMakinG merged 12 commits intoshapeshift:developfrom
gomes-bot:feat_megaEth
Feb 17, 2026
Merged

feat: megaeth support#11887
NeOMakinG merged 12 commits intoshapeshift:developfrom
gomes-bot:feat_megaEth

Conversation

@gomes-bot
Copy link
Contributor

@gomes-bot gomes-bot commented Feb 15, 2026

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

  • hdwallet _supportsMegaEth flags across all wallet implementations
  • MegaEthMainnet chain ID (eip155:4326) in caip/types
  • MegaEthChainAdapter (SecondClassEvmAdapter)
  • viem client + chain definition for MegaETH
  • CSP, plugin, feature flag, env vars, asset service integration
  • viem bump 2.40.3 → 2.43.5

Risk

Low — new chain, under feature flag (VITE_FEATURE_MEGAETH). Enabled in dev, disabled in prod.

Testing

Engineering

Toggle VITE_FEATURE_MEGAETH=true and verify MegaETH appears as a supported chain.

Operations

  • 🏁 My feature is behind a flag and doesn't require operations testing (yet)

Screenshots

https://jam.dev/c/224ccfbb-3b20-48c0-8b8e-61a76df77481

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Full MegaETH integration: network, clients, explorer links, plugin registration, and chain adapter.
    • MegaETH assets included in markets, popular assets, asset indexing, generated asset data, and fee/asset mappings.
    • Wallets updated to advertise MegaETH support and transaction monitoring added.
    • Feature flag and RPC configuration added to enable/disable MegaETH and set node URL.
  • Chores
    • Bumped viem dependency versions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Adds 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

Cohort / File(s) Summary
Environment & Config
\.env, \.env.development, src/config.ts
Added VITE_MEGAETH_NODE_URL and VITE_FEATURE_MEGAETH env entries and validators.
CSP
headers/csps/chains/megaeth.ts, headers/csps/index.ts
New CSP module sourcing VITE_MEGAETH_NODE_URL, added to exported CSPs.
Types & Constants
packages/types/src/base.ts, packages/caip/src/constants.ts, src/constants/chains.ts
Introduced MegaEth identifiers (MegaEthMainnet, megaethChainId, megaethAssetId), added to enums/unions, SECOND_CLASS_CHAINS and feature-flag gating.
Viem & Clients
packages/contracts/src/viemClient.ts, packages/*/package.json
Defined megaeth chain via defineChain, created viemMegaEthClient, mapped network/client, and bumped viem dependency versions across packages.
Chain Adapter & Index
packages/chain-adapters/src/evm/index.ts, packages/chain-adapters/src/evm/EvmBaseAdapter.ts, packages/chain-adapters/src/evm/megaeth/*, packages/chain-adapters/src/types.ts
Added megaeth export namespace, included MegaEthMainnet in EVM chain lists, implemented MegaEth ChainAdapter and types/display name.
Wallet Capability Flags
packages/hdwallet-*/src/*, packages/hdwallet-core/src/*
Added _supportsMegaEth flags across wallet implementations and supportsMegaEth guard in hdwallet-core.
Plugin & Registration
src/plugins/megaeth/index.tsx, src/plugins/activePlugins.ts, src/context/PluginProvider/PluginProvider.tsx
New MegaETH plugin registering chain adapter (uses VITE_MEGAETH_NODE_URL and getKnownTokens), added to active plugins and provider gating by feature flag.
Assets & Asset Generation
packages/utils/src/assetData/*, scripts/generateAssetData/*, scripts/generateAssetData/color-map.json
Added megaeth base asset, Coingecko integration and generator module, merged megaeth assets into generation, and updated color-map entries.
Swap / Relay
packages/swapper/src/swappers/RelaySwapper/*
Mapped megaethChainId to relay chain id 4326 and added token-to-assetId mapping for MegaEthMainnet.
Transaction Status & Utils
src/lib/utils/megaeth.ts, src/hooks/useActionCenterSubscribers/useSendActionSubscriber.tsx
Added getMegaEthTransactionStatus RPC helper and integrated MegaEth status polling.
App State & Feature Flags
src/state/slices/preferencesSlice/*, src/test/mocks/store.ts, src/state/migrations/index.ts
Added MegaEth feature flag, initialized from config, updated mock store and added migration entry.
UI & Hooks
src/components/.../useGetPopularAssetsQuery.tsx, src/pages/Markets/components/MarketsRow.tsx
Included MegaETH asset in popular assets and applied feature-flag chain filtering in markets UI.
Market / Coingecko adapters & tests
packages/caip/src/adapters/coingecko/*, src/lib/market-service/coingecko/coingecko.test.ts
Extended Coingecko platform/token mappings to include MegaEth and updated tests/expected mappings.
Portfolio & Account logic
src/lib/account/evm.ts, src/state/slices/portfolioSlice/utils/index.ts, src/lib/asset-service/service/AssetService.ts
Gated account/asset logic by feature flag and added wallet compatibility checks for MegaEth.

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)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested labels

high risk

Suggested reviewers

  • gomesalexandre

"I hopped in quick with whiskers bright,
Wove nodes and flags into the night,
Adapters, tokens, colors too,
A MegaETH meadow — hop! it's true,
Bugs beware — this rabbit's done the rite." 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: megaeth support' clearly and concisely describes the primary change: adding support for the MegaETH blockchain to the application.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

gomes-bot and others added 4 commits February 15, 2026 13:17
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>
@gomes-bot gomes-bot marked this pull request as ready for review February 16, 2026 10:10
@gomes-bot gomes-bot requested a review from a team as a code owner February 16, 2026 10:10
@gomes-bot
Copy link
Contributor Author

fixed in d065ece

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 fetch will hang indefinitely since there's no AbortSignal with 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() returns any. Consider adding a minimal type for the expected JSON-RPC response shape to improve type safety.

@gomes-bot
Copy link
Contributor Author

fixed in b43bd80

Copy link
Collaborator

@NeOMakinG NeOMakinG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@NeOMakinG NeOMakinG enabled auto-merge (squash) February 17, 2026 10:34
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (4)
.env (2)

158-158: LGTM! Node URL correctly configured for production.

The URL matches .env.development and 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_URL for 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 false in the base .env ensures MegaETH is disabled in production by default while allowing .env.development to 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=false

This 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_URL for 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 true in development while remaining false in 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=true

However, 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.

@NeOMakinG NeOMakinG merged commit 0a86a4b into shapeshift:develop Feb 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants