Skip to content

Commit f56835f

Browse files
committed
stash doc fixes
1 parent fa6d622 commit f56835f

30 files changed

Lines changed: 99 additions & 305 deletions

File tree

program-libs/token-interface/src/state/mint/compressed_mint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ pub struct CompressedMintMetadata {
7676
/// Pda with seed address of compressed mint
7777
pub mint: Pubkey,
7878
/// Signer pubkey used to derive the compressed address
79-
pub mint_signer: Pubkey,
79+
pub mint_signer: [u8; 32],
8080
/// Bump seed used for compressed address derivation
8181
pub bump: u8,
8282
}

program-libs/token-interface/tests/compressed_mint.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn generate_random_compressed_mint(rng: &mut impl Rng, with_extensions: bool) ->
7878
version: 3,
7979
mint,
8080
cmint_decompressed: rng.gen_bool(0.5),
81-
mint_signer: Pubkey::from(rng.gen::<[u8; 32]>()),
81+
mint_signer: rng.gen::<[u8; 32]>(),
8282
bump: rng.gen(),
8383
},
8484
reserved: [0u8; 16],
@@ -262,7 +262,7 @@ fn test_compressed_mint_edge_cases() {
262262
version: 3,
263263
mint: Pubkey::from([0xff; 32]),
264264
cmint_decompressed: false,
265-
mint_signer: Pubkey::from([0u8; 32]),
265+
mint_signer: [0u8; 32],
266266
bump: 0,
267267
},
268268
reserved: [0u8; 16],
@@ -343,7 +343,7 @@ fn test_compressed_mint_edge_cases() {
343343
version: 255,
344344
mint: Pubkey::from([0xbb; 32]),
345345
cmint_decompressed: true,
346-
mint_signer: Pubkey::from([0xcc; 32]),
346+
mint_signer: [0xcc; 32],
347347
bump: 255,
348348
},
349349
reserved: [0u8; 16],
@@ -372,7 +372,7 @@ fn test_base_mint_in_compressed_mint_spl_format() {
372372
version: 3,
373373
mint: Pubkey::from([3; 32]),
374374
cmint_decompressed: false,
375-
mint_signer: Pubkey::from([4u8; 32]),
375+
mint_signer: [4u8; 32],
376376
bump: 255,
377377
},
378378
reserved: [0u8; 16],

program-libs/token-interface/tests/cross_deserialization.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn create_test_cmint() -> CompressedMint {
2929
version: 3,
3030
mint: Pubkey::new_from_array([2; 32]),
3131
cmint_decompressed: false,
32-
mint_signer: Pubkey::new_from_array([5u8; 32]),
32+
mint_signer: [5u8; 32],
3333
bump: 255,
3434
},
3535
reserved: [0u8; 16],

