Repository navigation
Conversation
Signed-off-by: Gous0786 <gousalam0786@gmail.com>
✅ Deploy Preview for brilliant-pasca-3e80ec canceled.
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Gous0786 gousalam0786@gmail.com
Changes proposed in this pull request
parseAmount(input, scale)helper inapp/shared/utils.tsthat converts a user-entered decimal amount to asset base units with string arithmetic andBigInt, instead ofparseFloat(input) * 10^scale.parseAmountinLiquidityDialog, and keep the amount as a string so large values are no longer serialized as5e+21.0in the dialog (it previously passed the client check and failed on the server).Context
fixes #3986
The liquidity dialog (used for asset and peer deposit/withdraw liquidity) rejected valid amounts because of floating-point error. For example, at scale 2,
parseFloat('0.29') * 100is28.999999999999996, so0.29was rejected with "The asset scale cannot accomodate this value" while1.29was accepted. About 11% of 2-decimal amounts between0.00and99.99were affected. The backend accepts these amounts (amount: UInt64!), so only the frontend conversion was wrong.The new helper parses the input as text, splits on
., rejects it if the fractional part is longer thanasset.scale, and builds the amount from the digits:How to test
pnpm localenv:compose:psql up -dhttp://localhost:3010as the operator0.29: there is no error, and the deposit succeeds with exactly 29 base units0.291: the scale error is still shownBefore :

After

Checklist
fixes #numberuser-docslabel (if necessary)