WalletConnectKotlinV2: Wallets Migrated to v2 not working with DeepLink and Native Implementation

Describe the bug While using WalletConnect v2, can’t connect to a wallet supposedly migrated to v2 already. SDK Version

  • Client: [ANDROID NATIVE KOTLIN]
  • Version [Core 1.15.0, Sign 2.13.0]

To Reproduce In an example app I created Steps to reproduce the behavior:

  1. Initialize CoreClient and SignClient with all the parameters
  2. Use SignClient.connect method and on the Success callback launch the “pairing.uri” to the desired wallet
  3. Wallet opens but no modal to accept connection

Expected behavior Wallet to open the modal and accept the connection to then sign a message. Tested with [example Wallet v2] (https://react-wallet.walletconnect.com/) and all the process works smoothly. Several wallets “migrated” to v2 does not open the modal to accept the connection they just open reacting to the deeplink, but keeps there without doing nothing

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

Device (please complete the following information):

  • Device: [Xiaomi Mi 10 T]
  • OS: [Android 12]
  • Browser [Does not apply]
  • Version [Does not apply]

Additional context I would like to know if I’m are the one doing something wrong or the wallets are not supporting really v2 as the example wallet https://react-wallet.walletconnect.com/ works without any flaw to connect and sign the message.

CODE used:

In the Application class

//for v2
        val projectId = "<My project ID>" //Get Project ID at https://cloud.walletconnect.com/
        val relayUrl = "relay.walletconnect.com"
        val serverUrl = "wss://$relayUrl?projectId=${projectId}"
        val connectionType = ConnectionType.AUTOMATIC
        val application = this //Android Application level class
        println("WALLET_CONN -> serverUrl: $serverUrl")
        val appMetaData = Core.Model.AppMetaData(
            name = "WalletIntegration Example",
            description = "Kotlin Requester Implementation",
            url = "<URL here>",
            icons = listOf("https://raw.githubusercontent.com/WalletConnect/walletconnect-assets/master/Icon/Gradient/Icon.png"),
            redirect = "<My redirect>"
        )
        CoreClient.initialize(relayServerUrl = serverUrl, connectionType = connectionType, application = application, metaData = appMetaData) {error ->
            println("WALLET_CONN -> Error initialize Core $error")
        }

        SignClient.initialize(init = Sign.Params.Init(core = CoreClient)) { error ->
            println("WALLET_CONN -> Error initialize Sign $error")
        }

Where connecting

fun signV2() {
        /*Namespace identifier*/
        val namespace: String = "eip155" // reference: https://github.com/ChainAgnostic/CAIPs/blob/master/CAIPs/caip-2.md#syntax
        /*List of chains that wallet will be requested for*/
        val chains: List<String> = listOf(
            "eip155:42220" // Celo main net
        )
        /*List of methods that wallet will be requested for*/
        val methods: List<String> = listOf(
            "personal_sign" // ATM we only want to sign
        )
        /*List of events that wallet will be requested for*/
        val events: List<String> = listOf(
            "chainChanged",
            "accountChanged"
        ) // Actually all possible events

        val expiry = (System.currentTimeMillis() / 1000) + TimeUnit.SECONDS.convert(7, TimeUnit.DAYS)
        val properties: Map<String, String> = mapOf("sessionExpiry" to "$expiry")

        val namespaces: Map<String, Sign.Model.Namespace.Proposal> = mapOf(
            namespace to Sign.Model.Namespace.Proposal(
                chains,
                methods,
                events)
        )

        val pairing: Core.Model.Pairing = CoreClient.Pairing.create()!!

        val connectParams = Sign.Params.Connect(
            namespaces = namespaces,
            optionalNamespaces = namespaces,
            properties = properties,
            pairing = pairing)

        SignClient.connect(connectParams,
        onSuccess = {
            println("WALLET_CONN -> SignClient success")
            var deeplink = pairing.uri
            println("WALLET_CONN -> link: $deeplink")
            pairingDeeplink = "$deeplink" // Tried with "wc://wc?uri=$deeplink" too but is not working
            _connectionUri.postValue("$pairingDeeplink") // LiveData that triggers to open the link URI, allowing to select the wallet to open
        }, onError = { error ->
            println("WALLET_CONN -> SignClient error: $error")
        })
    }

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Reactions: 1
  • Comments: 43 (13 by maintainers)

Most upvoted comments

I have the same case with separate wallets and need help to make WC2 work somehow with some wallets.

For Trust Wallet, the signing process only functions correctly when we send the sign body in the format of [“$msg”, “$account”]. And after that signature is not what I expect and what I get from Metamask F.E.

However, for Zerion Wallet, the connection does not work at all, and the modal to accept the connection does not appear. For Spot Wallet, the connection does not work, and the modal to accept the connection appears with an “Authentication failed” error.

https://github.com/WalletConnect/WalletConnectKotlinV2/assets/41128384/afbd6c4e-7210-48c1-a67c-3971652102f8

https://github.com/WalletConnect/WalletConnectKotlinV2/assets/41128384/fa1c8cf2-8383-4529-a9be-0e75fa2808e2

https://github.com/WalletConnect/WalletConnectKotlinV2/assets/41128384/0a785fb2-efbb-48a1-827b-639a0e1bed47

If you already have some wallets which are working on full flow with Kotlin XML (Even if with Compass), please share.

We are using Android SDK 13(Tiramisu) , and yes it is Kotlin app. Here are the versions of the Wallet Connect packages we are using: implementation(“com.walletconnect:web3wallet:1.8.0”) implementation(“com.walletconnect:sign:2.13.0”) implementation(“com.walletconnect:android-core:1.15.0”) implementation(“com.walletconnect:android-bom:1.10.0”)

For connecting to the wallet we are using SignClient.connect()



            val connectParams =  Sign.Params.Connect(namespaces, null, null, pairing)

            SignClient.connect(connectParams,
                onSuccess = { ->
                    viewModelScope.launch(Dispatchers.Main) {
                        onProposedSequence(pairing!!.uri)
                    }
                },
                onError = { error -> println(error.throwable.message) }
            )

 And for signing process SignClient.request() is used.

            val requestParams = Sign.Params.Request(
                sessionTopic = topic,
                method = "personal_sign",
                params = params,
                chainId = "$parentChain:$chainId"
            )

            SignClient.request(  requestParams, { },  { }   )

            SignClient.getActiveSessionByTopic(topic)?.redirect?.toUri()
                ?.let { deepLinkUri ->  onProposedSequence(deepLinkUri) }

MM should reached 100% rollout by now - so it should be available for you as well - and yes the experience is the same

@bujoralexandru Android MM is in the release process that supports WalletConnect v2 - we verified that the upcoming release works correctly- we had access to internal builds - the rollout of MM on Android is pretty slow but it’s going on

As far as I can see it is using Web3Modal SDK. Am I right? Im using Core + Sign. Won’t it work with them? Im using [Core 1.15.0, Sign 2.13.0], should I try the next one or this is not the problem?

Web3Modal appears to be in alpha, so can’t rely on it