connect icon indicating copy to clipboard operation
connect copied to clipboard

Add ability for app to listen network changing and get network info

Open bolasblack opened this issue 2 years ago • 0 comments

We have our own testnet instance and we hope our app can alert users that they are using an unexpected network in their stacks wallet

So we hope @stacks/connect can provide some API to make the app able to know which network users are using, just like connect event and chainChanged event of MetaMask

Maybe we can do it like this:

interface NetworkInfo {
  networkAddress: string
}

interface UserSession {
  // other properties ...

  // return network info, or throw an error if users not signed in
  getNetworkInfo(): Promise<NetworkInfo>
}

interface AuthOptions {
  // other properties ...

  onNetworkChanged: () => void
}

Related issues:

  • https://github.com/hirosystems/stacks-wallet-web/issues/2535
  • https://github.com/hirosystems/stacks-wallet-web/issues/1281

bolasblack avatar Jul 31 '22 05:07 bolasblack