Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-09 13:32:34 +04:00
parent 535bb9b8c3
commit e225af5b30
15 changed files with 343 additions and 69 deletions

View file

@ -37,14 +37,16 @@ internal class AssociateNetworksDelegate(
// remove duplicates
.subtract(requiredNamespaces)
return userWallets
.associateWith { wallet -> mapNetworksForWallet(wallet, requiredNamespaces, optionalNamespaces) }
return userWallets.associateWith { wallet ->
mapNetworksForWallet(wallet, requiredNamespaces, optionalNamespaces, sessionProposal)
}
}
private suspend fun mapNetworksForWallet(
wallet: UserWallet,
requiredNamespaces: Set<String>,
optionalNamespaces: Set<String>,
sessionProposal: Wallet.Model.SessionProposal,
): ProposalNetwork {
val walletNetworks = getWalletNetworks(wallet)
@ -78,7 +80,9 @@ internal class AssociateNetworksDelegate(
notAdded.add(wcNetwork)
}
}
if (unknownRequired.isNotEmpty()) throw WcPairError.UnsupportedBlockchains(unknownRequired)
if (unknownRequired.isNotEmpty()) {
throw WcPairError.UnsupportedBlockchains(unknownRequired, sessionProposal.name)
}
return ProposalNetwork(
wallet = wallet,
missingRequired = missingRequired,

View file

@ -24,8 +24,6 @@ import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.*
import timber.log.Timber
val unsupportedDApps = listOf("dYdX", "dYdX v4", "Apex Pro", "The Sandbox")
@Suppress("LongParameterList")
internal class DefaultWcPairUseCase @AssistedInject constructor(
private val sessionsManager: WcSessionsManager,
@ -54,9 +52,9 @@ internal class DefaultWcPairUseCase @AssistedInject constructor(
.getOrNull() ?: return@flow
// check unsupported dApps, just local constant for now, finish if unsupported
if (sdkSessionProposal.name in unsupportedDApps) {
if (UnsupportedDApps.list.any { sdkSessionProposal.url.contains(it, ignoreCase = true) }) {
Timber.tag(WC_TAG).i("Unsupported DApp ${sdkSessionProposal.name}")
val error = WcPairState.Error(WcPairError.UnsupportedDApp)
val error = WcPairState.Error(WcPairError.UnsupportedDApp(sdkSessionProposal.name))
emit(error)
return@flow
}

View file

@ -0,0 +1,16 @@
package com.tangem.data.walletconnect.pair
/**
* These dApps are not supported by WC due to various issues with signing formats
* @see <a href = "https://www.notion.so/tangem/WalletConnect-1935d34eb678805fb9aff2e046dc1dfa?source=copy_link#1a15d34eb6788073925ce9c2b9fd12a5">Documentation<a/>
*/
object UnsupportedDApps {
val list = listOf(
"dydx.trade",
"dydx.exchange",
"pro.apex.exchange",
"services.dfx.swiss",
"sandbox.game",
"app.paradex.trade",
)
}

View file

@ -58,8 +58,8 @@ internal class DefaultWcPairUseCaseTest {
relayData = "",
)
private val unsupportedDApp = "Apex Pro"
private val unsupportedSdkProposal get() = sdkProposal.copy(name = unsupportedDApp)
private val unsupportedDAppUrl = "dydx.trade"
private val unsupportedSdkProposal get() = sdkProposal.copy(url = unsupportedDAppUrl)
private val sessionForApprove: WcSessionApprove
get() = WcSessionApprove(
@ -196,7 +196,7 @@ internal class DefaultWcPairUseCaseTest {
@Test
fun `success pair and reject unsupported dApp`() = runTest {
coEvery { sdkDelegate.pair(url) } returns unsupportedSdkProposal.right()
val unsupportedDAppError = WcPairState.Error(WcPairError.UnsupportedDApp)
val unsupportedDAppError = WcPairState.Error(WcPairError.UnsupportedDApp(unsupportedSdkProposal.name))
val useCase = useCaseFactory()
useCase.invoke().test {