diff --git a/features/markets/impl/build.gradle.kts b/features/markets/impl/build.gradle.kts index 4f73123e32..87db7e37d6 100644 --- a/features/markets/impl/build.gradle.kts +++ b/features/markets/impl/build.gradle.kts @@ -14,6 +14,7 @@ android { dependencies { /* Project - API */ api(projects.features.markets.api) + api(projects.features.onramp.api) implementation(projects.core.navigation) /* Domain */ diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt index 34923a5f2d..ce9e2b7841 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/model/TokenActionsHandler.kt @@ -23,6 +23,7 @@ import com.tangem.features.markets.impl.R import com.tangem.features.markets.portfolio.impl.loader.PortfolioData import com.tangem.features.markets.portfolio.impl.ui.WarningDialog import com.tangem.features.markets.portfolio.impl.ui.state.TokenActionsBSContentUM +import com.tangem.features.onramp.OnrampFeatureToggles import com.tangem.utils.Provider import dagger.assisted.Assisted import dagger.assisted.AssistedFactory @@ -41,12 +42,15 @@ internal class TokenActionsHandler @AssistedInject constructor( @Assisted private val onHandleQuickAction: (HandledQuickAction) -> Unit, private val isDemoCardUseCase: IsDemoCardUseCase, private val messageSender: UiMessageSender, + private val onrampFeatureToggles: OnrampFeatureToggles, ) { - private val disabledActionsInDemoMode = setOf( - TokenActionsBSContentUM.Action.Buy, - TokenActionsBSContentUM.Action.Sell, - ) + private val disabledActionsInDemoMode = buildSet { + if (!onrampFeatureToggles.isFeatureEnabled) { + add(TokenActionsBSContentUM.Action.Buy) + } + add(TokenActionsBSContentUM.Action.Sell) + } fun handle(action: TokenActionsBSContentUM.Action, cryptoCurrencyData: PortfolioData.CryptoCurrencyData) { onHandleQuickAction( diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt index 55d9d5ecb8..6690f0a085 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/viewmodels/TokenDetailsViewModel.kt @@ -462,9 +462,8 @@ internal class TokenDetailsViewModel @Inject constructor( return } - showErrorIfDemoModeOrElse { - val status = cryptoCurrencyStatus ?: return@showErrorIfDemoModeOrElse - + val status = cryptoCurrencyStatus ?: return + if (onrampFeatureToggles.isFeatureEnabled) { viewModelScope.launch(dispatchers.main) { reduxStateHolder.dispatch( TradeCryptoAction.Buy( @@ -475,6 +474,19 @@ internal class TokenDetailsViewModel @Inject constructor( ), ) } + } else { + showErrorIfDemoModeOrElse { + viewModelScope.launch(dispatchers.main) { + reduxStateHolder.dispatch( + TradeCryptoAction.Buy( + userWallet = userWallet, + source = OnrampSource.TOKEN_DETAILS, + cryptoCurrencyStatus = status, + appCurrencyCode = selectedAppCurrencyFlow.value.code, + ), + ) + } + } } }