Updated on 2026-08-14
This commit is contained in:
parent
5f2acac137
commit
547d562d6d
1 changed files with 20 additions and 1 deletions
|
|
@ -62,7 +62,8 @@ internal class SwapAmountSelectQuoteTransformer(
|
|||
)
|
||||
|
||||
return prevState.copy(
|
||||
isPrimaryButtonEnabled = quoteUM is SwapQuoteUM.Content,
|
||||
isPrimaryButtonEnabled = quoteUM is SwapQuoteUM.Content &&
|
||||
!hasInsufficientBalance(prevState, quoteContent, newPrimaryAmount),
|
||||
selectedQuote = quoteUM,
|
||||
isShowFCAWarning = isNeedApplyFCARestrictions && quoteUM.provider?.isRestrictedByFCA() == true,
|
||||
primaryAmount = newPrimaryAmount,
|
||||
|
|
@ -202,4 +203,22 @@ internal class SwapAmountSelectQuoteTransformer(
|
|||
prevState.secondaryAmount
|
||||
}
|
||||
}
|
||||
|
||||
private fun hasInsufficientBalance(
|
||||
prevState: SwapAmountUM.Content,
|
||||
quoteContent: SwapQuoteUM.Content?,
|
||||
newPrimaryAmount: SwapAmountFieldUM,
|
||||
): Boolean {
|
||||
if (quoteContent == null) return false
|
||||
|
||||
val primaryBalance = prevState.primaryCryptoCurrencyStatus.value.amount ?: return false
|
||||
val fromAmount = if (prevState.selectedAmountType == SwapAmountType.To) {
|
||||
quoteContent.fromAmount
|
||||
} else {
|
||||
val amountData = (newPrimaryAmount as? SwapAmountFieldUM.Content)?.amountField as? AmountState.Data
|
||||
amountData?.amountTextField?.cryptoAmount?.value
|
||||
}
|
||||
|
||||
return fromAmount != null && fromAmount > primaryBalance
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue