chore: refactor function to UtilsView
This commit is contained in:
parent
20f51a3647
commit
7e344b0d49
|
@ -100,12 +100,6 @@ QtObject:
|
||||||
QtProperty[QVariant] stickerPacks:
|
QtProperty[QVariant] stickerPacks:
|
||||||
read = getStickerPackList
|
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.} =
|
proc buyPackGasEstimate*(self: ChatsView, packId: int, address: string, price: string): int {.slot.} =
|
||||||
var success: bool
|
var success: bool
|
||||||
result = self.status.stickers.estimateGas(packId, address, price, success)
|
result = self.status.stickers.estimateGas(packId, address, price, success)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import NimQml, os
|
import NimQml, os, strformat, strutils, parseUtils
|
||||||
import ../../status/status
|
import ../../status/status
|
||||||
|
import ../../status/stickers
|
||||||
import ../../status/libstatus/accounts/constants as accountConstants
|
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:
|
QtObject:
|
||||||
type UtilsView* = ref object of QObject
|
type UtilsView* = ref object of QObject
|
||||||
|
@ -27,3 +31,21 @@ QtObject:
|
||||||
proc join3Paths*(self: UtilsView, start: string, middle: string, ending: string): string {.slot.} =
|
proc join3Paths*(self: UtilsView, start: string, middle: string, ending: string): string {.slot.} =
|
||||||
result = os.joinPath(start, middle, ending)
|
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
|
||||||
|
|
|
@ -487,13 +487,6 @@ QtObject:
|
||||||
QtProperty[string] defaultGasLimit:
|
QtProperty[string] defaultGasLimit:
|
||||||
read = 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.} =
|
proc getDefaultAddress*(self: WalletView): string {.slot.} =
|
||||||
result = $status_wallet.getWalletAccounts()[0].address
|
result = $status_wallet.getWalletAccounts()[0].address
|
||||||
|
|
||||||
|
@ -546,12 +539,6 @@ QtObject:
|
||||||
self.setCurrentTransactions(transactions)
|
self.setCurrentTransactions(transactions)
|
||||||
self.loadingTrxHistory(false)
|
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.} =
|
proc resolveENS*(self: WalletView, ens: string) {.slot.} =
|
||||||
spawnAndSend(self, "ensResolved") do:
|
spawnAndSend(self, "ensResolved") do:
|
||||||
status_ens.owner(ens)
|
status_ens.owner(ens)
|
||||||
|
|
Loading…
Reference in New Issue