chore(@wallet): remove dead code about estimage gas
This commit is contained in:
parent
b086d432d1
commit
364124b1ed
|
@ -100,12 +100,6 @@ proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairD
|
|||
proc loadTransactions*(self: Controller, address: string, toBlock: Uint256, limit: int = 20, loadMore: bool = false) =
|
||||
self.transactionService.loadTransactions(address, toBlock, limit, loadMore)
|
||||
|
||||
proc estimateGas*(self: Controller, from_addr: string, to: string, assetSymbol: string, value: string, data: string): string =
|
||||
try:
|
||||
result = self.transactionService.estimateGas(from_addr, to, assetSymbol, value, data)
|
||||
except Exception as e:
|
||||
result = "0"
|
||||
|
||||
proc transfer*(self: Controller, from_addr: string, to_addr: string, tokenSymbol: string,
|
||||
value: string, uuid: string, selectedRoutes: string, password: string) =
|
||||
self.transactionService.transfer(from_addr, to_addr, tokenSymbol, value, uuid, selectedRoutes, password)
|
||||
|
|
|
@ -37,9 +37,6 @@ method setHistoryFetchState*(self: AccessInterface, addresses: seq[string], isFe
|
|||
method setIsNonArchivalNode*(self: AccessInterface, isNonArchivalNode: bool) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method estimateGas*(self: AccessInterface, from_addr: string, to: string, assetSymbol: string, value: string, data: string): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method onUserAuthenticated*(self: AccessInterface, password: string) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
|
|
|
@ -91,9 +91,6 @@ method setTrxHistoryResult*(self: Module, transactions: seq[TransactionDto], add
|
|||
method setHistoryFetchState*(self: Module, addresses: seq[string], isFetching: bool) =
|
||||
self.view.setHistoryFetchStateForAccounts(addresses, isFetching)
|
||||
|
||||
method estimateGas*(self: Module, from_addr: string, to: string, assetSymbol: string, value: string, data: string): string =
|
||||
result = self.controller.estimateGas(from_addr, to, assetSymbol, value, data)
|
||||
|
||||
method setIsNonArchivalNode*(self: Module, isNonArchivalNode: bool) =
|
||||
self.view.setIsNonArchivalNode(isNonArchivalNode)
|
||||
|
||||
|
|
|
@ -105,9 +105,6 @@ QtObject:
|
|||
read = getIsNonArchivalNode
|
||||
notify = isNonArchivalNodeChanged
|
||||
|
||||
proc estimateGas*(self: View, from_addr: string, to: string, assetSymbol: string, value: string, data: string): string {.slot.} =
|
||||
result = self.delegate.estimateGas(from_addr, to, assetSymbol, value, data)
|
||||
|
||||
proc transactionSent*(self: View, txResult: string) {.signal.}
|
||||
|
||||
proc transactionWasSent*(self: View,txResult: string) {.slot} =
|
||||
|
|
|
@ -224,54 +224,6 @@ QtObject:
|
|||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
proc estimateGas*(
|
||||
self: Service,
|
||||
from_addr: string,
|
||||
to: string,
|
||||
assetSymbol: string,
|
||||
value: string,
|
||||
chainId: string,
|
||||
data: string = "",
|
||||
): string {.slot.} =
|
||||
var response: RpcResponse[JsonNode]
|
||||
var success: bool
|
||||
# TODO make this async
|
||||
let network = self.networkService.getNetwork(parseInt(chainId))
|
||||
|
||||
if network.nativeCurrencySymbol == assetSymbol:
|
||||
var tx = ens_utils.buildTransaction(
|
||||
parseAddress(from_addr),
|
||||
eth2Wei(parseFloat(value), 18),
|
||||
data = data
|
||||
)
|
||||
tx.to = parseAddress(to).some
|
||||
try:
|
||||
response = eth.estimateGas(parseInt(chainId), %*[%tx])
|
||||
let res = fromHex[int](response.result.getStr)
|
||||
return $(%* { "result": res, "success": true })
|
||||
except Exception as e:
|
||||
error "Error estimating gas", msg = e.msg
|
||||
return $(%* { "result": "-1", "success": false, "error": { "message": e.msg } })
|
||||
|
||||
let token = self.tokenService.findTokenBySymbol(network, assetSymbol)
|
||||
if token == nil:
|
||||
raise newException(ValueError, fmt"Could not find ERC-20 contract with symbol '{assetSymbol}' for the current network")
|
||||
|
||||
var tx = buildTokenTransaction(
|
||||
parseAddress(from_addr),
|
||||
token.address,
|
||||
)
|
||||
|
||||
let transfer = Transfer(to: parseAddress(to), value: conversion.eth2Wei(parseFloat(value), token.decimals))
|
||||
let transferproc = ERC20_procS.toTable["transfer"]
|
||||
try:
|
||||
let gas = transferproc.estimateGas(parseInt(chainId), tx, transfer, success)
|
||||
let res = fromHex[int](gas)
|
||||
return $(%* { "result": res, "success": success })
|
||||
except Exception as e:
|
||||
error "Error estimating gas", msg = e.msg
|
||||
return $(%* { "result": "-1", "success": false, "error": { "message": e.msg } })
|
||||
|
||||
proc transfer*(
|
||||
self: Service,
|
||||
from_addr: string,
|
||||
|
|
|
@ -111,9 +111,6 @@ QtObject {
|
|||
|
||||
property string currentCurrency: walletSection.currentCurrency
|
||||
property string signingPhrase: walletSection.signingPhrase
|
||||
function estimateGas(from_addr, to, assetSymbol, value, chainId, data) {
|
||||
return walletSectionTransactions.estimateGas(from_addr, to, assetSymbol, value, chainId, data)
|
||||
}
|
||||
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
||||
return profileSectionStore.ensUsernamesStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
||||
}
|
||||
|
|
|
@ -61,10 +61,6 @@ QtObject {
|
|||
globalUtils.copyToClipboard(text)
|
||||
}
|
||||
|
||||
function estimateGas(from_addr, to, assetSymbol, value, chainId, data) {
|
||||
return walletSectionTransactions.estimateGas(from_addr, to, assetSymbol, value, chainId, data)
|
||||
}
|
||||
|
||||
function getFiatValue(balance, cryptoSymbol, fiatSymbol) {
|
||||
return profileSectionStore.ensUsernamesStore.getFiatValue(balance, cryptoSymbol, fiatSymbol)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue