-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
toHex is not supporting passing Uint8Array #6957
Comments
Hi Marin! web3.utils.bytesToHex(
new Uint8Array([221, 128, 128, 128, 148, 186, 248, 242, 159, 130, 231, 84, 254, 199, 252, 69, 21, 58, 104, 102, 201, 137, 255, 3, 196, 10, 128, 128, 128, 128])
--> 0xdd80808094baf8f29f82e754fec7fc45153a6866c989ff03c40a80808080
web3.utils.toHex(new Uint8Array([221, 128, 128, 128, 148, 186, 248, 242, 159, 130, 231, 84, 254, 199, 252, 69, 21, 58, 104, 102, 201, 137, 255, 3, 196, 10, 128, 128, 128, 128]));
--> 0x7b2230223a3232312c2231223a3132382c2232223a3132382c2233223a3132382c2234223a3134382c2235223a3138362c2236223a3234382c2237223a3234322c2238223a3135392c2239223a3133302c223130223a3233312c223131223a38342c223132223a3235342c223133223a3139392c223134223a3235322c223135223a36392c223136223a32312c223137223a35382c223138223a3130342c223139223a3130322c223230223a3230312c223231223a3133372c223232223a3235352c223233223a332c223234223a3139362c223235223a31302c223236223a3132382c223237223a3132382c223238223a3132382c223239223a3132387d Or the idea is that |
@SantiagoDevRel toHex already accepts Uint8Array type. I already opened PR #6958 which fixes bug. The alternative is to remove Uint8Array from allowed inputs (breaking change though) |
17 tasks
Merged
This was referenced Jul 17, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected behavior
toHex(new Uint8Array([
221, 128, 128, 128, 148, 186, 248,
242, 159, 130, 231, 84, 254, 199,
252, 69, 21, 58, 104, 102, 201,
137, 255, 3, 196, 10, 128, 128,
128, 128
])) = 0xdd80808094baf8f29f82e754fec7fc45153a6866c989ff03c40a80808080
Actual behavior
It gets Json.stringified first and results in:
0x7b2230223a3232312c2231223a3132382c2232223a3132382c2233223a3132382c2234223a3134382c2235223a3138362c2236223a3234382c2237223a3234322c2238223a3135392c2239223a3133302c223130223a3233312c223131223a38342c223132223a3235342c223133223a3139392c223134223a3235322c223135223a36392c223136223a32312c223137223a35382c223138223a3130342c223139223a3130322c223230223a3230312c223231223a3133372c223232223a3235352c223233223a332c223234223a3139362c223235223a31302c223236223a3132382c223237223a3132382c223238223a3132382c223239223a3132387d
Steps to reproduce the behavior
Logs
Environment
The text was updated successfully, but these errors were encountered: