Skip to content

feat: Implement decentralized wallet connection - Remove WalletConnect/ReOwn dependency#27

Open
kartikeyg0104 wants to merge 1 commit intoStabilityNexus:mainfrom
kartikeyg0104:feat/decentralized-wallet-connection
Open

feat: Implement decentralized wallet connection - Remove WalletConnect/ReOwn dependency#27
kartikeyg0104 wants to merge 1 commit intoStabilityNexus:mainfrom
kartikeyg0104:feat/decentralized-wallet-connection

Conversation

@kartikeyg0104
Copy link
Copy Markdown

@kartikeyg0104 kartikeyg0104 commented Dec 14, 2025

Team- Big bull
Closes #19

Summary

This PR addresses the decentralization concerns with the current wallet connection implementation by removing the dependency on ReOwn's WalletConnect SDKs.

Problem Statement

The project's previous reliance on ReOwn's WalletConnect SDKs posed decentralization risks:

Risk Description
Centralization Required a centralized projectId from WalletConnect/ReOwn
Usage limits Subject to rate limiting from external services
Potential censorship Single point of failure that could block users
Service dependency Application functionality tied to third-party uptime

Solution Implemented

Replaced RainbowKit's WalletConnect-dependent configuration with a fully decentralized approach using Wagmi directly.

New Files Added

File Description
src/config/wagmi.ts Custom Wagmi configuration with direct wallet connectors
src/components/ConnectWallet.tsx Custom wallet connection UI component with full functionality

Modified Files

File Changes
src/App.tsx Removed RainbowKit provider, uses new decentralized wagmi config
src/Navbar.tsx Replaced RainbowKit ConnectButton with custom ConnectWallet component
package.json Removed @rainbow-me/rainbowkit dependency, pinned wagmi/viem versions
README.md Added documentation for decentralized wallet integration

Supported Wallet Connections

Wallet Type Connection Method Notes
MetaMask Injected (Browser Extension) Most popular wallet
Brave Wallet Injected (Browser Extension) Built into Brave browser
Trust Wallet Injected (Browser Extension) Mobile-first wallet
Other Browser Wallets Injected (EIP-1193) Any EIP-1193 compliant wallet
Coinbase Wallet Direct SDK Integration No WalletConnect relay

Supported Networks

20+ EVM chains including:

Mainnets:

  • Citrea Testnet (primary)
  • Ethereum Mainnet
  • Polygon
  • Arbitrum
  • Optimism
  • Base
  • BSC
  • Avalanche
  • Fantom
  • Gnosis
  • zkSync
  • Linea
  • Scroll

Testnets:

  • Sepolia
  • Mumbai
  • Arbitrum Sepolia
  • Optimism Sepolia
  • Base Sepolia
  • BSC Testnet
  • Avalanche Fuji
  • Fantom Testnet

Benefits

Benefit Description
✅ No external service dependencies Works without any third-party relay servers
✅ No API keys or project IDs required Zero configuration needed
✅ Works offline once connected No ongoing network requirements to relay
✅ Cannot be rate-limited or censored Direct peer-to-peer connection
✅ Enhanced 'unstoppability' True decentralization achieved
✅ Reduced bundle size Removed RainbowKit (~50KB+ savings)
✅ Better performance No relay server latency

Features of Custom ConnectWallet Component

  • 🎨 Dark theme matching the existing UI design
  • 🔄 Network/chain switching with visual feedback
  • 📋 Copy address to clipboard functionality
  • 🔍 View on block explorer link for each connected chain
  • 📱 Responsive design works on mobile & desktop
  • ⌨️ Keyboard accessibility (Escape to close modals)
  • 🔒 Click outside to close modal behavior
  • 💰 Balance display showing native token balance
  • 🌐 Multi-chain indicator showing current network

Technical Implementation Details

Wagmi Configuration (src/config/wagmi.ts)

// Direct connectors without WalletConnect
connectors: [
  injected({ shimDisconnect: true }),
  coinbaseWallet({ appName: "Bene Fundraising" }),
]

Key Design Decisions

  1. Injected Connector First: Prioritizes browser extension wallets for best UX
  2. Multi-injection Discovery: Automatically detects multiple installed wallets
  3. No SSR Dependency: Removed SSR flag since we're using client-side rendering
  4. Optimized Query Client: Added staleTime and retry configuration for better caching

Migration Notes

For developers working on this codebase:

  1. RainbowKit imports removed: No longer use @rainbow-me/rainbowkit
  2. New ConnectWallet component: Import from ./components/ConnectWallet
  3. Config location changed: Wagmi config now in ./config/wagmi.ts
  4. No projectId needed: Remove any WalletConnect projectId references

