Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-01 16:21:50 +05:00
parent 6ddf9a25ae
commit e8f2ed8517
22 changed files with 463 additions and 81 deletions

View file

@ -13,6 +13,8 @@ dependencies {
implementation(deps.arrow.core)
implementation(deps.kotlin.coroutines)
implementation(projects.core.utils)
implementation(projects.domain.core)
implementation(projects.domain.models)
implementation(projects.domain.nft.models)

View file

@ -0,0 +1,17 @@
package com.tangem.domain.nft
import com.tangem.domain.tokens.model.Network
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import kotlinx.coroutines.withContext
class FilterNFTAvailableNetworksUseCase(
private val dispatchers: CoroutineDispatcherProvider,
) {
suspend operator fun invoke(networks: List<Network>, searchQuery: String): List<Network> =
withContext(dispatchers.default) {
networks.filter {
it.name.contains(searchQuery, ignoreCase = true) ||
it.currencySymbol.contains(searchQuery, ignoreCase = true)
}
}
}

View file

@ -0,0 +1,22 @@
package com.tangem.domain.nft
import com.tangem.domain.nft.repository.NFTRepository
import com.tangem.domain.tokens.model.Network
import com.tangem.domain.tokens.repository.CurrenciesRepository
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
class GetNFTAvailableNetworksUseCase(
private val currenciesRepository: CurrenciesRepository,
private val nftRepository: NFTRepository,
) {
operator fun invoke(userWalletId: UserWalletId): Flow<List<Network>> = currenciesRepository
.getWalletCurrenciesUpdates(userWalletId)
.map { cryptoCurrencies ->
cryptoCurrencies
.map { cryptoCurrency -> cryptoCurrency.network }
.distinct()
.filter { nftRepository.isNFTSupported(it) }
}
}

View file

@ -12,4 +12,6 @@ interface NFTRepository {
suspend fun refreshCollections(userWalletId: UserWalletId, networks: List<Network>)
suspend fun refreshAssets(userWalletId: UserWalletId, network: Network, collectionId: NFTCollection.Identifier)
suspend fun isNFTSupported(network: Network): Boolean
}