yours-org / yours-wallet

A non-custodial and open-source wallet for BSV and 1Sat Ordinals.
Other
63 stars 51 forks source link

emit when switching network #176

Closed gitzhou closed 1 month ago

gitzhou commented 11 months ago

Hi team,

Would it be possible to support emitting signals when switching the network in the wallet?

It would be great if a front-end app could be notified when the wallet network is changed. 😄

danwag06 commented 1 month ago

It looks like this was originally fixed but would need to be re-introduced after v4.0.0 release as it only supports emitting switchAccount and signedOut events

danwag06 commented 1 month ago

@gitzhou After looking into this, in v4.0+ this doesn't apply as the notion of switching networks no longer exists. Instead, you can listen for the switchAccount event and then call getNetwork() or look at the address format to determine if the address is mainnet or testnet.

https://app.gitbook.com/o/k6HnSOibnJKs9gyXDEwI/s/8h5PbVdOLZTSAZHevtG0/the-basics/events