web3modal
web3modal copied to clipboard
Use chainId instead of network as a string
Currently, a Web3Modal requires a network parameter, however, this is a string:
new Web3Modal({
network: "mainnet" //string and not chainID,
...
})
This is passed to the ProviderController class which eventually uses getChain() in src/helpers/utils.ts to map the network (string) to a chainID (integer).
The mapping is based of a hardcoded dictionary found here - src/constants/chains.ts
With more and more L2s, sidechains or EVM like chains coming up, it isn't feasible to keep updating this list.
For backward compatibility
We can introduce a new parameter called chainId or even let network be a string or an integer.
Would be keen to hear your thoughts/designs to see how we can make this change! @pedrouid
@rahul-kothari I think this is great idea and kind of the standard way of how to specify the chain (by id). cc: @pedrouid
With stable version 2.0.0 of Web3Modal now released, we are officially dropping support for version 1.x Due to this this issue/pr was marked for closing. It is highly recommended to upgrade as 2.x will be receiving further updates that will enable functionality for some of our newer sdks like auth and push as well as support for WalletConnect v2 (See this post about WalletConnect v1 being deprecated https://medium.com/walletconnect/walletconnect-v1-0-sunset-notice-and-migration-schedule-8af9d3720d2e)
If you need to continue using Web3Modal 1.x and require this feature/fix implemented, we suggest adding it via forking V1 branch.