MCPcopy Create free account
hub / github.com/nifty-oss/asset / assert_delegate

Function assert_delegate

programs/asset/program/src/utils.rs:31–59  ·  view source on GitHub ↗
(
    delegates: &[Option<&Delegate>],
    target: &Pubkey,
    role: DelegateRole,
)

Source from the content-addressed store, hash-verified

29#[allow(clippy::manual_try_fold)]
30#[inline(always)]
31pub fn assert_delegate(
32 delegates: &[Option<&Delegate>],
33 target: &Pubkey,
34 role: DelegateRole,
35) -> ProgramResult {
36 delegates.iter().fold(
37 Err(AssetError::DelegateNotFound.into()),
38 |result, delegate| {
39 if let Some(delegate) = delegate {
40 require!(
41 *delegate.address == *target,
42 AssetError::InvalidDelegate,
43 "invalid delegate"
44 );
45
46 require!(
47 delegate.is_active(role),
48 AssetError::DelegateRoleNotActive,
49 "missing \"{:?}\" role",
50 role
51 );
52
53 Ok(())
54 } else {
55 result
56 }
57 },
58 )
59}
60
61#[macro_export]
62macro_rules! process_royalties {

Callers 4

process_lockFunction · 0.85
process_unlockFunction · 0.85
process_transferFunction · 0.85
process_burnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected