AlphaWallet / AlphaWallet-web3-provider

[Used in AlphaWallet]
MIT License
57 stars 37 forks source link

Expose net_version() function #22

Closed JamesSmartCell closed 2 years ago

JamesSmartCell commented 2 years ago

Exposes window.ethereum.net_version() function which some newer dapps use to determine which network they are running on (eg Quickswap). Provides a better experience as if you are on the wrong network the dapp will ask you to change networks, instead of not displaying any wallet.

In newer builds of provider, there is an additional switch table that funnels all these functions into the correct call in the provider, eg eth_accounts.

hboon commented 2 years ago

@JamesSmartCell thanks! I'll poke at it a bit. But seems great. We'll need to fix the whitespace (vs tab) and build the distribution as part of this commit, would you like me to do that?

hboon commented 2 years ago

Relevant doc: https://docs.metamask.io/guide/ethereum-provider.html#legacy-api

JamesSmartCell commented 2 years ago

The dapp in question is Quickswap. However I narrowed it down a bit further; we actually need to add engine.isMetaMask to get quickswap working correctly.

hboon commented 2 years ago

But iOS doesn't have isMetaMask = true too. I'm been meaning to set isMetaMask = true though, but worried it will involve an entire overhaul to be really compatible. But if you are able to just inject for 1 single site, go for it.

JamesSmartCell commented 2 years ago

But iOS doesn't have isMetaMask = true too. I'm been meaning to set isMetaMask = true though, but worried it will involve an entire overhaul to be really compatible. But if you are able to just inject for 1 single site, go for it.

Good point - let's add it in for Quickswap only for now, rather than a blanket add. Try it - you get a better experience.