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

Users can get around DECIMALS_MAX using exponential/scientific notation #2409

Open
dotmacro opened this issue Nov 1, 2024 · 1 comment
Open

Comments

@dotmacro
Copy link
Member

dotmacro commented Nov 1, 2024

Problem

The user can enter a pledge in exponential/scientific notation. This in itself is not a problem, especially as the app supports a currency with DECIMALS_MAX = 8.

However, the user can enter a number with more decimal places than DECIMALS_MAX by using exponential/scientific nation to enter their pledge.

For example, this user can enter a pledge of 2e-15 or 2.1234e-15, which the app (correctly and appropriately) rounds to 0.

image

image

image

The UI will not let the user enter a pledge of 2.12345e-15

image

Solution

Ensure users cannot enter a pledge with more decimal places than allowed.

@corrideat
Copy link
Member

This library of mine might be relevant: https://www.npmjs.com/package/intl-number-parser (it solves a slightly different problem, namely parsing numbers in different locales, so long as they are decimal-based)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants