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

Function process_update

programs/asset/program/src/processor/update.rs:41–380  ·  view source on GitHub ↗
(
    program_id: &Pubkey,
    ctx: Context<Update>,
    args: UpdateInput,
)

Source from the content-addressed store, hash-verified

39/// 3. `[optional]` system_program
40#[inline(always)]
41pub fn process_update(
42 program_id: &Pubkey,
43 ctx: Context<Update>,
44 args: UpdateInput,
45) -> ProgramResult {
46 // account validation
47
48 require!(
49 ctx.accounts.authority.is_signer(),
50 ProgramError::MissingRequiredSignature,
51 "authority"
52 );
53
54 require!(
55 ctx.accounts.asset.owner() == program_id,
56 ProgramError::IllegalOwner,
57 "asset"
58 );
59
60 let mut account_data = ctx.accounts.asset.try_borrow_mut_data()?;
61
62 require!(
63 account_data.len() >= Asset::LEN && account_data[0] == Discriminator::Asset.into(),
64 AssetError::Uninitialized,
65 "asset"
66 );
67
68 let asset = Asset::load_mut(&mut account_data);
69
70 require!(
71 asset.authority == *ctx.accounts.authority.key(),
72 AssetError::InvalidAuthority,
73 "authority"
74 );
75
76 require!(
77 <PodBool as Into<bool>>::into(asset.mutable),
78 AssetError::ImmutableAsset,
79 "asset"
80 );
81
82 // updates the asset:
83 //
84 // 1. name
85 // 2. mutable flag
86 // 3. extension
87
88 if let Some(name) = args.name {
89 asset.name = name.into();
90 }
91
92 if let Some(mutable) = args.mutable {
93 asset.mutable = mutable.into();
94 }
95
96 // creating/updating an extension is a multi-step process:
97 //
98 // 1. find the extension to update or determine that it is a new one

Callers 1

process_instructionFunction · 0.70

Calls 13

validateFunction · 0.85
try_extension_typeMethod · 0.80
boundaryMethod · 0.80
keyMethod · 0.80
set_extension_typeMethod · 0.80
set_lengthMethod · 0.80
set_boundaryMethod · 0.80
resizeFunction · 0.70
is_someMethod · 0.45
extension_typeMethod · 0.45
lengthMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected