From 1f12e01ee8027b89dfba3b428f8f1195c05a2c76 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 13:57:16 +0300 Subject: [PATCH 1/7] Updated on 2026-08-14 --- app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt b/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt index 2605d263c3..618d97f6e8 100644 --- a/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt @@ -25,7 +25,6 @@ import com.tangem.operations.pins.SetUserCodeCommand import com.tangem.tap.common.analytics.Analytics import com.tangem.tap.common.analytics.AnalyticsEvent import com.tangem.tap.common.analytics.AnalyticsHandler -import com.tangem.tap.common.analytics.FirebaseAnalyticsHandler import com.tangem.tap.domain.tasks.CreateWalletAndRescanTask import com.tangem.tap.domain.tasks.product.ResetToFactorySettingsTask import com.tangem.tap.domain.tasks.product.ScanProductTask @@ -33,6 +32,7 @@ import com.tangem.tap.domain.tasks.product.ScanResponse import com.tangem.tap.domain.tokens.CurrenciesRepository import com.tangem.wallet.R import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.isActive import kotlinx.coroutines.withContext import kotlin.coroutines.resume import kotlin.coroutines.suspendCoroutine @@ -135,7 +135,7 @@ class TangemSdkManager(private val tangemSdk: TangemSdk, private val context: Co withContext(Dispatchers.Main) { suspendCoroutine { continuation -> tangemSdk.startSessionWithRunnable(runnable, cardId, initialMessage) { result -> - continuation.resume(result) + if (isActive) continuation.resume(result) } } } From 5c49912ba4a3d6b29ceb06d50b3472a63f7a2d7b Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 14:56:55 +0300 Subject: [PATCH 2/7] Updated on 2026-08-14 --- app/build.gradle | 4 ++-- .../com/tangem/tap/domain/extensions/MoonpayStatus.kt | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 289652a415..a8cf0639c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,8 +78,8 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' implementation 'com.tangem:blockchain:develop-61' - implementation 'com.tangem.tangem-sdk-kotlin:core:develop-129' - implementation 'com.tangem.tangem-sdk-kotlin:android:develop-129' + implementation 'com.tangem.tangem-sdk-kotlin:core:develop-130' + implementation 'com.tangem.tangem-sdk-kotlin:android:develop-130' // WebView implementation "androidx.browser:browser:1.3.0" diff --git a/app/src/main/java/com/tangem/tap/domain/extensions/MoonpayStatus.kt b/app/src/main/java/com/tangem/tap/domain/extensions/MoonpayStatus.kt index d204a2051d..bd4b7af891 100644 --- a/app/src/main/java/com/tangem/tap/domain/extensions/MoonpayStatus.kt +++ b/app/src/main/java/com/tangem/tap/domain/extensions/MoonpayStatus.kt @@ -14,10 +14,11 @@ fun MoonpayStatus.buyIsAllowed(currency: Currency): Boolean { return when (currency) { is Currency.Blockchain -> { - if (currency.blockchain == Blockchain.Unknown || currency.blockchain == Blockchain.BSC) { - false - } else { - availableToBuy.contains(currency.currencySymbol) + val blockchain = currency.blockchain + when { + blockchain.isTestnet() -> blockchain.getTestnetTopUpUrl() != null + blockchain == Blockchain.Unknown || blockchain == Blockchain.BSC -> false + else -> availableToBuy.contains(currency.currencySymbol) } } is Currency.Token -> false From fb37a499e3aef96955d82e5d07c179d51eb2c739 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 15:09:06 +0300 Subject: [PATCH 3/7] Updated on 2026-08-14 --- .../tap/common/redux/global/GlobalAction.kt | 3 +- .../common/redux/global/GlobalMidlleware.kt | 1 + .../com/tangem/tap/domain/TangemSdkManager.kt | 10 +- .../domain/tasks/product/ScanProductTask.kt | 11 +- .../walletconnect/WalletConnectManager.kt | 13 +- .../WalletConnectNetworkUtils.kt | 3 +- .../walletconnect/WalletConnectAction.kt | 10 +- .../walletconnect/WalletConnectMiddleware.kt | 119 +++++++++--------- .../walletconnect/WalletConnectReducer.kt | 5 +- .../redux/walletconnect/WalletConnectState.kt | 6 +- .../ui/walletconnect/QrScanFragment.kt | 2 +- .../dialogs/ClipboardOrScanQrDialog.kt | 2 +- .../tap/features/home/redux/HomeMiddleware.kt | 4 +- 13 files changed, 101 insertions(+), 88 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt index 5f0db04ae5..04b8f27743 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalAction.kt @@ -1,5 +1,6 @@ package com.tangem.tap.common.redux.global +import com.tangem.blockchain.common.Blockchain import com.tangem.blockchain.common.WalletManager import com.tangem.common.CompletionResult import com.tangem.common.core.TangemError @@ -37,7 +38,7 @@ sealed class GlobalAction : Action { } data class ScanCard( - val shouldDeriveWC: Boolean, + val additionalBlockchainsToDerive: Collection? = null, val onSuccess: ((ScanResponse) -> Unit)? = null, val onFailure: ((TangemError) -> Unit)? = null, val messageResId: Int? = null, diff --git a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt index 6200feb947..97fc6ac162 100644 --- a/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt +++ b/app/src/main/java/com/tangem/tap/common/redux/global/GlobalMidlleware.kt @@ -90,6 +90,7 @@ private val globalMiddlewareHandler: Middleware = { dispatch, appState val result = tangemSdkManager.scanProduct( store.state.globalState.analyticsHandlers, currenciesRepository, + action.additionalBlockchainsToDerive, action.messageResId ) withMainContext { diff --git a/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt b/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt index 618d97f6e8..5712a5df13 100644 --- a/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt +++ b/app/src/main/java/com/tangem/tap/domain/TangemSdkManager.kt @@ -5,6 +5,7 @@ import CreateProductWalletTaskResponse import android.content.Context import com.tangem.Message import com.tangem.TangemSdk +import com.tangem.blockchain.common.Blockchain import com.tangem.common.CardFilter import com.tangem.common.CompletionResult import com.tangem.common.SuccessResponse @@ -42,13 +43,16 @@ class TangemSdkManager(private val tangemSdk: TangemSdk, private val context: Co suspend fun scanProduct( analyticsHandler: AnalyticsHandler?, currenciesRepository: CurrenciesRepository, + additionalBlockchainsToDerive: Collection? = null, messageRes: Int? = null, ): CompletionResult { analyticsHandler?.triggerEvent(AnalyticsEvent.READY_TO_SCAN, null) val message = Message(context.getString(messageRes ?: R.string.initial_message_scan_header)) - return runTaskAsyncReturnOnMain(ScanProductTask(null, currenciesRepository), null, message) - .also { sendScanResultsToAnalytics(analyticsHandler, it) } + return runTaskAsyncReturnOnMain( + runnable = ScanProductTask(null, currenciesRepository, additionalBlockchainsToDerive), + cardId = null, initialMessage = message + ).also { sendScanResultsToAnalytics(analyticsHandler, it) } } suspend fun createProductWallet( @@ -135,7 +139,7 @@ class TangemSdkManager(private val tangemSdk: TangemSdk, private val context: Co withContext(Dispatchers.Main) { suspendCoroutine { continuation -> tangemSdk.startSessionWithRunnable(runnable, cardId, initialMessage) { result -> - if (isActive) continuation.resume(result) + if (continuation.context.isActive) continuation.resume(result) } } } diff --git a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt index 05ab2ed34b..271b9bf761 100644 --- a/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt +++ b/app/src/main/java/com/tangem/tap/domain/tasks/product/ScanProductTask.kt @@ -80,7 +80,8 @@ typealias KeyWalletPublicKey = ByteArrayKey class ScanProductTask( val card: Card? = null, - private val currenciesRepository: CurrenciesRepository? + private val currenciesRepository: CurrenciesRepository?, + private val additionalBlockchainsToDerive: Collection? = null ) : CardSessionRunnable { override fun run( @@ -101,7 +102,7 @@ class ScanProductTask( val commandProcessor = when { TapWorkarounds.isTangemNote(card) -> ScanNoteProcessor() card.isTangemTwins() -> ScanTwinProcessor() - else -> ScanWalletProcessor(currenciesRepository) + else -> ScanWalletProcessor(currenciesRepository, additionalBlockchainsToDerive) } commandProcessor.proceed(card, session) { processorResult -> when (processorResult) { @@ -153,7 +154,8 @@ private class ScanNoteProcessor : ProductCommandProcessor { } private class ScanWalletProcessor( - private val currenciesRepository: CurrenciesRepository? + private val currenciesRepository: CurrenciesRepository?, + private val additionalBlockchainsToDerive: Collection? = null ) : ProductCommandProcessor { var primaryCard: PrimaryCard? = null @@ -291,6 +293,9 @@ private class ScanWalletProcessor( ) ) } + if (additionalBlockchainsToDerive != null) { + blockchainsToDerive.addAll(additionalBlockchainsToDerive) + } return blockchainsToDerive.distinct() } 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 49510ff791..dd94266b06 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 @@ -42,7 +42,7 @@ class WalletConnectManager { private var sessions: MutableMap = mutableMapOf() - fun connect(wcUri: String, wallet: WalletForSession) { + fun connect(wcUri: String) { val session = WCSession.from(wcUri) ?: return if (sessions[session] != null) { store.dispatchOnMain(WalletConnectAction.RefuseOpeningSession) @@ -57,7 +57,7 @@ class WalletConnectManager { remotePeerId = null, session = session, client = client, - wallet = wallet + wallet = WalletForSession(cardId = "") ) setupConnectionTimeoutCheck(session) } @@ -154,7 +154,12 @@ class WalletConnectManager { fun disconnect(session: WCSession) { val activeData = sessions[session] ?: return - val disconnected = activeData.client.killSession() + val disconnected = if (activeData.client.isConnected) { + activeData.client.killSession() + } else { + true + } + if (disconnected) { onSessionClosed(session) } @@ -296,7 +301,7 @@ class WalletConnectManager { val sessionData = data.toWalletConnectSession() sessionData?.let { store.dispatchOnMain( - WalletConnectAction.AcceptOpeningSession( + WalletConnectAction.ScanCard( session = sessionData, chainId = client.chainId?.toIntOrNull() ) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectNetworkUtils.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectNetworkUtils.kt index 4907e8d40c..aba7726098 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectNetworkUtils.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectNetworkUtils.kt @@ -10,7 +10,6 @@ class WalletConnectNetworkUtils { fun parseBlockchain( chainId: Int?, peer: WCPeerMeta, - isTestNet: Boolean? = null ): Blockchain? { return when { chainId != null -> { @@ -30,7 +29,7 @@ class WalletConnectNetworkUtils { Blockchain.BSC } else -> { - if (isTestNet == true) Blockchain.EthereumTestnet else Blockchain.Ethereum + Blockchain.Ethereum } } } 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 f5f509cc74..30b6af3508 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 @@ -23,21 +23,21 @@ sealed class WalletConnectAction : Action { data class ShowClipboardOrScanQrDialog(val wcUri: String) : WalletConnectAction() - data class ScanCard(val wcUri: String) : WalletConnectAction() - object UnsupportedCard : WalletConnectAction() data class OpenSession( val wcUri: String, - val wallet: WalletForSession, - val scanResponse: ScanResponse ) : WalletConnectAction() + data class AddScanResponse( + val scanResponse: ScanResponse + ): WalletConnectAction() + object RefuseOpeningSession : WalletConnectAction() data class OpeningSessionTimeout(val session: WCSession) : WalletConnectAction() - data class AcceptOpeningSession( + data class ScanCard( val session: WalletConnectSession, val chainId: Int?, ) : 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 92c6d69072..a8517bd1bc 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 @@ -1,13 +1,15 @@ package com.tangem.tap.features.details.redux.walletconnect -import com.tangem.blockchain.common.* -import com.tangem.tap.* +import com.tangem.blockchain.common.Blockchain +import com.tangem.blockchain.common.WalletManager +import com.tangem.common.extensions.guard import com.tangem.tap.common.extensions.dispatchOnMain import com.tangem.tap.common.extensions.getFromClipboard import com.tangem.tap.common.redux.AppState import com.tangem.tap.common.redux.global.GlobalAction import com.tangem.tap.common.redux.navigation.AppScreen import com.tangem.tap.common.redux.navigation.NavigationAction +import com.tangem.tap.currenciesRepository import com.tangem.tap.domain.TapWorkarounds.isTestCard import com.tangem.tap.domain.extensions.makeWalletManagerForApp import com.tangem.tap.domain.isMultiwalletAllowed @@ -16,10 +18,9 @@ import com.tangem.tap.domain.walletconnect.BnbHelper import com.tangem.tap.domain.walletconnect.WalletConnectManager import com.tangem.tap.domain.walletconnect.WalletConnectNetworkUtils import com.tangem.tap.features.wallet.redux.WalletAction +import com.tangem.tap.store import com.tangem.wallet.R -import com.trustwallet.walletconnect.models.WCPeerMeta import org.rekotlin.Middleware -import timber.log.Timber class WalletConnectMiddleware { private val walletConnectManager = WalletConnectManager() @@ -36,7 +37,7 @@ class WalletConnectMiddleware { is WalletConnectAction.HandleDeepLink -> { if (!action.wcUri.isNullOrBlank()) { if (WalletConnectManager.isCorrectWcUri(action.wcUri)) { - store.dispatchOnMain(WalletConnectAction.ScanCard(action.wcUri)) + store.dispatchOnMain(WalletConnectAction.OpenSession(action.wcUri)) } } } @@ -60,10 +61,6 @@ class WalletConnectMiddleware { ) } - is WalletConnectAction.ScanCard -> { - handleScanCard(action.wcUri) - } - is WalletConnectAction.OpeningSessionTimeout -> { store.dispatchOnMain(GlobalAction.ShowDialog(WalletConnectDialog.SessionTimeout)) } @@ -81,7 +78,6 @@ class WalletConnectMiddleware { is WalletConnectAction.OpenSession -> { walletConnectManager.connect( wcUri = action.wcUri, - wallet = action.wallet ) } @@ -93,16 +89,8 @@ class WalletConnectMiddleware { ) } - is WalletConnectAction.AcceptOpeningSession -> { - generateWalletKeys(action.session, action.chainId) - - store.dispatchOnMain( - GlobalAction.ShowDialog( - WalletConnectDialog.ApproveWcSession( - action.session - ) - ) - ) + is WalletConnectAction.ScanCard -> { + scanCard(action.session, action.chainId) } is WalletConnectAction.ApproveSession -> { @@ -176,35 +164,35 @@ class WalletConnectMiddleware { } } - private fun handleScanCard(wcUri: String) { - store.dispatch(GlobalAction.ScanCard(true, { scanResponse -> - val card = scanResponse.card - if (!card.isMultiwalletAllowed) { - store.dispatchOnMain(WalletConnectAction.UnsupportedCard) - return@ScanCard - } + private fun scanCard(session: WalletConnectSession, chainId: Int?) { + val blockchain = WalletConnectNetworkUtils.parseBlockchain( + chainId = chainId, peer = session.peerMeta + ) ?: Blockchain.Ethereum - store.dispatchOnMain( - WalletConnectAction.OpenSession( - wcUri = wcUri, - wallet = WalletForSession( - scanResponse.card.cardId, - null, - null, - null, - scanResponse.card.isTestCard - ), - scanResponse = scanResponse - ) - ) - }, { - store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null)) - }, R.string.wallet_connect_scan_card_message)) + store.dispatch(GlobalAction.ScanCard(additionalBlockchainsToDerive = listOf(blockchain), + onSuccess = { scanResponse -> + handleScanResponse(scanResponse, session, blockchain) + }, + onFailure = { + store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null)) + }, R.string.wallet_connect_scan_card_message + ) + ) } - private fun generateWalletKeys(session: WalletConnectSession, chainId: Int?) { - val scanResponse = store.state.walletConnectState.scanResponse ?: return - val walletManager = getWalletManager(scanResponse, session.peerMeta, chainId) ?: return + private fun handleScanResponse( + scanResponse: ScanResponse, session: WalletConnectSession, blockchain: Blockchain + ) { + val card = scanResponse.card + if (!card.isMultiwalletAllowed) { + store.dispatchOnMain(WalletConnectAction.UnsupportedCard) + return + } + + val walletManager = getWalletManager(scanResponse, blockchain).guard { + store.dispatchOnMain(WalletConnectAction.FailureEstablishingSession(null)) + return + } val wallet = walletManager.wallet val derivedKey = @@ -213,46 +201,55 @@ class WalletConnectMiddleware { } else { walletManager.wallet.publicKey.blockchainKey } - val updatedWallet = session.wallet.copy( + val walletForSession = WalletForSession( + cardId = scanResponse.card.cardId, walletPublicKey = wallet.publicKey.seedKey, derivedPublicKey = derivedKey, derivationPath = wallet.publicKey.derivationPath, blockchain = wallet.blockchain ) - val updatedSession = session.copy(wallet = updatedWallet) + val updatedSession = session.copy(wallet = walletForSession) walletConnectManager.updateSession(updatedSession) + + store.dispatchOnMain(WalletConnectAction.AddScanResponse(scanResponse)) + + store.dispatchOnMain( + GlobalAction.ShowDialog( + WalletConnectDialog.ApproveWcSession( + updatedSession + ) + ) + ) } private fun getWalletManager( - scanResponse: ScanResponse, peer: WCPeerMeta, chainId: Int? + scanResponse: ScanResponse, blockchain: Blockchain ): WalletManager? { val card = scanResponse.card val factory = store.state.globalState.tapWalletManager.walletManagerFactory - - val blockchain = WalletConnectNetworkUtils.parseBlockchain( - chainId = chainId, peer = peer, isTestNet = scanResponse.card.isTestCard - ) ?: if (scanResponse.card.isTestCard) Blockchain.EthereumTestnet else Blockchain.Ethereum - - Timber.d(blockchain.fullName) - + val blockchainToMake = if (blockchain == Blockchain.Ethereum && card.isTestCard) { + Blockchain.EthereumTestnet + } else { + blockchain + } return if (store.state.globalState.scanResponse?.card?.cardId == card.cardId) { - store.state.walletState.getWalletManager(blockchain) - ?: factory.makeWalletManagerForApp(scanResponse, blockchain) + store.state.walletState.getWalletManager(blockchainToMake) + ?: factory.makeWalletManagerForApp(scanResponse, blockchainToMake) ?.also { walletManager -> store.dispatch(WalletAction.MultiWallet.AddWalletManagers(walletManager)) store.dispatch(WalletAction.MultiWallet.AddBlockchain(walletManager.wallet.blockchain)) } } else { - val walletManager = factory.makeWalletManagerForApp(scanResponse, blockchain) + val walletManager = factory.makeWalletManagerForApp(scanResponse, blockchainToMake) if (currenciesRepository.loadCardCurrencies(card.cardId)?.blockchains?.contains( - blockchain + blockchainToMake ) != true ) { walletManager?.let { currenciesRepository.saveAddedBlockchain( card.cardId, - blockchain + blockchainToMake ) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectReducer.kt b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectReducer.kt index c96f72fc9e..216367e9ee 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectReducer.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectReducer.kt @@ -17,6 +17,9 @@ class WalletConnectReducer { ) } is WalletConnectAction.OpenSession -> { + state.copy(loading = true) + } + is WalletConnectAction.AddScanResponse -> { state.copy(scanResponse = action.scanResponse) } is WalletConnectAction.SetSessionsRestored -> @@ -27,8 +30,6 @@ class WalletConnectReducer { state.sessions.filterNot { it.session.toUri() == action.session.toUri() } state.copy(sessions = sessions) } - is WalletConnectAction.ScanCard -> state.copy(loading = true) - is WalletConnectAction.UnsupportedCard -> state.copy(loading = false) is WalletConnectAction.RefuseOpeningSession -> state.copy(loading = false) is WalletConnectAction.OpeningSessionTimeout -> state.copy(loading = false) diff --git a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectState.kt b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectState.kt index b00b7d9ff9..fdecb27416 100644 --- a/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectState.kt +++ b/app/src/main/java/com/tangem/tap/features/details/redux/walletconnect/WalletConnectState.kt @@ -34,9 +34,9 @@ data class WalletConnectSession( @JsonClass(generateAdapter = true) data class WalletForSession( val cardId: String, - val walletPublicKey: ByteArray?, - val derivedPublicKey: ByteArray?, - val derivationPath: DerivationPath?, + val walletPublicKey: ByteArray? = null, + val derivedPublicKey: ByteArray? = null, + val derivationPath: DerivationPath? = null, val isTestNet: Boolean = false, val blockchain: Blockchain? = if (isTestNet) Blockchain.EthereumTestnet else Blockchain.Ethereum ) { diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt index 94f6c24b8c..9daba1f257 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/QrScanFragment.kt @@ -56,7 +56,7 @@ class QrScanFragment : Fragment(0), ZXingScannerView.ResultHandler { store.dispatch(NavigationAction.PopBackTo()) if (!result.text.isNullOrBlank()) { - store.dispatch(WalletConnectAction.ScanCard(result.text)) + store.dispatch(WalletConnectAction.OpenSession(result.text)) } } diff --git a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt index 5fb2d1507a..809b37cf66 100644 --- a/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/details/ui/walletconnect/dialogs/ClipboardOrScanQrDialog.kt @@ -16,7 +16,7 @@ class ClipboardOrScanQrDialog { setTitle(context.getString(R.string.wallet_connect)) setMessage(context.getText(R.string.wallet_connect_clipboard_alert)) setPositiveButton(context.getText(R.string.wallet_connect_paste_from_clipboard)) { _, _ -> - store.dispatch(WalletConnectAction.ScanCard(wcUri)) + store.dispatch(WalletConnectAction.OpenSession(wcUri)) } setNegativeButton(context.getText(R.string.wallet_connect_scan_new_code)) { _, _ -> store.dispatch(NavigationAction.NavigateTo(AppScreen.QrScan)) diff --git a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt index 467929a848..fb59fee5b6 100644 --- a/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/home/redux/HomeMiddleware.kt @@ -67,7 +67,7 @@ private fun handleReadCard() { store.dispatch(NavigationAction.NavigateTo(AppScreen.Disclaimer)) } else { changeButtonState(ButtonState.PROGRESS) - store.dispatch(GlobalAction.ScanCard(false, { scanResponse -> + store.dispatch(GlobalAction.ScanCard( onSuccess = { scanResponse -> store.state.globalState.tapWalletManager.updateConfigManager(scanResponse) store.dispatch(TwinCardsAction.IfTwinsPrepareState(scanResponse)) @@ -88,7 +88,7 @@ private fun handleReadCard() { } } } - }, { + }, onFailure = { changeButtonState(ButtonState.ENABLED) })) } From 5353f810fe7b72e83fdcb1e401b88f89c4576e78 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 16:12:01 +0300 Subject: [PATCH 4/7] Updated on 2026-08-14 --- .../tap/features/tokens/ui/adapters/CurrenciesAdapter.kt | 5 ++++- app/src/main/res/layout/item_popular_token.xml | 5 ++++- app/src/main/res/values/strings_untranslated.xml | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/features/tokens/ui/adapters/CurrenciesAdapter.kt b/app/src/main/java/com/tangem/tap/features/tokens/ui/adapters/CurrenciesAdapter.kt index 142630f83d..bc2b3177ae 100644 --- a/app/src/main/java/com/tangem/tap/features/tokens/ui/adapters/CurrenciesAdapter.kt +++ b/app/src/main/java/com/tangem/tap/features/tokens/ui/adapters/CurrenciesAdapter.kt @@ -182,7 +182,10 @@ class CurrenciesAdapter : ListAdapter Picasso.get().loadCurrenciesIcon(view.iv_currency, view.tv_token_letter, token, token.blockchain) view.tv_currency_name.text = token.name - view.tv_currency_symbol.text = token.symbol + view.tv_currency_symbol.text = view.context.getString( + R.string.token_symbol_address_format, + token.symbol, token.contractAddress + ) view.btn_add_token.setOnClickListener { onItemAddListener.invoke(currency) currency.isAdded = true diff --git a/app/src/main/res/layout/item_popular_token.xml b/app/src/main/res/layout/item_popular_token.xml index dc388c1dfa..3f03f0279f 100644 --- a/app/src/main/res/layout/item_popular_token.xml +++ b/app/src/main/res/layout/item_popular_token.xml @@ -61,13 +61,16 @@ Solana network charges a rent of %s every 2 days. Accounts that can’t afford the rent are purged from the network. Deposit your account with more than %s to use it for free. + %1s (%2s) + From 1034eeaf8b9c81efe6e8ecf8e0310b151cae08b2 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 19:36:30 +0300 Subject: [PATCH 5/7] Updated on 2026-08-14 --- .../java/com/tangem/tap/domain/walletconnect/BnbHelper.kt | 5 +++-- .../tap/domain/walletconnect/WalletConnectSdkHelper.kt | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/BnbHelper.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/BnbHelper.kt index a8f3eb83c1..d35cc7c2e0 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/BnbHelper.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/BnbHelper.kt @@ -4,6 +4,7 @@ import com.github.salomonbrys.kotson.registerTypeAdapter import com.google.gson.GsonBuilder import com.tangem.blockchain.common.Blockchain import com.tangem.common.extensions.calculateSha256 +import com.tangem.tap.common.extensions.stripZeroPlainString import com.tangem.tap.features.details.redux.walletconnect.BinanceMessageData import com.tangem.tap.features.details.redux.walletconnect.TradeData import com.trustwallet.walletconnect.models.binance.WCBinanceTradeOrder @@ -24,8 +25,8 @@ class BnbHelper { .mapNotNull { if (it.denom == currency) it.amount else null } .sum() .toBigDecimal() - .movePointRight(Blockchain.Binance.decimals()) - .toString() + .movePointLeft(Blockchain.Binance.decimals()) + .stripZeroPlainString() val gson = GsonBuilder() .registerTypeAdapter(tradeOrderSerializer) diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt index 630176edc6..9f6185f5a3 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect/WalletConnectSdkHelper.kt @@ -10,6 +10,7 @@ import com.tangem.blockchain.extensions.* import com.tangem.common.CompletionResult import com.tangem.common.core.TangemSdkError import com.tangem.common.extensions.hexToBytes +import com.tangem.common.extensions.toDecompressedPublicKey import com.tangem.common.extensions.toHexString import com.tangem.crypto.CryptoUtils import com.tangem.operations.sign.SignHashCommand @@ -187,8 +188,8 @@ class WalletConnectSdkHelper { val result = tangemSdkManager.runTaskAsync(command, initialMessage = Message()) return when (result) { is CompletionResult.Success -> { - val key = session.wallet.derivedPublicKey - ?: session.wallet.walletPublicKey + val key = session.wallet.derivedPublicKey?.toDecompressedPublicKey() + ?: session.wallet.walletPublicKey.toDecompressedPublicKey() getBnbResultString( key.toHexString(), result.data.signature.toHexString() From 198441552336504156fd9fa7db75d83bf9f38d54 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 20:03:43 +0300 Subject: [PATCH 6/7] Updated on 2026-08-14 --- .../tap/features/onboarding/AddressInfoBottomSheetDialog.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/src/main/java/com/tangem/tap/features/onboarding/AddressInfoBottomSheetDialog.kt b/app/src/main/java/com/tangem/tap/features/onboarding/AddressInfoBottomSheetDialog.kt index a7bafedba2..c747e1a745 100644 --- a/app/src/main/java/com/tangem/tap/features/onboarding/AddressInfoBottomSheetDialog.kt +++ b/app/src/main/java/com/tangem/tap/features/onboarding/AddressInfoBottomSheetDialog.kt @@ -1,6 +1,7 @@ package com.tangem.tap.features.onboarding import android.content.Context +import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.tangem.tap.common.extensions.copyToClipboard import com.tangem.tap.common.extensions.dispatchDialogHide @@ -23,6 +24,7 @@ class AddressInfoBottomSheetDialog( init { this.setContentView(R.layout.dialog_onboarding_address_info) + behavior.state = BottomSheetBehavior.STATE_EXPANDED setOnCancelListener { store.dispatchDialogHide() } } From 462aca5dd399a736bdf1bf74b8743343e11656a7 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 9 Feb 2022 20:42:18 +0300 Subject: [PATCH 7/7] Updated on 2026-08-14 --- app/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 289652a415..222ad32676 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -78,8 +78,8 @@ dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' implementation 'com.tangem:blockchain:develop-61' - implementation 'com.tangem.tangem-sdk-kotlin:core:develop-129' - implementation 'com.tangem.tangem-sdk-kotlin:android:develop-129' + implementation 'com.tangem.tangem-sdk-kotlin:core:develop-131' + implementation 'com.tangem.tangem-sdk-kotlin:android:develop-131' // WebView implementation "androidx.browser:browser:1.3.0"