secretkeylabs / sats-connect

Sats connect is a simple javascript library that connects apps to Bitcoin wallets
https://www.npmjs.com/package/sats-connect
98 stars 36 forks source link

Feature Request: Support for Account and Network Change Listeners #117

Closed stoXmod closed 3 months ago

stoXmod commented 4 months ago

Description

In the Unisat wallet, we can listen for account and network changes using the following event listeners:

unisat.on('accountsChanged', handleAccountsChanged);
unisat.on('networkChanged', handleNetworkChanged);

This feature is crucial for maintaining the app's responsiveness to changes in the user's wallet settings, such as switching accounts or networks, which is common in blockchain applications.

Solution

I suggest adding support for event listeners in the Xverse wallet that can handle 'accountsChanged' and 'networkChanged' events. This would make the wallet more versatile and user-friendly, particularly for applications that need to react in real-time to changes in the user's wallet configuration.

Ideally, the implementation would allow developers to use event listeners similar to those in Unisat.

xverse.on('accountsChanged', handleAccountsChanged);
xverse.on('networkChanged', handleNetworkChanged);

Benefits:

stoXmod commented 4 months ago

I would love to hear, if is there currently any workaround for this. 🤔

teebszet commented 3 months ago

hi @stoXmod, thanks for the suggestion!

I can confirm this is in our roadmap and will be included very soon 👀

teebszet commented 3 months ago

duplicate of: https://github.com/secretkeylabs/sats-connect/issues/54