Updated on 2026-08-14
This commit is contained in:
parent
4c8af6b8e9
commit
1472431435
54 changed files with 370 additions and 352 deletions
|
|
@ -38,9 +38,7 @@ import com.tangem.utils.coroutines.runSuspendCatching
|
|||
import com.tangem.utils.extensions.addOrReplace
|
||||
import com.tangem.utils.extensions.indexOfFirstOrNull
|
||||
import kotlinx.coroutines.NonCancellable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
|
|
@ -69,14 +67,6 @@ internal class DefaultUserWalletsListRepository(
|
|||
|
||||
private val mutex = Mutex()
|
||||
|
||||
override fun getSyncOrNull(id: UserWalletId): UserWallet? {
|
||||
return userWallets.value?.find { it.walletId == id }
|
||||
}
|
||||
|
||||
override fun getSyncStrict(id: UserWalletId): UserWallet {
|
||||
return requireNotNull(getSyncOrNull(id)) { "Unable to find user wallet with provided ID: $id" }
|
||||
}
|
||||
|
||||
override suspend fun load() {
|
||||
mutex.withLock {
|
||||
if (userWallets.value != null) return
|
||||
|
|
@ -111,13 +101,6 @@ internal class DefaultUserWalletsListRepository(
|
|||
}
|
||||
}
|
||||
|
||||
override fun loadAndGet(): Flow<List<UserWallet>> = flow {
|
||||
load()
|
||||
userWallets.collect {
|
||||
emit(requireNotNull(it))
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun userWalletsSync(): List<UserWallet> {
|
||||
load()
|
||||
return requireNotNull(userWallets.value) {
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package com.tangem.tap.domain.userWalletList.repository
|
||||
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
import com.tangem.tap.domain.userWalletList.model.UserWalletEncryptionKey
|
||||
|
||||
internal interface UserWalletsKeysRepository {
|
||||
/**
|
||||
* Obtaining the encryption keys of all user wallets from the biometric vault. Biometric authentication required
|
||||
* If that operation runs more than biometric cipher key expiration time then the user will not receive all
|
||||
* encryption keys
|
||||
* @return [CompletionResult] of operation with stored [UserWalletEncryptionKey] list
|
||||
* */
|
||||
suspend fun getAll(): CompletionResult<List<UserWalletEncryptionKey>>
|
||||
|
||||
/**
|
||||
* Save the encryption key for user wallet. Biometric authentication not required
|
||||
* @param encryptionKey [UserWalletEncryptionKey] to save
|
||||
* @return [CompletionResult] of operation
|
||||
* */
|
||||
suspend fun save(encryptionKey: UserWalletEncryptionKey): CompletionResult<Unit>
|
||||
|
||||
/**
|
||||
* Delete encryption keys for user wallets. Biometric authentication not required
|
||||
* @param userWalletsIds List of [UserWalletId] whose encryption keys will be deleted
|
||||
* */
|
||||
suspend fun delete(userWalletsIds: List<UserWalletId>)
|
||||
|
||||
/**
|
||||
* Clear all encryption keys for user wallets. Biometric authentication not required
|
||||
* */
|
||||
suspend fun clear()
|
||||
|
||||
/**
|
||||
* Determine if the user has saved user wallets
|
||||
* @return [Boolean] true if user has saved wallets
|
||||
* */
|
||||
fun hasSavedEncryptionKeys(): Boolean
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue