From c5d78b20407b744d8224b092f1eaff8018b03463 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 24 Feb 2025 00:58:45 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../configs/feature_toggles_config.json | 4 ++ .../local/preferences/PreferencesKeys.kt | 2 + .../data/wallets/DefaultWalletsRepository.kt | 20 ++++++ .../wallets/repository/WalletsRepository.kt | 6 ++ features/nft/api/.gitignore | 1 + features/nft/api/build.gradle.kts | 22 +++++++ .../tangem/features/nft/NFTFeatureToggles.kt | 5 ++ features/nft/impl/.gitignore | 1 + features/nft/impl/build.gradle.kts | 66 +++++++++++++++++++ .../features/nft/DefaultNFTFeatureToggles.kt | 10 +++ .../tangem/features/nft/NFTFeatureModule.kt | 19 ++++++ 11 files changed, 156 insertions(+) create mode 100644 features/nft/api/.gitignore create mode 100644 features/nft/api/build.gradle.kts create mode 100644 features/nft/api/src/main/kotlin/com/tangem/features/nft/NFTFeatureToggles.kt create mode 100644 features/nft/impl/.gitignore create mode 100644 features/nft/impl/build.gradle.kts create mode 100644 features/nft/impl/src/main/kotlin/com/tangem/features/nft/DefaultNFTFeatureToggles.kt create mode 100644 features/nft/impl/src/main/kotlin/com/tangem/features/nft/NFTFeatureModule.kt diff --git a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json index ba2bb626ea..92d4653d08 100644 --- a/core/config-toggles/src/main/assets/configs/feature_toggles_config.json +++ b/core/config-toggles/src/main/assets/configs/feature_toggles_config.json @@ -46,5 +46,9 @@ { "name": "BALANCES_CACHING_ENABLED", "version": "5.21.0" + }, + { + "name": "NFT_ENABLED", + "version": "undefined" } ] diff --git a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt index 434d4c4a92..52d244da2b 100644 --- a/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt +++ b/core/datasource/src/main/java/com/tangem/datasource/local/preferences/PreferencesKeys.kt @@ -121,6 +121,8 @@ object PreferencesKeys { val SEED_FIRST_NOTIFICATION_SHOW_TIME by lazy { longPreferencesKey("seedFirstNotificationTime") } + val WALLETS_WITH_NFT_ENABLED_KEY by lazy { stringSetPreferencesKey(name = "walletsWithNftEnabled") } + fun getShouldShowStoriesKey(storyId: String) = booleanPreferencesKey("shouldShowStories_$storyId") // region Permission diff --git a/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt b/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt index 0d0c0f38ee..e8a5b95b08 100644 --- a/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt +++ b/data/wallets/src/main/java/com/tangem/data/wallets/DefaultWalletsRepository.kt @@ -202,4 +202,24 @@ internal class DefaultWalletsRepository( } } } + + override fun nftEnabledStatus(userWalletId: UserWalletId): Flow { + return appPreferencesStore + .get(key = PreferencesKeys.WALLETS_WITH_NFT_ENABLED_KEY, default = emptySet()) + .map { it.contains(userWalletId.stringValue) } + } + + override suspend fun enableNFT(userWalletId: UserWalletId) { + appPreferencesStore.editData { + val added = it[PreferencesKeys.WALLETS_WITH_NFT_ENABLED_KEY].orEmpty() + it[PreferencesKeys.WALLETS_WITH_NFT_ENABLED_KEY] = added + userWalletId.stringValue + } + } + + override suspend fun disableNFT(userWalletId: UserWalletId) { + appPreferencesStore.editData { + val added = it[PreferencesKeys.WALLETS_WITH_NFT_ENABLED_KEY].orEmpty() + it[PreferencesKeys.WALLETS_WITH_NFT_ENABLED_KEY] = added - userWalletId.stringValue + } + } } \ No newline at end of file diff --git a/domain/wallets/src/main/java/com/tangem/domain/wallets/repository/WalletsRepository.kt b/domain/wallets/src/main/java/com/tangem/domain/wallets/repository/WalletsRepository.kt index f226543d60..b1e526ce5c 100644 --- a/domain/wallets/src/main/java/com/tangem/domain/wallets/repository/WalletsRepository.kt +++ b/domain/wallets/src/main/java/com/tangem/domain/wallets/repository/WalletsRepository.kt @@ -29,4 +29,10 @@ interface WalletsRepository { suspend fun acceptSeedPhraseSecondNotification(userWalletId: UserWalletId) suspend fun markWallet2WasCreated(userWalletId: UserWalletId) + + fun nftEnabledStatus(userWalletId: UserWalletId): Flow + + suspend fun enableNFT(userWalletId: UserWalletId) + + suspend fun disableNFT(userWalletId: UserWalletId) } \ No newline at end of file diff --git a/features/nft/api/.gitignore b/features/nft/api/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/features/nft/api/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/features/nft/api/build.gradle.kts b/features/nft/api/build.gradle.kts new file mode 100644 index 0000000000..f94a0582c0 --- /dev/null +++ b/features/nft/api/build.gradle.kts @@ -0,0 +1,22 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + id("configuration") +} + +android { + namespace = "com.tangem.features.nft.api" +} + +dependencies { + + /* Project - Domain */ + implementation(projects.domain.models) + + /* Project - Core */ + implementation(projects.core.decompose) + implementation(projects.core.ui) + + /* Compose */ + implementation(deps.compose.runtime) +} \ No newline at end of file diff --git a/features/nft/api/src/main/kotlin/com/tangem/features/nft/NFTFeatureToggles.kt b/features/nft/api/src/main/kotlin/com/tangem/features/nft/NFTFeatureToggles.kt new file mode 100644 index 0000000000..a3b0ad1cb5 --- /dev/null +++ b/features/nft/api/src/main/kotlin/com/tangem/features/nft/NFTFeatureToggles.kt @@ -0,0 +1,5 @@ +package com.tangem.features.nft + +interface NFTFeatureToggles { + val isNFTEnabled: Boolean +} \ No newline at end of file diff --git a/features/nft/impl/.gitignore b/features/nft/impl/.gitignore new file mode 100644 index 0000000000..42afabfd2a --- /dev/null +++ b/features/nft/impl/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/features/nft/impl/build.gradle.kts b/features/nft/impl/build.gradle.kts new file mode 100644 index 0000000000..0de9bbcd2d --- /dev/null +++ b/features/nft/impl/build.gradle.kts @@ -0,0 +1,66 @@ +plugins { + alias(deps.plugins.android.library) + alias(deps.plugins.kotlin.android) + alias(deps.plugins.kotlin.kapt) + alias(deps.plugins.kotlin.serialization) + alias(deps.plugins.hilt.android) + id("configuration") +} + +android { + namespace = "com.tangem.features.nft.impl" +} + +dependencies { + /** Api */ + implementation(projects.features.nft.api) + + /** Core modules */ + implementation(projects.core.configToggles) + implementation(projects.core.analytics) + implementation(projects.core.analytics.models) + implementation(projects.core.utils) + implementation(projects.core.ui) + implementation(projects.core.res) + implementation(projects.core.decompose) + implementation(projects.core.navigation) + implementation(projects.core.datasource) + + /** Common */ + implementation(projects.common.ui) + implementation(projects.common.routing) + + /** Tangem libraries */ + implementation(projects.libs.tangemSdkApi) + implementation(deps.tangem.card.core) + implementation(deps.tangem.card.android) { + exclude(module = "joda-time") + } + + /** AndroidX libraries */ + implementation(deps.androidx.core.ktx) + implementation(deps.lifecycle.runtime.ktx) + + /** Compose libraries */ + implementation(deps.compose.material) // to use buttons and text field in MultiWalletSeedPhraseImport.kt + implementation(deps.compose.material3) + implementation(deps.compose.animation) + implementation(deps.compose.foundation) + implementation(deps.compose.ui) + implementation(deps.compose.ui.tooling) + implementation(deps.compose.coil) + implementation(deps.lottie.compose) + implementation(deps.decompose.ext.compose) + implementation(deps.androidx.activity.compose) + implementation(deps.androidx.datastore) + + /** Other libraries */ + implementation(deps.kotlin.immutable.collections) + implementation(deps.kotlin.serialization) + implementation(deps.timber) + implementation(deps.firebase.crashlytics) + + /** DI */ + implementation(deps.hilt.android) + kapt(deps.hilt.kapt) +} \ No newline at end of file diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/DefaultNFTFeatureToggles.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/DefaultNFTFeatureToggles.kt new file mode 100644 index 0000000000..7697217e52 --- /dev/null +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/DefaultNFTFeatureToggles.kt @@ -0,0 +1,10 @@ +package com.tangem.features.nft + +import com.tangem.core.configtoggle.feature.FeatureTogglesManager + +internal class DefaultNFTFeatureToggles( + private val featureTogglesManager: FeatureTogglesManager, +) : NFTFeatureToggles { + override val isNFTEnabled: Boolean + get() = featureTogglesManager.isFeatureEnabled(name = "NFT_ENABLED") +} \ No newline at end of file diff --git a/features/nft/impl/src/main/kotlin/com/tangem/features/nft/NFTFeatureModule.kt b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/NFTFeatureModule.kt new file mode 100644 index 0000000000..b456b29b0b --- /dev/null +++ b/features/nft/impl/src/main/kotlin/com/tangem/features/nft/NFTFeatureModule.kt @@ -0,0 +1,19 @@ +package com.tangem.features.nft + +import com.tangem.core.configtoggle.feature.FeatureTogglesManager +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 NFTFeatureModule { + + @Provides + @Singleton + fun provideFeatureToggles(featureTogglesManager: FeatureTogglesManager): NFTFeatureToggles { + return DefaultNFTFeatureToggles(featureTogglesManager) + } +} \ No newline at end of file