Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk-libs/account-pinocchio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ pub fn find_mint_address(mint_seed: &[u8; 32]) -> ([u8; 32], u8) {
light_sdk_types::interface::cpi::create_mints::find_mint_address::<AccountInfo>(mint_seed)
}

/// Derive the compressed mint address from a mint seed and address tree pubkey.
/// Derive the light mint address from a mint seed and address tree pubkey.
#[cfg(feature = "token")]
pub fn derive_mint_compressed_address(
mint_seed: &[u8; 32],
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/account/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub fn find_mint_address(mint_seed: &[u8; 32]) -> ([u8; 32], u8) {
)
}

/// Derive the compressed mint address from a mint seed and address tree pubkey.
/// Derive the light mint address from a mint seed and address tree pubkey.
#[cfg(feature = "token")]
pub fn derive_mint_compressed_address(
mint_seed: &[u8; 32],
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/client/src/interface/create_accounts_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl CreateAccountsProofInput {
Self::PdaWithOwner { pda, owner }
}

/// Compressed mint (Mint).
/// Light mint (Mint).
/// Address derived: `derive_mint_compressed_address(&mint_signer, &tree)`
pub fn mint(mint_signer: Pubkey) -> Self {
Self::Mint(mint_signer)
Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/compressed-token-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ For full examples, see the [Compressed Token Examples](https://github.com/Lightp
| Compress SPL account | [create-compressed-token-accounts](https://www.zkcompression.com/compressed-tokens/guides/create-compressed-token-accounts) | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/compress-spl-account.ts) |
| Decompress | [create-compressed-token-accounts](https://www.zkcompression.com/compressed-tokens/guides/create-compressed-token-accounts) | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/decompress.ts) |
| Merge token accounts | [create-compressed-token-accounts](https://www.zkcompression.com/compressed-tokens/guides/create-compressed-token-accounts) | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/merge-token-accounts.ts) |
| Create token pool | [create-compressed-token-accounts](https://www.zkcompression.com/compressed-tokens/guides/create-compressed-token-accounts) | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/create-token-pool.ts) |
| Create SPL interface PDA | [create-compressed-token-accounts](https://www.zkcompression.com/compressed-tokens/guides/create-compressed-token-accounts) | [example](https://github.com/Lightprotocol/examples-zk-compression/blob/main/compressed-token-cookbook/actions/create-token-pool.ts) |

### Toolkit guides

Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/compressed-token-sdk/src/compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub struct TokenData {
pub delegate: Option<Pubkey>,
/// The account's state
pub state: AccountState,
/// TLV extensions for compressed token accounts
/// TLV extensions for light token accounts
pub tlv: Option<Vec<light_token_interface::state::ExtensionStruct>>,
}

Expand Down
2 changes: 1 addition & 1 deletion sdk-libs/compressed-token-sdk/src/compressed_token/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Compressed token account types and instruction builders.
//! Light token account types and instruction builders.

#[cfg(feature = "v1")]
mod v1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn get_approve_instruction_account_metas(config: ApproveMetaConfig) -> Vec<A
false,
));

// self_program (compressed token program)
// self_program (light token program)
metas.push(AccountMeta::new_readonly(
default_pubkeys.self_program,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub struct ApproveInputs {
pub change_compressed_account_merkle_tree: Pubkey,
}

/// Create a compressed token approve instruction
/// Create a light token approve instruction
/// This creates two output accounts:
/// 1. A delegated account with the specified amount and delegate
/// 2. A change account with the remaining balance (if any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn get_batch_compress_instruction_account_metas(
// merkle_tree (mut)
metas.push(AccountMeta::new(config.merkle_tree, false));

// self_program (compressed token program)
// self_program (light token program)
metas.push(AccountMeta::new_readonly(
default_pubkeys.self_program,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl<'info, const N: usize> TransferAccountInfos<'_, 'info, N> {
account_infos.push(self.fee_payer.clone());
account_infos.push(self.authority.clone());

// Add ctoken accounts
// Add light-token accounts
for account in self.ctoken_accounts {
account_infos.push(account.clone());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use solana_pubkey::Pubkey;

use crate::utils::TokenDefaultAccounts;

/// Account metadata configuration for compressed token instructions
/// Account metadata configuration for light token instructions
#[derive(Debug, Default, Copy, Clone)]
pub struct TokenAccountsMetaConfig {
pub fee_payer: Option<Pubkey>,
Expand Down Expand Up @@ -134,7 +134,7 @@ impl TokenAccountsMetaConfig {
}
}

/// Get the standard account metas for a compressed token transfer instruction
/// Get the standard account metas for a light token transfer instruction
pub fn get_transfer_instruction_account_metas(config: TokenAccountsMetaConfig) -> Vec<AccountMeta> {
let default_pubkeys = TokenDefaultAccounts::default();
// Direct invoke adds fee_payer, and authority
Expand All @@ -159,7 +159,7 @@ pub fn get_transfer_instruction_account_metas(config: TokenAccountsMetaConfig) -
AccountMeta::new_readonly(default_pubkeys.account_compression_authority, false),
// account_compression_program
AccountMeta::new_readonly(default_pubkeys.account_compression_program, false),
// self_program (compressed token program)
// self_program (light token program)
AccountMeta::new_readonly(default_pubkeys.self_program, false),
]
} else {
Expand All @@ -176,12 +176,12 @@ pub fn get_transfer_instruction_account_metas(config: TokenAccountsMetaConfig) -
AccountMeta::new_readonly(default_pubkeys.account_compression_authority, false),
// account_compression_program
AccountMeta::new_readonly(default_pubkeys.account_compression_program, false),
// self_program (compressed token program)
// self_program (light token program)
AccountMeta::new_readonly(default_pubkeys.self_program, false),
]
};

// Optional token pool PDA (for compression/decompression)
// Optional SPL interface PDA (for compression/decompression)
if let Some(spl_interface_pda) = config.spl_interface_pda {
metas.push(AccountMeta::new(spl_interface_pda, false));
} else if config.fee_payer.is_some() || config.with_anchor_none {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ use crate::{
error::{Result, TokenSdkError},
AnchorSerialize,
};
// CTokenAccount abstraction to bundle inputs and create outputs.
// Light-token account abstraction to bundle inputs and create outputs.
// Users don't really need to interact with this struct directly.
// Counter point for an anchor like TokenAccount we need the CTokenAccount
// Counter point for an anchor like TokenAccount we need the light-token account
//
// Rename TokenAccountMeta -> TokenAccountMeta
//

// We should have a create instruction function that works onchain and offchain.
// - account infos don't belong into the create instruction function.
// One difference between spl and compressed token program is that you don't want to make a separate cpi per transfer.
// One difference between spl and light token program is that you don't want to make a separate cpi per transfer.
// -> transfer(from, to, amount) doesn't work well
// -
// -> compress(token_account, Option<amount>) could be compressed token account
// -> compress(token_account, Option<amount>) could be light token account
// -> decompress()
// TODO:
// - test decompress and compress in the same instruction
Expand All @@ -39,7 +39,7 @@ pub struct TransferConfig {

/// Create instruction function should only take Pubkeys as inputs not account infos.
///
/// Create the instruction for compressed token operations
/// Create the instruction for light token operations
pub fn create_transfer_instruction_raw(
mint: Pubkey,
token_accounts: Vec<CTokenAccount>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl CTokenAccount2 {
pool_account_index: 0,
pool_index: 0,
bump: 0,
decimals: 0, // Not used for ctoken compression
decimals: 0, // Not used for light-token compression
});
self.method_used = true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn find_account_indices(
destination_pubkey: &Pubkey,
) -> Result<CompressAndCloseIndices, TokenSdkError> {
let source_index = find_index(ctoken_account_key).ok_or_else(|| {
msg!("Source ctoken account not found in packed_accounts");
msg!("Source light-token account not found in packed_accounts");
TokenSdkError::InvalidAccountData
})?;

Expand Down Expand Up @@ -129,7 +129,7 @@ fn find_account_indices(
})
}

/// Compress and close compressed token accounts with pre-computed indices
/// Compress and close light token accounts with pre-computed indices
///
/// # Arguments
/// * `fee_payer` - The fee payer pubkey
Expand Down Expand Up @@ -174,7 +174,7 @@ pub fn compress_and_close_token_accounts_with_indices<'info>(

let amount = light_token_interface::state::Token::amount_from_slice(&account_data)?;

// Create CTokenAccount2 for CompressAndClose operation
// Create light-token account for CompressAndClose operation
let mut token_account = CTokenAccount2::new_empty(idx.owner_index, idx.mint_index);

// Set up compress_and_close with actual indices
Expand Down Expand Up @@ -230,12 +230,12 @@ pub fn compress_and_close_token_accounts_with_indices<'info>(
create_transfer2_instruction(inputs)
}

/// Compress and close compressed token accounts
/// Compress and close light token accounts
///
/// # Arguments
/// * `fee_payer` - The fee payer pubkey
/// * `output_queue_pubkey` - The output queue pubkey where compressed accounts will be stored
/// * `ctoken_solana_accounts` - Slice of ctoken Solana account infos to compress and close
/// * `ctoken_solana_accounts` - Slice of light-token account infos to compress and close
/// * `packed_accounts` - Slice of all accounts that will be used in the instruction (tree accounts)
///
/// # Returns
Expand All @@ -262,11 +262,11 @@ pub fn compress_and_close_token_accounts<'info>(
.map(|idx| (idx + 1) as u8) // Add 1 because output_queue will be at index 0
};

// Process each ctoken Solana account and build indices
// Process each light-token account and build indices
let mut indices_vec = Vec::with_capacity(ctoken_solana_accounts.len());

for ctoken_account_info in ctoken_solana_accounts.iter() {
// Deserialize the ctoken Solana account using light zero copy
// Deserialize the light-token account using light zero copy
let account_data = ctoken_account_info
.try_borrow_data()
.map_err(|_| TokenSdkError::AccountBorrowFailed)?;
Expand Down Expand Up @@ -313,7 +313,7 @@ pub fn compress_and_close_token_accounts<'info>(
)
}

/// Compress and close ctoken accounts, and invoke cpi.
/// Compress and close light-token accounts, and invoke cpi.
///
/// Wraps `compress_and_close_token_accounts`, builds the instruction, and
/// calls `invoke_signed` with provided seeds.
Expand Down Expand Up @@ -404,7 +404,7 @@ impl CompressAndCloseAccounts {
impl AccountMetasVec<AccountMeta> for CompressAndCloseAccounts {
/// Adds:
/// 1. system accounts if not set
/// 2. compressed token program and ctoken cpi authority pda to pre accounts
/// 2. light token program and light-token CPI authority PDA to pre accounts
fn get_account_metas_vec(
&self,
accounts: &mut PackedAccounts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use solana_pubkey::Pubkey;

use crate::utils::TokenDefaultAccounts;

/// Account metadata configuration for create cMint instruction
/// Account metadata configuration for create light mint instruction
#[derive(Debug, Copy, Clone)]
pub struct CreateMintMetaConfig {
pub fee_payer: Option<Pubkey>,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl CreateMintMetaConfig {
}
}

/// Get the standard account metas for a create cMint instruction
/// Get the standard account metas for a create light mint instruction
pub fn get_create_compressed_mint_instruction_account_metas(
config: CreateMintMetaConfig,
) -> Vec<AccountMeta> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{
AnchorDeserialize, AnchorSerialize,
};

/// Input struct for creating a compressed mint instruction
/// Input struct for creating a light mint instruction
#[derive(Debug, Clone, AnchorDeserialize, AnchorSerialize)]
pub struct CreateMintInputs {
pub decimals: u8,
Expand All @@ -38,7 +38,7 @@ pub struct CreateMintInputs {
pub version: u8,
}

/// Creates a compressed mint instruction (wrapper around mint_action)
/// Creates a light mint instruction (wrapper around mint_action)
pub fn create_compressed_mint_cpi(
input: CreateMintInputs,
cpi_context: Option<CpiContext>,
Expand Down Expand Up @@ -170,12 +170,12 @@ pub fn create_compressed_mint_cpi_write(input: CreateMintInputsCpiWrite) -> Resu
})
}

/// Creates a compressed mint instruction with automatic mint address derivation
/// Creates a light mint instruction with automatic mint address derivation
pub fn create_compressed_mint(input: CreateMintInputs) -> Result<Instruction> {
create_compressed_mint_cpi(input, None, None)
}

/// Derives the compressed mint address from the mint seed and address tree
/// Derives the light mint address from the mint seed and address tree
pub fn derive_mint_compressed_address(
mint_seed: &Pubkey,
address_tree_pubkey: &Pubkey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ use crate::{
#[derive(Debug, Clone, AnchorDeserialize, AnchorSerialize)]
pub struct DecompressFullIndices {
pub source: MultiInputTokenDataWithContext, // Complete compressed account data with merkle context
pub destination_index: u8, // Destination ctoken Solana account (must exist)
/// Whether this is an ATA decompression. For ATAs, the source.owner is the ATA address
pub destination_index: u8, // Destination light-token account (must exist)
/// Whether this is an associated token account decompression. For ATAs, the source.owner is the ATA address
/// (not the wallet), so it should NOT be marked as a signer - the wallet signs the tx instead.
pub is_ata: bool,
/// TLV extensions for this compressed account (e.g., CompressedOnly extension).
Expand Down Expand Up @@ -156,7 +156,7 @@ impl<'a> Unpack<AccountInfo<'a>> for DecompressFullIndices {
}
}

/// Decompress full balance from compressed token accounts with pre-computed indices
/// Decompress full balance from compressed light token accounts with pre-computed indices
///
/// # Arguments
/// * `fee_payer` - The fee payer pubkey
Expand Down Expand Up @@ -195,7 +195,7 @@ pub fn decompress_full_token_accounts_with_indices<'info>(
// For decompress_full, we don't have an output tree since everything goes to the destination
let mut token_account = CTokenAccount2::new(vec![idx.source])?;

// Set up decompress_full - decompress entire balance to destination ctoken account
// Set up decompress_full - decompress entire balance to destination light-token account
token_account.decompress(idx.source.amount, idx.destination_index)?;
token_accounts.push(token_account);

Expand Down Expand Up @@ -267,10 +267,10 @@ pub fn decompress_full_token_accounts_with_indices<'info>(
create_transfer2_instruction(inputs)
}

/// Helper function to pack compressed token accounts into DecompressFullIndices.
/// Helper function to pack compressed light token accounts into DecompressFullIndices.
/// Delegates to `DecompressFullInput::pack()`.
///
/// For non-ATA decompress: owner is marked as a signer.
/// For non-associated-token-account decompress: owner is marked as a signer.
#[cfg(not(target_os = "solana"))]
#[profile]
pub fn pack_for_decompress_full(
Expand Down Expand Up @@ -354,7 +354,7 @@ impl DecompressFullAccounts {
impl AccountMetasVec<AccountMeta> for DecompressFullAccounts {
/// Adds:
/// 1. system accounts if not set
/// 2. compressed token program and ctoken cpi authority pda to pre accounts
/// 2. light token program and light-token CPI authority PDA to pre accounts
fn get_account_metas_vec(
&self,
accounts: &mut PackedAccounts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ pub struct MintActionMetaConfig {
pub input_queue: Option<Pubkey>, // Input queue for existing compressed mint operations
pub tokens_out_queue: Option<Pubkey>, // Output queue for new token accounts
pub cpi_context: Option<Pubkey>,
pub token_accounts: Vec<Pubkey>, // For mint_to_ctoken actions
pub token_accounts: Vec<Pubkey>, // For mint to light-token actions
pub mint: Option<Pubkey>, // Mint PDA account for DecompressMint action
pub compressible_config: Option<Pubkey>, // CompressibleConfig account (when creating Mint)
pub rent_sponsor: Option<Pubkey>, // Rent sponsor PDA (when creating Mint)
pub mint_signer_must_sign: bool, // true for create_mint, false for decompress_mint
}

impl MintActionMetaConfig {
/// Create a new MintActionMetaConfig for creating a new compressed mint.
/// Create a new MintActionMetaConfig for creating a new light mint.
pub fn new_create_mint(
fee_payer: Pubkey,
authority: Pubkey,
Expand All @@ -47,7 +47,7 @@ impl MintActionMetaConfig {
}
}

/// Create a new MintActionMetaConfig for operations on an existing compressed mint.
/// Create a new MintActionMetaConfig for operations on an existing light mint.
#[inline(never)]
pub fn new(
fee_payer: Pubkey,
Expand Down Expand Up @@ -211,7 +211,7 @@ impl MintActionMetaConfig {

metas.push(AccountMeta::new(self.tree_pubkey, false));

// input_queue is present when operating on an existing compressed mint
// input_queue is present when operating on an existing compressed light mint
// (input_queue is set via new() for existing mints, None via new_create_mint() for new mints)
if let Some(input_queue) = self.input_queue {
metas.push(AccountMeta::new(input_queue, false));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct MintActionCpiWriteAccounts<'a, T: AccountInfoTrait + Clone> {
pub cpi_authority_pda: &'a T,
pub cpi_context: &'a T,
pub cpi_signer: CpiSigner,
pub recipient_token_accounts: Vec<&'a T>, // For mint_to_ctoken actions
pub recipient_token_accounts: Vec<&'a T>, // For mint to light-token actions
}

impl<T: AccountInfoTrait + Clone> MintActionCpiWriteAccounts<'_, T> {
Expand Down
Loading
Loading