mpl-bubblegum 3.0.0

Metaplex Bubblegum SDK
Documentation
//! This code was AUTOGENERATED using the kinobi library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun kinobi to update it.
//!
//! [https://github.com/metaplex-foundation/kinobi]
//!

use num_derive::FromPrimitive;
use solana_program_error::{ProgramError, ToStr};
use thiserror::Error;

#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum MplBubblegumError {
    /// 6000 (0x1770) - Asset Owner Does not match
    #[error("Asset Owner Does not match")]
    AssetOwnerMismatch,
    /// 6001 (0x1771) - PublicKeyMismatch
    #[error("PublicKeyMismatch")]
    PublicKeyMismatch,
    /// 6002 (0x1772) - Hashing Mismatch Within Leaf Schema
    #[error("Hashing Mismatch Within Leaf Schema")]
    HashingMismatch,
    /// 6003 (0x1773) - Unsupported Schema Version
    #[error("Unsupported Schema Version")]
    UnsupportedSchemaVersion,
    /// 6004 (0x1774) - Creator shares must sum to 100
    #[error("Creator shares must sum to 100")]
    CreatorShareTotalMustBe100,
    /// 6005 (0x1775) - No duplicate creator addresses in metadata
    #[error("No duplicate creator addresses in metadata")]
    DuplicateCreatorAddress,
    /// 6006 (0x1776) - Creator did not verify the metadata
    #[error("Creator did not verify the metadata")]
    CreatorDidNotVerify,
    /// 6007 (0x1777) - Creator not found in creator Vec
    #[error("Creator not found in creator Vec")]
    CreatorNotFound,
    /// 6008 (0x1778) - No creators in creator Vec
    #[error("No creators in creator Vec")]
    NoCreatorsPresent,
    /// 6009 (0x1779) - User-provided creator Vec must result in same user-provided creator hash
    #[error("User-provided creator Vec must result in same user-provided creator hash")]
    CreatorHashMismatch,
    /// 6010 (0x177A) - User-provided metadata must result in same user-provided data hash
    #[error("User-provided metadata must result in same user-provided data hash")]
    DataHashMismatch,
    /// 6011 (0x177B) - Creators list too long
    #[error("Creators list too long")]
    CreatorsTooLong,
    /// 6012 (0x177C) - Name in metadata is too long
    #[error("Name in metadata is too long")]
    MetadataNameTooLong,
    /// 6013 (0x177D) - Symbol in metadata is too long
    #[error("Symbol in metadata is too long")]
    MetadataSymbolTooLong,
    /// 6014 (0x177E) - Uri in metadata is too long
    #[error("Uri in metadata is too long")]
    MetadataUriTooLong,
    /// 6015 (0x177F) - Basis points in metadata cannot exceed 10000
    #[error("Basis points in metadata cannot exceed 10000")]
    MetadataBasisPointsTooHigh,
    /// 6016 (0x1780) - Tree creator or tree delegate must sign.
    #[error("Tree creator or tree delegate must sign.")]
    TreeAuthorityIncorrect,
    /// 6017 (0x1781) - Not enough unapproved mints left
    #[error("Not enough unapproved mints left")]
    InsufficientMintCapacity,
    /// 6018 (0x1782) - NumericalOverflowError
    #[error("NumericalOverflowError")]
    NumericalOverflowError,
    /// 6019 (0x1783) - Incorrect account owner
    #[error("Incorrect account owner")]
    IncorrectOwner,
    /// 6020 (0x1784) - Cannot Verify Collection in this Instruction
    #[error("Cannot Verify Collection in this Instruction")]
    CollectionCannotBeVerifiedInThisInstruction,
    /// 6021 (0x1785) - Collection Not Found on Metadata
    #[error("Collection Not Found on Metadata")]
    CollectionNotFound,
    /// 6022 (0x1786) - Collection item is already verified.
    #[error("Collection item is already verified.")]
    AlreadyVerified,
    /// 6023 (0x1787) - Collection item is already unverified.
    #[error("Collection item is already unverified.")]
    AlreadyUnverified,
    /// 6024 (0x1788) - Incorrect leaf metadata update authority.
    #[error("Incorrect leaf metadata update authority.")]
    UpdateAuthorityIncorrect,
    /// 6025 (0x1789) - This transaction must be signed by either the leaf owner or leaf delegate
    #[error("This transaction must be signed by either the leaf owner or leaf delegate")]
    LeafAuthorityMustSign,
    /// 6026 (0x178A) - Collection Not Compatable with Compression, Must be Sized
    #[error("Collection Not Compatable with Compression, Must be Sized")]
    CollectionMustBeSized,
    /// 6027 (0x178B) - Metadata mint does not match collection mint
    #[error("Metadata mint does not match collection mint")]
    MetadataMintMismatch,
    /// 6028 (0x178C) - Invalid collection authority
    #[error("Invalid collection authority")]
    InvalidCollectionAuthority,
    /// 6029 (0x178D) - Invalid delegate record pda derivation
    #[error("Invalid delegate record pda derivation")]
    InvalidDelegateRecord,
    /// 6030 (0x178E) - Edition account doesnt match collection
    #[error("Edition account doesnt match collection")]
    CollectionMasterEditionAccountInvalid,
    /// 6031 (0x178F) - Collection Must Be a Unique Master Edition v2
    #[error("Collection Must Be a Unique Master Edition v2")]
    CollectionMustBeAUniqueMasterEdition,
    /// 6032 (0x1790) - Could not convert external error to BubblegumError
    #[error("Could not convert external error to BubblegumError")]
    UnknownExternalError,
    /// 6033 (0x1791) - Decompression is disabled for this tree.
    #[error("Decompression is disabled for this tree.")]
    DecompressionDisabled,
    /// 6034 (0x1792) - Missing collection mint account
    #[error("Missing collection mint account")]
    MissingCollectionMintAccount,
    /// 6035 (0x1793) - Missing collection metadata account
    #[error("Missing collection metadata account")]
    MissingCollectionMetadataAccount,
    /// 6036 (0x1794) - Collection mismatch
    #[error("Collection mismatch")]
    CollectionMismatch,
    /// 6037 (0x1795) - Metadata not mutable
    #[error("Metadata not mutable")]
    MetadataImmutable,
    /// 6038 (0x1796) - Can only update primary sale to true
    #[error("Can only update primary sale to true")]
    PrimarySaleCanOnlyBeFlippedToTrue,
    /// 6039 (0x1797) - Creator did not unverify the metadata
    #[error("Creator did not unverify the metadata")]
    CreatorDidNotUnverify,
    /// 6040 (0x1798) - Only NonFungible standard is supported
    #[error("Only NonFungible standard is supported")]
    InvalidTokenStandard,
    /// 6041 (0x1799) - Canopy size should be set bigger for this tree
    #[error("Canopy size should be set bigger for this tree")]
    InvalidCanopySize,
    /// 6042 (0x179A) - Invalid log wrapper program
    #[error("Invalid log wrapper program")]
    InvalidLogWrapper,
    /// 6043 (0x179B) - Invalid compression program
    #[error("Invalid compression program")]
    InvalidCompressionProgram,
    /// 6044 (0x179C) - Leaf must be delegated to someone other than the leaf owner
    #[error("Leaf must be delegated to someone other than the leaf owner")]
    LeafMustBeDelegated,
    /// 6045 (0x179D) - Asset is frozen
    #[error("Asset is frozen")]
    AssetIsFrozen,
    /// 6046 (0x179E) - Asset is non-transferable
    #[error("Asset is non-transferable")]
    AssetIsNonTransferable,
    /// 6047 (0x179F) - Invalid authority
    #[error("Invalid authority")]
    InvalidAuthority,
    /// 6048 (0x17A0) - Collection is frozen
    #[error("Collection is frozen")]
    CollectionIsFrozen,
    /// 6049 (0x17A1) - Core collections must have the Bubblegum V2 plugin on them
    #[error("Core collections must have the Bubblegum V2 plugin on them")]
    CollectionMustHaveBubblegumPlugin,
    /// 6050 (0x17A2) - Feature not currently available
    #[error("Feature not currently available")]
    NotAvailable,
    /// 6051 (0x17A3) - Missing collection account
    #[error("Missing collection account")]
    MissingCollectionAccount,
    /// 6052 (0x17A4) - Asset data length too long
    #[error("Asset data length too long")]
    AssetDataLengthTooLong,
    /// 6053 (0x17A5) - Item is already in the collection
    #[error("Item is already in the collection")]
    AlreadyInCollection,
    /// 6054 (0x17A6) - Item is already not in a collection
    #[error("Item is already not in a collection")]
    AlreadyNotInCollection,
    /// 6055 (0x17A7) - Missing mpl-core CPI signer account
    #[error("Missing mpl-core CPI signer account")]
    MissingMplCoreCpiSignerAccount,
    /// 6056 (0x17A8) - Asset is not frozen
    #[error("Asset is not frozen")]
    AssetIsNotFrozen,
}

