parent
007ed915cc
commit
56bd8c74b8
|
@ -109,11 +109,11 @@ const timerTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
|||
|
||||
type
|
||||
BuildTokensTaskArg = ref object of QObjectTaskArg
|
||||
discard
|
||||
accounts: seq[string]
|
||||
|
||||
const prepareTokensTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[BuildTokensTaskArg](argEncoded)
|
||||
let response = backend.getWalletToken()
|
||||
let response = backend.getWalletToken(arg.accounts)
|
||||
arg.finish(response.result)
|
||||
|
||||
#################################################
|
||||
|
|
|
@ -116,7 +116,7 @@ QtObject:
|
|||
isHistoryFetchTimerAlreadyRunning: bool
|
||||
|
||||
# Forward declaration
|
||||
proc buildAllTokens(self: Service)
|
||||
proc buildAllTokens(self: Service, accounts: seq[string])
|
||||
proc checkRecentHistory*(self: Service)
|
||||
proc startWallet(self: Service)
|
||||
|
||||
|
@ -171,6 +171,9 @@ QtObject:
|
|||
x => x.toWalletAccountDto()
|
||||
).filter(a => not a.isChat)
|
||||
|
||||
proc getAddresses(self: Service): seq[string] =
|
||||
return toSeq(self.walletAccounts.keys())
|
||||
|
||||
proc init*(self: Service) =
|
||||
signalConnect(singletonInstance.localAccountSensitiveSettings, "isWalletEnabledChanged()", self, "onIsWalletEnabledChanged()", 2)
|
||||
|
||||
|
@ -180,7 +183,7 @@ QtObject:
|
|||
account.relatedAccounts = accounts.filter(x => not account.derivedFrom.isEmptyOrWhitespace and (cmpIgnoreCase(x.derivedFrom, account.derivedFrom) == 0))
|
||||
self.walletAccounts[account.address] = account
|
||||
|
||||
self.buildAllTokens()
|
||||
self.buildAllTokens(self.getAddresses())
|
||||
self.checkRecentHistory()
|
||||
self.startWallet()
|
||||
except Exception as e:
|
||||
|
@ -199,8 +202,8 @@ QtObject:
|
|||
var data = WalletSignal(e)
|
||||
case data.eventType:
|
||||
of "wallet-tick-reload":
|
||||
self.checkRecentHistory()
|
||||
self.buildAllTokens()
|
||||
self.buildAllTokens(self.getAddresses())
|
||||
self.checkRecentHistory()
|
||||
|
||||
|
||||
proc getAccountByAddress*(self: Service, address: string): WalletAccountDto =
|
||||
|
@ -250,7 +253,7 @@ QtObject:
|
|||
newAccount.relatedAccounts = accounts.filter(x => cmpIgnoreCase(x.derivedFrom, account.derivedFrom) == 0)
|
||||
break
|
||||
self.walletAccounts[newAccount.address] = newAccount
|
||||
self.buildAllTokens()
|
||||
self.buildAllTokens(@[newAccount.address])
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_SAVED, AccountSaved(account: newAccount))
|
||||
|
||||
proc generateNewAccount*(self: Service, password: string, accountName: string, color: string, emoji: string,
|
||||
|
@ -347,7 +350,7 @@ QtObject:
|
|||
|
||||
proc updateCurrency*(self: Service, newCurrency: string) =
|
||||
discard self.settingsService.saveCurrency(newCurrency)
|
||||
self.buildAllTokens()
|
||||
self.buildAllTokens(self.getAddresses())
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_CURRENCY_UPDATED, CurrencyUpdated())
|
||||
|
||||
proc toggleNetworkEnabled*(self: Service, chainId: int) =
|
||||
|
@ -454,15 +457,15 @@ QtObject:
|
|||
if(responseObj.getProp(wAddress, tokensArr)):
|
||||
tokens = map(tokensArr.getElems(), proc(x: JsonNode): WalletTokenDto = x.toWalletTokenDto())
|
||||
|
||||
tokens.sort(priorityTokenCmp)
|
||||
self.walletAccounts[wAddress].tokens = tokens
|
||||
data.accountsTokens[wAddress] = tokens
|
||||
tokens.sort(priorityTokenCmp)
|
||||
self.walletAccounts[wAddress].tokens = tokens
|
||||
data.accountsTokens[wAddress] = tokens
|
||||
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT, data)
|
||||
except Exception as e:
|
||||
error "error: ", procName="onAllTokensBuilt", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc buildAllTokens(self: Service) =
|
||||
proc buildAllTokens(self: Service, accounts: seq[string]) =
|
||||
if(not singletonInstance.localAccountSensitiveSettings.getIsWalletEnabled()):
|
||||
return
|
||||
|
||||
|
@ -470,11 +473,12 @@ QtObject:
|
|||
tptr: cast[ByteAddress](prepareTokensTask),
|
||||
vptr: cast[ByteAddress](self.vptr),
|
||||
slot: "onAllTokensBuilt",
|
||||
accounts: accounts
|
||||
)
|
||||
self.threadpool.start(arg)
|
||||
|
||||
proc onIsWalletEnabledChanged*(self: Service) {.slot.} =
|
||||
self.buildAllTokens()
|
||||
self.buildAllTokens(self.getAddresses())
|
||||
self.checkRecentHistory()
|
||||
self.startWallet()
|
||||
|
||||
|
@ -610,5 +614,5 @@ QtObject:
|
|||
return "(" & $response.error.code & ") " & response.error.message
|
||||
self.addNewAccountToLocalStore()
|
||||
except Exception as e:
|
||||
error "error: ", procName="deleteKeycard", errName = e.name, errDesription = e.msg
|
||||
error "error: ", procName="addWalletAccount", errName = e.name, errDesription = e.msg
|
||||
return "error: " & e.msg
|
|
@ -89,7 +89,7 @@ rpc(getPendingTransactionsByChainIDs, "wallet"):
|
|||
chainIds: seq[int]
|
||||
|
||||
rpc(getWalletToken, "wallet"):
|
||||
discard
|
||||
accounts: seq[string]
|
||||
|
||||
rpc(startWallet, "wallet"):
|
||||
discard
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 8ac154ee0cf0e113d7d8b06c9cd4e4f8caf3322e
|
||||
Subproject commit d7bf19fdbb9805ffd7106d10b7b0211dbb614257
|
Loading…
Reference in New Issue