From b5a735878a9e7b826a66b3e766abb7991dac1310 Mon Sep 17 00:00:00 2001 From: Jack May Date: Tue, 4 Feb 2020 14:54:41 -0800 Subject: [PATCH] Sysvar account_into return program error rather than option (#8121) --- sdk/src/sysvar/mod.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/src/sysvar/mod.rs b/sdk/src/sysvar/mod.rs index 3bdd2e4150..75a1177c36 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()