diff --git a/js/compressed-token/src/v3/instructions/create-associated-ctoken.ts b/js/compressed-token/src/v3/instructions/create-associated-ctoken.ts index 4328b9c5cc..dff70fb33d 100644 --- a/js/compressed-token/src/v3/instructions/create-associated-ctoken.ts +++ b/js/compressed-token/src/v3/instructions/create-associated-ctoken.ts @@ -31,7 +31,6 @@ const CompressibleExtensionInstructionDataLayout = struct([ ]); const CreateAssociatedTokenAccountInstructionDataLayout = struct([ - u8('bump'), option(CompressibleExtensionInstructionDataLayout, 'compressibleConfig'), ]); @@ -50,7 +49,6 @@ export interface CompressibleConfig { } export interface CreateAssociatedCTokenAccountParams { - bump: number; compressibleConfig?: CompressibleConfig; } @@ -93,14 +91,14 @@ export const DEFAULT_COMPRESSIBLE_CONFIG: CompressibleConfig = { compressToAccountPubkey: null, // Required null for ATAs }; -function getAssociatedCTokenAddressAndBump( +function getAssociatedCTokenAddress( owner: PublicKey, mint: PublicKey, -): [PublicKey, number] { +): PublicKey { return PublicKey.findProgramAddressSync( [owner.toBuffer(), CTOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], CTOKEN_PROGRAM_ID, - ); + )[0]; } function encodeCreateAssociatedCTokenAccountData( @@ -110,7 +108,6 @@ function encodeCreateAssociatedCTokenAccountData( const buffer = Buffer.alloc(2000); const len = CreateAssociatedTokenAccountInstructionDataLayout.encode( { - bump: params.bump, compressibleConfig: params.compressibleConfig || null, }, buffer, @@ -152,14 +149,10 @@ export function createAssociatedCTokenAccountInstruction( configAccount: PublicKey = LIGHT_TOKEN_CONFIG, rentPayerPda: PublicKey = LIGHT_TOKEN_RENT_SPONSOR, ): TransactionInstruction { - const [associatedTokenAccount, bump] = getAssociatedCTokenAddressAndBump( - owner, - mint, - ); + const associatedTokenAccount = getAssociatedCTokenAddress(owner, mint); const data = encodeCreateAssociatedCTokenAccountData( { - bump, compressibleConfig, }, false, @@ -213,14 +206,10 @@ export function createAssociatedCTokenAccountIdempotentInstruction( configAccount: PublicKey = LIGHT_TOKEN_CONFIG, rentPayerPda: PublicKey = LIGHT_TOKEN_RENT_SPONSOR, ): TransactionInstruction { - const [associatedTokenAccount, bump] = getAssociatedCTokenAddressAndBump( - owner, - mint, - ); + const associatedTokenAccount = getAssociatedCTokenAddress(owner, mint); const data = encodeCreateAssociatedCTokenAccountData( { - bump, compressibleConfig, }, true, diff --git a/program-libs/token-interface/src/instructions/create_associated_token_account.rs b/program-libs/token-interface/src/instructions/create_associated_token_account.rs index 167e573edc..8c77b5784f 100644 --- a/program-libs/token-interface/src/instructions/create_associated_token_account.rs +++ b/program-libs/token-interface/src/instructions/create_associated_token_account.rs @@ -8,7 +8,6 @@ use crate::{ #[repr(C)] #[derive(Debug, Clone, AnchorSerialize, AnchorDeserialize, ZeroCopy)] pub struct CreateAssociatedTokenAccountInstructionData { - pub bump: u8, /// Optional compressible configuration for the token account pub compressible_config: Option, } diff --git a/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs b/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs index 1f5f9453be..541d6f14d1 100644 --- a/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs +++ b/program-tests/compressed-token-test/tests/compress_only/ata_decompress.rs @@ -18,9 +18,12 @@ use light_test_utils::{ }, Rpc, RpcError, }; -use light_token::instruction::{ - derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, CreateTokenAccount, - TransferFromSpl, +use light_token::{ + instruction::{ + derive_token_ata, CompressibleParams, CreateAssociatedTokenAccount, CreateTokenAccount, + TransferFromSpl, + }, + utils::get_associated_token_address_and_bump, }; use light_token_interface::{ instructions::extensions::{CompressedOnlyExtensionInstructionData, ExtensionInstructionData}, @@ -74,7 +77,8 @@ async fn setup_ata_compressed_token( // Create ATA with compression_only=true let owner = Keypair::new(); - let (ata_pubkey, ata_bump) = derive_token_ata(&owner.pubkey(), &mint_pubkey); + let (ata_pubkey, ata_bump) = + get_associated_token_address_and_bump(&owner.pubkey(), &mint_pubkey); let create_ata_ix = CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint_pubkey) @@ -343,7 +347,7 @@ async fn test_ata_decompress_to_different_ata_fails() { let mint2_pubkey = mint2_keypair.pubkey(); // Create ATA for same owner but different mint - let (ata2_pubkey, _ata2_bump) = derive_token_ata(&context.owner.pubkey(), &mint2_pubkey); + let ata2_pubkey = derive_token_ata(&context.owner.pubkey(), &mint2_pubkey); let create_ata2_ix = CreateAssociatedTokenAccount::new( context.payer.pubkey(), @@ -1010,7 +1014,8 @@ async fn test_ata_multiple_compress_decompress_cycles() { // Setup wallet owner and derive ATA let wallet = Keypair::new(); - let (ata_pubkey, ata_bump) = derive_token_ata(&wallet.pubkey(), &mint_pubkey); + let (ata_pubkey, ata_bump) = + get_associated_token_address_and_bump(&wallet.pubkey(), &mint_pubkey); let amount1 = 100_000_000u64; let amount2 = 200_000_000u64; diff --git a/program-tests/compressed-token-test/tests/light_token/burn.rs b/program-tests/compressed-token-test/tests/light_token/burn.rs index 01ba115ef1..ccc43cbbdd 100644 --- a/program-tests/compressed-token-test/tests/light_token/burn.rs +++ b/program-tests/compressed-token-test/tests/light_token/burn.rs @@ -336,7 +336,7 @@ async fn setup_burn_test() -> BurnTestContext { let (mint_pda, _) = find_mint_address(&mint_seed.pubkey()); // Step 1: Create Light Token ATA for owner - let (ctoken_ata, _) = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); + let ctoken_ata = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); let create_ata_ix = CreateAssociatedTokenAccount::new(payer.pubkey(), owner_keypair.pubkey(), mint_pda) diff --git a/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs b/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs index ec78b45615..ca1d6e2616 100644 --- a/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs +++ b/program-tests/compressed-token-test/tests/light_token/compress_and_close.rs @@ -164,8 +164,7 @@ async fn test_compress_and_close_owner_scenarios() { // Set token balance on ATA use light_token::instruction::derive_token_ata; - let (ata_pubkey, _bump) = - derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); + let ata_pubkey = derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); let mut ata_account = context.rpc.get_account(ata_pubkey).await.unwrap().unwrap(); diff --git a/program-tests/compressed-token-test/tests/light_token/create_ata.rs b/program-tests/compressed-token-test/tests/light_token/create_ata.rs index 78db3428d3..00862f3d2f 100644 --- a/program-tests/compressed-token-test/tests/light_token/create_ata.rs +++ b/program-tests/compressed-token-test/tests/light_token/create_ata.rs @@ -184,7 +184,7 @@ async fn test_create_compressible_ata() { .unwrap(); // Verify ATA was created at the expected address - let (expected_ata, _) = derive_token_ata(&owner_and_mint, &owner_and_mint); + let expected_ata = derive_token_ata(&owner_and_mint, &owner_and_mint); let account = context.rpc.get_account(expected_ata).await.unwrap(); assert!( account.is_some(), @@ -419,8 +419,7 @@ async fn test_create_ata_failing() { // Use different mint for this test context.mint_pubkey = solana_sdk::pubkey::Pubkey::new_unique(); - let (ata_pubkey, bump) = - derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); + let ata_pubkey = derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); // Manually build instruction data with compress_to_account_pubkey (forbidden for ATAs) let compress_to_pubkey = CompressToPubkey { @@ -430,7 +429,6 @@ async fn test_create_ata_failing() { }; let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump, compressible_config: Some(CompressibleExtensionInstructionData { token_account_version: light_token_interface::state::TokenDataVersion::ShaFlat as u8, @@ -477,9 +475,9 @@ async fn test_create_ata_failing() { light_program_test::utils::assert::assert_rpc_error(result, 0, 2).unwrap(); } - // Test 5: Invalid PDA derivation (wrong bump) - // ATAs must use the correct bump derived from [owner, program_id, mint] - // Error: 21 (ProgramFailedToComplete - provided seeds do not result in valid address) + // Test 5: Invalid ATA address (wrong PDA) + // Passing a wrong ATA address that doesn't match the derived PDA should fail. + // verify_pda uses find_program_address and returns InvalidAccountData (3) on mismatch. { use anchor_lang::prelude::borsh::BorshSerialize; use light_token_interface::instructions::{ @@ -490,24 +488,15 @@ async fn test_create_ata_failing() { // Use different mint for this test context.mint_pubkey = solana_sdk::pubkey::Pubkey::new_unique(); - let (ata_pubkey, correct_bump) = - derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); - - // Manually build instruction data with WRONG bump - let wrong_bump = if correct_bump == 255 { - 254 - } else { - correct_bump + 1 - }; + // Use a wrong ATA address (random pubkey instead of derived) + let wrong_ata_pubkey = solana_sdk::pubkey::Pubkey::new_unique(); - // Owner and mint are now passed as accounts, not in instruction data let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump: wrong_bump, // Wrong bump! compressible_config: Some(CompressibleExtensionInstructionData { token_account_version: light_token_interface::state::TokenDataVersion::ShaFlat as u8, rent_payment: 2, - compression_only: 1, // ATAs always compression_only + compression_only: 1, write_top_up: 100, compress_to_account_pubkey: None, }), @@ -516,7 +505,6 @@ async fn test_create_ata_failing() { let mut data = vec![100]; // CreateAssociatedTokenAccount discriminator instruction_data.serialize(&mut data).unwrap(); - // Account order: owner, mint, payer, ata, system_program, config, rent_sponsor let ix = Instruction { program_id: light_compressed_token::ID, accounts: vec![ @@ -526,7 +514,7 @@ async fn test_create_ata_failing() { ), solana_sdk::instruction::AccountMeta::new_readonly(context.mint_pubkey, false), solana_sdk::instruction::AccountMeta::new(payer_pubkey, true), - solana_sdk::instruction::AccountMeta::new(ata_pubkey, false), + solana_sdk::instruction::AccountMeta::new(wrong_ata_pubkey, false), solana_sdk::instruction::AccountMeta::new_readonly( solana_sdk::pubkey::Pubkey::default(), false, @@ -545,16 +533,8 @@ async fn test_create_ata_failing() { .create_and_send_transaction(&[ix], &payer_pubkey, &[&context.payer]) .await; - // Wrong bump can trigger either ProgramFailedToComplete (21) or PrivilegeEscalation (19) - // depending on runtime state - accept either - let is_valid_error = - light_program_test::utils::assert::assert_rpc_error(result.clone(), 0, 21).is_ok() - || light_program_test::utils::assert::assert_rpc_error(result, 0, 19).is_ok(); - - assert!( - is_valid_error, - "Expected either ProgramFailedToComplete (21) or PrivilegeEscalation (19)" - ); + // Wrong ATA address is caught by verify_pda which returns InvalidAccountData (3) + light_program_test::utils::assert::assert_rpc_error(result, 0, 3).unwrap(); } // Test 6: Invalid config account owner @@ -706,11 +686,7 @@ async fn test_create_ata_failing() { // Test 10: Arbitrary keypair address instead of correct PDA (non-IDEMPOTENT) // Tests that providing an arbitrary address (not the correct PDA) fails. - // Currently fails with PrivilegeEscalation (19) at CreateAccount CPI because - // the program tries to sign for a PDA but the account address doesn't match. - // With proper validation (calling validate_ata_derivation in non-IDEMPOTENT mode), - // this would fail earlier with InvalidAccountData (17). - // Error: 19 (PrivilegeEscalation - CPI tries to sign for wrong address) + // verify_pda uses find_program_address and returns InvalidAccountData (3) on mismatch. { use anchor_lang::prelude::borsh::BorshSerialize; use light_token_interface::instructions::create_associated_token_account::CreateAssociatedTokenAccountInstructionData; @@ -719,18 +695,13 @@ async fn test_create_ata_failing() { // Use different mint for this test context.mint_pubkey = solana_sdk::pubkey::Pubkey::new_unique(); - // Get the correct PDA and bump - let (_correct_ata_pubkey, correct_bump) = - derive_token_ata(&context.owner_keypair.pubkey(), &context.mint_pubkey); - // Create an arbitrary keypair (NOT the correct PDA) let fake_ata_keypair = solana_sdk::signature::Keypair::new(); let fake_ata_pubkey = fake_ata_keypair.pubkey(); - // Build instruction with correct bump but WRONG address (arbitrary keypair) + // Build instruction with WRONG address (arbitrary keypair) // No compressible config for non-compressible ATAs let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump: correct_bump, // Correct bump for the real PDA compressible_config: None, }; @@ -766,10 +737,8 @@ async fn test_create_ata_failing() { .create_and_send_transaction(&[ix], &payer_pubkey, &[&context.payer]) .await; - // Fails with PrivilegeEscalation (19) - program tries to invoke_signed with - // seeds that derive to the correct PDA, but the account passed is a different address. - // Solana runtime rejects this as unauthorized signer privilege escalation. - light_program_test::utils::assert::assert_rpc_error(result, 0, 19).unwrap(); + // Wrong ATA address is caught by verify_pda which returns InvalidAccountData (3) + light_program_test::utils::assert::assert_rpc_error(result, 0, 3).unwrap(); } // Test 11: Non-compressible ATA for mint with restricted extensions @@ -799,11 +768,10 @@ async fn test_create_ata_failing() { let owner = solana_sdk::pubkey::Pubkey::new_unique(); // Derive ATA address - let (ata_pubkey, bump) = derive_token_ata(&owner, &mint_with_restricted_ext); + let ata_pubkey = derive_token_ata(&owner, &mint_with_restricted_ext); // Build instruction data with compressible_config: None (non-compressible) let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump, compressible_config: None, // Non-compressible! }; @@ -955,9 +923,9 @@ async fn test_ata_multiple_mints_same_owner() { assert_ne!(ata2, ata3, "ATA for mint2 and mint3 should be different"); // Verify each ATA is derived correctly for its mint - let (expected_ata1, _) = derive_token_ata(&owner, &mint1); - let (expected_ata2, _) = derive_token_ata(&owner, &mint2); - let (expected_ata3, _) = derive_token_ata(&owner, &mint3); + let expected_ata1 = derive_token_ata(&owner, &mint1); + let expected_ata2 = derive_token_ata(&owner, &mint2); + let expected_ata3 = derive_token_ata(&owner, &mint3); assert_eq!(ata1, expected_ata1, "ATA1 should match expected derivation"); assert_eq!(ata2, expected_ata2, "ATA2 should match expected derivation"); @@ -1010,7 +978,7 @@ async fn test_ata_multiple_owners_same_mint() { .await .unwrap(); - let (ata1, _) = derive_token_ata(&owner1, &mint); + let ata1 = derive_token_ata(&owner1, &mint); // Assert ATA1 was created correctly assert_create_associated_token_account( @@ -1033,7 +1001,7 @@ async fn test_ata_multiple_owners_same_mint() { .await .unwrap(); - let (ata2, _) = derive_token_ata(&owner2, &mint); + let ata2 = derive_token_ata(&owner2, &mint); // Assert ATA2 was created correctly assert_create_associated_token_account( @@ -1056,7 +1024,7 @@ async fn test_ata_multiple_owners_same_mint() { .await .unwrap(); - let (ata3, _) = derive_token_ata(&owner3, &mint); + let ata3 = derive_token_ata(&owner3, &mint); // Assert ATA3 was created correctly assert_create_associated_token_account( @@ -1074,9 +1042,9 @@ async fn test_ata_multiple_owners_same_mint() { assert_ne!(ata2, ata3, "ATA for owner2 and owner3 should be different"); // Verify each ATA is derived correctly for its owner - let (expected_ata1, _) = derive_token_ata(&owner1, &mint); - let (expected_ata2, _) = derive_token_ata(&owner2, &mint); - let (expected_ata3, _) = derive_token_ata(&owner3, &mint); + let expected_ata1 = derive_token_ata(&owner1, &mint); + let expected_ata2 = derive_token_ata(&owner2, &mint); + let expected_ata3 = derive_token_ata(&owner3, &mint); assert_eq!(ata1, expected_ata1, "ATA1 should match expected derivation"); assert_eq!(ata2, expected_ata2, "ATA2 should match expected derivation"); diff --git a/program-tests/compressed-token-test/tests/light_token/create_ata2.rs b/program-tests/compressed-token-test/tests/light_token/create_ata2.rs index ec04b8d4f4..f547ccc448 100644 --- a/program-tests/compressed-token-test/tests/light_token/create_ata2.rs +++ b/program-tests/compressed-token-test/tests/light_token/create_ata2.rs @@ -11,7 +11,7 @@ async fn create_and_assert_ata2( let payer_pubkey = context.payer.pubkey(); let owner_pubkey = context.owner_keypair.pubkey(); - let (ata_pubkey, bump) = derive_token_ata(&owner_pubkey, &context.mint_pubkey); + let ata_pubkey = derive_token_ata(&owner_pubkey, &context.mint_pubkey); let create_ata_ix = if let Some(compressible) = compressible_data.as_ref() { let compressible_params = CompressibleParams { @@ -37,7 +37,6 @@ async fn create_and_assert_ata2( // Create non-compressible account let mut builder = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer_pubkey, owner: owner_pubkey, mint: context.mint_pubkey, diff --git a/program-tests/compressed-token-test/tests/light_token/functional_ata.rs b/program-tests/compressed-token-test/tests/light_token/functional_ata.rs index c7b533a8a0..fbb11d2d16 100644 --- a/program-tests/compressed-token-test/tests/light_token/functional_ata.rs +++ b/program-tests/compressed-token-test/tests/light_token/functional_ata.rs @@ -116,7 +116,7 @@ async fn test_associated_token_account_operations() { .await; // Test closing compressible ATA - let (compressible_ata_pubkey, _) = + let compressible_ata_pubkey = derive_token_ata(&compressible_owner_pubkey, &context.mint_pubkey); // Create a separate destination account @@ -272,7 +272,7 @@ async fn test_create_ata_with_prefunded_lamports() { let owner_pubkey = context.owner_keypair.pubkey(); // Derive ATA address - let (ata, bump) = derive_token_ata(&owner_pubkey, &context.mint_pubkey); + let ata = derive_token_ata(&owner_pubkey, &context.mint_pubkey); // Pre-fund the ATA address with lamports (simulating attacker donation DoS attempt) let prefund_amount = 1_000; // 1000 lamports @@ -309,7 +309,6 @@ async fn test_create_ata_with_prefunded_lamports() { let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer_pubkey, owner: owner_pubkey, mint: context.mint_pubkey, diff --git a/program-tests/compressed-token-test/tests/light_token/shared.rs b/program-tests/compressed-token-test/tests/light_token/shared.rs index 78811c89bc..d2085a66a3 100644 --- a/program-tests/compressed-token-test/tests/light_token/shared.rs +++ b/program-tests/compressed-token-test/tests/light_token/shared.rs @@ -384,7 +384,7 @@ pub async fn create_and_assert_ata( let owner_pubkey = context.owner_keypair.pubkey(); // Derive ATA address - let (ata_pubkey, bump) = derive_token_ata(&owner_pubkey, &context.mint_pubkey); + let ata_pubkey = derive_token_ata(&owner_pubkey, &context.mint_pubkey); // Build instruction based on whether it's compressible let create_ata_ix = if let Some(compressible) = compressible_data.as_ref() { @@ -411,7 +411,6 @@ pub async fn create_and_assert_ata( // Create account with default compressible params (ATAs use default_ata) let mut builder = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer_pubkey, owner: owner_pubkey, mint: context.mint_pubkey, diff --git a/program-tests/compressed-token-test/tests/mint/burn.rs b/program-tests/compressed-token-test/tests/mint/burn.rs index 259ca534e2..18b9511808 100644 --- a/program-tests/compressed-token-test/tests/mint/burn.rs +++ b/program-tests/compressed-token-test/tests/mint/burn.rs @@ -40,7 +40,7 @@ async fn setup_burn_test(mint_amount: u64) -> BurnTestContext { let (mint_pda, _) = find_mint_address(&mint_seed.pubkey()); // Step 1: Create Light Token ATA for owner first (needed before minting) - let (ctoken_ata, _) = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); + let ctoken_ata = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); let create_ata_ix = CreateAssociatedTokenAccount::new(payer.pubkey(), owner_keypair.pubkey(), mint_pda) diff --git a/program-tests/compressed-token-test/tests/mint/cmint_resize.rs b/program-tests/compressed-token-test/tests/mint/cmint_resize.rs index be80b5fc81..e153976cb6 100644 --- a/program-tests/compressed-token-test/tests/mint/cmint_resize.rs +++ b/program-tests/compressed-token-test/tests/mint/cmint_resize.rs @@ -566,7 +566,7 @@ async fn test_cmint_all_operations() { }, // MintToCToken (decompressed recipient) MintActionType::MintToCToken { - account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0, + account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda), amount: 2000, }, // UpdateMintAuthority @@ -967,7 +967,7 @@ async fn test_decompress_with_mint_to_ctoken() { write_top_up: 0, }, MintActionType::MintToCToken { - account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0, + account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda), amount: 5000, }, ]; @@ -1103,7 +1103,7 @@ async fn test_decompress_with_all_operations() { }, // MintToCToken (decompressed recipient) MintActionType::MintToCToken { - account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0, + account: derive_token_ata(&recipient.pubkey(), &spl_mint_pda), amount: 2000, }, // UpdateMintAuthority 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 0572b51aa1..577c7a06d0 100644 --- a/program-tests/compressed-token-test/tests/mint/edge_cases.rs +++ b/program-tests/compressed-token-test/tests/mint/edge_cases.rs @@ -182,8 +182,7 @@ async fn functional_all_in_one_instruction() { }, // 2. MintToCToken - mint to decompressed account MintActionType::MintToCToken { - account: light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda) - .0, + account: light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda), amount: 2000u64, }, // 3. UpdateMintAuthority diff --git a/program-tests/compressed-token-test/tests/mint/failing.rs b/program-tests/compressed-token-test/tests/mint/failing.rs index 48b5246ec8..e0ffb9f073 100644 --- a/program-tests/compressed-token-test/tests/mint/failing.rs +++ b/program-tests/compressed-token-test/tests/mint/failing.rs @@ -470,7 +470,7 @@ async fn functional_and_failing_tests() { .unwrap(); let recipient_ata = - light_token::instruction::derive_token_ata(&recipient2.pubkey(), &spl_mint_pda).0; + light_token::instruction::derive_token_ata(&recipient2.pubkey(), &spl_mint_pda); // Try to mint with valid NEW authority (since we updated it) let result = light_test_utils::actions::mint_action_comprehensive( @@ -883,8 +883,7 @@ async fn test_mint_to_ctoken_max_top_up_exceeded() { .await .unwrap(); - let ctoken_ata = - light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; + let ctoken_ata = light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda); // 3. Build MintToCToken instruction with max_top_up = 1 (too low) // Get current compressed mint state diff --git a/program-tests/compressed-token-test/tests/mint/functional.rs b/program-tests/compressed-token-test/tests/mint/functional.rs index 1440b8f2be..1695ecaa88 100644 --- a/program-tests/compressed-token-test/tests/mint/functional.rs +++ b/program-tests/compressed-token-test/tests/mint/functional.rs @@ -217,10 +217,9 @@ async fn test_create_compressed_mint() { // 5. Decompress compressed tokens to ctokens // Create non-compressible token associated token account for decompression - let (ctoken_ata_pubkey, bump) = derive_token_ata(&new_recipient, &spl_mint_pda); + let ctoken_ata_pubkey = derive_token_ata(&new_recipient, &spl_mint_pda); let create_ata_instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: new_recipient, mint: spl_mint_pda, @@ -419,15 +418,13 @@ async fn test_create_compressed_mint() { let compress_from_spl_recipient = Keypair::new(); // Create SPL token account for compression source - let (compress_source_ata, _) = derive_token_ata(&new_recipient, &spl_mint_pda); + let compress_source_ata = derive_token_ata(&new_recipient, &spl_mint_pda); // This already exists from our previous test // Create non-compressible SPL token account for decompression destination - let (decompress_dest_ata, decompress_bump) = - derive_token_ata(&decompress_recipient.pubkey(), &spl_mint_pda); + let decompress_dest_ata = derive_token_ata(&decompress_recipient.pubkey(), &spl_mint_pda); let create_decompress_ata_instruction = CreateAssociatedTokenAccount { idempotent: false, - bump: decompress_bump, payer: payer.pubkey(), owner: decompress_recipient.pubkey(), mint: spl_mint_pda, @@ -689,7 +686,7 @@ async fn test_ctoken_transfer() { let (spl_mint_pda, _) = find_mint_address(&mint_seed.pubkey()); // Create compressed token ATA for recipient - let (recipient_ata, _) = derive_token_ata(&recipient_keypair.pubkey(), &spl_mint_pda); + let recipient_ata = derive_token_ata(&recipient_keypair.pubkey(), &spl_mint_pda); let compressible_params = CompressibleParams { compressible_config: rpc .test_accounts @@ -762,8 +759,7 @@ async fn test_ctoken_transfer() { // === CREATE SECOND RECIPIENT FOR TRANSFER TEST === let second_recipient_keypair = Keypair::new(); - let (second_recipient_ata, second_recipient_ata_bump) = - derive_token_ata(&second_recipient_keypair.pubkey(), &spl_mint_pda); + let second_recipient_ata = derive_token_ata(&second_recipient_keypair.pubkey(), &spl_mint_pda); rpc.airdrop_lamports(&second_recipient_keypair.pubkey(), 10_000_000_000) .await @@ -771,7 +767,6 @@ async fn test_ctoken_transfer() { let create_second_ata_instruction = CreateAssociatedTokenAccount { idempotent: false, - bump: second_recipient_ata_bump, payer: payer.pubkey(), owner: second_recipient_keypair.pubkey(), mint: spl_mint_pda, diff --git a/program-tests/compressed-token-test/tests/mint/mint_to.rs b/program-tests/compressed-token-test/tests/mint/mint_to.rs index fcc2803d0d..855fdbac79 100644 --- a/program-tests/compressed-token-test/tests/mint/mint_to.rs +++ b/program-tests/compressed-token-test/tests/mint/mint_to.rs @@ -38,7 +38,7 @@ async fn setup_mint_to_test() -> MintToTestContext { let (mint_pda, _) = find_mint_address(&mint_seed.pubkey()); // Step 1: Create Light Token ATA for owner first - let (ctoken_ata, _) = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); + let ctoken_ata = derive_token_ata(&owner_keypair.pubkey(), &mint_pda); let create_ata_ix = CreateAssociatedTokenAccount::new(payer.pubkey(), owner_keypair.pubkey(), mint_pda) diff --git a/program-tests/compressed-token-test/tests/mint/random.rs b/program-tests/compressed-token-test/tests/mint/random.rs index 1b8730bb8b..534e513e4b 100644 --- a/program-tests/compressed-token-test/tests/mint/random.rs +++ b/program-tests/compressed-token-test/tests/mint/random.rs @@ -143,7 +143,7 @@ async fn test_random_mint_action() { .await .unwrap(); - let ata = light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda).0; + let ata = light_token::instruction::derive_token_ata(&recipient.pubkey(), &spl_mint_pda); ctoken_atas.push(ata); } 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 e87a8b5095..9cf8114e7c 100644 --- a/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/compress_failing.rs @@ -89,7 +89,7 @@ async fn setup_compression_test(token_amount: u64) -> Result Result<(), RpcError> { // Derive mint and ATA addresses let (mint, _) = find_mint_address(&mint_seed.pubkey()); - let (ctoken_ata, _) = derive_token_ata(&owner.pubkey(), &mint); + let ctoken_ata = derive_token_ata(&owner.pubkey(), &mint); // Create compressible Light Token ATA with pre_pay_num_epochs = 0 (NO prepaid rent) // This means any write operation will require immediate rent top-up @@ -732,7 +732,7 @@ async fn test_compression_duplicate_account_no_double_charge_top_up() -> Result< // Derive mint and ATA addresses let (mint, _) = find_mint_address(&mint_seed.pubkey()); - let (ctoken_ata, _) = derive_token_ata(&owner.pubkey(), &mint); + let ctoken_ata = derive_token_ata(&owner.pubkey(), &mint); // Create compressible Light Token ATA with pre_pay_num_epochs = 0 (NO prepaid rent) let compressible_params = CompressibleParams { 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 7779289659..c640dc8990 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 @@ -113,7 +113,7 @@ async fn setup_spl_compression_test( rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await?; - let ctoken_ata = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_ata = derive_token_ata(&recipient.pubkey(), &mint); // Get output queue for compression (for system_accounts_offset calculation only) let output_queue = rpc 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 3000b84066..fe23a0348f 100644 --- a/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs +++ b/program-tests/compressed-token-test/tests/transfer2/decompress_failing.rs @@ -89,7 +89,7 @@ async fn setup_decompression_test( // Derive mint and ATA addresses let (mint, _) = find_mint_address(&mint_seed.pubkey()); - let (ctoken_ata, _) = derive_token_ata(&owner.pubkey(), &mint); + let ctoken_ata = derive_token_ata(&owner.pubkey(), &mint); // Create compressible Light Token ATA for owner (recipient of decompression) let compressible_params = CompressibleParams { 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 b5f940f58d..7cbda9c766 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 @@ -102,8 +102,8 @@ async fn setup_no_system_program_cpi_test( // Create compressed mint seed let mint_seed = Keypair::new(); let (mint, _) = find_mint_address(&mint_seed.pubkey()); - let (source_ata, _) = derive_token_ata(&owner.pubkey(), &mint); - let (recipient_ata, _) = derive_token_ata(&recipient.pubkey(), &mint); + let source_ata = derive_token_ata(&owner.pubkey(), &mint); + let recipient_ata = derive_token_ata(&recipient.pubkey(), &mint); // Create Light Token ATA for owner (source) let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), owner.pubkey(), mint) @@ -709,8 +709,8 @@ async fn test_too_many_mints() { // Create new mint seed let mint_seed = Keypair::new(); let (mint, _) = find_mint_address(&mint_seed.pubkey()); - let (source_ata, _) = derive_token_ata(&context.owner.pubkey(), &mint); - let (recipient_ata, _) = derive_token_ata(&context.recipient.pubkey(), &mint); + let source_ata = derive_token_ata(&context.owner.pubkey(), &mint); + let recipient_ata = derive_token_ata(&context.recipient.pubkey(), &mint); // Create source ATA let instruction = diff --git a/program-tests/compressed-token-test/tests/transfer2/shared.rs b/program-tests/compressed-token-test/tests/transfer2/shared.rs index 69237ef81d..0596494a1f 100644 --- a/program-tests/compressed-token-test/tests/transfer2/shared.rs +++ b/program-tests/compressed-token-test/tests/transfer2/shared.rs @@ -445,7 +445,7 @@ impl TestContext { .unwrap_or(&false); // Create Light Token ATA (compressible or regular based on requirements) - let (ata, bump) = light_token::instruction::derive_token_ata(&signer.pubkey(), &mint); + let ata = light_token::instruction::derive_token_ata(&signer.pubkey(), &mint); let create_ata_ix = if is_compressible { println!( @@ -469,7 +469,6 @@ impl TestContext { // Create non-compressible Light Token ATA CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: signer.pubkey(), mint, 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 d55087e5e8..eb3d7f94b4 100644 --- a/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs +++ b/program-tests/compressed-token-test/tests/transfer2/spl_ctoken.rs @@ -78,7 +78,7 @@ async fn test_spl_to_ctoken_transfer() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let associated_token_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let associated_token_account = derive_token_ata(&recipient.pubkey(), &mint); // Get initial SPL token balance let spl_account_data = rpc @@ -243,10 +243,9 @@ async fn test_failing_ctoken_to_spl_with_compress_and_close() { .unwrap(); // Create compressible token ATA for recipient (ATAs require compression_only=true) - let (associated_token_account, bump) = derive_token_ata(&recipient.pubkey(), &mint); + let associated_token_account = derive_token_ata(&recipient.pubkey(), &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: recipient.pubkey(), mint, diff --git a/program-tests/registry-test/tests/compressible.rs b/program-tests/registry-test/tests/compressible.rs index 633dc1831e..ee65152021 100644 --- a/program-tests/registry-test/tests/compressible.rs +++ b/program-tests/registry-test/tests/compressible.rs @@ -850,7 +850,7 @@ async fn test_deprecate_compressible_config_with_valid_authority() -> Result<(), // Test 3: CAN claim rent with deprecated config let forester_keypair = rpc.test_accounts.protocol.forester.insecure_clone(); - let (ata_pubkey, _) = derive_token_ata(&token_account_keypair.pubkey(), &mint); + let ata_pubkey = derive_token_ata(&token_account_keypair.pubkey(), &mint); // Claim from the account we created earlier let claim_result = claim_forester(&mut rpc, &[ata_pubkey], &forester_keypair, &payer).await; diff --git a/program-tests/utils/src/actions/legacy/mint_action.rs b/program-tests/utils/src/actions/legacy/mint_action.rs index d16ba10a3b..995eb5e5c1 100644 --- a/program-tests/utils/src/actions/legacy/mint_action.rs +++ b/program-tests/utils/src/actions/legacy/mint_action.rs @@ -111,7 +111,7 @@ pub async fn mint_action_comprehensive( for recipient in mint_to_decompressed_recipients { let recipient_pubkey = solana_pubkey::Pubkey::from(recipient.recipient.to_bytes()); - let (ata_address, _) = derive_token_ata(&recipient_pubkey, &spl_mint_pda); + let ata_address = derive_token_ata(&recipient_pubkey, &spl_mint_pda); actions.push(MintActionType::MintToCToken { account: ata_address, diff --git a/program-tests/utils/src/assert_create_token_account.rs b/program-tests/utils/src/assert_create_token_account.rs index d3452f66f7..0e5912c040 100644 --- a/program-tests/utils/src/assert_create_token_account.rs +++ b/program-tests/utils/src/assert_create_token_account.rs @@ -404,7 +404,7 @@ pub async fn assert_create_associated_token_account( expected_extensions: Option>, ) { // Derive the associated token account address - let (ata_pubkey, _bump) = derive_token_ata(&owner_pubkey, &mint_pubkey); + let ata_pubkey = derive_token_ata(&owner_pubkey, &mint_pubkey); // Verify the account exists at the derived address let account = rpc diff --git a/programs/compressed-token/program/src/compressed_token/mint_action/actions/decompress_mint.rs b/programs/compressed-token/program/src/compressed_token/mint_action/actions/decompress_mint.rs index 0c153e93e1..ab84e5867d 100644 --- a/programs/compressed-token/program/src/compressed_token/mint_action/actions/decompress_mint.rs +++ b/programs/compressed-token/program/src/compressed_token/mint_action/actions/decompress_mint.rs @@ -116,12 +116,7 @@ pub fn process_decompress_mint_action( // 6. Verify PDA derivation using stored mint_signer from compressed_mint metadata let pda_mint_signer_bytes: &[u8] = compressed_mint.metadata.mint_signer.as_ref(); let seeds: [&[u8]; 2] = [COMPRESSED_MINT_SEED, pda_mint_signer_bytes]; - verify_pda( - cmint.key(), - &seeds, - compressed_mint.metadata.bump, - &crate::LIGHT_CPI_SIGNER.program_id, - )?; + let canonical_bump = verify_pda(cmint.key(), &seeds, &crate::LIGHT_CPI_SIGNER.program_id)?; // 6b. Verify CMint account matches compressed_mint.metadata.mint if !pubkey_eq(cmint.key(), &compressed_mint.metadata.mint.to_bytes()) { msg!("CMint account does not match compressed_mint.metadata.mint"); @@ -156,8 +151,8 @@ pub fn process_decompress_mint_action( Seed::from(rent_sponsor_bump_bytes.as_ref()), ]; - // 7d. Build seeds for CMint PDA using stored values from compressed_mint metadata - let cmint_bump_bytes = [compressed_mint.metadata.bump]; + // 7d. Build seeds for CMint PDA using canonical bump from verify_pda + let cmint_bump_bytes = [canonical_bump]; let mint_signer_bytes: &[u8] = compressed_mint.metadata.mint_signer.as_ref(); let cmint_seeds = [ Seed::from(COMPRESSED_MINT_SEED), diff --git a/programs/compressed-token/program/src/ctoken/create_ata.rs b/programs/compressed-token/program/src/ctoken/create_ata.rs index a1608aa8cf..406981ea0f 100644 --- a/programs/compressed-token/program/src/ctoken/create_ata.rs +++ b/programs/compressed-token/program/src/ctoken/create_ata.rs @@ -61,14 +61,13 @@ fn process_create_associated_token_account_with_mode( let owner_bytes = owner.key(); let mint_bytes = mint.key(); - let bump = inputs.bump; + + // Derive canonical bump on-chain (validates PDA derivation) + let bump = validate_ata_derivation(associated_token_account, owner_bytes, mint_bytes)?; // If idempotent mode, check if account already exists - if IDEMPOTENT { - validate_ata_derivation(associated_token_account, owner_bytes, mint_bytes, bump)?; - if associated_token_account.is_owned_by(&crate::LIGHT_CPI_SIGNER.program_id) { - return Ok(()); - } + if IDEMPOTENT && associated_token_account.is_owned_by(&crate::LIGHT_CPI_SIGNER.program_id) { + return Ok(()); } // Check account is owned by system program (uninitialized) diff --git a/programs/compressed-token/program/src/shared/create_pda_account.rs b/programs/compressed-token/program/src/shared/create_pda_account.rs index f7eeb6ab12..26f6856278 100644 --- a/programs/compressed-token/program/src/shared/create_pda_account.rs +++ b/programs/compressed-token/program/src/shared/create_pda_account.rs @@ -90,18 +90,20 @@ pub fn create_pda_account( .map_err(convert_program_error) } -/// Verifies that the provided account matches the expected PDA +/// Verifies that the provided account matches the expected PDA. +/// Derives the canonical bump on-chain using `find_program_address`. +/// Returns the canonical bump on success. pub fn verify_pda( account_key: &[u8; 32], seeds: &[&[u8]; N], - bump: u8, program_id: &Pubkey, -) -> Result<(), ProgramError> { - let expected_pubkey = pinocchio_pubkey::derive_address(seeds, Some(bump), program_id); +) -> Result { + let (expected_pubkey, bump) = + pinocchio::pubkey::find_program_address(seeds.as_slice(), program_id); if account_key != &expected_pubkey { return Err(ProgramError::InvalidAccountData); } - Ok(()) + Ok(bump) } diff --git a/programs/compressed-token/program/src/shared/validate_ata_derivation.rs b/programs/compressed-token/program/src/shared/validate_ata_derivation.rs index 3d1a3f7a7b..5fe6978f29 100644 --- a/programs/compressed-token/program/src/shared/validate_ata_derivation.rs +++ b/programs/compressed-token/program/src/shared/validate_ata_derivation.rs @@ -4,7 +4,7 @@ use pinocchio::account_info::AccountInfo; /// Validates that an account is the correct Associated Token Account PDA /// -/// Returns Ok(()) if the account key matches the expected PDA derivation. +/// Returns the canonical bump if the account key matches the expected PDA derivation. /// This is used by both the regular and idempotent create ATA instructions. #[inline(always)] #[profile] @@ -12,18 +12,12 @@ pub fn validate_ata_derivation( account: &AccountInfo, owner: &[u8; 32], mint: &[u8; 32], - bump: u8, -) -> Result<(), ProgramError> { +) -> Result { let seeds = &[ owner.as_ref(), crate::LIGHT_CPI_SIGNER.program_id.as_ref(), mint.as_ref(), ]; - crate::shared::verify_pda( - account.key(), - seeds, - bump, - &crate::LIGHT_CPI_SIGNER.program_id, - ) + crate::shared::verify_pda(account.key(), seeds, &crate::LIGHT_CPI_SIGNER.program_id) } diff --git a/sdk-libs/account-pinocchio/src/lib.rs b/sdk-libs/account-pinocchio/src/lib.rs index fbc8893c74..b68b611e51 100644 --- a/sdk-libs/account-pinocchio/src/lib.rs +++ b/sdk-libs/account-pinocchio/src/lib.rs @@ -314,8 +314,8 @@ pub fn derive_mint_compressed_address( /// Derive the associated token account address for a given owner and mint. /// -/// Returns `([u8; 32], u8)` -- the ATA address and bump seed. +/// Returns `[u8; 32]` -- the ATA address. #[cfg(feature = "token")] -pub fn derive_associated_token_account(owner: &[u8; 32], mint: &[u8; 32]) -> ([u8; 32], u8) { +pub fn derive_associated_token_account(owner: &[u8; 32], mint: &[u8; 32]) -> [u8; 32] { derive_associated_token_account_generic::(owner, mint) } diff --git a/sdk-libs/account/README.md b/sdk-libs/account/README.md index ef67b38502..bb88eca06e 100644 --- a/sdk-libs/account/README.md +++ b/sdk-libs/account/README.md @@ -127,7 +127,7 @@ pub vault: UncheckedAccount<'info>, **With `init` (Anchor-created):** ```rust #[account(mut)] -#[light_account(init, associated_token::authority = owner, associated_token::mint = mint, associated_token::bump = params.bump)] +#[light_account(init, associated_token::authority = owner, associated_token::mint = mint)] pub token_account: UncheckedAccount<'info>, ``` diff --git a/sdk-libs/account/src/lib.rs b/sdk-libs/account/src/lib.rs index 4f85448d18..ebbdcf5bdb 100644 --- a/sdk-libs/account/src/lib.rs +++ b/sdk-libs/account/src/lib.rs @@ -125,7 +125,7 @@ //! **With `init` (Anchor-created):** //! ```rust,ignore //! #[account(mut)] -//! #[light_account(init, associated_token::authority = owner, associated_token::mint = mint, associated_token::bump = params.bump)] +//! #[light_account(init, associated_token::authority = owner, associated_token::mint = mint)] //! pub token_account: UncheckedAccount<'info>, //! ``` //! @@ -431,15 +431,15 @@ pub fn derive_mint_compressed_address( /// Derive the associated token account address for a given owner and mint. /// -/// Returns `(Pubkey, u8)` -- the ATA address and bump seed. +/// Returns the ATA address. #[cfg(feature = "token")] pub fn derive_associated_token_account( owner: &solana_pubkey::Pubkey, mint: &solana_pubkey::Pubkey, -) -> (solana_pubkey::Pubkey, u8) { - let (bytes, bump) = derive_associated_token_account_generic::>( +) -> solana_pubkey::Pubkey { + let bytes = derive_associated_token_account_generic::>( &owner.to_bytes(), &mint.to_bytes(), ); - (solana_pubkey::Pubkey::from(bytes), bump) + solana_pubkey::Pubkey::from(bytes) } diff --git a/sdk-libs/client/src/interface/account_interface.rs b/sdk-libs/client/src/interface/account_interface.rs index a7f30891fa..22488a2511 100644 --- a/sdk-libs/client/src/interface/account_interface.rs +++ b/sdk-libs/client/src/interface/account_interface.rs @@ -8,7 +8,7 @@ //! - `solana_account::Account` for raw account data //! - `spl_token_2022_interface::pod::PodAccount` for parsed token data -use light_token::instruction::derive_token_ata; +use light_token::utils::get_associated_token_address_and_bump; use light_token_interface::state::ExtensionStruct; use solana_account::Account; use solana_pubkey::Pubkey; @@ -311,7 +311,8 @@ impl TokenAccountInterface { /// Get ATA bump if this is an ATA. Returns None if not a valid ATA derivation. pub fn ata_bump(&self) -> Option { - let (derived_ata, bump) = derive_token_ata(&self.parsed.owner, &self.parsed.mint); + let (derived_ata, bump) = + get_associated_token_address_and_bump(&self.parsed.owner, &self.parsed.mint); (derived_ata == self.key).then_some(bump) } diff --git a/sdk-libs/client/src/interface/light_program_interface.rs b/sdk-libs/client/src/interface/light_program_interface.rs index 81efefcd6d..a128d20151 100644 --- a/sdk-libs/client/src/interface/light_program_interface.rs +++ b/sdk-libs/client/src/interface/light_program_interface.rs @@ -53,7 +53,7 @@ impl AccountToFetch { match self { Self::Pda { address, .. } => *address, Self::Token { address } => *address, - Self::Ata { wallet_owner, mint } => derive_token_ata(wallet_owner, mint).0, + Self::Ata { wallet_owner, mint } => derive_token_ata(wallet_owner, mint), Self::Mint { address } => *address, } } diff --git a/sdk-libs/client/src/interface/load_accounts.rs b/sdk-libs/client/src/interface/load_accounts.rs index d156b7316e..a73ecafa9f 100644 --- a/sdk-libs/client/src/interface/load_accounts.rs +++ b/sdk-libs/client/src/interface/load_accounts.rs @@ -364,7 +364,7 @@ fn build_transfer2( )?; let owner_idx = packed.insert_or_get_config(ctx.wallet_owner, true, false); - let ata_idx = packed.insert_or_get(derive_token_ata(&ctx.wallet_owner, &ctx.mint).0); + let ata_idx = packed.insert_or_get(derive_token_ata(&ctx.wallet_owner, &ctx.mint)); let mint_idx = packed.insert_or_get(token.mint); let delegate_idx = token.delegate.map(|d| packed.insert_or_get(d)).unwrap_or(0); diff --git a/sdk-libs/macros/docs/accounts/architecture.md b/sdk-libs/macros/docs/accounts/architecture.md index 347ef4bcef..bbe98c3531 100644 --- a/sdk-libs/macros/docs/accounts/architecture.md +++ b/sdk-libs/macros/docs/accounts/architecture.md @@ -195,7 +195,6 @@ pub cmint: UncheckedAccount<'info>, #[light_account(init, associated_token, associated_token::authority = owner, // ATA owner field (required) associated_token::mint = mint, // ATA mint field (required) - associated_token::bump = params.ata_bump // Optional: explicit bump )] pub user_ata: UncheckedAccount<'info>, ``` @@ -204,7 +203,6 @@ pub user_ata: UncheckedAccount<'info>, |-----------|-------------|----------| | `associated_token::authority` | ATA owner field reference | Yes | | `associated_token::mint` | ATA mint field reference | Yes | -| `associated_token::bump` | Explicit bump (auto-derived if omitted) | No | ### 2.4 Mark-Only Mode diff --git a/sdk-libs/macros/docs/accounts/associated_token.md b/sdk-libs/macros/docs/accounts/associated_token.md index 623e3d2f39..1a129f0822 100644 --- a/sdk-libs/macros/docs/accounts/associated_token.md +++ b/sdk-libs/macros/docs/accounts/associated_token.md @@ -19,12 +19,9 @@ |-----------|----------|-------------| | `associated_token::authority` | Yes | ATA owner field reference | | `associated_token::mint` | Yes | Token mint field reference | -| `associated_token::bump` | No | Explicit bump (auto-derived using `derive_token_ata` if omitted) | -**Bump handling:** -- ATA address is derived using fixed seeds: `[owner, LIGHT_TOKEN_PROGRAM_ID, mint]` -- If `bump` not provided, macro generates: `let (_, bump) = derive_token_ata(&owner, &mint);` -- Bump is used in the `CreateTokenAtaCpi` builder +**Note:** The ATA bump is derived on-chain by the cToken program. It is no longer +passed in instruction data. ### Infrastructure (auto-detected by name) @@ -40,9 +37,7 @@ system_program # System program ```rust #[derive(AnchorSerialize, AnchorDeserialize)] -pub struct CreateAtaParams { - pub ata_bump: u8, // Optional - can auto-derive -} +pub struct CreateAtaParams {} #[derive(Accounts, LightAccounts)] #[instruction(params: CreateAtaParams)] @@ -57,7 +52,6 @@ pub struct CreateAta<'info> { #[light_account(init, associated_token::authority = owner, // ATA owner associated_token::mint = mint, // Token mint - associated_token::bump = params.ata_bump // Optional: auto-derived if omitted )] pub user_ata: Account<'info, CToken>, diff --git a/sdk-libs/macros/src/light_pdas/accounts/light_account.rs b/sdk-libs/macros/src/light_pdas/accounts/light_account.rs index 5a1becdd29..bb6b13a990 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/light_account.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/light_account.rs @@ -26,7 +26,6 @@ //! #[light_account(init, //! associated_token::authority = owner, //! associated_token::mint = mint, -//! associated_token::bump = params.ata_bump //! )] //! ``` //! @@ -133,8 +132,6 @@ pub struct AtaField { pub owner: Expr, /// Mint for the ATA (from associated_token::mint = ... parameter) pub mint: Expr, - /// Bump seed (from associated_token::bump = ...) - pub bump: Option, } // ============================================================================ @@ -1017,18 +1014,22 @@ fn build_ata_field( ) -> Result { let mut owner: Option = None; // from associated_token::authority let mut mint: Option = None; - let mut bump: Option = None; for kv in key_values { match kv.key.to_string().as_str() { "authority" => owner = Some(kv.value.clone()), // authority -> owner "mint" => mint = Some(kv.value.clone()), - "bump" => bump = Some(kv.value.clone()), + "bump" => { + return Err(Error::new_spanned( + &kv.key, + "`associated_token::bump` is no longer supported. The bump is derived on-chain.", + )); + } other => { return Err(Error::new_spanned( &kv.key, format!( - "Unknown key `associated_token::{}`. Allowed: authority, mint, bump", + "Unknown key `associated_token::{}`. Allowed: authority, mint", other ), )); @@ -1055,7 +1056,6 @@ fn build_ata_field( has_init, owner, mint, - bump, }) } @@ -1600,9 +1600,9 @@ mod tests { #[test] fn test_parse_associated_token_shorthand_syntax() { - // Test shorthand syntax: mint, authority, bump without = value + // Test shorthand syntax: mint, authority without = value (bump is derived on-chain) let field: syn::Field = parse_quote! { - #[light_account(init, associated_token::authority, associated_token::mint, associated_token::bump)] + #[light_account(init, associated_token::authority, associated_token::mint)] pub user_ata: Account<'info, CToken> }; let ident = field.ident.clone().unwrap(); @@ -1616,12 +1616,24 @@ mod tests { LightAccountField::AssociatedToken(ata) => { assert_eq!(ata.field_ident.to_string(), "user_ata"); assert!(ata.has_init); - assert!(ata.bump.is_some()); } _ => panic!("Expected AssociatedToken field"), } } + #[test] + fn test_parse_associated_token_bump_rejected() { + // associated_token::bump should be rejected (bump is derived on-chain) + let field: syn::Field = parse_quote! { + #[light_account(init, associated_token::authority, associated_token::mint, associated_token::bump)] + pub user_ata: Account<'info, CToken> + }; + let ident = field.ident.clone().unwrap(); + + let result = parse_light_account_attr(&field, &ident, &None); + assert!(result.is_err()); + } + #[test] fn test_parse_token_duplicate_key_fails() { // Duplicate keys should be rejected diff --git a/sdk-libs/macros/src/light_pdas/accounts/token.rs b/sdk-libs/macros/src/light_pdas/accounts/token.rs index 15918f317d..f66645ad0a 100644 --- a/sdk-libs/macros/src/light_pdas/accounts/token.rs +++ b/sdk-libs/macros/src/light_pdas/accounts/token.rs @@ -185,23 +185,6 @@ pub(super) fn generate_ata_cpi(field: &AtaField, infra: &InfraRefs) -> Option( - &self.#owner.to_account_info().key.to_bytes(), - &self.#mint.to_account_info().key.to_bytes(), - ); - bump - } - } - }); - Some(quote! { // Create ATA: #field_ident { @@ -220,7 +203,6 @@ pub(super) fn generate_ata_cpi(field: &AtaField, infra: &InfraRefs) -> Option list of shorthand-eligible keys pub const SHORTHAND_KEYS_BY_NAMESPACE: &[(&str, &[&str])] = &[ ("token", &["mint", "owner", "bump"]), // seeds requires array, no shorthand - ("associated_token", &["authority", "mint", "bump"]), + ("associated_token", &["authority", "mint"]), // mint namespace does not support shorthand - values are typically expressions ]; @@ -201,7 +201,7 @@ mod tests { fn test_associated_token_namespace_keys() { assert!(ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"authority")); assert!(ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"mint")); - assert!(ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"bump")); + assert!(!ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"bump")); // bump derived on-chain assert!(!ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"owner")); // renamed to authority assert!(!ASSOCIATED_TOKEN_NAMESPACE_KEYS.contains(&"unknown")); } @@ -247,7 +247,6 @@ mod tests { // associated_token namespace assert!(is_shorthand_key("associated_token", "authority")); assert!(is_shorthand_key("associated_token", "mint")); - assert!(is_shorthand_key("associated_token", "bump")); // mint namespace - no shorthand assert!(!is_shorthand_key("mint", "signer")); diff --git a/sdk-libs/program-test/src/program_test/rpc.rs b/sdk-libs/program-test/src/program_test/rpc.rs index 0d4173cca4..76d1151eb7 100644 --- a/sdk-libs/program-test/src/program_test/rpc.rs +++ b/sdk-libs/program-test/src/program_test/rpc.rs @@ -545,7 +545,7 @@ impl Rpc for LightProgramTest { use light_sdk::constants::LIGHT_TOKEN_PROGRAM_ID; use light_token::instruction::derive_token_ata; - let (ata, _bump) = derive_token_ata(owner, mint); + let ata = derive_token_ata(owner, mint); let light_token_program_id: Pubkey = LIGHT_TOKEN_PROGRAM_ID.into(); let slot = self.context.get_sysvar::().slot; diff --git a/sdk-libs/sdk-types/src/interface/cpi/create_token_accounts.rs b/sdk-libs/sdk-types/src/interface/cpi/create_token_accounts.rs index 1d12ac1ac6..900bd3aad6 100644 --- a/sdk-libs/sdk-types/src/interface/cpi/create_token_accounts.rs +++ b/sdk-libs/sdk-types/src/interface/cpi/create_token_accounts.rs @@ -39,11 +39,11 @@ const DEFAULT_TOKEN_ACCOUNT_VERSION: u8 = 3; /// Derive the associated token account address for a given owner and mint. /// -/// Returns `([u8; 32], u8)` -- the ATA address and bump seed. +/// Returns `[u8; 32]` -- the ATA address. pub fn derive_associated_token_account( owner: &[u8; 32], mint: &[u8; 32], -) -> ([u8; 32], u8) { +) -> [u8; 32] { AI::find_program_address( &[ owner.as_ref(), @@ -52,6 +52,7 @@ pub fn derive_associated_token_account( ], &LIGHT_TOKEN_PROGRAM_ID, ) + .0 } // ============================================================================ @@ -246,7 +247,6 @@ impl<'a, AI: AccountInfoTrait + Clone> CreateTokenAccountRentFreeCpi<'a, AI> { /// owner: &ctx.accounts.owner, /// mint: &ctx.accounts.mint, /// ata: &ctx.accounts.user_ata, -/// bump: params.user_ata_bump, /// } /// .idempotent() /// .rent_free( @@ -261,7 +261,6 @@ pub struct CreateTokenAtaCpi<'a, AI: AccountInfoTrait + Clone> { pub owner: &'a AI, pub mint: &'a AI, pub ata: &'a AI, - pub bump: u8, } impl<'a, AI: AccountInfoTrait + Clone> CreateTokenAtaCpi<'a, AI> { @@ -282,7 +281,6 @@ impl<'a, AI: AccountInfoTrait + Clone> CreateTokenAtaCpi<'a, AI> { owner: self.owner, mint: self.mint, ata: self.ata, - bump: self.bump, idempotent: false, config, sponsor, @@ -309,7 +307,6 @@ impl<'a, AI: AccountInfoTrait + Clone> CreateTokenAtaCpiIdempotent<'a, AI> { owner: self.base.owner, mint: self.base.mint, ata: self.base.ata, - bump: self.base.bump, idempotent: true, config, sponsor, @@ -324,7 +321,6 @@ pub struct CreateTokenAtaRentFreeCpi<'a, AI: AccountInfoTrait + Clone> { owner: &'a AI, mint: &'a AI, ata: &'a AI, - bump: u8, idempotent: bool, config: &'a AI, sponsor: &'a AI, @@ -358,7 +354,6 @@ impl<'a, AI: AccountInfoTrait + Clone> CreateTokenAtaRentFreeCpi<'a, AI> { &self, ) -> Result<(Vec, Vec, Vec), LightSdkTypesError> { let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump: self.bump, compressible_config: Some(CompressibleExtensionInstructionData { token_account_version: DEFAULT_TOKEN_ACCOUNT_VERSION, rent_payment: DEFAULT_PRE_PAY_NUM_EPOCHS, diff --git a/sdk-libs/sdk-types/src/interface/program/decompression/create_token_account.rs b/sdk-libs/sdk-types/src/interface/program/decompression/create_token_account.rs index 46f11f416b..dcc39021bd 100644 --- a/sdk-libs/sdk-types/src/interface/program/decompression/create_token_account.rs +++ b/sdk-libs/sdk-types/src/interface/program/decompression/create_token_account.rs @@ -34,13 +34,11 @@ pub fn build_create_ata_instruction( mint: &[u8; 32], fee_payer: &[u8; 32], ata: &[u8; 32], - bump: u8, compressible_config: &[u8; 32], rent_sponsor: &[u8; 32], write_top_up: u32, ) -> Result<(Vec, Vec), LightSdkTypesError> { let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump, compressible_config: Some(CompressibleExtensionInstructionData { token_account_version: 3, // ShaFlat version (required) rent_payment: 16, // 24h diff --git a/sdk-libs/sdk-types/src/interface/program/decompression/token.rs b/sdk-libs/sdk-types/src/interface/program/decompression/token.rs index 613feed142..153943e275 100644 --- a/sdk-libs/sdk-types/src/interface/program/decompression/token.rs +++ b/sdk-libs/sdk-types/src/interface/program/decompression/token.rs @@ -80,7 +80,7 @@ where .ok_or(LightSdkTypesError::NotEnoughAccountKeys)? .key(); - if let Some((ata_bump, wallet_owner_index)) = ata_info { + if let Some((_ata_bump, wallet_owner_index)) = ata_info { // ATA path: use invoke() without signer seeds let wallet_owner_key = packed_accounts .get(wallet_owner_index as usize) @@ -94,7 +94,6 @@ where &mint_key, &fee_payer_key, &token_account_info.key(), - ata_bump, &ctoken_compressible_config_key, &ctoken_rent_sponsor_key, ctx.light_config.write_top_up, diff --git a/sdk-libs/token-pinocchio/src/instruction/create_ata.rs b/sdk-libs/token-pinocchio/src/instruction/create_ata.rs index 3c96fea1f5..1b4ba5d5cc 100644 --- a/sdk-libs/token-pinocchio/src/instruction/create_ata.rs +++ b/sdk-libs/token-pinocchio/src/instruction/create_ata.rs @@ -13,10 +13,10 @@ use pinocchio::account_info::AccountInfo; /// Derive the associated token account address for a given owner and mint. /// -/// Returns `([u8; 32], u8)` -- the ATA address and bump seed. +/// Returns `[u8; 32]` -- the ATA address. /// /// Uses pinocchio's `AccountInfo` for PDA derivation. -pub fn derive_associated_token_account(owner: &[u8; 32], mint: &[u8; 32]) -> ([u8; 32], u8) { +pub fn derive_associated_token_account(owner: &[u8; 32], mint: &[u8; 32]) -> [u8; 32] { AccountInfo::find_program_address( &[ owner.as_ref(), @@ -25,4 +25,5 @@ pub fn derive_associated_token_account(owner: &[u8; 32], mint: &[u8; 32]) -> ([u ], &LIGHT_TOKEN_PROGRAM_ID, ) + .0 } diff --git a/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs b/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs index 437fe7b189..26161f4869 100644 --- a/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs +++ b/sdk-libs/token-sdk/src/instruction/create_associated_token_account.rs @@ -1,10 +1,6 @@ use borsh::BorshSerialize; use light_token_types::{ - instructions::{ - create_associated_token_account::CreateAssociatedTokenAccountInstructionData, - create_associated_token_account2::CreateAssociatedTokenAccount2InstructionData, - extensions::compressible::CompressibleExtensionInstructionData, - }, + instructions::extensions::compressible::CompressibleExtensionInstructionData, state::TokenDataVersion, }; use solana_account_info::AccountInfo; @@ -16,8 +12,6 @@ use crate::error::{LightTokenError, LightTokenResult}; /// Discriminators for create ATA instructions const CREATE_ATA_DISCRIMINATOR: u8 = 100; const CREATE_ATA_IDEMPOTENT_DISCRIMINATOR: u8 = 102; -const CREATE_ATA2_DISCRIMINATOR: u8 = 106; -const CREATE_ATA2_IDEMPOTENT_DISCRIMINATOR: u8 = 107; /// Input parameters for creating an associated token account with compressible extension #[derive(Debug, Clone)] @@ -59,35 +53,12 @@ pub fn create_compressible_associated_token_account_idempotent( pub fn create_compressible_associated_token_account_with_mode( inputs: CreateCompressibleAssociatedTokenAccountInputs, ) -> LightTokenResult { - let (ata_pubkey, bump) = derive_associated_token_account(&inputs.owner, &inputs.mint); - create_compressible_associated_token_account_with_bump_and_mode::( - inputs, ata_pubkey, bump, - ) -} - -/// Creates a compressible associated token account instruction with a specified bump (non-idempotent) -pub fn create_compressible_associated_token_account_with_bump( - inputs: CreateCompressibleAssociatedTokenAccountInputs, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { - create_compressible_associated_token_account_with_bump_and_mode::( - inputs, ata_pubkey, bump, - ) -} - -/// Creates a compressible associated token account instruction with a specified bump and mode -pub fn create_compressible_associated_token_account_with_bump_and_mode( - inputs: CreateCompressibleAssociatedTokenAccountInputs, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { + let ata_pubkey = derive_associated_token_account(&inputs.owner, &inputs.mint); create_ata_instruction_unified::( inputs.payer, inputs.owner, inputs.mint, ata_pubkey, - bump, Some(( inputs.pre_pay_num_epochs, inputs.lamports_per_write, @@ -122,34 +93,8 @@ pub fn create_associated_token_account_with_mode( owner: Pubkey, mint: Pubkey, ) -> LightTokenResult { - let (ata_pubkey, bump) = derive_associated_token_account(&owner, &mint); - create_associated_token_account_with_bump_and_mode::( - payer, owner, mint, ata_pubkey, bump, - ) -} - -/// Creates a basic associated token account instruction with a specified bump (non-idempotent) -pub fn create_associated_token_account_with_bump( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { - create_associated_token_account_with_bump_and_mode::( - payer, owner, mint, ata_pubkey, bump, - ) -} - -/// Creates a basic associated token account instruction with specified bump and mode -pub fn create_associated_token_account_with_bump_and_mode( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { - create_ata_instruction_unified::(payer, owner, mint, ata_pubkey, bump, None) + let ata_pubkey = derive_associated_token_account(&owner, &mint); + create_ata_instruction_unified::(payer, owner, mint, ata_pubkey, None) } /// Unified function to create ATA instructions with compile-time configuration @@ -158,7 +103,6 @@ fn create_ata_instruction_unified, Pubkey, Pubkey, TokenDataVersion)>, // (pre_pay_num_epochs, lamports_per_write, rent_sponsor, compressible_config_account, token_account_version) ) -> LightTokenResult { // Select discriminator based on idempotent mode @@ -187,12 +131,10 @@ fn create_ata_instruction_unified (Pubkey, u8) { +pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> Pubkey { Pubkey::find_program_address( &[ owner.as_ref(), @@ -236,176 +178,12 @@ pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> (Pubkey ], &Pubkey::from(light_token_types::COMPRESSED_TOKEN_PROGRAM_ID), ) -} - -// ============================================================================ -// CreateAssociatedTokenAccount2 - Owner and mint as accounts -// ============================================================================ - -/// Creates a compressible associated token account instruction v2 (non-idempotent) -/// Owner and mint are passed as account infos instead of instruction data -pub fn create_compressible_associated_token_account2( - inputs: CreateCompressibleAssociatedTokenAccountInputs, -) -> LightTokenResult { - create_compressible_associated_token_account2_with_mode::(inputs) -} - -/// Creates a compressible associated token account instruction v2 (idempotent) -/// Owner and mint are passed as account infos instead of instruction data -pub fn create_compressible_associated_token_account2_idempotent( - inputs: CreateCompressibleAssociatedTokenAccountInputs, -) -> LightTokenResult { - create_compressible_associated_token_account2_with_mode::(inputs) -} - -/// Creates a compressible associated token account instruction v2 with compile-time idempotent mode -fn create_compressible_associated_token_account2_with_mode( - inputs: CreateCompressibleAssociatedTokenAccountInputs, -) -> LightTokenResult { - let (ata_pubkey, bump) = derive_associated_token_account(&inputs.owner, &inputs.mint); - create_compressible_associated_token_account2_with_bump_and_mode::( - inputs, ata_pubkey, bump, - ) -} - -/// Creates a compressible associated token account instruction v2 with specified bump and mode -fn create_compressible_associated_token_account2_with_bump_and_mode( - inputs: CreateCompressibleAssociatedTokenAccountInputs, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { - create_ata2_instruction_unified::( - inputs.payer, - inputs.owner, - inputs.mint, - ata_pubkey, - bump, - Some(( - inputs.pre_pay_num_epochs, - inputs.lamports_per_write, - inputs.rent_sponsor, - inputs.compressible_config, - inputs.token_account_version, - )), - ) -} - -/// Creates a basic associated token account instruction v2 (non-idempotent) -/// Owner and mint are passed as account infos instead of instruction data -pub fn create_associated_token_account2( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, -) -> LightTokenResult { - create_associated_token_account2_with_mode::(payer, owner, mint) -} - -/// Creates a basic associated token account instruction v2 (idempotent) -/// Owner and mint are passed as account infos instead of instruction data -pub fn create_associated_token_account2_idempotent( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, -) -> LightTokenResult { - create_associated_token_account2_with_mode::(payer, owner, mint) -} - -/// Creates a basic associated token account instruction v2 with compile-time idempotent mode -fn create_associated_token_account2_with_mode( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, -) -> LightTokenResult { - let (ata_pubkey, bump) = derive_associated_token_account(&owner, &mint); - create_associated_token_account2_with_bump_and_mode::( - payer, owner, mint, ata_pubkey, bump, - ) -} - -/// Creates a basic associated token account instruction v2 with specified bump and mode -fn create_associated_token_account2_with_bump_and_mode( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - ata_pubkey: Pubkey, - bump: u8, -) -> LightTokenResult { - create_ata2_instruction_unified::(payer, owner, mint, ata_pubkey, bump, None) -} - -/// Unified function to create ATA2 instructions with compile-time configuration -/// Account order: [owner, mint, fee_payer, ata, system_program, ...] -fn create_ata2_instruction_unified( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - ata_pubkey: Pubkey, - bump: u8, - compressible_config: Option<(u8, Option, Pubkey, Pubkey, TokenDataVersion)>, -) -> LightTokenResult { - let discriminator = if IDEMPOTENT { - CREATE_ATA2_IDEMPOTENT_DISCRIMINATOR - } else { - CREATE_ATA2_DISCRIMINATOR - }; - - let compressible_extension = if COMPRESSIBLE { - if let Some((pre_pay_num_epochs, lamports_per_write, _, _, token_account_version)) = - compressible_config - { - Some(CompressibleExtensionInstructionData { - token_account_version: token_account_version as u8, - rent_payment: pre_pay_num_epochs, - compression_only: 0, - write_top_up: lamports_per_write.unwrap_or(0), - compress_to_account_pubkey: None, - }) - } else { - return Err(LightTokenError::InvalidAccountData); - } - } else { - None - }; - - let instruction_data = CreateAssociatedTokenAccount2InstructionData { - bump, - compressible_config: compressible_extension, - }; - - let mut data = Vec::new(); - data.push(discriminator); - instruction_data - .serialize(&mut data) - .map_err(|_| LightTokenError::SerializationError)?; - - let mut accounts = vec![ - solana_instruction::AccountMeta::new_readonly(owner, false), - solana_instruction::AccountMeta::new_readonly(mint, false), - solana_instruction::AccountMeta::new(payer, true), - solana_instruction::AccountMeta::new(ata_pubkey, false), - solana_instruction::AccountMeta::new_readonly(Pubkey::new_from_array([0; 32]), false), - ]; - - if COMPRESSIBLE { - if let Some((_, _, rent_sponsor, compressible_config_account, _)) = compressible_config { - accounts.push(solana_instruction::AccountMeta::new_readonly( - compressible_config_account, - false, - )); - accounts.push(solana_instruction::AccountMeta::new(rent_sponsor, false)); - } - } - - Ok(Instruction { - program_id: Pubkey::from(light_token_types::COMPRESSED_TOKEN_PROGRAM_ID), - accounts, - data, - }) + .0 } /// CPI wrapper to create a compressible c-token associated token account. #[allow(clippy::too_many_arguments)] -pub fn create_associated_token_account<'info>( +pub fn create_associated_token_account_cpi<'info>( payer: AccountInfo<'info>, associated_token_account: AccountInfo<'info>, system_program: AccountInfo<'info>, @@ -413,7 +191,6 @@ pub fn create_associated_token_account<'info>( rent_sponsor: AccountInfo<'info>, authority: AccountInfo<'info>, mint: Pubkey, - bump: u8, pre_pay_num_epochs: Option, lamports_per_write: Option, ) -> std::result::Result<(), solana_program_error::ProgramError> { @@ -428,12 +205,7 @@ pub fn create_associated_token_account<'info>( token_account_version: TokenDataVersion::ShaFlat, }; - // TODO: switch to wrapper ixn using accounts instead of ixdata. - let ix = create_compressible_associated_token_account_with_bump( - inputs, - *associated_token_account.key, - bump, - )?; + let ix = create_compressible_associated_token_account(inputs)?; solana_cpi::invoke( &ix, @@ -451,7 +223,7 @@ pub fn create_associated_token_account<'info>( /// CPI wrapper to create a compressible c-token associated token account /// idempotently. #[allow(clippy::too_many_arguments)] -pub fn create_associated_token_account_idempotent<'info>( +pub fn create_associated_token_account_idempotent_cpi<'info>( payer: AccountInfo<'info>, associated_token_account: AccountInfo<'info>, system_program: AccountInfo<'info>, @@ -459,7 +231,6 @@ pub fn create_associated_token_account_idempotent<'info>( rent_sponsor: AccountInfo<'info>, authority: Pubkey, mint: Pubkey, - bump: u8, pre_pay_num_epochs: Option, lamports_per_write: Option, ) -> std::result::Result<(), solana_program_error::ProgramError> { @@ -474,11 +245,7 @@ pub fn create_associated_token_account_idempotent<'info>( token_account_version: TokenDataVersion::ShaFlat, }; - let ix = create_compressible_associated_token_account_with_bump_and_mode::( - inputs, - *associated_token_account.key, - bump, - )?; + let ix = create_compressible_associated_token_account_idempotent(inputs)?; solana_cpi::invoke( &ix, diff --git a/sdk-libs/token-sdk/src/instruction/create_ata.rs b/sdk-libs/token-sdk/src/instruction/create_ata.rs index 669b84f526..a76b21a150 100644 --- a/sdk-libs/token-sdk/src/instruction/create_ata.rs +++ b/sdk-libs/token-sdk/src/instruction/create_ata.rs @@ -14,7 +14,7 @@ use crate::instruction::{compressible::CompressibleParamsCpi, CompressibleParams const CREATE_ATA_DISCRIMINATOR: u8 = 100; const CREATE_ATA_IDEMPOTENT_DISCRIMINATOR: u8 = 102; -pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> (Pubkey, u8) { +pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> Pubkey { Pubkey::find_program_address( &[ owner.as_ref(), @@ -23,6 +23,7 @@ pub fn derive_associated_token_account(owner: &Pubkey, mint: &Pubkey) -> (Pubkey ], &Pubkey::from(light_token_interface::LIGHT_TOKEN_PROGRAM_ID), ) + .0 } /// # Create an associated ctoken account instruction: @@ -43,38 +44,18 @@ pub struct CreateAssociatedTokenAccount { pub owner: Pubkey, pub mint: Pubkey, pub associated_token_account: Pubkey, - pub bump: u8, pub compressible: CompressibleParams, pub idempotent: bool, } impl CreateAssociatedTokenAccount { pub fn new(payer: Pubkey, owner: Pubkey, mint: Pubkey) -> Self { - let (ata, bump) = derive_associated_token_account(&owner, &mint); + let ata = derive_associated_token_account(&owner, &mint); Self { payer, owner, mint, associated_token_account: ata, - bump, - compressible: CompressibleParams::default_ata(), - idempotent: false, - } - } - - pub fn new_with_bump( - payer: Pubkey, - owner: Pubkey, - mint: Pubkey, - associated_token_account: Pubkey, - bump: u8, - ) -> Self { - Self { - payer, - owner, - mint, - associated_token_account, - bump, compressible: CompressibleParams::default_ata(), idempotent: false, } @@ -92,7 +73,6 @@ impl CreateAssociatedTokenAccount { pub fn instruction(self) -> Result { let instruction_data = CreateAssociatedTokenAccountInstructionData { - bump: self.bump, compressible_config: Some(CompressibleExtensionInstructionData { token_account_version: self.compressible.token_account_version as u8, rent_payment: self.compressible.pre_pay_num_epochs, @@ -141,7 +121,6 @@ impl CreateAssociatedTokenAccount { /// owner: ctx.accounts.owner.to_account_info(), /// mint: ctx.accounts.mint.to_account_info(), /// ata: ctx.accounts.user_ata.to_account_info(), -/// bump: params.user_ata_bump, /// } /// .idempotent() /// .rent_free( @@ -156,7 +135,6 @@ pub struct CreateTokenAtaCpi<'info> { pub owner: AccountInfo<'info>, pub mint: AccountInfo<'info>, pub ata: AccountInfo<'info>, - pub bump: u8, } impl<'info> CreateTokenAtaCpi<'info> { @@ -177,7 +155,6 @@ impl<'info> CreateTokenAtaCpi<'info> { owner: self.owner, mint: self.mint, ata: self.ata, - bump: self.bump, idempotent: false, config, sponsor, @@ -197,7 +174,6 @@ impl<'info> CreateTokenAtaCpi<'info> { payer: self.payer, associated_token_account: self.ata, system_program, - bump: self.bump, compressible, idempotent: false, } @@ -223,7 +199,6 @@ impl<'info> CreateTokenAtaCpiIdempotent<'info> { owner: self.base.owner, mint: self.base.mint, ata: self.base.ata, - bump: self.base.bump, idempotent: true, config, sponsor, @@ -243,7 +218,6 @@ impl<'info> CreateTokenAtaCpiIdempotent<'info> { payer: self.base.payer, associated_token_account: self.base.ata, system_program, - bump: self.base.bump, compressible, idempotent: true, } @@ -257,7 +231,6 @@ pub struct CreateTokenAtaRentFreeCpi<'info> { owner: AccountInfo<'info>, mint: AccountInfo<'info>, ata: AccountInfo<'info>, - bump: u8, idempotent: bool, config: AccountInfo<'info>, sponsor: AccountInfo<'info>, @@ -273,7 +246,6 @@ impl<'info> CreateTokenAtaRentFreeCpi<'info> { payer: self.payer, associated_token_account: self.ata, system_program: self.system_program.clone(), - bump: self.bump, compressible: CompressibleParamsCpi::new_ata( self.config, self.sponsor, @@ -292,7 +264,6 @@ impl<'info> CreateTokenAtaRentFreeCpi<'info> { payer: self.payer, associated_token_account: self.ata, system_program: self.system_program.clone(), - bump: self.bump, compressible: CompressibleParamsCpi::new_ata( self.config, self.sponsor, @@ -311,7 +282,6 @@ struct InternalCreateAtaCpi<'info> { payer: AccountInfo<'info>, associated_token_account: AccountInfo<'info>, system_program: AccountInfo<'info>, - bump: u8, compressible: CompressibleParamsCpi<'info>, idempotent: bool, } @@ -323,7 +293,6 @@ impl<'info> InternalCreateAtaCpi<'info> { owner: *self.owner.key, mint: *self.mint.key, associated_token_account: *self.associated_token_account.key, - bump: self.bump, compressible: CompressibleParams { compressible_config: *self.compressible.compressible_config.key, rent_sponsor: *self.compressible.rent_sponsor.key, diff --git a/sdk-libs/token-sdk/src/instruction/decompress.rs b/sdk-libs/token-sdk/src/instruction/decompress.rs index 163ff6a05f..b2c7a3c83c 100644 --- a/sdk-libs/token-sdk/src/instruction/decompress.rs +++ b/sdk-libs/token-sdk/src/instruction/decompress.rs @@ -16,10 +16,7 @@ use solana_instruction::Instruction; use solana_program_error::ProgramError; use solana_pubkey::Pubkey; -use crate::{ - // compat::{AccountState, TokenData}, - instruction::derive_associated_token_account, -}; +use crate::utils::get_associated_token_address_and_bump; /// # Decompress compressed tokens to a cToken account /// @@ -106,7 +103,7 @@ impl Decompress { // For ATA decompress, derive the bump from wallet owner + mint // The signer is the wallet owner for ATAs let ata_bump = if is_ata { - let (_, bump) = derive_associated_token_account( + let (_, bump) = get_associated_token_address_and_bump( &self.signer, &Pubkey::from(self.token_data.mint.to_bytes()), ); diff --git a/sdk-libs/token-sdk/src/instruction/mod.rs b/sdk-libs/token-sdk/src/instruction/mod.rs index adc6df19e2..7e1f7d2971 100644 --- a/sdk-libs/token-sdk/src/instruction/mod.rs +++ b/sdk-libs/token-sdk/src/instruction/mod.rs @@ -60,7 +60,6 @@ //! owner: ctx.accounts.owner.to_account_info(), //! mint: ctx.accounts.mint.to_account_info(), //! ata: ctx.accounts.user_ata.to_account_info(), -//! bump, //! } //! .idempotent() //! .rent_free( diff --git a/sdk-libs/token-sdk/tests/address_derivation.rs b/sdk-libs/token-sdk/tests/address_derivation.rs index 183befcb3e..40e515dbfc 100644 --- a/sdk-libs/token-sdk/tests/address_derivation.rs +++ b/sdk-libs/token-sdk/tests/address_derivation.rs @@ -12,10 +12,10 @@ fn test_derive_ata_single_owner_mint() { let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let (ata, bump) = derive_associated_token_account(&owner, &mint); + let ata = derive_associated_token_account(&owner, &mint); // Verify the PDA is valid by checking we can recreate it - let (recreated_ata, recreated_bump) = Pubkey::find_program_address( + let (recreated_ata, _recreated_bump) = Pubkey::find_program_address( &[ owner.as_ref(), LIGHT_TOKEN_PROGRAM_ID.as_ref(), @@ -25,7 +25,6 @@ fn test_derive_ata_single_owner_mint() { ); assert_eq!(ata, recreated_ata); - assert_eq!(bump, recreated_bump); // ATA should not equal owner, mint, or program ID assert_ne!(ata, owner); @@ -40,8 +39,8 @@ fn test_derive_ata_different_owners_different_result() { let owner2 = Pubkey::new_unique(); let mint = Pubkey::new_unique(); - let (ata1, _bump1) = derive_associated_token_account(&owner1, &mint); - let (ata2, _bump2) = derive_associated_token_account(&owner2, &mint); + let ata1 = derive_associated_token_account(&owner1, &mint); + let ata2 = derive_associated_token_account(&owner2, &mint); // Different owners should produce different ATAs assert_ne!( @@ -57,8 +56,8 @@ fn test_derive_ata_different_mints_different_result() { let mint1 = Pubkey::new_unique(); let mint2 = Pubkey::new_unique(); - let (ata1, _bump1) = derive_associated_token_account(&owner, &mint1); - let (ata2, _bump2) = derive_associated_token_account(&owner, &mint2); + let ata1 = derive_associated_token_account(&owner, &mint1); + let ata2 = derive_associated_token_account(&owner, &mint2); // Different mints should produce different ATAs assert_ne!( @@ -67,22 +66,20 @@ fn test_derive_ata_different_mints_different_result() { ); } -/// Verify same inputs always produce same bump (deterministic derivation). +/// Verify same inputs always produce same result (deterministic derivation). #[test] -fn test_derive_ata_bump_consistency() { +fn test_derive_ata_consistency() { let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); // Derive multiple times - let (ata1, bump1) = derive_associated_token_account(&owner, &mint); - let (ata2, bump2) = derive_associated_token_account(&owner, &mint); - let (ata3, bump3) = derive_associated_token_account(&owner, &mint); + let ata1 = derive_associated_token_account(&owner, &mint); + let ata2 = derive_associated_token_account(&owner, &mint); + let ata3 = derive_associated_token_account(&owner, &mint); // All derivations should match assert_eq!(ata1, ata2); assert_eq!(ata2, ata3); - assert_eq!(bump1, bump2); - assert_eq!(bump2, bump3); } /// Verify SPL interface PDA derivation works correctly. @@ -134,7 +131,7 @@ fn test_spl_interface_pda_consistency() { /// Verify get_associated_token_address matches derive_associated_token_account. #[test] -fn test_get_associated_token_address_matches_with_bump() { +fn test_get_associated_token_address_matches_derive() { let owner = Pubkey::new_unique(); let mint = Pubkey::new_unique(); @@ -142,10 +139,10 @@ fn test_get_associated_token_address_matches_with_bump() { let ata = get_associated_token_address(&owner, &mint); // Get address with bump - let (ata_with_bump, bump) = get_associated_token_address_and_bump(&owner, &mint); + let (ata_with_bump, _bump) = get_associated_token_address_and_bump(&owner, &mint); // Both should match the derive function - let (derived_ata, derived_bump) = derive_associated_token_account(&owner, &mint); + let derived_ata = derive_associated_token_account(&owner, &mint); assert_eq!( ata, ata_with_bump, @@ -155,7 +152,6 @@ fn test_get_associated_token_address_matches_with_bump() { ata, derived_ata, "get_associated_token_address should match derive_associated_token_account" ); - assert_eq!(bump, derived_bump, "Bump from get_associated_token_address_and_bump should match derive_associated_token_account"); } /// Verify that known fixed pubkeys produce deterministic ATAs. @@ -166,7 +162,7 @@ fn test_derive_ata_seed_order() { let owner = Pubkey::new_from_array([1u8; 32]); let mint = Pubkey::new_from_array([2u8; 32]); - let (ata, _bump) = derive_associated_token_account(&owner, &mint); + let ata = derive_associated_token_account(&owner, &mint); // Verify with swapped order produces different result (confirms seed order matters) let (ata_swapped, _) = Pubkey::find_program_address( diff --git a/sdk-libs/token-sdk/tests/create_associated_token_account.rs b/sdk-libs/token-sdk/tests/create_associated_token_account.rs index 356f19edd7..fe8f653f6d 100644 --- a/sdk-libs/token-sdk/tests/create_associated_token_account.rs +++ b/sdk-libs/token-sdk/tests/create_associated_token_account.rs @@ -1,4 +1,4 @@ -use light_token::instruction::{derive_token_ata, CreateAssociatedTokenAccount}; +use light_token::instruction::CreateAssociatedTokenAccount; use solana_pubkey::Pubkey; const CREATE_ATA_DISCRIMINATOR: u8 = 100; @@ -43,30 +43,6 @@ fn test_instruction_data_consistency() { assert_eq!(ix_regular.program_id, ix_idempotent.program_id); } -#[test] -fn test_with_bump_functions() { - let payer = Pubkey::new_unique(); - let owner = Pubkey::new_unique(); - let mint = Pubkey::new_unique(); - let (ata_pubkey, bump) = derive_token_ata(&owner, &mint); - - 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, ata_pubkey, bump) - .idempotent() - .instruction() - .unwrap(); - assert_eq!( - ix_with_bump_idempotent.data[0], - CREATE_ATA_IDEMPOTENT_DISCRIMINATOR - ); -} - #[test] fn test_account_count() { let payer = Pubkey::new_unique(); diff --git a/sdk-tests/anchor-manual-test/src/all/derived.rs b/sdk-tests/anchor-manual-test/src/all/derived.rs index a5bf8b261b..92e263a285 100644 --- a/sdk-tests/anchor-manual-test/src/all/derived.rs +++ b/sdk-tests/anchor-manual-test/src/all/derived.rs @@ -8,10 +8,10 @@ use anchor_lang::prelude::*; use light_account::{ - derive_associated_token_account, prepare_compressed_account_on_init, CpiAccounts, - CpiAccountsConfig, CpiContextWriteAccounts, CreateMints, CreateMintsStaticAccounts, - CreateTokenAccountCpi, CreateTokenAtaCpi, InvokeLightSystemProgram, LightAccount, - LightFinalize, LightPreInit, LightSdkTypesError, PackedAddressTreeInfoExt, SingleMintParams, + prepare_compressed_account_on_init, CpiAccounts, CpiAccountsConfig, CpiContextWriteAccounts, + CreateMints, CreateMintsStaticAccounts, CreateTokenAccountCpi, CreateTokenAtaCpi, + InvokeLightSystemProgram, LightAccount, LightFinalize, LightPreInit, LightSdkTypesError, + PackedAddressTreeInfoExt, SingleMintParams, }; use light_compressed_account::instruction_data::{ cpi_context::CompressedCpiContext, with_account_info::InstructionDataInvokeCpiWithAccountInfo, @@ -224,9 +224,6 @@ impl<'info> LightPreInit, CreateAllParams> for CreateAllAccou // 7. Create ATA via CreateTokenAtaCpi // ==================================================================== { - let (_, ata_bump) = - derive_associated_token_account(self.ata_owner.key, self.mint.key); - let payer_info = self.payer.to_account_info(); let mint_info = self.mint.to_account_info(); let user_ata_info = self.user_ata.to_account_info(); @@ -236,7 +233,6 @@ impl<'info> LightPreInit, CreateAllParams> for CreateAllAccou owner: &self.ata_owner, mint: &mint_info, ata: &user_ata_info, - bump: ata_bump, } .rent_free( &self.compressible_config, diff --git a/sdk-tests/anchor-manual-test/src/ata/derived.rs b/sdk-tests/anchor-manual-test/src/ata/derived.rs index 62b0183e44..300899f8fa 100644 --- a/sdk-tests/anchor-manual-test/src/ata/derived.rs +++ b/sdk-tests/anchor-manual-test/src/ata/derived.rs @@ -1,10 +1,7 @@ //! Derived code - what the macro would generate for associated token accounts. use anchor_lang::prelude::*; -use light_account::{ - derive_associated_token_account, CreateTokenAtaCpi, LightFinalize, LightPreInit, - LightSdkTypesError, -}; +use light_account::{CreateTokenAtaCpi, LightFinalize, LightPreInit, LightSdkTypesError}; use solana_account_info::AccountInfo; use super::accounts::{CreateAtaAccounts, CreateAtaParams}; @@ -20,9 +17,6 @@ impl<'info> LightPreInit, CreateAtaParams> for CreateAtaAccou _params: &CreateAtaParams, ) -> std::result::Result { let inner = || -> std::result::Result { - // Derive the ATA bump on-chain - let (_, bump) = derive_associated_token_account(self.ata_owner.key, self.mint.key); - // Create ATA via CPI with idempotent + rent-free mode // NOTE: Unlike token vaults, ATAs use .invoke() not .invoke_signed() // because ATAs are derived from [owner, token_program, mint], not program PDAs @@ -34,7 +28,6 @@ impl<'info> LightPreInit, CreateAtaParams> for CreateAtaAccou owner: &self.ata_owner, mint: &self.mint, ata: &user_ata_info, - bump, } .idempotent() // Safe: won't fail if ATA already exists .rent_free( diff --git a/sdk-tests/anchor-manual-test/tests/all.rs b/sdk-tests/anchor-manual-test/tests/all.rs index 8ad3a53a20..511c18e11a 100644 --- a/sdk-tests/anchor-manual-test/tests/all.rs +++ b/sdk-tests/anchor-manual-test/tests/all.rs @@ -62,7 +62,7 @@ async fn test_create_all() { // ATA let ata_owner = Keypair::new(); - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); // ========== Get proof for 2 PDAs + 1 Mint ========== let proof_result = get_create_accounts_proof( diff --git a/sdk-tests/anchor-manual-test/tests/ata.rs b/sdk-tests/anchor-manual-test/tests/ata.rs index 488470f783..454e920b89 100644 --- a/sdk-tests/anchor-manual-test/tests/ata.rs +++ b/sdk-tests/anchor-manual-test/tests/ata.rs @@ -27,7 +27,7 @@ async fn test_create_ata() { let ata_owner = Keypair::new(); // Derive ATA address using light-token's standard derivation - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); let params = CreateAtaParams::default(); @@ -75,7 +75,7 @@ async fn test_create_ata_idempotent() { let mint = shared::create_test_mint(&mut rpc, &payer).await; let ata_owner = Keypair::new(); - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); let params = CreateAtaParams::default(); diff --git a/sdk-tests/anchor-semi-manual-test/src/instruction_accounts.rs b/sdk-tests/anchor-semi-manual-test/src/instruction_accounts.rs index e4b63460b0..aacd0af29d 100644 --- a/sdk-tests/anchor-semi-manual-test/src/instruction_accounts.rs +++ b/sdk-tests/anchor-semi-manual-test/src/instruction_accounts.rs @@ -53,7 +53,6 @@ pub struct CreatePda<'info> { #[derive(AnchorSerialize, AnchorDeserialize, Clone)] pub struct CreateAtaParams { pub create_accounts_proof: CreateAccountsProof, - pub ata_bump: u8, } /// Accounts struct for testing single ATA creation. @@ -71,7 +70,7 @@ pub struct CreateAta<'info> { /// ATA account - created via LightFinalize CPI. #[account(mut)] - #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint, associated_token::bump = params.ata_bump)] + #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint)] pub ata: UncheckedAccount<'info>, #[account(address = LIGHT_TOKEN_CONFIG)] @@ -315,7 +314,6 @@ pub struct CreateTwoMints<'info> { pub struct CreateAllParams { pub create_accounts_proof: CreateAccountsProof, pub owner: Pubkey, - pub ata_bump: u8, pub vault_bump: u8, pub mint_signer_bump_a: u8, pub mint_signer_bump_b: u8, @@ -365,7 +363,7 @@ pub struct CreateAll<'info> { pub ata_owner: AccountInfo<'info>, #[account(mut)] - #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint, associated_token::bump = params.ata_bump)] + #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint)] pub ata: UncheckedAccount<'info>, // -- Token vault -- diff --git a/sdk-tests/anchor-semi-manual-test/tests/stress_test.rs b/sdk-tests/anchor-semi-manual-test/tests/stress_test.rs index 976695115a..340726eb6e 100644 --- a/sdk-tests/anchor-semi-manual-test/tests/stress_test.rs +++ b/sdk-tests/anchor-semi-manual-test/tests/stress_test.rs @@ -112,7 +112,7 @@ async fn setup() -> (StressTestContext, TestPdas) { let (zc_record_pda, _) = Pubkey::find_program_address(&[RECORD_SEED, owner.as_ref()], &program_id); let ata_owner = payer.pubkey(); - let (ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &ata_mint); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &ata_mint); let (vault_authority, _) = Pubkey::find_program_address(&[VAULT_AUTH_SEED], &program_id); let (vault, vault_bump) = Pubkey::find_program_address(&[VAULT_SEED, vault_mint.as_ref()], &program_id); @@ -169,7 +169,6 @@ async fn setup() -> (StressTestContext, TestPdas) { params: CreateAllParams { create_accounts_proof: proof_result.create_accounts_proof, owner, - ata_bump, vault_bump, mint_signer_bump_a, mint_signer_bump_b, diff --git a/sdk-tests/anchor-semi-manual-test/tests/test_create_all.rs b/sdk-tests/anchor-semi-manual-test/tests/test_create_all.rs index d819332045..b4c91db9c4 100644 --- a/sdk-tests/anchor-semi-manual-test/tests/test_create_all.rs +++ b/sdk-tests/anchor-semi-manual-test/tests/test_create_all.rs @@ -43,7 +43,7 @@ async fn test_create_all_derive() { // ATA let ata_owner = payer.pubkey(); - let (ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &ata_mint); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &ata_mint); // Token vault let (vault_authority, _) = Pubkey::find_program_address(&[VAULT_AUTH_SEED], &program_id); @@ -106,7 +106,6 @@ async fn test_create_all_derive() { params: CreateAllParams { create_accounts_proof: proof_result.create_accounts_proof, owner, - ata_bump, vault_bump, mint_signer_bump_a, mint_signer_bump_b, diff --git a/sdk-tests/anchor-semi-manual-test/tests/test_create_ata.rs b/sdk-tests/anchor-semi-manual-test/tests/test_create_ata.rs index f13586606d..5953b31e71 100644 --- a/sdk-tests/anchor-semi-manual-test/tests/test_create_ata.rs +++ b/sdk-tests/anchor-semi-manual-test/tests/test_create_ata.rs @@ -20,7 +20,7 @@ async fn test_create_ata_derive() { let (mint, _mint_seed) = shared::setup_create_mint(&mut rpc, &payer, payer.pubkey(), 9).await; let ata_owner = payer.pubkey(); - let (ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); let proof_result = get_create_accounts_proof(&rpc, &program_id, vec![]) .await @@ -40,7 +40,6 @@ async fn test_create_ata_derive() { let instruction_data = anchor_semi_manual_test::instruction::CreateAta { params: CreateAtaParams { create_accounts_proof: proof_result.create_accounts_proof, - ata_bump, }, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs index eec8c1c643..979530e4b6 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/amm_test/initialize.rs @@ -24,7 +24,6 @@ pub struct InitializeParams { pub open_time: u64, pub create_accounts_proof: CreateAccountsProof, pub lp_mint_signer_bump: u8, - pub creator_lp_token_bump: u8, pub authority_bump: u8, } @@ -241,7 +240,6 @@ pub fn process_initialize_pool<'info>( owner: &owner_info, mint: &mint_info, ata: &ata_info, - bump: params.creator_lp_token_bump, } .idempotent() .rent_free(&config_info, &sponsor_info, &system_info) diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs index 85df44befa..12a9fc60f5 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instruction_accounts.rs @@ -11,7 +11,7 @@ pub struct FullAutoWithMintParams { pub session_id: u64, pub mint_signer_bump: u8, pub vault_bump: u8, - pub user_ata_bump: u8, + pub vault_mint_amount: u64, pub user_ata_mint_amount: u64, } diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs index 7ba4017a37..a62f978f6f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata.rs @@ -15,8 +15,6 @@ use light_account::{ #[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug)] pub struct D10SingleAtaParams { pub create_accounts_proof: CreateAccountsProof, - /// Bump for the ATA PDA - pub ata_bump: u8, } /// Tests #[light_account(init, associated_token, ...)] automatic code generation. @@ -35,7 +33,7 @@ pub struct D10SingleAta<'info> { /// ATA account - macro should generate creation code. #[account(mut)] - #[light_account(init, associated_token::authority = d10_ata_owner, associated_token::mint = d10_ata_mint, associated_token::bump = params.ata_bump)] + #[light_account(init, associated_token::authority = d10_ata_owner, associated_token::mint = d10_ata_mint)] pub d10_single_ata: UncheckedAccount<'info>, #[account(address = LIGHT_TOKEN_CONFIG)] diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata_markonly.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata_markonly.rs index ff3ba2ff08..89d03e7a66 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata_markonly.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d10_token_accounts/single_ata_markonly.rs @@ -11,10 +11,7 @@ use light_account::{ }; #[derive(AnchorSerialize, AnchorDeserialize, Clone, Debug)] -pub struct D10SingleAtaMarkonlyParams { - /// Bump for the ATA PDA - pub ata_bump: u8, -} +pub struct D10SingleAtaMarkonlyParams {} /// Tests #[light_account(associated_token::...)] mark-only mode (NO init keyword). /// The macro generates no-op LightPreInit/LightFinalize impls. diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d11_zero_copy/with_ata.rs b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d11_zero_copy/with_ata.rs index 08ccdb26a1..92fbac5f5a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d11_zero_copy/with_ata.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/instructions/d11_zero_copy/with_ata.rs @@ -17,8 +17,6 @@ pub const D11_ZC_ATA_RECORD_SEED: &[u8] = b"d11_zc_ata_record"; pub struct D11ZcWithAtaParams { pub create_accounts_proof: CreateAccountsProof, pub owner: Pubkey, - /// Bump for the ATA (needed for idempotent creation). - pub ata_bump: u8, } /// Tests `#[light_account(init, zero_copy)]` combined with ATA creation. @@ -55,7 +53,7 @@ pub struct D11ZcWithAta<'info> { /// User ATA - macro should generate idempotent creation code. #[account(mut)] - #[light_account(init, associated_token::authority = d11_ata_owner, associated_token::mint = d11_ata_mint, associated_token::bump = params.ata_bump)] + #[light_account(init, associated_token::authority = d11_ata_owner, associated_token::mint = d11_ata_mint)] pub d11_user_ata: UncheckedAccount<'info>, #[account(address = LIGHT_TOKEN_CONFIG)] diff --git a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs index a663bf7520..dc7b4350af 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/src/lib.rs @@ -371,7 +371,6 @@ pub mod csdk_anchor_full_derived_test { owner: &owner_info, mint: &mint_info, ata: &ata_info, - bump: params.user_ata_bump, } .idempotent() .rent_free(&config_info, &sponsor_info, &system_info) @@ -1447,7 +1446,7 @@ pub mod csdk_anchor_full_derived_test { /// skipping the CPI call. User manually calls CreateTokenAtaCpi in handler. pub fn d10_single_ata_markonly<'info>( ctx: Context<'_, '_, '_, 'info, D10SingleAtaMarkonly<'info>>, - params: D10SingleAtaMarkonlyParams, + _params: D10SingleAtaMarkonlyParams, ) -> Result<()> { use light_account::CreateTokenAtaCpi; @@ -1464,7 +1463,6 @@ pub mod csdk_anchor_full_derived_test { owner: &__owner, mint: &__mint, ata: &__ata, - bump: params.ata_bump, } .idempotent() .rent_free(&__config, &__sponsor, &__sys) diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_stress_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_stress_test.rs index ba1b8026f5..1bd04c0cbc 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_stress_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_stress_test.rs @@ -62,7 +62,6 @@ struct AmmPdas { lp_mint_signer_bump: u8, lp_mint: Pubkey, creator_lp_token: Pubkey, - creator_lp_token_bump: u8, } /// Context for AMM tests @@ -220,7 +219,7 @@ fn derive_amm_pdas( let (lp_mint, _) = find_mint_address(&lp_mint_signer); - let (creator_lp_token, creator_lp_token_bump) = + let (creator_lp_token, _creator_lp_token_bump) = get_associated_token_address_and_bump(creator, &lp_mint); AmmPdas { @@ -238,7 +237,6 @@ fn derive_amm_pdas( lp_mint_signer_bump, lp_mint, creator_lp_token, - creator_lp_token_bump, } } @@ -372,7 +370,6 @@ async fn initialize_pool(ctx: &mut AmmTestContext, pdas: &AmmPdas) { open_time: 0u64, create_accounts_proof: proof_result.create_accounts_proof, lp_mint_signer_bump: pdas.lp_mint_signer_bump, - creator_lp_token_bump: pdas.creator_lp_token_bump, authority_bump: pdas.authority_bump, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs index c3fc87673b..c30ab6369a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/amm_test.rs @@ -60,7 +60,6 @@ struct AmmPdas { lp_mint_signer_bump: u8, lp_mint: Pubkey, creator_lp_token: Pubkey, - creator_lp_token_bump: u8, } /// Context for AMM tests @@ -215,7 +214,7 @@ fn derive_amm_pdas( let (lp_mint, _) = find_mint_address(&lp_mint_signer); // Creator LP token ATA: using get_associated_token_address_and_bump - let (creator_lp_token, creator_lp_token_bump) = + let (creator_lp_token, _creator_lp_token_bump) = get_associated_token_address_and_bump(creator, &lp_mint); AmmPdas { @@ -233,7 +232,6 @@ fn derive_amm_pdas( lp_mint_signer_bump, lp_mint, creator_lp_token, - creator_lp_token_bump, } } @@ -272,7 +270,6 @@ async fn test_amm_full_lifecycle() { open_time, create_accounts_proof: proof_result.create_accounts_proof, lp_mint_signer_bump: pdas.lp_mint_signer_bump, - creator_lp_token_bump: pdas.creator_lp_token_bump, authority_bump: pdas.authority_bump, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs index 97c01e9a24..747c75ce32 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/basic_test.rs @@ -91,7 +91,7 @@ async fn test_create_pdas_and_mint_auto() { let (vault_pda, vault_bump) = Pubkey::find_program_address(&[VAULT_SEED, mint_pda.as_ref()], &program_id); let (vault_authority_pda, _) = Pubkey::find_program_address(&[b"vault_authority"], &program_id); - let (user_ata_pda, user_ata_bump) = + let (user_ata_pda, _user_ata_bump) = get_associated_token_address_and_bump(&payer.pubkey(), &mint_pda); let (user_record_pda, _) = Pubkey::find_program_address( @@ -175,7 +175,6 @@ async fn test_create_pdas_and_mint_auto() { session_id, mint_signer_bump, vault_bump, - user_ata_bump, vault_mint_amount, user_ata_mint_amount, }, diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs index 96abb0c3c2..fd04ba17db 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/d10_token_accounts_test.rs @@ -183,7 +183,7 @@ async fn test_d10_single_ata() { let ata_owner = ctx.payer.pubkey(); // Derive the ATA address using Light Token SDK's derivation - let (d10_single_ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let d10_single_ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof (no PDA accounts for ATA-only instruction) let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) @@ -205,7 +205,6 @@ async fn test_d10_single_ata() { let instruction_data = csdk_anchor_full_derived_test::instruction::D10SingleAta { params: D10SingleAtaParams { create_accounts_proof: proof_result.create_accounts_proof, - ata_bump, }, }; @@ -267,7 +266,7 @@ async fn test_d10_single_ata_idempotent_creation() { let ata_owner = ctx.payer.pubkey(); // Derive the ATA address - let (d10_single_ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let d10_single_ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof for first creation let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) @@ -289,7 +288,6 @@ async fn test_d10_single_ata_idempotent_creation() { let instruction_data = csdk_anchor_full_derived_test::instruction::D10SingleAta { params: D10SingleAtaParams { create_accounts_proof: proof_result.create_accounts_proof.clone(), - ata_bump, }, }; @@ -335,7 +333,6 @@ async fn test_d10_single_ata_idempotent_creation() { let instruction_data_2 = csdk_anchor_full_derived_test::instruction::D10SingleAta { params: D10SingleAtaParams { create_accounts_proof: proof_result_2.create_accounts_proof, - ata_bump, }, }; @@ -384,8 +381,7 @@ async fn test_d10_single_ata_markonly() { let ata_owner = Keypair::new().pubkey(); // Derive the ATA address using Light Token SDK's derivation - let (d10_markonly_ata, ata_bump) = - light_token::instruction::derive_token_ata(&ata_owner, &mint); + let d10_markonly_ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof (no PDA accounts for ATA-only instruction) let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) @@ -405,7 +401,7 @@ async fn test_d10_single_ata_markonly() { }; let instruction_data = csdk_anchor_full_derived_test::instruction::D10SingleAtaMarkonly { - params: D10SingleAtaMarkonlyParams { ata_bump }, + _params: D10SingleAtaMarkonlyParams {}, }; let instruction = Instruction { @@ -450,8 +446,7 @@ async fn test_d10_single_ata_markonly_lifecycle() { let ata_owner = ata_owner_keypair.pubkey(); // Derive the ATA address - let (d10_markonly_ata, ata_bump) = - light_token::instruction::derive_token_ata(&ata_owner, &mint); + let d10_markonly_ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); // PHASE 1: Create ATA let proof_result = get_create_accounts_proof(&ctx.rpc, &ctx.program_id, vec![]) @@ -470,7 +465,7 @@ async fn test_d10_single_ata_markonly_lifecycle() { }; let instruction_data = csdk_anchor_full_derived_test::instruction::D10SingleAtaMarkonly { - params: D10SingleAtaMarkonlyParams { ata_bump }, + _params: D10SingleAtaMarkonlyParams {}, }; let instruction = Instruction { diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/d11_zero_copy_test.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/d11_zero_copy_test.rs index ed5ff76fe8..7950bbee7a 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/d11_zero_copy_test.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/d11_zero_copy_test.rs @@ -323,7 +323,7 @@ async fn test_d11_zc_with_ata() { // Derive PDAs let (zc_pda, _) = Pubkey::find_program_address(&[D11_ZC_ATA_RECORD_SEED, owner.as_ref()], &ctx.program_id); - let (ata_pda, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let ata_pda = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof for PDA let proof_result = get_create_accounts_proof( @@ -353,7 +353,6 @@ async fn test_d11_zc_with_ata() { params: D11ZcWithAtaParams { create_accounts_proof: proof_result.create_accounts_proof, owner, - ata_bump, }, }; diff --git a/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs b/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs index 83a2fc7356..5ccd85b84f 100644 --- a/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs +++ b/sdk-tests/csdk-anchor-full-derived-test/tests/shared.rs @@ -316,7 +316,7 @@ pub async fn setup_create_mint( let mut ata_pubkeys = Vec::with_capacity(recipients.len()); for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint); diff --git a/sdk-tests/pinocchio-light-program-test/src/all/processor.rs b/sdk-tests/pinocchio-light-program-test/src/all/processor.rs index 3412d5bc1c..ba2dc8b579 100644 --- a/sdk-tests/pinocchio-light-program-test/src/all/processor.rs +++ b/sdk-tests/pinocchio-light-program-test/src/all/processor.rs @@ -1,9 +1,8 @@ use light_account_pinocchio::{ - derive_associated_token_account, prepare_compressed_account_on_init, CompressedCpiContext, - CpiAccounts, CpiAccountsConfig, CpiContextWriteAccounts, CreateMints, - CreateMintsStaticAccounts, CreateTokenAccountCpi, CreateTokenAtaCpi, - InstructionDataInvokeCpiWithAccountInfo, InvokeLightSystemProgram, LightAccount, LightConfig, - LightSdkTypesError, PackedAddressTreeInfoExt, SingleMintParams, + prepare_compressed_account_on_init, CompressedCpiContext, CpiAccounts, CpiAccountsConfig, + CpiContextWriteAccounts, CreateMints, CreateMintsStaticAccounts, CreateTokenAccountCpi, + CreateTokenAtaCpi, InstructionDataInvokeCpiWithAccountInfo, InvokeLightSystemProgram, + LightAccount, LightConfig, LightSdkTypesError, PackedAddressTreeInfoExt, SingleMintParams, }; use pinocchio::{ account_info::AccountInfo, @@ -192,14 +191,11 @@ pub fn process( // 7. Create ATA { - let (_, ata_bump) = derive_associated_token_account(ctx.ata_owner.key(), ctx.mint.key()); - CreateTokenAtaCpi { payer: ctx.payer, owner: ctx.ata_owner, mint: ctx.mint, ata: ctx.user_ata, - bump: ata_bump, } .rent_free( ctx.compressible_config, diff --git a/sdk-tests/pinocchio-light-program-test/src/ata/processor.rs b/sdk-tests/pinocchio-light-program-test/src/ata/processor.rs index d00a03c354..dbad0084c8 100644 --- a/sdk-tests/pinocchio-light-program-test/src/ata/processor.rs +++ b/sdk-tests/pinocchio-light-program-test/src/ata/processor.rs @@ -1,6 +1,4 @@ -use light_account_pinocchio::{ - derive_associated_token_account, CreateTokenAtaCpi, LightSdkTypesError, -}; +use light_account_pinocchio::{CreateTokenAtaCpi, LightSdkTypesError}; use pinocchio::account_info::AccountInfo; use super::accounts::{CreateAtaAccounts, CreateAtaParams}; @@ -10,14 +8,11 @@ pub fn process( _params: &CreateAtaParams, _remaining_accounts: &[AccountInfo], ) -> Result<(), LightSdkTypesError> { - let (_, bump) = derive_associated_token_account(ctx.ata_owner.key(), ctx.mint.key()); - CreateTokenAtaCpi { payer: ctx.payer, owner: ctx.ata_owner, mint: ctx.mint, ata: ctx.user_ata, - bump, } .idempotent() .rent_free( diff --git a/sdk-tests/pinocchio-light-program-test/tests/stress_test.rs b/sdk-tests/pinocchio-light-program-test/tests/stress_test.rs index 916cf02617..3779e20a5a 100644 --- a/sdk-tests/pinocchio-light-program-test/tests/stress_test.rs +++ b/sdk-tests/pinocchio-light-program-test/tests/stress_test.rs @@ -123,7 +123,7 @@ async fn setup() -> (StressTestContext, TestPdas) { // ATA (uses the mint we're creating) let ata_owner = payer.pubkey(); - let (ata, _) = light_token::instruction::derive_token_ata(&ata_owner, &mint_pda); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &mint_pda); // Create all accounts in one instruction let proof_result = get_create_accounts_proof( diff --git a/sdk-tests/pinocchio-light-program-test/tests/test_create_all.rs b/sdk-tests/pinocchio-light-program-test/tests/test_create_all.rs index 0d413a2bdc..c0b9742f13 100644 --- a/sdk-tests/pinocchio-light-program-test/tests/test_create_all.rs +++ b/sdk-tests/pinocchio-light-program-test/tests/test_create_all.rs @@ -52,7 +52,7 @@ async fn test_create_all_derive() { // ATA (uses the mint we're creating) let ata_owner = payer.pubkey(); - let (ata, _) = light_token::instruction::derive_token_ata(&ata_owner, &mint_pda); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &mint_pda); // Build proof inputs for PDA accounts and the mint let proof_result = get_create_accounts_proof( diff --git a/sdk-tests/pinocchio-light-program-test/tests/test_create_ata.rs b/sdk-tests/pinocchio-light-program-test/tests/test_create_ata.rs index 0e2aa6d0f9..229bde9dac 100644 --- a/sdk-tests/pinocchio-light-program-test/tests/test_create_ata.rs +++ b/sdk-tests/pinocchio-light-program-test/tests/test_create_ata.rs @@ -21,7 +21,7 @@ async fn test_create_ata_derive() { let (mint, _mint_seed) = shared::setup_create_mint(&mut rpc, &payer, payer.pubkey(), 9).await; let ata_owner = payer.pubkey(); - let (ata, _ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); let proof_result = get_create_accounts_proof(&rpc, &program_id, vec![]) .await diff --git a/sdk-tests/pinocchio-manual-test/src/all/derived.rs b/sdk-tests/pinocchio-manual-test/src/all/derived.rs index 84a11085cc..890eb14156 100644 --- a/sdk-tests/pinocchio-manual-test/src/all/derived.rs +++ b/sdk-tests/pinocchio-manual-test/src/all/derived.rs @@ -7,10 +7,10 @@ //! - 1 ATA via `CreateTokenAtaCpi` use light_account_pinocchio::{ - derive_associated_token_account, prepare_compressed_account_on_init, CpiAccounts, - CpiAccountsConfig, CpiContextWriteAccounts, CreateMints, CreateMintsStaticAccounts, - CreateTokenAccountCpi, CreateTokenAtaCpi, InvokeLightSystemProgram, LightAccount, - LightFinalize, LightPreInit, LightSdkTypesError, PackedAddressTreeInfoExt, SingleMintParams, + prepare_compressed_account_on_init, CpiAccounts, CpiAccountsConfig, CpiContextWriteAccounts, + CreateMints, CreateMintsStaticAccounts, CreateTokenAccountCpi, CreateTokenAtaCpi, + InvokeLightSystemProgram, LightAccount, LightFinalize, LightPreInit, LightSdkTypesError, + PackedAddressTreeInfoExt, SingleMintParams, }; use light_compressed_account::instruction_data::{ cpi_context::CompressedCpiContext, with_account_info::InstructionDataInvokeCpiWithAccountInfo, @@ -226,15 +226,11 @@ impl LightPreInit for CreateAllAccounts<'_> { // 7. Create ATA via CreateTokenAtaCpi // ==================================================================== { - let (_, ata_bump) = - derive_associated_token_account(self.ata_owner.key(), self.mint.key()); - CreateTokenAtaCpi { payer: self.payer, owner: self.ata_owner, mint: self.mint, ata: self.user_ata, - bump: ata_bump, } .rent_free( self.compressible_config, diff --git a/sdk-tests/pinocchio-manual-test/src/ata/derived.rs b/sdk-tests/pinocchio-manual-test/src/ata/derived.rs index a11e82cf7e..f743a8271f 100644 --- a/sdk-tests/pinocchio-manual-test/src/ata/derived.rs +++ b/sdk-tests/pinocchio-manual-test/src/ata/derived.rs @@ -1,9 +1,6 @@ //! Derived code - what the macro would generate for associated token accounts. -use light_account_pinocchio::{ - derive_associated_token_account, CreateTokenAtaCpi, LightFinalize, LightPreInit, - LightSdkTypesError, -}; +use light_account_pinocchio::{CreateTokenAtaCpi, LightFinalize, LightPreInit, LightSdkTypesError}; use pinocchio::account_info::AccountInfo; use super::accounts::{CreateAtaAccounts, CreateAtaParams}; @@ -19,9 +16,6 @@ impl LightPreInit for CreateAtaAccounts<'_> { _params: &CreateAtaParams, ) -> std::result::Result { let inner = || -> std::result::Result { - // Derive the ATA bump on-chain - let (_, bump) = derive_associated_token_account(self.ata_owner.key(), self.mint.key()); - // Create ATA via CPI with idempotent + rent-free mode // NOTE: Unlike token vaults, ATAs use .invoke() not .invoke_signed() // because ATAs are derived from [owner, token_program, mint], not program PDAs @@ -30,7 +24,6 @@ impl LightPreInit for CreateAtaAccounts<'_> { owner: self.ata_owner, mint: self.mint, ata: self.user_ata, - bump, } .idempotent() // Safe: won't fail if ATA already exists .rent_free( diff --git a/sdk-tests/pinocchio-manual-test/tests/all.rs b/sdk-tests/pinocchio-manual-test/tests/all.rs index c3b1c2d748..f49f1be613 100644 --- a/sdk-tests/pinocchio-manual-test/tests/all.rs +++ b/sdk-tests/pinocchio-manual-test/tests/all.rs @@ -64,7 +64,7 @@ async fn test_create_all() { // ATA let ata_owner = Keypair::new(); - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); // ========== Get proof for 2 PDAs + 1 Mint ========== let proof_result = get_create_accounts_proof( diff --git a/sdk-tests/pinocchio-manual-test/tests/ata.rs b/sdk-tests/pinocchio-manual-test/tests/ata.rs index eda13b3b58..4b2eb4b49c 100644 --- a/sdk-tests/pinocchio-manual-test/tests/ata.rs +++ b/sdk-tests/pinocchio-manual-test/tests/ata.rs @@ -27,7 +27,7 @@ async fn test_create_ata() { let ata_owner = Keypair::new(); // Derive ATA address using light-token's standard derivation - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); let params = CreateAtaParams::default(); @@ -83,7 +83,7 @@ async fn test_create_ata_idempotent() { let mint = shared::create_test_mint(&mut rpc, &payer).await; let ata_owner = Keypair::new(); - let (user_ata, _) = derive_associated_token_account(&ata_owner.pubkey(), &mint); + let user_ata = derive_associated_token_account(&ata_owner.pubkey(), &mint); let params = CreateAtaParams::default(); diff --git a/sdk-tests/sdk-light-token-pinocchio/src/create_ata.rs b/sdk-tests/sdk-light-token-pinocchio/src/create_ata.rs index ad36a0912b..ce41a1deda 100644 --- a/sdk-tests/sdk-light-token-pinocchio/src/create_ata.rs +++ b/sdk-tests/sdk-light-token-pinocchio/src/create_ata.rs @@ -7,7 +7,6 @@ use crate::{ATA_SEED, ID}; /// Instruction data for create ATA (owner and mint passed as accounts) #[derive(BorshSerialize, BorshDeserialize, Debug)] pub struct CreateAtaData { - pub bump: u8, pub pre_pay_num_epochs: u8, pub lamports_per_write: u32, } @@ -24,7 +23,7 @@ pub struct CreateAtaData { /// - accounts[6]: rent_sponsor pub fn process_create_ata_invoke( accounts: &[AccountInfo], - data: CreateAtaData, + _data: CreateAtaData, ) -> Result<(), ProgramError> { if accounts.len() < 7 { return Err(ProgramError::NotEnoughAccountKeys); @@ -35,7 +34,6 @@ pub fn process_create_ata_invoke( owner: &accounts[0], mint: &accounts[1], ata: &accounts[3], - bump: data.bump, } .rent_free( &accounts[5], // compressible_config @@ -60,7 +58,7 @@ pub fn process_create_ata_invoke( /// - accounts[6]: rent_sponsor pub fn process_create_ata_invoke_signed( accounts: &[AccountInfo], - data: CreateAtaData, + _data: CreateAtaData, ) -> Result<(), ProgramError> { if accounts.len() < 7 { return Err(ProgramError::NotEnoughAccountKeys); @@ -81,7 +79,6 @@ pub fn process_create_ata_invoke_signed( owner: &accounts[0], mint: &accounts[1], ata: &accounts[3], - bump: data.bump, } .rent_free( &accounts[5], // compressible_config diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/shared/mod.rs b/sdk-tests/sdk-light-token-pinocchio/tests/shared/mod.rs index a0a650659a..7e35bdd140 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/shared/mod.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/shared/mod.rs @@ -102,7 +102,7 @@ pub async fn setup_create_mint( let mut ata_pubkeys = Vec::with_capacity(recipients.len()); for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint); @@ -223,7 +223,7 @@ pub async fn setup_create_mint_with_freeze_authority( let mut ata_pubkeys = Vec::with_capacity(recipients.len()); for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint); @@ -362,7 +362,7 @@ pub async fn setup_create_mint_with_compression_only( }; for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint) diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/test_create_ata.rs b/sdk-tests/sdk-light-token-pinocchio/tests/test_create_ata.rs index 3787f3d133..f7d6eae111 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/test_create_ata.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/test_create_ata.rs @@ -34,11 +34,10 @@ async fn test_create_ata_invoke() { // Derive the ATA address let owner = payer.pubkey(); use light_token::instruction::derive_token_ata; - let (ata_address, bump) = derive_token_ata(&owner, &mint_pda); + let ata_address = derive_token_ata(&owner, &mint_pda); // Build CreateAtaData (owner and mint are passed as accounts) let create_ata_data = CreateAtaData { - bump, pre_pay_num_epochs: 2, lamports_per_write: 1, }; @@ -120,11 +119,10 @@ async fn test_create_ata_invoke_signed() { // Derive the ATA address for the PDA owner use light_token::instruction::derive_token_ata; - let (ata_address, bump) = derive_token_ata(&pda_owner, &mint_pda); + let ata_address = derive_token_ata(&pda_owner, &mint_pda); // Build CreateAtaData with PDA as owner (owner and mint are passed as accounts) let create_ata_data = CreateAtaData { - bump, pre_pay_num_epochs: 2, lamports_per_write: 1, }; diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/test_ctoken_mint_to.rs b/sdk-tests/sdk-light-token-pinocchio/tests/test_ctoken_mint_to.rs index 11458e67ea..7c29d030b1 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/test_ctoken_mint_to.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/test_ctoken_mint_to.rs @@ -202,8 +202,7 @@ async fn test_ctoken_mint_to_invoke_signed() { // Step 2: Create ATA for payer (CreateMint now auto-decompresses) let ata = { - let (ata_address, _) = - light_token::instruction::derive_token_ata(&payer.pubkey(), &mint_pda); + let ata_address = light_token::instruction::derive_token_ata(&payer.pubkey(), &mint_pda); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint_pda); let ata_instruction = create_ata.instruction().unwrap(); diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_checked.rs b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_checked.rs index 8f65c60888..6282b96d4e 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_checked.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_checked.rs @@ -99,8 +99,8 @@ async fn test_ctoken_transfer_checked_spl_mint() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); let create_source_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), source_owner, mint) .instruction() @@ -200,8 +200,8 @@ async fn test_ctoken_transfer_checked_t22_mint() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); use light_token::instruction::CompressibleParams; let compressible_params = CompressibleParams { diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_interface.rs b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_interface.rs index 197c361b08..3a5d82b608 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_interface.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_interface.rs @@ -75,7 +75,7 @@ async fn test_transfer_interface_spl_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get token pool PDA let (spl_interface_pda, spl_interface_pda_bump) = @@ -168,7 +168,7 @@ async fn test_transfer_interface_ctoken_to_spl_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&owner.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&owner.pubkey(), &mint); // Fund Light Token via temporary SPL account let temp_spl_keypair = Keypair::new(); @@ -304,7 +304,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let sender_ctoken = derive_token_ata(&sender.pubkey(), &mint).0; + let sender_ctoken = derive_token_ata(&sender.pubkey(), &mint); // Create recipient Light Token ATA let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) @@ -313,7 +313,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let recipient_ctoken = derive_token_ata(&recipient.pubkey(), &mint).0; + let recipient_ctoken = derive_token_ata(&recipient.pubkey(), &mint); // Fund sender Light Token via SPL let temp_spl_keypair = Keypair::new(); @@ -478,7 +478,7 @@ async fn test_transfer_interface_spl_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); let (spl_interface_pda, spl_interface_pda_bump) = find_spl_interface_pda_with_index(&mint, 0, false); @@ -569,10 +569,9 @@ async fn test_transfer_interface_ctoken_to_spl_invoke_signed() { .unwrap(); // Create Light Token ATA owned by PDA - let (ctoken_account, bump) = derive_token_ata(&authority_pda, &mint); + let ctoken_account = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, @@ -714,10 +713,9 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke_signed() { let transfer_amount = 5000u64; // Create source Light Token ATA owned by PDA - let (source_ctoken, bump) = derive_token_ata(&authority_pda, &mint); + let source_ctoken = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, @@ -741,7 +739,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let dest_ctoken = derive_token_ata(&recipient.pubkey(), &mint).0; + let dest_ctoken = derive_token_ata(&recipient.pubkey(), &mint); // Fund source Light Token via temporary SPL account let temp_spl_keypair = Keypair::new(); diff --git a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_spl_ctoken.rs b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_spl_ctoken.rs index 4b03365d29..2197b6428c 100644 --- a/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_spl_ctoken.rs +++ b/sdk-tests/sdk-light-token-pinocchio/tests/test_transfer_spl_ctoken.rs @@ -74,7 +74,7 @@ async fn test_spl_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get initial balances use spl_token_2022::pod::PodAccount; @@ -196,7 +196,7 @@ async fn test_ctoken_to_spl_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&owner.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&owner.pubkey(), &mint); // Create a temporary SPL account to mint tokens then transfer to ctoken let temp_spl_account_keypair = Keypair::new(); @@ -386,7 +386,7 @@ async fn test_spl_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get SPL interface PDA let (spl_interface_pda, spl_interface_pda_bump) = @@ -485,10 +485,9 @@ async fn test_ctoken_to_spl_invoke_signed() { .unwrap(); // Create ctoken ATA owned by the PDA - let (ctoken_account, bump) = derive_token_ata(&authority_pda, &mint); + let ctoken_account = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, diff --git a/sdk-tests/sdk-light-token-test/src/create_ata.rs b/sdk-tests/sdk-light-token-test/src/create_ata.rs index 9dd7ba9358..5bdb71f0d5 100644 --- a/sdk-tests/sdk-light-token-test/src/create_ata.rs +++ b/sdk-tests/sdk-light-token-test/src/create_ata.rs @@ -7,7 +7,6 @@ use crate::{ATA_SEED, ID}; /// Instruction data for create ATA (owner and mint passed as accounts) #[derive(BorshSerialize, BorshDeserialize, Debug)] pub struct CreateAtaData { - pub bump: u8, pub pre_pay_num_epochs: u8, pub lamports_per_write: u32, } @@ -24,7 +23,7 @@ pub struct CreateAtaData { /// - accounts[6]: rent_sponsor pub fn process_create_ata_invoke( accounts: &[AccountInfo], - data: CreateAtaData, + _data: CreateAtaData, ) -> Result<(), ProgramError> { if accounts.len() < 7 { return Err(ProgramError::NotEnoughAccountKeys); @@ -35,7 +34,6 @@ pub fn process_create_ata_invoke( owner: accounts[0].clone(), mint: accounts[1].clone(), ata: accounts[3].clone(), - bump: data.bump, } .rent_free( accounts[5].clone(), // compressible_config @@ -59,7 +57,7 @@ pub fn process_create_ata_invoke( /// - accounts[6]: rent_sponsor pub fn process_create_ata_invoke_signed( accounts: &[AccountInfo], - data: CreateAtaData, + _data: CreateAtaData, ) -> Result<(), ProgramError> { if accounts.len() < 7 { return Err(ProgramError::NotEnoughAccountKeys); @@ -80,7 +78,6 @@ pub fn process_create_ata_invoke_signed( owner: accounts[0].clone(), mint: accounts[1].clone(), ata: accounts[3].clone(), - bump: data.bump, } .rent_free( accounts[5].clone(), // compressible_config diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs b/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs index 5a552758dc..9efa3e2eda 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_spl.rs @@ -131,7 +131,7 @@ async fn test_spl_to_ctoken_scenario() { .await .unwrap(); - let (ctoken_ata, _bump) = derive_token_ata(&ctoken_recipient.pubkey(), &mint); + let ctoken_ata = derive_token_ata(&ctoken_recipient.pubkey(), &mint); let create_ata_instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), ctoken_recipient.pubkey(), mint) .instruction() diff --git a/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs b/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs index 6d5785a45b..e9db3c3c41 100644 --- a/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs +++ b/sdk-tests/sdk-light-token-test/tests/scenario_spl_restricted_ext.rs @@ -75,7 +75,7 @@ async fn test_t22_restricted_to_ctoken_scenario() { .await .unwrap(); - let (ctoken_ata, _bump) = derive_token_ata(&ctoken_recipient.pubkey(), &mint); + let ctoken_ata = derive_token_ata(&ctoken_recipient.pubkey(), &mint); let compressible_params = CompressibleParams { compression_only: true, ..Default::default() diff --git a/sdk-tests/sdk-light-token-test/tests/shared.rs b/sdk-tests/sdk-light-token-test/tests/shared.rs index aecc786261..d3046d227c 100644 --- a/sdk-tests/sdk-light-token-test/tests/shared.rs +++ b/sdk-tests/sdk-light-token-test/tests/shared.rs @@ -98,7 +98,7 @@ pub async fn setup_create_mint( let mut ata_pubkeys = Vec::with_capacity(recipients.len()); for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint); @@ -219,7 +219,7 @@ pub async fn setup_create_mint_with_freeze_authority( let mut ata_pubkeys = Vec::with_capacity(recipients.len()); for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint); @@ -358,7 +358,7 @@ pub async fn setup_create_mint_with_compression_only( }; for (_amount, owner) in &recipients { - let (ata_address, _bump) = derive_token_ata(owner, &mint); + let ata_address = derive_token_ata(owner, &mint); ata_pubkeys.push(ata_address); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), *owner, mint) diff --git a/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs b/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs index a189792fa1..fa283be243 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_create_ata.rs @@ -34,11 +34,10 @@ async fn test_create_ata_invoke() { // Derive the ATA address let owner = payer.pubkey(); use light_token::instruction::derive_token_ata; - let (ata_address, bump) = derive_token_ata(&owner, &mint_pda); + let ata_address = derive_token_ata(&owner, &mint_pda); // Build CreateAtaData (owner and mint are passed as accounts) let create_ata_data = CreateAtaData { - bump, pre_pay_num_epochs: 2, lamports_per_write: 1, }; @@ -120,11 +119,10 @@ async fn test_create_ata_invoke_signed() { // Derive the ATA address for the PDA owner use light_token::instruction::derive_token_ata; - let (ata_address, bump) = derive_token_ata(&pda_owner, &mint_pda); + let ata_address = derive_token_ata(&pda_owner, &mint_pda); // Build CreateAtaData with PDA as owner (owner and mint are passed as accounts) let create_ata_data = CreateAtaData { - bump, pre_pay_num_epochs: 2, lamports_per_write: 1, }; diff --git a/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs b/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs index 480f51c80d..69b6e822e7 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_ctoken_mint_to.rs @@ -196,8 +196,7 @@ async fn test_ctoken_mint_to_invoke_signed() { // Step 2: Create ATA for payer (CreateMint now auto-decompresses) let ata = { - let (ata_address, _) = - light_token::instruction::derive_token_ata(&payer.pubkey(), &mint_pda); + let ata_address = light_token::instruction::derive_token_ata(&payer.pubkey(), &mint_pda); let create_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint_pda); let ata_instruction = create_ata.instruction().unwrap(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs index 95ed48a797..9730f0eecb 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_checked.rs @@ -96,8 +96,8 @@ async fn test_ctoken_transfer_checked_spl_mint() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); let create_source_ata = CreateAssociatedTokenAccount::new(payer.pubkey(), source_owner, mint) .instruction() @@ -194,8 +194,8 @@ async fn test_ctoken_transfer_checked_t22_mint() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); use light_token::instruction::CompressibleParams; let compressible_params = CompressibleParams { diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs index f01d43a4ec..7347ddf7f7 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_interface.rs @@ -74,7 +74,7 @@ async fn test_transfer_interface_spl_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get token pool PDA let (spl_interface_pda, spl_interface_pda_bump) = @@ -167,7 +167,7 @@ async fn test_transfer_interface_ctoken_to_spl_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&owner.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&owner.pubkey(), &mint); // Fund Light Token via temporary SPL account let temp_spl_keypair = Keypair::new(); @@ -303,7 +303,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let sender_ctoken = derive_token_ata(&sender.pubkey(), &mint).0; + let sender_ctoken = derive_token_ata(&sender.pubkey(), &mint); // Create recipient Light Token ATA let instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), recipient.pubkey(), mint) @@ -312,7 +312,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let recipient_ctoken = derive_token_ata(&recipient.pubkey(), &mint).0; + let recipient_ctoken = derive_token_ata(&recipient.pubkey(), &mint); // Fund sender Light Token via SPL let temp_spl_keypair = Keypair::new(); @@ -477,7 +477,7 @@ async fn test_transfer_interface_spl_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); let (spl_interface_pda, spl_interface_pda_bump) = find_spl_interface_pda_with_index(&mint, 0, false); @@ -568,10 +568,9 @@ async fn test_transfer_interface_ctoken_to_spl_invoke_signed() { .unwrap(); // Create Light Token ATA owned by PDA - let (ctoken_account, bump) = derive_token_ata(&authority_pda, &mint); + let ctoken_account = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, @@ -713,10 +712,9 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke_signed() { let transfer_amount = 5000u64; // Create source Light Token ATA owned by PDA - let (source_ctoken, bump) = derive_token_ata(&authority_pda, &mint); + let source_ctoken = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, @@ -740,7 +738,7 @@ async fn test_transfer_interface_ctoken_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let dest_ctoken = derive_token_ata(&recipient.pubkey(), &mint).0; + let dest_ctoken = derive_token_ata(&recipient.pubkey(), &mint); // Fund source Light Token via temporary SPL account let temp_spl_keypair = Keypair::new(); diff --git a/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs b/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs index fbfa9fbe50..e07f125e58 100644 --- a/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs +++ b/sdk-tests/sdk-light-token-test/tests/test_transfer_spl_ctoken.rs @@ -73,7 +73,7 @@ async fn test_spl_to_ctoken_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get initial balances use spl_token_2022::pod::PodAccount; @@ -195,7 +195,7 @@ async fn test_ctoken_to_spl_invoke() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&owner.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&owner.pubkey(), &mint); // Create a temporary SPL account to mint tokens then transfer to ctoken let temp_spl_account_keypair = Keypair::new(); @@ -385,7 +385,7 @@ async fn test_spl_to_ctoken_invoke_signed() { rpc.create_and_send_transaction(&[instruction], &payer.pubkey(), &[&payer]) .await .unwrap(); - let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint).0; + let ctoken_account = derive_token_ata(&recipient.pubkey(), &mint); // Get SPL interface PDA let (spl_interface_pda, spl_interface_pda_bump) = @@ -484,10 +484,9 @@ async fn test_ctoken_to_spl_invoke_signed() { .unwrap(); // Create ctoken ATA owned by the PDA - let (ctoken_account, bump) = derive_token_ata(&authority_pda, &mint); + let ctoken_account = derive_token_ata(&authority_pda, &mint); let instruction = CreateAssociatedTokenAccount { idempotent: false, - bump, payer: payer.pubkey(), owner: authority_pda, mint, 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 6ff8560390..9cc64620c9 100644 --- a/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs +++ b/sdk-tests/sdk-token-test/tests/decompress_full_cpi.rs @@ -73,7 +73,7 @@ async fn setup_decompress_full_test(num_inputs: usize) -> (LightProgramTest, Tes additional_owner.pubkey() }; - let (destination_account, _) = derive_token_ata(&destination_owner, &mint_pubkey); + let destination_account = derive_token_ata(&destination_owner, &mint_pubkey); let compressible_params = CompressibleParams { compressible_config: rpc diff --git a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs index 4c19a08d88..990743a5a1 100644 --- a/sdk-tests/sdk-token-test/tests/pda_ctoken.rs +++ b/sdk-tests/sdk-token-test/tests/pda_ctoken.rs @@ -200,7 +200,7 @@ pub async fn create_mint( let (mint, mint_bump) = find_mint_address(&mint_seed.pubkey()); // Create compressed token associated token account for the mint authority - let (token_account, _) = derive_token_ata(&mint_authority.pubkey(), &mint); + let token_account = derive_token_ata(&mint_authority.pubkey(), &mint); println!("Created token_account (ATA): {:?}", token_account); let compressible_params = CompressibleParams { 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 fd978aeba7..488a63a35e 100644 --- a/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs +++ b/sdk-tests/sdk-token-test/tests/test_4_transfer2.rs @@ -96,7 +96,7 @@ async fn create_compressed_mints_and_tokens( mint_compressed_tokens(rpc, payer, &mint3_pda, mint3_pubkey, compress_amount).await; // Create associated token account for mint1 decompression - let (token_account1_pubkey, _bump) = + let token_account1_pubkey = light_token::instruction::derive_token_ata(&payer.pubkey(), &mint1_pda); let create_ata_instruction = CreateAssociatedTokenAccount::new(payer.pubkey(), payer.pubkey(), mint1_pda) diff --git a/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs b/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs index badb7dce42..c2d64eeaad 100644 --- a/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs +++ b/sdk-tests/sdk-token-test/tests/test_compress_full_and_close.rs @@ -176,7 +176,7 @@ async fn test_compress_full_and_close() { println!("✅ Minted {} compressed tokens to recipient", mint_amount); // Step 4: Create compressible associated token account for decompression - let (ctoken_ata_pubkey, bump) = derive_token_ata(&recipient, &mint_pda); + let ctoken_ata_pubkey = derive_token_ata(&recipient, &mint_pda); let compressible_params = CompressibleParams { token_account_version: TokenDataVersion::ShaFlat, pre_pay_num_epochs: 2, @@ -186,16 +186,11 @@ async fn test_compress_full_and_close() { rent_sponsor: rent_sponsor_pda(), compression_only: true, }; - let create_ata_instruction = CreateAssociatedTokenAccount::new_with_bump( - payer.pubkey(), - recipient, - mint_pda, - ctoken_ata_pubkey, - bump, - ) - .with_compressible(compressible_params) - .instruction() - .unwrap(); + let create_ata_instruction = + CreateAssociatedTokenAccount::new(payer.pubkey(), recipient, mint_pda) + .with_compressible(compressible_params) + .instruction() + .unwrap(); rpc.create_and_send_transaction(&[create_ata_instruction], &payer.pubkey(), &[&payer]) .await diff --git a/sdk-tests/single-ata-test/src/lib.rs b/sdk-tests/single-ata-test/src/lib.rs index 72bb66b1db..eec5bb77fb 100644 --- a/sdk-tests/single-ata-test/src/lib.rs +++ b/sdk-tests/single-ata-test/src/lib.rs @@ -19,8 +19,6 @@ pub const LIGHT_CPI_SIGNER: CpiSigner = #[derive(AnchorSerialize, AnchorDeserialize, Clone)] pub struct CreateAtaParams { pub create_accounts_proof: CreateAccountsProof, - /// Bump for the ATA PDA - pub ata_bump: u8, } /// Minimal accounts struct for testing single ATA creation. @@ -38,7 +36,7 @@ pub struct CreateAta<'info> { /// ATA account - macro should generate creation code. #[account(mut)] - #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint, associated_token::bump = params.ata_bump)] + #[light_account(init, associated_token::authority = ata_owner, associated_token::mint = ata_mint)] pub ata: UncheckedAccount<'info>, #[account(address = LIGHT_TOKEN_CONFIG)] diff --git a/sdk-tests/single-ata-test/tests/test.rs b/sdk-tests/single-ata-test/tests/test.rs index e5dff0f100..0196b17a23 100644 --- a/sdk-tests/single-ata-test/tests/test.rs +++ b/sdk-tests/single-ata-test/tests/test.rs @@ -122,7 +122,7 @@ async fn test_create_single_ata() { let ata_owner = payer.pubkey(); // Derive the ATA address using Light Token SDK's derivation - let (ata, ata_bump) = light_token::instruction::derive_token_ata(&ata_owner, &mint); + let ata = light_token::instruction::derive_token_ata(&ata_owner, &mint); // Get proof (no PDA accounts for ATA-only instruction) let proof_result = get_create_accounts_proof(&rpc, &program_id, vec![]) @@ -144,7 +144,6 @@ async fn test_create_single_ata() { let instruction_data = single_ata_test::instruction::CreateAta { params: CreateAtaParams { create_accounts_proof: proof_result.create_accounts_proof, - ata_bump, }, }; diff --git a/sdk-tests/token-client-test/tests/test_approve_revoke.rs b/sdk-tests/token-client-test/tests/test_approve_revoke.rs index 974023fcef..d5269a4061 100644 --- a/sdk-tests/token-client-test/tests/test_approve_revoke.rs +++ b/sdk-tests/token-client-test/tests/test_approve_revoke.rs @@ -50,7 +50,7 @@ async fn test_approve_basic() { // Create ATA for payer let owner = payer.pubkey(); - let (token_account, _) = derive_token_ata(&owner, &mint); + let token_account = derive_token_ata(&owner, &mint); CreateAta { mint, @@ -120,7 +120,7 @@ async fn test_approve_with_separate_owner() { // Create ATA for a different owner let owner = Keypair::new(); - let (token_account, _) = derive_token_ata(&owner.pubkey(), &mint); + let token_account = derive_token_ata(&owner.pubkey(), &mint); CreateAta { mint, @@ -190,7 +190,7 @@ async fn test_revoke_basic() { // Create ATA let owner = payer.pubkey(); - let (token_account, _) = derive_token_ata(&owner, &mint); + let token_account = derive_token_ata(&owner, &mint); CreateAta { mint, @@ -275,7 +275,7 @@ async fn test_revoke_with_separate_owner() { // Create ATA for a different owner let owner = Keypair::new(); - let (token_account, _) = derive_token_ata(&owner.pubkey(), &mint); + let token_account = derive_token_ata(&owner.pubkey(), &mint); CreateAta { mint, @@ -345,7 +345,7 @@ async fn test_approve_and_delegate_transfer() { // Create source ATA let source_owner = payer.pubkey(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); CreateAta { mint, @@ -358,7 +358,7 @@ async fn test_approve_and_delegate_transfer() { // Create destination ATA let dest_owner = Pubkey::new_unique(); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, diff --git a/sdk-tests/token-client-test/tests/test_transfer.rs b/sdk-tests/token-client-test/tests/test_transfer.rs index 218037ffa2..7a0bda6f27 100644 --- a/sdk-tests/token-client-test/tests/test_transfer.rs +++ b/sdk-tests/token-client-test/tests/test_transfer.rs @@ -52,8 +52,8 @@ async fn test_transfer_basic() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, @@ -137,8 +137,8 @@ async fn test_transfer_full_balance() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, diff --git a/sdk-tests/token-client-test/tests/test_transfer_checked.rs b/sdk-tests/token-client-test/tests/test_transfer_checked.rs index 070e3dcf04..02273ea4de 100644 --- a/sdk-tests/token-client-test/tests/test_transfer_checked.rs +++ b/sdk-tests/token-client-test/tests/test_transfer_checked.rs @@ -52,8 +52,8 @@ async fn test_transfer_checked_basic() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, @@ -140,8 +140,8 @@ async fn test_transfer_checked_different_decimals() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, diff --git a/sdk-tests/token-client-test/tests/test_transfer_interface.rs b/sdk-tests/token-client-test/tests/test_transfer_interface.rs index a5f8d0cba8..3061c8ff0d 100644 --- a/sdk-tests/token-client-test/tests/test_transfer_interface.rs +++ b/sdk-tests/token-client-test/tests/test_transfer_interface.rs @@ -52,8 +52,8 @@ async fn test_transfer_interface_light_to_light() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, @@ -141,8 +141,8 @@ async fn test_transfer_interface_multiple_transfers() { let source_owner = payer.pubkey(); let dest_owner = Pubkey::new_unique(); - let (source_ata, _) = derive_token_ata(&source_owner, &mint); - let (dest_ata, _) = derive_token_ata(&dest_owner, &mint); + let source_ata = derive_token_ata(&source_owner, &mint); + let dest_ata = derive_token_ata(&dest_owner, &mint); CreateAta { mint, diff --git a/sdk-tests/token-client-test/tests/test_wrap_unwrap.rs b/sdk-tests/token-client-test/tests/test_wrap_unwrap.rs index aa5a212f7e..64eca8894d 100644 --- a/sdk-tests/token-client-test/tests/test_wrap_unwrap.rs +++ b/sdk-tests/token-client-test/tests/test_wrap_unwrap.rs @@ -50,7 +50,7 @@ async fn test_wrap_basic() { // Create Light Token ATA for destination let owner = payer.pubkey(); - let (light_token_ata, _) = derive_token_ata(&owner, &mint); + let light_token_ata = derive_token_ata(&owner, &mint); CreateAta { mint, @@ -123,7 +123,7 @@ async fn test_unwrap_basic() { // Create Light Token ATA let owner = payer.pubkey(); - let (light_token_ata, _) = derive_token_ata(&owner, &mint); + let light_token_ata = derive_token_ata(&owner, &mint); CreateAta { mint, @@ -213,7 +213,7 @@ async fn test_wrap_unwrap_round_trip() { // Create Light Token ATA let owner = payer.pubkey(); - let (light_token_ata, _) = derive_token_ata(&owner, &mint); + let light_token_ata = derive_token_ata(&owner, &mint); CreateAta { mint, @@ -297,7 +297,7 @@ async fn test_wrap_large_amount() { // Create Light Token ATA let owner = payer.pubkey(); - let (light_token_ata, _) = derive_token_ata(&owner, &mint); + let light_token_ata = derive_token_ata(&owner, &mint); CreateAta { mint,