fix: Send refuses every amount the confirmation screen would refuse (closes #532)
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:
@@ -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 [
|
||||
|
||||
Reference in New Issue
Block a user