-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature Request: Expose Wallet Lock State & Disconnect Event #192
Comments
thanks @RyanTimesTen.
|
|
|
|
i updated the proposal with your suggestions, thank you |
@RyanTimesTen wrt silent-mode, pls see #194 ( |
thanks @avimak. both Braavos wallet and ArgentX will need to release updates to support this, right? |
yes, cc @janek26 |
Background
At Dynamic, we have partnered with StarkWare to build a bridge component as seen on https://starkgate.starknet.io/. We aim to create a smooth login experience for end users. We use
get-starknet-core
to connect users' starknet wallet, whether it's Braavos or ArgentX.Problem
There are two scenarios that could have improved UX, and they both begin at a state where the user has already connected a starknet wallet:
Additionally, when dealing with wallets in a locked state, we want to avoid uninitiated wallet popups – meaning, there should not be any wallet popups without the user explicitly clicking on a connect button.
The starknet window object (accessed via
get-starknet-core
) has a lot of useful properties and methods likeisConnected
andisPreauthorized
, however these cannot be used for accurately detecting wallet locked state while avoiding popups. The main reason for this is thatisConnected
is always false untilenable
is called. However, whenenable
is called, it will prompt the user to unlock the wallet if it's locked, so we have a chicken-and-egg problem.Proposed solution
There are two parts, each addressing the problems above, respectively:
accountsChanged
event withundefined
account address when the wallet is lockedenable
that states the dapp doesn't want to show a popup/UI in case the wallet is locked and/or not preauthorizedAlternate solution
disconnect
event when the wallet is lockedisLocked
(orisUnlocked
, whichever is preferred) value that represents the current locked status of the wallet, whether or notenable
has been called.Disconnect event
When the user explicitly locks their wallet, the wallet should emit a
disconnect
event that can be handled via theon
method, similar toaccountsChanged
andnetworkChanged
. This will solve the first UX scenario because in ourdisconnect
event handler, we can disconnect the wallet from our app state.isLocked
There should be a boolean value isLocked accessible via
get-starknet-core
similar toisConnected
that is:true
when the wallet is lockedfalse
when the wallet is lockedAdditionally, this boolean should have a value before calling enable – it should not be necessary to call enable for this property to have the correct value. This will solve the second UX scenario because our SDK can read this value and determine if it needs to remove the wallet from its connected state. For a reproduction of the UX problem we aim to solve, see: https://codesandbox.io/s/purple-glade-l3llkm?file=/src/App.js. The problem is with the automatic popup – since we have to call
enable
first to check ifisConnected
is true, there is a wallet connection popup on page load. If we were able to checkisLocked
, then we would know to simply "disconnect" the user (reset their connection state in our app), and then show them the connect button again.The text was updated successfully, but these errors were encountered: