Skip to content

feat(sncast): Add versioned accounts schema - #4548

Open
integraledelebesgue wants to merge 1 commit into
refactor/sncast-account-domainfrom
feat/sncast-accounts-schema-v2
Open

feat(sncast): Add versioned accounts schema#4548
integraledelebesgue wants to merge 1 commit into
refactor/sncast-account-domainfrom
feat/sncast-accounts-schema-v2

Conversation

@integraledelebesgue

@integraledelebesgue integraledelebesgue commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Introduced changes

This PR introduces a versioned schema of the accounts file:

  1. The previous model with private_key and ledger_path fields becomes the legacy v1 variant. Its behaviour remains exactly the same.
  2. The new model with explicit signer field, deserialized as a tagged enum, is the latest v2 variant.

Both variants converge to the common AccountsRegistry structure that holds the accounts' data expressed using domain models from #4547.

Utility functions in sncast::accounts::schema::migrations allow upgrading v1 to v2.

Checklist

  • Linked relevant issue
  • Updated relevant documentation
  • Added relevant tests
  • Performed self-review of the code
  • Added changes to CHANGELOG.md

@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from df091b9 to 3febf64 Compare August 19, 2026 16:13
@integraledelebesgue integraledelebesgue changed the title feat(sncast): add versioned accounts schema feat(sncast): Add versioned accounts schema Aug 20, 2026
@integraledelebesgue
integraledelebesgue marked this pull request as ready for review August 20, 2026 15:24
@integraledelebesgue
integraledelebesgue requested a review from a team as a code owner August 20, 2026 15:24
@integraledelebesgue
integraledelebesgue requested review from MKowalski8, ddoktorski and franciszekjob and removed request for MKowalski8 August 20, 2026 15:24
Comment thread crates/sncast/src/accounts/schema/v2.rs
Comment thread crates/sncast/src/accounts/error.rs Outdated
Comment thread crates/sncast/src/accounts/error.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/signers/derivation_path.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs
Comment thread crates/sncast/src/accounts/schema/v1.rs Outdated
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Account {
pub public_key: Felt,
pub address: Option<Felt>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why address is Option? 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It leaked from the previous logic, where native cast accounts were mixed with starkli ones. I changed the domain model and both schemas to enforce the address

Comment thread crates/sncast/src/accounts/error.rs Outdated
Comment thread crates/sncast/src/accounts/error.rs Outdated
Comment thread crates/sncast/src/accounts/error.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
impl VersionedAccountsFile {
pub fn decode(input: &[u8]) -> Result<Self, AccountsError> {
if input.iter().all(u8::is_ascii_whitespace) {
return Ok(Self::V1(v1::AccountsFile::default()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why V1 for an empty file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a natural solution - V1 file can technically be empty, while the V2 contains at least a version

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if someone creates an empty file and wants to add an account there?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be deserialized as V1. Any modifications (writes/removes) will happen via AccountRepository.mutate that converts the content to the latest schema version

Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/migration.rs Outdated
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch 2 times, most recently from 8b5ac73 to 3ecaf12 Compare August 25, 2026 10:15
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch 2 times, most recently from f62a6eb to adff940 Compare August 26, 2026 10:50
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from d69ff65 to d5d3943 Compare August 27, 2026 10:23
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from d5d3943 to 3da4f05 Compare August 27, 2026 11:01
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from 3da4f05 to be70592 Compare August 27, 2026 17:11
Comment thread crates/sncast/src/accounts/schema/conversion.rs Outdated
Comment thread crates/sncast/src/accounts/schema/conversion.rs
impl VersionedAccountsFile {
pub fn decode(input: &[u8]) -> Result<Self, AccountsError> {
if input.iter().all(u8::is_ascii_whitespace) {
return Ok(Self::V1(v1::AccountsFile::default()));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if someone creates an empty file and wants to add an account there?

Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/v1.rs
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/mod.rs
Comment thread crates/sncast/src/accounts/schema/conversion.rs
Comment thread crates/sncast/src/accounts/schema/mod.rs Outdated
Comment thread crates/sncast/src/accounts/schema/v1.rs Outdated
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from be70592 to 3f8188a Compare August 28, 2026 15:04
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from 3f8188a to b194201 Compare August 28, 2026 15:14
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch 2 times, most recently from cbc82f8 to db06d71 Compare August 28, 2026 15:20
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch 3 times, most recently from 0a63276 to 6e21e2d Compare August 28, 2026 17:16
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch 2 times, most recently from 270b677 to c4ee71c Compare September 2, 2026 10:48
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from c4ee71c to baa5911 Compare September 2, 2026 14:02
@integraledelebesgue
integraledelebesgue force-pushed the feat/sncast-accounts-schema-v2 branch from baa5911 to bea8623 Compare September 3, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants