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

Web3Modal uses wrong session when selecting a different chain #88

Open
marctatham opened this issue Sep 3, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@marctatham
Copy link

marctatham commented Sep 3, 2024

Describe the bug
Web3Modal determines the session by simply grabbing the first available session from getSessions(). This works when the only session is the connected wallet, it does NOT work when we are managing multiple sessions (such as in the case when you are using both Web3Modal to connect a wallet and connecting dApps as well)

SDK Version

  • Client: iOS-Swift
  • Version All versions, including latest version 1.5.2

To Reproduce

  1. Connect a wallet using web3modal
  2. Connect a dApp to the same application using Pair.instance.pair(...)
  3. Attempt to change network using Web3Modal.selectChain() , this will fail as the requests are being routed to the wrong session

Expected behaviour
The change network request should be sent to the wallet session. The web3Modal should manage its connected wallet session correctly.

Screenshots
N/A

Device:

Additional context
The exact problem can be found in how the session is determined here:

if let session = client.getSessions().first {
store.session = session
store.connectedWith = .wc
store.account = .init(from: session)
} else if CoinbaseWalletSDK.shared.isConnected() {
let storedAccount = AccountStorage.read()
store.connectedWith = .cb
store.account = storedAccount
} else {
AccountStorage.clear()
}

@marctatham marctatham added the bug Something isn't working label Sep 3, 2024
@marctatham marctatham changed the title Web3Modal uses wrong session when sending requests or for selecting a different chain Web3Modal uses wrong session when selecting a different chain Sep 3, 2024
@mrktrace
Copy link

Good morning,

I'm experiencing the same issue, I think it would be super useful to be able to perform web3 options sending a the sessionId.

Maybe it could be an optional string with a default nil value, and if the topicId is nil it could use the first session.

WDYT?

Thank you!

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

2 participants