Skip to content

Commit

Permalink
fix: rm deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase committed Sep 19, 2024
1 parent f000bd1 commit 2a3fe56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 2 additions & 3 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub enum VestingInstruction {
ChangeDestination { seeds: [u8; 32] },
}

#[allow(deprecated)]
impl VestingInstruction {
pub fn unpack(input: &[u8]) -> Result<Self, ProgramError> {
use VestingError::InvalidInstruction;
Expand Down Expand Up @@ -143,12 +142,12 @@ impl VestingInstruction {
let mint_address = rest
.get(32..64)
.and_then(|slice| slice.try_into().ok())
.map(Pubkey::new)
.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)
.map(Pubkey::new_from_array)
.ok_or(InvalidInstruction)?;
let number_of_schedules = rest[96..].len() / SCHEDULE_SIZE;
let mut schedules: Vec<Schedule> = Vec::with_capacity(number_of_schedules);
Expand Down
11 changes: 7 additions & 4 deletions program/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::convert::TryFrom;

use solana_program::{
program_error::ProgramError,
program_pack::{IsInitialized, Pack, Sealed},
Expand All @@ -20,7 +22,6 @@ pub struct VestingScheduleHeader {

impl Sealed for VestingScheduleHeader {}

#[allow(deprecated)]
impl Pack for VestingScheduleHeader {
const LEN: usize = 65;

Expand All @@ -42,9 +43,11 @@ impl Pack for VestingScheduleHeader {
if src.len() < 65 {
return Err(ProgramError::InvalidAccountData)
}
let destination_address = Pubkey::new(&src[..32]);
let mint_address = Pubkey::new(&src[32..64]);
let is_initialized = src[64] == 1;
let destination_address = Pubkey::try_from(&src[..32])
.map_err(|_| ProgramError::InvalidArgument)?;
let mint_address = Pubkey::try_from(&src[32..64])
.map_err(|_| ProgramError::InvalidArgument)?;
let is_initialized = src[64] == 1;
Ok(Self {
destination_address,
mint_address,
Expand Down

0 comments on commit 2a3fe56

Please sign in to comment.