1solana_program::declare_id!("metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s");
6
7pub(crate) mod instruction {
8 use {
9 super::state::DataV2,
10 borsh::{BorshDeserialize, BorshSerialize},
11 solana_program::{
12 instruction::{AccountMeta, Instruction},
13 pubkey::Pubkey,
14 },
15 };
16
17 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
18 struct CreateMetadataAccountArgsV3 {
19 pub data: DataV2,
21 pub is_mutable: bool,
23 pub collection_details: Option<u8>,
25 }
26
27 #[allow(clippy::too_many_arguments)]
28 pub(crate) fn create_metadata_accounts_v3(
29 program_id: Pubkey,
30 metadata_account: Pubkey,
31 mint: Pubkey,
32 mint_authority: Pubkey,
33 payer: Pubkey,
34 update_authority: Pubkey,
35 name: String,
36 symbol: String,
37 uri: String,
38 ) -> Instruction {
39 let mut data = vec![33]; data.append(
41 &mut borsh::to_vec(&CreateMetadataAccountArgsV3 {
42 data: DataV2 {
43 name,
44 symbol,
45 uri,
46 seller_fee_basis_points: 0,
47 creators: None,
48 collection: None,
49 uses: None,
50 },
51 is_mutable: true,
52 collection_details: None,
53 })
54 .unwrap(),
55 );
56 Instruction {
57 program_id,
58 accounts: vec![
59 AccountMeta::new(metadata_account, false),
60 AccountMeta::new_readonly(mint, false),
61 AccountMeta::new_readonly(mint_authority, true),
62 AccountMeta::new(payer, true),
63 AccountMeta::new_readonly(update_authority, true),
64 AccountMeta::new_readonly(solana_program::system_program::ID, false),
65 ],
66 data,
67 }
68 }
69
70 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
71 struct UpdateMetadataAccountArgsV2 {
72 pub data: Option<DataV2>,
73 pub update_authority: Option<Pubkey>,
74 pub primary_sale_happened: Option<bool>,
75 pub is_mutable: Option<bool>,
76 }
77 pub(crate) fn update_metadata_accounts_v2(
78 program_id: Pubkey,
79 metadata_account: Pubkey,
80 update_authority: Pubkey,
81 new_update_authority: Option<Pubkey>,
82 metadata: Option<DataV2>,
83 primary_sale_happened: Option<bool>,
84 is_mutable: Option<bool>,
85 ) -> Instruction {
86 let mut data = vec![15]; data.append(
88 &mut borsh::to_vec(&UpdateMetadataAccountArgsV2 {
89 data: metadata,
90 update_authority: new_update_authority,
91 primary_sale_happened,
92 is_mutable,
93 })
94 .unwrap(),
95 );
96 Instruction {
97 program_id,
98 accounts: vec![
99 AccountMeta::new(metadata_account, false),
100 AccountMeta::new_readonly(update_authority, true),
101 ],
102 data,
103 }
104 }
105}
106
107pub mod pda {
109 use {super::ID, solana_program::pubkey::Pubkey};
110 const PREFIX: &str = "metadata";
111 pub fn find_metadata_account(mint: &Pubkey) -> (Pubkey, u8) {
113 Pubkey::find_program_address(&[PREFIX.as_bytes(), ID.as_ref(), mint.as_ref()], &ID)
114 }
115}
116
117pub(crate) mod state {
118 use borsh::{BorshDeserialize, BorshSerialize};
119 #[repr(C)]
120 #[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone)]
121 pub(crate) struct DataV2 {
122 pub name: String,
124 pub symbol: String,
126 pub uri: String,
128 pub seller_fee_basis_points: u16,
131 pub creators: Option<u8>,
133 pub collection: Option<u8>,
135 pub uses: Option<u8>,
137 }
138}