Updated on 2026-08-14
This commit is contained in:
parent
7c50cc09dc
commit
d1189ffda2
12 changed files with 9 additions and 25 deletions
|
|
@ -10,7 +10,6 @@ import com.tangem.data.txhistory.repository.paging.TxHistoryPagingSource
|
|||
import com.tangem.datasource.local.txhistory.TxHistoryItemsStore
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.models.network.TxInfo
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
|
@ -75,8 +74,8 @@ class DefaultTxHistoryRepository(
|
|||
return pager.flow
|
||||
}
|
||||
|
||||
override fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
override fun getTxExploreUrl(txHash: String, currency: CryptoCurrency): String {
|
||||
val blockchain = currency.network.id.toBlockchain()
|
||||
val txExploreState = when (currency) {
|
||||
is CryptoCurrency.Token -> blockchain.getTokenExplorerTxUrl(txHash)
|
||||
else -> blockchain.getExploreTxUrl(txHash)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package com.tangem.domain.txhistory.repository
|
|||
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.models.network.TxInfo
|
||||
import com.tangem.domain.txhistory.models.TxHistoryListError
|
||||
import com.tangem.domain.txhistory.models.TxHistoryStateError
|
||||
|
|
@ -22,7 +21,7 @@ interface TxHistoryRepository {
|
|||
refresh: Boolean,
|
||||
): Flow<PagingData<TxInfo>>
|
||||
|
||||
fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String
|
||||
fun getTxExploreUrl(txHash: String, currency: CryptoCurrency): String
|
||||
|
||||
@Throws(TxHistoryListError::class)
|
||||
suspend fun getFixedSizeTxHistoryItems(
|
||||
|
|
|
|||
|
|
@ -4,19 +4,12 @@ import arrow.core.Either
|
|||
import arrow.core.raise.catch
|
||||
import arrow.core.raise.either
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.txhistory.models.TxStatusError
|
||||
import com.tangem.domain.txhistory.repository.TxHistoryRepository
|
||||
import javax.inject.Inject
|
||||
|
||||
class GetExplorerTransactionUrlUseCase @Inject constructor(
|
||||
private val repository: TxHistoryRepository,
|
||||
) {
|
||||
operator fun invoke(
|
||||
txHash: String,
|
||||
networkId: Network.ID,
|
||||
currency: CryptoCurrency,
|
||||
): Either<TxStatusError, String> {
|
||||
class GetExplorerTransactionUrlUseCase(private val repository: TxHistoryRepository) {
|
||||
|
||||
operator fun invoke(txHash: String, currency: CryptoCurrency): Either<TxStatusError, String> {
|
||||
return either {
|
||||
catch(
|
||||
block = {
|
||||
|
|
@ -24,7 +17,7 @@ class GetExplorerTransactionUrlUseCase @Inject constructor(
|
|||
raise(TxStatusError.EmptyUrlError)
|
||||
}
|
||||
|
||||
repository.getTxExploreUrl(txHash, networkId, currency).ifEmpty {
|
||||
repository.getTxExploreUrl(txHash, currency).ifEmpty {
|
||||
raise(TxStatusError.EmptyUrlError)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -482,7 +482,6 @@ internal class SendConfirmModel @Inject constructor(
|
|||
private fun updateTransactionStatus(txData: TransactionData.Uncompiled, txHash: String) {
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash.ifEmpty { txData.hash.orEmpty() },
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).getOrNull().orEmpty()
|
||||
_uiState.update(SendConfirmSentStateTransformer(txData, txUrl))
|
||||
|
|
|
|||
|
|
@ -334,7 +334,6 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
private fun updateTransactionStatus(txData: TransactionData.Uncompiled) {
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txData.hash.orEmpty(),
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).getOrElse { "" }
|
||||
_uiState.update(NFTSendConfirmSentStateTransformer(txData, txUrl))
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ internal class P2PEthPoolTransactionSender @AssistedInject constructor(
|
|||
ifRight = { broadcastResult ->
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = broadcastResult.hash,
|
||||
networkId = cryptoCurrencyStatus.currency.network.id,
|
||||
currency = cryptoCurrencyStatus.currency,
|
||||
).getOrNull().orEmpty()
|
||||
|
||||
balanceUpdater.updateAfterTransaction()
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ internal class StakeKitTransactionSender @AssistedInject constructor(
|
|||
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = transactionHashes.last(),
|
||||
networkId = cryptoCurrencyStatus.currency.network.id,
|
||||
currency = cryptoCurrencyStatus.currency,
|
||||
).getOrNull().orEmpty()
|
||||
|
||||
balanceUpdater.updateAfterTransaction()
|
||||
|
|
|
|||
|
|
@ -329,7 +329,6 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
onSendSuccess = { txHash, timestamp, data ->
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = primaryCurrencyStatus.currency.network.id,
|
||||
currency = primaryCurrencyStatus.currency,
|
||||
).getOrNull().orEmpty()
|
||||
sendSuccessAnalytics()
|
||||
|
|
|
|||
|
|
@ -975,7 +975,6 @@ internal class SwapModel @Inject constructor(
|
|||
)
|
||||
val url = getExplorerTransactionUrlUseCase(
|
||||
txHash = swapTransactionState.txHash,
|
||||
networkId = fromCurrency.currency.network.id,
|
||||
currency = fromCurrency.currency,
|
||||
).getOrElse {
|
||||
Timber.i("tx hash explore not supported")
|
||||
|
|
|
|||
|
|
@ -831,7 +831,6 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
override fun onTransactionClick(txHash: String) {
|
||||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
|
|
|
|||
|
|
@ -221,7 +221,6 @@ internal class TxHistoryModel @Inject constructor(
|
|||
override fun openTxInExplorer(txHash: String) {
|
||||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = params.currency.network.id,
|
||||
currency = params.currency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
|
|
|
|||
|
|
@ -299,7 +299,6 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
|
||||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = currency.network.id,
|
||||
currency = currency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue