fix: every screen cuts amounts the same way (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, and 0.00004 USDC read 0.0000. They now show the stored decimal string through truncateAmountNeverZero(), as Send and the approval screens do. History rows take the same floor. truncateAmount() is no longer exported. balanceLine() now takes the stored balance string instead of a parsed number. Model: opus-5-5
This commit is contained in:
1 parent
c150b83322
commit
2c5364f7bf
12 files changed
+164
-79
No files matched your search
@@ -25,10 +25,7 @@ const { ERC20_ABI } = require("../src/shared/constants");
|
||||
const { state } = require("../src/shared/state");
|
||||
const { decodeCalldata } = require("../src/popup/views/approval");
|
||||
const uniswap = require("../src/shared/uniswap");
|
||||
const {
|
||||
truncateAmount,
|
||||
truncateAmountNeverZero,
|
||||
} = require("../src/shared/amountDisplay");
|
||||
const { truncateAmountNeverZero } = require("../src/shared/amountDisplay");
|
||||
|
||||
const iface = new Interface(ERC20_ABI);
|
||||
|
||||
@@ -184,12 +181,7 @@ describe("the four-decimal rule is otherwise unchanged", () => {
|
||||
expect(amount(transferData(0n), DAI).rawValue).toBe("0.0000");
|
||||
});
|
||||
|
||||
// The three truncators now share one module. The floor is a policy of the
|
||||
// approval and confirmation screens only: the history and balance lists
|
||||
// keep plain truncation, because the transaction detail view is the
|
||||
// authoritative record and already shows exact precision.
|
||||
test("the list rule stays unfloored", () => {
|
||||
expect(truncateAmount("0.000000000000000001")).toBe("0.0000");
|
||||
test("one base unit of an 18-decimal token reads as itself", () => {
|
||||
expect(truncateAmountNeverZero("0.000000000000000001")).toBe(
|
||||
"0.000000000000000001",
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user