Updated on 2026-08-14
This commit is contained in:
parent
39303971df
commit
910be11531
12 changed files with 38 additions and 29 deletions
|
|
@ -75,28 +75,18 @@ class DefaultTxHistoryRepository(
|
|||
return pager.flow
|
||||
}
|
||||
|
||||
@Deprecated("Replace with getTxExploreUrl [UserWalletId, Network] instead")
|
||||
override fun getTxExploreUrl(txHash: String, networkId: Network.ID): String {
|
||||
override fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return when (val txExploreState = blockchain.getExploreTxUrl(txHash)) {
|
||||
val txExploreState = when (currency) {
|
||||
is CryptoCurrency.Token -> blockchain.getTokenExplorerTxUrl(txHash)
|
||||
else -> blockchain.getExploreTxUrl(txHash)
|
||||
}
|
||||
return when (txExploreState) {
|
||||
is TxExploreState.Url -> txExploreState.url
|
||||
is TxExploreState.Unsupported -> ""
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getTxExploreUrl(userWalletId: UserWalletId, network: Network): String {
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
)
|
||||
val lastTxHash = walletManager?.wallet?.recentTransactions?.last()?.hash.orEmpty()
|
||||
return when (val txExploreState = blockchain.getExploreTxUrl(lastTxHash)) {
|
||||
is TxExploreState.Url -> txExploreState.url
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getFixedSizeTxHistoryItems(
|
||||
userWalletId: UserWalletId,
|
||||
currency: CryptoCurrency,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
plugins {
|
||||
alias(deps.plugins.android.library)
|
||||
alias(deps.plugins.kotlin.android)
|
||||
alias(deps.plugins.kotlin.kapt)
|
||||
alias(deps.plugins.hilt.android)
|
||||
id("configuration")
|
||||
}
|
||||
|
||||
|
|
@ -23,4 +25,8 @@ dependencies {
|
|||
implementation(deps.androidx.paging.runtime)
|
||||
|
||||
api(projects.core.pagination)
|
||||
|
||||
/** DI */
|
||||
implementation(deps.hilt.android)
|
||||
kapt(deps.hilt.kapt)
|
||||
}
|
||||
|
|
@ -22,10 +22,7 @@ interface TxHistoryRepository {
|
|||
refresh: Boolean,
|
||||
): Flow<PagingData<TxInfo>>
|
||||
|
||||
fun getTxExploreUrl(txHash: String, networkId: Network.ID): String
|
||||
|
||||
/** Get transaction url in explorer via last transaction from wallet's recentTransactions list */
|
||||
suspend fun getTxExploreUrl(userWalletId: UserWalletId, network: Network): String
|
||||
fun getTxExploreUrl(txHash: String, networkId: Network.ID, currency: CryptoCurrency): String
|
||||
|
||||
@Throws(TxHistoryListError::class)
|
||||
suspend fun getFixedSizeTxHistoryItems(
|
||||
|
|
|
|||
|
|
@ -3,18 +3,24 @@ package com.tangem.domain.txhistory.usecase
|
|||
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(
|
||||
class GetExplorerTransactionUrlUseCase @Inject constructor(
|
||||
private val repository: TxHistoryRepository,
|
||||
) {
|
||||
operator fun invoke(txHash: String, networkId: Network.ID): Either<TxStatusError, String> {
|
||||
operator fun invoke(
|
||||
txHash: String,
|
||||
networkId: Network.ID,
|
||||
currency: CryptoCurrency,
|
||||
): Either<TxStatusError, String> {
|
||||
return either {
|
||||
catch(
|
||||
block = {
|
||||
repository.getTxExploreUrl(txHash, networkId).ifEmpty {
|
||||
repository.getTxExploreUrl(txHash, networkId, currency).ifEmpty {
|
||||
raise(TxStatusError.EmptyUrlError)
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -460,6 +460,7 @@ internal class SendConfirmModel @Inject constructor(
|
|||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txData.hash.orEmpty(),
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).getOrNull().orEmpty()
|
||||
_uiState.update(SendConfirmSentStateTransformer(txData, txUrl))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,6 +335,7 @@ internal class NFTSendConfirmModel @Inject constructor(
|
|||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txData.hash.orEmpty(),
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).getOrElse { "" }
|
||||
_uiState.update(NFTSendConfirmSentStateTransformer(txData, txUrl))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -253,7 +253,8 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = transactionHashes.last(),
|
||||
networkId = cryptoCurrencyStatus.currency.network.id,
|
||||
).getOrNull() ?: ""
|
||||
currency = cryptoCurrencyStatus.currency,
|
||||
).getOrNull().orEmpty()
|
||||
|
||||
balanceUpdater.updateAfterTransaction()
|
||||
onSendSuccess(txUrl)
|
||||
|
|
|
|||
|
|
@ -288,6 +288,7 @@ internal class SendWithSwapConfirmModel @Inject constructor(
|
|||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = primaryCurrencyStatus.currency.network.id,
|
||||
currency = primaryCurrencyStatus.currency,
|
||||
).getOrNull().orEmpty()
|
||||
sendSuccessAnalytics()
|
||||
uiState.transformerUpdate(
|
||||
|
|
|
|||
|
|
@ -781,6 +781,7 @@ 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")
|
||||
""
|
||||
|
|
|
|||
|
|
@ -830,6 +830,7 @@ internal class TokenDetailsModel @Inject constructor(
|
|||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = cryptoCurrency.network.id,
|
||||
currency = cryptoCurrency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
ifRight = { router.openUrl(url = it) },
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ internal class TxHistoryModel @Inject constructor(
|
|||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = params.currency.network.id,
|
||||
currency = params.currency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
ifRight = { urlOpener.openUrl(url = it) },
|
||||
|
|
|
|||
|
|
@ -322,8 +322,11 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
|
|||
?.currency
|
||||
?: return@launch
|
||||
|
||||
getExplorerTransactionUrlUseCase(txHash = txHash, networkId = currency.network.id)
|
||||
.fold(
|
||||
getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = currency.network.id,
|
||||
currency = currency,
|
||||
).fold(
|
||||
ifLeft = { Timber.e(it.toString()) },
|
||||
ifRight = { router.openUrl(url = it) },
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue