use num_derive::FromPrimitive;
use solana_program::{
decode_error::DecodeError,
msg,
program_error::{PrintProgramError, ProgramError},
};
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum MetadataError {
#[error("")]
InstructionUnpackError,
#[error("")]
InstructionPackError,
#[error("Lamport balance below rent-exempt threshold")]
NotRentExempt,
#[error("Already initialized")]
AlreadyInitialized,
#[error("Uninitialized")]
Uninitialized,
#[error(" Metadata's key must match seed of ['metadata', program id, mint] provided")]
InvalidMetadataKey,
#[error("Edition's key must match seed of ['metadata', program id, name, 'edition'] provided")]
InvalidEditionKey,
#[error("Update Authority given does not match")]
UpdateAuthorityIncorrect,
#[error("Update Authority needs to be signer to update metadata")]
UpdateAuthorityIsNotSigner,
#[error("You must be the mint authority and signer on this transaction")]
NotMintAuthority,
#[error("Mint authority provided does not match the authority on the mint")]
InvalidMintAuthority,
#[error("Name too long")]
NameTooLong,
#[error("Symbol too long")]
SymbolTooLong,
#[error("URI too long")]
UriTooLong,
#[error("")]
UpdateAuthorityMustBeEqualToMetadataAuthorityAndSigner,
#[error("Mint given does not match mint on Metadata")]
MintMismatch,
#[error("Editions must have exactly one token")]
EditionsMustHaveExactlyOneToken,
#[error("")]
MaxEditionsMintedAlready,
#[error("")]
TokenMintToFailed,
#[error("")]
MasterRecordMismatch,
#[error("")]
DestinationMintMismatch,
#[error("")]
EditionAlreadyMinted,
#[error("")]
PrintingMintDecimalsShouldBeZero,
#[error("")]
OneTimePrintingAuthorizationMintDecimalsShouldBeZero,
#[error("EditionMintDecimalsShouldBeZero")]
EditionMintDecimalsShouldBeZero,
#[error("")]
TokenBurnFailed,
#[error("")]
TokenAccountOneTimeAuthMintMismatch,
#[error("Derived key invalid")]
DerivedKeyInvalid,
#[error("The Printing mint does not match that on the master edition!")]
PrintingMintMismatch,
#[error("The One Time Printing Auth mint does not match that on the master edition!")]
OneTimePrintingAuthMintMismatch,
#[error("The mint of the token account does not match the Printing mint!")]
TokenAccountMintMismatch,
#[error("The mint of the token account does not match the master metadata mint!")]
TokenAccountMintMismatchV2,
#[error("Not enough tokens to mint a limited edition")]
NotEnoughTokens,
#[error("")]
PrintingMintAuthorizationAccountMismatch,
#[error("")]
AuthorizationTokenAccountOwnerMismatch,
#[error("")]
Disabled,
#[error("Creators list too long")]
CreatorsTooLong,
#[error("Creators must be at least one if set")]
CreatorsMustBeAtleastOne,
#[error("")]
MustBeOneOfCreators,
#[error("This metadata does not have creators")]
NoCreatorsPresentOnMetadata,
#[error("This creator address was not found")]
CreatorNotFound,
#[error("Basis points cannot be more than 10000")]
InvalidBasisPoints,
#[error("Primary sale can only be flipped to true and is immutable")]
PrimarySaleCanOnlyBeFlippedToTrue,
#[error("Owner does not match that on the account given")]
OwnerMismatch,
#[error("This account has no tokens to be used for authorization")]
NoBalanceInAccountForAuthorization,
#[error("Share total must equal 100 for creator array")]
ShareTotalMustBe100,
#[error("")]
ReservationExists,
#[error("")]
ReservationDoesNotExist,
#[error("")]
ReservationNotSet,
#[error("")]
ReservationAlreadyMade,
#[error("")]
BeyondMaxAddressSize,
#[error("NumericalOverflowError")]
NumericalOverflowError,
#[error("")]
ReservationBreachesMaximumSupply,
#[error("")]
AddressNotInReservation,
#[error("You cannot unilaterally verify another creator, they must sign")]
CannotVerifyAnotherCreator,
#[error("You cannot unilaterally unverify another creator")]
CannotUnverifyAnotherCreator,
#[error("")]
SpotMismatch,
#[error("Incorrect account owner")]
IncorrectOwner,
#[error("")]
PrintingWouldBreachMaximumSupply,
#[error("Data is immutable")]
DataIsImmutable,
#[error("No duplicate creator addresses")]
DuplicateCreatorAddress,
#[error("")]
ReservationSpotsRemainingShouldMatchTotalSpotsAtStart,
#[error("Invalid token program")]
InvalidTokenProgram,
#[error("Data type mismatch")]
DataTypeMismatch,
#[error("")]
BeyondAlottedAddressSize,
#[error("")]
ReservationNotComplete,
#[error("")]
TriedToReplaceAnExistingReservation,
#[error("Invalid operation")]
InvalidOperation,
#[error("Invalid Owner")]
InvalidOwner,
#[error("Printing mint supply must be zero for conversion")]
PrintingMintSupplyMustBeZeroForConversion,
#[error("One Time Auth mint supply must be zero for conversion")]
OneTimeAuthMintSupplyMustBeZeroForConversion,
#[error("You tried to insert one edition too many into an edition mark pda")]
InvalidEditionIndex,
#[error("")]
ReservationArrayShouldBeSizeOne,
#[error("Is Mutable can only be flipped to false")]
IsMutableCanOnlyBeFlippedToFalse,
#[error("Collection cannot be verified in this instruction")]
CollectionCannotBeVerifiedInThisInstruction,
#[error("This instruction was deprecated in a previous release and is now removed")]
Removed, #[error("")]
MustBeBurned,
#[error("This use method is invalid")]
InvalidUseMethod,
#[error("Cannot Change Use Method after the first use")]
CannotChangeUseMethodAfterFirstUse,
#[error("Cannot Change Remaining or Available uses after the first use")]
CannotChangeUsesAfterFirstUse,
#[error("Collection Not Found on Metadata")]
CollectionNotFound,
#[error("Collection Update Authority is invalid")]
InvalidCollectionUpdateAuthority,
#[error("Collection Must Be a Unique Master Edition v2")]
CollectionMustBeAUniqueMasterEdition,
#[error("The Use Authority Record Already Exists, to modify it Revoke, then Approve")]
UseAuthorityRecordAlreadyExists,
#[error("The Use Authority Record is empty or already revoked")]
UseAuthorityRecordAlreadyRevoked,
#[error("This token has no uses")]
Unusable,
#[error("There are not enough Uses left on this token.")]
NotEnoughUses,
#[error("This Collection Authority Record Already Exists.")]
CollectionAuthorityRecordAlreadyExists,
#[error("This Collection Authority Record Does Not Exist.")]
CollectionAuthorityDoesNotExist,
#[error("This Use Authority Record is invalid.")]
InvalidUseAuthorityRecord,
#[error("")]
InvalidCollectionAuthorityRecord,
#[error("Metadata does not match the freeze authority on the mint")]
InvalidFreezeAuthority,
#[error("All tokens in this account have not been delegated to this user.")]
InvalidDelegate,
#[error("")]
CannotAdjustVerifiedCreator,
#[error("Verified creators cannot be removed.")]
CannotRemoveVerifiedCreator,
#[error("")]
CannotWipeVerifiedCreators,
#[error("")]
NotAllowedToChangeSellerFeeBasisPoints,
#[error("Edition override cannot be zero")]
EditionOverrideCannotBeZero,
#[error("Invalid User")]
InvalidUser,
#[error("Revoke Collection Authority signer is incorrect")]
RevokeCollectionAuthoritySignerIncorrect,
#[error("")]
TokenCloseFailed,
#[error("Can't use this function on unsized collection")]
UnsizedCollection,
#[error("Can't use this function on a sized collection")]
SizedCollection,
#[error("Missing collection metadata account")]
MissingCollectionMetadata,
#[error("This NFT is not a member of the specified collection.")]
NotAMemberOfCollection,
#[error("This NFT is not a verified member of the specified collection.")]
NotVerifiedMemberOfCollection,
#[error("This NFT is not a collection parent NFT.")]
NotACollectionParent,
#[error("Could not determine a TokenStandard type.")]
CouldNotDetermineTokenStandard,
#[error("This mint account has an edition but none was provided.")]
MissingEditionAccount,
#[error("This edition is not a Master Edition")]
NotAMasterEdition,
#[error("This Master Edition has existing prints")]
MasterEditionHasPrints,
#[error("")]
BorshDeserializationError,
#[error("Cannot update a verified collection in this command")]
CannotUpdateVerifiedCollection,
#[error("Edition account doesnt match collection ")]
CollectionMasterEditionAccountInvalid,
#[error("Item is already verified.")]
AlreadyVerified,
#[error("")]
AlreadyUnverified,
#[error("This edition is not a Print Edition")]
NotAPrintEdition,
#[error("Invalid Master Edition")]
InvalidMasterEdition,
#[error("Invalid Print Edition")]
InvalidPrintEdition,
#[error("Invalid Edition Marker")]
InvalidEditionMarker,
#[error("Reservation List is Deprecated")]
ReservationListDeprecated,
#[error("Print Edition does not match Master Edition")]
PrintEditionDoesNotMatchMasterEdition,
#[error("Edition Number greater than max supply")]
EditionNumberGreaterThanMaxSupply,
#[error("Must unverify before migrating collections.")]
MustUnverify,
#[error("Invalid Escrow Account Bump Seed")]
InvalidEscrowBumpSeed,
#[error("Must Escrow Authority")]
MustBeEscrowAuthority,
#[error("Invalid System Program")]
InvalidSystemProgram,
#[error("Must be a Non Fungible Token")]
MustBeNonFungible,
#[error("Insufficient tokens for transfer")]
InsufficientTokens,
#[error("Borsh Serialization Error")]
BorshSerializationError,
#[error("Cannot create NFT with no Freeze Authority.")]
NoFreezeAuthoritySet,
#[error("Invalid collection size change")]
InvalidCollectionSizeChange,
#[error("Invalid bubblegum signer")]
InvalidBubblegumSigner,
#[error("Escrow parent cannot have a delegate")]
EscrowParentHasDelegate,
#[error("Mint needs to be signer to initialize the account")]
MintIsNotSigner,
#[error("Invalid token standard")]
InvalidTokenStandard,
#[error("Invalid mint account for specified token standard")]
InvalidMintForTokenStandard,
#[error("Invalid authorization rules account")]
InvalidAuthorizationRules,
#[error("Missing authorization rules account")]
MissingAuthorizationRules,
#[error("Missing programmable configuration")]
MissingProgrammableConfig,
#[error("Invalid programmable configuration")]
InvalidProgrammableConfig,
#[error("Delegate already exists")]
DelegateAlreadyExists,
#[error("Delegate not found")]
DelegateNotFound,
#[error("Required account not set in instruction builder")]
MissingAccountInBuilder,
#[error("Required argument not set in instruction builder")]
MissingArgumentInBuilder,
#[error("Feature not supported currently")]
FeatureNotSupported,
#[error("Invalid system wallet")]
InvalidSystemWallet,
#[error("Only the sale delegate can transfer while its set")]
OnlySaleDelegateCanTransfer,
#[error("Missing token account")]
MissingTokenAccount,
#[error("Missing SPL token program")]
MissingSplTokenProgram,
#[error("Missing authorization rules program")]
MissingAuthorizationRulesProgram,
#[error("Invalid delegate role for transfer")]
InvalidDelegateRoleForTransfer,
#[error("Invalid transfer authority")]
InvalidTransferAuthority,
#[error("Instruction not supported for ProgrammableNonFungible assets")]
InstructionNotSupported,
#[error("Public key does not match expected value")]
KeyMismatch,
#[error("Token is locked")]
LockedToken,
#[error("Token is unlocked")]
UnlockedToken,
#[error("Missing delegate role")]
MissingDelegateRole,
#[error("Invalid authority type")]
InvalidAuthorityType,
#[error("Missing token record account")]
MissingTokenRecord,
#[error("Mint supply must be zero for programmable assets")]
MintSupplyMustBeZero,
#[error("Data is empty or zeroed")]
DataIsEmptyOrZeroed,
#[error("Missing token owner")]
MissingTokenOwnerAccount,
#[error("Master edition account has an invalid length")]
InvalidMasterEditionAccountLength,
#[error("Incorrect token state")]
IncorrectTokenState,
#[error("Invalid delegate role")]
InvalidDelegateRole,
#[error("Print supply is required for non-fungibles")]
MissingPrintSupply,
#[error("Missing master edition account")]
MissingMasterEditionAccount,
#[error("Amount must be greater than zero")]
AmountMustBeGreaterThanZero,
#[error("Invalid delegate args")]
InvalidDelegateArgs,
#[error("Missing address for locked transfer")]
MissingLockedTransferAddress,
#[error("Invalid destination address for locked transfer")]
InvalidLockedTransferAddress,
#[error("Exceeded account realloc increase limit")]
DataIncrementLimitExceeded,
#[error("Cannot update the rule set of a programmable asset that has a delegate")]
CannotUpdateAssetWithDelegate,
#[error("Invalid token amount for this operation or token standard")]
InvalidAmount,
#[error("Missing master edition mint account")]
MissingMasterEditionMintAccount,
#[error("Missing master edition token account")]
MissingMasterEditionTokenAccount,
#[error("Missing edition marker account")]
MissingEditionMarkerAccount,
#[error("Cannot burn while persistent delegate is set")]
CannotBurnWithDelegate,
#[error("Missing edition account")]
MissingEdition,
#[error("Invalid Associated Token Account Program")]
InvalidAssociatedTokenAccountProgram,
#[error("Invalid InstructionsSysvar")]
InvalidInstructionsSysvar,
#[error("Invalid or Unneeded parent accounts")]
InvalidParentAccounts,
#[error("Authority cannot apply all update args")]
InvalidUpdateArgs,
#[error("Token account does not have enough tokens")]
InsufficientTokenBalance,
#[error("Missing collection account")]
MissingCollectionMint,
#[error("Missing collection master edition account")]
MissingCollectionMasterEdition,
#[error("Invalid token record account")]
InvalidTokenRecord,
#[error("The close authority needs to be revoked by the Utility Delegate")]
InvalidCloseAuthority,
#[error("Invalid or removed instruction")]
InvalidInstruction,
#[error("Missing delegate record")]
MissingDelegateRecord,
#[error("")]
InvalidFeeAccount,
#[error("")]
InvalidMetadataFlags,
}
impl PrintProgramError for MetadataError {
fn print<E>(&self) {
msg!(&self.to_string());
}
}
impl From<MetadataError> for ProgramError {
fn from(e: MetadataError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for MetadataError {
fn type_of() -> &'static str {
"Metadata Error"
}
}