fix: Send refuses every amount the confirmation screen would refuse (closes #532)
check / check (push) Waiting to run
e2e / e2e-chrome (push) Waiting to run
e2e / e2e-firefox (push) Waiting to run

Send accepted any amount parseFloat() read as above zero, so "1e-3",
"1abc" and an amount with a nonzero digit past the token's decimal places
reached ConfirmTx, which then refused them. isValidAmount() in
src/shared/txValidation.js is now the one check: Review and Max on Send
call it with the token's decimal places, and validateTransfer() calls it
for ConfirmTx, which now also refuses a zero amount and a token amount
with a nonzero digit past the token's places. Zeros past those places
are accepted, since the amount encoded for the transfer is the same.

Model: opus-5-5
This commit is contained in:
2026-10-18 19:34:11 +00:00
parent e48308c5b6
commit 75a24b59e7
7 changed files with 359 additions and 33 deletions
+6
View File
@@ -116,6 +116,12 @@ describe("transferAmountUnits", () => {
expect(() => transferAmountUnits("0.0000001", 6, 6n)).toThrow();
});
test("encodes zeros past the token's scale as the amount typed", () => {
// The Send screen accepts "1.0000000" for a 6-place token, so the
// transfer must move exactly 1 of it.
expect(transferAmountUnits("1.0000000", 6, 6n)).toBe(1000000n);
});
test("every refusal is a full sentence", () => {
const messages = [];
for (const args of [