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

Swap UI: Fixed input bug due to locale differences #76

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hesido
Copy link

@hesido hesido commented Aug 29, 2021

Inputs allow locale dependent entry
Negative inputs are denied

Inputs allow locale dependent entry
Negative inputs are denied
@hesido
Copy link
Author

hesido commented Aug 29, 2021

There was a problem with the inputs being impossible on different locales that does not use "." as the decimal separator. After some investigation, I realized the issue stemmed from trying to parseFloat the string input as the values entered were first converted into a string according to the local, but they could not be converted back to a number for locales that use ",". However, some work needs to be done before merging this, as parsefloat has precision problems. The conversion to string hid this, but internally, the precision is already lost when using float numbers.

Amounts use Big number type
Locale independent entry
Inputs are decoupled from amounts
@hesido
Copy link
Author

hesido commented Sep 4, 2021

In this second commit for the pull request, I have fixed some useability problems in the Swap UI:

  • You can now type "0" after the decimal separator. (e.g. you were not able to type 5.01, as 5.0 was immediately parsed back as 5.
  • The input is completely decoupled from internal amounts, and this allows user to keep on inputting without being affected from changes to the fair price during input
  • The amounts internally use big number types, so floating point rounding errors do not produce unintended input when inputting big numbers or many numbers after the decimal separator, would allow more robust and feature proof input.

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.

None yet

1 participant