Description
The deposit experience is entirely mocked: vaultBalance and walletBalance are hard-coded in App.tsx (src/App.tsx:282-283), the transaction hash is fabricated by createMockHash() (src/App.tsx:123-128), and handleApproveTransaction simulates approval/pending/confirmed purely with setTimeout (src/App.tsx:399-441). The landing copy and consumer steps already promise "Connect wallet" and on-chain settlement (src/App.tsx:52-69), and the explorer link points at Stellar testnet (src/App.tsx:97), so the UI is ready for a real wallet.
This issue introduces a Freighter wallet connection that supplies the real account address and surfaces a genuine network/connection state, replacing the fabricated wallet balance and laying the groundwork for real signing.
Requirements and context
- Add
@stellar/freighter-api and create src/hooks/useFreighter.ts exposing isConnected, publicKey, connect(), and isAvailable (whether the extension is installed).
- Add a "Connect wallet" control in the topbar (
src/App.tsx:475-482) that reflects connection state and the truncated public key.
- When connected, source
walletBalance from the account rather than the hard-coded 1260.5 (src/App.tsx:283); keep a clearly-labeled mock fallback when Freighter is unavailable so the demo still runs.
- Gate
handleApproveTransaction (src/App.tsx:399) on a connected wallet, and replace createMockHash with the signed transaction hash when a real signing path is wired (a clearly-marked mock may remain behind a feature flag for now).
- Non-functional: handle the "Freighter not installed" and "user rejected" cases with the existing
error-card / status-banner UI (src/App.tsx:894-902); never block the rest of the app when the wallet is absent.
Acceptance criteria
Suggested execution
1. Fork the repo and create a branch — git checkout -b feature/freighter-wallet-integration.
2. Implement changes — src/hooks/useFreighter.ts, src/App.tsx (topbar + deposit gating), and the deposit modal balance source.
3. Write/extend tests — this repo has no test runner configured. Add Vitest + @testing-library/react + jsdom and a "test": "vitest run" script, then test useFreighter against a mocked @stellar/freighter-api for connected, rejected, and not-installed states.
4. Test and commit —
npm install
npm run dev # verify connect flow with and without the extension
npm run build
npm run test
Example commit message
feat(wallet): integrate Freighter and replace mock wallet balance in deposit flow
Guidelines
- The new hook must reach ≥90% line coverage.
- Document the wallet setup in the README, keep the connect button keyboard-accessible, and never crash when the extension is absent.
- Timeframe: 96 hours.
Description
The deposit experience is entirely mocked:
vaultBalanceandwalletBalanceare hard-coded inApp.tsx(src/App.tsx:282-283), the transaction hash is fabricated bycreateMockHash()(src/App.tsx:123-128), andhandleApproveTransactionsimulates approval/pending/confirmed purely withsetTimeout(src/App.tsx:399-441). The landing copy and consumer steps already promise "Connect wallet" and on-chain settlement (src/App.tsx:52-69), and the explorer link points at Stellar testnet (src/App.tsx:97), so the UI is ready for a real wallet.This issue introduces a Freighter wallet connection that supplies the real account address and surfaces a genuine network/connection state, replacing the fabricated wallet balance and laying the groundwork for real signing.
Requirements and context
@stellar/freighter-apiand createsrc/hooks/useFreighter.tsexposingisConnected,publicKey,connect(), andisAvailable(whether the extension is installed).src/App.tsx:475-482) that reflects connection state and the truncated public key.walletBalancefrom the account rather than the hard-coded1260.5(src/App.tsx:283); keep a clearly-labeled mock fallback when Freighter is unavailable so the demo still runs.handleApproveTransaction(src/App.tsx:399) on a connected wallet, and replacecreateMockHashwith the signed transaction hash when a real signing path is wired (a clearly-marked mock may remain behind a feature flag for now).error-card/status-bannerUI (src/App.tsx:894-902); never block the rest of the app when the wallet is absent.Acceptance criteria
useFreighterhook implemented and unit-tested with a mocked@stellar/freighter-api.G...address.walletBalancereflects the connected account, with a labeled fallback when Freighter is missing./billing(src/App.tsx:581-594).npm run buildpasses.Suggested execution
1. Fork the repo and create a branch —
git checkout -b feature/freighter-wallet-integration.2. Implement changes —
src/hooks/useFreighter.ts,src/App.tsx(topbar + deposit gating), and the deposit modal balance source.3. Write/extend tests — this repo has no test runner configured. Add Vitest +
@testing-library/react+jsdomand a"test": "vitest run"script, then testuseFreighteragainst a mocked@stellar/freighter-apifor connected, rejected, and not-installed states.4. Test and commit —
Example commit message
Guidelines