Updated on 2026-08-14

This commit is contained in:
Tangem 2024-05-29 15:54:03 +04:00
parent d19703e048
commit 5d206bd37f
17 changed files with 107 additions and 98 deletions

View file

@ -5,7 +5,9 @@ package com.tangem.domain.wallets.models
*/
sealed interface SaveWalletError {
object DataError : SaveWalletError
val messageId: Int?
data class WalletAlreadySaved(val messageId: Int) : SaveWalletError
data class DataError(override val messageId: Int?) : SaveWalletError
data class WalletAlreadySaved(override val messageId: Int) : SaveWalletError
}

View file

@ -3,7 +3,6 @@ package com.tangem.domain.wallets.usecase
import com.tangem.domain.wallets.legacy.UserWalletsListManager
import com.tangem.domain.wallets.models.UserWallet
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.firstOrNull
/**
* Use case for getting list of user wallets
@ -18,5 +17,5 @@ class GetWalletsUseCase(private val userWalletsListManager: UserWalletsListManag
operator fun invoke(): Flow<List<UserWallet>> = userWalletsListManager.userWallets
@Throws(IllegalArgumentException::class)
suspend fun invokeSync(): List<UserWallet>? = userWalletsListManager.userWallets.firstOrNull()
fun invokeSync(): List<UserWallet> = userWalletsListManager.userWalletsSync
}

View file

@ -29,7 +29,7 @@ class SaveWalletUseCase(private val userWalletsListManager: UserWalletsListManag
is UserWalletsListError.WalletAlreadySaved -> SaveWalletError.WalletAlreadySaved(
it.messageResId,
)
else -> SaveWalletError.DataError
else -> SaveWalletError.DataError(it.messageResId)
}.left()
}