Skip to content

Commit

Permalink
chore: tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Oct 17, 2024
1 parent 5b0b271 commit 7ee3c61
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/connectors/src/metaMask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,15 @@ export function metaMask(parameters: MetaMaskParameters = {}) {
}
},
async onAccountsChanged(accounts) {
// Empty account list is the signal to disconnect from extension
// Disconnect if there are no accounts
if (accounts.length === 0) {
// ... and using browser extension
if (sdk.isExtensionActive()) this.onDisconnect()
return
// mobile app sometimes emits invalid `accountsChanged` event with empty accounts array
else return
}
// Connect if emitter is listening for connect event (e.g. is disconnected and connects through wallet interface)
if (config.emitter.listenerCount('connect')) {
else if (config.emitter.listenerCount('connect')) {
const chainId = (await this.getChainId()).toString()
this.onConnect({ chainId })
}
Expand Down

0 comments on commit 7ee3c61

Please sign in to comment.