1use 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("Collection cannot be verified 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
324 #[error("Cannot Change Use Method after the first use")]
325 CannotChangeUseMethodAfterFirstUse,
326
327 #[error("Cannot Change Remaining or Available uses after the first use")]
328 CannotChangeUsesAfterFirstUse,
329
330 #[error("Collection Not Found on Metadata")]
332 CollectionNotFound,
333
334 #[error("Collection Update Authority is invalid")]
335 InvalidCollectionUpdateAuthority,
336
337 #[error("Collection Must Be a Unique Master Edition v2")]
338 CollectionMustBeAUniqueMasterEdition,
339
340 #[error("The Use Authority Record Already Exists, to modify it Revoke, then Approve")]
341 UseAuthorityRecordAlreadyExists,
342
343 #[error("The Use Authority Record is empty or already revoked")]
344 UseAuthorityRecordAlreadyRevoked,
345
346 #[error("This token has no uses")]
347 Unusable,
348
349 #[error("There are not enough Uses left on this token.")]
350 NotEnoughUses,
351
352 #[error("This Collection Authority Record Already Exists.")]
353 CollectionAuthorityRecordAlreadyExists,
354
355 #[error("This Collection Authority Record Does Not Exist.")]
356 CollectionAuthorityDoesNotExist,
357
358 #[error("This Use Authority Record is invalid.")]
359 InvalidUseAuthorityRecord,
360
361 #[error("This Collection Authority Record is invalid.")]
363 InvalidCollectionAuthorityRecord,
364
365 #[error("Metadata does not match the freeze authority on the mint")]
366 InvalidFreezeAuthority,
367
368 #[error("All tokens in this account have not been delegated to this user.")]
369 InvalidDelegate,
370
371 #[error("Creator can not be adjusted once they are verified.")]
372 CannotAdjustVerifiedCreator,
373
374 #[error("Verified creators cannot be removed.")]
375 CannotRemoveVerifiedCreator,
376
377 #[error("Can not wipe verified creators.")]
378 CannotWipeVerifiedCreators,
379
380 #[error("Not allowed to change seller fee basis points.")]
381 NotAllowedToChangeSellerFeeBasisPoints,
382
383 #[error("Edition override cannot be zero")]
385 EditionOverrideCannotBeZero,
386
387 #[error("Invalid User")]
388 InvalidUser,
389
390 #[error("Revoke Collection Authority signer is incorrect")]
392 RevokeCollectionAuthoritySignerIncorrect,
393
394 #[error("Token close failed")]
396 TokenCloseFailed,
397
398 #[error("Can't use this function on unsized collection")]
400 UnsizedCollection,
401
402 #[error("Can't use this function on a sized collection")]
404 SizedCollection,
405
406 #[error("Missing collection metadata account")]
408 MissingCollectionMetadata,
409
410 #[error("This NFT is not a member of the specified collection.")]
412 NotAMemberOfCollection,
413
414 #[error("This NFT is not a verified member of the specified collection.")]
416 NotVerifiedMemberOfCollection,
417
418 #[error("This NFT is not a collection parent NFT.")]
420 NotACollectionParent,
421
422 #[error("Could not determine a TokenStandard type.")]
424 CouldNotDetermineTokenStandard,
425
426 #[error("This mint account has an edition but none was provided.")]
428 MissingEditionAccount,
429
430 #[error("This edition is not a Master Edition")]
432 NotAMasterEdition,
433
434 #[error("This Master Edition has existing prints")]
436 MasterEditionHasPrints,
437
438 #[error("Borsh Deserialization Error")]
440 BorshDeserializationError,
441
442 #[error("Cannot update a verified collection in this command")]
444 CannotUpdateVerifiedCollection,
445
446 #[error("Edition account doesnt match collection ")]
448 CollectionMasterEditionAccountInvalid,
449
450 #[error("Item is already verified.")]
452 AlreadyVerified,
453
454 #[error("Item is already unverified.")]
456 AlreadyUnverified,
457
458 #[error("This edition is not a Print Edition")]
460 NotAPrintEdition,
461
462 #[error("Invalid Master Edition")]
464 InvalidMasterEdition,
465
466 #[error("Invalid Print Edition")]
468 InvalidPrintEdition,
469
470 #[error("Invalid Edition Marker")]
472 InvalidEditionMarker,
473
474 #[error("Reservation List is Deprecated")]
476 ReservationListDeprecated,
477
478 #[error("Print Edition does not match Master Edition")]
480 PrintEditionDoesNotMatchMasterEdition,
481
482 #[error("Edition Number greater than max supply")]
484 EditionNumberGreaterThanMaxSupply,
485
486 #[error("Must unverify before migrating collections.")]
488 MustUnverify,
489
490 #[error("Invalid Escrow Account Bump Seed")]
492 InvalidEscrowBumpSeed,
493
494 #[error("Must Escrow Authority")]
496 MustBeEscrowAuthority,
497
498 #[error("Invalid System Program")]
500 InvalidSystemProgram,
501
502 #[error("Must be a Non Fungible Token")]
504 MustBeNonFungible,
505
506 #[error("Insufficient tokens for transfer")]
508 InsufficientTokens,
509
510 #[error("Borsh Serialization Error")]
512 BorshSerializationError,
513
514 #[error("Cannot create NFT with no Freeze Authority.")]
516 NoFreezeAuthoritySet,
517
518 #[error("Invalid collection size change")]
520 InvalidCollectionSizeChange,
521
522 #[error("Invalid bubblegum signer")]
524 InvalidBubblegumSigner,
525 #[error("Escrow parent cannot have a delegate")]
527 EscrowParentHasDelegate,
528
529 #[error("Mint needs to be signer to initialize the account")]
531 MintIsNotSigner,
532
533 #[error("Invalid token standard")]
535 InvalidTokenStandard,
536
537 #[error("Invalid mint account for specified token standard")]
539 InvalidMintForTokenStandard,
540
541 #[error("Invalid authorization rules account")]
543 InvalidAuthorizationRules,
544
545 #[error("Missing authorization rules account")]
547 MissingAuthorizationRules,
548
549 #[error("Missing programmable configuration")]
551 MissingProgrammableConfig,
552
553 #[error("Invalid programmable configuration")]
555 InvalidProgrammableConfig,
556
557 #[error("Delegate already exists")]
559 DelegateAlreadyExists,
560
561 #[error("Delegate not found")]
563 DelegateNotFound,
564
565 #[error("Required account not set in instruction builder")]
567 MissingAccountInBuilder,
568
569 #[error("Required argument not set in instruction builder")]
571 MissingArgumentInBuilder,
572
573 #[error("Feature not supported currently")]
575 FeatureNotSupported,
576
577 #[error("Invalid system wallet")]
579 InvalidSystemWallet,
580
581 #[error("Only the sale delegate can transfer while its set")]
583 OnlySaleDelegateCanTransfer,
584
585 #[error("Missing token account")]
587 MissingTokenAccount,
588
589 #[error("Missing SPL token program")]
591 MissingSplTokenProgram,
592
593 #[error("Missing authorization rules program")]
595 MissingAuthorizationRulesProgram,
596
597 #[error("Invalid delegate role for transfer")]
599 InvalidDelegateRoleForTransfer,
600
601 #[error("Invalid transfer authority")]
603 InvalidTransferAuthority,
604
605 #[error("Instruction not supported for ProgrammableNonFungible assets")]
607 InstructionNotSupported,
608
609 #[error("Public key does not match expected value")]
611 KeyMismatch,
612
613 #[error("Token is locked")]
615 LockedToken,
616
617 #[error("Token is unlocked")]
619 UnlockedToken,
620
621 #[error("Missing delegate role")]
623 MissingDelegateRole,
624
625 #[error("Invalid authority type")]
627 InvalidAuthorityType,
628
629 #[error("Missing token record account")]
631 MissingTokenRecord,
632
633 #[error("Mint supply must be zero for programmable assets")]
635 MintSupplyMustBeZero,
636
637 #[error("Data is empty or zeroed")]
639 DataIsEmptyOrZeroed,
640
641 #[error("Missing token owner")]
643 MissingTokenOwnerAccount,
644
645 #[error("Master edition account has an invalid length")]
647 InvalidMasterEditionAccountLength,
648
649 #[error("Incorrect token state")]
651 IncorrectTokenState,
652
653 #[error("Invalid delegate role")]
655 InvalidDelegateRole,
656
657 #[error("Print supply is required for non-fungibles")]
659 MissingPrintSupply,
660
661 #[error("Missing master edition account")]
663 MissingMasterEditionAccount,
664
665 #[error("Amount must be greater than zero")]
667 AmountMustBeGreaterThanZero,
668
669 #[error("Invalid delegate args")]
671 InvalidDelegateArgs,
672
673 #[error("Missing address for locked transfer")]
675 MissingLockedTransferAddress,
676
677 #[error("Invalid destination address for locked transfer")]
679 InvalidLockedTransferAddress,
680
681 #[error("Exceeded account realloc increase limit")]
683 DataIncrementLimitExceeded,
684
685 #[error("Cannot update the rule set of a programmable asset that has a delegate")]
687 CannotUpdateAssetWithDelegate,
688
689 #[error("Invalid token amount for this operation or token standard")]
691 InvalidAmount,
692
693 #[error("Missing master edition mint account")]
695 MissingMasterEditionMintAccount,
696
697 #[error("Missing master edition token account")]
699 MissingMasterEditionTokenAccount,
700
701 #[error("Missing edition marker account")]
703 MissingEditionMarkerAccount,
704
705 #[error("Cannot burn while persistent delegate is set")]
707 CannotBurnWithDelegate,
708
709 #[error("Missing edition account")]
711 MissingEdition,
712
713 #[error("Invalid Associated Token Account Program")]
715 InvalidAssociatedTokenAccountProgram,
716
717 #[error("Invalid InstructionsSysvar")]
719 InvalidInstructionsSysvar,
720
721 #[error("Invalid or Unneeded parent accounts")]
723 InvalidParentAccounts,
724
725 #[error("Authority cannot apply all update args")]
727 InvalidUpdateArgs,
728
729 #[error("Token account does not have enough tokens")]
731 InsufficientTokenBalance,
732
733 #[error("Missing collection account")]
735 MissingCollectionMint,
736
737 #[error("Missing collection master edition account")]
739 MissingCollectionMasterEdition,
740
741 #[error("Invalid token record account")]
743 InvalidTokenRecord,
744
745 #[error("The close authority needs to be revoked by the Utility Delegate")]
747 InvalidCloseAuthority,
748
749 #[error("Invalid or removed instruction")]
751 InvalidInstruction,
752
753 #[error("Missing delegate record")]
755 MissingDelegateRecord,
756}
757
758impl PrintProgramError for MetadataError {
759 fn print<E>(&self) {
760 msg!(&self.to_string());
761 }
762}
763
764impl From<MetadataError> for ProgramError {
765 fn from(e: MetadataError) -> Self {
766 ProgramError::Custom(e as u32)
767 }
768}
769
770impl<T> DecodeError<T> for MetadataError {
771 fn type_of() -> &'static str {
772 "Metadata Error"
773 }
774}