fix(@desktop/wallet): Selecting other than the mainnet doesn't display all tokens in the send popup

fixes #12255
This commit is contained in:
Khushboo Mehta 2023-10-03 22:44:22 +02:00 committed by Khushboo-dev-cpp
parent 92b2a209a2
commit 8252baf846
7 changed files with 5 additions and 25 deletions

View File

@ -84,7 +84,6 @@ proc walletTokenToItem*(
currencyAmountToItem(t.getCurrencyBalance(chainIds, currency), currencyFormat),
currencyAmountToItem(t.getBalance(enabledChainIds), tokenFormat),
currencyAmountToItem(t.getCurrencyBalance(enabledChainIds, currency), currencyFormat),
t.getVisibleForNetwork(enabledChainIds),
t.getVisibleForNetworkWithPositiveBalance(enabledChainIds),
t.getBalances(chainIds).map(b => balanceToItemBalanceItem(b, tokenFormat)),
t.description,

View File

@ -14,7 +14,6 @@ type
totalCurrencyBalance: CurrencyAmount
enabledNetworkCurrencyBalance: CurrencyAmount
enabledNetworkBalance: CurrencyAmount
visibleForNetwork: bool
visibleForNetworkWithPositiveBalance: bool
balances: balance_model.BalanceModel
description: string
@ -38,7 +37,6 @@ proc initItem*(
totalCurrencyBalance: CurrencyAmount,
enabledNetworkBalance: CurrencyAmount,
enabledNetworkCurrencyBalance: CurrencyAmount,
visibleForNetwork: bool,
visibleForNetworkWithPositiveBalance: bool,
balances: seq[balance_item.Item],
description: string,
@ -63,7 +61,6 @@ proc initItem*(
result.totalCurrencyBalance = totalCurrencyBalance
result.enabledNetworkBalance = enabledNetworkBalance
result.enabledNetworkCurrencyBalance = enabledNetworkCurrencyBalance
result.visibleForNetwork = visibleForNetwork
result.visibleForNetworkWithPositiveBalance = visibleForNetworkWithPositiveBalance
result.balances = balance_model.newModel()
result.balances.setItems(balances)
@ -92,7 +89,6 @@ proc `$`*(self: Item): string =
enabledNetworkBalance: {self.enabledNetworkBalance},
enabledNetworkCurrencyBalance: {self.enabledNetworkCurrencyBalance},
visibleForNetworkWithPositiveBalance: {self.visibleForNetworkWithPositiveBalance},
visibleForNetwork: {self.visibleForNetwork},
description: {self.description},
assetWebsiteUrl: {self.assetWebsiteUrl}
builtOn: {self.builtOn}
@ -118,7 +114,6 @@ proc initLoadingItem*(): Item =
totalCurrencyBalance = newCurrencyAmount(),
enabledNetworkBalance = newCurrencyAmount(),
enabledNetworkCurrencyBalance = newCurrencyAmount(),
visibleForNetwork = false,
visibleForNetworkWithPositiveBalance = false,
balances = @[],
description = "",
@ -158,9 +153,6 @@ proc getEnabledNetworkBalance*(self: Item): CurrencyAmount =
proc getEnabledNetworkCurrencyBalance*(self: Item): CurrencyAmount =
return self.enabledNetworkCurrencyBalance
proc getVisibleForNetwork*(self: Item): bool =
return self.visibleForNetwork
proc getVisibleForNetworkWithPositiveBalance*(self: Item): bool =
return self.visibleForNetworkWithPositiveBalance

View File

@ -12,7 +12,6 @@ type
TotalCurrencyBalance
EnabledNetworkCurrencyBalance
EnabledNetworkBalance
VisibleForNetwork
VisibleForNetworkWithPositiveBalance
Balances
Description
@ -71,7 +70,6 @@ QtObject:
ModelRole.TotalCurrencyBalance.int:"totalCurrencyBalance",
ModelRole.EnabledNetworkCurrencyBalance.int:"enabledNetworkCurrencyBalance",
ModelRole.EnabledNetworkBalance.int:"enabledNetworkBalance",
ModelRole.VisibleForNetwork.int:"visibleForNetwork",
ModelRole.VisibleForNetworkWithPositiveBalance.int:"visibleForNetworkWithPositiveBalance",
ModelRole.Balances.int:"balances",
ModelRole.Description.int:"description",
@ -115,8 +113,6 @@ QtObject:
result = newQVariant(item.getEnabledNetworkCurrencyBalance())
of ModelRole.EnabledNetworkBalance:
result = newQVariant(item.getEnabledNetworkBalance())
of ModelRole.VisibleForNetwork:
result = newQVariant(item.getVisibleForNetwork())
of ModelRole.VisibleForNetworkWithPositiveBalance:
result = newQVariant(item.getVisibleForNetworkWithPositiveBalance())
of ModelRole.Balances:
@ -162,7 +158,6 @@ QtObject:
of "totalCurrencyBalance": result = $item.getTotalCurrencyBalance().toJsonNode()
of "enabledNetworkCurrencyBalance": result = $item.getEnabledNetworkCurrencyBalance()
of "enabledNetworkBalance": result = $item.getEnabledNetworkBalance()
of "visibleForNetwork": result = $item.getVisibleForNetwork()
of "visibleForNetworkWithPositiveBalance": result = $item.getVisibleForNetworkWithPositiveBalance()
of "description": result = $item.getDescription()
of "assetWebsiteUrl": result = $item.getAssetWebsiteUrl()

View File

@ -188,12 +188,6 @@ proc getCurrencyBalance*(self: WalletTokenDto, chainIds: seq[int], currency: str
sum += self.balancesPerChain[chainId].getCurrencyBalance(price)
return sum
proc getVisibleForNetwork*(self: WalletTokenDto, chainIds: seq[int]): bool =
for chainId in chainIds:
if self.balancesPerChain.hasKey(chainId):
return true
return false
proc getVisibleForNetworkWithPositiveBalance*(self: WalletTokenDto, chainIds: seq[int]): bool =
for chainId in chainIds:
if alwaysVisible.hasKey(chainId) and self.symbol in alwaysVisible[chainId]:

View File

@ -16,7 +16,7 @@ ListModel {
stripTrailingZeroes: true,
amount: 3.234
}),
visibleForNetwork: true,
visibleForNetworkWithPositiveBalance: true,
symbol: "ETH",
name: "Ethereum",
balances: [
@ -46,7 +46,7 @@ ListModel {
stripTrailingZeroes: true,
amount: 23333213.234
}),
visibleForNetwork: true,
visibleForNetworkWithPositiveBalance: true,
symbol: "SNT",
name: "Status",
balances: [
@ -76,7 +76,7 @@ ListModel {
stripTrailingZeroes: true,
amount: 53333213.234
}),
visibleForNetwork: true,
visibleForNetworkWithPositiveBalance: true,
symbol: "DAI",
name: "DAI Stablecoin",
balances: [

View File

@ -96,7 +96,7 @@ Item {
ExpressionFilter {
expression: {
d.uppercaseSearchText; // Force re-evaluation when searchText changes
return visibleForNetwork && (
return visibleForNetworkWithPositiveBalance && (
d.uppercaseSearchText === "" ||
symbol.startsWith(d.uppercaseSearchText) ||
name.toUpperCase().startsWith(d.uppercaseSearchText) |

View File

@ -128,7 +128,7 @@ Item {
expression: {
var tokenSymbolByAddress = searchTokenSymbolByAddressFn(d.assetSearchString)
tokenList.positionViewAtBeginning()
return visibleForNetwork && (
return visibleForNetworkWithPositiveBalance && (
symbol.startsWith(d.assetSearchString.toUpperCase()) || name.toUpperCase().startsWith(d.assetSearchString.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
)
}