Updated on 2026-08-14
This commit is contained in:
parent
07ff9891dc
commit
f821956f4d
4 changed files with 28 additions and 12 deletions
|
|
@ -95,20 +95,19 @@ internal class SendNotificationFactory(
|
|||
val feeError = (feeState.feeSelectorState as? FeeSelectorState.Error)?.error
|
||||
|
||||
val recipientAddress = state.recipientState?.addressTextField?.value
|
||||
val statusValue = cryptoCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
|
||||
val feeToSubtract = if (isSubtractAvailableProvider()) {
|
||||
feeValue
|
||||
} else {
|
||||
BigDecimal.ZERO
|
||||
}
|
||||
val balanceAfterTransaction = statusValue?.let { it.amount - sendingAmount - feeToSubtract }
|
||||
val feeCurrencyBalanceAfterTransaction = getFeeCurrencyBalanceAfterTx(
|
||||
feeCurrencyStatus = feeCryptoCurrencyStatusProvider(),
|
||||
sendingCurrencyStatus = cryptoCurrencyStatus,
|
||||
sendingAmount = sendingAmount,
|
||||
feeValue = feeValue,
|
||||
)
|
||||
val currencyCheck = getCurrencyCheckUseCase(
|
||||
userWalletId = userWalletId,
|
||||
currencyStatus = cryptoCurrencyStatus,
|
||||
amount = sendingAmount,
|
||||
fee = feeValue,
|
||||
recipientAddress = recipientAddress,
|
||||
balanceAfterTransaction = balanceAfterTransaction,
|
||||
feeCurrencyBalanceAfterTransaction = feeCurrencyBalanceAfterTransaction,
|
||||
)
|
||||
buildList {
|
||||
addErrorNotifications(
|
||||
|
|
@ -143,6 +142,23 @@ internal class SendNotificationFactory(
|
|||
)
|
||||
}
|
||||
|
||||
private fun getFeeCurrencyBalanceAfterTx(
|
||||
feeCurrencyStatus: CryptoCurrencyStatus?,
|
||||
sendingCurrencyStatus: CryptoCurrencyStatus,
|
||||
sendingAmount: BigDecimal,
|
||||
feeValue: BigDecimal,
|
||||
): BigDecimal? {
|
||||
val sendingCurrencyBalance = sendingCurrencyStatus.value as? CryptoCurrencyStatus.Loaded
|
||||
val feeCurrencyBalance = feeCurrencyStatus?.value as? CryptoCurrencyStatus.Loaded
|
||||
if (feeCurrencyStatus?.value !is CryptoCurrencyStatus.Loaded) return null
|
||||
return when {
|
||||
feeCurrencyStatus == sendingCurrencyStatus -> sendingCurrencyBalance?.let {
|
||||
it.amount - sendingAmount - feeValue
|
||||
}
|
||||
else -> feeCurrencyBalance?.let { it.amount - feeValue }
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun MutableList<NotificationUM>.addErrorNotifications(
|
||||
feeError: GetFeeError?,
|
||||
sendingAmount: BigDecimal,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue