Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-09 10:42:27 +03:00
commit 6d0ae6a85a
9 changed files with 34 additions and 25 deletions

View file

@ -4,7 +4,6 @@ import com.tangem.blockchain.common.BlockchainSdkError
import com.tangem.common.ui.R
import com.tangem.common.ui.amountScreen.models.AmountFieldModel
import com.tangem.common.ui.amountScreen.utils.getFiatString
import com.tangem.common.ui.notifications.NotificationsFactory.addRequireDestinationFlagErrorNotification
import com.tangem.core.ui.extensions.networkIconResId
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.format
@ -115,10 +114,6 @@ object NotificationsFactory {
}
}
fun MutableList<NotificationUM>.addRequireDestinationFlagErrorNotification() {
add(NotificationUM.Error.DestinationMemoRequired)
}
fun MutableList<NotificationUM>.addMinimumAmountErrorNotification(
minimumSendAmount: BigDecimal?,
sendingAmount: BigDecimal,
@ -516,4 +511,8 @@ object NotificationsFactory {
is CryptoCurrency.Token -> isChangeLowerThanDust
}
}
private fun MutableList<NotificationUM>.addRequireDestinationFlagErrorNotification() {
add(NotificationUM.Error.DestinationMemoRequired)
}
}

View file

@ -26,15 +26,14 @@ class ValidateWalletAddressUseCase(
address: String,
currencyAddress: Set<NetworkAddress.Address>?,
): AddressValidationResult {
val decodedXAddress = BlockchainUtils.decodeRippleXAddress(address, network.id.value)
val isUtxoConsolidationAvailable =
walletManagersFacade.checkUtxoConsolidationAvailability(userWalletId, network)
val isCurrentAddress = currencyAddress?.any { it.value == address } ?: true
val addressToValidate = decodedXAddress?.address ?: address
val isCurrentAddress = currencyAddress?.any { it.value == addressToValidate } ?: true
val isForbidSelfSend = isCurrentAddress && !isUtxoConsolidationAvailable
val decodedXAddress = BlockchainUtils.decodeRippleXAddress(address, network.id.value)
val addressToValidate = decodedXAddress?.address ?: address
val isValidAddress = walletAddressServiceRepository.validateAddress(userWalletId, network, addressToValidate)
return when {
@ -51,15 +50,14 @@ class ValidateWalletAddressUseCase(
address: String,
senderAddresses: List<CryptoCurrencyAddress>,
): AddressValidationResult {
val decodedXAddress = BlockchainUtils.decodeRippleXAddress(address, network.id.value)
val isUtxoConsolidationAvailable =
walletManagersFacade.checkUtxoConsolidationAvailability(userWalletId, network)
val isCurrentAddress = senderAddresses.any { it.address == address }
val addressToValidate = decodedXAddress?.address ?: address
val isCurrentAddress = senderAddresses.any { it.address == addressToValidate }
val isForbidSelfSend = isCurrentAddress && !isUtxoConsolidationAvailable
val decodedXAddress = BlockchainUtils.decodeRippleXAddress(address, network.id.value)
val addressToValidate = decodedXAddress?.address ?: address
val isValidAddress = walletAddressServiceRepository.validateAddress(userWalletId, network, addressToValidate)
return when {

View file

@ -94,6 +94,7 @@ internal class SendConfirmComponent(
feeCryptoCurrencyStatus = params.feeCryptoCurrencyStatus,
appCurrency = params.appCurrency,
destinationAddress = model.enteredDestination.orEmpty(),
memo = model.enteredMemo,
amountValue = model.enteredAmount.orZero(),
reduceAmountBy = model.reduceAmountBy.orZero(),
isIgnoreReduce = model.isIgnoreReduce,

View file

@ -131,6 +131,8 @@ internal class SendConfirmModel @Inject constructor(
get() = amountState?.isIgnoreReduce == true
val enteredDestination: String?
get() = destinationUM?.addressTextField?.value
val enteredMemo: String?
get() = destinationUM?.memoTextField?.value
val fee: Fee?
get() = feeSelectorUM?.selectedFee
val feeError: GetFeeError?
@ -459,6 +461,7 @@ internal class SendConfirmModel @Inject constructor(
notificationsUpdateTrigger.triggerUpdate(
data = NotificationData(
destinationAddress = enteredDestination.orEmpty(),
memo = enteredMemo,
amountValue = enteredAmount.orZero(),
reduceAmountBy = reduceAmountBy.orZero(),
isIgnoreReduce = isIgnoreReduce,

View file

@ -16,6 +16,7 @@ internal sealed class SendAmountComponentParams {
abstract val userWallet: UserWallet
abstract val appCurrency: AppCurrency
abstract val cryptoCurrencyStatus: CryptoCurrencyStatus
abstract val predefinedAmountValue: String?
data class AmountParams(
override val state: AmountState,
@ -23,10 +24,10 @@ internal sealed class SendAmountComponentParams {
override val userWallet: UserWallet,
override val appCurrency: AppCurrency,
override val cryptoCurrencyStatus: CryptoCurrencyStatus,
override val predefinedAmountValue: String?,
val isEditMode: Boolean,
val callback: ModelCallback,
val currentRoute: Flow<SendRoute.Amount>,
val predefinedAmountValue: String?,
val isBalanceHidingFlow: StateFlow<Boolean>,
) : SendAmountComponentParams()
@ -36,8 +37,8 @@ internal sealed class SendAmountComponentParams {
override val userWallet: UserWallet,
override val appCurrency: AppCurrency,
override val cryptoCurrencyStatus: CryptoCurrencyStatus,
override val predefinedAmountValue: String?,
val blockClickEnableFlow: StateFlow<Boolean>,
val predefinedAmountValue: String?,
val isPredefinedValues: Boolean,
) : SendAmountComponentParams()
}

View file

@ -98,10 +98,7 @@ internal class SendAmountModel @Inject constructor(
),
)
}
val params = params as? SendAmountComponentParams.AmountBlockParams
if (params?.predefinedAmountValue != null) {
onAmountValueChange(params.predefinedAmountValue)
}
params.predefinedAmountValue?.let(::onAmountValueChange)
}
}

View file

@ -46,6 +46,7 @@ internal class NotificationsComponent(
val feeCryptoCurrencyStatus: CryptoCurrencyStatus,
val appCurrency: AppCurrency,
val destinationAddress: String,
val memo: String?,
val amountValue: BigDecimal,
val reduceAmountBy: BigDecimal,
val isIgnoreReduce: Boolean,

View file

@ -6,6 +6,7 @@ import java.math.BigDecimal
data class NotificationData(
val destinationAddress: String,
val memo: String?,
val amountValue: BigDecimal,
val reduceAmountBy: BigDecimal,
val isIgnoreReduce: Boolean,

View file

@ -79,6 +79,7 @@ internal class NotificationsModel @Inject constructor(
private val appCurrency = params.appCurrency
private var destinationAddress = params.destinationAddress
private var memo = params.memo
private var amountValue = params.amountValue
private var reduceAmountBy = params.reduceAmountBy
private var isIgnoreReduce = params.isIgnoreReduce
@ -110,6 +111,7 @@ internal class NotificationsModel @Inject constructor(
private suspend fun updateState(data: NotificationData) {
destinationAddress = data.destinationAddress
memo = data.memo
amountValue = data.amountValue
reduceAmountBy = data.reduceAmountBy
isIgnoreReduce = data.isIgnoreReduce
@ -134,6 +136,7 @@ internal class NotificationsModel @Inject constructor(
)
addDomainNotifications(
destinationAddress = destinationAddress,
memo = memo,
amountValue = amountValue,
reduceAmountBy = reduceAmountBy,
fee = fee,
@ -160,6 +163,7 @@ internal class NotificationsModel @Inject constructor(
private suspend fun MutableList<NotificationUM>.addDomainNotifications(
destinationAddress: String,
memo: String?,
amountValue: BigDecimal,
reduceAmountBy: BigDecimal,
fee: Fee?,
@ -199,6 +203,8 @@ internal class NotificationsModel @Inject constructor(
currencyCheck = currencyCheck,
)
addWarningNotifications(
destinationAddress = destinationAddress,
memo = memo,
enteredAmount = amountValue,
fee = fee,
feeValue = feeValue,
@ -288,6 +294,8 @@ internal class NotificationsModel @Inject constructor(
}
private suspend fun MutableList<NotificationUM>.addWarningNotifications(
destinationAddress: String,
memo: String?,
enteredAmount: BigDecimal,
sendingAmount: BigDecimal,
fee: Fee?,
@ -297,11 +305,11 @@ internal class NotificationsModel @Inject constructor(
) {
val validationError = validateTransactionUseCase(
userWalletId = userWalletId,
amount = enteredAmount.convertToSdkAmount(currency),
amount = amountValue.convertToSdkAmount(cryptoCurrencyStatus.currency),
fee = fee,
memo = null,
destination = "",
network = currency.network,
memo = memo,
destination = destinationAddress,
network = cryptoCurrencyStatus.currency.network,
).leftOrNull()
addRentExemptionNotification(