Updated on 2026-08-14
This commit is contained in:
parent
65ace6c5f2
commit
99a5efd7e2
8 changed files with 43 additions and 20 deletions
|
|
@ -1515,6 +1515,8 @@
|
|||
<string name="wc_alert_domain_issues_description">This domain cannot be verified. Check the request carefully approving.</string>
|
||||
<string name="wc_alert_network_not_connected_description">To continue, please reconnect your dApp session with the required network %s.</string>
|
||||
<string name="wc_alert_network_not_connected_title">Network not connected</string>
|
||||
<string name="wc_alert_request_timeout_description">Check your network connection</string>
|
||||
<string name="wc_alert_request_timeout_title">Request timeout</string>
|
||||
<string name="wc_alert_session_disconnected_description">Please return to your browser and reconnect via WalletConnect.</string>
|
||||
<string name="wc_alert_session_disconnected_title">Wallet Connect session was disconnected</string>
|
||||
<string name="wc_alert_sign_anyway">Sign anyway</string>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue