Updated on 2026-08-14

This commit is contained in:
Tangem 2023-08-07 18:36:05 +08:00
parent 4a058736ee
commit dc0b2a7e70
3 changed files with 44 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import com.tangem.domain.wallets.legacy.WalletsStateHolder
import com.tangem.domain.wallets.usecase.GetExploreUrlUseCase
import com.tangem.domain.wallets.usecase.GetWalletsUseCase
import com.tangem.domain.wallets.usecase.SaveWalletUseCase
import com.tangem.domain.wallets.usecase.UnlockWalletsUseCase
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
@ -32,4 +33,10 @@ internal object WalletsDomainModule {
fun providesGetExploreUrlUseCase(walletsManagersFacade: WalletManagersFacade): GetExploreUrlUseCase {
return GetExploreUrlUseCase(walletsManagersFacade = walletsManagersFacade)
}
@Provides
@ViewModelScoped
fun providesUnlockWalletUseCase(walletsStateHolder: WalletsStateHolder): UnlockWalletsUseCase {
return UnlockWalletsUseCase(walletsStateHolder = walletsStateHolder)
}
}

View file

@ -0,0 +1,6 @@
package com.tangem.domain.wallets.models
sealed interface UnlockWalletError {
object CommonError : UnlockWalletError
}

View file

@ -0,0 +1,31 @@
package com.tangem.domain.wallets.usecase
import arrow.core.Either
import arrow.core.left
import arrow.core.right
import com.tangem.common.doOnFailure
import com.tangem.common.doOnSuccess
import com.tangem.domain.wallets.legacy.WalletsStateHolder
import com.tangem.domain.wallets.legacy.asLockable
import com.tangem.domain.wallets.models.UnlockWalletError
/**
* Unlock wallets use case
*
* @property walletsStateHolder wallets state holder
*
[REDACTED_AUTHOR]
*/
class UnlockWalletsUseCase(private val walletsStateHolder: WalletsStateHolder) {
suspend operator fun invoke(): Either<UnlockWalletError, Unit> {
val userWalletsListManager = walletsStateHolder.userWalletsListManager?.asLockable()
?: return UnlockWalletError.CommonError.left()
userWalletsListManager.unlock()
.doOnSuccess { return Unit.right() }
.doOnFailure { return UnlockWalletError.CommonError.left() }
return Unit.right()
}
}