From 08d3e18b3e7dbed970290a4370977a74c475f24d Mon Sep 17 00:00:00 2001 From: Tangem Date: Tue, 11 Mar 2025 10:02:52 +0300 Subject: [PATCH] Updated on 2026-08-14 --- .../exchangeServices/DefaultRampManager.kt | 8 ++++---- .../analytics/TokenScreenAnalyticsEvent.kt | 4 +++- .../viewmodels/TokenDetailsViewModel.kt | 17 +++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt b/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt index 8876d81ae9..ca9bb24e80 100644 --- a/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt +++ b/app/src/main/java/com/tangem/tap/network/exchangeServices/DefaultRampManager.kt @@ -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() } } diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenScreenAnalyticsEvent.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenScreenAnalyticsEvent.kt index e88a9c31ee..9e8a010f52 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenScreenAnalyticsEvent.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenScreenAnalyticsEvent.kt @@ -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 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 a20a2babfc..535d369528 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 @@ -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(