Skip to content

Commit

Permalink
Adding assert_owner_in to mpl-utils. (#1168)
Browse files Browse the repository at this point in the history
  • Loading branch information
blockiosaurus committed Feb 7, 2024
1 parent aaa2739 commit 2a7b741
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions core/rust/utils/src/assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use solana_program::{
rent::Rent,
};

use crate::cmp_pubkeys;

pub fn assert_signer(account_info: &AccountInfo) -> ProgramResult {
if !account_info.is_signer {
Err(ProgramError::MissingRequiredSignature)
Expand Down Expand Up @@ -39,6 +41,18 @@ pub fn assert_owned_by(
}
}

pub fn assert_owner_in(
account: &AccountInfo,
owners: &[Pubkey],
error: impl Into<ProgramError>,
) -> ProgramResult {
if owners.iter().any(|owner| cmp_pubkeys(owner, account.owner)) {
Ok(())
} else {
Err(error.into())
}
}

pub fn assert_derivation(
program_id: &Pubkey,
account: &AccountInfo,
Expand Down

0 comments on commit 2a7b741

Please sign in to comment.