From 299b55b54096a49a6844d124a5c72497343002e9 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 18 Mar 2024 19:19:58 +0000 Subject: [PATCH 1/2] Updated on 2026-08-14 --- .../tangem/tap/common/CustomTabsManager.kt | 1 + .../domain/txhistory/models/TxStatusError.kt | 7 ++++++ .../GetExplorerTransactionUrlUseCase.kt | 17 ++++++++++++-- .../presentation/state/SendStateFactory.kt | 2 +- .../viewmodels/TokenDetailsViewModel.kt | 22 ++++++------------- .../intents/WalletContentClickIntents.kt | 8 ++++--- 6 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 domain/txhistory/models/src/main/kotlin/com/tangem/domain/txhistory/models/TxStatusError.kt diff --git a/app/src/main/java/com/tangem/tap/common/CustomTabsManager.kt b/app/src/main/java/com/tangem/tap/common/CustomTabsManager.kt index 08f62eee72..c56c238e57 100644 --- a/app/src/main/java/com/tangem/tap/common/CustomTabsManager.kt +++ b/app/src/main/java/com/tangem/tap/common/CustomTabsManager.kt @@ -14,6 +14,7 @@ import com.tangem.wallet.R class CustomTabsManager { fun openUrl(url: String, context: Context) { + if (url.isEmpty()) return val customTabsIntent = CustomTabsIntent.Builder() .setDefaultColorSchemeParams( CustomTabColorSchemeParams.Builder() diff --git a/domain/txhistory/models/src/main/kotlin/com/tangem/domain/txhistory/models/TxStatusError.kt b/domain/txhistory/models/src/main/kotlin/com/tangem/domain/txhistory/models/TxStatusError.kt new file mode 100644 index 0000000000..51a367f46f --- /dev/null +++ b/domain/txhistory/models/src/main/kotlin/com/tangem/domain/txhistory/models/TxStatusError.kt @@ -0,0 +1,7 @@ +package com.tangem.domain.txhistory.models + +sealed class TxStatusError { + + data object EmptyUrlError : TxStatusError() + data class DataError(val cause: Throwable) : TxStatusError() +} \ No newline at end of file diff --git a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetExplorerTransactionUrlUseCase.kt b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetExplorerTransactionUrlUseCase.kt index d5628aa838..974d439c7e 100644 --- a/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetExplorerTransactionUrlUseCase.kt +++ b/domain/txhistory/src/main/kotlin/com/tangem/domain/txhistory/usecase/GetExplorerTransactionUrlUseCase.kt @@ -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 { + return either { + catch( + block = { + repository.getTxExploreUrl(txHash, networkId).ifEmpty { + raise(TxStatusError.EmptyUrlError) + } + }, + catch = { raise(TxStatusError.DataError(it)) }, + ) + } } } \ No newline at end of file diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/SendStateFactory.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/SendStateFactory.kt index 619ec36aab..cbd7ea840b 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/SendStateFactory.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/SendStateFactory.kt @@ -233,7 +233,7 @@ internal class SendStateFactory( val txUrl = getExplorerTransactionUrlUseCase( txHash = txData.hash.orEmpty(), networkId = cryptoCurrency.network.id, - ) + ).getOrElse { "" } return state.copy( sendState = state.sendState.copy( transactionDate = txData.date?.timeInMillis ?: System.currentTimeMillis(), diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index fbdbcf8273..c5d482b009 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -6,7 +6,6 @@ import androidx.compose.runtime.setValue import androidx.lifecycle.* import androidx.paging.cachedIn import arrow.core.getOrElse -import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.address.AddressType import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.core.deeplink.DeepLinksRegistry @@ -600,20 +599,13 @@ internal class TokenDetailsViewModel @Inject constructor( } override fun onTransactionClick(txHash: String) { - // TODO: Fix tx urls [REDACTED_TASK_KEY] - when (Blockchain.fromId(cryptoCurrency.network.id.value)) { - Blockchain.TON, Blockchain.TONTestnet, - Blockchain.Decimal, Blockchain.DecimalTestnet, - -> return - else -> { - router.openUrl( - url = getExplorerTransactionUrlUseCase( - txHash = txHash, - networkId = cryptoCurrency.network.id, - ), - ) - } - } + getExplorerTransactionUrlUseCase( + txHash = txHash, + networkId = cryptoCurrency.network.id, + ).fold( + ifLeft = { Timber.e(it.toString()) }, + ifRight = { router.openUrl(url = it) }, + ) } override fun onRefreshSwipe() { diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletContentClickIntents.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletContentClickIntents.kt index a91eec17a0..cae3373a31 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletContentClickIntents.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/viewmodels/intents/WalletContentClickIntents.kt @@ -146,9 +146,11 @@ internal class WalletContentClickIntentsImplementor @Inject constructor( ?.currency ?: return@launch - router.openUrl( - url = getExplorerTransactionUrlUseCase(txHash = txHash, networkId = currency.network.id), - ) + getExplorerTransactionUrlUseCase(txHash = txHash, networkId = currency.network.id) + .fold( + ifLeft = { Timber.e(it.toString()) }, + ifRight = { router.openUrl(url = it) }, + ) } } } \ No newline at end of file From 01338ceb4d7a2d565c47cd724e67928a409ec645 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 18 Mar 2024 19:26:16 +0000 Subject: [PATCH 2/2] Updated on 2026-08-14 --- gradle/dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index 22742d3d83..b92767f469 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -85,7 +85,7 @@ web3j = "4.10.1" # endregion Other libraries # region Tangem -tangemBlockchainSdk = "release-app_5.8-535" +tangemBlockchainSdk = "release-app_5.8-536" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds tangemCardSdk = "release-app_5.8-336" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^