use strict treasury_tokens loader

This commit is contained in:
Hardhat Chad
2024-07-02 13:08:35 +00:00
parent b55b6d338d
commit 3b1039b469
5 changed files with 31 additions and 20 deletions

View File

@@ -252,6 +252,20 @@ pub fn load_treasury<'a, 'info>(
Ok(())
}
/// Errors if:
/// - Address does not match the expected treasury tokens address.
/// - Cannot load as a token account
pub fn load_treasury_tokens<'a, 'info>(
info: &'a AccountInfo<'info>,
is_writable: bool,
) -> Result<(), ProgramError> {
if info.key.ne(&TREASURY_TOKENS_ADDRESS) {
return Err(ProgramError::InvalidSeeds);
}
load_token_account(info, Some(&TREASURY_ADDRESS), &MINT_ADDRESS, is_writable)
}
/// Errors if:
/// - Owner is not SPL token program.
/// - Address does not match the expected mint address.