From abdb1e3941a39408d5a10c15cd868cd707bb4638 Mon Sep 17 00:00:00 2001 From: ananas-block Date: Fri, 5 Dec 2025 02:18:24 +0000 Subject: [PATCH] refactor: simplify create ctoken (ata) contructor --- .../tests/ctoken/compress_and_close.rs | 2 +- .../tests/ctoken/create.rs | 8 +- .../tests/ctoken/create_ata.rs | 30 ++--- .../tests/ctoken/create_ata2.rs | 9 +- .../tests/ctoken/functional.rs | 2 +- .../tests/ctoken/functional_ata.rs | 28 ++-- .../tests/ctoken/shared.rs | 22 ++- .../tests/mint/edge_cases.rs | 13 +- .../tests/mint/failing.rs | 37 ++---- .../tests/mint/functional.rs | 13 +- .../tests/mint/random.rs | 14 +- .../tests/transfer2/compress_failing.rs | 26 ++-- .../tests/transfer2/compress_spl_failing.rs | 15 +-- .../tests/transfer2/decompress_failing.rs | 13 +- .../no_system_program_cpi_failing.rs | 41 ++---- .../tests/transfer2/shared.rs | 12 +- .../tests/transfer2/spl_ctoken.rs | 17 +-- .../registry-test/tests/compressible.rs | 125 ++++++++---------- .../compressed-token-sdk/src/ctoken/create.rs | 15 +-- .../src/ctoken/create_ata.rs | 17 ++- .../tests/create_associated_token_account.rs | 63 +++------ .../create_compressible_token_account.rs | 14 +- sdk-tests/sdk-ctoken-test/tests/shared.rs | 12 +- .../tests/test_transfer_interface.rs | 68 +++------- .../tests/test_transfer_spl_ctoken.rs | 35 ++--- ...s_create_ctoken_with_compress_to_pubkey.rs | 2 +- .../tests/decompress_full_cpi.rs | 13 +- sdk-tests/sdk-token-test/tests/pda_ctoken.rs | 13 +- .../sdk-token-test/tests/test_4_transfer2.rs | 14 +- 29 files changed, 257 insertions(+), 436 deletions(-) diff --git a/program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs b/program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs index 49cb19a9e7..6747e4b389 100644 --- a/program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs +++ b/program-tests/compressed-token-test/tests/ctoken/compress_and_close.rs @@ -529,8 +529,8 @@ async fn test_compressible_account_with_custom_rent_payer_close_with_compression token_account_pubkey, context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); // Verify pool PDA balance decreased by only the rent-exempt amount (not the additional rent) diff --git a/program-tests/compressed-token-test/tests/ctoken/create.rs b/program-tests/compressed-token-test/tests/ctoken/create.rs index 168da9fa0f..97cff677bb 100644 --- a/program-tests/compressed-token-test/tests/ctoken/create.rs +++ b/program-tests/compressed-token-test/tests/ctoken/create.rs @@ -241,8 +241,8 @@ async fn test_create_compressible_token_account_failing() { token_account_pubkey.pubkey(), context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -380,8 +380,8 @@ async fn test_create_compressible_token_account_failing() { token_account_pubkey, context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -430,8 +430,8 @@ async fn test_create_compressible_token_account_failing() { context.token_account_keypair.pubkey(), context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -501,8 +501,8 @@ async fn test_create_compressible_token_account_failing() { context.token_account_keypair.pubkey(), context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); diff --git a/program-tests/compressed-token-test/tests/ctoken/create_ata.rs b/program-tests/compressed-token-test/tests/ctoken/create_ata.rs index 738cbc57fa..c33ad652d4 100644 --- a/program-tests/compressed-token-test/tests/ctoken/create_ata.rs +++ b/program-tests/compressed-token-test/tests/ctoken/create_ata.rs @@ -288,8 +288,8 @@ async fn test_create_ata_failing() { poor_payer_pubkey, new_owner.pubkey(), context.mint_pubkey, - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -465,8 +465,8 @@ async fn test_create_ata_failing() { payer_pubkey, context.owner_keypair.pubkey(), context.mint_pubkey, - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -534,8 +534,8 @@ async fn test_create_ata_failing() { payer_pubkey, context.owner_keypair.pubkey(), context.mint_pubkey, - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -649,10 +649,10 @@ async fn test_ata_multiple_owners_same_mint() { token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let create_ata_ix1 = - CreateAssociatedTokenAccount::new(payer_pubkey, owner1, mint, compressible_params.clone()) - .instruction() - .unwrap(); + let create_ata_ix1 = CreateAssociatedTokenAccount::new(payer_pubkey, owner1, mint) + .with_compressible(compressible_params.clone()) + .instruction() + .unwrap(); context .rpc @@ -671,10 +671,10 @@ async fn test_ata_multiple_owners_same_mint() { ) .await; - let create_ata_ix2 = - CreateAssociatedTokenAccount::new(payer_pubkey, owner2, mint, compressible_params.clone()) - .instruction() - .unwrap(); + let create_ata_ix2 = CreateAssociatedTokenAccount::new(payer_pubkey, owner2, mint) + .with_compressible(compressible_params.clone()) + .instruction() + .unwrap(); context .rpc @@ -693,10 +693,10 @@ async fn test_ata_multiple_owners_same_mint() { ) .await; - let create_ata_ix3 = - CreateAssociatedTokenAccount::new(payer_pubkey, owner3, mint, compressible_params) - .instruction() - .unwrap(); + let create_ata_ix3 = CreateAssociatedTokenAccount::new(payer_pubkey, owner3, mint) + .with_compressible(compressible_params) + .instruction() + .unwrap(); context .rpc diff --git a/program-tests/compressed-token-test/tests/ctoken/create_ata2.rs b/program-tests/compressed-token-test/tests/ctoken/create_ata2.rs index 2d80f85fbd..1be5c8f663 100644 --- a/program-tests/compressed-token-test/tests/ctoken/create_ata2.rs +++ b/program-tests/compressed-token-test/tests/ctoken/create_ata2.rs @@ -23,12 +23,9 @@ async fn create_and_assert_ata2( token_account_version: compressible.account_version, }; - let mut builder = CreateAssociatedTokenAccount::new( - payer_pubkey, - owner_pubkey, - context.mint_pubkey, - compressible_params, - ); + let mut builder = + CreateAssociatedTokenAccount::new(payer_pubkey, owner_pubkey, context.mint_pubkey) + .with_compressible(compressible_params); if idempotent { builder = builder.idempotent(); diff --git a/program-tests/compressed-token-test/tests/ctoken/functional.rs b/program-tests/compressed-token-test/tests/ctoken/functional.rs index 5d2ead3955..3924336121 100644 --- a/program-tests/compressed-token-test/tests/ctoken/functional.rs +++ b/program-tests/compressed-token-test/tests/ctoken/functional.rs @@ -141,8 +141,8 @@ async fn test_compressible_account_with_compression_authority_lifecycle() { token_account_pubkey, context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .map_err(|e| { RpcError::AssertRpcError(format!( diff --git a/program-tests/compressed-token-test/tests/ctoken/functional_ata.rs b/program-tests/compressed-token-test/tests/ctoken/functional_ata.rs index cd43fa0ff1..895183a5d1 100644 --- a/program-tests/compressed-token-test/tests/ctoken/functional_ata.rs +++ b/program-tests/compressed-token-test/tests/ctoken/functional_ata.rs @@ -68,8 +68,8 @@ async fn test_associated_token_account_operations() { payer_pubkey, compressible_owner_pubkey, context.mint_pubkey, - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -182,14 +182,10 @@ async fn test_create_ata_idempotent() { .await; // Attempt to create the same ATA again using non-idempotent instruction (should fail) - let instruction = CreateAssociatedTokenAccount::new( - payer_pubkey, - owner_pubkey, - context.mint_pubkey, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = + CreateAssociatedTokenAccount::new(payer_pubkey, owner_pubkey, context.mint_pubkey) + .instruction() + .unwrap(); let result = context .rpc @@ -203,15 +199,11 @@ async fn test_create_ata_idempotent() { ); // Now try with idempotent instruction (should succeed) - let instruction = CreateAssociatedTokenAccount::new( - payer_pubkey, - owner_pubkey, - context.mint_pubkey, - CompressibleParams::default(), - ) - .idempotent() - .instruction() - .unwrap(); + let instruction = + CreateAssociatedTokenAccount::new(payer_pubkey, owner_pubkey, context.mint_pubkey) + .idempotent() + .instruction() + .unwrap(); context .rpc diff --git a/program-tests/compressed-token-test/tests/ctoken/shared.rs b/program-tests/compressed-token-test/tests/ctoken/shared.rs index 155d41bc44..ce1149c6f0 100644 --- a/program-tests/compressed-token-test/tests/ctoken/shared.rs +++ b/program-tests/compressed-token-test/tests/ctoken/shared.rs @@ -103,8 +103,8 @@ pub async fn create_and_assert_token_account( token_account_pubkey, context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -157,8 +157,8 @@ pub async fn create_and_assert_token_account_fails( token_account_pubkey, context.mint_pubkey, context.owner_keypair.pubkey(), - compressible_params, ) + .with_compressible(compressible_params) .instruction() .unwrap(); @@ -424,12 +424,9 @@ pub async fn create_and_assert_ata( token_account_version: compressible.account_version, }; - let mut builder = CreateAssociatedTokenAccount::new( - payer_pubkey, - owner_pubkey, - context.mint_pubkey, - compressible_params, - ); + let mut builder = + CreateAssociatedTokenAccount::new(payer_pubkey, owner_pubkey, context.mint_pubkey) + .with_compressible(compressible_params); if idempotent { builder = builder.idempotent(); @@ -500,12 +497,9 @@ pub async fn create_and_assert_ata_fails( CompressibleParams::default() }; - let mut builder = CreateAssociatedTokenAccount::new( - payer_pubkey, - owner_pubkey, - context.mint_pubkey, - compressible_params, - ); + let mut builder = + CreateAssociatedTokenAccount::new(payer_pubkey, owner_pubkey, context.mint_pubkey) + .with_compressible(compressible_params); if idempotent { builder = builder.idempotent(); diff --git a/program-tests/compressed-token-test/tests/mint/edge_cases.rs b/program-tests/compressed-token-test/tests/mint/edge_cases.rs index afcc05b6fb..3b42a5af65 100644 --- a/program-tests/compressed-token-test/tests/mint/edge_cases.rs +++ b/program-tests/compressed-token-test/tests/mint/edge_cases.rs @@ -159,14 +159,11 @@ async fn functional_all_in_one_instruction() { token_account_version: TokenDataVersion::ShaFlat, }; - let create_compressible_ata_ix = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - spl_mint_pda, - compressible_params, - ) - .instruction() - .unwrap(); + let create_compressible_ata_ix = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), spl_mint_pda) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_compressible_ata_ix], &payer.pubkey(), &[&payer]) .await diff --git a/program-tests/compressed-token-test/tests/mint/failing.rs b/program-tests/compressed-token-test/tests/mint/failing.rs index 2e80cee9a7..b1fdf70de0 100644 --- a/program-tests/compressed-token-test/tests/mint/failing.rs +++ b/program-tests/compressed-token-test/tests/mint/failing.rs @@ -402,14 +402,10 @@ async fn functional_and_failing_tests() { // Create a ctoken account first let recipient = Keypair::new(); - let create_ata_ix = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - spl_mint_pda, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let create_ata_ix = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), spl_mint_pda) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_ix], &payer.pubkey(), &[&payer]) .await @@ -460,14 +456,10 @@ async fn functional_and_failing_tests() { // Create a new recipient for successful mint let recipient2 = Keypair::new(); - let create_ata_ix2 = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient2.pubkey(), - spl_mint_pda, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let create_ata_ix2 = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient2.pubkey(), spl_mint_pda) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_ix2], &payer.pubkey(), &[&payer]) .await @@ -877,14 +869,11 @@ async fn test_mint_to_ctoken_max_top_up_exceeded() { token_account_version: TokenDataVersion::ShaFlat, }; - let create_ata_ix = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - spl_mint_pda, - compressible_params, - ) - .instruction() - .unwrap(); + let create_ata_ix = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), spl_mint_pda) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_ix], &payer.pubkey(), &[&payer]) .await diff --git a/program-tests/compressed-token-test/tests/mint/functional.rs b/program-tests/compressed-token-test/tests/mint/functional.rs index a7963e7dd0..80f88cc56e 100644 --- a/program-tests/compressed-token-test/tests/mint/functional.rs +++ b/program-tests/compressed-token-test/tests/mint/functional.rs @@ -712,14 +712,11 @@ async fn test_ctoken_transfer() { token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let create_ata_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient_keypair.pubkey(), - spl_mint_pda, - compressible_params, - ) - .instruction() - .unwrap(); + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient_keypair.pubkey(), spl_mint_pda) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); diff --git a/program-tests/compressed-token-test/tests/mint/random.rs b/program-tests/compressed-token-test/tests/mint/random.rs index 408d15698e..73b23bc4d8 100644 --- a/program-tests/compressed-token-test/tests/mint/random.rs +++ b/program-tests/compressed-token-test/tests/mint/random.rs @@ -5,7 +5,7 @@ use light_compressed_token_sdk::{ compressed_token::create_compressed_mint::{ derive_compressed_mint_address, find_spl_mint_address, }, - ctoken::{CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::CreateAssociatedTokenAccount, }; use light_ctoken_types::state::{extensions::AdditionalMetadata, CompressedMint}; use light_program_test::{LightProgramTest, ProgramTestConfig}; @@ -130,14 +130,10 @@ async fn test_random_mint_action() { for _ in 0..5 { let recipient = Keypair::new(); - let create_ata_ix = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - spl_mint_pda, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let create_ata_ix = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), spl_mint_pda) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_ix], &payer.pubkey(), &[&payer]) .await diff --git a/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs b/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs index 9a36af6523..eafb4d5538 100644 --- a/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs @@ -100,14 +100,11 @@ async fn setup_compression_test(token_amount: u64) -> Result Result<(), RpcError> { token_account_version: TokenDataVersion::ShaFlat, }; - let create_ata_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - owner.pubkey(), - mint, - compressible_params, - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA: {:?}", e)))?; + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA: {:?}", e)))?; rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[&payer]) .await?; diff --git a/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs b/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs index cb378ded77..a4bdb714de 100644 --- a/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/compress_spl_failing.rs @@ -37,7 +37,7 @@ use light_compressed_token_sdk::{ }, CTokenAccount2, }, - ctoken::{derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}, token_pool::find_token_pool_pda_with_index, ValidityProof, }; @@ -100,14 +100,11 @@ async fn setup_spl_compression_test( airdrop_lamports(&mut rpc, &recipient.pubkey(), 1_000_000_000).await?; // Create compressed token ATA for recipient - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA instruction: {}", e)))?; + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!("Failed to create ATA instruction: {}", e)) + })?; rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await?; diff --git a/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs b/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs index 4a62ceb376..fd9dc877f9 100644 --- a/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs @@ -104,14 +104,11 @@ async fn setup_decompression_test( token_account_version: TokenDataVersion::ShaFlat, }; - let create_ata_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - owner.pubkey(), - mint, - compressible_params, - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA: {:?}", e)))?; + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA: {:?}", e)))?; rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[&payer]) .await?; diff --git a/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs b/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs index c501b105b6..c5dff07fc6 100644 --- a/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/no_system_program_cpi_failing.rs @@ -45,7 +45,7 @@ use light_compressed_token_sdk::{ compressed_token::create_compressed_mint::find_spl_mint_address, - ctoken::{derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}, ValidityProof, }; use light_ctoken_types::instructions::{mint_action::Recipient, transfer2::Compression}; @@ -106,29 +106,19 @@ async fn setup_no_system_program_cpi_test( let (recipient_ata, _) = derive_ctoken_ata(&recipient.pubkey(), &mint); // Create CToken ATA for owner (source) - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - owner.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create source ATA: {}", e))) - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) + .instruction() + .map_err(|e| RpcError::AssertRpcError(format!("Failed to create source ATA: {}", e))) + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); // Create CToken ATA for recipient - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create recipient ATA: {}", e))) - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .map_err(|e| RpcError::AssertRpcError(format!("Failed to create recipient ATA: {}", e))) + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -719,14 +709,10 @@ async fn test_too_many_mints() { let (recipient_ata, _) = derive_ctoken_ata(&context.recipient.pubkey(), &mint); // Create source ATA - let instruction = CreateAssociatedTokenAccount::new( - context.payer.pubkey(), - context.owner.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = + CreateAssociatedTokenAccount::new(context.payer.pubkey(), context.owner.pubkey(), mint) + .instruction() + .unwrap(); context .rpc .create_and_send_transaction(&[instruction], &context.payer.pubkey(), &[&context.payer]) @@ -738,7 +724,6 @@ async fn test_too_many_mints() { context.payer.pubkey(), context.recipient.pubkey(), mint, - CompressibleParams::default(), ) .instruction() .unwrap(); diff --git a/program-tests/compressed-token-test/tests/transfer2/shared.rs b/program-tests/compressed-token-test/tests/transfer2/shared.rs index 02391a44e5..b45e2fcc90 100644 --- a/program-tests/compressed-token-test/tests/transfer2/shared.rs +++ b/program-tests/compressed-token-test/tests/transfer2/shared.rs @@ -459,14 +459,10 @@ impl TestContext { compress_to_account_pubkey: None, token_account_version: TokenDataVersion::ShaFlat, // CompressAndClose requires ShaFlat }; - CreateAssociatedTokenAccount::new( - payer.pubkey(), - signer.pubkey(), - mint, - compressible_params, - ) - .instruction() - .unwrap() + CreateAssociatedTokenAccount::new(payer.pubkey(), signer.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .unwrap() } else { // Create non-compressible CToken ATA CreateAssociatedTokenAccount { diff --git a/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs b/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs index 5ed208c0f9..26b9cf5350 100644 --- a/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs +++ b/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs @@ -1,9 +1,7 @@ use anchor_lang::prelude::{AccountMeta, ProgramError}; // Re-export all necessary imports for test modules pub use anchor_spl::token_2022::spl_token_2022; -pub use light_compressed_token_sdk::ctoken::{ - derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount, -}; +pub use light_compressed_token_sdk::ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}; use light_compressed_token_sdk::{ compressed_token::{ transfer2::{ @@ -69,15 +67,10 @@ async fn test_spl_to_ctoken_transfer() { .unwrap(); // Create compressed token ATA for recipient - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA instruction: {}", e))) - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .map_err(|e| RpcError::AssertRpcError(format!("Failed to create ATA instruction: {}", e))) + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); diff --git a/program-tests/registry-test/tests/compressible.rs b/program-tests/registry-test/tests/compressible.rs index 341861e60f..5b9f5026af 100644 --- a/program-tests/registry-test/tests/compressible.rs +++ b/program-tests/registry-test/tests/compressible.rs @@ -497,20 +497,17 @@ async fn test_pause_compressible_config_with_valid_authority() -> Result<(), Rpc token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let compressible_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - payer.pubkey(), - Pubkey::new_unique(), - compressible_params, - ) - .instruction() - .map_err(|e| { - RpcError::AssertRpcError(format!( - "Failed to create compressible ATA instruction: {}", - e - )) - }) - .unwrap(); + let compressible_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), Pubkey::new_unique()) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!( + "Failed to create compressible ATA instruction: {}", + e + )) + }) + .unwrap(); let result = rpc .create_and_send_transaction(&[compressible_instruction], &payer.pubkey(), &[&payer]) @@ -633,20 +630,17 @@ async fn test_unpause_compressible_config_with_valid_authority() -> Result<(), R token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let compressible_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - payer.pubkey(), - Pubkey::new_unique(), - compressible_params, - ) - .instruction() - .map_err(|e| { - RpcError::AssertRpcError(format!( - "Failed to create compressible ATA instruction: {}", - e - )) - }) - .unwrap(); + let compressible_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), Pubkey::new_unique()) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!( + "Failed to create compressible ATA instruction: {}", + e + )) + }) + .unwrap(); let result = rpc .create_and_send_transaction(&[compressible_instruction], &payer.pubkey(), &[&payer]) @@ -682,20 +676,17 @@ async fn test_unpause_compressible_config_with_valid_authority() -> Result<(), R token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let compressible_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - payer.pubkey(), - Pubkey::new_unique(), - compressible_params, - ) - .instruction() - .map_err(|e| { - RpcError::AssertRpcError(format!( - "Failed to create compressible ATA instruction: {}", - e - )) - }) - .unwrap(); + let compressible_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), Pubkey::new_unique()) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!( + "Failed to create compressible ATA instruction: {}", + e + )) + }) + .unwrap(); let result2 = rpc .create_and_send_transaction(&[compressible_instruction], &payer.pubkey(), &[&payer]) @@ -774,20 +765,17 @@ async fn test_deprecate_compressible_config_with_valid_authority() -> Result<(), token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let compressible_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - token_account_keypair.pubkey(), - mint, - compressible_params, - ) - .instruction() - .map_err(|e| { - RpcError::AssertRpcError(format!( - "Failed to create compressible ATA instruction: {}", - e - )) - }) - .unwrap(); + let compressible_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), token_account_keypair.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!( + "Failed to create compressible ATA instruction: {}", + e + )) + }) + .unwrap(); rpc.create_and_send_transaction(&[compressible_instruction], &payer.pubkey(), &[&payer]) .await @@ -824,20 +812,17 @@ async fn test_deprecate_compressible_config_with_valid_authority() -> Result<(), token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let compressible_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - token_account_keypair2.pubkey(), - mint, - compressible_params, - ) - .instruction() - .map_err(|e| { - RpcError::AssertRpcError(format!( - "Failed to create compressible ATA instruction: {}", - e - )) - }) - .unwrap(); + let compressible_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), token_account_keypair2.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| { + RpcError::AssertRpcError(format!( + "Failed to create compressible ATA instruction: {}", + e + )) + }) + .unwrap(); let result = rpc .create_and_send_transaction(&[compressible_instruction], &payer.pubkey(), &[&payer]) diff --git a/sdk-libs/compressed-token-sdk/src/ctoken/create.rs b/sdk-libs/compressed-token-sdk/src/ctoken/create.rs index b86fa128d1..68711acd88 100644 --- a/sdk-libs/compressed-token-sdk/src/ctoken/create.rs +++ b/sdk-libs/compressed-token-sdk/src/ctoken/create.rs @@ -21,22 +21,21 @@ pub struct CreateCTokenAccount { } impl CreateCTokenAccount { - pub fn new( - payer: Pubkey, - account: Pubkey, - mint: Pubkey, - owner: Pubkey, - compressible_params: CompressibleParams, - ) -> Self { + pub fn new(payer: Pubkey, account: Pubkey, mint: Pubkey, owner: Pubkey) -> Self { Self { payer, account, mint, owner, - compressible: Some(compressible_params), + compressible: Some(CompressibleParams::default()), } } + pub fn with_compressible(mut self, compressible: CompressibleParams) -> Self { + self.compressible = Some(compressible); + self + } + pub fn instruction(self) -> Result { let compressible_extension = self.compressible diff --git a/sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs b/sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs index 892b311846..9b2ec0b175 100644 --- a/sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs +++ b/sdk-libs/compressed-token-sdk/src/ctoken/create_ata.rs @@ -44,12 +44,7 @@ pub struct CreateAssociatedTokenAccount { } impl CreateAssociatedTokenAccount { - pub fn new( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - compressible_params: CompressibleParams, - ) -> Self { + pub fn new(payer: Pubkey, owner: Pubkey, mint: Pubkey) -> Self { let (ata, bump) = derive_ctoken_ata(&owner, &mint); Self { payer, @@ -57,7 +52,7 @@ impl CreateAssociatedTokenAccount { mint, associated_token_account: ata, bump, - compressible: Some(compressible_params), + compressible: Some(CompressibleParams::default()), idempotent: false, } } @@ -66,7 +61,6 @@ impl CreateAssociatedTokenAccount { payer: Pubkey, owner: Pubkey, mint: Pubkey, - compressible_params: CompressibleParams, associated_token_account: Pubkey, bump: u8, ) -> Self { @@ -76,11 +70,16 @@ impl CreateAssociatedTokenAccount { mint, associated_token_account, bump, - compressible: Some(compressible_params), + compressible: Some(CompressibleParams::default()), idempotent: false, } } + pub fn with_compressible(mut self, compressible: CompressibleParams) -> Self { + self.compressible = Some(compressible); + self + } + pub fn idempotent(mut self) -> Self { self.idempotent = true; self diff --git a/sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs b/sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs index 86e2e850b1..43485a0d81 100644 --- a/sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs +++ b/sdk-libs/compressed-token-sdk/tests/create_associated_token_account.rs @@ -1,6 +1,4 @@ -use light_compressed_token_sdk::ctoken::{ - derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount, -}; +use light_compressed_token_sdk::ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}; use solana_pubkey::Pubkey; const CREATE_ATA_DISCRIMINATOR: u8 = 100; @@ -11,15 +9,13 @@ fn test_discriminator_selection() { let payer = Pubkey::new_unique(); let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let compressible_params = CompressibleParams::default(); - let ix_regular = - CreateAssociatedTokenAccount::new(payer, owner, mint, compressible_params.clone()) - .instruction() - .unwrap(); + let ix_regular = CreateAssociatedTokenAccount::new(payer, owner, mint) + .instruction() + .unwrap(); assert_eq!(ix_regular.data[0], CREATE_ATA_DISCRIMINATOR); - let ix_idempotent = CreateAssociatedTokenAccount::new(payer, owner, mint, compressible_params) + let ix_idempotent = CreateAssociatedTokenAccount::new(payer, owner, mint) .idempotent() .instruction() .unwrap(); @@ -31,13 +27,11 @@ fn test_instruction_data_consistency() { let payer = Pubkey::new_unique(); let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let compressible_params = CompressibleParams::default(); - let ix_regular = - CreateAssociatedTokenAccount::new(payer, owner, mint, compressible_params.clone()) - .instruction() - .unwrap(); - let ix_idempotent = CreateAssociatedTokenAccount::new(payer, owner, mint, compressible_params) + let ix_regular = CreateAssociatedTokenAccount::new(payer, owner, mint) + .instruction() + .unwrap(); + let ix_idempotent = CreateAssociatedTokenAccount::new(payer, owner, mint) .idempotent() .instruction() .unwrap(); @@ -54,32 +48,19 @@ fn test_with_bump_functions() { let payer = Pubkey::new_unique(); let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let compressible_params = CompressibleParams::default(); let (ata_pubkey, bump) = derive_ctoken_ata(&owner, &mint); - let ix_with_bump = CreateAssociatedTokenAccount::new_with_bump( - payer, - owner, - mint, - compressible_params.clone(), - ata_pubkey, - bump, - ) - .instruction() - .unwrap(); + let ix_with_bump = + CreateAssociatedTokenAccount::new_with_bump(payer, owner, mint, ata_pubkey, bump) + .instruction() + .unwrap(); assert_eq!(ix_with_bump.data[0], CREATE_ATA_DISCRIMINATOR); - let ix_with_bump_idempotent = CreateAssociatedTokenAccount::new_with_bump( - payer, - owner, - mint, - compressible_params, - ata_pubkey, - bump, - ) - .idempotent() - .instruction() - .unwrap(); + let ix_with_bump_idempotent = + CreateAssociatedTokenAccount::new_with_bump(payer, owner, mint, ata_pubkey, bump) + .idempotent() + .instruction() + .unwrap(); assert_eq!( ix_with_bump_idempotent.data[0], CREATE_ATA_IDEMPOTENT_DISCRIMINATOR @@ -91,12 +72,10 @@ fn test_account_count() { let payer = Pubkey::new_unique(); let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let compressible_params = CompressibleParams::default(); - let ix_compressible = - CreateAssociatedTokenAccount::new(payer, owner, mint, compressible_params) - .instruction() - .unwrap(); + let ix_compressible = CreateAssociatedTokenAccount::new(payer, owner, mint) + .instruction() + .unwrap(); assert_eq!(ix_compressible.accounts.len(), 5); } diff --git a/sdk-libs/token-client/src/actions/create_compressible_token_account.rs b/sdk-libs/token-client/src/actions/create_compressible_token_account.rs index 31929d4e96..dc182db510 100644 --- a/sdk-libs/token-client/src/actions/create_compressible_token_account.rs +++ b/sdk-libs/token-client/src/actions/create_compressible_token_account.rs @@ -63,15 +63,11 @@ pub async fn create_compressible_token_account( token_account_version, }; - let create_token_account_ix = CreateCTokenAccount::new( - payer.pubkey(), - token_account_pubkey, - mint, - owner, - compressible_params, - ) - .instruction() - .map_err(|e| RpcError::CustomError(format!("Failed to create instruction: {}", e)))?; + let create_token_account_ix = + CreateCTokenAccount::new(payer.pubkey(), token_account_pubkey, mint, owner) + .with_compressible(compressible_params) + .instruction() + .map_err(|e| RpcError::CustomError(format!("Failed to create instruction: {}", e)))?; rpc.create_and_send_transaction( &[create_token_account_ix], diff --git a/sdk-tests/sdk-ctoken-test/tests/shared.rs b/sdk-tests/sdk-ctoken-test/tests/shared.rs index 9aa818de39..95d2efcdd0 100644 --- a/sdk-tests/sdk-ctoken-test/tests/shared.rs +++ b/sdk-tests/sdk-ctoken-test/tests/shared.rs @@ -16,8 +16,8 @@ pub async fn setup_create_compressed_mint( recipients: Vec<(u64, Pubkey)>, ) -> (Pubkey, [u8; 32], Vec) { use light_compressed_token_sdk::ctoken::{ - CompressibleParams, CreateAssociatedTokenAccount, CreateCMint, CreateCMintParams, - MintToCToken, MintToCTokenParams, + CreateAssociatedTokenAccount, CreateCMint, CreateCMintParams, MintToCToken, + MintToCTokenParams, }; let mint_signer = Keypair::new(); @@ -93,7 +93,6 @@ pub async fn setup_create_compressed_mint( // Create ATAs for each recipient use light_compressed_token_sdk::ctoken::derive_ctoken_ata; - let compressible_params = CompressibleParams::default(); let mut ata_pubkeys = Vec::with_capacity(recipients.len()); @@ -101,12 +100,7 @@ pub async fn setup_create_compressed_mint( let (ata_address, _bump) = derive_ctoken_ata(owner, &mint_pda); ata_pubkeys.push(ata_address); - let create_ata = CreateAssociatedTokenAccount::new( - payer.pubkey(), - *owner, - mint_pda, - compressible_params.clone(), - ); + let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint_pda); let ata_instruction = create_ata.instruction().unwrap(); rpc.create_and_send_transaction(&[ata_instruction], &payer.pubkey(), &[payer]) diff --git a/sdk-tests/sdk-ctoken-test/tests/test_transfer_interface.rs b/sdk-tests/sdk-ctoken-test/tests/test_transfer_interface.rs index 3c7ab23c3d..fd1bad5077 100644 --- a/sdk-tests/sdk-ctoken-test/tests/test_transfer_interface.rs +++ b/sdk-tests/sdk-ctoken-test/tests/test_transfer_interface.rs @@ -5,7 +5,7 @@ mod shared; use borsh::BorshSerialize; use light_client::rpc::Rpc; use light_compressed_token_sdk::{ - ctoken::{derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}, token_pool::find_token_pool_pda_with_index, }; use light_compressed_token_types::CPI_AUTHORITY_PDA; @@ -66,14 +66,9 @@ async fn test_transfer_interface_spl_to_ctoken_invoke() { .await .unwrap(); - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -161,14 +156,9 @@ async fn test_transfer_interface_ctoken_to_spl_invoke() { .unwrap(); // Create and fund CToken ATA - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - owner.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -297,28 +287,18 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke() { let transfer_amount = 5000u64; // Create sender CToken ATA - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - sender.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), sender.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); let sender_ctoken = derive_ctoken_ata(&sender.pubkey(), &mint).0; // Create recipient CToken ATA - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -476,14 +456,9 @@ async fn test_transfer_interface_spl_to_ctoken_invoke_signed() { .await .unwrap(); - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -736,14 +711,9 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke_signed() { light_test_utils::airdrop_lamports(&mut rpc, &recipient.pubkey(), 1_000_000_000) .await .unwrap(); - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); diff --git a/sdk-tests/sdk-ctoken-test/tests/test_transfer_spl_ctoken.rs b/sdk-tests/sdk-ctoken-test/tests/test_transfer_spl_ctoken.rs index 3ef395da95..885930ee30 100644 --- a/sdk-tests/sdk-ctoken-test/tests/test_transfer_spl_ctoken.rs +++ b/sdk-tests/sdk-ctoken-test/tests/test_transfer_spl_ctoken.rs @@ -5,7 +5,7 @@ mod shared; use borsh::BorshSerialize; use light_client::rpc::Rpc; use light_compressed_token_sdk::{ - ctoken::{derive_ctoken_ata, CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::{derive_ctoken_ata, CreateAssociatedTokenAccount}, token_pool::find_token_pool_pda_with_index, }; use light_compressed_token_types::CPI_AUTHORITY_PDA; @@ -65,14 +65,9 @@ async fn test_spl_to_ctoken_invoke() { .await .unwrap(); - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -188,14 +183,9 @@ async fn test_ctoken_to_spl_invoke() { .unwrap(); // Create ctoken ATA and fund it via SPL transfer first - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - owner.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); @@ -379,14 +369,9 @@ async fn test_spl_to_ctoken_invoke_signed() { .await .unwrap(); - let instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - recipient.pubkey(), - mint, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); diff --git a/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs b/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs index b8b7111f4d..c07bdbf33f 100644 --- a/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs +++ b/sdk-tests/sdk-token-test/src/process_create_ctoken_with_compress_to_pubkey.rs @@ -34,8 +34,8 @@ pub fn process_create_ctoken_with_compress_to_pubkey<'info>( token_account_pubkey, mint, *ctx.accounts.signer.key, - compressible_params, ) + .with_compressible(compressible_params) .instruction()?; let seeds = [seeds[0], seeds[1], &[bump]]; diff --git a/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs b/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs index 94333b2828..27c4445677 100644 --- a/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs +++ b/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs @@ -85,14 +85,11 @@ async fn setup_decompress_full_test(num_inputs: usize) -> (LightProgramTest, Tes token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let create_token_account_ix = CreateAssociatedTokenAccount::new( - payer.pubkey(), - destination_owner, - mint_pubkey, - compressible_params, - ) - .instruction() - .unwrap(); + let create_token_account_ix = + CreateAssociatedTokenAccount::new(payer.pubkey(), destination_owner, mint_pubkey) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_token_account_ix], &payer.pubkey(), &[&payer]) .await diff --git a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs index e1d3554b68..76fafd094d 100644 --- a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs +++ b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs @@ -215,14 +215,11 @@ pub async fn create_mint( token_account_version: light_ctoken_types::state::TokenDataVersion::ShaFlat, }; - let create_ata_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - mint_authority.pubkey(), - mint, - compressible_params, - ) - .instruction() - .unwrap(); + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), mint_authority.pubkey(), mint) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[payer]) .await .expect("Failed to create associated token account"); diff --git a/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs b/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs index 08b09a1fe6..98c482f8bb 100644 --- a/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs +++ b/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs @@ -4,7 +4,7 @@ use light_compressed_token_sdk::{ create_compressed_mint::{create_compressed_mint, CreateCompressedMintInputs}, mint_to_compressed::{create_mint_to_compressed_instruction, MintToCompressedInputs}, }, - ctoken::{CompressibleParams, CreateAssociatedTokenAccount}, + ctoken::CreateAssociatedTokenAccount, utils::CTokenDefaultAccounts, }; use light_ctoken_types::{ @@ -96,14 +96,10 @@ async fn create_compressed_mints_and_tokens( // Create associated token account for mint1 decompression let (token_account1_pubkey, _bump) = light_compressed_token_sdk::ctoken::derive_ctoken_ata(&payer.pubkey(), &mint1_pda); - let create_ata_instruction = CreateAssociatedTokenAccount::new( - payer.pubkey(), - payer.pubkey(), - mint1_pda, - CompressibleParams::default(), - ) - .instruction() - .unwrap(); + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint1_pda) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[payer]) .await .unwrap();