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

Function process_verify

programs/asset/program/src/processor/verify.rs:20–71  ·  view source on GitHub ↗

Verifies a creator. ### Accounts: 0. `[writable]` asset 1. `[signer]` creator

(program_id: &Pubkey, ctx: Context<Verify>)

Source from the content-addressed store, hash-verified

18/// 0. `[writable]` asset
19/// 1. `[signer]` creator
20pub fn process_verify(program_id: &Pubkey, ctx: Context<Verify>) -> ProgramResult {
21 // account validation
22
23 require!(
24 ctx.accounts.creator.is_signer(),
25 ProgramError::MissingRequiredSignature,
26 "missing creator signature"
27 );
28
29 require!(
30 ctx.accounts.asset.owner() == program_id,
31 ProgramError::IllegalOwner,
32 "invalid asset account owner"
33 );
34
35 let mut data = ctx.accounts.asset.try_borrow_mut_data()?;
36
37 require!(
38 data.len() >= Asset::LEN && data[0] == Discriminator::Asset.into(),
39 AssetError::Uninitialized,
40 "asset"
41 );
42
43 let extension = if let Some(creators) = Asset::get_mut::<CreatorsMut>(&mut data) {
44 creators
45 } else {
46 return err!(
47 AssetError::ExtensionNotFound,
48 "Creators extension not found in asset account"
49 );
50 };
51
52 // verifies the creator
53
54 let mut found = false;
55
56 extension.creators.iter_mut().for_each(|creator| {
57 if creator.address == *ctx.accounts.creator.key() {
58 creator.verified = true.into();
59 found = true;
60 }
61 });
62
63 if !found {
64 return err!(
65 ProgramError::InvalidArgument,
66 "Creator not found in asset account"
67 );
68 }
69
70 Ok(())
71}

Callers 1

process_instructionFunction · 0.85

Calls 1

keyMethod · 0.80

Tested by

no test coverage detected