From 54199d425adcf6e152cdb3d49e2859aea4556675 Mon Sep 17 00:00:00 2001 From: JamesVictor-o Date: Sat, 26 Jul 2025 13:50:35 +0100 Subject: [PATCH 1/2] fix: implement real wallet connection and address display functionality --- .../anonymous-profile/wallet-card.tsx | 100 ++++++++---------- src/components/home/hero.tsx | 4 +- 2 files changed, 45 insertions(+), 59 deletions(-) diff --git a/src/components/anonymous-profile/wallet-card.tsx b/src/components/anonymous-profile/wallet-card.tsx index 902c83c..f8318b4 100644 --- a/src/components/anonymous-profile/wallet-card.tsx +++ b/src/components/anonymous-profile/wallet-card.tsx @@ -1,77 +1,63 @@ "use client"; import { Copy, LogOut, Wallet } from "lucide-react"; -import { motion } from "motion/react"; -import { useState } from "react"; -import { Walletvariant } from "./motion"; +import { useToast } from "@/components/ui/toast"; +import { useAccount, useDisconnect } from "@starknet-react/core"; -function WalletCard() { - const [walletConnected, setWalletConnected] = useState(true); +function truncateAddress(address: string) { + if (!address) return ""; + return address.slice(0, 6) + "..." + address.slice(-4); +} - const walletAddress = "0x742d35Cc6634C0532925a3b8D4C2C4e"; +function WalletCard() { + const { address, isConnected } = useAccount(); + const { disconnect } = useDisconnect(); + const { toast } = useToast(); const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); + toast.success("Copied to clipboard!"); }; - const disconnectWallet = () => { - setWalletConnected(false); - }; - - return ( - -
+ if (!isConnected) { + return ( +
Wallet Connection
+
Wallet not connected.
+ ); + } + return ( +
- {walletConnected ? ( -
-
-
-
-
-

Connected Wallet

-
-
-

{walletAddress}...

-
-
-
-
- - -
-
- ) : ( -
- -

No wallet connected

- -
- )} +
+ + Wallet Connection +
+
+ + {truncateAddress(address!)} + + + +
- +
); } - export default WalletCard; diff --git a/src/components/home/hero.tsx b/src/components/home/hero.tsx index 35b482c..9d61f45 100644 --- a/src/components/home/hero.tsx +++ b/src/components/home/hero.tsx @@ -4,7 +4,7 @@ import { Button } from "@/components/ui/button"; import { useRouter } from "next/navigation"; const Hero = () => { - const router = useRouter() + const router = useRouter(); return (
@@ -30,7 +30,7 @@ const Hero = () => {