Skip to content

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 force-pushed the ganache-hardhat-anvil-support branch from 8e80896 to bf0895e Compare August 16, 2023 17:21
@duckception duckception force-pushed the ganache-hardhat-anvil-support branch from bf0895e to b5a444e Compare August 16, 2023 18:39
@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