Repository navigation
feat(accounts): support SNIP-9 outside execution - #188
Merged
snickerdoodle2 merged 16 commits intoNov 27, 2026
Merged
snickerdoodle2 merged 16 commits into
snickerdoodle2 merged 16 commits into
Conversation
(cherry picked from commit 20da332)
snickerdoodle2
requested changes
Nov 16, 2026
snickerdoodle2
requested changes
Nov 18, 2026
- Split outside_execution into errors, nonce, typed_data, execution and signed submodules. - Add OutsideExecutionNonce newtype, obtainable only via OutsideExecutionNonce::fresh; OutsideExecution::new now picks a random nonce and with_nonce accepts a checked one. - Retry nonce checks on provider errors, keeping the last error. - Make SignedOutsideExecution constructible only through sign(). - Build typed data with separate type, domain and message matches. - Revert the selector!/short_string! type-path extension; compute selectors at runtime instead. - Revert unrelated contract_deployment test change. - Move provider-mock tests to tests/outside_execution.rs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snickerdoodle2
requested changes
Nov 19, 2026
- OutsideExecution::new now obtains a checked nonce through OutsideExecutionNonce::fresh (NEW_NONCE_ATTEMPTS attempts) and validates time bounds before querying the provider. - Drop OutsideExecutionNonce::random and ::get; use From<..> for Felt. - Rename SignedOutsideExecution::call to into_call. - Turn the Starknet.js vector generator into a small npm project with a lockfile and local .gitignore; the fixture is reproduced unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 of 4 tasks
snickerdoodle2
requested changes
Nov 20, 2026
- Validate time bounds only in `OutsideExecution::with_nonce` and inline the helper. - Rework `OutsideExecutionNonce`: add `OutsideExecutionNonceError` (provider or invalid), a `new` constructor that validates a given nonce with the account, and make `fresh` generate one random nonce and validate it without retries. Remove `FreshNonceError` and `NEW_NONCE_ATTEMPTS`. - Drop a redundant test binding in typed_data.rs. - snip9 fixture project: add license, drop unused provenance string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
snickerdoodle2
approved these changes
Nov 27, 2026
Contributor
|
Thanks for the contribution! |
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.
Introduced changes
Adds SNIP-9 v1/v2 outside execution in
starknet_rust_accounts::outside_execution.API
OutsideExecution::new(provider, account, block, caller, execute_after, execute_before, calls)validates the exclusive timestamp interval, then gets a nonce the account confirms is unused (up toNEW_NONCE_ATTEMPTS).OutsideExecutionNonceis a newtype that can only be obtained throughOutsideExecutionNonce::fresh(provider, account, block, max_attempts). It checks random candidates withis_valid_outside_execution_nonce; provider errors count as failed attempts, and the last one is kept inFreshNonceError.OutsideExecution::with_nonceaccepts one.OutsideExecution::signsigns the SNIP-12 message (revision 0 for v1, revision 1 for v2), bound to the account and chain, with anySigner. It is the only way to get aSignedOutsideExecution.SignedOutsideExecution::into_callencodes theexecute_from_outside/execute_from_outside_v2call. Relayers submit it through the normalexecute_v3builder, keeping fee, nonce and simulation options.supported_versiondetects v2/v1 support through SRC-5supports_interface, preferring v2, and tells unsupported accounts apart from RPC errors.ANY_CALLER, timestamp bounds and the fact that checking a nonce does not reserve it.The module is split into
errors,nonce,typed_data,executionandsigned. Selectors are computed at runtime withget_selector_from_name.Core change: the typed-data
selectorencoder now keeps precomputed hexadecimal felts (SNIP-9 v2 passes call selectors this way) and still hashes entrypoint names. Malformed hex and values at or above the field modulus are rejected instead of being reduced.Reference vectors: the v1/v2 message hashes for a two-call authorization are checked against fixtures generated with the published Starknet.js 11.5.1.
starknet-rust-core/test-data/typed-data/snip9/is a small npm project (pinnedpackage.json, committedpackage-lock.json, local.gitignore);npm ci --ignore-scripts && npm run generatereproduces the committed fixture byte for byte.No compatibility with a live account contract is claimed yet.
Validation
starknet-rust-accounts/tests/outside_execution.rswith a mocked JSON-RPC transport: SRC-5 version selection and fallback, RPC-error propagation, nonce attempt limits, retry after RPC errors, andnewwith a checked nonce.cargo clippy --all-targets -D warnings, strict rustdoc, wasm32 check,cargo fmtand jq JSON checks pass locally.Checklist
CHANGELOG.md🤖 Generated with Claude Code