Skip to content

refactor: Remove RainbowKit and WalletConnect cloud dependencies (EIP-6963 Migration) #90

@kushbosamiya

Description

@kushbosamiya

1. Problem

The frontend relies on @rainbow-me/rainbowkit and WalletConnect/Reown infrastructure, which introduces a cloud dependency and a Single Point of Failure (SPOF). This violates the core architectural directive of zero cloud dependencies for wallet connections.

  • Specifically, lib/config.ts, providers/providers.tsx, and components/ui/ConnectBtn.tsx are tightly coupled to NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID.
  • This introduces external relay servers and potential centralized censorship vectors.

2. Current Behavior

  • Reproduction: Connecting a wallet via the UI relies on <RainbowKitProvider> and <ConnectButton.Custom>. Mobile and general connections attempt to ping WalletConnect's relay endpoints.
  • Evidence: lib/config.ts currently imports getDefaultConfig and requires a WalletConnect projectId which actively makes network calls to Reown infrastructure upon initialization and connection.
  • Comparison: Deleting just the projectId breaks the components. We need a complete, atomic replacement of the connection layer to guarantee pure client-side wallet discovery.
flowchart TD
    %% ===== STYLES (Soft + Minimal) =====
    classDef base fill:#F8FAFC,stroke:#CBD5E1,stroke-width:1.5px,color:#0F172A
    classDef action fill:#E0F2FE,stroke:#7DD3FC,color:#075985
    classDef decision fill:#FEF3C7,stroke:#FCD34D,color:#78350F
    classDef success fill:#ECFDF5,stroke:#86EFAC,color:#065F46
    classDef error fill:#FEE2E2,stroke:#FCA5A5,color:#7F1D1D
    classDef external fill:#F1F5F9,stroke:#CBD5E1,color:#334155

    %% ===== FLOW =====
    A([Open pool page]):::base --> B[Enter amount]:::action

    B --> C{WETH balance sufficient}:::decision

    C -->|Yes| D[Check allowance]:::action
    C -->|No| E[Insufficient balance]:::error

    E --> F[Open Etherscan]:::external
    F --> G[Call WETH deposit]:::external
    G --> H[Return to app]:::external

    H --> B

    D --> I{Allowance sufficient}:::decision

    I -->|Yes| J[Submit buy]:::success
    I -->|No| K[Approve WETH]:::action

    K --> J

Loading

3. Proposed Solution

Migrate to pure wagmi v2 using multiInjectedProviderDiscovery: true (EIP-6963) to allow decentralized, peer-to-peer browser wallet discovery without external APIs.

  • Uninstall @rainbow-me/rainbowkit and any @walletconnect/* dependencies.
  • Update lib/config.ts to use createConfig from wagmi without the WalletConnect connector.
  • Rebuild ConnectBtn.tsx natively using useConnect, useAccount, and useDisconnect to maintain functionality and visual flow.
  • Remove NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID from .env.example.
flowchart TD
    %% ===== STYLES =====
    classDef base fill:#F8FAFC,stroke:#CBD5E1,stroke-width:1.5px,color:#0F172A
    classDef action fill:#E0F2FE,stroke:#7DD3FC,color:#075985
    classDef remove fill:#FEE2E2,stroke:#FCA5A5,color:#7F1D1D
    classDef success fill:#ECFDF5,stroke:#86EFAC,color:#065F46

    %% ===== FLOW =====
    A([Start]):::base --> B[Remove WalletConnect + RainbowKit]:::remove
    B --> C[Setup wagmi v2 config]:::action
    C --> D[Enable EIP-6963 discovery]:::action
    D --> E[Build Connect Button using wagmi hooks]:::action
    E --> F[Browser detects wallets]:::base
    F --> G[User connects wallet]:::success
    G --> H([Direct connection established]):::success
Loading

4. Acceptance Criteria

  • Wallet connection functions completely client-side with no network calls to *.walletconnect.com or *.reown.com.
  • @rainbow-me/rainbowkit package successfully removed from package.json.
  • Custom connect button built using wagmi hooks correctly handles connect, network switching, and disconnects.
  • No behavioral regressions.
  • Verified locally via build/lint/test.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions