From f1f089f946e42db7202755eb308752a53131b037 Mon Sep 17 00:00:00 2001 From: abdrasulov Date: Wed, 27 Nov 2024 15:39:55 +0600 Subject: [PATCH 1/2] Enable ton-connect --- .../bankwallet/modules/main/MainViewModel.kt | 9 +++--- .../settings/main/MainSettingsScreen.kt | 30 +++++++++---------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt index e942fc9da7..d0c20a7392 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt @@ -25,6 +25,7 @@ import io.horizontalsystems.bankwallet.modules.coin.CoinFragment import io.horizontalsystems.bankwallet.modules.main.MainModule.MainNavigation import io.horizontalsystems.bankwallet.modules.market.topplatforms.Platform import io.horizontalsystems.bankwallet.modules.nft.collection.NftCollectionFragment +import io.horizontalsystems.bankwallet.modules.tonconnect.TonConnectMainFragment import io.horizontalsystems.bankwallet.modules.walletconnect.WCManager import io.horizontalsystems.bankwallet.modules.walletconnect.WCSessionManager import io.horizontalsystems.bankwallet.modules.walletconnect.list.WCListFragment @@ -327,10 +328,10 @@ class MainViewModel( } } -// deeplinkString.startsWith("tc:") -> { -// deeplinkPage = DeeplinkPage(R.id.tcListFragment, TonConnectMainFragment.Input(deeplinkString)) -// tab = MainNavigation.Settings -// } + deeplinkString.startsWith("tc:") -> { + deeplinkPage = DeeplinkPage(R.id.tcListFragment, TonConnectMainFragment.Input(deeplinkString)) + tab = MainNavigation.Settings + } deeplinkString.startsWith("https://unstoppable.money/referral") -> { val userId: String? = deepLink.getQueryParameter("userId") diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt index e234c23cfa..cba3e31d5e 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/settings/main/MainSettingsScreen.kt @@ -184,21 +184,21 @@ private fun SettingSections( } } ) -// }, { -// HsSettingCell( -// title = R.string.Settings_TonConnect, -// icon = R.drawable.ic_ton_connect_24, -// value = null, -// counterBadge = null, -// onClick = { -// navController.slideFromRight(R.id.tcListFragment) -// -// stat( -// page = StatPage.Settings, -// event = StatEvent.Open(StatPage.TonConnect) -// ) -// } -// ) + }, { + HsSettingCell( + title = R.string.Settings_TonConnect, + icon = R.drawable.ic_ton_connect_24, + value = null, + counterBadge = null, + onClick = { + navController.slideFromRight(R.id.tcListFragment) + + stat( + page = StatPage.Settings, + event = StatEvent.Open(StatPage.TonConnect) + ) + } + ) }, { HsSettingCell( R.string.BackupManager_Title, From 2a55a6622d0b6c9a17dc5f053a813d8f71603fc7 Mon Sep 17 00:00:00 2001 From: abdrasulov Date: Thu, 28 Nov 2024 13:23:26 +0600 Subject: [PATCH 2/2] Update ton-connect-kit --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 11 +++++++++++ .../java/io/horizontalsystems/bankwallet/core/App.kt | 7 ++++++- .../bankwallet/core/managers/TonConnectManager.kt | 9 +++++++-- .../bankwallet/modules/balance/BalanceViewModel.kt | 5 ++++- .../bankwallet/modules/main/MainViewModel.kt | 1 + 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e2ee3c1d4f..fe7c9519ae 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -281,7 +281,7 @@ dependencies { debugImplementation leakCanary // Wallet kits - implementation 'com.github.horizontalsystems:ton-kit-android:763a5c3' + implementation 'com.github.horizontalsystems:ton-kit-android:969fe77' implementation 'com.github.horizontalsystems:bitcoin-kit-android:ced5801' implementation 'com.github.horizontalsystems:ethereum-kit-android:a5eff38' implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 12249789a4..c3f947f63f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -85,6 +85,7 @@ + @@ -123,6 +124,7 @@ + @@ -161,6 +163,7 @@ + @@ -199,6 +202,7 @@ + @@ -237,6 +241,7 @@ + @@ -275,6 +280,7 @@ + @@ -313,6 +319,7 @@ + @@ -351,6 +358,7 @@ + @@ -389,6 +397,7 @@ + @@ -427,6 +436,7 @@ + @@ -465,6 +475,7 @@ + diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt index af88305552..63b5c3d3d2 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/App.kt @@ -453,7 +453,12 @@ class App : CoreApp(), WorkConfiguration.Provider, ImageLoaderFactory { spamManager = SpamManager(localStorage) - tonConnectManager = TonConnectManager(this, adapterFactory) + tonConnectManager = TonConnectManager( + context = this, + adapterFactory = adapterFactory, + appName = "Unstoppable Wallet", + appVersion = appConfigProvider.appVersion + ) tonConnectManager.start() startTasks() diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TonConnectManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TonConnectManager.kt index 084fea65f1..8a1ea618aa 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TonConnectManager.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/TonConnectManager.kt @@ -9,8 +9,13 @@ import io.horizontalsystems.tonkit.tonconnect.TonConnectKit import kotlinx.coroutines.flow.MutableSharedFlow import kotlinx.coroutines.flow.asSharedFlow -class TonConnectManager(context: Context, val adapterFactory: AdapterFactory) { - val kit = TonConnectKit.getInstance(context) +class TonConnectManager( + context: Context, + val adapterFactory: AdapterFactory, + appName: String, + appVersion: String, +) { + val kit = TonConnectKit.getInstance(context, appName, appVersion) val transactionSigner = TonKit.getTransactionSigner(TonKit.getTonApi(Network.MainNet)) val sendRequestFlow by kit::sendRequestFlow diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt index 9116a3d977..315e774d03 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/balance/BalanceViewModel.kt @@ -243,7 +243,10 @@ class BalanceViewModel( fun handleScannedData(scannedText: String) { viewModelScope.launch { - if (scannedText.startsWith("tc:")) { + if ( + scannedText.startsWith("tc:") || + scannedText.startsWith("https://unstoppable.money/ton-connect") + ) { App.tonConnectManager.handle(scannedText) } else { val wcUriVersion = WalletConnectListModule.getVersionFromUri(scannedText) diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt index d0c20a7392..b82b3bad01 100644 --- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt +++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainViewModel.kt @@ -328,6 +328,7 @@ class MainViewModel( } } + deeplinkString.startsWith("unstoppable.money:") || deeplinkString.startsWith("tc:") -> { deeplinkPage = DeeplinkPage(R.id.tcListFragment, TonConnectMainFragment.Input(deeplinkString)) tab = MainNavigation.Settings