Skip to content

refactor: simplify create ctoken (ata) contructor#2095

Merged
SwenSchaeferjohann merged 1 commit intomainfrom
jorrit/refactore-simplify-create-ctoken-construtor
Dec 5, 2025
Merged

refactor: simplify create ctoken (ata) contructor#2095
SwenSchaeferjohann merged 1 commit intomainfrom
jorrit/refactore-simplify-create-ctoken-construtor

Conversation

@ananas-block
Copy link
Contributor

@ananas-block ananas-block commented Dec 5, 2025

Summary by CodeRabbit

  • New Features

    • Added builder-style configuration method for token creation optional settings.
  • API Changes

    • Simplified constructor signatures for token account creation by removing optional parameter requirements; optional configurations now available through dedicated method.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 5, 2025

Walkthrough

This PR refactors token account creation APIs to adopt a builder pattern. Constructor signatures are simplified by removing the CompressibleParams parameter and initializing with defaults instead. A new with_compressible() fluent method enables optional configuration post-construction. All callers are updated accordingly.

Changes

Cohort / File(s) Change Summary
Constructor refactoring – Token creation APIs
sdk-libs/compressed-token-sdk/src/ctoken/create.rs, sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
Removed CompressibleParams from CreateCTokenAccount::new() and CreateAssociatedTokenAccount::new() / new_with_bump() signatures. Constructors now initialize with CompressibleParams::default(). Added new public with_compressible() builder method to configure compressible params after construction.
Test updates
sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
Updated all test constructor calls to omit CompressibleParams argument. Removed unnecessary clones and simplified imports. Test logic remains functionally equivalent.
Caller-side adaptation
sdk-libs/token-client/src/actions/create_compressible_token_account.rs
Updated CreateCTokenAccount::new() call to use the new builder pattern: chained .with_compressible(compressible_params) after construction instead of passing params to the constructor.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Areas requiring extra attention:

  • Constructor signature consistency: Verify all internal and external callers of CreateCTokenAccount::new(), CreateAssociatedTokenAccount::new(), and CreateAssociatedTokenAccount::new_with_bump() have been updated to match the new parameter lists and use the builder pattern where CompressibleParams configuration is needed.
  • Builder method chaining: Confirm that with_compressible() is properly integrated into call chains and that the fluent API doesn't mask any default behavior changes or side effects.
  • Test coverage: Ensure tests cover both the default initialization path and the explicit with_compressible() configuration path to verify the builder pattern works as intended.

Possibly related PRs

Suggested labels

ai-review

Suggested reviewers

  • sergeytimoshin
  • SwenSchaeferjohann

Poem

🏗️ Builders emerge with fluent grace,
Defaults step in to save the place,
With_compressible chains the way,
Constructors simpler, brighter day!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 70.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main refactoring work: simplifying the constructor for create ctoken and ATA by removing the compressible_params parameter and adding a fluent builder method.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch jorrit/refactore-simplify-create-ctoken-construtor

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21ddf7a and abdb1e3.

⛔ Files ignored due to path filters (25)
  • program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/create.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/create_ata.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/create_ata2.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/functional.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/functional_ata.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/ctoken/shared.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/mint/edge_cases.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/mint/failing.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/mint/functional.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/mint/random.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/compress_failing.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/shared.rs is excluded by none and included by none
  • program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs is excluded by none and included by none
  • program-tests/registry-test/tests/compressible.rs is excluded by none and included by none
  • sdk-tests/sdk-ctoken-test/tests/shared.rs is excluded by none and included by none
  • sdk-tests/sdk-ctoken-test/tests/test_transfer_interface.rs is excluded by none and included by none
  • sdk-tests/sdk-ctoken-test/tests/test_transfer_spl_ctoken.rs is excluded by none and included by none
  • sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs is excluded by none and included by none
  • sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs is excluded by none and included by none
  • sdk-tests/sdk-token-test/tests/pda_ctoken.rs is excluded by none and included by none
  • sdk-tests/sdk-token-test/tests/test_4_transfer2.rs is excluded by none and included by none
📒 Files selected for processing (4)
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs (1 hunks)
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs (2 hunks)
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (5 hunks)
  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
