fix: an address holding only unpriced tokens is no longer totalled at $0.00 (closes #261)
All checks were successful
check / check (push) Successful in 26s
All checks were successful
check / check (push) Successful in 26s
Prices are fetched for the top 25 tokens only, so an address can hold real
assets this build has no price for. The address total summed the priced
holdings and printed the result as the total, so an address holding nothing
but unpriced ERC-20s was reported as worth $0.00 — wrong in the direction
that matters, and on the address-removal confirmation it sat directly under
"This address holds a balance."
getAddressValue() returns { usd, partial }: the value of the priced holdings,
and whether an unpriced holding was left out of it. Worth zero and worth an
unknown amount stay separate facts, as an absent holders_count stays separate
from a count of zero. formatAddressTotal() is the one rendering of that pair,
so no screen can word it differently:
- nothing knowable (testnet, before the first fetch): no total line
- everything priced: "Total: $5,500.00"
- part priced: "Total: $3,000.00 plus unpriced tokens"
- nothing priced: "Total: unpriced tokens only"
A partial total is kept rather than suppressed: the figure is the ETH and
priced tokens the user does hold and is correct as far as it goes, so it is
named as a floor instead of being thrown away. What is never printed is a
figure covering no holdings at all.
All four call sites read it — the Home summary line, the Home wallet list,
AddressDetail and the removal confirmation — and getWalletValue() and
getTotalValue() carry partial up so a future consumer cannot lose it.
The per-token balance lines are unchanged: a token with no price shows its
quantity and a blank USD column.
tests/addressValue.test.js covers the only-unpriced, genuinely-zero and
fully-priced cases at the helper, at its formatter, and through both call
sites that return their markup as a string. Written first and watched fail
on the unfixed helper: the Home wallet list gave "$0.00" and the removal
confirmation "Total: $0.00" for an address holding 5000 unpriced tokens.
This commit is contained in:
39
README.md
39
README.md
@@ -538,6 +538,27 @@ Both are click-copyable. Truncating to 4 decimals in summary views is acceptable
|
||||
for scannability, but the detail view must never discard precision — it is the
|
||||
one place the user can always use to verify exact details.
|
||||
|
||||
#### Partial USD totals
|
||||
|
||||
Prices are fetched for the top 25 tokens only, so an address can hold assets the
|
||||
extension has no price for. Worth zero and worth an unknown amount are different
|
||||
facts and are never collapsed into one number. `getAddressValue()` in
|
||||
`src/shared/prices.js` returns `{ usd, partial }` — the value of the priced
|
||||
holdings, and whether an unpriced holding was left out of it — and every screen
|
||||
renders it through `formatAddressTotal()`, so the wording cannot drift:
|
||||
|
||||
- Nothing knowable (testnet, or before the first price fetch): no total line.
|
||||
- Everything priced: `Total: $5,500.00`.
|
||||
- Part priced: `Total: $3,000.00 plus unpriced tokens` — the figure is real as
|
||||
far as it goes and is kept, named as a floor rather than the total.
|
||||
- Nothing priced but something held: `Total: unpriced tokens only`. No figure,
|
||||
because the only figure available would be the `$0.00` sum of an empty set,
|
||||
and on the address-removal confirmation that sits directly under "This address
|
||||
holds a balance."
|
||||
|
||||
The per-token balance lines are unaffected: each shows its quantity, and a USD
|
||||
column that is blank for a token with no price.
|
||||
|
||||
#### Language & Labeling
|
||||
|
||||
All user-facing text avoids unnecessary jargon wherever possible:
|
||||
@@ -673,7 +694,9 @@ on ConfirmTx, DeleteWallet, ApproveTx and ApproveSign.
|
||||
- **When**: At least one wallet exists. This is the root screen.
|
||||
- **Elements**:
|
||||
- Active address ETH balance (large) + USD value in parentheses
|
||||
- "Total:" USD value across ETH and every token shown for the active address
|
||||
- "Total:" USD value across ETH and every token shown for the active
|
||||
address, written by `formatAddressTotal()` — see
|
||||
[Partial USD totals](#partial-usd-totals)
|
||||
- Active address (color dot, full address, etherscan link, tap to copy)
|
||||
- Send / Receive quick-action buttons, both acting on the active address
|
||||
- ETH/USD price display
|
||||
@@ -735,7 +758,7 @@ on ConfirmTx, DeleteWallet, ApproveTx and ApproveSign.
|
||||
- Title: "Wallet Name — Address N"
|
||||
- ENS name (if resolved, bold above the address)
|
||||
- Full address (color dot, etherscan link, tap to copy)
|
||||
- USD total for address
|
||||
- USD total for address (see [Partial USD totals](#partial-usd-totals))
|
||||
- Balance list: ETH + the ERC-20 tokens shown for this address (4 decimal
|
||||
places, USD inline). Each balance row is clickable → **AddressToken**
|
||||
- Send / Receive / + Token buttons and a "···" menu button
|
||||
@@ -1101,11 +1124,13 @@ on ConfirmTx, DeleteWallet, ApproveTx and ApproveSign.
|
||||
xprv wallet has no recovery phrase to re-import.
|
||||
- A warning when the address holds anything, ETH or any tracked ERC-20,
|
||||
followed by the holdings themselves via `balanceLinesForAddress()` and the
|
||||
USD total via `getAddressValueUsd()`. The sentence names no figure of its
|
||||
own: the lines round to four decimals, so a sentence built from a rounded
|
||||
number would report `0.0000 ETH` for an address holding real money. The
|
||||
predicate is `addressHoldsFunds()` in `src/popup/views/helpers.js`,
|
||||
unrounded and token-aware. A balance is a warning, never a refusal.
|
||||
USD total via `formatAddressTotal()` (see
|
||||
[Partial USD totals](#partial-usd-totals)). The sentence names no figure
|
||||
of its own: the lines round to four decimals, so a sentence built from a
|
||||
rounded number would report `0.0000 ETH` for an address holding real
|
||||
money. The predicate is `addressHoldsFunds()` in
|
||||
`src/popup/views/helpers.js`, unrounded and token-aware. A balance is a
|
||||
warning, never a refusal.
|
||||
- The rule that a wallet always keeps at least one address, and that
|
||||
removing the last one means deleting the wallet from Settings
|
||||
- Error line
|
||||
|
||||
Reference in New Issue
Block a user