Skip to content

Commit

Permalink
chore: merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Sep 25, 2024
2 parents 6068f5c + e324816 commit 5e0c2f0
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 34 deletions.
17 changes: 1 addition & 16 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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())
Expand All @@ -144,7 +136,6 @@ impl VestingInstruction {
Self::Create {
seeds,
mint_address,
destination_token_address,
schedule,
}
}
Expand Down Expand Up @@ -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());
}
Expand Down Expand Up @@ -227,15 +216,13 @@ 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],
) -> Result<Instruction, ProgramError> {
let data = VestingInstruction::Create {
mint_address: *mint_address,
seeds,
destination_token_address: *destination_token_account_key,
schedule,
}
.pack();
Expand Down Expand Up @@ -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],
Expand All @@ -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();
Expand Down
5 changes: 1 addition & 4 deletions program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
};
Expand Down Expand Up @@ -284,7 +283,6 @@ impl Processor {
VestingInstruction::Create {
seeds,
mint_address,
destination_token_address,
schedule,
} => {
msg!("Instruction: Create Schedule");
Expand All @@ -293,7 +291,6 @@ impl Processor {
accounts,
seeds,
&mint_address,
&destination_token_address,
schedule,
)
}
Expand Down
15 changes: 1 addition & 14 deletions program/tests/functional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand All @@ -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()
];
Expand Down

0 comments on commit 5e0c2f0

Please sign in to comment.