shadow_nft_standard/
lib.rs

1use anchor_lang::prelude::*;
2
3pub mod common;
4pub mod error;
5pub mod instructions;
6
7use instructions::{
8    burn::*, create::*, create_collection::*, create_group::*, mint::*, update::*, withdraw::*,
9};
10
11declare_id!(shadow_nft_common::STANDARD_PROGRAM);
12
13#[program]
14pub mod shadow_nft_standard {
15
16    use super::*;
17
18    /// Instruction to create a metadata account. A `CreatorGroup` and `Collection` must be initialized.
19    pub fn create_metadata_account(
20        ctx: Context<CreateMetadataAccount>,
21        args: CreateMetaArgs,
22    ) -> Result<()> {
23        handle_create_metadata(ctx, args)
24    }
25
26    /// Instruction to mint an NFT. Requires an existing metadata account.
27    pub fn mint_nft(ctx: Context<MintNFT>, cost_lamports: u64) -> Result<()> {
28        handle_mint(ctx, cost_lamports)
29    }
30
31    /// Instruction to update a metadata account. Requires an existing metadata account.
32    pub fn update_metadata(ctx: Context<UpdateMetadata>, args: UpdateMetaArgs) -> Result<()> {
33        handle_update(ctx, args)
34    }
35
36    /// Instruction to burn a metadata account and associated NFT.
37    pub fn burn(ctx: Context<Burn>) -> Result<()> {
38        handle_burn(ctx)
39    }
40
41    // Instruction to create a `CreatorGroup`. Required for creating a collection.
42    pub fn create_group(ctx: Context<CreateGroup>, args: CreateGroupArgs) -> Result<()> {
43        handle_create_group(ctx, args)
44    }
45
46    // Instruction to withdraw fees from a `Collection` after a mint occurs.
47    pub fn withdraw<'a>(ctx: Context<'_, '_, '_, 'a, Withdraw<'a>>) -> Result<()> {
48        handle_withdraw(ctx)
49    }
50
51    // Instruction to create a `Collection`. A `CreatorGroup` must be initialized.
52    pub fn create_collection(
53        ctx: Context<CreateCollection>,
54        args: CreateCollectionArgs,
55    ) -> Result<()> {
56        handle_create_collection(ctx, args)
57    }
58}
59
60#[macro_export]
61macro_rules! verbose_msg {
62    ($msg:expr) => {
63        #[cfg(feature = "verbose")]
64        anchor_lang::solana_program::log::sol_log($msg)
65    };
66    ($($arg:tt)*) => {
67        #[cfg(feature = "verbose")]
68        (anchor_lang::solana_program::log::sol_log(&format!($($arg)*)))
69    };
70}