Skip to content

Commit

Permalink
Merge pull request #1415 from Web3Auth/feat/metamask-provider-brave
Browse files Browse the repository at this point in the history
handle `.once` not being available in brave
  • Loading branch information
chaitanyapotti authored Mar 21, 2023
2 parents ec36644 + 6daee1b commit 35f4fb9
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/adapters/metamask-adapter/src/metamaskAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ class MetamaskAdapter extends BaseEvmAdapter<void> {
}
this.status = ADAPTER_STATUS.CONNECTED;
if (!this.provider) throw WalletLoginError.notConnectedError("Failed to connect with provider");
this.provider.once("disconnect", () => {
const disconnectHandler = () => {
// ready to be connected again
this.disconnect();
});
this.provider?.removeListener("disconnect", disconnectHandler);
};
this.provider.on("disconnect", disconnectHandler);
this.emit(ADAPTER_EVENTS.CONNECTED, { adapter: WALLET_ADAPTERS.METAMASK, reconnected: this.rehydrated } as CONNECTED_EVENT_DATA);
return this.provider;
} catch (error) {
Expand Down

0 comments on commit 35f4fb9

Please sign in to comment.