chore: refactor function to UtilsView

This commit is contained in:
hydr063n 2020-09-28 09:46:46 +02:00 committed by Iuri Matias
parent 20f51a3647
commit 7e344b0d49
3 changed files with 23 additions and 20 deletions

View File

@ -100,12 +100,6 @@ QtObject:
QtProperty[QVariant] stickerPacks:
read = getStickerPackList
proc getStickerMarketAddress(self: ChatsView): QVariant {.slot.} =
newQVariant($self.status.stickers.getStickerMarketAddress)
QtProperty[QVariant] stickerMarketAddress:
read = getStickerMarketAddress
proc buyPackGasEstimate*(self: ChatsView, packId: int, address: string, price: string): int {.slot.} =
var success: bool
result = self.status.stickers.estimateGas(packId, address, price, success)

View File

@ -1,6 +1,10 @@
import NimQml, os
import NimQml, os, strformat, strutils, parseUtils
import ../../status/status
import ../../status/stickers
import ../../status/libstatus/accounts/constants as accountConstants
import ../../status/libstatus/tokens
import ../../status/libstatus/wallet as status_wallet
import ../../status/libstatus/utils as status_utils
QtObject:
type UtilsView* = ref object of QObject
@ -27,3 +31,21 @@ QtObject:
proc join3Paths*(self: UtilsView, start: string, middle: string, ending: string): string {.slot.} =
result = os.joinPath(start, middle, ending)
proc getSNTAddress*(self: UtilsView): string {.slot.} =
result = getSNTAddress()
proc getSNTBalance*(self: UtilsView): string {.slot.} =
let currAcct = status_wallet.getWalletAccounts()[0]
result = getSNTBalance($currAcct.address)
proc eth2Wei*(self: UtilsView, eth: string, decimals: int): string {.slot.} =
return $status_utils.eth2Wei(parseFloat(eth), decimals)
proc wei2Token*(self: UtilsView, wei: string, decimals: int): string {.slot.} =
return status_utils.wei2Token(wei, decimals)
proc getStickerMarketAddress(self: UtilsView): QVariant {.slot.} =
newQVariant($self.status.stickers.getStickerMarketAddress)
QtProperty[QVariant] stickerMarketAddress:
read = getStickerMarketAddress

View File

@ -487,13 +487,6 @@ QtObject:
QtProperty[string] defaultGasLimit:
read = defaultGasLimit
proc getSNTAddress*(self: WalletView): string {.slot.} =
result = getSNTAddress()
proc getSNTBalance*(self: WalletView): string {.slot.} =
let currAcct = status_wallet.getWalletAccounts()[0]
result = getSNTBalance($currAcct.address)
proc getDefaultAddress*(self: WalletView): string {.slot.} =
result = $status_wallet.getWalletAccounts()[0].address
@ -546,12 +539,6 @@ QtObject:
self.setCurrentTransactions(transactions)
self.loadingTrxHistory(false)
proc eth2Wei*(self: WalletView, eth: string, decimals: int): string {.slot.} =
return $status_utils.eth2Wei(parseFloat(eth), decimals)
proc wei2Token*(self: WalletView, wei: string, decimals: int): string {.slot.} =
return status_utils.wei2Token(wei, decimals)
proc resolveENS*(self: WalletView, ens: string) {.slot.} =
spawnAndSend(self, "ensResolved") do:
status_ens.owner(ens)