Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/adapters/openlogin-adapter/src/openloginAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ export class OpenloginAdapter extends BaseAdapter<OpenloginLoginParams> {
try {
await this.connectWithProvider(params);
return this.provider;
} catch (error) {
} catch (error: unknown) {
log.error("Failed to connect with openlogin provider", error);
// ready again to be connected
this.status = ADAPTER_STATUS.READY;
this.emit(ADAPTER_EVENTS.ERRORED, error);
if ((error as Error)?.message.includes("user closed popup")) {
throw WalletLoginError.popupClosed();
}
throw WalletLoginError.connectionError("Failed to login with openlogin");
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/base/src/errors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ export class WalletLoginError extends Web3AuthError {
5111: "Failed to connect with wallet",
5112: "Failed to disconnect from wallet",
5113: "Wallet is not connected",
5114: "Wallet popup has been closed by the user",
};

public constructor(code: number, message?: string) {
Expand All @@ -153,4 +154,8 @@ export class WalletLoginError extends Web3AuthError {
public static notConnectedError(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5113, extraMessage);
}

public static popupClosed(extraMessage = ""): IWeb3AuthError {
return WalletLoginError.fromCode(5114, extraMessage);
}
}
3 changes: 2 additions & 1 deletion packages/modal/src/modalManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,8 @@ export class Web3Auth extends Web3AuthCore {
this.loginModal.on(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, async (visibility: boolean) => {
log.debug("is login modal visible", visibility);
this.emit(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, visibility);
if (visibility && this.status !== ADAPTER_STATUS.CONNECTING && this.status !== ADAPTER_STATUS.CONNECTED) {
const walletConnectStatus = this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1]?.status;
if (visibility && walletConnectStatus === ADAPTER_STATUS.READY) {
// refreshing session for wallet connect whenever modal is opened.
this.walletAdapters[WALLET_ADAPTERS.WALLET_CONNECT_V1].connect();
}
Expand Down