From 706cb18444374fa4e4315ea44f229ca9195ec776 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 25 Jul 2025 20:30:38 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../send/v2/api/params/FeeSelectorParams.kt | 14 ++-- .../DefaultFeeSelectorBlockComponent.kt | 2 +- .../v2/feeselector/model/FeeSelectorModel.kt | 2 +- .../model/transformers/FeeItemConverter.kt | 66 +++++++++++++------ .../FeeSelectorLoadedTransformer.kt | 4 +- .../v2/send/confirm/SendConfirmComponent.kt | 2 +- .../v2/send/confirm/model/SendConfirmModel.kt | 6 +- .../confirm/SendWithSwapConfirmComponent.kt | 8 +-- .../components/common/WcNavigationUtils.kt | 2 +- .../send/WcSendTransactionComponent.kt | 2 +- .../model/WcSendTransactionModel.kt | 8 +-- 11 files changed, 72 insertions(+), 44 deletions(-) diff --git a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/params/FeeSelectorParams.kt b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/params/FeeSelectorParams.kt index 4eaa21bf65..94c63eef08 100644 --- a/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/params/FeeSelectorParams.kt +++ b/features/send-v2/api/src/main/java/com/tangem/features/send/v2/api/params/FeeSelectorParams.kt @@ -14,7 +14,7 @@ sealed class FeeSelectorParams { abstract val onLoadFee: suspend () -> Either abstract val cryptoCurrencyStatus: CryptoCurrencyStatus abstract val feeCryptoCurrencyStatus: CryptoCurrencyStatus - abstract val suggestedFeeState: SuggestedFeeState + abstract val feeStateConfiguration: FeeStateConfiguration abstract val feeDisplaySource: FeeDisplaySource data class FeeSelectorBlockParams( @@ -22,7 +22,7 @@ sealed class FeeSelectorParams { override val onLoadFee: suspend () -> Either, override val cryptoCurrencyStatus: CryptoCurrencyStatus, override val feeCryptoCurrencyStatus: CryptoCurrencyStatus, - override val suggestedFeeState: SuggestedFeeState, + override val feeStateConfiguration: FeeStateConfiguration, override val feeDisplaySource: FeeDisplaySource, ) : FeeSelectorParams() @@ -31,14 +31,16 @@ sealed class FeeSelectorParams { override val onLoadFee: suspend () -> Either, override val cryptoCurrencyStatus: CryptoCurrencyStatus, override val feeCryptoCurrencyStatus: CryptoCurrencyStatus, - override val suggestedFeeState: SuggestedFeeState, + override val feeStateConfiguration: FeeStateConfiguration, override val feeDisplaySource: FeeDisplaySource, val callback: FeeSelectorModelCallback, ) : FeeSelectorParams() - sealed class SuggestedFeeState { - data object None : SuggestedFeeState() - data class Suggestion(val title: TextReference, val fee: Fee) : SuggestedFeeState() + sealed class FeeStateConfiguration { + data object None : FeeStateConfiguration() + data class Suggestion(val title: TextReference, val fee: Fee) : FeeStateConfiguration() + + data object ExcludeLow : FeeStateConfiguration() } enum class FeeDisplaySource { diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/DefaultFeeSelectorBlockComponent.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/DefaultFeeSelectorBlockComponent.kt index 3e1665101c..54be595d0a 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/DefaultFeeSelectorBlockComponent.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/DefaultFeeSelectorBlockComponent.kt @@ -48,7 +48,7 @@ internal class DefaultFeeSelectorBlockComponent @AssistedInject constructor( feeCryptoCurrencyStatus = params.feeCryptoCurrencyStatus, cryptoCurrencyStatus = params.cryptoCurrencyStatus, callback = model, - suggestedFeeState = FeeSelectorParams.SuggestedFeeState.None, + feeStateConfiguration = params.feeStateConfiguration, feeDisplaySource = FeeSelectorParams.FeeDisplaySource.Screen, ), onDismiss = { diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/FeeSelectorModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/FeeSelectorModel.kt index 2175fa9e65..addccac202 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/FeeSelectorModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/FeeSelectorModel.kt @@ -94,7 +94,7 @@ internal class FeeSelectorModel @Inject constructor( feeCryptoCurrencyStatus = params.feeCryptoCurrencyStatus, appCurrency = appCurrency, fees = fee, - suggestedFeeState = params.suggestedFeeState, + feeStateConfiguration = params.feeStateConfiguration, isFeeApproximate = isFeeApproximate(fee.normal.amount.type), feeSelectorIntents = this@FeeSelectorModel, ), diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeItemConverter.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeItemConverter.kt index e8ef3fec18..864d53807d 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeItemConverter.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeItemConverter.kt @@ -12,7 +12,7 @@ import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.toImmutableList internal class FeeItemConverter( - private val suggestedFeeState: FeeSelectorParams.SuggestedFeeState, + private val feeStateConfiguration: FeeSelectorParams.FeeStateConfiguration, private val normalFee: Fee, private val feeSelectorIntents: FeeSelectorIntents, private val appCurrency: AppCurrency, @@ -29,32 +29,58 @@ internal class FeeItemConverter( override fun convert(value: Input): ImmutableList { val fees = mutableListOf() - when (suggestedFeeState) { - FeeSelectorParams.SuggestedFeeState.None -> Unit - is FeeSelectorParams.SuggestedFeeState.Suggestion -> fees.add( - FeeItem.Suggested( - title = suggestedFeeState.title, - fee = suggestedFeeState.fee, - ), - ) - } - when (value.transactionFee) { - is TransactionFee.Choosable -> { - fees.add(FeeItem.Slow(fee = value.transactionFee.minimum)) - fees.add(FeeItem.Market(fee = value.transactionFee.normal)) - fees.add(FeeItem.Fast(fee = value.transactionFee.priority)) + when (feeStateConfiguration) { + FeeSelectorParams.FeeStateConfiguration.None -> fees.addFeeItemsFull(value = value) + is FeeSelectorParams.FeeStateConfiguration.Suggestion -> { + fees.addFeeItemSuggested(feeStateConfiguration) + fees.addFeeItemsFull(value = value) } - is TransactionFee.Single -> { - fees.add(FeeItem.Market(fee = value.transactionFee.normal)) + FeeSelectorParams.FeeStateConfiguration.ExcludeLow -> { + fees.addFeeItemsLimited(value = value) } } - val customFee = value.customFee ?: constructCustomFee() - customFee?.let(fees::add) - return fees.toImmutableList() } + private fun MutableList.addFeeItemsFull(value: Input) { + when (value.transactionFee) { + is TransactionFee.Choosable -> { + add(FeeItem.Slow(fee = value.transactionFee.minimum)) + add(FeeItem.Market(fee = value.transactionFee.normal)) + add(FeeItem.Fast(fee = value.transactionFee.priority)) + } + is TransactionFee.Single -> { + add(FeeItem.Market(fee = value.transactionFee.normal)) + } + } + val customFee = value.customFee ?: constructCustomFee() + customFee?.let(::add) + } + + private fun MutableList.addFeeItemsLimited(value: Input) { + when (value.transactionFee) { + is TransactionFee.Choosable -> { + add(FeeItem.Market(fee = value.transactionFee.normal)) + add(FeeItem.Fast(fee = value.transactionFee.priority)) + } + is TransactionFee.Single -> { + add(FeeItem.Market(fee = value.transactionFee.normal)) + } + } + } + + private fun MutableList.addFeeItemSuggested( + feeStateConfiguration: FeeSelectorParams.FeeStateConfiguration.Suggestion, + ) { + add( + FeeItem.Suggested( + title = feeStateConfiguration.title, + fee = feeStateConfiguration.fee, + ), + ) + } + private fun constructCustomFee(): FeeItem.Custom? { val customFeeFields = customFeeFieldConverter.convert(normalFee) diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeSelectorLoadedTransformer.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeSelectorLoadedTransformer.kt index da024d61e6..b2b45f8a90 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeSelectorLoadedTransformer.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/feeselector/model/transformers/FeeSelectorLoadedTransformer.kt @@ -18,13 +18,13 @@ internal class FeeSelectorLoadedTransformer( private val feeCryptoCurrencyStatus: CryptoCurrencyStatus, private val appCurrency: AppCurrency, private val fees: TransactionFee, - private val suggestedFeeState: FeeSelectorParams.SuggestedFeeState, + private val feeStateConfiguration: FeeSelectorParams.FeeStateConfiguration, private val isFeeApproximate: Boolean, private val feeSelectorIntents: FeeSelectorIntents, ) : Transformer { private val feeItemsConverter = FeeItemConverter( - suggestedFeeState = suggestedFeeState, + feeStateConfiguration = feeStateConfiguration, normalFee = fees.normal, feeSelectorIntents = feeSelectorIntents, appCurrency = appCurrency, diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt index 3a1a55fd99..e98b5f4d20 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/SendConfirmComponent.kt @@ -102,7 +102,7 @@ internal class SendConfirmComponent( onLoadFee = params.onLoadFee, feeCryptoCurrencyStatus = params.feeCryptoCurrencyStatus, cryptoCurrencyStatus = params.cryptoCurrencyStatus, - suggestedFeeState = model.suggestedFeeState, + feeStateConfiguration = model.feeStateConfiguration, feeDisplaySource = FeeSelectorParams.FeeDisplaySource.Screen, ), onResult = model::onFeeResult, diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt index 2c6b6584a0..8dac9245d8 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt @@ -26,6 +26,7 @@ import com.tangem.domain.feedback.SendFeedbackEmailUseCase import com.tangem.domain.feedback.models.BlockchainErrorInfo import com.tangem.domain.feedback.models.FeedbackEmailType import com.tangem.domain.models.currency.CryptoCurrency +import com.tangem.domain.models.wallet.requireColdWallet import com.tangem.domain.settings.IsSendTapHelpEnabledUseCase import com.tangem.domain.settings.NeverShowTapHelpUseCase import com.tangem.domain.tokens.AddCryptoCurrenciesUseCase @@ -34,12 +35,11 @@ import com.tangem.domain.transaction.usecase.CreateTransferTransactionUseCase import com.tangem.domain.transaction.usecase.SendTransactionUseCase import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase import com.tangem.domain.utils.convertToSdkAmount -import com.tangem.domain.models.wallet.requireColdWallet import com.tangem.features.send.v2.api.SendNotificationsComponent import com.tangem.features.send.v2.api.SendNotificationsComponent.Params.NotificationData import com.tangem.features.send.v2.api.callbacks.FeeSelectorModelCallback import com.tangem.features.send.v2.api.entity.FeeNonce -import com.tangem.features.send.v2.api.params.FeeSelectorParams +import com.tangem.features.send.v2.api.params.FeeSelectorParams.FeeStateConfiguration import com.tangem.features.send.v2.api.subcomponents.destination.entity.DestinationUM import com.tangem.features.send.v2.api.subcomponents.feeSelector.FeeSelectorReloadTrigger import com.tangem.features.send.v2.api.subcomponents.notifications.SendNotificationsUpdateListener @@ -144,7 +144,7 @@ internal class SendConfirmModel @Inject constructor( private var sendIdleTimer: Long = 0L private var isAmountSubtractAvailable = false - internal var suggestedFeeState: FeeSelectorParams.SuggestedFeeState = FeeSelectorParams.SuggestedFeeState.None + internal var feeStateConfiguration: FeeStateConfiguration = FeeStateConfiguration.None init { modelScope.launch { diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt index 83b344621f..1d02dcce0c 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/SendWithSwapConfirmComponent.kt @@ -16,7 +16,7 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.features.send.v2.api.FeeSelectorBlockComponent import com.tangem.features.send.v2.api.SendNotificationsComponent import com.tangem.features.send.v2.api.entity.PredefinedValues -import com.tangem.features.send.v2.api.params.FeeSelectorParams +import com.tangem.features.send.v2.api.params.FeeSelectorParams.* import com.tangem.features.send.v2.api.subcomponents.destination.SendDestinationBlockComponent import com.tangem.features.send.v2.api.subcomponents.destination.SendDestinationComponentParams import com.tangem.features.swap.v2.impl.amount.SwapAmountBlockComponent @@ -80,13 +80,13 @@ internal class SendWithSwapConfirmComponent @AssistedInject constructor( private val feeSelectorBlockComponent = feeSelectorBlockComponentFactory.create( context = child("sendWithSwapConfirmFeeBlock"), - params = FeeSelectorParams.FeeSelectorBlockParams( + params = FeeSelectorBlockParams( state = model.uiState.value.feeSelectorUM, onLoadFee = model::loadFee, feeCryptoCurrencyStatus = model.primaryFeePaidCurrencyStatus, cryptoCurrencyStatus = model.primaryCurrencyStatus, - suggestedFeeState = FeeSelectorParams.SuggestedFeeState.None, - feeDisplaySource = FeeSelectorParams.FeeDisplaySource.Screen, + feeStateConfiguration = FeeStateConfiguration.ExcludeLow, + feeDisplaySource = FeeDisplaySource.Screen, ), onResult = model::onFeeResult, ) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/common/WcNavigationUtils.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/common/WcNavigationUtils.kt index 4ecb4fd6c9..d2a25d9cd4 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/common/WcNavigationUtils.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/common/WcNavigationUtils.kt @@ -48,7 +48,7 @@ internal fun getWcCommonScreen( feeCryptoCurrencyStatus = model.cryptoCurrencyStatus, cryptoCurrencyStatus = model.cryptoCurrencyStatus, callback = model, - suggestedFeeState = model.suggestedFeeState, + feeStateConfiguration = model.feeStateConfiguration, feeDisplaySource = FeeSelectorParams.FeeDisplaySource.BottomSheet, ), ) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/send/WcSendTransactionComponent.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/send/WcSendTransactionComponent.kt index 9448938815..eb105f2216 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/send/WcSendTransactionComponent.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/components/send/WcSendTransactionComponent.kt @@ -27,7 +27,7 @@ internal class WcSendTransactionComponent( onLoadFee = model::loadFee, cryptoCurrencyStatus = model.cryptoCurrencyStatus, feeCryptoCurrencyStatus = model.cryptoCurrencyStatus, - suggestedFeeState = model.suggestedFeeState, + feeStateConfiguration = model.feeStateConfiguration, feeDisplaySource = FeeSelectorParams.FeeDisplaySource.BottomSheet, ), onResult = model::updateFee, diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt index 27d97ceff8..463c89fc5a 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/transaction/model/WcSendTransactionModel.kt @@ -18,6 +18,7 @@ import com.tangem.core.ui.clipboard.ClipboardManager import com.tangem.core.ui.extensions.stringReference import com.tangem.domain.core.lce.Lce import com.tangem.domain.models.network.Network +import com.tangem.domain.models.wallet.UserWallet import com.tangem.domain.tokens.GetNetworkCoinStatusUseCase import com.tangem.domain.tokens.error.CurrencyStatusError import com.tangem.domain.tokens.model.CryptoCurrencyStatus @@ -28,10 +29,9 @@ import com.tangem.domain.walletconnect.WcRequestUseCaseFactory import com.tangem.domain.walletconnect.model.WcRequestError import com.tangem.domain.walletconnect.model.WcRequestError.Companion.message import com.tangem.domain.walletconnect.usecase.method.* -import com.tangem.domain.models.wallet.UserWallet import com.tangem.features.send.v2.api.callbacks.FeeSelectorModelCallback import com.tangem.features.send.v2.api.entity.FeeSelectorUM -import com.tangem.features.send.v2.api.params.FeeSelectorParams +import com.tangem.features.send.v2.api.params.FeeSelectorParams.FeeStateConfiguration import com.tangem.features.send.v2.api.subcomponents.feeSelector.FeeSelectorReloadTrigger import com.tangem.features.send.v2.api.subcomponents.feeSelector.entity.FeeSelectorData import com.tangem.features.walletconnect.connections.routing.WcInnerRoute @@ -77,7 +77,7 @@ internal class WcSendTransactionModel @Inject constructor( val stackNavigation = StackNavigation() internal var cryptoCurrencyStatus: CryptoCurrencyStatus by Delegates.notNull() - internal var suggestedFeeState: FeeSelectorParams.SuggestedFeeState = FeeSelectorParams.SuggestedFeeState.None + internal var feeStateConfiguration: FeeStateConfiguration = FeeStateConfiguration.None private var useCase: WcSignUseCase<*> by Delegates.notNull() private var signState: WcSignState<*> by Delegates.notNull() private var wcApproval: WcApproval? = null @@ -103,7 +103,7 @@ internal class WcSendTransactionModel @Inject constructor( (useCase as? WcMutableFee) ?.dAppFee() ?.let { dAppFee -> - suggestedFeeState = FeeSelectorParams.SuggestedFeeState.Suggestion( + feeStateConfiguration = FeeStateConfiguration.Suggestion( title = stringReference(useCase.session.sdkModel.appMetaData.name), fee = dAppFee, )