Screenshots

Screenshot 2025-12-14 at 7 09 06 AM

Goal Achieved

Enhanced the project's unstoppability and resilience by removing all centralized dependencies from the wallet connection flow.

Summary by CodeRabbit

Release Notes

  • New Features

    • Decentralized wallet integration with direct browser extension connections
    • New wallet selection interface with chain switching capabilities
    • Account menu featuring address management, balance display, and disconnect functionality
    • Support for multiple wallet types including injected wallets and Coinbase Wallet
  • Documentation

    • Added comprehensive guide on decentralized wallet connections and supported networks

✏️ Tip: You can customize this high-level summary in your review settings.

…/ReOwn dependency

This commit removes the dependency on RainbowKit and WalletConnect/ReOwn SDKs,
which posed decentralization risks including centralization, usage limits,
and potential censorship.

Changes:
- Created custom wagmi configuration with direct wallet connectors
- Added custom ConnectWallet component with chain switching support
- Removed @rainbow-me/rainbowkit dependency
- Updated App.tsx to use the new decentralized configuration
- Updated Navbar.tsx to use the custom ConnectWallet component
- Updated README.md with documentation about the decentralized approach

Supported wallet connections:
- Injected wallets (MetaMask, Brave, Trust Wallet, etc.)
- Coinbase Wallet (direct SDK integration)

Benefits:
- No external service dependencies
- No API keys or project IDs required
- Works offline once wallet is connected
- Cannot be rate-limited or censored
- Enhanced 'unstoppability' and resilience
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 14, 2025

Walkthrough

This PR removes RainbowKit and WalletConnect/ReOwn SDK dependencies, replacing them with a decentralized wallet integration using wagmi. It introduces a new ConnectWallet component supporting direct browser extension wallets and Coinbase Wallet, updated dependency versions, and corresponding documentation.

Changes

Cohort / File(s) Summary
Documentation & Dependencies
README.md, package.json
Added "Decentralized Wallet Integration" section documenting direct wallet connections without WalletConnect/ReOwn SDKs; removed @rainbow-me/rainbowkit dependency, updated viem to ^2.21.0 and wagmi to ^2.12.0.
Wagmi Configuration & Custom Wallet Component
src/config/wagmi.ts, src/components/ConnectWallet.tsx
Created new wagmi configuration module with consolidated chain list, injected and Coinbase Wallet connectors, and HTTP transports; introduced ConnectWallet component with wallet selection UI, connection flow, chain switching, account menu, balance fetching, and local modal/menu handling.
App Integration
src/App.tsx, src/Navbar.tsx
Removed RainbowKit setup and UI wrapper from App; integrated wagmiConfig and added dedicated QueryClient with 5-minute staleTime; replaced RainbowKit ConnectButton with custom ConnectWallet component in Navbar.
Build Configuration
tsconfig.app.tsbuildinfo
Updated build metadata root array to include new source files and paths.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant ConnectWallet as ConnectWallet Component
    participant Wagmi as Wagmi Hook
    participant Wallet as Browser Wallet
    participant Chain as Chain Switcher

    rect rgb(220, 240, 255)
    Note over User,Wallet: Wallet Connection Phase
    User->>ConnectWallet: Select wallet from list
    ConnectWallet->>Wagmi: useConnect()
    Wagmi->>Wallet: Trigger wallet connection
    Wallet-->>Wagmi: User approves connection
    Wagmi-->>ConnectWallet: Connection established
    ConnectWallet->>ConnectWallet: Fetch balance & display account
    end

    rect rgb(240, 220, 255)
    Note over User,Chain: Chain Switching Phase
    User->>ConnectWallet: Open chain selector
    ConnectWallet->>ConnectWallet: Show allChains dropdown
    User->>ConnectWallet: Select new chain
    ConnectWallet->>Wagmi: useSwitchChain()
    Wagmi->>Wallet: Request chain switch
    Wallet-->>Wagmi: Chain switched
    Wagmi-->>ConnectWallet: Update active chain
    ConnectWallet->>ConnectWallet: Refresh UI with new chain
    end

    rect rgb(240, 255, 240)
    Note over User,ConnectWallet: Account Management Phase
    User->>ConnectWallet: Account menu (copy, view, disconnect)
    ConnectWallet->>ConnectWallet: Execute action
    ConnectWallet-->>User: Address copied / Explorer opened / Disconnected
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • src/components/ConnectWallet.tsx: Substantial new component with complex state management (wallet selection modal, chain switcher popover, account menu), balance fetching, address formatting, and external-click/Escape key handling—requires careful review of interaction flows and edge cases.
  • src/config/wagmi.ts: New configuration module defining chain list, transports, and connector setup; verify correctness of chain IDs, HTTP RPC endpoints, and connector configuration.
  • src/App.tsx: Significant changes removing RainbowKit infrastructure and introducing wagmi integration; verify QueryClient configuration (staleTime, retry settings) is appropriate and no initialization issues arise.
  • Dependency updates in package.json: Confirm viem ^2.21.0 and wagmi ^2.12.0 are compatible with the new component and configuration logic.

