Updated on 2026-08-14

This commit is contained in:
Tangem 2026-05-04 14:46:26 +04:00
parent 3d5a8654a5
commit 67ca192c16
19 changed files with 90 additions and 52 deletions

View file

@ -2,6 +2,7 @@ package com.tangem.domain.wallets.usecase
import arrow.core.Either
import arrow.core.raise.either
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.domain.common.wallets.UserWalletsListRepository
import com.tangem.domain.common.wallets.error.UnlockWalletError
import com.tangem.domain.models.wallet.UserWallet
@ -22,7 +23,10 @@ class NonBiometricUnlockWalletUseCase(
private val walletsRepository: WalletsRepository,
) {
suspend operator fun invoke(userWalletId: UserWalletId): Either<UnlockWalletError, Unit> = either {
suspend operator fun invoke(
userWalletId: UserWalletId,
source: AnalyticsParam.ScreensSources,
): Either<UnlockWalletError, Unit> = either {
val userWallet = userWalletsListRepository.userWalletsSync()
.find { it.walletId == userWalletId }
?: raise(UnlockWalletError.UserWalletNotFound)
@ -32,7 +36,7 @@ class NonBiometricUnlockWalletUseCase(
}
val method = when (userWallet) {
is UserWallet.Cold -> UserWalletsListRepository.UnlockMethod.Scan()
is UserWallet.Cold -> UserWalletsListRepository.UnlockMethod.Scan(scanResponse = null, source = source)
is UserWallet.Hot -> UserWalletsListRepository.UnlockMethod.AccessCode
}

View file

@ -2,6 +2,7 @@ package com.tangem.domain.wallets.usecase
import arrow.core.Either
import arrow.core.raise.either
import com.tangem.core.analytics.models.AnalyticsParam
import com.tangem.domain.common.wallets.UserWalletsListRepository
import com.tangem.domain.common.wallets.error.UnlockWalletError
import com.tangem.domain.models.wallet.UserWalletId
@ -19,12 +20,15 @@ class UnlockWalletUseCase(
private val nonBiometricUnlockWalletUseCase: NonBiometricUnlockWalletUseCase,
) {
suspend operator fun invoke(userWalletId: UserWalletId): Either<UnlockWalletError, Unit> = either {
suspend operator fun invoke(
userWalletId: UserWalletId,
source: AnalyticsParam.ScreensSources,
): Either<UnlockWalletError, Unit> = either {
userWalletsListRepository.unlock(userWalletId, UserWalletsListRepository.UnlockMethod.Biometric)
.mapLeft { error ->
when (error) {
UnlockWalletError.AlreadyUnlocked -> Unit
else -> nonBiometricUnlockWalletUseCase(userWalletId).bind()
else -> nonBiometricUnlockWalletUseCase(userWalletId, source).bind()
}
}
}