Skip to content
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

v7.7.0 Dapp Devs - How to switch accounts on a given site #7643

Closed
tmashuang opened this issue Dec 4, 2019 · 8 comments
Closed

v7.7.0 Dapp Devs - How to switch accounts on a given site #7643

tmashuang opened this issue Dec 4, 2019 · 8 comments
Assignees

Comments

@tmashuang
Copy link
Contributor

tmashuang commented Dec 4, 2019

First brought out on reddit.

TLDR;

User story could be i.e. swap Sai -> Dai (or w.e.) but doesn't remember which Account it's under.
Navigating to Account 3 (guess - timation) then realize its not there via auto-pop token list. Guess - timate next Account 2. etc.

Question: How to swap to Account 2 in this scenario??

My idea would be a screen before the tx-conf to select account.

@danfinlay
Copy link
Contributor

danfinlay commented Dec 4, 2019

Currently there are three ways, two of which work:

The working ways:

  1. The site calls enable() again

ethereum.enable() initiates a fresh login, so sites can add a "switch account" button easily.

  1. Disconnect from the site first.

Users can use the "Connected sites" menu to disconnect the current connected account:
eip-2255-logout-smaller

The not working way:

  1. Connect from a different account

When logged in with account 1, select account 2, and then select "connected sites". Does not seem to currently work properly.

@kartojal
Copy link

kartojal commented Dec 4, 2019

Have a question, does window.ethereum fire a event when the user "switches" his account? This event does not need to reveal the new address, but at least to notify to the frontend, and asking again to enable permissions if is a new address.

@satosheth
Copy link

satosheth commented Dec 4, 2019

If a user is logged into my dapp with one account and then switches the account, it does not update to the new account. Even if they close the web page, switch accounts, and open it again with the new account, it just reverts back to the first account. Is there some breaking change to accounts that we should know about with this new version? Is there an easy way for our users to downgrade metmask until they can easily switch between accounts by just clicking on them instead of having to go through those extra screens?

@kartojal
Copy link

kartojal commented Dec 4, 2019

Was thinking about using ethereum.on('accountsChanged', function () {}) method, and ask for permissions, but does not work with in this release.

You can try yourself with the next minimal example, prior Metamask release fires the event, new one does not fire this event.
https://jsfiddle.net/Lo3910sm/

@danfinlay
Copy link
Contributor

We've rolled back 7.7.0 for now until we can fix these usability issues, thanks a ton for reporting the things you find!

@cjeria
Copy link
Contributor

cjeria commented Dec 4, 2019

There were UX considerations we considered during the design phase of this work that unfortunately didn't make it into this release. We feel as though these important design considerations would have likely mitigated and/or reduced user confusion.

Through the many discussions/concerns we had during design cycles regarding accounts switching, the one we landed on was a toast message in MetaMask that appears when the user switches accounts after one has been connected to a dapp. The notification (see below) displays a message saying the account selected is not connected. We also give the user a connect button option right within the notif. If clicked, it would connect them to the dapp with the current account selected.

We realize that changing the core behavior of account switching is a big deal so we appreciate all feedback while we continue testing and iterating.

Feedback on the below designs is also greatly appreciated!

image

ezgif com-optimize

@satosheth
Copy link

That looks good to me. As a dapp developer I mainly care that we can programmatically listen for an account change and then prompt the users ourselves to connect their wallet if it hasn't been approved yet.

I was also seeing the wallet automatically switch to an approved account when going to a site (when I loaded the site with a non-approved account), which was confusing and could cause users to be interacting with a different account then they thought.

@CrackerHax
Copy link

CrackerHax commented Dec 11, 2019

I would like to see the addition of a function for a site to request a switch to a custom RPC network such as this: #5101

"FOO.com is requesting a switch to BAR network"

But even better if this is done automatically when giving permission to connect a wallet to a site (although in some cases a site might want to be able to switch between multiple networks throughout a single session).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests