You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have analyzed the new Cairo v2.4.0 release, and searched what could be the impacts on Starknet.js.
I have found 2 new types that have been added in the abi :
bytes31
ByteArray
Describe the solution you'd like
Cairo team explained me how they are serialized :
bytes31
is just a Bigint limited to 31 bytes, representing a ShortString.
"type": "core::bytes_31::bytes31"
It will be straightforward to implement.
ByteArray
Here, it's more complicated. This type is an object representing a LongString.
In Cairo, it's used as a normal string ; nobody see the low level object.
But this complex object is used in the abi (similar to enums, but slightly more complicated).
I have coded/compiled a small cairo example. The result in the abi is :
I think that on Starknet.js side, users want just to provide/receive a LongString in the calldata.
It means that we will not be in accordance with the abi for data input.
Will probably be interesting also for @haroune-mohammedi .
Cairo team has explained me how to read/write this struct ; I coded something that is conform.
One question is remaining : without Abi, what should be the behavior of CallData.compile in case of a string in the input data?
If it's a short string, deliver a Bigint, an array of Bigint, or a serialized ByteArray?
If it's a long string, deliver an array of Bigint, or a serialized ByteArray?
Describe alternatives you've considered
N/A
Additional context
As Cairo v2.4.0 is implemented for the first time in Starknet v0.13.0, it could be a good thing to implement these 2 new types in Starknet.js v6.0.
The text was updated successfully, but these errors were encountered:
My code for CallData.compile() is working this way :
If it's a short string, deliver a Bigint.
If it's a long string, deliver a serialized ByteArray.
If it's a short string, and if I want absolutely a ByteArray, deliver a serialized ByteArray with const myCalldata= CallData.compile({mess:byteArray.byteArrayFromString("Take care.")});
If it's a long string, and if I want absolutely an array of shortString (for Cairo 0), deliver an array of felt with const myCalldata= CallData.compile({mess:shortString.splitLongString('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore')})
Is your feature request related to a problem? Please describe.
I have analyzed the new Cairo v2.4.0 release, and searched what could be the impacts on Starknet.js.
I have found 2 new types that have been added in the abi :
Describe the solution you'd like
Cairo team explained me how they are serialized :
bytes31
is just a Bigint limited to 31 bytes, representing a ShortString.
It will be straightforward to implement.
ByteArray
Here, it's more complicated. This type is an object representing a LongString.
In Cairo, it's used as a normal string ; nobody see the low level object.
But this complex object is used in the abi (similar to enums, but slightly more complicated).
I have coded/compiled a small cairo example. The result in the abi is :
I think that on Starknet.js side, users want just to provide/receive a LongString in the calldata.
It means that we will not be in accordance with the abi for data input.
Will probably be interesting also for @haroune-mohammedi .
Cairo team has explained me how to read/write this struct ; I coded something that is conform.
Describe alternatives you've considered
N/A
Additional context
As Cairo v2.4.0 is implemented for the first time in Starknet v0.13.0, it could be a good thing to implement these 2 new types in Starknet.js v6.0.
The text was updated successfully, but these errors were encountered: