Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ton connect #7780

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -123,6 +124,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -161,6 +163,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -199,6 +202,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -237,6 +241,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -275,6 +280,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -313,6 +319,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -351,6 +358,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -389,6 +397,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -427,6 +436,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down Expand Up @@ -465,6 +475,7 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="tc" />
<data android:scheme="unstoppable.money" />
</intent-filter>
<intent-filter android:label="@string/App_Name">
<action android:name="android.intent.action.VIEW" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -327,10 +328,11 @@ class MainViewModel(
}
}

// deeplinkString.startsWith("tc:") -> {
// deeplinkPage = DeeplinkPage(R.id.tcListFragment, TonConnectMainFragment.Input(deeplinkString))
// tab = MainNavigation.Settings
// }
deeplinkString.startsWith("unstoppable.money:") ||
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down