diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 5c4aaaac37..d8615f2502 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -102,6 +102,7 @@ dependencies { implementation(projects.data.feedback) implementation(projects.data.qrScanning) implementation(projects.data.staking) + implementation(projects.data.walletConnect) /** Features */ implementation(projects.features.onboarding) diff --git a/data/wallet-connect/.gitignore b/data/wallet-connect/.gitignore new file mode 100644 index 0000000000..796b96d1c4 --- /dev/null +++ b/data/wallet-connect/.gitignore @@ -0,0 +1 @@ +/build diff --git a/data/wallet-connect/build.gradle.kts b/data/wallet-connect/build.gradle.kts new file mode 100644 index 0000000000..5dc33697df --- /dev/null +++ b/data/wallet-connect/build.gradle.kts @@ -0,0 +1,30 @@ +plugins { + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.android.library) + id("configuration") +} + +android { + namespace = "com.tangem.data.walletconnect" +} + +dependencies { + + /* Project - Domain */ + implementation(projects.domain.walletConnect) + implementation(projects.domain.wallets.models) + + /* Project - Data */ + implementation(projects.core.datasource) + + /* Project - Core */ + implementation(projects.core.utils) + + /* DI */ + implementation(deps.hilt.core) + kapt(deps.hilt.kapt) + + /* Other */ + implementation(deps.kotlin.coroutines) +} \ No newline at end of file diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt new file mode 100644 index 0000000000..f701e44de9 --- /dev/null +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/DefaultWalletConnectRepository.kt @@ -0,0 +1,21 @@ +package com.tangem.data.walletconnect + +import com.tangem.datasource.local.userwallet.UserWalletsStore +import com.tangem.domain.walletconnect.repository.WalletConnectRepository +import com.tangem.domain.wallets.models.UserWalletId +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.withContext + +internal class DefaultWalletConnectRepository( + private val userWalletsStore: UserWalletsStore, + private val dispatchers: CoroutineDispatcherProvider, +) : WalletConnectRepository { + + override suspend fun checkIsAvailable(userWalletId: UserWalletId): Boolean = withContext(dispatchers.io) { + val userWallet = requireNotNull(userWalletsStore.getSyncOrNull(userWalletId)) { + "User wallet with id $userWalletId not found" + } + + userWallet.isMultiCurrency + } +} \ No newline at end of file diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt new file mode 100644 index 0000000000..02c6f391db --- /dev/null +++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/di/WalletConnectDataModule.kt @@ -0,0 +1,25 @@ +package com.tangem.data.walletconnect.di + +import com.tangem.data.walletconnect.DefaultWalletConnectRepository +import com.tangem.datasource.local.userwallet.UserWalletsStore +import com.tangem.domain.walletconnect.repository.WalletConnectRepository +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import dagger.Module +import dagger.Provides +import dagger.hilt.InstallIn +import dagger.hilt.components.SingletonComponent +import javax.inject.Singleton + +@Module +@InstallIn(SingletonComponent::class) +internal object WalletConnectDataModule { + + @Provides + @Singleton + fun providesWalletConnectRepository( + userWalletsStore: UserWalletsStore, + dispatchers: CoroutineDispatcherProvider, + ): WalletConnectRepository { + return DefaultWalletConnectRepository(userWalletsStore, dispatchers) + } +} \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 6977617dc4..9f9643c29f 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -212,4 +212,5 @@ include(":data:onboarding") include(":data:feedback") include(":data:qr-scanning") include(":data:staking") +include(":data:wallet-connect") // endregion Data modules \ No newline at end of file