Updated on 2026-08-14
This commit is contained in:
parent
f1085eea2f
commit
68255809a6
3 changed files with 21 additions and 5 deletions
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.data.walletconnect.pair
|
||||
|
||||
import androidx.core.net.toUri
|
||||
import com.tangem.domain.walletconnect.WcPairService
|
||||
import com.tangem.domain.walletconnect.model.WcPairRequest
|
||||
import com.tangem.domain.walletconnect.repository.WcSessionsManager
|
||||
|
|
@ -38,8 +37,19 @@ class DefaultWcPairService @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun existSessionTopic(uri: String) = runCatching {
|
||||
val sessionTopic = uri.toUri().getQueryParameter("sessionTopic") ?: return@runCatching false
|
||||
val deeplinkRegex = Regex(WC_PARAM_REGEX)
|
||||
val matched = deeplinkRegex.findAll(uri)
|
||||
val sessionTopic = matched
|
||||
.firstOrNull { it.value.contains(WC_TOPIC_QUERY_NAME) }
|
||||
?.groupValues
|
||||
?.lastOrNull()
|
||||
?: return@runCatching false
|
||||
val isExistSession = sessionsManager.findSessionByTopic(sessionTopic) != null
|
||||
return@runCatching isExistSession
|
||||
}
|
||||
|
||||
private companion object {
|
||||
const val WC_TOPIC_QUERY_NAME = "sessionTopic"
|
||||
const val WC_PARAM_REGEX = "([a-zA-Z\\d-]+)=([a-zA-Z\\d]+)"
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@ sealed interface WcEthMethod : WcMethod {
|
|||
val account: String,
|
||||
val dataForSign: String,
|
||||
) : WcEthMethod {
|
||||
val humanMsg: String = params.message.orEmpty()
|
||||
val humanMsg: String = params.message?.contents.orEmpty()
|
||||
}
|
||||
|
||||
data class SendTransaction(
|
||||
|
|
|
|||
|
|
@ -6,5 +6,11 @@ import com.squareup.moshi.JsonClass
|
|||
@JsonClass(generateAdapter = true)
|
||||
data class WcEthSignTypedDataParams(
|
||||
@Json(name = "message")
|
||||
val message: String?,
|
||||
)
|
||||
val message: Message?,
|
||||
) {
|
||||
@JsonClass(generateAdapter = true)
|
||||
data class Message(
|
||||
@Json(name = "contents")
|
||||
val contents: String?,
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue