From bd14f694c5afe474a33b468bbc57cbef2dd6ee15 Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 17 Feb 2026 11:25:36 +0400 Subject: [PATCH] Updated on 2026-08-14 --- .../SwapNotificationsComponent.kt | 6 +++++ .../model/SwapNotificationsModel.kt | 26 +++++++++++++++++++ .../confirm/SendWithSwapConfirmComponent.kt | 4 +++ .../confirm/model/SendWithSwapConfirmModel.kt | 4 +++ 4 files changed, 40 insertions(+) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt index 8de4dc6649..3634569cf9 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/SwapNotificationsComponent.kt @@ -7,6 +7,8 @@ import com.tangem.core.decompose.context.AppComponentContext import com.tangem.core.decompose.model.getOrCreateModel import com.tangem.domain.express.models.ExpressError import com.tangem.domain.models.currency.CryptoCurrency +import com.tangem.domain.models.currency.CryptoCurrencyStatus +import com.tangem.domain.models.wallet.UserWalletId import com.tangem.features.swap.v2.impl.notifications.model.SwapNotificationsModel import com.tangem.features.swap.v2.impl.notifications.ui.swapNotifications import kotlinx.collections.immutable.ImmutableList @@ -40,6 +42,10 @@ internal class SwapNotificationsComponent( data class SwapNotificationData( val expressError: ExpressError?, val fromCryptoCurrency: CryptoCurrency?, + val destinationAddress: String, + val memo: String? = null, + val toCryptoCurrencyStatus: CryptoCurrencyStatus? = null, + val userWalletId: UserWalletId? = null, ) } } \ No newline at end of file diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt index e2be8113cd..89e743866c 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/notifications/model/SwapNotificationsModel.kt @@ -1,5 +1,6 @@ package com.tangem.features.swap.v2.impl.notifications.model +import com.tangem.blockchain.common.BlockchainSdkError import com.tangem.common.ui.notifications.NotificationUM import com.tangem.core.decompose.di.ModelScoped import com.tangem.core.decompose.model.Model @@ -7,6 +8,8 @@ import com.tangem.core.decompose.model.ParamsContainer import com.tangem.core.ui.format.bigdecimal.crypto import com.tangem.core.ui.format.bigdecimal.format import com.tangem.domain.express.models.ExpressError +import com.tangem.domain.transaction.usecase.ValidateTransactionUseCase +import com.tangem.domain.utils.convertToSdkAmount import com.tangem.features.swap.v2.api.subcomponents.SwapAmountUpdateTrigger import com.tangem.features.swap.v2.impl.notifications.DefaultSwapNotificationsUpdateTrigger import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsComponent @@ -14,6 +17,7 @@ import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsComponent import com.tangem.features.swap.v2.impl.notifications.SwapNotificationsUpdateListener import com.tangem.features.swap.v2.impl.notifications.entity.SwapNotificationUM import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import java.math.BigDecimal import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf import kotlinx.collections.immutable.toImmutableList @@ -30,6 +34,7 @@ internal class SwapNotificationsModel @Inject constructor( private val swapNotificationsUpdateListener: SwapNotificationsUpdateListener, private val swapNotificationsUpdateTrigger: DefaultSwapNotificationsUpdateTrigger, private val swapAmountUpdateTrigger: SwapAmountUpdateTrigger, + private val validateTransactionUseCase: ValidateTransactionUseCase, paramsContainer: ParamsContainer, ) : Model() { @@ -61,12 +66,33 @@ internal class SwapNotificationsModel @Inject constructor( private suspend fun buildNotifications() { val notifications = buildList { addExpressErrorNotification() + addDestinationTagRequiredNotification() } swapNotificationsUpdateTrigger.callbackHasError(notifications.isNotEmpty()) uiState.value = notifications.toImmutableList() } + private suspend fun MutableList.addDestinationTagRequiredNotification() { + val toCryptoCurrencyStatus = notificationData.toCryptoCurrencyStatus ?: return + val userWalletId = notificationData.userWalletId ?: return + val destinationAddress = notificationData.destinationAddress + if (destinationAddress.isEmpty()) return + + val validationError = validateTransactionUseCase( + amount = BigDecimal.ZERO.convertToSdkAmount(toCryptoCurrencyStatus), + fee = null, + memo = notificationData.memo, + destination = destinationAddress, + userWalletId = userWalletId, + network = toCryptoCurrencyStatus.currency.network, + ).leftOrNull() + + if (validationError is BlockchainSdkError.DestinationTagRequired) { + add(NotificationUM.Error.DestinationTagRequired) + } + } + fun MutableList.addExpressErrorNotification() { val expressError = notificationData.expressError ?: return val fromCryptoCurrency = notificationData.fromCryptoCurrency ?: return diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt index aac3bb92dd..59d34c0701 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt @@ -133,6 +133,10 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor( swapNotificationData = SwapNotificationsComponent.Params.SwapNotificationData( expressError = (model.confirmData.quote as? SwapQuoteUM.Error)?.expressError, fromCryptoCurrency = model.confirmData.fromCryptoCurrencyStatus?.currency, + destinationAddress = model.confirmData.enteredDestination.orEmpty(), + memo = model.confirmData.enteredMemo, + toCryptoCurrencyStatus = model.confirmData.toCryptoCurrencyStatus, + userWalletId = params.userWallet.walletId, ), ), ) diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index 6fdf6bdb46..271decfaa7 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -429,6 +429,10 @@ internal class SendWithSwapConfirmModel @Inject constructor( data = SwapNotificationData( expressError = (confirmData.quote as? SwapQuoteUM.Error)?.expressError, fromCryptoCurrency = confirmData.fromCryptoCurrencyStatus?.currency, + destinationAddress = confirmData.enteredDestination.orEmpty(), + memo = confirmData.enteredMemo, + toCryptoCurrencyStatus = confirmData.toCryptoCurrencyStatus, + userWalletId = params.userWallet.walletId, ), ) uiState.transformerUpdate(