Updated on 2026-08-14
This commit is contained in:
parent
ecca7b1f6b
commit
69443deb2a
6 changed files with 49 additions and 23 deletions
|
|
@ -135,6 +135,7 @@ class DefaultWalletManagersFacade(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
addressType: AddressType,
|
||||
contractAddress: String?,
|
||||
): String {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
|
||||
|
|
@ -148,8 +149,12 @@ class DefaultWalletManagersFacade(
|
|||
"Unable to get a wallet manager for blockchain: $blockchain"
|
||||
}
|
||||
|
||||
val address = walletManager.wallet.addresses.find { it.type == addressType }?.value
|
||||
return walletManager.wallet.getExploreUrl(address)
|
||||
val address = walletManager
|
||||
.wallet
|
||||
.addresses
|
||||
.find { it.type == addressType }
|
||||
?.value ?: walletManager.wallet.address
|
||||
return blockchain.getExploreUrl(address, contractAddress)
|
||||
}
|
||||
|
||||
override suspend fun getTxHistoryState(userWalletId: UserWalletId, network: Network): TxHistoryState {
|
||||
|
|
|
|||
|
|
@ -62,10 +62,16 @@ interface WalletManagersFacade {
|
|||
* @param userWalletId The ID of the user's wallet.
|
||||
* @param network The network.
|
||||
* @param addressType Address type.
|
||||
* @param contractAddress Contract address if currency is Token.
|
||||
*
|
||||
* @return The network explorer URL, maybe empty if the wallet manager was not found.
|
||||
* */
|
||||
suspend fun getExploreUrl(userWalletId: UserWalletId, network: Network, addressType: AddressType): String
|
||||
suspend fun getExploreUrl(
|
||||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
addressType: AddressType,
|
||||
contractAddress: String?,
|
||||
): String
|
||||
|
||||
/**
|
||||
* Returns transactions count
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package com.tangem.domain.wallets.usecase
|
||||
|
||||
import arrow.core.raise.catch
|
||||
import com.tangem.domain.tokens.model.Network
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
||||
|
|
@ -12,11 +12,19 @@ class GetExploreUrlUseCase(private val walletsManagersFacade: WalletManagersFaca
|
|||
// FIXME: Handle error
|
||||
suspend operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
currency: CryptoCurrency,
|
||||
addressType: AddressType = AddressType.Default,
|
||||
): String {
|
||||
return catch({ walletsManagersFacade.getExploreUrl(userWalletId, network, addressType) }) {
|
||||
""
|
||||
}
|
||||
return catch(
|
||||
block = {
|
||||
walletsManagersFacade.getExploreUrl(
|
||||
userWalletId = userWalletId,
|
||||
network = currency.network,
|
||||
addressType = addressType,
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
},
|
||||
catch = { "" }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ 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.common.Provider
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
|
|
@ -397,7 +398,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
router.openUrl(
|
||||
url = getExploreUrlUseCase(
|
||||
userWalletId = userWalletId,
|
||||
network = cryptoCurrency.network,
|
||||
currency = cryptoCurrency,
|
||||
addressType = AddressType.Default,
|
||||
),
|
||||
)
|
||||
|
|
@ -429,7 +430,7 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
router.openUrl(
|
||||
url = getExploreUrlUseCase(
|
||||
userWalletId = userWalletId,
|
||||
network = cryptoCurrency.network,
|
||||
currency = cryptoCurrency,
|
||||
addressType = AddressType.valueOf(addressModel.type.name),
|
||||
),
|
||||
)
|
||||
|
|
@ -438,12 +439,18 @@ internal class TokenDetailsViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onTransactionClick(txHash: String) {
|
||||
router.openUrl(
|
||||
url = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = cryptoCurrency.network.id,
|
||||
),
|
||||
)
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.id.value)
|
||||
// TODO: Fix ton tx urls [REDACTED_TASK_KEY]
|
||||
if (blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet) {
|
||||
return
|
||||
} else {
|
||||
router.openUrl(
|
||||
url = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = cryptoCurrency.network.id,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRefreshSwipe() {
|
||||
|
|
|
|||
|
|
@ -819,18 +819,18 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
private fun openExplorer() {
|
||||
val state = uiState as? WalletState.ContentState ?: return
|
||||
val currencyNetwork = singleWalletCryptoCurrencyStatus?.currency?.network ?: return
|
||||
val currency = singleWalletCryptoCurrencyStatus?.currency ?: return
|
||||
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
val userWalletId = getWallet(state.walletsListConfig.selectedWalletIndex).walletId
|
||||
|
||||
val addresses = walletManagersFacade.getAddress(userWalletId = userWalletId, network = currencyNetwork)
|
||||
val addresses = walletManagersFacade.getAddress(userWalletId = userWalletId, network = currency.network)
|
||||
|
||||
if (addresses.size == 1) {
|
||||
router.openUrl(
|
||||
url = getExploreUrlUseCase(
|
||||
userWalletId = userWalletId,
|
||||
network = currencyNetwork,
|
||||
currency = currency,
|
||||
addressType = AddressType.Default,
|
||||
),
|
||||
)
|
||||
|
|
@ -848,7 +848,7 @@ internal class WalletViewModel @Inject constructor(
|
|||
onClick = {
|
||||
onAddressTypeSelected(
|
||||
userWalletId = userWalletId,
|
||||
currencyNetwork = currencyNetwork,
|
||||
currency = currency,
|
||||
addressModel = it,
|
||||
)
|
||||
},
|
||||
|
|
@ -860,14 +860,14 @@ internal class WalletViewModel @Inject constructor(
|
|||
|
||||
private fun onAddressTypeSelected(
|
||||
userWalletId: UserWalletId,
|
||||
currencyNetwork: Network,
|
||||
currency: CryptoCurrency,
|
||||
addressModel: AddressModel,
|
||||
) {
|
||||
viewModelScope.launch(dispatchers.main) {
|
||||
router.openUrl(
|
||||
url = getExploreUrlUseCase(
|
||||
userWalletId = userWalletId,
|
||||
network = currencyNetwork,
|
||||
currency = currency,
|
||||
addressType = AddressType.valueOf(addressModel.type.name),
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ spr-client = "3.6.2"
|
|||
# endregion Other libraries
|
||||
|
||||
# region Tangem
|
||||
tangemBlockchainSdk = "release-app_5.0-365"
|
||||
tangemBlockchainSdk = "release-app_5.0-368"
|
||||
#tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds
|
||||
tangemCardSdk = "release-app_5.0-308"
|
||||
#tangemCardSdk = "0.0.1" # Keep it! - used for local builds
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue