67P / kredits-web

Kredits Web UI
https://kredits.kosmos.org
6 stars 2 forks source link

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

Closed bumi closed 5 years ago

bumi commented 5 years ago

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 5 years ago

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 5 years ago

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)

raucao commented 5 years ago

Ah, I see. Thanks. :+1: