-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Allow locally hosted RPC and Block Explorer Urls with wallet_addEthereumChain
#14272
Allow locally hosted RPC and Block Explorer Urls with wallet_addEthereumChain
#14272
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
I have read the CLA Document and I hereby sign the CLA |
3e03807
to
cde3fca
Compare
app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js
Outdated
Show resolved
Hide resolved
app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js
Outdated
Show resolved
Hide resolved
3963192
to
3713ea5
Compare
Many thanks for this PR @MicaiahReid ! Eager to use this patch ASAP 👍 |
3713ea5
to
f4cfade
Compare
Just wanted to mention that this feature would really help me out. Right now I'm running a small hardhat instance for testing. I don't seem to have a problem adding my chain from the extension network page ( |
@danjm Is there anything else needed to merge this? Merging is still blocked for me, but it looks like I've had two approvals? |
This comment was marked as spam.
This comment was marked as spam.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general would ask for tests here, but doesn't seem we currently have any test suites for our RPC middleware methods...
LGTM
ea4d508
to
9e80229
Compare
fixes #14416 |
Explanation
Currently, adding a chain using the
wallet_addEthereumChain
RPC method requires that the supplied chain has an array of RPC urls, with at least one of them being an HTTPS url.This is a problem because locally hosted resources are considered secure, and users may want to programmatically add their own local chains (e.g. Ganache) to MetaMask.
This change instead requires that at least one of the urls is either HTTPS or locally hosted (
url.hostname === "localhost" || url.hostname === "127.0.0.1"
).The same change is made for the block explorer urls.
Manual testing steps
To test, run MetaMask and run
ganache --port 8544 --chain.chainId 1338
. Send thewallet_addEthereumChain
RPC method to MetaMask with the payload:Verify that the chain is successfully added to MetaMask.