Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose net_version() function #22

Closed
wants to merge 1 commit into from
Closed

Conversation

JamesSmartCell
Copy link
Member

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.

@JamesSmartCell JamesSmartCell requested a review from hboon January 15, 2022 10:21
@hboon
Copy link
Member

hboon commented Jan 15, 2022

@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?

Copy link
Member

@hboon hboon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean to add support for this instead?

await ethereum.request({ method: 'net_version' }).

eg on iOS:

await ethereum.request({ method: 'net_version' })
[Info] "0x1"

It is implemented at:

case 'net_version':

On the other hand, MetaMask doesn't support ethereum.net_version():

ethereum.net_version()
VM555:1 Uncaught TypeError: ethereum.net_version is not a function

Which dapp calls ethereum.net_version()?

@hboon
Copy link
Member

hboon commented Jan 15, 2022

@JamesSmartCell
Copy link
Member Author

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
Copy link
Member

hboon commented Jan 15, 2022

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
Copy link
Member Author

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.

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.

None yet

2 participants