Updated on 2026-08-14
This commit is contained in:
parent
07ff9891dc
commit
f821956f4d
4 changed files with 28 additions and 12 deletions
|
|
@ -19,7 +19,7 @@ class GetCurrencyCheckUseCase(
|
|||
currencyStatus: CryptoCurrencyStatus,
|
||||
amount: BigDecimal?,
|
||||
fee: BigDecimal?,
|
||||
balanceAfterTransaction: BigDecimal?,
|
||||
feeCurrencyBalanceAfterTransaction: BigDecimal?,
|
||||
recipientAddress: String? = null,
|
||||
): CryptoCurrencyCheck {
|
||||
return withContext(dispatchers.io) {
|
||||
|
|
@ -32,7 +32,7 @@ class GetCurrencyCheckUseCase(
|
|||
val rentWarning = currencyChecksRepository.getRentExemptionError(
|
||||
userWalletId = userWalletId,
|
||||
currencyStatus = currencyStatus,
|
||||
balanceAfterTransaction = balanceAfterTransaction ?: BigDecimal.ZERO,
|
||||
balanceAfterTransaction = feeCurrencyBalanceAfterTransaction ?: BigDecimal.ZERO,
|
||||
)
|
||||
val isAccountFunded = recipientAddress?.let {
|
||||
currencyChecksRepository.checkIfAccountFunded(
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -647,7 +647,7 @@ internal class StakingViewModel @Inject constructor(
|
|||
currencyStatus = cryptoCurrencyStatus,
|
||||
amount = amount,
|
||||
fee = fee,
|
||||
balanceAfterTransaction = balanceAfterTransaction,
|
||||
feeCurrencyBalanceAfterTransaction = balanceAfterTransaction,
|
||||
)
|
||||
stateController.update(
|
||||
AddStakingNotificationsTransformer(
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
currencyStatus = fromTokenStatus,
|
||||
amount = amount.value,
|
||||
fee = fee,
|
||||
balanceAfterTransaction = balanceAfterTransaction,
|
||||
feeCurrencyBalanceAfterTransaction = balanceAfterTransaction,
|
||||
)
|
||||
|
||||
return currencyCheck
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue