mpl-core 0.12.0

A flexible digital asset standard for Solana
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 MplCoreError {
    /// 0 (0x0) - Invalid System Program
    #[error("Invalid System Program")]
    InvalidSystemProgram,
    /// 1 (0x1) - Error deserializing account
    #[error("Error deserializing account")]
    DeserializationError,
    /// 2 (0x2) - Error serializing account
    #[error("Error serializing account")]
    SerializationError,
    /// 3 (0x3) - Plugins not initialized
    #[error("Plugins not initialized")]
    PluginsNotInitialized,
    /// 4 (0x4) - Plugin not found
    #[error("Plugin not found")]
    PluginNotFound,
    /// 5 (0x5) - Numerical Overflow
    #[error("Numerical Overflow")]
    NumericalOverflow,
    /// 6 (0x6) - Incorrect account
    #[error("Incorrect account")]
    IncorrectAccount,
    /// 7 (0x7) - Incorrect asset hash
    #[error("Incorrect asset hash")]
    IncorrectAssetHash,
    /// 8 (0x8) - Invalid Plugin
    #[error("Invalid Plugin")]
    InvalidPlugin,
    /// 9 (0x9) - Invalid Authority
    #[error("Invalid Authority")]
    InvalidAuthority,
    /// 10 (0xA) - Cannot transfer a frozen asset
    #[error("Cannot transfer a frozen asset")]
    AssetIsFrozen,
    /// 11 (0xB) - Missing compression proof
    #[error("Missing compression proof")]
    MissingCompressionProof,
    /// 12 (0xC) - Cannot migrate a master edition used for prints
    #[error("Cannot migrate a master edition used for prints")]
    CannotMigrateMasterWithSupply,
    /// 13 (0xD) - Cannot migrate a print edition
    #[error("Cannot migrate a print edition")]
    CannotMigratePrints,
    /// 14 (0xE) - Cannot burn a collection NFT
    #[error("Cannot burn a collection NFT")]
    CannotBurnCollection,
    /// 15 (0xF) - Plugin already exists
    #[error("Plugin already exists")]
    PluginAlreadyExists,
    /// 16 (0x10) - Numerical overflow
    #[error("Numerical overflow")]
    NumericalOverflowError,
    /// 17 (0x11) - Already compressed account
    #[error("Already compressed account")]
    AlreadyCompressed,
    /// 18 (0x12) - Already decompressed account
    #[error("Already decompressed account")]
    AlreadyDecompressed,
    /// 19 (0x13) - Invalid Collection passed in
    #[error("Invalid Collection passed in")]
    InvalidCollection,
    /// 20 (0x14) - Missing update authority
    #[error("Missing update authority")]
    MissingUpdateAuthority,
    /// 21 (0x15) - Missing new owner
    #[error("Missing new owner")]
    MissingNewOwner,
    /// 22 (0x16) - Missing system program
    #[error("Missing system program")]
    MissingSystemProgram,
    /// 23 (0x17) - Feature not available
    #[error("Feature not available")]
    NotAvailable,
    /// 24 (0x18) - Invalid Asset passed in
    #[error("Invalid Asset passed in")]
    InvalidAsset,
    /// 25 (0x19) - Missing collection
    #[error("Missing collection")]
    MissingCollection,
    /// 26 (0x1A) - Neither the asset or any plugins have approved this operation
    #[error("Neither the asset or any plugins have approved this operation")]
    NoApprovals,
    /// 27 (0x1B) - Plugin Manager cannot redelegate a delegated plugin without revoking first
    #[error("Plugin Manager cannot redelegate a delegated plugin without revoking first")]
    CannotRedelegate,
    /// 28 (0x1C) - Invalid setting for plugin
    #[error("Invalid setting for plugin")]
    InvalidPluginSetting,
    /// 29 (0x1D) - Cannot specify both an update authority and collection on an asset
    #[error("Cannot specify both an update authority and collection on an asset")]
    ConflictingAuthority,
    /// 30 (0x1E) - Invalid Log Wrapper Program
    #[error("Invalid Log Wrapper Program")]
    InvalidLogWrapperProgram,
    /// 31 (0x1F) - External Plugin Adapter not found
    #[error("External Plugin Adapter not found")]
    ExternalPluginAdapterNotFound,
    /// 32 (0x20) - External Plugin Adapter already exists
    #[error("External Plugin Adapter already exists")]
    ExternalPluginAdapterAlreadyExists,
    /// 33 (0x21) - Missing asset needed for extra account PDA derivation
    #[error("Missing asset needed for extra account PDA derivation")]
    MissingAsset,
    /// 34 (0x22) - Missing account needed for external plugin adapter
    #[error("Missing account needed for external plugin adapter")]
    MissingExternalPluginAdapterAccount,
    /// 35 (0x23) - Oracle external plugin adapter can only be configured to reject
    #[error("Oracle external plugin adapter can only be configured to reject")]
    OracleCanRejectOnly,
    /// 36 (0x24) - External plugin adapter must have at least one lifecycle check
    #[error("External plugin adapter must have at least one lifecycle check")]
    RequiresLifecycleCheck,
    /// 37 (0x25) - Duplicate lifecycle checks were provided for external plugin adapter
    #[error("Duplicate lifecycle checks were provided for external plugin adapter ")]
    DuplicateLifecycleChecks,
    /// 38 (0x26) - Could not read from oracle account
    #[error("Could not read from oracle account")]
    InvalidOracleAccountData,
    /// 39 (0x27) - Oracle account is uninitialized
    #[error("Oracle account is uninitialized")]
    UninitializedOracleAccount,
    /// 40 (0x28) - Missing required signer for operation
    #[error("Missing required signer for operation")]
    MissingSigner,
    /// 41 (0x29) - Invalid plugin operation
    #[error("Invalid plugin operation")]
    InvalidPluginOperation,
    /// 42 (0x2A) - Collection must be empty to be burned
    #[error("Collection must be empty to be burned")]
    CollectionMustBeEmpty,
    /// 43 (0x2B) - Two data sources provided, only one is allowed
    #[error("Two data sources provided, only one is allowed")]
    TwoDataSources,
    /// 44 (0x2C) - External Plugin does not support this operation
    #[error("External Plugin does not support this operation")]
    UnsupportedOperation,
    /// 45 (0x2D) - No data sources provided, one is required
    #[error("No data sources provided, one is required")]
    NoDataSources,
    /// 46 (0x2E) - This plugin adapter cannot be added to an Asset
    #[error("This plugin adapter cannot be added to an Asset")]
    InvalidPluginAdapterTarget,
    /// 47 (0x2F) - Cannot add a Data Section without a linked external plugin
    #[error("Cannot add a Data Section without a linked external plugin")]
    CannotAddDataSection,
    /// 48 (0x30) - Cannot move asset to collection with permanent delegates
    #[error("Cannot move asset to collection with permanent delegates")]
    PermanentDelegatesPreventMove,
    /// 49 (0x31) - Invalid Signing PDA for Asset or Collection Execute
    #[error("Invalid Signing PDA for Asset or Collection Execute")]
    InvalidExecutePda,
    /// 50 (0x32) - Bubblegum V2 Plugin limits other plugins
    #[error("Bubblegum V2 Plugin limits other plugins")]
    BlockedByBubblegumV2,
    /// 51 (0x33) - Agent Identity Program must sign
    #[error("Agent Identity Program must sign")]
    AgentIdentityMustSign,
    /// 52 (0x34) - Group must be empty to be closed
    #[error("Group must be empty to be closed")]
    GroupMustBeEmpty,
    /// 53 (0x35) - Duplicate entry provided when adding relationships to a group
    #[error("Duplicate entry provided when adding relationships to a group")]
    DuplicateEntry,
    /// 54 (0x36) - Group vector is at maximum capacity
    #[error("Group vector is at maximum capacity")]
    GroupVectorFull,
    /// 55 (0x37) - Group nesting depth exceeded
    #[error("Group nesting depth exceeded")]
    GroupNestingDepthExceeded,
    /// 56 (0x38) - Bidirectional group relationship is inconsistent
    #[error("Bidirectional group relationship is inconsistent")]
    InconsistentGroupRelationship,
}

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

