fix: every balance is cut to four decimals (closes #757)
The balance lists and Home's ETH line rounded with toFixed(4), so 0.99996 ETH read 1.0000 there and 0.9999 on Send. Send's current balance and ConfirmTx's balance line kept the nonzero floor, so 0.00004 USDC read 0.0000 in the lists and 0.00004 on Send. All four now cut the stored decimal string with truncateAmount(), as the history rows do. balanceLine() takes the stored balance string instead of a parsed number, and escapes the quantity cell. The amounts, fees and allowances a screen asks the user to approve keep the floor of truncateAmountNeverZero(). Disclosure: for a holding below 0.0001, ConfirmTx shows the amount sent beside a balance that reads 0.0000. Model: opus-5-5
This commit was merged in pull request #768.
This commit is contained in:
1 parent
32b232db60
commit
d909567ab9
15 files changed
+208
-89
No files matched your search
@@ -159,10 +159,10 @@ function renderBalance() {
|
||||
const addr =
|
||||
state.wallets[state.selectedWallet].addresses[state.selectedAddress];
|
||||
const tokenId = state.selectedToken;
|
||||
let amount, price;
|
||||
let balance, price;
|
||||
if (tokenId === "ETH") {
|
||||
// null when no refresh has read the balance.
|
||||
amount = unknownableAmount(addr.balance);
|
||||
balance = addr.balance;
|
||||
price = getPrice("ETH");
|
||||
} else {
|
||||
const id = tokenId.toLowerCase();
|
||||
@@ -175,12 +175,13 @@ function renderBalance() {
|
||||
// null when the scale is unknown, or when no refresh has read the
|
||||
// token's balance: no quantity to show, and none to price.
|
||||
// balanceLine() states that rather than printing 0.0000.
|
||||
if (tb) amount = unknownableAmount(tb.balance);
|
||||
else amount = tracked && tracked.balanceNotFetched ? null : 0;
|
||||
if (tb) balance = tb.balance;
|
||||
else balance = tracked && tracked.balanceNotFetched ? null : "0";
|
||||
price = getPrice(tokenId);
|
||||
}
|
||||
|
||||
// USD total for this token only
|
||||
const amount = unknownableAmount(balance);
|
||||
const usdVal = price && amount !== null ? amount * price : null;
|
||||
const usdStr = formatUsd(usdVal);
|
||||
$("address-token-usd-total").innerHTML = escapeHtml(usdStr) || " ";
|
||||
@@ -188,7 +189,7 @@ function renderBalance() {
|
||||
// Single token balance line (no tokenId — not clickable here)
|
||||
$("address-token-balance").innerHTML = balanceLine(
|
||||
currentSymbol,
|
||||
amount,
|
||||
balance,
|
||||
price,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user