Skip to content

Commit 51690d7

Browse files
committed
add comments
1 parent b073cd8 commit 51690d7

File tree

6 files changed

+27
-7
lines changed

6 files changed

+27
-7
lines changed

program-libs/ctoken-types/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ pub mod error;
66

77
pub use error::*;
88
pub mod state;
9+
// TODO: cleanup this crate
10+
// TODO: move all constants to constants.
911

1012
// Re-export Pubkey type
1113
#[cfg(feature = "anchor")]

program-libs/ctoken-types/src/state/extensions/compressible.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct CompressibleExtension {
3030
/// Authority that can close this account (in addition to owner)
3131
pub rent_authority: Pubkey,
3232
pub rent_recipient: Pubkey,
33-
// TODO: add state variable
33+
// TODO: confirm that state variable is not necessary because we realloc memory to 0.
3434
}
3535

3636
// Implement PdaTimingData trait for integration with light-protocol2's compression SDK
@@ -63,6 +63,7 @@ impl ZCompressibleExtension<'_> {
6363
Ok(u64::from(target_slot).saturating_sub(current_slot))
6464
}
6565

66+
// Note this might clash with rust tests. (Maybe I can use an env variable)
6667
/// Get the remaining slots until compression is allowed (non-Solana target)
6768
/// Returns 0 if compression is already allowed
6869
#[cfg(not(target_os = "solana"))]

programs/compressed-token/program/src/convert_account_infos.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anchor_lang::prelude::ProgramError;
22
use pinocchio::account_info::AccountInfo;
3-
3+
// TODO: move to light-account-checks
44
/// Convert Pinocchio AccountInfo to Solana AccountInfo with minimal safety overhead
55
///
66
/// # SAFETY

programs/compressed-token/program/src/decompressed_token_transfer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn process_decompressed_token_transfer(
2323
TokenInstruction::Transfer { amount } => {
2424
let account_infos = unsafe { convert_account_infos::<MAX_ACCOUNTS>(accounts)? };
2525
// Note:
26-
// need to use light_token_22 fork for token_22 contains
26+
// We need to use light_token_22 fork for token_22 contains
2727
// a hardcoded program id check for account ownership.
2828
light_token_22::processor::Processor::process_transfer(
2929
&crate::ID,

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub mod extensions;
1414
pub mod mint_action;
1515
pub mod shared;
1616
pub mod transfer2;
17+
// TODO: move ErrorCode -> pinocchio program and rename to CTokenError
1718

1819
// Reexport the wrapped anchor program.
1920
pub use ::anchor_compressed_token::*;
@@ -35,12 +36,26 @@ pub const MAX_ACCOUNTS: usize = 30;
3536
// When adding new instructions check anchor discriminators for collisions!
3637
#[repr(u8)]
3738
pub enum InstructionType {
38-
DecompressedTransfer = 3, // SPL Token transfer
39-
CloseTokenAccount = 9, // SPL Token CloseAccount
39+
/// Decompressed CToken transfer
40+
DecompressedTransfer = 3,
41+
/// Decompressed CToken CloseAccount
42+
CloseTokenAccount = 9,
43+
/// Create decompressed CToken, equivalent to SPL Token InitializeAccount3
44+
CreateTokenAccount = 18,
45+
// TODO: start at 100
4046
CreateAssociatedTokenAccount = 103,
4147
Transfer2 = 104,
48+
/// Batch instruction for operation on one compressed Mint account:
49+
/// 1. CreateMint
50+
/// 2. MintTo
51+
/// 3. UpdateMintAuthority
52+
/// 4. UpdateFreezeAuthority
53+
/// 5. CreateSplMint
54+
/// 6. MintToDecompressed
55+
/// 7. UpdateMetadataField
56+
/// 8. UpdateMetadataAuthority
57+
/// 9. RemoveMetadataKey
4258
MintAction = 106,
43-
CreateTokenAccount = 18, // equivalen to SPL Token InitializeAccount3
4459
Other,
4560
}
4661

@@ -49,10 +64,10 @@ impl From<u8> for InstructionType {
4964
match value {
5065
3 => InstructionType::DecompressedTransfer,
5166
9 => InstructionType::CloseTokenAccount,
67+
18 => InstructionType::CreateTokenAccount,
5268
103 => InstructionType::CreateAssociatedTokenAccount,
5369
104 => InstructionType::Transfer2,
5470
106 => InstructionType::MintAction,
55-
18 => InstructionType::CreateTokenAccount,
5671
_ => InstructionType::Other,
5772
}
5873
}
@@ -101,6 +116,7 @@ pub fn process_instruction(
101116
process_mint_action(accounts, &instruction_data[1..])?;
102117
}
103118
// anchor instructions have no discriminator conflicts with InstructionType
119+
// TODO: add test for discriminator conflict
104120
_ => {
105121
let account_infos = unsafe { convert_account_infos::<MAX_ACCOUNTS>(accounts)? };
106122
let account_infos = ManuallyDrop::new(account_infos);

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ pub struct AccountsConfig {
306306
}
307307

308308
impl AccountsConfig {
309+
// TODO: Unit test
309310
/// Initialize AccountsConfig based in instruction data. -
310311
pub fn new(parsed_instruction_data: &ZMintActionCompressedInstructionData) -> AccountsConfig {
311312
// 1.cpi context

0 commit comments

Comments
 (0)