sdk-libs/**/*.rs

📄 CodeRabbit inference engine (CLAUDE.md)

Unit tests in sdk-libs must not depend on light-test-utils; any test requiring light-test-utils must be in sdk-tests

Files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
🧠 Learnings (32)
📓 Common learnings
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-11-24T17:55:32.059Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/*.rs : Use the builder pattern from `light-compressed-token-sdk::ctoken` module for CPI operations instead of manual instruction building
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:30.871Z
Learning: Use light-compressed-token-sdk functions from sdk-libs/compressed-token-sdk for testing ctoken instructions
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:54.689Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CREATE_TOKEN_ACCOUNT.md : Create Token Account Instructions documentation must cover creation of regular and associated ctoken accounts
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/README.md:0-0
Timestamp: 2025-11-24T17:54:38.537Z
Learning: Implement compressed token program interfaces for third-party token creation and usage on Solana using ZK Compression
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-11-24T17:55:32.059Z
Learning: Document compressible token account features and PDA pattern use cases in program documentation
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/anchor/README.md:0-0
Timestamp: 2025-11-24T17:54:33.614Z
Learning: Implement the Compressed Token Program interface for creating and using compressed tokens on Solana with ZK Compression
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-11-24T18:00:13.178Z
Learning: Applies to program-libs/compressible/docs/**/*instruction*.rs : Validate CompressibleConfig state using `validate_active()` method to ensure state == Active before allowing new compressed token account creation
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/**/*.rs : Compressed token accounts (ctoken solana accounts) must use the same account layout as SPL tokens with a custom Compressible extension
📚 Learning: 2025-11-24T18:01:14.087Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:14.087Z
Learning: Applies to program-libs/compressible/**/*.rs : Use `calculate_rent_and_balance` function to determine if a CToken account is compressible

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/decompress_context.rs : Decompression trait implementation (`DecompressContext`) with account accessors, PDA/token separation logic, and token processing delegation should be in `decompress_context.rs`

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:14.087Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:14.087Z
Learning: Applies to program-libs/compressible/**/*.rs : Use `calculate_close_lamports` function to determine lamport distribution when closing CToken accounts

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/*.rs : Create wrapper instruction module at `src/account_compression_cpi/new_operation.rs` with `NewOperationContext` struct defining required accounts

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T17:55:32.059Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-11-24T17:55:32.059Z
Learning: Applies to sdk-tests/sdk-ctoken-test/**/*.rs : Use the builder pattern from `light-compressed-token-sdk::ctoken` module for CPI operations instead of manual instruction building

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/**/*.rs : Compressed token accounts (ctoken solana accounts) must use the same account layout as SPL tokens with a custom Compressible extension

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:14.087Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:14.087Z
Learning: Applies to program-libs/compressible/**/*.rs : Derive PDA addresses using `derive_pda` and `derive_v1_config_pda` functions for CToken account configuration

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/instructions.rs : Compress/decompress instruction handlers and context struct generation should be implemented in `instructions.rs`, with compress using PDA-only and decompress supporting full PDA + ctoken

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
📚 Learning: 2025-11-24T18:00:13.178Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-11-24T18:00:13.178Z
Learning: Applies to program-libs/compressible/docs/**/*instruction*.rs : Validate CompressibleConfig state using `validate_active()` method to ensure state == Active before allowing new compressed token account creation

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
📚 Learning: 2025-11-24T17:55:17.323Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-libs/macros/src/compressible/README.md:0-0
Timestamp: 2025-11-24T17:55:17.323Z
Learning: Applies to sdk-libs/macros/src/compressible/**/variant_enum.rs : Account variant enum (`CompressedAccountVariant`) generation and `CompressedAccountData` wrapper struct should be implemented in `variant_enum.rs`

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/close_token_account.rs : Close Token Account instruction must return rent exemption to rent recipient if compressible, and return remaining lamports to destination account

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/create_*_account*.rs : Token account creation instructions (Create CToken Account and Create Associated CToken Account) require ACTIVE config validation only

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T17:55:32.059Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-ctoken-test/README.md:0-0
Timestamp: 2025-11-24T17:55:32.059Z
Learning: Implement all 8 core compressed token operations: create_cmint, mint_to_ctoken, create_token_account_invoke, create_token_account_invoke_signed, create_ata_invoke, create_ata_invoke_signed, transfer_interface_invoke, and transfer_interface_invoke_signed

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:01:54.689Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/docs/instructions/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:54.689Z
Learning: Applies to programs/compressed-token/program/docs/instructions/instructions/CREATE_TOKEN_ACCOUNT.md : Create Token Account Instructions documentation must cover creation of regular and associated ctoken accounts

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/transfer2/**/*.rs : Transfer2 instruction must support Compress, Decompress, and CompressAndClose operations with multi-mint support and sum checks

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/{claim,transfer2}/**/*.rs : Rent authority can only compress accounts when is_compressible() returns true; lamport distribution on close is: rent → rent_sponsor, unutilized → destination

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:59:54.233Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/account-checks/docs/PACKED_ACCOUNTS.md:0-0
Timestamp: 2025-11-24T17:59:54.233Z
Learning: Applies to program-libs/account-checks/docs/program-libs/account-checks/src/**/*.rs : Provide descriptive names in ProgramPackedAccounts error messages (e.g., 'token_mint' instead of 'account')

