parent
f18e09769a
commit
b1775357c3
|
@ -110,7 +110,6 @@ QtObject:
|
||||||
|
|
||||||
proc estimateGas*(self: View, from_addr: string, to: string, assetAddress: string, value: string, data: string): string {.slot.} =
|
proc estimateGas*(self: View, from_addr: string, to: string, assetAddress: string, value: string, data: string): string {.slot.} =
|
||||||
result = self.delegate.estimateGas(from_addr, to, assetAddress, value, data)
|
result = self.delegate.estimateGas(from_addr, to, assetAddress, value, data)
|
||||||
result = self.delegate.estimateGas(from_addr, to, assetAddress, value, data)
|
|
||||||
|
|
||||||
proc transactionSent*(self: View, txResult: string) {.signal.}
|
proc transactionSent*(self: View, txResult: string) {.signal.}
|
||||||
|
|
||||||
|
|
|
@ -224,7 +224,6 @@ QtObject:
|
||||||
): string {.slot.} =
|
): string {.slot.} =
|
||||||
var response: RpcResponse[JsonNode]
|
var response: RpcResponse[JsonNode]
|
||||||
# TODO make this async
|
# TODO make this async
|
||||||
try:
|
|
||||||
if assetAddress != ZERO_ADDRESS and not assetAddress.isEmptyOrWhitespace:
|
if assetAddress != ZERO_ADDRESS and not assetAddress.isEmptyOrWhitespace:
|
||||||
var tx = buildTokenTransaction(
|
var tx = buildTokenTransaction(
|
||||||
parseAddress(from_addr),
|
parseAddress(from_addr),
|
||||||
|
@ -240,24 +239,28 @@ QtObject:
|
||||||
let transfer = Transfer(to: parseAddress(to), value: conversion.eth2Wei(parseFloat(value), token.decimals))
|
let transfer = Transfer(to: parseAddress(to), value: conversion.eth2Wei(parseFloat(value), token.decimals))
|
||||||
let transferproc = ERC20_procS.toTable["transfer"]
|
let transferproc = ERC20_procS.toTable["transfer"]
|
||||||
var success: bool
|
var success: bool
|
||||||
|
try:
|
||||||
let gas = transferproc.estimateGas(tx, transfer, success)
|
let gas = transferproc.estimateGas(tx, transfer, success)
|
||||||
|
|
||||||
let res = fromHex[int](gas)
|
let res = fromHex[int](gas)
|
||||||
result = $(%* { "result": res, "success": success })
|
return $(%* { "result": res, "success": success })
|
||||||
else:
|
except Exception as e:
|
||||||
|
error "Error estimating gas", msg = e.msg
|
||||||
|
return $(%* { "result": "-1", "success": false, "error": { "message": e.msg } })
|
||||||
|
|
||||||
var tx = ens_utils.buildTransaction(
|
var tx = ens_utils.buildTransaction(
|
||||||
parseAddress(from_addr),
|
parseAddress(from_addr),
|
||||||
eth2Wei(parseFloat(value), 18),
|
eth2Wei(parseFloat(value), 18),
|
||||||
data = data
|
data = data
|
||||||
)
|
)
|
||||||
tx.to = parseAddress(to).some
|
tx.to = parseAddress(to).some
|
||||||
|
try:
|
||||||
response = eth.estimateGas(%*[%tx])
|
response = eth.estimateGas(%*[%tx])
|
||||||
|
|
||||||
let res = fromHex[int](response.result.getStr)
|
let res = fromHex[int](response.result.getStr)
|
||||||
result = $(%* { "result": %res, "success": true })
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
error "Error estimating gas", msg = e.msg
|
error "Error estimating gas", msg = e.msg
|
||||||
result = $(%* { "result": "-1", "success": false, "error": { "message": e.msg } })
|
return $(%* { "result": "-1", "success": false })
|
||||||
|
|
||||||
|
|
||||||
proc transferEth*(
|
proc transferEth*(
|
||||||
self: Service,
|
self: Service,
|
||||||
|
|
Loading…
Reference in New Issue