diff --git a/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt b/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt index 09c66ed8c8..a2eed383f5 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/notifications/ExpressNotificationsUM.kt @@ -6,23 +6,27 @@ import com.tangem.core.ui.extensions.resourceReference object ExpressNotificationsUM { - data class NeedVerification(val onGoToProviderClick: () -> Unit) : NotificationUM.Warning( + data class NeedVerification(val onGoToProviderClick: (() -> Unit)?) : NotificationUM.Warning( title = resourceReference(R.string.express_exchange_notification_verification_title), subtitle = resourceReference(R.string.express_exchange_notification_verification_text), iconResId = R.drawable.ic_alert_triangle_20, - buttonsState = NotificationConfig.ButtonsState.SecondaryButtonConfig( - text = resourceReference(R.string.common_go_to_provider), - onClick = onGoToProviderClick, - ), + buttonsState = onGoToProviderClick?.let { onClick -> + NotificationConfig.ButtonsState.SecondaryButtonConfig( + text = resourceReference(R.string.common_go_to_provider), + onClick = onClick, + ) + }, ) - data class FailedByProvider(val onGoToProviderClick: () -> Unit) : NotificationUM.Error( + data class FailedByProvider(val onGoToProviderClick: (() -> Unit)?) : NotificationUM.Error( title = resourceReference(R.string.express_exchange_notification_failed_title), subtitle = resourceReference(R.string.express_exchange_notification_failed_text), iconResId = R.drawable.ic_alert_circle_24, - buttonState = NotificationConfig.ButtonsState.SecondaryButtonConfig( - text = resourceReference(R.string.common_go_to_provider), - onClick = onGoToProviderClick, - ), + buttonState = onGoToProviderClick?.let { onClick -> + NotificationConfig.ButtonsState.SecondaryButtonConfig( + text = resourceReference(R.string.common_go_to_provider), + onClick = onClick, + ) + }, ) } \ No newline at end of file diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenOnrampAnalyticsEvent.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenOnrampAnalyticsEvent.kt index 50eaec64e5..69ba4f794b 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenOnrampAnalyticsEvent.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/analytics/TokenOnrampAnalyticsEvent.kt @@ -1,7 +1,6 @@ package com.tangem.domain.tokens.model.analytics import com.tangem.core.analytics.models.AnalyticsEvent -import com.tangem.core.analytics.models.AnalyticsParam.Key.CURRENCY import com.tangem.core.analytics.models.AnalyticsParam.Key.PROVIDER import com.tangem.core.analytics.models.AnalyticsParam.Key.STATUS import com.tangem.core.analytics.models.AnalyticsParam.Key.TOKEN_PARAM @@ -16,7 +15,7 @@ class TokenOnrampAnalyticsEvent( params = mapOf( TOKEN_PARAM to tokenSymbol, PROVIDER to provider, - CURRENCY to fiatCurrency, + "Currency Type" to fiatCurrency, ), ) @@ -27,7 +26,7 @@ class TokenOnrampAnalyticsEvent( TOKEN_PARAM to tokenSymbol, STATUS to status, PROVIDER to provider, - CURRENCY to fiatCurrency, + "Currency Type" to fiatCurrency, ), ) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/confirmresidency/DefaultConfirmResidencyComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/confirmresidency/DefaultConfirmResidencyComponent.kt index e7f8a4d6dc..0e1ea2888c 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/confirmresidency/DefaultConfirmResidencyComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/confirmresidency/DefaultConfirmResidencyComponent.kt @@ -70,12 +70,14 @@ internal class DefaultConfirmResidencyComponent @AssistedInject constructor( context = childByContext(componentContext), params = SelectCountryComponent.Params( cryptoCurrency = params.cryptoCurrency, - onDismiss = { + onDismiss = { isCountrySelected -> // Dismiss country select sheet model.bottomSheetNavigation.dismiss() - // Dismiss confirm residency sheet - config.onDismiss() + if (isCountrySelected) { + // Dismiss confirm residency sheet + config.onDismiss() + } }, ), ) diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/DefaultSelectCountryComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/DefaultSelectCountryComponent.kt index fa24e2dc0f..0cc50766e3 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/DefaultSelectCountryComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/DefaultSelectCountryComponent.kt @@ -25,7 +25,7 @@ internal class DefaultSelectCountryComponent @AssistedInject constructor( private val model: OnrampSelectCountryModel = getOrCreateModel(params) override fun dismiss() { - model.dismiss() + model.dismiss(isCountrySelected = false) } @Composable diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt index ba72314dd6..8abf849546 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/SelectCountryComponent.kt @@ -6,7 +6,7 @@ import com.tangem.domain.tokens.model.CryptoCurrency internal interface SelectCountryComponent : ComposableBottomSheetComponent { - data class Params(val cryptoCurrency: CryptoCurrency, val onDismiss: () -> Unit) + data class Params(val cryptoCurrency: CryptoCurrency, val onDismiss: (Boolean) -> Unit) interface Factory : ComponentFactory } \ No newline at end of file diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/model/OnrampSelectCountryModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/model/OnrampSelectCountryModel.kt index d7e2a1c6ad..94296a59e1 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/model/OnrampSelectCountryModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/selectcountry/model/OnrampSelectCountryModel.kt @@ -60,8 +60,8 @@ internal class OnrampSelectCountryModel @Inject constructor( modelScope.launch { subscribeOnUpdateState() } } - fun dismiss() { - params.onDismiss() + fun dismiss(isCountrySelected: Boolean) { + params.onDismiss(isCountrySelected) } private suspend fun subscribeOnUpdateState() { @@ -92,7 +92,7 @@ internal class OnrampSelectCountryModel @Inject constructor( analyticsEventHandler.send(OnrampAnalyticsEvent.OnResidenceChosen(country.name)) modelScope.launch { saveDefaultCountryUseCase.invoke(country) - dismiss() + dismiss(isCountrySelected = true) } } diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt index 36999376a3..a3c7234332 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/settings/DefaultOnrampSettingsComponent.kt @@ -53,7 +53,7 @@ internal class DefaultOnrampSettingsComponent @AssistedInject constructor( context = childByContext(componentContext), params = SelectCountryComponent.Params( params.cryptoCurrency, - model.bottomSheetNavigation::dismiss, + onDismiss = { model.bottomSheetNavigation.dismiss() }, ), ) } diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt index 435ced42ba..834e4fb850 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/entity/conterter/SetOnrampSuccessContentConverter.kt @@ -52,22 +52,27 @@ internal class SetOnrampSuccessContentConverter( } private fun getNotification(status: OnrampStatus.Status, externalTxUrl: String?): NotificationUM? { - if (externalTxUrl == null) return null return when (status) { OnrampStatus.Status.Verifying -> { - ExpressNotificationsUM.NeedVerification { - goToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.NeedVerification( + onGoToProviderClick = onProviderClick(externalTxUrl), + ) } OnrampStatus.Status.Failed -> { - ExpressNotificationsUM.FailedByProvider { - goToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.FailedByProvider( + onGoToProviderClick = onProviderClick(externalTxUrl), + ) } else -> null } } + private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) { + { goToProviderClick(externalTxUrl) } + } else { + null + } + private fun convertStatuses(status: OnrampStatus.Status, externalTxUrl: String?): ExpressStatusUM { val statuses = with(status) { persistentListOf( diff --git a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/model/OnrampSuccessComponentModel.kt b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/model/OnrampSuccessComponentModel.kt index 03cf4aa0e3..34f4ff9f39 100644 --- a/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/model/OnrampSuccessComponentModel.kt +++ b/features/onramp/impl/src/main/kotlin/com/tangem/features/onramp/success/model/OnrampSuccessComponentModel.kt @@ -79,10 +79,17 @@ internal class OnrampSuccessComponentModel @Inject constructor( } private suspend fun loadTransactionStatus(transaction: OnrampTransaction) { - val cryptoCurrency = getCryptoCurrencyUseCase( + val multiCryptoCurrency = getCryptoCurrencyUseCase( transaction.userWalletId, transaction.toCurrencyId, - ).getOrElse { error("Crypto currency not found") } + ).getOrNull() + + val cryptoCurrency = multiCryptoCurrency + ?: getCryptoCurrencyUseCase.invoke(transaction.userWalletId).getOrElse { + Timber.e("Crypto currency not found") + showErrorAlert(OnrampError.DomainError(null)) + return + } getOnrampStatusUseCase(txId = transaction.txId) .fold( diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt index 9fc0a051b5..3b8d00da73 100644 --- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt +++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/factory/TokenDetailsOnrampTransactionStateConverter.kt @@ -108,23 +108,24 @@ internal class TokenDetailsOnrampTransactionStateConverter( externalTxUrl: String?, providerName: String, ): NotificationUM? { - if (externalTxUrl == null) return null return when (status) { OnrampStatus.Status.Verifying -> { analyticsEventHandler.send(TokenOnrampAnalyticsEvent.NoticeKYC(cryptoCurrency.symbol, providerName)) - ExpressNotificationsUM.NeedVerification { - clickIntents.onGoToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.NeedVerification(onGoToProviderClick = onProviderClick(externalTxUrl)) } OnrampStatus.Status.Failed -> { - ExpressNotificationsUM.FailedByProvider { - clickIntents.onGoToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.FailedByProvider(onGoToProviderClick = onProviderClick(externalTxUrl)) } else -> null } } + private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) { + { clickIntents.onGoToProviderClick(externalTxUrl) } + } else { + null + } + private fun getIconState(status: OnrampStatus.Status): ExpressTransactionStateIconUM { return when (status) { OnrampStatus.Status.Verifying -> ExpressTransactionStateIconUM.Warning diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/OnrampStatusFactory.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/OnrampStatusFactory.kt index 8387de10c1..7686df2258 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/OnrampStatusFactory.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/domain/OnrampStatusFactory.kt @@ -67,7 +67,7 @@ internal class OnrampStatusFactory @Inject constructor( analyticsEventHandler.send( TokenOnrampAnalyticsEvent.OnrampStatusChanged( tokenSymbol = onrampTx.info.toAmountSymbol, - status = status.name, + status = status.value, provider = onrampTx.providerName, fiatCurrency = onrampTx.fromCurrencyCode, ), diff --git a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt index f6443b6ed5..606d0ed064 100644 --- a/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt +++ b/features/wallet/impl/src/main/java/com/tangem/feature/wallet/presentation/wallet/state/transformers/converter/SingleWalletOnrampTransactionConverter.kt @@ -117,25 +117,30 @@ internal class SingleWalletOnrampTransactionConverter( externalTxUrl: String?, providerName: String, ): NotificationUM? { - if (externalTxUrl == null) return null return when (status) { OnrampStatus.Status.Verifying -> { analyticsEventHandler.send( TokenOnrampAnalyticsEvent.NoticeKYC(currency.symbol, providerName), ) - ExpressNotificationsUM.NeedVerification { - clickIntents.onGoToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.NeedVerification( + onGoToProviderClick = onProviderClick(externalTxUrl), + ) } OnrampStatus.Status.Failed -> { - ExpressNotificationsUM.FailedByProvider { - clickIntents.onGoToProviderClick(externalTxUrl) - } + ExpressNotificationsUM.FailedByProvider( + onGoToProviderClick = onProviderClick(externalTxUrl), + ) } else -> null } } + private fun onProviderClick(externalTxUrl: String?) = if (externalTxUrl != null) { + { clickIntents.onGoToProviderClick(externalTxUrl) } + } else { + null + } + private fun getIconState(status: OnrampStatus.Status): ExpressTransactionStateIconUM { return when (status) { OnrampStatus.Status.Verifying -> ExpressTransactionStateIconUM.Warning