Updated on 2026-08-14
This commit is contained in:
parent
808040cf0c
commit
bede92a2dc
5 changed files with 45 additions and 24 deletions
|
|
@ -64,25 +64,16 @@ internal class WcSignUseCaseDelegate<MiddleAction, SignModel>(
|
|||
}
|
||||
.onEach { state ->
|
||||
val step = state.domainStep as? WcSignStep.Result ?: return@onEach
|
||||
val event = step.result.fold(
|
||||
ifLeft = { error ->
|
||||
val errorMessage = error.message() ?: ""
|
||||
WcAnalyticEvents.SignatureRequestFailed(
|
||||
rawRequest = context.rawSdkRequest,
|
||||
network = context.network,
|
||||
errorCode = error.code() ?: error::class.simpleName.orEmpty(),
|
||||
errorMessage = errorMessage,
|
||||
)
|
||||
},
|
||||
ifRight = {
|
||||
WcAnalyticEvents.SignatureRequestHandled(
|
||||
rawRequest = context.rawSdkRequest,
|
||||
network = context.network,
|
||||
securityStatus = context.session.securityStatus,
|
||||
)
|
||||
},
|
||||
)
|
||||
analytics.send(event)
|
||||
step.result.leftOrNull()?.let { error ->
|
||||
val errorMessage = error.message() ?: ""
|
||||
val event = WcAnalyticEvents.SignatureRequestFailed(
|
||||
rawRequest = context.rawSdkRequest,
|
||||
network = context.network,
|
||||
errorCode = error.code() ?: error::class.simpleName.orEmpty(),
|
||||
errorMessage = errorMessage,
|
||||
)
|
||||
analytics.send(event)
|
||||
}
|
||||
}
|
||||
|
||||
var signJob: Job? = null
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ sealed class WcAnalyticEvents(
|
|||
rawRequest: WcSdkSessionRequest,
|
||||
network: Network,
|
||||
emulationStatus: EmulationStatus?,
|
||||
securityStatus: CheckDAppResult?,
|
||||
securityStatus: CheckDAppResult,
|
||||
) : WcAnalyticEvents(
|
||||
event = "Signature Request Received",
|
||||
params = mapOf(
|
||||
|
|
@ -121,7 +121,7 @@ sealed class WcAnalyticEvents(
|
|||
AnalyticsParam.Key.METHOD_NAME to rawRequest.request.method,
|
||||
AnalyticsParam.Key.BLOCKCHAIN to network.name,
|
||||
AnalyticsParam.Key.EMULATION_STATUS to emulationStatus?.status,
|
||||
AnalyticsParam.Key.TYPE to securityStatus?.toAnalyticVerificationStatus(),
|
||||
AnalyticsParam.Key.TYPE to securityStatus.toAnalyticVerificationStatus(),
|
||||
).mapNotNullValues { it.value },
|
||||
) {
|
||||
enum class EmulationStatus(val status: String) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.features.walletconnect.transaction.model
|
|||
import androidx.compose.runtime.Stable
|
||||
import com.arkivanov.decompose.router.stack.StackNavigation
|
||||
import com.arkivanov.decompose.router.stack.pushNew
|
||||
import com.domain.blockaid.models.dapp.CheckDAppResult
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -132,7 +133,7 @@ internal class WcAddNetworkModel @Inject constructor(
|
|||
rawRequest = useCase.rawSdkRequest,
|
||||
network = useCase.network,
|
||||
emulationStatus = null,
|
||||
securityStatus = null,
|
||||
securityStatus = CheckDAppResult.FAILED_TO_VERIFY,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import arrow.core.Either
|
|||
import com.arkivanov.decompose.router.stack.StackNavigation
|
||||
import com.arkivanov.decompose.router.stack.pop
|
||||
import com.arkivanov.decompose.router.stack.pushNew
|
||||
import com.domain.blockaid.models.dapp.CheckDAppResult
|
||||
import com.domain.blockaid.models.transaction.SimulationResult
|
||||
import com.domain.blockaid.models.transaction.ValidationResult
|
||||
import com.tangem.blockchain.common.TransactionData
|
||||
|
|
@ -94,6 +95,8 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
private var sign: () -> Unit = {}
|
||||
private val feeReloadState = MutableStateFlow(false)
|
||||
private val signatureReceivedAnalyticsSendState = MutableStateFlow(false)
|
||||
private val securityStatusState =
|
||||
MutableStateFlow<Lce<Throwable, BlockAidTransactionCheck.Result>>(Lce.Loading(partialContent = null))
|
||||
|
||||
init {
|
||||
@Suppress("UnusedPrivateMember")
|
||||
|
|
@ -130,6 +133,7 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
.collectLatest { (signState, securityCheck) ->
|
||||
if (signingIsDone(signState, useCase)) return@collectLatest
|
||||
|
||||
securityStatusState.value = securityCheck
|
||||
sendSignatureReceivedAnalytics(useCase, securityCheck)
|
||||
|
||||
this@WcSendTransactionModel.signState = signState
|
||||
|
|
@ -372,6 +376,12 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
false
|
||||
}
|
||||
is Either.Right<String> -> {
|
||||
val event = WcAnalyticEvents.SignatureRequestHandled(
|
||||
rawRequest = useCase.rawSdkRequest,
|
||||
network = useCase.network,
|
||||
securityStatus = securityStatusState.value.toCheckDAppResult(),
|
||||
)
|
||||
analytics.send(event)
|
||||
showSuccessSignMessage()
|
||||
router.pop()
|
||||
true
|
||||
|
|
@ -408,10 +418,22 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
rawRequest = useCase.rawSdkRequest,
|
||||
network = useCase.network,
|
||||
emulationStatus = emulationStatus,
|
||||
securityStatus = useCase.session.securityStatus,
|
||||
securityStatus = securityCheck.toCheckDAppResult(),
|
||||
),
|
||||
)
|
||||
|
||||
signatureReceivedAnalyticsSendState.value = true
|
||||
}
|
||||
|
||||
private fun Lce<Throwable, BlockAidTransactionCheck.Result>.toCheckDAppResult(): CheckDAppResult {
|
||||
return when (this) {
|
||||
is Lce.Content -> when (this.content.result.validation) {
|
||||
ValidationResult.SAFE -> CheckDAppResult.SAFE
|
||||
ValidationResult.UNSAFE, ValidationResult.WARNING -> CheckDAppResult.UNSAFE
|
||||
ValidationResult.FAILED_TO_VALIDATE -> CheckDAppResult.FAILED_TO_VERIFY
|
||||
}
|
||||
is Lce.Error -> CheckDAppResult.FAILED_TO_VERIFY
|
||||
is Lce.Loading -> CheckDAppResult.FAILED_TO_VERIFY
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ import androidx.compose.runtime.Stable
|
|||
import com.arkivanov.decompose.router.stack.StackNavigation
|
||||
import com.arkivanov.decompose.router.stack.pop
|
||||
import com.arkivanov.decompose.router.stack.pushNew
|
||||
import com.domain.blockaid.models.dapp.CheckDAppResult
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.core.decompose.di.ModelScoped
|
||||
import com.tangem.core.decompose.model.Model
|
||||
|
|
@ -133,6 +134,12 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
private fun signingIsDone(signState: WcSignState<*>): Boolean {
|
||||
(signState.domainStep as? WcSignStep.Result)?.result?.let { result ->
|
||||
if (result.isRight()) {
|
||||
val event = WcAnalyticEvents.SignatureRequestHandled(
|
||||
rawRequest = useCase.rawSdkRequest,
|
||||
network = useCase.network,
|
||||
securityStatus = CheckDAppResult.FAILED_TO_VERIFY,
|
||||
)
|
||||
analytics.send(event)
|
||||
showSuccessSignMessage()
|
||||
}
|
||||
router.pop()
|
||||
|
|
@ -158,7 +165,7 @@ internal class WcSignTransactionModel @Inject constructor(
|
|||
rawRequest = useCase.rawSdkRequest,
|
||||
network = useCase.network,
|
||||
emulationStatus = null,
|
||||
securityStatus = null,
|
||||
securityStatus = CheckDAppResult.FAILED_TO_VERIFY,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue