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
added an helper : isTypeNonZero
This new type is not something rigid as uint256. It more similar to array, and is just listing real types. That's why I do not included the code in the CairoDataTypes directory.
added handling in parsers.
tests : As cairo1v2.test.tsis now huge, I have create a new cairov240onwards.test.ts, moved all recent tests due to Cairo evolution, and added new tests for NonZero. A new test contract has been created to test various cases.
Checklist:
[x] Performed a self-review of the code
[x] Rebased to the last commit of the target branch (or merged it into my branch)
[x] Linked the issues which this PR resolves
[x] Documented the changes in code (API docs will be generated automatically)
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/45433As 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
isTypeNonZero
array
, and is just listing real types. That's why I do not included the code in the CairoDataTypes directory.cairo1v2.test.ts
is now huge, I have create a newcairov240onwards.test.ts
, moved all recent tests due to Cairo evolution, and added new tests for NonZero. A new test contract has been created to test various cases.Checklist: