Updated on 2026-08-14

This commit is contained in:
Tangem 2024-06-17 13:40:04 +04:00
parent 888d26029b
commit e1ef1c4b8a
10 changed files with 352 additions and 8 deletions

View file

@ -16,6 +16,7 @@ dependencies {
// endregion
// region Domain modules
api(projects.domain.core)
implementation(projects.domain.legacy)
implementation(projects.libs.blockchainSdk)
implementation(projects.domain.models)
@ -28,9 +29,4 @@ dependencies {
implementation(deps.tangem.blockchain) // android-library
implementation(deps.tangem.card.core)
// endregion
// region Other libraries
implementation(deps.arrow.core)
implementation(deps.kotlin.coroutines)
// endregion
}

View file

@ -1,12 +1,17 @@
package com.tangem.domain.wallets.usecase
import arrow.core.Either
import arrow.core.left
import arrow.core.raise.either
import arrow.core.raise.ensureNotNull
import arrow.core.right
import com.tangem.domain.core.utils.EitherFlow
import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.domain.wallets.models.GetUserWalletError
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.transformLatest
class GetUserWalletUseCase(private val userWalletsListManager: UserWalletsListManager) {
@ -17,4 +22,13 @@ class GetUserWalletUseCase(private val userWalletsListManager: UserWalletsListMa
raise(GetUserWalletError.UserWalletNotFound)
}
}
@OptIn(ExperimentalCoroutinesApi::class)
fun invokeFlow(userWalletId: UserWalletId): EitherFlow<GetUserWalletError, UserWallet> {
return userWalletsListManager.userWallets.transformLatest { userWallets ->
userWallets.firstOrNull { it.walletId == userWalletId }
?.let { emit(it.right()) }
?: emit(GetUserWalletError.UserWalletNotFound.left())
}
}
}