Updated on 2026-08-14

This commit is contained in:
Tangem 2024-03-18 19:19:58 +00:00
parent e878dcd7c3
commit 299b55b540
6 changed files with 36 additions and 21 deletions

View file

@ -0,0 +1,7 @@
package com.tangem.domain.txhistory.models
sealed class TxStatusError {
data object EmptyUrlError : TxStatusError()
data class DataError(val cause: Throwable) : TxStatusError()
}

View file

@ -1,12 +1,25 @@
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.txhistory.models.TxStatusError
import com.tangem.domain.txhistory.repository.TxHistoryRepository
class GetExplorerTransactionUrlUseCase(
private val repository: TxHistoryRepository,
) {
operator fun invoke(txHash: String, networkId: Network.ID): String {
return repository.getTxExploreUrl(txHash, networkId)
operator fun invoke(txHash: String, networkId: Network.ID): Either<TxStatusError, String> {
return either {
catch(
block = {
repository.getTxExploreUrl(txHash, networkId).ifEmpty {
raise(TxStatusError.EmptyUrlError)
}
},
catch = { raise(TxStatusError.DataError(it)) },
)
}
}
}