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

Update helpers.js #4613

Merged
merged 4 commits into from Jan 7, 2022
Merged

Update helpers.js #4613

merged 4 commits into from Jan 7, 2022

Conversation

Jack-Works
Copy link

@Jack-Works Jack-Works commented Dec 9, 2021

Description

Please include a summary of the changes and be sure to follow our Contribution Guidelines.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

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.

Copy link

@fallingicarus fallingicarus left a comment

Choose a reason for hiding this comment

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

Code

@nazarhussain
Copy link
Contributor

@Jack-Works Thanks for the contribution. I would suggest to create an issue on the repo mentioning what was the issue intended to fix and then link it to this PR. Also add entry to CHANGELOG.md file for your PR.

Assigning some reviewers to get approvals, as soon you make above changes and PR looks good will be able to include in upcoming release.

@nazarhussain nazarhussain added 1.x 1.0 related issues Changes Requested Requires further changes Review Needed Maintainer(s) need to review labels Dec 9, 2021
Copy link
Contributor

@nazarhussain nazarhussain left a comment

Choose a reason for hiding this comment

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

For reference for others attaching some docs describing historical changes which brought globalThis

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#description

@Jack-Works Jack-Works marked this pull request as draft December 9, 2021 16:38
@Jack-Works
Copy link
Author

👀 Maybe don't merge yet. I want to review the whole repo to search for all window usages. FIY I'm trying to running web3.js in Web Workers

@coveralls
Copy link

coveralls commented Dec 9, 2021

Pull Request Test Coverage Report for Build 1575924982

  • 0 of 1 (0.0%) changed or added relevant line in 1 file are covered.
  • 276 unchanged lines in 8 files lost coverage.
  • Overall coverage increased (+2.2%) to 74.88%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/web3-eth-accounts/src/index.js 0 1 0.0%
Files with Coverage Reduction New Missed Lines %
packages/web3-core-requestmanager/src/jsonrpc.js 1 70.0%
packages/web3-core-helpers/src/formatters.js 6 84.87%
packages/web3-core-requestmanager/lib/givenProvider.js 13 40.0%
packages/web3-core-helpers/src/errors.js 29 1.56%
packages/web3-utils/src/soliditySha3.js 34 3.43%
packages/web3-utils/src/index.js 43 31.38%
packages/web3-utils/src/utils.js 44 9.66%
packages/web3-eth-accounts/src/index.js 106 23.67%
Totals Coverage Status
Change from base Build 1545963131: 2.2%
Covered Lines: 3234
Relevant Lines: 4084

💛 - Coveralls

@nazarhussain nazarhussain added the Needs Clarification Requires additional input label Dec 9, 2021
@Jack-Works Jack-Works marked this pull request as ready for review December 10, 2021 03:36
@Jack-Works
Copy link
Author

Hi! I have searched in the repo and removed all usage to window. I use globalThis(modern JS) and self (available in both normal webpage and web worker) as fallback.

@luu-alex
Copy link
Contributor

thank you for opening this PR, if possible can you update the CHANGELOG.MD https://github.com/ChainSafe/web3.js/blob/1.x/CHANGELOG.md detailing the changes you made?

@Jack-Works
Copy link
Author

thank you for opening this PR, if possible can you update the CHANGELOG.MD https://github.com/ChainSafe/web3.js/blob/1.x/CHANGELOG.md detailing the changes you made?

Done!

Copy link
Contributor

@nazarhussain nazarhussain left a comment

Choose a reason for hiding this comment

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

@Jack-Works The integration tests on windows are failing for your PR. Can you please debug those further.

@Jack-Works
Copy link
Author

@Jack-Works The integration tests on windows are failing for your PR. Can you please debug those further.

>>>>>>
HTTP:MAINNET getBlock
>>>>>>
Error: Failed to connect to Infura over websockets after 10 tries
    at getBlockWithRetry (D:\a\web3.js\web3.js\windows_test\basic_usage.js:31:15)

Hmm sorry, but I didn't change any platform-aware code. I have no idea why it is happening. It looks like a network problem on the CI machine, so I guess re-run the test might resolve the problem?

@spacesailor24
Copy link
Contributor

@Jack-Works The failing tests don't seem to be related to changes. The failing Build / e2e_windows (pull_request) is a recurring issue that we haven't found the cause for. In the past, waiting a bit and rerunning the tests seem to have resolved the issue, but we might need to rotate the Infura key

@spacesailor24 spacesailor24 changed the base branch from 1.x to wyatt/1.x/failing-windows-test-debug January 7, 2022 02:10
@spacesailor24 spacesailor24 merged commit 843d456 into web3:wyatt/1.x/failing-windows-test-debug Jan 7, 2022
@spacesailor24
Copy link
Contributor

spacesailor24 commented Jan 7, 2022

Okay so FYI for everyone, I merged this PR into a branch I just created and opened PR #4671, and the Windows test is no longer failing. I don't have an answer as to why this works, but we used this to solve the same issue previously

@Jack-Works
Copy link
Author

Okay so FYI for everyone, I merged this PR into a branch I just created and opened PR #4671, and the Windows test is no longer failing. I don't have an answer as to why this works, but we used this to solve the same issue previously

Oh, I know why.

The Infura key is not accessible when the PR is triggered by a non-contributor (me). Because leaking a secret environment variable is a security violation.

@Jack-Works Jack-Works deleted the patch-1 branch January 7, 2022 08:05
spacesailor24 added a commit that referenced this pull request Feb 2, 2022
* Update helpers.js

* fix: remove more window use

* Update CHANGELOG.md

Co-authored-by: Jack Works <jackworks@protonmail.com>
@jdevcs jdevcs mentioned this pull request Feb 10, 2022
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 Changes Requested Requires further changes Needs Clarification Requires additional input Review Needed Maintainer(s) need to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants