mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-21 20:09:37 +00:00
fix(wallet): Validate decimals for crypto when sending (#15523)
This commit is contained in:
parent
ec86a30d6e
commit
55b2224593
@ -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
|
||||
}
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user