Repository navigation
fix(balances): show "--" for the total when no token has a price - #3077
Merged
Merged
Conversation
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
Contributor
|
PR Preview build is ready: https://github.com/stellar/freighter/releases/tag/untagged-9c849376a609b815c7bf |
Contributor
There was a problem hiding this comment.
🟡 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
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
JakeUrban
marked this pull request as ready for review
November 10, 2026 15:23
JiahuiWho
reviewed
Nov 10, 2026
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
JiahuiWho
approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.
null$0.00--$0.00--null----(no change)Changes:
getTotalUsd(extension/src/popup/helpers/balance.ts) now returns{ totalUsd, hasPrices }from one lookup.hasPricesis true when at least one held balance has a price. A price for a token that the account does not hold does not count.getTotalUsdLabelnow takes ahasPricesboolean, not the price map. The Home view anduseGetWalletsDatapass the value fromgetTotalUsd.Why
The backend can return a key for each token with a
nullprice. 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-mobilealready uses this rule (hasPricesinuseTotalBalance). It checks prices only on held balances, and itsgetTotalUsdLabeltakes the samehasPricesboolean. 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.
$0.00--Checklist
Tests:
getTotalUsdLabel.test.tscovers the label cases and thegetTotalUsdcases: 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.tscpasses. I did not test the change in a browser.🤖 Generated with Claude Code
https://claude.ai/code/session_01R8cp43wK2MV78D42ej16as