Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-26 10:11:00 +03:00
parent 7c50cc09dc
commit d1189ffda2
12 changed files with 9 additions and 25 deletions

View file

@ -10,7 +10,6 @@ import com.tangem.data.txhistory.repository.paging.TxHistoryPagingSource
import com.tangem.datasource.local.txhistory.TxHistoryItemsStore import com.tangem.datasource.local.txhistory.TxHistoryItemsStore
import com.tangem.datasource.local.userwallet.UserWalletsStore import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.models.currency.CryptoCurrency 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.network.TxInfo
import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.models.wallet.UserWalletId
@ -75,8 +74,8 @@ class DefaultTxHistoryRepository(
return pager.flow return pager.flow
} }
override fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String { override fun getTxExploreUrl(txHash: String, currency: CryptoCurrency): String {
val blockchain = networkId.toBlockchain() val blockchain = currency.network.id.toBlockchain()
val txExploreState = when (currency) { val txExploreState = when (currency) {
is CryptoCurrency.Token -> blockchain.getTokenExplorerTxUrl(txHash) is CryptoCurrency.Token -> blockchain.getTokenExplorerTxUrl(txHash)
else -> blockchain.getExploreTxUrl(txHash) else -> blockchain.getExploreTxUrl(txHash)

View file

@ -2,7 +2,6 @@ package com.tangem.domain.txhistory.repository
import androidx.paging.PagingData import androidx.paging.PagingData
import com.tangem.domain.models.currency.CryptoCurrency 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.network.TxInfo
import com.tangem.domain.txhistory.models.TxHistoryListError import com.tangem.domain.txhistory.models.TxHistoryListError
import com.tangem.domain.txhistory.models.TxHistoryStateError import com.tangem.domain.txhistory.models.TxHistoryStateError
@ -22,7 +21,7 @@ interface TxHistoryRepository {
refresh: Boolean, refresh: Boolean,
): Flow<PagingData<TxInfo>> ): Flow<PagingData<TxInfo>>
fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String fun getTxExploreUrl(txHash: String, currency: CryptoCurrency): String
@Throws(TxHistoryListError::class) @Throws(TxHistoryListError::class)
suspend fun getFixedSizeTxHistoryItems( suspend fun getFixedSizeTxHistoryItems(

View file

@ -4,19 +4,12 @@ import arrow.core.Either
import arrow.core.raise.catch import arrow.core.raise.catch
import arrow.core.raise.either import arrow.core.raise.either
import com.tangem.domain.models.currency.CryptoCurrency 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.models.TxStatusError
import com.tangem.domain.txhistory.repository.TxHistoryRepository import com.tangem.domain.txhistory.repository.TxHistoryRepository
import javax.inject.Inject
class GetExplorerTransactionUrlUseCase @Inject constructor( class GetExplorerTransactionUrlUseCase(private val repository: TxHistoryRepository) {
private val repository: TxHistoryRepository,
) { operator fun invoke(txHash: String, currency: CryptoCurrency): Either<TxStatusError, String> {
operator fun invoke(
txHash: String,
networkId: Network.ID,
currency: CryptoCurrency,
): Either<TxStatusError, String> {
return either { return either {
catch( catch(
block = { block = {
@ -24,7 +17,7 @@ class GetExplorerTransactionUrlUseCase @Inject constructor(
raise(TxStatusError.EmptyUrlError) raise(TxStatusError.EmptyUrlError)
} }
repository.getTxExploreUrl(txHash, networkId, currency).ifEmpty { repository.getTxExploreUrl(txHash, currency).ifEmpty {
raise(TxStatusError.EmptyUrlError) raise(TxStatusError.EmptyUrlError)
} }
}, },

View file

@ -482,7 +482,6 @@ internal class SendConfirmModel @Inject constructor(
private fun updateTransactionStatus(txData: TransactionData.Uncompiled, txHash: String) { private fun updateTransactionStatus(txData: TransactionData.Uncompiled, txHash: String) {
val txUrl = getExplorerTransactionUrlUseCase( val txUrl = getExplorerTransactionUrlUseCase(
txHash = txHash.ifEmpty { txData.hash.orEmpty() }, txHash = txHash.ifEmpty { txData.hash.orEmpty() },
networkId = cryptoCurrency.network.id,
currency = cryptoCurrency, currency = cryptoCurrency,
).getOrNull().orEmpty() ).getOrNull().orEmpty()
_uiState.update(SendConfirmSentStateTransformer(txData, txUrl)) _uiState.update(SendConfirmSentStateTransformer(txData, txUrl))

View file

@ -334,7 +334,6 @@ internal class NFTSendConfirmModel @Inject constructor(
private fun updateTransactionStatus(txData: TransactionData.Uncompiled) { private fun updateTransactionStatus(txData: TransactionData.Uncompiled) {
val txUrl = getExplorerTransactionUrlUseCase( val txUrl = getExplorerTransactionUrlUseCase(
txHash = txData.hash.orEmpty(), txHash = txData.hash.orEmpty(),
networkId = cryptoCurrency.network.id,
currency = cryptoCurrency, currency = cryptoCurrency,
).getOrElse { "" } ).getOrElse { "" }
_uiState.update(NFTSendConfirmSentStateTransformer(txData, txUrl)) _uiState.update(NFTSendConfirmSentStateTransformer(txData, txUrl))

View file

@ -76,7 +76,7 @@ internal class P2PEthPoolTransactionSender @AssistedInject constructor(
ifRight = { broadcastResult -> ifRight = { broadcastResult ->
val txUrl = getExplorerTransactionUrlUseCase( val txUrl = getExplorerTransactionUrlUseCase(
txHash = broadcastResult.hash, txHash = broadcastResult.hash,
networkId = cryptoCurrencyStatus.currency.network.id, currency = cryptoCurrencyStatus.currency,
).getOrNull().orEmpty() ).getOrNull().orEmpty()
balanceUpdater.updateAfterTransaction() balanceUpdater.updateAfterTransaction()

View file

@ -261,7 +261,7 @@ internal class StakeKitTransactionSender @AssistedInject constructor(
val txUrl = getExplorerTransactionUrlUseCase( val txUrl = getExplorerTransactionUrlUseCase(
txHash = transactionHashes.last(), txHash = transactionHashes.last(),
networkId = cryptoCurrencyStatus.currency.network.id, currency = cryptoCurrencyStatus.currency,
).getOrNull().orEmpty() ).getOrNull().orEmpty()
balanceUpdater.updateAfterTransaction() balanceUpdater.updateAfterTransaction()

View file

@ -329,7 +329,6 @@ internal class SendWithSwapConfirmModel @Inject constructor(
onSendSuccess = { txHash, timestamp, data -> onSendSuccess = { txHash, timestamp, data ->
val txUrl = getExplorerTransactionUrlUseCase( val txUrl = getExplorerTransactionUrlUseCase(
txHash = txHash, txHash = txHash,
networkId = primaryCurrencyStatus.currency.network.id,
currency = primaryCurrencyStatus.currency, currency = primaryCurrencyStatus.currency,
).getOrNull().orEmpty() ).getOrNull().orEmpty()
sendSuccessAnalytics() sendSuccessAnalytics()

View file

@ -975,7 +975,6 @@ internal class SwapModel @Inject constructor(
) )
val url = getExplorerTransactionUrlUseCase( val url = getExplorerTransactionUrlUseCase(
txHash = swapTransactionState.txHash, txHash = swapTransactionState.txHash,
networkId = fromCurrency.currency.network.id,
currency = fromCurrency.currency, currency = fromCurrency.currency,
).getOrElse { ).getOrElse {
Timber.i("tx hash explore not supported") Timber.i("tx hash explore not supported")

View file

@ -831,7 +831,6 @@ internal class TokenDetailsModel @Inject constructor(
override fun onTransactionClick(txHash: String) { override fun onTransactionClick(txHash: String) {
getExplorerTransactionUrlUseCase( getExplorerTransactionUrlUseCase(
txHash = txHash, txHash = txHash,
networkId = cryptoCurrency.network.id,
currency = cryptoCurrency, currency = cryptoCurrency,
).fold( ).fold(
ifLeft = { Timber.e(it.toString()) }, ifLeft = { Timber.e(it.toString()) },

View file

@ -221,7 +221,6 @@ internal class TxHistoryModel @Inject constructor(
override fun openTxInExplorer(txHash: String) { override fun openTxInExplorer(txHash: String) {
getExplorerTransactionUrlUseCase( getExplorerTransactionUrlUseCase(
txHash = txHash, txHash = txHash,
networkId = params.currency.network.id,
currency = params.currency, currency = params.currency,
).fold( ).fold(
ifLeft = { Timber.e(it.toString()) }, ifLeft = { Timber.e(it.toString()) },

View file

@ -299,7 +299,6 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
getExplorerTransactionUrlUseCase( getExplorerTransactionUrlUseCase(
txHash = txHash, txHash = txHash,
networkId = currency.network.id,
currency = currency, currency = currency,
).fold( ).fold(
ifLeft = { Timber.e(it.toString()) }, ifLeft = { Timber.e(it.toString()) },