impl TryFrom<u32> for MplCoreError {
    type Error = ProgramError;
    fn try_from(error: u32) -> Result<Self, Self::Error> {
        match error {
            0 => Ok(MplCoreError::InvalidSystemProgram),
            1 => Ok(MplCoreError::DeserializationError),
            2 => Ok(MplCoreError::SerializationError),
            3 => Ok(MplCoreError::PluginsNotInitialized),
            4 => Ok(MplCoreError::PluginNotFound),
            5 => Ok(MplCoreError::NumericalOverflow),
            6 => Ok(MplCoreError::IncorrectAccount),
            7 => Ok(MplCoreError::IncorrectAssetHash),
            8 => Ok(MplCoreError::InvalidPlugin),
            9 => Ok(MplCoreError::InvalidAuthority),
            10 => Ok(MplCoreError::AssetIsFrozen),
            11 => Ok(MplCoreError::MissingCompressionProof),
            12 => Ok(MplCoreError::CannotMigrateMasterWithSupply),
            13 => Ok(MplCoreError::CannotMigratePrints),
            14 => Ok(MplCoreError::CannotBurnCollection),
            15 => Ok(MplCoreError::PluginAlreadyExists),
            16 => Ok(MplCoreError::NumericalOverflowError),
            17 => Ok(MplCoreError::AlreadyCompressed),
            18 => Ok(MplCoreError::AlreadyDecompressed),
            19 => Ok(MplCoreError::InvalidCollection),
            20 => Ok(MplCoreError::MissingUpdateAuthority),
            21 => Ok(MplCoreError::MissingNewOwner),
            22 => Ok(MplCoreError::MissingSystemProgram),
            23 => Ok(MplCoreError::NotAvailable),
            24 => Ok(MplCoreError::InvalidAsset),
            25 => Ok(MplCoreError::MissingCollection),
            26 => Ok(MplCoreError::NoApprovals),
            27 => Ok(MplCoreError::CannotRedelegate),
            28 => Ok(MplCoreError::InvalidPluginSetting),
            29 => Ok(MplCoreError::ConflictingAuthority),
            30 => Ok(MplCoreError::InvalidLogWrapperProgram),
            31 => Ok(MplCoreError::ExternalPluginAdapterNotFound),
            32 => Ok(MplCoreError::ExternalPluginAdapterAlreadyExists),
            33 => Ok(MplCoreError::MissingAsset),
            34 => Ok(MplCoreError::MissingExternalPluginAdapterAccount),
            35 => Ok(MplCoreError::OracleCanRejectOnly),
            36 => Ok(MplCoreError::RequiresLifecycleCheck),
            37 => Ok(MplCoreError::DuplicateLifecycleChecks),
            38 => Ok(MplCoreError::InvalidOracleAccountData),
            39 => Ok(MplCoreError::UninitializedOracleAccount),
            40 => Ok(MplCoreError::MissingSigner),
            41 => Ok(MplCoreError::InvalidPluginOperation),
            42 => Ok(MplCoreError::CollectionMustBeEmpty),
            43 => Ok(MplCoreError::TwoDataSources),
            44 => Ok(MplCoreError::UnsupportedOperation),
            45 => Ok(MplCoreError::NoDataSources),
            46 => Ok(MplCoreError::InvalidPluginAdapterTarget),
            47 => Ok(MplCoreError::CannotAddDataSection),
            48 => Ok(MplCoreError::PermanentDelegatesPreventMove),
            49 => Ok(MplCoreError::InvalidExecutePda),
            50 => Ok(MplCoreError::BlockedByBubblegumV2),
            51 => Ok(MplCoreError::AgentIdentityMustSign),
            52 => Ok(MplCoreError::GroupMustBeEmpty),
            53 => Ok(MplCoreError::DuplicateEntry),
            54 => Ok(MplCoreError::GroupVectorFull),
            55 => Ok(MplCoreError::GroupNestingDepthExceeded),
            56 => Ok(MplCoreError::InconsistentGroupRelationship),
            _ => Err(ProgramError::InvalidArgument),
        }
    }
}

