This commit is contained in:
Hardhat Chad
2024-04-27 16:30:45 +00:00
parent 3a109e7a11
commit f4d36f9b9f
18 changed files with 1019 additions and 721 deletions

View File

@@ -7,9 +7,11 @@ use spl_token::state::Mint;
use crate::{
state::{Bus, Config, Proof, Treasury},
utils::AccountDeserialize,
BUS_ADDRESSES, BUS_COUNT, CONFIG_ADDRESS, MINT_ADDRESS, TREASURY_ADDRESS,
BUS_ADDRESSES, BUS_COUNT, CONFIG_ADDRESS, MINT_ADDRESS, NOISE_ADDRESS, TREASURY_ADDRESS,
};
// TODO Account checks don't need to deserialize the whole byte array. They can just check the type byte
/// Errors if:
/// - Account is not a signer.
pub fn load_signer<'a, 'info>(info: &'a AccountInfo<'info>) -> Result<(), ProgramError> {
@@ -127,6 +129,30 @@ pub fn load_config<'a, 'info>(
Ok(())
}
/// asdf
pub fn load_noise<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.owner.ne(&crate::id()) {
return Err(ProgramError::InvalidAccountOwner);
}
if info.key.ne(&NOISE_ADDRESS) {
return Err(ProgramError::InvalidSeeds);
}
if info.data_is_empty() {
return Err(ProgramError::UninitializedAccount);
}
if is_writable && !info.is_writable {
return Err(ProgramError::InvalidAccountData);
}
Ok(())
}
/// Errors if:
/// - Owner is not Ore program.
/// - Data is empty.