From d862133d703e47c8f5055971bbe576004b28d8da Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 18 Dec 2023 17:21:20 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../card/repository/DerivationsRepository.kt | 1 + features/wallet/impl/build.gradle.kts | 1 + .../wallet/viewmodels/WalletViewModel.kt | 1 - .../intents/WalletWarningsClickIntents.kt | 29 +++++++++++++------ 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/domain/card/src/main/kotlin/com/tangem/domain/card/repository/DerivationsRepository.kt b/domain/card/src/main/kotlin/com/tangem/domain/card/repository/DerivationsRepository.kt index eb058255a9..cd1af0a789 100644 --- a/domain/card/src/main/kotlin/com/tangem/domain/card/repository/DerivationsRepository.kt +++ b/domain/card/src/main/kotlin/com/tangem/domain/card/repository/DerivationsRepository.kt @@ -5,5 +5,6 @@ import com.tangem.domain.wallets.models.UserWalletId interface DerivationsRepository { + @Throws suspend fun derivePublicKeys(userWalletId: UserWalletId, currencies: List) } \ No newline at end of file diff --git a/features/wallet/impl/build.gradle.kts b/features/wallet/impl/build.gradle.kts index c10b9557d3..a3207eb5cd 100644 --- a/features/wallet/impl/build.gradle.kts +++ b/features/wallet/impl/build.gradle.kts @@ -70,6 +70,7 @@ dependencies { //TODO: Create api/impl modules for onboarding [REDACTED_JIRA] implementation(projects.features.onboarding) + implementation(projects.features.tester.api) /** Feature Apis */ implementation(projects.features.wallet.api) diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt index 4306e8b79a..6c025c1a77 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/WalletViewModel.kt @@ -316,7 +316,6 @@ internal class WalletViewModel @Inject constructor( } @Deprecated("Use DerivePublicKeysUseCase instead") - // FIXME: Migration: [REDACTED_JIRA] private fun deriveMissingCurrencies( scanResponse: ScanResponse, currencyList: List, diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt index 4643ee1da6..55407311ad 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletWarningsClickIntents.kt @@ -35,10 +35,12 @@ import com.tangem.feature.wallet.presentation.wallet.state.WalletEvent import com.tangem.feature.wallet.presentation.wallet.state2.WalletStateController import com.tangem.feature.wallet.presentation.wallet.state2.transformers.CloseBottomSheetTransformer import com.tangem.feature.wallet.presentation.wallet.state2.utils.WalletEventSender +import com.tangem.features.tester.api.TesterFeatureToggles import com.tangem.operations.derivation.ExtendedPublicKeysMap import com.tangem.utils.coroutines.CoroutineDispatcherProvider import dagger.hilt.android.scopes.ViewModelScoped import kotlinx.coroutines.launch +import timber.log.Timber import javax.inject.Inject internal interface WalletWarningsClickIntents { @@ -78,6 +80,7 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor( private val remindToRateAppLaterUseCase: RemindToRateAppLaterUseCase, private val analyticsEventHandler: AnalyticsEventHandler, private val reduxStateHolder: ReduxStateHolder, + private val testerFeatureToggles: TesterFeatureToggles, private val dispatchers: CoroutineDispatcherProvider, ) : BaseWalletClickIntents(), WalletWarningsClickIntents { @@ -107,8 +110,6 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor( } } - @Deprecated("Use DerivePublicKeysUseCase instead") - // FIXME: Migration: [REDACTED_JIRA] override fun onGenerateMissedAddressesClick(missedAddressCurrencies: List) { val userWallet = getSelectedWalletSyncUseCase.unwrap() ?: return @@ -116,15 +117,25 @@ internal class WalletWarningsClickIntentsImplementer @Inject constructor( analyticsEventHandler.send(MainScreen.NoticeScanYourCardTapped) viewModelScope.launch(dispatchers.main) { - deriveMissingCurrencies( - scanResponse = userWallet.scanResponse, - currencyList = missedAddressCurrencies, - ) { scannedCardResponse -> - updateWalletUseCase( + if (testerFeatureToggles.isDerivePublicKeysRefactoringEnabled) { + derivePublicKeysUseCase( userWalletId = userWallet.walletId, - update = { it.copy(scanResponse = scannedCardResponse) }, + currencies = missedAddressCurrencies, ) - .onRight { fetchTokenListUseCase(userWalletId = it.walletId) } + .onRight { fetchTokenListUseCase(userWalletId = userWallet.walletId) } + .onLeft { Timber.e("Failed to derive public keys: $it") } + } else { + // TODO: delete [REDACTED_JIRA] + deriveMissingCurrencies( + scanResponse = userWallet.scanResponse, + currencyList = missedAddressCurrencies, + ) { scannedCardResponse -> + updateWalletUseCase( + userWalletId = userWallet.walletId, + update = { it.copy(scanResponse = scannedCardResponse) }, + ) + .onRight { fetchTokenListUseCase(userWalletId = it.walletId) } + } } } }