-
Notifications
You must be signed in to change notification settings - Fork 23
feat(components): extract WalletConnectionGuard shared component (#4) #98
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
Closed
devcarole
wants to merge
3
commits into
Fundable-Protocol:main
from
devcarole:feature/4-wallet-connection-guard
Closed
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
apps/web/src/components/modules/wallet/WalletConnectionGuard.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| "use client"; | ||
|
|
||
| import React, { type ReactNode } from "react"; | ||
| import { Wallet } from "lucide-react"; | ||
|
|
||
| import { Button } from "@/components/ui/button"; | ||
| import { cn } from "@/lib/utils"; | ||
| import { useWallet } from "@/providers/StellarWalletProvider"; | ||
|
|
||
| interface WalletConnectionGuardProps { | ||
| children: ReactNode; | ||
| contextLabel?: string; | ||
| } | ||
|
|
||
| export function WalletConnectionGuard({ | ||
| children, | ||
| contextLabel, | ||
| }: WalletConnectionGuardProps) { | ||
| const { address, openModal } = useWallet(); | ||
|
|
||
| if (!address) { | ||
devcarole marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return ( | ||
| <div className="flex min-h-[60vh] items-center justify-center px-4 py-10"> | ||
| <div className="relative w-full max-w-xl overflow-hidden rounded-3xl border border-white/10 bg-fundable-mid-dark p-10 text-center shadow-[0_0_40px_rgba(130,86,255,0.12)]"> | ||
| <div className="pointer-events-none absolute inset-0 bg-gradient-to-br from-white/5 via-transparent to-fundable-purple-2/10" /> | ||
| <div className="relative z-10 space-y-6"> | ||
| <div className="mx-auto flex h-16 w-16 items-center justify-center rounded-full border border-white/10 bg-white/5"> | ||
| <Wallet className="h-7 w-7 text-fundable-purple-2" /> | ||
| </div> | ||
| <div className="space-y-2"> | ||
| <h2 className="text-2xl font-semibold text-white"> | ||
| Connect your wallet to continue | ||
| </h2> | ||
| <p className="text-fundable-light-grey"> | ||
| {contextLabel || "You'll need a Stellar wallet connected to use this feature."} | ||
| </p> | ||
| </div> | ||
| <Button variant="gradient" size="lg" onClick={openModal}> | ||
| Connect Wallet | ||
| </Button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| } | ||
|
|
||
| export default WalletConnectionGuard; | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion | 🟠 Major
🧩 Analysis chain
🏁 Script executed:
Repository: Fundable-Protocol/stellar_client_os
Length of output: 4286
🏁 Script executed:
fd -type f -name '*WalletConnectionGuard*' --exec cat {}Repository: Fundable-Protocol/stellar_client_os
Length of output: 249
🏁 Script executed:
fd -t f 'WalletConnectionGuard' --exec cat {}Repository: Fundable-Protocol/stellar_client_os
Length of output: 1869
Remove redundant wallet connection guard.
Both
ProtectedRoute(line 387) andWalletConnectionGuard(line 388) checkuseWallet().addressand render a wallet connection prompt when disconnected. SinceProtectedRoutewrapsWalletConnectionGuard, it will always intercept first, makingWalletConnectionGuardunreachable when the wallet is disconnected.Remove one of the wrappers. If migrating to
WalletConnectionGuard, removeProtectedRoute. If keepingProtectedRoutefor its customization options (title, description, actionLabel, container/card classes), removeWalletConnectionGuardfrom this page.🤖 Prompt for AI Agents