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
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Handle repeated AddToMetaMask clicks
  • Loading branch information
lukaw3d committed Jul 10, 2024
commit 325b4ab0ba383907cf57969aa732f69919083867
2 changes: 2 additions & 0 deletions src/AddToMetaMask.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)

})
}}
>
Expand Down