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

Fix parsing of non-eth_subscription provider events #3660

Merged
merged 2 commits into from
Jul 28, 2020

Conversation

ryanio
Copy link
Collaborator

@ryanio ryanio commented Jul 27, 2020

Description

This PR fixes parsing of non-eth_subscription provider events, such as the new wallet_accountsChanged found in #3659, by adding some additional guards when checking for a subscription callback.

Fixes #3659

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran npm run dtslint with success and extended the tests and types if necessary.
  • I ran npm run test:unit with success.
  • I ran npm run test:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build and tested dist/web3.min.js in a browser.
  • I have tested my code on the live network.
  • I have checked the Deploy Preview and it looks correct.
  • I have updated the CHANGELOG.md file in the root folder.

…ripton, as other non-subscription events may come down the pipe
@ryanio ryanio added Bug Addressing a bug 1.x 1.0 related issues labels Jul 27, 2020
@ryanio ryanio changed the title Fix parsing of provider events Fix parsing of non-eth_subscription provider events Jul 27, 2020
@coveralls
Copy link

coveralls commented Jul 27, 2020

Coverage Status

Coverage remained the same at 84.321% when pulling 181cc1f on fix-provider-events into bf06daa on 1.x.

@GregTheGreek
Copy link
Contributor

GregTheGreek commented Jul 28, 2020

This is a duplicate of #3642, but this will supersedes that pr since I haven't heard back from the original contributor. At the time I don't think my metamask was updated.

This also closes #3651

GregTheGreek
GregTheGreek previously approved these changes Jul 28, 2020
@GregTheGreek GregTheGreek dismissed their stale review July 28, 2020 01:54

need to update changelog

Copy link
Contributor

@spacesailor24 spacesailor24 left a comment

Choose a reason for hiding this comment

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

Changelog was updated, and after testing changes locally, I no longer receive an error when changing accounts in Metamask

@JF0001
Copy link

JF0001 commented Jul 31, 2020

Hi,
I am on Metamask Version 8.0.5, but I am still obtaining this error when using window.ethereum.on(accountsChanged, callbackFunction): Uncaught TypeError: Cannot read property 'subscription' of undefined
Furthermore, please note that contrary to DotCoyote who has reported the issue, my CallBack Function is not executing properly, as it used to.
Was this fixed? Where can I obtain the patch?
Thank you. J

@GregTheGreek
Copy link
Contributor

GregTheGreek commented Jul 31, 2020

@JF0001 This currently exists on the 1.x branch, it has not yet been published. can you test that version out ?

@JF0001
Copy link

JF0001 commented Jul 31, 2020

Thank you Gregory. Yes, I am no longer seeing the error. The account change in MetaMask is not properly triggering the method, but that is most likely due to my code, which I have been modifying extensively. Could you please add a note to this thread if possible if anything else is modified regarding this fix.
Thank you again. J

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.x 1.0 related issues Bug Addressing a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeError on window.ethereum.on('accountsChanged', ...)
5 participants