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

Handle repeated AddToMetaMask clicks #869

Merged
merged 2 commits into from
Jul 10, 2024
Merged

Conversation

lukaw3d
Copy link
Member

@lukaw3d lukaw3d commented Jul 4, 2024

If user already has a chain added in metamask, then button does nothing. Added a message

Before, After:

before.after.webm

@lukaw3d lukaw3d requested a review from matevz July 4, 2024 23:42
Copy link

netlify bot commented Jul 4, 2024

Deploy Preview for oasisprotocol-docs ready!

Name Link
🔨 Latest commit 55f352e
🔍 Latest deploy log https://app.netlify.com/sites/oasisprotocol-docs/deploys/668df732e56cee0008a967e9
😎 Deploy Preview https://deploy-preview-869--oasisprotocol-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@matevz matevz left a comment

Choose a reason for hiding this comment

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

Good idea. I suggest a slightly more sophisticated message.

@@ -33,6 +33,8 @@ const AddToMetaMask = (props: {
blockExplorerUrls: props.be,
},
],
}).then(response => {
if (response === null) alert('Added')
Copy link
Member

Choose a reason for hiding this comment

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

Can you change the alert to something like:

The RPC endpoint for Chain ID {props.chainId} already exists.
If you want to replace it, please remove the old RPC endpoint first and then add the new one.
Suggested change
if (response === null) alert('Added')
if (response === null) alert('Added')

Copy link
Member Author

Choose a reason for hiding this comment

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

  • This message is shown when you first add Sapphire too. We would need to measure how quickly null is returned to differentiate "already exists" vs "added first time".
  • If you have OPF sapphire RPC added and you click 1RPC: metamask will ask you if you want to add 1RPC as a separate entry. No need to remove first. (if we really wanted to, I guess we could detect any existing entries with wallet_switchEthereumChain)

src/AddToMetaMask.tsx Outdated Show resolved Hide resolved
@lukaw3d lukaw3d force-pushed the lw/repeated-add-to-metamask branch 2 times, most recently from 2a43fa7 to fa63772 Compare July 10, 2024 02:50
@lukaw3d lukaw3d force-pushed the lw/repeated-add-to-metamask branch from fa63772 to 55f352e Compare July 10, 2024 02:51
@lukaw3d lukaw3d merged commit 93d7172 into main Jul 10, 2024
6 checks passed
@lukaw3d lukaw3d deleted the lw/repeated-add-to-metamask branch July 10, 2024 23:59
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.

2 participants