Updated on 2026-08-14
This commit is contained in:
parent
81cce1254d
commit
879c8d603b
19 changed files with 566 additions and 415 deletions
|
|
@ -6,7 +6,7 @@ data class TxHistoryItem(
|
|||
val txHash: String,
|
||||
val timestampInMillis: Long,
|
||||
val direction: TransactionDirection,
|
||||
val status: TxStatus,
|
||||
val status: TransactionStatus,
|
||||
val type: TransactionType,
|
||||
val amount: BigDecimal,
|
||||
) {
|
||||
|
|
@ -20,9 +20,21 @@ data class TxHistoryItem(
|
|||
|
||||
sealed interface TransactionType {
|
||||
object Transfer : TransactionType
|
||||
object Submit : TransactionType
|
||||
object Approve : TransactionType
|
||||
object Supply : TransactionType
|
||||
object Withdraw : TransactionType
|
||||
object Deposit : TransactionType
|
||||
object Swap : TransactionType
|
||||
object Unoswap : TransactionType
|
||||
data class Custom(val id: String) : TransactionType
|
||||
}
|
||||
|
||||
enum class TxStatus { Confirmed, Unconfirmed }
|
||||
sealed class TransactionStatus {
|
||||
object Failed : TransactionStatus()
|
||||
object Unconfirmed : TransactionStatus()
|
||||
object Confirmed : TransactionStatus()
|
||||
}
|
||||
|
||||
sealed class Address {
|
||||
data class Single(val rawAddress: String) : Address()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.tangem.domain.txhistory.repository
|
||||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.domain.tokens.models.CryptoCurrency
|
||||
import com.tangem.domain.tokens.models.Network
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
|
|
@ -13,5 +14,5 @@ interface TxHistoryRepository {
|
|||
suspend fun getTxHistoryItemsCount(network: Network): Int
|
||||
|
||||
@Throws(TxHistoryListError::class)
|
||||
fun getTxHistoryItems(network: Network, pageSize: Int): Flow<PagingData<TxHistoryItem>>
|
||||
fun getTxHistoryItems(currency: CryptoCurrency, pageSize: Int): Flow<PagingData<TxHistoryItem>>
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.domain.txhistory.usecase
|
|||
import androidx.paging.PagingData
|
||||
import arrow.core.Either
|
||||
import arrow.core.raise.either
|
||||
import com.tangem.domain.tokens.models.Network
|
||||
import com.tangem.domain.tokens.models.CryptoCurrency
|
||||
import com.tangem.domain.txhistory.models.TxHistoryItem
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
import com.tangem.domain.txhistory.repository.TxHistoryRepository
|
||||
|
|
@ -15,12 +15,12 @@ private const val DEFAULT_PAGE_SIZE = 20
|
|||
class GetTxHistoryItemsUseCase(private val repository: TxHistoryRepository) {
|
||||
|
||||
operator fun invoke(
|
||||
network: Network,
|
||||
currency: CryptoCurrency,
|
||||
pageSize: Int = DEFAULT_PAGE_SIZE,
|
||||
): Either<TxHistoryListError, Flow<PagingData<TxHistoryItem>>> {
|
||||
return either {
|
||||
repository
|
||||
.getTxHistoryItems(network = network, pageSize = pageSize)
|
||||
.getTxHistoryItems(currency = currency, pageSize = pageSize)
|
||||
.catch { raise(TxHistoryListError.DataError(it)) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue