-
Notifications
You must be signed in to change notification settings - Fork 777
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
byteArrayFromString
produces incorrect result for short string
#1003
Comments
Thank you for reporting, we will look into it. @PhilippeR26 |
Hello,
Starknet.js will continue to follow the real behavior of the Starknet network. |
Thanks for your reply. Could you provide further clarification on how you verified that current behaviour is the correct one? It's important to note that the behavior described in the docs is not a typo; it's expected, as indicated in the tests within the cairo repo. |
I just deployed in Sepolia the Starknet.js test contract at : const resp4= await stringContract.call("proceed_string",["Take care."],{parseResponse:false}); The response is :
Cairo source code : https://github.com/starknet-io/starknet.js/blob/develop/__mocks__/cairo/cairo240/string.cairo |
The issue seems to be with the way data is serialized and sent when calling Calling the following function in Cairo/snforge returns the data array as explained in the doc
But, calling the function in the test, from sn.js returns an array with "0x0" as a first element. To confirm this, a function w/o any appending will return the correct structure.
calling it from sn.js, results in the following result
will result in TL;DR, ByteArray should be serialized as explained in the docs, but sn.js is serializing them incorrectly when sending them to a contract |
This reverts commit 03363b3. It was confirmed that logic from the docs should be used: starknet-io/starknet.js#1003 (comment)
This reverts commit 03363b3. It was confirmed that logic from the docs should be used: starknet-io/starknet.js#1003 (comment)
I think I understood, and I will correct this. Shouldn't it be somewhere after the SDK request a check of the consistency of the serialized ByteArray?
|
Describe the bug
The algorithm, used both in byteArray.ts and typedData.ts seems to produce incorrect results for short strings of length <31.
It ensures at least one value (
0x00
) is present inByteArray
'sdata
, contrary to the docs, where in such casedata
should be empty.To Reproduce
Run the following test, based on the example from the docs:
Expected behavior
Test passes
Actual behavior
Test fails, actual
ByteArray
is:Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: