Updated on 2026-08-14

This commit is contained in:
Tangem 2025-03-11 10:02:52 +03:00
parent f9cc3decfb
commit 08d3e18b3e
3 changed files with 16 additions and 13 deletions

View file

@ -77,10 +77,6 @@ internal class DefaultRampManager(
catch = { raise(ScenarioUnavailabilityReason.NotSupportedBySellService(status.currency.name)) },
)
ensure(condition = sellSupportedByService) {
ScenarioUnavailabilityReason.NotSupportedBySellService(status.currency.name)
}
val reason = getSendUnavailabilityReason(userWalletId, status)
ensure(condition = reason is ScenarioUnavailabilityReason.None) {
@ -95,6 +91,10 @@ internal class DefaultRampManager(
}
}
ensure(condition = sellSupportedByService) {
ScenarioUnavailabilityReason.NotSupportedBySellService(status.currency.name)
}
Unit.right()
}
}

View file

@ -167,15 +167,17 @@ sealed class TokenScreenAnalyticsEvent(
private const val NO_QUOTE = "Quotes Unavailable"
private const val SINGLE_WALLET = "Single Wallet"
private const val LOADING = "Loading"
private const val ASSET_REQUIREMENT = "AssetRequirement"
@Suppress("CyclomaticComplexMethod")
fun ScenarioUnavailabilityReason.toReasonAnalyticsText(): String {
return when (this) {
is ScenarioUnavailabilityReason.BuyUnavailable,
is ScenarioUnavailabilityReason.NotExchangeable,
is ScenarioUnavailabilityReason.NotSupportedBySellService,
is ScenarioUnavailabilityReason.StakingUnavailable,
ScenarioUnavailabilityReason.UnassociatedAsset,
-> UNAVAILABLE
ScenarioUnavailabilityReason.UnassociatedAsset -> ASSET_REQUIREMENT
is ScenarioUnavailabilityReason.EmptyBalance -> EMPTY
is ScenarioUnavailabilityReason.PendingTransaction -> PENDING
ScenarioUnavailabilityReason.UsedOutdatedData -> CACHING

View file

@ -575,18 +575,19 @@ internal class TokenDetailsViewModel @Inject constructor(
override fun onReceiveClick(unavailabilityReason: ScenarioUnavailabilityReason) {
val networkAddress = cryptoCurrencyStatus?.value?.networkAddress ?: return
analyticsEventsHandler.send(
TokenScreenAnalyticsEvent.ButtonWithParams.ButtonReceive(
token = cryptoCurrency.symbol,
blockchain = cryptoCurrency.network.name,
status = unavailabilityReason.toReasonAnalyticsText(),
),
)
if (handleUnavailabilityReason(unavailabilityReason = unavailabilityReason)) {
return
}
viewModelScope.launch(dispatchers.main) {
analyticsEventsHandler.send(
TokenScreenAnalyticsEvent.ButtonWithParams.ButtonReceive(
token = cryptoCurrency.symbol,
blockchain = cryptoCurrency.network.name,
status = unavailabilityReason.toReasonAnalyticsText(),
),
)
viewModelScope.launch {
analyticsEventsHandler.send(TokenReceiveAnalyticsEvent.ReceiveScreenOpened(cryptoCurrency.symbol))
internalUiState.value = stateFactory.getStateWithReceiveBottomSheet(