impl ToStr for MplCoreError {
    fn to_str(&self) -> &'static str {
        match self {
            MplCoreError::InvalidSystemProgram => "Invalid System Program",
            MplCoreError::DeserializationError => "Error deserializing account",
            MplCoreError::SerializationError => "Error serializing account",
            MplCoreError::PluginsNotInitialized => "Plugins not initialized",
            MplCoreError::PluginNotFound => "Plugin not found",
            MplCoreError::NumericalOverflow => "Numerical Overflow",
            MplCoreError::IncorrectAccount => "Incorrect account",
            MplCoreError::IncorrectAssetHash => "Incorrect asset hash",
            MplCoreError::InvalidPlugin => "Invalid Plugin",
            MplCoreError::InvalidAuthority => "Invalid Authority",
            MplCoreError::AssetIsFrozen => "Cannot transfer a frozen asset",
            MplCoreError::MissingCompressionProof => "Missing compression proof",
            MplCoreError::CannotMigrateMasterWithSupply => {
                "Cannot migrate a master edition used for prints"
            }
            MplCoreError::CannotMigratePrints => "Cannot migrate a print edition",
            MplCoreError::CannotBurnCollection => "Cannot burn a collection NFT",
            MplCoreError::PluginAlreadyExists => "Plugin already exists",
            MplCoreError::NumericalOverflowError => "Numerical overflow",
            MplCoreError::AlreadyCompressed => "Already compressed account",
            MplCoreError::AlreadyDecompressed => "Already decompressed account",
            MplCoreError::InvalidCollection => "Invalid Collection passed in",
            MplCoreError::MissingUpdateAuthority => "Missing update authority",
            MplCoreError::MissingNewOwner => "Missing new owner",
            MplCoreError::MissingSystemProgram => "Missing system program",
            MplCoreError::NotAvailable => "Feature not available",
            MplCoreError::InvalidAsset => "Invalid Asset passed in",
            MplCoreError::MissingCollection => "Missing collection",
            MplCoreError::NoApprovals => {
                "Neither the asset or any plugins have approved this operation"
            }
            MplCoreError::CannotRedelegate => {
                "Plugin Manager cannot redelegate a delegated plugin without revoking first"
            }
            MplCoreError::InvalidPluginSetting => "Invalid setting for plugin",
            MplCoreError::ConflictingAuthority => {
                "Cannot specify both an update authority and collection on an asset"
            }
            MplCoreError::InvalidLogWrapperProgram => "Invalid Log Wrapper Program",
            MplCoreError::ExternalPluginAdapterNotFound => "External Plugin Adapter not found",
            MplCoreError::ExternalPluginAdapterAlreadyExists => {
                "External Plugin Adapter already exists"
            }
            MplCoreError::MissingAsset => "Missing asset needed for extra account PDA derivation",
            MplCoreError::MissingExternalPluginAdapterAccount => {
                "Missing account needed for external plugin adapter"
            }
            MplCoreError::OracleCanRejectOnly => {
                "Oracle external plugin adapter can only be configured to reject"
            }
            MplCoreError::RequiresLifecycleCheck => {
                "External plugin adapter must have at least one lifecycle check"
            }
            MplCoreError::DuplicateLifecycleChecks => {
                "Duplicate lifecycle checks were provided for external plugin adapter "
            }
            MplCoreError::InvalidOracleAccountData => "Could not read from oracle account",
            MplCoreError::UninitializedOracleAccount => "Oracle account is uninitialized",
            MplCoreError::MissingSigner => "Missing required signer for operation",
            MplCoreError::InvalidPluginOperation => "Invalid plugin operation",
            MplCoreError::CollectionMustBeEmpty => "Collection must be empty to be burned",
            MplCoreError::TwoDataSources => "Two data sources provided, only one is allowed",
            MplCoreError::UnsupportedOperation => "External Plugin does not support this operation",
            MplCoreError::NoDataSources => "No data sources provided, one is required",
            MplCoreError::InvalidPluginAdapterTarget => {
                "This plugin adapter cannot be added to an Asset"
            }
            MplCoreError::CannotAddDataSection => {
                "Cannot add a Data Section without a linked external plugin"
            }
            MplCoreError::PermanentDelegatesPreventMove => {
                "Cannot move asset to collection with permanent delegates"
            }
            MplCoreError::InvalidExecutePda => {
                "Invalid Signing PDA for Asset or Collection Execute"
            }
            MplCoreError::BlockedByBubblegumV2 => "Bubblegum V2 Plugin limits other plugins",
            MplCoreError::AgentIdentityMustSign => "Agent Identity Program must sign",
            MplCoreError::GroupMustBeEmpty => "Group must be empty to be closed",
            MplCoreError::DuplicateEntry => {
                "Duplicate entry provided when adding relationships to a group"
            }
            MplCoreError::GroupVectorFull => "Group vector is at maximum capacity",
            MplCoreError::GroupNestingDepthExceeded => "Group nesting depth exceeded",
            MplCoreError::InconsistentGroupRelationship => {
                "Bidirectional group relationship is inconsistent"
            }
        }
    }
}