useDApp icon indicating copy to clipboard operation
useDApp copied to clipboard

Switching Accounts in Metamask Mobile causes unstable behaviour

Open JayWelsh opened this issue 3 years ago • 0 comments

Describe the bug Using Metamask Mobile, if we connect to the website using useDapp (i.e. Account A), then switch to another account (i.e. Account B), a bug occurs once we make a wallet interaction (e.g. sign message). As far as I can tell, as soon as we run a function which causes wallet interaction, the account pulled from useEthers() will immediately glitch back to Account A (despite Account B being selected in Metamask Mobile), assuming we are signing a message, the Metamask Popup will actually show Account B when asking if you want to sign the message (so account via useEthers glitches back to the account which was selected when first connecting, despite the Metamask Mobile dialogue showing Account B, furthermore, upon signing the message and running an ecrecover on the signed message, we will see that it was signed by Account A).

To Reproduce For the sake of this description, let's imagine a user has Account A and Account B stored within the same Metamask Mobile instance.

  1. User initially connects to a website using Account A
  2. User switches to Account B (bug is now locked and loaded, ready to show)
  3. User tries to sign a message using Account B
  4. account from useEthers glitches back to Account A
  5. Metamask Mobile confirms if user wants to sign message using Account B
  6. ecrecover on the signed message shows that it was signed by Account A, instead of Account B

Software versions

  • useDapp version: 1.1.5
  • yarn
  • Node version: v14.16.0

Additional context

Video demonstration using https://example.usedapp.io/ - unfortunately the example website isn't mobile friendly but I've done my best to add some basic annotations as to what is happening

https://user-images.githubusercontent.com/14224459/196252756-9608d169-6f68-48ef-892c-3ee85727b190.mp4

JayWelsh avatar Oct 17 '22 18:10 JayWelsh