Skip to content

feat(mobile): balance card with Lens fiat value - #595

Merged
Miracle656 merged 1 commit into
Miracle656:mainfrom
Lazyartist1:feat/mobile-balance-card
Aug 9, 2026
Merged

feat(mobile): balance card with Lens fiat value#595
Miracle656 merged 1 commit into
Miracle656:mainfrom
Lazyartist1:feat/mobile-balance-card

Conversation

@Lazyartist1

Copy link
Copy Markdown
Contributor

Summary

Adds the dashboard's primary balance card (backlog item 30) — native XLM plus its fiat value from the Lens price oracle — the most-looked-at element in the product, so it loads fast and degrades gracefully.

Changes

  • lib/fetchPrice.ts — native port of the web wallet's oracle client (frontend/wallet/lib/fetchPrice.ts), reading EXPO_PUBLIC_LENS_URL. Best-effort: every failure (402 x402 gating, 404, timeout, malformed body) collapses to null. Adds pure usdValue/formatUsd helpers.
  • components/BalanceCard.tsx — self-loading card. Balance comes from Horizon (unfunded accounts read as 0, not an error) and is authoritative; the fiat line shows an em dash whenever the price feed is unavailable, so a slow/gated oracle never blocks the card. Loading, no-wallet, and error states included.
  • Mounts the card on the home route (app/index.tsx).

Acceptance

  • Shows XLM balance + USD via Lens
  • Handles price-fetch failure (fiat degrades to , balance still renders)

Testing

  • tsc --noEmit clean
  • jest lib/__tests__/fetchPrice.test.ts — 10/10 passing (USDC pin, success, non-OK/402, missing-price, network-error → null; usdValue + formatUsd)

Closes #458

@Lazyartist1
Lazyartist1 requested a review from Miracle656 as a code owner July 30, 2026 06:48
@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Lazyartist1 is attempting to deploy a commit to the miracle656's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Lazyartist1 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Miracle656

Copy link
Copy Markdown
Owner

Thanks — the BalanceCard + fetchPrice additions look useful, but this needs a rebase: it's conflicting with main on app/index.tsx, which has changed since this branch was cut. Please rebase onto current main and re-wire the balance card into the current index screen. One note: the Lens fiat value depends on the Lens price service, which is currently down (503) — make sure the card degrades gracefully (shows the token balance without fiat) when Lens is unreachable. Then I'll re-review.

@Lazyartist1
Lazyartist1 force-pushed the feat/mobile-balance-card branch 2 times, most recently from 686576a to c9f694d Compare August 9, 2026 09:25
@Lazyartist1

Copy link
Copy Markdown
Contributor Author

Hi! I've rebased this branch onto main, resolved the conflicts in app/index.tsx, and wired the BalanceCard component directly into the dashboard tab screen (app/(tabs)/dashboard.tsx) in place of the static placeholder balance hero. I've also verified that the card degrades gracefully by showing an em dash (—) for the fiat value when the Lens oracle service is down or unreachable. Ready for review!

@Miracle656

Copy link
Copy Markdown
Owner

Thanks for the rebase — moving the balance card into (tabs)/dashboard.tsx is the right call. Unfortunately it's conflicting again through no fault of yours: #587 (pull-to-refresh) landed on dashboard.tsx right after you pushed. One more rebase onto current main and resolving dashboard.tsx should clear it (your change is only ~7 lines, so it should be quick). While you're there, please double-check the card degrades gracefully when the Lens price service is unreachable (it's currently returning 503) — show the token balance without the fiat value rather than erroring. Then I'll merge.

@Lazyartist1
Lazyartist1 force-pushed the feat/mobile-balance-card branch from c9f694d to 6bf3b1a Compare August 9, 2026 10:59
@Lazyartist1

Copy link
Copy Markdown
Contributor Author

Hi! I've rebased this branch onto the latest main (which now includes PR #587) and resolved the conflict in app/(tabs)/dashboard.tsx. The BalanceCard is successfully wired into the new dashboard screen alongside the pull-to-refresh and polling logic. Ready for merge!

Show the primary XLM balance on the dashboard the moment the app opens,
with its USD value from the Lens price oracle. The balance is loaded from
Horizon (unfunded accounts read as zero) and is always shown once ready;
the fiat line degrades to an em dash whenever the oracle is slow, gated, or
offline, so pricing never blocks the card.

Adds lib/fetchPrice.ts (native port of the web wallet's oracle client) and
components/BalanceCard.tsx, and mounts the card on the home route.

Closes Miracle656#458
@Lazyartist1
Lazyartist1 force-pushed the feat/mobile-balance-card branch from 6bf3b1a to debfe4c Compare August 9, 2026 11:01
@Lazyartist1

Copy link
Copy Markdown
Contributor Author

Hi! I've updated the PR with a new unit test verifying that non-native assets are correctly formatted and encoded as CODE:ISSUER in the Lens price oracle requests, and verified that both fetchPrice and formatUsd/usdValue handle these assets generically. Ready for review!

@Miracle656
Miracle656 merged commit 3d51809 into Miracle656:main Aug 9, 2026
11 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

30. Balance card

2 participants