Digine-Labs / rosettanet

Ethereum <> Starknet RPC middleware.
MIT License
34 stars 26 forks source link

docs: ABI for all possible data types #181

Open ermvrs opened 2 months ago

ermvrs commented 2 months ago

Add a document md file for all possible abis from starknet and ethereum. In starknet, it has to have both return and parameters.

The most important data types are complex types. We already have basic type conversions. We need documentation for types like an array of basic types, an array of arrays, an array of custom structs, custom structs, bytes31, and bytes array.

This documentation lets us show the most idiomatic way to approach converting custom data types to basic types, then we can convert to Ethereum type.

Add an MD file to the docs folder.

ermvrs commented 2 months ago

Example types

 Supported Cairo Types

Abiwan supports all of Cairo types, here's the mapping between Cairo types and Typescript types

Primitive Types

Cairo TypeScript
felt252 string \| number \| bigint
u8 - u32 number \| bigint 
u64 - u256 number \| bigint \| U256 
ContractAddress  string
EthAddress  string
ClassHash  string
bytes31  string
ByteArray  string
bool boolean 
()  void

 Complex Types

Cairo TypeScript
Option<T> T \| undefined
Array<T> T[]
Span<T> T[]
tuple (T1, T2, ..., Tn) [T1, T2, ..., Tn] 
struct  an object where keys are struct member names
enum a union of objects, each enum variant is an object 
ermvrs commented 2 months ago

Please also tracking page for which types we support completely