From ceb7f85e4ebc77d3e860e64d419d5c91f8e7ffbe Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Tue, 8 Jun 2021 11:20:54 -0400 Subject: [PATCH] remove most references to libstatus wallet --- src/app/chat/views/stickers.nim | 10 ++++------ src/app/profile/views/ens_manager.nim | 4 ++-- src/app/utilsView/view.nim | 5 ++--- src/app/wallet/core.nim | 1 - src/app/wallet/view.nim | 6 +++--- src/status/wallet.nim | 15 +++++++++++++++ 6 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/app/chat/views/stickers.nim b/src/app/chat/views/stickers.nim index b92a6b799d..7a436624b4 100644 --- a/src/app/chat/views/stickers.nim +++ b/src/app/chat/views/stickers.nim @@ -5,10 +5,8 @@ import # vendor libs chronicles, NimQml import # status-desktop libs - ../../../status/[status, stickers], ../../../status/libstatus/[types, utils], - ../../../status/libstatus/stickers as status_stickers, - ../../../status/libstatus/wallet as status_wallet, sticker_pack_list, - sticker_list, chat_item, ../../../status/tasks/[qt, task_runner_impl] + ../../../status/[status, stickers, wallet], ../../../status/libstatus/[types, utils], + ../../../status/libstatus/stickers as status_stickers, sticker_pack_list, sticker_list, chat_item, ../../../status/tasks/[qt, task_runner_impl] logScope: topics = "stickers-view" @@ -143,7 +141,7 @@ QtObject: proc setAvailableStickerPacks*(self: StickersView, availableStickersJSON: string) {.slot.} = let - accounts = status_wallet.getWalletAccounts() # TODO: make generic + accounts = self.status.wallet.getWalletAccounts() # TODO: make generic installedStickerPacks = self.status.stickers.getInstalledStickerPacks() var purchasedStickerPacks: seq[int] @@ -152,7 +150,7 @@ QtObject: purchasedStickerPacks = self.status.stickers.getPurchasedStickerPacks(address) let availableStickers = JSON.decode($availableStickersJSON, seq[StickerPack]) - let pendingTransactions = status_wallet.getPendingTransactions() + let pendingTransactions = self.status.wallet.getPendingTransactions() var pendingStickerPacks = initHashSet[int]() if (pendingTransactions != ""): for trx in pendingTransactions.parseJson{"result"}.getElems(): diff --git a/src/app/profile/views/ens_manager.nim b/src/app/profile/views/ens_manager.nim index 338a5ad538..90e468a7c0 100644 --- a/src/app/profile/views/ens_manager.nim +++ b/src/app/profile/views/ens_manager.nim @@ -8,7 +8,7 @@ import ../../../status/ens as status_ens import ../../../status/libstatus/wallet as status_wallet import ../../../status/libstatus/settings as status_settings import ../../../status/libstatus/utils as libstatus_utils -import ../../../status/[status, settings] +import ../../../status/[status, settings, wallet] import ../../../status/wallet import sets import web3/ethtypes @@ -108,7 +108,7 @@ QtObject: self.usernames = getSetting[seq[string]](self.status.settings, Setting.Usernames, @[]) # Get pending ens names - let pendingTransactions = status_wallet.getPendingTransactions() + let pendingTransactions = self.status.wallet.getPendingTransactions() if (pendingTransactions == ""): return for trx in pendingTransactions.parseJson{"result"}.getElems(): diff --git a/src/app/utilsView/view.nim b/src/app/utilsView/view.nim index 2526c2e762..02c7691b16 100644 --- a/src/app/utilsView/view.nim +++ b/src/app/utilsView/view.nim @@ -1,13 +1,12 @@ import NimQml, os, strformat, strutils, parseUtils, chronicles import stint -import ../../status/status +import ../../status/[status, wallet] import ../../status/accounts as status_accounts import ../../status/stickers import ../../status/libstatus/accounts/constants as accountConstants import ../../status/libstatus/tokens import ../../status/libstatus/types import ../../status/libstatus/settings -import ../../status/libstatus/wallet as status_wallet import ../../status/libstatus/utils as status_utils import ../../status/ens as status_ens import ../utils/image_utils @@ -49,7 +48,7 @@ QtObject: result = getSNTAddress() proc getSNTBalance*(self: UtilsView): string {.slot.} = - let currAcct = status_wallet.getWalletAccounts()[0] + let currAcct = self.status.wallet.getWalletAccounts()[0] result = getSNTBalance($currAcct.address) proc eth2Wei*(self: UtilsView, eth: string, decimals: int): string {.slot.} = diff --git a/src/app/wallet/core.nim b/src/app/wallet/core.nim index 76b939c3e8..764e0a40da 100644 --- a/src/app/wallet/core.nim +++ b/src/app/wallet/core.nim @@ -2,7 +2,6 @@ import NimQml, strformat, strutils, chronicles, sugar, sequtils import view import views/[asset_list, account_list, account_item] -import ../../status/libstatus/wallet as status_wallet import ../../status/libstatus/types as status_types import ../../status/signals/types import ../../status/[status, wallet, settings] diff --git a/src/app/wallet/view.nim b/src/app/wallet/view.nim index e23a3c261d..91fbafe775 100644 --- a/src/app/wallet/view.nim +++ b/src/app/wallet/view.nim @@ -554,7 +554,7 @@ QtObject: var addresses:seq[string] = @[] for acc in self.status.wallet.accounts: addresses.add(acc.address) - discard status_wallet.checkRecentHistory(addresses) + discard self.status.wallet.checkRecentHistory(addresses) proc transactionWatchResultReceived(self: WalletView, watchResult: string) {.slot.} = let wTxRes = watchResult.parseJSON()["result"].getStr().parseJson(){"result"} @@ -675,7 +675,7 @@ QtObject: read = defaultGasLimit proc getDefaultAddress*(self: WalletView): string {.slot.} = - result = $status_wallet.getWalletAccounts()[0].address + result = $self.status.wallet.getWalletAccounts()[0].address proc getDefaultTokenList(self: WalletView): QVariant {.slot.} = self.defaultTokenList.loadDefaultTokens() @@ -816,4 +816,4 @@ QtObject: notify = dappBrowserAccountChanged proc setInitialRange*(self: WalletView) {.slot.} = - discard status_wallet.setInitialBlocksRange() + discard self.status.wallet.setInitialBlocksRange() diff --git a/src/status/wallet.nim b/src/status/wallet.nim index 094cdcf384..866a3e720e 100644 --- a/src/status/wallet.nim +++ b/src/status/wallet.nim @@ -359,3 +359,18 @@ proc getGasPricePredictions*(): GasPricePrediction = except Exception as e: echo "error getting gas price predictions" echo e.msg + +proc checkRecentHistory*(self: WalletModel, addresses: seq[string]): string = + result = status_wallet.checkRecentHistory(addresses) + +proc setInitialBlocksRange*(self: WalletModel): string = + result = status_wallet.setInitialBlocksRange() + +proc getWalletAccounts*(self: WalletModel): seq[WalletAccount] = + result = status_wallet.getWalletAccounts() + +proc watchTransaction*(self: WalletModel, transactionHash: string): string = + result = status_wallet.watchTransaction(transactionHash) + +proc getPendingTransactions*(self: WalletModel): string = + result = status_wallet.getPendingTransactions()