fix: return "0x00" for normalize(0)#306
Conversation
| } | ||
|
|
||
| if (typeof input === 'number') { | ||
| if (input < 0) { |
There was a problem hiding this comment.
@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.
Ah, I guess the intention is to throw on negative numbers.
eth-sig-util/src/utils.test.ts
Line 120 in f33a032
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
kumavis
left a comment
There was a problem hiding this comment.
good
this is a breaking change
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? |
|
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
normalizefunction returns0x${number}for all numbers except0, for which it returnsundefined. This changes it to return0x00for0.