chore(@wallet): remove dead code about estimage gas

This commit is contained in:
Anthony Laibe 2023-01-06 12:29:08 +01:00 committed by Anthony Laibe
parent b086d432d1
commit 364124b1ed
7 changed files with 0 additions and 70 deletions

View File

@ -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)

View File

@ -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")

View File

@ -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)

View File

@ -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} =

View File

@ -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,

View File

@ -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)
}

View File

@ -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)
}