Skip to content

feat: add #[codama(skip)] directive for all enum variants#80

Merged
lorisleiva merged 3 commits intocodama-idl:mainfrom
amilz:feat/skip-directive
Mar 5, 2026
Merged

feat: add #[codama(skip)] directive for all enum variants#80
lorisleiva merged 3 commits intocodama-idl:mainfrom
amilz:feat/skip-directive

Conversation

@amilz
Copy link
Copy Markdown
Contributor

@amilz amilz commented Mar 3, 2026

Summary

  • Adds #[codama(skip)] support for account and error and instruction variants.
  • Discriminator counting is preserved — skipped variants still occupy their slot.

Usage

#[derive(CodamaInstructions)]
enum MyProgramInstructions {
    Initialize { amount: u64 },
    #[codama(skip)]
    EmitEvent {} = 228,  // Internal CPI-only, excluded from IDL
    Update { amount: u64 },
    // Update gets discriminator 2 (not 1)
}

In practice (escrow program — skipping an internal CPI event emitter):

#[codama(skip)]
#[codama(account(name = "event_authority", signer))]
EmitEvent {} = 228,

Works on CodamaAccounts and CodamaErrors enums with the same semantics.

Test plan

  • cargo fmt --check && cargo clippy --all-targets -- -D warnings && cargo test

amilz added 2 commits March 3, 2026 08:00
Extend #[codama(skip)] support beyond instruction enum variants to also
work on account and error enum variants, keeping discriminator counting
consistent when variants are skipped.
@amilz amilz marked this pull request as ready for review March 3, 2026 22:51
Copy link
Copy Markdown
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

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

Thanks! Just a few comments to keep things consistent.

@amilz
Copy link
Copy Markdown
Contributor Author

amilz commented Mar 4, 2026

Good catches. I think bd39202 should cover those @lorisleiva.

Copy link
Copy Markdown
Member

@lorisleiva lorisleiva left a comment

Choose a reason for hiding this comment

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

Thanks!

@lorisleiva lorisleiva merged commit ec2ce22 into codama-idl:main Mar 5, 2026
2 checks passed
@amilz amilz deleted the feat/skip-directive branch March 5, 2026 12:59
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.

2 participants