From 2f7c547396727d4c0c1a84a69087ac10d130bdfc Mon Sep 17 00:00:00 2001 From: emergent-agent-e1 Date: Sat, 8 Nov 2025 17:18:18 +0000 Subject: [PATCH] auto-commit for 94c75fb4-6c64-432e-b4b1-a4d57643ebca --- frontend/src/screens/HomeScreen.tsx | 52 ++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/frontend/src/screens/HomeScreen.tsx b/frontend/src/screens/HomeScreen.tsx index d340d6c4..ca60bace 100644 --- a/frontend/src/screens/HomeScreen.tsx +++ b/frontend/src/screens/HomeScreen.tsx @@ -112,11 +112,55 @@ function HomeTab() { } function WalletTab() { + const { user } = useAuth(); + const [hezBalance, setHezBalance] = useState('Loading...'); + const [pezBalance, setPezBalance] = useState('Loading...'); + const [loading, setLoading] = useState(true); + + const TEST_WALLET = '5GgTgG9sRmPQAYU1RsTejZYnZRjwzKZKWD3awtuqjHioki45'; + + useEffect(() => { + fetchBalance(); + }, []); + + const fetchBalance = async () => { + try { + const backendUrl = process.env.EXPO_PUBLIC_BACKEND_URL || 'http://localhost:8001'; + const response = await fetch(`${backendUrl}/api/blockchain/balance`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + address: TEST_WALLET, + }), + }); + + if (response.ok) { + const data = await response.json(); + setHezBalance(parseFloat(data.hez).toFixed(2)); + setPezBalance(parseFloat(data.pez).toFixed(2)); + } else { + setHezBalance('Error'); + setPezBalance('Error'); + } + } catch (error) { + console.error('Balance fetch error:', error); + setHezBalance('Error'); + setPezBalance('Error'); + } finally { + setLoading(false); + } + }; + return ( My Wallet + + + {/* Balance Cards */} @@ -129,8 +173,8 @@ function WalletTab() { /> HEZ - 5,000.00 - ≈ $50,000 USD + {hezBalance} + Hemwelatî Token @@ -141,8 +185,8 @@ function WalletTab() { /> PEZ - 1,000.00 - ≈ $1,000 USD + {pezBalance} + Pezkuwî Token