Updated on 2026-08-14

This commit is contained in:
Tangem 2025-07-25 20:30:38 +05:00
parent 7de53d6b0c
commit 706cb18444
11 changed files with 72 additions and 44 deletions

View file

@ -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 = {

View file

@ -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,
),

View file

@ -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<FeeItem> {
val fees = mutableListOf<FeeItem>()
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<FeeItem>.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<FeeItem>.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<FeeItem>.addFeeItemSuggested(
feeStateConfiguration: FeeSelectorParams.FeeStateConfiguration.Suggestion,
) {
add(
FeeItem.Suggested(
title = feeStateConfiguration.title,
fee = feeStateConfiguration.fee,
),
)
}
private fun constructCustomFee(): FeeItem.Custom? {
val customFeeFields = customFeeFieldConverter.convert(normalFee)

View file

@ -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<FeeSelectorUM> {
private val feeItemsConverter = FeeItemConverter(
suggestedFeeState = suggestedFeeState,
feeStateConfiguration = feeStateConfiguration,
normalFee = fees.normal,
feeSelectorIntents = feeSelectorIntents,
appCurrency = appCurrency,

View file

@ -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,

View file

@ -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 {