Why this matters now: WalletScreen.tsx:18 calls refreshBalance().finally(() => setLoading(false)). If refreshBalance throws (Horizon network failure, rate limiting, account not found), the error is silently consumed. The user sees their old balance (or zero) with no indication that the data is stale. For a financial dApp, showing wrong balance data is worse than showing an error.
Problem / What: src/screens/WalletScreen.tsx:17-19 — refreshBalance().finally(() => setLoading(false)) — no .catch(), no error state. The useStellarWallet hook's refreshBalance (line 205-210) calls stellar.getBalance() which catches errors and returns '0' — so the error is double-swallowed: once in stellar.ts:40-42 (returns '0'), and once in WalletScreen (no error handling).
Key Challenges:
stellar.getBalance() currently returns '0' on error (line 40-42). This is wrong for network failures — it should distinguish between "account not found" (legitimately '0') and "network error" (should propagate).
- Add error state to
WalletScreen to display a "Failed to refresh balance" message.
- Add a retry mechanism (pull-to-refresh or retry button).
- Consider showing a "stale data" indicator when the last refresh failed.
Acceptance Criteria:
stellar.getBalance() distinguishes "account not found" from network errors.
WalletScreen displays an error message when balance refresh fails.
- User can retry the balance refresh.
- Stale balance data is visually indicated.
- Tests verify error state display and retry.
Relevant files/functions:
src/screens/WalletScreen.tsx:17-19
src/hooks/useStellarWallet.ts:205-210
src/services/stellar.ts:35-43
Out of scope: Offline balance caching, background balance refresh.
Labels: error-handling, intermediate, wallet
Why this matters now:
WalletScreen.tsx:18callsrefreshBalance().finally(() => setLoading(false)). IfrefreshBalancethrows (Horizon network failure, rate limiting, account not found), the error is silently consumed. The user sees their old balance (or zero) with no indication that the data is stale. For a financial dApp, showing wrong balance data is worse than showing an error.Problem / What:
src/screens/WalletScreen.tsx:17-19—refreshBalance().finally(() => setLoading(false))— no.catch(), no error state. TheuseStellarWallethook'srefreshBalance(line 205-210) callsstellar.getBalance()which catches errors and returns'0'— so the error is double-swallowed: once instellar.ts:40-42(returns'0'), and once inWalletScreen(no error handling).Key Challenges:
stellar.getBalance()currently returns'0'on error (line 40-42). This is wrong for network failures — it should distinguish between "account not found" (legitimately'0') and "network error" (should propagate).WalletScreento display a "Failed to refresh balance" message.Acceptance Criteria:
stellar.getBalance()distinguishes "account not found" from network errors.WalletScreendisplays an error message when balance refresh fails.Relevant files/functions:
src/screens/WalletScreen.tsx:17-19src/hooks/useStellarWallet.ts:205-210src/services/stellar.ts:35-43Out of scope: Offline balance caching, background balance refresh.
Labels:
error-handling,intermediate,wallet