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
This commit is contained in:
Ivan Belyakov 2024-07-17 14:14:01 +02:00 committed by IvanBelyakoff
parent 248ba1c1c8
commit 2f9bf48856
6 changed files with 15 additions and 16 deletions

View File

@ -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)

View File

@ -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),

View File

@ -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) {

View File

@ -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()
}
}
}

View File

@ -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)

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit 5059c19aae4afbd1bdc4fa07f93f37b70989b2c7
Subproject commit d07f9b5b162c078f71bf19a189e2e26c118a0db4