starknet-io / starknet.js

JavaScript library for StarkNet
https://www.starknetjs.com
MIT License
1.21k stars 706 forks source link

feat: handling of Cairo Zeroable type #1150

Closed PhilippeR26 closed 3 weeks ago

PhilippeR26 commented 1 month ago

Motivation and Resolution

Solves issue #1144 Cairo is using now the NonZero type in its Abi. I didn't found any documentation on this type. So I read the Cairo code, and used this message : Telegram : https://t.me/sncorestars/11902/45433

   Author : Ori Ziv (08/apr/2024)
   "NonZero is only supported for purely numeric types (u*, i* and felt252) and EcPoint."

As EcPoint do not includes trait Serde, it can't be seen in an ABI. u512 is not compatible. i are not currently handled by Starknet.js (and core::zeroable::NonZero::<i> seems not to compile in Cairo 2.6.3). So, are authorized here : u8, u16, u32, u64, u128, u256 and felt252.

Usage related changes

Contracts with an ABI including this kind of things is now handled, both for requests and for responses : core::zeroable::NonZero::<core::integer::u256>

Development related changes

Checklist: