diff --git a/src/app/modules/main/wallet_section/all_tokens/controller.nim b/src/app/modules/main/wallet_section/all_tokens/controller.nim index 15411dcdca..6a335b8eb5 100644 --- a/src/app/modules/main/wallet_section/all_tokens/controller.nim +++ b/src/app/modules/main/wallet_section/all_tokens/controller.nim @@ -15,7 +15,7 @@ proc newController*( delegate: io_interface.AccessInterface, events: EventEmitter, tokenService: token_service.Service, - walletAccountService: wallet_account_service.Service, + walletAccountService: wallet_account_service.Service ): Controller = result = Controller() result.events = events @@ -41,8 +41,8 @@ proc findTokenSymbolByAddress*(self: Controller, address: string): string = proc getHistoricalDataForToken*(self: Controller, symbol: string, currency: string, range: int) = self.tokenService.getHistoricalDataForToken(symbol, currency, range) -proc fetchHistoricalBalanceForTokenAsJson*(self: Controller, address: string, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) = - self.tokenService.fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, BalanceHistoryTimeInterval(timeIntervalEnum)) +method fetchHistoricalBalanceForTokenAsJson*(self: Controller, addresses: seq[string], allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) = + self.tokenService.fetchHistoricalBalanceForTokenAsJson(addresses, allAddresses, tokenSymbol, currencySymbol, BalanceHistoryTimeInterval(timeIntervalEnum)) proc getSourcesOfTokensList*(self: Controller): var seq[SupportedSourcesItem] = return self.tokenService.getSourcesOfTokensList() diff --git a/src/app/modules/main/wallet_section/all_tokens/io_interface.nim b/src/app/modules/main/wallet_section/all_tokens/io_interface.nim index 32e12eb454..28e1122e15 100644 --- a/src/app/modules/main/wallet_section/all_tokens/io_interface.nim +++ b/src/app/modules/main/wallet_section/all_tokens/io_interface.nim @@ -34,7 +34,7 @@ method getHistoricalDataForToken*(self: AccessInterface, symbol: string, currenc method tokenHistoricalDataResolved*(self: AccessInterface, tokenDetails: string) {.base.} = raise newException(ValueError, "No implementation available") -method fetchHistoricalBalanceForTokenAsJson*(self: AccessInterface, address: string, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) {.base.} = +method fetchHistoricalBalanceForTokenAsJson*(self: AccessInterface, address: string, allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) {.base.} = raise newException(ValueError, "No implementation available") method tokenBalanceHistoryDataResolved*(self: AccessInterface, balanceHistoryJson: string) {.base.} = @@ -54,3 +54,6 @@ method getTokenBySymbolModelDataSource*(self: AccessInterface): TokenBySymbolMod # inheritance, which is not well supported in Nim. method viewDidLoad*(self: AccessInterface) {.base.} = raise newException(ValueError, "No implementation available") + +method filterChanged*(self: AccessInterface, addresses: seq[string]) = + raise newException(ValueError, "No implementation available") \ No newline at end of file diff --git a/src/app/modules/main/wallet_section/all_tokens/module.nim b/src/app/modules/main/wallet_section/all_tokens/module.nim index 619a41ebde..eefbe42821 100644 --- a/src/app/modules/main/wallet_section/all_tokens/module.nim +++ b/src/app/modules/main/wallet_section/all_tokens/module.nim @@ -18,6 +18,7 @@ type view: View controller: Controller moduleLoaded: bool + addresses: seq[string] proc newModule*( delegate: delegate_interface.AccessInterface, @@ -31,6 +32,7 @@ proc newModule*( result.view = newView(result) result.controller = controller.newController(result, events, tokenService, walletAccountService) result.moduleLoaded = false + result.addresses = @[] method delete*(self: Module) = self.view.delete @@ -68,8 +70,9 @@ method getHistoricalDataForToken*(self: Module, symbol: string, currency: string method tokenHistoricalDataResolved*(self: Module, tokenDetails: string) = self.view.setTokenHistoricalDataReady(tokenDetails) -method fetchHistoricalBalanceForTokenAsJson*(self: Module, address: string, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) = - self.controller.fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol,timeIntervalEnum) +method fetchHistoricalBalanceForTokenAsJson*(self: Module, address: string, allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) = + let addresses = if allAddresses: self.addresses else: @[address] + self.controller.fetchHistoricalBalanceForTokenAsJson(addresses, allAddresses, tokenSymbol, currencySymbol,timeIntervalEnum) method tokenBalanceHistoryDataResolved*(self: Module, balanceHistoryJson: string) = self.view.setTokenBalanceHistoryDataReady(balanceHistoryJson) @@ -99,3 +102,8 @@ method getTokenBySymbolModelDataSource*(self: Module): TokenBySymbolModelDataSou return ( getTokenBySymbolList: proc(): var seq[TokenBySymbolItem] = self.getTokenBySymbolList() ) + +method filterChanged*(self: Module, addresses: seq[string]) = + if addresses == self.addresses: + return + self.addresses = addresses diff --git a/src/app/modules/main/wallet_section/all_tokens/view.nim b/src/app/modules/main/wallet_section/all_tokens/view.nim index e7c7ab096e..1191dcfdde 100644 --- a/src/app/modules/main/wallet_section/all_tokens/view.nim +++ b/src/app/modules/main/wallet_section/all_tokens/view.nim @@ -72,9 +72,9 @@ QtObject: self.setMarketHistoryIsLoading(false) self.tokenHistoricalDataReady(tokenDetails) - proc fetchHistoricalBalanceForTokenAsJson*(self: View, address: string, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) {.slot.} = + proc fetchHistoricalBalanceForTokenAsJson*(self: View, address: string, allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeIntervalEnum: int) {.slot.} = self.setBalanceHistoryIsLoading(true) - self.delegate.fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, timeIntervalEnum) + self.delegate.fetchHistoricalBalanceForTokenAsJson(address, allAddresses, tokenSymbol, currencySymbol, timeIntervalEnum) proc tokenBalanceHistoryDataReady*(self: View, balanceHistoryJson: string) {.signal.} diff --git a/src/app/modules/main/wallet_section/module.nim b/src/app/modules/main/wallet_section/module.nim index 98b890d9f9..56b2e1639f 100644 --- a/src/app/modules/main/wallet_section/module.nim +++ b/src/app/modules/main/wallet_section/module.nim @@ -183,6 +183,7 @@ proc notifyFilterChanged(self: Module) = self.sendModule.filterChanged(self.filter.addresses, self.filter.chainIds) self.activityController.globalFilterChanged(self.filter.addresses, self.filter.allAddresses, self.filter.chainIds, self.filter.allChainsEnabled) self.collectiblesController.setFilterAddressesAndChains(self.filter.addresses, self.filter.chainIds) + self.allTokensModule.filterChanged(self.filter.addresses) if self.filter.addresses.len > 0: self.view.filterChanged(self.filter.addresses[0], self.filter.allAddresses) diff --git a/src/app_service/service/token/async_tasks.nim b/src/app_service/service/token/async_tasks.nim index ebd2d1298a..80fefe6ffd 100644 --- a/src/app_service/service/token/async_tasks.nim +++ b/src/app_service/service/token/async_tasks.nim @@ -85,7 +85,8 @@ type type GetTokenBalanceHistoryDataTaskArg = ref object of QObjectTaskArg chainIds: seq[int] - address: string + addresses: seq[string] + allAddresses: bool tokenSymbol: string currencySymbol: string timeInterval: BalanceHistoryTimeInterval @@ -95,11 +96,12 @@ const getTokenBalanceHistoryDataTask*: Task = proc(argEncoded: string) {.gcsafe, var response = %*{} try: # status-go time intervals are starting from 1 - response = backend.getBalanceHistory(arg.chainIds, arg.address, arg.tokenSymbol, arg.currencySymbol, int(arg.timeInterval) + 1).result + response = backend.getBalanceHistory(arg.chainIds, arg.addresses, arg.tokenSymbol, arg.currencySymbol, int(arg.timeInterval) + 1).result let output = %* { "chainIds": arg.chainIds, - "address": arg.address, + "addresses": arg.addresses, + "allAddresses": arg.allAddresses, "tokenSymbol": arg.tokenSymbol, "currencySymbol": arg.currencySymbol, "timeInterval": int(arg.timeInterval), @@ -111,7 +113,8 @@ const getTokenBalanceHistoryDataTask*: Task = proc(argEncoded: string) {.gcsafe, except Exception as e: let output = %* { "chainIds": arg.chainIds, - "address": arg.address, + "addresses": arg.addresses, + "allAddresses": arg.allAddresses, "tokenSymbol": arg.tokenSymbol, "currencySymbol": arg.currencySymbol, "timeInterval": int(arg.timeInterval), diff --git a/src/app_service/service/token/service.nim b/src/app_service/service/token/service.nim index 0e62858db7..f365230804 100644 --- a/src/app_service/service/token/service.nim +++ b/src/app_service/service/token/service.nim @@ -398,7 +398,7 @@ QtObject: result: response )) - proc fetchHistoricalBalanceForTokenAsJson*(self: Service, address: string, tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) = + proc fetchHistoricalBalanceForTokenAsJson*(self: Service, addresses: seq[string], allAddresses: bool, tokenSymbol: string, currencySymbol: string, timeInterval: BalanceHistoryTimeInterval) = # create an empty list of chain ids var chainIds: seq[int] = @[] let networks = self.networkService.getNetworks() @@ -422,7 +422,8 @@ QtObject: vptr: cast[ByteAddress](self.vptr), slot: "tokenBalanceHistoryDataResolved", chainIds: chainIds, - address: address, + addresses: addresses, + allAddresses: allAddresses, tokenSymbol: tokenSymbol, currencySymbol: currencySymbol, timeInterval: timeInterval diff --git a/src/backend/backend.nim b/src/backend/backend.nim index 37175ea948..4de6d55f2a 100644 --- a/src/backend/backend.nim +++ b/src/backend/backend.nim @@ -294,7 +294,7 @@ rpc(getName, "ens"): rpc(getBalanceHistory, "wallet"): chainIds: seq[int] - address: string + addresses: seq[string] tokenSymbol: string currencySymbol: string timeInterval: int diff --git a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml index 3cf199ea9c..fe6dc6d7f6 100644 --- a/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml +++ b/ui/app/AppLayouts/Wallet/views/AssetsDetailView.qml @@ -23,6 +23,7 @@ Item { property var token: ({}) property var networkConnectionStore /*required*/ property string address: "" + property bool showAllAccounts: false property bool assetsLoading: true QtObject { @@ -265,8 +266,8 @@ Item { let selectedTimeRangeEnum = balanceStore.timeRangeStrToEnum(graphDetail.selectedTimeRange) let currencySymbol = RootStore.currencyStore.currentCurrency - if(!balanceStore.hasData(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum)) { - RootStore.fetchHistoricalBalanceForTokenAsJson(root.address, token.symbol, currencySymbol, selectedTimeRangeEnum) + if(!balanceStore.hasData(root.address, root.showAllAccounts, token.symbol, currencySymbol, selectedTimeRangeEnum)) { + RootStore.fetchHistoricalBalanceForTokenAsJson(root.address, root.showAllAccounts, token.symbol, currencySymbol, selectedTimeRangeEnum) } } diff --git a/ui/app/AppLayouts/Wallet/views/RightTabView.qml b/ui/app/AppLayouts/Wallet/views/RightTabView.qml index 96b0efcbc4..082d0a417c 100644 --- a/ui/app/AppLayouts/Wallet/views/RightTabView.qml +++ b/ui/app/AppLayouts/Wallet/views/RightTabView.qml @@ -171,6 +171,7 @@ Item { assetsLoading: RootStore.assetsLoading address: RootStore.overview.mixedcaseAddress + showAllAccounts: root.showAllAccounts networkConnectionStore: root.networkConnectionStore diff --git a/ui/imports/shared/stores/RootStore.qml b/ui/imports/shared/stores/RootStore.qml index 200ca065cd..07ad00ad1d 100644 --- a/ui/imports/shared/stores/RootStore.qml +++ b/ui/imports/shared/stores/RootStore.qml @@ -244,9 +244,9 @@ QtObject { property bool marketHistoryIsLoading: Global.appIsReady? walletSectionAllTokens.marketHistoryIsLoading : false - function fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, timeIntervalEnum) { + function fetchHistoricalBalanceForTokenAsJson(address, allAddresses, tokenSymbol, currencySymbol, timeIntervalEnum) { if (Global.appIsReady) - walletSectionAllTokens.fetchHistoricalBalanceForTokenAsJson(address, tokenSymbol, currencySymbol, timeIntervalEnum) + walletSectionAllTokens.fetchHistoricalBalanceForTokenAsJson(address, allAddresses, tokenSymbol, currencySymbol, timeIntervalEnum) } property bool balanceHistoryIsLoading: Global.appIsReady? walletSectionAllTokens.balanceHistoryIsLoading : false diff --git a/ui/imports/shared/stores/TokenBalanceHistoryStore.qml b/ui/imports/shared/stores/TokenBalanceHistoryStore.qml index b62db9f480..a729efabff 100644 --- a/ui/imports/shared/stores/TokenBalanceHistoryStore.qml +++ b/ui/imports/shared/stores/TokenBalanceHistoryStore.qml @@ -10,6 +10,7 @@ ChartStoreBase { readonly property alias address: d.address readonly property alias tokenSymbol: d.tokenSymbol readonly property alias currencySymbol: d.currencySymbol + readonly property alias allAddresses: d.allAddresses QtObject { id: d @@ -17,17 +18,18 @@ ChartStoreBase { // Data identity received from backend property var chainIds: [] property string address + property bool allAddresses: false property string tokenSymbol property string currencySymbol } - function hasData(address, tokenSymbol, currencySymbol, timeRangeEnum) { - return address === d.address && tokenSymbol === d.tokenSymbol && currencySymbol === d.currencySymbol + function hasData(address, allAddresses, tokenSymbol, currencySymbol, timeRangeEnum) { + return address === d.address && allAddresses === d.allAddresses && tokenSymbol === d.tokenSymbol && currencySymbol === d.currencySymbol && root.dataRange[root.timeRangeEnumToTimeIndex(timeRangeEnum)][root.timeRangeEnumToStr(timeRangeEnum)].length > 0 } /// \arg timeRange: of type ChartStoreBase.TimeRange - function setData(address, tokenSymbol, currencySymbol, timeRange, timeRangeData, balanceData) { + function setData(address, allAddresses, tokenSymbol, currencySymbol, timeRange, timeRangeData, balanceData) { switch(timeRange) { case ChartStoreBase.TimeRange.Weekly: root.weeklyData = balanceData @@ -55,15 +57,16 @@ ChartStoreBase { } d.address = address + d.allAddresses = allAddresses d.tokenSymbol = tokenSymbol d.currencySymbol = currencySymbol root.newDataReady(address, tokenSymbol, currencySymbol, timeRange) } - function resetAllData(address, tokenSymbol, currencySymbol) { + function resetAllData(address, allAddresses, tokenSymbol, currencySymbol) { for (let tR = ChartStoreBase.TimeRange.Weekly; tR <= ChartStoreBase.TimeRange.All; tR++) { - root.setData(address, tokenSymbol, currencySymbol, tR, [], []) + root.setData(address, allAddresses, tokenSymbol, currencySymbol, tR, [], []) } } @@ -78,8 +81,14 @@ ChartStoreBase { return } - if(d.address != response.address || d.tokenSymbol != response.tokenSymbol || d.currencySymbol != response.currencySymbol) { - root.resetAllData(response.address, response.tokenSymbol, response.currencySymbol) + if (!response.allAddresses && response.addresses.length > 0) { + response.address = response.addresses[0] + } else { + response.address = "" + } + + if(d.allAddresses != response.allAddresses || d.address != response.address || d.tokenSymbol != response.tokenSymbol || d.currencySymbol != response.currencySymbol) { + root.resetAllData(response.address, response.allAddresses, response.tokenSymbol, response.currencySymbol) } if(typeof response.historicalData === "undefined" || response.historicalData === null || response.historicalData.length == 0) { @@ -93,7 +102,7 @@ ChartStoreBase { tmpDataValues.push({ x: new Date(dataEntry.time * 1000), y: dataEntry.value }) } - root.setData(response.address, response.tokenSymbol, response.currencySymbol, response.timeInterval, [], tmpDataValues) + root.setData(response.address, response.allAddresses, response.tokenSymbol, response.currencySymbol, response.timeInterval, [], tmpDataValues) } } } diff --git a/vendor/status-go b/vendor/status-go index 472e4bdb77..078ead7876 160000 --- a/vendor/status-go +++ b/vendor/status-go @@ -1 +1 @@ -Subproject commit 472e4bdb7761e9e05204dd0f74b1a5f138e8138c +Subproject commit 078ead7876c0545a6c2ddb2ec25a30f937d160d9