Skip to content

fix(balances): show "--" for the total when no token has a price - #3077

Merged
JakeUrban merged 4 commits into
masterfrom
claude/confident-gauss-zms0vo
Nov 11, 2026
Merged

JakeUrban merged 4 commits into
masterfrom
claude/confident-gauss-zms0vo

Conversation

@JakeUrban

@JakeUrban JakeUrban commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

What

The Home total balance now shows "--" when no held token has a price. It shows a partial total when at least one held token has a price. The account list in the account sheet uses the same rule.

Prices returned Before After
Each price is null $0.00 --
Held tokens have no price, but a token the account does not hold has a price $0.00 --
Some prices are null Sum of priced tokens Sum of priced tokens (no change)
Each token has a price Full total Full total (no change)
No price map, or an empty map -- -- (no change)

Changes:

  • getTotalUsd (extension/src/popup/helpers/balance.ts) now returns { totalUsd, hasPrices } from one lookup. hasPrices is true when at least one held balance has a price. A price for a token that the account does not hold does not count.
  • getTotalUsdLabel now takes a hasPrices boolean, not the price map. The Home view and useGetWalletsData pass the value from getTotalUsd.

Why

The backend can return a key for each token with a null price. This occurs when the price service has a problem. The old check saw keys in the map and showed the sum of 0 as "$0.00". "$0.00" tells the user that the account has no value. That is not correct. The token rows already show "--" in this case, so the total did not agree with the rows.

The price cache can also keep prices for tokens the account does not hold, such as a swap destination. The total does not add these prices, so the check must ignore them too. One lookup gives both values, so the label and the total always count the same prices.

freighter-mobile already uses this rule (hasPrices in useTotalBalance). It checks prices only on held balances, and its getTotalUsdLabel takes the same hasPrices boolean. This change makes the extension behave the same way.

Screenshots / video

Before: the total shows "$0.00". The XLM and USDC rows show "--".

After: not captured. The total shows "--" in the same state.

Before After
$0.00 --

Checklist

  • I have read CONTRIBUTING.md and this PR meets its requirements.
  • This PR has narrow scope and does not mix refactoring with feature changes.
  • This PR adds tests for the new functionality or fixes.
  • These changes have been tested in both Chrome and Firefox.
  • This PR includes relevant before and after screenshots for UI changes.
  • I took the time to review my own PR.

Tests: getTotalUsdLabel.test.ts covers the label cases and the getTotalUsd cases: each price null, an empty map, a partial price map, and a price for a token the account does not hold. The helper, Home and account component tests (804) pass. tsc passes. I did not test the change in a browser.

🤖 Generated with Claude Code

https://claude.ai/code/session_01R8cp43wK2MV78D42ej16as

The backend can return a key for each token with a null price. The
total label checked only for keys, so it showed "$0.00". Now it checks
for at least one real price. One price gives a partial total. No price
gives "--". This matches freighter-mobile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8cp43wK2MV78D42ej16as
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-9c849376a609b815c7bf
Backend: V1 prod + V2 beta (no sandbox configured for @JakeUrban). SDF collaborators only — install instructions in the release description.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active moderate issue remains because the total-price fallback scans stale or extra cached tokens, which can display $0.00 instead of -- when held assets lack prices.

1 open issue
What changed in this PR

Updates the popup total balance label to show -- when token prices are unavailable, while preserving partial totals when at least one token is priced.

Changes:

  • Checks token price values before formatting the total.
  • Adds tests for all-null and partially priced token scenarios.
  • Preserves existing zero-value and no-price-feed behavior.
File Description
extension/​src/​popup/​helpers/​balance.ts Updates total balance label logic to distinguish unavailable prices from valid zero or partial totals.
extension/​src/​popup/​helpers/​__tests__/​getTotalUsdLabel.test.ts Adds tests covering all-null and partially priced token price maps.

Review effort: Lite

Comment thread extension/src/popup/helpers/balance.ts Resolved
The price cache can keep prices for tokens the account does not hold,
such as a swap destination. The total does not add these prices. The
label check counted them, so the label could show "$0.00" in place of
"--".

Add hasHeldPrice. It uses the same lookup as getTotalUsd.
getTotalUsdLabel now takes a hasPrices boolean, as on mobile.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8cp43wK2MV78D42ej16as

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A moderate active issue remains because malformed or infinite price strings can produce a misleading $0.00 balance label instead of the expected --.

1 open issue
1 resolved since last review

Review effort: Lite

Comment thread extension/src/popup/helpers/balance.ts Resolved
@JakeUrban
JakeUrban marked this pull request as ready for review November 10, 2026 15:23
Comment thread extension/src/popup/helpers/balance.ts Resolved
getTotalUsd now returns the total and whether any held balance has a
price. This removes hasHeldPrice, which repeated the same lookup loop.
The label and the total now always count the same prices.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01R8cp43wK2MV78D42ej16as
@JakeUrban
JakeUrban requested a review from JiahuiWho November 10, 2026 17:53
@JakeUrban
JakeUrban merged commit 82a7cca into master Nov 11, 2026
11 checks passed
@JakeUrban
JakeUrban deleted the claude/confident-gauss-zms0vo branch November 11, 2026 18:42
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.

4 participants