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
+9
-9
@@ -829,12 +829,11 @@ test("a common-token quick-pick fills in the contract address (#150)", async (en
|
||||
await visible(env.page, "#view-address");
|
||||
});
|
||||
|
||||
// The native amount as the transaction list writes it (four decimals) and
|
||||
// as the detail screen writes it (full precision). Both are rendered here
|
||||
// from the fixture rather than read off the screen, so the assertions
|
||||
// compare against the wei the stub served.
|
||||
const NATIVE_ROW_TEXT =
|
||||
parseFloat(formatEther(STUB_NATIVE_VALUE_WEI)).toFixed(4) + " ETH";
|
||||
// The native amount as the transaction list writes it (cut to four decimals,
|
||||
// quantity() below) and as the detail screen writes it (full precision). Both
|
||||
// are rendered here from the fixture rather than read off the screen, so the
|
||||
// assertions compare against the wei the stub served.
|
||||
const NATIVE_ROW_TEXT = quantity(STUB_NATIVE_VALUE_WEI) + " ETH";
|
||||
const NATIVE_DETAIL_TEXT = formatEther(STUB_NATIVE_VALUE_WEI) + " ETH";
|
||||
|
||||
test("the native ETH transaction detail still renders (#151)", async (env) => {
|
||||
@@ -2724,10 +2723,11 @@ async function goToConfirm(page, send) {
|
||||
await assertAddressesFit(page, "the confirmation screen");
|
||||
}
|
||||
|
||||
// A balance as the main view renders it: balanceLinesForAddress() writes
|
||||
// every quantity with four decimal places.
|
||||
// An amount in wei as the main view's balance lines and the transaction list
|
||||
// write it: cut to four decimal places, never rounded, as feeEth() does.
|
||||
function quantity(wei) {
|
||||
return parseFloat(formatEther(wei)).toFixed(4);
|
||||
const [whole, frac = ""] = formatEther(wei).split(".");
|
||||
return whole + "." + (frac + "0000").slice(0, 4);
|
||||
}
|
||||
|
||||
// Wait on the main view until a changed balance fixture has been picked up.
|
||||
|
||||
Reference in new issue
Block a user