Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-15 23:47:29 +05:00
parent 4cd56a1588
commit 17ae97606e
13 changed files with 119 additions and 64 deletions

View file

@ -49,6 +49,6 @@ dependencies {
implementation(tangemDeps.card.core)
/** DI */
implementation(deps.hilt.core)
implementation(deps.hilt.android)
kapt(deps.hilt.kapt)
}

View file

@ -1,5 +1,6 @@
package com.tangem.data.nft
import android.content.res.Resources
import arrow.core.Either
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
@ -48,6 +49,7 @@ internal class DefaultNFTRepository @Inject constructor(
private val excludedBlockchains: ExcludedBlockchains,
private val userWalletsStore: UserWalletsStore,
private val nftFeatureToggles: NFTFeatureToggles,
resources: Resources,
) : NFTRepository {
private val networkJobs = ConcurrentHashMap<Network, JobHolder>()
@ -59,6 +61,7 @@ internal class DefaultNFTRepository @Inject constructor(
private val collectionIdConverter = NFTSdkCollectionIdentifierConverter
private val assetIdConverter = NFTSdkAssetIdentifierConverter
private val nftSdkCollectionConverter by lazy { NFTSdkCollectionConverter(resources) }
override fun observeCollections(userWalletId: UserWalletId, networks: List<Network>): Flow<List<NFTCollections>> =
flow { emitAll(observeCollectionsInternal(userWalletId, networks)) }
@ -319,7 +322,7 @@ internal class DefaultNFTRepository @Inject constructor(
content = NFTCollections.Content.Collections(
collections = collections
.map { collection ->
NFTSdkCollectionConverter.convert(network to collection)
nftSdkCollectionConverter.convert(network to collection)
}
.filter {
it.id !is NFTCollection.Identifier.Unknown
@ -417,7 +420,7 @@ internal class DefaultNFTRepository @Inject constructor(
content = NFTCollections.Content.Collections(
collections = it
?.map { collection ->
NFTSdkCollectionConverter.convert(network to collection)
nftSdkCollectionConverter.convert(network to collection)
}
?.filter {
it.id !is NFTCollection.Identifier.Unknown

View file

@ -1,18 +1,45 @@
package com.tangem.data.nft.di
import android.content.Context
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
import com.tangem.data.nft.DefaultNFTRepository
import com.tangem.datasource.local.nft.NFTPersistenceStoreFactory
import com.tangem.datasource.local.nft.NFTRuntimeStoreFactory
import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.nft.repository.NFTRepository
import dagger.Binds
import com.tangem.domain.walletmanager.WalletManagersFacade
import com.tangem.features.nft.NFTFeatureToggles
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton
@Module
@InstallIn(SingletonComponent::class)
internal interface NFTDataModule {
internal object NFTDataModule {
@Binds
@Provides
@Singleton
fun bindNFTRepository(repository: DefaultNFTRepository): NFTRepository
fun provideNFTRepository(
@ApplicationContext context: Context,
nftPersistenceStoreFactory: NFTPersistenceStoreFactory,
nftRuntimeStoreFactory: NFTRuntimeStoreFactory,
walletManagersFacade: WalletManagersFacade,
dispatchers: CoroutineDispatcherProvider,
excludedBlockchains: ExcludedBlockchains,
userWalletsStore: UserWalletsStore,
nftFeatureToggles: NFTFeatureToggles,
): NFTRepository = DefaultNFTRepository(
nftPersistenceStoreFactory = nftPersistenceStoreFactory,
nftRuntimeStoreFactory = nftRuntimeStoreFactory,
walletManagersFacade = walletManagersFacade,
dispatchers = dispatchers,
excludedBlockchains = excludedBlockchains,
userWalletsStore = userWalletsStore,
nftFeatureToggles = nftFeatureToggles,
resources = context.resources,
)
}