Updated on 2026-08-14
This commit is contained in:
parent
93f7f4b424
commit
9b1d655ab5
8 changed files with 24 additions and 15 deletions
|
|
@ -12,7 +12,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
interface TxHistoryRepository {
|
||||
|
||||
@Throws(TxHistoryStateError::class)
|
||||
suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, network: Network): Int
|
||||
suspend fun getTxHistoryItemsCount(userWalletId: UserWalletId, currency: CryptoCurrency): Int
|
||||
|
||||
@Throws(TxHistoryListError::class)
|
||||
fun getTxHistoryItems(
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.domain.txhistory.usecase
|
|||
import arrow.core.Either
|
||||
import arrow.core.raise.catch
|
||||
import arrow.core.raise.either
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
import com.tangem.domain.txhistory.repository.TxHistoryRepository
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
|
@ -11,10 +11,13 @@ import com.tangem.domain.wallets.models.UserWalletId
|
|||
// TODO: Add tests
|
||||
class GetTxHistoryItemsCountUseCase(private val repository: TxHistoryRepository) {
|
||||
|
||||
suspend operator fun invoke(userWalletId: UserWalletId, network: Network): Either<TxHistoryStateError, Int> {
|
||||
suspend operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
currency: CryptoCurrency,
|
||||
): Either<TxHistoryStateError, Int> {
|
||||
return either {
|
||||
catch(
|
||||
block = { repository.getTxHistoryItemsCount(userWalletId, network) },
|
||||
block = { repository.getTxHistoryItemsCount(userWalletId, currency) },
|
||||
catch = { throwable ->
|
||||
raise(
|
||||
when (throwable) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue