From 2b41ded8afebfc9c81ff9a3b1402cc090c16eb1b Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 28 Nov 2024 14:59:56 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/build.gradle.kts | 4 +- .../DefaultLegacyWalletConnectRepository.kt | 42 ++++++++----------- gradle/dependencies.toml | 8 ++-- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e6d30a7cc6..c939548392 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -228,8 +228,8 @@ dependencies { implementation(deps.armadillo) implementation(deps.mviCore.watcher) implementation(deps.kotlin.serialization) - implementation(deps.walletConnectCore) - implementation(deps.walletConnectWeb3) + implementation(deps.reownCore) + implementation(deps.reownWeb3) implementation(deps.prettyLogger) /** Testing libraries */ diff --git a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt index bcf6ba147c..776836a294 100644 --- a/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/walletconnect2/data/DefaultLegacyWalletConnectRepository.kt @@ -2,6 +2,11 @@ package com.tangem.tap.domain.walletconnect2.data import android.app.Application import arrow.core.flatten +import com.reown.android.Core +import com.reown.android.CoreClient +import com.reown.android.relay.ConnectionType +import com.reown.walletkit.client.Wallet +import com.reown.walletkit.client.WalletKit import com.tangem.core.analytics.api.AnalyticsEventHandler import com.tangem.tap.common.analytics.events.WalletConnect import com.tangem.tap.domain.walletconnect2.domain.LegacyWalletConnectRepository @@ -9,11 +14,6 @@ import com.tangem.tap.domain.walletconnect2.domain.WcJrpcMethods import com.tangem.tap.domain.walletconnect2.domain.WcJrpcRequestsDeserializer import com.tangem.tap.domain.walletconnect2.domain.WcRequest import com.tangem.tap.domain.walletconnect2.domain.models.* -import com.walletconnect.android.Core -import com.walletconnect.android.CoreClient -import com.walletconnect.android.relay.ConnectionType -import com.walletconnect.web3.wallet.client.Wallet -import com.walletconnect.web3.wallet.client.Web3Wallet import kotlinx.coroutines.* import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableSharedFlow @@ -72,7 +72,7 @@ internal class DefaultLegacyWalletConnectRepository( } } - Web3Wallet.initialize(Wallet.Params.Init(core = CoreClient)) { error -> + WalletKit.initialize(Wallet.Params.Init(core = CoreClient)) { error -> Timber.e("Error while initializing Web3Wallet: $error") scope.launch { _events.emit( @@ -84,11 +84,11 @@ internal class DefaultLegacyWalletConnectRepository( } val walletDelegate = defineWalletDelegate() - Web3Wallet.setWalletDelegate(walletDelegate) + WalletKit.setWalletDelegate(walletDelegate) } - private fun defineWalletDelegate(): Web3Wallet.WalletDelegate { - return object : Web3Wallet.WalletDelegate { + private fun defineWalletDelegate(): WalletKit.WalletDelegate { + return object : WalletKit.WalletDelegate { override fun onSessionProposal( sessionProposal: Wallet.Model.SessionProposal, verifyContext: Wallet.Model.VerifyContext, @@ -188,14 +188,6 @@ internal class DefaultLegacyWalletConnectRepository( } } - override fun onAuthRequest( - authRequest: Wallet.Model.AuthRequest, - verifyContext: Wallet.Model.VerifyContext, - ) { - // Triggered when Dapp / Requester makes an authorization request - Timber.i("onAuthRequest: $authRequest") - } - override fun onSessionDelete(sessionDelete: Wallet.Model.SessionDelete) { // Triggered when the session is deleted by the peer if (sessionDelete is Wallet.Model.SessionDelete.Success) { @@ -251,7 +243,7 @@ internal class DefaultLegacyWalletConnectRepository( } override fun pair(uri: String) { - Web3Wallet.pair( + WalletKit.pair( params = Wallet.Params.Pair(uri), onSuccess = { Timber.i("Paired successfully: $it") @@ -303,7 +295,7 @@ internal class DefaultLegacyWalletConnectRepository( Timber.i("Session approval is prepared for sending: $sessionApproval") - Web3Wallet.approveSession( + WalletKit.approveSession( params = sessionApproval, onSuccess = { Timber.i("Approved successfully: $it") @@ -364,7 +356,7 @@ internal class DefaultLegacyWalletConnectRepository( ) } - Web3Wallet.respondSessionRequest( + WalletKit.respondSessionRequest( params = Wallet.Params.SessionRequestResponse( sessionTopic = requestData.topic, jsonRpcResponse = Wallet.Model.JsonRpcResponse.JsonRpcResult( @@ -409,7 +401,7 @@ internal class DefaultLegacyWalletConnectRepository( } override fun cancelRequest(topic: String, id: Long, message: String) { - Web3Wallet.respondSessionRequest( + WalletKit.respondSessionRequest( params = Wallet.Params.SessionRequestResponse( sessionTopic = topic, jsonRpcResponse = Wallet.Model.JsonRpcResponse.JsonRpcError( @@ -424,7 +416,7 @@ internal class DefaultLegacyWalletConnectRepository( } override fun reject() { - Web3Wallet.rejectSession( + WalletKit.rejectSession( params = Wallet.Params.SessionReject( proposerPublicKey = sessionProposal?.proposerPublicKey ?: "", reason = "", @@ -440,7 +432,7 @@ internal class DefaultLegacyWalletConnectRepository( override fun disconnect(topic: String) { val session = currentSessions.find { it.topic == topic } - Web3Wallet.disconnectSession( + WalletKit.disconnectSession( params = Wallet.Params.SessionDisconnect(topic), onSuccess = { analyticsHandler.send( @@ -459,7 +451,7 @@ internal class DefaultLegacyWalletConnectRepository( } fun send(topic: String, id: Long, data: String) { - Web3Wallet.respondSessionRequest( + WalletKit.respondSessionRequest( params = Wallet.Params.SessionRequestResponse( sessionTopic = topic, jsonRpcResponse = Wallet.Model.JsonRpcResponse.JsonRpcResult( @@ -477,7 +469,7 @@ internal class DefaultLegacyWalletConnectRepository( } private fun updateSessionsInternal(): Job = scope.launch { - val availableSessions = Web3Wallet.getListOfActiveSessions() + val availableSessions = WalletKit.getListOfActiveSessions() .map { WalletConnectSession( topic = it.topic, diff --git a/gradle/dependencies.toml b/gradle/dependencies.toml index cbd909be0e..42c41b11d8 100644 --- a/gradle/dependencies.toml +++ b/gradle/dependencies.toml @@ -70,8 +70,8 @@ zxingQrCode = "3.5.1" mviCore = "1.3.1" kotlinSerialization = "1.4.1" arrow = "1.2.3" -walletConnectCore = "1.35.2" -walletConnectWeb3 = "1.35.2" +reownCore = "1.0.2" +reownWeb3 = "1.0.2" prettyLogger = "2.2.0" okHttp-prettyLogging = "3.1.0" chucker = "4.0.0" @@ -251,8 +251,8 @@ mviCore-watcher = { module = "com.github.badoo.mvicore:mvicore-diff", version.re kotlin-serialization = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinSerialization" } arrow-core = { module = "io.arrow-kt:arrow-core", version.ref = "arrow" } arrow-fx = { module = "io.arrow-kt:arrow-fx-coroutines", version.ref = "arrow" } -walletConnectCore = { module = "com.walletconnect:android-core", version.ref = "walletConnectCore" } -walletConnectWeb3 = { module = "com.walletconnect:web3wallet", version.ref = "walletConnectWeb3" } +reownCore = { module = "com.reown:android-core", version.ref = "reownCore" } +reownWeb3 = { module = "com.reown:walletkit", version.ref = "reownWeb3" } prettyLogger = { module = "com.orhanobut:logger", version.ref = "prettyLogger" } chucker = { module = "com.github.chuckerteam.chucker:library", version.ref = "chucker" } chuckerStub = { module = "com.github.chuckerteam.chucker:library-no-op", version.ref = "chucker" }