Skip to content

feat(ENG-288): Add field attributes to #[frame] for declarative constant generation#55

Merged
alnoki merged 8 commits intomainfrom
eng-288
Apr 4, 2026
Merged

feat(ENG-288): Add field attributes to #[frame] for declarative constant generation#55
alnoki merged 8 commits intomainfrom
eng-288

Conversation

@alnoki
Copy link
Copy Markdown
Contributor

@alnoki alnoki commented Apr 4, 2026

Changes

  1. Add comment width validation to the build injector so that
    assembly comments exceeding 75 characters fail at build time
    (cargo check / rust-analyzer), preventing overlong .equ
    comment lines in .s files
  2. Extend #[frame] to accept an optional module name argument
    (#[frame("frame")]) and, when combined with #[inject] and
    #[prefix] on the struct, generate a constant group module
    directly from field-level attributes, eliminating the separate
    constant_group! block for frame-based groups
  3. Support field attributes #[offset], #[unaligned_offset],
    #[pubkey_offsets], #[unaligned_pubkey_offsets],
    #[signer_seeds], #[cpi_accounts], and #[sol_instruction]
    with auto-inferred SCREAMING_SNAKE_CASE names from the field
    name, optional name overrides, and sub-field access via
    comma-separated syntax (#[unaligned_offset(NAME, sub, "doc")])
  4. Support struct-level #[relative_offset(NAME, from, to, "doc")]
    for cross-field offset differences
  5. Migrate RegisterMarketFrame and its constant_group! block
    to the new field-attribute syntax, making the struct the single
    source of truth for both layout and constant definitions
  6. Remove _pad: u32 from CreateAccountData and rearrange the
    frame to maintain 8-byte alignment without it
  7. Split macros/src/frame.rs into frame/mod.rs, frame/parse.rs,
    and frame/field_constants.rs, collapsing repeated offset match
    arms via a shared offset_kind helper
  8. Update constant_group! doc comment to list all supported
    constant kinds
  9. Update build-scaffolding.md docs for #[frame],
    signer_seeds!, and cpi_accounts! sections to document the
    new field-attribute workflow

@linear
Copy link
Copy Markdown

linear bot commented Apr 4, 2026

ENG-288

@alnoki alnoki changed the title ENG-288 feat(ENG-288): Add field attributes to #[frame] for declarative constant generation Apr 4, 2026
@alnoki alnoki marked this pull request as ready for review April 4, 2026 00:40
@alnoki alnoki merged commit 23dd6b1 into main Apr 4, 2026
6 of 7 checks passed
@alnoki alnoki deleted the eng-288 branch April 4, 2026 00:47
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.

1 participant