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

Add stripHexPrefix #3781

Merged
merged 11 commits into from
Nov 12, 2020
Merged

Add stripHexPrefix #3781

merged 11 commits into from
Nov 12, 2020

Conversation

spacesailor24
Copy link
Contributor

@spacesailor24 spacesailor24 commented Nov 11, 2020

Description

Adds missing stripHexPrefix method

Fixes #3776

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

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.

@coveralls
Copy link

coveralls commented Nov 11, 2020

Coverage Status

Coverage increased (+2.4%) to 80.413% when pulling ac38da1 on wyatt/3776-stripHexPrefix into edf481d on 1.x.

Copy link
Contributor

@frankiebee frankiebee left a comment

Choose a reason for hiding this comment

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

dont bump the versions in this pr please. also if their are no new packages dont commit the package*.json files

packages/web3-bzz/package.json Outdated Show resolved Hide resolved
frankiebee
frankiebee previously approved these changes Nov 11, 2020
Copy link
Contributor

@frankiebee frankiebee left a comment

Choose a reason for hiding this comment

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

oh my gosh! you are so good at writing tests!

expected: 'ff\u0003\u0000\u0000\u00005èÆÕL]\u0012|Î¾ž\u001a7«›\u00052\u0011(ЗY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076*…\bŽ—ñžùC1ÉUÀé2\u001aӆBŒ'},
{ value: '\u0003\u0000\u0000\u00005èÆÕL]\u0012|Î¾ž\u001a7«›\u00052\u0011(ЗY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076*…\bŽ—ñžùC1ÉUÀé2\u001aӆBŒ',
expected: '\u0003\u0000\u0000\u00005èÆÕL]\u0012|Î¾ž\u001a7«›\u00052\u0011(ЗY\n<\u0010\u0000\u0000\u0000\u0000\u0000\u0000e!ßd/ñõì\f:z¦Î¦±ç·÷Í¢Ëß\u00076*…\bŽ—ñžùC1ÉUÀé2\u001aӆBŒ'},
{ value: '내가 제일 잘 나가', expected: '내가 제일 잘 나가'},
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add a test like:

value: "0xfffff0x0fffffffffff0xffffff0x"
expected: "fffff0x0fffffffffff0xffffff0x"

to ensure we're preserving the 0x(s) that may appear in the middle (even though this breaks convention of hex, better safe than sorry)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this case, the original value (0xfffff0x0fffffffffff0xffffff0x) would be returned since it fails the isHex check:

var isHex = function (hex) {
    return ((_.isString(hex) || _.isNumber(hex)) && /^(-0x|0x)?[0-9a-f]*$/i.test(hex));
};

@spacesailor24
Copy link
Contributor Author

oh my gosh! you are so good at writing tests!

Wish I could take credit for the setup, but it was basically all copy/paste

GregTheGreek
GregTheGreek previously approved these changes Nov 12, 2020
@spacesailor24 spacesailor24 merged commit ee8bec9 into 1.x Nov 12, 2020
@spacesailor24 spacesailor24 deleted the wyatt/3776-stripHexPrefix branch November 12, 2020 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stripHexPrefix is present in types for web3-utils but isn't present in js code
4 participants