Possibly related issues

Poem

🐰 No more ReOwn chains holding us tight,
Direct wallets hop free through the night,
Wagmi whispers, no middlemen in sight,
Decentralized dreams burning bright—
Bunny hops cheering this radical flight! 🌙

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title directly and accurately summarizes the main change: replacing WalletConnect/ReOwn-based wallet integration with a decentralized wallet connection implementation using Wagmi, which aligns perfectly with the changeset across all modified files.
✨ 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.

Copy link
Copy Markdown

@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: 4

🧹 Nitpick comments (7)
src/Navbar.tsx (1)

3-3: Prefer isConnected over address for gating UI.
Using Account.isConnected reads clearer and avoids edge cases where address is temporarily falsy during reconnect.

Also applies to: 70-81, 83-89

src/components/ConnectWallet.tsx (5)

44-49: Harden formatBalance against NaN input.
parseFloat can yield NaN (unexpected formatted strings); consider a Number.isFinite guard and a safe fallback.


113-122: Don’t close the connect modal until the connection succeeds (preserve errors / pending state).
Right now setIsModalOpen(false) runs immediately after connect(...), which hides errors and the pending spinner UX. Close only after success.

Also applies to: 155-206


137-141: Handle clipboard failures (and await the promise).
navigator.clipboard.writeText(...) can throw/reject (permissions, non-HTTPS). Consider await + try/catch and user feedback.


154-215: Modal accessibility: add dialog semantics + focus handling.
Consider role="dialog", aria-modal="true", aria-labelledby, initial focus, and focus trap/return-focus on close.


129-135: Handle switchChain errors / unsupported chains (and reflect pending).
switchChain can fail (connector limitations, user rejection). Consider showing errors and disabling the menu during pending.

Also applies to: 240-265

src/config/wagmi.ts (1)

73-76: Coinbase appLogoUrl may need an absolute URL.
Some wallets expect a fully-qualified URL rather than a relative path. Consider using a config value derived from window.location.origin (or document this expectation).

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b816112 and 834f928.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (7)
  • README.md (3 hunks)
  • package.json (1 hunks)
  • src/App.tsx (1 hunks)
  • src/Navbar.tsx (2 hunks)
  • src/components/ConnectWallet.tsx (1 hunks)
  • src/config/wagmi.ts (1 hunks)
  • tsconfig.app.tsbuildinfo (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
src/config/wagmi.ts (1)
src/CitreaTestnet.ts (1)
  • citreaTestnet (3-13)
src/components/ConnectWallet.tsx (2)
src/config/wagmi.ts (1)
  • allChains (84-84)
src/CitreaTestnet.ts (1)
  • citreaTestnet (3-13)
src/Navbar.tsx (1)
src/components/ConnectWallet.tsx (1)
  • ConnectWallet (58-329)
src/App.tsx (1)
src/config/wagmi.ts (1)
  • wagmiConfig (65-81)
🔇 Additional comments (5)
src/App.tsx (2)

27-35: QueryClient defaults look reasonable.
staleTime + limited retries should reduce noisy refetching.


39-41: No action needed—WagmiProvider/QueryClientProvider nesting is correct.
The current setup with WagmiProvider wrapping QueryClientProvider matches wagmi v2.12.0 requirements.

package.json (1)

35-36: The versions are compatible: wagmi v2.12.0 requires viem@2.x as a peer dependency, and viem@2.21.0 satisfies that constraint. Caret ranges are acceptable here and align with standard npm practices for peer dependencies. No evidence suggests tighter pinning is required for this pair.

src/components/ConnectWallet.tsx (1)

74-80: No action needed. wagmi v2.12.0 automatically disables the useBalance query when address is undefined, preventing any errors or unnecessary work. The code is already safe without an explicit enabled guard.

src/config/wagmi.ts (1)

23-45: All wagmi chain exports are available in wagmi@2.12.0—no build-time failures expected.

Verified that chains.polygonMumbai, chains.fantomTestnet, chains.zkSync, chains.linea, and chains.scroll are all properly exported from wagmi/chains. The import pattern (import * as chains from "wagmi/chains") is correct for wagmi v2.

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.

Integrate Alternative Wallet Connectors (e.g., RainbowKit) to Decouple from ReOwn

2 participants