Applied to files:

  • sdk-libs/token-client/src/actions/create_compressible_token_account.rs
📚 Learning: 2025-11-24T18:00:13.178Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/docs/CONFIG_ACCOUNT.md:0-0
Timestamp: 2025-11-24T18:00:13.178Z
Learning: Applies to program-libs/compressible/docs/**/config.rs : Set CompressibleConfig default values for CToken V1: base_rent = 1220, compression_cost = 11000, lamports_per_byte_per_epoch = 10, and address_space[0] = `amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx`

Applied to files:

  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
📚 Learning: 2025-11-24T18:02:15.670Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/registry/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:15.670Z
Learning: Applies to programs/registry/src/account_compression_cpi/mod.rs : Export new wrapper modules in `account_compression_cpi/mod.rs` using `pub mod new_operation;` and `pub use new_operation::*;`, then import in `lib.rs`

Applied to files:

  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: When working with ctoken accounts having the compressible extension, you must read program-libs/compressible/docs/ documentation including RENT.md, CONFIG_ACCOUNT.md, and SOLANA_RENT.md for rent system understanding

Applied to files:

  • sdk-libs/compressed-token-sdk/src/ctoken/create.rs
📚 Learning: 2025-11-24T18:01:30.012Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-tests/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:30.012Z
Learning: Run compressed token core tests using `cargo test-sbf -p compressed-token-test --test ctoken`, `--test v1`, `--test mint`, and `--test transfer2`

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:54:38.537Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/README.md:0-0
Timestamp: 2025-11-24T17:54:38.537Z
Learning: Implement compressed token program interfaces for third-party token creation and usage on Solana using ZK Compression

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:54:33.614Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/anchor/README.md:0-0
Timestamp: 2025-11-24T17:54:33.614Z
Learning: Implement the Compressed Token Program interface for creating and using compressed tokens on Solana with ZK Compression

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:02:30.871Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: sdk-tests/sdk-token-test/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:02:30.871Z
Learning: Use light-compressed-token-sdk functions from sdk-libs/compressed-token-sdk for testing ctoken instructions

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:56:00.229Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/CLAUDE.md:0-0
Timestamp: 2025-11-24T17:56:00.229Z
Learning: Applies to program-libs/batched-merkle-tree/docs/**/Cargo.toml : Depend on light-compressed-account crate for compressed account types and utilities

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/src/mint_action/**/*.rs : MintAction instruction must support 9 action types: CreateCompressedMint, MintTo, UpdateMintAuthority, UpdateFreezeAuthority, CreateSplMint, MintToCToken, UpdateMetadataField, UpdateMetadataAuthority, RemoveMetadataKey

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:01:42.343Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: programs/compressed-token/program/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:42.343Z
Learning: Applies to programs/compressed-token/program/docs/ACCOUNTS.md : All account documentation must include: description, discriminator, state layout, serialization example, hashing (for compressed accounts only), derivation (for PDAs only), and associated instructions

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:56:50.011Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_STATE_TREE.md:0-0
Timestamp: 2025-11-24T17:56:50.011Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_state_tree.rs : Initialize an output queue account as `BatchedQueueAccount` with `QueueType::OutputStateV2`, temporary storage for compressed account hashes before tree insertion with immediate spending capability via proof-by-index, using discriminator b`queueacc` [113, 117, 101, 117, 101, 97, 99, 99]

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:56:20.711Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/INITIALIZE_ADDRESS_TREE.md:0-0
Timestamp: 2025-11-24T17:56:20.711Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/initialize_address_tree.rs : Set discriminator to `BatchMta` `[66, 97, 116, 99, 104, 77, 116, 97]` (8 bytes) for BatchedMerkleTreeAccount in `src/initialize_address_tree.rs`.

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T17:57:39.230Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/batched-merkle-tree/docs/QUEUE_ACCOUNT.md:0-0
Timestamp: 2025-11-24T17:57:39.230Z
Learning: Applies to program-libs/batched-merkle-tree/docs/src/queue.rs : Validate account ownership by Light account compression program using `check_owner` from `light-account-checks` when deserializing `BatchedQueueAccount` with `output_from_account_info`

