solana_nft_token_metadata/
error.rs1use num_derive::FromPrimitive;
4use solana_program::{
5 decode_error::DecodeError,
6 msg,
7 program_error::{PrintProgramError, ProgramError},
8};
9use thiserror::Error;
10
11#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
13pub enum MetadataError {
14 #[error("Failed to unpack instruction data")]
16 InstructionUnpackError,
17
18 #[error("Failed to pack instruction data")]
20 InstructionPackError,
21
22 #[error("Lamport balance below rent-exempt threshold")]
24 NotRentExempt,
25
26 #[error("Already initialized")]
28 AlreadyInitialized,
29
30 #[error("Uninitialized")]
32 Uninitialized,
33
34 #[error(" Metadata's key must match seed of ['metadata', program id, mint] provided")]
36 InvalidMetadataKey,
37
38 #[error("Edition's key must match seed of ['metadata', program id, name, 'edition'] provided")]
40 InvalidEditionKey,
41
42 #[error("Update Authority given does not match")]
44 UpdateAuthorityIncorrect,
45
46 #[error("Update Authority needs to be signer to update metadata")]
48 UpdateAuthorityIsNotSigner,
49
50 #[error("You must be the mint authority and signer on this transaction")]
52 NotMintAuthority,
53
54 #[error("Mint authority provided does not match the authority on the mint")]
56 InvalidMintAuthority,
57
58 #[error("Name too long")]
60 NameTooLong,
61
62 #[error("Symbol too long")]
64 SymbolTooLong,
65
66 #[error("URI too long")]
68 UriTooLong,
69
70 #[error("Update authority must be equivalent to the metadata's authority and also signer of this transaction")]
72 UpdateAuthorityMustBeEqualToMetadataAuthorityAndSigner,
73
74 #[error("Mint given does not match mint on Metadata")]
76 MintMismatch,
77
78 #[error("Editions must have exactly one token")]
80 EditionsMustHaveExactlyOneToken,
81
82 #[error("Maximum editions printed already")]
84 MaxEditionsMintedAlready,
85
86 #[error("Token mint to failed")]
88 TokenMintToFailed,
89
90 #[error("The master edition record passed must match the master record on the edition given")]
92 MasterRecordMismatch,
93
94 #[error("The destination account does not have the right mint")]
96 DestinationMintMismatch,
97
98 #[error("An edition can only mint one of its kind!")]
100 EditionAlreadyMinted,
101
102 #[error("Printing mint decimals should be zero")]
104 PrintingMintDecimalsShouldBeZero,
105
106 #[error("OneTimePrintingAuthorization mint decimals should be zero")]
108 OneTimePrintingAuthorizationMintDecimalsShouldBeZero,
109
110 #[error("EditionMintDecimalsShouldBeZero")]
112 EditionMintDecimalsShouldBeZero,
113
114 #[error("Token burn failed")]
116 TokenBurnFailed,
117
118 #[error("The One Time authorization mint does not match that on the token account!")]
120 TokenAccountOneTimeAuthMintMismatch,
121
122 #[error("Derived key invalid")]
124 DerivedKeyInvalid,
125
126 #[error("The Printing mint does not match that on the master edition!")]
128 PrintingMintMismatch,
129
130 #[error("The One Time Printing Auth mint does not match that on the master edition!")]
132 OneTimePrintingAuthMintMismatch,
133
134 #[error("The mint of the token account does not match the Printing mint!")]
136 TokenAccountMintMismatch,
137
138 #[error("The mint of the token account does not match the master metadata mint!")]
140 TokenAccountMintMismatchV2,
141
142 #[error("Not enough tokens to mint a limited edition")]
144 NotEnoughTokens,
145
146 #[error(
148 "The mint on your authorization token holding account does not match your Printing mint!"
149 )]
150 PrintingMintAuthorizationAccountMismatch,
151
152 #[error("The authorization token account has a different owner than the update authority for the master edition!")]
154 AuthorizationTokenAccountOwnerMismatch,
155
156 #[error("This feature is currently disabled.")]
158 Disabled,
159
160 #[error("Creators list too long")]
162 CreatorsTooLong,
163
164 #[error("Creators must be at least one if set")]
166 CreatorsMustBeAtleastOne,
167
168 #[error("If using a creators array, you must be one of the creators listed")]
170 MustBeOneOfCreators,
171
172 #[error("This metadata does not have creators")]
174 NoCreatorsPresentOnMetadata,
175
176 #[error("This creator address was not found")]
178 CreatorNotFound,
179
180 #[error("Basis points cannot be more than 10000")]
182 InvalidBasisPoints,
183
184 #[error("Primary sale can only be flipped to true and is immutable")]
186 PrimarySaleCanOnlyBeFlippedToTrue,
187
188 #[error("Owner does not match that on the account given")]
190 OwnerMismatch,
191
192 #[error("This account has no tokens to be used for authorization")]
194 NoBalanceInAccountForAuthorization,
195
196 #[error("Share total must equal 100 for creator array")]
198 ShareTotalMustBe100,
199
200 #[error("This reservation list already exists!")]
202 ReservationExists,
203
204 #[error("This reservation list does not exist!")]
206 ReservationDoesNotExist,
207
208 #[error("This reservation list exists but was never set with reservations")]
210 ReservationNotSet,
211
212 #[error("This reservation list has already been set!")]
214 ReservationAlreadyMade,
215
216 #[error("Provided more addresses than max allowed in single reservation")]
218 BeyondMaxAddressSize,
219
220 #[error("NumericalOverflowError")]
222 NumericalOverflowError,
223
224 #[error("This reservation would go beyond the maximum supply of the master edition!")]
226 ReservationBreachesMaximumSupply,
227
228 #[error("Address not in reservation!")]
230 AddressNotInReservation,
231
232 #[error("You cannot unilaterally verify another creator, they must sign")]
234 CannotVerifyAnotherCreator,
235
236 #[error("You cannot unilaterally unverify another creator")]
238 CannotUnverifyAnotherCreator,
239
240 #[error("In initial reservation setting, spots remaining should equal total spots")]
242 SpotMismatch,
243
244 #[error("Incorrect account owner")]
246 IncorrectOwner,
247
248 #[error("printing these tokens would breach the maximum supply limit of the master edition")]
250 PrintingWouldBreachMaximumSupply,
251
252 #[error("Data is immutable")]
254 DataIsImmutable,
255
256 #[error("No duplicate creator addresses")]
258 DuplicateCreatorAddress,
259
260 #[error("Reservation spots remaining should match total spots when first being created")]
262 ReservationSpotsRemainingShouldMatchTotalSpotsAtStart,
263
264 #[error("Invalid token program")]
266 InvalidTokenProgram,
267
268 #[error("Data type mismatch")]
270 DataTypeMismatch,
271
272 #[error("Beyond alotted address size in reservation!")]
274 BeyondAlottedAddressSize,
275
276 #[error("The reservation has only been partially alotted")]
278 ReservationNotComplete,
279
280 #[error("You cannot splice over an existing reservation!")]
282 TriedToReplaceAnExistingReservation,
283
284 #[error("Invalid operation")]
286 InvalidOperation,
287
288 #[error("Invalid Owner")]
290 InvalidOwner,
291
292 #[error("Printing mint supply must be zero for conversion")]
294 PrintingMintSupplyMustBeZeroForConversion,
295
296 #[error("One Time Auth mint supply must be zero for conversion")]
298 OneTimeAuthMintSupplyMustBeZeroForConversion,
299
300 #[error("You tried to insert one edition too many into an edition mark pda")]
302 InvalidEditionIndex,
303
304 #[error("In the legacy system the reservation needs to be of size one for cpu limit reasons")]
306 ReservationArrayShouldBeSizeOne,
307
308 #[error("Is Mutable can only be flipped to false")]
310 IsMutableCanOnlyBeFlippedToFalse,
311
312 #[error("Cannont Verify Collection in this Instruction")]
313 CollectionCannotBeVerifiedInThisInstruction,
314
315 #[error("This instruction was deprecated in a previous release and is now removed")]
316 Removed, #[error("This token use method is burn and there are no remaining uses, it must be burned")]
319 MustBeBurned,
320
321 #[error("This use method is invalid")]
322 InvalidUseMethod,
323 #[error("Cannot Change Use Method after the first use")]
324 CannotChangeUseMethodAfterFirstUse,
325
326 #[error("Cannot Change Remaining or Available uses after the first use")]
327 CannotChangeUsesAfterFirstUse,
328
329 #[error("Collection Not Found on Metadata")]
330 CollectionNotFound,
331
332 #[error("Collection Update Authority is invalid")]
333 InvalidCollectionUpdateAuthority,
334
335 #[error("Collection Must Be a Unique Master Edition v2")]
336 CollectionMustBeAUniqueMasterEdition,
337
338 #[error("The Use Authority Record Already Exists, to modify it Revoke, then Approve")]
339 UseAuthorityRecordAlreadyExists,
340
341 #[error("The Use Authority Record is empty or already revoked")]
342 UseAuthorityRecordAlreadyRevoked,
343
344 #[error("This token has no uses")]
345 Unusable,
346
347 #[error("There are not enough Uses left on this token.")]
348 NotEnoughUses,
349
350 #[error("This Collection Authority Record Already Exists.")]
351 CollectionAuthorityRecordAlreadyExists,
352
353 #[error("This Collection Authoritty Record Does Not Exist.")]
354 CollectionAuthorityDoesNotExist,
355}
356
357impl PrintProgramError for MetadataError {
358 fn print<E>(&self) {
359 msg!(&self.to_string());
360 }
361}
362
363impl From<MetadataError> for ProgramError {
364 fn from(e: MetadataError) -> Self {
365 ProgramError::Custom(e as u32)
366 }
367}
368
369impl<T> DecodeError<T> for MetadataError {
370 fn type_of() -> &'static str {
371 "Metadata Error"
372 }
373}