From c9d5d65799a858ba5bdeac7c9de90db381eb2bdd Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 18 Aug 2022 12:49:06 +0400 Subject: [PATCH 1/6] Updated on 2026-08-14 --- .../features/details/ui/resetcard/ResetCardScreen.kt | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt index 2c07b092ad..eda04bf95c 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/resetcard/ResetCardScreen.kt @@ -2,6 +2,7 @@ package com.tangem.tap.features.details.ui.resetcard import androidx.compose.foundation.Image import androidx.compose.foundation.background +import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -86,11 +87,14 @@ fun ResetCardView( color = colorResource(id = R.color.text_secondary), ) - Spacer(modifier = modifier.size(44.dp)) + Spacer(modifier = modifier.size(28.dp)) Row( modifier = modifier .fillMaxWidth() - .padding(end = 20.dp), + .clickable( + onClick = { state.onAcceptWarningToggleClick(!state.accepted) }, + ) + .padding(top = 16.dp, bottom = 16.dp), ) { IconToggleButton( checked = state.accepted, @@ -117,10 +121,12 @@ fun ResetCardView( text = stringResource(id = R.string.reset_card_to_factory_warning_message), style = TangemTypography.body2, color = colorResource(id = R.color.text_secondary), + modifier = modifier + .padding(end = 20.dp), ) } - Spacer(modifier = modifier.size(32.dp)) + Spacer(modifier = modifier.size(16.dp)) Box( modifier = modifier .padding(start = 16.dp, end = 16.dp, bottom = 32.dp), From d0fe9b8b099c2b1684ff72b3e50d9482af216e56 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 16:58:03 +0400 Subject: [PATCH 2/6] Updated on 2026-08-14 --- .../tangem/tap/features/details/ui/details/DetailsScreen.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt index 24129ec514..e0b4f1f186 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/details/DetailsScreen.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.defaultMinSize import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height @@ -86,7 +87,7 @@ fun WalletConnectDetailsItem( ) { Row( modifier = modifier - .height(84.dp) + .defaultMinSize(minHeight = 84.dp) .fillMaxWidth() .clickable { onItemsClick(SettingsElement.WalletConnect) }, horizontalArrangement = Arrangement.Start, @@ -99,7 +100,7 @@ fun WalletConnectDetailsItem( tint = colorResource(id = R.color.all_colors_azure), ) Column( - modifier = modifier.height(56.dp), + modifier = modifier.defaultMinSize(minHeight = 56.dp), horizontalAlignment = Alignment.Start, verticalArrangement = Arrangement.Center, ) { From 90e5b0012ba2d6680dcc82bbbaf0859feadf4558 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 17:21:29 +0400 Subject: [PATCH 3/6] Updated on 2026-08-14 --- .../details/ui/walletconnect/WalletConnectScreen.kt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectScreen.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectScreen.kt index 8474878afc..168bd4a024 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectScreen.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/WalletConnectScreen.kt @@ -140,13 +140,12 @@ private fun WalletConnectSessions( horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically, ) { - Column(modifier = modifier) { - Text( - text = session.description, - style = TangemTypography.subtitle1, - color = colorResource(id = R.color.text_primary_1), - ) - } + Text( + text = session.description, + style = TangemTypography.subtitle1, + color = colorResource(id = R.color.text_primary_1), + modifier = modifier.weight(1f), + ) IconButton( onClick = { state.onRemoveSession(session.sessionId) }, ) { From 937011724fcc8242c3f90b8cbb874b22883cbcd4 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 17:30:00 +0400 Subject: [PATCH 4/6] Updated on 2026-08-14 --- .../domain/walletconnect/WalletConnectManager.kt | 14 ++++++++++++-- .../redux/walletconnect/WalletConnectAction.kt | 8 ++++++-- .../redux/walletconnect/WalletConnectMiddleware.kt | 12 ++++++++++++ app/src/main/res/values-de/strings_final.xml | 1 + app/src/main/res/values-fr/strings_final.xml | 1 + app/src/main/res/values-it/strings_final.xml | 1 + app/src/main/res/values-ru/strings_final.xml | 1 + app/src/main/res/values/strings_final.xml | 1 + 8 files changed, 35 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt index 45c3dee2e3..8a0362acb0 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectManager.kt @@ -57,7 +57,10 @@ class WalletConnectManager { private var sessions: MutableMap = mutableMapOf() fun connect(wcUri: String) { - val session = WCSession.from(wcUri) ?: return + val session = WCSession.from(wcUri).guard { + store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null, true)) + return + } if (sessions[session] != null) { store.dispatchOnMain(WalletConnectAction.RefuseOpeningSession) return @@ -65,7 +68,14 @@ class WalletConnectManager { val client = WCClient(httpClient = okHttpClient) setListeners(client) val peerId = UUID.randomUUID().toString() - client.connect(session, tangemPeerMeta, peerId) + + try { + client.connect(session, tangemPeerMeta, peerId) + } catch (exception: IllegalArgumentException) { + store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null, true)) + return + } + sessions[session] = WalletConnectActiveData( peerId = peerId, remotePeerId = null, diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectAction.kt b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectAction.kt index 0258af7316..5947f349ef 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectAction.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectAction.kt @@ -52,7 +52,11 @@ sealed class WalletConnectAction : Action { val updatedSession: WalletConnectSession, ) : WalletConnectAction() - data class FailureEstablishingSession(val session: WCSession?) : WalletConnectAction() + data class FailureEstablishingSession( + val session: WCSession?, + val showWarning: Boolean = false, + ) : WalletConnectAction() + data class SetSessionsRestored(val sessions: List) : WalletConnectAction() @@ -103,6 +107,6 @@ sealed class WalletConnectAction : Action { data class Sign( val id: Long, val data: ByteArray, val sessionData: WCSession, - ) : WalletConnectAction() + ) : WalletConnectAction() } } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt index cad8f8ab14..9265253b3a 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectMiddleware.kt @@ -9,6 +9,7 @@ import com.tangem.domain.common.ScanResponse import com.tangem.domain.common.TapWorkarounds.derivationStyle import com.tangem.domain.common.extensions.withMainContext import com.tangem.tap.common.extensions.dispatchOnMain +import com.tangem.tap.common.redux.AppDialog import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.AppScreen @@ -22,6 +23,7 @@ import com.tangem.tap.features.demo.DemoHelper import com.tangem.tap.features.wallet.redux.WalletState import com.tangem.tap.scope import com.tangem.tap.store +import com.tangem.wallet.R import kotlinx.coroutines.launch import org.rekotlin.Action import org.rekotlin.Middleware @@ -99,6 +101,16 @@ class WalletConnectMiddleware { if (action.session != null) { walletConnectManager.disconnect(action.session) } + if (action.showWarning) { + store.dispatchOnMain( + GlobalAction.ShowDialog( + AppDialog.SimpleOkDialogRes( + headerId = R.string.common_warning, + messageId = R.string.wallet_connect_error_failed_to_connect, + ), + ), + ) + } } is WalletConnectAction.UnsupportedCard -> { store.dispatchOnMain(GlobalAction.ShowDialog(WalletConnectDialog.UnsupportedCard)) diff --git a/app/src/main/res/values-de/strings_final.xml b/app/src/main/res/values-de/strings_final.xml index f32a97ae89..08c0072255 100644 --- a/app/src/main/res/values-de/strings_final.xml +++ b/app/src/main/res/values-de/strings_final.xml @@ -88,4 +88,5 @@ Select network Scan your card To access all the networks you need to scan the card + Failed to establish WalletConnect session \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings_final.xml b/app/src/main/res/values-fr/strings_final.xml index ef550053ca..16105d506d 100644 --- a/app/src/main/res/values-fr/strings_final.xml +++ b/app/src/main/res/values-fr/strings_final.xml @@ -88,4 +88,5 @@ Select network Scan your card To access all the networks you need to scan the card + Failed to establish WalletConnect session \ No newline at end of file diff --git a/app/src/main/res/values-it/strings_final.xml b/app/src/main/res/values-it/strings_final.xml index ef550053ca..16105d506d 100644 --- a/app/src/main/res/values-it/strings_final.xml +++ b/app/src/main/res/values-it/strings_final.xml @@ -88,4 +88,5 @@ Select network Scan your card To access all the networks you need to scan the card + Failed to establish WalletConnect session \ No newline at end of file diff --git a/app/src/main/res/values-ru/strings_final.xml b/app/src/main/res/values-ru/strings_final.xml index b1ffa0ba10..225d7eb8cb 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -104,4 +104,5 @@ Сеть %s использует концепцию экзистенциального депозита. Если баланс вашего счета опустится ниже %s %s, он будет деактивирован, а все оставшиеся средства будут уничтожены. Отсканируйте карту Чтобы получить доступ ко всем сетям, вам необходимо отсканировать карту + Не удалось установить сессию WalletConnect diff --git a/app/src/main/res/values/strings_final.xml b/app/src/main/res/values/strings_final.xml index 4585bee0c1..bfa90d2130 100644 --- a/app/src/main/res/values/strings_final.xml +++ b/app/src/main/res/values/strings_final.xml @@ -101,4 +101,5 @@ Select network Scan your card To access all the networks you need to scan the card + Failed to establish WalletConnect session From d9f57b33b1fafd875c9d8ace2da413247ef8ee78 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 17:41:10 +0400 Subject: [PATCH 5/6] Updated on 2026-08-14 --- .../tap/features/wallet/redux/WalletState.kt | 35 +++++++++++-------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt index f81d4662a5..933ca823bc 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/WalletState.kt @@ -193,21 +193,28 @@ data class WalletState( fun removeWallet(walletData: WalletData?): WalletState { if (walletData == null) return this - return if (walletData.currency is Currency.Blockchain) { - val walletStores = wallets.filterNot { - it.blockchainNetwork.blockchain == walletData.currency.blockchain - && it.blockchainNetwork.derivationPath == walletData.currency.derivationPath + return when (val currency = walletData.currency) { + is Currency.Blockchain -> { + val walletStores = wallets.filterNot { + it.blockchainNetwork.blockchain == currency.blockchain + && it.blockchainNetwork.derivationPath == currency.derivationPath + } + copy(wallets = walletStores) + .updateTotalBalance() + .updateProgressState() + } + is Currency.Token -> { + val walletStore = getWalletStore(walletData.currency) + val walletDataList = walletStore?.walletsData + ?.filterNot { it.currency == walletData.currency } + ?: emptyList() + val updatedWalletManager = walletStore?.walletManager?.also { it.removeToken(currency.token) } + val updatedWalletStore = walletStore?.copy( + walletsData = walletDataList, + walletManager = updatedWalletManager, + ) + updateWalletStore(updatedWalletStore) } - copy(wallets = walletStores) - .updateTotalBalance() - .updateProgressState() - } else { - val walletStore = getWalletStore(walletData.currency) - val walletDataList = walletStore?.walletsData - ?.filterNot { it.currency == walletData.currency } - ?: emptyList() - val updatedWalletStore = walletStore?.copy(walletsData = walletDataList) - updateWalletStore(updatedWalletStore) } } From 5db29f6fea8458c9a8bac2fca9c31bfdd2915571 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 17:49:45 +0400 Subject: [PATCH 6/6] Updated on 2026-08-14 --- .../tap/features/wallet/ui/adapters/WalletAdapter.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt index af061d48f1..a688bb9e42 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/adapters/WalletAdapter.kt @@ -110,8 +110,12 @@ class WalletAdapter lContent.tvExchangeRate.text = wallet.fiatRateString ?: root.getString(id = R.string.token_item_no_rate) - cardWallet.setOnClickListener { - store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet)) + if (wallet.walletAddresses != null) { + cardWallet.setOnClickListener { + store.dispatch(WalletAction.MultiWallet.SelectWallet(wallet)) + } + } else { + cardWallet.setOnClickListener(null) } } }