From 6ac5724e56d9fee4c2142dd5796eae1ba6e332b3 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 18 Nov 2024 14:40:19 +0200 Subject: [PATCH] Updated on 2026-08-14 --- .../converters/TokenMarketInfoConverter.kt | 10 +++++----- .../tangem/domain/markets/TokenMarketInfo.kt | 18 +++++++++--------- .../analytics/MarketDetailsAnalyticsEvent.kt | 13 +++++++++++++ .../impl/model/MarketsTokenDetailsModel.kt | 13 ++++++++++++- .../model/converters/SecurityScoreConverter.kt | 12 ++++++------ .../converters/TokenMarketInfoConverter.kt | 6 ++++-- .../ui/components/SecurityScoreBottomSheet.kt | 4 ++-- .../ui/preview/SecurityScorePreviewData.kt | 8 ++++---- .../state/SecurityScoreBottomSheetContent.kt | 16 ++++++++-------- 9 files changed, 63 insertions(+), 37 deletions(-) diff --git a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt index 7910c58025..85afc94699 100644 --- a/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt +++ b/data/markets/src/main/java/com/tangem/data/markets/converters/TokenMarketInfoConverter.kt @@ -114,12 +114,12 @@ internal object TokenMarketInfoConverter : Converter, + val securityScoreProviderData: List, ) - data class ProviderData( + data class SecurityScoreProvider( val providerId: String, val providerName: String, - val urlData: ProviderUrlData?, + val urlData: UrlData?, val iconUrl: String, val securityScore: Float, val lastAuditDate: DateTime?, - ) - - data class ProviderUrlData( - val fullUrl: String, - val rootHost: String?, - ) + ) { + data class UrlData( + val fullUrl: String, + val rootHost: String?, + ) + } data class Links( val officialLinks: List?, diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt index 3216b03dd3..85d934fd13 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/analytics/MarketDetailsAnalyticsEvent.kt @@ -51,6 +51,19 @@ internal class MarketDetailsAnalyticsEvent( "Token" to token.symbol, ), ) + + fun securityScoreOpened() = MarketDetailsAnalyticsEvent( + event = "Security Score Info", + params = mapOf("Token" to token.symbol), + ) + + fun securityScoreProviderClicked(provider: String) = MarketDetailsAnalyticsEvent( + event = "Security Score Provider Clicked", + params = mapOf( + "Token" to token.symbol, + "Provider" to provider, + ), + ) } enum class IntervalType(val source: String) { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt index aa748cfe5f..b6d4827fda 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt @@ -88,8 +88,19 @@ internal class MarketsTokenDetailsModel @Inject constructor( // === Analytics === analyticsEventHandler.send(analyticsEventBuilder.linkClicked(linkTitle = link.title)) }, + onSecurityScoreInfoClick = { + showBottomSheet(it) + + // === Analytics === + analyticsEventHandler.send(analyticsEventBuilder.securityScoreOpened()) + }, onSecurityScoreProviderLinkClick = { - urlOpener.openUrl(it) + it.urlData?.fullUrl?.let { url -> + urlOpener.openUrl(url) + } + + // === Analytics === + analyticsEventHandler.send(analyticsEventBuilder.securityScoreProviderClicked(it.name)) }, // === Analytics === onPricePerformanceIntervalChanged = { diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt index 906842ebf0..aee019594a 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/SecurityScoreConverter.kt @@ -13,12 +13,12 @@ import com.tangem.utils.converter.Converter @Stable internal class SecurityScoreConverter( - private val onInfoClick: (SecurityScoreBottomSheetContent) -> Unit, - private val onSecurityScoreProviderLinkClick: (String) -> Unit, + private val onSecurityScoreInfoClick: (SecurityScoreBottomSheetContent) -> Unit, + private val onSecurityScoreProviderLinkClick: (SecurityScoreBottomSheetContent.SecurityScoreProviderUM) -> Unit, ) : Converter { override fun convert(value: TokenMarketInfo.SecurityData): SecurityScoreUM { - val ratingsCount = value.providerData.size + val ratingsCount = value.securityScoreProviderData.size return SecurityScoreUM( score = value.totalSecurityScore, description = pluralReference( @@ -27,11 +27,11 @@ internal class SecurityScoreConverter( formatArgs = wrappedList(ratingsCount), ), onInfoClick = { - onInfoClick( + onSecurityScoreInfoClick( SecurityScoreBottomSheetContent( title = resourceReference(R.string.markets_token_details_security_score), description = resourceReference(R.string.markets_token_details_security_score_description), - providers = value.providerData.map { + providers = value.securityScoreProviderData.map { SecurityScoreBottomSheetContent.SecurityScoreProviderUM( name = it.providerName, lastAuditDate = it.lastAuditDate?.let { date -> @@ -40,7 +40,7 @@ internal class SecurityScoreConverter( score = it.securityScore, urlData = it.urlData?.let { urlData -> - SecurityScoreBottomSheetContent.SecurityScoreProviderUrlData( + SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = urlData.fullUrl, rootHost = urlData.rootHost, ) diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt index d857983a3a..85c354906a 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/converters/TokenMarketInfoConverter.kt @@ -8,6 +8,7 @@ import com.tangem.domain.markets.TokenMarketInfo import com.tangem.features.markets.details.impl.ui.state.LinksUM import com.tangem.features.markets.details.impl.ui.state.ListedOnUM import com.tangem.features.markets.details.impl.ui.state.MarketsTokenDetailsUM +import com.tangem.features.markets.details.impl.ui.state.SecurityScoreBottomSheetContent import com.tangem.utils.Provider import com.tangem.utils.converter.Converter @@ -17,8 +18,9 @@ internal class TokenMarketInfoConverter( private val appCurrency: Provider, private val onInfoClick: (TangemBottomSheetConfigContent) -> Unit, private val onListedOnClick: (Int) -> Unit, + onSecurityScoreInfoClick: (SecurityScoreBottomSheetContent) -> Unit, onLinkClick: (LinksUM.Link) -> Unit, - onSecurityScoreProviderLinkClick: (String) -> Unit, + onSecurityScoreProviderLinkClick: (SecurityScoreBottomSheetContent.SecurityScoreProviderUM) -> Unit, onPricePerformanceIntervalChanged: (PriceChangeInterval) -> Unit, onInsightsIntervalChanged: (PriceChangeInterval) -> Unit, ) : Converter { @@ -30,7 +32,7 @@ internal class TokenMarketInfoConverter( ) private val securityScoreConverter = SecurityScoreConverter( - onInfoClick = onInfoClick, + onSecurityScoreInfoClick = onSecurityScoreInfoClick, onSecurityScoreProviderLinkClick = onSecurityScoreProviderLinkClick, ) private val pricePerformanceConverter = PricePerformanceConverter( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt index 69cf38aa34..6841aa66c0 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/components/SecurityScoreBottomSheet.kt @@ -86,7 +86,7 @@ internal fun SecurityScoreBottomSheet(config: TangemBottomSheetConfig) { @Composable private fun SecurityScoreProviderRow( providerUM: SecurityScoreBottomSheetContent.SecurityScoreProviderUM, - onLinkClick: (String) -> Unit, + onLinkClick: (SecurityScoreBottomSheetContent.SecurityScoreProviderUM) -> Unit, ) { Row( modifier = Modifier @@ -137,7 +137,7 @@ private fun SecurityScoreProviderRow( enabled = providerUM.urlData != null, indication = ripple(bounded = false), interactionSource = remember { MutableInteractionSource() }, - onClick = { providerUM.urlData?.let { onLinkClick(it.fullUrl) } }, + onClick = { onLinkClick(providerUM) }, ), ) { ScoreStarsBlock( diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/SecurityScorePreviewData.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/SecurityScorePreviewData.kt index 45e80ad9b7..d80e49af6c 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/SecurityScorePreviewData.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/preview/SecurityScorePreviewData.kt @@ -17,7 +17,7 @@ internal object SecurityScorePreviewData { name = "Moralis", lastAuditDate = "21.10.2024", score = 4.9F, - urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUrlData( + urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = "https://moralis.com/", rootHost = "moralis.com", ), @@ -27,7 +27,7 @@ internal object SecurityScorePreviewData { name = "Certik", lastAuditDate = "10.07.2024", score = 4.6F, - urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUrlData( + urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = "https://certik.com/", rootHost = "certik.com", ), @@ -37,7 +37,7 @@ internal object SecurityScorePreviewData { name = "Cyberscope", lastAuditDate = "25.06.2023", score = 4.5F, - urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUrlData( + urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = "https://cyberscope.com/", rootHost = "cyberscope.com", ), @@ -47,7 +47,7 @@ internal object SecurityScorePreviewData { name = "TokenInsight", lastAuditDate = "17.01.2022", score = 4.0F, - urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUrlData( + urlData = SecurityScoreBottomSheetContent.SecurityScoreProviderUM.UrlData( fullUrl = "https://tokeninsight.com/", rootHost = "tokeninsight.com", ), diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/SecurityScoreBottomSheetContent.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/SecurityScoreBottomSheetContent.kt index bfac7fcab1..ceb100bdfb 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/SecurityScoreBottomSheetContent.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/ui/state/SecurityScoreBottomSheetContent.kt @@ -7,19 +7,19 @@ internal data class SecurityScoreBottomSheetContent( val title: TextReference, val description: TextReference, val providers: List, - val onProviderLinkClick: (String) -> Unit, + val onProviderLinkClick: (SecurityScoreProviderUM) -> Unit, ) : TangemBottomSheetConfigContent { data class SecurityScoreProviderUM( val name: String, val lastAuditDate: String?, val score: Float, - val urlData: SecurityScoreProviderUrlData?, + val urlData: UrlData?, val iconUrl: String?, - ) - - data class SecurityScoreProviderUrlData( - val fullUrl: String, - val rootHost: String?, - ) + ) { + data class UrlData( + val fullUrl: String, + val rootHost: String?, + ) + } } \ No newline at end of file