mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-16 16:47:24 +00:00
parent
f71870cb8f
commit
eb726a315c
@ -131,9 +131,6 @@ QtObject:
|
||||
proc setDappBrowserAddress*(self: WalletView) {.slot.} =
|
||||
self.dappBrowserView.setDappBrowserAddress()
|
||||
|
||||
proc loadTransactionsForAccount*(self: WalletView, address: string) {.slot.} =
|
||||
self.historyView.loadTransactionsForAccount(address)
|
||||
|
||||
proc setHistoryFetchState*(self: WalletView, accounts: seq[string], isFetching: bool) =
|
||||
self.historyView.setHistoryFetchState(accounts, isFetching)
|
||||
|
||||
|
@ -4,6 +4,7 @@ import NimQml, json, sequtils, chronicles, strutils, strformat, json
|
||||
|
||||
import
|
||||
../../../status/[status, settings, wallet, tokens, types, utils],
|
||||
../../../status/wallet as status_wallet,
|
||||
../../../status/tasks/[qt, task_runner_impl]
|
||||
|
||||
import account_list, account_item, transaction_list, accounts, asset_list, token_list, transactions
|
||||
@ -11,6 +12,32 @@ import account_list, account_item, transaction_list, accounts, asset_list, token
|
||||
logScope:
|
||||
topics = "history-view"
|
||||
|
||||
type
|
||||
LoadTransactionsTaskArg = ref object of QObjectTaskArg
|
||||
address: string
|
||||
toBlock: Uint256
|
||||
limit: int
|
||||
loadMore: bool
|
||||
|
||||
const loadTransactionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let
|
||||
arg = decode[LoadTransactionsTaskArg](argEncoded)
|
||||
output = %*{
|
||||
"address": arg.address,
|
||||
"history": status_wallet.getTransfersByAddress(arg.address, arg.toBlock, arg.limit, arg.loadMore),
|
||||
"loadMore": arg.loadMore
|
||||
}
|
||||
arg.finish(output)
|
||||
|
||||
proc loadTransactions*[T](self: T, slot: string, address: string, toBlock: Uint256, limit: int, loadMore: bool) =
|
||||
let arg = LoadTransactionsTaskArg(
|
||||
tptr: cast[ByteAddress](loadTransactionsTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: slot, address: address,
|
||||
toBlock: toBlock, limit: limit, loadMore: loadMore
|
||||
)
|
||||
self.status.tasks.threadpool.start(arg)
|
||||
|
||||
QtObject:
|
||||
type HistoryView* = ref object of QObject
|
||||
status: Status
|
||||
@ -46,19 +73,11 @@ QtObject:
|
||||
|
||||
proc loadingTrxHistoryChanged*(self: HistoryView, isLoading: bool, address: string) {.signal.}
|
||||
|
||||
# proc loadTransactionsForAccount*(self: HistoryView, address: string) {.slot.} =
|
||||
# self.loadingTrxHistoryChanged(true)
|
||||
# self.transactionsView.loadTransactions("setTrxHistoryResult", address)
|
||||
|
||||
proc loadTransactionsForAccount*(self: HistoryView, address: string, toBlock: string = "0x0", limit: int = 20, loadMore: bool = false) {.slot.} =
|
||||
self.loadingTrxHistoryChanged(true, address)
|
||||
let toBlockParsed = stint.fromHex(Uint256, toBlock)
|
||||
self.loadTransactions("setTrxHistoryResult", address, toBlockParsed, limit, loadMore)
|
||||
|
||||
# proc getLatestTransactionHistory*(self: HistoryView, accounts: seq[string]) =
|
||||
# for acc in accounts:
|
||||
# self.loadTransactionsForAccount(acc)
|
||||
|
||||
proc setTrxHistoryResult(self: HistoryView, historyJSON: string) {.slot.} =
|
||||
let
|
||||
historyData = parseJson(historyJSON)
|
||||
|
@ -36,6 +36,8 @@ QtObject:
|
||||
result.setup
|
||||
|
||||
proc getLastTxBlockNumber*(self: TransactionList): string {.slot.} =
|
||||
if (self.transactions.len == 0):
|
||||
return "0x0"
|
||||
return self.transactions[^1].blockNumber
|
||||
|
||||
method rowCount*(self: TransactionList, index: QModelIndex = nil): int =
|
||||
|
@ -23,11 +23,6 @@ type
|
||||
gasPrice: string
|
||||
password: string
|
||||
uuid: string
|
||||
LoadTransactionsTaskArg = ref object of QObjectTaskArg
|
||||
address: string
|
||||
toBlock: Uint256
|
||||
limit: int
|
||||
loadMore: bool
|
||||
WatchTransactionTaskArg = ref object of QObjectTaskArg
|
||||
transactionHash: string
|
||||
|
||||
@ -53,25 +48,6 @@ proc sendTransaction[T](self: T, slot: string, from_addr: string, to: string, as
|
||||
)
|
||||
self.status.tasks.threadpool.start(arg)
|
||||
|
||||
const loadTransactionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let
|
||||
arg = decode[LoadTransactionsTaskArg](argEncoded)
|
||||
output = %*{
|
||||
"address": arg.address,
|
||||
"history": status_wallet.getTransfersByAddress(arg.address, arg.toBlock, arg.limit, arg.loadMore),
|
||||
"loadMore": arg.loadMore
|
||||
}
|
||||
arg.finish(output)
|
||||
|
||||
proc loadTransactions*[T](self: T, slot: string, address: string, toBlock: Uint256, limit: int, loadMore: bool) =
|
||||
let arg = LoadTransactionsTaskArg(
|
||||
tptr: cast[ByteAddress](loadTransactionsTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: slot, address: address,
|
||||
toBlock: toBlock, limit: limit, loadMore: loadMore
|
||||
)
|
||||
self.status.tasks.threadpool.start(arg)
|
||||
|
||||
const watchTransactionTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let
|
||||
arg = decode[WatchTransactionTaskArg](argEncoded)
|
||||
|
@ -30,12 +30,12 @@ Item {
|
||||
}
|
||||
|
||||
function fetchHistory() {
|
||||
if (walletModel.isFetchingHistory()) {
|
||||
if (walletModel.historyView.isFetchingHistory(walletModel.accountsView.currentAccount.address)) {
|
||||
loadingImg.active = true
|
||||
} else {
|
||||
walletModel.loadTransactionsForAccount(
|
||||
walletModel.currentAccount.address,
|
||||
walletModel.transactions.getLastTxBlockNumber(),
|
||||
walletModel.historyView.loadTransactionsForAccount(
|
||||
walletModel.accountsView.currentAccount.address,
|
||||
walletModel.transactionsView.transactions.getLastTxBlockNumber(),
|
||||
pageSize,
|
||||
true)
|
||||
}
|
||||
@ -72,7 +72,7 @@ Item {
|
||||
target: walletModel.historyView
|
||||
// onHistoryWasFetched: checkIfHistoryIsBeingFetched()
|
||||
onLoadingTrxHistoryChanged: {
|
||||
if (walletModel.currentAccount.address.toLowerCase() === address.toLowerCase()) {
|
||||
if (walletModel.accountsView.currentAccount.address.toLowerCase() === address.toLowerCase()) {
|
||||
loadingImg.active = isLoading
|
||||
}
|
||||
}
|
||||
@ -267,7 +267,7 @@ Item {
|
||||
text: qsTrId("load-more")
|
||||
// TODO: handle case when requested limit === transaction count -- there
|
||||
// is currently no way to know that there are no more results
|
||||
enabled: !loadingImg.active && walletModel.transactions.hasMore
|
||||
enabled: !loadingImg.active && walletModel.transactionsView.transactions.hasMore
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.bottomMargin: Style.current.padding
|
||||
|
Loading…
x
Reference in New Issue
Block a user