Repository navigation
refactor: isolate and mark the code specific to Cairo 0 - #1719
Merged
PhilippeR26 merged 1 commit intoOct 1, 2026
Merged
Conversation
Move the Cairo 0 class hash (computeHintedClassHash, computeLegacyContractClassHash, nullSkipReplacer) to hash/classHash/cairo0.ts, and the Cairo 0 multicall (transformCallsToMulticallArrays, fromCallsToExecuteCalldata) to transaction/cairo0.ts. Move Builtins, EntryPointsByType and ContractEntryPointFields from legacy.ts to sierra.ts, since CASM uses them. Public exports are unchanged. Mark every other Cairo 0 specific place with `// Cairo 0 specific: when Cairo 0 support is dropped, ...`. Each comment says what to do on that day: remove the code, or, where it depends on whether Starknet still holds Cairo 0 contracts, keep it or turn it into a clear error. `grep -rn "Cairo 0 specific" src __tests__` lists them all. Fix two outdated comments (cairoTypeStrategy, CairoBool) and the connect_account guide, which said that cairoVersion defaults to '1'.
Contributor
|
🎉 This PR is included in version 11.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Resolution
Cairo 0 support will be dropped one day. There is no date yet, and it may happen together with a full removal of Cairo 0 from Starknet itself. This PR prepares that day, so that it needs no new analysis.
The calldata codec already keeps Cairo 0 apart:
AbiParser0serializes throughrequestParser.ts,responseParser.tsandvalidate.ts, which no other parser uses. The rest of the Cairo 0 code was spread over many files, often inside functions that also serve Cairo 1.This PR:
src/utils/hash/classHash/cairo0.ts:computeHintedClassHash,computeLegacyContractClassHash,nullSkipReplacer;src/utils/transaction/cairo0.ts:transformCallsToMulticallArrays,fromCallsToExecuteCalldata;Builtins,EntryPointsByTypeandContractEntryPointFieldsfromlegacy.tstosierra.ts. CASM uses them, solegacy.tscould not lose its Cairo 0 part without breaking the Sierra types;The first form is for code that only serves Cairo 0. The second is for what depends on whether Starknet still holds Cairo 0 contracts on that day: the detection, the places that choose between Cairo 0 and Cairo 1 (which may then have to refuse a Cairo 0 input with a clear error),
LegacyContractClassin the node responses, the existing declare guards and thecairoVersionchain.grep -rn "Cairo 0 specific" src __tests__lists all 84 markers.A marker is put where something is declared or decided, not at every use: TypeScript will flag the uses once the declaration changes. Markers are line comments, never inside a JSDoc, so they do not reach the generated API docs.
There is no change of behavior and no change of the public API.
RPC version (if applicable)
Not applicable.
Usage related changes
connect_account.md: it said thatcairoVersiondefaults to'1'. When omitted, it is read from the node.Development related changes
src/utils/hash/classHash/cairo0.tsandsrc/utils/transaction/cairo0.ts.pedersen.tskeeps the contract address computation and the Pedersen helpers; its header no longer presents it as the Cairo 0 class hash.Builtins,EntryPointsByTypeandContractEntryPointFieldsnow live insierra.ts.Cairo 0 specificmarkers insrc/and__tests__/, test cases included.parsingStrategy.test.tsandrequestParser.test.tsalso test Cairo 1, so only their Cairo 0 blocks are marked.cairoTypeStrategy(it said that nothing reads the strategy yet) andCairoBool(it said thatcompilerefuses1for acore::bool, which is no longer true since v11; checked by running it).nullSkipReplacergets an@example.ts:check, ESLint, Prettier, the unit tests and the full suite against devnet pass. The list of names exported bydist(values, namespace members and types: 1647 entries) is identical before and after.Checklist: