Merge pull request #2831 from AlphaWallet/filter-away-spurious-tokens-wallet-tab

Remove spurious tokens from Wallet tab
pull/2843/head
Hwee-Boon Yar 3 years ago committed by GitHub
commit c3663e0a73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      AlphaWallet/Tokens/ViewModels/TokensViewModel.swift

@ -80,10 +80,15 @@ class TokensViewModel {
init(filterTokensCoordinator: FilterTokensCoordinator, tokens: [TokenObject], tickers: [AddressAndRPCServer: CoinTicker]) {
self.filterTokensCoordinator = filterTokensCoordinator
self.tokens = tokens
self.tokens = Self.filterAwaySpuriousTokens(tokens)
self.tickers = tickers
}
//Remove tokens that look unwanted in the Wallet tab
private static func filterAwaySpuriousTokens(_ tokens: [TokenObject]) -> [TokenObject] {
tokens.filter { !($0.name.isEmpty && $0.symbol.isEmpty && $0.decimals == 0) }
}
func markTokenHidden(token: TokenObject) -> Bool {
if let index = tokens.firstIndex(where: { $0.primaryKey == token.primaryKey }) {
tokens.remove(at: index)

Loading…
Cancel
Save