fix(wallet): Crash when enter -1 to Gas Selector

Validation check is updated, so user cannot enter zero or less than zero value for "gas amount limit" or "per-gas overall limit".
In gas.nim a crash prevention check is added.

Fixes: #2753
This commit is contained in:
Sale Djenic 2021-07-05 12:59:50 +02:00 committed by Iuri Matias
parent a9fd4513aa
commit 6f55c51ff2
2 changed files with 11 additions and 2 deletions

View File

@ -58,6 +58,15 @@ QtObject:
discard gweiValue.parseInt(gweiValueInt)
discard gasLimit.parseInt(gasLimitInt)
# The following two check prevents app crash, cause we're trying to promote
# gweiValueInt and gasLimitInt to unsigned 256 int, and these two numbers
# must be positive numbers, because of overflow.
if (gweiValueInt < 0):
gweiValueInt = 0
if (gasLimitInt < 0):
gasLimitInt = 0
let weiValue = gweiValueInt.u256 * 1000000000.u256 * gasLimitInt.u256
let ethValue = wei2Eth(weiValue)
result = fmt"{ethValue}"

View File

@ -69,10 +69,10 @@ Item {
}
let inputLimit = parseFloat(inputGasLimit.text || "0.00")
let inputPrice = parseFloat(inputGasPrice.text || "0.00")
if (inputLimit === 0.00) {
if (inputLimit <= 0) {
inputGasLimit.validationError = root.greaterThan0ErrorMessage
}
if (inputPrice === 0.00) {
if (inputPrice <= 0) {
inputGasPrice.validationError = root.greaterThan0ErrorMessage
}
const isValid = inputGasLimit.validationError === "" && inputGasPrice.validationError === ""