feat: Implement decentralized wallet connection - Remove WalletConnect/ReOwn dependency#27
Conversation
…/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
WalkthroughThis 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related issues
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ 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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (7)
src/Navbar.tsx (1)
3-3: PreferisConnectedoveraddressfor gating UI.
UsingAccount.isConnectedreads clearer and avoids edge cases whereaddressis temporarily falsy during reconnect.Also applies to: 70-81, 83-89
src/components/ConnectWallet.tsx (5)
44-49: HardenformatBalanceagainst NaN input.
parseFloatcan yieldNaN(unexpected formatted strings); consider aNumber.isFiniteguard and a safe fallback.
113-122: Don’t close the connect modal until the connection succeeds (preserve errors / pending state).
Right nowsetIsModalOpen(false)runs immediately afterconnect(...), 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). Considerawait+ try/catch and user feedback.
154-215: Modal accessibility: add dialog semantics + focus handling.
Considerrole="dialog",aria-modal="true",aria-labelledby, initial focus, and focus trap/return-focus on close.
129-135: HandleswitchChainerrors / unsupported chains (and reflect pending).
switchChaincan 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: CoinbaseappLogoUrlmay need an absolute URL.
Some wallets expect a fully-qualified URL rather than a relative path. Consider using a config value derived fromwindow.location.origin(or document this expectation).
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
package-lock.jsonis 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 theuseBalancequery whenaddressisundefined, preventing any errors or unnecessary work. The code is already safe without an explicitenabledguard.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, andchains.scrollare all properly exported fromwagmi/chains. The import pattern (import * as chains from "wagmi/chains") is correct for wagmi v2.
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:
Solution Implemented
Replaced RainbowKit's WalletConnect-dependent configuration with a fully decentralized approach using Wagmi directly.
New Files Added
src/config/wagmi.tssrc/components/ConnectWallet.tsxModified Files
src/App.tsxsrc/Navbar.tsxpackage.json@rainbow-me/rainbowkitdependency, pinned wagmi/viem versionsREADME.mdSupported Wallet Connections
Supported Networks
20+ EVM chains including:
Mainnets:
Testnets:
Benefits
Features of Custom ConnectWallet Component
Technical Implementation Details
Wagmi Configuration (
src/config/wagmi.ts)Key Design Decisions
Migration Notes
For developers working on this codebase:
@rainbow-me/rainbowkit./components/ConnectWallet./config/wagmi.tsScreenshots
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
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.