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

CoreClient.initialize Error in Kotlin #948

Open
constantinp2022 opened this issue Jun 24, 2023 · 2 comments
Open

CoreClient.initialize Error in Kotlin #948

constantinp2022 opened this issue Jun 24, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@constantinp2022
Copy link

Describe the bug
I am trying to create an dApp on mobile using kotlin language in Android Studio.
When I am trying to create a new pairing and connect using deeplink the wallet opens but NO pop up appears.
In the logs I can find the stack trace provided

SDK Version

  • Client: Kotlin
    implementation("com.walletconnect:android-core:1.12.0")
    implementation("com.walletconnect:sign:2.10.0")

To Reproduce
Steps to reproduce the behavior:

  1. Have the CoreClient.initialize and SignClient.initialize in MainActivity function onCreate
  2. The pairing and connectParams are created on a button action calling a view model

Expected behavior
The error should not appear at all and the connection view should appear on the wallet.

Screenshots
If applicable, add screenshots to help explain your problem.

Stack Trace:
E/cpr_error: CoreClient.initialize com.walletconnect.android.internal.common.exception.GenericException
at com.walletconnect.android.utils.ExtensionsKt.getToWalletConnectException(Extensions.kt:57)
at com.walletconnect.android.relay.RelayClient$collectConnectionErrors$$inlined$map$1$2.emit(Emitters.kt:224)
at com.walletconnect.android.relay.RelayClient$collectConnectionErrors$$inlined$filterIsInstance$1$2.emit(Emitters.kt:224)
at kotlinx.coroutines.flow.FlowKt__TransformKt$onEach$$inlined$unsafeTransform$1$2.emit(Emitters.kt:224)
at kotlinx.coroutines.flow.SharedFlowImpl.collect$suspendImpl(SharedFlow.kt:383)
at kotlinx.coroutines.flow.SharedFlowImpl$collect$1.invokeSuspend(Unknown Source:15)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
at kotlinx.coroutines.internal.LimitedDispatcher.run(LimitedDispatcher.kt:42)
at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:95)
at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677)
at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)

@constantinp2022 constantinp2022 added the bug Something isn't working label Jun 24, 2023
@constantinp2022
Copy link
Author

Additional mentions:

  1. I am using compose and coroutines
  2. Using NavHostController for navigation within the app
  3. I have successfully done the connection with the wallet previously the only difference it was a different screen(different nav) where I call the ViewModel function connectToWallet is similar as in the example provided by you

@constantinp2022
Copy link
Author

constantinp2022 commented Jun 24, 2023

Extra additional Mention:
The connection with the relay seems to fail if it's done immediatly after starting the app:

  1. Stack Trace:

Failed to CONNECT! com.walletconnect.android.internal.common.exception.NoRelayConnectionException: No connection available
at com.walletconnect.android.internal.common.json_rpc.domain.JsonRpcInteractor.checkConnectionWorking(JsonRpcInteractor.kt:56)
at com.walletconnect.android.internal.common.json_rpc.domain.JsonRpcInteractor.subscribe(JsonRpcInteractor.kt:223)
at com.walletconnect.android.internal.common.model.type.JsonRpcInteractorInterface$DefaultImpls.subscribe$default(JsonRpcInteractorInterface.kt:17)
at com.walletconnect.android.pairing.engine.domain.PairingEngine.create(PairingEngine.kt:91)
at com.walletconnect.android.pairing.client.PairingProtocol.create(PairingProtocol.kt:42)
at com.fantompay.fpay.web3connection.connect.ConnectViewModel.connectToWallet(ConnectViewModel.kt:140)
at com.fantompay.fpay.screen.WelcomeScreenKt$Web3Login$openWallet$1.invoke(WelcomeScreen.kt:163)
at com.fantompay.fpay.screen.WelcomeScreenKt$Web3Login$2$2$1$1.invoke(WelcomeScreen.kt:265)
at com.fantompay.fpay.screen.WelcomeScreenKt$Web3Login$2$2$1$1.invoke(WelcomeScreen.kt:265)
at androidx.compose.foundation.ClickableKt$clickable$4$gesture$1$1$2.invoke-k-4lQ0M(Clickable.kt:163)
at androidx.compose.foundation.ClickableKt$clickable$4$gesture$1$1$2.invoke(Clickable.kt:152)
at androidx.compose.foundation.gestures.TapGestureDetectorKt$detectTapAndPress$2$1.invokeSuspend(TapGestureDetector.kt:255)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178)
at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)
at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)
at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328)
at androidx.compose.ui.input.pointer.SuspendingPointerInputFilter$PointerEventHandlerCoroutine.offerPointerEvent(SuspendingPointerInputFilter.kt:566)
at androidx.compose.ui.input.pointer.SuspendingPointerInputFilter.dispatchPointerEvent(SuspendingPointerInputFilter.kt:456)
at androidx.compose.ui.input.pointer.SuspendingPointerInputFilter.onPointerEvent-H0pRuoY(SuspendingPointerInputFilter.kt:469)
at androidx.compose.ui.node.BackwardsCompatNode.onPointerEvent-H0pRuoY(BackwardsCompatNode.kt:394)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:314)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:301)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:301)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:301)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:301)
at androidx.compose.ui.input.pointer.Node.dispatchMainEventPass(HitPathTracker.kt:301)
at androidx.compose.ui.input.pointer.NodeParent.dispatchMainEventPass(HitPathTracker.kt:183)
at androidx.compose.ui.input.pointer.HitPathTracker.dispatchChanges(HitPathTracker.kt:102)
at androidx.compose.ui.input.pointer.PointerInputEventProcessor.process-BIzXfog(PointerInputEventProcessor.kt:98)
at androidx.compose.ui.platform.AndroidComposeView.sendMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1363)
at androidx.compose.ui.platform.AndroidComposeView.handleMotionEvent-8iAsVTc(AndroidComposeView.android.kt:1309)
at androidx.compose.ui.platform.AndroidComposeView.dispatchTouchEvent(AndroidComposeView.android.kt:1248)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)
at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:3249)
at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2938)
at android.view.ViewGroup.d

  1. Silly solution was to repeat up to succes, code:
    while(!isLoaded)
    {
    var connectedSuccessfully = true
    val pairing: Core.Model.Pairing = CoreClient.Pairing.create { error ->
    connectedSuccessfully = false
    Log.d("cpr_Navigation_startPairingCreate", "Failed to CONNECT! ${error.throwable.stackTraceToString()}")
    }!!

         if (connectedSuccessfully) { // Check if pairing is not null
             GlobalContext.globalURI = pairing.uri
             connectParams =
                 Sign.Params.Connect(
                     namespaces = namespaces_selected.toMutableMap().plus(tmp),
                     properties = properties,
                     pairing = pairing // Retry if pairing is null
                 )
             Log.d("cpr_Navigation_startPairingCreate", "withContext Ended")
             isLoaded = true // Move the flag assignment here
         }
         else
         {
    
         }
     }
    

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant