Updated on 2026-08-14

This commit is contained in:
Tangem 2025-04-29 16:50:04 +05:00
parent 8619b424f5
commit f955a8d40b
10 changed files with 26 additions and 62 deletions

View file

@ -3,19 +3,16 @@ package com.tangem.core.deeplink.global
import com.tangem.core.deeplink.DeepLink
class BuyCurrencyDeepLink(
val onReceive: (txId: String) -> Unit,
val onReceive: () -> Unit,
) : DeepLink() {
override val uri = BUY_REDIRECT_DEEPLINK
override fun onReceive(params: Map<String, String>) {
onReceive(
params["merchant_transaction_id"] ?: return,
)
onReceive()
}
companion object {
const val ONRAMP_REDIRECT_DEEPLINK = "https://tangem.com/success?action=dismissBrowser"
private const val BUY_REDIRECT_DEEPLINK = "tangem://redirect?action=dismissBrowser"
}
}

View file

@ -2,7 +2,6 @@ package com.tangem.data.onramp
import com.squareup.moshi.Moshi
import com.tangem.blockchain.extensions.toBigDecimalOrDefault
import com.tangem.core.deeplink.global.BuyCurrencyDeepLink
import com.tangem.data.common.api.safeApiCall
import com.tangem.data.onramp.converters.CountryConverter
import com.tangem.data.onramp.converters.CurrencyConverter
@ -363,7 +362,7 @@ internal class DefaultOnrampRepository(
toDecimals = cryptoCurrency.decimals,
providerId = quote.provider.id,
toAddress = address,
redirectUrl = BuyCurrencyDeepLink.ONRAMP_REDIRECT_DEEPLINK,
redirectUrl = "",
language = null,
theme = getTheme(isDarkTheme),
requestId = requestId,

View file

@ -16,6 +16,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.feature.tokendetails.presentation.tokendetails.model.TokenDetailsModel
import com.tangem.feature.tokendetails.presentation.tokendetails.ui.TokenDetailsScreen
import com.tangem.features.markets.token.block.TokenMarketBlockComponent
import com.tangem.features.onramp.OnrampFeatureToggles
import com.tangem.features.tokendetails.TokenDetailsComponent
import com.tangem.features.txhistory.TxHistoryFeatureToggles
import com.tangem.features.txhistory.component.TxHistoryComponent
@ -23,12 +24,14 @@ import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
@Suppress("LongParameterList")
internal class DefaultTokenDetailsComponent @AssistedInject constructor(
@Assisted appComponentContext: AppComponentContext,
@Assisted params: TokenDetailsComponent.Params,
tokenMarketBlockComponentFactory: TokenMarketBlockComponent.Factory,
txHistoryComponentFactory: TxHistoryComponent.Factory,
txHistoryFeatureToggles: TxHistoryFeatureToggles,
onrampFeatureToggles: OnrampFeatureToggles,
deepLinksRegistry: DeepLinksRegistry,
) : TokenDetailsComponent, AppComponentContext by appComponentContext {
@ -48,11 +51,19 @@ internal class DefaultTokenDetailsComponent @AssistedInject constructor(
onResume = model::onResume,
)
val deeplinks = buildList {
if (!onrampFeatureToggles.isFeatureEnabled) {
add(
BuyCurrencyDeepLink(
onReceive = model::onBuyCurrencyDeepLink,
),
)
}
}
registerDeepLinks(
registry = deepLinksRegistry,
BuyCurrencyDeepLink(
onReceive = model::onBuyCurrencyDeepLink,
),
deeplinks,
)
}

View file

@ -46,15 +46,4 @@ internal class DefaultTokenDetailsRouter @Inject constructor(
),
)
}
override fun openOnrampSuccess(txId: String) {
// finish current onramp flow and show onramp success screen
val replaceOnrampScreens = router.stack
.filterNot { it is AppRoute.Onramp }
.toMutableList()
replaceOnrampScreens.add(AppRoute.OnrampSuccess(txId))
router.replaceAll(*replaceOnrampScreens.toTypedArray())
}
}

View file

@ -17,6 +17,4 @@ internal interface InnerTokenDetailsRouter {
fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency)
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yieldId: String)
fun openOnrampSuccess(txId: String)
}

