From 9eea75683a001d0dbe91d4d334a55bddcd080a9a Mon Sep 17 00:00:00 2001 From: kubel Date: Tue, 29 Oct 2024 07:28:21 +0100 Subject: [PATCH 1/8] Remove initialization counter --- .../com/reown/walletkit/client/WalletKit.kt | 30 ++----------------- .../sample/wallet/WalletKitApplication.kt | 4 +-- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt index d881f99b8..f7c377919 100644 --- a/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt +++ b/product/walletkit/src/main/kotlin/com/reown/walletkit/client/WalletKit.kt @@ -97,17 +97,13 @@ object WalletKit { @Throws(IllegalStateException::class) fun initialize(params: Wallet.Params.Init, onSuccess: () -> Unit = {}, onError: (Wallet.Model.Error) -> Unit) { coreClient = params.core - var clientInitCounter = 0 - val onSuccessfulInitialization: () -> Unit = { clientInitCounter++ } - - SignClient.initialize(Sign.Params.Init(params.core), onSuccess = onSuccessfulInitialization) { error -> + SignClient.initialize(Sign.Params.Init(params.core), onSuccess = onSuccess) { error -> if (error.throwable is SignClientAlreadyInitializedException) { - onSuccessfulInitialization() + onSuccess() } else { onError(Wallet.Model.Error(error.throwable)) } } - validateInitializationCount(clientInitCounter, onSuccess, onError) } @Throws(IllegalStateException::class) @@ -340,24 +336,4 @@ object WalletKit { fun getListOfVerifyContexts(): List { return SignClient.getListOfVerifyContexts().map { verifyContext -> verifyContext.toWallet() } } - - private fun validateInitializationCount(clientInitCounter: Int, onSuccess: () -> Unit, onError: (Wallet.Model.Error) -> Unit) { - scope.launch { - try { - withTimeout(TIMEOUT) { - while (true) { - if (clientInitCounter == 2) { - onSuccess() - return@withTimeout - } - delay(100) - } - } - } catch (e: Exception) { - onError(Wallet.Model.Error(e)) - } - } - } - - private const val TIMEOUT: Long = 10000 -} +} \ No newline at end of file diff --git a/sample/wallet/src/main/kotlin/com/reown/sample/wallet/WalletKitApplication.kt b/sample/wallet/src/main/kotlin/com/reown/sample/wallet/WalletKitApplication.kt index 50f42386d..a1f48fafd 100644 --- a/sample/wallet/src/main/kotlin/com/reown/sample/wallet/WalletKitApplication.kt +++ b/sample/wallet/src/main/kotlin/com/reown/sample/wallet/WalletKitApplication.kt @@ -97,10 +97,10 @@ class WalletKitApplication : Application() { FirebaseMessaging.getInstance().token.addOnSuccessListener { token -> WalletKit.registerDeviceToken(firebaseAccessToken = token, enableEncrypted = true, onSuccess = { - println("kobe; Successfully registered firebase token for Web3Wallet: $token") + println("Successfully registered firebase token for Web3Wallet: $token") }, onError = { - println("kobe; Error while registering firebase token for Web3Wallet: ${it.throwable}") + println("Error while registering firebase token for Web3Wallet: ${it.throwable}") } ) } From 8bafdc183913de7f3592da2aa799f67c359ccfbb Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 30 Oct 2024 06:59:15 +0100 Subject: [PATCH 2/8] Versions bump --- buildSrc/src/main/kotlin/Versions.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index e00f7b501..fb8613d55 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID" const val KEY_SDK_NAME = "SDK_NAME" //Latest versions -const val BOM_VERSION = "1.0.0" -const val FOUNDATION_VERSION = "1.0.0" -const val CORE_VERSION = "1.0.0" -const val SIGN_VERSION = "1.0.0" -const val NOTIFY_VERSION = "1.0.0" -const val WALLETKIT_VERSION = "1.0.0" -const val APPKIT_VERSION = "1.0.0" -const val MODAL_CORE_VERSION = "1.0.0" +const val BOM_VERSION = "1.0.1" +const val FOUNDATION_VERSION = "1.0.1" +const val CORE_VERSION = "1.0.1" +const val SIGN_VERSION = "1.0.1" +const val NOTIFY_VERSION = "1.0.1" +const val WALLETKIT_VERSION = "1.0.1" +const val APPKIT_VERSION = "1.0.1" +const val MODAL_CORE_VERSION = "1.0.1" //Artifact ids const val ANDROID_BOM = "android-bom" From 571a3785195964061754e0f9d28514b45be4c1cc Mon Sep 17 00:00:00 2001 From: kubel Date: Wed, 13 Nov 2024 17:13:36 +0100 Subject: [PATCH 3/8] Set app theme onDestroy dialog --- .../main/kotlin/com/reown/appkit/ui/AppKitSheet.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt index 4576f32dc..7cdfc1144 100644 --- a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt +++ b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt @@ -5,6 +5,7 @@ package com.reown.appkit.ui import android.app.Dialog import android.content.Context import android.os.Bundle +import android.util.TypedValue import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -34,12 +35,25 @@ import com.reown.appkit.ui.components.internal.AppKitComponent import com.reown.appkit.ui.theme.ColorPalette class AppKitSheet : BottomSheetDialogFragment() { + private val appTheme: Int by lazy { getApplicationTheme() } override fun onCreate(savedInstanceState: Bundle?) { requireContext().setTheme(R.style.Web3ModalTheme_DialogTheme) + super.onCreate(savedInstanceState) } + override fun onDestroy() { + super.onDestroy() + requireContext().setTheme(appTheme) + } + + private fun getApplicationTheme(): Int { + val typedValue = TypedValue() + requireContext().theme.resolveAttribute(android.R.attr.theme, typedValue, true) + return typedValue.resourceId + } + override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, From d528b6ca204af111529a6774d52c1e8d6b08d416 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 15 Nov 2024 12:37:38 +0100 Subject: [PATCH 4/8] Update getting app theme --- .../src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt index 7cdfc1144..da4977047 100644 --- a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt +++ b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt @@ -35,7 +35,7 @@ import com.reown.appkit.ui.components.internal.AppKitComponent import com.reown.appkit.ui.theme.ColorPalette class AppKitSheet : BottomSheetDialogFragment() { - private val appTheme: Int by lazy { getApplicationTheme() } + private val appTheme: Int by lazy { requireContext().applicationInfo.theme } override fun onCreate(savedInstanceState: Bundle?) { requireContext().setTheme(R.style.Web3ModalTheme_DialogTheme) @@ -48,12 +48,6 @@ class AppKitSheet : BottomSheetDialogFragment() { requireContext().setTheme(appTheme) } - private fun getApplicationTheme(): Int { - val typedValue = TypedValue() - requireContext().theme.resolveAttribute(android.R.attr.theme, typedValue, true) - return typedValue.resourceId - } - override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, From 66d58de7d16c07529eb7d17c11b65a1b54c80dc4 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 15 Nov 2024 12:48:47 +0100 Subject: [PATCH 5/8] onSaveInstanceState crash fix --- .../kotlin/com/reown/appkit/ui/AppKitSheet.kt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt index da4977047..171875976 100644 --- a/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt +++ b/product/appkit/src/main/kotlin/com/reown/appkit/ui/AppKitSheet.kt @@ -5,6 +5,8 @@ package com.reown.appkit.ui import android.app.Dialog import android.content.Context import android.os.Bundle +import android.os.Handler +import android.os.Looper import android.util.TypedValue import android.view.LayoutInflater import android.view.View @@ -84,7 +86,18 @@ class AppKitSheet : BottomSheetDialogFragment() { modifier = Modifier.nestedScroll(rememberNestedScrollInteropConnection()), navController = navController, shouldOpenChooseNetwork = shouldOpenChooseNetwork, - closeModal = { this@AppKitSheet.dismiss() }) + closeModal = { + if (isAdded) { + if (!isStateSaved) { + this@AppKitSheet.dismiss() + } else { + Handler(Looper.getMainLooper()).post { + this@AppKitSheet.dismissAllowingStateLoss() + } + } + } + } + ) } } From c3050aeb2072232265e5e50b9853cbea90b11dd3 Mon Sep 17 00:00:00 2001 From: kubel Date: Fri, 15 Nov 2024 14:54:36 +0100 Subject: [PATCH 6/8] Fix callback --- build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Versions.kt | 18 +++++++++--------- .../com/reown/appkit/engine/AppKitEngine.kt | 8 +++++--- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e8d4c4cd7..326de8651 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -112,7 +112,7 @@ task("clean") { nexusPublishing { repositories { -// project.version = "-SNAPSHOT" + project.version = "-SNAPSHOT" sonatype { stagingProfileId.set(System.getenv("REOWN_SONATYPE_STAGING_PROFILE_ID")) username.set(System.getenv("OSSRH_USERNAME")) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index fb8613d55..9009c834c 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID" const val KEY_SDK_NAME = "SDK_NAME" //Latest versions -const val BOM_VERSION = "1.0.1" -const val FOUNDATION_VERSION = "1.0.1" -const val CORE_VERSION = "1.0.1" -const val SIGN_VERSION = "1.0.1" -const val NOTIFY_VERSION = "1.0.1" -const val WALLETKIT_VERSION = "1.0.1" -const val APPKIT_VERSION = "1.0.1" -const val MODAL_CORE_VERSION = "1.0.1" +const val BOM_VERSION = "1.0.3-SNAPSHOT" +const val FOUNDATION_VERSION = "1.0.3-SNAPSHOT" +const val CORE_VERSION = "1.0.3-SNAPSHOT" +const val SIGN_VERSION = "1.0.3-SNAPSHOT" +const val NOTIFY_VERSION = "1.0.3-SNAPSHOT" +const val WALLETKIT_VERSION = "1.0.3-SNAPSHOT" +const val APPKIT_VERSION = "1.0.3-SNAPSHOT" +const val MODAL_CORE_VERSION = "1.0.3-SNAPSHOT" //Artifact ids const val ANDROID_BOM = "android-bom" @@ -28,5 +28,5 @@ val jvmVersion = JavaVersion.VERSION_11 const val MIN_SDK: Int = 23 const val TARGET_SDK: Int = 34 const val COMPILE_SDK: Int = TARGET_SDK -val SAMPLE_VERSION_CODE = BOM_VERSION.replace(".", "").toInt() +val SAMPLE_VERSION_CODE = BOM_VERSION.replace("-SNAPSHOT", "").replace(".", "").toInt() const val SAMPLE_VERSION_NAME = BOM_VERSION \ No newline at end of file diff --git a/product/appkit/src/main/kotlin/com/reown/appkit/engine/AppKitEngine.kt b/product/appkit/src/main/kotlin/com/reown/appkit/engine/AppKitEngine.kt index 46b3c16c1..8a5de627c 100644 --- a/product/appkit/src/main/kotlin/com/reown/appkit/engine/AppKitEngine.kt +++ b/product/appkit/src/main/kotlin/com/reown/appkit/engine/AppKitEngine.kt @@ -205,9 +205,11 @@ internal class AppKitEngine( SignClient.disconnect(Sign.Params.Disconnect(session.topic), onSuccess = { sendEventUseCase.send(Props(EventType.TRACK, EventType.Track.DISCONNECT_SUCCESS)) - scope.launch { deleteSessionDataUseCase() } - shouldDisconnect = true - onSuccess() + scope.launch { + deleteSessionDataUseCase() + shouldDisconnect = true + onSuccess() + } }, onError = { sendEventUseCase.send(Props(EventType.TRACK, EventType.Track.DISCONNECT_ERROR)) From ec5b30590a3b49777e2b7fab5b4e86ba4dbfb79f Mon Sep 17 00:00:00 2001 From: kubel Date: Mon, 18 Nov 2024 10:10:25 +0100 Subject: [PATCH 7/8] Clean up --- build.gradle.kts | 2 +- buildSrc/src/main/kotlin/Versions.kt | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 326de8651..e8d4c4cd7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -112,7 +112,7 @@ task("clean") { nexusPublishing { repositories { - project.version = "-SNAPSHOT" +// project.version = "-SNAPSHOT" sonatype { stagingProfileId.set(System.getenv("REOWN_SONATYPE_STAGING_PROFILE_ID")) username.set(System.getenv("OSSRH_USERNAME")) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index 9009c834c..fb8613d55 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID" const val KEY_SDK_NAME = "SDK_NAME" //Latest versions -const val BOM_VERSION = "1.0.3-SNAPSHOT" -const val FOUNDATION_VERSION = "1.0.3-SNAPSHOT" -const val CORE_VERSION = "1.0.3-SNAPSHOT" -const val SIGN_VERSION = "1.0.3-SNAPSHOT" -const val NOTIFY_VERSION = "1.0.3-SNAPSHOT" -const val WALLETKIT_VERSION = "1.0.3-SNAPSHOT" -const val APPKIT_VERSION = "1.0.3-SNAPSHOT" -const val MODAL_CORE_VERSION = "1.0.3-SNAPSHOT" +const val BOM_VERSION = "1.0.1" +const val FOUNDATION_VERSION = "1.0.1" +const val CORE_VERSION = "1.0.1" +const val SIGN_VERSION = "1.0.1" +const val NOTIFY_VERSION = "1.0.1" +const val WALLETKIT_VERSION = "1.0.1" +const val APPKIT_VERSION = "1.0.1" +const val MODAL_CORE_VERSION = "1.0.1" //Artifact ids const val ANDROID_BOM = "android-bom" @@ -28,5 +28,5 @@ val jvmVersion = JavaVersion.VERSION_11 const val MIN_SDK: Int = 23 const val TARGET_SDK: Int = 34 const val COMPILE_SDK: Int = TARGET_SDK -val SAMPLE_VERSION_CODE = BOM_VERSION.replace("-SNAPSHOT", "").replace(".", "").toInt() +val SAMPLE_VERSION_CODE = BOM_VERSION.replace(".", "").toInt() const val SAMPLE_VERSION_NAME = BOM_VERSION \ No newline at end of file From 1a50ea5ef678c32e63695876a4451c533a563972 Mon Sep 17 00:00:00 2001 From: kubel Date: Mon, 18 Nov 2024 10:22:16 +0100 Subject: [PATCH 8/8] Version bump --- buildSrc/src/main/kotlin/Versions.kt | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt index fb8613d55..bac44a1b5 100644 --- a/buildSrc/src/main/kotlin/Versions.kt +++ b/buildSrc/src/main/kotlin/Versions.kt @@ -5,14 +5,14 @@ const val KEY_PUBLISH_ARTIFACT_ID = "PUBLISH_ARTIFACT_ID" const val KEY_SDK_NAME = "SDK_NAME" //Latest versions -const val BOM_VERSION = "1.0.1" -const val FOUNDATION_VERSION = "1.0.1" -const val CORE_VERSION = "1.0.1" -const val SIGN_VERSION = "1.0.1" -const val NOTIFY_VERSION = "1.0.1" -const val WALLETKIT_VERSION = "1.0.1" -const val APPKIT_VERSION = "1.0.1" -const val MODAL_CORE_VERSION = "1.0.1" +const val BOM_VERSION = "1.0.2" +const val FOUNDATION_VERSION = "1.0.2" +const val CORE_VERSION = "1.0.2" +const val SIGN_VERSION = "1.0.2" +const val NOTIFY_VERSION = "1.0.2" +const val WALLETKIT_VERSION = "1.0.2" +const val APPKIT_VERSION = "1.0.2" +const val MODAL_CORE_VERSION = "1.0.2" //Artifact ids const val ANDROID_BOM = "android-bom"