Fix: App crashes when split payment total is small #4229
Merged
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.
Description
Fix an issue with the app crashing when the split payment type is too small.
Took a while to figure out the actual root cause of this, since the crash was caused by an invalid input to BigNumber, but I had to actually trace it back about 6 steps to find out why it was ending up in that format.
Long story short, when the user changes the percentage of a payout in a split payment, there is a function run to calculate the amount. When this amount is set, we need to use the
toFixed
instead oftoString
method fromdecimal.js
, because otherwise when the amount is small it will be in scientific notation, which down the line (after trying to move the decimal point and convert to wei and then pass to BigNumber) causes the crash 😥Small side note: I also fixed some awkward padding / styling for scientific notation amounts by wrapping the amounts in span tags in the completed action.
Testing
Diffs
Changes 🏗
toFixed
instead oftoString
when calculating split payment amountsResolves #4031