impl From<MplBubblegumError> for ProgramError {
    fn from(e: MplBubblegumError) -> Self {
        ProgramError::Custom(e as u32)
    }
}

impl TryFrom<u32> for MplBubblegumError {
    type Error = ProgramError;
    fn try_from(error: u32) -> Result<Self, Self::Error> {
        match error {
            6000 => Ok(MplBubblegumError::AssetOwnerMismatch),
            6001 => Ok(MplBubblegumError::PublicKeyMismatch),
            6002 => Ok(MplBubblegumError::HashingMismatch),
            6003 => Ok(MplBubblegumError::UnsupportedSchemaVersion),
            6004 => Ok(MplBubblegumError::CreatorShareTotalMustBe100),
            6005 => Ok(MplBubblegumError::DuplicateCreatorAddress),
            6006 => Ok(MplBubblegumError::CreatorDidNotVerify),
            6007 => Ok(MplBubblegumError::CreatorNotFound),
            6008 => Ok(MplBubblegumError::NoCreatorsPresent),
            6009 => Ok(MplBubblegumError::CreatorHashMismatch),
            6010 => Ok(MplBubblegumError::DataHashMismatch),
            6011 => Ok(MplBubblegumError::CreatorsTooLong),
            6012 => Ok(MplBubblegumError::MetadataNameTooLong),
            6013 => Ok(MplBubblegumError::MetadataSymbolTooLong),
            6014 => Ok(MplBubblegumError::MetadataUriTooLong),
            6015 => Ok(MplBubblegumError::MetadataBasisPointsTooHigh),
            6016 => Ok(MplBubblegumError::TreeAuthorityIncorrect),
            6017 => Ok(MplBubblegumError::InsufficientMintCapacity),
            6018 => Ok(MplBubblegumError::NumericalOverflowError),
            6019 => Ok(MplBubblegumError::IncorrectOwner),
            6020 => Ok(MplBubblegumError::CollectionCannotBeVerifiedInThisInstruction),
            6021 => Ok(MplBubblegumError::CollectionNotFound),
            6022 => Ok(MplBubblegumError::AlreadyVerified),
            6023 => Ok(MplBubblegumError::AlreadyUnverified),
            6024 => Ok(MplBubblegumError::UpdateAuthorityIncorrect),
            6025 => Ok(MplBubblegumError::LeafAuthorityMustSign),
            6026 => Ok(MplBubblegumError::CollectionMustBeSized),
            6027 => Ok(MplBubblegumError::MetadataMintMismatch),
            6028 => Ok(MplBubblegumError::InvalidCollectionAuthority),
            6029 => Ok(MplBubblegumError::InvalidDelegateRecord),
            6030 => Ok(MplBubblegumError::CollectionMasterEditionAccountInvalid),
            6031 => Ok(MplBubblegumError::CollectionMustBeAUniqueMasterEdition),
            6032 => Ok(MplBubblegumError::UnknownExternalError),
            6033 => Ok(MplBubblegumError::DecompressionDisabled),
            6034 => Ok(MplBubblegumError::MissingCollectionMintAccount),
            6035 => Ok(MplBubblegumError::MissingCollectionMetadataAccount),
            6036 => Ok(MplBubblegumError::CollectionMismatch),
            6037 => Ok(MplBubblegumError::MetadataImmutable),
            6038 => Ok(MplBubblegumError::PrimarySaleCanOnlyBeFlippedToTrue),
            6039 => Ok(MplBubblegumError::CreatorDidNotUnverify),
            6040 => Ok(MplBubblegumError::InvalidTokenStandard),
            6041 => Ok(MplBubblegumError::InvalidCanopySize),
            6042 => Ok(MplBubblegumError::InvalidLogWrapper),
            6043 => Ok(MplBubblegumError::InvalidCompressionProgram),
            6044 => Ok(MplBubblegumError::LeafMustBeDelegated),
            6045 => Ok(MplBubblegumError::AssetIsFrozen),
            6046 => Ok(MplBubblegumError::AssetIsNonTransferable),
            6047 => Ok(MplBubblegumError::InvalidAuthority),
            6048 => Ok(MplBubblegumError::CollectionIsFrozen),
            6049 => Ok(MplBubblegumError::CollectionMustHaveBubblegumPlugin),
            6050 => Ok(MplBubblegumError::NotAvailable),
            6051 => Ok(MplBubblegumError::MissingCollectionAccount),
            6052 => Ok(MplBubblegumError::AssetDataLengthTooLong),
            6053 => Ok(MplBubblegumError::AlreadyInCollection),
            6054 => Ok(MplBubblegumError::AlreadyNotInCollection),
            6055 => Ok(MplBubblegumError::MissingMplCoreCpiSignerAccount),
            6056 => Ok(MplBubblegumError::AssetIsNotFrozen),
            _ => Err(ProgramError::InvalidArgument),
        }
    }
}

