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

Function process_create

programs/bridge/src/processor/create.rs:34–282  ·  view source on GitHub ↗
(
    program_id: &Pubkey,
    ctx: Context<CreateAccounts>,
    args: CreateArgs,
)

Source from the content-addressed store, hash-verified

32};
33
34pub fn process_create(
35 program_id: &Pubkey,
36 ctx: Context<CreateAccounts>,
37 args: CreateArgs,
38) -> ProgramResult {
39 // account validation
40
41 require!(
42 SPL_TOKEN_PROGRAM_IDS.contains(ctx.accounts.mint.owner),
43 ProgramError::IllegalOwner,
44 "mint"
45 );
46
47 require!(
48 *ctx.accounts.metadata.owner == mpl_token_metadata::ID,
49 ProgramError::IllegalOwner,
50 "metadata"
51 );
52
53 // relationship validation
54
55 let metadata = Metadata::try_from(ctx.accounts.metadata)?;
56
57 require!(
58 matches!(
59 metadata.token_standard,
60 Some(TokenStandard::NonFungible) | Some(TokenStandard::ProgrammableNonFungible)
61 ),
62 ProgramError::InvalidAccountData,
63 "invalid token standard"
64 );
65
66 require!(
67 metadata.mint == *ctx.accounts.mint.key,
68 BridgeError::InvalidMint,
69 "mint"
70 );
71
72 require!(
73 metadata.update_authority == *ctx.accounts.update_authority.key,
74 BridgeError::InvalidAuthority,
75 "update_authority"
76 );
77
78 let authority_as_signer = if let Some(Collection { verified, key }) = metadata.collection {
79 // if collection is verified, then we require the collection NFT
80 // to be bridged as well
81 if verified {
82 let (derived_key, _) = bridged_asset::find_pda(&key);
83
84 let collection_asset = if let Some(collection_asset) = ctx.accounts.collection {
85 collection_asset
86 } else {
87 return err!(ProgramError::NotEnoughAccountKeys, "collection_asset");
88 };
89
90 require!(
91 derived_key == *collection_asset.key,

Callers 1

process_instructionFunction · 0.70

Calls 14

find_pdaFunction · 0.85
create_accountFunction · 0.85
setMethod · 0.45
dataMethod · 0.45
invoke_signedMethod · 0.45
extensionMethod · 0.45
system_programMethod · 0.45
payerMethod · 0.45
assetMethod · 0.45
addMethod · 0.45
is_someMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected