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