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

Add web3 shim #113

Merged
merged 3 commits into from
Dec 1, 2020
Merged

Add web3 shim #113

merged 3 commits into from
Dec 1, 2020

Conversation

rekmarks
Copy link
Member

Adds a function for shimming window.web3.currentProvider, which initProvider can be configured to call.

src/shimWeb3.js Outdated Show resolved Hide resolved
src/shimWeb3.js Outdated Show resolved Hide resolved
src/shimWeb3.js Outdated Show resolved Hide resolved
Co-authored-by: Mark Stacey <[email protected]>
@rekmarks rekmarks requested a review from Gudahtt December 1, 2020 16:32
@brad-decker brad-decker assigned brad-decker and Gudahtt and unassigned brad-decker Dec 1, 2020
src/shimWeb3.js Outdated
)

Object.defineProperty(window, 'web3', {
value: Object.freeze(web3Shim),
Copy link
Member

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?

Gudahtt
Gudahtt previously approved these changes Dec 1, 2020
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

LGTM as well.

@rekmarks
Copy link
Member Author

rekmarks commented Dec 1, 2020

@rekmarks rekmarks merged commit a339baf into main Dec 1, 2020
@rekmarks rekmarks deleted the web3-shim branch December 1, 2020 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants