From c9d5d65799a858ba5bdeac7c9de90db381eb2bdd Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 18 Aug 2022 12:49:06 +0400 Subject: [PATCH 01/14] 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 1d536906ea166fc064b1db89c12a58497e46ff3a Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 21 Sep 2022 13:14:32 +0400 Subject: [PATCH 02/14] Updated on 2026-08-14 --- app/src/main/assets/testnet_tokens.json | 20 ++- .../tap/common/extensions/Blockchain.kt | 4 + .../res/drawable/ic_ethereumfair_no_color.xml | 40 +++++ .../res/drawable/ic_ethereumfair_round.xml | 40 +++++ .../res/drawable/ic_ethereumpow_no_color.xml | 31 ++++ .../res/drawable/ic_ethereumpow_round.xml | 166 ++++++++++++++++++ dependencies.gradle | 2 +- .../domain/common/extensions/Blockchain.kt | 8 + 8 files changed, 305 insertions(+), 6 deletions(-) create mode 100644 app/src/main/res/drawable/ic_ethereumfair_no_color.xml create mode 100644 app/src/main/res/drawable/ic_ethereumfair_round.xml create mode 100644 app/src/main/res/drawable/ic_ethereumpow_no_color.xml create mode 100644 app/src/main/res/drawable/ic_ethereumpow_round.xml diff --git a/app/src/main/assets/testnet_tokens.json b/app/src/main/assets/testnet_tokens.json index 84c055f105..e9e185e5f0 100644 --- a/app/src/main/assets/testnet_tokens.json +++ b/app/src/main/assets/testnet_tokens.json @@ -412,12 +412,22 @@ ] }, { - "id" : "stellar", - "symbol" : "XLM", - "name" : "Stellar", - "networks" : [ + "id": "stellar", + "symbol": "XLM", + "name": "Stellar", + "networks": [ { - "networkId" : "stellar/test" + "networkId": "stellar/test" + } + ] + }, + { + "id": "ethereum-pow-iou", + "symbol": "ETHW", + "name": "Ethereum PoW", + "networks": [ + { + "networkId": "ethereum-pow-iou/test" } ] } diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Blockchain.kt b/app/src/main/java/com/tangem/tap/common/extensions/Blockchain.kt index e2490e7886..3b12f0ec88 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Blockchain.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Blockchain.kt @@ -28,6 +28,8 @@ fun Blockchain.getRoundIconRes(): Int { Blockchain.Dogecoin -> R.drawable.ic_dogecoin_round Blockchain.Tron, Blockchain.TronTestnet -> R.drawable.ic_tron_round Blockchain.Gnosis -> R.drawable.ic_gnosis_round + Blockchain.EthereumPow, Blockchain.EthereumPowTestnet -> R.drawable.ic_ethereumpow_round + Blockchain.EthereumFair -> R.drawable.ic_ethereumfair_round else -> R.drawable.ic_tangem_logo } } @@ -55,6 +57,8 @@ fun Blockchain.getGreyedOutIconRes(): Int { Blockchain.Dogecoin -> R.drawable.ic_dogecoin_no_color Blockchain.Tron, Blockchain.TronTestnet -> R.drawable.ic_tron_no_color Blockchain.Gnosis -> R.drawable.ic_gnosis_no_color + Blockchain.EthereumPow, Blockchain.EthereumPowTestnet -> R.drawable.ic_ethereumpow_no_color + Blockchain.EthereumFair -> R.drawable.ic_ethereumfair_no_color else -> R.drawable.ic_tangem_logo } } diff --git a/app/src/main/res/drawable/ic_ethereumfair_no_color.xml b/app/src/main/res/drawable/ic_ethereumfair_no_color.xml new file mode 100644 index 0000000000..dd68efa83e --- /dev/null +++ b/app/src/main/res/drawable/ic_ethereumfair_no_color.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_ethereumfair_round.xml b/app/src/main/res/drawable/ic_ethereumfair_round.xml new file mode 100644 index 0000000000..b8e6604a7a --- /dev/null +++ b/app/src/main/res/drawable/ic_ethereumfair_round.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_ethereumpow_no_color.xml b/app/src/main/res/drawable/ic_ethereumpow_no_color.xml new file mode 100644 index 0000000000..aa369fd0ab --- /dev/null +++ b/app/src/main/res/drawable/ic_ethereumpow_no_color.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_ethereumpow_round.xml b/app/src/main/res/drawable/ic_ethereumpow_round.xml new file mode 100644 index 0000000000..052ac58398 --- /dev/null +++ b/app/src/main/res/drawable/ic_ethereumpow_round.xml @@ -0,0 +1,166 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dependencies.gradle b/dependencies.gradle index 0fdf41d259..18c09c7c2d 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ ext.versions = [ kotlin : '1.6.10', build_gradle : '7.1.3', tangem_card_sdk : 'develop-159', - tangem_blockchain_sdk: 'AND-2102-develop-105-hotfix_xlm-109', + tangem_blockchain_sdk: 'AND-2140_develop_105_hotfix_eth_pow_fair-116', // tangem_blockchain_sdk: '0.0.1', ] diff --git a/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt b/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt index 8708f1a0a8..3fd24aa445 100644 --- a/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt +++ b/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt @@ -38,6 +38,9 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? { "tron/test" -> Blockchain.TronTestnet "xrp", "ripple" -> Blockchain.XRP "xdai" -> Blockchain.Gnosis + "ethereum-pow-iou" -> Blockchain.EthereumPow + "ethereum-pow-iou/test" -> Blockchain.EthereumPowTestnet + "ethereumfair" -> Blockchain.EthereumFair else -> null } } @@ -80,6 +83,9 @@ fun Blockchain.toNetworkId(): String { Blockchain.Tron -> "tron" Blockchain.TronTestnet -> "tron/test" Blockchain.Gnosis -> "xdai" + Blockchain.EthereumPow -> "ethereum-pow-iou" + Blockchain.EthereumPowTestnet -> "ethereum-pow-iou/test" + Blockchain.EthereumFair -> "ethereumfair" } } @@ -105,6 +111,8 @@ fun Blockchain.toCoinId(): String { Blockchain.Dogecoin -> "dogecoin" Blockchain.Tron, Blockchain.TronTestnet -> "tron" Blockchain.Gnosis -> "xdai" + Blockchain.EthereumPow, Blockchain.EthereumPowTestnet -> "ethereum-pow-iou" + Blockchain.EthereumFair -> "ethereumfair" Blockchain.Unknown -> "unknown" } } \ No newline at end of file From dfe1e389d334c4a8b7c44bb8a0dd21cb2f75c465 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 22 Sep 2022 12:57:27 +0400 Subject: [PATCH 03/14] Updated on 2026-08-14 --- .../tangem/tap/features/demo/DemoHelper.kt | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt b/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt index 650ce5ea09..b0d473cde0 100644 --- a/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt +++ b/app/src/main/java/com/tangem/tap/features/demo/DemoHelper.kt @@ -448,6 +448,33 @@ class DemoConfig { "AB02000000049533", "AB02000000049541", "AB02000000049830", + // === more cids === + "AC03000000091418", + "AC03000000091400", + "AC03000000099007", + "AC03000000098991", + "AC03000000098942", + "AC03000000091715", + "AC03000000091301", + "AC03000000091343", + "AB01000000055705", + "AB01000000052918", + "AB01000000047710", + "AB01000000052306", + "AB01000000047645", + "AB01000000048957", + "AB01000000052900", + "AB01000000050391", + "AB01000000047363", + "AB02000000053998", + "AB02000000019809", + "AB02000000020872", + "AB02000000022027", + "AB02000000058955", + "AB02000000053253", + "AB02000000048063", + "AB02000000023736", + "AB02000000058187", ) private val testDemoCardIds = listOf( From d02dac09ecb1bba6b01701125b3864c34c36c9f5 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 22 Sep 2022 17:07:13 +0400 Subject: [PATCH 04/14] Updated on 2026-08-14 --- .../java/com/tangem/tap/domain/TapErrors.kt | 8 +++- .../walletconnect/WalletConnectManager.kt | 33 ++++++++++----- .../walletconnect/extensions/WcPeerMeta.kt | 9 ++++ .../walletconnect/WalletConnectAction.kt | 3 +- .../walletconnect/WalletConnectMiddleware.kt | 41 ++++++++++++------- app/src/main/res/values-de/strings_final.xml | 2 + app/src/main/res/values-fr/strings_final.xml | 2 + app/src/main/res/values-it/strings_final.xml | 2 + app/src/main/res/values-ru/strings_final.xml | 2 + app/src/main/res/values/strings_final.xml | 2 + 10 files changed, 75 insertions(+), 29 deletions(-) create mode 100644 app/src/main/java/com/tangem/tap/domain/walletconnect/extensions/WcPeerMeta.kt diff --git a/app/src/main/java/com/tangem/tap/domain/TapErrors.kt b/app/src/main/java/com/tangem/tap/domain/TapErrors.kt index 9d3cc79eee..03dc7f645b 100644 --- a/app/src/main/java/com/tangem/tap/domain/TapErrors.kt +++ b/app/src/main/java/com/tangem/tap/domain/TapErrors.kt @@ -41,7 +41,7 @@ sealed class TapError( data class UnsupportedState( val stateError: String, - val customMessage: String = "Unsupported state:" + val customMessage: String = "Unsupported state:", ) : TapError(R.string.common_custom_string, listOf("$customMessage $stateError")) sealed class WalletManager { @@ -52,9 +52,13 @@ sealed class TapError( object BlockchainIsUnreachableTryLater : TapError(R.string.wallet_balance_blockchain_unreachable_try_later) } + sealed class WalletConnect { + object UnsupportedDapp : TapError(R.string.wallet_connect_error_unsupported_dapp) + } + data class ValidateTransactionErrors( override val errorList: List, - override val builder: (List) -> String + override val builder: (List) -> String, ) : TapError(-1), MultiMessageError } 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 7e4fae297a..064c3b180b 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 @@ -5,6 +5,8 @@ import com.tangem.common.extensions.guard import com.tangem.tap.common.analytics.Analytics import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.redux.global.GlobalAction +import com.tangem.tap.domain.TapError +import com.tangem.tap.domain.walletconnect.extensions.isDappSupported import com.tangem.tap.features.details.redux.walletconnect.WalletConnectAction import com.tangem.tap.features.details.redux.walletconnect.WalletConnectDialog import com.tangem.tap.features.details.redux.walletconnect.WalletConnectSession @@ -325,21 +327,30 @@ class WalletConnectManager { val session = client.session val data = sessions[session]?.copy(peerMeta = peer, remotePeerId = client.remotePeerId) if (data != null && session != null) { - sessions[session] = data - val sessionData = data.toWalletConnectSession() - sessionData?.let { + if (!peer.isDappSupported()) { store.dispatchOnMain( - WalletConnectAction.ScanCard( - session = sessionData, - chainId = client.chainId?.toIntOrNull() + WalletConnectAction.FailureEstablishingSession( + session = session, + error = TapError.WalletConnect.UnsupportedDapp, + ), + ) + } else { + sessions[session] = data + val sessionData = data.toWalletConnectSession() + sessionData?.let { + store.dispatchOnMain( + WalletConnectAction.ScanCard( + session = sessionData, + chainId = client.chainId?.toIntOrNull(), + ), ) + } + store.state.globalState.analyticsHandlers?.logWcEvent( + Analytics.WcAnalyticsEvent.Session( + Analytics.WcSessionEvent.Connect, peer.url, + ), ) } - store.state.globalState.analyticsHandlers?.logWcEvent( - Analytics.WcAnalyticsEvent.Session( - Analytics.WcSessionEvent.Connect, peer.url - ) - ) } } client.onSessionUpdate = { id: Long, update: WCSessionUpdate -> diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/extensions/WcPeerMeta.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/extensions/WcPeerMeta.kt new file mode 100644 index 0000000000..057caf7bd2 --- /dev/null +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/extensions/WcPeerMeta.kt @@ -0,0 +1,9 @@ +package com.tangem.tap.domain.walletconnect.extensions + +import com.trustwallet.walletconnect.models.WCPeerMeta + +fun WCPeerMeta.isDappSupported(): Boolean { + return !unsupportedDappsList.any { this.url.contains(it) } +} + +private val unsupportedDappsList: List = listOf("dydx.exchange") \ No newline at end of file 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 14a871fbd9..9106094b1a 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 @@ -2,6 +2,7 @@ package com.tangem.tap.features.details.redux.walletconnect import com.tangem.blockchain.common.Blockchain import com.tangem.tap.common.redux.NotificationAction +import com.tangem.tap.domain.TapError import com.tangem.wallet.R import com.trustwallet.walletconnect.models.binance.WCBinanceTradeOrder import com.trustwallet.walletconnect.models.binance.WCBinanceTransferOrder @@ -53,7 +54,7 @@ sealed class WalletConnectAction : Action { val updatedSession: WalletConnectSession, ) : WalletConnectAction() - data class FailureEstablishingSession(val session: WCSession?) : WalletConnectAction() + data class FailureEstablishingSession(val session: WCSession?, val error: TapError? = null) : WalletConnectAction() data class SetSessionsRestored(val sessions: List) : WalletConnectAction() 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 d98fb0b0f5..faf6594595 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 @@ -8,6 +8,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 @@ -90,6 +91,16 @@ class WalletConnectMiddleware { store.dispatchOnMain(GlobalAction.ShowDialog(WalletConnectDialog.SessionTimeout)) } is WalletConnectAction.FailureEstablishingSession -> { + if (action.error != null) { + store.dispatch( + GlobalAction.ShowDialog( + AppDialog.SimpleOkDialogRes( + headerId = R.string.common_warning, + messageId = action.error.messageResource, + ), + ), + ) + } if (action.session != null) { walletConnectManager.disconnect(action.session) } @@ -273,21 +284,21 @@ class WalletConnectMiddleware { ) return } - val wallet = walletManager.wallet - val derivedKey = - if (wallet.publicKey.blockchainKey.contentEquals(wallet.publicKey.seedKey)) { - null - } else { - walletManager.wallet.publicKey.blockchainKey - } - val walletForSession = WalletForSession( - cardId = scanResponse.card.cardId, - walletPublicKey = wallet.publicKey.seedKey, - derivedPublicKey = derivedKey, - derivationPath = wallet.publicKey.derivationPath, - derivationStyle = scanResponse.card.derivationStyle, - blockchain = wallet.blockchain, - ) + val wallet = walletManager.wallet + val derivedKey = + if (wallet.publicKey.blockchainKey.contentEquals(wallet.publicKey.seedKey)) { + null + } else { + walletManager.wallet.publicKey.blockchainKey + } + val walletForSession = WalletForSession( + cardId = scanResponse.card.cardId, + walletPublicKey = wallet.publicKey.seedKey, + derivedPublicKey = derivedKey, + derivationPath = wallet.publicKey.derivationPath, + derivationStyle = scanResponse.card.derivationStyle, + blockchain = wallet.blockchain, + ) withMainContext { val updatedSession = session.copy(wallet = walletForSession) diff --git a/app/src/main/res/values-de/strings_final.xml b/app/src/main/res/values-de/strings_final.xml index a2c94fc2da..042969a1b3 100644 --- a/app/src/main/res/values-de/strings_final.xml +++ b/app/src/main/res/values-de/strings_final.xml @@ -99,4 +99,6 @@ Tag Invalid Memo. It won\'t be added to the transaction Invalid Tag. It won\'t be added to the transaction + + Connection with this Dapp cannot be established due to its technical implementation. \ 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 01b15baa13..44cf70e8a4 100644 --- a/app/src/main/res/values-fr/strings_final.xml +++ b/app/src/main/res/values-fr/strings_final.xml @@ -99,4 +99,6 @@ Tag Invalid Memo. It won\'t be added to the transaction Invalid Tag. It won\'t be added to the transaction + + Connection with this Dapp cannot be established due to its technical implementation. \ 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 f6b98a333f..8052503722 100644 --- a/app/src/main/res/values-it/strings_final.xml +++ b/app/src/main/res/values-it/strings_final.xml @@ -100,4 +100,6 @@ Tag Invalid Memo. It won\'t be added to the transaction Invalid Tag. It won\'t be added to the transaction + + Connection with this Dapp cannot be established due to its technical implementation. \ 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 3ccd9d13aa..22f9894ae8 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -116,4 +116,6 @@ Tag Недопустимый Memo. Он не будет добавлен в транзакцию. Недопустимый Tag. Он не будет добавлен в транзакцию. + + Cоединение с этим Dapp сервисом не может быть установлено из-за его технической реализации. diff --git a/app/src/main/res/values/strings_final.xml b/app/src/main/res/values/strings_final.xml index 0e11c29566..bd35c99d4e 100644 --- a/app/src/main/res/values/strings_final.xml +++ b/app/src/main/res/values/strings_final.xml @@ -118,4 +118,6 @@ Tag Invalid Memo. It won\'t be added to the transaction Invalid Tag. It won\'t be added to the transaction + + Connection with this Dapp cannot be established due to its technical implementation. From f1d61dad13ffd00683a0024a46000d4f783c5041 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 22 Sep 2022 17:09:06 +0400 Subject: [PATCH 05/14] Updated on 2026-08-14 --- dependencies.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies.gradle b/dependencies.gradle index 18c09c7c2d..e1b2eb8ab6 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ ext.versions = [ kotlin : '1.6.10', build_gradle : '7.1.3', tangem_card_sdk : 'develop-159', - tangem_blockchain_sdk: 'AND-2140_develop_105_hotfix_eth_pow_fair-116', + tangem_blockchain_sdk: 'AND-2145_develop_105_hotfix_eth_classic-118', // tangem_blockchain_sdk: '0.0.1', ] From 0e4c0349de82239c6c1e3455f9bda5111d31ffe0 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 23 Sep 2022 10:24:28 +0400 Subject: [PATCH 06/14] Updated on 2026-08-14 --- .../wallet/ui/images/CurrencyIconRequest.kt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt index cd7959319e..f6d1124e89 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt @@ -52,9 +52,6 @@ class CurrencyIconRequest( private fun loadTokenIcon() { loadTokenIconBase( - onStart = { - currencyImageView.setColorFilter(it.getColor()) - }, onSuccess = { currencyImageView.colorFilter = null } @@ -94,17 +91,25 @@ class CurrencyIconRequest( data = getTokenIcon(token, blockchain), placeholderRes = R.drawable.shape_circle, onStart = { - currencyTextView.text = token.symbol.take(1) - currencyTextView.setTextColor(token.getTextColor()) + showPlaceholder(token) onStart(token) }, onSuccess = { currencyTextView.text = null onSuccess(token) }, - onError = { onError(token) }, + onError = { + showPlaceholder(token) + onError(token) + }, ) } + + private fun showPlaceholder(token: Token) { + currencyTextView.text = token.symbol.take(1) + currencyTextView.setTextColor(token.getTextColor()) + currencyImageView.setColorFilter(token.getColor()) + } } private inline fun ImageView.loadIcon( From 5ad45b5e22ef6e66530392da0b46e22440c09104 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 15 Sep 2022 01:00:26 +0400 Subject: [PATCH 07/14] Updated on 2026-08-14 --- .../com/tangem/tap/common/extensions/Token.kt | 20 +++++---- .../wallet/ui/images/CurrencyIconRequest.kt | 38 +++++++++------- .../wallet/ui/images/CurrencyIconView.kt | 43 ++++++++----------- .../main/res/layout/view_currency_icon.xml | 7 +-- 4 files changed, 58 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/common/extensions/Token.kt b/app/src/main/java/com/tangem/tap/common/extensions/Token.kt index 10897bc069..59c918d736 100644 --- a/app/src/main/java/com/tangem/tap/common/extensions/Token.kt +++ b/app/src/main/java/com/tangem/tap/common/extensions/Token.kt @@ -5,19 +5,23 @@ import androidx.annotation.ColorInt import androidx.core.graphics.luminance import androidx.core.graphics.toColorInt import com.tangem.blockchain.common.Token -import com.tangem.wallet.R @ColorInt -fun Token.getColor(): Int { - return try { - ("#" + this.contractAddress.subSequence(2..7).toString()) - .toColorInt() +fun Token.getColor(isTestnet: Boolean = false): Int { + val defaultColor = "#C7C7CC".toColorInt() // equivalent to R.color.lightGray4 + + return if (isTestnet) + defaultColor + else try { + ("#" + this.contractAddress.subSequence(2..7).toString()).toColorInt() } catch (exception: Exception) { - R.color.lightGray4 + defaultColor } } @ColorInt -fun Token.getTextColor(): Int { - return if (this.getColor().luminance > 0.5) Color.BLACK else Color.WHITE +fun Token.getTextColor(isTestnet: Boolean = false): Int = when { + isTestnet -> Color.WHITE + this.getColor().luminance > 0.5 -> Color.BLACK + else -> Color.WHITE } \ No newline at end of file diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt index f6d1124e89..62f015909c 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconRequest.kt @@ -21,7 +21,7 @@ private const val VOYR = "VOYRME" class CurrencyIconRequest( private val currencyImageView: ImageFilterView, - private val currencyTextView: TextView, + private val currencyTextView: TextView?, private val token: Token?, private val blockchain: Blockchain, ) { @@ -38,7 +38,7 @@ class CurrencyIconRequest( loadBlockchainIconBase( onStart = { currencyImageView.colorFilter = null - } + }, ) } @@ -46,15 +46,22 @@ class CurrencyIconRequest( loadBlockchainIconBase( onStart = { currencyImageView.saturation = 0f - } + }, ) } private fun loadTokenIcon() { loadTokenIconBase( + onStart = { + currencyImageView.setColorFilter(it.getColor()) + }, onSuccess = { currencyImageView.colorFilter = null - } + }, + onError = { + currencyImageView.setColorFilter(it.getColor()) + currencyTextView?.setTextColor(it.getTextColor()) + }, ) } @@ -62,7 +69,12 @@ class CurrencyIconRequest( loadTokenIconBase( onStart = { currencyImageView.saturation = 0f - } + }, + onError = { + currencyImageView.saturation = 0f + currencyImageView.setColorFilter(it.getColor(true)) + currencyTextView?.setTextColor(it.getTextColor(true)) + }, ) } @@ -91,25 +103,21 @@ class CurrencyIconRequest( data = getTokenIcon(token, blockchain), placeholderRes = R.drawable.shape_circle, onStart = { - showPlaceholder(token) + currencyTextView?.text = token.name.take(1) + currencyTextView?.setTextColor(token.getTextColor()) onStart(token) }, onSuccess = { - currencyTextView.text = null + currencyTextView?.text = null onSuccess(token) }, onError = { - showPlaceholder(token) + // for some reason the onStart doesn't call if an error occurs + currencyTextView?.text = token.name.take(1) onError(token) }, ) } - - private fun showPlaceholder(token: Token) { - currencyTextView.text = token.symbol.take(1) - currencyTextView.setTextColor(token.getTextColor()) - currencyImageView.setColorFilter(token.getColor()) - } } private inline fun ImageView.loadIcon( @@ -127,7 +135,7 @@ private inline fun ImageView.loadIcon( .listener( onStart = { onStart() }, onSuccess = { _, _ -> onSuccess() }, - onError = { _, _ -> onError() } + onError = { _, _ -> onError() }, ) .target(imageView = this) .build() diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt index ec9ff38519..96d03cdd22 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt @@ -4,13 +4,11 @@ import android.content.Context import android.util.AttributeSet import android.view.LayoutInflater import android.widget.TextView -import androidx.annotation.DrawableRes import androidx.constraintlayout.utils.widget.ImageFilterView import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible import com.tangem.blockchain.common.DerivationStyle import com.tangem.tangem_sdk_new.extensions.dpToPx -import com.tangem.tap.common.extensions.getRoundIconRes import com.tangem.tap.features.wallet.models.Currency import com.tangem.wallet.databinding.ViewCurrencyIconBinding import kotlin.math.roundToInt @@ -24,29 +22,16 @@ class CurrencyIconView @JvmOverloads constructor( LayoutInflater.from(context), this, ) - private val currencyImageView: ImageFilterView get() = binding.ivCurrency - private val currencyTextView: TextView get() = binding.tvTokenLetter - - private var isBlockchainIconVisible: Boolean - get() = binding.ivBlockchain.isVisible - set(value) = binding.ivBlockchain::isVisible.set(value) - - private var isBadgeVisible: Boolean - get() = binding.badge.isVisible - set(value) = binding.badge::isVisible.set(value) - - @DrawableRes - private var blockchainIconRes: Int? = null - set(value) { - if (value != null && value != field && isBlockchainIconVisible) { - binding.ivBlockchain.setImageResource(value) - field = value - } - } + private var isBlockchainBadgeVisible: Boolean + get() = binding.ivBlockchainBadge.isVisible + set(value) = binding.ivBlockchainBadge::isVisible.set(value) + private var isCustomCurrencyBadgeVisible: Boolean + get() = binding.customBadge.isVisible + set(value) = binding.customBadge::isVisible.set(value) init { minWidth = dpToPx(48f).roundToInt() @@ -57,9 +42,7 @@ class CurrencyIconView @JvmOverloads constructor( currency: Currency, derivationStyle: DerivationStyle?, ) { - isBlockchainIconVisible = currency.isToken() - isBadgeVisible = currency.isCustomCurrency(derivationStyle) - blockchainIconRes = currency.blockchain.getRoundIconRes() + isCustomCurrencyBadgeVisible = currency.isCustomCurrency(derivationStyle) CurrencyIconRequest( currencyImageView = currencyImageView, @@ -67,5 +50,17 @@ class CurrencyIconView @JvmOverloads constructor( token = (currency as? Currency.Token)?.token, blockchain = currency.blockchain, ).load() + + if (currency.isToken()) { + // load a blockchain icon into the blockchain badge + isBlockchainBadgeVisible = true + + CurrencyIconRequest( + currencyImageView = binding.ivBlockchainBadge, + currencyTextView = null, + token = null, + blockchain = currency.blockchain, + ).load() + } } } \ No newline at end of file diff --git a/app/src/main/res/layout/view_currency_icon.xml b/app/src/main/res/layout/view_currency_icon.xml index 801ac76c97..aa1330c398 100644 --- a/app/src/main/res/layout/view_currency_icon.xml +++ b/app/src/main/res/layout/view_currency_icon.xml @@ -35,12 +35,13 @@ android:textColor="@android:color/white" android:textSize="25sp" android:textStyle="bold" + android:translationY="-1dp" tools:text="J" /> - Date: Thu, 15 Sep 2022 15:44:08 +0400 Subject: [PATCH 08/14] Updated on 2026-08-14 --- .../wallet/ui/WalletDetailsFragment.kt | 1 + .../wallet/ui/adapters/WalletAdapter.kt | 1 + .../wallet/ui/images/CurrencyIconView.kt | 50 ++++++++++--------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt index ab07dd33d5..db9173e486 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt @@ -41,6 +41,7 @@ import com.tangem.tap.features.wallet.redux.WalletState import com.tangem.tap.features.wallet.redux.WalletState.Companion.UNKNOWN_AMOUNT_SIGN import com.tangem.tap.features.wallet.ui.adapters.PendingTransactionsAdapter import com.tangem.tap.features.wallet.ui.adapters.WalletDetailWarningMessagesAdapter +import com.tangem.tap.features.wallet.ui.images.load import com.tangem.tap.features.wallet.ui.test.TestWalletDetails import com.tangem.tap.store import com.tangem.wallet.R 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 4be9104bb1..af061d48f1 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 @@ -15,6 +15,7 @@ import com.tangem.tap.common.extensions.show import com.tangem.tap.features.wallet.redux.WalletAction import com.tangem.tap.features.wallet.redux.WalletData import com.tangem.tap.features.wallet.ui.BalanceStatus +import com.tangem.tap.features.wallet.ui.images.load import com.tangem.tap.store import com.tangem.wallet.R import com.tangem.wallet.databinding.ItemCurrencyWalletBinding diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt index 96d03cdd22..4f5fd38bf9 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/images/CurrencyIconView.kt @@ -22,14 +22,16 @@ class CurrencyIconView @JvmOverloads constructor( LayoutInflater.from(context), this, ) - private val currencyImageView: ImageFilterView + val currencyImageView: ImageFilterView get() = binding.ivCurrency - private val currencyTextView: TextView + val currencyTextView: TextView get() = binding.tvTokenLetter - private var isBlockchainBadgeVisible: Boolean + val blockchainBadge: ImageFilterView + get() = binding.ivBlockchainBadge + var isBlockchainBadgeVisible: Boolean get() = binding.ivBlockchainBadge.isVisible set(value) = binding.ivBlockchainBadge::isVisible.set(value) - private var isCustomCurrencyBadgeVisible: Boolean + var isCustomCurrencyBadgeVisible: Boolean get() = binding.customBadge.isVisible set(value) = binding.customBadge::isVisible.set(value) @@ -37,30 +39,30 @@ class CurrencyIconView @JvmOverloads constructor( minWidth = dpToPx(48f).roundToInt() minHeight = dpToPx(48f).roundToInt() } +} - fun load( - currency: Currency, - derivationStyle: DerivationStyle?, - ) { - isCustomCurrencyBadgeVisible = currency.isCustomCurrency(derivationStyle) +fun CurrencyIconView.load( + currency: Currency, + derivationStyle: DerivationStyle?, +) { + isCustomCurrencyBadgeVisible = currency.isCustomCurrency(derivationStyle) + + CurrencyIconRequest( + currencyImageView = currencyImageView, + currencyTextView = currencyTextView, + token = (currency as? Currency.Token)?.token, + blockchain = currency.blockchain, + ).load() + + if (currency.isToken()) { + // load a blockchain icon into the blockchain badge + isBlockchainBadgeVisible = true CurrencyIconRequest( - currencyImageView = currencyImageView, - currencyTextView = currencyTextView, - token = (currency as? Currency.Token)?.token, + currencyImageView = blockchainBadge, + currencyTextView = null, + token = null, blockchain = currency.blockchain, ).load() - - if (currency.isToken()) { - // load a blockchain icon into the blockchain badge - isBlockchainBadgeVisible = true - - CurrencyIconRequest( - currencyImageView = binding.ivBlockchainBadge, - currencyTextView = null, - token = null, - blockchain = currency.blockchain, - ).load() - } } } \ No newline at end of file From d0fe9b8b099c2b1684ff72b3e50d9482af216e56 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 29 Sep 2022 16:58:03 +0400 Subject: [PATCH 09/14] 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 10/14] 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 11/14] 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 12/14] 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 13/14] 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) } } } From c307bc2110ff198d88c2069479d5e6740160938c Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 30 Sep 2022 12:21:42 +0400 Subject: [PATCH 14/14] Updated on 2026-08-14 --- .../main/java/com/tangem/tap/domain/TapErrors.kt | 1 + .../domain/walletconnect/WalletConnectManager.kt | 14 ++++++++++++-- app/src/main/res/values-ru/strings_final.xml | 1 - dependencies.gradle | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/TapErrors.kt b/app/src/main/java/com/tangem/tap/domain/TapErrors.kt index 0b74cb1912..5a0cf85668 100644 --- a/app/src/main/java/com/tangem/tap/domain/TapErrors.kt +++ b/app/src/main/java/com/tangem/tap/domain/TapErrors.kt @@ -55,6 +55,7 @@ sealed class TapError( sealed class WalletConnect { object UnsupportedDapp : TapError(R.string.wallet_connect_error_unsupported_dapp) + object UnsupportedLink : TapError(R.string.wallet_connect_error_failed_to_connect) } data class ValidateTransactionErrors( 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 0a108530df..de71029d2c 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 @@ -60,7 +60,12 @@ class WalletConnectManager { fun connect(wcUri: String) { val session = WCSession.from(wcUri).guard { - store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null, true)) + store.dispatchOnMain( + WalletConnectAction.FailureEstablishingSession( + session = null, + error = TapError.WalletConnect.UnsupportedLink, + ), + ) return } if (sessions[session] != null) { @@ -74,7 +79,12 @@ class WalletConnectManager { try { client.connect(session, tangemPeerMeta, peerId) } catch (exception: IllegalArgumentException) { - store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null, true)) + store.dispatchOnMain( + WalletConnectAction.FailureEstablishingSession( + session = null, + error = TapError.WalletConnect.UnsupportedLink, + ), + ) return } diff --git a/app/src/main/res/values-ru/strings_final.xml b/app/src/main/res/values-ru/strings_final.xml index 7e9e83795e..81edc55d19 100644 --- a/app/src/main/res/values-ru/strings_final.xml +++ b/app/src/main/res/values-ru/strings_final.xml @@ -103,7 +103,6 @@ Tag Недопустимый Memo. Он не будет добавлен в транзакцию. Недопустимый Tag. Он не будет добавлен в транзакцию. - Сеть %s использует концепцию экзистенциального депозита. Если баланс вашего счета опустится ниже %s %s, он будет деактивирован, а все оставшиеся средства будут уничтожены. Не удалось установить сессию WalletConnect Cоединение с этим Dapp сервисом не может быть установлено из-за его технической реализации. diff --git a/dependencies.gradle b/dependencies.gradle index 5d1d0d6fa5..0b11f515b1 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -2,7 +2,7 @@ ext.versions = [ kotlin : '1.6.10', build_gradle : '7.1.3', tangem_card_sdk : 'develop-159', - tangem_blockchain_sdk: 'develop-115', + tangem_blockchain_sdk: 'develop-121', // tangem_blockchain_sdk: '0.0.1', ]