impl ToStr for MplBubblegumError {
    fn to_str(&self) -> &'static str {
        match self {
            MplBubblegumError::AssetOwnerMismatch => "Asset Owner Does not match",
            MplBubblegumError::PublicKeyMismatch => "PublicKeyMismatch",
            MplBubblegumError::HashingMismatch => "Hashing Mismatch Within Leaf Schema",
            MplBubblegumError::UnsupportedSchemaVersion => "Unsupported Schema Version",
            MplBubblegumError::CreatorShareTotalMustBe100 => "Creator shares must sum to 100",
            MplBubblegumError::DuplicateCreatorAddress => {
                "No duplicate creator addresses in metadata"
            }
            MplBubblegumError::CreatorDidNotVerify => "Creator did not verify the metadata",
            MplBubblegumError::CreatorNotFound => "Creator not found in creator Vec",
            MplBubblegumError::NoCreatorsPresent => "No creators in creator Vec",
            MplBubblegumError::CreatorHashMismatch => {
                "User-provided creator Vec must result in same user-provided creator hash"
            }
            MplBubblegumError::DataHashMismatch => {
                "User-provided metadata must result in same user-provided data hash"
            }
            MplBubblegumError::CreatorsTooLong => "Creators list too long",
            MplBubblegumError::MetadataNameTooLong => "Name in metadata is too long",
            MplBubblegumError::MetadataSymbolTooLong => "Symbol in metadata is too long",
            MplBubblegumError::MetadataUriTooLong => "Uri in metadata is too long",
            MplBubblegumError::MetadataBasisPointsTooHigh => {
                "Basis points in metadata cannot exceed 10000"
            }
            MplBubblegumError::TreeAuthorityIncorrect => "Tree creator or tree delegate must sign.",
            MplBubblegumError::InsufficientMintCapacity => "Not enough unapproved mints left",
            MplBubblegumError::NumericalOverflowError => "NumericalOverflowError",
            MplBubblegumError::IncorrectOwner => "Incorrect account owner",
            MplBubblegumError::CollectionCannotBeVerifiedInThisInstruction => {
                "Cannot Verify Collection in this Instruction"
            }
            MplBubblegumError::CollectionNotFound => "Collection Not Found on Metadata",
            MplBubblegumError::AlreadyVerified => "Collection item is already verified.",
            MplBubblegumError::AlreadyUnverified => "Collection item is already unverified.",
            MplBubblegumError::UpdateAuthorityIncorrect => {
                "Incorrect leaf metadata update authority."
            }
            MplBubblegumError::LeafAuthorityMustSign => {
                "This transaction must be signed by either the leaf owner or leaf delegate"
            }
            MplBubblegumError::CollectionMustBeSized => {
                "Collection Not Compatable with Compression, Must be Sized"
            }
            MplBubblegumError::MetadataMintMismatch => {
                "Metadata mint does not match collection mint"
            }
            MplBubblegumError::InvalidCollectionAuthority => "Invalid collection authority",
            MplBubblegumError::InvalidDelegateRecord => "Invalid delegate record pda derivation",
            MplBubblegumError::CollectionMasterEditionAccountInvalid => {
                "Edition account doesnt match collection"
            }
            MplBubblegumError::CollectionMustBeAUniqueMasterEdition => {
                "Collection Must Be a Unique Master Edition v2"
            }
            MplBubblegumError::UnknownExternalError => {
                "Could not convert external error to BubblegumError"
            }
            MplBubblegumError::DecompressionDisabled => "Decompression is disabled for this tree.",
            MplBubblegumError::MissingCollectionMintAccount => "Missing collection mint account",
            MplBubblegumError::MissingCollectionMetadataAccount => {
                "Missing collection metadata account"
            }
            MplBubblegumError::CollectionMismatch => "Collection mismatch",
            MplBubblegumError::MetadataImmutable => "Metadata not mutable",
            MplBubblegumError::PrimarySaleCanOnlyBeFlippedToTrue => {
                "Can only update primary sale to true"
            }
            MplBubblegumError::CreatorDidNotUnverify => "Creator did not unverify the metadata",
            MplBubblegumError::InvalidTokenStandard => "Only NonFungible standard is supported",
            MplBubblegumError::InvalidCanopySize => {
                "Canopy size should be set bigger for this tree"
            }
            MplBubblegumError::InvalidLogWrapper => "Invalid log wrapper program",
            MplBubblegumError::InvalidCompressionProgram => "Invalid compression program",
            MplBubblegumError::LeafMustBeDelegated => {
                "Leaf must be delegated to someone other than the leaf owner"
            }
            MplBubblegumError::AssetIsFrozen => "Asset is frozen",
            MplBubblegumError::AssetIsNonTransferable => "Asset is non-transferable",
            MplBubblegumError::InvalidAuthority => "Invalid authority",
            MplBubblegumError::CollectionIsFrozen => "Collection is frozen",
            MplBubblegumError::CollectionMustHaveBubblegumPlugin => {
                "Core collections must have the Bubblegum V2 plugin on them"
            }
            MplBubblegumError::NotAvailable => "Feature not currently available",
            MplBubblegumError::MissingCollectionAccount => "Missing collection account",
            MplBubblegumError::AssetDataLengthTooLong => "Asset data length too long",
            MplBubblegumError::AlreadyInCollection => "Item is already in the collection",
            MplBubblegumError::AlreadyNotInCollection => "Item is already not in a collection",
            MplBubblegumError::MissingMplCoreCpiSignerAccount => {
                "Missing mpl-core CPI signer account"
            }
            MplBubblegumError::AssetIsNotFrozen => "Asset is not frozen",
        }
    }
}