-
Notifications
You must be signed in to change notification settings - Fork 747
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
truncates leading zeroes
#1028
Comments
Hello, const hexNum = encode.sanitizeHex(hexString); |
In general, toHex is an unopinionated number conversion. Maybe we should add a helper method toCallerAddress(number: BigNumberish): string; That would ensure leading zero on every conversion based on https://docs.starknet.io/documentation/architecture_and_concepts/Network_Architecture/starknet-state/#address_0x0 |
Just use |
We have 3 options:
|
This function is already existing in Starknet.js : https://www.starknetjs.com/docs/next/api/modules/#addaddresspadding If you want, I can add some JSdoc. |
ok, we can do that also! thanks! |
Made. |
@PhilippeR26 @ivpavici @tabaktoni Sorry, I didn't explain the actual issue. The following method starknet.js/src/provider/rpc.ts Line 675 in d72b1be
toHex in order to make sure address is hex. By doing so padding zeroes are getting removed and the RPC throws an exception about incorrect address length.
|
This time I understood. |
toHex
function truncates leading zeroes:starknet.js/src/utils/num.ts
Line 36 in 70e7ba6
For example:
(zero after '0x' gets truncate)
The text was updated successfully, but these errors were encountered: