diff --git a/sdk/src/sysvar/mod.rs b/sdk/src/sysvar/mod.rs index 3bdd2e415..75a1177c3 100644 --- a/sdk/src/sysvar/mod.rs +++ b/sdk/src/sysvar/mod.rs @@ -4,6 +4,7 @@ use crate::{ account::{Account, KeyedAccount}, account_info::AccountInfo, instruction::InstructionError, + program_error::ProgramError, pubkey::Pubkey, }; @@ -70,8 +71,8 @@ pub trait Sysvar: fn to_account(&self, account: &mut Account) -> Option<()> { bincode::serialize_into(&mut account.data[..], self).ok() } - fn from_account_info(account_info: &AccountInfo) -> Option { - bincode::deserialize(&account_info.data.borrow()).ok() + fn from_account_info(account_info: &AccountInfo) -> Result { + bincode::deserialize(&account_info.data.borrow()).map_err(|_| ProgramError::InvalidArgument) } fn to_account_info(&self, account_info: &mut AccountInfo) -> Option<()> { bincode::serialize_into(&mut account_info.data.borrow_mut()[..], self).ok()