Skip to content

Commit c3b3101

Browse files
v4.2.8
1 parent ab7e2a0 commit c3b3101

File tree

290 files changed

+7335
-3442
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+7335
-3442
lines changed

changelogs/4.2.8.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Bug fixes and performance improvements

mobile/android/air/SubModules/AirAsFramework/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dependencies {
5454
implementation(project("$airSubModulePath:UIAssets"))
5555
implementation(project("$airSubModulePath:UIBrowser"))
5656
implementation(project("$airSubModulePath:UISettings"))
57+
implementation(project("$airSubModulePath:UITonConnect"))
5758
implementation(project("$airSubModulePath:WalletContext"))
5859
implementation(project("$airSubModulePath:WalletBaseContext"))
5960
implementation(project("$airSubModulePath:WalletCore"))

mobile/android/air/SubModules/AirAsFramework/src/main/java/org/mytonwallet/app_air/airasframework/MainWindow.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ class MainWindow : WWindow() {
5151

5252
fun restartBridge(forcedRecreation: Boolean) {
5353
splashVC.preloadScreens()
54-
WalletCore.setupBridge(this, windowView, forcedRecreation = forcedRecreation) {
54+
WalletCore.setupBridge(
55+
applicationContext,
56+
windowView,
57+
forcedRecreation = forcedRecreation
58+
) {
5559
// Bridge ready now!
5660
splashVC.bridgeIsReady()
5761
setAppFocusedState()

mobile/android/air/SubModules/AirAsFramework/src/main/java/org/mytonwallet/app_air/airasframework/WidgetConfigurationWindow.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class WidgetConfigurationWindow : WWindow() {
4949
super.onCreate(savedInstanceState)
5050

5151
if (!WGlobalStorage.isInitialized) {
52+
finish()
5253
return
5354
}
5455

@@ -64,7 +65,12 @@ class WidgetConfigurationWindow : WWindow() {
6465
}
6566

6667
fun restartBridge(forcedRecreation: Boolean) {
67-
WalletCore.setupBridge(this, windowView, forcedRecreation = forcedRecreation) {
68+
WalletCore.setupBridge(
69+
applicationContext,
70+
windowView,
71+
forcedRecreation = forcedRecreation,
72+
isOnAirApp = false
73+
) {
6874
setAppFocusedState()
6975
}
7076
}

mobile/android/air/SubModules/AirAsFramework/src/main/java/org/mytonwallet/app_air/airasframework/splash/SplashVC.kt

Lines changed: 132 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ import org.mytonwallet.app_air.uisend.send.SendVC
3737
import org.mytonwallet.app_air.uisend.send.SendVC.InitialValues
3838
import org.mytonwallet.app_air.uistake.earn.EarnRootVC
3939
import org.mytonwallet.app_air.uiswap.screens.swap.SwapVC
40+
import org.mytonwallet.app_air.uitonconnect.TonConnectController
41+
import org.mytonwallet.app_air.uitonconnect.viewControllers.connect.TonConnectRequestConnectVC
42+
import org.mytonwallet.app_air.uitonconnect.viewControllers.send.requestSend.TonConnectRequestSendVC
43+
import org.mytonwallet.app_air.walletbasecontext.localization.LocaleController
44+
import org.mytonwallet.app_air.walletbasecontext.logger.LogMessage
45+
import org.mytonwallet.app_air.walletbasecontext.logger.Logger
46+
import org.mytonwallet.app_air.walletbasecontext.theme.WColor
47+
import org.mytonwallet.app_air.walletbasecontext.theme.color
4048
import org.mytonwallet.app_air.walletcontext.WalletContextManager
4149
import org.mytonwallet.app_air.walletcontext.WalletContextManagerDelegate
4250
import org.mytonwallet.app_air.walletcontext.cacheStorage.WCacheStorage
@@ -46,8 +54,6 @@ import org.mytonwallet.app_air.walletcontext.helpers.BiometricHelpers
4654
import org.mytonwallet.app_air.walletcontext.helpers.LaunchConfig
4755
import org.mytonwallet.app_air.walletcontext.helpers.WordCheckMode
4856
import org.mytonwallet.app_air.walletcontext.secureStorage.WSecureStorage
49-
import org.mytonwallet.app_air.walletbasecontext.theme.WColor
50-
import org.mytonwallet.app_air.walletbasecontext.theme.color
5157
import org.mytonwallet.app_air.walletcontext.utils.CoinUtils
5258
import org.mytonwallet.app_air.walletcore.MAIN_NETWORK
5359
import org.mytonwallet.app_air.walletcore.TEST_NETWORK
@@ -64,25 +70,25 @@ import org.mytonwallet.app_air.walletcore.deeplink.DeeplinkParser
6470
import org.mytonwallet.app_air.walletcore.helpers.TonConnectHelper
6571
import org.mytonwallet.app_air.walletcore.models.MAccount
6672
import org.mytonwallet.app_air.walletcore.models.MBlockchain
73+
import org.mytonwallet.app_air.walletcore.moshi.ApiConnectionType
6774
import org.mytonwallet.app_air.walletcore.moshi.MApiSwapAsset
6875
import org.mytonwallet.app_air.walletcore.moshi.api.ApiMethod.DApp.StartSseConnection
6976
import org.mytonwallet.app_air.walletcore.moshi.api.ApiMethod.DApp.StartSseConnection.Request
77+
import org.mytonwallet.app_air.walletcore.moshi.api.ApiUpdate
7078
import org.mytonwallet.app_air.walletcore.pushNotifications.AirPushNotifications
7179
import org.mytonwallet.app_air.walletcore.stores.AccountStore
7280
import org.mytonwallet.app_air.walletcore.stores.ActivityStore
7381
import org.mytonwallet.app_air.walletcore.stores.BalanceStore
7482
import org.mytonwallet.app_air.walletcore.stores.StakingStore
7583
import org.mytonwallet.app_air.walletcore.stores.TokenStore
76-
import org.mytonwallet.app_air.walletbasecontext.localization.LocaleController
77-
import org.mytonwallet.app_air.walletbasecontext.logger.LogMessage
78-
import org.mytonwallet.app_air.walletbasecontext.logger.Logger
7984
import org.mytonwallet.uihome.tabs.TabsVC
8085
import java.io.UnsupportedEncodingException
8186
import java.net.URLEncoder
8287

8388
class SplashVC(context: Context) : WViewController(context),
8489
WalletContextManagerDelegate,
85-
DeeplinkNavigator {
90+
DeeplinkNavigator,
91+
WalletCore.UpdatesObserver {
8692

8793
override val shouldDisplayTopBar = false
8894

@@ -111,6 +117,7 @@ class SplashVC(context: Context) : WViewController(context),
111117
// Handle possible deep-links right after screen load (like switch to classic on first app launch)
112118
handleDeeplinkIfRequired()
113119
updateTheme()
120+
WalletCore.subscribeToApiUpdates(ApiUpdate.ApiUpdateDappLoading::class.java, this)
114121
}
115122

116123
override fun updateTheme() {
@@ -211,7 +218,7 @@ class SplashVC(context: Context) : WViewController(context),
211218
} else {
212219
// No more accounts left, let's reset
213220
Logger.d(Logger.LogTag.ACCOUNT, "Reset accounts on splash error")
214-
StakingStore.clean()
221+
StakingStore.wipeData()
215222
resetToIntro()
216223
}
217224
} else {
@@ -424,14 +431,60 @@ class SplashVC(context: Context) : WViewController(context),
424431
switchToLegacy()
425432
return
426433
}
427-
if (!_isWalletReady || !isAppUnlocked()) {
434+
if (!_isWalletReady) {
435+
nextDeeplink = deeplink
436+
return
437+
}
438+
handleInstantDeeplinks(deeplink)
439+
if (!isAppUnlocked()) {
428440
nextDeeplink = deeplink
429441
return
430442
}
431443
if (window?.presentPendingPresentationNav() == true) {
432444
nextDeeplink = null
433445
return
434446
}
447+
handleWalletReadyDeeplinks(deeplink)
448+
}
449+
450+
private fun handleInstantDeeplinks(deeplink: Deeplink) {
451+
when (deeplink) {
452+
is Deeplink.TonConnect2 -> {
453+
if (deeplink.isConnectRequest &&
454+
AccountStore.activeAccount?.accountType == MAccount.AccountType.VIEW
455+
) {
456+
return // Will show a dialog after unlock!
457+
}
458+
val uri = try {
459+
encodeUriParams(deeplink.requestUri).toString()
460+
} catch (_: Throwable) {
461+
//Logger.e(Logger.LogTag.DEEPLINK, "Encode error: ${t.toString()}")
462+
return
463+
}
464+
//Logger.d(Logger.LogTag.DEEPLINK, uri)
465+
WalletCore.call(
466+
StartSseConnection(
467+
Request(
468+
url = uri,
469+
deviceInfo = TonConnectHelper.deviceInfo,
470+
identifier = TonConnectHelper.generateId()
471+
)
472+
)
473+
) { returnStrategy, err ->
474+
if (err != null) {
475+
//Logger.e(Logger.LogTag.DEEPLINK, "Error: $err")
476+
return@call
477+
}
478+
//Logger.d(Logger.LogTag.DEEPLINK, "Strategy: $returnStrategy")
479+
}
480+
nextDeeplink = null
481+
}
482+
483+
else -> {}
484+
}
485+
}
486+
487+
private fun handleWalletReadyDeeplinks(deeplink: Deeplink) {
435488
if (deeplink.accountAddress != null) {
436489
val accountId =
437490
AccountStore.accountIdByAddress(deeplink.accountAddress) ?: run {
@@ -489,7 +542,6 @@ class SplashVC(context: Context) : WViewController(context),
489542
return
490543
}
491544

492-
@Suppress("KotlinConstantConditions")
493545
when (deeplink) {
494546
is Deeplink.Invoice -> {
495547
if (AccountStore.activeAccount?.accountType == MAccount.AccountType.VIEW) {
@@ -546,33 +598,17 @@ class SplashVC(context: Context) : WViewController(context),
546598
}
547599

548600
is Deeplink.TonConnect2 -> {
549-
if (AccountStore.activeAccount?.accountType == MAccount.AccountType.VIEW) {
601+
if (deeplink.isConnectRequest &&
602+
AccountStore.activeAccount?.accountType == MAccount.AccountType.VIEW
603+
) {
604+
window?.topViewController?.showAlert(
605+
LocaleController.getString("Error"),
606+
LocaleController.getString("Action is not possible on a view-only wallet.")
607+
)
550608
nextDeeplink = null
551609
return
552610
}
553-
val uri = try {
554-
encodeUriParams(deeplink.requestUri).toString()
555-
} catch (_: Throwable) {
556-
//Logger.e(Logger.LogTag.DEEPLINK, "Encode error: ${t.toString()}")
557-
return
558-
}
559-
//Logger.d(Logger.LogTag.DEEPLINK, uri)
560-
561-
WalletCore.call(
562-
StartSseConnection(
563-
Request(
564-
url = uri,
565-
deviceInfo = TonConnectHelper.deviceInfo,
566-
identifier = TonConnectHelper.generateId()
567-
)
568-
)
569-
) { returnStrategy, err ->
570-
if (err != null) {
571-
//Logger.e(Logger.LogTag.DEEPLINK, "Error: $err")
572-
return@call
573-
}
574-
//Logger.d(Logger.LogTag.DEEPLINK, "Strategy: $returnStrategy")
575-
}
611+
// Already handled
576612
}
577613

578614
is Deeplink.Swap -> {
@@ -758,4 +794,67 @@ class SplashVC(context: Context) : WViewController(context),
758794
}
759795
} ?: onThemeChanged()
760796
}
797+
798+
private fun presentTonConnectLoading() {
799+
window?.let { window ->
800+
val tonConnectRequestVC = TonConnectRequestConnectVC(window)
801+
val isLoadingVCAdded =
802+
TonConnectController.setLoadingConnectRequestViewController(
803+
tonConnectRequestVC
804+
)
805+
if (isLoadingVCAdded) {
806+
val navVC = WNavigationController(
807+
window, WNavigationController.PresentationConfig(
808+
overFullScreen = false,
809+
isBottomSheet = true
810+
)
811+
)
812+
navVC.setRoot(tonConnectRequestVC)
813+
if (isAppUnlocked())
814+
window.present(navVC)
815+
else
816+
window.presentOnWalletReady(navVC)
817+
}
818+
}
819+
}
820+
821+
private fun presentTonSendLoading(connectionType: ApiConnectionType) {
822+
window?.let { window ->
823+
if (!window.isAnimating &&
824+
window.pendingPresentationNav?.viewControllers?.firstOrNull() !is TonConnectRequestSendVC
825+
) {
826+
val tonConnectRequestSendVC = TonConnectRequestSendVC(window, connectionType)
827+
val isLoadingVCAdded =
828+
TonConnectController.setLoadingSendRequestViewController(
829+
tonConnectRequestSendVC
830+
)
831+
if (isLoadingVCAdded) {
832+
val navVC = WNavigationController(window)
833+
navVC.setRoot(tonConnectRequestSendVC)
834+
if (isAppUnlocked())
835+
window.present(navVC)
836+
else
837+
window.presentOnWalletReady(navVC)
838+
}
839+
}
840+
}
841+
}
842+
843+
override fun onBridgeUpdate(update: ApiUpdate) {
844+
when (update) {
845+
is ApiUpdate.ApiUpdateDappLoading -> {
846+
when (update.connectionType) {
847+
ApiConnectionType.CONNECT -> {
848+
presentTonConnectLoading()
849+
}
850+
851+
ApiConnectionType.SEND_TRANSACTION, ApiConnectionType.SIGN_DATA -> {
852+
presentTonSendLoading(update.connectionType)
853+
}
854+
}
855+
}
856+
857+
else -> {}
858+
}
859+
}
761860
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp"
3+
android:height="24dp"
4+
android:viewportWidth="24"
5+
android:viewportHeight="24">
6+
<path
7+
android:pathData="M18.5,15.25L12,8.75L5.5,15.25"
8+
android:strokeLineJoin="round"
9+
android:strokeWidth="2.1"
10+
android:fillColor="#00000000"
11+
android:strokeColor="#717579"
12+
android:strokeLineCap="round"/>
13+
</vector>

mobile/android/air/SubModules/Icons/src/main/res/drawable/ic_details.xml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,27 @@
44
android:viewportWidth="20"
55
android:viewportHeight="20">
66
<path
7-
android:pathData="M11.323,5.125C10.52,5.125 9.869,5.776 9.869,6.578C9.869,7.381 10.52,8.032 11.323,8.032C12.125,8.032 12.776,7.381 12.776,6.578C12.776,5.776 12.125,5.125 11.323,5.125ZM8.465,5.828C8.797,4.56 9.951,3.625 11.323,3.625C12.695,3.625 13.848,4.56 14.18,5.828H16.25C16.665,5.828 17,6.164 17,6.578C17,6.993 16.665,7.328 16.25,7.328H14.18C13.848,8.596 12.695,9.532 11.323,9.532C9.951,9.532 8.797,8.596 8.465,7.328H3.75C3.336,7.328 3,6.993 3,6.578C3,6.164 3.336,5.828 3.75,5.828H8.465ZM8.678,11.968C7.876,11.968 7.225,12.619 7.225,13.421C7.225,14.224 7.876,14.875 8.678,14.875C9.481,14.875 10.132,14.224 10.132,13.421C10.132,12.619 9.481,11.968 8.678,11.968ZM5.821,12.671C6.153,11.403 7.306,10.468 8.678,10.468C10.05,10.468 11.204,11.403 11.536,12.671H16.25C16.665,12.671 17,13.007 17,13.421C17,13.836 16.665,14.171 16.25,14.171H11.536C11.204,15.439 10.05,16.375 8.678,16.375C7.306,16.375 6.153,15.439 5.821,14.171H3.75C3.336,14.171 3,13.836 3,13.421C3,13.007 3.336,12.671 3.75,12.671H5.821Z"
8-
android:fillColor="#89898B"
9-
android:fillType="evenOdd"/>
7+
android:pathData="M5.417,11.683L5.417,11.683A2.9,2.9 0,0 1,8.316 14.583L8.316,14.583A2.9,2.9 0,0 1,5.417 17.483L5.417,17.483A2.9,2.9 0,0 1,2.516 14.583L2.516,14.583A2.9,2.9 0,0 1,5.417 11.683z"
8+
android:strokeWidth="1.7"
9+
android:fillColor="#00000000"
10+
android:strokeColor="#717579"/>
11+
<path
12+
android:pathData="M11.667,14.583H17.083"
13+
android:strokeLineJoin="round"
14+
android:strokeWidth="1.7"
15+
android:fillColor="#00000000"
16+
android:strokeColor="#717579"
17+
android:strokeLineCap="round"/>
18+
<path
19+
android:pathData="M2.917,5.417H8.333"
20+
android:strokeLineJoin="round"
21+
android:strokeWidth="1.7"
22+
android:fillColor="#00000000"
23+
android:strokeColor="#717579"
24+
android:strokeLineCap="round"/>
25+
<path
26+
android:pathData="M14.583,2.517L14.583,2.517A2.9,2.9 0,0 1,17.483 5.417L17.483,5.417A2.9,2.9 0,0 1,14.583 8.317L14.583,8.317A2.9,2.9 0,0 1,11.684 5.417L11.684,5.417A2.9,2.9 0,0 1,14.583 2.517z"
27+
android:strokeWidth="1.7"
28+
android:fillColor="#00000000"
29+
android:strokeColor="#717579"/>
1030
</vector>

0 commit comments

Comments
 (0)