fix(wallet): fix loading of initial balances
This commit is contained in:
parent
eb726a315c
commit
b720a611c4
|
@ -101,14 +101,27 @@ QtObject:
|
|||
if loadTransactions:
|
||||
self.historyView.loadTransactionsForAccount(accountAddress)
|
||||
|
||||
proc initBalance(self: BalanceView, acc: WalletAccount, loadTransactions: bool = true) =
|
||||
let
|
||||
accountAddress = acc.address
|
||||
tokenList = acc.assetList.filter(proc(x:Asset): bool = x.address != "").map(proc(x: Asset): string = x.address)
|
||||
self.initBalances("getAccountBalanceSuccess", accountAddress, tokenList)
|
||||
if loadTransactions:
|
||||
self.historyView.loadTransactionsForAccount(accountAddress)
|
||||
|
||||
proc initBalance*(self: BalanceView, accountAddress: string, loadTransactions: bool = true) =
|
||||
echo "initBalance"
|
||||
#var found = false
|
||||
#let acc = self.status.wallet.accounts.find(acc => acc.address.toLowerAscii == accountAddress.toLowerAscii, found)
|
||||
#if not found:
|
||||
# error "Failed to init balance: could not find account", account=accountAddress
|
||||
# return
|
||||
#self.initBalance(acc, loadTransactions)
|
||||
var found = false
|
||||
var acc: WalletAccount
|
||||
for a in self.status.wallet.accounts:
|
||||
if a.address.toLowerAscii == accountAddress.toLowerAscii:
|
||||
found = true
|
||||
acc = a
|
||||
break
|
||||
|
||||
if not found:
|
||||
error "Failed to init balance: could not find account", account=accountAddress
|
||||
return
|
||||
self.initBalance(acc, loadTransactions)
|
||||
|
||||
proc getAccountBalanceSuccess*(self: BalanceView, jsonResponse: string) {.slot.} =
|
||||
let jsonObj = jsonResponse.parseJson()
|
||||
|
|
|
@ -33,8 +33,11 @@ proc loadTransactions*[T](self: T, slot: string, address: string, toBlock: Uint2
|
|||
let arg = LoadTransactionsTaskArg(
|
||||
tptr: cast[ByteAddress](loadTransactionsTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: slot, address: address,
|
||||
toBlock: toBlock, limit: limit, loadMore: loadMore
|
||||
slot: slot,
|
||||
address: address,
|
||||
toBlock: toBlock,
|
||||
limit: limit,
|
||||
loadMore: loadMore
|
||||
)
|
||||
self.status.tasks.threadpool.start(arg)
|
||||
|
||||
|
@ -58,10 +61,12 @@ QtObject:
|
|||
|
||||
proc historyWasFetched*(self: HistoryView) {.signal.}
|
||||
|
||||
proc loadingTrxHistoryChanged*(self: HistoryView, isLoading: bool, address: string) {.signal.}
|
||||
|
||||
proc setHistoryFetchState*(self: HistoryView, accounts: seq[string], isFetching: bool) =
|
||||
for acc in accounts:
|
||||
self.fetchingHistoryState[acc] = isFetching
|
||||
if not isFetching: self.historyWasFetched()
|
||||
self.loadingTrxHistoryChanged(isFetching, acc)
|
||||
|
||||
proc isFetchingHistory*(self: HistoryView, address: string): bool {.slot.} =
|
||||
if self.fetchingHistoryState.hasKey(address):
|
||||
|
@ -71,8 +76,6 @@ QtObject:
|
|||
proc isHistoryFetched*(self: HistoryView, address: string): bool {.slot.} =
|
||||
return self.transactionsView.currentTransactions.rowCount() > 0
|
||||
|
||||
proc loadingTrxHistoryChanged*(self: HistoryView, isLoading: bool, address: string) {.signal.}
|
||||
|
||||
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)
|
||||
|
|
|
@ -340,7 +340,7 @@ proc addCustomToken*(self: WalletModel, symbol: string, enable: bool, address: s
|
|||
addCustomToken(address, name, symbol, decimals, color)
|
||||
|
||||
proc getTransfersByAddress*(self: WalletModel, address: string, toBlock: Uint256, limit: int, loadMore: bool): seq[Transaction] =
|
||||
result = status_wallet.getTransfersByAddress(address, toBlock, limit, loadMore)
|
||||
result = status_wallet.getTransfersByAddress(address, toBlock, limit, loadMore)
|
||||
|
||||
proc validateMnemonic*(self: WalletModel, mnemonic: string): string =
|
||||
result = status_wallet.validateMnemonic(mnemonic).parseJSON()["error"].getStr
|
||||
|
|
|
@ -11,19 +11,19 @@ import "../../../shared/status"
|
|||
Item {
|
||||
property int pageSize: 20 // number of transactions per page
|
||||
property var tokens: {
|
||||
const count = walletModel.tokensView.defaultTokenList.rowCount()
|
||||
let count = walletModel.tokensView.defaultTokenList.rowCount()
|
||||
const toks = []
|
||||
for (var i = 0; i < count; i++) {
|
||||
for (let i = 0; i < count; i++) {
|
||||
toks.push({
|
||||
"address": walletModel.tokensView.defaultTokenList.rowData(i, 'address'),
|
||||
"symbol": walletModel.tokensView.defaultTokenList.rowData(i, 'symbol')
|
||||
})
|
||||
}
|
||||
count = walletModel.customTokenList.rowCount()
|
||||
for (var i = 0; i < count; i++) {
|
||||
count = walletModel.tokensView.customTokenList.rowCount()
|
||||
for (let j = 0; j < count; j++) {
|
||||
toks.push({
|
||||
"address": walletModel.customTokenList.rowData(i, 'address'),
|
||||
"symbol": walletModel.customTokenList.rowData(i, 'symbol')
|
||||
"address": walletModel.customTokenList.rowData(j, 'address'),
|
||||
"symbol": walletModel.customTokenList.rowData(j, 'symbol')
|
||||
})
|
||||
}
|
||||
return toks
|
||||
|
|
Loading…
Reference in New Issue