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

Compatibility with Web3.js patching the ethereum provider #21

Merged
merged 3 commits into from
Feb 17, 2020

Conversation

bpierre
Copy link
Contributor

@bpierre bpierre commented Feb 16, 2020

Also added as a question for web3.js at web3/web3.js#3374.

@bpierre bpierre requested a review from sohkai February 16, 2020 19:26
Copy link
Contributor

@sohkai sohkai left a comment

Choose a reason for hiding this comment

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

LGTM, have a few clarifying questions

@@ -10,30 +10,53 @@ export function getNetworkName(chainId) {

export function rpcResult(response) {
// Some providers don’t wrap the response
if (response && response.jsonrpc) {
if (response && 'jsonrpc' in response) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting; usually you'd want to avoid in.

Does a hasOwnProperty() not work, because we're traversing a proxy or etc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I almost used hasOwnProperty(), but then I thought I don’t have a reason to invalidate jsonrpc if it was on the prototype. Do you see one?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not particularly, but then wouldn't normal property accessing through the . work?

Copy link
Contributor Author

@bpierre bpierre Feb 17, 2020

Choose a reason for hiding this comment

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

No, it’s set to undefined in some cases (MetaMask’s sendAsync()) :-(

@bpierre bpierre merged commit aa7fa2f into master Feb 17, 2020
@bpierre bpierre deleted the web3-js-compat branch February 17, 2020 23:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants