-
Notifications
You must be signed in to change notification settings - Fork 825
feat: CairoTypeOption CairoTypeResult CairoTypeCustomEnum and others #1484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: cairotypes/all
Are you sure you want to change the base?
feat: CairoTypeOption CairoTypeResult CairoTypeCustomEnum and others #1484
Conversation
|
Added a commit to solve problems of recursive decompose. |
|
Added a commit to solve several problems of recursive encoding. |
|
@tabaktoni
|
|
@tabaktoni |
…ser files. adapt parseEvent
|
Ready for review. |
| } | ||
|
|
||
| toDecimalString() { | ||
| return addHexPrefix(this.toBigInt().toString(10)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return addHexPrefix(this.toBigInt().toString(10)); | |
| return this.toBigInt().toString(10); |
|
|
||
| toApiRequest(): string[] { | ||
| return addCompiledFlag([this.toHexString()]); | ||
| return addCompiledFlag([this.toDecimalString()]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for the hex to decimal swap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because test suite is expecting everywhere decimalString for a Calldata.
| data: bigint; | ||
|
|
||
| static abiSelector = 'core::integer::u96'; | ||
| static abiSelector = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to stop supporting u96?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cairo language u96 is still supported, but in abi it's not named 'core::integer::u96' ; it's named 'core::internal::bounded_int::BoundedInt::<0, 79228162514264337593543950335>'
|
I performed local tests of encoding/decoding of Cairo 0 & cairo V1.1 contracts. |
Motivation and Resolution
In the frame of the new parsing strategy, implementation of Cairo option & Cairo result type.
Usage related changes
No user change.
Development related changes
Current
CairoOption,CairoResult&CairoCustomEnumclasses remains unchanged, and is used by users.New
CairoTypeOption,CairoTypeResult&CairoTypeCustomEnumclasses are created in conformity with theCairoTypeinterface, and are used to encode/decode to Starknet API. Can be used by user, or is automatically created from aCairoOption.Added also CairoNonZero, CairoEth, CairoEthAddress, CairoBool classes, CairoStruct.
Also handling of ContractAddress & ClassHash (are in fact just felt252).
Checklist: