Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-07 15:49:08 +02:00
parent b7ea0b5d2c
commit c6c7cf61ab
14 changed files with 241 additions and 90 deletions

View file

@ -1,6 +1,7 @@
package com.tangem.domain.onramp.analytics
import com.tangem.core.analytics.models.AnalyticsEvent
import com.tangem.core.analytics.models.AnalyticsParam.Key.BLOCKCHAIN
import com.tangem.core.analytics.models.AnalyticsParam.Key.ERROR_CODE
import com.tangem.core.analytics.models.AnalyticsParam.Key.ERROR_DESCRIPTION
import com.tangem.core.analytics.models.AnalyticsParam.Key.PAYMENT_METHOD
@ -208,4 +209,17 @@ sealed class OnrampAnalyticsEvent(
event = "Button - All Offers",
params = emptyMap(),
)
data class NoticeBuyNotSupported(
private val source: OnrampSource,
private val tokenSymbol: String,
private val blockchain: String,
) : OnrampAnalyticsEvent(
event = "Notice - Buy Not Supported",
params = mapOf(
SOURCE to source.analyticsName,
TOKEN_PARAM to tokenSymbol,
BLOCKCHAIN to blockchain,
),
)
}

View file

@ -54,37 +54,6 @@ internal open class BaseActionsFactory(
}
}
/**
* Determines the unavailability reason for the BUY action
*
* @param userWallet the user's cold wallet
* @param currency the cryptocurrency to check
* @param requirementsDeferred a deferred object containing the asset requirements condition
*/
protected suspend fun getOnrampUnavailabilityReason(
userWallet: UserWallet,
currency: CryptoCurrency,
requirementsDeferred: Deferred<AssetRequirementsCondition?>?,
): ScenarioUnavailabilityReason {
// Start2Coin (S2C) are legacy single-currency cards that do not support buying crypto in-app
// (historically only Receive/Send were offered for them).
if (userWallet is UserWallet.Cold && userWallet.cardTypesResolver.isStart2Coin()) {
return ScenarioUnavailabilityReason.BuyUnavailable(currency.name)
}
val onrampUnavailabilityReason = rampStateManager.availableForBuy(
userWallet = userWallet,
cryptoCurrency = currency,
)
val shouldCheckAssetRequirements =
onrampUnavailabilityReason == ScenarioUnavailabilityReason.None && requirementsDeferred != null
return if (shouldCheckAssetRequirements) {
getReceiveScenario(requirementsDeferred.await())
} else {
onrampUnavailabilityReason
}
}
/**
* Determines the unavailability reason for the SEND action
*

View file

@ -50,14 +50,6 @@ internal class CommonActionsFactory(
null
}
val onrampUnavailabilityReasonDeferred = async {
getOnrampUnavailabilityReason(
userWallet = userWallet,
currency = cryptoCurrencyStatus.currency,
requirementsDeferred = requirementsDeferred,
)
}
val sendUnavailabilityReasonDeferred = async {
getSendUnavailabilityReason(userWalletId = userWallet.walletId, cryptoCurrencyStatus = cryptoCurrencyStatus)
}
@ -99,7 +91,7 @@ internal class CommonActionsFactory(
// endregion
// region Buy
addBuyAction(reason = onrampUnavailabilityReasonDeferred.await())
addBuyAction(reason = ScenarioUnavailabilityReason.None)
// endregion
// region Sell

View file

@ -52,14 +52,6 @@ internal class OutdatedDataActionsFactory(
null
}
val onrampUnavailabilityReasonDeferred = async {
getOnrampUnavailabilityReason(
userWallet = userWallet,
currency = cryptoCurrencyStatus.currency,
requirementsDeferred = requirementsDeferred,
)
}
val sendUnavailabilityReasonDeferred = if (sources.networkSource == StatusSource.ACTUAL) {
async {
getSendUnavailabilityReason(
@ -87,7 +79,7 @@ internal class OutdatedDataActionsFactory(
// endregion
// region Buy
addBuyAction(reason = onrampUnavailabilityReasonDeferred.await())
addBuyAction(reason = ScenarioUnavailabilityReason.None)
// endregion
// region Stake

View file

@ -35,14 +35,6 @@ internal class UnreachableActionsFactory(
null
}
val onrampUnavailabilityReasonDeferred = async {
getOnrampUnavailabilityReason(
userWallet = userWallet,
currency = cryptoCurrencyStatus.currency,
requirementsDeferred = requirementsDeferred,
)
}
val hideTokenUnavailabilityReason = getTokenHideUnavailabilityReason(userWallet)
// endregion
@ -52,7 +44,7 @@ internal class UnreachableActionsFactory(
// endregion
// region Buy
addBuyAction(reason = onrampUnavailabilityReasonDeferred.await())
addBuyAction(reason = ScenarioUnavailabilityReason.None)
// endregion
// region Receive