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

Fetch chain id from local node for add/switch network calls #252

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

duckception
Copy link

@duckception duckception commented Aug 16, 2023

This PR allows users to add a localhost network no matter which major local node they use, i.e., Ganache, Hardhat, Anvil.

The previous implementation assumed the user had a local node with a custom port and chain ID, which is often not the case. Most of the time, devs use local nodes on the default port (8545), and with this in mind, we can fetch chain ID from the node to supply into the wallet_addEthereumChain call. This change results in support for Ganache, Hardhat, Anvil, and also forked local nodes 🚀

After giving it some thought and looking through the MetaMask tests (test/e2e/tests/dapp-interactions.spec.js), I've understood why the port 8546 was used instead of the default 8545. However, I still believe that fetching chain ID from the local node instead of hardcoding this value in the dapp is a QoL improvement.

@duckception duckception changed the title Use default RPC info for wallet_addEthereumChain button Fetch chain id from local node for add/switch network calls Aug 16, 2023
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.

1 participant