Skip to content

Commit 8ff86c7

Browse files
committed
Refactor
1 parent 06bd1fb commit 8ff86c7

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

program/rust/src/deserialize.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,10 @@ pub fn load_account_as_mut<'a, T: Pod>(
6969
}))
7070
}
7171

72-
pub fn load_checked<'a, T: PythAccount>(
73-
account: &'a AccountInfo,
74-
version: u32,
72+
pub fn check_owned_and_rent_exempt_account<T: PythAccount>(
73+
account: &AccountInfo,
7574
program_id: &Pubkey,
76-
) -> Result<RefMut<'a, T>, ProgramError> {
75+
) -> Result<(), ProgramError> {
7776
// Check size and rent
7877
pyth_assert(
7978
account.data_len() >= T::minimum_size()
@@ -84,8 +83,17 @@ pub fn load_checked<'a, T: PythAccount>(
8483
// Check owner
8584
pyth_assert(
8685
account.owner == program_id,
87-
OracleError::SmallSizeOrNotEnoughRent.into(),
86+
OracleError::AccountNotOwnerByOracle.into(),
8887
)?;
88+
Ok(())
89+
}
90+
91+
pub fn load_checked<'a, T: PythAccount>(
92+
account: &'a AccountInfo,
93+
version: u32,
94+
program_id: &Pubkey,
95+
) -> Result<RefMut<'a, T>, ProgramError> {
96+
check_owned_and_rent_exempt_account::<T>(account, program_id)?;
8997

9098
// Check header
9199
{

0 commit comments

Comments
 (0)