program-libs/token-interface/tests/mint_borsh_zero_copy.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn generate_random_mint() -> CompressedMint {
103103
rng.fill(&mut bytes);
104104
Pubkey::from(bytes)
105105
},
106-
mint_signer: Pubkey::from(rng.gen::<[u8; 32]>()),
106+
mint_signer: rng.gen::<[u8; 32]>(),
107107
bump: rng.gen(),
108108
},
109109
reserved: [0u8; 16],
@@ -258,7 +258,7 @@ fn generate_mint_with_extensions() -> CompressedMint {
258258
version: 3,
259259
cmint_decompressed: rng.gen_bool(0.5),
260260
mint: Pubkey::from(rng.gen::<[u8; 32]>()),
261-
mint_signer: Pubkey::from(rng.gen::<[u8; 32]>()),
261+
mint_signer: rng.gen::<[u8; 32]>(),
262262
bump: rng.gen(),
263263
},
264264
reserved: [0u8; 16],
@@ -294,7 +294,7 @@ fn test_mint_extension_edge_cases() {
294294
version: 3,
295295
cmint_decompressed: false,
296296
mint: Pubkey::from([2u8; 32]),
297-
mint_signer: Pubkey::from([0u8; 32]),
297+
mint_signer: [0u8; 32],
298298
bump: 0,
299299
},
300300
reserved: [0u8; 16],
@@ -325,7 +325,7 @@ fn test_mint_extension_edge_cases() {
325325
version: 3,
326326
cmint_decompressed: true,
327327
mint: Pubkey::from([0xbbu8; 32]),
328-
mint_signer: Pubkey::from([0xddu8; 32]),
328+
mint_signer: [0xddu8; 32],
329329
bump: 255,
330330
},
331331
reserved: [0u8; 16],
@@ -369,7 +369,7 @@ fn test_mint_extension_edge_cases() {
369369
version: 3,
370370
cmint_decompressed: false,
371371
mint: Pubkey::from([4u8; 32]),
372-
mint_signer: Pubkey::from([5u8; 32]),
372+
mint_signer: [5u8; 32],
373373
bump: 255,
374374
},
375375
reserved: [0u8; 16],
@@ -400,7 +400,7 @@ fn test_mint_extension_edge_cases() {
400400
version: 3,
401401
cmint_decompressed: true,
402402
mint: Pubkey::from([7u8; 32]),
403-
mint_signer: Pubkey::from([8u8; 32]),
403+
mint_signer: [8u8; 32],
404404
bump: 255,
405405
},
406406
reserved: [0u8; 16],

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async fn test_setup() -> TestSetup {
8484
version: 3,
8585
cmint_decompressed: false,
8686
mint: spl_mint_pda.into(),
87-
mint_signer: mint_seed.pubkey().into(),
87+
mint_signer: mint_seed.pubkey().to_bytes(),
8888
bump,
8989
},
9090
mint_authority: Some(mint_authority.pubkey().into()),
@@ -334,7 +334,7 @@ async fn test_write_to_cpi_context_invalid_compressed_address() {
334334

335335
// Swap the mint_signer to an invalid one (this should fail validation)
336336
// The compressed address will be derived from the invalid mint_signer
337-
let invalid_mint_signer = light_compressed_account::Pubkey::new_from_array([42u8; 32]);
337+
let invalid_mint_signer = [42u8; 32];
338338

339339
// Build instruction data with invalid mint_signer in metadata
340340
let mut invalid_mint = compressed_mint_inputs.mint.clone().unwrap();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ async fn test_mint_actions() {
12211221
version: 3, // With metadata
12221222
mint: spl_mint_pda.into(),
12231223
cmint_decompressed: false, // Becomes true after DecompressMint action
1224-
mint_signer: mint_seed.pubkey().into(),
1224+
mint_signer: mint_seed.pubkey().to_bytes(),
12251225
bump: mint_bump,
12261226
},
12271227
reserved: [0u8; 16],
@@ -1457,7 +1457,7 @@ async fn test_create_compressed_mint_with_cmint() {
14571457
version: 3,
14581458
cmint_decompressed: false, // Before DecompressMint
14591459
mint: cmint_pda.to_bytes().into(),
1460-
mint_signer: mint_seed.pubkey().into(),
1460+
mint_signer: mint_seed.pubkey().to_bytes(),
14611461
bump: cmint_bump,
14621462
},
14631463
reserved: [0u8; 16],

programs/compressed-token/program/docs/compressed_token/MINT_ACTION.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ The account ordering differs based on whether writing to CPI context or executin
7070
- Light Protocol system program for CPI to create or update the compressed mint account.
7171

7272
2. mint_signer (optional)
73-
- (signer if create_mint is Some, non-signer for DecompressMint)
74-
- Required if create_mint is Some or DecompressMint action is present
73+
- (signer if create_mint is Some)
74+
- Required only if create_mint is Some
7575
- PDA seed derivation from compressed mint randomness
7676

7777
3. authority

programs/compressed-token/program/src/compressed_token/mint_action/accounts.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ use crate::shared::{
1919
pub struct MintActionAccounts<'info> {
2020
pub light_system_program: &'info AccountInfo,
2121
/// Seed for mint PDA derivation.
22-
/// Required for compressed mint creation and DecompressMint.
22+
/// Required only for compressed mint creation.
2323
/// Note: mint_signer is not in executing accounts since create mint
2424
/// is allowed in combination with write to cpi context.
2525
pub mint_signer: Option<&'info AccountInfo>,
2626
pub authority: &'info AccountInfo,
27-
/// Reqired accounts to execute an instruction
27+
/// Required accounts to execute an instruction
2828
/// with or without cpi context.
2929
/// - write_to_cpi_context_system is None
3030
pub executing: Option<ExecutingAccounts<'info>>,
@@ -350,7 +350,7 @@ pub struct AccountsConfig {
350350
pub cmint_decompressed: bool,
351351
/// 5. Mint
352352
pub require_token_output_queue: bool,
353-
/// 6. Compressed mint is created or DecompressMint action is present.
353+
/// 6. Compressed mint is created.
354354
pub with_mint_signer: bool,
355355
/// 7. Compressed mint is created.
356356
pub create_mint: bool,

programs/compressed-token/program/src/compressed_token/mint_action/actions/create_mint.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ pub fn process_create_mint_action(
3838
.ok_or(ProgramError::InvalidInstructionData)?;
3939

4040
// 1. Validate mint_signer matches account
41-
if mint_signer.as_slice() != mint.metadata.mint_signer.array_ref() {
41+
if mint_signer.as_slice() != mint.metadata.mint_signer.as_ref() {
4242
msg!("Mint signer mismatch");
4343
return Err(ErrorCode::MintActionInvalidMintSigner.into());
4444
}
45+
// 2. Validate bump matches derived bump
4546
if mint_pda_bump != mint.metadata.bump {
46-
msg!("Mint bump mismatch");
47+
msg!("Invalid mint bump");
4748
return Err(ErrorCode::MintActionInvalidMintBump.into());
4849
}
4950

@@ -59,7 +60,8 @@ pub fn process_create_mint_action(
5960
// -> Therefore we manually verify the compressed address derivation here.
6061
//
6162
// else is not required since for new_address_params_assigned
62-
// the light system program checks correct address derivation and we check the
63+
// the light system program checks correct address derivation and we check
64+
// the address tree in new_address_params.
6365
if let Some(cpi_context) = &parsed_instruction_data.cpi_context {
6466
if !pubkey_eq(&cpi_context.address_tree_pubkey, &CMINT_ADDRESS_TREE) {
6567
msg!("Invalid address tree pubkey in cpi context");
@@ -70,8 +72,8 @@ pub fn process_create_mint_action(
7072
&cpi_context.address_tree_pubkey,
7173
&crate::LIGHT_CPI_SIGNER.program_id,
7274
);
73-
// Validate derived address matches the compressed_address from metadata
74-
// (which derives from mint PDA, CMINT_ADDRESS_TREE, and LIGHT_TOKEN_PROGRAM_ID)
75+
// Validate derived address matches the compressed_address computed from metadata
76+
// (derived from mint PDA, CMINT_ADDRESS_TREE, and LIGHT_TOKEN_PROGRAM_ID)
7577
if address != mint.metadata.compressed_address() {
7678
msg!("Invalid compressed mint address derivation");
7779
return Err(ErrorCode::MintActionInvalidCompressedMintAddress.into());

programs/compressed-token/program/src/compressed_token/mint_action/processor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ pub fn process_mint_action(
130130
&accounts_config,
131131
&mint,
132132
)?;
133-
};
133+
}
134134

135135
let result = process_output_compressed_account(
136136
&parsed_instruction_data,

0 commit comments

Comments
 (0)