Do not rely on web3 injection with new ethereum provider standard #102

Merged
bumi merged 1 commits from chore/ethereum-provider into master 2019-04-10 14:19:45 +00:00
bumi commented 2019-04-09 20:40:16 +00:00 (Migrated from github.com)

when window.ethereum is available web3 is likely not available as the
browser uses the new provider standard.
So we either user the window.ethereum as provider or the
web3.currentProvider as legacy option.

when window.ethereum is available web3 is likely not available as the browser uses the new provider standard. So we either user the window.ethereum as provider or the web3.currentProvider as legacy option.
raucao commented 2019-04-10 14:04:39 +00:00 (Migrated from github.com)

I'm not sure I understand. This is ported from the official upgrade instructions for Metamask and it comes with window.ethereum and window.Web3 (the constructor, not the instance). It is then set as web3 instance on window, so that the APIs are the same.

Am I missing something? Or is there a particular wallet that doesn't work this way perhaps?

I'm not sure I understand. This is ported from the official upgrade instructions for Metamask and it comes with `window.ethereum` and `window.Web3` (the constructor, not the instance). It is then set as `web3` instance on `window`, so that the APIs are the same. Am I missing something? Or is there a particular wallet that doesn't work this way perhaps?
bumi commented 2019-04-10 14:14:59 +00:00 (Migrated from github.com)

When I tried the app in opera I get the error that Web3 is undefined, but it injects an window.ethereum provider.
Looking at the metamask documentation here it seems that window.ethereum == window.web3.currentProvider. So there is no need to initialize another Web3 object.

It seems the new global API only injects window.ethereum and no Web3 is available. (which somehow makes sense as for example we use ethers and no full web3 is needed at all)

When I tried the app in opera I get the error that `Web3` is undefined, but it injects an `window.ethereum` provider. Looking at the [metamask documentation here](https://metamask.github.io/metamask-docs/API_Reference/Ethereum_Provider) it seems that window.ethereum == window.web3.currentProvider. So there is no need to initialize another Web3 object. It seems the new global API only injects `window.ethereum` and no Web3 is available. (which somehow makes sense as for example we use ethers and no full web3 is needed at all)
raucao commented 2019-04-10 14:17:16 +00:00 (Migrated from github.com)

Ah, I see. Thanks. 👍

Ah, I see. Thanks. :+1:
raucao (Migrated from github.com) approved these changes 2019-04-10 14:17:29 +00:00
Sign in to join this conversation.