Updated on 2026-08-14
This commit is contained in:
commit
48f20925f6
53 changed files with 541 additions and 76 deletions
|
|
@ -84,6 +84,11 @@ interface UserWalletsListManager {
|
|||
*/
|
||||
suspend fun get(userWalletId: UserWalletId): CompletionResult<UserWallet>
|
||||
|
||||
/**
|
||||
* Indicates that the [UserWalletsListManager] supports [UserWalletsListManager.Lockable]
|
||||
* */
|
||||
fun isLockable(): Boolean
|
||||
|
||||
interface Lockable : UserWalletsListManager {
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -6,12 +6,6 @@ import com.tangem.domain.wallets.models.UserWallet
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
/**
|
||||
* Indicates that the [UserWalletsListManager] implements [UserWalletsListManager.Lockable]
|
||||
* */
|
||||
val UserWalletsListManager.isLockable: Boolean
|
||||
get() = this is UserWalletsListManager.Lockable
|
||||
|
||||
/**
|
||||
* Indicates that the [UserWalletsListManager] is locked
|
||||
*
|
||||
|
|
@ -48,16 +42,6 @@ suspend fun UserWalletsListManager.unlockIfLockable(type: UnlockType = UnlockTyp
|
|||
return asLockable()?.unlock(type) ?: CompletionResult.Failure(UserWalletsListError.UnableToUnlockUserWallets())
|
||||
}
|
||||
|
||||
/**
|
||||
* Call [UserWalletsListManager.Lockable.lock] if [UserWalletsListManager] implements [UserWalletsListManager.Lockable]
|
||||
* or do nothing otherwise
|
||||
*
|
||||
* @see UserWalletsListManager.Lockable.lock
|
||||
* */
|
||||
fun UserWalletsListManager.lockIfLockable() {
|
||||
asLockable()?.lock()
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe cast [UserWalletsListManager] to [UserWalletsListManager.Lockable]
|
||||
*
|
||||
|
|
@ -65,5 +49,8 @@ fun UserWalletsListManager.lockIfLockable() {
|
|||
* [UserWalletsListManager.Lockable] otherwise
|
||||
* */
|
||||
fun UserWalletsListManager.asLockable(): UserWalletsListManager.Lockable? {
|
||||
return this as? UserWalletsListManager.Lockable
|
||||
if (this.isLockable()) {
|
||||
return this as? UserWalletsListManager.Lockable
|
||||
}
|
||||
return null
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue