-
-
Notifications
You must be signed in to change notification settings - Fork 226
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: interpret 0x as hex in bytes encodeField #354
Conversation
be9e21f
to
2174b6a
Compare
@@ -253,6 +253,7 @@ const encodeDataExamples = { | |||
'0xa22cb465000000000000000000000000a9079d872d10185b54c5db2c36cc978cbd3f72b70000000000000000000000000000000000000000000000000000000000000001', // even number of characters hex string with value greater than MAX_SAFE_INTEGER | |||
MAX_SAFE_INTEGER_AS_HEX, | |||
MAX_SAFE_INTEGER_PLUS_ONE_CHAR_AS_HEX, | |||
'0x', |
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.
Nit: Might also be a good idea to test an empty string. The fact that the encoding was the same as for '0x' helped me understand what was happening here.
0x0 might be a nice test case as well 🤔
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.
Empty string is supposed to be breaking as of #315 (but we could add that too according to current)
Added test for and verified consistency of results of 0x0
, though.
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!
2174b6a
to
2984288
Compare
the snapshot matches pre-v6 behavior, which was changed in MetaMask#319.
2984288
to
51e131d
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.
Reviewed differences between ethjs-util
(previous package) and @metamask/utils
(new package):
- https://github.com/ethjs/ethjs-util/blob/e9aede668177b6d1ea62d741ba1c19402bc337b3/src/index.js#L180
- https://github.com/MetaMask/utils/blob/031c81462c67ea52b675492ed4c6cbc906e94e53/src/hex.ts#L11
This fix makes sense.
ethereumjs-abi
for@metamask/abi-utils
#319v5.1.0
.Related