11use pinocchio:: program_error:: ProgramError ;
22
3+ /// Instructions supported by the program metadata program.
34#[ derive( Clone , Copy , Debug ) ]
45pub enum ProgramMetadataInstruction {
56 /// Writes data to a pre-funded buffer.
@@ -45,7 +46,7 @@ pub enum ProgramMetadataInstruction {
4546 /// - `u8`: compression
4647 /// - `u8`: format
4748 /// - `u8`: data source
48- /// - `[u8]`: (optional) bytes
49+ /// - `[u8]`: (optional) bytes to write
4950 Initialize ,
5051
5152 /// Sets the authority of a buffer or metadata account.
@@ -55,13 +56,20 @@ pub enum ProgramMetadataInstruction {
5556 /// required.
5657 ///
5758 /// Special cases:
58- /// - It is not possible to set an authority if the metadata account
59- /// is non-canonical, otherwise the derivation becomes invalid.
60- /// - It is not possible to set an authority if the metadata account
61- /// is immutable.
62- /// - If no new authority is provided for a metadata account, the
63- /// authority is removed.
64- /// - It is not possible to remove the authority of a buffer account.
59+ /// - It is not possible to set an authority if the metadata account
60+ /// is non-canonical, otherwise the derivation becomes invalid.
61+ /// - It is not possible to set an authority if the metadata account
62+ /// is immutable.
63+ /// - If no new authority is provided for a metadata account, the
64+ /// authority is removed. For canonical metadata accounts, the program
65+ /// upgrade authority will still be able to manage the account.
66+ /// - It is not possible to remove the authority of a buffer account.
67+ ///
68+ /// There are 2 optional accounts:
69+ /// - `program`: required to validate whether the authority is the program upgrade
70+ /// authority.
71+ /// - `program_data`: required to validate whether the authority is the program upgrade
72+ /// authority.
6573 ///
6674 /// Accounts expected by this instruction:
6775 ///
@@ -76,7 +84,7 @@ pub enum ProgramMetadataInstruction {
7684 /// - `[u8; 32]`: (optional) new authority
7785 SetAuthority ,
7886
79- /// Sets the data and its metadata.
87+ /// Sets the data to a program metadata account .
8088 ///
8189 /// The data can be provided as instruction data or copied from a buffer
8290 /// account. When setting the data to a `canonical` metadata account
@@ -85,6 +93,13 @@ pub enum ProgramMetadataInstruction {
8593 ///
8694 /// Note: It is not possible to set data if the account is immutable.
8795 ///
96+ /// There are 2 optional accounts:
97+ /// - `buffer`: used to specify the data to be copied.
98+ /// - `program`: required to validate whether the authority is the program upgrade
99+ /// authority.
100+ /// - `program_data`: required to validate whether the authority is the program upgrade
101+ /// authority.
102+ ///
88103 /// Accounts expected by this instruction:
89104 ///
90105 /// 0. `[w]` Metadata account.
@@ -99,11 +114,17 @@ pub enum ProgramMetadataInstruction {
99114 /// - `u8`: compression
100115 /// - `u8`: format
101116 /// - `u8`: data source
102- /// - `[u8]`: (optional) bytes
117+ /// - `[u8]`: (optional) bytes to write
103118 SetData ,
104119
105120 /// Sets the metadata account as immutable.
106121 ///
122+ /// There are 2 optional accounts:
123+ /// - `program`: required to validate whether the authority is the program upgrade
124+ /// authority.
125+ /// - `program_data`: required to validate whether the authority is the program upgrade
126+ /// authority.
127+ ///
107128 /// Accounts expected by this instruction:
108129 ///
109130 /// 0. `[w]` Metadata account.
@@ -112,12 +133,18 @@ pub enum ProgramMetadataInstruction {
112133 /// 3. `[o]` (optional) Program data account.
113134 SetImmutable ,
114135
115- /// Withdraws excess lamports from a buffer or metadata account.
136+ /// Resizes and withdraws excess lamports from a buffer or metadata account.
116137 ///
117138 /// This instruction will attempt to resize the account to its
118139 /// minimum size required to be rent exempt, returning any extra
119140 /// lamports to the `destination` account.
120141 ///
142+ /// There are 2 optional accounts:
143+ /// - `program`: required to validate whether the authority is the program upgrade
144+ /// authority.
145+ /// - `program_data`: required to validate whether the authority is the program upgrade
146+ /// authority.
147+ ///
121148 /// Accounts expected by this instruction:
122149 ///
123150 /// 0. `[w]` Buffer or metadata account.
@@ -128,14 +155,20 @@ pub enum ProgramMetadataInstruction {
128155 /// 6. `[]` Rent sysvar account.
129156 Trim ,
130157
131- /// Closes a program-owned account.
158+ /// Closes a program-owned buffer or metadata account.
132159 ///
133160 /// The lamports in the metadata account are transferred to the destination
134161 /// account.
135162 ///
136163 /// Note: It is not possible to close a metadata account if the account
137164 /// is immutable.
138165 ///
166+ /// There are 2 optional accounts:
167+ /// - `program`: required to validate whether the authority is the program upgrade
168+ /// authority.
169+ /// - `program_data`: required to validate whether the authority is the program upgrade
170+ /// authority.
171+ ///
139172 /// Accounts expected by this instruction:
140173 ///
141174 /// 0. `[w]` Account to close.
@@ -157,6 +190,14 @@ pub enum ProgramMetadataInstruction {
157190 ///
158191 /// A `seed` value is required for PDA buffer accounts.
159192 ///
193+ /// There are 2 optional accounts:
194+ /// - `program`: required to validate whether the authority is the program upgrade
195+ /// authority.
196+ /// - `program_data`: required to validate whether the authority is the program upgrade
197+ /// authority.
198+ /// - `system_program`: required to allocate the account. When using a pre-allocated buffer,
199+ /// this is not required.
200+ ///
160201 /// Accounts expected by this instruction:
161202 ///
162203 /// 0. `[w]` Buffer account to allocate.
@@ -170,11 +211,17 @@ pub enum ProgramMetadataInstruction {
170211 /// - `[u8; 16]`: seed (optional)
171212 Allocate ,
172213
173- /// Extends the buffer or metadata account data by the requested length.
214+ /// Extends a buffer or metadata account data by the requested length.
174215 ///
175216 /// The account is expected to be pre-funded with the required lamports
176217 /// for the new size.
177218 ///
219+ /// There are 2 optional accounts:
220+ /// - `program`: required to validate whether the authority is the program upgrade
221+ /// authority.
222+ /// - `program_data`: required to validate whether the authority is the program upgrade
223+ /// authority.
224+ ///
178225 /// Accounts expected by this instruction:
179226 ///
180227 /// 0. `[w]` Buffer or metadata account.
0 commit comments