Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-02 16:22:47 +07:00
parent c039057700
commit 47ba4043a3
10 changed files with 30 additions and 16 deletions

View file

@ -43,6 +43,7 @@ internal object WalletConnectInteractorModule {
currenciesRepository: CurrenciesRepository,
walletManagersFacade: WalletManagersFacade,
userWalletsListManager: UserWalletsListManager,
walletConnectFeatureToggles: WalletConnectFeatureToggles,
coroutineDispatcherProvider: CoroutineDispatcherProvider,
): WalletConnectInteractor {
return WalletConnectInteractor(
@ -55,6 +56,7 @@ internal object WalletConnectInteractorModule {
walletManagersFacade = walletManagersFacade,
userWalletsListManager = userWalletsListManager,
dispatchers = coroutineDispatcherProvider,
walletConnectFeatureToggles = walletConnectFeatureToggles,
)
}
}

View file

@ -16,6 +16,7 @@ import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.domain.wallets.models.isMultiCurrency
import com.tangem.domain.wallets.models.requireColdWallet
import com.tangem.domain.wallets.usecase.GetSelectedWalletUseCase
import com.tangem.features.walletconnect.components.WalletConnectFeatureToggles
import com.tangem.tap.common.extensions.dispatchOnMain
import com.tangem.tap.common.extensions.filterNotNull
import com.tangem.tap.domain.walletconnect.WalletConnectSdkHelper
@ -39,8 +40,10 @@ class WalletConnectInteractor(
private val walletManagersFacade: WalletManagersFacade,
private val currenciesRepository: CurrenciesRepository,
private val userWalletsListManager: UserWalletsListManager,
private val walletConnectFeatureToggles: WalletConnectFeatureToggles,
val blockchainHelper: WcBlockchainHelper,
) {
private val isNewWc by lazy { walletConnectFeatureToggles.isRedesignedWalletConnectEnabled }
private var isWalletConnectReadyForDeepLinks = false
@ -88,6 +91,7 @@ class WalletConnectInteractor(
}
private fun initWithWallet(userWallet: UserWallet) {
if (isNewWc) return
if (userWallet.isMultiCurrency) {
Timber.i("WalletConnect: initialize and setup networks for ${userWallet.walletId}")
startListeningWc(userWallet.walletId.stringValue, getCardId(userWallet))
@ -243,6 +247,7 @@ class WalletConnectInteractor(
}
fun approveSessionProposal(accounts: List<Account>) {
if (isNewWc) return
Timber.i("Approve session proposal: $accounts")
val userNamespaces: Map<NetworkNamespace, List<Account>> = accounts
.groupBy { account ->
@ -259,16 +264,19 @@ class WalletConnectInteractor(
}
fun rejectSessionProposal() {
if (isNewWc) return
Timber.i("Reject session proposal")
walletConnectRepository.reject()
}
fun disconnectSession(topic: String) {
if (isNewWc) return
Timber.i("Disconnect session: $topic")
walletConnectRepository.disconnect(topic)
}
fun cancelRequest(topic: String, id: Long) {
if (isNewWc) return
Timber.i("Cancel request: $topic, $id")
walletConnectRepository.cancelRequest(topic, id)
}
@ -323,6 +331,7 @@ class WalletConnectInteractor(
}
suspend fun continueWithRequest(request: WcPreparedRequest) {
if (isNewWc) return
val currentRequest = this.currentRequest
if (currentRequest == null || request.topic != currentRequest.topic) return
@ -386,6 +395,7 @@ class WalletConnectInteractor(
* @param deeplink deeplink to handle
*/
fun addDeeplink(deeplink: String) {
if (isNewWc) return
val deeplinkRegex = Regex(WC_PARAM_REGEX)
val matched = deeplinkRegex.findAll(deeplink)
val sessionTopic = matched.firstOrNull { it.value.contains(WC_TOPIC_QUERY_NAME) }?.groupValues?.lastOrNull()

View file

@ -108,6 +108,7 @@ internal class DeepLinkFactory @Inject constructor(
}
}
@Suppress("CyclomaticComplexMethod")
private fun handleTangemDeepLinks(deeplinkUri: Uri, coroutineScope: CoroutineScope, isFromOnNewIntent: Boolean) {
val queryParams = getQueryParams(deeplinkUri)
when (deeplinkUri.host) {
@ -127,6 +128,7 @@ internal class DeepLinkFactory @Inject constructor(
DeepLinkRoute.Buy.host -> buyDeepLink.create()
DeepLinkRoute.Sell.host -> sellDeepLink.create()
DeepLinkRoute.Swap.host -> swapDeepLink.create()
DeepLinkRoute.WalletConnect.host -> walletConnectDeepLink.create(deeplinkUri)
else -> {
Timber.i(
"""