Skip to content

Commit 2a7b741

Browse files
Adding assert_owner_in to mpl-utils. (#1168)
1 parent aaa2739 commit 2a7b741

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

core/rust/utils/src/assertions.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ use solana_program::{
77
rent::Rent,
88
};
99

10+
use crate::cmp_pubkeys;
11+
1012
pub fn assert_signer(account_info: &AccountInfo) -> ProgramResult {
1113
if !account_info.is_signer {
1214
Err(ProgramError::MissingRequiredSignature)
@@ -39,6 +41,18 @@ pub fn assert_owned_by(
3941
}
4042
}
4143

44+
pub fn assert_owner_in(
45+
account: &AccountInfo,
46+
owners: &[Pubkey],
47+
error: impl Into<ProgramError>,
48+
) -> ProgramResult {
49+
if owners.iter().any(|owner| cmp_pubkeys(owner, account.owner)) {
50+
Ok(())
51+
} else {
52+
Err(error.into())
53+
}
54+
}
55+
4256
pub fn assert_derivation(
4357
program_id: &Pubkey,
4458
account: &AccountInfo,

0 commit comments

Comments
 (0)