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

Replace deprecated String.prototype.substr() #4855

Merged
merged 7 commits into from
Apr 13, 2022
Merged

Replace deprecated String.prototype.substr() #4855

merged 7 commits into from
Apr 13, 2022

Conversation

CommanderRoot
Copy link

@CommanderRoot CommanderRoot commented Mar 14, 2022

Description

String.prototype.substr() is deprecated so we replace it with String.prototype.slice() which works similarily but isn't deprecated.
.substr() probably isn't going away anytime soon but the change is trivial so it doesn't hurt to do it.

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.

@jdevcs jdevcs added 1.x 1.0 related issues Review Needed Maintainer(s) need to review labels Mar 16, 2022
Copy link
Contributor

@jdevcs jdevcs left a comment

Choose a reason for hiding this comment

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

@CommanderRoot Thanks for your contributions, Could you also update changelog, and add this PR under 1.7.2

String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
@CommanderRoot
Copy link
Author

Of course. I've added the changelog entry as requested

@nazarhussain
Copy link
Contributor

@CommanderRoot Please resolve the conflicts in CHANGELOG.md

@coveralls
Copy link

coveralls commented Mar 17, 2022

Pull Request Test Coverage Report for Build 2042580940

  • 1 of 6 (16.67%) changed or added relevant lines in 3 files are covered.
  • 425 unchanged lines in 7 files lost coverage.
  • Overall coverage decreased (-2.3%) to 72.197%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/web3-utils/src/index.js 0 2 0.0%
packages/web3-utils/src/utils.js 0 3 0.0%
Files with Coverage Reduction New Missed Lines %
packages/web3-core-requestmanager/src/jsonrpc.js 1 88.0%
packages/web3-core-helpers/src/formatters.js 25 81.07%
packages/web3-core-helpers/src/errors.js 31 4.41%
packages/web3-utils/src/soliditySha3.js 55 5.13%
packages/web3-utils/src/index.js 60 29.31%
packages/web3-utils/src/utils.js 90 12.86%
packages/web3-eth-accounts/src/index.js 163 23.77%
Totals Coverage Status
Change from base Build 2029198956: -2.3%
Covered Lines: 3368
Relevant Lines: 4396

💛 - Coveralls

@jdevcs jdevcs requested review from nikoulai and avkos March 17, 2022 16:16
@jdevcs jdevcs self-requested a review April 13, 2022 14:54
@jdevcs jdevcs changed the base branch from 1.x to junaid/4855e2ewinTestsRemovingsubstr April 13, 2022 15:03
@jdevcs jdevcs merged commit 8371fa0 into web3:junaid/4855e2ewinTestsRemovingsubstr Apr 13, 2022
jdevcs added a commit that referenced this pull request Apr 13, 2022
* Replace deprecated String.prototype.substr()

String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with slice() which works similarily but isn't deprecated.
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

Co-authored-by: CommanderRoot <CommanderRoot@users.noreply.github.com>
@jdevcs
Copy link
Contributor

jdevcs commented Apr 13, 2022

Merged in 1.x via #4941

@jdevcs jdevcs mentioned this pull request May 17, 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 Review Needed Maintainer(s) need to review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants