feat(wallet)_: add backend support for wallet reload functionality
- Added `reloadAccountTokens` method to `Controller`, `AccessInterface`, and `Module` in `wallet_section` to trigger wallet reload. - Updated `view` in `wallet_section` to handle new properties `isAccountTokensReloading` and `lastReloadTimestamp`. - Emitted `SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT` with a timestamp in `service_token`. - Implemented `restartWalletReloadTimer` RPC in `backend`. resolves: #13652
This commit is contained in:
parent
35b64f0483
commit
8a3d24bc3a
|
@ -68,3 +68,6 @@ proc getKeypairByAccountAddress*(self: Controller, address: string): KeypairDto
|
|||
|
||||
proc hasPairedDevices*(self: Controller): bool =
|
||||
return self.walletAccountService.hasPairedDevices()
|
||||
|
||||
proc reloadAccountTokens*(self: Controller) =
|
||||
self.walletAccountService.reloadAccountTokens()
|
||||
|
|
|
@ -119,4 +119,7 @@ method resetRpcStats*(self: AccessInterface) {.base.} =
|
|||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method canProfileProveOwnershipOfProvidedAddresses*(self: AccessInterface, addresses: string): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method reloadAccountTokens*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
|
|
@ -283,8 +283,11 @@ method load*(self: Module) =
|
|||
self.setTotalCurrencyBalance()
|
||||
self.notifyFilterChanged()
|
||||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args):
|
||||
let args = TokensPerAccountArgs(e)
|
||||
self.setTotalCurrencyBalance()
|
||||
self.notifyModulesBalanceIsLoaded()
|
||||
self.view.setLastReloadTimestamp(args.timestamp)
|
||||
self.view.setIsAccountTokensReloading(false)
|
||||
self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args):
|
||||
self.setTotalCurrencyBalance()
|
||||
self.notifyFilterChanged()
|
||||
|
@ -522,3 +525,7 @@ method canProfileProveOwnershipOfProvidedAddresses*(self: Module, addresses: str
|
|||
if keypair.migratedToKeycard():
|
||||
return false
|
||||
return true
|
||||
|
||||
method reloadAccountTokens*(self: Module) =
|
||||
self.view.setIsAccountTokensReloading(true)
|
||||
self.controller.reloadAccountTokens()
|
||||
|
|
|
@ -29,6 +29,8 @@ QtObject:
|
|||
walletReady: bool
|
||||
addressFilters: string
|
||||
currentCurrency: string
|
||||
isAccountTokensReloading: bool
|
||||
lastReloadTimestamp: int64
|
||||
|
||||
proc setup(self: View) =
|
||||
self.QObject.setup
|
||||
|
@ -266,4 +268,34 @@ QtObject:
|
|||
self.delegate.resetRpcStats()
|
||||
|
||||
proc canProfileProveOwnershipOfProvidedAddresses*(self: View, addresses: string): bool {.slot.} =
|
||||
return self.delegate.canProfileProveOwnershipOfProvidedAddresses(addresses)
|
||||
return self.delegate.canProfileProveOwnershipOfProvidedAddresses(addresses)
|
||||
|
||||
proc reloadAccountTokens*(self: View) {.slot.} =
|
||||
self.delegate.reloadAccountTokens()
|
||||
|
||||
proc lastReloadTimestampChanged*(self: View) {.signal.}
|
||||
|
||||
proc setLastReloadTimestamp*(self: View, lastReloadTimestamp: int64) =
|
||||
self.lastReloadTimestamp = lastReloadTimestamp
|
||||
self.lastReloadTimestampChanged()
|
||||
|
||||
proc getLastReloadTimestamp(self: View): QVariant {.slot.} =
|
||||
return newQVariant(self.lastReloadTimestamp)
|
||||
|
||||
QtProperty[QVariant] lastReloadTimestamp:
|
||||
read = getLastReloadTimestamp
|
||||
notify = lastReloadTimestampChanged
|
||||
|
||||
proc isAccountTokensReloadingChanged*(self: View) {.signal.}
|
||||
|
||||
proc setIsAccountTokensReloading*(self: View, isAccountTokensReloading: bool) =
|
||||
self.isAccountTokensReloading = isAccountTokensReloading
|
||||
self.isAccountTokensReloadingChanged()
|
||||
|
||||
proc getIsAccountTokensReloading(self: View): bool {.slot.} =
|
||||
return self.isAccountTokensReloading
|
||||
|
||||
QtProperty[bool] isAccountTokensReloading:
|
||||
read = getIsAccountTokensReloading
|
||||
notify = isAccountTokensReloadingChanged
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
proc onAllTokensBuilt*(self: Service, response: string) {.slot.} =
|
||||
var accountAddresses: seq[string] = @[]
|
||||
var accountTokens: seq[GroupedTokenItem] = @[]
|
||||
defer: self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT, TokensPerAccountArgs(accountAddresses:accountAddresses, accountTokens: accountTokens))
|
||||
defer:
|
||||
let timestamp = getTime().toUnix()
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT, TokensPerAccountArgs(accountAddresses:accountAddresses, accountTokens: accountTokens, timestamp: timestamp))
|
||||
try:
|
||||
let responseObj = response.parseJson
|
||||
var storeResult: bool
|
||||
|
@ -166,6 +168,12 @@ proc checkRecentHistory*(self: Service, addresses: seq[string]) =
|
|||
error "error: ", errDescription
|
||||
|
||||
proc reloadAccountTokens*(self: Service) =
|
||||
try:
|
||||
discard backend.restartWalletReloadTimer()
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
error "error restartWalletReloadTimer: ", errDesription
|
||||
|
||||
let addresses = self.getWalletAddresses()
|
||||
self.buildAllTokens(addresses, store = true)
|
||||
self.checkRecentHistory(addresses)
|
||||
|
|
|
@ -72,6 +72,7 @@ type DerivedAddressesArgs* = ref object of Args
|
|||
type TokensPerAccountArgs* = ref object of Args
|
||||
accountAddresses*: seq[string]
|
||||
accountTokens*: seq[GroupedTokenItem]
|
||||
timestamp*: int64
|
||||
|
||||
type KeycardActivityArgs* = ref object of Args
|
||||
success*: bool
|
||||
|
|
|
@ -331,3 +331,6 @@ rpc(getBalancesByChain, "wallet"):
|
|||
chainIds: seq[int]
|
||||
addresses: seq[string]
|
||||
tokenAddresses: seq[string]
|
||||
|
||||
rpc(restartWalletReloadTimer, "wallet"):
|
||||
discard
|
||||
|
|
Loading…
Reference in New Issue