-
Notifications
You must be signed in to change notification settings - Fork 242
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
Conversation
c28c9b5
to
d3526e6
Compare
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, 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) { |
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.
Interesting; usually you'd want to avoid in
.
Does a hasOwnProperty()
not work, because we're traversing a proxy or etc?
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.
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?
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.
Not particularly, but then wouldn't normal property accessing through the .
work?
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.
No, it’s set to undefined
in some cases (MetaMask’s sendAsync()
) :-(
Also added as a question for web3.js at web3/web3.js#3374.