Open php4fan opened 2 years ago
This update addresses this issue as the "addNetwork" request performs the same function as "switchNetwork", however if the network doesn't exist, it prompts to add it first.
Once the patch is propagated to the minified build and pushed to the CDN I will close this issue.
Consider this example:
https://opentarget.org/test/stupid/mm/wc/index2.html
Ignore the "Send Transaction" button, just consider the "Connect" one, which is yours.
This attempts to connect to the BNB Smart Chain.
If you do this with MetaMask browser extension (choosing Metamask when asked to choose wallet, that is using the MetaMask API), and the currently selected network is not BSC, but BSC is configured, then MetaMask will prompt to switch network as expected.
But if you do not have the BSC network set up in Networks, it will not prompt to add it.
Prompting to add a network is trivial. Look at this example: https://opentarget.org/test/stupid/mm/trans/
This does the following:
(my example then also proceeds to request a transaction but that's irrelevant.)
I believe this can be done also with WalletConnect, but of that I'm not 100% sure. What's 100% sure is it can be done when choosing the MetaMask API, and I'm almost sure with Binance Wallet too, since their API is pretty much copied from MetaMask's.