Skip to content

Design: Do we need explicit #[account(init)]? #123

@jimmy-claw

Description

@jimmy-claw

Summary

This issue documents a design question about the attribute in SPEL instructions.

Current Design

The attribute is required to indicate that an account should be claimed (transferred from to the program) rather than updated (already owned by the program).

Current Usage

Pattern Generated Code LEZ Validation
PDA derivation must match
must be true
(no init)

Questions

  1. Is without or valid?

    • Currently generates without signer authorization
    • LEZ v0.2.0-rc1 requires for
    • This would fail validation unless account has
  2. Could we make implicit?

    Alternative approach: Runtime check

    Pros:

    • Less boilerplate in instruction definitions
    • Can't forget to add

    Cons:

    • Implicit behavior might hide logic errors
    • Harder to debug when expectations are wrong
    • Runtime validation happens later (post-compile)
  3. Should we require + ( OR )?

    • alone seems invalid (can't claim without PDA or authorization)
    • Macro could enforce this at compile time

Related

Next Steps

Discussion needed on whether to:

  1. Keep current explicit design
  2. Make implicit (runtime detection)
  3. Enforce requires or at compile time

/cc @vpavlin

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions