From e82c500b3957ddc97b197c0f7c7c6c4066d56b78 Mon Sep 17 00:00:00 2001 From: Chaitanya Potti Date: Fri, 22 Dec 2023 18:15:57 +0800 Subject: [PATCH] throw error if user closes the modal --- packages/modal/src/modalManager.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/modal/src/modalManager.ts b/packages/modal/src/modalManager.ts index e8bf02d89..3d5356933 100644 --- a/packages/modal/src/modalManager.ts +++ b/packages/modal/src/modalManager.ts @@ -231,6 +231,12 @@ export class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal { this.once(ADAPTER_EVENTS.ERRORED, (err: unknown) => { return reject(err); }); + this.once(LOGIN_MODAL_EVENTS.MODAL_VISIBILITY, (visibility: boolean) => { + // modal is closed but user is not connected to any wallet. + if (!visibility && this.status !== ADAPTER_STATUS.CONNECTED) { + return reject(new Error("User closed the modal")); + } + }); }); }