Skip to content
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

feat: add UiInputAmount and decimals validation #592

Merged
merged 3 commits into from
Aug 6, 2024

Conversation

Sekhmet
Copy link
Member

@Sekhmet Sekhmet commented Aug 6, 2024

Summary

Closes: #583

This PR adds new UiInputAmount that can be used to input numeric amounts, but without drawbacks of using number input for it:

  • Because it's no longer number it doesn't get converted to exponential form (for example in StakeToken modal output value would be displayed as 1e-7).
  • Similarly when entering small value like 0.000000000000001 and triggering re-render, for example by going to contact picker and back it would be turned to exponential form.
  • UiInputAmount value has consistent type (always string), where UiInputNumber could have either string (when input is empty) or number.

This PR also adds decimals validation so we can validate the form (SendToken and StakeToken).

How to test

  1. Go there: http://localhost:8080/#/eth:0x6E60b6dCc2923267104Bb4a68F4766f627430664/treasury
  2. Try creating SendToken execution, enter big values or small ones, trigger decimals error.
  3. Try creating StakeToken execution, enter big values or small ones, trigger decimals error.
  4. Nothing breaks.

Note: Currently if you enter error state (for example too many decimals) and open picker and back dirty flag gets cleared so it won't display the error on UI, but it's true for all inputs at the moment, we have issue for that: #573

Screenshots

Before

Screen.Recording.2024-08-06.at.16.30.14.mov

After

Screen.Recording.2024-08-06.at.16.30.50.mov

@Sekhmet Sekhmet requested review from ChaituVR and bonustrack August 6, 2024 14:33
Copy link
Member

@bonustrack bonustrack left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK

@Sekhmet Sekhmet merged commit 3792f72 into master Aug 6, 2024
3 checks passed
@Sekhmet Sekhmet deleted the sekhmet/amount-refactor branch August 6, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: No validation inside stake modal
2 participants