View file

@ -195,13 +195,9 @@ internal class TokenDetailsModel @Inject constructor(
handleBalanceHiding()
}
fun onBuyCurrencyDeepLink(txId: String) {
if (onrampFeatureToggles.isFeatureEnabled) {
router.openOnrampSuccess(txId)
} else {
val currency = cryptoCurrencyStatus?.currency ?: return
analyticsEventsHandler.send(TokenScreenAnalyticsEvent.Bought(currency.symbol))
}
fun onBuyCurrencyDeepLink() {
val currency = cryptoCurrencyStatus?.currency ?: return
analyticsEventsHandler.send(TokenScreenAnalyticsEvent.Bought(currency.symbol))
}
fun onPause() {

View file

@ -38,8 +38,6 @@ internal interface WalletContentClickIntents {
fun onOrganizeTokensClick()
fun onOnrampSuccessClick(txId: String)
fun onDismissMarketsOnboarding()
fun onTokenItemClick(currencyStatus: CryptoCurrencyStatus)
@ -116,10 +114,6 @@ 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) }
modelScope.launch {

View file

@ -11,7 +11,6 @@ import com.tangem.domain.tokens.GetCryptoCurrencyUseCase
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.child.wallet.model.intents.WalletClickIntents
import com.tangem.features.onramp.OnrampFeatureToggles
import com.tangem.utils.coroutines.launchOnCancellation
import kotlinx.coroutines.CoroutineScope
@ -24,7 +23,6 @@ internal class WalletDeepLinksHandler @Inject constructor(
private val deepLinksRegistry: DeepLinksRegistry,
private val analyticsEventHandler: AnalyticsEventHandler,
private val getCryptoCurrencyUseCase: GetCryptoCurrencyUseCase,
private val clickIntents: WalletClickIntents,
private val onrampFeatureToggles: OnrampFeatureToggles,
private val router: AppRouter,
) {
@ -55,11 +53,11 @@ internal class WalletDeepLinksHandler @Inject constructor(
return buildList {
add(sellCurrencyDeepLink)
if (onrampFeatureToggles.isFeatureEnabled || !userWallet.isMultiCurrency) {
if (!onrampFeatureToggles.isFeatureEnabled && !userWallet.isMultiCurrency) {
add(
BuyCurrencyDeepLink(
onReceive = { externalTxId ->
scope.launch { onBuyCurrencyDeepLink(externalTxId, userWallet) }
onReceive = {
scope.launch { onBuyCurrencyDeepLink(userWallet) }
},
),
)
@ -87,12 +85,8 @@ internal class WalletDeepLinksHandler @Inject constructor(
router.push(route)
}
private suspend fun onBuyCurrencyDeepLink(externalTxId: String, userWallet: UserWallet) {
if (onrampFeatureToggles.isFeatureEnabled) {
clickIntents.onOnrampSuccessClick(externalTxId)
} else {
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
}
private suspend fun onBuyCurrencyDeepLink(userWallet: UserWallet) {
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId).getOrNull() ?: return
analyticsEventHandler.send(TokenScreenAnalyticsEvent.Bought(cryptoCurrency.symbol))
}
}

View file

@ -58,17 +58,6 @@ internal class DefaultWalletRouter @Inject constructor(
)
}
override fun openOnrampSuccessScreen(txId: String) {
// finish current onramp flow and show onramp success screen
val replaceOnrampScreens = router.stack
.filterNot { it is AppRoute.Onramp }
.toMutableList()
replaceOnrampScreens.add(AppRoute.OnrampSuccess(txId))
router.replaceAll(*replaceOnrampScreens.toTypedArray())
}
override fun openUrl(url: String) {
urlOpener.openUrl(url)
}

View file

@ -34,9 +34,6 @@ internal interface InnerWalletRouter {
/** Open onboarding screen */
fun openOnboardingScreen(scanResponse: ScanResponse, continueBackup: Boolean = false)
/** Open onramp success screen for [txId] */
fun openOnrampSuccessScreen(txId: String)
/** Open transaction history website by [url] */
fun openUrl(url: String)