Updated on 2026-08-14
This commit is contained in:
parent
312740cd64
commit
5f95ba532e
4 changed files with 43 additions and 23 deletions
|
|
@ -110,6 +110,13 @@ interface UserWalletsListManager {
|
|||
*/
|
||||
suspend fun unlock(): CompletionResult<UserWallet>
|
||||
|
||||
/**
|
||||
* Unlock all [UserWallet]s and select passed [UserWalletId]
|
||||
*
|
||||
* @param selectedWalletId [UserWalletId] of [UserWallet] which must be selected
|
||||
*/
|
||||
suspend fun unlockAndSelect(selectedWalletId: UserWalletId): CompletionResult<UserWallet>
|
||||
|
||||
/** Remove [UserWallet]s from [userWallets] and set [isLocked] as true */
|
||||
fun lock()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ 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
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
||||
/**
|
||||
* Unlock wallets use case
|
||||
|
|
@ -18,11 +19,11 @@ import com.tangem.domain.wallets.models.UnlockWalletError
|
|||
*/
|
||||
class UnlockWalletsUseCase(private val walletsStateHolder: WalletsStateHolder) {
|
||||
|
||||
suspend operator fun invoke(): Either<UnlockWalletError, Unit> {
|
||||
suspend operator fun invoke(selectedWalletId: UserWalletId): Either<UnlockWalletError, Unit> {
|
||||
val userWalletsListManager = walletsStateHolder.userWalletsListManager?.asLockable()
|
||||
?: return UnlockWalletError.CommonError.left()
|
||||
|
||||
userWalletsListManager.unlock()
|
||||
userWalletsListManager.unlockAndSelect(selectedWalletId = selectedWalletId)
|
||||
.doOnSuccess { return Unit.right() }
|
||||
.doOnFailure { return UnlockWalletError.CommonError.left() }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue