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