Skip to content
Merged
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
3 changes: 2 additions & 1 deletion program-libs/compressible/src/rent/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pub const COMPRESSION_INCENTIVE: u16 = 1000;

pub const BASE_RENT: u16 = 128;
pub const RENT_PER_BYTE: u8 = 1;
pub const SLOTS_PER_EPOCH: u64 = 6300; // 1.75h
// Epoch duration: 1.5 hours, 90 minutes * 60 seconds / 0.4 seconds per slot = 13,500 slots per epoch
pub const SLOTS_PER_EPOCH: u64 = 13500;

/// Trait for accessing rent configuration parameters.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ impl<'info> CreateCTokenAccounts<'info> {

#[profile]
#[inline(always)]
pub fn parse_config_account<'info>(
config_account: &'info AccountInfo,
) -> Result<&'info CompressibleConfig, ProgramError> {
pub fn parse_config_account(
config_account: &AccountInfo,
) -> Result<&CompressibleConfig, ProgramError> {
// Validate config account owner
check_owner(
&pubkey!("Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX").to_bytes(),
Expand Down
4 changes: 2 additions & 2 deletions programs/compressed-token/program/src/ctoken_transfer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::shared::{
/// Process ctoken transfer instruction
#[profile]
#[inline(always)]
pub fn process_ctoken_transfer<'a>(
accounts: &'a [AccountInfo],
pub fn process_ctoken_transfer(
accounts: &[AccountInfo],
instruction_data: &[u8],
) -> Result<(), ProgramError> {
if accounts.len() < 3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use crate::{shared::convert_program_error, LIGHT_CPI_SIGNER};
///
/// ## Parameters
/// - `configs`: ArrayVec of PDA configs. First config is for the new account being created.
/// Additional configs are for fee payer PDAs that need to sign.
/// Additional configs are for fee payer PDAs that need to sign.
#[profile]
pub fn create_pda_account<const N: usize>(
fee_payer: &AccountInfo,
Expand Down
25 changes: 13 additions & 12 deletions sdk-libs/compressed-token-sdk/src/ctoken/compressible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,30 @@ impl Default for CompressibleParams {
Self {
compressible_config: COMPRESSIBLE_CONFIG_V1,
rent_sponsor: RENT_SPONSOR,
pre_pay_num_epochs: 2,
lamports_per_write: Some(100),
pre_pay_num_epochs: 16,
lamports_per_write: Some(766),
Comment thread
SwenSchaeferjohann marked this conversation as resolved.
compress_to_account_pubkey: None,
token_account_version: TokenDataVersion::ShaFlat,
}
}
}

impl CompressibleParams {
pub fn new(lamports_per_write: u32, pre_pay_num_epochs: u8) -> Self {
Self {
lamports_per_write: Some(lamports_per_write),
pre_pay_num_epochs,
..Default::default()
}
/// Creates a new `CompressibleParams` with default values.
///
/// Use builder methods to customize:
/// - [`compress_to_pubkey`](Self::compress_to_pubkey) - set the destination for compression
pub fn new() -> Self {
Self::default()
}
Comment thread
ananas-block marked this conversation as resolved.

/// Sets the destination pubkey for compression.
pub fn compress_to_pubkey(mut self, compress_to: CompressToPubkey) -> Self {
self.compress_to_account_pubkey = Some(compress_to);
self
}
}

pub struct CompressibleParamsInfos<'info> {
pub compressible_config: AccountInfo<'info>,
pub rent_sponsor: AccountInfo<'info>,
Expand All @@ -55,18 +57,17 @@ pub struct CompressibleParamsInfos<'info> {

impl<'info> CompressibleParamsInfos<'info> {
pub fn new(
pre_pay_num_epochs: u8,
lamports_per_write: u32,
compressible_config: AccountInfo<'info>,
rent_sponsor: AccountInfo<'info>,
system_program: AccountInfo<'info>,
) -> Self {
let defaults = CompressibleParams::default();
Self {
compressible_config,
rent_sponsor,
system_program,
pre_pay_num_epochs,
lamports_per_write: Some(lamports_per_write),
pre_pay_num_epochs: defaults.pre_pay_num_epochs,
lamports_per_write: defaults.lamports_per_write,
compress_to_account_pubkey: None,
token_account_version: TokenDataVersion::ShaFlat,
}
Comment thread
ananas-block marked this conversation as resolved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ async fn test_create_and_decompress_two_accounts() {
)
.await;

rpc.warp_to_slot(300).unwrap();
rpc.warp_epoch_forward(1).await.unwrap();

compress_token_account_after_decompress(
&mut rpc,
Expand Down
4 changes: 0 additions & 4 deletions sdk-tests/sdk-ctoken-test/src/create_ata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pub fn process_create_ata_invoke(

// Build the compressible params using constructor
let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[3].clone(),
accounts[4].clone(),
accounts[2].clone(),
Expand Down Expand Up @@ -82,8 +80,6 @@ pub fn process_create_ata_invoke_signed(

// Build the compressible params using constructor
let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[3].clone(),
accounts[4].clone(),
accounts[2].clone(),
Expand Down
4 changes: 0 additions & 4 deletions sdk-tests/sdk-ctoken-test/src/create_ata2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ pub fn process_create_ata2_invoke(
}

let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[5].clone(),
accounts[6].clone(),
accounts[4].clone(),
Expand Down Expand Up @@ -82,8 +80,6 @@ pub fn process_create_ata2_invoke_signed(
}

let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[5].clone(),
accounts[6].clone(),
accounts[4].clone(),
Expand Down
4 changes: 0 additions & 4 deletions sdk-tests/sdk-ctoken-test/src/create_token_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ pub fn process_create_token_account_invoke(

// Build the compressible params using constructor
let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[3].clone(),
accounts[5].clone(),
accounts[4].clone(),
Expand Down Expand Up @@ -82,8 +80,6 @@ pub fn process_create_token_account_invoke_signed(

// Build the compressible params using constructor
let compressible_params = CompressibleParamsInfos::new(
data.pre_pay_num_epochs,
data.lamports_per_write,
accounts[3].clone(),
accounts[5].clone(),
accounts[4].clone(),
Expand Down
27 changes: 25 additions & 2 deletions sdk-tests/sdk-ctoken-test/tests/test_create_cmint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ mod shared;
use borsh::BorshSerialize;
use light_client::{indexer::Indexer, rpc::Rpc};
use light_compressed_token_sdk::compressed_token::mint_action::MintActionMetaConfig;
use light_ctoken_types::{
instructions::extensions::{
token_metadata::TokenMetadataInstructionData, ExtensionInstructionData,
},
state::AdditionalMetadata,
};
use light_program_test::{LightProgramTest, ProgramTestConfig};
use native_ctoken_examples::{CreateCmintData, ID, MINT_SIGNER_SEED};
use solana_sdk::{
Expand Down Expand Up @@ -57,7 +63,7 @@ async fn test_create_compressed_mint() {
.unwrap()
.value;

// Create instruction data for wrapper program
// Create instruction data for wrapper program with TokenMetadata extension
let create_cmint_data = CreateCmintData {
decimals,
address_merkle_tree_root_index: rpc_result.addresses[0].root_index,
Expand All @@ -66,7 +72,24 @@ async fn test_create_compressed_mint() {
compression_address,
mint: mint_pda,
freeze_authority: None,
extensions: None,
extensions: Some(vec![ExtensionInstructionData::TokenMetadata(
TokenMetadataInstructionData {
update_authority: Some(payer.pubkey().to_bytes().into()),
name: b"Test Token".to_vec(),
symbol: b"TEST".to_vec(),
uri: b"https://example.com/metadata.json".to_vec(),
additional_metadata: Some(vec![
AdditionalMetadata {
key: b"test1".to_vec(),
value: b"value1".to_vec(),
},
AdditionalMetadata {
key: b"test2".to_vec(),
value: b"value2".to_vec(),
},
]),
},
)]),
};
let instruction_data = [vec![0u8], create_cmint_data.try_to_vec().unwrap()].concat();

Expand Down