diff --git a/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift b/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift index 07012ee27bd..fae9a126fab 100644 --- a/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift +++ b/Sources/BraveWallet/Crypto/Asset Details/AssetDetailView.swift @@ -137,16 +137,7 @@ struct AssetDetailView: View { case .blockchainToken(_): accountsBalanceView transactionsView - case .coinMarket(let coinMarket, let isSupported): - if isSupported { - accountsBalanceView - transactionsView - } else { - Text(Strings.Wallet.assetDetailNoSupported) - .font(.footnote) - .foregroundColor(Color(.braveLabel)) - .listRowBackground(Color.clear) - } + case .coinMarket(let coinMarket): Section { HStack { VStack(spacing: 10) { diff --git a/Sources/BraveWallet/Crypto/Market/MarketView.swift b/Sources/BraveWallet/Crypto/Market/MarketView.swift index b98e0fcfed4..4867f8a93f5 100644 --- a/Sources/BraveWallet/Crypto/Market/MarketView.swift +++ b/Sources/BraveWallet/Crypto/Market/MarketView.swift @@ -29,11 +29,6 @@ struct MarketView: View { self.marketStore = cryptoStore.marketStore } - private var isSelectedCoinMarketSupported: Bool { - guard let coinMarket = selectedCoinMarket else { return false } - return marketStore.allCoingeckoTokens.contains(where: { $0.coingeckoId.caseInsensitiveCompare(coinMarket.id) == .orderedSame }) - } - private var emptyState: some View { VStack(alignment: .center, spacing: 10) { Text(Strings.Wallet.coinMarketEmptyMsg) @@ -176,12 +171,12 @@ struct MarketView: View { destination: { if let coinMarket = selectedCoinMarket { AssetDetailView( - assetDetailStore: cryptoStore.assetDetailStore(for: .coinMarket(coinMarket, isSelectedCoinMarketSupported)), + assetDetailStore: cryptoStore.assetDetailStore(for: .coinMarket(coinMarket)), keyringStore: keyringStore, networkStore: cryptoStore.networkStore ) .onDisappear { - cryptoStore.closeAssetDetailStore(for: .coinMarket(coinMarket, isSelectedCoinMarketSupported)) + cryptoStore.closeAssetDetailStore(for: .coinMarket(coinMarket)) } } }, diff --git a/Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift b/Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift index c194674fc98..96027050c51 100644 --- a/Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/AssetDetailStore.swift @@ -20,13 +20,13 @@ struct AccountAssetViewModel: Identifiable { enum AssetDetailType: Identifiable { case blockchainToken(BraveWallet.BlockchainToken) - case coinMarket(BraveWallet.CoinMarket, Bool) + case coinMarket(BraveWallet.CoinMarket) var id: String { switch self { case .blockchainToken(let token): return token.tokenId - case .coinMarket(let coinMarket, _): + case .coinMarket(let coinMarket): return coinMarket.id } } @@ -86,7 +86,7 @@ class AssetDetailStore: ObservableObject { switch assetDetailType { case .blockchainToken(let token): return token - case .coinMarket(let coinMarket, _): + case .coinMarket(let coinMarket): return .init().then { for tokens in allBuyTokensAllOptions.values { if let matchedToken = tokens.first(where: { token in token.symbol.caseInsensitiveCompare(coinMarket.symbol) == .orderedSame }) { @@ -209,7 +209,7 @@ class AssetDetailStore: ObservableObject { self.accounts = await fetchAccountBalances(updatedAccounts, keyring: keyring, network: network) let assetRatios = [token.assetRatioId.lowercased(): assetPriceValue] self.transactionSummaries = await fetchTransactionSummarys(keyring: keyring, network: network, assetRatios: assetRatios) - case .coinMarket(let coinMarket, _): + case .coinMarket(let coinMarket): // comes from Market tab self.price = self.currencyFormatter.string(from: NSNumber(value: coinMarket.currentPrice)) ?? "" self.priceDelta = self.percentFormatter.string(from: NSNumber(value: coinMarket.priceChangePercentage24h / 100.0)) ?? "" diff --git a/Sources/BraveWallet/Crypto/Stores/MarketStore.swift b/Sources/BraveWallet/Crypto/Stores/MarketStore.swift index dc6c064cd0c..152a1b85fac 100644 --- a/Sources/BraveWallet/Crypto/Stores/MarketStore.swift +++ b/Sources/BraveWallet/Crypto/Stores/MarketStore.swift @@ -33,7 +33,6 @@ public class MarketStore: ObservableObject { private let rpcService: BraveWalletJsonRpcService private let walletService: BraveWalletBraveWalletService private let assetsRequestLimit = 250 - var allCoingeckoTokens: [BraveWallet.BlockchainToken] = [] let priceFormatter: NumberFormatter = .usdCurrencyFormatter let priceChangeFormatter = NumberFormatter().then { $0.numberStyle = .percent @@ -67,26 +66,8 @@ public class MarketStore: ObservableObject { // update currency code guard !Task.isCancelled else { return } self.currencyCode = await walletService.defaultBaseCurrency() - // update all supported coingecko tokens - guard !Task.isCancelled else { return } - self.allCoingeckoTokens = await fetchCoingeckoTokens() self.isLoading = false } } - - // Returns all coingecko tokens from the BlockchainRegistry and User's assets - @MainActor func fetchCoingeckoTokens() async -> [BraveWallet.BlockchainToken] { - let allNetworks = await rpcService.allNetworksForSupportedCoins() - let allUserAssets = await walletService.allUserAssets(in: allNetworks) - // Filter `allTokens` to remove any tokens existing in `allUserAssets`. This is possible for ERC721 tokens in the registry without a `tokenId`, which requires the user to add as a custom token - let allUserTokens = allUserAssets.flatMap(\.tokens).filter { !$0.coingeckoId.isEmpty } - let allBlockchainTokens = await blockchainRegistry.allTokens(in: allNetworks) - .flatMap(\.tokens) - .filter { token in - !allUserTokens.contains(where: { $0.id == token.id && !$0.coingeckoId.isEmpty }) - } - - return allUserTokens + allBlockchainTokens - } } diff --git a/Sources/BraveWallet/WalletStrings.swift b/Sources/BraveWallet/WalletStrings.swift index 01eab3bf149..0e193f3ff5c 100644 --- a/Sources/BraveWallet/WalletStrings.swift +++ b/Sources/BraveWallet/WalletStrings.swift @@ -3946,13 +3946,6 @@ extension Strings { value: "Market", comment: "The page title that will display the top 250 tokens from the market via CoinGecko" ) - public static let assetDetailNoSupported = NSLocalizedString( - "wallet.assetDetailNoSupported", - tableName: "BraveWallet", - bundle: .module, - value: "This asset is not supported by Brave Wallet", - comment: "A label that will be displayed instead of account balances and transactions when the token is not supported by Brave Wallet." - ) public static let coinMarketInformation = NSLocalizedString( "wallet.coinMarketInformation", tableName: "BraveWallet",