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