Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-25 13:55:50 +03:00
commit 40b163c06d
3 changed files with 15 additions and 2 deletions

View file

@ -8,4 +8,5 @@ data class CryptoCurrencyCheck(
val reserveAmount: BigDecimal?,
val existentialDeposit: BigDecimal?,
val utxoAmountLimit: UtxoAmountLimit?,
val isAccountFunded: Boolean,
)

View file

@ -15,11 +15,19 @@ class GetCurrencyCheckUseCase(
currencyStatus: CryptoCurrencyStatus,
amount: BigDecimal?,
fee: BigDecimal?,
recipientAddress: String? = null,
): CryptoCurrencyCheck {
val network = currencyStatus.currency.network
val dustValue = currencyChecksRepository.getDustValue(userWalletId, network)
val reserveAmount = currencyChecksRepository.getReserveAmount(userWalletId, network)
val existentialDeposit = currencyChecksRepository.getExistentialDeposit(userWalletId, network)
val isAccountFunded = recipientAddress?.let {
currencyChecksRepository.checkIfAccountFunded(
userWalletId,
network,
recipientAddress,
)
} ?: false
val utxoAmountLimit = if (amount != null && fee != null) {
currencyChecksRepository.checkUtxoAmountLimit(
userWalletId = userWalletId,
@ -36,6 +44,7 @@ class GetCurrencyCheckUseCase(
reserveAmount = reserveAmount,
existentialDeposit = existentialDeposit,
utxoAmountLimit = utxoAmountLimit,
isAccountFunded = isAccountFunded,
)
}
}

View file

@ -45,7 +45,7 @@ import kotlinx.coroutines.flow.map
import java.math.BigDecimal
@Suppress("LongParameterList", "LargeClass")
internal class SendNotificationFactory constructor(
internal class SendNotificationFactory(
private val analyticsEventHandler: AnalyticsEventHandler,
private val validateTransactionUseCase: ValidateTransactionUseCase,
private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase,
@ -90,11 +90,14 @@ internal class SendNotificationFactory constructor(
reduceAmountBy = reduceAmountBy,
)
val feeError = (feeState.feeSelectorState as? FeeSelectorState.Error)?.error
val recipientAddress = state.recipientState?.addressTextField?.value
val currencyCheck = getCurrencyCheckUseCase(
userWalletId = userWalletId,
currencyStatus = cryptoCurrencyStatus,
amount = sendingAmount,
fee = feeValue,
recipientAddress = recipientAddress,
)
buildList {
addErrorNotifications(
@ -187,7 +190,7 @@ internal class SendNotificationFactory constructor(
reserveAmount = currencyCheck.reserveAmount,
sendingAmount = sendingAmount,
cryptoCurrency = currency,
isAccountFunded = false,
isAccountFunded = currencyCheck.isAccountFunded,
)
}