-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TX flow] Adds nonce validation #2175
Conversation
Branch preview✅ Deploy successful! https://nonce_validation--walletweb.review-wallet-web.5afe.dev |
We should also think about disabling the "Next" and "Submit" button if the nonce is invalid. Previously this was covered since the nonce was edited in a separate modal and the user couldn't leave without entering a valid input there. I suggest we add another state |
ESLint Summary View Full Report
Report generated by eslint-plus-action |
Should we also limit the maximum number the user can enter or additionally show another warning/error if the input is much higher than the current nonce? Currently, if the user keeps typing the number changes to "Infinity" at some point which is handled as a valid input. |
@@ -224,7 +224,7 @@ const CreateTokenTransfer = ({ | |||
</FormControl> | |||
|
|||
{isDisabled && ( | |||
<Box mt={1} display="flex" alignItems="center"> | |||
<Box display="flex" alignItems="center" mt={-2} mb={3}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the issue that the safe error is too close to the divider
How about just not letting the user choose an incorrect nonce? I assumed this validation would do that. |
After our discussion:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} | ||
|
||
if (nonce >= Number.MAX_SAFE_INTEGER) { | ||
return 'Nonce is too big' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return 'Nonce is too big' | |
return 'Nonce is too high' |
const isNotValid = validateInput(value) | ||
|
||
if (isNotValid) { | ||
setError(validateInput(value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const isNotValid = validateInput(value) | |
if (isNotValid) { | |
setError(validateInput(value)) | |
const error = validateInput(value) | |
if (error) { | |
setError(error) |
) | ||
|
||
const handleBlur = useCallback(() => { | ||
setError(undefined) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the current nonce
is erroneous?
Edit: this ties in with my review summary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we don't save the nonce if its incorrect the current nonce must be correct so we can safely remove the error.
For visibility (as per our discussion) two thoughts:
|
I agree its not ideal but since we use the same value for controlling the input we can't easily let the user remove and not update it.
Thanks for catching this. I updated both the replace and reject flow to work now. For replacing a transaction we need to call |
We could save the new nonce if validation fails and not return early or have a local state that saves the nonce |
# Conflicts: # src/components/tx-flow/common/TxNonce/index.tsx # src/components/tx-flow/flows/TokenTransfer/CreateTokenTransfer.tsx
What it solves
Resolves #2110
How this PR fixes it
How to test it
Screenshots
Checklist