Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-29 15:20:33 +04:00
parent 78c4581372
commit 3069b8d32d
23 changed files with 287 additions and 20 deletions

View file

@ -2,4 +2,5 @@ package com.tangem.features.swap.v2.api
interface SwapFeatureToggles {
val isSwapProviderFilterEnabled: Boolean
val isHighFeeWarningEnabled: Boolean
}

View file

@ -10,4 +10,7 @@ internal class DefaultSwapFeatureToggles @Inject constructor(
) : SwapFeatureToggles {
override val isSwapProviderFilterEnabled: Boolean =
featureToggles.isFeatureEnabled(FeatureToggles.AND_15009_SWAP_PROVIDER_FILTER_ENABLED)
override val isHighFeeWarningEnabled: Boolean =
featureToggles.isFeatureEnabled(FeatureToggles.TWI_1367_HIGH_FEE_WARNING_ENABLED)
}

View file

@ -27,6 +27,7 @@ import com.tangem.domain.models.account.derivationIndex
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.domain.models.wallet.isHotWallet
import com.tangem.domain.quotes.IsHighNetworkFeeUseCase
import com.tangem.domain.settings.IsSendTapHelpEnabledUseCase
import com.tangem.domain.swap.models.SwapAmountType
import com.tangem.domain.swap.models.SwapDirection.Companion.withSwapDirection
@ -47,6 +48,7 @@ import com.tangem.features.send.api.subcomponents.destination.entity.Destination
import com.tangem.features.send.api.subcomponents.feeSelector.FeeSelectorReloadTrigger
import com.tangem.features.send.api.subcomponents.notifications.SendNotificationsUpdateListener
import com.tangem.features.send.api.subcomponents.notifications.SendNotificationsUpdateTrigger
import com.tangem.features.swap.v2.api.SwapFeatureToggles
import com.tangem.features.swap.v2.api.subcomponents.SwapAmountUpdateTrigger
import com.tangem.features.swap.v2.impl.R
import com.tangem.features.swap.v2.impl.amount.SwapAmountReduceTrigger
@ -89,6 +91,8 @@ internal class SendWithSwapConfirmModel @Inject constructor(
private val estimateFeeForTokenUseCase: EstimateFeeForTokenUseCase,
private val estimateFeeForGaslessTxUseCase: EstimateFeeForGaslessTxUseCase,
private val isAmountSubtractAvailableUseCase: IsAmountSubtractAvailableUseCase,
private val isHighNetworkFeeUseCase: IsHighNetworkFeeUseCase,
private val swapFeatureToggles: SwapFeatureToggles,
private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase,
private val sendNotificationsUpdateTrigger: SendNotificationsUpdateTrigger,
private val swapNotificationsUpdateTrigger: SwapNotificationsUpdateTrigger,
@ -467,12 +471,19 @@ internal class SendWithSwapConfirmModel @Inject constructor(
feeValue = confirmData.fee?.amount?.value,
),
)
val isHighNetworkFee = isHighNetworkFee(feeCryptoCurrencyStatus.currency)
uiState.transformerUpdate(
SendWithSwapConfirmationNotificationsTransformer(),
SendWithSwapConfirmationNotificationsTransformer(isHighNetworkFee = isHighNetworkFee),
)
}
}
private suspend fun isHighNetworkFee(feeCurrency: CryptoCurrency): Boolean {
if (!swapFeatureToggles.isHighFeeWarningEnabled) return false
val feeAmount = confirmData.fee?.amount?.value ?: return false
return isHighNetworkFeeUseCase(feeCurrency, feeAmount)
}
private fun subscribeOnNotificationUpdates() {
combine(
flow = sendNotificationsUpdateListener.hasErrorFlow,

View file

@ -22,7 +22,9 @@ import com.tangem.features.swap.v2.impl.sendviaswap.entity.SendWithSwapUM
import com.tangem.utils.transformer.Transformer
import kotlinx.collections.immutable.toPersistentList
internal class SendWithSwapConfirmationNotificationsTransformer : Transformer<SendWithSwapUM> {
internal class SendWithSwapConfirmationNotificationsTransformer(
private val isHighNetworkFee: Boolean,
) : Transformer<SendWithSwapUM> {
override fun transform(prevState: SendWithSwapUM): SendWithSwapUM {
val confirmUM = prevState.confirmUM as? ConfirmUM.Content ?: return prevState
val feeSelectorUM = prevState.feeSelectorUM as? FeeSelectorUM.Content ?: return prevState
@ -34,11 +36,18 @@ internal class SendWithSwapConfirmationNotificationsTransformer : Transformer<Se
notifications = buildList {
addTooHighNotification(feeSelectorUM = feeSelectorUM)
addTooLowNotification(feeSelectorUM = feeSelectorUM)
addHighNetworkFeeNotification()
}.toPersistentList(),
),
)
}
private fun MutableList<NotificationUM>.addHighNetworkFeeNotification() {
if (isHighNetworkFee) {
add(NotificationUM.Warning.HighNetworkFee)
}
}
private fun MutableList<NotificationUM>.addTooLowNotification(feeSelectorUM: FeeSelectorUM.Content) {
if (checkIfCustomFeeTooLow(feeSelectorUM = feeSelectorUM)) {
add(NotificationUM.Warning.FeeTooLow)