Updated on 2026-08-14
This commit is contained in:
parent
51e6f1d5a3
commit
3d9b107be6
6 changed files with 17 additions and 0 deletions
|
|
@ -23,6 +23,7 @@ sealed class FeeSelectorParams {
|
|||
abstract val feeDisplaySource: FeeDisplaySource
|
||||
abstract val analyticsCategoryName: String
|
||||
abstract val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource
|
||||
abstract val shouldShowOnlySpeedOption: Boolean
|
||||
|
||||
data class FeeSelectorBlockParams(
|
||||
override val state: FeeSelectorUM,
|
||||
|
|
@ -37,6 +38,7 @@ sealed class FeeSelectorParams {
|
|||
override val feeDisplaySource: FeeDisplaySource,
|
||||
override val analyticsCategoryName: String,
|
||||
override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource,
|
||||
override val shouldShowOnlySpeedOption: Boolean = false,
|
||||
val bottomSheetShown: (Boolean) -> Unit = {},
|
||||
) : FeeSelectorParams()
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ sealed class FeeSelectorParams {
|
|||
override val feeDisplaySource: FeeDisplaySource,
|
||||
override val analyticsCategoryName: String,
|
||||
override val analyticsSendSource: CommonSendAnalyticEvents.CommonSendSource,
|
||||
override val shouldShowOnlySpeedOption: Boolean = false,
|
||||
val callback: FeeSelectorModelCallback,
|
||||
) : FeeSelectorParams()
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ internal class DefaultFeeSelectorBlockComponent @AssistedInject constructor(
|
|||
analyticsCategoryName = params.analyticsCategoryName,
|
||||
analyticsSendSource = params.analyticsSendSource,
|
||||
userWalletId = params.userWalletId,
|
||||
shouldShowOnlySpeedOption = model.shouldShowOnlySpeedOption,
|
||||
),
|
||||
onDismiss = {
|
||||
model.feeSelectorBottomSheet.dismiss()
|
||||
|
|
|
|||
|
|
@ -38,6 +38,8 @@ internal class FeeSelectorBlockModel @Inject constructor(
|
|||
modelScope = modelScope,
|
||||
)
|
||||
|
||||
val shouldShowOnlySpeedOption: Boolean
|
||||
get() = feeSelectorLogic.shouldShowOnlySpeedOption.value
|
||||
val feeSelectorBottomSheet = SlotNavigation<Unit>()
|
||||
val uiState: StateFlow<FeeSelectorUM>
|
||||
field = feeSelectorLogic.uiState
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import dagger.assisted.AssistedFactory
|
|||
import dagger.assisted.AssistedInject
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
|
|
@ -68,6 +69,9 @@ internal class FeeSelectorLogic @AssistedInject constructor(
|
|||
isGaslessFeeSupportedForNetwork(params.feeCryptoCurrencyStatus.currency.network) &&
|
||||
params.cryptoCurrencyStatus.currency is CryptoCurrency.Token
|
||||
|
||||
val shouldShowOnlySpeedOption: StateFlow<Boolean>
|
||||
field = MutableStateFlow(params.shouldShowOnlySpeedOption)
|
||||
|
||||
init {
|
||||
initAppCurrency()
|
||||
subscribeOnFeeReloadTriggerUpdates()
|
||||
|
|
@ -253,12 +257,14 @@ internal class FeeSelectorLogic @AssistedInject constructor(
|
|||
is GetFeeError.GaslessError.NotEnoughFunds -> error.left()
|
||||
is GetFeeError.GaslessError -> {
|
||||
// Something wrong with gasless fee, fallback to basic fee
|
||||
shouldShowOnlySpeedOption.value = true
|
||||
params.onLoadFee().map { LoadedFeeResult.Basic(it) }
|
||||
}
|
||||
else -> error.left()
|
||||
}
|
||||
},
|
||||
ifRight = { fee ->
|
||||
shouldShowOnlySpeedOption.value = false
|
||||
populateExtendedFee(fee)
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ internal class FeeSelectorModel @Inject constructor(
|
|||
|
||||
fun getInitialRoute(): FeeSelectorRoute {
|
||||
return when {
|
||||
params.shouldShowOnlySpeedOption -> FeeSelectorRoute.ChooseSpeed
|
||||
feeSelectorLogic.isGaslessEnabled -> FeeSelectorRoute.NetworkFee
|
||||
else -> FeeSelectorRoute.ChooseSpeed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2161,6 +2161,10 @@ internal class SwapModel @Inject constructor(
|
|||
val toToken = dataState.toCryptoCurrency ?: return Either.Left(GetFeeError.UnknownError)
|
||||
val selectedProvider = dataStateStateFlow.first { it.selectedProvider != null }.selectedProvider!!
|
||||
|
||||
if (selectedProvider.type != ExchangeProviderType.CEX) {
|
||||
return Either.Left(GetFeeError.GaslessError.NetworkIsNotSupported)
|
||||
}
|
||||
|
||||
if (dataState.lastLoadedSwapStates[selectedProvider] !is SwapState.QuotesLoadedState) {
|
||||
return Either.Left(GetFeeError.UnknownError)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue