Updated on 2026-08-14
This commit is contained in:
commit
f3dfb262c2
527 changed files with 12898 additions and 3301 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
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@ internal data object SwapAmountContentPreview {
|
|||
value = "bitcoin",
|
||||
derivationPath = Network.DerivationPath.None,
|
||||
),
|
||||
backendId = "bitcoin",
|
||||
name = "Bitcoin",
|
||||
currencySymbol = "BTC",
|
||||
derivationPath = Network.DerivationPath.None,
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ internal class SwapChooseContentStateTransformer(
|
|||
|
||||
val isMain = cryptoCurrency is CryptoCurrency.Coin
|
||||
val subtitle = when {
|
||||
BlockchainUtils.isL2Network(networkId = network.backendId) -> MAIN_NETWORK_L2_TYPE_NAME
|
||||
BlockchainUtils.isL2Network(networkId = network.rawId) -> MAIN_NETWORK_L2_TYPE_NAME
|
||||
isMain -> MAIN_NETWORK_TYPE_NAME
|
||||
network.standardType !is Network.StandardType.Unspecified -> network.standardType.name
|
||||
else -> ""
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ internal class SwapAlertFactory @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage.orEmpty(),
|
||||
blockchainId = cryptoCurrency?.network?.rawId.orEmpty(),
|
||||
derivationPath = cryptoCurrency?.network?.derivationPath?.value.orEmpty(),
|
||||
networkId = cryptoCurrency?.network?.id,
|
||||
destinationAddress = confirmData?.enteredDestination.orEmpty(),
|
||||
tokenSymbol = confirmData?.toCryptoCurrencyStatus?.currency?.symbol.orEmpty(),
|
||||
amount = confirmData?.enteredFromAmount?.toString().orEmpty(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue