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

web3-providers-http: Migrate from xhr2-cookies to cross-fetch #5179

Merged
merged 7 commits into from
Jul 1, 2022

Conversation

nazarhussain
Copy link
Contributor

Description

Created the PR to merge #5085

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:cov and my test cases cover all the lines and branches of the added code.
  • I ran npm run build with success.
  • I have tested the built 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.

* Update CHANGELOG.md

* Migrate from xhr2-cookies to cross-fetch

* Address comments for web3-providers-http

* web3-providers-http: Prevent global leakage of this.connected

* Return server side error without creating additional error object

* Fixed type of http.Agent

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

* Removed unused variable

* Remove unnecessary catch block

* Remove unnecessary internal _prepareRequest function from web3-providers-http
@render
Copy link

render bot commented Jun 28, 2022

@nazarhussain nazarhussain changed the title web3-providers-http: Migrate from xhr2-cookies to cross-fetch (#5085) web3-providers-http: Migrate from xhr2-cookies to cross-fetch Jun 28, 2022
@nazarhussain nazarhussain self-assigned this Jun 28, 2022
@nazarhussain nazarhussain added the 1.x 1.0 related issues label Jun 28, 2022
@@ -46,7 +45,7 @@ export interface HttpProviderOptions {
export class HttpProvider extends HttpProviderBase {
host: string;

withCredentials: boolean;
withCredentials?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be breaking change, why we need it to be string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We can remain consistent with existing 1.x https://web3js.readthedocs.io/en/v1.7.4/web3.html#configuration and have withCredentials as boolean in web3.js options obj, and based on boolean value provided by user we can pass string to fetch ( include, omit ) here and it will go as fetch wants plus we will not introduce breaking change.

Copy link

@ghost ghost Jul 1, 2022

Choose a reason for hiding this comment

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

@jdevcs @nazarhussain Then it should be something more like withCredentials?: boolean | string; and handle boolean value with if block. Great idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jdevcs Please re-review.

packages/web3-providers-http/src/index.js Outdated Show resolved Hide resolved
@nazarhussain
Copy link
Contributor Author

@jdevcs This PR contains only the package-lock.json changes. Rest of these comes from the community PR #5085. Opened here to pass the browsers tests.

@nazarhussain nazarhussain requested a review from jdevcs June 29, 2022 14:51
test/httpprovider.js Outdated Show resolved Hide resolved
@coveralls
Copy link

coveralls commented Jul 1, 2022

Pull Request Test Coverage Report for Build 2595964794

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 21 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 74.326%

Files with Coverage Reduction New Missed Lines %
packages/web3-providers-http/lib/index.js 21 63.64%
Totals Coverage Status
Change from base Build 2590161082: -0.2%
Covered Lines: 3257
Relevant Lines: 4132

💛 - Coveralls

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 Future Release For future release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants