Updated on 2026-08-14

This commit is contained in:
Tangem 2024-03-18 19:43:58 +00:00
commit 83584a499c
7 changed files with 37 additions and 22 deletions

View file

@ -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()

View file

@ -0,0 +1,7 @@
package com.tangem.domain.txhistory.models
sealed class TxStatusError {
data object EmptyUrlError : TxStatusError()
data class DataError(val cause: Throwable) : TxStatusError()
}

View file

@ -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<TxStatusError, String> {
return either {
catch(
block = {
repository.getTxExploreUrl(txHash, networkId).ifEmpty {
raise(TxStatusError.EmptyUrlError)
}
},
catch = { raise(TxStatusError.DataError(it)) },
)
}
}
}

View file

@ -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(),

View file

@ -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() {

View file

@ -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) },
)
}
}
}

View file

@ -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 ^