fix: it should be possible to enter gas prices with decimals
This commit is contained in:
parent
b21e1d87c0
commit
d34dafd525
|
@ -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}"
|
||||
|
||||
|
|
Loading…
Reference in New Issue