From d34dafd52574b0495e8a295f66c3e3e80c62544d Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Sun, 1 Aug 2021 12:04:42 -0400 Subject: [PATCH] fix: it should be possible to enter gas prices with decimals --- src/app/wallet/views/gas.nim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/wallet/views/gas.nim b/src/app/wallet/views/gas.nim index 0820df3e6..307dba6a7 100644 --- a/src/app/wallet/views/gas.nim +++ b/src/app/wallet/views/gas.nim @@ -52,22 +52,21 @@ QtObject: result.setup proc getGasEthValue*(self: GasView, gweiValue: string, gasLimit: string): string {.slot.} = - var gweiValueInt:int var gasLimitInt:int - 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 + var gwei = gweiValue.parseFloat() + if (gwei < 0): + gwei = 0 if (gasLimitInt < 0): gasLimitInt = 0 - let weiValue = gweiValueInt.u256 * 1000000000.u256 * gasLimitInt.u256 + let weiValue = gwei2Wei(gwei) * gasLimitInt.u256 let ethValue = wei2Eth(weiValue) result = fmt"{ethValue}"