-
Notifications
You must be signed in to change notification settings - Fork 86
chore: rename macros #2180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: rename macros #2180
Conversation
📝 WalkthroughWalkthroughThis PR renames and restructures the macros from RentFree → LightAccounts, introduces a unified Changes
Sequence Diagram(s)(omitted — changes are primarily internal macro refactors and renames, not a multi-component runtime flow requiring sequence visualization) Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
65d643f to
dd12267
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 13
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (21)
sdk-libs/macros/src/light_pdas/shared_utils.rs (1)
1-6: Module documentation is inconsistent with the rename.The module doc still references "rentfree macro implementation" but this file is now in
light_pdas/. Consider updating it to reflect the new naming convention for consistency across the codebase.📝 Suggested fix
-//! Shared utilities for rentfree macro implementation. +//! Shared utilities for light_pdas macro implementation.sdk-libs/macros/src/light_pdas/README.md (1)
1-29: README has inconsistent naming throughout.The README is partially updated but retains several stale references:
- Title (line 1): Still says "Rent-Free Macros"
- Directory structure (lines 7-29): Shows
rentfree/but this file is inlight_pdas/- Section headers (lines 33, 40): Still reference "RentFree"
- Line 46: Still mentions
RentFreeAccountVariant(should beLightAccountVariantper AI summary)Consider updating these for consistency with the overall rename strategy. The README is often the first thing developers read, so alignment with the new naming convention improves discoverability.
📝 Suggested structural updates
-# Rent-Free Macros +# Light PDAs Macros -Procedural macros for generating rent-free account types and their hooks for Solana programs. +Procedural macros for generating light account types and their hooks for Solana programs. ## Directory Structure-rentfree/
+light_pdas/
├── mod.rs # Module declaration
├── README.md # This file
├── accounts/ # #[derive(LightAccounts)] implementationAnd similar updates for section headers and `RentFreeAccountVariant` references. </details> </blockquote></details> <details> <summary>sdk-libs/macros/src/light_pdas/mod.rs (1)</summary><blockquote> `1-6`: **Rename remaining “rentfree” terms in module docs.** Line 1-4 still say “Rent-free” and `#[rentfree_program]`, which conflicts with the LightAccounts/Light program rename and can mislead readers. <details> <summary>✏️ Suggested doc update</summary> ```diff -//! Rent-free account compression macros. -//! -//! This module organizes all rent-free related macros: -//! - `program/` - `#[rentfree_program]` attribute macro for program-level auto-discovery +//! Light account compression macros. +//! +//! This module organizes all light account related macros: +//! - `program/` - `#[light_program]` attribute macro for program-level auto-discovery //! - `accounts/` - `#[derive(LightAccounts)]` derive macro for Accounts structsAs per coding guidelines, ensure docs match the current API surface.
sdk-libs/macros/docs/account/light_compressible.md (1)
259-275: Rename remaining RentFree references in examples and related macrosThe example comment and the related-macros table still mention RentFree; these should align with the LightAccounts rename and the current doc location. As per coding guidelines, ensure docs match the implementation.
✏️ Suggested tweak (example comment)
-// Accounts struct - apply RentFree +// Accounts struct - apply LightAccountsAlso applies to: 309-315
sdk-libs/macros/docs/light_program/architecture.md (2)
1-17: Docs still describe#[rentfree_program]and “rent-free” field discoveryTitle, location, and discovery flow still point at
rentfree_program/rentfreesemantics even though the table already shows LightAccounts and#[light_account]. Please align these sections with the new macro name and discovery syntax. As per coding guidelines, ensure docs match the implementation.Also applies to: 29-33, 59-61
90-100: Update diagram and summary table to use actual generated type namesThe generated artifacts use
LightAccountVariantandLightInstructionError, not theRentFree*names shown in the diagram (lines 90-100) and summary table (lines 197-209). Update both locations to match the actual codegen output.sdk-libs/macros/src/light_pdas/program/parsing.rs (1)
401-429: Remove unusedLightFinalizeimport in generated wrapper
LightFinalizeis currently unused because finalize is commented out. Macro-expanded unused imports generate warnings and can fail indeny(warnings)crates.🧹 Proposed fix
- use light_sdk::compressible::{LightPreInit, LightFinalize}; + use light_sdk::compressible::LightPreInit;sdk-libs/macros/src/light_pdas/program/decompress.rs (1)
147-159: Align field naming in generated DecompressAccountsIdempotent struct for consistencyThe struct does mix
light_token_programandlight_token_cpi_authoritywithctoken_rent_sponsorandctoken_config. However, this is generated code with hardcoded field name mappings in the DecompressContext trait implementation (decompress_context.rs lines 126, 138). Renaming requires coordinated updates in bothdecompress.rsanddecompress_context.rs.Since
ctoken_*naming appears intentional (hardcoded trait impl references), clarify whether the rename should proceed before making changes. If pursuing consistency with thelight_token_*pattern used for other token-related fields, update both:
decompress.rs: Rename struct fieldsdecompress_context.rs: Update trait method bodies to reference renamed fieldssdk-libs/macros/CLAUDE.md (2)
14-47: Update macro names and source tree path to Light terminology.*
The macro table, usage import, and source tree still referencerentfree_programandsrc/rentfree/, but the public macro is nowlight_programand the module moved tolight_pdas/. This will mislead consumers following the docs.Proposed doc updates
-| `#[rentfree_program]` | Attribute | Program-level auto-discovery and instruction generation | +| `#[light_program]` | Attribute | Program-level auto-discovery and instruction generation | -├── rentfree/ # LightAccounts macro system +├── light_pdas/ # LightAccounts macro system -use light_sdk_macros::{rentfree_program, LightAccounts, LightCompressible}; +use light_sdk_macros::{light_program, LightAccounts, LightCompressible}; -#[rentfree_program] +#[light_program]
32-41: Specify a language for the fenced code block.
markdownlint MD040 flags this block because it lacks a language identifier.Suggested fix
-``` +```text src/ ├── lib.rs # Macro entry points ├── rentfree/ # LightAccounts macro system │ ├── account/ # Trait derive macros for account data structs │ ├── accounts/ # #[derive(LightAccounts)] for Accounts structs │ ├── program/ # #[rentfree_program] attribute macro │ └── shared_utils.rs # Common utilities └── hasher/ # LightHasherSha derive macro -``` +```sdk-libs/macros/docs/features/light-features.md (2)
9-19: Overview snippet uses old derives and misplaces#[light_account(init)].
Line 9-19 still importsRentFreeand applies#[light_account(init)]to the data struct.#[light_account(init)]is a field attribute inside#[derive(Accounts, LightAccounts)]structs; the data struct should useLightAccountorLightCompressible.Suggested shape
use light_sdk_macros::{LightAccount, LightAccounts}; #[derive(LightAccount)] pub struct MyAccount { pub data: u64, #[compression_info] pub compression_info: CompressionInfo, } #[derive(Accounts, LightAccounts)] pub struct Create<'info> { #[light_account(init)] pub my_account: Account<'info, MyAccount>, }
130-153: Replacerentfree_program/RentFreereferences with the new API.
Sections 5 and the complete example still use#[rentfree_program]andRentFree. These should be#[light_program]andLightAccounts/LightAccountto match the renamed macros.Also applies to: 455-479
sdk-libs/macros/docs/features/comparison.md (2)
7-13: Rename “Light RentFree” headings to LightAccounts for consistency.The column header and surrounding text still use “Light RentFree” while the examples now use
LightAccounts/#[light_account(...)]. Please update the headings and labels to the new name to avoid documenting a deprecated API surface. As per coding guidelines, documentation should match the current API.
153-162: Pack/Unpack traits are not generated by#[derive(LightAccounts)].
LightAccountsderivesLightPreInit/LightFinalizefor Accounts structs, but Pack/Unpack come from data-struct derives likeCompressiblePackorLightCompressible. Update this row to reflect the correct derive(s). Based on learnings, the Pack/Unpack traits are provided by the data-struct derives, not the Accounts derive.sdk-libs/macros/docs/accounts/light_mint.md (2)
7-16: Update the example import to match the new derive name.The example still imports
RentFreebut derivesLightAccounts. That will not compile and is confusing for readers. Please update the import to theLightAccountsderive. As per coding guidelines, documentation should reflect the current API.Proposed fix
-use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts;
292-296: Replace#[light_mint]wording with#[light_account(init, mint)].The text still refers to
#[light_mint], but the examples and new syntax use#[light_account(init, mint, ...)]. Please update this section to the new attribute name. As per coding guidelines, documentation should match the current API.sdk-libs/macros/docs/accounts/architecture.md (3)
14-25: Module path still referencesrentfree/after the rename.The module structure points to
sdk-libs/macros/src/rentfree/, but the code has moved tolight_pdas/. Please update the tree to match the new layout. As per coding guidelines, documentation should reflect the current source layout.
69-79: Update the optional-arguments snippet to#[light_account(init, ...)].The snippet still shows
#[rentfree(...)], which no longer matches the new attribute syntax. Please update it to#[light_account(init, ...)]to avoid documenting a deprecated attribute. As per coding guidelines, documentation should match the current API.
124-133: Codegen flow still names#[light_mint]fields.The parsing/flow description says
#[light_mint]and maps toLightMintField. With the unified attribute, this should describe#[light_account(init, mint, ...)]. Please update the flow labels to match the new syntax. As per coding guidelines, documentation should match the current API.sdk-libs/macros/src/light_pdas/program/variant_enum.rs (1)
46-62: Error message still references#[rentfree_program].Please update the validation error to
#[light_program]and the LightAccounts terminology so users see the correct macro name.sdk-libs/macros/src/light_pdas/accounts/mint.rs (1)
308-311: Align defaults with documentation—16u8/766u32 do not match documented 2/0.Three issues need addressing:
Default value mismatch: Code uses
16u8and766u32, but the struct doc comments andlight_mint.mddocument defaults as2u8and0u32. Update code defaults to match docs, or revise documentation to reflect the actual defaults.Multi-mint limitation: Taking
rent_paymentandwrite_top_uponly from the first mint without validating other mints have compatible values is a known limitation (TODO comment at line 344). Either enforce identical values at parse-time, support per-mint values, or document this constraint explicitly for users.Empty slice safety: The
mints[0]access assumes the slice is non-empty. While the builder pattern'shas_mints()check protects this in practice, add an explicit guard or assert for clarity and robustness.
🤖 Fix all issues with AI agents
In `@sdk-libs/macros/docs/accounts/architecture.md`:
- Around line 577-579: Add a single blank line immediately before the "### Type
Restrictions" heading so the heading is separated from the preceding
paragraph/list (fixing MD022); update the section around the "### Type
Restrictions" heading to ensure there is an empty line above it and leave the
existing lines under that heading unchanged.
- Around line 99-106: Update the documentation to stop referencing the old
attribute `#[light_mint]` and instead use the unified macro form
`#[light_account(init, mint)]`; specifically change the example and surrounding
text that mentions `#[light_mint]` to show `#[light_account(init, mint)]` (keep
the `#[derive(Accounts, LightAccounts)]`, `#[instruction(params:
CreateParams)]`, and the `CreateAccounts<'info>` struct name intact) and adjust
any explanatory text so it reflects the new `#[light_account(init, mint, ...)]`
syntax.
In `@sdk-libs/macros/docs/features/comparison.md`:
- Around line 224-227: The markdown has no blank line between the "After
(LightAccounts)" paragraph and the fenced code block, triggering MD031; edit the
section containing the "After (LightAccounts)" heading and the following code
fence (the ```rust block shown) and insert a single blank line between the
paragraph/heading and the opening ```rust fence so the fenced code block is
separated by an empty line.
In `@sdk-libs/macros/src/light_pdas/account/seed_extraction.rs`:
- Around line 204-238: The function check_light_account_type currently iterates
the parsed tokens twice to set has_mint and has_init; change it to a single pass
over the tokens (after extracting list.tokens from attr.meta in
check_light_account_type) and set both boolean flags in that loop, then return
(!has_mint, has_mint) when has_init is true; keep the existing
attr.path().is_ident("light_account") and meta parsing logic and ensure you
still handle non-List metas by continuing the outer loop.
In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs`:
- Around line 3-6: The doc comment in the light_pdas accounts module incorrectly
states that the PDA form "replaces `#[light_account(init)]`" which is circular;
change the second reference to the legacy PDA attribute (for example
`#[rentfree]`) so the sentence reads that `#[light_account(init)]` replaces the
legacy PDA attribute `#[rentfree]` (or the correct legacy attribute name used
previously), and ensure the surrounding bullet still correctly lists
`#[light_account(init)]` as the new PDA syntax; update the doc string near the
top of the module where the three bullets are defined.
- Around line 88-104: The token branch in the parser (where it checks if first
== "token" and currently consumes remaining tokens then returns Self { has_init:
false, is_token: true, account_type: LightAccountType::Pda, ... }) should not
silently accept arbitrary/malformed arguments; instead, parse and validate the
remaining token arguments using the shared parser (e.g., the seed_extraction.rs
parser) or explicitly validate allowed key/value pairs (like "authority") and
emit a diagnostic on unexpected tokens; update the logic in that branch to call
the common parser or return Err with a clear message when extra tokens are
invalid, and keep setting has_init/is_token appropriately while not hiding
format errors.
In `@sdk-libs/macros/src/light_pdas/accounts/mint.rs`:
- Around line 24-27: Update the doc comment for the field_ident member on struct
LightMintField to reflect the new public attribute syntax: replace the old
reference to #[light_mint] with #[light_account(init, mint, ...)] so the comment
correctly describes where the attribute is applied (the CMint account) and
avoids confusion.
In `@sdk-libs/macros/src/light_pdas/accounts/parse.rs`:
- Around line 90-101: The set method currently overwrites existing infra fields;
change InfraFields::set to detect duplicates and return a failure rather than
silently overwrite: have set take (or return) a Result<(), syn::Error> (or
otherwise produce a compile error via syn::Error::new_spanned on the incoming
Ident) and for each InfraFieldType arm (e.g., InfraFieldType::FeePayer,
CompressionConfig, LightTokenConfig, LightTokenRentSponsor, LightTokenProgram,
LightTokenCpiAuthority) check if the corresponding Option (self.fee_payer,
self.compression_config, etc.) is already Some and, if so, return
Err(syn::Error::new_spanned(ident, "duplicate infrastructure field: <name>"));
otherwise set the field to Some(ident) and return Ok(()); apply the same
duplicate-check logic to the other affected location mentioned (lines around
188-192) and update call sites to handle the Result.
- Around line 205-218: The error messages for the deprecated attributes are
misleading: when attr.path().is_ident("rentfree") and when
attr.path().is_ident("light_mint") the Err::new_spanned messages incorrectly
reference #[light_account(init)] instead of the actual deprecated attribute
names; update the message strings in these branches (the blocks that return
Err::new_spanned for rentfree and light_mint) to mention #[rentfree] and
#[light_mint] respectively and provide the corrected replacement usage text
(e.g., for rentfree explain the new attribute(s) to use, and for light_mint show
the full #[light_account(init, mint, mint_signer = ..., authority = ...,
decimals = ..., mint_seeds = ...)] usage).
In `@sdk-libs/macros/src/light_pdas/program/instructions.rs`:
- Around line 108-110: The current call to
LightVariantBuilder::new(&pda_ctx_seeds).build()? triggers validation that fails
when pda_ctx_seeds is empty, breaking TokenOnly variants; modify the logic to
skip invoking LightVariantBuilder (or skip its validate step) when
pda_ctx_seeds.is_empty() and the instruction_variant is
InstructionVariant::TokenOnly—mirroring the DecompressBuilder approach—so that
TokenOnly programs which legitimately have no PDA seeds do not error; locate
usages around LightVariantBuilder::new, pda_ctx_seeds, and
InstructionVariant::TokenOnly and conditionally bypass or relax validation
accordingly.
In `@sdk-libs/macros/src/light_pdas/program/variant_enum.rs`:
- Around line 490-497: Rename the helper function
generate_rentfree_account_data_struct to a clearer name that matches the emitted
type (e.g., generate_light_account_data_struct); update the function signature,
its doc comment, and all call sites that reference
generate_rentfree_account_data_struct to the new name, and ensure any references
in comments or tests are updated so the helper clearly reflects that it emits
the LightAccountData struct and not a rent-free-specific type.
In `@sdk-libs/macros/src/light_pdas/shared_utils.rs`:
- Line 88: Update the doc comment example for the light_account attribute to add
the missing space after the comma between mint and mint_signer; locate the
comment containing the attribute example `#[light_account(init, mint,mint_signer
= self.authority)]` and change it to use a consistent spacing `mint,
mint_signer` so the attribute reads `#[light_account(init, mint, mint_signer =
self.authority)]`.
In `@sdk-libs/token-sdk/src/token/decompress_mint.rs`:
- Around line 341-343: The doc comment above the struct field
light_token_cpi_authority is outdated (mentions "CToken program's CPI
authority"); update it to match the new name and intent—e.g., replace "CToken
program's CPI authority" with "Light token program's CPI authority" or similar
wording consistent with the renaming so the comment and the field
light_token_cpi_authority are aligned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 5
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (16)
sdk-libs/macros/src/light_pdas/README.md (2)
1-20: Doc still references RentFree paths/macros; update to Light naming.This README lives under
light_pdas/but still documentsrentfree/,#[rentfree_program],rentfree_program_impl(), andRentFreeAccountVariant. That conflicts with the PR’s rename and will mislead users. Please align all directory/module/macro names to the Light equivalents (e.g.,light_pdas/,#[light_program],light_program_impl(),LightAccountVariant).
33-47: Module header still says RentFree; align section titles.The
accounts/andprogram/section headings still say “RentFree” and describe#[rentfree_program]. Update the headings and macro names to Light nomenclature to avoid mixed terminology.sdk-libs/macros/docs/accounts/light_mint.md (3)
11-12: Import statement uses outdated macro name.The example still imports
RentFreebut per the PR objectives, this should beLightAccounts:-use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts;
316-320: Related documentation paths reference old naming.The related documentation section still references the old
rentfreepaths. These should be updated to reflect the new naming:-## Related Documentation - -- **`../rentfree.md`** - Full RentFree derive macro documentation -- **`../rentfree_program/`** - Program-level `#[rentfree_program]` macro -- **`../account/`** - Trait derives for data structs +## Related Documentation + +- **`../light_accounts.md`** - Full LightAccounts derive macro documentation +- **`../light_program/`** - Program-level `#[light_program]` macro +- **`../account/`** - Trait derives for data structs
103-112: Add blank lines around fenced code blocks.Per markdownlint MD031, fenced code blocks should be surrounded by blank lines. The code blocks after "ERROR" comments need spacing:
// ERROR: name without symbol and uri #[light_account(init, mint, ..., name = params.name.clone() )] + // ERROR: additional_metadata without name, symbol, urisdk-libs/macros/docs/features/light-features.md (3)
1-3: Title and overview still reference "RentFree" naming.The document title and opening paragraph still use the old "RentFree" terminology. For consistency with the PR's unified "Light" naming:
-# Light Protocol RentFree Features +# Light Protocol LightAccounts Features -This document covers the 17 features available in Light Protocol's rentfree macro system for creating compressed (rent-free) accounts and tokens. +This document covers the 17 features available in Light Protocol's LightAccounts macro system for creating compressed (rent-free) accounts and tokens.
9-20: Overview example mixes old and new naming conventions.The overview code block imports
RentFreeand derivesRentFree, but uses the new#[light_account(init)]attribute. This creates confusion. The imports and derives should be updated:use light_sdk::compressible::CompressionInfo; -use light_sdk_macros::{RentFree, Compressible, HasCompressionInfo}; +use light_sdk_macros::LightAccounts; -#[derive(RentFree, Compressible, HasCompressionInfo)] +#[derive(LightAccounts)] #[light_account(init)] pub struct MyAccount {Note: Based on the coding guidelines,
#[derive(LightAccounts)]should replace the combination ofRentFree,Compressible, andHasCompressionInfofor account-level macros.
450-464: Complete example still uses old derive naming.The "Complete Example" section at the end still shows the old derive pattern. This should demonstrate the new unified approach:
-#[derive(RentFree, Compressible, HasCompressionInfo)] +#[derive(LightAccounts)] #[light_account(init)] pub struct UserProfile {sdk-libs/macros/docs/accounts/architecture.md (3)
1-1: Document title inconsistent with content.The title says "RentFree Derive Macro" but the content describes
#[derive(LightAccounts)]. Update for consistency:-# RentFree Derive Macro and Trait Derives +# LightAccounts Derive Macro and Trait Derives
14-35: Module structure paths reference old directory.The module structure diagram still shows
sdk-libs/macros/src/rentfree/but this should be updated tosdk-libs/macros/src/light_pdas/to match the actual directory structure after the rename:-sdk-libs/macros/src/rentfree/ +sdk-libs/macros/src/light_pdas/Similarly, lines 45, 122, 152, 357, 375, 415, 476, and 511-564 reference
rentfree/paths that should belight_pdas/.
587-591: Related documentation paths reference old naming.The related documentation section references outdated paths:
-## 6. Related Documentation - -- **`sdk-libs/macros/docs/rentfree_program/`** - Program-level `#[rentfree_program]` attribute macro (architecture.md + codegen.md) +## 6. Related Documentation + +- **`sdk-libs/macros/docs/light_program/`** - Program-level `#[light_program]` attribute macro (architecture.md + codegen.md)sdk-libs/macros/src/light_pdas/accounts/mint.rs (2)
330-333: Avoid panics on missing proof.Using
expectwill abort the program. Prefer a recoverable error so failures surface cleanly to callers.🐛 Suggested fix
- let __proof: light_token_sdk::CompressedProof = `#params_ident.create_accounts_proof.proof.0.clone`() - .expect("proof is required for mint creation"); + let __proof: light_token_sdk::CompressedProof = `#params_ident` + .create_accounts_proof + .proof + .0 + .clone() + .ok_or(anchor_lang::solana_program::program_error::ProgramError::InvalidArgument)?;
42-45: Update field documentation to match actual code defaults.Lines 42 and 44 document
rent_paymentas defaulting to 2 andwrite_top_upas defaulting to 0, but the code at lines 309–310 uses 16u8 and 766u32 as fallback values when these fields are not provided. Update the documentation to reflect the actual defaults:Doc fix
- /// Rent payment epochs for decompression (default: 2) + /// Rent payment epochs for decompression (default: 16) pub rent_payment: Option<Expr>, - /// Write top-up lamports for decompression (default: 0) + /// Write top-up lamports for decompression (default: 766) pub write_top_up: Option<Expr>,sdk-libs/macros/src/light_pdas/accounts/builder.rs (2)
1-20: Update the header to LightAccounts naming.The file-level docs still reference RentFree.
✏️ Suggested fix
-//! Builder for RentFree derive macro code generation. +//! Builder for LightAccounts derive macro code generation. @@ -/// Builder for RentFree derive macro code generation. +/// Builder for LightAccounts derive macro code generation.
265-271: Align both CPI accounts paths to the canonical source.This file uses
light_sdk_types::cpi_accounts::CpiAccountsConfigat line 210 butlight_sdk::cpi::CpiAccountsConfigat line 270. While both resolve to the same type (the latter re-exports the former), keeping them consistent within the same file improves readability. Use the direct source path throughout.🛠️ Suggested fix
- light_sdk::cpi::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER), + light_sdk_types::cpi_accounts::CpiAccountsConfig::new_with_cpi_context(crate::LIGHT_CPI_SIGNER),sdk-libs/macros/src/light_pdas/program/variant_enum.rs (1)
10-63: Rename remaining RentFree references in docs/errors.The section header and validation error still mention
RentFree/#[rentfree_program], which is inconsistent with the new Light naming.✏️ Suggested fix
-// RENTFREE VARIANT BUILDER +// LIGHT VARIANT BUILDER @@ - "#[rentfree_program] requires at least one Accounts struct with \ + "#[light_program] requires at least one Accounts struct with \
🤖 Fix all issues with AI agents
In `@sdk-libs/macros/docs/accounts/light_mint.md`:
- Line 7: The docs reference an outdated module location (old "rentfree" layout)
for light_mint; update the "Source" line in
sdk-libs/macros/docs/accounts/light_mint.md to point to the new module (e.g.,
macros::accounts::light_mint or crate::accounts::light_mint corresponding to the
moved light_mint.rs) so the doc link matches the refactor, then run the
docs/build check to ensure the reference resolves.
In `@sdk-libs/macros/docs/features/comparison.md`:
- Around line 226-227: Replace the old RentFree derive in the "After" example
with the new LightAccounts pattern: change #[derive(RentFree, Compressible,
HasCompressionInfo)] to #[derive(LightAccounts, Compressible,
HasCompressionInfo)] and update the attribute #[light_account(init)] to
#[light_accounts(init)] so the example shows the new derive/attribute names
(referencing the RentFree derive, LightAccounts derive, light_account and
light_accounts attribute identifiers).
In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs`:
- Around line 290-295: The loop that assigns mint_signer and authority currently
accepts arbitrary values (kv.value) which later get expanded as
self.#mint_signer / self.#authority and can produce invalid code; change the
logic in the key_values match for "mint_signer" and "authority" to validate that
kv.value is a simple identifier (e.g., attempt to parse kv.value as a syn::Ident
or otherwise ensure it matches identifier rules) and return a clear compile-time
error if parsing/validation fails, storing the validated Ident (or its string)
instead of an arbitrary expression; keep the existing handling for other keys
like "decimals" and "mint_seeds".
In `@sdk-libs/macros/src/light_pdas/README.md`:
- Around line 11-14: The README currently repeats the attribute
`#[light_account(init)]` and omits token/mint variants; update the attribute
list that documents the accounts module to remove the duplicate
`#[light_account(init)]` and add the token/mint forms you support (e.g.
`#[light_account(token)]` and `#[light_account(mint)]` or your exact mint
variant name), and make the same correction in the other occurrence of the
duplicated attribute list elsewhere in the file so both places consistently show
init, token, and mint variants.
In `@sdk-libs/token-sdk/src/token/decompress_mint.rs`:
- Around line 398-399: Comment mentions "ctoken's CPI authority" but the field
is now named light_token_cpi_authority; update the inline comment to match the
new identifier and terminology. Locate the line referencing
self.light_token_cpi_authority in decompress_mint (around the CPI call) and
change the comment to something like "Use light_token's CPI authority for the
CPI, not the calling program's authority" so the comment consistently reflects
the renamed field and intent.
♻️ Duplicate comments (3)
sdk-libs/macros/docs/features/comparison.md (1)
224-227: Missing blank line before fenced code block (MD031).There should be a blank line before the code fence to satisfy markdownlint:
**After (LightAccounts)**: + ```rust #[derive(RentFree, Compressible, HasCompressionInfo)]sdk-libs/macros/docs/accounts/architecture.md (2)
99-106: Replace#[light_mint]with#[light_account(init, mint)].This section still mentions
#[instruction(...)]being required for#[light_mint], but the macro surface is now unified under#[light_account(init, mint, ...)]:-Must be present on the struct when using `#[light_account(init)]` or `#[light_account(init)]`. +Must be present on the struct when using `#[light_account(init)]` or `#[light_account(init, mint)]`.Note: Line 101 currently shows
#[light_account(init)]twice, which appears to be a copy-paste error.
574-580: Add blank line before "Type Restrictions" heading.Per MD022, headings should be surrounded by blank lines:
- **Maximum 255 fields**: Total `#[light_account(init)]` + `#[light_account(init)]` fields must be <= 255 (u8 index limit) - **Single mint field**: Currently only the first `#[light_account(init)]` field is processed + ### Type RestrictionsAlso, line 574 shows
#[light_account(init)]twice — should be#[light_account(init)]+#[light_account(init, mint)].
| The `#[light_mint(...)]` attribute marks a field in an Anchor Accounts struct for compressed mint creation. When applied to a `CMint` account field, it generates code to create a compressed mint with automatic decompression support. | ||
| The `#[light_account(init, mint,...)]` attribute marks a field in an Anchor Accounts struct for compressed mint creation. When applied to a `CMint` account field, it generates code to create a compressed mint with automatic decompression support. | ||
|
|
||
| **Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Source path references outdated module location.
The source path still points to the old rentfree directory. Based on the PR's module restructuring:
-**Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs`
+**Source**: `sdk-libs/macros/src/light_pdas/accounts/light_mint.rs`📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| **Source**: `sdk-libs/macros/src/rentfree/accounts/light_mint.rs` | |
| **Source**: `sdk-libs/macros/src/light_pdas/accounts/light_mint.rs` |
🤖 Prompt for AI Agents
In `@sdk-libs/macros/docs/accounts/light_mint.md` at line 7, The docs reference an
outdated module location (old "rentfree" layout) for light_mint; update the
"Source" line in sdk-libs/macros/docs/accounts/light_mint.md to point to the new
module (e.g., macros::accounts::light_mint or crate::accounts::light_mint
corresponding to the moved light_mint.rs) so the doc link matches the refactor,
then run the docs/build check to ensure the reference resolves.
| #[derive(RentFree, Compressible, HasCompressionInfo)] | ||
| #[rentfree] | ||
| #[light_account(init)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"After" example still uses old derive naming.
The "After (LightAccounts)" example ironically still shows the old RentFree derive. This should demonstrate the new pattern:
-#[derive(RentFree, Compressible, HasCompressionInfo)]
+#[derive(LightAccounts)]
#[light_account(init)]
pub struct Counter {🤖 Prompt for AI Agents
In `@sdk-libs/macros/docs/features/comparison.md` around lines 226 - 227, Replace
the old RentFree derive in the "After" example with the new LightAccounts
pattern: change #[derive(RentFree, Compressible, HasCompressionInfo)] to
#[derive(LightAccounts, Compressible, HasCompressionInfo)] and update the
attribute #[light_account(init)] to #[light_accounts(init)] so the example shows
the new derive/attribute names (referencing the RentFree derive, LightAccounts
derive, light_account and light_accounts attribute identifiers).
| for kv in key_values { | ||
| match kv.key.to_string().as_str() { | ||
| "mint_signer" => mint_signer = Some(kv.value.clone()), | ||
| "authority" => authority = Some(kv.value.clone()), | ||
| "decimals" => decimals = Some(kv.value.clone()), | ||
| "mint_seeds" => mint_seeds = Some(kv.value.clone()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate mint_signer/authority as identifiers.
These values are later expanded as self.#mint_signer / self.#authority. Allowing arbitrary expressions will generate invalid code with confusing errors. Validate them as simple identifiers for clearer diagnostics.
🛠️ Suggested fix
- "mint_signer" => mint_signer = Some(kv.value.clone()),
- "authority" => authority = Some(kv.value.clone()),
+ "mint_signer" => {
+ let ident = expr_to_ident(&kv.value, "mint_signer")?;
+ mint_signer = Some(syn::parse_quote!(`#ident`));
+ }
+ "authority" => {
+ let ident = expr_to_ident(&kv.value, "authority")?;
+ authority = Some(syn::parse_quote!(`#ident`));
+ }🤖 Prompt for AI Agents
In `@sdk-libs/macros/src/light_pdas/accounts/light_account.rs` around lines 290 -
295, The loop that assigns mint_signer and authority currently accepts arbitrary
values (kv.value) which later get expanded as self.#mint_signer /
self.#authority and can produce invalid code; change the logic in the key_values
match for "mint_signer" and "authority" to validate that kv.value is a simple
identifier (e.g., attempt to parse kv.value as a syn::Ident or otherwise ensure
it matches identifier rules) and return a clear compile-time error if
parsing/validation fails, storing the validated Ident (or its string) instead of
an arbitrary expression; keep the existing handling for other keys like
"decimals" and "mint_seeds".
| ├── accounts/ # #[derive(LightAccounts)] implementation | ||
| │ ├── mod.rs # Entry point: derive_rentfree() | ||
| │ ├── parse.rs # Parsing #[rentfree], #[light_mint] attributes | ||
| │ ├── parse.rs # Parsing #[light_account(init)], #[light_account(init)] attributes | ||
| │ └── codegen.rs # LightPreInit/LightFinalize trait generation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix duplicated attribute list; include token/mint variants.
The attribute list repeats #[light_account(init)] twice and omits the token/mint forms mentioned in the PR summary. Please correct the list to include #[light_account(token)] and any mint variant you support.
Also applies to: 37-38
🤖 Prompt for AI Agents
In `@sdk-libs/macros/src/light_pdas/README.md` around lines 11 - 14, The README
currently repeats the attribute `#[light_account(init)]` and omits token/mint
variants; update the attribute list that documents the accounts module to remove
the duplicate `#[light_account(init)]` and add the token/mint forms you support
(e.g. `#[light_account(token)]` and `#[light_account(mint)]` or your exact mint
variant name), and make the same correction in the other occurrence of the
duplicated attribute list elsewhere in the file so both places consistently show
init, token, and mint variants.
| // Use ctoken's CPI authority for the CPI, not the calling program's authority | ||
| self.ctoken_cpi_authority.clone(), | ||
| self.light_token_cpi_authority.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor inconsistency in inline comment.
The comment on line 398 still references "ctoken's CPI authority" while the field itself has been renamed to light_token_cpi_authority. For consistency with the broader rename:
- // Use ctoken's CPI authority for the CPI, not the calling program's authority
+ // Use light token program's CPI authority for the CPI, not the calling program's authority📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Use ctoken's CPI authority for the CPI, not the calling program's authority | |
| self.ctoken_cpi_authority.clone(), | |
| self.light_token_cpi_authority.clone(), | |
| // Use light token program's CPI authority for the CPI, not the calling program's authority | |
| self.light_token_cpi_authority.clone(), |
🤖 Prompt for AI Agents
In `@sdk-libs/token-sdk/src/token/decompress_mint.rs` around lines 398 - 399,
Comment mentions "ctoken's CPI authority" but the field is now named
light_token_cpi_authority; update the inline comment to match the new identifier
and terminology. Locate the line referencing self.light_token_cpi_authority in
decompress_mint (around the CPI call) and change the comment to something like
"Use light_token's CPI authority for the CPI, not the calling program's
authority" so the comment consistently reflects the renamed field and intent.
Changes
Impact
Macros & Attributes
Functions
Structs & Types
Modules/Directories
Field/Account Names
Module Imports
Summary by CodeRabbit
New Features
Refactor
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.