diff --git a/src/app/modules/shared_models/balance_model.nim b/src/app/modules/shared_models/balance_model.nim index fc621836c9..5d6818cb1e 100644 --- a/src/app/modules/shared_models/balance_model.nim +++ b/src/app/modules/shared_models/balance_model.nim @@ -8,6 +8,7 @@ type Address Balance CurrencyBalance + Enabled QtObject: type @@ -47,6 +48,7 @@ QtObject: ModelRole.Address.int:"address", ModelRole.Balance.int:"balance", ModelRole.CurrencyBalance.int:"currencyBalance", + ModelRole.Enabled.int:"enabled", }.toTable method data(self: BalanceModel, index: QModelIndex, role: int): QVariant = @@ -68,6 +70,8 @@ QtObject: result = newQVariant(item.balance) of ModelRole.CurrencyBalance: result = newQVariant(item.currencyBalance) + of ModelRole.Enabled: + result = newQVariant(item.enabled) proc rowData(self: BalanceModel, index: int, column: string): string {.slot.} = if (index >= self.items.len): @@ -78,6 +82,7 @@ QtObject: of "address": result = $item.address of "balance": result = $item.balance of "currencyBalance": result = $item.currencyBalance + of "enabled": result = $item.enabled proc setItems*(self: BalanceModel, items: seq[BalanceDto]) = self.beginResetModel() diff --git a/src/app_service/service/wallet_account/async_tasks.nim b/src/app_service/service/wallet_account/async_tasks.nim index 2ef0cf3238..91d4be3814 100644 --- a/src/app_service/service/wallet_account/async_tasks.nim +++ b/src/app_service/service/wallet_account/async_tasks.nim @@ -276,7 +276,8 @@ const prepareTokensTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = balance: chainBalance, currencyBalance: chainBalance * prices[network.nativeCurrencySymbol], chainId: network.chainId, - address: "0x0000000000000000000000000000000000000000" + address: "0x0000000000000000000000000000000000000000", + enabled: network.enabled, ) if network.enabled: enabledNetworkBalance.balance += balancesPerChain[network.chainId].balance @@ -342,11 +343,17 @@ const prepareTokensTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} = for token in tokens: let balanceForToken = tokenBalances{address}{token.addressAsString()}.getStr let chainBalanceForToken = parsefloat(hex2Balance(balanceForToken, token.decimals)) + var enabled = false + for network in arg.networks: + if network.chainId == token.chainId: + enabled = true + balancesPerChain[token.chainId] = BalanceDto( balance: chainBalanceForToken, currencyBalance: chainBalanceForToken * prices[token.symbol], chainId: token.chainId, - address: $token.address + address: $token.address, + enabled: enabled, ) if isNetworkEnabledForChainId(arg.networks, token.chainId): visible = true diff --git a/src/app_service/service/wallet_account/dto.nim b/src/app_service/service/wallet_account/dto.nim index a09a47901b..9726304fd3 100644 --- a/src/app_service/service/wallet_account/dto.nim +++ b/src/app_service/service/wallet_account/dto.nim @@ -13,6 +13,7 @@ type BalanceDto* = object currencyBalance*: float64 address*: string chainId*: int + enabled*: bool type WalletTokenDto* = object @@ -107,6 +108,7 @@ proc toBalanceDto*(jsonObj: JsonNode): BalanceDto = discard jsonObj.getProp("currencyBalance", result.currencyBalance) discard jsonObj.getProp("address", result.address) discard jsonObj.getProp("chainId", result.chainId) + discard jsonObj.getProp("enabled", result.enabled) proc toWalletTokenDto*(jsonObj: JsonNode): WalletTokenDto = result = WalletTokenDto() diff --git a/ui/imports/shared/controls/AssetsDetailsHeader.qml b/ui/imports/shared/controls/AssetsDetailsHeader.qml index e6ccaf1c1f..2962d93790 100644 --- a/ui/imports/shared/controls/AssetsDetailsHeader.qml +++ b/ui/imports/shared/controls/AssetsDetailsHeader.qml @@ -77,6 +77,7 @@ Control { id: chainRepeater model: balances ? balances : null delegate: InformationTag { + visible: model.enabled tagPrimaryLabel.text: model.balance tagPrimaryLabel.color: root.getNetworkColor(model.chainId) image.source: Style.svg("tiny/%1".arg(root.getNetworkIcon(model.chainId))) diff --git a/ui/imports/shared/views/AssetsDetailView.qml b/ui/imports/shared/views/AssetsDetailView.qml index 4b655d144f..73e690580b 100644 --- a/ui/imports/shared/views/AssetsDetailView.qml +++ b/ui/imports/shared/views/AssetsDetailView.qml @@ -43,8 +43,8 @@ Item { asset.name: token && token.symbol ? Style.png("tokens/%1".arg(token.symbol)) : "" asset.isImage: true primaryText: token ? token.name : "" - secondaryText: token ? qsTr("%1 %2").arg(Utils.toLocaleString(token.totalBalance, RootStore.locale, {"currency": true})).arg(token.symbol) : "" - tertiaryText: token ? "%1 %2".arg(Utils.toLocaleString(token.totalCurrencyBalance.toFixed(2), RootStore.locale, {"currency": true})).arg(RootStore.currencyStore.currentCurrency.toUpperCase()) : "" + secondaryText: token ? `${token.enabledNetworkBalance} ${token.symbol}` : "" + tertiaryText: token ? "%1 %2".arg(Utils.toLocaleString(token.enabledNetworkCurrencyBalance.toFixed(2), RootStore.locale, {"currency": true})).arg(RootStore.currencyStore.currentCurrency.toUpperCase()) : "" balances: token && token.balances ? token.balances : null getNetworkColor: function(chainId){ return RootStore.getNetworkColor(chainId) diff --git a/ui/imports/shared/views/AssetsView.qml b/ui/imports/shared/views/AssetsView.qml index 127f10dd02..b477c6db8b 100644 --- a/ui/imports/shared/views/AssetsView.qml +++ b/ui/imports/shared/views/AssetsView.qml @@ -46,7 +46,7 @@ Item { objectName: "AssetView_TokenListItem_" + symbol width: parent.width title: name - subTitle: qsTr("%1 %2").arg(Utils.toLocaleString(enabledNetworkBalance, RootStore.locale, {"currency": true})).arg(symbol) + subTitle: `${enabledNetworkBalance} ${symbol}` asset.name: symbol ? Style.png("tokens/" + symbol) : "" asset.isImage: true components: [