Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:reown-com/reown-kotlin into use_…
Browse files Browse the repository at this point in the history
…package_name_in_relay_header
  • Loading branch information
jakubuid committed Dec 3, 2024
2 parents ab8d8b8 + 1a50ea5 commit 45daef9
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 41 deletions.
16 changes: 8 additions & 8 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ 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
import android.view.ViewGroup
Expand Down Expand Up @@ -34,12 +37,19 @@ import com.reown.appkit.ui.components.internal.AppKitComponent
import com.reown.appkit.ui.theme.ColorPalette

class AppKitSheet : BottomSheetDialogFragment() {
private val appTheme: Int by lazy { requireContext().applicationInfo.theme }

override fun onCreate(savedInstanceState: Bundle?) {
requireContext().setTheme(R.style.Web3ModalTheme_DialogTheme)

super.onCreate(savedInstanceState)
}

override fun onDestroy() {
super.onDestroy()
requireContext().setTheme(appTheme)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
Expand Down Expand Up @@ -76,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()
}
}
}
}
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -340,24 +336,4 @@ object WalletKit {
fun getListOfVerifyContexts(): List<Wallet.Model.VerifyContext> {
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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
}
)
}
Expand Down

0 comments on commit 45daef9

Please sign in to comment.