Skip to content

Commit c5e8590

Browse files
committed
rename close cmint -> compress and close cmint
1 parent d2c1dae commit c5e8590

20 files changed

Lines changed: 105 additions & 104 deletions

File tree

program-libs/ctoken-interface/src/instructions/mint_action/builder.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use light_compressed_account::instruction_data::{
44
};
55

66
use crate::instructions::mint_action::{
7-
Action, CloseCMintAction, CompressedMintInstructionData, CompressedMintWithContext, CpiContext,
8-
CreateMint, DecompressMintAction, MintActionCompressedInstructionData, MintToCTokenAction,
9-
MintToCompressedAction, RemoveMetadataKeyAction, UpdateAuthority,
7+
Action, CompressAndCloseCMintAction, CompressedMintInstructionData, CompressedMintWithContext,
8+
CpiContext, CreateMint, DecompressMintAction, MintActionCompressedInstructionData,
9+
MintToCTokenAction, MintToCompressedAction, RemoveMetadataKeyAction, UpdateAuthority,
1010
UpdateMetadataAuthorityAction, UpdateMetadataFieldAction,
1111
};
1212

@@ -134,9 +134,9 @@ impl MintActionCompressedInstructionData {
134134
self
135135
}
136136

137-
#[must_use = "with_close_cmint returns a new value"]
138-
pub fn with_close_cmint(mut self, action: CloseCMintAction) -> Self {
139-
self.actions.push(Action::CloseCMint(action));
137+
#[must_use = "with_compress_and_close_cmint returns a new value"]
138+
pub fn with_compress_and_close_cmint(mut self, action: CompressAndCloseCMintAction) -> Self {
139+
self.actions.push(Action::CompressAndCloseCMint(action));
140140
self
141141
}
142142

program-libs/ctoken-interface/src/instructions/mint_action/close_cmint.rs renamed to program-libs/ctoken-interface/src/instructions/mint_action/compress_and_close_cmint.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@ use light_zero_copy::ZeroCopy;
22

33
use crate::{AnchorDeserialize, AnchorSerialize};
44

5-
/// Action to close a CMint Solana account.
5+
/// Action to compress and close a CMint Solana account.
66
/// The compressed mint state is always preserved.
77
///
88
/// ## Requirements
99
/// - CMint must exist (cmint_decompressed = true) - unless idempotent is set
1010
/// - CMint must have Compressible extension
11-
/// - Authority must be compression_authority, mint_authority, or freeze_authority
1211
/// - is_compressible() must return true (rent expired)
1312
/// - Cannot be combined with DecompressMint in same instruction
1413
///
15-
/// ## Lamport Distribution
16-
/// - compression_authority: gets compression_cost incentive, ALL remaining to rent_sponsor
17-
/// - mint/freeze_authority: ALL lamports to rent_sponsor
14+
/// ## Note
15+
/// CompressAndCloseCMint is **permissionless** - anyone can compress and close a CMint
16+
/// provided is_compressible() returns true. All lamports are returned to rent_sponsor.
1817
#[repr(C)]
1918
#[derive(Debug, Clone, Copy, AnchorSerialize, AnchorDeserialize, ZeroCopy)]
20-
pub struct CloseCMintAction {
19+
pub struct CompressAndCloseCMintAction {
2120
/// If non-zero, succeed silently when CMint doesn't exist (cmint_decompressed = false)
2221
pub idempotent: u8,
2322
}

program-libs/ctoken-interface/src/instructions/mint_action/instruction_data.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use light_compressed_account::{instruction_data::compressed_proof::CompressedPro
22
use light_zero_copy::ZeroCopy;
33

44
use super::{
5-
CloseCMintAction, CpiContext, CreateSplMintAction, DecompressMintAction, MintToCTokenAction,
6-
MintToCompressedAction, RemoveMetadataKeyAction, UpdateAuthority,
5+
CompressAndCloseCMintAction, CpiContext, CreateSplMintAction, DecompressMintAction,
6+
MintToCTokenAction, MintToCompressedAction, RemoveMetadataKeyAction, UpdateAuthority,
77
UpdateMetadataAuthorityAction, UpdateMetadataFieldAction,
88
};
99
use crate::{
@@ -38,10 +38,9 @@ pub enum Action {
3838
/// Decompress a compressed mint to a CMint Solana account.
3939
/// Creates a CMint PDA that becomes the source of truth.
4040
DecompressMint(DecompressMintAction),
41-
/// Close a CMint Solana account. The compressed mint state is preserved.
42-
/// Authority can be compression_authority, mint_authority, or freeze_authority.
43-
/// All require is_compressible() to return true (rent expired).
44-
CloseCMint(CloseCMintAction),
41+
/// Compress and close a CMint Solana account. The compressed mint state is preserved.
42+
/// Permissionless - anyone can call if is_compressible() returns true (rent expired).
43+
CompressAndCloseCMint(CompressAndCloseCMintAction),
4544
}
4645

4746
#[repr(C)]

program-libs/ctoken-interface/src/instructions/mint_action/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
mod builder;
2-
mod close_cmint;
2+
mod compress_and_close_cmint;
33
mod cpi_context;
44
mod create_spl_mint;
55
mod decompress_mint;
@@ -9,7 +9,7 @@ mod mint_to_ctoken;
99
mod update_metadata;
1010
mod update_mint;
1111

12-
pub use close_cmint::*;
12+
pub use compress_and_close_cmint::*;
1313
pub use cpi_context::*;
1414
pub use create_spl_mint::*;
1515
pub use decompress_mint::*;

program-tests/compressed-token-test/tests/mint/failing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ async fn functional_and_failing_tests() {
422422
&invalid_mint_authority, // Invalid authority
423423
&payer,
424424
None, // decompress_mint
425-
false, // close_cmint
425+
false, // compress_and_close_cmint
426426
vec![], // No compressed recipients
427427
vec![
428428
light_ctoken_interface::instructions::mint_action::Recipient::new(
@@ -481,7 +481,7 @@ async fn functional_and_failing_tests() {
481481
&new_mint_authority, // Valid NEW authority after update
482482
&payer,
483483
None, // decompress_mint
484-
false, // close_cmint
484+
false, // compress_and_close_cmint
485485
vec![], // No compressed recipients
486486
vec![
487487
light_ctoken_interface::instructions::mint_action::Recipient::new(

program-tests/compressed-token-test/tests/mint/functional.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ async fn test_ctoken_transfer() {
743743
&mint_authority,
744744
&payer,
745745
None, // decompress_mint
746-
false, // close_cmint
746+
false, // compress_and_close_cmint
747747
vec![], // no compressed recipients
748748
decompressed_recipients, // mint to decompressed recipients
749749
None, // no mint authority update
@@ -1194,7 +1194,7 @@ async fn test_mint_actions() {
11941194
&mint_authority,
11951195
&payer,
11961196
None, // decompress_mint
1197-
false, // close_cmint
1197+
false, // compress_and_close_cmint
11981198
recipients.clone(), // mint_to_recipients
11991199
vec![], // mint_to_decompressed_recipients
12001200
Some(new_mint_authority.pubkey()), // update_mint_authority
@@ -1343,7 +1343,7 @@ async fn test_mint_actions() {
13431343
&new_mint_authority, // Current authority from first test (now the authority for this mint)
13441344
&payer,
13451345
None, // decompress_mint
1346-
false, // close_cmint
1346+
false, // compress_and_close_cmint
13471347
additional_recipients.clone(), // mint_to_recipients
13481348
vec![], // mint_to_decompressed_recipients
13491349
Some(newer_mint_authority.pubkey()), // update_mint_authority to newer authority
@@ -1435,7 +1435,7 @@ async fn test_create_compressed_mint_with_cmint() {
14351435
&mint_authority,
14361436
&payer,
14371437
Some(DecompressMintParams::default()), // decompress_mint = true (creates CMint)
1438-
false, // close_cmint = false
1438+
false, // compress_and_close_cmint = false
14391439
vec![], // no compressed recipients
14401440
vec![], // no decompressed recipients
14411441
None, // no mint authority update
@@ -1484,9 +1484,9 @@ async fn test_create_compressed_mint_with_cmint() {
14841484
)
14851485
.await;
14861486

1487-
println!("Create compressed mint with CMint completed, now testing CloseCMint...");
1487+
println!("Create compressed mint with CMint completed, now testing CompressAndCloseCMint...");
14881488

1489-
// === CLOSE CMINT ===
1489+
// === COMPRESS AND CLOSE CMINT ===
14901490
// Warp to epoch 2 so that rent expires (CMint created with rent_payment: 2)
14911491
rpc.warp_to_slot(SLOTS_PER_EPOCH * 2).unwrap();
14921492

@@ -1500,14 +1500,14 @@ async fn test_create_compressed_mint_with_cmint() {
15001500
BorshDeserialize::deserialize(&mut cmint_account_data.data.as_slice())
15011501
.expect("Failed to deserialize CMint data");
15021502

1503-
// Close CMint using mint_authority
1503+
// Compress and close CMint (permissionless when rent expired)
15041504
let close_signature = light_token_client::actions::mint_action_comprehensive(
15051505
&mut rpc,
15061506
&mint_seed,
15071507
&mint_authority,
15081508
&payer,
15091509
None, // no decompress_mint
1510-
true, // close_cmint = true
1510+
true, // compress_and_close_cmint = true
15111511
vec![], // no compressed recipients
15121512
vec![], // no decompressed recipients
15131513
None, // no mint authority update
@@ -1517,18 +1517,18 @@ async fn test_create_compressed_mint_with_cmint() {
15171517
.await
15181518
.unwrap();
15191519

1520-
println!("CloseCMint signature: {}", close_signature);
1520+
println!("CompressAndCloseCMint signature: {}", close_signature);
15211521

1522-
// Verify CloseCMint action results using assert_mint_action
1522+
// Verify CompressAndCloseCMint action results using assert_mint_action
15231523
assert_mint_action(
15241524
&mut rpc,
15251525
compressed_mint_address,
15261526
pre_close_mint,
1527-
vec![MintActionType::CloseCMint { idempotent: false }],
1527+
vec![MintActionType::CompressAndCloseCMint { idempotent: false }],
15281528
)
15291529
.await;
15301530

1531-
println!("CloseCMint test completed successfully!");
1531+
println!("CompressAndCloseCMint test completed successfully!");
15321532
}
15331533

15341534
/// Test decompressing an existing compressed mint to CMint
@@ -1633,7 +1633,7 @@ async fn test_decompress_existing_mint_to_cmint() {
16331633
&mint_authority,
16341634
&payer,
16351635
Some(DecompressMintParams::default()), // decompress_mint = true (creates CMint)
1636-
false, // close_cmint
1636+
false, // compress_and_close_cmint
16371637
vec![], // no new compressed recipients
16381638
vec![], // no decompressed recipients
16391639
None, // no mint authority update

program-tests/compressed-token-test/tests/transfer2/compress_failing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async fn setup_compression_test(token_amount: u64) -> Result<CompressionTestCont
118118
&mint_authority,
119119
&payer,
120120
None, // no decompress mint
121-
false, // close_cmint
121+
false, // compress_and_close_cmint
122122
vec![], // no compressed recipients
123123
decompressed_recipients, // mint to decompressed CToken ATA
124124
None, // no mint authority update

program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async fn setup_decompression_test(
123123
&mint_authority,
124124
&payer,
125125
None, // no decompress mint
126-
false, // close_cmint
126+
false, // compress_and_close_cmint
127127
compressed_recipients, // mint compressed tokens to owner
128128
decompressed_recipients, // mint 1 token to decompressed CToken ATA
129129
None, // no mint authority update

program-tests/utils/src/assert_mint_action.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ pub async fn assert_mint_action(
113113
MintActionType::DecompressMint { .. } => {
114114
expected_mint.metadata.cmint_decompressed = true;
115115
}
116-
MintActionType::CloseCMint { .. } => {
116+
MintActionType::CompressAndCloseCMint { .. } => {
117117
expected_mint.metadata.cmint_decompressed = false;
118118
// Remove Compressible extension
119119
if let Some(ref mut extensions) = expected_mint.extensions {
@@ -128,10 +128,10 @@ pub async fn assert_mint_action(
128128
// Determine pre and post decompression states
129129
let post_decompressed = expected_mint.metadata.cmint_decompressed;
130130

131-
// Check for CloseCMint action
132-
let has_close_cmint = actions
131+
// Check for CompressAndCloseCMint action
132+
let has_compress_and_close_cmint = actions
133133
.iter()
134-
.any(|a| matches!(a, MintActionType::CloseCMint { .. }));
134+
.any(|a| matches!(a, MintActionType::CompressAndCloseCMint { .. }));
135135

136136
if post_decompressed {
137137
// === CASE 1 & 2: CMint is source of truth after actions ===
@@ -186,7 +186,7 @@ pub async fn assert_mint_action(
186186
);
187187
} else {
188188
// === CASE 3 & 4: Compressed account is source of truth after actions ===
189-
// (Either CloseCMint happened OR was never decompressed)
189+
// (Either CompressAndCloseCMint happened OR was never decompressed)
190190
let actual_mint_account = rpc
191191
.indexer()
192192
.unwrap()
@@ -218,8 +218,8 @@ pub async fn assert_mint_action(
218218
}
219219
}
220220

221-
// If CloseCMint, verify CMint Solana account is closed
222-
if has_close_cmint {
221+
// If CompressAndCloseCMint, verify CMint Solana account is closed
222+
if has_compress_and_close_cmint {
223223
let cmint_pda = Pubkey::from(pre_compressed_mint.metadata.mint);
224224

225225
let cmint_account = rpc
@@ -229,7 +229,7 @@ pub async fn assert_mint_action(
229229

230230
assert!(
231231
cmint_account.is_none(),
232-
"CMint PDA account should not exist after CloseCMint action"
232+
"CMint PDA account should not exist after CompressAndCloseCMint action"
233233
);
234234
}
235235
// Verify CToken accounts for MintToCToken actions

programs/compressed-token/anchor/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,16 +454,14 @@ pub enum ErrorCode {
454454
WriteTopUpExceedsMaximum,
455455
#[msg("Failed to calculate CMint top-up amount")]
456456
CMintTopUpCalculationFailed,
457-
// CloseCMint specific errors
457+
// CompressAndCloseCMint specific errors
458458
#[msg("CMint is not decompressed")]
459459
CMintNotDecompressed,
460460
#[msg("CMint is missing Compressible extension")]
461461
CMintMissingCompressibleExtension,
462-
#[msg("Invalid authority for CloseCMint - must be compression_authority, mint_authority, or freeze_authority")]
463-
InvalidCloseCMintAuthority,
464462
#[msg("CMint is not compressible (rent not expired)")]
465463
CMintNotCompressible,
466-
#[msg("Cannot combine DecompressMint and CloseCMint in same instruction")]
464+
#[msg("Cannot combine DecompressMint and CompressAndCloseCMint in same instruction")]
467465
CannotDecompressAndCloseInSameInstruction,
468466
#[msg("CMint account does not match compressed_mint.metadata.mint")]
469467
InvalidCMintAccount,

0 commit comments

Comments
 (0)