From 2a3fe5602326c8d75379ca8528f496e1b245cdb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wei=C3=9Fer=20Hase?= Date: Thu, 19 Sep 2024 15:39:48 +0200 Subject: [PATCH] fix: rm deprecated methods --- program/src/instruction.rs | 5 ++--- program/src/state.rs | 11 +++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/program/src/instruction.rs b/program/src/instruction.rs index 529e0c7..fd18f6b 100644 --- a/program/src/instruction.rs +++ b/program/src/instruction.rs @@ -114,7 +114,6 @@ pub enum VestingInstruction { ChangeDestination { seeds: [u8; 32] }, } -#[allow(deprecated)] impl VestingInstruction { pub fn unpack(input: &[u8]) -> Result { use VestingError::InvalidInstruction; @@ -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 = Vec::with_capacity(number_of_schedules); diff --git a/program/src/state.rs b/program/src/state.rs index e7a69f0..ad51f97 100644 --- a/program/src/state.rs +++ b/program/src/state.rs @@ -1,3 +1,5 @@ +use std::convert::TryFrom; + use solana_program::{ program_error::ProgramError, program_pack::{IsInitialized, Pack, Sealed}, @@ -20,7 +22,6 @@ pub struct VestingScheduleHeader { impl Sealed for VestingScheduleHeader {} -#[allow(deprecated)] impl Pack for VestingScheduleHeader { const LEN: usize = 65; @@ -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,