Updated on 2026-08-14

This commit is contained in:
Tangem 2024-11-27 14:04:49 +05:00
parent 1a1cce4e70
commit 12146c8981
11 changed files with 51 additions and 12 deletions

View file

@ -94,6 +94,7 @@ dependencies {
implementation(projects.features.details.api)
implementation(projects.features.pushNotifications.api)
implementation(projects.features.markets.api)
implementation(projects.features.onramp.api)
/** Common modules */
implementation(projects.common.ui)

View file

@ -16,6 +16,8 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.analytics.TokenScreenAnalyticsEvent
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.feature.wallet.presentation.wallet.viewmodels.intents.WalletClickIntents
import com.tangem.features.onramp.OnrampFeatureToggles
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.firstOrNull
import kotlinx.coroutines.launch
@ -31,6 +33,8 @@ internal class WalletDeepLinksHandler @Inject constructor(
private val getFeePaidCryptoCurrencyStatusSyncUseCase: GetFeePaidCryptoCurrencyStatusSyncUseCase,
private val getNetworkCoinStatusUseCase: GetNetworkCoinStatusUseCase,
private val reduxStateHolder: ReduxStateHolder,
private val clickIntents: WalletClickIntents,
private val onrampFeatureToggles: OnrampFeatureToggles,
) {
private var deepLinksMap = mutableMapOf<UserWalletId, List<DeepLink>>()
@ -58,11 +62,11 @@ internal class WalletDeepLinksHandler @Inject constructor(
return buildList {
add(sellCurrencyDeepLink)
if (!userWallet.isMultiCurrency) {
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
add(
BuyCurrencyDeepLink(
onReceive = {
scope.launch { onBuyCurrencyDeepLink(userWallet) }
onReceive = { txId ->
scope.launch { onBuyCurrencyDeepLink(txId, userWallet) }
},
),
)
@ -102,10 +106,13 @@ internal class WalletDeepLinksHandler @Inject constructor(
}
}
private suspend fun onBuyCurrencyDeepLink(userWallet: UserWallet) {
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
private suspend fun onBuyCurrencyDeepLink(txId: String, userWallet: UserWallet) {
if (onrampFeatureToggles.isFeatureEnabled) {
clickIntents.onOnrampSuccessClick(txId)
} else {
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
}
}
private suspend fun findCryptoCurrencyStatus(

View file

@ -112,6 +112,10 @@ internal class DefaultWalletRouter(
)
}
override fun openOnrampSuccessScreen(txId: String) {
router.push(AppRoute.OnrampSuccess(txId))
}
override fun openUrl(url: String) {
urlOpener.openUrl(url)
}

View file

@ -38,6 +38,9 @@ internal interface InnerWalletRouter : WalletRouter {
/** Open onboarding screen */
fun openOnboardingScreen()
/** Open onramp success screen for [txId] */
fun openOnrampSuccessScreen(txId: String)
/** Open transaction history website by [url] */
fun openUrl(url: String)

View file

@ -34,6 +34,8 @@ internal interface WalletContentClickIntents {
fun onOrganizeTokensClick()
fun onOnrampSuccessClick(txId: String)
fun onDismissMarketsOnboarding()
fun onTokenItemClick(currencyStatus: CryptoCurrencyStatus)
@ -97,6 +99,10 @@ internal class WalletContentClickIntentsImplementor @Inject constructor(
router.openOrganizeTokensScreen(userWalletId = stateHolder.getSelectedWalletId())
}
override fun onOnrampSuccessClick(txId: String) {
router.openOnrampSuccessScreen(txId = txId)
}
override fun onDismissMarketsOnboarding() {
stateHolder.update { it.copy(showMarketsOnboarding = false) }
viewModelScope.launch {