diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/entity/WcConnectedAppInfoUM.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/entity/WcConnectedAppInfoUM.kt index 43f68a162b..0871ed2cba 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/entity/WcConnectedAppInfoUM.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/entity/WcConnectedAppInfoUM.kt @@ -8,6 +8,7 @@ data class WcConnectedAppInfoUM( val appIcon: String, val isVerified: Boolean, val verifiedDAppState: VerifiedDAppState, + val notification: WcAppInfoSecurityNotification? = null, val appSubtitle: String, val walletName: String, val networks: ImmutableList, diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcConnectedAppInfoModel.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcConnectedAppInfoModel.kt index d49fa80461..507f490f0d 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcConnectedAppInfoModel.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/model/WcConnectedAppInfoModel.kt @@ -17,6 +17,7 @@ import com.tangem.features.walletconnect.connections.entity.VerifiedDAppState import com.tangem.features.walletconnect.connections.entity.WcConnectedAppInfoUM import com.tangem.features.walletconnect.connections.entity.WcNetworkInfoItem import com.tangem.features.walletconnect.connections.entity.WcPrimaryButtonConfig +import com.tangem.features.walletconnect.connections.entity.WcAppInfoSecurityNotification import com.tangem.features.walletconnect.connections.model.transformers.WcAppSubtitleConverter import com.tangem.utils.coroutines.CoroutineDispatcherProvider import kotlinx.collections.immutable.toImmutableList @@ -75,6 +76,7 @@ internal class WcConnectedAppInfoModel @Inject constructor( enabled = true, onClick = { disconnect(session) }, ), + notification = extractNotificationInfo(session), onDismiss = ::dismiss, ) } @@ -82,6 +84,14 @@ internal class WcConnectedAppInfoModel @Inject constructor( } } + private fun extractNotificationInfo(session: WcSession): WcAppInfoSecurityNotification? { + return when (session.securityStatus) { + CheckDAppResult.SAFE -> null + CheckDAppResult.UNSAFE -> WcAppInfoSecurityNotification.SecurityRisk + CheckDAppResult.FAILED_TO_VERIFY -> WcAppInfoSecurityNotification.UnknownDomain + } + } + private fun extractVerifiedState(session: WcSession): VerifiedDAppState { return if (session.securityStatus == CheckDAppResult.SAFE) { VerifiedDAppState.Verified(onVerifiedClick = {}) diff --git a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/ui/WcConnectedAppInfoBS.kt b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/ui/WcConnectedAppInfoBS.kt index f46252eb10..95f99d2965 100644 --- a/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/ui/WcConnectedAppInfoBS.kt +++ b/features/walletconnect/impl/src/main/kotlin/com/tangem/features/walletconnect/connections/ui/WcConnectedAppInfoBS.kt @@ -21,14 +21,13 @@ import com.tangem.core.ui.components.SecondaryButton import com.tangem.core.ui.components.bottomsheets.TangemBottomSheetConfig import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheet import com.tangem.core.ui.components.bottomsheets.modal.TangemModalBottomSheetTitle +import com.tangem.core.ui.components.notifications.Notification import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringResourceSafe +import com.tangem.core.ui.res.TangemColorPalette import com.tangem.core.ui.res.TangemTheme import com.tangem.core.ui.res.TangemThemePreview -import com.tangem.features.walletconnect.connections.entity.VerifiedDAppState -import com.tangem.features.walletconnect.connections.entity.WcConnectedAppInfoUM -import com.tangem.features.walletconnect.connections.entity.WcNetworkInfoItem -import com.tangem.features.walletconnect.connections.entity.WcPrimaryButtonConfig +import com.tangem.features.walletconnect.connections.entity.* import com.tangem.features.walletconnect.impl.R import kotlinx.collections.immutable.ImmutableList import kotlinx.collections.immutable.persistentListOf @@ -73,6 +72,28 @@ private fun WcConnectedAppInfoBSContent(state: WcConnectedAppInfoUM, modifier: M .padding(top = 8.dp) .then(blocksModifier), ) + state.notification?.let { notification -> + val (containerColor, titleColor, iconTint) = when (notification) { + WcAppInfoSecurityNotification.SecurityRisk -> Triple( + TangemColorPalette.Amaranth.copy(alpha = 0.1F), + TangemTheme.colors.text.warning, + TangemTheme.colors.icon.warning, + ) + WcAppInfoSecurityNotification.UnknownDomain -> Triple( + null, + TangemTheme.colors.text.primary1, + TangemTheme.colors.icon.attention, + ) + } + Notification( + modifier = Modifier.padding(top = TangemTheme.dimens.spacing14), + config = notification.config, + containerColor = containerColor, + titleColor = titleColor, + subtitleColor = TangemTheme.colors.text.primary1, + iconTint = iconTint, + ) + } NetworksBlock( networks = state.networks, modifier = Modifier