-
-
Notifications
You must be signed in to change notification settings - Fork 17
feat(wallet): integrate RainbowKit + Wagmi to enable multi-wallet support #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,3 +22,6 @@ dist-ssr | |
| *.njsproj | ||
| *.sln | ||
| *.sw? | ||
|
|
||
|
|
||
| .env.local | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| "use client" | ||
|
|
||
| import { WagmiProvider } from "wagmi" | ||
| import { RainbowKitProvider } from "@rainbow-me/rainbowkit" | ||
| import { QueryClient, QueryClientProvider } from "@tanstack/react-query" | ||
| import { wagmiConfig } from "@/lib/wallet/config" | ||
|
|
||
| const queryClient = new QueryClient() | ||
|
|
||
| export function Providers({ children }: { children: React.ReactNode }) { | ||
| return ( | ||
| <WagmiProvider config={wagmiConfig}> | ||
| <QueryClientProvider client={queryClient}> | ||
| <RainbowKitProvider> | ||
| {children} | ||
| </RainbowKitProvider> | ||
| </QueryClientProvider> | ||
| </WagmiProvider> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| "use client" | ||
|
|
||
| import { ConnectButton } from "@rainbow-me/rainbowkit" | ||
|
|
||
| export default function WalletConnect() { | ||
| return <ConnectButton /> | ||
| } | ||
|
Comment on lines
+5
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Search for imports or usage of WalletConnect component
rg -nP --type=ts --type=tsx -C3 '\bWalletConnect\b' -g '!src/components/wallet-connect.tsx'Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 115 🏁 Script executed: #!/bin/bash
# Search for imports or usage of WalletConnect component
rg -nP -t ts -C3 '\bWalletConnect\b' -g '!src/components/wallet-connect.tsx'Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 70 🏁 Script executed: #!/bin/bash
# Check if Navbar.tsx exists and examine its imports
fd -e tsx -e ts 'Navbar' | head -5Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 102 🏁 Script executed: #!/bin/bash
# Read the first part of Navbar.tsx to see imports
head -80 src/Navbar.tsx | cat -nRepository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 3238 Remove the unused The 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { useAccount, useChainId } from "wagmi" | ||
|
|
||
| export function useWallet() { | ||
| const { address, isConnected, connector } = useAccount() | ||
| const chainId = useChainId() | ||
|
|
||
| return { | ||
| address, | ||
| isConnected, | ||
| chainId, | ||
| connector, | ||
| } | ||
| } | ||
|
Comment on lines
+3
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: rg -nP --type=ts --type=tsx -C3 '\buseWallet\b' -g '!src/hooks/useWallet.ts'Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 115 🏁 Script executed: rg -nP '\buseWallet\b' -g '*.ts' -g '*.tsx' --exclude='src/hooks/useWallet.ts'Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 499 🏁 Script executed: rg '\buseWallet\b' -g '*.ts' -g '*.tsx'Repository: StabilityNexus/Bene-FundRaising-EVM-Frontend Length of output: 140 Remove the unused This custom hook is not referenced anywhere in the codebase and is dead code. Since components import 🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| import { mainnet, polygon, optimism, arbitrum } from "wagmi/chains" | ||
|
|
||
| export const supportedChains = [ | ||
| mainnet, | ||
| polygon, | ||
| optimism, | ||
| arbitrum, | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,11 @@ | ||||||||||||||||||||||||||||
| import { getDefaultConfig } from "@rainbow-me/rainbowkit" | ||||||||||||||||||||||||||||
| import { supportedChains } from "./chains" | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| export const wagmiConfig = getDefaultConfig({ | ||||||||||||||||||||||||||||
| appName: "YourAppName", | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace placeholder The Apply this diff: export const wagmiConfig = getDefaultConfig({
- appName: "YourAppName",
+ appName: "Bene",
projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!, | ||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add runtime validation for required environment variable. The non-null assertion operator ( Apply this diff to validate the environment variable: +const projectId = process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID
+if (!projectId) {
+ throw new Error(
+ "NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID is not defined. " +
+ "Please add it to your .env.local file."
+ )
+}
+
export const wagmiConfig = getDefaultConfig({
appName: "YourAppName",
- projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID!,
+ projectId,
chains: supportedChains as const,📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||
| chains: supportedChains as const, | ||||||||||||||||||||||||||||
| ssr: true, | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move
QueryClientinstantiation into component state.Creating the
QueryClientat module level is an anti-pattern in React. The same instance will be shared across all component mounts, potentially causing stale cache issues, memory leaks, and unexpected behavior during hot reloads or in SSR contexts.Apply this diff to instantiate the client per component:
Don't forget to import
useState:"use client" +import { useState } from "react" import { WagmiProvider } from "wagmi"📝 Committable suggestion
🤖 Prompt for AI Agents