diff --git a/program/src/instruction.rs b/program/src/instruction.rs index eaeca50..9556a47 100644 --- a/program/src/instruction.rs +++ b/program/src/instruction.rs @@ -29,11 +29,9 @@ impl Arbitrary for VestingInstruction { let key_bytes: [u8; 32] = u.arbitrary()?; let mint_address: Pubkey = Pubkey::new_from_array(key_bytes); let key_bytes: [u8; 32] = u.arbitrary()?; - let destination_token_address: Pubkey = Pubkey::new_from_array(key_bytes); return Ok(Self::Create { seeds, mint_address, - destination_token_address, schedule: schedule, }); } @@ -82,7 +80,6 @@ pub enum VestingInstruction { Create { seeds: [u8; 32], mint_address: Pubkey, - destination_token_address: Pubkey, schedule: Schedule, }, /// Unlocks a simple vesting contract (SVC) - can only be invoked by the program itself @@ -121,12 +118,7 @@ impl VestingInstruction { .and_then(|slice| slice.try_into().ok()) .map(Pubkey::new_from_array) .ok_or(InvalidInstruction)?; - let destination_token_address = rest - .get(64..96) - .and_then(|slice| slice.try_into().ok()) - .map(Pubkey::new_from_array) - .ok_or(InvalidInstruction)?; - let offset = 96; + let offset = 64; let release_time = rest .get(offset..offset + 8) .and_then(|slice| slice.try_into().ok()) @@ -144,7 +136,6 @@ impl VestingInstruction { Self::Create { seeds, mint_address, - destination_token_address, schedule, } } @@ -174,13 +165,11 @@ impl VestingInstruction { Self::Create { seeds, mint_address, - destination_token_address, schedule, } => { buf.push(1); buf.extend_from_slice(seeds); buf.extend_from_slice(&mint_address.to_bytes()); - buf.extend_from_slice(&destination_token_address.to_bytes()); buf.extend_from_slice(&schedule.release_time.to_le_bytes()); buf.extend_from_slice(&schedule.amount.to_le_bytes()); } @@ -227,7 +216,6 @@ pub fn create( vesting_token_account_key: &Pubkey, source_token_account_owner_key: &Pubkey, source_token_account_key: &Pubkey, - destination_token_account_key: &Pubkey, mint_address: &Pubkey, schedule: Schedule, seeds: [u8; 32], @@ -235,7 +223,6 @@ pub fn create( let data = VestingInstruction::Create { mint_address: *mint_address, seeds, - destination_token_address: *destination_token_account_key, schedule, } .pack(); @@ -285,7 +272,6 @@ mod test { #[test] fn test_instruction_packing() { let mint_address = Pubkey::new_unique(); - let destination_token_address = Pubkey::new_unique(); let original_create = VestingInstruction::Create { seeds: [50u8; 32], @@ -294,7 +280,6 @@ mod test { release_time: 250, }, mint_address: mint_address.clone(), - destination_token_address, }; let packed_create = original_create.pack(); let unpacked_create = VestingInstruction::unpack(&packed_create).unwrap(); diff --git a/program/src/processor.rs b/program/src/processor.rs index 0a50978..bf6e141 100644 --- a/program/src/processor.rs +++ b/program/src/processor.rs @@ -73,7 +73,6 @@ impl Processor { accounts: &[AccountInfo], seeds: [u8; 32], mint_address: &Pubkey, - destination_token_address: &Pubkey, schedule: Schedule, ) -> ProgramResult { let accounts_iter = &mut accounts.iter(); @@ -127,7 +126,7 @@ impl Processor { } let state_header = VestingScheduleHeader { - destination_address: *destination_token_address, + destination_address: *source_token_account.key, mint_address: *mint_address, is_initialized: true, }; @@ -284,7 +283,6 @@ impl Processor { VestingInstruction::Create { seeds, mint_address, - destination_token_address, schedule, } => { msg!("Instruction: Create Schedule"); @@ -293,7 +291,6 @@ impl Processor { accounts, seeds, &mint_address, - &destination_token_address, schedule, ) } diff --git a/program/tests/functional.rs b/program/tests/functional.rs index 3458a89..a6de175 100644 --- a/program/tests/functional.rs +++ b/program/tests/functional.rs @@ -24,12 +24,6 @@ async fn test_token_vesting() { let source_account = Keypair::new(); let source_token_account = Keypair::new(); - let destination_account = Keypair::new(); - let destination_token_account = Keypair::new(); - - let new_destination_account = Keypair::new(); - let new_destination_token_account = Keypair::new(); - let mut seeds = [42u8; 32]; let (vesting_account_key, bump) = Pubkey::find_program_address(&[&seeds[..31]], &program_id); seeds[31] = bump; @@ -88,12 +82,6 @@ async fn test_token_vesting() { banks_client.process_transaction( create_token_account(&payer, &mint, recent_blockhash, &vesting_token_account, &vesting_account_key) ).await.unwrap(); - banks_client.process_transaction( - create_token_account(&payer, &mint, recent_blockhash, &destination_token_account, &destination_account.pubkey()) - ).await.unwrap(); - banks_client.process_transaction( - create_token_account(&payer, &mint, recent_blockhash, &new_destination_token_account, &new_destination_account.pubkey()) - ).await.unwrap(); // Create and process the vesting transactions @@ -118,7 +106,6 @@ async fn test_token_vesting() { &vesting_token_account.pubkey(), &source_account.pubkey(), &source_token_account.pubkey(), - &destination_token_account.pubkey(), &mint.pubkey(), schedule, seeds.clone() @@ -129,7 +116,7 @@ async fn test_token_vesting() { &sysvar::clock::id(), &vesting_account_key, &vesting_token_account.pubkey(), - &destination_token_account.pubkey(), + &source_token_account.pubkey(), seeds.clone() ).unwrap() ];