fix: Fixed tokens initialization. Fixed SendModal for ENS.
This commit is contained in:
parent
5ff4c35bf0
commit
470200a477
|
@ -1,4 +1,4 @@
|
||||||
import NimQml, Tables, strutils, strformat
|
import NimQml, Tables, strutils, strformat, json
|
||||||
|
|
||||||
import ./token_item
|
import ./token_item
|
||||||
import ./currency_amount
|
import ./currency_amount
|
||||||
|
@ -153,8 +153,8 @@ QtObject:
|
||||||
case column:
|
case column:
|
||||||
of "name": result = $item.getName()
|
of "name": result = $item.getName()
|
||||||
of "symbol": result = $item.getSymbol()
|
of "symbol": result = $item.getSymbol()
|
||||||
of "totalBalance": result = $item.getTotalBalance()
|
of "totalBalance": result = $item.getTotalBalance().toJsonNode()
|
||||||
of "totalCurrencyBalance": result = $item.getTotalCurrencyBalance()
|
of "totalCurrencyBalance": result = $item.getTotalCurrencyBalance().toJsonNode()
|
||||||
of "enabledNetworkCurrencyBalance": result = $item.getEnabledNetworkCurrencyBalance()
|
of "enabledNetworkCurrencyBalance": result = $item.getEnabledNetworkCurrencyBalance()
|
||||||
of "enabledNetworkBalance": result = $item.getEnabledNetworkBalance()
|
of "enabledNetworkBalance": result = $item.getEnabledNetworkBalance()
|
||||||
of "visibleForNetwork": result = $item.getVisibleForNetwork()
|
of "visibleForNetwork": result = $item.getVisibleForNetwork()
|
||||||
|
|
|
@ -14,7 +14,7 @@ proc newTimedCache*[T](): TimedCache[T] = initTable[string, Value[T]]()
|
||||||
proc init*[T](self: var TimedCache[T], values: Table[string, T]) =
|
proc init*[T](self: var TimedCache[T], values: Table[string, T]) =
|
||||||
self.clear()
|
self.clear()
|
||||||
for cacheKey, value in values:
|
for cacheKey, value in values:
|
||||||
self[cacheKey].value = value
|
self.set(cacheKey, value)
|
||||||
|
|
||||||
proc getTimestamp[T](self: TimedCache[T], cacheKey: string): DateTime = self[cacheKey].timestamp
|
proc getTimestamp[T](self: TimedCache[T], cacheKey: string): DateTime = self[cacheKey].timestamp
|
||||||
|
|
||||||
|
|
|
@ -72,8 +72,12 @@ QtObject:
|
||||||
proc init*(self: Service) =
|
proc init*(self: Service) =
|
||||||
try:
|
try:
|
||||||
let response = backend.getCachedPrices()
|
let response = backend.getCachedPrices()
|
||||||
self.initTokenPrices(jsonToPricesMap(response.result))
|
let prices = jsonToPricesMap(response.result)
|
||||||
|
self.initTokenPrices(prices)
|
||||||
|
except Exception as e:
|
||||||
|
error "Cached prices init error", errDesription = e.msg
|
||||||
|
|
||||||
|
try:
|
||||||
let networks = self.networkService.getNetworks()
|
let networks = self.networkService.getNetworks()
|
||||||
|
|
||||||
for network in networks:
|
for network in networks:
|
||||||
|
@ -93,11 +97,8 @@ QtObject:
|
||||||
self.tokens[network.chainId] = default_tokens.filter(
|
self.tokens[network.chainId] = default_tokens.filter(
|
||||||
proc(x: TokenDto): bool = x.chainId == network.chainId
|
proc(x: TokenDto): bool = x.chainId == network.chainId
|
||||||
)
|
)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
let errDesription = e.msg
|
error "Tokens init error", errDesription = e.msg
|
||||||
error "error: ", errDesription
|
|
||||||
return
|
|
||||||
|
|
||||||
proc findTokenBySymbol*(self: Service, network: NetworkDto, symbol: string): TokenDto =
|
proc findTokenBySymbol*(self: Service, network: NetworkDto, symbol: string): TokenDto =
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -54,15 +54,16 @@ Item {
|
||||||
let assetsList = buyEnsModal.store.currentAccount.assets
|
let assetsList = buyEnsModal.store.currentAccount.assets
|
||||||
for(var i=0; i< assetsList.count;i++) {
|
for(var i=0; i< assetsList.count;i++) {
|
||||||
let symbol = JSON.parse(root.stickersStore.getStatusToken()).symbol
|
let symbol = JSON.parse(root.stickersStore.getStatusToken()).symbol
|
||||||
if(symbol === assetsList.rowData(i, "symbol"))
|
if (symbol !== assetsList.rowData(i, "symbol"))
|
||||||
return {
|
continue
|
||||||
name: assetsList.rowData(i, "name"),
|
return {
|
||||||
symbol: assetsList.rowData(i, "symbol"),
|
name: assetsList.rowData(i, "name"),
|
||||||
totalBalance: assetsList.rowData(i, "totalBalance"),
|
symbol: assetsList.rowData(i, "symbol"),
|
||||||
totalCurrencyBalance: assetsList.rowData(i, "totalCurrencyBalance"),
|
totalBalance: JSON.parse(assetsList.rowData(i, "totalBalance")),
|
||||||
balances: assetsList.rowData(i, "balances"),
|
totalCurrencyBalance: JSON.parse(assetsList.rowData(i, "totalCurrencyBalance")),
|
||||||
decimals: assetsList.rowData(i, "decimals")
|
balances: assetsList.rowData(i, "balances"),
|
||||||
}
|
decimals: assetsList.rowData(i, "decimals")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,12 @@ StatusDialog {
|
||||||
StatusListItemTag {
|
StatusListItemTag {
|
||||||
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
|
||||||
Layout.preferredHeight: 22
|
Layout.preferredHeight: 22
|
||||||
title: d.maxFiatBalance && d.maxFiatBalance.amount > 0 ? qsTr("Max: %1").arg(LocaleUtils.currencyAmountToLocaleString(d.maxFiatBalance)) : qsTr("No balances active")
|
title: {
|
||||||
|
if (!d.maxFiatBalance || d.maxFiatBalance.amount <= 0)
|
||||||
|
return qsTr("No balances active")
|
||||||
|
const balance = LocaleUtils.currencyAmountToLocaleString(d.maxFiatBalance)
|
||||||
|
return qsTr("Max: %1").arg(balance)
|
||||||
|
}
|
||||||
closeButtonVisible: false
|
closeButtonVisible: false
|
||||||
titleText.font.pixelSize: 12
|
titleText.font.pixelSize: 12
|
||||||
bgColor: amountToSendInput.input.valid ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2
|
bgColor: amountToSendInput.input.valid ? Theme.palette.primaryColor3 : Theme.palette.dangerColor2
|
||||||
|
|
Loading…
Reference in New Issue