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

fix: don't show empty placeholder account in the account button #538

Closed
wants to merge 3 commits into from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Jul 26, 2024

Summary

This fix an issue when metamask is locked, and logged out user is not accepting to unlock it when prompted

Issue reproduction

  • Logged out of all metamask account
  • Lock metamask
  • Click on the "Connect wallet" button in the top right corner
  • It should prompt you to unlock metamask
  • Ignore it and go back to the site
  • The "Connect wallet" button should still be stuck in the loading state
  • Refresh the page
  • The account button should be back to "Connect wallet" state
  • Click on it, and choose metamask again
  • The button will show:

Screenshot 2024-07-26 at 13 25 10

  • Even after refreshing the page, the button will still continue to show that state

This PR will try to fix this issue by showing a special state for when metamask is waiting for an user action, by showing the "Waiting for your wallet" message (can be improved)

How to test

  1. Use the same steps as the reproduction steps above
  2. Instead of the 0x000 icon and empty account name, it should show the "Waiting for your wallet" message

Note

  • This fix is specific to metamask, as in the case of argent x and braavos, refusing to unlock by closing the argentX/Braavos popup will revert to unlogged state.
  • This will not fix the issue in bug: connector is triggered on page load #478, which is another issue specific to logged in user

@wa0x6e wa0x6e marked this pull request as draft July 26, 2024 04:05
@wa0x6e wa0x6e marked this pull request as ready for review July 26, 2024 04:45
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 26, 2024

btw, We don't handle this case on snapshot.org, the connect button just crash, and don't appear anymore

@wa0x6e wa0x6e changed the title fix: show account only if available fix: don't show empty placeholder account in the account button Jul 26, 2024
Copy link
Member

@ChaituVR ChaituVR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tAck

@Sekhmet
Copy link
Member

Sekhmet commented Jul 26, 2024

Do we need another loading state? We already have one loading state (just loading indicator), now we are adding another different state which to me means the same.

Is it related to this PR? #220

I feel like situation where isAuthenticated is true but account is missing is indicator that something else is broken, we should prevent this situation as it might cause issues in other parts of the app.

@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 27, 2024

Do we need another loading state? We already have one loading state (just loading indicator), now we are adding another different state which to me means the same.

Is it related to this PR? #220

I feel like situation where isAuthenticated is true but account is missing is indicator that something else is broken, we should prevent this situation as it might cause issues in other parts of the app.

This is continuation of fixing of #220 indeed.

In the previous PR, we fixed the error occuring after the page refresh step.
This PR take things a step further, it fixes the error occuring when clicking on the "Connect wallet" button, after page refresh.

This PR is quickfix, the best way to fix this would be trigger the metamask prompt again when you want to connect to metamask.

Seems it's an open issue for years MetaMask/metamask-extension#10085

There's some kind of solution proposed there, will try a few

@wa0x6e wa0x6e marked this pull request as draft July 27, 2024 04:55
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 27, 2024

Will instead be fixed in amount, with snapshot-labs/lock#114

This will fix the issue where an authenticated user is not authenticated

@wa0x6e wa0x6e closed this Jul 27, 2024
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Jul 29, 2024

This issue has been resolved with new version of lock: snapshot-labs/lock@b5a3203

@Sekhmet how are packages updated ?

@Sekhmet
Copy link
Member

Sekhmet commented Jul 29, 2024

@wa0x6e it looks like 0.2.5 was published via CI after your PR was merged. So here you just bump package to the version you need and run yarn in repo root.

@wa0x6e wa0x6e mentioned this pull request Aug 1, 2024
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

Successfully merging this pull request may close these issues.

3 participants