-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
fix: return "0x00" for normalize(0) #306
Conversation
if (!input) { | ||
return undefined; | ||
} | ||
|
||
if (typeof input === 'number') { | ||
if (input < 0) { |
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.
@adonesky1 @kumavis This stood out to me. Do you recall the context on why this returns 0x
for all negative numbers instead of throwing like it does on other invalid input?
1e4f176#diff-39b2554fd18da165b59a6351b1aafff3714e2a80c1435f2de9706355b4d32351R111
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.
Ah, I guess the intention is to throw on negative numbers.
eth-sig-util/src/utils.test.ts
Line 120 in f33a032
// TODO: Add validation to disallow negative integers. |
I can address that in a separate change (as it's a breaking one) after this one has been merged and released.
b29aaf8
to
7e736dc
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.
good
this is a breaking change
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.
LGTM!
7e736dc
to
8f9c3a2
Compare
Not certain if this should be merged and released before or after #273. |
@mikesposito @legobeat This seems complementary to #315. There would be conflicts whether we merge one first or the other, but I don't see a reason why we couldn't have both. Do you? |
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.
Makes sense.
I don't think the functional change made in this PR is relevant anymore. The change in #315 is functionally equivalent in the case where zero is passed in, though broader in that it also affects the case where an empty string is passed in. Agreed that the test would be useful to include though! |
I have created a separate PR to add just the test: #317 |
The
normalize
function returns0x${number}
for all numbers except0
, for which it returnsundefined
. This changes it to return0x00
for0
.