(
program_id: &Pubkey,
ctx: Context<CreateAccounts>,
args: CreateArgs,
)
| 32 | }; |
| 33 | |
| 34 | pub 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, |
no test coverage detected