fix(@wallet): fix token list
there is 2 type of token list, the whole list for send modal and the list for asset view
This commit is contained in:
parent
9391cabcba
commit
f7704c719a
|
@ -53,7 +53,8 @@ proc setAssets(self: Module, tokens: seq[WalletTokenDto]) =
|
|||
t.getCurrencyBalance(chainIds),
|
||||
t.getBalance(enabledChainIds),
|
||||
t.getCurrencyBalance(enabledChainIds),
|
||||
t.getVisible(enabledChainIds),
|
||||
t.getVisibleForNetwork(enabledChainIds),
|
||||
t.getVisibleForNetworkWithPositiveBalance(enabledChainIds),
|
||||
t.getBalances(enabledChainIds),
|
||||
t.description,
|
||||
t.assetWebsiteUrl,
|
||||
|
|
|
@ -84,7 +84,8 @@ method refreshWalletAccounts*(self: Module) =
|
|||
t.getCurrencyBalance(chainIds),
|
||||
t.getBalance(enabledChainIds),
|
||||
t.getCurrencyBalance(enabledChainIds),
|
||||
t.getVisible(enabledChainIds),
|
||||
t.getVisibleForNetwork(enabledChainIds),
|
||||
t.getVisibleForNetworkWithPositiveBalance(enabledChainIds),
|
||||
t.getBalances(enabledChainIds),
|
||||
t.description,
|
||||
t.assetWebsiteUrl,
|
||||
|
|
|
@ -84,7 +84,8 @@ proc setAssetsAndBalance(self: Module, tokens: seq[WalletTokenDto]) =
|
|||
t.getCurrencyBalance(chainIds),
|
||||
t.getBalance(enabledChainIds),
|
||||
t.getCurrencyBalance(enabledChainIds),
|
||||
t.getVisible(enabledChainIds),
|
||||
t.getVisibleForNetwork(enabledChainIds),
|
||||
t.getVisibleForNetworkWithPositiveBalance(enabledChainIds),
|
||||
t.getBalances(enabledChainIds),
|
||||
t.description,
|
||||
t.assetWebsiteUrl,
|
||||
|
|
|
@ -11,7 +11,8 @@ type
|
|||
totalCurrencyBalance: float
|
||||
enabledNetworkCurrencyBalance: float
|
||||
enabledNetworkBalance: float
|
||||
networkVisible: bool
|
||||
visibleForNetwork: bool
|
||||
visibleForNetworkWithPositiveBalance: bool
|
||||
balances: balance_model.BalanceModel
|
||||
description: string
|
||||
assetWebsiteUrl: string
|
||||
|
@ -33,7 +34,8 @@ proc initItem*(
|
|||
totalCurrencyBalance: float,
|
||||
enabledNetworkBalance: float,
|
||||
enabledNetworkCurrencyBalance: float,
|
||||
networkVisible: bool,
|
||||
visibleForNetwork: bool,
|
||||
visibleForNetworkWithPositiveBalance: bool,
|
||||
balances: seq[BalanceDto],
|
||||
description: string,
|
||||
assetWebsiteUrl: string,
|
||||
|
@ -55,7 +57,8 @@ proc initItem*(
|
|||
result.totalCurrencyBalance = totalCurrencyBalance
|
||||
result.enabledNetworkBalance = enabledNetworkBalance
|
||||
result.enabledNetworkCurrencyBalance = enabledNetworkCurrencyBalance
|
||||
result.networkVisible = networkVisible
|
||||
result.visibleForNetwork = visibleForNetwork
|
||||
result.visibleForNetworkWithPositiveBalance = visibleForNetworkWithPositiveBalance
|
||||
result.balances = balance_model.newModel()
|
||||
result.balances.setItems(balances)
|
||||
result.description = description
|
||||
|
@ -80,7 +83,8 @@ proc `$`*(self: Item): string =
|
|||
totalCurrencyBalance: {self.totalCurrencyBalance},
|
||||
enabledNetworkBalance: {self.enabledNetworkBalance},
|
||||
enabledNetworkCurrencyBalance: {self.enabledNetworkCurrencyBalance},
|
||||
networkVisible: {self.networkVisible},
|
||||
visibleForNetworkWithPositiveBalance: {self.visibleForNetworkWithPositiveBalance},
|
||||
visibleForNetwork: {self.visibleForNetwork},
|
||||
description: {self.description},
|
||||
assetWebsiteUrl: {self.assetWebsiteUrl}
|
||||
builtOn: {self.builtOn}
|
||||
|
@ -114,8 +118,11 @@ proc getEnabledNetworkBalance*(self: Item): float =
|
|||
proc getEnabledNetworkCurrencyBalance*(self: Item): float =
|
||||
return self.enabledNetworkCurrencyBalance
|
||||
|
||||
proc getNetworkVisible*(self: Item): bool =
|
||||
return self.networkVisible
|
||||
proc getVisibleForNetwork*(self: Item): bool =
|
||||
return self.visibleForNetwork
|
||||
|
||||
proc getVisibleForNetworkWithPositiveBalance*(self: Item): bool =
|
||||
return self.visibleForNetworkWithPositiveBalance
|
||||
|
||||
proc getBalances*(self: Item): balance_model.BalanceModel =
|
||||
return self.balances
|
||||
|
|
|
@ -10,7 +10,8 @@ type
|
|||
TotalCurrencyBalance
|
||||
EnabledNetworkCurrencyBalance
|
||||
EnabledNetworkBalance
|
||||
NetworkVisible
|
||||
VisibleForNetwork
|
||||
VisibleForNetworkWithPositiveBalance
|
||||
Balances
|
||||
Description
|
||||
AssetWebsiteUrl
|
||||
|
@ -66,7 +67,8 @@ QtObject:
|
|||
ModelRole.TotalCurrencyBalance.int:"totalCurrencyBalance",
|
||||
ModelRole.EnabledNetworkCurrencyBalance.int:"enabledNetworkCurrencyBalance",
|
||||
ModelRole.EnabledNetworkBalance.int:"enabledNetworkBalance",
|
||||
ModelRole.NetworkVisible.int:"networkVisible",
|
||||
ModelRole.VisibleForNetwork.int:"visibleForNetwork",
|
||||
ModelRole.VisibleForNetworkWithPositiveBalance.int:"visibleForNetworkWithPositiveBalance",
|
||||
ModelRole.Balances.int:"balances",
|
||||
ModelRole.Description.int:"description",
|
||||
ModelRole.AssetWebsiteUrl.int:"assetWebsiteUrl",
|
||||
|
@ -106,8 +108,10 @@ QtObject:
|
|||
result = newQVariant(item.getEnabledNetworkCurrencyBalance())
|
||||
of ModelRole.EnabledNetworkBalance:
|
||||
result = newQVariant(item.getEnabledNetworkBalance())
|
||||
of ModelRole.NetworkVisible:
|
||||
result = newQVariant(item.getNetworkVisible())
|
||||
of ModelRole.VisibleForNetwork:
|
||||
result = newQVariant(item.getVisibleForNetwork())
|
||||
of ModelRole.VisibleForNetworkWithPositiveBalance:
|
||||
result = newQVariant(item.getVisibleForNetworkWithPositiveBalance())
|
||||
of ModelRole.Balances:
|
||||
result = newQVariant(item.getBalances())
|
||||
of ModelRole.Description:
|
||||
|
@ -148,7 +152,8 @@ QtObject:
|
|||
of "totalCurrencyBalance": result = $item.getTotalCurrencyBalance()
|
||||
of "enabledNetworkCurrencyBalance": result = $item.getEnabledNetworkCurrencyBalance()
|
||||
of "enabledNetworkBalance": result = $item.getEnabledNetworkBalance()
|
||||
of "networkVisible": result = $item.getNetworkVisible()
|
||||
of "visibleForNetwork": result = $item.getVisibleForNetwork()
|
||||
of "visibleForNetworkWithPositiveBalance": result = $item.getVisibleForNetworkWithPositiveBalance()
|
||||
of "description": result = $item.getDescription()
|
||||
of "assetWebsiteUrl": result = $item.getAssetWebsiteUrl()
|
||||
of "builtOn": result = $item.getBuiltOn()
|
||||
|
|
|
@ -130,7 +130,14 @@ proc getCurrencyBalance*(self: WalletTokenDto, chainIds: seq[int]): float64 =
|
|||
|
||||
return sum
|
||||
|
||||
proc getVisible*(self: WalletTokenDto, chainIds: seq[int]): bool =
|
||||
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]:
|
||||
return true
|
||||
|
|
|
@ -17,7 +17,7 @@ Item {
|
|||
anchors.right: parent.right
|
||||
|
||||
anchors.left: parent.left
|
||||
visible: networkVisible
|
||||
visible: visibleForNetworkWithPositiveBalance
|
||||
height: visible ? 40 + 2 * Style.current.padding : 0
|
||||
|
||||
Image {
|
||||
|
|
|
@ -76,7 +76,7 @@ Item {
|
|||
ExpressionFilter {
|
||||
expression: {
|
||||
var tokenSymbolByAddress = searchTokenSymbolByAddressFn(d.searchString)
|
||||
return networkVisible && (
|
||||
return visibleForNetwork && (
|
||||
symbol.startsWith(d.searchString.toUpperCase()) || name.toUpperCase().startsWith(d.searchString.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
|
||||
)
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ Item {
|
|||
sourceModel: account.assets
|
||||
filters: [
|
||||
ExpressionFilter {
|
||||
expression: networkVisible
|
||||
expression: visibleForNetworkWithPositiveBalance
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ Rectangle {
|
|||
ExpressionFilter {
|
||||
expression: {
|
||||
var tokenSymbolByAddress = searchTokenSymbolByAddressFn(d.searchString)
|
||||
return networkVisible && (
|
||||
return visibleForNetwork && (
|
||||
symbol.startsWith(d.searchString.toUpperCase()) || name.toUpperCase().startsWith(d.searchString.toUpperCase()) || (tokenSymbolByAddress!=="" && symbol.startsWith(tokenSymbolByAddress))
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue