diff --git a/app/build.gradle b/app/build.gradle
index 1f5d772e11..6b50b18b5d 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -19,8 +19,8 @@ android {
compileSdk compile_sdk_version
minSdkVersion min_sdk_version
targetSdkVersion compile_sdk_version
- versionCode 112
- versionName "0.39.2"
+ versionCode 113
+ versionName "0.39.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
ksp {
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 76022b0928..b671a4a0c4 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -92,6 +92,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/Interfaces.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/Interfaces.kt
index eba4b87302..66b2545769 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/core/Interfaces.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/Interfaces.kt
@@ -7,6 +7,7 @@ import io.horizontalsystems.bankwallet.core.adapters.zcash.ZcashAdapter
import io.horizontalsystems.bankwallet.core.managers.ActiveAccountState
import io.horizontalsystems.bankwallet.core.managers.Bep2TokenInfoService
import io.horizontalsystems.bankwallet.core.managers.EvmKitWrapper
+import io.horizontalsystems.bankwallet.core.managers.MiniAppRegisterService.RegisterAppResponse
import io.horizontalsystems.bankwallet.core.providers.FeeRates
import io.horizontalsystems.bankwallet.core.utils.AddressUriResult
import io.horizontalsystems.bankwallet.entities.Account
@@ -214,6 +215,7 @@ interface INetworkManager {
fun ping(host: String, url: String, isSafeCall: Boolean): Flowable
fun getEvmInfo(host: String, path: String): Single
suspend fun getBep2Tokens(): List
+ suspend fun registerApp(userId: String, referralCode: String): RegisterAppResponse
}
interface IClipboardManager {
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/NetworkManager.kt b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/NetworkManager.kt
index 468e88ce96..24d0a2a059 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/NetworkManager.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/core/managers/NetworkManager.kt
@@ -53,6 +53,11 @@ class NetworkManager : INetworkManager {
override suspend fun getBep2Tokens(): List {
return Bep2TokenInfoService.service().tokens()
}
+
+ override suspend fun registerApp(userId: String, referralCode: String)
+ : MiniAppRegisterService.RegisterAppResponse {
+ return MiniAppRegisterService.service().registerApp(userId, referralCode)
+ }
}
object ServiceFullTransaction {
@@ -145,6 +150,28 @@ object ServiceChangeLogs {
}
}
+object MiniAppRegisterService {
+ private val apiUrl = "https://be.unstoppable.money/"
+
+ fun service(): UnstoppableApi {
+ return APIClient.retrofit(apiUrl, 60)
+ .create(UnstoppableApi::class.java)
+ }
+
+ interface UnstoppableApi {
+ @GET("api/v1/tasks/registerApp")
+ suspend fun registerApp(
+ @Query("userId") userId: String,
+ @Query("referralCode") referralCode: String
+ ): RegisterAppResponse
+ }
+
+ data class RegisterAppResponse(
+ val success: Boolean,
+ val message: String
+ )
+}
+
object APIClient {
private val logger = HttpLoggingInterceptor().apply {
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainModule.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainModule.kt
index 28424d5c40..5c42615e66 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainModule.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/main/MainModule.kt
@@ -28,6 +28,7 @@ object MainModule {
App.localStorage,
App.wcSessionManager,
App.wcManager,
+ App.networkManager,
) as T
}
}
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 9184164758..01b63ad02e 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
@@ -1,12 +1,14 @@
package io.horizontalsystems.bankwallet.modules.main
import android.net.Uri
+import android.util.Log
import androidx.lifecycle.viewModelScope
import cash.z.ecc.android.sdk.ext.collectWith
import io.horizontalsystems.bankwallet.R
import io.horizontalsystems.bankwallet.core.IAccountManager
import io.horizontalsystems.bankwallet.core.IBackupManager
import io.horizontalsystems.bankwallet.core.ILocalStorage
+import io.horizontalsystems.bankwallet.core.INetworkManager
import io.horizontalsystems.bankwallet.core.IRateAppManager
import io.horizontalsystems.bankwallet.core.ITermsManager
import io.horizontalsystems.bankwallet.core.ViewModelUiState
@@ -41,6 +43,7 @@ class MainViewModel(
private val localStorage: ILocalStorage,
wcSessionManager: WCSessionManager,
private val wcManager: WCManager,
+ private val networkManager: INetworkManager
) : ViewModelUiState() {
private var wcPendingRequestsCount = 0
@@ -320,11 +323,34 @@ class MainViewModel(
}
}
+ deeplinkString.startsWith("https://unstoppable.money/referral") -> {
+ val userId: String? = deepLink.getQueryParameter("userId")
+ val referralCode: String? = deepLink.getQueryParameter("referralCode")
+ if (userId != null && referralCode != null) {
+ registerApp(userId, referralCode)
+ }
+ }
+
else -> {}
}
return Pair(tab, deeplinkPage)
}
+ private fun registerApp(userId: String, referralCode: String) {
+ viewModelScope.launch {
+ try {
+ val response = networkManager.registerApp(userId, referralCode)
+ if (response.success) {
+ //do nothing
+ } else {
+ Log.e("MainViewModel", "registerApp api fail message: ${response.message}")
+ }
+ } catch (e: Exception) {
+ Log.e("MainViewModel", "registerApp error: ", e)
+ }
+ }
+ }
+
private fun syncNavigation() {
mainNavItems = navigationItems()
if (selectedTabIndex >= mainNavItems.size) {