diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index ec20bf2c8f..f9238788d1 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -1515,6 +1515,8 @@
This domain cannot be verified. Check the request carefully approving.
To continue, please reconnect your dApp session with the required network %s.
Network not connected
+ Check your network connection
+ Request timeout
Please return to your browser and reconnect via WalletConnect.
Wallet Connect session was disconnected
Sign anyway
diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt
index 0e78ed19ce..ad67584bed 100644
--- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt
+++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/DefaultWcPairUseCase.kt
@@ -20,6 +20,7 @@ import com.tangem.domain.walletconnect.usecase.pair.WcPairUseCase
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
+import kotlinx.coroutines.TimeoutCancellationException
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.flow.*
import org.joda.time.DateTime
@@ -119,14 +120,21 @@ internal class DefaultWcPairUseCase @AssistedInject constructor(
Timber.tag(WC_TAG).e(it, "Failed to approve session ${sdkSessionProposal.name}")
}
emit(WcPairState.Approving.Result(sessionForApprove, either))
- }.onCompletion {
- if (it != null) {
- Timber.tag(WC_TAG).e(it, "Completed with error $pairRequest")
- emit(WcPairState.Error(WcPairError.Unknown(it.message.orEmpty())))
- } else {
- Timber.tag(WC_TAG).i("Completed successfully $pairRequest")
- }
}
+ .catch {
+ val pairError: WcPairError = when (it) {
+ is TimeoutCancellationException -> WcPairError.TimeoutException(it.message.orEmpty())
+ else -> WcPairError.Unknown(it.message.orEmpty())
+ }
+ emit(WcPairState.Error(pairError))
+ }
+ .onCompletion {
+ if (it != null) {
+ Timber.tag(WC_TAG).e(it, "Completed with error $pairRequest")
+ } else {
+ Timber.tag(WC_TAG).i("Completed successfully $pairRequest")
+ }
+ }
}
override fun approve(sessionForApprove: WcSessionApprove) {
diff --git a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/WcPairSdkDelegate.kt b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/WcPairSdkDelegate.kt
index e9665c0673..35902fb41f 100644
--- a/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/WcPairSdkDelegate.kt
+++ b/data/wallet-connect/src/main/kotlin/com/tangem/data/walletconnect/pair/WcPairSdkDelegate.kt
@@ -150,7 +150,7 @@ internal class WcPairSdkDelegate : WcSdkObserver {
private fun Throwable.toApproveError() = WcPairError.ApprovalFailed(this.localizedMessage.orEmpty()).left()
companion object {
- private const val CALLBACK_TIMEOUT = 60
+ private const val CALLBACK_TIMEOUT = 15
// com.reown.android.pairing.engine.domain.PairingEngine.pair
private val pairingExpiredMessages = listOf(
"Pairing URI expired",
diff --git a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcPairError.kt b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcPairError.kt
index f04de6251a..2ac1b68531 100644
--- a/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcPairError.kt
+++ b/domain/wallet-connect/models/src/main/java/com/tangem/domain/walletconnect/model/WcPairError.kt
@@ -16,4 +16,5 @@ sealed class WcPairError(
data class ApprovalFailed(override val message: String) : WcPairError("107 002 003")
data object RejectionFailed : WcPairError("107 002 004")
data class Unknown(override val message: String) : WcPairError(message)
+ data class TimeoutException(override val message: String) : WcPairError(message)
}
\ No newline at end of file
diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/components/WcPairComponent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/components/WcPairComponent.kt
index b41e493f67..afa23ea711 100644
--- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/components/WcPairComponent.kt
+++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/components/WcPairComponent.kt
@@ -121,6 +121,7 @@ internal class WcPairComponent(
is Alert.Type.UnsupportedNetwork ->
WcAlertsFactory.createUnsupportedChainAlert(alertType.appName, model::errorAlertOnDismiss)
is Alert.Type.UriAlreadyUsed -> WcAlertsFactory.createUriAlreadyUsedAlert(model::errorAlertOnDismiss)
+ is Alert.Type.TimeoutException -> WcAlertsFactory.createTimeoutExceptionAlert(model::errorAlertOnDismiss)
}
}
diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt
index 7c566be7c6..fe64931b39 100644
--- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt
+++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcPairModel.kt
@@ -216,18 +216,11 @@ internal class WcPairModel @Inject constructor(
private fun processError(error: WcPairError) {
val alert = when (error) {
- is WcPairError.InvalidDomainURL -> {
- WcAppInfoRoutes.Alert.Type.InvalidDomain
- }
- is WcPairError.UnsupportedDApp -> {
- WcAppInfoRoutes.Alert.Type.UnsupportedDApp(error.appName)
- }
- is WcPairError.UnsupportedBlockchains -> {
- WcAppInfoRoutes.Alert.Type.UnsupportedNetwork(error.appName)
- }
- is WcPairError.UriAlreadyUsed -> {
- WcAppInfoRoutes.Alert.Type.UriAlreadyUsed
- }
+ is WcPairError.InvalidDomainURL -> WcAppInfoRoutes.Alert.Type.InvalidDomain
+ is WcPairError.UnsupportedDApp -> WcAppInfoRoutes.Alert.Type.UnsupportedDApp(error.appName)
+ is WcPairError.UnsupportedBlockchains -> WcAppInfoRoutes.Alert.Type.UnsupportedNetwork(error.appName)
+ is WcPairError.UriAlreadyUsed -> WcAppInfoRoutes.Alert.Type.UriAlreadyUsed
+ is WcPairError.TimeoutException -> WcAppInfoRoutes.Alert.Type.TimeoutException
else -> {
messageSender.send(ToastMessage(message = stringReference(error.message)))
router.pop()
diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/routes/WcAppInfoRoutes.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/routes/WcAppInfoRoutes.kt
index 226ececbbc..784e0457ed 100644
--- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/routes/WcAppInfoRoutes.kt
+++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/routes/WcAppInfoRoutes.kt
@@ -36,6 +36,7 @@ internal sealed class WcAppInfoRoutes : TangemBottomSheetConfigContent, Route {
data class UnsupportedDApp(val appName: String) : Type()
data class UnsupportedNetwork(val appName: String) : Type()
data object UriAlreadyUsed : Type()
+ data object TimeoutException : Type()
}
}
}
\ No newline at end of file
diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/utils/WcAlertsFactory.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/utils/WcAlertsFactory.kt
index a17284a34d..5ac9d638e6 100644
--- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/utils/WcAlertsFactory.kt
+++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/utils/WcAlertsFactory.kt
@@ -127,6 +127,23 @@ internal object WcAlertsFactory {
}
}
+ fun createTimeoutExceptionAlert(onDismiss: () -> Unit): MessageBottomSheetUMV2 {
+ return messageBottomSheetUM {
+ infoBlock {
+ icon(R.drawable.ic_wallet_connect_24) {
+ type = Type.Informative
+ backgroundType = MessageBottomSheetUMV2.Icon.BackgroundType.SameAsTint
+ }
+ title = resourceReference(R.string.wc_alert_request_timeout_title)
+ body = resourceReference(R.string.wc_alert_request_timeout_description)
+ }
+ primaryButton {
+ text = resourceReference(R.string.common_got_it)
+ onClick { onDismiss() }
+ }
+ }
+ }
+
fun createUnsupportedChainAlert(appName: String, onDismiss: () -> Unit): MessageBottomSheetUMV2 {
return messageBottomSheetUM {
infoBlock {