Updated on 2026-08-14
This commit is contained in:
parent
502d9e3b40
commit
44a191019a
8 changed files with 46 additions and 16 deletions
|
|
@ -3,6 +3,7 @@ package com.tangem.features.walletconnect.transaction.converter
|
|||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.walletconnect.model.WcEthMethod
|
||||
import com.tangem.domain.walletconnect.model.WcSolanaMethod
|
||||
import com.tangem.domain.walletconnect.usecase.method.BlockAidTransactionCheck
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcMethodContext
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcSignState
|
||||
import com.tangem.domain.walletconnect.usecase.method.WcSignStep
|
||||
|
|
@ -52,6 +53,7 @@ internal class WcSendTransactionUMConverter @Inject constructor(
|
|||
estimatedWalletChanges = WcSendReceiveTransactionCheckResultsUM(),
|
||||
isLoading = value.signState.domainStep == WcSignStep.Signing,
|
||||
address = WcAddressConverter.convert(value.context.derivationState),
|
||||
transactionValidationResult = value.securityCheck?.result?.validation,
|
||||
sendEnabled = value.feeSelectorUM is FeeSelectorUM.Content && feeErrorNotification == null,
|
||||
feeErrorNotification = feeErrorNotification,
|
||||
),
|
||||
|
|
@ -78,6 +80,7 @@ internal class WcSendTransactionUMConverter @Inject constructor(
|
|||
val actions: WcTransactionActionsUM,
|
||||
val feeSelectorUM: FeeSelectorUM?,
|
||||
val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
val securityCheck: BlockAidTransactionCheck.Result?,
|
||||
val onFeeReload: () -> Unit,
|
||||
)
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.features.walletconnect.transaction.entity.send
|
||||
|
||||
import com.domain.blockaid.models.transaction.ValidationResult
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
import com.tangem.features.send.v2.api.entity.FeeSelectorUM
|
||||
|
|
@ -27,6 +28,7 @@ internal data class WcSendTransactionItemUM(
|
|||
val walletName: String?,
|
||||
val networkInfo: WcNetworkInfoUM,
|
||||
val address: String?,
|
||||
val transactionValidationResult: ValidationResult?,
|
||||
val sendEnabled: Boolean,
|
||||
val feeErrorNotification: NotificationUM.Info?,
|
||||
val isLoading: Boolean = false,
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
feeSelectorUM = uiState.value?.feeSelectorUM,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
onFeeReload = ::triggerFeeReload,
|
||||
securityCheck = securityCheck.getOrNull(),
|
||||
),
|
||||
)
|
||||
transactionUM = transactionUM?.copy(
|
||||
|
|
@ -280,6 +281,7 @@ internal class WcSendTransactionModel @Inject constructor(
|
|||
stackNavigation.pushNew(WcTransactionRoutes.SelectFee)
|
||||
}
|
||||
|
||||
// Before change, make sure you are align with WcTransactionRequestButtons
|
||||
private fun onSign(securityCheck: BlockAidTransactionCheck.Result?) {
|
||||
when (securityCheck?.result?.validation) {
|
||||
ValidationResult.UNSAFE -> showMaliciousAlert(securityCheck.result.description)
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ internal fun WcAddEthereumChainModalBottomSheetContent(
|
|||
onClickActiveButton = state.onSign,
|
||||
activeButtonText = resourceReference(R.string.common_sign),
|
||||
isLoading = state.isLoading,
|
||||
validationResult = null,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import com.domain.blockaid.models.transaction.ValidationResult
|
||||
import com.tangem.core.ui.components.PrimaryButton
|
||||
import com.tangem.core.ui.components.PrimaryButtonIconEnd
|
||||
import com.tangem.core.ui.components.SecondaryButton
|
||||
import com.tangem.core.ui.extensions.TextReference
|
||||
|
|
@ -17,6 +19,7 @@ import com.tangem.features.walletconnect.impl.R
|
|||
internal fun WcTransactionRequestButtons(
|
||||
activeButtonText: TextReference,
|
||||
isLoading: Boolean,
|
||||
validationResult: ValidationResult?,
|
||||
onDismiss: () -> Unit,
|
||||
onClickActiveButton: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
|
|
@ -30,15 +33,32 @@ internal fun WcTransactionRequestButtons(
|
|||
text = stringResourceSafe(R.string.common_cancel),
|
||||
onClick = onDismiss,
|
||||
)
|
||||
PrimaryButtonIconEnd(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
text = activeButtonText.resolveReference(),
|
||||
onClick = onClickActiveButton,
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
showProgress = isLoading,
|
||||
enabled = enabled,
|
||||
)
|
||||
// Before change, make sure you are align with WcSendTransactionModel::onSign
|
||||
when (validationResult) {
|
||||
ValidationResult.UNSAFE,
|
||||
ValidationResult.WARNING,
|
||||
-> PrimaryButton(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
text = stringResourceSafe(R.string.common_continue),
|
||||
onClick = onClickActiveButton,
|
||||
showProgress = isLoading,
|
||||
enabled = enabled,
|
||||
)
|
||||
ValidationResult.SAFE,
|
||||
ValidationResult.FAILED_TO_VALIDATE,
|
||||
null,
|
||||
-> PrimaryButtonIconEnd(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
text = activeButtonText.resolveReference(),
|
||||
onClick = onClickActiveButton,
|
||||
iconResId = R.drawable.ic_tangem_24,
|
||||
showProgress = isLoading,
|
||||
enabled = enabled,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -16,6 +16,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.domain.blockaid.models.transaction.ValidationResult
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig
|
||||
import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfigContent
|
||||
|
|
@ -137,6 +138,7 @@ internal fun WcSendTransactionModalBottomSheet(
|
|||
activeButtonText = resourceReference(R.string.common_send),
|
||||
isLoading = state.isLoading,
|
||||
enabled = state.sendEnabled,
|
||||
validationResult = state.transactionValidationResult,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
@ -221,6 +223,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
address = null,
|
||||
sendEnabled = true,
|
||||
feeErrorNotification = null,
|
||||
transactionValidationResult = null,
|
||||
),
|
||||
WcSendTransactionItemUM(
|
||||
onDismiss = {},
|
||||
|
|
@ -263,6 +266,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
title = stringReference("Insufficient Ethereum"),
|
||||
subtitle = stringReference("Top up your balance to cover the network fee"),
|
||||
),
|
||||
transactionValidationResult = ValidationResult.WARNING,
|
||||
),
|
||||
WcSendTransactionItemUM(
|
||||
onDismiss = {},
|
||||
|
|
@ -309,6 +313,7 @@ private class WcSendTransactionStateProvider : CollectionPreviewParameterProvide
|
|||
onClick = {},
|
||||
),
|
||||
),
|
||||
transactionValidationResult = ValidationResult.SAFE,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
|
@ -95,6 +95,7 @@ internal fun WcSignTransactionModalBottomSheetContent(
|
|||
onClickActiveButton = state.onSign,
|
||||
activeButtonText = resourceReference(R.string.common_sign),
|
||||
isLoading = state.isLoading,
|
||||
validationResult = null,
|
||||
)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.features.walletconnect.utils
|
||||
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.common.ui.notifications.NotificationUM
|
||||
import com.tangem.core.ui.components.notifications.NotificationConfig
|
||||
import com.tangem.core.ui.extensions.resourceReference
|
||||
|
|
@ -54,14 +53,11 @@ internal class WcNotificationsFactory @Inject constructor() {
|
|||
feeSelectorUM: FeeSelectorUM?,
|
||||
): Boolean {
|
||||
val feeSelectorContent = feeSelectorUM as? FeeSelectorUM.Content ?: return false
|
||||
val lowestFee = when (val fees = feeSelectorContent.fees) {
|
||||
is TransactionFee.Choosable -> fees.minimum
|
||||
is TransactionFee.Single -> fees.normal
|
||||
}
|
||||
val selectedFee = feeSelectorContent.selectedFeeItem.fee
|
||||
|
||||
return FeeCalculationUtils.checkExceedBalance(
|
||||
feeBalance = cryptoCurrencyStatus.value.amount,
|
||||
feeAmount = lowestFee.amount.value,
|
||||
feeAmount = selectedFee.amount.value,
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue