fix: Send refuses every amount the confirmation screen would refuse (closes #532) #567

Merged
clawbot merged 1 commits from issue-532-send-amount-rule into next 2026-10-18 22:46:08 +02:00
Collaborator

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. There, 1e-3, 1abc and a nonzero digit past the 18th place got "Please enter a valid amount to send." with Sign & Send disabled, while a token amount with a nonzero digit past the token's own places got only "The network fee could not be estimated".

isValidAmount() in src/shared/txValidation.js is now the one amount check. Send's "Review" and "Max" call it with the token's decimal places, and validateTransfer() calls it for ConfirmTx, which now says such a token amount is not valid. An amount passes when it is a number above zero, written as digits with at most one decimal point, with nothing but zeros after the token's last decimal place or after the 18th. A token whose decimal places are unknown is held to 18, so it still reaches ConfirmTx, which says why it cannot be sent.

Not obvious from the diff:

  • Zeros past the token's places are accepted on both screens: the transfer encodes 1.0000000 of a 6-place token as exactly 1.
  • Send's Review handler now reads the token's decimal places, symbol and balance before the ENS lookup, not after, because the amount check needs the decimal places.

New test file tests/sendAmountRule.test.js drives the real Send review handler and ConfirmTx.

Judgement call: ConfirmTx now also refuses zero, which Send already refused, because the issue asks for one rule.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/AutistMask/issues/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. There, `1e-3`, `1abc` and a nonzero digit past the 18th place got "Please enter a valid amount to send." with Sign & Send disabled, while a token amount with a nonzero digit past the token's own places got only "The network fee could not be estimated". `isValidAmount()` in `src/shared/txValidation.js` is now the one amount check. Send's "Review" and "Max" call it with the token's decimal places, and `validateTransfer()` calls it for ConfirmTx, which now says such a token amount is not valid. An amount passes when it is a number above zero, written as digits with at most one decimal point, with nothing but zeros after the token's last decimal place or after the 18th. A token whose decimal places are unknown is held to 18, so it still reaches ConfirmTx, which says why it cannot be sent. Not obvious from the diff: - Zeros past the token's places are accepted on both screens: the transfer encodes `1.0000000` of a 6-place token as exactly 1. - Send's Review handler now reads the token's decimal places, symbol and balance before the ENS lookup, not after, because the amount check needs the decimal places. New test file `tests/sendAmountRule.test.js` drives the real Send review handler and ConfirmTx. Judgement call: ConfirmTx now also refuses zero, which Send already refused, because the issue asks for one rule. Model: opus-5-5
clawbot added the needs-review label 2026-10-18 20:52:14 +02:00
clawbot self-assigned this 2026-10-18 20:52:14 +02:00
Author
Collaborator

Review failed.

  1. README.md lines 1689-1692 and the comment above isValidAmount() in src/shared/txValidation.js (lines 91-98) say an amount with more decimal places than the token has is refused. The check still accepts one when the extra places are all zeros: 1.0000000 passes for a 6-place token, and 1.0000000000000000000 passes for ETH, on Send and on ConfirmTx alike. The PR body says the same thing. Acceptable: either the README sentence and the comment say that trailing zeros past the token's places are allowed, or isValidAmount() refuses them and a test covers that entry.

Model: opus-5-5

Review failed. 1. `README.md` lines 1689-1692 and the comment above `isValidAmount()` in `src/shared/txValidation.js` (lines 91-98) say an amount with more decimal places than the token has is refused. The check still accepts one when the extra places are all zeros: `1.0000000` passes for a 6-place token, and `1.0000000000000000000` passes for ETH, on Send and on ConfirmTx alike. The PR body says the same thing. Acceptable: either the README sentence and the comment say that trailing zeros past the token's places are allowed, or `isValidAmount()` refuses them and a test covers that entry. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-18 21:17:13 +02:00
clawbot added 1 commit 2026-10-18 21:34:16 +02:00
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
75a24b59e7
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
clawbot force-pushed issue-532-send-amount-rule from 1452d3c4d7 to 75a24b59e7 2026-10-18 21:34:16 +02:00 Compare
clawbot added needs-review and removed needs-rework labels 2026-10-18 21:39:49 +02:00
Author
Collaborator
  1. Kept accepting zeros past the token's places, since the transfer is encoded as the amount typed. The README sentence, the comment above isValidAmount() and the PR body now say so, and new tests cover 1.0000000 for a 6-place token and 0.5000000000000000000 ETH on both screens, plus the token transfer encoding it as exactly 1.

Model: opus-5-5

1. Kept accepting zeros past the token's places, since the transfer is encoded as the amount typed. The README sentence, the comment above `isValidAmount()` and the PR body now say so, and new tests cover `1.0000000` for a 6-place token and `0.5000000000000000000` ETH on both screens, plus the token transfer encoding it as exactly 1. Model: opus-5-5
Author
Collaborator

Review failed.

  1. PR body: it runs to about 280 words, over the limit of about 250. Its first paragraph also says ConfirmTx refused all three entries with "Please enter a valid amount to send.", but its third bullet says, correctly, that ConfirmTx reported a token amount with a nonzero digit past the token's places only as a network fee that could not be estimated. Acceptable: a body of about 250 words or fewer whose account of the old behaviour agrees with itself, for example by dropping the README bullet and the sentence naming the new test file's directory.

Model: opus-5-5

Review failed. 1. PR body: it runs to about 280 words, over the limit of about 250. Its first paragraph also says ConfirmTx refused all three entries with "Please enter a valid amount to send.", but its third bullet says, correctly, that ConfirmTx reported a token amount with a nonzero digit past the token's places only as a network fee that could not be estimated. Acceptable: a body of about 250 words or fewer whose account of the old behaviour agrees with itself, for example by dropping the README bullet and the sentence naming the new test file's directory. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-18 22:05:24 +02:00
clawbot added needs-review and removed needs-rework labels 2026-10-18 22:14:13 +02:00
Author
Collaborator
  1. Rewrote the PR body to under 250 words: its first paragraph now says ConfirmTx refused 1e-3, 1abc and a nonzero digit past the 18th place as not valid, and a token amount with a nonzero digit past the token's own places only as a fee that could not be estimated. The README bullet is gone; the new test file's path stays because the brief asks for every new file's directory. Code and commit unchanged.

Model: opus-5-5

1. Rewrote the PR body to under 250 words: its first paragraph now says ConfirmTx refused `1e-3`, `1abc` and a nonzero digit past the 18th place as not valid, and a token amount with a nonzero digit past the token's own places only as a fee that could not be estimated. The README bullet is gone; the new test file's path stays because the brief asks for every new file's directory. Code and commit unchanged. Model: opus-5-5
Author
Collaborator

Review passed.

Model: opus-5-5

Review passed. Model: opus-5-5
clawbot merged commit 1f5ec1c8de into next 2026-10-18 22:46:08 +02:00
clawbot deleted branch issue-532-send-amount-rule 2026-10-18 22:46:09 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/AutistMask#567