diff --git a/src/app/modules/main/wallet_section/assets/controller.nim b/src/app/modules/main/wallet_section/assets/controller.nim index 169b440e00..13257d1b96 100644 --- a/src/app/modules/main/wallet_section/assets/controller.nim +++ b/src/app/modules/main/wallet_section/assets/controller.nim @@ -30,8 +30,12 @@ proc newController*( proc delete*(self: Controller) = discard +proc buildAllTokens*(self: Controller, addresses: seq[string]) = + self.walletAccountService.buildAllTokens(addresses, store = true) + proc init*(self: Controller) = - self.walletAccountService.buildAllTokens(self.walletAccountService.getWalletAddresses(), store = true) + let walletAddresses = self.walletAccountService.getWalletAddresses() + self.buildAllTokens(walletAddresses) discard proc getChainIds*(self: Controller): seq[int] = diff --git a/src/app/modules/main/wallet_section/assets/module.nim b/src/app/modules/main/wallet_section/assets/module.nim index e8bfb8d583..62e343cd8f 100644 --- a/src/app/modules/main/wallet_section/assets/module.nim +++ b/src/app/modules/main/wallet_section/assets/module.nim @@ -70,3 +70,6 @@ method getGroupedAccountAssetsDataSource*(self: Module): GroupedAccountAssetsDat return ( getGroupedAccountsAssetsList: proc(): var seq[GroupedTokenItem] = self.controller.getGroupedAccountsAssetsList() ) + +method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) = + self.controller.buildAllTokens(addresses) diff --git a/src/app/modules/main/wallet_section/filter.nim b/src/app/modules/main/wallet_section/filter.nim index 13569849eb..f08ac34c6a 100644 --- a/src/app/modules/main/wallet_section/filter.nim +++ b/src/app/modules/main/wallet_section/filter.nim @@ -23,13 +23,16 @@ proc `$`*(self: Filter): string = chainIds: {self.chainIds}, )""" +proc setAddresses*(self: Filter, addresses: seq[string]) = + self.addresses = addresses + proc setAddress*(self: Filter, address: string) = - self.addresses = @[address] + self.setAddresses(@[address]) proc removeAddress*(self: Filter, address: string) = if len(self.addresses) == 1 and self.addresses[0] == address: let accounts = self.controller.getWalletAccounts() - self.addresses = @[accounts[0].address] + self.setAddresses(@[accounts[0].address]) return let ind = self.addresses.find(address) diff --git a/src/app/modules/main/wallet_section/io_interface.nim b/src/app/modules/main/wallet_section/io_interface.nim index b335ebb552..845d2005c9 100644 --- a/src/app/modules/main/wallet_section/io_interface.nim +++ b/src/app/modules/main/wallet_section/io_interface.nim @@ -18,6 +18,9 @@ method isLoaded*(self: AccessInterface): bool {.base.} = method setFilterAddress*(self: AccessInterface, address: string) {.base.} = raise newException(ValueError, "No implementation available") +method setFilterAllAddresses*(self: AccessInterface) {.base.} = + raise newException(ValueError, "No implementation available") + method updateCurrency*(self: AccessInterface, currency: string) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/wallet_section/module.nim b/src/app/modules/main/wallet_section/module.nim index f4a756dc1f..76b6f3ea0d 100644 --- a/src/app/modules/main/wallet_section/module.nim +++ b/src/app/modules/main/wallet_section/module.nim @@ -192,20 +192,32 @@ method updateCurrency*(self: Module, currency: string) = method getCurrentCurrency*(self: Module): string = self.controller.getCurrency() -method setTotalCurrencyBalance*(self: Module) = +proc getWalletAddressesNotHidden(self: Module): seq[string] = let walletAccounts = self.controller.getWalletAccounts() - var addresses = walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address) + return walletAccounts.filter(a => not a.hideFromTotalBalance).map(a => a.address) + +method setTotalCurrencyBalance*(self: Module) = + let addresses = self.getWalletAddressesNotHidden() self.view.setTotalCurrencyBalance(self.controller.getTotalCurrencyBalance(addresses, self.filter.chainIds)) -proc notifyFilterChanged(self: Module) = +proc notifyModulesOnFilterChanged(self: Module) = self.overviewModule.filterChanged(self.filter.addresses, self.filter.chainIds) self.accountsModule.filterChanged(self.filter.addresses, self.filter.chainIds) self.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds) self.activityController.globalFilterChanged(self.filter.addresses, self.filter.chainIds, self.filter.allChainsEnabled) self.allTokensModule.filterChanged(self.filter.addresses) - self.view.setAddressFilters(self.filter.addresses.join(":")) - if self.filter.addresses.len > 0: - self.view.filterChanged(self.filter.addresses[0]) + self.allCollectiblesModule.refreshWalletAccounts() + self.assetsModule.filterChanged(self.filter.addresses, self.filter.chainIds) + +proc updateViewWithAddressFilterChanged(self: Module) = + if self.overviewModule.getIsAllAccounts(): + self.view.filterChanged("") + else: + self.view.filterChanged(self.view.getAddressFilters()) + +proc notifyFilterChanged(self: Module) = + self.updateViewWithAddressFilterChanged() + self.notifyModulesOnFilterChanged() method getCurrencyAmount*(self: Module, amount: float64, symbol: string): CurrencyAmount = return self.controller.getCurrencyAmount(amount, symbol) @@ -218,7 +230,17 @@ proc setKeypairOperabilityForObservedAccount(self: Module, address: string) = self.view.setKeypairOperabilityForObservedAccount(keypair.getOperability()) method setFilterAddress*(self: Module, address: string) = + self.setKeypairOperabilityForObservedAccount(address) self.filter.setAddress(address) + self.overviewModule.setIsAllAccounts(false) + self.view.setAddressFilters(address) + self.notifyFilterChanged() + +method setFilterAllAddresses*(self: Module) = + self.view.setKeypairOperabilityForObservedAccount("") + self.filter.setAddresses(self.getWalletAddressesNotHidden()) + self.view.setAddressFilters(self.filter.addresses.join(":")) + self.overviewModule.setIsAllAccounts(true) self.notifyFilterChanged() method load*(self: Module) = @@ -249,7 +271,7 @@ method load*(self: Module) = self.notifyFilterChanged() self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args): self.setTotalCurrencyBalance() - self.notifyFilterChanged() + # self.notifyFilterChanged() self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args): self.setTotalCurrencyBalance() self.notifyFilterChanged() @@ -285,6 +307,9 @@ method load*(self: Module) = let data = LocalPairingStatus(e) self.onLocalPairingStatusUpdate(data) self.events.on(SIGNAL_WALLET_ACCOUNT_HIDDEN_UPDATED) do(e: Args): + if self.overviewModule.getIsAllAccounts(): + self.filter.setAddresses(self.getWalletAddressesNotHidden()) + self.view.setAddressFilters(self.filter.addresses.join(":")) self.notifyFilterChanged() self.setTotalCurrencyBalance() @@ -339,6 +364,7 @@ proc checkIfModuleDidLoad(self: Module) = let mnemonicBackedUp = self.controller.isMnemonicBackedUp() self.view.setData(signingPhrase, mnemonicBackedUp) self.setTotalCurrencyBalance() + self.filter.setAddresses(self.getWalletAddressesNotHidden()) self.filter.load() self.notifyFilterChanged() self.moduleLoaded = true diff --git a/src/app/modules/main/wallet_section/overview/controller.nim b/src/app/modules/main/wallet_section/overview/controller.nim index 92e0c8cd2f..2a6576171f 100644 --- a/src/app/modules/main/wallet_section/overview/controller.nim +++ b/src/app/modules/main/wallet_section/overview/controller.nim @@ -27,6 +27,9 @@ proc init*(self: Controller) = proc getWalletAccountsByAddresses*(self: Controller, addresses: seq[string]): seq[wallet_account_service.WalletAccountDto] = return self.walletAccountService.getAccountsByAddresses(addresses) +proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] = + return self.walletAccountService.getWalletAccounts() + proc getTotalCurrencyBalance*(self: Controller, addresses: seq[string], chainIds: seq[int]): float64 = return self.walletAccountService.getTotalCurrencyBalance(addresses, chainIds) diff --git a/src/app/modules/main/wallet_section/overview/io_interface.nim b/src/app/modules/main/wallet_section/overview/io_interface.nim index b8ebd4ec40..9a6e5d9349 100644 --- a/src/app/modules/main/wallet_section/overview/io_interface.nim +++ b/src/app/modules/main/wallet_section/overview/io_interface.nim @@ -19,3 +19,9 @@ method viewDidLoad*(self: AccessInterface) {.base.} = method filterChanged*(self: AccessInterface, addresses: seq[string], chainIds: seq[int]) {.base.} = raise newException(ValueError, "No implementation available") + +method setIsAllAccounts*(self: AccessInterface, value: bool) {.base.} = + raise newException(ValueError, "No implementation available") + +method getIsAllAccounts*(self: AccessInterface): bool {.base.} = + raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/wallet_section/overview/module.nim b/src/app/modules/main/wallet_section/overview/module.nim index 72488bdb4a..a7acd2af50 100644 --- a/src/app/modules/main/wallet_section/overview/module.nim +++ b/src/app/modules/main/wallet_section/overview/module.nim @@ -20,6 +20,7 @@ type view: View controller: Controller moduleLoaded: bool + isAllAccounts: bool proc newModule*( delegate: delegate_interface.AccessInterface, @@ -33,6 +34,7 @@ proc newModule*( result.view = newView(result) result.controller = newController(result, walletAccountService, currencyService) result.moduleLoaded = false + result.isAllAccounts = false method delete*(self: Module) = self.view.delete @@ -66,20 +68,40 @@ method filterChanged*(self: Module, addresses: seq[string], chainIds: seq[int]) let walletAccounts = self.controller.getWalletAccountsByAddresses(addresses) let walletAccount = walletAccounts[0] let loading = walletAccounts[0].assetsLoading or self.controller.getTokensMarketValuesLoading() - let isWatchOnlyAccount = walletAccount.walletType == "watch" - let item = initItem( - walletAccount.name, - walletAccount.mixedCaseAddress, - walletAccount.ens, - loading, - walletAccount.colorId, - walletAccount.emoji, - isWatchOnlyAccount=isWatchOnlyAccount, - canSend=not isWatchOnlyAccount and (walletAccount.operable==AccountFullyOperable or walletAccount.operable==AccountPartiallyOperable) - ) - self.view.setData(item) + if self.isAllAccounts: + let item = initItem( + "", + "", + "", + loading, + "", + "", + isWatchOnlyAccount=false, + isAllAccounts=true, + self.getWalletAccoutColors(walletAccounts) + ) + self.view.setData(item) + else: + let isWatchOnlyAccount = walletAccount.walletType == "watch" + let item = initItem( + walletAccount.name, + walletAccount.mixedCaseAddress, + walletAccount.ens, + loading, + walletAccount.colorId, + walletAccount.emoji, + isWatchOnlyAccount=isWatchOnlyAccount, + canSend=not isWatchOnlyAccount and (walletAccount.operable==AccountFullyOperable or walletAccount.operable==AccountPartiallyOperable) + ) + self.view.setData(item) if loading: self.view.setCurrencyBalance(newCurrencyAmount()) else: self.setBalance(addresses, chainIds) + +method setIsAllAccounts(self: Module, value: bool) = + self.isAllAccounts = value + +method getIsAllAccounts(self: Module): bool = + return self.isAllAccounts diff --git a/src/app/modules/main/wallet_section/view.nim b/src/app/modules/main/wallet_section/view.nim index 50ccdbe265..58f52f4e09 100644 --- a/src/app/modules/main/wallet_section/view.nim +++ b/src/app/modules/main/wallet_section/view.nim @@ -94,7 +94,7 @@ QtObject: proc setAddressFilters*(self: View, address: string) = self.addressFilters = address self.addressFiltersChanged() - proc getAddressFilters(self: View): string {.slot.} = + proc getAddressFilters*(self: View): string {.slot.} = return self.addressFilters QtProperty[string] addressFilters: read = getAddressFilters @@ -103,6 +103,9 @@ QtObject: proc setFilterAddress(self: View, address: string) {.slot.} = self.delegate.setFilterAddress(address) + proc setFilterAllAddresses*(self: View) {.slot.} = + self.delegate.setFilterAllAddresses() + proc setTotalCurrencyBalance*(self: View, totalCurrencyBalance: CurrencyAmount) = self.totalCurrencyBalance = totalCurrencyBalance self.totalCurrencyBalanceChanged() diff --git a/src/app_service/service/wallet_account/service_account.nim b/src/app_service/service/wallet_account/service_account.nim index 3048c869e6..9088ac09ca 100644 --- a/src/app_service/service/wallet_account/service_account.nim +++ b/src/app_service/service/wallet_account/service_account.nim @@ -101,7 +101,7 @@ proc getWalletAccounts*(self: Service, excludeWatchOnly: bool = false): seq[Wall result.sort(walletAccountsCmp) proc getWalletAddresses*(self: Service): seq[string] = - return self.getWalletAccounts().map(a => a.address) + return self.getWalletAccounts().filter(a => not a.hideFromTotalBalance).map(a => a.address) proc updateAssetsLoadingState(self: Service, address: string, loading: bool) = var acc = self.getAccountByAddress(address) diff --git a/src/app_service/service/wallet_account/service_token.nim b/src/app_service/service/wallet_account/service_token.nim index 497bdf5b80..71dacb481f 100644 --- a/src/app_service/service/wallet_account/service_token.nim +++ b/src/app_service/service/wallet_account/service_token.nim @@ -96,7 +96,6 @@ proc buildAllTokens*(self: Service, accounts: seq[string], store: bool) = self.threadpool.start(arg) proc getTotalCurrencyBalance*(self: Service, addresses: seq[string], chainIds: seq[int]): float64 = - echo "+++++++ getTotalCurrencyBalance, addresses ", addresses, " chainIds: ", chainIds var totalBalance: float64 = 0.0 for token in self.groupedAccountsTokensList: let price = self.tokenService.getPriceBySymbol(token.symbol) diff --git a/ui/app/AppLayouts/Wallet/WalletLayout.qml b/ui/app/AppLayouts/Wallet/WalletLayout.qml index e60d949a2a..be9b198708 100644 --- a/ui/app/AppLayouts/Wallet/WalletLayout.qml +++ b/ui/app/AppLayouts/Wallet/WalletLayout.qml @@ -70,9 +70,7 @@ Item { d.displayAllAddresses() - if (rightPanelStackView.currentItem && !!rightPanelStackView.currentItem.resetView) { - rightPanelStackView.currentItem.resetView() - } + d.resetRightPanelStackView() if(!hideSignPhraseModal && !RootStore.hideSignPhraseModal){ signPhrasePopup.open(); @@ -139,11 +137,13 @@ Item { function displayAllAddresses() { RootStore.showSavedAddresses = false RootStore.selectedAddress = "" + RootStore.setFilterAllAddresses() } function displayAddress(address) { RootStore.showSavedAddresses = false RootStore.selectedAddress = address + d.resetRightPanelStackView() // Avoids crashing on asset items being destroyed while in signal handler RootStore.setFilterAddress(address) } @@ -151,6 +151,12 @@ Item { RootStore.showSavedAddresses = true RootStore.selectedAddress = "" } + + function resetRightPanelStackView() { + if (rightPanelStackView.currentItem && !!rightPanelStackView.currentItem.resetView) { + rightPanelStackView.currentItem.resetView() + } + } } SignPhraseModal { diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index 1d8be55f25..c104d82ab4 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -234,6 +234,10 @@ QtObject { walletSection.setFilterAddress(address) } + function setFilterAllAddresses() { + walletSectionInst.setFilterAllAddresses() + } + function deleteAccount(address) { return walletSectionAccounts.deleteAccount(address) } diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index 67d3193717..04bb0c078e 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -24,10 +24,8 @@ RightTabBaseView { signal launchShareAddressModal() function resetView() { - stack.currentIndex = 0 + resetStack() root.currentTabIndex = 0 - if (walletTabBar.currentIndex === 2) - mainViewLoader.item.resetView() } function resetStack() { @@ -182,7 +180,7 @@ RightTabBaseView { RootStore.collectiblesStore.getDetailedCollectible(chainId, contractAddress, tokenId) RootStore.setCurrentViewedHolding(uid, tokenType) d.detailedCollectibleActivityController.resetFilter() - d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":")), RootStore.showAllAccounts) + d.detailedCollectibleActivityController.setFilterAddressesJson(JSON.stringify(RootStore.addressFilters.split(":"))) d.detailedCollectibleActivityController.setFilterChainsJson(JSON.stringify([chainId]), false) d.detailedCollectibleActivityController.setFilterCollectibles(JSON.stringify([uid])) d.detailedCollectibleActivityController.updateFilter() diff --git a/vendor/status-go b/vendor/status-go index a549529637..12deb23360 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit a549529637b414621074c014d8411e9c189e484d +Subproject commit 12deb2336028639ff11b6a3e08043e2961bed5c4