fix: Send refuses every amount the confirmation screen would refuse (closes #532)
Send's Review accepted any amount parseFloat() read as above zero, so 1e-3, 1abc and amounts with too many decimal places reached ConfirmTx, which then refused them or failed to estimate the fee. isValidAmount() in src/shared/txValidation.js is now the one amount check, used by Send's Review and Max and by validateTransfer() for ConfirmTx: plain digits with at most one decimal point, above zero, nothing but zeros past the token's places. Zeros past those places are accepted, since the transfer encodes the amount exactly. Send now reads the token's decimal places before the ENS lookup, because the check needs them. Judgement call: ConfirmTx now also refuses zero, as Send already did. Model: opus-5-5
This commit was merged in pull request #567.
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