-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Add stripHexPrefix #3781
Conversation
There was a problem hiding this 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
3a93a59
to
5fbd65c
Compare
There was a problem hiding this 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: '내가 제일 잘 나가'}, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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));
};
Wish I could take credit for the setup, but it was basically all copy/paste |
ac38da1
Description
Adds missing
stripHexPrefix
methodFixes #3776
Type of change
Checklist:
npm run dtslint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:cov
and my test cases cover all the lines and branches of the added code.npm run build
and testeddist/web3.min.js
in a browser.CHANGELOG.md
file in the root folder.