From b0f22bcf477809202939c26fcc6a1c587535a9e2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 10 Dec 2025 14:42:26 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../di/UserWalletsListManagerModule.kt | 3 +++ .../repository/DefaultUserWalletsListRepository.kt | 13 ++++++++----- .../entry/AddExistingWalletModel.kt | 3 ++- .../walletactivation/entry/WalletActivationModel.kt | 3 ++- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerModule.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerModule.kt index abe6b49ded..74ad98e889 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerModule.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/di/UserWalletsListManagerModule.kt @@ -10,6 +10,7 @@ import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.analytics.utils.TrackingContextProxy import com.tangem.datasource.local.preferences.AppPreferencesStore import com.tangem.domain.common.wallets.UserWalletsListRepository +import com.tangem.domain.hotwallet.repository.HotWalletRepository import com.tangem.domain.models.scan.serialization.* import com.tangem.domain.visa.model.VisaActivationRemoteState import com.tangem.domain.visa.model.VisaCardActivationStatus @@ -127,6 +128,7 @@ internal object UserWalletsListManagerModule { tangemHotSdk: TangemHotSdk, trackingContextProxy: TrackingContextProxy, analyticsEventHandler: AnalyticsEventHandler, + hotWalletRepository: HotWalletRepository, ): UserWalletsListRepository { val moshi = buildMoshi() val secureStorage = buildSecureStorage(applicationContext = applicationContext) @@ -176,6 +178,7 @@ internal object UserWalletsListManagerModule { tangemHotSdk = tangemHotSdk, trackingContextProxy = trackingContextProxy, analyticsEventHandler = analyticsEventHandler, + hotWalletRepository = hotWalletRepository, ) } diff --git a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt index 3064dd8840..80dce033a7 100644 --- a/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/userWalletList/repository/DefaultUserWalletsListRepository.kt @@ -16,6 +16,7 @@ import com.tangem.datasource.local.preferences.utils.getSyncOrDefault import com.tangem.domain.common.wallets.UserWalletsListRepository import com.tangem.domain.common.wallets.UserWalletsListRepository.LockMethod import com.tangem.domain.common.wallets.error.* +import com.tangem.domain.hotwallet.repository.HotWalletRepository import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.isLocked @@ -55,6 +56,7 @@ internal class DefaultUserWalletsListRepository( private val tangemHotSdk: TangemHotSdk, private val trackingContextProxy: TrackingContextProxy, private val analyticsEventHandler: AnalyticsEventHandler, + private val hotWalletRepository: HotWalletRepository, ) : UserWalletsListRepository { override val userWallets = MutableStateFlow?>(null) @@ -209,7 +211,7 @@ internal class DefaultUserWalletsListRepository( userWalletEncryptionKeysRepository.delete(userWalletIds) - removeHotWalletsFromSDK(userWalletIds) + removeHotWalletsFromSDKAndRepos(userWalletIds) userWallets.update { currentWallets -> val updatedWallets = currentWallets?.filter { userWalletIds.contains(it.walletId).not() } @@ -388,7 +390,7 @@ internal class DefaultUserWalletsListRepository( if (newUserWallet.walletId == oldUserWallet.walletId && oldUserWallet is UserWallet.Hot && newUserWallet is UserWallet.Cold ) { - removeHotWalletsFromSDK(walletIds = listOf(oldUserWallet.walletId)) + removeHotWalletsFromSDKAndRepos(walletIds = listOf(oldUserWallet.walletId)) // When upgrading from Hot to Cold, if biometric lock is available, set it if (hasBiometry()) { setLock(newUserWallet.walletId, LockMethod.Biometric, changeUnsecured = true) @@ -399,13 +401,14 @@ internal class DefaultUserWalletsListRepository( } } - private suspend fun removeHotWalletsFromSDK(walletIds: List) { + private suspend fun removeHotWalletsFromSDKAndRepos(walletIds: List) { val hotWalletsToDelete = userWalletsSync() .filterIsInstance() .filter { walletIds.contains(it.walletId) } - hotWalletsToDelete.forEach { - tangemHotSdk.delete(it.hotWalletId) + hotWalletsToDelete.forEach { wallet -> + hotWalletRepository.setAccessCodeSkipped(wallet.walletId, false) // In case the wallet is added again + tangemHotSdk.delete(wallet.hotWalletId) } } diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt index e40072474a..51cfc12211 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/addexistingwallet/entry/AddExistingWalletModel.kt @@ -27,6 +27,7 @@ import com.tangem.features.hotwallet.stepper.api.HotWalletStepperComponent import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks import com.tangem.features.pushnotifications.api.utils.PUSH_PERMISSION import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -110,7 +111,7 @@ internal class AddExistingWalletModel @Inject constructor( title = resourceReference(R.string.access_code_alert_skip_ok), onClick = { if (userWalletId != null) { - modelScope.launch { + modelScope.launch(NonCancellable) { setAccessCodeSkippedUseCase(userWalletId, true) } } diff --git a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt index 7def0b0676..3f91e6d246 100644 --- a/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt +++ b/features/hot-wallet/impl/src/main/kotlin/com/tangem/features/hotwallet/walletactivation/entry/WalletActivationModel.kt @@ -33,6 +33,7 @@ import com.tangem.features.hotwallet.WalletActivationComponent import com.tangem.features.hotwallet.stepper.api.HotWalletStepperComponent import com.tangem.features.pushnotifications.api.PushNotificationsModelCallbacks import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.NonCancellable import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import javax.inject.Inject @@ -134,7 +135,7 @@ internal class WalletActivationModel @Inject constructor( secondAction = EventMessageAction( title = resourceReference(R.string.access_code_alert_skip_ok), onClick = { - modelScope.launch { + modelScope.launch(NonCancellable) { setAccessCodeSkippedUseCase(userWalletId, true) } navigateToPushNotificationsOrNext()