Skip to content

feat: multi-chain RPC failover and wallet-connector fallback layer — Closes #341 - #368

Merged
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
mayborn005:feat/rpc-failover-walletconnect-fallback
Jul 29, 2026
Merged

feat: multi-chain RPC failover and wallet-connector fallback layer — Closes #341#368
Lakes41 merged 2 commits into
Adamantine-guild:mainfrom
mayborn005:feat/rpc-failover-walletconnect-fallback

Conversation

@mayborn005

Copy link
Copy Markdown

Closes #341

Summary

Implements a resilient multi-chain RPC failover and wallet-connector fallback layer as described in #341.

What changed

Multi-RPC failover (lib/wallet/config.ts):

  • NEXT_PUBLIC_WALLET_RPC_* variables now accept comma-separated URLs per chain
  • Uses viem's fallback([...]) transport with all user-provided endpoints + public default as final fallback
  • Health tracking deprioritizes endpoints after 3 consecutive failures (60s cooldown, auto-recovery)
  • Exported recordRpcFailure(), recordRpcSuccess(), isDeprioritized() for UI/test use

WalletConnect connector (lib/wallet/connectors.ts, lib/wallet/config.ts):

  • SUPPORTED_CONNECTOR_NAMES extended with walletConnect
  • NEXT_PUBLIC_WALLET_CONNECTORS now accepts walletConnect alongside injected
  • Requires NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID when walletConnect is enabled
  • Validation rejects unsupported connector names with clear error messages

Fallback connector UI (components/wallet/connect-button.tsx):

  • Detects injected wallet availability via hasInjectedWallet()
  • When no injected wallet is detected and multiple connectors exist, shows fallback prompt + connector picker
  • Preserves all existing 3-state button behavior and CopyAddressButton

Tests (test/rpc-failover.test.ts):

  • Health tracking: failure threshold, deprioritization, recovery, independent per-URL tracking
  • SSR safety of hasInjectedWallet()
  • Multi-RPC CSV parsing and connector validation

Documentation (.env.example, README.md):

  • Documents multi-RPC comma-separated syntax with examples
  • Documents walletConnect connector in the Wallet connectors table
  • Describes failover behavior and connector fallback UX

Acceptance criteria

  • Configuring multiple RPC URLs per chain results in automatic failover on primary failure
  • At least one non-injected wallet connector (walletConnect) is supported and documented
  • Validation correctly rejects malformed multi-value configuration
  • Tests cover RPC failover and connector fallback scenarios
  • README/.env.example updated

Verification

  • npm run lint — clean
  • npm run typecheck — only pre-existing upstream errors in node_modules/viem
  • Test compilation — all errors are pre-existing upstream ox type issues, no errors in project files

mordabdul1 and others added 2 commits July 28, 2026 11:05
Closes Adamantine-guild#341

- Support comma-separated RPC URLs per chain with viem fallback transport
- Add health-based endpoint deprioritization (3 failures → 60s cooldown)
- Add walletConnect connector alongside injected with graceful fallback UI
- Detect missing injected wallet and prompt for alternative connector
- Validate multi-RPC and multi-connector config shapes with clear errors
- Add tests for RPC health tracking, CSV parsing, connector validation
- Update .env.example and README with new configuration docs
@Lakes41
Lakes41 merged commit 23b322c into Adamantine-guild:main Jul 29, 2026
1 check 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.

Design a resilient multi-chain RPC failover and wallet-connector fallback layer

2 participants