WalletConnect / WalletConnectKotlinV2

WalletConnect Kotlin SDK v2
Apache License 2.0
197 stars 70 forks source link

When send accountchanged to sessionevnet in Kotlin version, only string type can be send, but in case of js, accountchanged checks array. #1329

Open cp-byungsun opened 6 months ago

cp-byungsun commented 6 months ago

Describe the bug When send accountchanged to sessionevnet in Kotlin version, only string type can be send, but in case of js, accountchanged checks array.

SDK Version

To Reproduce Sign.kt data class SessionEvent( val name: String, val data: String, ) : Model()

Expected behavior A clear and concise description of what you expected to happen.

Screenshots swift or flutter data is dynamic type

Additional context Is there another way to send accountsChanged sesstionevent in kotlin?

jakubuid commented 6 months ago

Hey! Does changing from String to Any for the data field solve your issue?

cp-byungsun commented 6 months ago

@jakubuid maybe I think it will probably be resolved. Currently, cannot change the address in wallet.

Jimyeol commented 6 months ago

This is part of the code for a dApp using walletconnect-monorepo - UniversalProvider. When the "accountsChanged" event is received, it calls isValidArray from the data. This is a function that validates whether the data is an Array.

if (event.name === "accountsChanged") {
        const accounts = event.data;
        if (accounts && isValidArray(accounts))
          this.events.emit("accountsChanged", accounts.map(parseCaip10Account));
      }

In WalletConnectKotlinV2, the Event data class is as follows:

 data class SessionEvent(
            val name: String,
            val data: String,
        ) : Model()

Because it is in String format, it cannot trigger the accountsChanged event.

I've tried sending it as JSON and also as a String like "["0xAccount"]", but the event does not trigger because it is not an ArrayString.

jakubuid commented 6 months ago

@Jimyeol @cp-byungsun Did you try this form?

"[\"0xAccount\"]"

Jimyeol commented 6 months ago

@jakubuid I've tried it, It doesn't work.

jakubuid commented 6 months ago

@Jimyeol Regarding this issue, I'll come back to you shortly with the follow up 🙏

cp-byungsun commented 3 months ago

@jakubuid I'd like to know what's going on.

jakubuid commented 3 months ago

Apologies for the delay! Which dapp should I connect to reproduce?