blocknative / web3-onboard

Client library to onboard users to web3 apps
https://onboard.blocknative.com/
MIT License
829 stars 488 forks source link

[BUG]: Event when user disconnects all wallets #2147

Open titusdecali opened 4 months ago

titusdecali commented 4 months ago

Is your request related to a problem?

I have a complex flow using multiple wallet connectors, and thus am managing connected wallets internally and not only via Onboard. If the user uses the Onboard disconnect all wallets button, I would like to catch an event and wipe those wallets from my internal state as well (since they are no longer available), however I see nothing in the docs which provides this.

I've also tried adding a watcher to the connectedWallet value to see if it is updated when all wallets are disconnected, but it doesn't appear to update.

Am I missing something in the docs, or can you add this minor feature?

Thanks

Feature Description

No response

Alternative Solutions

No response

Anything else?

No response

Adamj1232 commented 4 months ago

@titusdecali thanks for opening this PR - there does seem to be an issue with connectedWallets. It may take some tim,e for this to work its way into our back log so for the time being you can get the proper events directly from the wallets state through the API as shown here

  // Subscribe to wallet updates
  const wallets$ = onboard.state.select('wallets').pipe(share())
  wallets$.subscribe(wallet => {
    console.log(wallet)
  })
titusdecali commented 4 months ago

@Adamj1232 That worked a treat! Thanks for your support ^^ I'll leave this issue open for you to close when the wallets are updating as expected.