-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
Add web3 shim #113
Add web3 shim #113
Conversation
Co-authored-by: Mark Stacey <[email protected]>
src/shimWeb3.js
Outdated
) | ||
|
||
Object.defineProperty(window, 'web3', { | ||
value: Object.freeze(web3Shim), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might make some dapps blow up 🤔 In strict mode, mutating a frozen object will throw a TypeError
.
I don't really know why a dapp would mutate web3, or what we should do in this scenario. Throwing an error might help dapp devs track down this problem. Have you encountered any dapps that mutate web3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM as well.
Adds a function for shimming
window.web3.currentProvider
, whichinitProvider
can be configured to call.