Issue title: Return null
from web3auth.connect()
when the user closes the modal without signing in
Describe the question
The @web3auth/modal
documentation regarding connect()
states that it will return a SafeEventEmitterProvider
instance on success and null
value on error. This is correct according to what I see in the code and the events listened by the Web3Auth
instance (ADAPTER_EVENTS.CONNECTED
and ADAPTER_EVENTS.ERRORED
).
However when the user closes the modal without signing in, no event is fired and no promise ever resolves until the user opens the modal again and actually tries to login. Multiple events are then fired if he fails or succeeds since the event listeners attached on the first attempt aren't removed.
Steps to Reproduce
Steps to reproduce the behavior:
- await
web3auth.connect()
call - close the modal
- see that statements after aren't executed
- try to login again
- see that all statements are executed at once
Expected behavior:
It would make sense to returnnull
fromconnect()
when the modal is closed without any login attempt.
Platform Details
- Operating System: MacOS
- Platform used: Web
- SDK used: Web (
@web3auth/modal
) - Browser Chrome, Safari
- Web3Auth Version 4.6.2
Additional context
You can wrap the call toconnect()
inconsole.log
to see that all after statements are triggered when theconnect()
promise resolves.
console.log('click connect before'); const provider = await web3auth.connect(); console.log('click connect after');
Originally posted by: edouardruiz
Check the discussion at: https://github.com/orgs/Web3Auth/discussions/1366