You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, parsing and calculations (for fees and final amounts) are all correct and in the correct units. However, XE and mXE are mixed together in places, so it's not always clear what unit calculations are in. As the wallet evolves, this is likely to create avoidable display/calculation errors.
Example: the balance store value is in mXE, as are all amounts/fees in blockchain API. On the other hand, when sending XE we parse the XE input directly to XE and calculate fees from that, then convert to mXE when submitting the transaction. This has the effect that our validator has to convert units, rather than simply comparing directly:
helpers.withParams({ b, p },helpers.withMessage('Insufficient funds.',()=>{
if(isNaN(p))returnfalse
returnp<=(b/1e6)
}))
It's worth noting that because of the conversion requirement, we have to copy-paste the validator for EDGE deposits. If we simply parse mXE and remove this need, we can use the same validator irrespective of currency, as long as the parsed/balance units match.
Using mXE as calculation base also simplifies minimum-amount validation, as we only need to ensure a transaction amount is greater than 0 mXE, rather than greater than 0.000001 XE. We can also round values more safely, ensuring mXE is an indivisible unit. Generally, moving towards integer calculations will improve clarity and robustness.
Once the mXE basis is in place, validation should be reviewed to ensure sub-mXE inputs are not possible e.g.
The text was updated successfully, but these errors were encountered:
At the moment, parsing and calculations (for fees and final amounts) are all correct and in the correct units. However, XE and mXE are mixed together in places, so it's not always clear what unit calculations are in. As the wallet evolves, this is likely to create avoidable display/calculation errors.
Example: the
balance
store value is in mXE, as are all amounts/fees in blockchain API. On the other hand, when sending XE we parse the XE input directly to XE and calculate fees from that, then convert to mXE when submitting the transaction. This has the effect that our validator has to convert units, rather than simply comparing directly:wallet/src/utils/validation.js
Lines 23 to 26 in 1c567a9
It's worth noting that because of the conversion requirement, we have to copy-paste the validator for EDGE deposits. If we simply parse mXE and remove this need, we can use the same validator irrespective of currency, as long as the parsed/balance units match.
Using mXE as calculation base also simplifies minimum-amount validation, as we only need to ensure a transaction amount is greater than 0 mXE, rather than greater than 0.000001 XE. We can also round values more safely, ensuring mXE is an indivisible unit. Generally, moving towards integer calculations will improve clarity and robustness.
Once the mXE basis is in place, validation should be reviewed to ensure sub-mXE inputs are not possible e.g.
The text was updated successfully, but these errors were encountered: