phantom / docs

32 stars 17 forks source link

Feature requests: events for `clusterChanged` and `accountsChanged` #21

Closed arcticmatt closed 9 months ago

arcticmatt commented 2 years ago

It would be useful to be able to listen for these events in the frontend, e.g. so you can do something when someone changes their account in Phantom.

MetaMask has support for accountsChanged https://docs.metamask.io/guide/ethereum-provider.html#events

yozenou commented 2 years ago

@arcticmatt Hi!! how are you ? do you found a way to handle these event ? thank you

niZmosis commented 1 year ago

For account events, you can use "accountChanged". Notice it is "account" and not "accounts". Now for the chain or cluster, I can't find anything. Phantom team should look into adding an event for us. As of right now, you'd almost have to make an interval that checks that network every so often and emit your own event. Mostly every connector has this feature, so it's odd it isn't available for us. The apps right now will have no idea that the user has changed from mainnet to devnet or vise-versa, and will need to check it before interacting with the wallet every time, which is lousy.