diff --git a/sdk-libs/compressible-client/src/lib.rs b/sdk-libs/compressible-client/src/lib.rs index 77c18ff0a3..bcb6c651bb 100644 --- a/sdk-libs/compressible-client/src/lib.rs +++ b/sdk-libs/compressible-client/src/lib.rs @@ -251,7 +251,7 @@ pub mod compressible_instruction { use super::*; /// Returns program account metas for decompress_accounts_idempotent with CToken support. - /// Includes ctoken_rent_sponsor, light_token_program, ctoken_cpi_authority, ctoken_config. + /// Includes ctoken_rent_sponsor, light_token_program, light_token_cpi_authority, ctoken_config. pub fn accounts( fee_payer: Pubkey, config: Pubkey, diff --git a/sdk-libs/macros/CLAUDE.md b/sdk-libs/macros/CLAUDE.md index f8f229dd1d..52c0ea1181 100644 --- a/sdk-libs/macros/CLAUDE.md +++ b/sdk-libs/macros/CLAUDE.md @@ -13,7 +13,7 @@ This crate provides macros that enable rent-free compressed accounts on Solana w | Macro | Type | Purpose | |-------|------|---------| -| `#[derive(RentFree)]` | Derive | Generates `LightPreInit`/`LightFinalize` for Accounts structs | +| `#[derive(LightAccounts)]` | Derive | Generates `LightPreInit`/`LightFinalize` for Accounts structs | | `#[rentfree_program]` | Attribute | Program-level auto-discovery and instruction generation | | `#[derive(LightCompressible)]` | Derive | Combined traits for compressible account data | | `#[derive(Compressible)]` | Derive | Compression traits (HasCompressionInfo, CompressAs, Size) | @@ -24,7 +24,7 @@ This crate provides macros that enable rent-free compressed accounts on Solana w Detailed macro documentation is in the `docs/` directory: - **`docs/CLAUDE.md`** - Documentation structure guide -- **`docs/rentfree.md`** - `#[derive(RentFree)]` and trait derives +- **`docs/rentfree.md`** - `#[derive(LightAccounts)]` and trait derives - **`docs/rentfree_program/`** - `#[rentfree_program]` attribute macro (architecture.md + codegen.md) ## Source Structure @@ -32,9 +32,9 @@ Detailed macro documentation is in the `docs/` directory: ``` src/ ├── lib.rs # Macro entry points -├── rentfree/ # RentFree macro system +├── rentfree/ # LightAccounts macro system │ ├── account/ # Trait derive macros for account data structs -│ ├── accounts/ # #[derive(RentFree)] for Accounts structs +│ ├── accounts/ # #[derive(LightAccounts)] for Accounts structs │ ├── program/ # #[rentfree_program] attribute macro │ └── shared_utils.rs # Common utilities └── hasher/ # LightHasherSha derive macro @@ -43,7 +43,7 @@ src/ ## Usage Example ```rust -use light_sdk_macros::{rentfree_program, RentFree, LightCompressible}; +use light_sdk_macros::{rentfree_program, LightAccounts, LightCompressible}; // State account with compression support #[derive(Default, Debug, InitSpace, LightCompressible)] @@ -55,14 +55,14 @@ pub struct UserRecord { } // Accounts struct with rent-free field -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct Create<'info> { #[account(mut)] pub fee_payer: Signer<'info>, #[account(init, payer = fee_payer, space = 8 + UserRecord::INIT_SPACE, seeds = [b"user", params.owner.as_ref()], bump)] - #[rentfree] + #[light_account(init)] pub user_record: Account<'info, UserRecord>, } diff --git a/sdk-libs/macros/docs/CLAUDE.md b/sdk-libs/macros/docs/CLAUDE.md index b6f8348a24..ba0b604a71 100644 --- a/sdk-libs/macros/docs/CLAUDE.md +++ b/sdk-libs/macros/docs/CLAUDE.md @@ -10,7 +10,7 @@ Documentation for the rentfree macro system in `light-sdk-macros`. These macros |------|-------------| | **`CLAUDE.md`** | This file - documentation structure guide | | **`../CLAUDE.md`** | Main entry point for sdk-libs/macros | -| **`rentfree.md`** | `#[derive(RentFree)]` macro and trait derives | +| **`rentfree.md`** | `#[derive(LightAccounts)]` macro and trait derives | | **`rentfree_program/`** | `#[rentfree_program]` attribute macro | | **`rentfree_program/architecture.md`** | Architecture overview, usage, generated items | | **`rentfree_program/codegen.md`** | Technical implementation details (code generation) | @@ -19,13 +19,13 @@ Documentation for the rentfree macro system in `light-sdk-macros`. These macros ### Accounts Field Attributes -Field-level attributes applied inside `#[derive(RentFree)]` Accounts structs: +Field-level attributes applied inside `#[derive(LightAccounts)]` Accounts structs: | File | Attribute | Description | |------|-----------|-------------| -| **`accounts/light_mint.md`** | `#[light_mint(...)]` | Creates compressed mint with automatic decompression | +| **`accounts/light_mint.md`** | `#[light_account(init, mint,...)]` | Creates compressed mint with automatic decompression | -See also: `#[rentfree]` attribute documented in `rentfree.md` +See also: `#[light_account(init)]` attribute documented in `rentfree.md` ### Account Trait Documentation @@ -51,7 +51,7 @@ See also: `#[rentfree]` attribute documented in `rentfree.md` ``` #[rentfree_program] <- Program-level (rentfree_program/) | - +-- Discovers #[derive(RentFree)] structs + +-- Discovers #[derive(LightAccounts)] structs | +-- Generates: - RentFreeAccountVariant enum @@ -59,7 +59,7 @@ See also: `#[rentfree]` attribute documented in `rentfree.md` - Compress/Decompress instructions - Config instructions -#[derive(RentFree)] <- Account-level (rentfree.md) +#[derive(LightAccounts)] <- Account-level (rentfree.md) | +-- Generates LightPreInit + LightFinalize impls | @@ -76,7 +76,7 @@ See also: `#[rentfree]` attribute documented in `rentfree.md` ``` sdk-libs/macros/src/rentfree/ ├── account/ # Trait derive macros for account data structs -├── accounts/ # #[derive(RentFree)] implementation +├── accounts/ # #[derive(LightAccounts)] implementation ├── program/ # #[rentfree_program] implementation ├── shared_utils.rs # Common utilities └── mod.rs # Module exports diff --git a/sdk-libs/macros/docs/account/light_compressible.md b/sdk-libs/macros/docs/account/light_compressible.md index e47af4f03e..91de5cca2d 100644 --- a/sdk-libs/macros/docs/account/light_compressible.md +++ b/sdk-libs/macros/docs/account/light_compressible.md @@ -4,7 +4,7 @@ The `#[derive(LightCompressible)]` macro is a convenience derive that combines all traits required for a fully compressible account. It is the recommended way to prepare account structs for Light Protocol's rent-free compression system. -**When to use**: Apply this derive to any account struct that will be used with `#[rentfree]` in an Accounts struct. This is the standard approach for most use cases. +**When to use**: Apply this derive to any account struct that will be used with `#[light_account(init)]` in an Accounts struct. This is the standard approach for most use cases. **Source**: `sdk-libs/macros/src/rentfree/traits/light_compressible.rs` (lines 56-79) @@ -83,11 +83,11 @@ INPUT GENERATED | Data Struct | --> | Accounts Struct | --> | Runtime | +-------------------+ +-------------------+ +-------------------+ | #[derive( | | #[derive(Accounts,| | light_pre_init() | -| LightCompressible)] | RentFree)] | | Uses: | +| LightCompressible)] | LightAccounts)] | | Uses: | | | | #[instruction] | | - DataHasher | | Provides: | | pub struct Create | | - LightDiscrim. | | - Hashing | | { | | - HasCompression| -| - Discriminator | | #[rentfree] | | Info | +| - Discriminator | | #[light_account(init)] | | Info | | - Compression | | pub user_record | | - CompressAs | | - Pack/Unpack | | } | | - Size | +-------------------+ +-------------------+ | - Pack | @@ -256,9 +256,9 @@ If no `Pubkey` fields exist, identity implementations are generated instead. --- -## 10. Usage with RentFree +## 10. Usage with LightAccounts -`LightCompressible` prepares the data struct for use with `#[derive(RentFree)]` on Accounts structs: +`LightCompressible` prepares the data struct for use with `#[derive(LightAccounts)]` on Accounts structs: ```rust // Data struct - apply LightCompressible @@ -271,14 +271,14 @@ pub struct UserRecord { } // Accounts struct - apply RentFree -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct Create<'info> { #[account(mut)] pub fee_payer: Signer<'info>, #[account(init, payer = fee_payer, space = 8 + UserRecord::INIT_SPACE, ...)] - #[rentfree] + #[light_account(init)] pub user_record: Account<'info, UserRecord>, } ``` diff --git a/sdk-libs/macros/docs/accounts/architecture.md b/sdk-libs/macros/docs/accounts/architecture.md index 90aa45788e..bbc49aca30 100644 --- a/sdk-libs/macros/docs/accounts/architecture.md +++ b/sdk-libs/macros/docs/accounts/architecture.md @@ -2,7 +2,7 @@ ## 1. Overview -The `#[derive(RentFree)]` macro and associated trait derives enable rent-free compressed accounts on Solana with minimal boilerplate. These macros generate code for: +The `#[derive(LightAccounts)]` macro and associated trait derives enable rent-free compressed accounts on Solana with minimal boilerplate. These macros generate code for: - Pre-instruction compression setup (`LightPreInit` trait) - Post-instruction cleanup (`LightFinalize` trait) @@ -16,7 +16,7 @@ sdk-libs/macros/src/rentfree/ |-- mod.rs # Module exports |-- shared_utils.rs # Common utilities (constant detection, identifier extraction) | -|-- accounts/ # #[derive(RentFree)] for Accounts structs +|-- accounts/ # #[derive(LightAccounts)] for Accounts structs | |-- mod.rs # Module entry point | |-- derive.rs # Orchestration layer | |-- builder.rs # Code generation builder @@ -36,7 +36,7 @@ sdk-libs/macros/src/rentfree/ --- -## 2. `#[derive(RentFree)]` Derive Macro +## 2. `#[derive(LightAccounts)]` Derive Macro ### 2.1 Purpose @@ -46,12 +46,12 @@ Generates `LightPreInit` and `LightFinalize` trait implementations for Anchor Ac ### 2.2 Supported Attributes -#### `#[rentfree]` - Mark PDA Fields for Compression +#### `#[light_account(init)]` - Mark PDA Fields for Compression Applied to `Account<'info, T>` or `Box>` fields. ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateAccounts<'info> { #[account( @@ -61,7 +61,7 @@ pub struct CreateAccounts<'info> { seeds = [b"user", params.owner.as_ref()], bump )] - #[rentfree] // Uses default address_tree_info and output_tree from params + #[light_account(init)] // Uses default address_tree_info and output_tree from params pub user_record: Account<'info, UserRecord>, } ``` @@ -78,12 +78,12 @@ pub struct CreateAccounts<'info> { pub user_record: Account<'info, UserRecord>, ``` -#### `#[light_mint(...)]` - Mark Mint Fields +#### `#[light_account(init, mint,...)]` - Mark Mint Fields Creates a compressed mint with automatic decompression. ```rust -#[light_mint( +#[light_account(init, mint, mint_signer = mint_signer, // AccountInfo that seeds the mint PDA (required) authority = authority, // Mint authority (required) decimals = 9, // Token decimals (required) @@ -98,10 +98,10 @@ pub cmint: Account<'info, CMint>, #### `#[instruction(...)]` - Specify Instruction Parameters (Required) -Must be present on the struct when using `#[rentfree]` or `#[light_mint]`. +Must be present on the struct when using `#[light_account(init)]` or `#[light_account(init)]`. ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateAccounts<'info> { ... } ``` @@ -114,10 +114,10 @@ Infrastructure fields are auto-detected by naming convention. No attribute requi |------------|----------------| | Fee Payer | `fee_payer`, `payer`, `creator` | | Compression Config | `compression_config` | -| CToken Config | `ctoken_compressible_config`, `ctoken_config`, `light_token_config_account` | +| CToken Config | `light_token_compressible_config`, `ctoken_config`, `light_token_config_account` | | CToken Rent Sponsor | `ctoken_rent_sponsor`, `light_token_rent_sponsor` | | CToken Program | `ctoken_program`, `light_token_program` | -| CToken CPI Authority | `ctoken_cpi_authority`, `light_token_program_cpi_authority`, `compress_token_program_cpi_authority` | +| CToken CPI Authority | `light_token_cpi_authority`, `light_token_program_cpi_authority`, `compress_token_program_cpi_authority` | **Source**: `sdk-libs/macros/src/rentfree/accounts/parse.rs` (lines 30-53) @@ -127,14 +127,14 @@ Infrastructure fields are auto-detected by naming convention. No attribute requi 1. Parse |-- parse_rentfree_struct() extracts: | - Struct name and generics - | - #[rentfree] fields -> RentFreeField - | - #[light_mint] fields -> LightMintField + | - #[light_account(init)] fields -> RentFreeField + | - #[light_account(init)] fields -> LightMintField | - #[instruction] args | - Infrastructure fields by naming convention | 2. Validate |-- Total fields <= 255 (u8 index limit) - |-- #[instruction] required when #[rentfree] or #[light_mint] present + |-- #[instruction] required when #[light_account(init)] or #[light_account(init)] present | 3. Generate pre_init Body |-- PDAs + Mints: generate_pre_init_pdas_and_mints() @@ -156,7 +156,7 @@ Infrastructure fields are auto-detected by naming convention. No attribute requi **Input**: ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateAccounts<'info> { #[account(mut)] @@ -171,7 +171,7 @@ pub struct CreateAccounts<'info> { seeds = [b"user", params.owner.as_ref()], bump )] - #[rentfree] + #[light_account(init)] pub user_record: Account<'info, UserRecord>, } ``` @@ -254,7 +254,7 @@ The following diagram shows how the derive macros compose together to enable ren ==================== +--------------------+ - | #[derive(RentFree)]| <-- Applied to Anchor Accounts struct + | #[derive(LightAccounts)]| <-- Applied to Anchor Accounts struct +--------------------+ | | generates @@ -327,11 +327,11 @@ The following diagram shows how the derive macros compose together to enable ren | } | | | | // Accounts struct - apply RentFree | - | #[derive(Accounts, RentFree)] | + | #[derive(Accounts, LightAccounts)] | | #[instruction(params: CreateParams)] | | pub struct Create<'info> { | | #[account(init, ...)] | - | #[rentfree] <-- Marks for compression | + | #[light_account(init)] <-- Marks for compression | | pub user_record: Account<'info, UserRecord>, | | } | | | @@ -533,14 +533,14 @@ sdk-libs/macros/src/rentfree/ | |-- builder.rs RentFreeBuilder for code generation | |-- parse.rs Attribute parsing with darling | | - ParsedRentFreeStruct -| | - RentFreeField (#[rentfree] data) +| | - RentFreeField (#[light_account(init)] data) | | - InfraFields (auto-detected infrastructure) | | - InfraFieldClassifier (naming convention matching) | |-- pda.rs PDA compression block generation | | - PdaBlockBuilder | | - generate_pda_compress_blocks() | +-- light_mint.rs Mint action CPI generation -| - LightMintField (#[light_mint] data) +| - LightMintField (#[light_account(init)] data) | - InfraRefs - resolved infrastructure field references | - LightMintBuilder - builder pattern for mint CPI generation | - CpiContextParts - encapsulates CPI context branching logic @@ -571,13 +571,13 @@ sdk-libs/macros/src/rentfree/ ## 5. Limitations ### Field Limits -- **Maximum 255 fields**: Total `#[rentfree]` + `#[light_mint]` fields must be <= 255 (u8 index limit) -- **Single mint field**: Currently only the first `#[light_mint]` field is processed +- **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 Restrictions -- `#[rentfree]` only applies to `Account<'info, T>` or `Box>` fields +- `#[light_account(init)]` only applies to `Account<'info, T>` or `Box>` fields - Nested `Box>>` is not supported -- `#[rentfree]` and `#[light_mint]` are mutually exclusive on the same field +- `#[light_account(init)]` and `#[light_account(init)]` are mutually exclusive on the same field ### No-op Fallback When no `#[instruction]` attribute is present, the macro generates no-op implementations for backwards compatibility with non-compressible Accounts structs. diff --git a/sdk-libs/macros/docs/accounts/light_mint.md b/sdk-libs/macros/docs/accounts/light_mint.md index 29923349cb..4e035aa775 100644 --- a/sdk-libs/macros/docs/accounts/light_mint.md +++ b/sdk-libs/macros/docs/accounts/light_mint.md @@ -1,8 +1,8 @@ -# `#[light_mint(...)]` Attribute +# `#[light_account(init, mint,...)]` Attribute ## Overview -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` @@ -12,7 +12,7 @@ The `#[light_mint(...)]` attribute marks a field in an Anchor Accounts struct fo use light_sdk_macros::RentFree; use anchor_lang::prelude::*; -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateMint<'info> { #[account(mut)] @@ -25,7 +25,7 @@ pub struct CreateMint<'info> { pub authority: Signer<'info>, /// The CMint account to create - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 9, @@ -34,10 +34,10 @@ pub struct CreateMint<'info> { pub cmint: Account<'info, CMint>, // Infrastructure accounts (auto-detected by name) - pub ctoken_compressible_config: Account<'info, CtokenConfig>, + pub light_token_compressible_config: Account<'info, CtokenConfig>, pub ctoken_rent_sponsor: Account<'info, CtokenRentSponsor>, pub light_token_program: Program<'info, LightTokenProgram>, - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, } ``` @@ -80,7 +80,7 @@ Optional fields for creating a mint with the TokenMetadata extension: ### Metadata Example ```rust -#[light_mint( +#[light_account(init, mint, mint_signer = mint_signer, authority = fee_payer, decimals = 9, @@ -99,13 +99,13 @@ pub cmint: UncheckedAccount<'info>, ```rust // ERROR: name without symbol and uri -#[light_mint( +#[light_account(init, mint, ..., name = params.name.clone() )] // ERROR: additional_metadata without name, symbol, uri -#[light_mint( +#[light_account(init, mint, ..., additional_metadata = params.additional_metadata.clone() )] @@ -126,7 +126,7 @@ let (mint_pda, bump) = light_token_sdk::token::find_mint_address(mint_signer.key The `mint_seeds` attribute provides the PDA signer seeds used for `invoke_signed` when calling the light token program. These seeds must derive to the `mint_signer` pubkey for the CPI to succeed. ```rust -#[light_mint( +#[light_account(init, mint, mint_signer = mint_signer, authority = mint_authority, decimals = 9, @@ -159,14 +159,14 @@ invoke_signed(&mint_action_ix, &account_infos, &[mint_seeds])?; ### CPI Context Integration -When used alongside `#[rentfree]` PDAs, the mint is batched with PDA compression in a single CPI context. The mint receives an `assigned_account_index` to order it relative to PDAs. +When used alongside `#[light_account(init)]` PDAs, the mint is batched with PDA compression in a single CPI context. The mint receives an `assigned_account_index` to order it relative to PDAs. ## Examples ### Basic Mint Creation ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateBasicMint<'info> { #[account(mut)] @@ -178,7 +178,7 @@ pub struct CreateBasicMint<'info> { pub authority: Signer<'info>, - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 6, @@ -195,7 +195,7 @@ pub struct CreateBasicMint<'info> { When the authority is a PDA, provide `authority_seeds`: ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateMintWithPdaAuthority<'info> { #[account(mut)] @@ -209,7 +209,7 @@ pub struct CreateMintWithPdaAuthority<'info> { #[account(seeds = [b"authority"], bump)] pub authority: AccountInfo<'info>, - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 9, @@ -225,7 +225,7 @@ pub struct CreateMintWithPdaAuthority<'info> { ### Mint with Freeze Authority ```rust -#[light_mint( +#[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 9, @@ -241,7 +241,7 @@ pub freeze_auth: Signer<'info>, ### Custom Decompression Settings ```rust -#[light_mint( +#[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 9, @@ -252,10 +252,10 @@ pub freeze_auth: Signer<'info>, pub cmint: Account<'info, CMint>, ``` -### Combined with #[rentfree] PDAs +### Combined with #[light_account(init)] PDAs ```rust -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateParams)] pub struct CreateMintAndPda<'info> { #[account(mut)] @@ -267,7 +267,7 @@ pub struct CreateMintAndPda<'info> { pub authority: Signer<'info>, - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = authority, decimals = 9, @@ -282,14 +282,14 @@ pub struct CreateMintAndPda<'info> { seeds = [b"token", params.owner.as_ref()], bump )] - #[rentfree] + #[light_account(init)] pub token_account: Account<'info, TokenAccount>, // ... infrastructure accounts } ``` -When both `#[light_mint]` and `#[rentfree]` are present, the macro: +When both `#[light_account(init)]` and `#[light_account(init)]` are present, the macro: 1. Processes PDAs first, writing them to the CPI context 2. Invokes mint_action with CPI context to batch the mint creation 3. Uses `assigned_account_index` to order the mint relative to PDAs @@ -301,10 +301,10 @@ The macro requires certain infrastructure accounts, auto-detected by naming conv | Account Type | Accepted Names | |--------------|----------------| | Fee Payer | `fee_payer`, `payer`, `creator` | -| CToken Config | `ctoken_compressible_config`, `ctoken_config`, `light_token_config_account` | +| CToken Config | `light_token_compressible_config`, `ctoken_config`, `light_token_config_account` | | CToken Rent Sponsor | `ctoken_rent_sponsor`, `light_token_rent_sponsor` | | CToken Program | `ctoken_program`, `light_token_program` | -| CToken CPI Authority | `ctoken_cpi_authority`, `light_token_program_cpi_authority`, `compress_token_program_cpi_authority` | +| CToken CPI Authority | `light_token_cpi_authority`, `light_token_program_cpi_authority`, `compress_token_program_cpi_authority` | ## Validation diff --git a/sdk-libs/macros/docs/features/comparison.md b/sdk-libs/macros/docs/features/comparison.md index b6775f68e6..43c854b9e8 100644 --- a/sdk-libs/macros/docs/features/comparison.md +++ b/sdk-libs/macros/docs/features/comparison.md @@ -10,8 +10,8 @@ This document provides a comprehensive comparison between Anchor's account macro | Idempotent create | `init_if_needed` | `init_if_needed` | `init_if_needed` + compression check | | Pre-allocated | `zero` | - | `zero` (same) | | PDA creation | `seeds + bump + init` | `seeds + bump + init` | `seeds + bump + init` + address registration | -| Token account | - | `token::*` | `#[rentfree_token]` | -| Mint creation | - | `mint::*` | `#[light_mint]` | +| Token account | - | `token::*` | `#[light_account(token)]` | +| Mint creation | - | `mint::*` | `#[light_account(init)]` | | ATA creation | - | `associated_token::*` | Via `light_pre_init()` | ## Constraint Types Matrix @@ -29,10 +29,10 @@ This document provides a comprehensive comparison between Anchor's account macro | `seeds + bump` | Yes | Yes | Yes + address derivation | Extended | | `rent_exempt` | Yes | Yes | N/A | Rent-free by design | | `constraint` | Yes | Yes | Yes | Identical | -| `token::mint` | - | Yes | Via `#[rentfree_token]` | Different syntax | -| `token::authority` | - | Yes | Via `#[rentfree_token]` | Different syntax | -| `mint::decimals` | - | Yes | Via `#[light_mint]` | Different syntax | -| `mint::authority` | - | Yes | Via `#[light_mint]` | Different syntax | +| `token::mint` | - | Yes | Via `#[light_account(token)]` | Different syntax | +| `token::authority` | - | Yes | Via `#[light_account(token)]` | Different syntax | +| `mint::decimals` | - | Yes | Via `#[light_account(init)]` | Different syntax | +| `mint::authority` | - | Yes | Via `#[light_account(init)]` | Different syntax | | `compression_info` | - | - | Yes | RentFree only | | `compress_as` | - | - | Yes | RentFree only | @@ -93,10 +93,10 @@ try_accounts() ───> light_pre_init() ───> handler() ───> light |----------------|---------------------| | `Account<'info, T>` | `Account<'info, T>` (with RentFree derive) | | `#[account(init)]` | `#[account(init)]` + compression hooks | -| `#[account(init, token::mint = m)]` | `#[rentfree_token]` + `#[light_mint]` | +| `#[account(init, token::mint = m)]` | `#[light_account(token)]` + `#[light_account(init)]` | | `Program<'info, Token>` | `Program<'info, CompressedToken>` | -| `Account<'info, Mint>` | `UncheckedAccount<'info>` + `#[light_mint]` | -| `Account<'info, TokenAccount>` | `Account<'info, T>` with `#[rentfree_token]` | +| `Account<'info, Mint>` | `UncheckedAccount<'info>` + `#[light_account(init)]` | +| `Account<'info, TokenAccount>` | `Account<'info, T>` with `#[light_account(token)]` | | `close = destination` | `close = destination` + compression cleanup | | Manual token CPI | Auto-generated in `light_pre_init()` | @@ -105,7 +105,7 @@ try_accounts() ───> light_pre_init() ───> handler() ───> light | Anchor SPL Type | Light RentFree Type | |-----------------|---------------------| | `Mint` | `UncheckedAccount` (during init) | -| `TokenAccount` | Custom struct with `#[rentfree_token]` | +| `TokenAccount` | Custom struct with `#[light_account(token)]` | | `Token` program | `CompressedToken` program | | `TokenInterface` | Not yet supported | | `InterfaceAccount` | Not yet supported | @@ -129,7 +129,7 @@ pub mint: Account<'info, Mint>, // RentFree: CPI happens in light_pre_init() after try_accounts() /// CHECK: Created in light_pre_init #[account(mut)] -#[light_mint(decimals = 6, authority = user)] +#[light_account(init, mint,decimals = 6, authority = user)] pub mint: UncheckedAccount<'info>, ``` @@ -159,7 +159,7 @@ RentFree timeline: | Space calculation | Manual or `InitSpace` | Manual or `InitSpace` | | CompressionInfo field | - | Required for compressible | | compress_as attributes | - | Optional per field | -| Pack/Unpack traits | - | Generated by `#[derive(RentFree)]` | +| Pack/Unpack traits | - | Generated by `#[derive(LightAccounts)]` | ### Anchor Data Struct ```rust @@ -174,7 +174,7 @@ pub struct MyData { ### RentFree Data Struct ```rust #[derive(RentFree, Compressible, HasCompressionInfo)] -#[rentfree] +#[light_account(init)] pub struct MyData { #[compress_as(pubkey)] pub owner: Pubkey, @@ -209,7 +209,7 @@ pub struct MyData { 3. **Add compress_as**: Annotate fields for hashing 4. **Update program attribute**: Add `#[rentfree_program]` 5. **Add Light accounts**: Include protocol programs in accounts struct -6. **Update token handling**: Convert `mint::*` to `#[light_mint]` +6. **Update token handling**: Convert `mint::*` to `#[light_account(init)]` ### Minimal Changes Example @@ -221,10 +221,10 @@ pub struct Counter { } ``` -**After (RentFree)**: +**After (LightAccounts)**: ```rust #[derive(RentFree, Compressible, HasCompressionInfo)] -#[rentfree] +#[light_account(init)] pub struct Counter { pub count: u64, #[compression_info] diff --git a/sdk-libs/macros/docs/features/rentfree-features.md b/sdk-libs/macros/docs/features/light-features.md similarity index 93% rename from sdk-libs/macros/docs/features/rentfree-features.md rename to sdk-libs/macros/docs/features/light-features.md index 23adfbf921..1b42d0b4e8 100644 --- a/sdk-libs/macros/docs/features/rentfree-features.md +++ b/sdk-libs/macros/docs/features/light-features.md @@ -11,7 +11,7 @@ use light_sdk::compressible::CompressionInfo; use light_sdk_macros::{RentFree, Compressible, HasCompressionInfo}; #[derive(RentFree, Compressible, HasCompressionInfo)] -#[rentfree] +#[light_account(init)] pub struct MyAccount { pub data: u64, #[compression_info] @@ -23,7 +23,7 @@ pub struct MyAccount { ## Account-Level Macros -### 1. `#[derive(RentFree)]` +### 1. `#[derive(LightAccounts)]` **Purpose**: Generates the core traits needed for a compressible account. @@ -34,7 +34,7 @@ pub struct MyAccount { **Example**: ```rust -#[derive(RentFree)] +#[derive(LightAccounts)] pub struct UserProfile { pub name: [u8; 32], pub score: u64, @@ -43,7 +43,7 @@ pub struct UserProfile { --- -### 2. `#[rentfree]` +### 2. `#[light_account(init)]` **Purpose**: Attribute for account structs that marks fields and configures compression behavior. @@ -53,8 +53,8 @@ pub struct UserProfile { **Example**: ```rust -#[derive(RentFree)] -#[rentfree] +#[derive(LightAccounts)] +#[light_account(init)] pub struct GameState { #[compress_as(pubkey)] pub player: Pubkey, @@ -66,7 +66,7 @@ pub struct GameState { --- -### 3. `#[rentfree_token]` +### 3. `#[light_account(token)]` **Purpose**: Marks an account as a token account that can be compressed/decompressed. @@ -77,20 +77,21 @@ pub struct GameState { **Example**: ```rust -#[derive(RentFree)] -#[rentfree_token] -pub struct MyTokenAccount { - pub mint: Pubkey, - pub owner: Pubkey, - pub amount: u64, - #[compression_info] - pub compression_info: CompressionInfo, +#[derive(Accounts, LightAccounts)] +pub struct CreateVault<'info> { + #[account( + mut, + seeds = [b"vault", mint.key().as_ref()], + bump + )] + #[light_account(token, authority = [b"vault_authority"])] + pub vault: UncheckedAccount<'info>, } ``` --- -### 4. `#[light_mint]` +### 4. `#[light_account(init)]` **Purpose**: Creates a compressed mint alongside an on-chain mint PDA. @@ -99,7 +100,7 @@ pub struct MyTokenAccount { - Creates compressed mint via CPI to compressed token program - Links on-chain mint to compressed representation -**Key insight**: Unlike Anchor's `mint::*` which runs during `try_accounts()`, `#[light_mint]` runs in `light_pre_init()` AFTER account deserialization. +**Key insight**: Unlike Anchor's `mint::*` which runs during `try_accounts()`, `#[light_account(init)]` runs in `light_pre_init()` AFTER account deserialization. **Example**: ```rust @@ -110,7 +111,7 @@ pub struct CreateMint<'info> { /// CHECK: Initialized in light_pre_init #[account(mut)] - #[light_mint( + #[light_account(init, mint, decimals = 6, authority = payer, freeze_authority = payer @@ -171,7 +172,7 @@ impl<'info> LightPreInit<'info> for CreateProfile<'info> { fn light_pre_init(&mut self, /* params */) -> Result<()> { // 1. Derive compressed account address // 2. Register with Light system program - // 3. Create compressed mint if #[light_mint] + // 3. Create compressed mint if #[light_account(init)] Ok(()) } } @@ -434,7 +435,7 @@ try_accounts() { } light_pre_init() { 4. Register compressed address - 5. Create compressed mint CPI (if #[light_mint]) + 5. Create compressed mint CPI (if #[light_account(init)]) } // instruction handler light_finalize() { @@ -452,7 +453,7 @@ use light_sdk::compressible::CompressionInfo; use light_sdk_macros::*; #[derive(RentFree, Compressible, HasCompressionInfo)] -#[rentfree] +#[light_account(init)] pub struct UserProfile { #[compress_as(pubkey)] pub owner: Pubkey, diff --git a/sdk-libs/macros/docs/rentfree_program/architecture.md b/sdk-libs/macros/docs/light_program/architecture.md similarity index 94% rename from sdk-libs/macros/docs/rentfree_program/architecture.md rename to sdk-libs/macros/docs/light_program/architecture.md index b26aec3d04..7336f218ab 100644 --- a/sdk-libs/macros/docs/rentfree_program/architecture.md +++ b/sdk-libs/macros/docs/light_program/architecture.md @@ -11,9 +11,9 @@ The `#[rentfree_program]` attribute macro provides program-level auto-discovery | Location | Macro | Purpose | |----------|-------|---------| | Program module | `#[rentfree_program]` | Discovers fields, generates instructions, wraps handlers | -| Accounts struct | `#[derive(RentFree)]` | Generates `LightPreInit`/`LightFinalize` trait impls | -| Account field | `#[rentfree]` | Marks PDA for compression | -| Account field | `#[rentfree_token(authority=[...])]` | Marks token account for compression | +| Accounts struct | `#[derive(LightAccounts)]` | Generates `LightPreInit`/`LightFinalize` trait impls | +| Account field | `#[light_account(init)]` | Marks PDA for compression | +| Account field | `#[light_account(token, authority=[...])]` | Marks token account for compression | | State struct | `#[derive(LightCompressible)]` | Generates compression traits + `Packed{Type}` | | State struct | `compression_info: Option` | Required field for compression metadata | @@ -56,8 +56,8 @@ pub mod my_program { | | | For each #[derive(Accounts)] struct: | | | -| 1. Find #[rentfree] fields --> PDA accounts | -| 2. Find #[rentfree_token] fields --> Token accounts | +| 1. Find #[light_account(init)] fields --> PDA accounts | +| 2. Find #[light_account(token)] fields --> Token accounts | | 3. Parse #[account(seeds=[...])] --> Seed expressions | | 4. Parse #[instruction(...)] --> Params type | | | @@ -224,4 +224,4 @@ Seeds in `#[account(seeds = [...])]` can reference: | Max size | 800 bytes per compressed account (compile-time check) | | Module discovery | Requires `pub mod name;` pattern (not inline `mod name {}`) | | Instruction variants | Only `Mixed` (PDA + token) fully implemented | -| Token authority | `#[rentfree_token]` requires `authority = [...]` seeds | +| Token authority | `#[light_account(token)]` requires `authority = [...]` seeds | diff --git a/sdk-libs/macros/docs/rentfree_program/codegen.md b/sdk-libs/macros/docs/light_program/codegen.md similarity index 96% rename from sdk-libs/macros/docs/rentfree_program/codegen.md rename to sdk-libs/macros/docs/light_program/codegen.md index b7e782e9f6..60df1b387c 100644 --- a/sdk-libs/macros/docs/rentfree_program/codegen.md +++ b/sdk-libs/macros/docs/light_program/codegen.md @@ -111,7 +111,7 @@ sdk-libs/macros/src/rentfree/ ### Automatic Function Wrapping -Functions using `#[rentfree]` Accounts structs are automatically wrapped with lifecycle hooks: +Functions using `#[light_account(init)]` Accounts structs are automatically wrapped with lifecycle hooks: ```rust // Original: @@ -158,8 +158,8 @@ const _: () = { ### Instruction Variants The macro supports three instruction variants based on field types: -- `PdaOnly`: Only `#[rentfree]` PDA fields -- `TokenOnly`: Only `#[rentfree_token]` token fields +- `PdaOnly`: Only `#[light_account(init)]` PDA fields +- `TokenOnly`: Only `#[light_account(token)]` token fields - `Mixed`: Both PDA and token fields (most common) Currently, only `Mixed` variant is fully implemented. `PdaOnly` and `TokenOnly` will error at runtime. diff --git a/sdk-libs/macros/src/lib.rs b/sdk-libs/macros/src/lib.rs index 0d42596617..df301d3a6f 100644 --- a/sdk-libs/macros/src/lib.rs +++ b/sdk-libs/macros/src/lib.rs @@ -8,8 +8,8 @@ use utils::into_token_stream; mod account; mod discriminator; mod hasher; +mod light_pdas; mod rent_sponsor; -mod rentfree; mod utils; #[proc_macro_derive(LightDiscriminator)] @@ -124,7 +124,7 @@ pub fn light_hasher_sha(input: TokenStream) -> TokenStream { #[proc_macro_derive(HasCompressionInfo)] pub fn has_compression_info(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as ItemStruct); - into_token_stream(rentfree::account::traits::derive_has_compression_info( + into_token_stream(light_pdas::account::traits::derive_has_compression_info( input, )) } @@ -166,28 +166,28 @@ pub fn has_compression_info(input: TokenStream) -> TokenStream { #[proc_macro_derive(CompressAs, attributes(compress_as))] pub fn compress_as_derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as ItemStruct); - into_token_stream(rentfree::account::traits::derive_compress_as(input)) + into_token_stream(light_pdas::account::traits::derive_compress_as(input)) } -/// Auto-discovering rent-free program macro that reads external module files. +/// Auto-discovering Light program macro that reads external module files. /// -/// This macro automatically discovers #[rentfree] fields in Accounts structs +/// This macro automatically discovers #[light_account(init)] fields in Accounts structs /// by reading external module files. No explicit type list needed! /// -/// It also **automatically wraps** instruction handlers that use rentfree Accounts +/// It also **automatically wraps** instruction handlers that use Light Accounts /// structs with `light_pre_init`/`light_finalize` logic - no separate attribute needed! /// /// Usage: /// ```ignore -/// #[rentfree_program] +/// #[light_program] /// #[program] /// pub mod my_program { /// pub mod instruction_accounts; // Macro reads this file! /// pub mod state; -/// +/// /// use instruction_accounts::*; /// use state::*; -/// +/// /// pub fn create_user(ctx: Context, params: Params) -> Result<()> { /// // Your business logic /// } @@ -196,18 +196,15 @@ pub fn compress_as_derive(input: TokenStream) -> TokenStream { /// /// The macro: /// 1. Scans the crate's `src/` directory for `#[derive(Accounts)]` structs -/// 2. Extracts seeds from `#[account(seeds = [...])]` on `#[rentfree]` fields +/// 2. Extracts seeds from `#[account(seeds = [...])]` on `#[light_account(init)]` fields /// 3. Auto-wraps instruction handlers that use those Accounts structs /// 4. Generates all necessary types, enums, and instruction handlers /// /// Seeds are declared ONCE in Anchor attributes - no duplication! #[proc_macro_attribute] -pub fn rentfree_program(args: TokenStream, input: TokenStream) -> TokenStream { +pub fn light_program(args: TokenStream, input: TokenStream) -> TokenStream { let module = syn::parse_macro_input!(input as syn::ItemMod); - into_token_stream(rentfree::program::rentfree_program_impl( - args.into(), - module, - )) + into_token_stream(light_pdas::program::light_program_impl(args.into(), module)) } #[proc_macro_attribute] @@ -249,7 +246,7 @@ pub fn account(_: TokenStream, input: TokenStream) -> TokenStream { /// pub struct GameSession { /// pub compression_info: Option, /// pub session_id: u64, // KEPT -/// pub player: Pubkey, // KEPT +/// pub player: Pubkey, // KEPT /// pub game_type: String, // KEPT /// pub start_time: u64, // RESET to 0 /// pub end_time: Option, // RESET to None @@ -259,7 +256,7 @@ pub fn account(_: TokenStream, input: TokenStream) -> TokenStream { #[proc_macro_derive(Compressible, attributes(compress_as, light_seeds))] pub fn compressible_derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - into_token_stream(rentfree::account::traits::derive_compressible(input)) + into_token_stream(light_pdas::account::traits::derive_compressible(input)) } /// Automatically implements Pack and Unpack traits for compressible accounts. @@ -286,12 +283,12 @@ pub fn compressible_derive(input: TokenStream) -> TokenStream { #[proc_macro_derive(CompressiblePack)] pub fn compressible_pack(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - into_token_stream(rentfree::account::pack_unpack::derive_compressible_pack( + into_token_stream(light_pdas::account::pack_unpack::derive_compressible_pack( input, )) } -/// Consolidates all required traits for rent-free state accounts into a single derive. +/// Consolidates all required traits for Light Protocol state accounts into a single derive. /// /// This macro is equivalent to deriving: /// - `LightHasherSha` (SHA256/ShaFlat hashing - type 3) @@ -302,11 +299,11 @@ pub fn compressible_pack(input: TokenStream) -> TokenStream { /// ## Example /// /// ```ignore -/// use light_sdk_macros::RentFreeAccount; +/// use light_sdk_macros::LightAccount; /// use light_sdk::compressible::CompressionInfo; /// use solana_pubkey::Pubkey; /// -/// #[derive(Default, Debug, InitSpace, RentFreeAccount)] +/// #[derive(Default, Debug, InitSpace, LightAccount)] /// #[account] /// pub struct UserRecord { /// pub owner: Pubkey, @@ -333,10 +330,10 @@ pub fn compressible_pack(input: TokenStream) -> TokenStream { /// - The `compression_info` field is auto-detected and handled (no `#[skip]` needed) /// - SHA256 (ShaFlat) hashes the entire serialized struct (no `#[hash]` needed) /// - The struct must have a `compression_info: Option` field -#[proc_macro_derive(RentFreeAccount, attributes(compress_as))] -pub fn rent_free_account(input: TokenStream) -> TokenStream { +#[proc_macro_derive(LightAccount, attributes(compress_as))] +pub fn light_account_derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - into_token_stream(rentfree::account::light_compressible::derive_rentfree_account(input)) + into_token_stream(light_pdas::account::light_compressible::derive_light_account(input)) } /// Derives a Rent Sponsor PDA for a program at compile time. @@ -373,33 +370,33 @@ pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { rent_sponsor::derive_light_rent_sponsor(input) } -/// Generates `RentFree` trait implementation for rent-free accounts and light-mints. +/// Generates `LightFinalize` trait implementation for Light Protocol accounts. /// /// This derive macro works alongside Anchor's `#[derive(Accounts)]` to add /// compression finalize logic for: -/// - Accounts marked with `#[rentfree]` (rent-free PDAs) -/// - Accounts marked with `#[rentfree_token(...)]` (rent-free token accounts) -/// - Accounts marked with `#[light_mint(...)]` (light-mint creation) +/// - Accounts marked with `#[light_account(init)]` (PDAs) +/// - Accounts marked with `#[light_account(init, mint, ...)]` (compressed mints) +/// - Accounts marked with `#[light_account(token, ...)]` (rent-free token accounts) /// /// The trait is defined in `light_sdk::compressible::LightFinalize`. /// -/// ## Usage - Rent-free PDAs +/// ## Usage - PDAs /// /// ```ignore -/// #[derive(Accounts, RentFree)] +/// #[derive(Accounts, LightAccounts)] /// #[instruction(params: CompressionParams)] -/// pub struct CreateRentFree<'info> { +/// pub struct CreatePda<'info> { /// #[account(mut)] /// pub fee_payer: Signer<'info>, -/// +/// /// #[account( /// init, payer = fee_payer, space = 8 + MyData::INIT_SPACE, /// seeds = [b"my_data", authority.key().as_ref()], /// bump /// )] -/// #[rentfree] +/// #[light_account(init)] /// pub my_account: Account<'info, MyData>, -/// +/// /// /// CHECK: Compression config /// pub compression_config: AccountInfo<'info>, /// } @@ -408,15 +405,14 @@ pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { /// ## Usage - Rent-free Token Accounts /// /// ```ignore -/// #[derive(Accounts, RentFree)] +/// #[derive(Accounts, LightAccounts)] /// pub struct CreateVault<'info> { /// #[account( /// mut, /// seeds = [b"vault", cmint.key().as_ref()], /// bump /// )] -/// // Variant name derived from field name: vault -> Vault -/// #[rentfree_token(authority = [b"vault_authority"])] +/// #[light_account(token, authority = [b"vault_authority"])] /// pub vault: UncheckedAccount<'info>, /// } /// ``` @@ -424,21 +420,21 @@ pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { /// ## Usage - Light Mints /// /// ```ignore -/// #[derive(Accounts, RentFree)] +/// #[derive(Accounts, LightAccounts)] /// #[instruction(params: MintParams)] /// pub struct CreateMint<'info> { /// #[account(mut)] /// pub fee_payer: Signer<'info>, -/// +/// /// #[account(mut)] -/// #[light_mint( +/// #[light_account(init, mint, /// mint_signer = mint_signer, /// authority = authority, /// decimals = 9, -/// signer_seeds = &[...] +/// mint_seeds = &[...] /// )] /// pub mint: UncheckedAccount<'info>, -/// +/// /// pub mint_signer: Signer<'info>, /// pub authority: Signer<'info>, /// } @@ -451,11 +447,8 @@ pub fn derive_light_rent_sponsor(input: TokenStream) -> TokenStream { /// - `ID`: Program ID (from declare_id!) /// /// The struct should have fields named `fee_payer` (or `payer`) and `compression_config`. -#[proc_macro_derive( - RentFree, - attributes(rentfree, rentfree_token, light_mint, instruction) -)] -pub fn rent_free_derive(input: TokenStream) -> TokenStream { +#[proc_macro_derive(LightAccounts, attributes(light_account, instruction))] +pub fn light_accounts_derive(input: TokenStream) -> TokenStream { let input = parse_macro_input!(input as DeriveInput); - into_token_stream(rentfree::accounts::derive_rentfree(input)) + into_token_stream(light_pdas::accounts::derive_light_accounts(input)) } diff --git a/sdk-libs/macros/src/rentfree/README.md b/sdk-libs/macros/src/light_pdas/README.md similarity index 82% rename from sdk-libs/macros/src/rentfree/README.md rename to sdk-libs/macros/src/light_pdas/README.md index 6c78ca533b..6132c11acd 100644 --- a/sdk-libs/macros/src/rentfree/README.md +++ b/sdk-libs/macros/src/light_pdas/README.md @@ -8,9 +8,9 @@ Procedural macros for generating rent-free account types and their hooks for Sol rentfree/ ├── mod.rs # Module declaration ├── README.md # This file -├── accounts/ # #[derive(RentFree)] implementation +├── 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 ├── program/ # #[rentfree_program] implementation │ ├── mod.rs # Entry point: rentfree_program_impl() @@ -22,7 +22,7 @@ rentfree/ ├── mod.rs # Module declaration ├── traits.rs # HasCompressionInfo, CompressAs, Compressible ├── pack_unpack.rs # Pack/Unpack trait implementations - ├── light_compressible.rs # RentFreeAccount combined derive + ├── light_compressible.rs # LightAccount combined derive ├── anchor_seeds.rs # Seed extraction from Anchor attributes ├── decompress_context.rs # DecompressContext trait generation └── utils.rs # Shared utility functions @@ -32,9 +32,9 @@ rentfree/ ### `accounts/` - RentFree Derive Macro -Implements `#[derive(RentFree)]` for Anchor Accounts structs: +Implements `#[derive(LightAccounts)]` for Anchor Accounts structs: -- **parse.rs** - Parses `#[rentfree]`, `#[rentfree_token]`, `#[light_mint]` attributes +- **parse.rs** - Parses `#[light_account(init)]`, `#[light_account(token)]`, `#[light_account(init)]` attributes - **codegen.rs** - Generates `LightPreInit` and `LightFinalize` trait implementations ### `program/` - RentFree Program Macro @@ -52,7 +52,7 @@ Core trait implementations shared across macros: - **traits.rs** - `HasCompressionInfo`, `CompressAs`, `Compressible` derives - **pack_unpack.rs** - Generates `PackedXxx` structs, `Pack`/`Unpack` traits -- **light_compressible.rs** - `RentFreeAccount` combined derive macro +- **light_compressible.rs** - `LightAccount` combined derive macro - **anchor_seeds.rs** - Extracts seeds from `#[account(seeds = [...])]` - **decompress_context.rs** - `DecompressContext` trait generation - **utils.rs** - Shared utilities (e.g., empty CToken enum generation) diff --git a/sdk-libs/macros/src/rentfree/account/decompress_context.rs b/sdk-libs/macros/src/light_pdas/account/decompress_context.rs similarity index 95% rename from sdk-libs/macros/src/rentfree/account/decompress_context.rs rename to sdk-libs/macros/src/light_pdas/account/decompress_context.rs index 0a9da002ea..adf8aab56f 100644 --- a/sdk-libs/macros/src/rentfree/account/decompress_context.rs +++ b/sdk-libs/macros/src/light_pdas/account/decompress_context.rs @@ -5,8 +5,8 @@ use quote::{format_ident, quote}; use syn::{Ident, Result}; // Re-export from variant_enum for convenience -pub use crate::rentfree::program::variant_enum::PdaCtxSeedInfo; -use crate::rentfree::shared_utils::{ +pub use crate::light_pdas::program::variant_enum::PdaCtxSeedInfo; +use crate::light_pdas::shared_utils::{ make_packed_type, make_packed_variant_name, qualify_type_with_crate, }; @@ -75,7 +75,7 @@ pub fn generate_decompress_context_trait_impl( quote! { variant_seed_params = SeedParams { #(#field_inits,)* ..Default::default() }; } }; quote! { - RentFreeAccountVariant::#packed_variant_name { data: packed, #(#idx_field_patterns,)* #(#params_field_patterns,)* .. } => { + LightAccountVariant::#packed_variant_name { data: packed, #(#idx_field_patterns,)* #(#params_field_patterns,)* .. } => { #(#resolve_ctx_seeds)* #ctx_seeds_construction #seed_params_update @@ -94,7 +94,7 @@ pub fn generate_decompress_context_trait_impl( std::option::Option::Some(&variant_seed_params), )?; } - RentFreeAccountVariant::#variant_name { .. } => { + LightAccountVariant::#variant_name { .. } => { return std::result::Result::Err(light_sdk::error::LightSdkError::UnexpectedUnpackedVariant.into()); } } @@ -105,7 +105,7 @@ pub fn generate_decompress_context_trait_impl( Ok(quote! { impl<#lifetime> light_sdk::compressible::DecompressContext<#lifetime> for DecompressAccountsIdempotent<#lifetime> { - type CompressedData = RentFreeAccountData; + type CompressedData = LightAccountData; type PackedTokenData = light_token_sdk::compat::PackedCTokenData<#packed_token_variant_ident>; type CompressedMeta = light_sdk::instruction::account_meta::CompressedAccountMetaNoLamportsNoAddress; type SeedParams = SeedParams; @@ -131,7 +131,7 @@ pub fn generate_decompress_context_trait_impl( } fn token_cpi_authority(&self) -> std::option::Option<&solana_account_info::AccountInfo<#lifetime>> { - self.ctoken_cpi_authority.as_ref().map(|a| &**a) + self.light_token_cpi_authority.as_ref().map(|a| &**a) } fn token_config(&self) -> std::option::Option<&solana_account_info::AccountInfo<#lifetime>> { @@ -168,13 +168,13 @@ pub fn generate_decompress_context_trait_impl( let mut variant_seed_params = SeedParams::default(); match compressed_data.data { #(#pda_match_arms)* - RentFreeAccountVariant::PackedCTokenData(mut data) => { + LightAccountVariant::PackedCTokenData(mut data) => { solana_msg::msg!("collect_pda_and_token: token variant {}", i); data.token_data.version = 3; compressed_token_accounts.push((data, meta)); solana_msg::msg!("collect_pda_and_token: token {} done", i); } - RentFreeAccountVariant::CTokenData(_) => { + LightAccountVariant::CTokenData(_) => { return std::result::Result::Err(light_sdk::error::LightSdkError::UnexpectedUnpackedVariant.into()); } } diff --git a/sdk-libs/macros/src/rentfree/account/light_compressible.rs b/sdk-libs/macros/src/light_pdas/account/light_compressible.rs similarity index 94% rename from sdk-libs/macros/src/rentfree/account/light_compressible.rs rename to sdk-libs/macros/src/light_pdas/account/light_compressible.rs index ae2044b5a9..b516a37a28 100644 --- a/sdk-libs/macros/src/rentfree/account/light_compressible.rs +++ b/sdk-libs/macros/src/light_pdas/account/light_compressible.rs @@ -13,7 +13,7 @@ use syn::{DeriveInput, Fields, ItemStruct, Result}; use crate::{ discriminator::discriminator, hasher::derive_light_hasher_sha, - rentfree::account::{pack_unpack::derive_compressible_pack, traits::derive_compressible}, + light_pdas::account::{pack_unpack::derive_compressible_pack, traits::derive_compressible}, }; /// Derives all required traits for a compressible account. @@ -53,7 +53,7 @@ use crate::{ /// /// - The `compression_info` field is auto-detected and handled specially (no `#[skip]` needed) /// - SHA256 hashing serializes the entire struct, so `#[hash]` is not needed -pub fn derive_rentfree_account(input: DeriveInput) -> Result { +pub fn derive_light_account(input: DeriveInput) -> Result { // Convert DeriveInput to ItemStruct for macros that need it let item_struct = derive_input_to_item_struct(&input)?; @@ -128,7 +128,7 @@ mod tests { } }; - let result = derive_rentfree_account(input); + let result = derive_light_account(input); assert!(result.is_ok(), "LightCompressible should succeed"); let output = result.unwrap().to_string(); @@ -181,7 +181,7 @@ mod tests { } }; - let result = derive_rentfree_account(input); + let result = derive_light_account(input); assert!( result.is_ok(), "LightCompressible with compress_as should succeed" @@ -203,7 +203,7 @@ mod tests { } }; - let result = derive_rentfree_account(input); + let result = derive_light_account(input); assert!( result.is_ok(), "LightCompressible without Pubkey fields should succeed" @@ -235,7 +235,7 @@ mod tests { } }; - let result = derive_rentfree_account(input); + let result = derive_light_account(input); assert!(result.is_err(), "LightCompressible should fail for enums"); } @@ -248,7 +248,7 @@ mod tests { } }; - let result = derive_rentfree_account(input); + let result = derive_light_account(input); // Compressible derive validates compression_info field assert!( result.is_err(), diff --git a/sdk-libs/macros/src/rentfree/account/mod.rs b/sdk-libs/macros/src/light_pdas/account/mod.rs similarity index 89% rename from sdk-libs/macros/src/rentfree/account/mod.rs rename to sdk-libs/macros/src/light_pdas/account/mod.rs index 1909b7fa04..76b727a6fc 100644 --- a/sdk-libs/macros/src/rentfree/account/mod.rs +++ b/sdk-libs/macros/src/light_pdas/account/mod.rs @@ -3,7 +3,7 @@ //! This module provides: //! - `seed_extraction` - Seed extraction from Anchor account attributes //! - `decompress_context` - Decompression context utilities -//! - `light_compressible` - Combined RentFreeAccount derive macro +//! - `light_compressible` - Combined LightAccount derive macro //! - `pack_unpack` - Pack/Unpack trait implementations //! - `traits` - HasCompressionInfo, Compressible, CompressAs traits //! - `utils` - Shared utility functions diff --git a/sdk-libs/macros/src/rentfree/account/pack_unpack.rs b/sdk-libs/macros/src/light_pdas/account/pack_unpack.rs similarity index 100% rename from sdk-libs/macros/src/rentfree/account/pack_unpack.rs rename to sdk-libs/macros/src/light_pdas/account/pack_unpack.rs diff --git a/sdk-libs/macros/src/rentfree/account/seed_extraction.rs b/sdk-libs/macros/src/light_pdas/account/seed_extraction.rs similarity index 82% rename from sdk-libs/macros/src/rentfree/account/seed_extraction.rs rename to sdk-libs/macros/src/light_pdas/account/seed_extraction.rs index 1d65b1fad8..51122d26ee 100644 --- a/sdk-libs/macros/src/rentfree/account/seed_extraction.rs +++ b/sdk-libs/macros/src/light_pdas/account/seed_extraction.rs @@ -6,7 +6,7 @@ use syn::{Expr, Ident, ItemStruct, Type}; use crate::{ - rentfree::shared_utils::{extract_terminal_ident, is_constant_identifier}, + light_pdas::shared_utils::{extract_terminal_ident, is_constant_identifier}, utils::snake_to_camel_case, }; @@ -48,12 +48,12 @@ pub struct ExtractedSeedSpec { pub seeds: Vec, } -/// Extracted token specification for a #[rentfree_token = Variant] field +/// Extracted token specification for a #[light_account(token, ...)] field #[derive(Clone, Debug)] pub struct ExtractedTokenSpec { /// The field name in the Accounts struct pub field_name: Ident, - /// The variant name from #[rentfree_token = Variant] + /// The variant name derived from field name pub variant_name: Ident, /// Seeds from #[account(seeds = [...])] pub seeds: Vec, @@ -69,7 +69,7 @@ pub struct ExtractedAccountsInfo { pub struct_name: Ident, pub pda_fields: Vec, pub token_fields: Vec, - /// True if struct has any #[light_mint] fields + /// True if struct has any #[light_account(init)] fields pub has_light_mint_fields: bool, } @@ -92,26 +92,18 @@ pub fn extract_from_accounts_struct( None => continue, }; - // Check for #[rentfree] attribute - let has_rentfree = field - .attrs - .iter() - .any(|attr| attr.path().is_ident("rentfree")); + // Check for #[light_account(...)] attribute and determine its type + let (has_light_account_pda, has_light_account_mint) = + check_light_account_type(&field.attrs); - // Check for #[light_mint(...)] attribute - let has_light_mint = field - .attrs - .iter() - .any(|attr| attr.path().is_ident("light_mint")); - - if has_light_mint { + if has_light_account_mint { has_light_mint_fields = true; } - // Check for #[rentfree_token(...)] attribute - let token_attr = extract_rentfree_token_attr(&field.attrs); + // Check for #[light_account(token, ...)] attribute + let token_attr = extract_light_token_attr(&field.attrs); - if has_rentfree { + if has_light_account_pda { // Extract inner type from Account<'info, T> or Box> // Note: is_boxed is not needed for ExtractedSeedSpec, only inner_type let (_, inner_type) = match extract_account_inner_type(&field.ty) { @@ -119,7 +111,7 @@ pub fn extract_from_accounts_struct( None => { return Err(syn::Error::new_spanned( &field.ty, - "#[rentfree] requires Account<'info, T> or Box>", + "#[light_account(init)] requires Account<'info, T> or Box>", )); } }; @@ -207,108 +199,116 @@ pub fn extract_from_accounts_struct( })) } -/// Parsed #[rentfree_token(...)] attribute -struct RentFreeTokenAttr { +/// Check #[light_account(...)] attributes for PDA or mint type. +/// Returns (has_pda, has_mint) indicating which type was detected. +fn check_light_account_type(attrs: &[syn::Attribute]) -> (bool, bool) { + for attr in attrs { + if attr.path().is_ident("light_account") { + // Parse the content to determine if it's init-only (PDA) or init+mint (Mint) + let tokens = match &attr.meta { + syn::Meta::List(list) => list.tokens.clone(), + _ => continue, + }; + + // Single pass to check for both "init" and "mint" keywords + let mut has_mint = false; + let mut has_init = false; + for token in tokens { + if let proc_macro2::TokenTree::Ident(ident) = token { + if ident == "mint" { + has_mint = true; + } else if ident == "init" { + has_init = true; + } + } + } + + if has_init { + // If has mint, it's a mint field; otherwise it's a PDA + return (!has_mint, has_mint); + } + } + } + (false, false) +} + +/// Parsed #[light_account(token, ...)] attribute +struct LightTokenAttr { /// Optional variant name - if None, derived from field name variant_name: Option, authority_seeds: Option>, } -/// Extract #[rentfree_token(authority = [...])] attribute -/// Variant name is now derived from field name, not specified in attribute -fn extract_rentfree_token_attr(attrs: &[syn::Attribute]) -> Option { +/// Extract #[light_account(token, authority = [...])] attribute +/// Variant name is derived from field name, not specified in attribute +fn extract_light_token_attr(attrs: &[syn::Attribute]) -> Option { for attr in attrs { - if attr.path().is_ident("rentfree_token") { - match &attr.meta { - // #[rentfree_token = Variant] (deprecated but still supported) - syn::Meta::NameValue(nv) => { - if let Expr::Path(path) = &nv.value { - if let Some(ident) = path.path.get_ident() { - return Some(RentFreeTokenAttr { - variant_name: Some(ident.clone()), - authority_seeds: None, - }); - } - } - } - // #[rentfree_token(authority = [...])] or #[rentfree_token(Variant, authority = [...])] - syn::Meta::List(list) => { - if let Ok(parsed) = parse_rentfree_token_list(&list.tokens) { - return Some(parsed); - } - // Fallback: try parsing as just an identifier (deprecated) - if let Ok(ident) = syn::parse2::(list.tokens.clone()) { - return Some(RentFreeTokenAttr { - variant_name: Some(ident), - authority_seeds: None, - }); - } - } - // #[rentfree_token] with no arguments - syn::Meta::Path(_) => { - return Some(RentFreeTokenAttr { - variant_name: None, - authority_seeds: None, - }); + if attr.path().is_ident("light_account") { + let tokens = match &attr.meta { + syn::Meta::List(list) => list.tokens.clone(), + _ => continue, + }; + + // Check if "token" keyword is present (without requiring "init") + let has_token = tokens + .clone() + .into_iter() + .any(|t| matches!(&t, proc_macro2::TokenTree::Ident(ident) if ident == "token")); + + if has_token { + // Parse authority = [...] if present + if let Ok(parsed) = parse_light_token_list(&tokens) { + return Some(parsed); } + return Some(LightTokenAttr { + variant_name: None, + authority_seeds: None, + }); } } } None } -/// Parse rentfree_token(authority = [...]) or rentfree_token(Variant, authority = [...]) content -fn parse_rentfree_token_list(tokens: &proc_macro2::TokenStream) -> syn::Result { +/// Parse light_account(token, authority = [...]) content +fn parse_light_token_list(tokens: &proc_macro2::TokenStream) -> syn::Result { use syn::parse::Parser; - let parser = |input: syn::parse::ParseStream| -> syn::Result { - let mut variant_name = None; + let parser = |input: syn::parse::ParseStream| -> syn::Result { let mut authority_seeds = None; - // Check if first token is authority = [...] or a variant name - if input.peek(Ident) { - let ident: Ident = input.parse()?; - - if ident == "authority" { - // First token is authority, parse the seeds - input.parse::()?; - let array: syn::ExprArray = input.parse()?; - let mut seeds = Vec::new(); - for elem in &array.elems { - if let Ok(seed) = classify_seed_expr(elem) { - seeds.push(seed); - } - } - authority_seeds = Some(seeds); - } else { - // First token is variant name (deprecated but supported) - variant_name = Some(ident); - - // Check for comma and additional args - while input.peek(syn::Token![,]) { - input.parse::()?; - - // Look for authority = [...] - if input.peek(Ident) { - let key: Ident = input.parse()?; - if key == "authority" { - input.parse::()?; - let array: syn::ExprArray = input.parse()?; - let mut seeds = Vec::new(); - for elem in &array.elems { - if let Ok(seed) = classify_seed_expr(elem) { - seeds.push(seed); - } - } - authority_seeds = Some(seeds); + // Parse comma-separated items looking for "token" and "authority = [...]" + while !input.is_empty() { + if input.peek(Ident) { + let ident: Ident = input.parse()?; + + if ident == "token" { + // Skip the token keyword, continue parsing + } else if ident == "authority" { + // Parse authority = [...] + input.parse::()?; + let array: syn::ExprArray = input.parse()?; + let mut seeds = Vec::new(); + for elem in &array.elems { + if let Ok(seed) = classify_seed_expr(elem) { + seeds.push(seed); } } + authority_seeds = Some(seeds); } } + + // Skip comma if present + if input.peek(syn::Token![,]) { + input.parse::()?; + } else if !input.is_empty() { + // Skip unexpected tokens + let _: proc_macro2::TokenTree = input.parse()?; + } } - Ok(RentFreeTokenAttr { - variant_name, + Ok(LightTokenAttr { + variant_name: None, // Variant name is always derived from field name authority_seeds, }) }; @@ -681,10 +681,10 @@ pub fn get_data_fields(seeds: &[ClassifiedSeed]) -> Vec<(Ident, Option)> /// Get params-only seed fields from a TokenSeedSpec. /// This is a convenience wrapper that works with the SeedElement type. pub fn get_params_only_seed_fields_from_spec( - spec: &crate::rentfree::program::instructions::TokenSeedSpec, + spec: &crate::light_pdas::program::instructions::TokenSeedSpec, state_field_names: &std::collections::HashSet, ) -> Vec<(Ident, syn::Type, bool)> { - use crate::rentfree::program::instructions::SeedElement; + use crate::light_pdas::program::instructions::SeedElement; let mut fields = Vec::new(); for seed in &spec.seeds { @@ -713,7 +713,7 @@ pub fn get_params_only_seed_fields_from_spec( /// Extract data field name and conversion info from an expression. /// Returns (field_name, has_conversion) if the expression is a data.* field. fn extract_data_field_from_expr(expr: &syn::Expr) -> Option<(Ident, bool)> { - use crate::rentfree::shared_utils::is_base_path; + use crate::light_pdas::shared_utils::is_base_path; match expr { syn::Expr::Field(field_expr) => { diff --git a/sdk-libs/macros/src/rentfree/account/traits.rs b/sdk-libs/macros/src/light_pdas/account/traits.rs similarity index 100% rename from sdk-libs/macros/src/rentfree/account/traits.rs rename to sdk-libs/macros/src/light_pdas/account/traits.rs diff --git a/sdk-libs/macros/src/rentfree/account/utils.rs b/sdk-libs/macros/src/light_pdas/account/utils.rs similarity index 100% rename from sdk-libs/macros/src/rentfree/account/utils.rs rename to sdk-libs/macros/src/light_pdas/account/utils.rs diff --git a/sdk-libs/macros/src/rentfree/accounts/builder.rs b/sdk-libs/macros/src/light_pdas/accounts/builder.rs similarity index 82% rename from sdk-libs/macros/src/rentfree/accounts/builder.rs rename to sdk-libs/macros/src/light_pdas/accounts/builder.rs index 8ddb9b0f8b..e512450f8d 100644 --- a/sdk-libs/macros/src/rentfree/accounts/builder.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/builder.rs @@ -8,8 +8,8 @@ use quote::quote; use syn::DeriveInput; use super::{ - light_mint::{InfraRefs, LightMintsBuilder}, - parse::ParsedRentFreeStruct, + mint::{InfraRefs, LightMintsBuilder}, + parse::{InfraFieldType, ParsedLightAccountsStruct}, pda::generate_pda_compress_blocks, }; @@ -17,15 +17,15 @@ use super::{ /// /// Encapsulates parsed struct data and resolved infrastructure fields, /// providing methods for validation, querying, and code generation. -pub(super) struct RentFreeBuilder { - parsed: ParsedRentFreeStruct, +pub(super) struct LightAccountsBuilder { + parsed: ParsedLightAccountsStruct, infra: InfraRefs, } -impl RentFreeBuilder { +impl LightAccountsBuilder { /// Parse a DeriveInput and construct the builder. pub fn parse(input: &DeriveInput) -> Result { - let parsed = super::parse::parse_rentfree_struct(input)?; + let parsed = super::parse::parse_light_accounts_struct(input)?; let infra = InfraRefs::from_parsed(&parsed.infra_fields); Ok(Self { parsed, infra }) } @@ -59,15 +59,82 @@ impl RentFreeBuilder { ), )); } + + // Validate infrastructure fields are present + self.validate_infra_fields()?; + + Ok(()) + } + + /// Validate that required infrastructure fields are present. + fn validate_infra_fields(&self) -> Result<(), syn::Error> { + let has_pdas = self.has_pdas(); + let has_mints = self.has_mints(); + + // Skip validation if no light_account fields + if !has_pdas && !has_mints { + return Ok(()); + } + + let mut missing = Vec::new(); + + // fee_payer is always required + if self.parsed.infra_fields.fee_payer.is_none() { + missing.push(InfraFieldType::FeePayer); + } + + // PDAs require compression_config + if has_pdas && self.parsed.infra_fields.compression_config.is_none() { + missing.push(InfraFieldType::CompressionConfig); + } + + // Mints require light_token_config, light_token_rent_sponsor, light_token_cpi_authority + if has_mints { + if self.parsed.infra_fields.light_token_config.is_none() { + missing.push(InfraFieldType::LightTokenConfig); + } + if self.parsed.infra_fields.light_token_rent_sponsor.is_none() { + missing.push(InfraFieldType::LightTokenRentSponsor); + } + if self.parsed.infra_fields.light_token_cpi_authority.is_none() { + missing.push(InfraFieldType::LightTokenCpiAuthority); + } + } + + if !missing.is_empty() { + let context = if has_pdas && has_mints { + "PDA and mint" + } else if has_mints { + "mint" + } else { + "PDA" + }; + + let mut msg = format!( + "#[derive(LightAccounts)] with {} fields requires the following infrastructure fields:\n", + context + ); + + for field_type in &missing { + msg.push_str(&format!( + "\n - {} (add one of: {})", + field_type.description(), + field_type.accepted_names().join(", ") + )); + } + + return Err(syn::Error::new_spanned(&self.parsed.struct_name, msg)); + } + Ok(()) } - /// Query: any #[rentfree] fields? + /// Query: any #[light_account(init)] fields? pub fn has_pdas(&self) -> bool { !self.parsed.rentfree_fields.is_empty() } - /// Query: any #[light_mint] fields? + /// Query: any #[light_account(init)] fields? pub fn has_mints(&self) -> bool { !self.parsed.light_mint_fields.is_empty() } diff --git a/sdk-libs/macros/src/rentfree/accounts/derive.rs b/sdk-libs/macros/src/light_pdas/accounts/derive.rs similarity index 84% rename from sdk-libs/macros/src/rentfree/accounts/derive.rs rename to sdk-libs/macros/src/light_pdas/accounts/derive.rs index a0537c7b24..41ee08bcf7 100644 --- a/sdk-libs/macros/src/rentfree/accounts/derive.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/derive.rs @@ -1,8 +1,8 @@ -//! Orchestration layer for RentFree derive macro. +//! Orchestration layer for LightAccounts derive macro. //! //! This module coordinates code generation by combining: //! - PDA block generation from `pda.rs` -//! - Mint action invocation from `light_mint.rs` +//! - Mint action invocation from `mint.rs` //! - Parsing results from `parse.rs` //! //! Design for mints: @@ -21,11 +21,11 @@ use proc_macro2::TokenStream; use quote::quote; use syn::DeriveInput; -use super::builder::RentFreeBuilder; +use super::builder::LightAccountsBuilder; /// Main orchestration - shows the high-level flow clearly. -pub(super) fn derive_rentfree(input: &DeriveInput) -> Result { - let builder = RentFreeBuilder::parse(input)?; +pub(super) fn derive_light_accounts(input: &DeriveInput) -> Result { + let builder = LightAccountsBuilder::parse(input)?; builder.validate()?; // No instruction args = no-op impls (backwards compatibility) diff --git a/sdk-libs/macros/src/light_pdas/accounts/light_account.rs b/sdk-libs/macros/src/light_pdas/accounts/light_account.rs new file mode 100644 index 0000000000..f046a62b43 --- /dev/null +++ b/sdk-libs/macros/src/light_pdas/accounts/light_account.rs @@ -0,0 +1,608 @@ +//! Unified #[light_account(...)] attribute parsing. +//! +//! This module provides a single unified syntax for all Light Protocol account types: +//! - `#[light_account(init)]` - PDAs +//! - `#[light_account(init, mint, ...)]` - Light Mints +//! - `#[light_account(token, ...)]` - Light token accounts +//! +//! Note: Token fields are NOT processed here - they're handled by seed_extraction.rs +//! in the light_program macro. This parser returns None for token fields. + +use syn::{ + parse::{Parse, ParseStream}, + Error, Expr, Field, Ident, Token, Type, +}; + +use super::mint::LightMintField; +pub(super) use crate::light_pdas::account::seed_extraction::extract_account_inner_type; + +// ============================================================================ +// Account Type Classification +// ============================================================================ + +/// Account type specifier parsed from the attribute. +#[derive(Clone, Copy, Debug, PartialEq, Default)] +pub enum LightAccountType { + #[default] + Pda, // Default (no type specifier) - for PDAs + Mint, // `mint` keyword - for compressed mints + // Future: + // TokenAccount, // `token_account` keyword + // Ata, // `ata` keyword +} + +// ============================================================================ +// Unified Parsed Result +// ============================================================================ + +/// Unified representation of a #[light_account(...)] field. +pub enum LightAccountField { + Pda(Box), + Mint(Box), +} + +/// A field marked with #[light_account(init)] (PDA). +pub struct PdaField { + pub ident: Ident, + /// The inner type T from Account<'info, T> or Box> + pub inner_type: Type, + pub address_tree_info: Expr, + pub output_tree: Expr, + /// True if the field is Box>, false if Account + pub is_boxed: bool, +} + +// ============================================================================ +// Custom Parser for #[light_account(init, [mint,] key = value, ...)] +// ============================================================================ + +/// Key-value pair in the attribute arguments. +struct KeyValue { + key: Ident, + value: Expr, +} + +impl Parse for KeyValue { + fn parse(input: ParseStream) -> syn::Result { + let key: Ident = input.parse()?; + input.parse::()?; + let value: Expr = input.parse()?; + Ok(Self { key, value }) + } +} + +/// Parsed arguments from #[light_account(init, [mint,] ...)]. +struct LightAccountArgs { + /// True if `init` keyword is present (required for PDA/Mint). + has_init: bool, + /// True if `token` keyword is present (marks token fields - skip in LightAccounts derive). + is_token: bool, + /// The account type (Pda, Mint, etc.). + account_type: LightAccountType, + /// Key-value pairs for additional arguments. + key_values: Vec, +} + +impl Parse for LightAccountArgs { + fn parse(input: ParseStream) -> syn::Result { + // First token must be `init` or `token` + let first: Ident = input.parse()?; + + // If first argument is `token`, this is a token field handled by light_program + // Validate remaining tokens - only `authority = [...]` is allowed + if first == "token" { + while !input.is_empty() { + input.parse::()?; + + if input.is_empty() { + break; + } + + let key: Ident = input.parse()?; + if key != "authority" { + return Err(Error::new_spanned( + &key, + format!( + "Unknown argument `{}` in #[light_account(token, ...)]. \ + Only `authority` is allowed.", + key + ), + )); + } + + input.parse::()?; + + // Parse the bracketed content for authority seeds + let content; + syn::bracketed!(content in input); + // Consume the bracket contents (validated by seed_extraction.rs) + while !content.is_empty() { + let _: proc_macro2::TokenTree = content.parse()?; + } + } + return Ok(Self { + has_init: false, + is_token: true, + account_type: LightAccountType::Pda, // not used for token + key_values: Vec::new(), + }); + } + + if first != "init" { + return Err(Error::new_spanned( + &first, + "First argument to #[light_account] must be `init` or `token`", + )); + } + + let mut account_type = LightAccountType::Pda; + let mut key_values = Vec::new(); + + // Parse remaining tokens + while !input.is_empty() { + input.parse::()?; + + // Check if this is a type keyword (mint, token_account, ata) + if input.peek(Ident) { + let lookahead = input.fork(); + let ident: Ident = lookahead.parse()?; + + // Check for type keywords + if ident == "mint" && !lookahead.peek(Token![=]) { + input.parse::()?; // consume it + account_type = LightAccountType::Mint; + continue; + } + // Future: token_account, ata keywords + } + + // Otherwise it's a key-value pair + if !input.is_empty() { + let kv: KeyValue = input.parse()?; + key_values.push(kv); + } + } + + Ok(Self { + has_init: true, + is_token: false, + account_type, + key_values, + }) + } +} + +// ============================================================================ +// Main Parsing Function +// ============================================================================ + +/// Parse #[light_account(...)] attribute from a field. +/// Returns None if no light_account attribute or if it's a token field (handled elsewhere). +/// Returns Some(LightAccountField) for PDA or Mint fields. +pub(super) fn parse_light_account_attr( + field: &Field, + field_ident: &Ident, +) -> Result, syn::Error> { + for attr in &field.attrs { + if attr.path().is_ident("light_account") { + let args: LightAccountArgs = attr.parse_args()?; + + // Token fields are handled by light_program macro (seed_extraction.rs) + // Return None so LightAccounts derive skips them + if args.is_token { + return Ok(None); + } + + if !args.has_init { + return Err(Error::new_spanned( + attr, + "#[light_account] requires `init` as the first argument (or use `token` for token accounts)", + )); + } + + return match args.account_type { + LightAccountType::Pda => Ok(Some(LightAccountField::Pda(Box::new( + build_pda_field(field, field_ident, &args.key_values)?, + )))), + LightAccountType::Mint => Ok(Some(LightAccountField::Mint(Box::new( + build_mint_field(field_ident, &args.key_values, attr)?, + )))), + }; + } + } + Ok(None) +} + +/// Build a PdaField from parsed key-value pairs. +fn build_pda_field( + field: &Field, + field_ident: &Ident, + key_values: &[KeyValue], +) -> Result { + let mut address_tree_info: Option = None; + let mut output_tree: Option = None; + + for kv in key_values { + match kv.key.to_string().as_str() { + "address_tree_info" => address_tree_info = Some(kv.value.clone()), + "output_tree" => output_tree = Some(kv.value.clone()), + other => { + return Err(Error::new_spanned( + &kv.key, + format!( + "Unknown argument `{other}` for PDA. Expected: address_tree_info, output_tree" + ), + )); + } + } + } + + // Use defaults if not specified + let address_tree_info = address_tree_info + .unwrap_or_else(|| syn::parse_quote!(params.create_accounts_proof.address_tree_info)); + let output_tree = output_tree + .unwrap_or_else(|| syn::parse_quote!(params.create_accounts_proof.output_state_tree_index)); + + // Validate this is an Account type (or Box) + let (is_boxed, inner_type) = extract_account_inner_type(&field.ty).ok_or_else(|| { + Error::new_spanned( + &field.ty, + "#[light_account(init)] can only be applied to Account<...> or Box> fields. \ + Nested Box> is not supported.", + ) + })?; + + Ok(PdaField { + ident: field_ident.clone(), + inner_type, + address_tree_info, + output_tree, + is_boxed, + }) +} + +/// Build a LightMintField from parsed key-value pairs. +fn build_mint_field( + field_ident: &Ident, + key_values: &[KeyValue], + attr: &syn::Attribute, +) -> Result { + // Required fields + let mut mint_signer: Option = None; + let mut authority: Option = None; + let mut decimals: Option = None; + let mut mint_seeds: Option = None; + + // Optional fields + let mut address_tree_info: Option = None; + let mut freeze_authority: Option = None; + let mut authority_seeds: Option = None; + let mut rent_payment: Option = None; + let mut write_top_up: Option = None; + + // Metadata fields + let mut name: Option = None; + let mut symbol: Option = None; + let mut uri: Option = None; + let mut update_authority: Option = None; + let mut additional_metadata: Option = None; + + 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()), + "address_tree_info" => address_tree_info = Some(kv.value.clone()), + "freeze_authority" => { + freeze_authority = Some(expr_to_ident(&kv.value, "freeze_authority")?); + } + "authority_seeds" => authority_seeds = Some(kv.value.clone()), + "rent_payment" => rent_payment = Some(kv.value.clone()), + "write_top_up" => write_top_up = Some(kv.value.clone()), + "name" => name = Some(kv.value.clone()), + "symbol" => symbol = Some(kv.value.clone()), + "uri" => uri = Some(kv.value.clone()), + "update_authority" => { + update_authority = Some(expr_to_ident(&kv.value, "update_authority")?); + } + "additional_metadata" => additional_metadata = Some(kv.value.clone()), + other => { + return Err(Error::new_spanned( + &kv.key, + format!("Unknown argument `{other}` for mint"), + )); + } + } + } + + // Validate required fields + let mint_signer = mint_signer.ok_or_else(|| { + Error::new_spanned( + attr, + "#[light_account(init, mint, ...)] requires `mint_signer`", + ) + })?; + let authority = authority.ok_or_else(|| { + Error::new_spanned( + attr, + "#[light_account(init, mint, ...)] requires `authority`", + ) + })?; + let decimals = decimals.ok_or_else(|| { + Error::new_spanned( + attr, + "#[light_account(init, mint, ...)] requires `decimals`", + ) + })?; + let mint_seeds = mint_seeds.ok_or_else(|| { + Error::new_spanned( + attr, + "#[light_account(init, mint, ...)] requires `mint_seeds`", + ) + })?; + + // Validate metadata fields (all-or-nothing rule) + validate_metadata_fields( + &name, + &symbol, + &uri, + &update_authority, + &additional_metadata, + attr, + )?; + + // address_tree_info defaults to params.create_accounts_proof.address_tree_info + let address_tree_info = address_tree_info + .unwrap_or_else(|| syn::parse_quote!(params.create_accounts_proof.address_tree_info)); + + Ok(LightMintField { + field_ident: field_ident.clone(), + mint_signer, + authority, + decimals, + address_tree_info, + freeze_authority, + mint_seeds, + authority_seeds, + rent_payment, + write_top_up, + name, + symbol, + uri, + update_authority, + additional_metadata, + }) +} + +/// Convert an expression to an identifier (for field references). +fn expr_to_ident(expr: &Expr, field_name: &str) -> Result { + match expr { + Expr::Path(path) => path.path.get_ident().cloned().ok_or_else(|| { + Error::new_spanned(expr, format!("`{field_name}` must be a simple identifier")) + }), + _ => Err(Error::new_spanned( + expr, + format!("`{field_name}` must be a simple identifier"), + )), + } +} + +/// Validates TokenMetadata field requirements. +/// +/// Rules: +/// 1. `name`, `symbol`, `uri` must all be defined together or none +/// 2. `update_authority` and `additional_metadata` require `name`, `symbol`, `uri` +fn validate_metadata_fields( + name: &Option, + symbol: &Option, + uri: &Option, + update_authority: &Option, + additional_metadata: &Option, + attr: &syn::Attribute, +) -> Result<(), syn::Error> { + let has_name = name.is_some(); + let has_symbol = symbol.is_some(); + let has_uri = uri.is_some(); + let has_update_authority = update_authority.is_some(); + let has_additional_metadata = additional_metadata.is_some(); + + let core_metadata_count = [has_name, has_symbol, has_uri] + .iter() + .filter(|&&x| x) + .count(); + + // Rule 1: name, symbol, uri must all be defined together or none + if core_metadata_count > 0 && core_metadata_count < 3 { + return Err(Error::new_spanned( + attr, + "TokenMetadata requires all of `name`, `symbol`, and `uri` to be specified together", + )); + } + + // Rule 2: update_authority and additional_metadata require name, symbol, uri + if (has_update_authority || has_additional_metadata) && core_metadata_count == 0 { + return Err(Error::new_spanned( + attr, + "`update_authority` and `additional_metadata` require `name`, `symbol`, and `uri` to also be specified", + )); + } + + Ok(()) +} + +// ============================================================================ +// Conversion to existing types (for compatibility with existing code gen) +// ============================================================================ + +/// Convert PdaField to ParsedPdaField (used by existing codegen). +impl From for super::parse::ParsedPdaField { + fn from(pda: PdaField) -> Self { + Self { + ident: pda.ident, + inner_type: pda.inner_type, + address_tree_info: pda.address_tree_info, + output_tree: pda.output_tree, + is_boxed: pda.is_boxed, + } + } +} + +#[cfg(test)] +mod tests { + use syn::parse_quote; + + use super::*; + + #[test] + fn test_parse_light_account_pda_bare() { + let field: syn::Field = parse_quote! { + #[light_account(init)] + pub record: Account<'info, MyRecord> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_ok()); + let result = result.unwrap(); + assert!(result.is_some()); + + match result.unwrap() { + LightAccountField::Pda(pda) => { + assert_eq!(pda.ident.to_string(), "record"); + assert!(!pda.is_boxed); + } + _ => panic!("Expected PDA field"), + } + } + + #[test] + fn test_parse_light_account_pda_with_options() { + let field: syn::Field = parse_quote! { + #[light_account(init, address_tree_info = custom_tree, output_tree = custom_output)] + pub record: Account<'info, MyRecord> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_ok()); + let result = result.unwrap(); + assert!(result.is_some()); + + match result.unwrap() { + LightAccountField::Pda(_) => {} + _ => panic!("Expected PDA field"), + } + } + + #[test] + fn test_parse_light_account_mint() { + let field: syn::Field = parse_quote! { + #[light_account(init, mint, + mint_signer = mint_signer, + authority = authority, + decimals = 9, + mint_seeds = &[b"test"] + )] + pub cmint: UncheckedAccount<'info> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_ok()); + let result = result.unwrap(); + assert!(result.is_some()); + + match result.unwrap() { + LightAccountField::Mint(mint) => { + assert_eq!(mint.field_ident.to_string(), "cmint"); + } + _ => panic!("Expected Mint field"), + } + } + + #[test] + fn test_parse_light_account_mint_with_metadata() { + let field: syn::Field = parse_quote! { + #[light_account(init, mint, + mint_signer = mint_signer, + authority = authority, + decimals = 9, + mint_seeds = &[b"test"], + name = params.name.clone(), + symbol = params.symbol.clone(), + uri = params.uri.clone() + )] + pub cmint: UncheckedAccount<'info> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_ok()); + let result = result.unwrap(); + assert!(result.is_some()); + + match result.unwrap() { + LightAccountField::Mint(mint) => { + assert!(mint.name.is_some()); + assert!(mint.symbol.is_some()); + assert!(mint.uri.is_some()); + } + _ => panic!("Expected Mint field"), + } + } + + #[test] + fn test_parse_light_account_missing_init() { + let field: syn::Field = parse_quote! { + #[light_account(mint, decimals = 9)] + pub cmint: UncheckedAccount<'info> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_err()); + } + + #[test] + fn test_parse_light_account_mint_missing_required() { + let field: syn::Field = parse_quote! { + #[light_account(init, mint, decimals = 9)] + pub cmint: UncheckedAccount<'info> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_err()); + } + + #[test] + fn test_parse_light_account_partial_metadata_fails() { + let field: syn::Field = parse_quote! { + #[light_account(init, mint, + mint_signer = mint_signer, + authority = authority, + decimals = 9, + mint_seeds = &[b"test"], + name = params.name.clone() + )] + pub cmint: UncheckedAccount<'info> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_err()); + } + + #[test] + fn test_no_light_account_attr_returns_none() { + let field: syn::Field = parse_quote! { + pub record: Account<'info, MyRecord> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident); + assert!(result.is_ok()); + assert!(result.unwrap().is_none()); + } +} diff --git a/sdk-libs/macros/src/rentfree/accounts/light_mint.rs b/sdk-libs/macros/src/light_pdas/accounts/mint.rs similarity index 69% rename from sdk-libs/macros/src/rentfree/accounts/light_mint.rs rename to sdk-libs/macros/src/light_pdas/accounts/mint.rs index e6fb87bd59..a8ac07e983 100644 --- a/sdk-libs/macros/src/rentfree/accounts/light_mint.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/mint.rs @@ -1,13 +1,7 @@ -//! Light mint parsing and code generation. +//! Light mint code generation. //! -//! This module handles: -//! - Parsing of #[light_mint(...)] attributes using darling -//! - Code generation for mint_action CPI invocations -//! -//! ## Parsed Attributes -//! -//! Required: `mint_signer`, `authority`, `decimals`, `mint_seeds` -//! Optional: `address_tree_info`, `freeze_authority`, `authority_seeds`, `rent_payment`, `write_top_up` +//! This module handles code generation for mint_action CPI invocations. +//! Parsing is handled by `light_account.rs`. //! //! ## Code Generation //! @@ -17,21 +11,19 @@ //! //! See `CpiContextParts` for what differs between these cases. -use darling::FromMeta; use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::{Expr, Ident}; use super::parse::InfraFields; -use crate::rentfree::shared_utils::MetaExpr; // ============================================================================ -// Parsing with darling +// Field Types // ============================================================================ -/// A field marked with #[light_mint(...)] +/// A field marked with #[light_account(init, mint, ...)] pub(super) struct LightMintField { - /// The field name where #[light_mint] is attached (CMint account) + /// The field name where #[light_account(init)] is attached (CMint account) pub field_ident: Ident, /// The mint_signer field (AccountInfo that seeds the mint PDA) pub mint_signer: Expr, @@ -64,131 +56,6 @@ pub(super) struct LightMintField { pub additional_metadata: Option, } -/// Arguments inside #[light_mint(...)] parsed by darling. -/// -/// Required fields (darling auto-validates): mint_signer, authority, decimals -/// Optional fields: address_tree_info, freeze_authority, mint_seeds, authority_seeds, rent_payment, write_top_up -/// Metadata fields (all optional): name, symbol, uri, update_authority, additional_metadata -#[derive(FromMeta)] -struct LightMintArgs { - /// The mint_signer field (AccountInfo that seeds the mint PDA) - REQUIRED - mint_signer: MetaExpr, - /// The authority for mint operations - REQUIRED - authority: MetaExpr, - /// Decimals for the mint - REQUIRED - decimals: MetaExpr, - /// Address tree info expression (defaults to params.create_accounts_proof.address_tree_info) - #[darling(default)] - address_tree_info: Option, - /// Optional freeze authority (field name, e.g., `freeze_authority = freeze_auth`) - #[darling(default)] - freeze_authority: Option, - /// Signer seeds for the mint_signer PDA (required) - mint_seeds: MetaExpr, - /// Signer seeds for the authority PDA (optional - if not provided, authority must be a tx signer) - #[darling(default)] - authority_seeds: Option, - /// Rent payment epochs for decompression - #[darling(default)] - rent_payment: Option, - /// Write top-up lamports for decompression - #[darling(default)] - write_top_up: Option, - // Metadata extension fields - /// Token name for TokenMetadata extension (expression yielding Vec) - #[darling(default)] - name: Option, - /// Token symbol for TokenMetadata extension (expression yielding Vec) - #[darling(default)] - symbol: Option, - /// Token URI for TokenMetadata extension (expression yielding Vec) - #[darling(default)] - uri: Option, - /// Update authority field reference for TokenMetadata extension - #[darling(default)] - update_authority: Option, - /// Additional metadata for TokenMetadata extension (expression yielding Option>) - #[darling(default)] - additional_metadata: Option, -} - -/// Validates TokenMetadata field requirements. -/// -/// Rules: -/// 1. `name`, `symbol`, `uri` must all be defined together or none -/// 2. `update_authority` and `additional_metadata` require `name`, `symbol`, `uri` -fn validate_metadata_fields(args: &LightMintArgs) -> Result<(), &'static str> { - let has_name = args.name.is_some(); - let has_symbol = args.symbol.is_some(); - let has_uri = args.uri.is_some(); - let has_update_authority = args.update_authority.is_some(); - let has_additional_metadata = args.additional_metadata.is_some(); - - let core_metadata_count = [has_name, has_symbol, has_uri] - .iter() - .filter(|&&x| x) - .count(); - - // Rule 1: name, symbol, uri must all be defined together or none - if core_metadata_count > 0 && core_metadata_count < 3 { - return Err( - "TokenMetadata requires all of `name`, `symbol`, and `uri` to be specified together", - ); - } - - // Rule 2: update_authority and additional_metadata require name, symbol, uri - if (has_update_authority || has_additional_metadata) && core_metadata_count == 0 { - return Err( - "`update_authority` and `additional_metadata` require `name`, `symbol`, and `uri` to also be specified", - ); - } - - Ok(()) -} - -/// Parse #[light_mint(...)] attribute from a field. -/// Returns None if no light_mint attribute, Some(LightMintField) if found. -pub(super) fn parse_light_mint_attr( - field: &syn::Field, - field_ident: &Ident, -) -> Result, syn::Error> { - for attr in &field.attrs { - if attr.path().is_ident("light_mint") { - // Use darling to parse the attribute arguments - let args = LightMintArgs::from_meta(&attr.meta) - .map_err(|e| syn::Error::new_spanned(attr, e.to_string()))?; - - // Validate metadata fields - validate_metadata_fields(&args).map_err(|msg| syn::Error::new_spanned(attr, msg))?; - - // address_tree_info defaults to params.create_accounts_proof.address_tree_info - let address_tree_info = args.address_tree_info.map(Into::into).unwrap_or_else(|| { - syn::parse_quote!(params.create_accounts_proof.address_tree_info) - }); - - return Ok(Some(LightMintField { - field_ident: field_ident.clone(), - mint_signer: args.mint_signer.into(), - authority: args.authority.into(), - decimals: args.decimals.into(), - address_tree_info, - freeze_authority: args.freeze_authority, - mint_seeds: args.mint_seeds.into(), - authority_seeds: args.authority_seeds.map(Into::into), - rent_payment: args.rent_payment.map(Into::into), - write_top_up: args.write_top_up.map(Into::into), - // Metadata extension fields - name: args.name.map(Into::into), - symbol: args.symbol.map(Into::into), - uri: args.uri.map(Into::into), - update_authority: args.update_authority, - additional_metadata: args.additional_metadata.map(Into::into), - })); - } - } - Ok(None) -} - // ============================================================================ // Code Generation // ============================================================================ @@ -212,9 +79,9 @@ fn resolve_field_name(field: &Option, default: &str) -> TokenStream pub(super) struct InfraRefs { pub fee_payer: TokenStream, pub compression_config: TokenStream, - pub ctoken_config: TokenStream, - pub ctoken_rent_sponsor: TokenStream, - pub ctoken_cpi_authority: TokenStream, + pub light_token_config: TokenStream, + pub light_token_rent_sponsor: TokenStream, + pub light_token_cpi_authority: TokenStream, } impl InfraRefs { @@ -223,14 +90,17 @@ impl InfraRefs { Self { fee_payer: resolve_field_name(&infra.fee_payer, "fee_payer"), compression_config: resolve_field_name(&infra.compression_config, "compression_config"), - ctoken_config: resolve_field_name(&infra.ctoken_config, "ctoken_compressible_config"), - ctoken_rent_sponsor: resolve_field_name( - &infra.ctoken_rent_sponsor, - "ctoken_rent_sponsor", + light_token_config: resolve_field_name( + &infra.light_token_config, + "light_token_compressible_config", + ), + light_token_rent_sponsor: resolve_field_name( + &infra.light_token_rent_sponsor, + "light_token_rent_sponsor", ), - ctoken_cpi_authority: resolve_field_name( - &infra.ctoken_cpi_authority, - "ctoken_cpi_authority", + light_token_cpi_authority: resolve_field_name( + &infra.light_token_cpi_authority, + "light_token_cpi_authority", ), } } @@ -296,9 +166,9 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { // Infrastructure field references let fee_payer = &infra.fee_payer; - let ctoken_config = &infra.ctoken_config; - let ctoken_rent_sponsor = &infra.ctoken_rent_sponsor; - let ctoken_cpi_authority = &infra.ctoken_cpi_authority; + let light_token_config = &infra.light_token_config; + let light_token_rent_sponsor = &infra.light_token_rent_sponsor; + let light_token_cpi_authority = &infra.light_token_cpi_authority; // Determine CPI context offset based on PDA context let (cpi_context_offset, output_tree_setup) = match &builder.pda_context { @@ -515,12 +385,12 @@ fn generate_mints_invocation(builder: &LightMintsBuilder) -> TokenStream { address_tree: __address_tree.clone(), output_queue: __output_queue.clone(), state_merkle_tree: __state_merkle_tree.clone(), - compressible_config: self.#ctoken_config.to_account_info(), + compressible_config: self.#light_token_config.to_account_info(), mints: &__mint_accounts, - rent_sponsor: self.#ctoken_rent_sponsor.to_account_info(), + rent_sponsor: self.#light_token_rent_sponsor.to_account_info(), system_accounts: light_token_sdk::token::SystemAccountInfos { light_system_program: cpi_accounts.light_system_program()?.clone(), - cpi_authority_pda: self.#ctoken_cpi_authority.to_account_info(), + cpi_authority_pda: self.#light_token_cpi_authority.to_account_info(), registered_program_pda: cpi_accounts.registered_program_pda()?.clone(), account_compression_authority: cpi_accounts.account_compression_authority()?.clone(), account_compression_program: cpi_accounts.account_compression_program()?.clone(), diff --git a/sdk-libs/macros/src/light_pdas/accounts/mod.rs b/sdk-libs/macros/src/light_pdas/accounts/mod.rs new file mode 100644 index 0000000000..e4f81b2991 --- /dev/null +++ b/sdk-libs/macros/src/light_pdas/accounts/mod.rs @@ -0,0 +1,27 @@ +//! Light accounts derive macro implementation. +//! +//! This module provides `#[derive(LightAccounts)]` which generates: +//! - `LightPreInit` trait implementation for pre-instruction compression setup +//! - `LightFinalize` trait implementation for post-instruction cleanup +//! - Supports Light PDAs, Light token accounts, and light mints +//! +//! Module structure: +//! - `light_account.rs` - Unified parsing for #[light_account(init, ...)] attributes +//! - `parse.rs` - Struct-level parsing and field classification +//! - `pda.rs` - PDA block code generation +//! - `mint.rs` - Mint action invocation code generation +//! - `derive.rs` - Orchestration layer that wires everything together + +mod builder; +mod derive; +mod light_account; +mod mint; +mod parse; +mod pda; + +use proc_macro2::TokenStream; +use syn::DeriveInput; + +pub fn derive_light_accounts(input: DeriveInput) -> Result { + derive::derive_light_accounts(&input) +} diff --git a/sdk-libs/macros/src/light_pdas/accounts/parse.rs b/sdk-libs/macros/src/light_pdas/accounts/parse.rs new file mode 100644 index 0000000000..707924b3af --- /dev/null +++ b/sdk-libs/macros/src/light_pdas/accounts/parse.rs @@ -0,0 +1,272 @@ +//! Parsing logic for #[light_account(...)] attributes. +//! +//! This module handles struct-level parsing and field classification. +//! The unified #[light_account] attribute parsing is in `light_account.rs`. + +use syn::{ + parse::{Parse, ParseStream}, + punctuated::Punctuated, + DeriveInput, Error, Expr, Ident, Token, Type, +}; + +// Import unified parsing from light_account module +use super::light_account::{parse_light_account_attr, LightAccountField}; +// Import LightMintField from mint module (for type export) +pub(super) use super::mint::LightMintField; + +// ============================================================================ +// Infrastructure Field Classification +// ============================================================================ + +/// Classification of infrastructure fields by naming convention. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(super) enum InfraFieldType { + FeePayer, + CompressionConfig, + LightTokenConfig, + LightTokenRentSponsor, + LightTokenProgram, + LightTokenCpiAuthority, +} + +impl InfraFieldType { + /// Returns the accepted field names for this infrastructure type. + pub fn accepted_names(&self) -> &'static [&'static str] { + match self { + InfraFieldType::FeePayer => &["fee_payer", "payer", "creator"], + InfraFieldType::CompressionConfig => &["compression_config"], + InfraFieldType::LightTokenConfig => &["light_token_compressible_config"], + InfraFieldType::LightTokenRentSponsor => &["light_token_rent_sponsor", "rent_sponsor"], + InfraFieldType::LightTokenProgram => &["light_token_program"], + InfraFieldType::LightTokenCpiAuthority => &["light_token_cpi_authority"], + } + } + + /// Human-readable description for error messages. + pub fn description(&self) -> &'static str { + match self { + InfraFieldType::FeePayer => "fee payer (transaction signer)", + InfraFieldType::CompressionConfig => "compression config", + InfraFieldType::LightTokenConfig => "light token compressible config", + InfraFieldType::LightTokenRentSponsor => "light token rent sponsor", + InfraFieldType::LightTokenProgram => "light token program", + InfraFieldType::LightTokenCpiAuthority => "light token CPI authority", + } + } +} + +/// Classifier for infrastructure fields by naming convention. +pub(super) struct InfraFieldClassifier; + +impl InfraFieldClassifier { + /// Classify a field name into its infrastructure type, if any. + #[inline] + pub fn classify(name: &str) -> Option { + match name { + "fee_payer" | "payer" | "creator" => Some(InfraFieldType::FeePayer), + "compression_config" => Some(InfraFieldType::CompressionConfig), + "light_token_compressible_config" => Some(InfraFieldType::LightTokenConfig), + "light_token_rent_sponsor" | "rent_sponsor" => { + Some(InfraFieldType::LightTokenRentSponsor) + } + "light_token_program" => Some(InfraFieldType::LightTokenProgram), + "light_token_cpi_authority" => Some(InfraFieldType::LightTokenCpiAuthority), + _ => None, + } + } +} + +/// Collected infrastructure field identifiers. +#[derive(Default)] +pub(super) struct InfraFields { + pub fee_payer: Option, + pub compression_config: Option, + pub light_token_config: Option, + pub light_token_rent_sponsor: Option, + pub light_token_program: Option, + pub light_token_cpi_authority: Option, +} + +impl InfraFields { + /// Set an infrastructure field by type. + /// Returns an error if the field is already set (duplicate detection). + pub fn set(&mut self, field_type: InfraFieldType, ident: Ident) -> Result<(), Error> { + match field_type { + InfraFieldType::FeePayer => { + if self.fee_payer.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: fee_payer", + )); + } + self.fee_payer = Some(ident); + } + InfraFieldType::CompressionConfig => { + if self.compression_config.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: compression_config", + )); + } + self.compression_config = Some(ident); + } + InfraFieldType::LightTokenConfig => { + if self.light_token_config.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: light_token_config", + )); + } + self.light_token_config = Some(ident); + } + InfraFieldType::LightTokenRentSponsor => { + if self.light_token_rent_sponsor.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: light_token_rent_sponsor", + )); + } + self.light_token_rent_sponsor = Some(ident); + } + InfraFieldType::LightTokenProgram => { + if self.light_token_program.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: light_token_program", + )); + } + self.light_token_program = Some(ident); + } + InfraFieldType::LightTokenCpiAuthority => { + if self.light_token_cpi_authority.is_some() { + return Err(Error::new_spanned( + &ident, + "duplicate infrastructure field: light_token_cpi_authority", + )); + } + self.light_token_cpi_authority = Some(ident); + } + } + Ok(()) + } +} + +/// Parsed representation of a struct with rentfree and light_mint fields. +pub(super) struct ParsedLightAccountsStruct { + pub struct_name: Ident, + pub generics: syn::Generics, + pub rentfree_fields: Vec, + pub light_mint_fields: Vec, + pub instruction_args: Option>, + /// Infrastructure fields detected by naming convention. + pub infra_fields: InfraFields, +} + +/// A field marked with #[light_account(init)] +pub(super) struct ParsedPdaField { + pub ident: Ident, + /// The inner type T from Account<'info, T> or Box> + /// Preserves the full type path (e.g., crate::state::UserRecord). + pub inner_type: Type, + pub address_tree_info: Expr, + pub output_tree: Expr, + /// True if the field is Box>, false if Account + pub is_boxed: bool, +} + +/// Instruction argument from #[instruction(...)] +pub(super) struct InstructionArg { + pub name: Ident, + pub ty: Type, +} + +impl Parse for InstructionArg { + fn parse(input: ParseStream) -> syn::Result { + let name: Ident = input.parse()?; + input.parse::()?; + let ty: Type = input.parse()?; + Ok(Self { name, ty }) + } +} + +/// Parse #[instruction(...)] attribute from struct. +/// +/// Returns `Ok(None)` if no instruction attribute is present, +/// `Ok(Some(args))` if successfully parsed, or `Err` on malformed syntax. +fn parse_instruction_attr(attrs: &[syn::Attribute]) -> Result>, Error> { + for attr in attrs { + if attr.path().is_ident("instruction") { + let args = attr.parse_args_with(|input: ParseStream| { + let content: Punctuated = + Punctuated::parse_terminated(input)?; + Ok(content.into_iter().collect::>()) + })?; + return Ok(Some(args)); + } + } + Ok(None) +} + +/// Parse a struct to extract light_account fields (PDAs and mints). +pub(super) fn parse_light_accounts_struct( + input: &DeriveInput, +) -> Result { + let struct_name = input.ident.clone(); + let generics = input.generics.clone(); + + let instruction_args = parse_instruction_attr(&input.attrs)?; + + let fields = match &input.data { + syn::Data::Struct(data) => match &data.fields { + syn::Fields::Named(fields) => &fields.named, + _ => return Err(Error::new_spanned(input, "expected named fields")), + }, + _ => return Err(Error::new_spanned(input, "expected struct")), + }; + + let mut rentfree_fields = Vec::new(); + let mut light_mint_fields = Vec::new(); + let mut infra_fields = InfraFields::default(); + + for field in fields { + let field_ident = field + .ident + .clone() + .ok_or_else(|| Error::new_spanned(field, "expected named field with identifier"))?; + let field_name = field_ident.to_string(); + + // Track infrastructure fields by naming convention using the classifier. + // See InfraFieldClassifier for supported field names. + if let Some(field_type) = InfraFieldClassifier::classify(&field_name) { + infra_fields.set(field_type, field_ident.clone())?; + } + + // Check for #[light_account(...)] - the unified syntax + if let Some(light_account_field) = parse_light_account_attr(field, &field_ident)? { + match light_account_field { + LightAccountField::Pda(pda) => rentfree_fields.push((*pda).into()), + LightAccountField::Mint(mint) => light_mint_fields.push(*mint), + } + continue; // Field processed, move to next + } + } + + // Validation: #[light_account] fields require #[instruction] attribute + if (!rentfree_fields.is_empty() || !light_mint_fields.is_empty()) && instruction_args.is_none() + { + return Err(Error::new_spanned( + input, + "#[light_account] fields require #[instruction(params: YourParamsType)] \ + attribute on the struct", + )); + } + + Ok(ParsedLightAccountsStruct { + struct_name, + generics, + rentfree_fields, + light_mint_fields, + instruction_args, + infra_fields, + }) +} diff --git a/sdk-libs/macros/src/rentfree/accounts/pda.rs b/sdk-libs/macros/src/light_pdas/accounts/pda.rs similarity index 96% rename from sdk-libs/macros/src/rentfree/accounts/pda.rs rename to sdk-libs/macros/src/light_pdas/accounts/pda.rs index 80fb37a10d..a86d3f8455 100644 --- a/sdk-libs/macros/src/rentfree/accounts/pda.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/pda.rs @@ -1,7 +1,7 @@ //! PDA block code generation for rent-free accounts. //! //! This module handles the generation of compression blocks for PDA fields -//! marked with `#[rentfree]`. Each PDA field generates code for: +//! marked with `#[light_account(init)]`. Each PDA field generates code for: //! - Account extraction (get account info and key bytes) //! - New address params struct creation //! - Address derivation from seed and merkle tree @@ -11,7 +11,7 @@ use proc_macro2::TokenStream; use quote::{format_ident, quote}; use syn::Ident; -use super::parse::RentFreeField; +use super::parse::ParsedPdaField; /// Generated identifier names for a PDA field. pub(super) struct PdaIdents { @@ -40,12 +40,12 @@ impl PdaIdents { /// Builder for PDA compression block code generation. pub(super) struct PdaBlockBuilder<'a> { - field: &'a RentFreeField, + field: &'a ParsedPdaField, idents: PdaIdents, } impl<'a> PdaBlockBuilder<'a> { - pub fn new(field: &'a RentFreeField, idx: usize) -> Self { + pub fn new(field: &'a ParsedPdaField, idx: usize) -> Self { Self { field, idents: PdaIdents::new(idx), @@ -181,7 +181,7 @@ impl<'a> PdaBlockBuilder<'a> { /// - Vector of TokenStreams for compression blocks /// - Vector of TokenStreams for new address parameter identifiers pub(super) fn generate_pda_compress_blocks( - fields: &[RentFreeField], + fields: &[ParsedPdaField], ) -> (Vec, Vec) { let mut blocks = Vec::with_capacity(fields.len()); let mut addr_idents = Vec::with_capacity(fields.len()); diff --git a/sdk-libs/macros/src/rentfree/mod.rs b/sdk-libs/macros/src/light_pdas/mod.rs similarity index 85% rename from sdk-libs/macros/src/rentfree/mod.rs rename to sdk-libs/macros/src/light_pdas/mod.rs index 05b0f9b73e..c9be7db2fb 100644 --- a/sdk-libs/macros/src/rentfree/mod.rs +++ b/sdk-libs/macros/src/light_pdas/mod.rs @@ -2,7 +2,7 @@ //! //! This module organizes all rent-free related macros: //! - `program/` - `#[rentfree_program]` attribute macro for program-level auto-discovery -//! - `accounts/` - `#[derive(RentFree)]` derive macro for Accounts structs +//! - `accounts/` - `#[derive(LightAccounts)]` derive macro for Accounts structs //! - `account/` - Trait derive macros for account data structs (Compressible, Pack, HasCompressionInfo, etc.) //! - `shared_utils` - Common utilities (constant detection, identifier extraction) diff --git a/sdk-libs/macros/src/rentfree/program/compress.rs b/sdk-libs/macros/src/light_pdas/program/compress.rs similarity index 99% rename from sdk-libs/macros/src/rentfree/program/compress.rs rename to sdk-libs/macros/src/light_pdas/program/compress.rs index c2eead012d..9bc3c4fdd4 100644 --- a/sdk-libs/macros/src/rentfree/program/compress.rs +++ b/sdk-libs/macros/src/light_pdas/program/compress.rs @@ -8,7 +8,7 @@ use quote::quote; use syn::{Result, Type}; use super::parsing::InstructionVariant; -use crate::rentfree::shared_utils::qualify_type_with_crate; +use crate::light_pdas::shared_utils::qualify_type_with_crate; // ============================================================================= // COMPRESS BUILDER @@ -263,7 +263,7 @@ impl CompressBuilder { // that covers all possible error conditions. Ok(quote! { #[error_code] - pub enum RentFreeInstructionError { + pub enum LightInstructionError { #[msg("Rent sponsor mismatch")] InvalidRentSponsor, #[msg("Missing seed account")] diff --git a/sdk-libs/macros/src/rentfree/program/crate_context.rs b/sdk-libs/macros/src/light_pdas/program/crate_context.rs similarity index 95% rename from sdk-libs/macros/src/rentfree/program/crate_context.rs rename to sdk-libs/macros/src/light_pdas/program/crate_context.rs index 8e59bab79d..d01572d0dc 100644 --- a/sdk-libs/macros/src/rentfree/program/crate_context.rs +++ b/sdk-libs/macros/src/light_pdas/program/crate_context.rs @@ -1,7 +1,7 @@ //! Anchor-style crate context parser for `#[rentfree_program]`. //! //! This module recursively reads all module files at macro expansion time, -//! allowing `#[rentfree_program]` to discover all `#[derive(RentFree)]` structs +//! allowing `#[rentfree_program]` to discover all `#[derive(LightAccounts)]` structs //! across the entire crate. //! //! Based on Anchor's `CrateContext::parse()` pattern from `anchor-syn/src/parser/context.rs`. @@ -64,7 +64,7 @@ impl CrateContext { self.modules.values().flat_map(|module| module.structs()) } - /// Find structs that have a specific derive attribute (e.g., "RentFree"). + /// Find structs that have a specific derive attribute (e.g., "LightAccounts"). pub fn structs_with_derive(&self, derive_name: &str) -> Vec<&ItemStruct> { self.structs() .filter(|s| has_derive_attribute(&s.attrs, derive_name)) @@ -237,13 +237,13 @@ fn has_derive_attribute(attrs: &[syn::Attribute], derive_name: &str) -> bool { syn::punctuated::Punctuated::::parse_terminated, ) { for path in nested { - // Check simple ident: #[derive(RentFree)] + // Check simple ident: #[derive(LightAccounts)] if let Some(ident) = path.get_ident() { if ident == derive_name { return true; } } - // Check path: #[derive(light_sdk::RentFree)] + // Check path: #[derive(light_sdk::LightAccounts)] if let Some(segment) = path.segments.last() { if segment.ident == derive_name { return true; @@ -262,13 +262,13 @@ mod tests { #[test] fn test_has_derive_attribute() { let code = quote::quote! { - #[derive(Accounts, RentFree)] + #[derive(Accounts, LightAccounts)] pub struct CreateUser<'info> { pub fee_payer: Signer<'info>, } }; let item: ItemStruct = syn::parse2(code).unwrap(); - assert!(has_derive_attribute(&item.attrs, "RentFree")); + assert!(has_derive_attribute(&item.attrs, "LightAccounts")); assert!(has_derive_attribute(&item.attrs, "Accounts")); assert!(!has_derive_attribute(&item.attrs, "Clone")); } @@ -276,12 +276,12 @@ mod tests { #[test] fn test_has_derive_attribute_qualified() { let code = quote::quote! { - #[derive(light_sdk::RentFree)] + #[derive(light_sdk::LightAccounts)] pub struct CreateUser<'info> { pub fee_payer: Signer<'info>, } }; let item: ItemStruct = syn::parse2(code).unwrap(); - assert!(has_derive_attribute(&item.attrs, "RentFree")); + assert!(has_derive_attribute(&item.attrs, "LightAccounts")); } } diff --git a/sdk-libs/macros/src/rentfree/program/decompress.rs b/sdk-libs/macros/src/light_pdas/program/decompress.rs similarity index 97% rename from sdk-libs/macros/src/rentfree/program/decompress.rs rename to sdk-libs/macros/src/light_pdas/program/decompress.rs index be92ceb5e0..827ca3a931 100644 --- a/sdk-libs/macros/src/rentfree/program/decompress.rs +++ b/sdk-libs/macros/src/light_pdas/program/decompress.rs @@ -14,7 +14,7 @@ use super::{ seed_utils::ctx_fields_to_set, variant_enum::PdaCtxSeedInfo, }; -use crate::rentfree::shared_utils::{is_constant_identifier, qualify_type_with_crate}; +use crate::light_pdas::shared_utils::{is_constant_identifier, qualify_type_with_crate}; // ============================================================================= // DECOMPRESS BUILDER @@ -67,7 +67,7 @@ impl DecompressBuilder { let lifetime: syn::Lifetime = syn::parse_quote!('info); let trait_impl = - crate::rentfree::account::decompress_context::generate_decompress_context_trait_impl( + crate::light_pdas::account::decompress_context::generate_decompress_context_trait_impl( self.pda_ctx_seeds.clone(), self.token_variant_ident.clone(), lifetime, @@ -90,7 +90,7 @@ impl DecompressBuilder { accounts: &DecompressAccountsIdempotent<'info>, remaining_accounts: &[solana_account_info::AccountInfo<'info>], proof: light_sdk::instruction::ValidityProof, - compressed_accounts: Vec, + compressed_accounts: Vec, system_accounts_offset: u8, ) -> Result<()> { light_sdk::compressible::process_decompress_accounts_idempotent( @@ -115,7 +115,7 @@ impl DecompressBuilder { pub fn decompress_accounts_idempotent<'info>( ctx: Context<'_, '_, '_, 'info, DecompressAccountsIdempotent<'info>>, proof: light_sdk::instruction::ValidityProof, - compressed_accounts: Vec, + compressed_accounts: Vec, system_accounts_offset: u8, ) -> Result<()> { __processor_functions::process_decompress_accounts_idempotent( @@ -153,7 +153,7 @@ impl DecompressBuilder { pub light_token_program: Option>, /// CHECK: #[account(address = solana_pubkey::pubkey!("GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy"))] - pub ctoken_cpi_authority: Option>, + pub light_token_cpi_authority: Option>, /// CHECK: Checked by SDK pub ctoken_config: Option>, } @@ -403,7 +403,7 @@ fn get_params_only_field_name( expr: &syn::Expr, state_field_names: &std::collections::HashSet, ) -> Option { - use crate::rentfree::shared_utils::is_base_path; + use crate::light_pdas::shared_utils::is_base_path; match expr { syn::Expr::Field(field_expr) => { diff --git a/sdk-libs/macros/src/rentfree/program/expr_traversal.rs b/sdk-libs/macros/src/light_pdas/program/expr_traversal.rs similarity index 98% rename from sdk-libs/macros/src/rentfree/program/expr_traversal.rs rename to sdk-libs/macros/src/light_pdas/program/expr_traversal.rs index 99ee69b6a3..8f74097d2e 100644 --- a/sdk-libs/macros/src/rentfree/program/expr_traversal.rs +++ b/sdk-libs/macros/src/light_pdas/program/expr_traversal.rs @@ -7,7 +7,7 @@ use std::collections::HashSet; use syn::Expr; -use crate::rentfree::shared_utils::is_base_path; +use crate::light_pdas::shared_utils::is_base_path; // ============================================================================= // EXPRESSION TRANSFORMER diff --git a/sdk-libs/macros/src/rentfree/program/instructions.rs b/sdk-libs/macros/src/light_pdas/program/instructions.rs similarity index 92% rename from sdk-libs/macros/src/rentfree/program/instructions.rs rename to sdk-libs/macros/src/light_pdas/program/instructions.rs index f9d1b4968a..c5c7cd6278 100644 --- a/sdk-libs/macros/src/rentfree/program/instructions.rs +++ b/sdk-libs/macros/src/light_pdas/program/instructions.rs @@ -14,12 +14,12 @@ use super::{ decompress::DecompressBuilder, parsing::{ convert_classified_to_seed_elements, convert_classified_to_seed_elements_vec, - extract_context_and_params, macro_error, wrap_function_with_rentfree, + extract_context_and_params, macro_error, wrap_function_with_light, }, - variant_enum::{PdaCtxSeedInfo, RentFreeVariantBuilder, TokenVariantBuilder}, + variant_enum::{LightVariantBuilder, PdaCtxSeedInfo, TokenVariantBuilder}, }; use crate::{ - rentfree::shared_utils::{ident_to_type, qualify_type_with_crate}, + light_pdas::shared_utils::{ident_to_type, qualify_type_with_crate}, utils::to_snake_case, }; @@ -53,10 +53,10 @@ fn codegen( if !token_seed_specs.is_empty() { TokenVariantBuilder::new(token_seed_specs).build()? } else { - crate::rentfree::account::utils::generate_empty_ctoken_enum() + crate::light_pdas::account::utils::generate_empty_ctoken_enum() } } else { - crate::rentfree::account::utils::generate_empty_ctoken_enum() + crate::light_pdas::account::utils::generate_empty_ctoken_enum() }; if let Some(ref token_seed_specs) = token_seeds { @@ -78,7 +78,7 @@ fn codegen( .iter() .map(|spec| { let ctx_fields = extract_ctx_seed_fields(&spec.seeds); - // Use inner_type if available (from #[rentfree] fields), otherwise fall back to variant as type + // Use inner_type if available (from #[light_account(init)] fields), otherwise fall back to variant as type let inner_type = spec .inner_type .clone() @@ -91,7 +91,7 @@ fn codegen( .unwrap_or_default(); // Extract params-only seed fields (data.* fields that don't exist on state) - let params_only_seed_fields = crate::rentfree::account::seed_extraction::get_params_only_seed_fields_from_spec(spec, &state_field_names); + let params_only_seed_fields = crate::light_pdas::account::seed_extraction::get_params_only_seed_fields_from_spec(spec, &state_field_names); PdaCtxSeedInfo::with_state_fields( spec.variant.clone(), @@ -105,7 +105,7 @@ fn codegen( }) .unwrap_or_default(); - let enum_and_traits = RentFreeVariantBuilder::new(&pda_ctx_seeds).build()?; + let enum_and_traits = LightVariantBuilder::new(&pda_ctx_seeds).build()?; // Collect all unique params-only seed fields across all variants for SeedParams struct // Use BTreeMap for deterministic ordering @@ -196,7 +196,7 @@ fn codegen( } Some(quote! { if data.#field != seeds.#field { - return std::result::Result::Err(RentFreeInstructionError::SeedMismatch.into()); + return std::result::Result::Err(LightInstructionError::SeedMismatch.into()); } }) }).collect(); @@ -210,7 +210,7 @@ fn codegen( #(#ctx_field_decls,)* #(#data_field_decls,)* } - impl RentFreeAccountVariant { + impl LightAccountVariant { pub fn #constructor_name( account_data: &[u8], seeds: #seeds_struct_name, @@ -230,9 +230,9 @@ fn codegen( }) } } - impl light_sdk::compressible::IntoVariant for #seeds_struct_name { - fn into_variant(self, data: &[u8]) -> std::result::Result { - RentFreeAccountVariant::#constructor_name(data, self) + impl light_sdk::compressible::IntoVariant for #seeds_struct_name { + fn into_variant(self, data: &[u8]) -> std::result::Result { + LightAccountVariant::#constructor_name(data, self) } } } @@ -282,9 +282,9 @@ fn codegen( mod __trait_impls { use super::*; - impl light_sdk::compressible::HasTokenVariant for RentFreeAccountData { + impl light_sdk::compressible::HasTokenVariant for LightAccountData { fn is_packed_token(&self) -> bool { - matches!(self.data, RentFreeAccountVariant::PackedCTokenData(_)) + matches!(self.data, LightAccountVariant::PackedCTokenData(_)) } } } @@ -401,7 +401,7 @@ fn codegen( content.1.push(item); } - // Insert XxxSeeds structs and RentFreeAccountVariant constructors + // Insert XxxSeeds structs and LightAccountVariant constructors for seeds_tokens in seeds_structs_and_constructors.into_iter() { let wrapped: syn::File = syn::parse2(seeds_tokens)?; for item in wrapped.items { @@ -460,15 +460,15 @@ fn codegen( // MAIN ENTRY POINT // ============================================================================= -/// Main entry point for #[rentfree_program] macro. +/// Main entry point for #[light_program] macro. /// /// This macro reads external module files to extract seed information from -/// Accounts structs with #[rentfree] fields. It also automatically wraps +/// Accounts structs with #[light_account(init)] fields. It also automatically wraps /// instruction handlers that use these Accounts structs with pre_init/finalize logic. /// /// Usage: /// ```ignore -/// #[rentfree_program] +/// #[light_program] /// #[program] /// pub mod my_program { /// pub mod instruction_accounts; // Macro reads this file! @@ -484,9 +484,9 @@ fn codegen( /// } /// ``` #[inline(never)] -pub fn rentfree_program_impl(_args: TokenStream, mut module: ItemMod) -> Result { +pub fn light_program_impl(_args: TokenStream, mut module: ItemMod) -> Result { use super::crate_context::CrateContext; - use crate::rentfree::account::seed_extraction::{ + use crate::light_pdas::account::seed_extraction::{ extract_from_accounts_struct, get_data_fields, ExtractedSeedSpec, ExtractedTokenSpec, }; @@ -519,7 +519,7 @@ pub fn rentfree_program_impl(_args: TokenStream, mut module: ItemMod) -> Result< if pda_specs.is_empty() && token_specs.is_empty() { return Err(macro_error!( &module, - "No #[rentfree] or #[rentfree_token] fields found in any Accounts struct.\n\ + "No #[light_account(init)] or #[light_account(token)] fields found in any Accounts struct.\n\ Ensure your Accounts structs are in modules declared with `pub mod xxx;`" )); } @@ -532,7 +532,7 @@ pub fn rentfree_program_impl(_args: TokenStream, mut module: ItemMod) -> Result< if let Some((context_type, params_ident)) = extract_context_and_params(fn_item) { if rentfree_struct_names.contains(&context_type) { // Wrap the function with pre_init/finalize logic - *fn_item = wrap_function_with_rentfree(fn_item, ¶ms_ident); + *fn_item = wrap_function_with_light(fn_item, ¶ms_ident); } } } diff --git a/sdk-libs/macros/src/rentfree/program/mod.rs b/sdk-libs/macros/src/light_pdas/program/mod.rs similarity index 60% rename from sdk-libs/macros/src/rentfree/program/mod.rs rename to sdk-libs/macros/src/light_pdas/program/mod.rs index 5992ce18be..2ff7064f4d 100644 --- a/sdk-libs/macros/src/rentfree/program/mod.rs +++ b/sdk-libs/macros/src/light_pdas/program/mod.rs @@ -1,7 +1,7 @@ -//! Rent-free program macro implementation. +//! Light program macro implementation. //! -//! This module provides `#[rentfree_program]` attribute macro that: -//! - Automatically discovers #[rentfree] fields in Accounts structs +//! This module provides `#[light_program]` attribute macro that: +//! - Automatically discovers #[light_account(init)] fields in Accounts structs //! - Auto-wraps instruction handlers with light_pre_init/light_finalize logic //! - Generates all necessary types, enums, and instruction handlers @@ -16,4 +16,4 @@ pub mod seed_utils; pub mod variant_enum; pub mod visitors; -pub use instructions::rentfree_program_impl; +pub use instructions::light_program_impl; diff --git a/sdk-libs/macros/src/rentfree/program/parsing.rs b/sdk-libs/macros/src/light_pdas/program/parsing.rs similarity index 96% rename from sdk-libs/macros/src/rentfree/program/parsing.rs rename to sdk-libs/macros/src/light_pdas/program/parsing.rs index 96d9584b1b..6e8bab8fdc 100644 --- a/sdk-libs/macros/src/rentfree/program/parsing.rs +++ b/sdk-libs/macros/src/light_pdas/program/parsing.rs @@ -61,7 +61,7 @@ pub struct TokenSeedSpec { pub authority: Option>, /// The inner type (e.g., crate::state::SinglePubkeyRecord - used for type references) /// Preserves the full type path for code generation. - /// Only set for PDAs extracted from #[rentfree] fields; None for parsed specs + /// Only set for PDAs extracted from #[light_account(init)] fields; None for parsed specs pub inner_type: Option, } @@ -146,7 +146,7 @@ impl Parse for TokenSeedSpec { is_token, seeds, authority, - inner_type: None, // Set by caller for #[rentfree] fields + inner_type: None, // Set by caller for #[light_account(init)] fields }) } } @@ -283,9 +283,9 @@ pub fn extract_data_seed_fields( /// Convert ClassifiedSeed to SeedElement (Punctuated) pub fn convert_classified_to_seed_elements( - seeds: &[crate::rentfree::account::seed_extraction::ClassifiedSeed], + seeds: &[crate::light_pdas::account::seed_extraction::ClassifiedSeed], ) -> Punctuated { - use crate::rentfree::account::seed_extraction::ClassifiedSeed; + use crate::light_pdas::account::seed_extraction::ClassifiedSeed; let mut result = Punctuated::new(); for seed in seeds { @@ -338,7 +338,7 @@ pub fn convert_classified_to_seed_elements( } pub fn convert_classified_to_seed_elements_vec( - seeds: &[crate::rentfree::account::seed_extraction::ClassifiedSeed], + seeds: &[crate::light_pdas::account::seed_extraction::ClassifiedSeed], ) -> Vec { convert_classified_to_seed_elements(seeds) .into_iter() @@ -399,7 +399,7 @@ pub fn extract_context_and_params(fn_item: &ItemFn) -> Option<(String, Ident)> { } /// Wrap a function with pre_init/finalize logic. -pub fn wrap_function_with_rentfree(fn_item: &ItemFn, params_ident: &Ident) -> ItemFn { +pub fn wrap_function_with_light(fn_item: &ItemFn, params_ident: &Ident) -> ItemFn { let fn_vis = &fn_item.vis; let fn_sig = &fn_item.sig; let fn_block = &fn_item.block; diff --git a/sdk-libs/macros/src/rentfree/program/seed_codegen.rs b/sdk-libs/macros/src/light_pdas/program/seed_codegen.rs similarity index 99% rename from sdk-libs/macros/src/rentfree/program/seed_codegen.rs rename to sdk-libs/macros/src/light_pdas/program/seed_codegen.rs index 10dc4451d2..92042baa9b 100644 --- a/sdk-libs/macros/src/rentfree/program/seed_codegen.rs +++ b/sdk-libs/macros/src/light_pdas/program/seed_codegen.rs @@ -75,7 +75,7 @@ pub fn generate_ctoken_seed_provider_implementation( let authority_arm = quote! { #pattern => { Err(solana_program_error::ProgramError::Custom( - RentFreeInstructionError::MissingSeedAccount.into() + LightInstructionError::MissingSeedAccount.into() )) } }; diff --git a/sdk-libs/macros/src/rentfree/program/seed_utils.rs b/sdk-libs/macros/src/light_pdas/program/seed_utils.rs similarity index 98% rename from sdk-libs/macros/src/rentfree/program/seed_utils.rs rename to sdk-libs/macros/src/light_pdas/program/seed_utils.rs index d2675a7fab..f93d9fc171 100644 --- a/sdk-libs/macros/src/rentfree/program/seed_utils.rs +++ b/sdk-libs/macros/src/light_pdas/program/seed_utils.rs @@ -12,7 +12,7 @@ use quote::quote; use syn::Ident; use super::parsing::SeedElement; -use crate::rentfree::shared_utils::is_constant_identifier; +use crate::light_pdas::shared_utils::is_constant_identifier; // ============================================================================= // SEED EXPRESSION CONVERSION diff --git a/sdk-libs/macros/src/rentfree/program/variant_enum.rs b/sdk-libs/macros/src/light_pdas/program/variant_enum.rs similarity index 85% rename from sdk-libs/macros/src/rentfree/program/variant_enum.rs rename to sdk-libs/macros/src/light_pdas/program/variant_enum.rs index b3411cc089..c2babeea8f 100644 --- a/sdk-libs/macros/src/rentfree/program/variant_enum.rs +++ b/sdk-libs/macros/src/light_pdas/program/variant_enum.rs @@ -3,7 +3,7 @@ use quote::{format_ident, quote}; use syn::{Ident, Result, Type}; use super::parsing::{SeedElement, TokenSeedSpec}; -use crate::rentfree::shared_utils::{ +use crate::light_pdas::shared_utils::{ make_packed_type, make_packed_variant_name, qualify_type_with_crate, }; @@ -11,25 +11,25 @@ use crate::rentfree::shared_utils::{ // RENTFREE VARIANT BUILDER // ============================================================================= -/// Builder for generating `RentFreeAccountVariant` enum and its trait implementations. +/// Builder for generating `LightAccountVariant` enum and its trait implementations. /// /// Encapsulates the PDA context seed info and configuration needed to generate /// all variant-related code: enum definition, trait impls, and wrapper struct. -pub(super) struct RentFreeVariantBuilder<'a> { +pub(super) struct LightVariantBuilder<'a> { /// PDA context seed info for each account type. pda_ctx_seeds: &'a [PdaCtxSeedInfo], /// Whether to include CToken variants in the generated enum. include_ctoken: bool, } -impl<'a> RentFreeVariantBuilder<'a> { - /// Create a new RentFreeVariantBuilder with the given PDA context seeds. +impl<'a> LightVariantBuilder<'a> { + /// Create a new LightVariantBuilder with the given PDA context seeds. /// /// # Arguments /// * `pda_ctx_seeds` - PDA context seed info for each account type /// /// # Returns - /// A new RentFreeVariantBuilder instance + /// A new LightVariantBuilder instance pub fn new(pda_ctx_seeds: &'a [PdaCtxSeedInfo]) -> Self { Self { pda_ctx_seeds, @@ -47,7 +47,19 @@ impl<'a> RentFreeVariantBuilder<'a> { if self.pda_ctx_seeds.is_empty() { return Err(syn::Error::new( proc_macro2::Span::call_site(), - "At least one account type must be specified", + "#[rentfree_program] requires at least one Accounts struct with \ + #[light_account(init)] fields.\n\n\ + Make sure your program has:\n\ + 1. An Accounts struct with #[derive(Accounts, LightAccounts)]\n\ + 2. At least one field marked with #[light_account(init)]\n\n\ + Example:\n\ + #[derive(Accounts, LightAccounts)]\n\ + #[instruction(params: MyParams)]\n\ + pub struct MyAccounts<'info> {\n \ + #[account(init, ...)]\n \ + #[light_account(init)]\n \ + pub my_account: Account<'info, MyData>,\n\ + }", )); } Ok(()) @@ -71,7 +83,7 @@ impl<'a> RentFreeVariantBuilder<'a> { let size_impl = self.generate_size_impl(); let pack_impl = self.generate_pack_impl(); let unpack_impl = self.generate_unpack_impl()?; - let rentfree_account_data_struct = self.generate_rentfree_account_data_struct(); + let light_account_data_struct = self.generate_light_account_data_struct(); Ok(quote! { #enum_def @@ -82,7 +94,7 @@ impl<'a> RentFreeVariantBuilder<'a> { #size_impl #pack_impl #unpack_impl - #rentfree_account_data_struct + #light_account_data_struct }) } @@ -131,7 +143,7 @@ impl<'a> RentFreeVariantBuilder<'a> { Ok(quote! { #[derive(Clone, Debug, anchor_lang::AnchorSerialize, anchor_lang::AnchorDeserialize)] - pub enum RentFreeAccountVariant { + pub enum LightAccountVariant { #(#account_variants_tokens)* #ctoken_variants } @@ -154,7 +166,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }); quote! { - impl Default for RentFreeAccountVariant { + impl Default for LightAccountVariant { fn default() -> Self { Self::#first_variant { data: #first_type::default(), #(#first_default_ctx_fields,)* #(#first_default_params_fields,)* } } @@ -169,8 +181,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_hasher::DataHasher>::hash::(data), - RentFreeAccountVariant::#packed_variant_name { .. } => Err(light_hasher::HasherError::EmptyInput), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_hasher::DataHasher>::hash::(data), + LightAccountVariant::#packed_variant_name { .. } => Err(light_hasher::HasherError::EmptyInput), } }); @@ -184,7 +196,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }; quote! { - impl light_hasher::DataHasher for RentFreeAccountVariant { + impl light_hasher::DataHasher for LightAccountVariant { fn hash(&self) -> std::result::Result<[u8; 32], light_hasher::HasherError> { match self { #(#hash_match_arms)* @@ -198,7 +210,7 @@ impl<'a> RentFreeVariantBuilder<'a> { /// Generate the LightDiscriminator implementation. fn generate_light_discriminator_impl(&self) -> TokenStream { quote! { - impl light_sdk::LightDiscriminator for RentFreeAccountVariant { + impl light_sdk::LightDiscriminator for LightAccountVariant { const LIGHT_DISCRIMINATOR: [u8; 8] = [0; 8]; const LIGHT_DISCRIMINATOR_SLICE: &'static [u8] = &Self::LIGHT_DISCRIMINATOR; } @@ -212,8 +224,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info(data), - RentFreeAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info(data), + LightAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), } }); @@ -222,8 +234,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info_mut(data), - RentFreeAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info_mut(data), + LightAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), } }); @@ -232,8 +244,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info_mut_opt(data), - RentFreeAccountVariant::#packed_variant_name { .. } => panic!("compression_info_mut_opt not supported on packed variants"), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::compression_info_mut_opt(data), + LightAccountVariant::#packed_variant_name { .. } => panic!("compression_info_mut_opt not supported on packed variants"), } }); @@ -242,8 +254,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::set_compression_info_none(data), - RentFreeAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::compressible::HasCompressionInfo>::set_compression_info_none(data), + LightAccountVariant::#packed_variant_name { .. } => Err(light_sdk::error::LightSdkError::PackedVariantCompressionInfo.into()), } }); @@ -264,7 +276,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }; quote! { - impl light_sdk::compressible::HasCompressionInfo for RentFreeAccountVariant { + impl light_sdk::compressible::HasCompressionInfo for LightAccountVariant { fn compression_info(&self) -> std::result::Result<&light_sdk::compressible::CompressionInfo, solana_program_error::ProgramError> { match self { #(#compression_info_match_arms)* @@ -303,8 +315,8 @@ impl<'a> RentFreeVariantBuilder<'a> { let inner_type = qualify_type_with_crate(&info.inner_type); let packed_variant_name = format_ident!("Packed{}", variant_name); quote! { - RentFreeAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::account::Size>::size(data), - RentFreeAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), + LightAccountVariant::#variant_name { data, .. } => <#inner_type as light_sdk::account::Size>::size(data), + LightAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), } }); @@ -318,7 +330,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }; quote! { - impl light_sdk::account::Size for RentFreeAccountVariant { + impl light_sdk::account::Size for LightAccountVariant { fn size(&self) -> std::result::Result { match self { #(#size_match_arms)* @@ -349,17 +361,17 @@ impl<'a> RentFreeVariantBuilder<'a> { if ctx_fields.is_empty() && params_only_fields.is_empty() { quote! { - RentFreeAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), - RentFreeAccountVariant::#variant_name { data, .. } => Ok(RentFreeAccountVariant::#packed_variant_name { + LightAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), + LightAccountVariant::#variant_name { data, .. } => Ok(LightAccountVariant::#packed_variant_name { data: <#inner_type as light_sdk::compressible::Pack>::pack(data, remaining_accounts)?, }), } } else { quote! { - RentFreeAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), - RentFreeAccountVariant::#variant_name { data, #(#ctx_field_names,)* #(#params_field_names,)* .. } => { + LightAccountVariant::#packed_variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), + LightAccountVariant::#variant_name { data, #(#ctx_field_names,)* #(#params_field_names,)* .. } => { #(#pack_ctx_seeds)* - Ok(RentFreeAccountVariant::#packed_variant_name { + Ok(LightAccountVariant::#packed_variant_name { data: <#inner_type as light_sdk::compressible::Pack>::pack(data, remaining_accounts)?, #(#idx_field_names,)* #(#params_field_names: *#params_field_names,)* @@ -381,7 +393,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }; quote! { - impl light_sdk::compressible::Pack for RentFreeAccountVariant { + impl light_sdk::compressible::Pack for LightAccountVariant { type Packed = Self; fn pack(&self, remaining_accounts: &mut light_sdk::instruction::PackedAccounts) -> std::result::Result { @@ -429,22 +441,22 @@ impl<'a> RentFreeVariantBuilder<'a> { if ctx_fields.is_empty() && params_only_fields.is_empty() { unpack_match_arms.push(quote! { - RentFreeAccountVariant::#packed_variant_name { data, .. } => Ok(RentFreeAccountVariant::#variant_name { + LightAccountVariant::#packed_variant_name { data, .. } => Ok(LightAccountVariant::#variant_name { data: <#packed_inner_type as light_sdk::compressible::Unpack>::unpack(data, remaining_accounts)?, }), - RentFreeAccountVariant::#variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), + LightAccountVariant::#variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), }); } else { unpack_match_arms.push(quote! { - RentFreeAccountVariant::#packed_variant_name { data, #(#idx_field_names,)* #(#params_field_names,)* .. } => { + LightAccountVariant::#packed_variant_name { data, #(#idx_field_names,)* #(#params_field_names,)* .. } => { #(#unpack_ctx_seeds)* - Ok(RentFreeAccountVariant::#variant_name { + Ok(LightAccountVariant::#variant_name { data: <#packed_inner_type as light_sdk::compressible::Unpack>::unpack(data, remaining_accounts)?, #(#ctx_field_names,)* #(#params_field_names: *#params_field_names,)* }) }, - RentFreeAccountVariant::#variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), + LightAccountVariant::#variant_name { .. } => Err(solana_program_error::ProgramError::InvalidAccountData), }); } } @@ -459,7 +471,7 @@ impl<'a> RentFreeVariantBuilder<'a> { }; Ok(quote! { - impl light_sdk::compressible::Unpack for RentFreeAccountVariant { + impl light_sdk::compressible::Unpack for LightAccountVariant { type Unpacked = Self; fn unpack( @@ -475,13 +487,13 @@ impl<'a> RentFreeVariantBuilder<'a> { }) } - /// Generate the RentFreeAccountData struct. - fn generate_rentfree_account_data_struct(&self) -> TokenStream { + /// Generate the LightAccountData struct. + fn generate_light_account_data_struct(&self) -> TokenStream { quote! { #[derive(Clone, Debug, anchor_lang::AnchorDeserialize, anchor_lang::AnchorSerialize)] - pub struct RentFreeAccountData { + pub struct LightAccountData { pub meta: light_sdk::instruction::account_meta::CompressedAccountMetaNoLamportsNoAddress, - pub data: RentFreeAccountVariant, + pub data: LightAccountVariant, } } } @@ -723,9 +735,9 @@ impl<'a> TokenVariantBuilder<'a> { /// Generate the IntoCTokenVariant implementation. fn generate_into_ctoken_variant_impl(&self) -> TokenStream { quote! { - impl light_sdk::compressible::IntoCTokenVariant for TokenAccountVariant { - fn into_ctoken_variant(self, token_data: light_token_sdk::compat::TokenData) -> RentFreeAccountVariant { - RentFreeAccountVariant::CTokenData(light_token_sdk::compat::CTokenData { + impl light_sdk::compressible::IntoCTokenVariant for TokenAccountVariant { + fn into_ctoken_variant(self, token_data: light_token_sdk::compat::TokenData) -> LightAccountVariant { + LightAccountVariant::CTokenData(light_token_sdk::compat::CTokenData { variant: self, token_data, }) diff --git a/sdk-libs/macros/src/rentfree/program/visitors.rs b/sdk-libs/macros/src/light_pdas/program/visitors.rs similarity index 99% rename from sdk-libs/macros/src/rentfree/program/visitors.rs rename to sdk-libs/macros/src/light_pdas/program/visitors.rs index 378a0522dc..6477587f31 100644 --- a/sdk-libs/macros/src/rentfree/program/visitors.rs +++ b/sdk-libs/macros/src/light_pdas/program/visitors.rs @@ -19,7 +19,7 @@ use syn::{ }; use super::instructions::{InstructionDataSpec, SeedElement}; -use crate::rentfree::{account::utils::is_pubkey_type, shared_utils::is_constant_identifier}; +use crate::light_pdas::{account::utils::is_pubkey_type, shared_utils::is_constant_identifier}; /// Visitor that extracts field names matching ctx.field, ctx.accounts.field, or data.field patterns. /// diff --git a/sdk-libs/macros/src/rentfree/shared_utils.rs b/sdk-libs/macros/src/light_pdas/shared_utils.rs similarity index 98% rename from sdk-libs/macros/src/rentfree/shared_utils.rs rename to sdk-libs/macros/src/light_pdas/shared_utils.rs index 91dde17a28..51d629e11a 100644 --- a/sdk-libs/macros/src/rentfree/shared_utils.rs +++ b/sdk-libs/macros/src/light_pdas/shared_utils.rs @@ -85,7 +85,7 @@ pub fn ident_to_type(ident: &Ident) -> Type { /// Wrapper for syn::Expr that implements darling's FromMeta trait. /// /// Enables darling to parse arbitrary expressions in attributes like -/// `#[light_mint(mint_signer = self.authority)]`. +/// `#[light_account(init, mint,mint_signer = self.authority)]`. #[derive(Clone)] pub struct MetaExpr(Expr); diff --git a/sdk-libs/macros/src/rentfree/accounts/mod.rs b/sdk-libs/macros/src/rentfree/accounts/mod.rs deleted file mode 100644 index 8ca7039210..0000000000 --- a/sdk-libs/macros/src/rentfree/accounts/mod.rs +++ /dev/null @@ -1,25 +0,0 @@ -//! Rent-free accounts derive macro implementation. -//! -//! This module provides `#[derive(RentFree)]` which generates: -//! - `LightPreInit` trait implementation for pre-instruction compression setup -//! - `LightFinalize` trait implementation for post-instruction cleanup -//! - Supports rent-free PDAs, rent-free token accounts, and light mints -//! -//! Module structure: -//! - `parse.rs` - Parsing #[rentfree] and #[light_mint] attributes -//! - `pda.rs` - PDA block code generation -//! - `light_mint.rs` - Mint action invocation code generation -//! - `derive.rs` - Orchestration layer that wires everything together - -mod builder; -mod derive; -mod light_mint; -mod parse; -mod pda; - -use proc_macro2::TokenStream; -use syn::DeriveInput; - -pub fn derive_rentfree(input: DeriveInput) -> Result { - derive::derive_rentfree(&input) -} diff --git a/sdk-libs/macros/src/rentfree/accounts/parse.rs b/sdk-libs/macros/src/rentfree/accounts/parse.rs deleted file mode 100644 index df0dd01142..0000000000 --- a/sdk-libs/macros/src/rentfree/accounts/parse.rs +++ /dev/null @@ -1,264 +0,0 @@ -//! Parsing logic for #[rentfree(...)] attributes using darling. - -use darling::FromMeta; -use syn::{ - parse::{Parse, ParseStream}, - punctuated::Punctuated, - DeriveInput, Error, Expr, Ident, Token, Type, -}; - -// Import LightMintField and parsing from light_mint module -use super::light_mint::{parse_light_mint_attr, LightMintField}; -// Import shared types -pub(super) use crate::rentfree::account::seed_extraction::extract_account_inner_type; -use crate::rentfree::shared_utils::MetaExpr; - -// ============================================================================ -// Infrastructure Field Classification -// ============================================================================ - -/// Classification of infrastructure fields by naming convention. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(super) enum InfraFieldType { - FeePayer, - CompressionConfig, - CTokenConfig, - CTokenRentSponsor, - CTokenProgram, - CTokenCpiAuthority, -} - -/// Classifier for infrastructure fields by naming convention. -pub(super) struct InfraFieldClassifier; - -impl InfraFieldClassifier { - /// Classify a field name into its infrastructure type, if any. - #[inline] - pub fn classify(name: &str) -> Option { - match name { - "fee_payer" | "payer" | "creator" => Some(InfraFieldType::FeePayer), - "compression_config" => Some(InfraFieldType::CompressionConfig), - "ctoken_compressible_config" | "ctoken_config" | "light_token_config_account" => { - Some(InfraFieldType::CTokenConfig) - } - "ctoken_rent_sponsor" | "light_token_rent_sponsor" => { - Some(InfraFieldType::CTokenRentSponsor) - } - "ctoken_program" | "light_token_program" => Some(InfraFieldType::CTokenProgram), - "ctoken_cpi_authority" - | "light_token_program_cpi_authority" - | "compress_token_program_cpi_authority" => Some(InfraFieldType::CTokenCpiAuthority), - _ => None, - } - } -} - -/// Collected infrastructure field identifiers. -#[derive(Default)] -pub(super) struct InfraFields { - pub fee_payer: Option, - pub compression_config: Option, - pub ctoken_config: Option, - pub ctoken_rent_sponsor: Option, - pub ctoken_program: Option, - pub ctoken_cpi_authority: Option, -} - -impl InfraFields { - /// Set an infrastructure field by type. - pub fn set(&mut self, field_type: InfraFieldType, ident: Ident) { - match field_type { - InfraFieldType::FeePayer => self.fee_payer = Some(ident), - InfraFieldType::CompressionConfig => self.compression_config = Some(ident), - InfraFieldType::CTokenConfig => self.ctoken_config = Some(ident), - InfraFieldType::CTokenRentSponsor => self.ctoken_rent_sponsor = Some(ident), - InfraFieldType::CTokenProgram => self.ctoken_program = Some(ident), - InfraFieldType::CTokenCpiAuthority => self.ctoken_cpi_authority = Some(ident), - } - } -} - -/// Parsed representation of a struct with rentfree and light_mint fields. -pub(super) struct ParsedRentFreeStruct { - pub struct_name: Ident, - pub generics: syn::Generics, - pub rentfree_fields: Vec, - pub light_mint_fields: Vec, - pub instruction_args: Option>, - /// Infrastructure fields detected by naming convention. - pub infra_fields: InfraFields, -} - -/// A field marked with #[rentfree(...)] -pub(super) struct RentFreeField { - pub ident: Ident, - /// The inner type T from Account<'info, T> or Box> - /// Preserves the full type path (e.g., crate::state::UserRecord). - pub inner_type: Type, - pub address_tree_info: Expr, - pub output_tree: Expr, - /// True if the field is Box>, false if Account - pub is_boxed: bool, -} - -/// Instruction argument from #[instruction(...)] -pub(super) struct InstructionArg { - pub name: Ident, - pub ty: Type, -} - -impl Parse for InstructionArg { - fn parse(input: ParseStream) -> syn::Result { - let name: Ident = input.parse()?; - input.parse::()?; - let ty: Type = input.parse()?; - Ok(Self { name, ty }) - } -} - -fn rentfree_args_default() -> darling::Result { - Ok(RentFreeArgs::default()) -} - -/// Arguments inside #[rentfree(...)] parsed by darling. -/// -/// Supports both `#[rentfree]` (word format) and `#[rentfree(...)]` (list format). -/// All fields default to None if not specified. -#[derive(FromMeta, Default)] -#[darling(default, from_word = rentfree_args_default)] -struct RentFreeArgs { - /// Address tree info expression - address_tree_info: Option, - /// Output tree index expression - output_tree: Option, -} - -/// Parse #[instruction(...)] attribute from struct. -/// -/// Returns `Ok(None)` if no instruction attribute is present, -/// `Ok(Some(args))` if successfully parsed, or `Err` on malformed syntax. -fn parse_instruction_attr(attrs: &[syn::Attribute]) -> Result>, Error> { - for attr in attrs { - if attr.path().is_ident("instruction") { - let args = attr.parse_args_with(|input: ParseStream| { - let content: Punctuated = - Punctuated::parse_terminated(input)?; - Ok(content.into_iter().collect::>()) - })?; - return Ok(Some(args)); - } - } - Ok(None) -} - -/// Parse a struct to extract rentfree and light_mint fields -pub(super) fn parse_rentfree_struct(input: &DeriveInput) -> Result { - let struct_name = input.ident.clone(); - let generics = input.generics.clone(); - - let instruction_args = parse_instruction_attr(&input.attrs)?; - - let fields = match &input.data { - syn::Data::Struct(data) => match &data.fields { - syn::Fields::Named(fields) => &fields.named, - _ => return Err(Error::new_spanned(input, "expected named fields")), - }, - _ => return Err(Error::new_spanned(input, "expected struct")), - }; - - let mut rentfree_fields = Vec::new(); - let mut light_mint_fields = Vec::new(); - let mut infra_fields = InfraFields::default(); - - for field in fields { - let field_ident = field - .ident - .clone() - .ok_or_else(|| Error::new_spanned(field, "expected named field with identifier"))?; - let field_name = field_ident.to_string(); - - // Track infrastructure fields by naming convention using the classifier. - // See InfraFieldClassifier for supported field names. - if let Some(field_type) = InfraFieldClassifier::classify(&field_name) { - infra_fields.set(field_type, field_ident.clone()); - } - - // Track if this field already has a compression attribute - let mut has_compression_attr = false; - - // Check for #[light_mint(...)] attribute first (delegated to light_mint module) - if let Some(mint_field) = parse_light_mint_attr(field, &field_ident)? { - has_compression_attr = true; - light_mint_fields.push(mint_field); - } - - // Look for #[rentfree] or #[rentfree(...)] attribute - for attr in &field.attrs { - if attr.path().is_ident("rentfree") { - // Check for duplicate compression attributes on same field - if has_compression_attr { - return Err(Error::new_spanned( - attr, - "Field already has a compression attribute (#[rentfree] or #[light_mint]). \ - Only one is allowed per field.", - )); - } - - // Use darling to parse the attribute arguments - // Handles both #[rentfree] and #[rentfree(...)] - let args = RentFreeArgs::from_meta(&attr.meta) - .map_err(|e| Error::new_spanned(attr, e.to_string()))?; - - // Use defaults if not specified - let address_tree_info = - args.address_tree_info.map(Into::into).unwrap_or_else(|| { - syn::parse_quote!(params.create_accounts_proof.address_tree_info) - }); - let output_tree = args.output_tree.map(Into::into).unwrap_or_else(|| { - syn::parse_quote!(params.create_accounts_proof.output_state_tree_index) - }); - - // Validate this is an Account type (or Box) - let (is_boxed, inner_type) = - extract_account_inner_type(&field.ty).ok_or_else(|| { - Error::new_spanned( - &field.ty, - "#[rentfree] can only be applied to Account<...> or Box> fields. \ - Nested Box> is not supported.", - ) - })?; - - rentfree_fields.push(RentFreeField { - ident: field_ident.clone(), - inner_type, - address_tree_info, - output_tree, - is_boxed, - }); - break; - } - - // TODO(diff-pr): Add parsing for #[rentfree_token(...)] attribute for token accounts and ATAs. - // Would need RentFreeTokenField struct with: field_ident, authority_seeds, mint field ref. - } - } - - // Validation: #[rentfree] and #[light_mint] require #[instruction] attribute - if (!rentfree_fields.is_empty() || !light_mint_fields.is_empty()) && instruction_args.is_none() - { - return Err(Error::new_spanned( - input, - "#[rentfree] and #[light_mint] fields require #[instruction(params: YourParamsType)] \ - attribute on the struct", - )); - } - - Ok(ParsedRentFreeStruct { - struct_name, - generics, - rentfree_fields, - light_mint_fields, - instruction_args, - infra_fields, - }) -} diff --git a/sdk-libs/sdk/src/compressible/finalize.rs b/sdk-libs/sdk/src/compressible/finalize.rs index 5e24ba2daf..b16767f7cc 100644 --- a/sdk-libs/sdk/src/compressible/finalize.rs +++ b/sdk-libs/sdk/src/compressible/finalize.rs @@ -13,7 +13,7 @@ use solana_account_info::AccountInfo; /// Trait for pre-initialization operations (mint creation). /// -/// This is generated by `#[derive(LightFinalize)]` when `#[light_mint]` fields exist. +/// This is generated by `#[derive(LightFinalize)]` when `#[light_account(init)]` fields exist. /// Called at the START of an instruction to write mint creation to CPI context. /// /// The mints are written to CPI context but NOT executed yet - execution happens diff --git a/sdk-libs/token-sdk/src/token/decompress_mint.rs b/sdk-libs/token-sdk/src/token/decompress_mint.rs index fb9e688d64..6ef3da3fea 100644 --- a/sdk-libs/token-sdk/src/token/decompress_mint.rs +++ b/sdk-libs/token-sdk/src/token/decompress_mint.rs @@ -338,9 +338,9 @@ pub struct DecompressCMintCpiWithContext<'info> { pub cpi_context_account: AccountInfo<'info>, /// System accounts for Light Protocol pub system_accounts: SystemAccountInfos<'info>, - /// CToken program's CPI authority (GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy) + /// Light token program's CPI authority (GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy) /// This is separate from system_accounts.cpi_authority_pda which is the calling program's authority - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, /// Compressed mint with context (from indexer) pub compressed_mint_with_context: MintWithContext, /// Validity proof for the compressed mint @@ -396,7 +396,7 @@ impl<'info> DecompressCMintCpiWithContext<'info> { self.rent_sponsor.clone(), self.payer.clone(), // 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(), self.system_accounts.registered_program_pda.clone(), self.system_accounts.account_compression_authority.clone(), self.system_accounts.account_compression_program.clone(), diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs index 2af4b45b79..1d0170f104 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs @@ -1,9 +1,9 @@ -//! Initialize instruction with all rentfree markers. +//! Initialize instruction with all light account markers. //! //! Tests: -//! - 2x #[rentfree] (pool_state, observation_state) -//! - 2x #[rentfree_token(authority = [...])] (token_0_vault, token_1_vault) -//! - 1x #[light_mint(...)] (lp_mint) +//! - 2x #[light_account(init)] (pool_state, observation_state) +//! - 2x #[light_account(token, authority = [...])] (token_0_vault, token_1_vault) +//! - 1x #[light_account(init, mint,...)] (lp_mint) //! - CreateTokenAccountCpi.rent_free() //! - CreateTokenAtaCpi.rent_free() //! - MintToCpi @@ -11,10 +11,10 @@ use anchor_lang::prelude::*; use anchor_spl::token_interface::{Mint, TokenAccount, TokenInterface}; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use light_token_sdk::token::{ CreateTokenAccountCpi, CreateTokenAtaCpi, MintToCpi, COMPRESSIBLE_CONFIG_V1, - RENT_SPONSOR as CTOKEN_RENT_SPONSOR, + RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR, }; use super::states::*; @@ -30,7 +30,7 @@ pub struct InitializeParams { pub authority_bump: u8, } -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: InitializeParams)] pub struct InitializePool<'info> { #[account(mut)] @@ -58,7 +58,7 @@ pub struct InitializePool<'info> { payer = creator, space = 8 + PoolState::INIT_SPACE )] - #[rentfree] + #[light_account(init)] pub pool_state: Box>, #[account( @@ -77,7 +77,7 @@ pub struct InitializePool<'info> { pub lp_mint_signer: UncheckedAccount<'info>, // TODO: check where the cpi gets the seeds from #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = lp_mint_signer, authority = authority, decimals = 9, @@ -112,7 +112,7 @@ pub struct InitializePool<'info> { ], bump, )] - #[rentfree_token(authority = [AUTH_SEED.as_bytes()])] + #[light_account(token, authority = [AUTH_SEED.as_bytes()])] pub token_0_vault: UncheckedAccount<'info>, #[account( @@ -124,7 +124,7 @@ pub struct InitializePool<'info> { ], bump, )] - #[rentfree_token(authority = [AUTH_SEED.as_bytes()])] + #[light_account(token, authority = [AUTH_SEED.as_bytes()])] pub token_1_vault: UncheckedAccount<'info>, #[account( @@ -134,7 +134,7 @@ pub struct InitializePool<'info> { payer = creator, space = 8 + ObservationState::INIT_SPACE )] - #[rentfree] + #[light_account(init)] pub observation_state: Box>, pub token_program: Interface<'info, TokenInterface>, @@ -148,15 +148,15 @@ pub struct InitializePool<'info> { pub compression_config: AccountInfo<'info>, #[account(address = COMPRESSIBLE_CONFIG_V1)] - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, - #[account(mut, address = CTOKEN_RENT_SPONSOR)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + #[account(mut, address = LIGHT_TOKEN_RENT_SPONSOR)] + pub rent_sponsor: AccountInfo<'info>, pub light_token_program: AccountInfo<'info>, /// CHECK: CToken CPI authority. - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, } /// Initialize instruction handler (noop for compilation test). @@ -174,8 +174,10 @@ pub fn process_initialize_pool<'info>( owner: ctx.accounts.authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) @@ -194,8 +196,10 @@ pub fn process_initialize_pool<'info>( owner: ctx.accounts.authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) @@ -216,8 +220,10 @@ pub fn process_initialize_pool<'info>( } .idempotent() .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), ) .invoke()?; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/mod.rs index a8a3ff5b5d..b87fb7ec5c 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/mod.rs @@ -1,9 +1,9 @@ //! AMM test cases based on cp-swap-reference patterns. //! //! Tests: -//! - Multiple #[rentfree] fields -//! - #[rentfree_token] with authority seeds -//! - #[light_mint] for LP token creation +//! - Multiple #[light_account(init)] fields +//! - #[light_account(token)] with authority seeds +//! - #[light_account(init)] for LP token creation //! - CreateTokenAccountCpi.rent_free() //! - CreateTokenAtaCpi.rent_free() //! - MintToCpi / BurnCpi diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/states.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/states.rs index bcae3c176f..13e7579e80 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/states.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/states.rs @@ -2,7 +2,7 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; pub const POOL_SEED: &str = "pool"; pub const POOL_VAULT_SEED: &str = "pool_vault"; @@ -10,7 +10,7 @@ pub const OBSERVATION_SEED: &str = "observation"; pub const POOL_LP_MINT_SIGNER_SEED: &[u8] = b"pool_lp_mint"; pub const AUTH_SEED: &str = "vault_and_lp_mint_auth_seed"; -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] #[repr(C)] pub struct PoolState { @@ -49,7 +49,7 @@ pub struct Observation { pub cumulative_token_1_price_x32: u128, } -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct ObservationState { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs index a486eae760..f9194936a0 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs @@ -1,6 +1,6 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::*; @@ -21,7 +21,7 @@ pub const LP_MINT_SIGNER_SEED: &[u8] = b"lp_mint_signer"; pub const AUTO_VAULT_SEED: &[u8] = b"auto_vault"; pub const AUTO_VAULT_AUTHORITY_SEED: &[u8] = b"auto_vault_authority"; -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: FullAutoWithMintParams)] pub struct CreatePdasAndMintAuto<'info> { #[account(mut)] @@ -52,7 +52,7 @@ pub struct CreatePdasAndMintAuto<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub user_record: Account<'info, UserRecord>, #[account( @@ -66,12 +66,12 @@ pub struct CreatePdasAndMintAuto<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub game_session: Account<'info, GameSession>, /// CHECK: Initialized by mint_action #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = mint_authority, decimals = 9, @@ -85,7 +85,7 @@ pub struct CreatePdasAndMintAuto<'info> { seeds = [VAULT_SEED, cmint.key().as_ref()], bump, )] - #[rentfree_token(authority = [b"vault_authority"])] + #[light_account(token, authority = [b"vault_authority"])] pub vault: UncheckedAccount<'info>, /// CHECK: PDA used as vault owner @@ -100,17 +100,17 @@ pub struct CreatePdasAndMintAuto<'info> { pub compression_config: AccountInfo<'info>, /// CHECK: CToken config - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, /// CHECK: CToken rent sponsor #[account(mut)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + pub rent_sponsor: AccountInfo<'info>, /// CHECK: CToken program pub light_token_program: AccountInfo<'info>, /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } @@ -131,8 +131,8 @@ pub struct CreateTwoMintsParams { pub mint_signer_b_bump: u8, } -/// Test instruction with 2 #[light_mint] fields to verify multi-mint support. -#[derive(Accounts, RentFree)] +/// Test instruction with 2 #[light_account(init)] fields to verify multi-mint support. +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateTwoMintsParams)] pub struct CreateTwoMints<'info> { #[account(mut)] @@ -156,7 +156,7 @@ pub struct CreateTwoMints<'info> { /// CHECK: Initialized by mint_action - first mint #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer_a, authority = fee_payer, decimals = 6, @@ -166,7 +166,7 @@ pub struct CreateTwoMints<'info> { /// CHECK: Initialized by mint_action - second mint #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer_b, authority = fee_payer, decimals = 9, @@ -178,17 +178,17 @@ pub struct CreateTwoMints<'info> { pub compression_config: AccountInfo<'info>, /// CHECK: CToken config - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, /// CHECK: CToken rent sponsor #[account(mut)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + pub rent_sponsor: AccountInfo<'info>, /// CHECK: CToken program pub light_token_program: AccountInfo<'info>, /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } @@ -207,8 +207,8 @@ pub struct CreateThreeMintsParams { pub mint_signer_c_bump: u8, } -/// Test instruction with 3 #[light_mint] fields to verify multi-mint support. -#[derive(Accounts, RentFree)] +/// Test instruction with 3 #[light_account(init)] fields to verify multi-mint support. +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateThreeMintsParams)] pub struct CreateThreeMints<'info> { #[account(mut)] @@ -239,7 +239,7 @@ pub struct CreateThreeMints<'info> { /// CHECK: Initialized by light_mint CPI #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer_a, authority = fee_payer, decimals = 6, @@ -249,7 +249,7 @@ pub struct CreateThreeMints<'info> { /// CHECK: Initialized by light_mint CPI #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer_b, authority = fee_payer, decimals = 8, @@ -259,7 +259,7 @@ pub struct CreateThreeMints<'info> { /// CHECK: Initialized by light_mint CPI #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer_c, authority = fee_payer, decimals = 9, @@ -271,17 +271,17 @@ pub struct CreateThreeMints<'info> { pub compression_config: AccountInfo<'info>, /// CHECK: CToken config - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, /// CHECK: CToken rent sponsor #[account(mut)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + pub rent_sponsor: AccountInfo<'info>, /// CHECK: CToken program pub light_token_program: AccountInfo<'info>, /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } @@ -302,9 +302,9 @@ pub struct CreateMintWithMetadataParams { pub additional_metadata: Option>, } -/// Test instruction with #[light_mint] with metadata fields. +/// Test instruction with #[light_account(init)] with metadata fields. /// Tests the metadata support in the RentFree macro. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: CreateMintWithMetadataParams)] pub struct CreateMintWithMetadata<'info> { #[account(mut)] @@ -321,7 +321,7 @@ pub struct CreateMintWithMetadata<'info> { /// CHECK: Initialized by light_mint CPI with metadata #[account(mut)] - #[light_mint( + #[light_account(init, mint, mint_signer = mint_signer, authority = fee_payer, decimals = 9, @@ -338,17 +338,17 @@ pub struct CreateMintWithMetadata<'info> { pub compression_config: AccountInfo<'info>, /// CHECK: CToken config - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, /// CHECK: CToken rent sponsor #[account(mut)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + pub rent_sponsor: AccountInfo<'info>, /// CHECK: CToken program pub light_token_program: AccountInfo<'info>, /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs index 274bd23148..2655c33abc 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/all.rs @@ -1,12 +1,12 @@ //! D5 Test: All marker types combined //! -//! Tests #[rentfree] + #[rentfree_token] together in one instruction struct. -//! Note: #[light_mint] is tested separately in amm_test/initialize.rs. +//! Tests #[light_account(init)] + #[light_account(token)] together in one instruction struct. +//! Note: #[light_account(init)] is tested separately in amm_test/initialize.rs. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; +use light_sdk_macros::LightAccounts; +use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -20,9 +20,9 @@ pub struct D5AllMarkersParams { } /// Tests all marker types in one struct: -/// - #[rentfree] for PDA account -/// - #[rentfree_token] for token vault -#[derive(Accounts, RentFree)] +/// - #[light_account(init)] for PDA account +/// - #[light_account(token)] for token vault +#[derive(Accounts, LightAccounts)] #[instruction(params: D5AllMarkersParams)] pub struct D5AllMarkers<'info> { #[account(mut)] @@ -47,7 +47,7 @@ pub struct D5AllMarkers<'info> { seeds = [b"d5_all_record", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d5_all_record: Account<'info, SinglePubkeyRecord>, #[account( @@ -55,20 +55,20 @@ pub struct D5AllMarkers<'info> { seeds = [D5_ALL_VAULT_SEED, mint.key().as_ref()], bump, )] - #[rentfree_token(authority = [D5_ALL_AUTH_SEED])] + #[light_account(token, authority = [D5_ALL_AUTH_SEED])] pub d5_all_vault: UncheckedAccount<'info>, #[account(address = COMPRESSIBLE_CONFIG_V1)] - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, - #[account(mut, address = CTOKEN_RENT_SPONSOR)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + #[account(mut, address = LIGHT_TOKEN_RENT_SPONSOR)] + pub light_token_rent_sponsor: AccountInfo<'info>, - /// CHECK: CToken program + /// CHECK: Light token program pub light_token_program: AccountInfo<'info>, - /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + /// CHECK: Light token CPI authority + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_token.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs similarity index 54% rename from sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_token.rs rename to sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs index 34c35968f7..04cf0180ef 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_token.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/light_token.rs @@ -1,26 +1,26 @@ -//! D5 Test: #[rentfree_token] attribute with authority seeds +//! D5 Test: #[light_account(token)] attribute with authority seeds //! -//! Tests that the #[rentfree_token(authority = [...])] attribute works correctly +//! Tests that the #[light_account(token, authority = [...])] attribute works correctly //! for token accounts that need custom authority derivation. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; +use light_sdk_macros::LightAccounts; +use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; pub const D5_VAULT_AUTH_SEED: &[u8] = b"d5_vault_auth"; pub const D5_VAULT_SEED: &[u8] = b"d5_vault"; #[derive(AnchorSerialize, AnchorDeserialize, Clone)] -pub struct D5RentfreeTokenParams { +pub struct D5LightTokenParams { pub create_accounts_proof: CreateAccountsProof, pub vault_bump: u8, } -/// Tests #[rentfree_token(authority = [...])] attribute compilation. -#[derive(Accounts, RentFree)] -#[instruction(params: D5RentfreeTokenParams)] -pub struct D5RentfreeToken<'info> { +/// Tests #[light_account(token, authority = [...])] attribute compilation. +#[derive(Accounts, LightAccounts)] +#[instruction(params: D5LightTokenParams)] +pub struct D5LightToken<'info> { #[account(mut)] pub fee_payer: Signer<'info>, @@ -38,20 +38,20 @@ pub struct D5RentfreeToken<'info> { seeds = [D5_VAULT_SEED, mint.key().as_ref()], bump, )] - #[rentfree_token(authority = [D5_VAULT_AUTH_SEED])] + #[light_account(token, authority = [D5_VAULT_AUTH_SEED])] pub d5_token_vault: UncheckedAccount<'info>, #[account(address = COMPRESSIBLE_CONFIG_V1)] - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, - #[account(mut, address = CTOKEN_RENT_SPONSOR)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + #[account(mut, address = LIGHT_TOKEN_RENT_SPONSOR)] + pub light_token_rent_sponsor: AccountInfo<'info>, - /// CHECK: CToken program + /// CHECK: Light token program pub light_token_program: AccountInfo<'info>, - /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + /// CHECK: Light token CPI authority + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/mod.rs index 3229d39f5e..d170c11e8e 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/mod.rs @@ -1,12 +1,12 @@ //! D5: Field marker attributes //! -//! Tests #[rentfree], #[rentfree_token], and #[light_mint] attribute parsing. +//! Tests #[light_account(init)], #[light_account(token)], and #[light_account(init)] attribute parsing. mod all; +mod light_token; mod rentfree_bare; -mod rentfree_token; // Note: rentfree_custom is a failing test case due to pre-existing AddressTreeInfo bug. pub use all::*; +pub use light_token::*; pub use rentfree_bare::*; -pub use rentfree_token::*; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_bare.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_bare.rs index 1bfe5b4da3..732e9f1a25 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_bare.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d5_markers/rentfree_bare.rs @@ -1,14 +1,14 @@ -//! D5 Test: #[rentfree] attribute with #[rentfree_program] macro +//! D5 Test: #[light_account(init)] attribute with #[light_program] macro //! -//! Tests that the #[rentfree] attribute works correctly when used with the -//! #[rentfree_program] macro on instruction structs in submodules. +//! Tests that the #[light_account(init)] attribute works correctly when used with the +//! #[light_program] macro on instruction structs in submodules. //! //! Note: The params struct must contain `create_accounts_proof: CreateAccountsProof` //! because the RentFree derive macro generates code that accesses this field. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -18,10 +18,10 @@ pub struct D5RentfreeBareParams { pub owner: Pubkey, } -/// Tests that #[rentfree] attribute compiles with the #[rentfree_program] macro. +/// Tests that #[light_account(init)] attribute compiles with the #[light_program] macro. /// The field name can now differ from the type name (e.g., `record` with type `SinglePubkeyRecord`) /// because the macro now uses the inner_type for seed spec correlation. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D5RentfreeBareParams)] pub struct D5RentfreeBare<'info> { #[account(mut)] @@ -37,7 +37,7 @@ pub struct D5RentfreeBare<'info> { seeds = [b"d5_bare", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/account.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/account.rs index ff5d00a3d0..75ba46ea75 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/account.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/account.rs @@ -1,10 +1,10 @@ //! D6 Test: Direct Account<'info, T> type //! -//! Tests that #[rentfree] works with Account<'info, T> directly (not boxed). +//! Tests that #[light_account(init)] works with Account<'info, T> directly (not boxed). use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -14,8 +14,8 @@ pub struct D6AccountParams { pub owner: Pubkey, } -/// Tests #[rentfree] with direct Account<'info, T> type. -#[derive(Accounts, RentFree)] +/// Tests #[light_account(init)] with direct Account<'info, T> type. +#[derive(Accounts, LightAccounts)] #[instruction(params: D6AccountParams)] pub struct D6Account<'info> { #[account(mut)] @@ -31,7 +31,7 @@ pub struct D6Account<'info> { seeds = [b"d6_account", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d6_account_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/all.rs index ea2be23ff1..5c3181c6f8 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/all.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::{ d1_field_types::single_pubkey::SinglePubkeyRecord, @@ -20,7 +20,7 @@ pub struct D6AllParams { /// Tests both account types in one struct: /// - Account<'info, T> (direct) /// - Box> (boxed) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D6AllParams)] pub struct D6All<'info> { #[account(mut)] @@ -36,7 +36,7 @@ pub struct D6All<'info> { seeds = [b"d6_all_direct", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d6_all_direct: Account<'info, SinglePubkeyRecord>, #[account( @@ -46,7 +46,7 @@ pub struct D6All<'info> { seeds = [b"d6_all_boxed", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d6_all_boxed: Box>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/boxed.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/boxed.rs index 90e8f6ba2a..52721559df 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/boxed.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d6_account_types/boxed.rs @@ -1,11 +1,11 @@ //! D6 Test: Box> type //! -//! Tests that #[rentfree] works with Box> (boxed account). +//! Tests that #[light_account(init)] works with Box> (boxed account). //! This exercises the Box unwrap path in seed_extraction.rs with is_boxed = true. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -15,8 +15,8 @@ pub struct D6BoxedParams { pub owner: Pubkey, } -/// Tests #[rentfree] with Box> type. -#[derive(Accounts, RentFree)] +/// Tests #[light_account(init)] with Box> type. +#[derive(Accounts, LightAccounts)] #[instruction(params: D6BoxedParams)] pub struct D6Boxed<'info> { #[account(mut)] @@ -32,7 +32,7 @@ pub struct D6Boxed<'info> { seeds = [b"d6_boxed", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d6_boxed_record: Box>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs index 9c6038e80d..201349126f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/all.rs @@ -4,8 +4,8 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; +use light_sdk_macros::LightAccounts; +use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -20,9 +20,9 @@ pub struct D7AllNamesParams { /// Tests multiple naming variants: /// - `payer` as the fee payer field -/// - `ctoken_compressible_config` for config -/// - `ctoken_rent_sponsor` for rent sponsor -#[derive(Accounts, RentFree)] +/// - `light_token_compressible_config` for config +/// - `rent_sponsor` for rent sponsor (short form) +#[derive(Accounts, LightAccounts)] #[instruction(params: D7AllNamesParams)] pub struct D7AllNames<'info> { #[account(mut)] @@ -47,7 +47,7 @@ pub struct D7AllNames<'info> { seeds = [b"d7_all_record", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d7_all_record: Account<'info, SinglePubkeyRecord>, #[account( @@ -55,20 +55,20 @@ pub struct D7AllNames<'info> { seeds = [D7_ALL_VAULT_SEED, mint.key().as_ref()], bump, )] - #[rentfree_token(authority = [D7_ALL_AUTH_SEED])] + #[light_account(token, authority = [D7_ALL_AUTH_SEED])] pub d7_all_vault: UncheckedAccount<'info>, #[account(address = COMPRESSIBLE_CONFIG_V1)] - pub ctoken_compressible_config: AccountInfo<'info>, + pub light_token_compressible_config: AccountInfo<'info>, - #[account(mut, address = CTOKEN_RENT_SPONSOR)] - pub ctoken_rent_sponsor: AccountInfo<'info>, + #[account(mut, address = LIGHT_TOKEN_RENT_SPONSOR)] + pub rent_sponsor: AccountInfo<'info>, - /// CHECK: CToken program + /// CHECK: Light token program pub light_token_program: AccountInfo<'info>, - /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, + /// CHECK: Light token CPI authority + pub light_token_cpi_authority: AccountInfo<'info>, pub system_program: Program<'info, System>, } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/creator.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/creator.rs index 3dbfb1492b..f86bd5e1b8 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/creator.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/creator.rs @@ -1,10 +1,10 @@ //! D7 Test: "creator" field name variant //! -//! Tests that #[rentfree] works when the payer field is named `creator` instead of `fee_payer`. +//! Tests that #[light_account(init)] works when the payer field is named `creator` instead of `fee_payer`. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -14,8 +14,8 @@ pub struct D7CreatorParams { pub owner: Pubkey, } -/// Tests #[rentfree] with `creator` field name (InfraFieldClassifier FeePayer variant). -#[derive(Accounts, RentFree)] +/// Tests #[light_account(init)] with `creator` field name (InfraFieldClassifier FeePayer variant). +#[derive(Accounts, LightAccounts)] #[instruction(params: D7CreatorParams)] pub struct D7Creator<'info> { #[account(mut)] @@ -31,7 +31,7 @@ pub struct D7Creator<'info> { seeds = [b"d7_creator", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d7_creator_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/ctoken_config.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/ctoken_config.rs deleted file mode 100644 index b4c8a6dac1..0000000000 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/ctoken_config.rs +++ /dev/null @@ -1,55 +0,0 @@ -//! D7 Test: "ctoken_config" naming variant -//! -//! Tests that #[rentfree_token] works with alternative naming for ctoken infrastructure fields. - -use anchor_lang::prelude::*; -use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; -use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; - -pub const D7_CTOKEN_AUTH_SEED: &[u8] = b"d7_ctoken_auth"; -pub const D7_CTOKEN_VAULT_SEED: &[u8] = b"d7_ctoken_vault"; - -#[derive(AnchorSerialize, AnchorDeserialize, Clone)] -pub struct D7CtokenConfigParams { - pub create_accounts_proof: CreateAccountsProof, -} - -/// Tests #[rentfree_token] with `ctoken_compressible_config` and `ctoken_rent_sponsor` field names. -#[derive(Accounts, RentFree)] -#[instruction(params: D7CtokenConfigParams)] -pub struct D7CtokenConfig<'info> { - #[account(mut)] - pub fee_payer: Signer<'info>, - - /// CHECK: Token mint - pub mint: AccountInfo<'info>, - - #[account( - seeds = [D7_CTOKEN_AUTH_SEED], - bump, - )] - pub d7_ctoken_authority: UncheckedAccount<'info>, - - #[account( - mut, - seeds = [D7_CTOKEN_VAULT_SEED, mint.key().as_ref()], - bump, - )] - #[rentfree_token(authority = [D7_CTOKEN_AUTH_SEED])] - pub d7_ctoken_vault: UncheckedAccount<'info>, - - #[account(address = COMPRESSIBLE_CONFIG_V1)] - pub ctoken_compressible_config: AccountInfo<'info>, - - #[account(mut, address = CTOKEN_RENT_SPONSOR)] - pub ctoken_rent_sponsor: AccountInfo<'info>, - - /// CHECK: CToken program - pub light_token_program: AccountInfo<'info>, - - /// CHECK: CToken CPI authority - pub ctoken_cpi_authority: AccountInfo<'info>, - - pub system_program: Program<'info, System>, -} diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs new file mode 100644 index 0000000000..d88283732d --- /dev/null +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/light_token_config.rs @@ -0,0 +1,55 @@ +//! D7 Test: light_token naming variant +//! +//! Tests that #[light_account(token)] works with light_token infrastructure fields. + +use anchor_lang::prelude::*; +use light_compressible::CreateAccountsProof; +use light_sdk_macros::LightAccounts; +use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR}; + +pub const D7_LIGHT_TOKEN_AUTH_SEED: &[u8] = b"d7_light_token_auth"; +pub const D7_LIGHT_TOKEN_VAULT_SEED: &[u8] = b"d7_light_token_vault"; + +#[derive(AnchorSerialize, AnchorDeserialize, Clone)] +pub struct D7LightTokenConfigParams { + pub create_accounts_proof: CreateAccountsProof, +} + +/// Tests #[light_account(token)] with `light_token_compressible_config` and `light_token_rent_sponsor` field names. +#[derive(Accounts, LightAccounts)] +#[instruction(params: D7LightTokenConfigParams)] +pub struct D7LightTokenConfig<'info> { + #[account(mut)] + pub fee_payer: Signer<'info>, + + /// CHECK: Token mint + pub mint: AccountInfo<'info>, + + #[account( + seeds = [D7_LIGHT_TOKEN_AUTH_SEED], + bump, + )] + pub d7_light_token_authority: UncheckedAccount<'info>, + + #[account( + mut, + seeds = [D7_LIGHT_TOKEN_VAULT_SEED, mint.key().as_ref()], + bump, + )] + #[light_account(token, authority = [D7_LIGHT_TOKEN_AUTH_SEED])] + pub d7_light_token_vault: UncheckedAccount<'info>, + + #[account(address = COMPRESSIBLE_CONFIG_V1)] + pub light_token_compressible_config: AccountInfo<'info>, + + #[account(mut, address = LIGHT_TOKEN_RENT_SPONSOR)] + pub light_token_rent_sponsor: AccountInfo<'info>, + + /// CHECK: Light token program + pub light_token_program: AccountInfo<'info>, + + /// CHECK: Light token CPI authority + pub light_token_cpi_authority: AccountInfo<'info>, + + pub system_program: Program<'info, System>, +} diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/mod.rs index bc8e7d2259..a680d87435 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/mod.rs @@ -3,14 +3,14 @@ //! Tests macro handling of different field naming conventions: //! - payer instead of fee_payer //! - creator instead of fee_payer -//! - ctoken_config variants +//! - light_token_config variants mod all; mod creator; -mod ctoken_config; +mod light_token_config; mod payer; pub use all::*; pub use creator::*; -pub use ctoken_config::*; +pub use light_token_config::*; pub use payer::*; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/payer.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/payer.rs index 721fd489a7..88c43c3315 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/payer.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d7_infra_names/payer.rs @@ -1,10 +1,10 @@ //! D7 Test: "payer" field name variant //! -//! Tests that #[rentfree] works when the payer field is named `payer` instead of `fee_payer`. +//! Tests that #[light_account(init)] works when the payer field is named `payer` instead of `fee_payer`. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -14,8 +14,8 @@ pub struct D7PayerParams { pub owner: Pubkey, } -/// Tests #[rentfree] with `payer` field name (InfraFieldClassifier FeePayer variant). -#[derive(Accounts, RentFree)] +/// Tests #[light_account(init)] with `payer` field name (InfraFieldClassifier FeePayer variant). +#[derive(Accounts, LightAccounts)] #[instruction(params: D7PayerParams)] pub struct D7Payer<'info> { #[account(mut)] @@ -31,7 +31,7 @@ pub struct D7Payer<'info> { seeds = [b"d7_payer", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d7_payer_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/all.rs index 1bbdf87791..8eda4f81bf 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/all.rs @@ -1,10 +1,10 @@ -//! D8 Test: Multiple #[rentfree] fields with different state types +//! D8 Test: Multiple #[light_account(init)] fields with different state types //! -//! Tests the builder path with multiple #[rentfree] fields of different state types. +//! Tests the builder path with multiple #[light_account(init)] fields of different state types. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::{ d1_field_types::single_pubkey::SinglePubkeyRecord, @@ -17,8 +17,8 @@ pub struct D8AllParams { pub owner: Pubkey, } -/// Tests builder path with multiple #[rentfree] fields of different state types. -#[derive(Accounts, RentFree)] +/// Tests builder path with multiple #[light_account(init)] fields of different state types. +#[derive(Accounts, LightAccounts)] #[instruction(params: D8AllParams)] pub struct D8All<'info> { #[account(mut)] @@ -34,7 +34,7 @@ pub struct D8All<'info> { seeds = [b"d8_all_single", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d8_all_single: Account<'info, SinglePubkeyRecord>, #[account( @@ -44,7 +44,7 @@ pub struct D8All<'info> { seeds = [b"d8_all_multi", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d8_all_multi: Box>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/mod.rs index b9639ba8c4..b9eb73bb43 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/mod.rs @@ -1,9 +1,9 @@ //! D8: Builder code generation paths //! //! Tests different builder code generation scenarios: -//! - pda_only: Only #[rentfree] fields (no tokens) -//! - multi_rentfree: Multiple #[rentfree] fields -//! - all: Multiple #[rentfree] fields with different state types +//! - pda_only: Only #[light_account(init)] fields (no tokens) +//! - multi_rentfree: Multiple #[light_account(init)] fields +//! - all: Multiple #[light_account(init)] fields with different state types mod all; mod multi_rentfree; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/multi_rentfree.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/multi_rentfree.rs index bf4760215a..1d861f659f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/multi_rentfree.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/multi_rentfree.rs @@ -1,10 +1,10 @@ -//! D8 Test: Multiple #[rentfree] fields +//! D8 Test: Multiple #[light_account(init)] fields //! -//! Tests the builder path with multiple #[rentfree] PDA accounts of the same type. +//! Tests the builder path with multiple #[light_account(init)] PDA accounts of the same type. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -16,8 +16,8 @@ pub struct D8MultiRentfreeParams { pub id2: u64, } -/// Tests builder path with multiple #[rentfree] fields of the same type. -#[derive(Accounts, RentFree)] +/// Tests builder path with multiple #[light_account(init)] fields of the same type. +#[derive(Accounts, LightAccounts)] #[instruction(params: D8MultiRentfreeParams)] pub struct D8MultiRentfree<'info> { #[account(mut)] @@ -33,7 +33,7 @@ pub struct D8MultiRentfree<'info> { seeds = [b"d8_multi_1", params.owner.as_ref(), params.id1.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d8_multi_record1: Account<'info, SinglePubkeyRecord>, #[account( @@ -43,7 +43,7 @@ pub struct D8MultiRentfree<'info> { seeds = [b"d8_multi_2", params.owner.as_ref(), params.id2.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d8_multi_record2: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/pda_only.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/pda_only.rs index 1db85edcca..9dc29e9c8a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/pda_only.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d8_builder_paths/pda_only.rs @@ -1,11 +1,11 @@ -//! D8 Test: Only #[rentfree] fields (no token accounts) +//! D8 Test: Only #[light_account(init)] fields (no token accounts) //! //! Tests the `generate_pre_init_pdas_only` code path where only PDA accounts -//! are marked with #[rentfree], without any token accounts. +//! are marked with #[light_account(init)], without any token accounts. use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -16,7 +16,7 @@ pub struct D8PdaOnlyParams { } /// Tests builder path with only PDA accounts (no token accounts). -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D8PdaOnlyParams)] pub struct D8PdaOnly<'info> { #[account(mut)] @@ -32,7 +32,7 @@ pub struct D8PdaOnly<'info> { seeds = [b"d8_pda_only", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d8_pda_only_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/all.rs index f0294d6cda..f23c228d94 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/all.rs @@ -10,7 +10,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -26,7 +26,7 @@ pub struct D9AllParams { } /// Tests all 6 seed types in one struct. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9AllParams)] pub struct D9All<'info> { #[account(mut)] @@ -46,7 +46,7 @@ pub struct D9All<'info> { seeds = [b"d9_all_lit"], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_lit: Account<'info, SinglePubkeyRecord>, // Test 2: Constant @@ -57,7 +57,7 @@ pub struct D9All<'info> { seeds = [D9_ALL_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_const: Account<'info, SinglePubkeyRecord>, // Test 3: CtxAccount @@ -68,7 +68,7 @@ pub struct D9All<'info> { seeds = [b"d9_all_ctx", authority.key().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_ctx: Account<'info, SinglePubkeyRecord>, // Test 4: DataField (param Pubkey) @@ -79,7 +79,7 @@ pub struct D9All<'info> { seeds = [b"d9_all_param", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_param: Account<'info, SinglePubkeyRecord>, // Test 5: DataField (bytes conversion) @@ -90,7 +90,7 @@ pub struct D9All<'info> { seeds = [b"d9_all_bytes", params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_bytes: Account<'info, SinglePubkeyRecord>, // Test 6: FunctionCall @@ -101,7 +101,7 @@ pub struct D9All<'info> { seeds = [b"d9_all_func", crate::max_key(¶ms.key_a, ¶ms.key_b).as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_all_func: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/array_bumps.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/array_bumps.rs index f8f599b9b1..4cf0c9880e 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/array_bumps.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/array_bumps.rs @@ -6,7 +6,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -26,7 +26,7 @@ pub struct D9BumpLiteralParams { } /// Tests literal seed with bump attribute -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpLiteralParams)] pub struct D9BumpLiteral<'info> { #[account(mut)] @@ -42,7 +42,7 @@ pub struct D9BumpLiteral<'info> { seeds = [b"d9_bump_lit"], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -58,7 +58,7 @@ pub struct D9BumpConstantParams { } /// Tests constant seed with bump attribute -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpConstantParams)] pub struct D9BumpConstant<'info> { #[account(mut)] @@ -74,7 +74,7 @@ pub struct D9BumpConstant<'info> { seeds = [D9_BUMP_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -90,7 +90,7 @@ pub struct D9BumpQualifiedParams { } /// Tests crate::path::CONST.as_bytes() with bump - the pattern that caused type inference issues -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpQualifiedParams)] pub struct D9BumpQualified<'info> { #[account(mut)] @@ -106,7 +106,7 @@ pub struct D9BumpQualified<'info> { seeds = [crate::instructions::d9_seeds::array_bumps::D9_BUMP_STR.as_bytes()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -123,7 +123,7 @@ pub struct D9BumpParamParams { } /// Tests params.owner.as_ref() with bump -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpParamParams)] pub struct D9BumpParam<'info> { #[account(mut)] @@ -139,7 +139,7 @@ pub struct D9BumpParam<'info> { seeds = [b"d9_bump_param", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -155,7 +155,7 @@ pub struct D9BumpCtxParams { } /// Tests account.key().as_ref() with bump -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpCtxParams)] pub struct D9BumpCtx<'info> { #[account(mut)] @@ -174,7 +174,7 @@ pub struct D9BumpCtx<'info> { seeds = [b"d9_bump_ctx", authority.key().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -192,7 +192,7 @@ pub struct D9BumpMixedParams { } /// Tests literal + constant + param + bytes with bump -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9BumpMixedParams)] pub struct D9BumpMixed<'info> { #[account(mut)] @@ -208,7 +208,7 @@ pub struct D9BumpMixed<'info> { seeds = [b"d9_bump_mix", D9_BUMP_SEED, params.owner.as_ref(), params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/complex_mixed.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/complex_mixed.rs index 800b6b32c1..ef9273b081 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/complex_mixed.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/complex_mixed.rs @@ -7,7 +7,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -27,7 +27,7 @@ pub struct D9ComplexThreeParams { } /// Tests 3 seeds: literal + constant + param.as_ref() -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexThreeParams)] pub struct D9ComplexThree<'info> { #[account(mut)] @@ -43,7 +43,7 @@ pub struct D9ComplexThree<'info> { seeds = [b"d9_complex3", D9_COMPLEX_PREFIX, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -61,7 +61,7 @@ pub struct D9ComplexFourParams { } /// Tests 4 seeds: version + namespace + param + bytes -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexFourParams)] pub struct D9ComplexFour<'info> { #[account(mut)] @@ -77,7 +77,7 @@ pub struct D9ComplexFour<'info> { seeds = [D9_COMPLEX_V1, D9_COMPLEX_NAMESPACE.as_bytes(), params.owner.as_ref(), params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -95,7 +95,7 @@ pub struct D9ComplexFiveParams { } /// Tests 5 seeds with context account -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexFiveParams)] pub struct D9ComplexFive<'info> { #[account(mut)] @@ -114,7 +114,7 @@ pub struct D9ComplexFive<'info> { seeds = [D9_COMPLEX_V1, D9_COMPLEX_NAMESPACE.as_bytes(), authority.key().as_ref(), params.owner.as_ref(), params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -131,7 +131,7 @@ pub struct D9ComplexQualifiedMixParams { } /// Tests qualified crate paths mixed with local constants -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexQualifiedMixParams)] pub struct D9ComplexQualifiedMix<'info> { #[account(mut)] @@ -147,7 +147,7 @@ pub struct D9ComplexQualifiedMix<'info> { seeds = [crate::instructions::d9_seeds::complex_mixed::D9_COMPLEX_V1, D9_COMPLEX_PREFIX, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -166,7 +166,7 @@ pub struct D9ComplexFuncParams { } /// Tests function call combined with other seed types -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexFuncParams)] pub struct D9ComplexFunc<'info> { #[account(mut)] @@ -182,7 +182,7 @@ pub struct D9ComplexFunc<'info> { seeds = [D9_COMPLEX_V1, crate::max_key(¶ms.key_a, ¶ms.key_b).as_ref(), params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -199,7 +199,7 @@ pub struct D9ComplexAllQualifiedParams { } /// Tests all paths being fully qualified -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexAllQualifiedParams)] pub struct D9ComplexAllQualified<'info> { #[account(mut)] @@ -219,7 +219,7 @@ pub struct D9ComplexAllQualified<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -236,7 +236,7 @@ pub struct D9ComplexProgramIdParams { } /// Tests using crate::ID (program ID) as a seed element -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexProgramIdParams)] pub struct D9ComplexProgramId<'info> { #[account(mut)] @@ -252,7 +252,7 @@ pub struct D9ComplexProgramId<'info> { seeds = [b"d9_progid", crate::ID.as_ref(), params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -269,7 +269,7 @@ pub struct D9ComplexIdFuncParams { } /// Tests using crate::id() function call as a seed element -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ComplexIdFuncParams)] pub struct D9ComplexIdFunc<'info> { #[account(mut)] @@ -285,7 +285,7 @@ pub struct D9ComplexIdFunc<'info> { seeds = [b"d9_idfunc", crate::id().as_ref(), params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/const_patterns.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/const_patterns.rs index 13ac5de813..63ec146be4 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/const_patterns.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/const_patterns.rs @@ -8,7 +8,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -63,7 +63,7 @@ pub struct D9AssocConstParams { } /// Tests SomeStruct::CONSTANT pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9AssocConstParams)] pub struct D9AssocConst<'info> { #[account(mut)] @@ -79,7 +79,7 @@ pub struct D9AssocConst<'info> { seeds = [SeedHolder::SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -95,7 +95,7 @@ pub struct D9AssocConstMethodParams { } /// Tests SomeStruct::CONSTANT.as_bytes() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9AssocConstMethodParams)] pub struct D9AssocConstMethod<'info> { #[account(mut)] @@ -111,7 +111,7 @@ pub struct D9AssocConstMethod<'info> { seeds = [SeedHolder::NAMESPACE.as_bytes()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -128,7 +128,7 @@ pub struct D9MultiAssocConstParams { } /// Tests multiple associated constants from different types -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MultiAssocConstParams)] pub struct D9MultiAssocConst<'info> { #[account(mut)] @@ -144,7 +144,7 @@ pub struct D9MultiAssocConst<'info> { seeds = [SeedHolder::SEED, AnotherHolder::PREFIX, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -160,7 +160,7 @@ pub struct D9ConstFnParams { } /// Tests const_fn() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ConstFnParams)] pub struct D9ConstFn<'info> { #[account(mut)] @@ -176,7 +176,7 @@ pub struct D9ConstFn<'info> { seeds = [const_seed()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -192,7 +192,7 @@ pub struct D9ConstFnGenericParams { } /// Tests const_fn::() pattern with const generics -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ConstFnGenericParams)] pub struct D9ConstFnGeneric<'info> { #[account(mut)] @@ -208,7 +208,7 @@ pub struct D9ConstFnGeneric<'info> { seeds = [identity_seed::<12>(b"generic_seed")], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -224,7 +224,7 @@ pub struct D9TraitAssocConstParams { } /// Tests ::CONSTANT pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9TraitAssocConstParams)] pub struct D9TraitAssocConst<'info> { #[account(mut)] @@ -240,7 +240,7 @@ pub struct D9TraitAssocConst<'info> { seeds = [::TRAIT_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -256,7 +256,7 @@ pub struct D9StaticParams { } /// Tests static variable as seed -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9StaticParams)] pub struct D9Static<'info> { #[account(mut)] @@ -272,7 +272,7 @@ pub struct D9Static<'info> { seeds = [&STATIC_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -288,7 +288,7 @@ pub struct D9QualifiedConstFnParams { } /// Tests crate::module::const_fn() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedConstFnParams)] pub struct D9QualifiedConstFn<'info> { #[account(mut)] @@ -304,7 +304,7 @@ pub struct D9QualifiedConstFn<'info> { seeds = [crate::instructions::d9_seeds::const_patterns::const_seed()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -320,7 +320,7 @@ pub struct D9FullyQualifiedAssocParams { } /// Tests crate::module::Type::CONSTANT pattern (fully qualified associated constant) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9FullyQualifiedAssocParams)] pub struct D9FullyQualifiedAssoc<'info> { #[account(mut)] @@ -336,7 +336,7 @@ pub struct D9FullyQualifiedAssoc<'info> { seeds = [crate::instructions::d9_seeds::const_patterns::SeedHolder::SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -352,7 +352,7 @@ pub struct D9FullyQualifiedTraitParams { } /// Tests ::CONSTANT pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9FullyQualifiedTraitParams)] pub struct D9FullyQualifiedTrait<'info> { #[account(mut)] @@ -368,7 +368,7 @@ pub struct D9FullyQualifiedTrait<'info> { seeds = [::TRAIT_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -384,7 +384,7 @@ pub struct D9FullyQualifiedGenericParams { } /// Tests crate::module::const_fn::() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9FullyQualifiedGenericParams)] pub struct D9FullyQualifiedGeneric<'info> { #[account(mut)] @@ -400,7 +400,7 @@ pub struct D9FullyQualifiedGeneric<'info> { seeds = [crate::instructions::d9_seeds::const_patterns::identity_seed::<10>(b"fq_generic")], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -417,7 +417,7 @@ pub struct D9ConstCombinedParams { } /// Tests combining various constant patterns with full paths -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ConstCombinedParams)] pub struct D9ConstCombined<'info> { #[account(mut)] @@ -437,7 +437,7 @@ pub struct D9ConstCombined<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/constant.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/constant.rs index 6337844b3d..e795083f4d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/constant.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/constant.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -16,7 +16,7 @@ pub struct D9ConstantParams { } /// Tests ClassifiedSeed::Constant with constant identifier seeds. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ConstantParams)] pub struct D9Constant<'info> { #[account(mut)] @@ -32,7 +32,7 @@ pub struct D9Constant<'info> { seeds = [D9_CONSTANT_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub d9_constant_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/ctx_account.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/ctx_account.rs index d2dd23db87..68af8c335f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/ctx_account.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/ctx_account.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -14,7 +14,7 @@ pub struct D9CtxAccountParams { } /// Tests ClassifiedSeed::CtxAccount with authority.key() seeds. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9CtxAccountParams)] pub struct D9CtxAccount<'info> { #[account(mut)] @@ -33,7 +33,7 @@ pub struct D9CtxAccount<'info> { seeds = [b"d9_ctx", authority.key().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_ctx_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/edge_cases.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/edge_cases.rs index ccbda17d95..5a1e73b356 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/edge_cases.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/edge_cases.rs @@ -10,7 +10,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -37,7 +37,7 @@ pub struct D9EdgeEmptyParams { } /// Tests minimal byte literal seed -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeEmptyParams)] pub struct D9EdgeEmpty<'info> { #[account(mut)] @@ -53,7 +53,7 @@ pub struct D9EdgeEmpty<'info> { seeds = [&b"d9_edge_empty"[..], &b"_"[..], params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -69,7 +69,7 @@ pub struct D9EdgeSingleByteParams { } /// Tests single byte constant -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeSingleByteParams)] pub struct D9EdgeSingleByte<'info> { #[account(mut)] @@ -85,7 +85,7 @@ pub struct D9EdgeSingleByte<'info> { seeds = [D9_SINGLE_BYTE], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -101,7 +101,7 @@ pub struct D9EdgeSingleLetterParams { } /// Tests single letter constant name (A) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeSingleLetterParams)] pub struct D9EdgeSingleLetter<'info> { #[account(mut)] @@ -117,7 +117,7 @@ pub struct D9EdgeSingleLetter<'info> { seeds = [A], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -133,7 +133,7 @@ pub struct D9EdgeDigitsParams { } /// Tests constant name containing digits (SEED_123) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeDigitsParams)] pub struct D9EdgeDigits<'info> { #[account(mut)] @@ -149,7 +149,7 @@ pub struct D9EdgeDigits<'info> { seeds = [SEED_123], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -165,7 +165,7 @@ pub struct D9EdgeUnderscoreParams { } /// Tests leading underscore constant name -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeUnderscoreParams)] pub struct D9EdgeUnderscore<'info> { #[account(mut)] @@ -181,7 +181,7 @@ pub struct D9EdgeUnderscore<'info> { seeds = [_UNDERSCORE_CONST], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -197,7 +197,7 @@ pub struct D9EdgeManyLiteralsParams { } /// Tests many byte literals in same seeds array -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeManyLiteralsParams)] pub struct D9EdgeManyLiterals<'info> { #[account(mut)] @@ -213,7 +213,7 @@ pub struct D9EdgeManyLiterals<'info> { seeds = [b"a", b"b", b"c", b"d", b"e"], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -230,7 +230,7 @@ pub struct D9EdgeMixedParams { } /// Tests mixing various edge case constants -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9EdgeMixedParams)] pub struct D9EdgeMixed<'info> { #[account(mut)] @@ -246,7 +246,7 @@ pub struct D9EdgeMixed<'info> { seeds = [A, SEED_123, _UNDERSCORE_CONST, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/external_paths.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/external_paths.rs index 622755fe66..acb9606ced 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/external_paths.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/external_paths.rs @@ -7,7 +7,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -22,7 +22,7 @@ pub struct D9ExternalSdkTypesParams { } /// Tests external crate path: light_sdk_types::constants::CPI_AUTHORITY_PDA_SEED -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalSdkTypesParams)] pub struct D9ExternalSdkTypes<'info> { #[account(mut)] @@ -38,7 +38,7 @@ pub struct D9ExternalSdkTypes<'info> { seeds = [b"d9_ext_sdk", light_sdk_types::constants::CPI_AUTHORITY_PDA_SEED, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -55,7 +55,7 @@ pub struct D9ExternalCtokenParams { } /// Tests external crate path: light_token_types::constants::POOL_SEED -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalCtokenParams)] pub struct D9ExternalCtoken<'info> { #[account(mut)] @@ -71,7 +71,7 @@ pub struct D9ExternalCtoken<'info> { seeds = [b"d9_ext_ctoken", light_token_types::constants::POOL_SEED, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -88,7 +88,7 @@ pub struct D9ExternalMixedParams { } /// Tests multiple external crate constants mixed together -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalMixedParams)] pub struct D9ExternalMixed<'info> { #[account(mut)] @@ -108,7 +108,7 @@ pub struct D9ExternalMixed<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -128,7 +128,7 @@ pub struct D9ExternalWithLocalParams { } /// Tests external constant combined with local constant -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalWithLocalParams)] pub struct D9ExternalWithLocal<'info> { #[account(mut)] @@ -144,7 +144,7 @@ pub struct D9ExternalWithLocal<'info> { seeds = [D9_EXTERNAL_LOCAL, light_sdk_types::constants::RENT_SPONSOR_SEED, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -161,7 +161,7 @@ pub struct D9ExternalBumpParams { } /// Tests external constant path with bump attribute -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalBumpParams)] pub struct D9ExternalBump<'info> { #[account(mut)] @@ -177,7 +177,7 @@ pub struct D9ExternalBump<'info> { seeds = [light_token_interface::COMPRESSED_MINT_SEED, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -196,7 +196,7 @@ pub struct D9ExternalReexportParams { } /// Tests re-exported external constant -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ExternalReexportParams)] pub struct D9ExternalReexport<'info> { #[account(mut)] @@ -212,7 +212,7 @@ pub struct D9ExternalReexport<'info> { seeds = [REEXPORTED_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/function_call.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/function_call.rs index af90c7bf77..ae88ccc298 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/function_call.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/function_call.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -16,7 +16,7 @@ pub struct D9FunctionCallParams { } /// Tests ClassifiedSeed::FunctionCall with max_key(&a, &b) seeds. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9FunctionCallParams)] pub struct D9FunctionCall<'info> { #[account(mut)] @@ -32,7 +32,7 @@ pub struct D9FunctionCall<'info> { seeds = [b"d9_func", crate::max_key(¶ms.key_a, ¶ms.key_b).as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_func_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/literal.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/literal.rs index 26a58095b8..4f4e8dfcc9 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/literal.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/literal.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -14,7 +14,7 @@ pub struct D9LiteralParams { } /// Tests ClassifiedSeed::Literal with byte literal seeds. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9LiteralParams)] pub struct D9Literal<'info> { #[account(mut)] @@ -30,7 +30,7 @@ pub struct D9Literal<'info> { seeds = [b"d9_literal_record"], bump, )] - #[rentfree] + #[light_account(init)] pub d9_literal_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/method_chains.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/method_chains.rs index 3d5e5b2b58..f3a60f0b4e 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/method_chains.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/method_chains.rs @@ -9,7 +9,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -29,7 +29,7 @@ pub struct D9MethodAsRefParams { } /// Tests constant.as_ref() method call -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodAsRefParams)] pub struct D9MethodAsRef<'info> { #[account(mut)] @@ -45,7 +45,7 @@ pub struct D9MethodAsRef<'info> { seeds = [D9_METHOD_BYTES.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -61,7 +61,7 @@ pub struct D9MethodAsBytesParams { } /// Tests string_constant.as_bytes() method call -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodAsBytesParams)] pub struct D9MethodAsBytes<'info> { #[account(mut)] @@ -77,7 +77,7 @@ pub struct D9MethodAsBytes<'info> { seeds = [D9_METHOD_STR.as_bytes()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -93,7 +93,7 @@ pub struct D9MethodQualifiedAsBytesParams { } /// Tests crate::path::CONST.as_bytes() - the pattern that caused type inference issues -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodQualifiedAsBytesParams)] pub struct D9MethodQualifiedAsBytes<'info> { #[account(mut)] @@ -109,7 +109,7 @@ pub struct D9MethodQualifiedAsBytes<'info> { seeds = [crate::instructions::d9_seeds::method_chains::D9_METHOD_STR.as_bytes()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -126,7 +126,7 @@ pub struct D9MethodToLeBytesParams { } /// Tests params.field.to_le_bytes().as_ref() chain -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodToLeBytesParams)] pub struct D9MethodToLeBytes<'info> { #[account(mut)] @@ -142,7 +142,7 @@ pub struct D9MethodToLeBytes<'info> { seeds = [b"d9_le", params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -159,7 +159,7 @@ pub struct D9MethodToBeBytesParams { } /// Tests params.field.to_be_bytes().as_ref() chain -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodToBeBytesParams)] pub struct D9MethodToBeBytes<'info> { #[account(mut)] @@ -175,7 +175,7 @@ pub struct D9MethodToBeBytes<'info> { seeds = [b"d9_be", params.id.to_be_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -193,7 +193,7 @@ pub struct D9MethodMixedParams { } /// Tests mixing different method calls in same seeds -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MethodMixedParams)] pub struct D9MethodMixed<'info> { #[account(mut)] @@ -209,7 +209,7 @@ pub struct D9MethodMixed<'info> { seeds = [D9_METHOD_STR.as_bytes(), params.owner.as_ref(), params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/mixed.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/mixed.rs index bbc64a0619..d8c517aee7 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/mixed.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/mixed.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -15,7 +15,7 @@ pub struct D9MixedParams { } /// Tests multiple seed types combined: literal + ctx_account + param. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9MixedParams)] pub struct D9Mixed<'info> { #[account(mut)] @@ -34,7 +34,7 @@ pub struct D9Mixed<'info> { seeds = [b"d9_mixed", authority.key().as_ref(), params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_mixed_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/nested_seeds.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/nested_seeds.rs index 7391f769c5..b31101a3ce 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/nested_seeds.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/nested_seeds.rs @@ -7,7 +7,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -40,7 +40,7 @@ pub struct D9NestedSimpleParams { } /// Tests params.nested.owner.as_ref() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9NestedSimpleParams)] pub struct D9NestedSimple<'info> { #[account(mut)] @@ -56,7 +56,7 @@ pub struct D9NestedSimple<'info> { seeds = [b"d9_nested_simple", params.nested.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -73,7 +73,7 @@ pub struct D9NestedDoubleParams { } /// Tests params.outer.nested.owner.as_ref() pattern (double nested) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9NestedDoubleParams)] pub struct D9NestedDouble<'info> { #[account(mut)] @@ -89,7 +89,7 @@ pub struct D9NestedDouble<'info> { seeds = [b"d9_nested_double", params.outer.nested.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -106,7 +106,7 @@ pub struct D9NestedArrayFieldParams { } /// Tests params.outer.array as seed (array field in nested struct) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9NestedArrayFieldParams)] pub struct D9NestedArrayField<'info> { #[account(mut)] @@ -122,7 +122,7 @@ pub struct D9NestedArrayField<'info> { seeds = [b"d9_nested_array", params.outer.array.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -140,7 +140,7 @@ pub struct D9ArrayIndexParams { } /// Tests params.arrays[2].as_slice() pattern (array indexing) -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ArrayIndexParams)] pub struct D9ArrayIndex<'info> { #[account(mut)] @@ -156,7 +156,7 @@ pub struct D9ArrayIndex<'info> { seeds = [b"d9_array_idx", params.arrays[2].as_slice()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -173,7 +173,7 @@ pub struct D9NestedBytesParams { } /// Tests params.nested.id.to_le_bytes().as_ref() pattern -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9NestedBytesParams)] pub struct D9NestedBytes<'info> { #[account(mut)] @@ -189,7 +189,7 @@ pub struct D9NestedBytes<'info> { seeds = [b"d9_nested_bytes", params.nested.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -206,7 +206,7 @@ pub struct D9NestedCombinedParams { } /// Tests combining multiple nested accessors in seeds array -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9NestedCombinedParams)] pub struct D9NestedCombined<'info> { #[account(mut)] @@ -226,7 +226,7 @@ pub struct D9NestedCombined<'info> { ], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param.rs index e90715a32a..91ebb686e5 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -15,7 +15,7 @@ pub struct D9ParamParams { } /// Tests ClassifiedSeed::DataField with params.owner.as_ref() seeds. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ParamParams)] pub struct D9Param<'info> { #[account(mut)] @@ -31,7 +31,7 @@ pub struct D9Param<'info> { seeds = [b"d9_param", params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_param_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param_bytes.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param_bytes.rs index db6996b644..107d4384bd 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param_bytes.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/param_bytes.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -15,7 +15,7 @@ pub struct D9ParamBytesParams { } /// Tests ClassifiedSeed::DataField with params.id.to_le_bytes() conversion. -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9ParamBytesParams)] pub struct D9ParamBytes<'info> { #[account(mut)] @@ -31,7 +31,7 @@ pub struct D9ParamBytes<'info> { seeds = [b"d9_param_bytes", params.id.to_le_bytes().as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub d9_param_bytes_record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/qualified_paths.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/qualified_paths.rs index b7b378db40..5e5fb84bb1 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/qualified_paths.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d9_seeds/qualified_paths.rs @@ -8,7 +8,7 @@ use anchor_lang::prelude::*; use light_compressible::CreateAccountsProof; -use light_sdk_macros::RentFree; +use light_sdk_macros::LightAccounts; use crate::state::d1_field_types::single_pubkey::SinglePubkeyRecord; @@ -28,7 +28,7 @@ pub struct D9QualifiedBareParams { } /// Tests bare constant reference without path prefix -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedBareParams)] pub struct D9QualifiedBare<'info> { #[account(mut)] @@ -44,7 +44,7 @@ pub struct D9QualifiedBare<'info> { seeds = [D9_QUALIFIED_LOCAL], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -60,7 +60,7 @@ pub struct D9QualifiedSelfParams { } /// Tests self:: prefix path qualification -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedSelfParams)] pub struct D9QualifiedSelf<'info> { #[account(mut)] @@ -76,7 +76,7 @@ pub struct D9QualifiedSelf<'info> { seeds = [self::D9_QUALIFIED_LOCAL], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -92,7 +92,7 @@ pub struct D9QualifiedCrateParams { } /// Tests crate:: prefix path qualification -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedCrateParams)] pub struct D9QualifiedCrate<'info> { #[account(mut)] @@ -108,7 +108,7 @@ pub struct D9QualifiedCrate<'info> { seeds = [crate::instructions::d9_seeds::qualified_paths::D9_QUALIFIED_CRATE], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -124,7 +124,7 @@ pub struct D9QualifiedDeepParams { } /// Tests deeply nested crate path -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedDeepParams)] pub struct D9QualifiedDeep<'info> { #[account(mut)] @@ -140,7 +140,7 @@ pub struct D9QualifiedDeep<'info> { seeds = [crate::instructions::d9_seeds::D9_CONSTANT_SEED], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, @@ -157,7 +157,7 @@ pub struct D9QualifiedMixedParams { } /// Tests mixing qualified and bare paths in same seeds -#[derive(Accounts, RentFree)] +#[derive(Accounts, LightAccounts)] #[instruction(params: D9QualifiedMixedParams)] pub struct D9QualifiedMixed<'info> { #[account(mut)] @@ -173,7 +173,7 @@ pub struct D9QualifiedMixed<'info> { seeds = [D9_QUALIFIED_LOCAL, crate::instructions::d9_seeds::D9_CONSTANT_SEED, params.owner.as_ref()], bump, )] - #[rentfree] + #[light_account(init)] pub record: Account<'info, SinglePubkeyRecord>, pub system_program: Program<'info, System>, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/mod.rs index a7e9e9d180..d68f3a471d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/mod.rs @@ -1,7 +1,7 @@ //! Instruction account test cases organized by dimension. //! //! Each subdirectory tests a specific macro code path dimension: -//! - d5_markers: Field marker attributes (#[rentfree], #[rentfree_token], #[light_mint]) +//! - d5_markers: Field marker attributes (#[light_account(init)], #[light_account(token)], #[light_account(init)]) //! - d6_account_types: Account type extraction (Account, Box) //! - d7_infra_names: Infrastructure field naming variations //! - d8_builder_paths: Builder code generation paths diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs index 102444ab80..cf57c19811 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs @@ -3,7 +3,7 @@ use anchor_lang::prelude::*; use light_sdk::{derive_light_cpi_signer, derive_light_rent_sponsor_pda}; -use light_sdk_macros::rentfree_program; +use light_sdk_macros::light_program; use light_sdk_types::CpiSigner; pub mod amm_test; @@ -26,7 +26,7 @@ pub use d9_seeds::*; pub use instruction_accounts::*; pub use instructions::{ d7_infra_names::{ - D7_ALL_AUTH_SEED, D7_ALL_VAULT_SEED, D7_CTOKEN_AUTH_SEED, D7_CTOKEN_VAULT_SEED, + D7_ALL_AUTH_SEED, D7_ALL_VAULT_SEED, D7_LIGHT_TOKEN_AUTH_SEED, D7_LIGHT_TOKEN_VAULT_SEED, }, d9_seeds::{D9_ALL_SEED, D9_CONSTANT_SEED}, }; @@ -81,7 +81,7 @@ pub fn program_rent_sponsor() -> Pubkey { pub const GAME_SESSION_SEED: &str = "game_session"; -#[rentfree_program] +#[light_program] #[program] pub mod csdk_anchor_full_derived_test { #![allow(clippy::too_many_arguments)] @@ -89,13 +89,13 @@ pub mod csdk_anchor_full_derived_test { use super::{ amm_test::{Deposit, InitializeParams, InitializePool, Withdraw}, d5_markers::{ - D5AllMarkers, D5AllMarkersParams, D5RentfreeBare, D5RentfreeBareParams, - D5RentfreeToken, D5RentfreeTokenParams, + D5AllMarkers, D5AllMarkersParams, D5LightToken, D5LightTokenParams, D5RentfreeBare, + D5RentfreeBareParams, }, d6_account_types::{D6Account, D6AccountParams, D6Boxed, D6BoxedParams}, d7_infra_names::{ - D7AllNames, D7AllNamesParams, D7Creator, D7CreatorParams, D7CtokenConfig, - D7CtokenConfigParams, D7Payer, D7PayerParams, + D7AllNames, D7AllNamesParams, D7Creator, D7CreatorParams, D7LightTokenConfig, + D7LightTokenConfigParams, D7Payer, D7PayerParams, }, d8_builder_paths::{ D8All, D8AllParams, D8MultiRentfree, D8MultiRentfreeParams, D8PdaOnly, D8PdaOnlyParams, @@ -276,8 +276,10 @@ pub mod csdk_anchor_full_derived_test { owner: ctx.accounts.vault_authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) @@ -296,8 +298,10 @@ pub mod csdk_anchor_full_derived_test { } .idempotent() .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), ) .invoke()?; @@ -329,7 +333,7 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// Second instruction to test #[rentfree_program] with multiple instructions. + /// Second instruction to test #[light_program] with multiple instructions. /// Delegates to nested processor in separate module. pub fn create_single_record<'info>( ctx: Context<'_, '_, '_, 'info, D5RentfreeBare<'info>>, @@ -374,8 +378,8 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// AMM initialize instruction with all rentfree markers. - /// Tests: 2x #[rentfree], 2x #[rentfree_token], 1x #[light_mint], + /// AMM initialize instruction with all light account markers. + /// Tests: 2x #[light_account(init)], 2x #[light_account(token)], 1x #[light_account(init)], /// CreateTokenAccountCpi.rent_free(), CreateTokenAtaCpi.rent_free(), MintToCpi pub fn initialize_pool<'info>( ctx: Context<'_, '_, '_, 'info, InitializePool<'info>>, @@ -420,7 +424,7 @@ pub mod csdk_anchor_full_derived_test { // D8 Builder Paths: Builder code generation paths // ========================================================================= - /// D8: Only #[rentfree] fields (no token accounts) + /// D8: Only #[light_account(init)] fields (no token accounts) pub fn d8_pda_only<'info>( ctx: Context<'_, '_, '_, 'info, D8PdaOnly<'info>>, params: D8PdaOnlyParams, @@ -429,7 +433,7 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// D8: Multiple #[rentfree] fields of same type + /// D8: Multiple #[light_account(init)] fields of same type pub fn d8_multi_rentfree<'info>( ctx: Context<'_, '_, '_, 'info, D8MultiRentfree<'info>>, params: D8MultiRentfreeParams, @@ -439,7 +443,7 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// D8: Multiple #[rentfree] fields of different types + /// D8: Multiple #[light_account(init)] fields of different types pub fn d8_all<'info>( ctx: Context<'_, '_, '_, 'info, D8All<'info>>, params: D8AllParams, @@ -529,10 +533,10 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// D7: "ctoken_config" naming variant for token accounts - pub fn d7_ctoken_config<'info>( - ctx: Context<'_, '_, '_, 'info, D7CtokenConfig<'info>>, - _params: D7CtokenConfigParams, + /// D7: "light_token_config" naming variant for token accounts + pub fn d7_light_token_config<'info>( + ctx: Context<'_, '_, '_, 'info, D7LightTokenConfig<'info>>, + _params: D7LightTokenConfigParams, ) -> Result<()> { use light_token_sdk::token::CreateTokenAccountCpi; @@ -540,7 +544,7 @@ pub mod csdk_anchor_full_derived_test { // Derive the vault bump at runtime let (_, vault_bump) = Pubkey::find_program_address( &[ - crate::d7_infra_names::D7_CTOKEN_VAULT_SEED, + crate::d7_infra_names::D7_LIGHT_TOKEN_VAULT_SEED, mint_key.as_ref(), ], &crate::ID, @@ -548,25 +552,27 @@ pub mod csdk_anchor_full_derived_test { CreateTokenAccountCpi { payer: ctx.accounts.fee_payer.to_account_info(), - account: ctx.accounts.d7_ctoken_vault.to_account_info(), + account: ctx.accounts.d7_light_token_vault.to_account_info(), mint: ctx.accounts.mint.to_account_info(), - owner: ctx.accounts.d7_ctoken_authority.key(), + owner: ctx.accounts.d7_light_token_authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.light_token_rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) .invoke_signed(&[ - crate::d7_infra_names::D7_CTOKEN_VAULT_SEED, + crate::d7_infra_names::D7_LIGHT_TOKEN_VAULT_SEED, mint_key.as_ref(), &[vault_bump], ])?; Ok(()) } - /// D7: All naming variants combined (payer + ctoken config/sponsor) + /// D7: All naming variants combined (payer + light_token config/sponsor) pub fn d7_all_names<'info>( ctx: Context<'_, '_, '_, 'info, D7AllNames<'info>>, params: D7AllNamesParams, @@ -591,8 +597,10 @@ pub mod csdk_anchor_full_derived_test { owner: ctx.accounts.d7_all_authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) @@ -1171,10 +1179,10 @@ pub mod csdk_anchor_full_derived_test { // D5 Additional Markers Tests // ========================================================================= - /// D5: #[rentfree_token] attribute test - pub fn d5_rentfree_token<'info>( - ctx: Context<'_, '_, '_, 'info, D5RentfreeToken<'info>>, - params: D5RentfreeTokenParams, + /// D5: #[light_account(token)] attribute test + pub fn d5_light_token<'info>( + ctx: Context<'_, '_, '_, 'info, D5LightToken<'info>>, + params: D5LightTokenParams, ) -> Result<()> { use light_token_sdk::token::CreateTokenAccountCpi; @@ -1186,8 +1194,10 @@ pub mod csdk_anchor_full_derived_test { owner: ctx.accounts.vault_authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.light_token_rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) @@ -1199,7 +1209,7 @@ pub mod csdk_anchor_full_derived_test { Ok(()) } - /// D5: All markers combined (#[rentfree] + #[rentfree_token]) + /// D5: All markers combined (#[light_account(init)] + #[light_account(token)]) pub fn d5_all_markers<'info>( ctx: Context<'_, '_, '_, 'info, D5AllMarkers<'info>>, params: D5AllMarkersParams, @@ -1224,8 +1234,10 @@ pub mod csdk_anchor_full_derived_test { owner: ctx.accounts.d5_all_authority.key(), } .rent_free( - ctx.accounts.ctoken_compressible_config.to_account_info(), - ctx.accounts.ctoken_rent_sponsor.to_account_info(), + ctx.accounts + .light_token_compressible_config + .to_account_info(), + ctx.accounts.light_token_rent_sponsor.to_account_info(), ctx.accounts.system_program.to_account_info(), &crate::ID, ) diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/all.rs index 9690c5cf2f..104d23c4a0 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/all.rs @@ -9,10 +9,10 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Comprehensive struct with all field type variations. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct AllFieldTypesRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/arrays.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/arrays.rs index 10c6ea2233..8faa3571a6 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/arrays.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/arrays.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with array fields. /// Tests [u8; 32] (byte array) and fixed-size arrays. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct ArrayRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/multi_pubkey.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/multi_pubkey.rs index 98c506a1e9..78566470cd 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/multi_pubkey.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/multi_pubkey.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with multiple Pubkey fields. /// PackedMultiPubkeyRecord will have: owner_index, delegate_index, authority_index: u8 -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct MultiPubkeyRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/no_pubkey.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/no_pubkey.rs index 98822f70fd..a9b253a5d7 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/no_pubkey.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/no_pubkey.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with only primitive fields - no Pubkey. /// This tests the identity Pack path where PackedNoPubkeyRecord = NoPubkeyRecord. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct NoPubkeyRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/non_copy.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/non_copy.rs index 6822618d70..ac3c35d6cc 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/non_copy.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/non_copy.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with a String field (non-Copy type). /// This tests the clone() code path for non-Copy fields. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct NonCopyRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_primitive.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_primitive.rs index bdb5bdf6a2..2813bf7dcf 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_primitive.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_primitive.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with Option fields. /// These stay as Option in the packed struct (not Option). -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct OptionPrimitiveRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_pubkey.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_pubkey.rs index 0a2ddf29bf..cfb13f6f07 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_pubkey.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/option_pubkey.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with Option fields. /// PackedOptionPubkeyRecord will have: delegate_index: Option -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct OptionPubkeyRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/single_pubkey.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/single_pubkey.rs index e0c1c26f61..56d837bf19 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/single_pubkey.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d1_field_types/single_pubkey.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with exactly one Pubkey field. /// PackedSinglePubkeyRecord will have: owner_index: u8 -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct SinglePubkeyRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/absent.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/absent.rs index a519ab94c3..b3c94af41d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/absent.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/absent.rs @@ -5,11 +5,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct without any compress_as attribute. /// All fields are compressed as-is using self.field. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct NoCompressAsRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/all.rs index f56d3a75de..230229d93f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/all.rs @@ -7,10 +7,10 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Comprehensive struct with all compress_as variations. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[compress_as(time = 0, end = None, score = 0, cached = 0)] #[account] pub struct AllCompressAsRecord { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/multiple.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/multiple.rs index 9ce81f05b7..02d1c1f174 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/multiple.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/multiple.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with multiple compress_as overrides. /// start, score, and cached all have compression overrides. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[compress_as(start = 0, score = 0, cached = 0)] #[account] pub struct MultipleCompressAsRecord { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/option_none.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/option_none.rs index 701ec3b7aa..3a1236189c 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/option_none.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/option_none.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with compress_as None for Option fields. /// end_time is compressed as None instead of self.end_time. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[compress_as(end_time = None)] #[account] pub struct OptionNoneCompressAsRecord { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/single.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/single.rs index f6916a0ae6..18c8f15474 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/single.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d2_compress_as/single.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// A struct with single compress_as override. /// cached field is compressed as 0 instead of self.cached. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[compress_as(cached = 0)] #[account] pub struct SingleCompressAsRecord { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/all.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/all.rs index 303b5500b0..f233224c4b 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/all.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/all.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Comprehensive large struct with all field types. /// 15+ fields to trigger SHA256 mode with all D1 variations. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[compress_as(cached_time = 0, end_time = None)] #[account] pub struct AllCompositionRecord { diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/info_last.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/info_last.rs index 707f8cd5cd..567022fbb5 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/info_last.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/info_last.rs @@ -4,11 +4,11 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Struct with compression_info as last field. /// Tests that field ordering is handled correctly. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct InfoLastRecord { pub owner: Pubkey, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/large.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/large.rs index f940d4eaeb..a2f308c94a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/large.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/large.rs @@ -4,10 +4,10 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Large struct with 12+ fields for SHA256 hash mode. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct LargeRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/minimal.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/minimal.rs index 577b71fd03..cc25b94df4 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/minimal.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/d4_composition/minimal.rs @@ -4,10 +4,10 @@ use anchor_lang::prelude::*; use light_sdk::{compressible::CompressionInfo, LightDiscriminator}; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; /// Smallest valid struct: compression_info + one field. -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct MinimalRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs b/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs index 308d7eadc8..7e0e438bb4 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/state/mod.rs @@ -4,7 +4,7 @@ use anchor_lang::prelude::*; use light_sdk::{ compressible::CompressionInfo, instruction::PackedAddressTreeInfo, LightDiscriminator, }; -use light_sdk_macros::RentFreeAccount; +use light_sdk_macros::LightAccount; use light_token_interface::instructions::mint_action::MintWithContext; use light_token_sdk::ValidityProof; @@ -15,7 +15,7 @@ pub mod d4_composition; // Original state types used by the main program -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct UserRecord { pub compression_info: Option, @@ -26,7 +26,7 @@ pub struct UserRecord { pub category_id: u64, } -#[derive(Default, Debug, PartialEq, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, PartialEq, InitSpace, LightAccount)] #[compress_as(start_time = 0, end_time = None, score = 0)] #[account] pub struct GameSession { @@ -40,7 +40,7 @@ pub struct GameSession { pub score: u64, } -#[derive(Default, Debug, InitSpace, RentFreeAccount)] +#[derive(Default, Debug, InitSpace, LightAccount)] #[account] pub struct PlaceholderRecord { pub compression_info: Option, diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros.rs index cc572631ff..76e1307978 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros.rs @@ -1,6 +1,6 @@ -//! Unit tests for RentFreeAccount-derived traits +//! Unit tests for LightAccount-derived traits //! -//! Tests individual traits derived by the `RentFreeAccount` macro on account data structs. +//! Tests individual traits derived by the `LightAccount` macro on account data structs. #[path = "account_macros/shared.rs"] pub mod shared; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/CLAUDE.md b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/CLAUDE.md index 6674dfe507..e9aeb80a6a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/CLAUDE.md +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/CLAUDE.md @@ -1,10 +1,10 @@ # Account Macros Test Directory -This directory contains unit tests for trait implementations derived by the `#[derive(RentFreeAccount)]` and `#[derive(LightCompressible)]` macros on account data structs. +This directory contains unit tests for trait implementations derived by the `#[derive(LightAccount)]` and `#[derive(LightCompressible)]` macros on account data structs. ## Test Coverage Requirement -**Every account struct** with `#[derive(RentFreeAccount)]` or `#[derive(LightCompressible)]` **must have its own dedicated test file** in this directory. +**Every account struct** with `#[derive(LightAccount)]` or `#[derive(LightCompressible)]` **must have its own dedicated test file** in this directory. ## Directory Structure diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_observation_state_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_observation_state_test.rs index a6cf5edf87..577df3ad96 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_observation_state_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_observation_state_test.rs @@ -1,6 +1,6 @@ //! AMM ObservationState Tests: ObservationState trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `ObservationState`: +//! Tests each trait derived by `LightAccount` macro for `ObservationState`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_pool_state_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_pool_state_test.rs index 4d71974558..520c6e0184 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_pool_state_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/amm_pool_state_test.rs @@ -1,6 +1,6 @@ //! AMM PoolState Tests: PoolState trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `PoolState`: +//! Tests each trait derived by `LightAccount` macro for `PoolState`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_game_session_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_game_session_test.rs index 51ba3613c6..d1d167d890 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_game_session_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_game_session_test.rs @@ -1,6 +1,6 @@ //! Core Tests: GameSession trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `GameSession`: +//! Tests each trait derived by `LightAccount` macro for `GameSession`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_placeholder_record_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_placeholder_record_test.rs index ce29bf8a2e..423c8130b7 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_placeholder_record_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_placeholder_record_test.rs @@ -1,6 +1,6 @@ //! Core Tests: PlaceholderRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `PlaceholderRecord`: +//! Tests each trait derived by `LightAccount` macro for `PlaceholderRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_user_record_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_user_record_test.rs index 40047cca64..998c443ec3 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_user_record_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/core_user_record_test.rs @@ -1,6 +1,6 @@ //! Core Tests: UserRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `UserRecord`: +//! Tests each trait derived by `LightAccount` macro for `UserRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_all_field_types_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_all_field_types_test.rs index 4217eac0c1..5e13a83d19 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_all_field_types_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_all_field_types_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: AllFieldTypesRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `AllFieldTypesRecord`: +//! Tests each trait derived by `LightAccount` macro for `AllFieldTypesRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_array_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_array_test.rs index d7f1bc9970..036f2fd88b 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_array_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_array_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: ArrayRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `ArrayRecord`: +//! Tests each trait derived by `LightAccount` macro for `ArrayRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_multi_pubkey_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_multi_pubkey_test.rs index a24130bbd5..f885f33024 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_multi_pubkey_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_multi_pubkey_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: MultiPubkeyRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `MultiPubkeyRecord`: +//! Tests each trait derived by `LightAccount` macro for `MultiPubkeyRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_no_pubkey_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_no_pubkey_test.rs index 6547c3e76a..f9523d1c34 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_no_pubkey_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_no_pubkey_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: NoPubkeyRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `NoPubkeyRecord`: +//! Tests each trait derived by `LightAccount` macro for `NoPubkeyRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_non_copy_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_non_copy_test.rs index 9f28d3adbf..0f48311be5 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_non_copy_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_non_copy_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: NonCopyRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `NonCopyRecord`: +//! Tests each trait derived by `LightAccount` macro for `NonCopyRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_primitive_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_primitive_test.rs index eec38f168d..cf9db8af3d 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_primitive_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_primitive_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: OptionPrimitiveRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `OptionPrimitiveRecord`: +//! Tests each trait derived by `LightAccount` macro for `OptionPrimitiveRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_pubkey_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_pubkey_test.rs index 12bc2b69d1..b713ab1337 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_pubkey_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_option_pubkey_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: OptionPubkeyRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `OptionPubkeyRecord`: +//! Tests each trait derived by `LightAccount` macro for `OptionPubkeyRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_single_pubkey_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_single_pubkey_test.rs index 5d4e749b9e..e431243d93 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_single_pubkey_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d1_single_pubkey_test.rs @@ -1,6 +1,6 @@ //! D1 Tests: SinglePubkeyRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `SinglePubkeyRecord`: +//! Tests each trait derived by `LightAccount` macro for `SinglePubkeyRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_all_compress_as_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_all_compress_as_test.rs index d4ed5ee2ab..daf4fde43a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_all_compress_as_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_all_compress_as_test.rs @@ -1,6 +1,6 @@ //! D2 Tests: AllCompressAsRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `AllCompressAsRecord`: +//! Tests each trait derived by `LightAccount` macro for `AllCompressAsRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_multiple_compress_as_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_multiple_compress_as_test.rs index 5c47716985..bec32980de 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_multiple_compress_as_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_multiple_compress_as_test.rs @@ -1,6 +1,6 @@ //! D2 Tests: MultipleCompressAsRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `MultipleCompressAsRecord`: +//! Tests each trait derived by `LightAccount` macro for `MultipleCompressAsRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_no_compress_as_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_no_compress_as_test.rs index b82e0457ad..5f3e110452 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_no_compress_as_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_no_compress_as_test.rs @@ -1,6 +1,6 @@ //! D2 Tests: NoCompressAsRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `NoCompressAsRecord`: +//! Tests each trait derived by `LightAccount` macro for `NoCompressAsRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_option_none_compress_as_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_option_none_compress_as_test.rs index 6bc5e3553a..1886fb9daa 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_option_none_compress_as_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_option_none_compress_as_test.rs @@ -1,6 +1,6 @@ //! D2 Tests: OptionNoneCompressAsRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `OptionNoneCompressAsRecord`: +//! Tests each trait derived by `LightAccount` macro for `OptionNoneCompressAsRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_single_compress_as_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_single_compress_as_test.rs index 9deb78210c..13fa4048b0 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_single_compress_as_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d2_single_compress_as_test.rs @@ -1,6 +1,6 @@ //! D2 Tests: SingleCompressAsRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `SingleCompressAsRecord`: +//! Tests each trait derived by `LightAccount` macro for `SingleCompressAsRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_all_composition_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_all_composition_test.rs index ff2055d4d2..cac09da6ae 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_all_composition_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_all_composition_test.rs @@ -1,6 +1,6 @@ //! D4 Tests: AllCompositionRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `AllCompositionRecord`: +//! Tests each trait derived by `LightAccount` macro for `AllCompositionRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_info_last_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_info_last_test.rs index d54234f11e..023464df84 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_info_last_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_info_last_test.rs @@ -1,6 +1,6 @@ //! D4 Tests: InfoLastRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `InfoLastRecord`: +//! Tests each trait derived by `LightAccount` macro for `InfoLastRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_large_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_large_test.rs index 144b2c8bfa..8e924492e2 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_large_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_large_test.rs @@ -1,6 +1,6 @@ //! D4 Tests: LargeRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `LargeRecord`: +//! Tests each trait derived by `LightAccount` macro for `LargeRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_minimal_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_minimal_test.rs index e07cb324fd..0bafa663cb 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_minimal_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/d4_minimal_test.rs @@ -1,6 +1,6 @@ //! D4 Tests: MinimalRecord trait derive tests //! -//! Tests each trait derived by `RentFreeAccount` macro for `MinimalRecord`: +//! Tests each trait derived by `LightAccount` macro for `MinimalRecord`: //! - LightHasherSha -> DataHasher + ToByteArray //! - LightDiscriminator -> LIGHT_DISCRIMINATOR constant //! - Compressible -> HasCompressionInfo + CompressAs + Size + CompressedInitSpace diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/shared.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/shared.rs index d851ffe820..d0b1316a2a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/shared.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/account_macros/shared.rs @@ -1,4 +1,4 @@ -//! Shared generic test helpers for RentFreeAccount-derived traits. +//! Shared generic test helpers for LightAccount-derived traits. //! //! These functions test trait implementations generically and can be reused //! across different account struct types. diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs index a257496817..50a0a2e5ac 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs @@ -377,10 +377,10 @@ async fn test_amm_full_lifecycle() { system_program: solana_sdk::system_program::ID, rent: solana_sdk::sysvar::rent::ID, compression_config: ctx.config_pda, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: LIGHT_TOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: LIGHT_TOKEN_RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID, - ctoken_cpi_authority: LIGHT_TOKEN_CPI_AUTHORITY, + light_token_cpi_authority: LIGHT_TOKEN_CPI_AUTHORITY, }; let instruction_data = csdk_anchor_full_derived_test::instruction::InitializePool { diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs index 5ea375fb04..451e2a9539 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs @@ -4,7 +4,6 @@ use light_compressible_client::{ get_create_accounts_proof, AccountInterfaceExt, CreateAccountsProofInput, InitializeRentFreeConfig, }; -use light_macros::pubkey; use light_program_test::{ program_test::{setup_mock_program_data, LightProgramTest, TestRpc}, Indexer, ProgramTestConfig, Rpc, @@ -16,8 +15,6 @@ use solana_keypair::Keypair; use solana_pubkey::Pubkey; use solana_signer::Signer; -const RENT_SPONSOR: Pubkey = pubkey!("CLEuMG7pzJX9xAuKCFzBP154uiG1GaNo4Fq7x6KAcAfG"); - /// 2 PDAs + 1 CMint + 1 Vault + 1 User ATA, all in one instruction with single proof. /// After init: all accounts on-chain + parseable. /// After warp: all cold (auto-compressed) with non-empty compressed data. @@ -29,8 +26,7 @@ async fn test_create_pdas_and_mint_auto() { }; use light_token_interface::state::Token; use light_token_sdk::token::{ - get_associated_token_address_and_bump, COMPRESSIBLE_CONFIG_V1, - RENT_SPONSOR as CTOKEN_RENT_SPONSOR, + get_associated_token_address_and_bump, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; // Helpers @@ -179,10 +175,10 @@ async fn test_create_pdas_and_mint_auto() { vault_authority: vault_authority_pda, user_ata: user_ata_pda, compression_config: config_pda, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; @@ -476,8 +472,7 @@ async fn test_create_two_mints() { CreateTwoMintsParams, MINT_SIGNER_A_SEED, MINT_SIGNER_B_SEED, }; use light_token_sdk::token::{ - find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, - RENT_SPONSOR as CTOKEN_RENT_SPONSOR, + find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; let program_id = csdk_anchor_full_derived_test::ID; @@ -551,10 +546,10 @@ async fn test_create_two_mints() { cmint_a: cmint_a_pda, cmint_b: cmint_b_pda, compression_config: config_pda, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; @@ -599,7 +594,7 @@ async fn test_create_two_mints() { let mint_b: Mint = borsh::BorshDeserialize::deserialize(&mut &cmint_b_account.data[..]) .expect("Failed to deserialize Mint B"); - // Verify decimals match what was specified in #[light_mint] + // Verify decimals match what was specified in #[light_account(init)] assert_eq!(mint_a.base.decimals, 6, "Mint A should have 6 decimals"); assert_eq!(mint_b.base.decimals, 9, "Mint B should have 9 decimals"); @@ -671,8 +666,7 @@ async fn test_create_multi_mints() { CreateThreeMintsParams, MINT_SIGNER_A_SEED, MINT_SIGNER_B_SEED, MINT_SIGNER_C_SEED, }; use light_token_sdk::token::{ - find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, - RENT_SPONSOR as CTOKEN_RENT_SPONSOR, + find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; let program_id = csdk_anchor_full_derived_test::ID; @@ -744,10 +738,10 @@ async fn test_create_multi_mints() { cmint_b: cmint_b_pda, cmint_c: cmint_c_pda, compression_config: config_pda, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; @@ -801,7 +795,7 @@ async fn test_create_multi_mints() { let mint_c: Mint = borsh::BorshDeserialize::deserialize(&mut &cmint_c_account.data[..]) .expect("Failed to deserialize Mint C"); - // Verify decimals match what was specified in #[light_mint] + // Verify decimals match what was specified in #[light_account(init)] assert_eq!(mint_a.base.decimals, 6, "Mint A should have 6 decimals"); assert_eq!(mint_b.base.decimals, 8, "Mint B should have 8 decimals"); assert_eq!(mint_c.base.decimals, 9, "Mint C should have 9 decimals"); diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs index e1b8014e21..8b9a77f2cc 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/integration_tests.rs @@ -8,7 +8,7 @@ mod shared; use anchor_lang::{InstructionData, ToAccountMetas}; -use csdk_anchor_full_derived_test::csdk_anchor_full_derived_test::RentFreeAccountVariant; +use csdk_anchor_full_derived_test::csdk_anchor_full_derived_test::LightAccountVariant; use light_compressible::rent::SLOTS_PER_EPOCH; use light_compressible_client::{ create_load_accounts_instructions, get_create_accounts_proof, AccountInterface, @@ -104,7 +104,7 @@ impl TestContext { /// Runs the full compression/decompression lifecycle for a single PDA. async fn assert_lifecycle(&mut self, pda: &Pubkey, seeds: S) where - S: IntoVariant, + S: IntoVariant, { // Warp to trigger compression self.rpc @@ -299,7 +299,7 @@ async fn test_d6_boxed() { // D8 Builder Paths Tests // ============================================================================= -/// Tests D8PdaOnly: Only #[rentfree] fields (no token accounts) +/// Tests D8PdaOnly: Only #[light_account(init)] fields (no token accounts) #[tokio::test] async fn test_d8_pda_only() { use csdk_anchor_full_derived_test::d8_builder_paths::D8PdaOnlyParams; @@ -358,7 +358,7 @@ async fn test_d8_pda_only() { .await; } -/// Tests D8MultiRentfree: Multiple #[rentfree] fields of same type +/// Tests D8MultiRentfree: Multiple #[light_account(init)] fields of same type #[tokio::test] async fn test_d8_multi_rentfree() { use csdk_anchor_full_derived_test::d8_builder_paths::D8MultiRentfreeParams; @@ -499,7 +499,7 @@ async fn test_d8_multi_rentfree() { ctx.assert_onchain_exists(&pda2).await; } -/// Tests D8All: Multiple #[rentfree] fields of different types +/// Tests D8All: Multiple #[light_account(init)] fields of different types #[tokio::test] async fn test_d8_all() { use csdk_anchor_full_derived_test::d8_builder_paths::D8AllParams; @@ -1300,7 +1300,7 @@ async fn test_d9_all() { ctx.assert_onchain_closed(&pda_func).await; // Helper to decompress a single account - async fn decompress_one>( + async fn decompress_one>( ctx: &mut TestContext, pda: &Pubkey, seeds: S, @@ -1478,16 +1478,16 @@ async fn test_d8_pda_only_full_lifecycle() { // D5 Markers Token Tests (require mint setup) // ============================================================================= -/// Tests D5RentfreeToken: #[rentfree_token] attribute -/// NOTE: This test is skipped because token-only instructions (no #[rentfree] PDAs) +/// Tests D5LightToken: #[light_account(token)] attribute +/// NOTE: This test is skipped because token-only instructions (no #[light_account(init)] PDAs) /// still require a CreateAccountsProof but get_create_accounts_proof fails with empty inputs. #[tokio::test] -async fn test_d5_rentfree_token() { +async fn test_d5_light_token() { use csdk_anchor_full_derived_test::d5_markers::{ - D5RentfreeTokenParams, D5_VAULT_AUTH_SEED, D5_VAULT_SEED, + D5LightTokenParams, D5_VAULT_AUTH_SEED, D5_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; + use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; @@ -1505,20 +1505,20 @@ async fn test_d5_rentfree_token() { .unwrap(); // Build instruction - let accounts = csdk_anchor_full_derived_test::accounts::D5RentfreeToken { + let accounts = csdk_anchor_full_derived_test::accounts::D5LightToken { fee_payer: ctx.payer.pubkey(), mint, vault_authority, d5_token_vault: vault, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + light_token_rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; - let instruction_data = csdk_anchor_full_derived_test::instruction::D5RentfreeToken { - params: D5RentfreeTokenParams { + let instruction_data = csdk_anchor_full_derived_test::instruction::D5LightToken { + params: D5LightTokenParams { create_accounts_proof: proof_result.create_accounts_proof, vault_bump, }, @@ -1537,7 +1537,7 @@ async fn test_d5_rentfree_token() { ctx.rpc .create_and_send_transaction(&[instruction], &ctx.payer.pubkey(), &[&ctx.payer]) .await - .expect("D5RentfreeToken instruction should succeed"); + .expect("D5LightToken instruction should succeed"); // Verify token vault exists ctx.assert_onchain_exists(&vault).await; @@ -1545,14 +1545,14 @@ async fn test_d5_rentfree_token() { // Note: Token vault decompression not tested - requires TokenAccountVariant } -/// Tests D5AllMarkers: #[rentfree] + #[rentfree_token] combined +/// Tests D5AllMarkers: #[light_account(init)] + #[light_account(token)] combined #[tokio::test] async fn test_d5_all_markers() { use csdk_anchor_full_derived_test::d5_markers::{ D5AllMarkersParams, D5_ALL_AUTH_SEED, D5_ALL_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; + use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; let owner = Keypair::new().pubkey(); @@ -1584,10 +1584,10 @@ async fn test_d5_all_markers() { d5_all_authority, d5_all_record, d5_all_vault, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + light_token_rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; @@ -1628,15 +1628,17 @@ async fn test_d5_all_markers() { // D7 Infrastructure Names Token Tests (require mint setup) // ============================================================================= -/// Tests D7CtokenConfig: ctoken_compressible_config/ctoken_rent_sponsor naming -/// Token-only instruction (no #[rentfree] PDAs) - verifies infrastructure field naming. +/// Tests D7LightTokenConfig: light_token_compressible_config/light_token_rent_sponsor naming +/// Token-only instruction (no #[light_account(init)] PDAs) - verifies infrastructure field naming. #[tokio::test] -async fn test_d7_ctoken_config() { +async fn test_d7_light_token_config() { use csdk_anchor_full_derived_test::d7_infra_names::{ - D7CtokenConfigParams, D7_CTOKEN_AUTH_SEED, D7_CTOKEN_VAULT_SEED, + D7LightTokenConfigParams, D7_LIGHT_TOKEN_AUTH_SEED, D7_LIGHT_TOKEN_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; + use light_token_sdk::token::{ + COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as LIGHT_TOKEN_RENT_SPONSOR, + }; let mut ctx = TestContext::new().await; @@ -1644,10 +1646,10 @@ async fn test_d7_ctoken_config() { let (mint, _compression_addr, _atas, _mint_seed) = ctx.setup_mint().await; // Derive PDAs - let (d7_ctoken_authority, _) = - Pubkey::find_program_address(&[D7_CTOKEN_AUTH_SEED], &ctx.program_id); - let (d7_ctoken_vault, _) = - Pubkey::find_program_address(&[D7_CTOKEN_VAULT_SEED, mint.as_ref()], &ctx.program_id); + let (d7_light_token_authority, _) = + Pubkey::find_program_address(&[D7_LIGHT_TOKEN_AUTH_SEED], &ctx.program_id); + let (d7_light_token_vault, _) = + Pubkey::find_program_address(&[D7_LIGHT_TOKEN_VAULT_SEED, mint.as_ref()], &ctx.program_id); // Get proof (no PDA accounts for token-only instruction) let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) @@ -1655,20 +1657,20 @@ async fn test_d7_ctoken_config() { .unwrap(); // Build instruction - let accounts = csdk_anchor_full_derived_test::accounts::D7CtokenConfig { + let accounts = csdk_anchor_full_derived_test::accounts::D7LightTokenConfig { fee_payer: ctx.payer.pubkey(), mint, - d7_ctoken_authority, - d7_ctoken_vault, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + d7_light_token_authority, + d7_light_token_vault, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + light_token_rent_sponsor: LIGHT_TOKEN_RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; - let instruction_data = csdk_anchor_full_derived_test::instruction::D7CtokenConfig { - _params: D7CtokenConfigParams { + let instruction_data = csdk_anchor_full_derived_test::instruction::D7LightTokenConfig { + _params: D7LightTokenConfigParams { create_accounts_proof: proof_result.create_accounts_proof, }, }; @@ -1686,22 +1688,22 @@ async fn test_d7_ctoken_config() { ctx.rpc .create_and_send_transaction(&[instruction], &ctx.payer.pubkey(), &[&ctx.payer]) .await - .expect("D7CtokenConfig instruction should succeed"); + .expect("D7LightTokenConfig instruction should succeed"); // Verify token vault exists - ctx.assert_onchain_exists(&d7_ctoken_vault).await; + ctx.assert_onchain_exists(&d7_light_token_vault).await; // Note: Token vault decompression not tested - requires TokenAccountVariant } -/// Tests D7AllNames: payer + ctoken_config/rent_sponsor naming combined +/// Tests D7AllNames: payer + light_token_config/rent_sponsor naming combined #[tokio::test] async fn test_d7_all_names() { use csdk_anchor_full_derived_test::d7_infra_names::{ D7AllNamesParams, D7_ALL_AUTH_SEED, D7_ALL_VAULT_SEED, }; use light_sdk_types::LIGHT_TOKEN_PROGRAM_ID; - use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR as CTOKEN_RENT_SPONSOR}; + use light_token_sdk::token::{COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR}; let mut ctx = TestContext::new().await; let owner = Keypair::new().pubkey(); @@ -1733,10 +1735,10 @@ async fn test_d7_all_names() { d7_all_authority, d7_all_record, d7_all_vault, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs index 10575ccabf..f294d3456b 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/mint/metadata_test.rs @@ -1,4 +1,4 @@ -//! Integration tests for mint with metadata support in #[light_mint] macro. +//! Integration tests for mint with metadata support in #[light_account(init)] macro. use anchor_lang::{InstructionData, ToAccountMetas}; use light_compressible::rent::SLOTS_PER_EPOCH; @@ -6,7 +6,6 @@ use light_compressible_client::{ decompress_mint::decompress_mint, get_create_accounts_proof, AccountInterfaceExt, CreateAccountsProofInput, InitializeRentFreeConfig, }; -use light_macros::pubkey; use light_program_test::{ program_test::{setup_mock_program_data, LightProgramTest, TestRpc}, Indexer, ProgramTestConfig, Rpc, @@ -17,8 +16,6 @@ use solana_keypair::Keypair; use solana_pubkey::Pubkey; use solana_signer::Signer; -const RENT_SPONSOR: Pubkey = pubkey!("CLEuMG7pzJX9xAuKCFzBP154uiG1GaNo4Fq7x6KAcAfG"); - /// Test creating a mint with metadata and full lifecycle. /// Phase 1: Create mint on-chain with metadata (name, symbol, uri, update_authority, additional_metadata) /// Phase 2: Warp slots to trigger auto-compression by forester @@ -29,8 +26,7 @@ async fn test_create_mint_with_metadata() { CreateMintWithMetadataParams, METADATA_MINT_SIGNER_SEED, }; use light_token_sdk::token::{ - find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, - RENT_SPONSOR as CTOKEN_RENT_SPONSOR, + find_mint_address as find_cmint_address, COMPRESSIBLE_CONFIG_V1, RENT_SPONSOR, }; let program_id = csdk_anchor_full_derived_test::ID; @@ -99,10 +95,10 @@ async fn test_create_mint_with_metadata() { mint_signer: mint_signer_pda, cmint: cmint_pda, compression_config: config_pda, - ctoken_compressible_config: COMPRESSIBLE_CONFIG_V1, - ctoken_rent_sponsor: CTOKEN_RENT_SPONSOR, + light_token_compressible_config: COMPRESSIBLE_CONFIG_V1, + rent_sponsor: RENT_SPONSOR, light_token_program: LIGHT_TOKEN_PROGRAM_ID.into(), - ctoken_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), + light_token_cpi_authority: light_token_types::CPI_AUTHORITY_PDA.into(), system_program: solana_sdk::system_program::ID, }; @@ -143,7 +139,7 @@ async fn test_create_mint_with_metadata() { let mint: Mint = borsh::BorshDeserialize::deserialize(&mut &cmint_account.data[..]) .expect("Failed to deserialize Mint"); - // Verify decimals match what was specified in #[light_mint] + // Verify decimals match what was specified in #[light_account(init)] assert_eq!(mint.base.decimals, 9, "Mint should have 9 decimals"); // Verify mint authority diff --git a/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs b/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs index 7b12e5a950..530fa8b8da 100644 --- a/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs +++ b/sdk-tests/sdk-token-test/src/ctoken_pda/mint.rs @@ -54,7 +54,7 @@ pub fn process_mint_action<'a, 'info>( mint_signer: Some(ctx.accounts.mint_seed.as_ref()), authority: ctx.accounts.mint_authority.as_ref(), fee_payer: ctx.accounts.payer.as_ref(), - cpi_authority_pda: ctx.accounts.ctoken_cpi_authority.as_ref(), + cpi_authority_pda: ctx.accounts.light_token_cpi_authority.as_ref(), cpi_context: cpi_accounts.cpi_context().unwrap(), cpi_signer: crate::LIGHT_CPI_SIGNER, recipient_token_accounts: vec![], diff --git a/sdk-tests/sdk-token-test/src/ctoken_pda/mod.rs b/sdk-tests/sdk-token-test/src/ctoken_pda/mod.rs index 9a327540f1..5b0d561ce3 100644 --- a/sdk-tests/sdk-token-test/src/ctoken_pda/mod.rs +++ b/sdk-tests/sdk-token-test/src/ctoken_pda/mod.rs @@ -13,5 +13,5 @@ pub struct CTokenPda<'info> { /// CHECK: pub light_token_program: UncheckedAccount<'info>, /// CHECK: - pub ctoken_cpi_authority: UncheckedAccount<'info>, + pub light_token_cpi_authority: UncheckedAccount<'info>, } diff --git a/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs b/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs index 1e9fa397ea..33798fae69 100644 --- a/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs +++ b/sdk-tests/sdk-token-test/src/pda_ctoken/mint.rs @@ -57,7 +57,7 @@ pub fn process_mint_action<'a, 'info>( mint_signer: Some(ctx.accounts.mint_seed.as_ref()), authority: ctx.accounts.mint_authority.as_ref(), fee_payer: ctx.accounts.payer.as_ref(), - compressed_token_cpi_authority: ctx.accounts.ctoken_cpi_authority.as_ref(), + compressed_token_cpi_authority: ctx.accounts.light_token_cpi_authority.as_ref(), registered_program_pda: cpi_accounts.registered_program_pda().unwrap(), account_compression_authority: cpi_accounts.account_compression_authority().unwrap(), account_compression_program: cpi_accounts.account_compression_program().unwrap(), @@ -75,7 +75,7 @@ pub fn process_mint_action<'a, 'info>( // Get all account infos needed for the mint action let mut account_infos = cpi_accounts.to_account_infos(); - account_infos.push(ctx.accounts.ctoken_cpi_authority.to_account_info()); + account_infos.push(ctx.accounts.light_token_cpi_authority.to_account_info()); account_infos.push(ctx.accounts.light_token_program.to_account_info()); account_infos.push(ctx.accounts.mint_authority.to_account_info()); account_infos.push(ctx.accounts.mint_seed.to_account_info()); diff --git a/sdk-tests/sdk-token-test/src/pda_ctoken/mod.rs b/sdk-tests/sdk-token-test/src/pda_ctoken/mod.rs index 5158622533..5c3ef6be29 100644 --- a/sdk-tests/sdk-token-test/src/pda_ctoken/mod.rs +++ b/sdk-tests/sdk-token-test/src/pda_ctoken/mod.rs @@ -18,5 +18,5 @@ pub struct PdaCToken<'info> { /// CHECK: pub light_token_program: UncheckedAccount<'info>, /// CHECK: - pub ctoken_cpi_authority: UncheckedAccount<'info>, + pub light_token_cpi_authority: UncheckedAccount<'info>, } diff --git a/sdk-tests/sdk-token-test/tests/ctoken_pda.rs b/sdk-tests/sdk-token-test/tests/ctoken_pda.rs index 74e997c337..5b2816ffcd 100644 --- a/sdk-tests/sdk-token-test/tests/ctoken_pda.rs +++ b/sdk-tests/sdk-token-test/tests/ctoken_pda.rs @@ -227,7 +227,7 @@ pub async fn create_mint( mint_authority: mint_authority.pubkey(), mint_seed: mint_seed.pubkey(), light_token_program: Pubkey::new_from_array(LIGHT_TOKEN_PROGRAM_ID), - ctoken_cpi_authority: Pubkey::new_from_array(CPI_AUTHORITY_PDA), + light_token_cpi_authority: Pubkey::new_from_array(CPI_AUTHORITY_PDA), }; let pda_new_address_params = light_sdk::address::NewAddressParamsAssignedPacked { diff --git a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs index 7709a019b2..b9cace9e17 100644 --- a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs +++ b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs @@ -298,7 +298,7 @@ pub async fn create_mint( mint_authority: mint_authority.pubkey(), mint_seed: mint_seed.pubkey(), light_token_program: Pubkey::new_from_array(LIGHT_TOKEN_PROGRAM_ID), - ctoken_cpi_authority: Pubkey::new_from_array(CPI_AUTHORITY_PDA), + light_token_cpi_authority: Pubkey::new_from_array(CPI_AUTHORITY_PDA), token_account, };