NethermindEth / starknet-abi-form

Starknet ABI Form
https://www.npmjs.com/package/starknet-abi-forms
Apache License 2.0
4 stars 3 forks source link

Serialization of certain types are not supported #25

Open prxgr4mm3r opened 2 months ago

prxgr4mm3r commented 2 months ago

Types that need to be supported:

u256 A u256 value in Cairo is represented by two felt252 values, as follows:

i8, i16, i32, i64, i128 For these types, each value is serialized as a single-member list that contains one felt252 value. A negative value, ($-x$) , is serialized as $P-x$ , where: $$P = 2^{252} + 17*2^{192} + 1$$

ByteArray A string is represented in Cairo as a ByteArray type. A byte array is actually a struct with the following members:

  1. data: Array<felt252> Contains 31-byte chunks of the byte array. Each felt252 value has exactly 31 bytes. If the number of bytes in the byte array is less than 31, then this array is empty.
  2. pending_word: felt252 The bytes that remain after filling the data array with full 31-byte chunks. The pending word consists of at most 30 bytes.
  3. pending_word_len: usize The number of bytes in pending_word.

Enums An enum is serialized as follows:

,