Skip to content

bugfix(starknet): Removed intermediate names from event generated code.#9638

Merged
orizi merged 1 commit intomainfrom
orizi/02-11-bugfix_starknet_removed_intermediate_names_from_event_generated_code
Feb 11, 2026
Merged

bugfix(starknet): Removed intermediate names from event generated code.#9638
orizi merged 1 commit intomainfrom
orizi/02-11-bugfix_starknet_removed_intermediate_names_from_event_generated_code

Conversation

@orizi
Copy link
Collaborator

@orizi orizi commented Feb 11, 2026

Summary

Simplified the event deserialization code by removing intermediate variables and directly inlining deserialization calls. This refactoring reduces code verbosity while maintaining the same functionality. Additionally it removes the possible shadowing of vars by the macro generated code.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

The event deserialization code was unnecessarily verbose, with multiple intermediate variables and separate functions that made the code harder to read and maintain. This change streamlines the code by directly using the deserialization results where needed, making the generated code more concise.


What was the behavior or documentation before?

Previously, the code would generate separate statements for deserializing each field and then use those variables in the constructor. For example:

let x = core::serde::Serde::deserialize(ref data)?;
let data = core::serde::Serde::deserialize(ref keys)?;
Option::Some(A {x, data, })

What is the behavior or documentation after?

Now, the deserialization is inlined directly in the struct initialization, making the code more concise:

Option::Some(A {
    x: core::serde::Serde::deserialize(ref data)?, 
    data: core::serde::Serde::deserialize(ref keys)?, 
})

Additional context

This change introduces a new helper function deserialize_member_code that returns the appropriate deserialization code string based on the field kind, which is then used directly in the struct initialization. This approach reduces code duplication and makes the generated code more maintainable.

@reviewable-StarkWare
Copy link

This change is Reviewable

@orizi orizi requested a review from TomerStarkware February 11, 2026 11:28
Copy link
Collaborator Author

orizi commented Feb 11, 2026

This stack of pull requests is managed by Graphite. Learn more about stacking.

@orizi orizi marked this pull request as ready for review February 11, 2026 11:29
Copy link
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 16 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @orizi).

@orizi orizi added this pull request to the merge queue Feb 11, 2026
Merged via the queue into main with commit 4251cc7 Feb 11, 2026
52 checks passed
@orizi orizi deleted the orizi/02-11-bugfix_starknet_removed_intermediate_names_from_event_generated_code branch February 11, 2026 11:52
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