WalletConnect / web3modal-vanilla-js-example

An example application how to use Web3modal from vanilla JavaScript
https://web3modal.com/
173 stars 147 forks source link

getChain() fails with Metamask/Ganache #9

Open topac opened 3 years ago

topac commented 3 years ago

I'm using the official live demo here https://web3modal.github.io/web3modal-vanilla-js-example/ Metamask connected. If the chain is changed to http://127.0.0.1:8545 (Ganache), I got the following error:

Uncaught (in promise) Error: No chain found matching chainId: 1337
    at Object.i [as getChain] (index.min.js:1)
    at fetchAccountData (example.js:88)
    at async refreshAccountData (example.js:152)
    at async HTMLButtonElement.onConnect (example.js:185)

Everything is file when using Mainnet or Ropsten.

pedrouid commented 3 years ago

This example uses an NPM package called evm-chains which provides data about public chains that are EVM-compatible (like Ethereum)

Since Ganache is not a public chain it will fail to find data for it matching the chainId 1337 so I'm not sure this is necessarily a bug or out-of-scope of this example

Perhaps we could make an assumption that any unknown chains would be testnet but that's still too ambiguous IMO

What do you think @miohtama?

miohtama commented 3 years ago

I will fix the example to show the chain as "unknown" when the database lacks an entry.