-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Make web3.js side-effect free #3374
Comments
@bpierre Have some further questions about this...
Could you go into greater detail about what issues you're seeing / give an example?
Could you clarify this as well? For further background, there's also an effort underway to formalize the ethereum provider JS API in EIP 1193 and it looks like Metamask is planning to roll this out as a breaking change in "early 2020" |
An app or library should expect Metamask to provide the We could also imagine a library relying on On the web3.js side, MetaMask could decide to freeze the
Sure! window.ethereum === window.web3.currentProvider // true Objects are passed by reference in JavaScript, so any modification to
Yes this API is available in Metamask already − and it’s exactly the issue I encountered: I was trying to interact with |
Ah! Thanks...will investigate this. |
For further background, per this Metamask breaking change notice there is an interim 6 week period where Metamask will continue to inject web3 while it rolls out the I think at the end of this the following should hold (and side-effects for the MM case should disappear): window.ethereum === window.web3.currentProvider // false There's additional info about MM no longer injecting Web3 in this Metamask blog post). If anyone is looking for an example patch, @bpierre has written one at aragon/use-wallet PR 21 |
Web3.js is modifying the
window.ethereum
object, which can cause different issues with other libraries trying to interact withwindow.ethereum
.I think
window.ethereum
should be considered immutable, and any modification to its API, if needed, should be done internally.More generally, I think a library like web3.js should not have any side effect.
The text was updated successfully, but these errors were encountered: