Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-14 14:22:01 +04:00
parent 589805424e
commit c448a1aebb
8 changed files with 64 additions and 57 deletions

View file

@ -34,7 +34,6 @@ import com.tangem.domain.tokens.GetCurrencyCheckUseCase
import com.tangem.domain.tokens.IsAmountSubtractAvailableUseCase
import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck
import com.tangem.domain.transaction.usecase.ValidateTransactionUseCase
import com.tangem.domain.transaction.usecase.ValidateWalletMemoUseCase
import com.tangem.domain.utils.convertToSdkAmount
import com.tangem.features.send.v2.api.SendNotificationsComponent
import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData
@ -69,7 +68,6 @@ internal class NotificationsModel @Inject constructor(
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
private val getBalanceNotEnoughForFeeWarningUseCase: GetBalanceNotEnoughForFeeWarningUseCase,
private val validateTransactionUseCase: ValidateTransactionUseCase,
private val validateWalletMemoUseCase: ValidateWalletMemoUseCase,
private val getTronFeeNotificationShowCountUseCase: GetTronFeeNotificationShowCountUseCase,
private val incrementNotificationsShowCountUseCase: IncrementNotificationsShowCountUseCase,
private val notificationsUpdateTrigger: SendNotificationsUpdateTrigger,
@ -302,7 +300,7 @@ internal class NotificationsModel @Inject constructor(
}
private suspend fun MutableList<NotificationUM>.addWarningNotifications(
destinationAddress: String,
destinationAddress: String?,
memo: String?,
enteredAmount: BigDecimal,
sendingAmount: BigDecimal,
@ -311,14 +309,18 @@ internal class NotificationsModel @Inject constructor(
isFeeCoverage: Boolean,
currencyCheck: CryptoCurrencyCheck,
) {
val validationError = validateTransactionUseCase(
userWalletId = userWalletId,
amount = enteredAmount.convertToSdkAmount(cryptoCurrencyStatus),
fee = fee,
memo = memo,
destination = destinationAddress,
network = cryptoCurrencyStatus.currency.network,
).leftOrNull()
val validationError = if (destinationAddress != null) {
validateTransactionUseCase(
userWalletId = userWalletId,
amount = enteredAmount.convertToSdkAmount(cryptoCurrencyStatus),
fee = fee,
memo = memo,
destination = destinationAddress,
network = cryptoCurrencyStatus.currency.network,
).leftOrNull()
} else {
null
}
addRentExemptionNotification(
rentWarning = currencyCheck.rentWarning,
@ -352,10 +354,6 @@ internal class NotificationsModel @Inject constructor(
params.callback.onAmountReduceTo(reduceTo)
},
)
addDestinationTagRequiredNotification(
isMemoRequired = currencyCheck.isMemoRequired,
memo = memo,
)
addHighFeeWarningNotification(
enteredAmountValue = enteredAmount,
cryptoCurrencyStatus = cryptoCurrencyStatus,
@ -376,21 +374,6 @@ internal class NotificationsModel @Inject constructor(
addTronNetworkFeesNotification()
}
private suspend fun MutableList<NotificationUM>.addDestinationTagRequiredNotification(
isMemoRequired: Boolean,
memo: String?,
) {
if (!isMemoRequired || contains(NotificationUM.Error.DestinationTagRequired)) return
val isMemoInvalid = memo.isNullOrEmpty() || validateWalletMemoUseCase(
userWalletId = userWalletId,
cryptoCurrency = currency,
memo = memo,
).isLeft()
if (isMemoInvalid) {
add(NotificationUM.Error.DestinationTagRequired)
}
}
private suspend fun MutableList<NotificationUM>.addTronNetworkFeesNotification() {
val cryptoCurrency = cryptoCurrencyStatus.currency
val isTronToken = cryptoCurrency is CryptoCurrency.Token &&