From 13e03d338991b73cc76ae1504f7b58a066f8f44c Mon Sep 17 00:00:00 2001 From: devfoma Date: Tue, 28 Apr 2026 10:45:55 -0700 Subject: [PATCH 1/2] feat: extract and standardize CopyButton component and refactor usages --- app/connect/page.tsx | 20 +------------------- components/ui/copy-button.tsx | 8 ++++---- components/wallet/ConnectWalletButton.tsx | 10 +--------- 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/app/connect/page.tsx b/app/connect/page.tsx index 498619b..26bdbed 100644 --- a/app/connect/page.tsx +++ b/app/connect/page.tsx @@ -8,7 +8,6 @@ import { Zap, Globe, ArrowLeft, - Copy, Check, ExternalLink, AlertCircle, @@ -60,7 +59,6 @@ export default function ConnectWalletPage() { error, } = useStellar(); - const [copied, setCopied] = useState(false); const [step, setStep] = useState("intro"); const [showDisconnectConfirm, setShowDisconnectConfirm] = useState(false); const [errorExpanded, setErrorExpanded] = useState(false); @@ -92,13 +90,6 @@ export default function ConnectWalletPage() { await connect(); }; - const handleCopy = async () => { - if (publicKey) { - await navigator.clipboard.writeText(publicKey); - setCopied(true); - setTimeout(() => setCopied(false), 2000); - } - }; const handleDisconnect = () => { disconnect(); @@ -494,7 +485,7 @@ export default function ConnectWalletPage() { - {copied && ( - - Address copied to clipboard - - )} {/* Fund testnet */} diff --git a/components/ui/copy-button.tsx b/components/ui/copy-button.tsx index c51b209..4998702 100644 --- a/components/ui/copy-button.tsx +++ b/components/ui/copy-button.tsx @@ -9,14 +9,14 @@ interface CopyButtonProps { value: string; label?: string; className?: string; - iconSize?: number; + size?: number; } export default function CopyButton({ value, label = "Copy to clipboard", className = "", - iconSize = 16, + size = 16, }: CopyButtonProps) { const [copied, setCopied] = useState(false); const timeoutRef = useRef(null); @@ -62,7 +62,7 @@ export default function CopyButton({ exit={{ opacity: 0, scale: 0.5, rotate: 45 }} transition={{ duration: 0.15 }} > - + ) : ( - + )} diff --git a/components/wallet/ConnectWalletButton.tsx b/components/wallet/ConnectWalletButton.tsx index 8a0db90..7a337b7 100644 --- a/components/wallet/ConnectWalletButton.tsx +++ b/components/wallet/ConnectWalletButton.tsx @@ -3,7 +3,7 @@ import React, { useState, useRef, useEffect } from "react"; import { useRouter } from "next/navigation"; import { motion, AnimatePresence } from "framer-motion"; -import { Wallet, LogOut, Copy, Check, ChevronDown, ExternalLink, AlertCircle, Loader2, Coins, AlertTriangle, Maximize2, Minimize2 } from "lucide-react"; +import { Wallet, LogOut, Copy, ChevronDown, ExternalLink, AlertCircle, Loader2, Coins, AlertTriangle, Maximize2, Minimize2 } from "lucide-react"; import { useStellarAuth } from "@/context/StellarContext"; import { ConfirmDialog } from "@/components/ui/confirm-dialog"; import { BottomSheet } from "@/components/ui/bottom-sheet"; @@ -31,7 +31,6 @@ function toDisplayNetworkName(network: "TESTNET" | "MAINNET"): string { export default function ConnectWalletButton() { const { publicKey, isConnected, connect, disconnect, isConnecting, isFreighterInstalled, isRestoring, error } = useStellarAuth(); const [isOpen, setIsOpen] = useState(false); - const [copied, setCopied] = useState(false); const [errorExpanded, setErrorExpanded] = useState(false); const { balance, isLoading: isBalanceLoading } = useWalletBalance(publicKey, isOpen); const [walletNetwork, setWalletNetwork] = useState<"TESTNET" | "MAINNET" | null>(null); @@ -57,13 +56,6 @@ export default function ConnectWalletButton() { ? `${publicKey.slice(0, 4)}...${publicKey.slice(-4)}` : ""; - const handleCopy = async () => { - if (publicKey) { - await navigator.clipboard.writeText(publicKey); - setCopied(true); - setTimeout(() => setCopied(false), 2000); - } - }; const handleDisconnect = () => { disconnect(); From 45894fbb956c87db733f4e3404efb6a1ab3db46f Mon Sep 17 00:00:00 2001 From: devfoma Date: Tue, 28 Apr 2026 12:18:31 -0700 Subject: [PATCH 2/2] feat: show success toast on wallet connection --- app/layout.tsx | 13 ++++++++----- components/ui/app-shell.tsx | 13 +++++-------- context/StellarContext.tsx | 4 ++++ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/layout.tsx b/app/layout.tsx index b0270b2..fb76bd5 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -4,6 +4,7 @@ import "@/lib/env"; import { AppShell } from "@/components/ui/app-shell"; import { PageTransition } from "@/components/ui/page-transition"; import { StellarProvider } from "@/context/StellarContext"; +import { ToastProvider } from "@/components/ui/toast-provider"; import "./globals.css"; const inter = Inter({ @@ -56,11 +57,13 @@ export default function RootLayout({ - - - {children} - - + + + + {children} + + + ); diff --git a/components/ui/app-shell.tsx b/components/ui/app-shell.tsx index f0f0376..96f910a 100644 --- a/components/ui/app-shell.tsx +++ b/components/ui/app-shell.tsx @@ -4,7 +4,6 @@ import React, { useState, useEffect } from "react"; import { ThemeProvider } from "@/components/ui/theme-provider"; import { DottedSurface } from "@/components/ui/dotted-surface"; import { useStellar } from "@/context/StellarContext"; -import { ToastProvider } from "@/components/ui/toast-provider"; import { SkipLink } from "@/components/ui/skip-link"; import { ErrorBoundary } from "@/components/ui/error-boundary"; import OfflineBanner from "./offline-banner"; @@ -57,13 +56,11 @@ export function AppShell({ children }: { children: React.ReactNode }) { )}