Applied to files:

  • sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs
📚 Learning: 2025-11-24T18:01:14.087Z
Learnt from: CR
Repo: Lightprotocol/light-protocol PR: 0
File: program-libs/compressible/CLAUDE.md:0-0
Timestamp: 2025-11-24T18:01:14.087Z
Learning: Applies to program-libs/compressible/**/*.rs : Use Anchor serialization for CompressibleConfig account structures in Rust programs

Applied to files:

  • sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs
🧬 Code graph analysis (3)
sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/create.rs (2)
  • new (24-32)
  • new (101-115)
sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (2)
sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs (6)
  • derive_ctoken_ata (20-29)
  • new (47-58)
  • new (154-173)
  • new (267-283)
  • new_with_bump (60-76)
  • new_with_bump (285-302)
sdk-libs/compressed-token-sdk/src/ctoken/create.rs (2)
  • new (24-32)
  • new (101-115)
sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs (3)
sdk-libs/compressed-token-sdk/src/ctoken/create.rs (2)
  • new (24-32)
  • new (101-115)
sdk-libs/compressed-token-sdk/src/ctoken/compressible.rs (3)
  • new (37-39)
  • new (59-74)
  • default (20-29)
sdk-libs/compressed-token-sdk/src/ctoken/mod.rs (1)
  • default (65-76)
🔇 Additional comments (6)
sdk-libs/compressed-token-sdk/src/ctoken/create.rs (2)

24-31: LGTM! Builder pattern simplifies API.

The constructor now provides sensible defaults via CompressibleParams::default(), making the common case easier. Combined with the new with_compressible method, this gives users flexibility without forcing complexity upfront.

Based on learnings, this aligns with the builder pattern approach recommended for ctoken operations.


34-37: Builder method correctly implemented.

The fluent with_compressible method allows optional configuration after construction, completing the builder pattern.

sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (1)

1-23: Tests updated correctly for new API.

All test cases properly reflect the simplified constructor signatures without CompressibleParams.

sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs (2)

46-76: V1 API correctly adopts builder pattern.

The CreateAssociatedTokenAccount constructor now provides sensible defaults and the with_compressible builder method enables customization. Both new and new_with_bump variants follow the same pattern.


78-81: Builder method correctly implemented.

sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)

66-70: LGTM! Proper usage of the new builder pattern.

The code correctly constructs a CreateCTokenAccount with the simplified four-parameter constructor, then applies with_compressible to configure compressibility before building the instruction. This demonstrates the intended usage pattern.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ananas-block ananas-block force-pushed the jorrit/refactore-simplify-create-ctoken-construtor branch from 7a5a4ce to abdb1e3 Compare December 5, 2025 02:21
@SwenSchaeferjohann SwenSchaeferjohann merged commit 5fcb2f4 into main Dec 5, 2025
28 checks passed
@SwenSchaeferjohann SwenSchaeferjohann deleted the jorrit/refactore-simplify-create-ctoken-construtor branch December 5, 2025 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants