crown new top staker

This commit is contained in:
Hardhat Chad
2024-06-27 14:01:52 +00:00
parent 77bf195139
commit 3608071f1c
10 changed files with 106 additions and 23 deletions

View File

@@ -158,6 +158,34 @@ pub fn load_proof<'a, 'info>(
Ok(())
}
/// Errors if:
/// - Owner is not Ore program.
/// - Data is empty.
/// - Data cannot deserialize into a proof account.
/// - Expected to be writable, but is not.
pub fn load_any_proof<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
if info.data_is_empty() {
return Err(ProgramError::UninitializedAccount);
}
if info.data.borrow()[0].ne(&(Proof::discriminator() as u8)) {
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
}
if is_writable && !info.is_writable {
return Err(ProgramError::InvalidAccountData);
}
Ok(())
}
/// Errors if:
/// - Owner is not Ore program.
/// - Address does not match the expected address.