fix(wallet): Validate decimals for crypto when sending (#15523)

This commit is contained in:
Cuteivist 2024-07-17 18:48:16 +02:00 committed by GitHub
parent ec86a30d6e
commit 55b2224593
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 2 deletions

View File

@ -117,6 +117,10 @@ ColumnLayout {
input.validate()
}
onSelectedHoldingChanged: {
input.validate()
}
StatusBaseText {
text: root.caption
font.pixelSize: 13
@ -145,9 +149,17 @@ ColumnLayout {
errorMessage: ""
validate: (text) => {
var num = LocaleUtils.numberFromLocaleString(topAmountToSendInput.text,
const num = LocaleUtils.numberFromLocaleString(topAmountToSendInput.text,
topAmountToSendInput.locale)
return !isNaN(num) && num > 0 && num <= root.maxInputBalance
if (isNaN(num) || num <= 0 || num > root.maxInputBalance) {
return false
}
if(!root.selectedHolding || !root.selectedHolding.marketDetails || !root.selectedHolding.marketDetails.currencyPrice) {
return false
}
const cryptoValueToSend = root.inputIsFiat ? num / root.selectedHolding.marketDetails.currencyPrice.amount : num
const cryptoValueToSendRaw = SQUtils.AmountsArithmetic.fromNumber(cryptoValueToSend, root.multiplierIndex).toString()
return cryptoValueToSendRaw >= 1
}
}
]