refactor: ctoken sdk dir structure#2065
Conversation
WalkthroughThis PR restructures the compressed-token SDK by reorganizing the instruction module hierarchy. It introduces Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Areas requiring extra attention:
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 10
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
116-117: Remove debug println! statements before merging.These debug statements should not be present in production code. They can impact performance and potentially expose sensitive configuration data.
Apply this diff to remove the debug statements:
- println!("config {:?}", config); - println!("default_pubkeys {:?}", default_pubkeys); // token_pool_pda (mut) metas.push(AccountMeta::new(config.token_pool_pda, false));
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (53)
program-tests/compressed-token-test/tests/ctoken/compress_and_close.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create_ata.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create_ata2.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/functional.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/functional_ata.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/shared.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/cpi_context.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/edge_cases.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/functional.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/random.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/compress_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/decompress_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/shared.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/spl_ctoken.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/transfer_failing.rsis excluded by none and included by noneprogram-tests/registry-test/tests/compressible.rsis excluded by none and included by noneprogram-tests/utils/src/assert_create_token_account.rsis excluded by none and included by noneprogram-tests/utils/src/assert_mint_to_compressed.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/src/instructions/create_user_record_and_game_session.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/src/instructions/decompress_accounts_idempotent.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/tests/multi_account_tests.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/ctoken_pda/mint.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/lib.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/pda_ctoken/mint.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_batch_compress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi_context.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi_indices.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_full_and_close.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_create_compressed_account.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_decompress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_four_invokes.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_four_transfer2.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_transfer_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_update_deposit.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/compress_and_close_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/ctoken_pda.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/decompress_full_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/pda_ctoken.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_4_invocations.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_4_transfer2.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_compress_full_and_close.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_deposit.rsis excluded by none and included by nonetypedoc.stateless.jsonis excluded by none and included by none
📒 Files selected for processing (50)
forester/src/compressible/compressor.rs(1 hunks)forester/tests/test_compressible_ctoken.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_infos.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs(2 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs(2 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressible/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/ctoken/mod.rs(2 hunks)sdk-libs/compressed-token-sdk/src/ctoken/transfer_ctoken.rs(1 hunks)sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs(1 hunks)sdk-libs/compressed-token-sdk/src/instructions/burn.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/ctoken_accounts.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/mint_to.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/mod.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/transfer_ctoken.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs(0 hunks)sdk-libs/compressed-token-sdk/src/lib.rs(1 hunks)sdk-libs/compressed-token-sdk/src/utils.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/account_metas_test.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/mint_action_cpi_accounts_tests.rs(1 hunks)sdk-libs/program-test/src/forester/compress_and_close_forester.rs(1 hunks)sdk-libs/token-client/src/actions/create_compressible_token_account.rs(1 hunks)sdk-libs/token-client/src/actions/mint_action.rs(2 hunks)sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs(2 hunks)sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs(2 hunks)sdk-libs/token-client/src/instructions/create_mint.rs(1 hunks)sdk-libs/token-client/src/instructions/mint_action.rs(1 hunks)sdk-libs/token-client/src/instructions/mint_to_compressed.rs(1 hunks)sdk-libs/token-client/src/instructions/transfer2.rs(1 hunks)sdk-libs/token-client/src/instructions/update_compressed_mint.rs(1 hunks)
💤 Files with no reviewable changes (6)
- sdk-libs/compressed-token-sdk/src/instructions/ctoken_accounts.rs
- sdk-libs/compressed-token-sdk/src/instructions/burn.rs
- sdk-libs/compressed-token-sdk/src/instructions/mint_to.rs
- sdk-libs/compressed-token-sdk/src/instructions/transfer_interface.rs
- sdk-libs/compressed-token-sdk/src/instructions/transfer_ctoken.rs
- sdk-libs/compressed-token-sdk/src/instructions/mod.rs
🧰 Additional context used
🧬 Code graph analysis (29)
sdk-libs/token-client/src/instructions/create_mint.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
get_batch_compress_instruction_account_metas(72-183)
forester/tests/test_compressible_ctoken.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/token-client/src/actions/mint_action.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (3)
create_compressed_mint(190-194)derive_compressed_mint_address(197-206)find_spl_mint_address(216-221)sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (2)
create_associated_token_account(102-108)derive_ctoken_ata(230-239)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
get_mint_action_instruction_account_metas(172-277)get_mint_action_instruction_account_metas_cpi_write(291-321)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs (1)
get_approve_instruction_account_metas(47-136)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
get_mint_action_instruction_account_metas(172-277)
sdk-libs/token-client/src/instructions/update_compressed_mint.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
update_compressed_mint(93-95)
sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/create_token_account/instruction.rs (1)
create_token_account(92-118)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (2)
create_compressed_mint(190-194)find_spl_mint_address(216-221)
sdk-libs/token-client/src/instructions/mint_action.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (3)
create_compressed_mint(190-194)derive_compressed_mint_address(197-206)find_spl_mint_address(216-221)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
get_mint_action_instruction_account_metas(172-277)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
get_mint_action_instruction_account_metas(172-277)get_mint_action_instruction_account_metas_cpi_write(291-321)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/compressed-token-sdk/src/ctoken/mod.rs (5)
sdk-libs/sdk/src/compressible/close.rs (1)
close(6-40)sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (1)
create_associated_token_account(102-108)sdk-libs/compressed-token-sdk/src/ctoken/create_token_account/instruction.rs (1)
create_token_account(92-118)sdk-libs/token-client/src/actions/ctoken_transfer.rs (1)
transfer_ctoken(20-38)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs (2)
sdk-libs/compressed-token-sdk/src/token_pool.rs (1)
find_token_pool_pda_with_index(20-28)program-libs/compressed-account/src/pubkey.rs (1)
new_from_array(79-81)
sdk-libs/compressed-token-sdk/src/utils.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
default(464-471)
sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs (2)
sdk-libs/compressed-token-sdk/src/token_pool.rs (1)
find_token_pool_pda_with_index(20-28)program-libs/compressed-account/src/pubkey.rs (1)
new_from_array(79-81)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
programs/registry/src/lib.rs (1)
compress_and_close(775-790)
sdk-libs/token-client/src/instructions/transfer2.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
update_compressed_mint(93-95)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
get_transfer_instruction_account_metas(138-221)sdk-libs/compressed-token-sdk/src/compressed_token/v1/account.rs (2)
new_empty(46-62)mint(182-184)
sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (1)
create_associated_token_account(102-108)
sdk-libs/compressed-token-sdk/src/ctoken/transfer_ctoken.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs (11)
invoke(54-67)invoke(189-202)invoke(331-344)invoke(524-588)invoke_signed(69-82)invoke_signed(204-217)invoke_signed(346-359)invoke_signed(594-658)from(86-98)from(221-233)from(363-375)
sdk-libs/token-client/src/instructions/mint_to_compressed.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (2)
create_compressed_mint(190-194)derive_cmint_from_spl_mint(208-214)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
create_mint_to_compressed_instruction(41-110)
sdk-libs/compressed-token-sdk/tests/account_metas_test.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
get_batch_compress_instruction_account_metas(72-183)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
get_transfer_instruction_account_metas(138-221)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs (3)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
approve(86-88)programs/compressed-token/anchor/src/lib.rs (1)
batch_compress(98-123)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (1)
transfer(205-231)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs (1)
get_transfer2_instruction_account_metas(50-126)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs (5)
sdk-libs/compressed-token-sdk/src/ctoken/transfer_ctoken.rs (5)
invoke(27-31)invoke_signed(33-37)instruction(23-25)instruction(52-67)from(41-48)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (2)
create_transfer2_instruction(69-138)new(27-29)sdk-libs/compressed-token-sdk/src/utils.rs (1)
is_ctoken_account(22-37)sdk-libs/compressed-token-sdk/src/compressed_token/v2/account2.rs (6)
mint(362-364)new(23-51)compress_spl(193-220)decompress_ctoken(224-247)compress_ctoken(169-190)decompress_spl(250-279)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs (2)
new(21-31)new_decompressed_accounts_only(33-46)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
- GitHub Check: Forester e2e test
- GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
- GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
- GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
- GitHub Check: programs (compressed-token-and-e2e, ["cargo-test-sbf -p compressed-token-test --test v1", "cargo-...
🔇 Additional comments (46)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
4-4: LGTM! Import path updated correctly.The import path change from
crate::instructions::CTokenDefaultAccountstocrate::utils::CTokenDefaultAccountsaligns with the directory structure refactor.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/account_metas.rs (1)
4-4: LGTM! Import path updated correctly.The import path change from
crate::instructions::CTokenDefaultAccountstocrate::utils::CTokenDefaultAccountsis consistent with the directory structure refactor.sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs (1)
8-8: LGTM! Idiomatic relative import.The change from
crate::instructions::batch_compress::account_metastosuper::account_metasuses idiomatic Rust relative imports for sibling modules, which is cleaner and more maintainable.sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
17-22: LGTM! Import paths updated for new module structure.The import path changes from
crate::instructions::mint_actiontocrate::compressed_token::mint_actioncorrectly reflect the reorganized module structure.sdk-libs/token-client/src/instructions/update_compressed_mint.rs (1)
7-9: LGTM! External import path updated correctly.The import path change from
instructions::update_compressed_minttocompressed_token::update_compressed_mintcorrectly reflects the public API reorganization of the compressed-token-sdk.sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
8-8: LGTM! Import path updated for new public API surface.The import path change from
instructions::compress_and_closetocompressed_token::compress_and_closecorrectly reflects the SDK's reorganized public API structure.sdk-libs/compressed-token-sdk/src/compressible/mod.rs (1)
1-5: LGTM! Standard module organization pattern.The module structure follows idiomatic Rust patterns with module declarations and re-exports, making the compressible functionality accessible at the parent module level.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/account_metas.rs (1)
4-4: LGTM - Import path updated consistently.Same refactoring pattern as other v2 modules.
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs (1)
4-4: LGTM - Import path updated consistently.sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs (1)
6-6: LGTM - Import path updated consistently.sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
4-4: LGTM - Import path updated consistently.sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (1)
1-1: LGTM - Test updated to use new SDK module structure.The import path has been updated from
instructions::create_associated_token_accounttoctoken::create_associated_token_account, reflecting the SDK's reorganization.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs (2)
1-9: All declared modules are present and correctly declared.Verification confirms that all nine modules—both the private
account2and the eight public v2 API modules—exist as files in the v2 directory. The module declarations properly establish the public surface for the v2 API.
11-11: Re-export pattern is correct—no issues found.The
pub use account2::*;at line 11 appropriately exposes only theCTokenAccount2struct, which is clearly intended as part of the v2 module's public API. The account2 module remains a private implementation detail, with its sole public item properly re-exported. This is idiomatic Rust with good encapsulation.forester/src/compressible/compressor.rs (1)
6-6: LGTM - Import path correctly updated and verified across codebase.The import path has been successfully updated from
instructions::compress_and_closetocompressed_token::compress_and_close. Verification confirms no references to the oldlight_compressed_token_sdk::instructionsmodule remain in the codebase, and all other consumers (includingsdk-libs/program-test/src/forester/compress_and_close_forester.rs) are already using the new module paths. The migration is complete and consistent.sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/account_metas.rs (1)
4-4: Import path reorganization verified—no action needed.The import change from
crate::instructionstocrate::utilsis correct and properly integrated. Verification confirms:
CTokenDefaultAccountsis publicly exported fromsdk-libs/compressed-token-sdk/src/lib.rs(line 7:pub mod utils)- The struct is defined with proper visibility and a Default implementation
- No remaining references to the old import path exist in the codebase
- The updated import in
account_metas.rscorrectly accesses the type through the new module locationThe reorganization is complete and the module hierarchy is sound.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
11-13: LGTM - Clean import path refactoring.The module reorganization from
instructions::mint_actiontocompressed_token::mint_actionis consistent with the PR's directory restructuring objective. The imported items remain unchanged, preserving the existing functionality.forester/tests/test_compressible_ctoken.rs (1)
12-12: LGTM - Consistent path update in test file.The import path has been correctly updated to reflect the new module organization under
compressed_token. Usage throughout the test file remains unchanged.sdk-libs/compressed-token-sdk/tests/account_metas_test.rs (1)
2-10: LGTM - Well-organized import restructuring.The import paths have been properly updated to use
compressed_token::*paths, and the addition ofutils::CTokenDefaultAccountsmakes the import source explicit for theCTokenDefaultAccountstype used throughout the tests.sdk-libs/compressed-token-sdk/tests/mint_action_cpi_accounts_tests.rs (1)
4-6: LGTM - Straightforward path update.The import path correctly reflects the new module organization. Test functionality remains unchanged.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
13-18: LGTM - Import reorganization with minor reordering.The module path has been updated consistently with the rest of the PR. The reordering of the error import is acceptable and doesn't impact functionality.
sdk-libs/token-client/src/instructions/mint_to_compressed.rs (1)
7-12: LGTM - Nested import paths properly updated.The imports have been correctly reorganized to use the nested
compressed_token::module structure. The grouping undercreate_compressed_mintandmint_to_compressedsubmodules improves organization.sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)
2-5: No action required—module naming distinction is intentional and properly structured.The verification confirms that
ctokenandcompressed_tokenare distinct, deliberately-structured modules at the root level of the SDK.ctokenis the primary Compressed Token Program API (evidenced by its own program ID, CPI authority constants, andid()function), whilecompressed_tokenserves as a sibling module with utility and helper functionality. The import pathctoken::create_token_account::create_compressible_token_account_instructionis correct and aligns with the deliberate module hierarchy—there is no naming inconsistency.sdk-libs/token-client/src/instructions/transfer2.rs (1)
6-13: LGTM - Clean import path refactoring.The import paths have been successfully updated to reflect the new module structure, moving from the flatter
account2and standaloneerrormodules to the hierarchicalcompressed_tokenorganization. The grouping of transfer2-related items undercompressed_token::transfer2improves discoverability.sdk-libs/token-client/src/instructions/create_mint.rs (1)
5-7: LGTM - Import path updated correctly.The migration from
instructions::create_compressed_minttocompressed_token::create_compressed_mintis consistent with the directory restructuring. All imported items remain available.sdk-libs/token-client/src/instructions/mint_action.rs (1)
7-10: LGTM - Improved import organization.The restructured imports separate concerns more clearly, with
create_compressed_mintandmint_actionfunctionality now in distinct submodules undercompressed_token. This enhances maintainability.sdk-libs/token-client/src/actions/mint_action.rs (2)
5-5: LGTM - Top-level import updated correctly.The import path for
derive_compressed_mint_addresshas been updated to the new module structure.
102-105: LGTM - Scoped imports properly organized.The scoped imports are appropriately split between
compressed_token::create_compressed_mintandctoken::create_associated_token_accountmodules, reflecting their distinct concerns. Keeping these imports scoped to where they're used is good practice.sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_infos.rs (1)
6-6: LGTM - Import updated to v1 module structure.The explicit reference to
compressed_token::v1::CTokenAccountclarifies the version being used and aligns with the new versioned module organization.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
5-5: LGTM - Utility import relocated correctly.Moving
CTokenDefaultAccountstocrate::utilsis appropriate for shared utility types and improves discoverability.
197-200: LGTM - Function path updated to new module structure.The
find_spl_mint_addressfunction call now correctly references the new path undercompressed_token::create_compressed_mint.sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (2)
10-10: LGTM - Sibling module import using super::.Using
super::account_metasfor a sibling module in the same directory is more maintainable than a full crate path and clearly indicates the module relationship.
12-12: LGTM - CTokenAccount2 import path updated.The import has been successfully migrated from the standalone
account2module to thecompressed_tokenmodule structure.sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
17-24: LGTM - Well-organized import restructuring.The imports are now cleanly separated:
- Local v2 modules via
super::(account2, transfer2)- Shared utilities via
crate::(utils, error)This distinction makes the module relationships explicit and improves maintainability.
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
9-13: LGTM!Import paths correctly updated to reflect the new v1 module structure. The functionality remains unchanged.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/instruction.rs (1)
9-10: LGTM!Import paths correctly updated to use the new v2 module structure. No functional changes.
sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs (2)
37-49: LGTM! Builder pattern improves clarity.The transition from a function-based approach to a struct-based builder pattern (
TransferSplToCtoken) makes the field assignments more explicit and easier to follow.
46-46: Future work: Dynamic SPL token program support.The TODO indicates that
spl_token_programis currently hardcoded. Consider adding support for Token-2022 and other SPL token program variants in a future PR.sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (1)
9-14: LGTM!Import paths correctly updated for the new v1 module structure. The unqualified use of
CTokenAccount::new_emptyat line 173 is valid since the type is imported.sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs (2)
26-38: LGTM! Consistent builder pattern.The
TransferCtokenToSplstruct-based approach mirrors the changes inspl_to_ctoken.rs, providing consistency across the transfer operations.
35-35: Future work: Dynamic SPL token program support.Same TODO as in
spl_to_ctoken.rsabout making the SPL token program dynamic. Consider addressing both in the same future PR for consistency.sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs (1)
1-6: LGTM! Clean module organization.The pattern of a private
accountmodule with public re-export alongside public submodules (approve,batch_compress,transfer) is a standard Rust idiom for controlling API surface while maintaining internal organization flexibility.sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs (2)
14-21: LGTM! Import paths updated correctly.The reorganization consolidates imports from the new v2 module structure (
super::transfer2,super::account2) and shared utilities (crate::utils,crate::compat,crate::error). The changes maintain the same functionality with clearer module boundaries.
61-77: Signer flag logic is properly validated—no issues found.The bounds check you requested verification for already exists at lines 73-75:
let owner_idx = idx.source.owner as usize; if owner_idx >= signer_flags.len() { return Err(TokenSdkError::InvalidAccountData); } signer_flags[owner_idx] = true;The code correctly validates that
idx.source.owner(cast tousize) stays within bounds ofsigner_flagsbefore indexing. Thesigner_flagsvector is sized to matchpacked_accounts.len()at line 61, and any mismatch between pre-computed indices and the passed-in account slice is caught and rejected withInvalidAccountData. This handles the edge case: if a caller passes fewer accounts than the pre-computed indices expect, the error returns cleanly rather than panicking.sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs (1)
7-8: No naming conflicts exist between v1 and v2 wildcard re-exports.The verification shows that v1 and v2 maintain distinct public APIs with no overlapping names. v1 exports base operations (transfer, compress, decompress, approve, batch_compress) while v2 exports operation-specific variants (transfer2, mint_action, mint_to_compressed, compress_and_close, decompress_full, update_compressed_mint, create_compressed_mint). Account types are also clearly differentiated (CTokenAccount vs CTokenAccount2). The dual wildcard re-exports at the top level pose no risk of name collision or ambiguous imports.
sdk-libs/compressed-token-sdk/src/ctoken/mod.rs (1)
1-5: New ctoken submodules match the reorganized SDK surfaceExposing
close,create_associated_token_account,create_token_account,transfer_ctoken, andtransfer_interfacehere is consistent with the new structure and makes the ctoken API discoverable under a single module. No functional issues spotted.
| //pub mod cpi_helpers; | ||
| pub mod instruction; | ||
|
|
||
| pub use account_metas::*; |
There was a problem hiding this comment.
🧩 Analysis chain
Verify the new wildcard re-export is intentional.
Adding pub use account_metas::*; expands the public API surface of the transfer2 module. Ensure this is intentional and that all items in account_metas are meant to be publicly exposed at this level.
Wildcard re-exports can unintentionally expose internal items if new public items are added to account_metas in the future.
🏁 Script executed:
#!/bin/bash
# Description: Check what's being re-exported from account_metas
# Find all public items in the account_metas module
ast-grep --pattern $'pub $_ $NAME $_' sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs
# Also check if this follows the same pattern as other v2 modules
rg -n "pub use account_metas::\*;" sdk-libs/compressed-token-sdk/src/compressed_token/v2/ -C2Length of output: 482
I need to gather more information to verify this concern properly. Let me examine what's actually being re-exported.Now let me inspect the actual contents of the account_metas module to see what's being re-exported:
🏁 Script executed:
#!/bin/bash
# Get contents and public items from account_metas.rs
echo "=== Contents of account_metas.rs ==="
cat sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs
echo -e "\n=== Check if this is part of a wider re-export pattern in v2 ==="
find sdk-libs/compressed-token-sdk/src/compressed_token/v2 -name "mod.rs" -exec grep -l "pub use.*\*" {} \;Length of output: 4949
Let me check the parent module's re-export strategy:
🏁 Script executed:
#!/bin/bash
# Check parent module re-export pattern
echo "=== transfer2/mod.rs re-exports ==="
rg -n "pub use" sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/mod.rs -A1
echo -e "\n=== parent v2/mod.rs re-exports ==="
rg -n "pub use" sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs -A1
echo -e "\n=== Check for any module documentation/guidelines ==="
head -20 sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rsLength of output: 527
Use explicit named imports for consistency and maintainability.
The wildcard re-export is currently safe—account_metas only contains Transfer2AccountsMetaConfig and get_transfer2_instruction_account_metas, both reasonable to expose. However, this creates an inconsistency with the pattern already established in this file: line 8 shows cpi_helpers::* deliberately commented out, suggesting deliberate decisions about what enters the public API.
For consistency and to prevent unintended exposure of future additions, change:
pub use account_metas::*;to:
pub use account_metas::{Transfer2AccountsMetaConfig, get_transfer2_instruction_account_metas};This aligns with the selective re-export pattern (Transfer2CpiAccounts on line 7) and guards against accidental API surface expansion.
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/mod.rs around
line 6, replace the wildcard re-export `pub use account_metas::*;` with an
explicit named re-export to match the file's selective API pattern: export only
Transfer2AccountsMetaConfig and get_transfer2_instruction_account_metas by
changing the statement to `pub use account_metas::{Transfer2AccountsMetaConfig,
get_transfer2_instruction_account_metas};` so future additions to account_metas
won’t be accidentally exposed.
| pub use crate::compressed_token::create_compressed_mint::{ | ||
| derive_cmint_from_spl_mint, find_spl_mint_address, | ||
| }; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Re-export path update to compressed_token::create_compressed_mint looks correct
Switching the re-export from crate::instructions::create_compressed_mint to crate::compressed_token::create_compressed_mint aligns this module with the new top-level compressed_token API. Just ensure any external callers relying on the old path are updated or given a deprecation path as needed.
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/mod.rs around lines 42 to 44, the
re-export has been changed to point to
crate::compressed_token::create_compressed_mint; keep this new correct path, but
also add a compatibility re-export in the old module
(crate::instructions::create_compressed_mint) or update all external import
sites to the new path. Specifically, either (A) add a forwarding pub use in
crate::instructions that re-exports from
crate::compressed_token::create_compressed_mint to preserve existing callers
during a deprecation period, or (B) update downstream crates to import from
crate::compressed_token::create_compressed_mint and remove the old path; choose
one approach and apply consistent changes across affected modules.
| pub struct TransferCtoken { | ||
| pub source: Pubkey, | ||
| pub destination: Pubkey, | ||
| pub amount: u64, | ||
| pub authority: Pubkey, | ||
| } | ||
|
|
||
| pub struct TransferCtokenAccountInfos<'info> { | ||
| pub source: AccountInfo<'info>, | ||
| pub destination: AccountInfo<'info>, | ||
| pub amount: u64, | ||
| pub authority: AccountInfo<'info>, | ||
| } | ||
|
|
||
| impl<'info> TransferCtokenAccountInfos<'info> { | ||
| pub fn instruction(&self) -> Result<Instruction, ProgramError> { | ||
| TransferCtoken::from(self).instruction() | ||
| } | ||
|
|
||
| pub fn invoke(self) -> Result<(), ProgramError> { | ||
| let instruction = TransferCtoken::from(&self).instruction()?; | ||
| let account_infos = [self.source, self.destination, self.authority]; | ||
| invoke(&instruction, &account_infos) | ||
| } | ||
|
|
||
| pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> { | ||
| let instruction = TransferCtoken::from(&self).instruction()?; | ||
| let account_infos = [self.source, self.destination, self.authority]; | ||
| invoke_signed(&instruction, &account_infos, signer_seeds) | ||
| } | ||
| } | ||
|
|
||
| impl<'info> From<&TransferCtokenAccountInfos<'info>> for TransferCtoken { | ||
| fn from(account_infos: &TransferCtokenAccountInfos<'info>) -> Self { | ||
| Self { | ||
| source: *account_infos.source.key, | ||
| destination: *account_infos.destination.key, | ||
| amount: account_infos.amount, | ||
| authority: *account_infos.authority.key, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| impl TransferCtoken { | ||
| pub fn instruction(self) -> Result<Instruction, ProgramError> { | ||
| Ok(Instruction { | ||
| program_id: Pubkey::from(C_TOKEN_PROGRAM_ID), | ||
| accounts: vec![ | ||
| AccountMeta::new(self.source, false), | ||
| AccountMeta::new(self.destination, false), | ||
| AccountMeta::new_readonly(self.authority, true), | ||
| ], | ||
| data: { | ||
| let mut data = vec![3u8]; | ||
| data.push(3u8); | ||
| data.extend_from_slice(&self.amount.to_le_bytes()); | ||
| data | ||
| }, | ||
| }) | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Consider adding input validation and documentation.
While the implementation follows the pattern of similar transfer functions, consider adding:
- Input validation (e.g., non-zero amount checks)
- Documentation explaining the instruction format and account requirements
- A constant or well-documented reason for the
[3, 3]discriminator
Example documentation to add:
/// Transfer compressed tokens between two ctoken accounts.
///
/// # Instruction Format
/// - Discriminator: [3, 3] (corresponds to TransferCtoken instruction)
/// - Data: 8-byte little-endian amount
///
/// # Accounts
/// - `source`: Source ctoken account (writable)
/// - `destination`: Destination ctoken account (writable)
/// - `authority`: Transfer authority (signer)
pub struct TransferCtoken {🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/transfer_ctoken.rs around lines 8 to
67, add input validation and documentation: document the TransferCtoken struct
and its instruction format/accounts (describe discriminator [3,3], 8-byte LE
amount, source and destination writable, authority signer), introduce a named
constant for the discriminator (e.g., TRANSFER_CTOKEN_DISCRIMINATOR = [3u8,3u8])
instead of inline [3,3], and add a runtime check in instruction() to reject zero
amounts (return an appropriate ProgramError) before building the Instruction;
keep account metas consistent with the docs.
| let mut data = vec![3u8]; | ||
| data.push(3u8); | ||
| data.extend_from_slice(&self.amount.to_le_bytes()); | ||
| data |
There was a problem hiding this comment.
🧩 Analysis chain
Simplify data construction and verify instruction discriminator.
The data construction can be simplified, and the instruction discriminator [3, 3] should be verified against the program's instruction definitions.
Apply this diff to simplify the data construction:
data: {
- let mut data = vec![3u8];
- data.push(3u8);
- data.extend_from_slice(&self.amount.to_le_bytes());
- data
+ let mut data = vec![3u8, 3u8];
+ data.extend_from_slice(&self.amount.to_le_bytes());
+ data
},Please verify that the instruction discriminator [3, 3] is correct by checking it against the compressed token program's instruction enum:
🏁 Script executed:
#!/bin/bash
# Search for instruction discriminator definitions in the ctoken program
rg -n "discriminator|instruction.*enum" --type rust -g '*ctoken*' -g '*compressed*token*' -C 3Length of output: 1549
I see the search found related code but not the instruction enum definition itself. Let me dig deeper to find where the instruction discriminators are actually defined in the program.
🏁 Script executed:
#!/bin/bash
# Search for instruction enum in the compressed-token program
rg -n "pub enum.*[Ii]nstruction|#\[derive.*Instruction\]" --type rust -C 5Length of output: 4286
🏁 Script executed:
#!/bin/bash
# Look for Transfer instruction variant specifically
rg -n "Transfer\s*[{,=]|Transfer\s*\(" --type rust -C 3 | head -60Length of output: 5216
🏁 Script executed:
#!/bin/bash
# Check if discriminators are explicitly defined anywhere
rg -n "3\s*=>|=> 3|discriminant|TransferCtoken" --type rust -C 2Length of output: 33726
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| let mut data = vec![3u8]; | |
| data.push(3u8); | |
| data.extend_from_slice(&self.amount.to_le_bytes()); | |
| data | |
| let mut data = vec![3u8]; | |
| data.extend_from_slice(&self.amount.to_le_bytes()); | |
| data |
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/transfer_ctoken.rs around lines
61-64, the code currently constructs the instruction data as [3, 3, amount] by
initializing vec![3u8] and then calling data.push(3u8); remove the redundant
data.push(3u8) so the data buffer is only vec![3u8] followed by
extend_from_slice(&self.amount.to_le_bytes()), producing the correct single-byte
discriminator layout [3, amount].
| impl<'info> TransferSplToCtokenAccountInfos<'info> { | ||
| pub fn instruction(&self) -> Result<Instruction, ProgramError> { | ||
| TransferSplToCtoken::from(self).instruction() | ||
| } | ||
|
|
||
| pub fn invoke(self) -> Result<(), ProgramError> { | ||
| let instruction = TransferSplToCtoken::from(&self).instruction()?; | ||
| let account_infos = [ | ||
| self.payer, | ||
| self.compressed_token_program_authority, | ||
| self.mint, // Index 0: Mint | ||
| self.destination_ctoken_account, // Index 1: Destination owner | ||
| self.authority, // Index 2: Authority (signer) | ||
| self.source_spl_token_account, // Index 3: Source SPL token account | ||
| self.token_pool_pda, // Index 4: Token pool PDA | ||
| self.spl_token_program, // Index 5: SPL Token program | ||
| ]; | ||
| invoke(&instruction, &account_infos) | ||
| } | ||
|
|
||
| pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> { | ||
| let instruction = TransferSplToCtoken::from(&self).instruction()?; | ||
| let account_infos = [ | ||
| self.payer, | ||
| self.compressed_token_program_authority, | ||
| self.mint, // Index 0: Mint | ||
| self.destination_ctoken_account, // Index 1: Destination owner | ||
| self.authority, // Index 2: Authority (signer) | ||
| self.source_spl_token_account, // Index 3: Source SPL token account | ||
| self.token_pool_pda, // Index 4: Token pool PDA | ||
| self.spl_token_program, // Index 5: SPL Token program | ||
| ]; | ||
| invoke_signed(&instruction, &account_infos, signer_seeds) | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
SPL→ctoken path is structurally sound; consider de‑duplicating destination fields
The SPL→ctoken flow (TransferSplToCtoken*) looks internally consistent:
packed_accountsorder matches the comments and theaccount_infosorder ininvoke/invoke_signed.- Indices passed into
Compression::compress_splandCompression::decompress_ctokenline up with that order.
One minor API smell: TransferSplToCtokenAccountInfos<'info> carries both to: AccountInfo<'info> and destination_ctoken_account: AccountInfo<'info>, and the code assumes they refer to the same key (one for metas, one for infos). That opens the door to accidental mismatch if someone instantiates it manually.
If you don’t have a strong reason to keep both, consider collapsing them to a single field (e.g. destination_ctoken_account) and using that consistently in both From and invoke* paths.
Also applies to: 85-99, 101-157
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs around lines
49-82 (and likewise at 85-99 and 101-157), the struct carries both `to` and
`destination_ctoken_account` which are expected to be the same account but can
be set inconsistently; collapse them to a single field (e.g.
`destination_ctoken_account`), remove `to`, update all `From`/conversion impls
to populate metas from that one field, and update `invoke`/`invoke_signed` to
use the single field in the account_infos array and any comment/index references
so metas and AccountInfos always refer to the same key.
| pub fn invoke(self) -> Result<(), ProgramError> { | ||
| let instruction = TransferCtokenToSpl::from(&self).instruction()?; | ||
| let account_infos = [ | ||
| self.payer, | ||
| self.compressed_token_program_authority, | ||
| self.mint, // Index 0: Mint | ||
| self.source_ctoken_account, // Index 1: Source ctoken account | ||
| self.authority, // Index 3: Authority (signer) | ||
| self.destination_spl_token_account, // Index 2: Destination SPL token account | ||
| self.token_pool_pda, // Index 4: Token pool PDA | ||
| self.spl_token_program, // Index 5: SPL Token program | ||
| ]; | ||
| invoke(&instruction, &account_infos) |
There was a problem hiding this comment.
🧩 Analysis chain
AccountInfo ordering for ctoken→SPL flows doesn’t match AccountMeta indices
In both TransferCtokenToSplAccountInfos and CtokenToSplTransferAndCloseAccountInfos, the account_infos arrays used for invoke / invoke_signed don’t line up with the packed_accounts order in the corresponding instruction() builders:
- In
TransferCtokenToSpl::instruction()andCtokenToSplTransferAndClose::instruction():
let packed_accounts = vec![
// 0: Mint
AccountMeta::new_readonly(self.mint, false),
// 1: Source ctoken
AccountMeta::new(self.source_ctoken_account, false),
// 2: Destination SPL
AccountMeta::new(self.destination_spl_token_account, false),
// 3: Authority
AccountMeta::new_readonly(self.authority, true),
// 4: Token pool PDA
AccountMeta::new(self.token_pool_pda, false),
// 5: SPL Token program
AccountMeta::new_readonly(self.spl_token_program, false),
];- But in
invoke()you currently have (same forinvoke_signedand the*_AndClosevariant):
let account_infos = [
self.payer,
self.compressed_token_program_authority,
self.mint, // 0
self.source_ctoken_account, // 1
self.authority, // 3
self.destination_spl_token_account, // 2
self.token_pool_pda, // 4
self.spl_token_program, // 5
];After the two “extra” accounts (payer and compressed_token_program_authority), the metas expect the order
mint, source_ctoken, destination_spl, authority, pool, spl_program, but the infos are
mint, source_ctoken, authority, destination_spl, pool, spl_program. That swaps the authority and destination_spl accounts.
Because the Compression::decompress_spl(...) calls hard‑code indices like 2 for the destination SPL account and 3 for the authority, this mismatch means runtime will see the wrong accounts in those slots — at best failing verification, at worst acting on the wrong account.
You should keep the info ordering aligned with the meta ordering. For example:
@@ impl<'info> TransferCtokenToSplAccountInfos<'info> {
- pub fn invoke(self) -> Result<(), ProgramError> {
+ pub fn invoke(self) -> Result<(), ProgramError> {
let instruction = TransferCtokenToSpl::from(&self).instruction()?;
let account_infos = [
self.payer,
self.compressed_token_program_authority,
self.mint, // Index 0: Mint
self.source_ctoken_account, // Index 1: Source ctoken account
- self.authority, // Index 3: Authority (signer)
- self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.authority, // Index 3: Authority (signer)
self.token_pool_pda, // Index 4: Token pool PDA
self.spl_token_program, // Index 5: SPL Token program
];
invoke(&instruction, &account_infos)
}
@@
- pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> {
+ pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> {
let instruction = TransferCtokenToSpl::from(&self).instruction()?;
let account_infos = [
self.payer,
self.compressed_token_program_authority,
self.mint, // Index 0: Mint
self.source_ctoken_account, // Index 1: Source ctoken account
- self.authority, // Index 3: Authority (signer)
- self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.authority, // Index 3: Authority (signer)
self.token_pool_pda, // Index 4: Token pool PDA
self.spl_token_program, // Index 5: SPL Token program
];
invoke_signed(&instruction, &account_infos, signer_seeds)
}
@@ impl<'info> CtokenToSplTransferAndCloseAccountInfos<'info> {
- pub fn invoke(self) -> Result<(), ProgramError> {
+ pub fn invoke(self) -> Result<(), ProgramError> {
let instruction = CtokenToSplTransferAndClose::from(&self).instruction()?;
let account_infos = [
self.payer,
self.compressed_token_program_authority,
self.mint, // Index 0: Mint
self.source_ctoken_account, // Index 1: Source ctoken account
- self.authority, // Index 3: Authority (signer)
- self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.authority, // Index 3: Authority (signer)
self.token_pool_pda, // Index 4: Token pool PDA
self.spl_token_program, // Index 5: SPL Token program
];
invoke(&instruction, &account_infos)
}
@@
- pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> {
+ pub fn invoke_signed(self, signer_seeds: &[&[&[u8]]]) -> Result<(), ProgramError> {
let instruction = CtokenToSplTransferAndClose::from(&self).instruction()?;
let account_infos = [
self.payer,
self.compressed_token_program_authority,
self.mint, // Index 0: Mint
self.source_ctoken_account, // Index 1: Source ctoken account
- self.authority, // Index 3: Authority (signer)
- self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.destination_spl_token_account, // Index 2: Destination SPL token account
+ self.authority, // Index 3: Authority (signer)
self.token_pool_pda, // Index 4: Token pool PDA
self.spl_token_program, // Index 5: SPL Token program
];
invoke_signed(&instruction, &account_infos, signer_seeds)
}That keeps the post‑config ordering exactly aligned: mint (0), source (1), destination SPL (2), authority (3), pool (4), SPL program (5).
Given how tightly these indices are coded into the Compression calls, this should be treated as a correctness fix before merging.
Also applies to: 204-216, 331-343, 346-358
I'll verify the account ordering claim by examining the actual code structure. Let me start:Now let me run shell scripts to examine the actual code:
🏁 Script executed:
#!/bin/bash
# Fetch the transfer_interface.rs file to inspect the actual account ordering
find . -name "transfer_interface.rs" -type f | head -1Length of output: 68
🏁 Script executed:
#!/bin/bash
# Read the transfer_interface.rs file to examine account ordering
cat ./git/sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rsLength of output: 100
🏁 Script executed:
# Also search for hard-coded index usage in Compression calls
rg "Compression::" ./git/sdk-libs/compressed-token-sdk/src/ctoken/ -A 5 -B 2Length of output: 87
</parameter>
🏁 Script executed:
#!/bin/bash
# Find and display the transfer_interface.rs file
find . -type f -name "transfer_interface.rs" -exec cat {} \;Length of output: 27811
🏁 Script executed:
# Search for TransferCtokenToSplAccountInfos and CtokenToSplTransferAndCloseAccountInfos impls
rg "impl.*TransferCtokenToSplAccountInfos|impl.*CtokenToSplTransferAndCloseAccountInfos" -A 30 --type rsLength of output: 26
🏁 Script executed:
# Search for Compression decompress calls with index references
rg "decompress.*\[.*[0-9]" --type rs -B 2 -A 2Length of output: 26
Fix account ordering mismatch in TransferCtokenToSpl and CtokenToSplTransferAndClose flows
Your analysis is correct and critical. In both TransferCtokenToSplAccountInfos and CtokenToSplTransferAndCloseAccountInfos, the account_infos arrays have authority and destination_spl_token_account swapped relative to the packed_accounts order defined in their instruction() methods.
The packed_accounts order is:
- 0: Mint
- 1: Source ctoken
- 2: Destination SPL ← hard-coded in
Compression::decompress_spl() - 3: Authority ← hard-coded in
Compression::decompress_spl() - 4: Token pool
- 5: SPL Token program
But the account_infos arrays place them as:
- 2: Mint ✓
- 3: Source ctoken ✓
- 4: Authority ✗
- 5: Destination SPL ✗
- 6: Token pool ✓
- 7: SPL Token program ✓
At runtime, when Compression::decompress_spl() references index 2 for the destination SPL account, it will receive the authority account instead. This breaks account validation and token transfers.
Apply the suggested diff to all four methods:
TransferCtokenToSplAccountInfos::invoke()(line 189)TransferCtokenToSplAccountInfos::invoke_signed()(line 204)CtokenToSplTransferAndCloseAccountInfos::invoke()(line 331)CtokenToSplTransferAndCloseAccountInfos::invoke_signed()(line 346)
Reorder each account_infos array to place destination_spl_token_account at index 5 and authority at index 4 (following the two prefix accounts).
🤖 Prompt for AI Agents
sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs around lines
189-201 (and also update the analogous spots at ~204, ~331, ~346): the
account_infos arrays have destination_spl_token_account and authority swapped
relative to the instruction's packed_accounts (two prefix accounts shift
indices), causing Compression::decompress_spl() to read the wrong account; fix
by reordering each account_infos array so that after the two prefix accounts
(payer, compressed_token_program_authority) the order is mint,
source_ctoken_account, destination_spl_token_account, authority, token_pool_pda,
spl_token_program (i.e., ensure destination is before authority in the array) in
the four methods listed.
| impl TransferCtokenToSpl { | ||
| #[profile] | ||
| pub fn instruction(self) -> Result<Instruction, ProgramError> { | ||
| let packed_accounts = vec![ | ||
| // Mint (index 0) | ||
| AccountMeta::new_readonly(self.mint, false), | ||
| // Source ctoken account (index 1) - writable | ||
| AccountMeta::new(self.source_ctoken_account, false), | ||
| // Destination SPL token account (index 2) - writable | ||
| AccountMeta::new(self.destination_spl_token_account, false), | ||
| // Authority (index 3) - signer | ||
| AccountMeta::new_readonly(self.authority, true), | ||
| // Token pool PDA (index 4) - writable | ||
| AccountMeta::new(self.token_pool_pda, false), | ||
| // SPL Token program (index 5) - needed for CPI | ||
| AccountMeta::new_readonly(self.spl_token_program, false), | ||
| ]; | ||
|
|
||
| // First operation: compress from ctoken account to pool using compress_spl | ||
| let compress_to_pool = CTokenAccount2 { | ||
| inputs: vec![], | ||
| output: MultiTokenTransferOutputData::default(), | ||
| compression: Some(Compression::compress_ctoken( | ||
| self.amount, | ||
| 0, // mint index | ||
| 1, // source ctoken account index | ||
| 3, // authority index | ||
| )), | ||
| delegate_is_set: false, | ||
| method_used: true, | ||
| }; | ||
|
|
||
| // Second operation: decompress from pool to SPL token account using decompress_spl | ||
| let decompress_to_spl = CTokenAccount2 { | ||
| inputs: vec![], | ||
| output: MultiTokenTransferOutputData::default(), | ||
| compression: Some(Compression::decompress_spl( | ||
| self.amount, | ||
| 0, // mint index | ||
| 2, // destination SPL token account index | ||
| 4, // pool_account_index | ||
| 0, // pool_index (TODO: make dynamic) | ||
| self.token_pool_pda_bump, | ||
| )), | ||
| delegate_is_set: false, | ||
| method_used: true, | ||
| }; | ||
|
|
||
| let inputs = Transfer2Inputs { | ||
| validity_proof: ValidityProof::new(None), | ||
| transfer_config: Transfer2Config::default().filter_zero_amount_outputs(), | ||
| meta_config: Transfer2AccountsMetaConfig::new_decompressed_accounts_only( | ||
| self.payer, | ||
| packed_accounts, | ||
| ), | ||
| in_lamports: None, | ||
| out_lamports: None, | ||
| token_accounts: vec![compress_to_pool, decompress_to_spl], | ||
| output_queue: 0, // Decompressed accounts only, no output queue needed | ||
| }; | ||
|
|
||
| create_transfer2_instruction(inputs).map_err(ProgramError::from) | ||
| } | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
Index usage in Compression calls relies heavily on magic numbers
Both ctoken→SPL builders (TransferCtokenToSpl::instruction and CtokenToSplTransferAndClose::instruction) hard‑code indices into the Compression helpers:
Compression::compress_ctoken(self.amount, 0, 1, 3)assumes:- 0 → mint
- 1 → source ctoken
- 3 → authority
Compression::decompress_spl(self.amount, 0, 2, 4, 0, self.token_pool_pda_bump)assumes:- 0 → mint
- 2 → destination SPL
- 4 → pool
- 0 → pool index
The comments match the current packed_accounts order, so the implementation is coherent, but it’s quite brittle: any future reshuffle of packed_accounts or changes in Compression’s argument ordering will silently break these paths.
Consider introducing small local constants or an enum for the account indices (e.g. const MINT_IDX: u8 = 0; const SRC_CTOKEN_IDX: u8 = 1; …) and reusing them across all flows. That would make the assumptions explicit and reduce the risk of subtle index drift.
Also applies to: 378-444
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs around lines
236 to 299, the Compression::compress_ctoken and Compression::decompress_spl
calls use hard-coded numeric indices that mirror packed_accounts order;
introduce named index constants (e.g. const MINT_IDX = 0usize; const
SRC_CTOKEN_IDX = 1usize; const DEST_SPL_IDX = 2usize; const AUTHORITY_IDX =
3usize; const POOL_IDX = 4usize) and replace all literal index arguments and
their comments with these constants to make the mapping explicit and robust;
ensure the constant types match the expected parameter types (cast or use
usize/u8 as needed) and apply the same refactor to the other affected block
(lines 378–444) so both flows use the shared index constants.
| /// # Errors | ||
| /// * `SplBridgeConfigRequired` - If transferring to/from SPL without required accounts | ||
| /// * `UseRegularSplTransfer` - If both source and destination are SPL accounts | ||
| /// * `CannotDetermineAccountType` - If account type cannot be determined | ||
| pub fn invoke(self) -> Result<(), ProgramError> { | ||
| let source_is_ctoken = is_ctoken_account(&self.source_account) | ||
| .map_err(|_| ProgramError::InvalidAccountData)?; | ||
| let dest_is_ctoken = is_ctoken_account(&self.destination_account) | ||
| .map_err(|_| ProgramError::InvalidAccountData)?; | ||
|
|
||
| match (source_is_ctoken, dest_is_ctoken) { | ||
| (true, true) => TransferCtokenAccountInfos { | ||
| source: self.source_account.clone(), | ||
| destination: self.destination_account.clone(), | ||
| amount: self.amount, | ||
| authority: self.authority.clone(), | ||
| } | ||
| .invoke(), | ||
|
|
||
| (true, false) => { | ||
| let config = self.spl_bridge_config.ok_or_else(|| { | ||
| ProgramError::Custom(TokenSdkError::IncompleteSplBridgeConfig.into()) | ||
| })?; | ||
|
|
||
| TransferCtokenToSplAccountInfos { | ||
| source_ctoken_account: self.source_account.clone(), | ||
| destination_spl_token_account: self.destination_account.clone(), | ||
| amount: self.amount, | ||
| authority: self.authority.clone(), | ||
| mint: config.mint.clone(), | ||
| payer: self.payer.clone(), | ||
| token_pool_pda: config.token_pool_pda.clone(), | ||
| token_pool_pda_bump: config.token_pool_pda_bump, | ||
| spl_token_program: config.spl_token_program.clone(), | ||
| compressed_token_program_authority: self | ||
| .compressed_token_program_authority | ||
| .clone(), | ||
| } | ||
| .invoke() | ||
| } | ||
|
|
||
| (false, true) => { | ||
| let config = self.spl_bridge_config.ok_or_else(|| { | ||
| ProgramError::Custom(TokenSdkError::IncompleteSplBridgeConfig.into()) | ||
| })?; | ||
|
|
||
| TransferSplToCtokenAccountInfos { | ||
| source_spl_token_account: self.source_account.clone(), | ||
| to: self.destination_account.clone(), | ||
| amount: self.amount, | ||
| authority: self.authority.clone(), | ||
| mint: config.mint.clone(), | ||
| payer: self.payer.clone(), | ||
| token_pool_pda: config.token_pool_pda.clone(), | ||
| token_pool_pda_bump: config.token_pool_pda_bump, | ||
| spl_token_program: config.spl_token_program.clone(), | ||
| compressed_token_program_authority: self | ||
| .compressed_token_program_authority | ||
| .clone(), | ||
| destination_ctoken_account: self.destination_account.clone(), | ||
| } | ||
| .invoke() | ||
| } | ||
|
|
||
| (false, false) => Err(ProgramError::Custom( | ||
| TokenSdkError::UseRegularSplTransfer.into(), | ||
| )), | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
TransferInterface error docs don’t match actual error mapping
The docs on TransferInterface::invoke / invoke_signed list:
SplBridgeConfigRequiredUseRegularSplTransferCannotDetermineAccountType
But the implementation actually:
- Uses
TokenSdkError::IncompleteSplBridgeConfigwhenspl_bridge_configisNonein SPL<->ctoken branches. - Uses
TokenSdkError::UseRegularSplTransferwhen both ends are SPL (good). - Maps any
Errfromis_ctoken_account— includingTokenSdkError::CannotDetermineAccountType— toProgramError::InvalidAccountDataviamap_err(|_| ProgramError::InvalidAccountData).
So callers will never see TokenSdkError::CannotDetermineAccountType from this interface, and the name SplBridgeConfigRequired in the comments doesn’t match the actual variant used.
I’d suggest either:
- Update the doc comments to describe the real behavior (
InvalidAccountDatawhen account type can’t be determined;IncompleteSplBridgeConfigwhen required SPL bridge accounts are missing), or - Change the mapping to propagate the underlying
TokenSdkErrorvariants (wrapped asProgramError::Custom) if you want the higher‑level API to carry those semantics.
Aligning the docs with reality will make this interface much easier to reason about for downstream callers.
Also applies to: 590-658
I'll verify the claims in this review comment by examining the actual codebase. Let me search for the doc comments, error types, and related code.
---
🏁 Script executed:
```shell
#!/bin/bash
# Find and display the doc comments for invoke and invoke_signed methods
echo "=== Looking for invoke/invoke_signed doc comments ==="
rg -n -B20 "pub fn invoke\(" sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs | head -60
echo ""
echo "=== Looking for invoke_signed doc comments ==="
rg -n -B20 "pub fn invoke_signed\(" sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs | head -60
Length of output: 5526
🏁 Script executed:
#!/bin/bash
# Find TokenSdkError enum definition to see actual variants
echo "=== Searching for TokenSdkError enum ==="
rg -n "enum TokenSdkError" -A 30 sdk-libs/compressed-token-sdk/Length of output: 2670
🏁 Script executed:
#!/bin/bash
# Find is_ctoken_account function to see what errors it can return
echo "=== Searching for is_ctoken_account function ==="
rg -n -A 15 "fn is_ctoken_account" sdk-libs/compressed-token-sdk/Length of output: 1309
🏁 Script executed:
#!/bin/bash
# Show lines 590-658 to verify invoke_signed has similar pattern
echo "=== Showing lines 590-658 (invoke_signed area) ==="
sed -n '590,658p' sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rsLength of output: 3353
Update the error documentation to match actual behavior
The review comment is accurate. I've verified the code:
-
The
invoke()andinvoke_signed()doc comments claim three error variants that don't align with reality:- Docs say
SplBridgeConfigRequired, but the code emitsTokenSdkError::IncompleteSplBridgeConfig - Docs claim
CannotDetermineAccountTypewill be returned, but the.map_err(|_| ProgramError::InvalidAccountData)wrapper converts it toInvalidAccountData - Only
UseRegularSplTransferis correctly documented
- Docs say
-
is_ctoken_account()inutils.rs:36can legitimately returnTokenSdkError::CannotDetermineAccountType, but it's intentionally suppressed by the error mapping in both methods
The same documentation mismatch exists in invoke_signed() (lines 590–594).
Recommend: Update the doc comments to accurately describe what callers will actually observe:
InvalidAccountDatawhen account type cannot be determinedIncompleteSplBridgeConfigwhen required SPL bridge config is missingUseRegularSplTransferwhen both ends are SPL
This will eliminate confusion for downstream consumers of this API.
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs around lines
520–588 (and also update the similar block for invoke_signed around lines
590–594), the doc comments list error variants that don't match actual returns;
update the documentation to state callers will observe
ProgramError::InvalidAccountData when account type cannot be determined,
ProgramError::Custom(TokenSdkError::IncompleteSplBridgeConfig.into()) when the
SPL bridge config is missing (replace "SplBridgeConfigRequired"), and
ProgramError::Custom(TokenSdkError::UseRegularSplTransfer.into()) for the
both-SPL case; make the wording concise and exact to the ProgramError forms
actually produced by the code.
| use light_compressed_token_types::{ | ||
| ACCOUNT_COMPRESSION_AUTHORITY_PDA, ACCOUNT_COMPRESSION_PROGRAM_ID, CPI_AUTHORITY_PDA, | ||
| LIGHT_SYSTEM_PROGRAM_ID, NOOP_PROGRAM_ID, PROGRAM_ID as LIGHT_COMPRESSED_TOKEN_PROGRAM_ID, | ||
| }; | ||
| use light_sdk::constants::REGISTERED_PROGRAM_PDA; | ||
|
|
||
| /// Standard pubkeys for compressed token instructions | ||
| #[derive(Debug, Copy, Clone)] | ||
| pub struct CTokenDefaultAccounts { | ||
| pub light_system_program: Pubkey, | ||
| pub registered_program_pda: Pubkey, | ||
| pub noop_program: Pubkey, | ||
| pub account_compression_authority: Pubkey, | ||
| pub account_compression_program: Pubkey, | ||
| pub self_program: Pubkey, | ||
| pub cpi_authority_pda: Pubkey, | ||
| pub system_program: Pubkey, | ||
| pub compressed_token_program: Pubkey, | ||
| } | ||
|
|
||
| impl Default for CTokenDefaultAccounts { | ||
| fn default() -> Self { | ||
| Self { | ||
| light_system_program: Pubkey::from(LIGHT_SYSTEM_PROGRAM_ID), | ||
| registered_program_pda: Pubkey::from(REGISTERED_PROGRAM_PDA), | ||
| noop_program: Pubkey::from(NOOP_PROGRAM_ID), | ||
| account_compression_authority: Pubkey::from(ACCOUNT_COMPRESSION_AUTHORITY_PDA), | ||
| account_compression_program: Pubkey::from(ACCOUNT_COMPRESSION_PROGRAM_ID), | ||
| self_program: Pubkey::from(LIGHT_COMPRESSED_TOKEN_PROGRAM_ID), | ||
| cpi_authority_pda: Pubkey::from(CPI_AUTHORITY_PDA), | ||
| system_program: Pubkey::default(), | ||
| compressed_token_program: Pubkey::from(C_TOKEN_PROGRAM_ID), | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
🧩 Analysis chain
CTokenDefaultAccounts::default().system_program is an all‑zero Pubkey
CTokenDefaultAccounts is documented as:
/// Standard pubkeys for compressed token instructions
but in the Default impl:
system_program: Pubkey::default(),returns the all‑zeros key, not the canonical system program id. That’s very likely to cause subtle failures if any code constructs metas with CTokenDefaultAccounts::default().system_program and expects the real system program.
Consider one of:
- Wire this to the actual system program id (e.g. via a constant or helper from your Solana dependency).
- Or, if you intentionally expect callers to supply it, remove
system_programfromCTokenDefaultAccountsor make it anOption<Pubkey>to avoid suggesting a valid default.
All the other fields are wired to concrete, non-zero constants, so this one stands out as inconsistent and error-prone.
I'll verify this concern by examining the codebase and checking how CTokenDefaultAccounts is actually used.
🏁 Script executed:
#!/bin/bash
# Find all usages of CTokenDefaultAccounts to understand how system_program is handled
rg -n "CTokenDefaultAccounts" --type rust -B2 -A2Length of output: 18989
🏁 Script executed:
#!/bin/bash
# Search for builder patterns or struct construction that might override system_program
rg -n "system_program:" --type rust -B3 -A1Length of output: 83887
🏁 Script executed:
#!/bin/bash
# Look for Solana system program constant definitions in the codebase
rg -n "SYSTEM_PROGRAM\|system_program_id\|SystemProgram" --type rust -B1 -A1Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check if Default is being called directly or if there's a builder pattern
rg -n "CTokenDefaultAccounts::default\|Default::default" --type rust -B1 -A3Length of output: 0
🏁 Script executed:
#!/bin/bash
# Inspect the actual file to see context around the Default implementation
cat sdk-libs/compressed-token-sdk/src/utils.rs | head -100Length of output: 3505
🏁 Script executed:
#!/bin/bash
# Look for any constants related to C_TOKEN_PROGRAM_ID to understand the pattern
rg -n "C_TOKEN_PROGRAM_ID" --type rust -B2 -A2Length of output: 3806
🏁 Script executed:
#!/bin/bash
# Search for Solana system program references to find canonical constant names
rg -n "solana_program|system_program" --type rust -B1 -A1 | head -50Length of output: 2783
🏁 Script executed:
#!/bin/bash
# Check imports at top of utils.rs to see what's available
head -15 sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 606
🏁 Script executed:
#!/bin/bash
# Look for any tests or examples that construct CTokenDefaultAccounts
rg -n "CTokenDefaultAccounts\s*\{" --type rust -B2 -A5Length of output: 1348
🏁 Script executed:
#!/bin/bash
# Check if there's a way to provide custom accounts or if Default is the only path
rg -n "impl.*CTokenDefaultAccounts\|fn.*new.*CTokenDefaultAccounts" --type rust -B1 -A5Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for Solana SDK version/dependency info to check system program constant
fd -e toml | xargs grep -l "solana" 2>/dev/null | head -5Length of output: 182
🏁 Script executed:
#!/bin/bash
# Check Cargo.toml for solana dependencies and their versions
cat sdk-libs/compressed-token-sdk/Cargo.toml | grep -A5 -B5 "solana\|light"Length of output: 2031
🏁 Script executed:
#!/bin/bash
# Search for AccountMeta creation patterns to see how system_program is used
rg -n "AccountMeta\|account_metas" --type rust -B2 -A2 | head -40Length of output: 0
🏁 Script executed:
#!/bin/bash
# Find CLAUDE.md or similar documentation files
fd -e md | grep -i claudeLength of output: 477
🏁 Script executed:
#!/bin/bash
# Look for README or docs that might explain design decisions
fd -name "README*" -o -name "*.md" | head -10Length of output: 230
🏁 Script executed:
#!/bin/bash
# Check if system_program field is ever read/accessed in the codebase
rg -n "\.system_program" --type rustLength of output: 3859
🏁 Script executed:
#!/bin/bash
# Look for any initialization patterns where system_program might be set
rg -n "system_program\s*:" --type rust -B3 -A1 | head -60Length of output: 3991
🏁 Script executed:
#!/bin/bash
# Check the actual test cases or usage in integration tests
find . -name "*test*" -o -name "*example*" | grep -E "\.rs$" | xargs grep -l "CTokenDefaultAccounts" 2>/dev/nullLength of output: 59
🏁 Script executed:
#!/bin/bash
# See if there's a helper function that creates accounts with real system program
rg -n "system_program\|SYSTEM_PROGRAM" --type rust -C4 | grep -A10 -B10 "default\|Default"Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check if solana_sdk is imported and what's available from it
rg -n "use solana_sdk" --type rustLength of output: 7703
🏁 Script executed:
#!/bin/bash
# Look for any comments or TODOs about system_program handling
rg -n "system_program\|TODO\|FIXME" --type rust -B1 -A1 | grep -i "system\|TODO\|FIXME" | head -40Length of output: 0
🏁 Script executed:
#!/bin/bash
# Final check: see the complete CTokenDefaultAccounts and how it's used in actual code
rg -n "struct CTokenDefaultAccounts\|impl.*CTokenDefaultAccounts" --type rust -A30Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check if there's a builder pattern or constructor function
rg -n "pub fn.*\|pub struct CTokenDefaultAccounts" --type rust -B2 -A15Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for the definition of SYSTEM_PROGRAM or similar in solana_program
rg -n "SYSTEM_PROGRAM_ID" --type rustLength of output: 7768
🏁 Script executed:
#!/bin/bash
# Check what Pubkey::default() actually is in solana_program
rg -n "impl Default for Pubkey" --type rust -A5Length of output: 0
🏁 Script executed:
#!/bin/bash
# Search across all files for system program constant usage patterns
rg -n "system.*program.*id\|SYSTEM_PROGRAM" --type rust -i | head -30Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check if C_TOKEN_PROGRAM_ID is imported from somewhere
rg -n "C_TOKEN_PROGRAM_ID" --type rust -B10 | head -30Length of output: 2554
🏁 Script executed:
#!/bin/bash
# Look at the import statement to see if it's supposed to be imported from light_compressed_token_types
grep -n "use light_compressed_token_types" sdk-libs/compressed-token-sdk/src/utils.rs -A10Length of output: 505
🏁 Script executed:
#!/bin/bash
# Check if there's a follow-up fix or related code that addresses this
git log --oneline -20 -- sdk-libs/compressed-token-sdk/src/utils.rs 2>/dev/null || echo "Git not available"Length of output: 137
🏁 Script executed:
#!/bin/bash
# Check if there's documentation about expected usage pattern
rg -n "CTokenDefaultAccounts" --type rust --type md -B3 -A3 | head -50Length of output: 4042
🏁 Script executed:
#!/bin/bash
# Look for the actual callers that construct instruction metas using these accounts
rg -n "\.system_program\b" --type rustLength of output: 3859
🏁 Script executed:
#!/bin/bash
# Check if there's an AccountsBuilder or similar pattern
rg -n "Builder\|builder\|with_\|set_" --type rust | grep -i "system_program\|account" | head -20Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for any test that actually uses system_program from CTokenDefaultAccounts
find . -name "*.rs" -exec grep -l "CTokenDefaultAccounts" {} \; | xargs grep -l "test\|mod test" 2>/dev/null | head -5Length of output: 134
🏁 Script executed:
#!/bin/bash
# Final comprehensive search: all references to the struct
rg -n "CTokenDefaultAccounts" --type rust -B5 -A10Length of output: 55959
🏁 Script executed:
#!/bin/bash
# Check if light_compressed_token_types exports SYSTEM_PROGRAM_ID or similar
rg -n "SYSTEM_PROGRAM\|pub const" --type rust | grep -i "system\|program" | head -20Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look at the exact line in context - show more context around the Default impl
sed -n '60,100p' sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 1480
🏁 Script executed:
#!/bin/bash
# Check all fields to see if any are actually used and how
rg -n "compressed_token_program\|noop_program\|light_system_program" --type rust -B2 -A2 | head -40Length of output: 0
🏁 Script executed:
#!/bin/bash
# Search for where these accounts are actually used in instruction construction
rg -n "CTokenDefaultAccounts" --type rust -A20 | grep -A20 "default()"Length of output: 51070
🏁 Script executed:
#!/bin/bash
# Check if there's a constant defined in the same file or imported
rg -n "const.*SYSTEM_PROGRAM\|pub const" sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 0
🏁 Script executed:
#!/bin/bash
# Look for solana_sdk or solana_program dependency in this specific crate
cat sdk-libs/compressed-token-sdk/Cargo.tomlLength of output: 2031
🏁 Script executed:
#!/bin/bash
# Check what's available from solana_program::system_program
rg -n "solana_program::system_program\|use.*system_program" --type rustLength of output: 0
🏁 Script executed:
#!/bin/bash
# Direct check: does system_program field ever get assigned a different value?
rg -n "system_program\s*=" --type rust -B3 -A1 | head -50Length of output: 4826
🏁 Script executed:
#!/bin/bash
# Look for actual AccountMeta construction patterns with system_program
rg -n "AccountMeta.*system_program\|system_program.*AccountMeta" --type rust -B2 -A2Length of output: 0
🏁 Script executed:
#!/bin/bash
# Final verification: Look for any indication that system_program is meant to be overridden
rg -n "system_program" --type rust -C5 | grep -i "override\|replace\|custom\|provide\|pass"Length of output: 1765
🏁 Script executed:
#!/bin/bash
# Check if there's a with_system_program or similar method
rg -n "pub fn.*system\|pub fn.*with_" sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 0
🏁 Script executed:
#!/bin/bash
# One more check: see the full file structure
wc -l sdk-libs/compressed-token-sdk/src/utils.rs && echo "---" && head -20 sdk-libs/compressed-token-sdk/src/utils.rs && echo "..." && tail -20 sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 1681
🏁 Script executed:
#!/bin/bash
# Check if solana_program is a dependency
rg -n "solana[_-]program\|solana[_-]sdk" --type toml sdk-libs/compressed-token-sdk/Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for the canonical system program ID in solana crates
rg -n "solana_program\|system_program" --type rust | grep -i "const\|id\|pubkey" | head -20Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check imports in utils.rs one more time
head -20 sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 773
🏁 Script executed:
#!/bin/bash
# See if there's any evidence of system_program being used in actual instruction calls
rg -n "solana_program::instruction\|AccountMeta" sdk-libs/compressed-token-sdk/src/utils.rs -B3 -A3Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check the full utils.rs file to understand complete context
cat sdk-libs/compressed-token-sdk/src/utils.rsLength of output: 3505
🏁 Script executed:
#!/bin/bash
# Look for where CTokenDefaultAccounts::default() is actually used in practice
rg -n "CTokenDefaultAccounts::default()" --type rust -B3 -A10Length of output: 30778
🏁 Script executed:
#!/bin/bash
# Check if C_TOKEN_PROGRAM_ID is defined - it's used in the code but may not be imported properly
rg -n "C_TOKEN_PROGRAM_ID" --type rust -B10 | head -40Length of output: 3354
🏁 Script executed:
#!/bin/bash
# Simple import check
grep -r "C_TOKEN_PROGRAM_ID" sdk-libs/compressed-token-sdk/src/ 2>/dev/nullLength of output: 522
🏁 Script executed:
#!/bin/bash
# Check what's exported from light_compressed_token_types
rg -n "pub const\|pub static" --type rust | grep -i "program\|token" | head -30Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for solana_program::system_program::id or similar
rg -n "solana_program.*system_program\|system_program.*::id" --type rustLength of output: 0
🏁 Script executed:
#!/bin/bash
# Final attempt: check what's available in Solana SDK for system program
rg -n "solana" --type toml sdk-libs/compressed-token-sdk/Cargo.tomlLength of output: 399
🏁 Script executed:
#!/bin/bash
# Verify the Pubkey type and its default behavior
rg -n "struct Pubkey\|impl.*Pubkey" --type rust -A5 | head -40Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for solana-program or solana-sdk in dependencies across the project
find . -name "Cargo.toml" -exec grep -l "solana" {} \;Length of output: 1153
🏁 Script executed:
#!/bin/bash
# Check one root Cargo.toml to understand dependency versions
find . -name "Cargo.toml" -path "*/Cargo.toml" | head -1 | xargs cat | grep -A5 "solana"Length of output: 949
🏁 Script executed:
#!/bin/bash
# Look at the first Cargo.toml we find
find . -maxdepth 2 -name "Cargo.toml" -exec cat {} \; | grep -A5 "solana"Length of output: 949
🏁 Script executed:
#!/bin/bash
# Check if system_program is ever actually used from this struct
find . -name "*.rs" -exec grep -l "CTokenDefaultAccounts" {} \; | xargs grep -n "\.system_program"Length of output: 1298
🏁 Script executed:
#!/bin/bash
# See all usages of CTokenDefaultAccounts
find . -name "*.rs" -exec grep -l "CTokenDefaultAccounts" {} \;Length of output: 960
🏁 Script executed:
#!/bin/bash
# Check one of those files for actual usage
find . -name "*.rs" -exec grep -l "CTokenDefaultAccounts" {} \; | head -1 | xargs catLength of output: 4695
🏁 Script executed:
#!/bin/bash
# Simple check: where is this struct used?
grep -r "CTokenDefaultAccounts" . --include="*.rs" 2>/dev/null | grep -v "^Binary"Length of output: 4958
🏁 Script executed:
#!/bin/bash
# Look for imports and usages in one go
grep -r "CTokenDefaultAccounts\|use.*utils" . --include="*.rs" 2>/dev/null | head -30Length of output: 2685
🏁 Script executed:
#!/bin/bash
# Check if there's any builder or configuration pattern
grep -r "system_program" sdk-libs/compressed-token-sdk/src/ --include="*.rs" 2>/dev/nullLength of output: 10371
🏁 Script executed:
#!/bin/bash
# Look for constructor functions or similar
grep -r "impl CTokenDefaultAccounts\|fn.*CTokenDefaultAccounts\|fn new\|fn with" sdk-libs/compressed-token-sdk/src/ --include="*.rs" 2>/dev/nullLength of output: 4356
🏁 Script executed:
#!/bin/bash
# Final check of the actual file content
ls -la sdk-libs/compressed-token-sdk/src/Length of output: 597
🏁 Script executed:
#!/bin/bash
# Look at the entire utils.rs file
cat sdk-libs/compressed-token-sdk/src/utils.rs 2>/dev/null || echo "File not found, looking for utils.rs"Length of output: 3505
🏁 Script executed:
#!/bin/bash
# Search everywhere for utils.rs
find . -name "utils.rs" -path "*/compressed-token*" 2>/dev/nullLength of output: 44
🏁 Script executed:
#!/bin/bash
# Look for the specific directory
find . -name "compressed-token*" -type d 2>/dev/nullLength of output: 115
🏁 Script executed:
#!/bin/bash
# List structure
ls -la . 2>/dev/null | head -20Length of output: 1122
🏁 Script executed:
#!/bin/bash
# Check if solana_program::system_program has a constant
python3 << 'EOF'
import urllib.request
import urllib.error
# Try to fetch Solana SDK documentation or source
try:
url = "https://docs.rs/solana-program/latest/solana_program/system_program/fn.id.html"
with urllib.request.urlopen(url, timeout=5) as response:
print(f"Solana system_program::id() exists: {response.status == 200}")
except urllib.error.URLError as e:
print(f"Cannot verify online: {e}")
EOFLength of output: 149
🏁 Script executed:
#!/bin/bash
# Look for C_TOKEN_PROGRAM_ID usage and definition across the repo
find . -type f -name "*.rs" -o -name "*.toml" | xargs grep -l "C_TOKEN_PROGRAM_ID" 2>/dev/null | head -10Length of output: 235
🏁 Script executed:
#!/bin/bash
# Comprehensive search for system program in the entire repo
find . -type f -name "*.rs" | xargs grep -n "SYSTEM_PROGRAM\|system_program" 2>/dev/null | head -30Length of output: 3501
🏁 Script executed:
#!/bin/bash
# Look for the light_compressed_token_types crate definition
find . -type f -path "*/light*token*types*" -name "*.rs" -o -name "Cargo.toml" 2>/dev/null | head -20Length of output: 774
🏁 Script executed:
#!/bin/bash
# Check if it's in lib.rs or constants file
find . -name "*.rs" | xargs grep -l "light_compressed_token_types\|LIGHT_COMPRESSED_TOKEN_PROGRAM_ID" 2>/dev/null | head -10Length of output: 735
🏁 Script executed:
#!/bin/bash
# Look at directory structure to understand project layout
find . -type d -name "*light*" -o -type d -name "*compressed*token*" 2>/dev/null | head -20Length of output: 277
🏁 Script executed:
#!/bin/bash
# Simpler: just look at immediate subdirectories
ls -laLength of output: 1122
🏁 Script executed:
#!/bin/bash
# Look for the actual review context - are there any actual failures documented?
find . -name "*.rs" -o -name "*.md" | xargs grep -i "system_program.*error\|system_program.*fail\|system_program.*bug" 2>/dev/null | head -10Length of output: 0
🏁 Script executed:
#!/bin/bash
# Check if there's existing issue or TODO about this
grep -r "TODO\|FIXME\|XXX\|HACK" . --include="*.rs" | grep -i "system_program\|default" | head -10Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for any version info or changelog
find . -name "CHANGELOG*" -o -name "VERSION*" -o -name "HISTORY*" 2>/dev/null | head -5Length of output: 114
🏁 Script executed:
#!/bin/bash
# Check the CLAUDE.md file if it exists as per the tone instructions
find . -name "CLAUDE.md" -o -name "claude.md" 2>/dev/nullLength of output: 503
🏁 Script executed:
#!/bin/bash
# Look for README to understand the project
find . -name "README*" -type f 2>/dev/null | head -5Length of output: 115
🏁 Script executed:
#!/bin/bash
# Look at root directory
pwd && ls -la && echo "---" && find . -maxdepth 1 -type f | head -20Length of output: 1206
🏁 Script executed:
#!/bin/bash
# Try to understand the repo structure
find . -maxdepth 2 -type f -name "*.md" -o -name "*.rs" 2>/dev/null | head -30Length of output: 186
🏁 Script executed:
#!/bin/bash
# Check if this is maybe not a Rust project or different structure
file Cargo.toml 2>/dev/null || find . -name "Cargo.toml" | head -1Length of output: 21
🏁 Script executed:
#!/bin/bash
# Direct existence check
test -f sdk-libs/compressed-token-sdk/src/utils.rs && echo "File exists" || echo "File does not exist"Length of output: 11
🏁 Script executed:
#!/bin/bash
# List what's in that directory
ls -la sdk-libs/compressed-token-sdk/src/ 2>/dev/null || ls -la sdk-libs/compressed-token-sdk/ 2>/dev/null || ls -la sdk-libs/ 2>/dev/nullLength of output: 597
🏁 Script executed:
#!/bin/bash
# Broad search for C_TOKEN_PROGRAM_ID which is mentioned in the snippet
rg "C_TOKEN_PROGRAM_ID" --type rust 2>/dev/null || echo "Not found with rg"Length of output: 908
🏁 Script executed:
#!/bin/bash
# Check if C_TOKEN_PROGRAM_ID might be missing - that's also an issue
rg "C_TOKEN_PROGRAM_ID" 2>/dev/null || echo "Constant not found anywhere"Length of output: 908
🏁 Script executed:
#!/bin/bash
# Verify if this is the actual state or outdated
find . -name "utils.rs" -path "*/compressed*" 2>/dev/null | xargs cat 2>/dev/null | head -100Length of output: 3505
🏁 Script executed:
#!/bin/bash
# Get everything
find . -name "utils.rs" 2>/dev/null | xargs ls -la 2>/dev/nullLength of output: 793
🏁 Script executed:
#!/bin/bash
# Last resort - search by pattern that must exist if the code is there
rg "CTokenDefaultAccounts" 2>/dev/null || echo "Pattern not found in repository"Length of output: 4888
🏁 Script executed:
#!/bin/bash
# Check if maybe we need to look elsewhere
git status 2>/dev/null || echo "Not a git repo"Length of output: 128
🏁 Script executed:
#!/bin/bash
# Check what we have available
ls -la && echo "---" && pwdLength of output: 1145
🏁 Script executed:
#!/bin/bash
# One final comprehensive check
rg "struct CTokenDefaultAccounts" 2>/dev/null || echo "Not found"Length of output: 77
🏁 Script executed:
#!/bin/bash
# Try cargo check/info if available
(cd sdk-libs/compressed-token-sdk && cargo metadata --format-version=1 2>/dev/null | head -50) || echo "Cargo metadata not available"Length of output: 0
🏁 Script executed:
#!/bin/bash
# Simple verification: does the error really exist?
rg "system_program.*default\(\)" --type rust 2>/dev/null || echo "Pattern not found"Length of output: 386
🏁 Script executed:
#!/bin/bash
# Maybe it's a different file - search for the imports mentioned
rg "ACCOUNT_COMPRESSION_AUTHORITY_PDA" --type rust 2>/dev/null || echo "Imports not found"Length of output: 3831
🏁 Script executed:
#!/bin/bash
# Check if the code from the snippet even exists in the repo
rg "light_system_program.*Pubkey" --type rust 2>/dev/null || echo "Code not found"Length of output: 323
🏁 Script executed:
#!/bin/bash
# Last attempt - maybe it's toml syntax
cat Cargo.toml 2>/dev/null | head -50Length of output: 0
🏁 Script executed:
#!/bin/bash
# Look for Solana system program constant in standard locations
python3 << 'EOF'
# Check what the actual system program ID should be in Solana
# In Solana, the system program ID is always: 11111111111111111111111111111111
print("Canonical Solana System Program ID: 11111111111111111111111111111111")
print("Zero/default Pubkey: 00000000000000000000000000000000")
print("These are different - confirming the issue exists in principle")
EOFLength of output: 185
CTokenDefaultAccounts::default() sets system_program to the all‑zero Pubkey — breakage risk
Default currently uses system_program: Pubkey::default(), but that value is propagated into AccountMeta builders across compressed-token-sdk (examples: sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs, v1/approve/account_metas.rs, v1/batch_compress/account_metas.rs, v2/transfer2/account_metas.rs, v2/mint_to_compressed/account_metas.rs) and tests (sdk-libs/compressed-token-sdk/tests/account_metas_test.rs). That yields AccountMeta entries referencing the zero pubkey instead of the canonical Solana system program ID (11111111111111111111111111111111), producing inconsistent behaviour and potential runtime failures.
Fix (choose one):
- Set
system_programin sdk-libs/compressed-token-sdk/src/utils.rs (impl Default for CTokenDefaultAccounts) to the canonical system program ID (e.g.solana_sdk::system_program::id()or the repo constant). - Or make the field non‑defaultable (Option or remove from Default) so callers must supply an explicit system_program; update all account_metas builders and tests that assume Pubkey::default().
[suggested_location]
- Primary: sdk-libs/compressed-token-sdk/src/utils.rs — impl Default for CTokenDefaultAccounts.
- Update call sites in sdk-libs/compressed-token-sdk/src/compressed_token/**/account_metas.rs and sdk-libs/compressed-token-sdk/tests/account_metas_test.rs to match the chosen invariant.
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/utils.rs around lines 61 to 95, the Default
impl sets system_program to Pubkey::default() (all-zero) which yields invalid
AccountMeta entries; change the default to the canonical Solana system program
id (e.g. Pubkey::from(solana_sdk::system_program::id()) or the repo constant)
and add the necessary import, then run/adjust the compressed-token-sdk
account_metas builders and tests to ensure they now rely on the canonical system
program rather than the zero pubkey.
5ae967d to
cd65069
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/mod.rs (1)
6-6: Use explicit named imports instead of wildcard re-export.This wildcard re-export was already flagged in a previous review. The recommendation remains valid: use explicit named imports for consistency with the selective re-export pattern already established in this file (line 7 shows
Transfer2CpiAccountsexplicitly named).Replace with:
pub use account_metas::{Transfer2AccountsMetaConfig, get_transfer2_instruction_account_metas};This prevents unintended public API surface expansion if new items are added to
account_metasin the future.Based on past review comments.
sdk-libs/compressed-token-sdk/src/lib.rs (1)
1-2: Breaking API changes require migration plan.The past review comment correctly identifies this as externally breaking. Given that this PR is stacked on #2064, ensure:
- The removal of
instructions,account,account2,ctoken_instruction, andtoken_metadata_uimodules is documented in release notes- A migration guide shows downstream users how to update imports from old paths to new
compressed_tokenandcompressiblemodules- Consider a deprecation window with
#[deprecated]re-exports if this lands before a major version bumpsdk-libs/compressed-token-sdk/src/utils.rs (1)
81-95: Critical: system_program defaults to zero pubkey.Line 91 uses
Pubkey::default()(all-zeros) instead of the canonical Solana system program ID. This is inconsistent with the other eight fields that correctly use proper constants, and will causeAccountMetaconstruction to reference an invalid pubkey.The past review comment comprehensively documents this issue with verification. Fix by using the actual system program constant (e.g.,
solana_sdk::system_program::id()or add a SYSTEM_PROGRAM_ID constant to your imports).
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (53)
program-tests/compressed-token-test/tests/ctoken/compress_and_close.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create_ata.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/create_ata2.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/functional.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/functional_ata.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/ctoken/shared.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/cpi_context.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/edge_cases.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/functional.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/mint/random.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/compress_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/decompress_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/shared.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/spl_ctoken.rsis excluded by none and included by noneprogram-tests/compressed-token-test/tests/transfer2/transfer_failing.rsis excluded by none and included by noneprogram-tests/registry-test/tests/compressible.rsis excluded by none and included by noneprogram-tests/utils/src/assert_create_token_account.rsis excluded by none and included by noneprogram-tests/utils/src/assert_mint_to_compressed.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/src/instructions/create_user_record_and_game_session.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/src/instructions/decompress_accounts_idempotent.rsis excluded by none and included by nonesdk-tests/sdk-compressible-test/tests/multi_account_tests.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/ctoken_pda/mint.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/lib.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/mint_compressed_tokens_cpi_write.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/pda_ctoken/mint.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_batch_compress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi_context.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_and_close_cpi_indices.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_full_and_close.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_compress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_create_compressed_account.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_decompress_full_cpi_context.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_decompress_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_four_invokes.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_four_transfer2.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_transfer_tokens.rsis excluded by none and included by nonesdk-tests/sdk-token-test/src/process_update_deposit.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/compress_and_close_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/ctoken_pda.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/decompress_full_cpi.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/pda_ctoken.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_4_invocations.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_4_transfer2.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_compress_full_and_close.rsis excluded by none and included by nonesdk-tests/sdk-token-test/tests/test_deposit.rsis excluded by none and included by nonetypedoc.stateless.jsonis excluded by none and included by none
📒 Files selected for processing (47)
forester/src/compressible/compressor.rs(1 hunks)forester/tests/test_compressible_ctoken.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_infos.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs(2 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs(2 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/account_metas.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs(1 hunks)sdk-libs/compressed-token-sdk/src/compressible/mod.rs(1 hunks)sdk-libs/compressed-token-sdk/src/ctoken/mod.rs(2 hunks)sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs(1 hunks)sdk-libs/compressed-token-sdk/src/instructions/burn.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/ctoken_accounts.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/mint_to.rs(0 hunks)sdk-libs/compressed-token-sdk/src/instructions/mod.rs(0 hunks)sdk-libs/compressed-token-sdk/src/lib.rs(1 hunks)sdk-libs/compressed-token-sdk/src/utils.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/account_metas_test.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs(1 hunks)sdk-libs/compressed-token-sdk/tests/mint_action_cpi_accounts_tests.rs(1 hunks)sdk-libs/program-test/src/forester/compress_and_close_forester.rs(1 hunks)sdk-libs/token-client/src/actions/create_compressible_token_account.rs(1 hunks)sdk-libs/token-client/src/actions/mint_action.rs(2 hunks)sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs(1 hunks)sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs(1 hunks)sdk-libs/token-client/src/instructions/create_mint.rs(1 hunks)sdk-libs/token-client/src/instructions/mint_action.rs(1 hunks)sdk-libs/token-client/src/instructions/mint_to_compressed.rs(1 hunks)sdk-libs/token-client/src/instructions/transfer2.rs(1 hunks)sdk-libs/token-client/src/instructions/update_compressed_mint.rs(1 hunks)
💤 Files with no reviewable changes (4)
- sdk-libs/compressed-token-sdk/src/instructions/mint_to.rs
- sdk-libs/compressed-token-sdk/src/instructions/ctoken_accounts.rs
- sdk-libs/compressed-token-sdk/src/instructions/burn.rs
- sdk-libs/compressed-token-sdk/src/instructions/mod.rs
🧰 Additional context used
🧬 Code graph analysis (29)
sdk-libs/compressed-token-sdk/tests/mint_action_cpi_accounts_tests.rs (1)
sdk-libs/token-client/src/actions/mint_action.rs (1)
mint_action(24-59)
sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/create_token_account/instruction.rs (1)
create_token_account(92-118)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
get_mint_action_instruction_account_metas(172-277)
sdk-libs/token-client/src/instructions/mint_action.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (3)
create_compressed_mint(190-194)derive_compressed_mint_address(197-206)find_spl_mint_address(216-221)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
get_mint_action_instruction_account_metas(172-277)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
get_batch_compress_instruction_account_metas(72-183)
sdk-libs/token-client/src/actions/mint_action.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (3)
create_compressed_mint(190-194)derive_compressed_mint_address(197-206)find_spl_mint_address(216-221)sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (2)
create_associated_token_account(102-108)derive_ctoken_ata(230-239)
sdk-libs/token-client/src/instructions/update_compressed_mint.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
update_compressed_mint(93-95)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (2)
sdk-libs/token-client/src/actions/mint_action.rs (1)
mint_action(24-59)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
get_mint_action_instruction_account_metas(172-277)get_mint_action_instruction_account_metas_cpi_write(291-321)
sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (1)
sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (1)
create_associated_token_account(102-108)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs (1)
get_transfer2_instruction_account_metas(50-126)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs (3)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
approve(86-88)programs/compressed-token/anchor/src/lib.rs (1)
batch_compress(98-123)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (1)
transfer(205-231)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
get_mint_action_instruction_account_metas(172-277)get_mint_action_instruction_account_metas_cpi_write(291-321)
sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs (1)
sdk-libs/compressed-token-sdk/src/token_pool.rs (1)
find_token_pool_pda_with_index(20-28)
sdk-libs/compressed-token-sdk/tests/account_metas_test.rs (3)
programs/compressed-token/anchor/src/lib.rs (1)
batch_compress(98-123)sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
get_batch_compress_instruction_account_metas(72-183)sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
get_transfer_instruction_account_metas(138-221)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs (1)
get_approve_instruction_account_metas(47-136)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
forester/tests/test_compressible_ctoken.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/token-client/src/instructions/transfer2.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/token-client/src/instructions/create_mint.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/compressed-token-sdk/src/utils.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
default(464-471)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
get_transfer_instruction_account_metas(138-221)sdk-libs/compressed-token-sdk/src/compressed_token/v1/account.rs (2)
new_empty(46-62)mint(182-184)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (2)
create_compressed_mint(190-194)find_spl_mint_address(216-221)
sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
programs/registry/src/lib.rs (1)
compress_and_close(775-790)
sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs (1)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
create_transfer2_instruction(69-138)
sdk-libs/compressed-token-sdk/src/ctoken/mod.rs (5)
sdk-libs/sdk/src/compressible/close.rs (1)
close(6-40)sdk-libs/compressed-token-sdk/src/ctoken/create_associated_token_account.rs (1)
create_associated_token_account(102-108)sdk-libs/compressed-token-sdk/src/ctoken/create_token_account/instruction.rs (1)
create_token_account(92-118)sdk-libs/token-client/src/actions/ctoken_transfer.rs (1)
transfer_ctoken(20-38)sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)
sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs (1)
sdk-libs/compressed-token-sdk/src/token_pool.rs (1)
find_token_pool_pda_with_index(20-28)
sdk-libs/token-client/src/instructions/mint_to_compressed.rs (2)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (2)
create_compressed_mint(190-194)derive_cmint_from_spl_mint(208-214)sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
create_mint_to_compressed_instruction(41-110)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs (3)
sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
create_compressed_mint(190-194)sdk-libs/token-client/src/actions/mint_action.rs (1)
mint_action(24-59)sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
update_compressed_mint(93-95)
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Forester e2e test
- GitHub Check: programs (system-cpi-test-v2-functional-account-infos, ["cargo-test-sbf -p system-cpi-v2-test -- ...
- GitHub Check: programs (system-cpi-test-v2-functional-read-only, ["cargo-test-sbf -p system-cpi-v2-test -- func...
- GitHub Check: programs (system-cpi-test, ["cargo-test-sbf -p system-cpi-test", "cargo test -p light-system-prog...
🔇 Additional comments (44)
sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/account_metas.rs (1)
4-4: LGTM! Import path correctly updated.The import path for
CTokenDefaultAccountshas been properly updated to reflect its new location in theutilsmodule, consistent with the PR's restructuring objectives.forester/src/compressible/compressor.rs (1)
6-6: LGTM! Import path correctly updated.The import path for
CompressAndCloseAccountshas been properly updated to reflect the newcompressed_tokenmodule structure.sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs (1)
1-1: LGTM! Test import path correctly updated.The import path has been properly updated to reflect the new
ctokenmodule location. Test logic remains unchanged.sdk-libs/compressed-token-sdk/src/ctoken/transfer_interface.rs (1)
12-19: LGTM! Import paths correctly reorganized.The import paths have been properly restructured to reflect the new module hierarchy:
transfer2items now imported fromcompressed_token::transfer2CTokenAccount2imported fromcompressed_tokenTokenSdkErrorcorrectly imported fromerrormoduleNote: This file has pre-existing issues flagged in previous reviews (account ordering mismatches in lines 189-358) that are unrelated to this refactoring.
sdk-libs/token-client/src/instructions/update_compressed_mint.rs (1)
7-9: LGTM! Import path correctly updated.The import path for
update_compressed_mintandUpdateCompressedMintInputshas been properly updated to reflect the newcompressed_tokenmodule structure.sdk-libs/token-client/src/instructions/mint_action.rs (1)
7-10: LGTM! Import paths correctly reorganized.The import paths have been properly restructured to reflect the new nested module hierarchy under
compressed_token:
create_compressed_mintitems (address derivation functions)mint_actionitems (account metas and config)All functionality preserved.
sdk-libs/token-client/src/instructions/create_mint.rs (1)
5-7: LGTM! Import path correctly updated.The import path for
create_compressed_mintmodule items has been properly updated to reflect the newcompressed_tokenmodule structure.sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_infos.rs (1)
6-6: LGTM! Import path correctly updated.The import path for
CTokenAccounthas been properly updated to reflect the new versioned module structure undercompressed_token::v1.sdk-libs/token-client/src/actions/create_compressible_token_account.rs (1)
2-5: LGTM! Import path correctly updated.The import path has been properly updated to reflect the new module structure (
ctoken::create_token_account), aligning with the broader SDK reorganization.sdk-libs/program-test/src/forester/compress_and_close_forester.rs (1)
8-8: LGTM! Import path correctly updated.The import for
CompressAndCloseAccountshas been properly updated to the newcompressed_token::compress_and_closemodule path.sdk-libs/compressed-token-sdk/src/compressed_token/v2/compress_and_close.rs (1)
17-24: LGTM! Import paths correctly reorganized.The imports have been properly updated to use relative paths (
super::) for sibling modules and the newutils::CTokenDefaultAccountslocation. This aligns with the module hierarchy reorganization.sdk-libs/compressed-token-sdk/src/compressible/mod.rs (1)
1-5: LGTM! Clean module organization.The new
compressiblemodule is well-structured with proper submodule declarations and re-exports, making the API surface convenient for consumers.sdk-libs/compressed-token-sdk/src/ctoken/mod.rs (2)
1-5: LGTM! New modules properly declared.The new submodules expand the
ctokennamespace with well-organized functionality for token account operations.
42-44: The original review comment is based on incorrect assumptions and should be dismissed.The old path
crate::instructions::create_compressed_mintnever existed in this crate. The compressed-token-sdk has never exported aninstructionsmodule—the library structure shows only:compressed_token,compressible,ctoken,error,pack,token_pool, andutils.The current re-export at lines 42-44 uses the
compressed_token::create_compressed_mintpath, which aligns with the crate's actual module organization. This isn't a breaking change between two paths; it's the existing (or newly organized) public API. The references tocrate::instructionsfound elsewhere are in different crates (e.g.,token-client), not in compressed-token-sdk itself.Likely an incorrect or invalid review comment.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/account_metas.rs (1)
4-4: LGTM! Import path correctly updated.The import for
CTokenDefaultAccountshas been properly updated to reference the newutilsmodule location.sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/account_metas.rs (1)
4-4: LGTM! Import path correctly updated.The import for
CTokenDefaultAccountshas been properly updated to the newutilsmodule location, consistent with the broader refactoring.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/account_metas.rs (1)
4-4: LGTM! Import path correctly updated.The import for
CTokenDefaultAccountshas been properly updated to the newutilsmodule location, completing the consistent refactoring across all account_metas files.sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/account_metas.rs (1)
6-6: LGTM: Clean import path updateThe import path for
CTokenDefaultAccountshas been correctly updated to reflect its new location in theutilsmodule. The usage throughout the file remains unchanged, maintaining functional behavior.sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/account_metas.rs (1)
4-4: LGTM: Consistent import path updateImport updated to use
crate::utils::CTokenDefaultAccounts, consistent with the v2 module changes. The refactor maintains all existing functionality.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_to_compressed/instruction.rs (1)
11-13: LGTM: Module path reorganizationThe imports have been correctly updated from
crate::instructions::mint_actiontocrate::compressed_token::mint_action, aligning with the new module structure. All usage of the imported functions remains intact.sdk-libs/compressed-token-sdk/tests/mint_action_cpi_accounts_tests.rs (1)
4-6: LGTM: Test updated for new public API pathThe test imports have been updated to use the new
compressed_token::mint_actionmodule path. All test functionality remains unchanged, confirming the refactor maintains backward compatibility through proper re-exports.sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/account_metas.rs (1)
4-4: LGTM: Default accounts import relocatedImport path updated to
crate::utils::CTokenDefaultAccounts, consistent with the centralization of default account utilities. All usage in the file remains functionally identical.sdk-libs/token-client/src/actions/transfer2/spl_to_ctoken.rs (1)
6-6: LGTM: Updated to use transfer interface moduleImport correctly updated to use the new
ctoken::transfer_interface::TransferSplToCtokenpath. The functional usage remains unchanged, demonstrating proper API compatibility.sdk-libs/compressed-token-sdk/src/compressed_token/v2/transfer2/instruction.rs (1)
10-12: LGTM: Module organization improvedThe imports have been properly updated to use
super::account_metasfor sibling module access andcompressed_token::CTokenAccount2for the type path. This aligns with the new v2 module structure while maintaining all functionality.sdk-libs/token-client/src/instructions/mint_to_compressed.rs (1)
7-12: LGTM: Imports reorganized to new module structureThe imports have been correctly restructured to use the new
compressed_tokenmodule hierarchy with proper nesting (create_compressed_mint,mint_to_compressedsubmodules). All imported items are used consistently throughout the file, and functionality is preserved.sdk-libs/compressed-token-sdk/src/compressed_token/v1/batch_compress/instruction.rs (1)
8-8: LGTM - Import path correctly updated for v1 module structure.The import path has been correctly updated from
crate::instructions::batch_compress::account_metastosuper::account_metas, aligning with the new v1 module organization whereaccount_metasis a sibling module undercompressed_token/v1/batch_compress/.sdk-libs/compressed-token-sdk/src/compressed_token/v2/create_compressed_mint/instruction.rs (1)
17-22: LGTM - Import paths correctly reorganized for v2 structure.The import paths have been properly updated from
crate::instructions::mint_actiontocrate::compressed_token::mint_action, aligning with the new v2 module hierarchy. The reordering of error imports is a minor organizational improvement.forester/tests/test_compressible_ctoken.rs (1)
12-12: LGTM - Test updated to use new public API path.The test import has been correctly updated from
light_compressed_token_sdk::instructions::create_compressed_minttolight_compressed_token_sdk::compressed_token::create_compressed_mint. This change demonstrates the breaking nature of this refactor for external SDK consumers.sdk-libs/compressed-token-sdk/src/compressed_token/v2/update_compressed_mint/instruction.rs (1)
13-18: LGTM - Consistent import path updates for v2 module.Import paths correctly updated from
crate::instructions::mint_actiontocrate::compressed_token::mint_action, consistent with the v2 module reorganization. The error import reordering maintains consistency with other v2 instruction files.sdk-libs/compressed-token-sdk/src/compressed_token/v1/approve/instruction.rs (1)
9-11: LGTM - Import paths correctly updated for v1 module organization.Both import path updates are correct:
account_metasnow imported fromsuper::account_metas(sibling module)CTokenAccountpath updated tocrate::compressed_token::v1::CTokenAccountThese changes align with the new v1 module structure where account types and metadata live under their respective versioned modules.
sdk-libs/compressed-token-sdk/src/compressed_token/v1/transfer/instruction.rs (1)
9-11: LGTM - Transfer instruction imports correctly reorganized.Import paths properly updated:
- Account metadata utilities from
super::account_metasCTokenAccountfromcrate::compressed_token::v1::account::CTokenAccountThe changes are consistent with the v1 module structure and align with similar updates in other v1 instruction files like approve.
sdk-libs/compressed-token-sdk/tests/account_metas_test.rs (1)
2-9: LGTM - Test imports comprehensively updated to new module structure.The test imports have been properly reorganized:
batch_compressandtransfer::account_metasnow accessed viacompressed_tokenmoduleCTokenDefaultAccountsrelocated toutilsmodule (previously underinstructions)This change demonstrates the complete public API reorganization and validates that the refactor maintains backward compatibility in terms of functionality while updating the import paths.
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/account_metas.rs (2)
5-5: LGTM - CTokenDefaultAccounts correctly relocated to utils module.The import path for
CTokenDefaultAccountshas been updated fromcrate::instructionstocrate::utils, reflecting its relocation to a dedicated utilities module. This change is consistent across all files in this refactor and represents a cleaner separation of concerns.
197-200: LGTM - Cross-module reference uses correct compressed_token path.The call to
crate::compressed_token::create_compressed_mint::find_spl_mint_addresscorrectly uses the new module structure path. This demonstrates proper internal module referencing within the refactored SDK.sdk-libs/token-client/src/instructions/transfer2.rs (1)
6-14: LGTM! Clean import path reorganization.The import paths have been correctly updated to reflect the new module structure:
- Transfer2-related items now under
compressed_token::transfer2CTokenAccount2moved tocompressed_token- Error types properly namespaced under
error::No logic changes, purely structural refactoring as intended.
sdk-libs/token-client/src/actions/transfer2/ctoken_to_spl.rs (1)
6-6: LGTM! Import path correctly updated.The
TransferCtokenToSplimport has been properly relocated frominstructionstoctoken::transfer_interface, consistent with the new module organization.sdk-libs/compressed-token-sdk/src/compressed_token/v2/mint_action/instruction.rs (1)
9-10: LGTM! Import paths properly updated.The imports have been correctly reorganized to use relative paths (
super::cpi_accounts) and updated crate paths forCTokenInstructionandTokenSdkError. No functional changes to the trait implementations.sdk-libs/token-client/src/actions/mint_action.rs (2)
5-5: LGTM! Import path correctly updated.The
derive_compressed_mint_addressimport now references the proper nested module path undercompressed_token::create_compressed_mint.
102-105: LGTM! Scoped imports properly reorganized.The scoped import block correctly brings in
find_spl_mint_addressandderive_ctoken_atafrom their new module paths, keeping the namespace clean for this specific function.sdk-libs/compressed-token-sdk/src/compressed_token/v2/decompress_full.rs (1)
14-21: LGTM! Import paths properly consolidated.The imports have been cleanly reorganized to use:
- Relative paths (
super::) for sibling modules (CTokenAccount2, transfer2 items)- Consolidated crate imports for related types (compat, error, utils)
This improves readability and aligns with the new module structure. No functional changes.
sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs (1)
7-8: Wildcard re-exports appear intentional for API surface versioning—document the design decision.The verification confirms no naming conflicts between v1 and v2 exports. The structure is deliberate: v1 exposes
approve,batch_compress,transfer(plus account types), while v2 exposescompress_and_close,create_compressed_mint,transfer2(plus account2 types). Each version independently manages its public surface before flattening at the top level.This versioning approach is sound, but recommend:
- Adding a doc comment above the re-exports explaining this is intentional versioning strategy
- Consider using explicit re-exports in future if the API surface grows significantly, to prevent accidental public additions
sdk-libs/compressed-token-sdk/src/compressed_token/v2/mod.rs (2)
1-9: Module structure looks clean.The v2 namespace organization is clear, with sensible groupings for compressed token operations. The private
account2module with public re-export (line 11) keeps internal organization flexible while exposing a stable API surface.
11-11: Re-export pattern is appropriate.Exposing
account2items at the v2 module level throughpub useis idiomatic and maintains a clean public API boundary.sdk-libs/compressed-token-sdk/src/utils.rs (1)
61-79: Struct definition is well-organized.The
CTokenDefaultAccountsstruct provides a clear API for standard compressed token account pubkeys, with appropriate derives and documentation.
| mod account; | ||
| pub mod approve; | ||
| pub mod batch_compress; | ||
| pub mod transfer; | ||
|
|
||
| pub use account::*; |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial
🧩 Analysis chain
Verify the wildcard re-export of the private account module is intentional.
The account module is declared as private (mod account on line 1) but then fully re-exported as public via pub use account::* (line 6). This pattern makes all public items from the private module available in the v1 namespace.
Ensure:
- All items in the
accountmodule are meant to be part of v1's public API - This pattern is documented if it's an intentional design choice for API ergonomics
- Future additions to
accountwon't accidentally expand the public surface
Consider using explicit named re-exports for better control:
pub use account::{CTokenAccount, /* other specific types */};🏁 Script executed:
#!/bin/bash
# Check what's being re-exported from the account module
echo "=== Public items in v1/account module ==="
rg -n "^pub " sdk-libs/compressed-token-sdk/src/compressed_token/v1/account.rs -A1 2>/dev/null || \
rg -n "^pub " sdk-libs/compressed-token-sdk/src/compressed_token/v1/account/ -A1Length of output: 108
🏁 Script executed:
#!/bin/bash
# Get comprehensive view of account module - list all pub items
echo "=== All public items in v1/account module ==="
if [ -f sdk-libs/compressed-token-sdk/src/compressed_token/v1/account.rs ]; then
rg -n "^pub " sdk-libs/compressed-token-sdk/src/compressed_token/v1/account.rs -A2
elif [ -d sdk-libs/compressed-token-sdk/src/compressed_token/v1/account ]; then
find sdk-libs/compressed-token-sdk/src/compressed_token/v1/account -name "*.rs" -exec rg -n "^pub " {} + -A2
fi
echo -e "\n=== Check parent compressed_token/mod.rs pattern ==="
cat sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs 2>/dev/null | head -20
echo -e "\n=== Look for CLAUDE.md or design docs ==="
find . -maxdepth 3 -name "CLAUDE.md" -o -name "*.md" | head -10Length of output: 570
🏁 Script executed:
#!/bin/bash
echo "=== Extract CLAUDE.md module organization guidance ==="
grep -n -i -A5 -B5 "module\|re-export\|wildcard\|pub use\|api.*surface" ./CLAUDE.md | head -50
echo -e "\n=== Check for any TODO/FIXME in the mod files ==="
grep -r "TODO\|FIXME\|XXX" sdk-libs/compressed-token-sdk/src/compressed_token/ | grep -i "mod\|export\|account"
echo -e "\n=== Look for comments in v1/mod.rs about the pattern ==="
cat sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rsLength of output: 3722
Align module visibility pattern with submodules or document the design rationale.
The account module is marked private but then fully re-exported via pub use account::*, while approve, batch_compress, and transfer are declared as public modules. This asymmetrical design lacks explanation.
The parent compressed_token/mod.rs mirrors this pattern (pub use v1::*), suggesting intentional API flattening, but there's no documentation in CLAUDE.md or code comments explaining why account is treated differently.
Consider one of:
- Make
accounta public module for consistency:pub mod account;(simplest) - Make all submodules private with wildcard re-exports for strict encapsulation and add a design comment explaining the versioning strategy
- At minimum, add a doc comment explaining the deliberate visibility choice
Since CTokenAccount is the only public export from account, the surface area is controlled, but consistency matters for developer expectations.
🤖 Prompt for AI Agents
In sdk-libs/compressed-token-sdk/src/compressed_token/v1/mod.rs lines 1-6, the
account module is declared private but is immediately re-exported with `pub use
account::*`, creating an inconsistent visibility pattern vs the other `pub mod`
submodules; either make the module declaration public for consistency (change to
`pub mod account;`) while keeping the existing `pub use account::*`, or if you
intend to keep the module private, add a clear doc comment above the `mod
account;` line explaining the deliberate visibility choice and
versioning/API-flattening rationale so readers understand why `account` differs
from `approve`, `batch_compress`, and `transfer`.
- Restore typedoc.stateless.json accidentally deleted in PR #2065 - Add compressed-token build step before typedoc generation - Add workflow_dispatch for manual triggers - Add swen/js-beta branch push trigger for auto-rebuild
- Restore typedoc.stateless.json accidentally deleted in PR #2065 - Add compressed-token build step before typedoc generation - Add workflow_dispatch for manual triggers - Add branch push triggers (main, swen/pub-beta-cov) with path filter on js/*/src/**
- Restore typedoc.stateless.json accidentally deleted in PR #2065 - Add compressed-token build step before typedoc generation - Add workflow_dispatch for manual triggers - Add branch push triggers (main, swen/pub-beta-cov) with path filter on js/*/src/** Co-authored-by: tilo-14 <tilo@luminouslabs.com>
stacked on #2064
Summary by CodeRabbit
Release Notes
New Features
TransferCtokenfunctionality for token transfers.Refactoring
compressed_tokenandctokenmodule hierarchy.✏️ Tip: You can customize this high-level summary in your review settings.