//! This code was AUTOGENERATED using the codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

use num_derive::FromPrimitive;
use thiserror::Error;

#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum SubscriptionsError {
    /// 100 - Account must be a signer
    #[error("Account must be a signer")]
    NotSigner = 0x64,
    /// 101 - Invalid account address
    #[error("Invalid account address")]
    InvalidAddress = 0x65,
    /// 102 - Invalid escrow PDA derivation
    #[error("Invalid escrow PDA derivation")]
    InvalidEscrowPda = 0x66,
    /// 103 - Invalid subscription-authority PDA derivation
    #[error("Invalid subscription-authority PDA derivation")]
    InvalidSubscriptionAuthorityPda = 0x67,
    /// 104 - Expected system program
    #[error("Expected system program")]
    NotSystemProgram = 0x68,
    /// 105 - Token Program does not match other accounts
    #[error("Token Program does not match other accounts")]
    InvalidTokenProgram = 0x69,
    /// 106 - Invalid Token-2022 mint account data
    #[error("Invalid Token-2022 mint account data")]
    InvalidToken2022MintAccountData = 0x6A,
    /// 107 - Invalid Token-2022 token account data
    #[error("Invalid Token-2022 token account data")]
    InvalidToken2022TokenAccountData = 0x6B,
    /// 108 - Invalid associated token account address
    #[error("Invalid associated token account address")]
    InvalidAssociatedTokenAccountDerivedAddress = 0x6C,
    /// 109 - Invalid SPL Token mint account data
    #[error("Invalid SPL Token mint account data")]
    InvalidTokenSplMintAccountData = 0x6D,
    /// 110 - Invalid SPL Token account data
    #[error("Invalid SPL Token account data")]
    InvalidTokenSplTokenAccountData = 0x6E,
    /// 111 - Invalid account data
    #[error("Invalid account data")]
    InvalidAccountData = 0x6F,
    /// 112 - Invalid instruction data
    #[error("Invalid instruction data")]
    InvalidInstructionData = 0x70,
    /// 113 - Not enough account keys provided
    #[error("Not enough account keys provided")]
    NotEnoughAccountKeys = 0x71,
    /// 114 - Invalid instruction
    #[error("Invalid instruction")]
    InvalidInstruction = 0x72,
    /// 115 - Arithmetic Overflow
    #[error("Arithmetic Overflow")]
    ArithmeticOverflow = 0x73,
    /// 116 - Arithmetic Underflow
    #[error("Arithmetic Underflow")]
    ArithmeticUnderflow = 0x74,
    /// 117 - Invalid account discriminator
    #[error("Invalid account discriminator")]
    InvalidAccountDiscriminator = 0x75,
    /// 118 - Mint has ConfidentialTransfer extension
    #[error("Mint has ConfidentialTransfer extension")]
    MintHasConfidentialTransfer = 0x76,
    /// 119 - Mint has NonTransferable extension
    #[error("Mint has NonTransferable extension")]
    MintHasNonTransferable = 0x77,
    /// 120 - Mint has PermanentDelegate extension
    #[error("Mint has PermanentDelegate extension")]
    MintHasPermanentDelegate = 0x78,
    /// 121 - Mint has TransferHook extension
    #[error("Mint has TransferHook extension")]
    MintHasTransferHook = 0x79,
    /// 122 - Mint has TransferFee extension
    #[error("Mint has TransferFee extension")]
    MintHasTransferFee = 0x7A,
    /// 123 - Mint has MintCloseAuthority extension
    #[error("Mint has MintCloseAuthority extension")]
    MintHasMintCloseAuthority = 0x7B,
    /// 124 - Mint has Pausable extension
    #[error("Mint has Pausable extension")]
    MintHasPausable = 0x7C,
    /// 125 - Token mint mismatch
    #[error("Token mint mismatch")]
    MintMismatch = 0x7D,
    /// 126 - Invalid delegation PDA derivation
    #[error("Invalid delegation PDA derivation")]
    InvalidDelegatePda = 0x7E,
    /// 127 - Invalid header data
    #[error("Invalid header data")]
    InvalidHeaderData = 0x7F,
    /// 128 - Delegation has expired
    #[error("Delegation has expired")]
    DelegationExpired = 0x80,
    /// 129 - Invalid amount specified
    #[error("Invalid amount specified")]
    InvalidAmount = 0x81,
    /// 130 - Caller not authorized for this action
    #[error("Caller not authorized for this action")]
    Unauthorized = 0x82,
    /// 131 - Account must be writable
    #[error("Account must be writable")]
    AccountNotWritable = 0x83,
    /// 132 - Token account owner does not match expected
    #[error("Token account owner does not match expected")]
    AtaOwnerMismatch = 0x84,
    /// 133 - Delegation header version is not compatible
    #[error("Delegation header version is not compatible")]
    DelegationVersionMismatch = 0x85,
    /// 134 - Account requires explicit migration
    #[error("Account requires explicit migration")]
    MigrationRequired = 0x86,
    /// 135 - Delegation account already exists
    #[error("Delegation account already exists")]
    DelegationAlreadyExists = 0x87,
    /// 136 - Delegation init_id does not match current SubscriptionAuthority
    #[error("Delegation init_id does not match current SubscriptionAuthority")]
    StaleSubscriptionAuthority = 0x88,
    /// 137 - Too many transfer hook accounts provided
    #[error("Too many transfer hook accounts provided")]
    TransferHookTooManyAccounts = 0x89,
    /// 300 - Transfer amount exceeds delegation limit
    #[error("Transfer amount exceeds delegation limit")]
    AmountExceedsLimit = 0x12C,
    /// 301 - Expiry time specified is less than current time
    #[error("Expiry time specified is less than current time")]
    FixedDelegationExpiryInPast = 0x12D,
    /// 302 - zero amount specified
    #[error("zero amount specified")]
    FixedDelegationAmountZero = 0x12E,
    /// 400 - Transfer amount exceeds period limit
    #[error("Transfer amount exceeds period limit")]
    AmountExceedsPeriodLimit = 0x190,
    /// 401 - Period has not elapsed yet
    #[error("Period has not elapsed yet")]
    PeriodNotElapsed = 0x191,
    /// 402 - Invalid Period length
    #[error("Invalid Period length")]
    InvalidPeriodLength = 0x192,
    /// 403 - Payer provided does not match delegation
    #[error("Payer provided does not match delegation")]
    InvalidPayerData = 0x193,
    /// 404 - Past start time specified
    #[error("Past start time specified")]
    RecurringDelegationStartTimeInPast = 0x194,
    /// 405 - start time specified is greater than expiry
    #[error("start time specified is greater than expiry")]
    RecurringDelegationStartTimeGreaterThanExpiry = 0x195,
    /// 406 - zero amount specified
    #[error("zero amount specified")]
    RecurringDelegationAmountZero = 0x196,
    /// 407 - Delegation period has not started yet
    #[error("Delegation period has not started yet")]
    DelegationNotStarted = 0x197,
    /// 408 - start_ts of 0 (start on landing) requires a non-zero expiry
    #[error("start_ts of 0 (start on landing) requires a non-zero expiry")]
    RecurringDelegationStartOnLandingRequiresExpiry = 0x198,
    /// 500 - Plan is in sunset status
    #[error("Plan is in sunset status")]
    PlanSunset = 0x1F4,
    /// 501 - Plan has expired
    #[error("Plan has expired")]
    PlanExpired = 0x1F5,
    /// 502 - Invalid Plan PDA derivation
    #[error("Invalid Plan PDA derivation")]
    InvalidPlanPda = 0x1F6,
    /// 503 - Invalid subscription PDA derivation
    #[error("Invalid subscription PDA derivation")]
    InvalidSubscriptionPda = 0x1F7,
    /// 504 - Caller is not the plan owner
    #[error("Caller is not the plan owner")]
    NotPlanOwner = 0x1F8,
    /// 505 - Subscription does not belong to this plan
    #[error("Subscription does not belong to this plan")]
    SubscriptionPlanMismatch = 0x1F9,
    /// 506 - Destination not in plan whitelist
    #[error("Destination not in plan whitelist")]
    UnauthorizedDestination = 0x1FA,
    /// 507 - No valid destinations provided
    #[error("No valid destinations provided")]
    InvalidNumDestinations = 0x1FB,
    /// 508 - Subscription cancelled and past valid period
    #[error("Subscription cancelled and past valid period")]
    SubscriptionCancelled = 0x1FC,
    /// 509 - Subscription already cancelled
    #[error("Subscription already cancelled")]
    SubscriptionAlreadyCancelled = 0x1FD,
    /// 510 - Subscription is not cancelled
    #[error("Subscription is not cancelled")]
    SubscriptionNotCancelled = 0x1FE,
    /// 511 - End timestamp must be zero or in the future
    #[error("End timestamp must be zero or in the future")]
    InvalidEndTs = 0x1FF,
    /// 512 - Invalid plan status value
    #[error("Invalid plan status value")]
    InvalidPlanStatus = 0x200,
    /// 513 - Plan cannot be updated after sunset
    #[error("Plan cannot be updated after sunset")]
    PlanImmutableAfterSunset = 0x201,
    /// 514 - Sunset requires a non-zero end timestamp
    #[error("Sunset requires a non-zero end timestamp")]
    SunsetRequiresEndTs = 0x202,
    /// 515 - Plan must be expired to delete
    #[error("Plan must be expired to delete")]
    PlanNotExpired = 0x203,
    /// 516 - Plan account has been closed
    #[error("Plan account has been closed")]
    PlanClosed = 0x204,
    /// 517 - Already subscribed to this plan
    #[error("Already subscribed to this plan")]
    AlreadySubscribed = 0x205,
    /// 518 - Plan account already exists
    #[error("Plan account already exists")]
    PlanAlreadyExists = 0x206,
    /// 519 - Subscription plan terms do not match the current plan
    #[error("Subscription plan terms do not match the current plan")]
    PlanTermsMismatch = 0x207,
    /// 520 - A finite plan end timestamp can only be shortened, not removed or extended
    #[error("A finite plan end timestamp can only be shortened, not removed or extended")]
    PlanEndTsCannotExtend = 0x208,
    /// 600 - Invalid event authority PDA
    #[error("Invalid event authority PDA")]
    InvalidEventAuthority = 0x258,
    /// 601 - Invalid event data
    #[error("Invalid event data")]
    InvalidEventData = 0x259,
    /// 602 - Invalid event tag prefix
    #[error("Invalid event tag prefix")]
    InvalidEventTag = 0x25A,
    /// 603 - Unknown event discriminator
    #[error("Unknown event discriminator")]
    InvalidEventDiscriminator = 0x25B,
    /// 604 - Self program account does not match this program
    #[error("Self program account does not match this program")]
    InvalidSelfProgram = 0x25C,
}

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

