From 2f9bf488561c2c22d1e2a841605dca4d8d5bfec1 Mon Sep 17 00:00:00 2001 From: Ivan Belyakov Date: Wed, 17 Jul 2024 14:14:01 +0200 Subject: [PATCH] fix(wallet): fix balance chart to display chart for tokens Replace missing methods calls of chart after it was replaced with a different component. Update chart on networks change. Fix data for all chains requested - both test and real networks. Fix some unrelated qml errors --- src/app_service/service/network/service.nim | 3 ++- .../service/wallet_account/balance_history.nim | 11 +---------- ui/app/AppLayouts/Wallet/stores/RootStore.qml | 3 +++ ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml | 10 +++++++--- ui/imports/shared/views/HistoryView.qml | 2 +- vendor/status-go | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/app_service/service/network/service.nim b/src/app_service/service/network/service.nim index b52c8327fa..86b3c46336 100644 --- a/src/app_service/service/network/service.nim +++ b/src/app_service/service/network/service.nim @@ -66,7 +66,8 @@ proc getFlatNetworks*(self: Service): var seq[NetworkItem] = # passes networks based on users choice of test/mainnet proc getCurrentNetworks*(self: Service): seq[NetworkItem] = - self.flatNetworks.filter(n => n.isTest == self.settingsService.areTestNetworksEnabled()) + let testEnabled = self.settingsService.areTestNetworksEnabled() + self.flatNetworks.filter(n => n.isTest == testEnabled) proc getCurrentNetworksChainIds*(self: Service): seq[int] = return self.getCurrentNetworks().map(n => n.chainId) diff --git a/src/app_service/service/wallet_account/balance_history.nim b/src/app_service/service/wallet_account/balance_history.nim index 50dc147560..ae147a45e1 100644 --- a/src/app_service/service/wallet_account/balance_history.nim +++ b/src/app_service/service/wallet_account/balance_history.nim @@ -9,16 +9,7 @@ proc tokenBalanceHistoryDataResolved*(self: Service, response: string) {.slot.} )) proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) = - # create an empty list of chain ids - var chainIds: seq[int] = self.networkService.getCurrentNetworks().filter(n => n.isEnabled and n.nativeCurrencySymbol == tokenSymbol).map(n => n.chainId) - if chainIds.len == 0: - let tokenChainIds = self.tokenService.getFlatTokensList().filter(t => t.symbol == tokenSymbol and t.communityId.isEmptyOrWhitespace).map(t => t.chainID) - chainIds = concat(chainIds, tokenChainIds) - - if chainIds.len == 0: - error "failed to find a network with the symbol", tokenSymbol - return - + var chainIds: seq[int] = self.networkService.getEnabledChainIds() let arg = GetTokenBalanceHistoryDataTaskArg( tptr: getTokenBalanceHistoryDataTask, vptr: cast[ByteAddress](self.vptr), diff --git a/ui/app/AppLayouts/Wallet/stores/RootStore.qml b/ui/app/AppLayouts/Wallet/stores/RootStore.qml index d5e73a803a..08cd08a4e9 100644 --- a/ui/app/AppLayouts/Wallet/stores/RootStore.qml +++ b/ui/app/AppLayouts/Wallet/stores/RootStore.qml @@ -537,6 +537,9 @@ QtObject { } function transactionType(transaction) { + if (!transaction) + return Constants.TransactionType.Send + // Cross chain Send to another recipient is not a bridge, though involves bridging if (transaction.txType == Constants.TransactionType.Bridge && transaction.sender !== transaction.recipient) { if (root.showAllAccounts) { diff --git a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml index bed55cd37d..0f12f3b7b7 100644 --- a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml +++ b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml @@ -30,6 +30,7 @@ Item { property var networkConnectionStore property var allNetworksModel property var networkFilters + onNetworkFiltersChanged: d.forceRefreshBalanceStore = true /*required*/ property string address: "" property TokenBalanceHistoryStore balanceStore: TokenBalanceHistoryStore {} @@ -46,6 +47,8 @@ Item { rightModel: root.allNetworksModel joinRole: "chainId" } + + property bool forceRefreshBalanceStore: false } Connections { @@ -174,7 +177,7 @@ Item { graphDetail.selectedStore = graphDetail.selectedGraphType === AssetsDetailView.GraphType.Price ? d.marketValueStore : balanceStore } - chart.animateToNewData() + chart.refresh() } readonly property var dateToShortLabel: function (value) { @@ -312,7 +315,7 @@ Item { let selectedTimeRangeEnum = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange) let currencySymbol = RootStore.currencyStore.currentCurrency - if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum)) { + if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) || d.forceRefreshBalanceStore) { RootStore.fetchHistoricalBalanceForTokenAsJson(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) } } @@ -320,8 +323,9 @@ Item { Connections { target: balanceStore function onNewDataReady(address, tokenSymbol, currencySymbol, timeRange) { + d.forceRefreshBalanceStore = false if (timeRange === balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange)) { - chart.updateToNewData() + chart.refresh() } } } diff --git a/ui/imports/shared/views/HistoryView.qml b/ui/imports/shared/views/HistoryView.qml index 14891bf315..c02ee984e4 100644 --- a/ui/imports/shared/views/HistoryView.qml +++ b/ui/imports/shared/views/HistoryView.qml @@ -183,7 +183,7 @@ ColumnLayout { proxyRoles: ExpressionRole { name: "date" expression: { - if (model.activityEntry.timestamp === 0) + if (!model.activityEntry || model.activityEntry.timestamp === 0) return "" const currDate = new Date() const timestampDate = new Date(model.activityEntry.timestamp * 1000) diff --git a/vendor/status-go b/vendor/status-go index 5059c19aae..d07f9b5b16 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 5059c19aae4afbd1bdc4fa07f93f37b70989b2c7 +Subproject commit d07f9b5b162c078f71bf19a189e2e26c118a0db4