Skip to content

Commit

Permalink
chore(@wallet): remove dead code about estimage gas
Browse files Browse the repository at this point in the history
  • Loading branch information
alaibe committed Jan 7, 2023
1 parent b086d43 commit 364124b
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
3 changes: 0 additions & 3 deletions src/app/modules/main/wallet_section/transactions/module.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions src/app/modules/main/wallet_section/transactions/view.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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} =
Expand Down
48 changes: 0 additions & 48 deletions src/app_service/service/transaction/service.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 0 additions & 3 deletions ui/app/AppLayouts/stores/RootStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 0 additions & 4 deletions ui/imports/shared/stores/TransactionStore.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 364124b

Please sign in to comment.