satrush-client 0.1.8

Rust client to interact with SatRush's on-chain program.
Documentation
//! 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 SatrushError {
    /// 6000 - Signer is not authorized to execute this instruction
    #[error("Signer is not authorized to execute this instruction")]
    Unauthorized = 0x1770,
    /// 6001 - Ongoing round is not yet finished
    #[error("Ongoing round is not yet finished")]
    RoundInProgress = 0x1771,
    /// 6002 - Invalid round id supplied to create round
    #[error("Invalid round id supplied to create round")]
    InvalidRoundId = 0x1772,
    /// 6003 - Round duration must be greater than zero
    #[error("Round duration must be greater than zero")]
    InvalidRoundDuration = 0x1773,
    /// 6004 - Entropy value is invalid
    #[error("Entropy value is invalid")]
    InvalidEntropy = 0x1774,
    /// 6005 - Round is not accepting deploys
    #[error("Round is not accepting deploys")]
    RoundNotActive = 0x1775,
    /// 6006 - Deployment amount must be greater than zero
    #[error("Deployment amount must be greater than zero")]
    InvalidDeploymentAmount = 0x1776,
    /// 6007 - Selection mask must pick between 1 and 21 tiles within the 21-bit range
    #[error("Selection mask must pick between 1 and 21 tiles within the 21-bit range")]
    InvalidSelectionMask = 0x1777,
    /// 6008 - Arithmetic overflow
    #[error("Arithmetic overflow")]
    MathOverflow = 0x1778,
    /// 6009 - Arithmetic underflow
    #[error("Arithmetic underflow")]
    MathUnderflow = 0x1779,
    /// 6010 - Round winning tile has already been revealed
    #[error("Round winning tile has already been revealed")]
    AlreadyRevealed = 0x177A,
    /// 6011 - Slot hash entropy is unavailable or invalid
    #[error("Slot hash entropy is unavailable or invalid")]
    InvalidSlotHash = 0x177B,
    /// 6012 - Round winning tile has not been revealed yet
    #[error("Round winning tile has not been revealed yet")]
    RoundNotRevealed = 0x177C,
    /// 6013 - Round is not in the finished state
    #[error("Round is not in the finished state")]
    RoundNotFinished = 0x177D,
    /// 6014 - Round is not in the settled state
    #[error("Round is not in the settled state")]
    RoundNotSettled = 0x177E,
    /// 6015 - Swap program account does not match the configured swap program
    #[error("Swap program account does not match the configured swap program")]
    InvalidSwapProgram = 0x177F,
    /// 6016 - Round stake has already been swapped into BTC
    #[error("Round stake has already been swapped into BTC")]
    AlreadySwapped = 0x1780,
    /// 6017 - Swap spent more USD than the budgeted amount
    #[error("Swap spent more USD than the budgeted amount")]
    SwapOverspent = 0x1781,
    /// 6018 - Swap output is below the minimum acceptable amount
    #[error("Swap output is below the minimum acceptable amount")]
    SlippageExceeded = 0x1782,
    /// 6019 - Share amount must be greater than zero
    #[error("Share amount must be greater than zero")]
    InvalidShareAmount = 0x1783,
    /// 6020 - Miner does not hold enough Sats Vault shares
    #[error("Miner does not hold enough Sats Vault shares")]
    InsufficientShares = 0x1784,
    /// 6021 - Strike jackpot was already triggered on the provided round
    #[error("Strike jackpot was already triggered on the provided round")]
    StrikeAlreadyTriggered = 0x1785,
    /// 6022 - Epoch iteration is not accepting ticket purchases
    #[error("Epoch iteration is not accepting ticket purchases")]
    EpochNotOpen = 0x1786,
    /// 6023 - Epoch iteration window has not elapsed yet
    #[error("Epoch iteration window has not elapsed yet")]
    EpochWindowNotElapsed = 0x1787,
    /// 6024 - Epoch iteration is not in the settling state
    #[error("Epoch iteration is not in the settling state")]
    EpochNotSettling = 0x1788,
    /// 6025 - Epoch iteration is not in the settled state
    #[error("Epoch iteration is not in the settled state")]
    EpochNotSettled = 0x1789,
    /// 6026 - Supplied page does not contain the current winning ticket
    #[error("Supplied page does not contain the current winning ticket")]
    EpochInvalidPage = 0x178A,
    /// 6027 - Signer is not a winner of this epoch draw
    #[error("Signer is not a winner of this epoch draw")]
    EpochNotAWinner = 0x178B,
    /// 6028 - Epoch reward has already been claimed
    #[error("Epoch reward has already been claimed")]
    EpochAlreadyClaimed = 0x178C,
    /// 6029 - Epoch iteration has reached the maximum number of participants
    #[error("Epoch iteration has reached the maximum number of participants")]
    EpochMaxParticipants = 0x178D,
    /// 6030 - Tickets count must be greater than zero
    #[error("Tickets count must be greater than zero")]
    InvalidTicketsCount = 0x178E,
    /// 6031 - Miner does not have enough hashrate
    #[error("Miner does not have enough hashrate")]
    InsufficientHashrate = 0x178F,
    /// 6032 - 1 BTC Vault iteration is not accepting ticket purchases
    #[error("1 BTC Vault iteration is not accepting ticket purchases")]
    OneBtcNotOpen = 0x1790,
    /// 6033 - 1 BTC Vault iteration is not in the settled state
    #[error("1 BTC Vault iteration is not in the settled state")]
    OneBtcNotSettled = 0x1791,
    /// 6034 - 1 BTC Vault has not accumulated enough BTC to trigger a draw
    #[error("1 BTC Vault has not accumulated enough BTC to trigger a draw")]
    OneBtcNotTriggerable = 0x1792,
    /// 6035 - 1 BTC Vault draw has no participants
    #[error("1 BTC Vault draw has no participants")]
    OneBtcNoParticipants = 0x1793,
    /// 6036 - Ticket does not hold the winning ticket for this draw
    #[error("Ticket does not hold the winning ticket for this draw")]
    OneBtcNotAWinner = 0x1794,
    /// 6037 - The winning ticket cannot be closed until the prize is claimed
    #[error("The winning ticket cannot be closed until the prize is claimed")]
    OneBtcWinningTicketLocked = 0x1795,
    /// 6038 - Epoch page has already been sealed
    #[error("Epoch page has already been sealed")]
    EpochPageAlreadySealed = 0x1796,
    /// 6039 - Epoch page is not sealed yet
    #[error("Epoch page is not sealed yet")]
    EpochPageNotSealed = 0x1797,
    /// 6040 - Epoch sealed page chain does not reconcile with the iteration's ticket total
    #[error("Epoch sealed page chain does not reconcile with the iteration's ticket total")]
    EpochSealMismatch = 0x1798,
    /// 6041 - Treasury has no accrued fees to withdraw
    #[error("Treasury has no accrued fees to withdraw")]
    TreasuryEmpty = 0x1799,
    /// 6042 - Claim amount must be greater than zero
    #[error("Claim amount must be greater than zero")]
    InvalidClaimAmount = 0x179A,
    /// 6043 - Miner does not hold enough unclaimed USD
    #[error("Miner does not hold enough unclaimed USD")]
    InsufficientUnclaimedUsd = 0x179B,
    /// 6044 - Automation balance cannot cover the per-round deploy amount
    #[error("Automation balance cannot cover the per-round deploy amount")]
    InsufficientAutomationBalance = 0x179C,
    /// 6045 - Automation amount must be greater than zero
    #[error("Automation amount must be greater than zero")]
    InvalidAutomationAmount = 0x179D,
    /// 6046 - Selection mask does not match the automation strategy
    #[error("Selection mask does not match the automation strategy")]
    InvalidAutomationStrategyMask = 0x179E,
    /// 6047 - Deploy amount is below the 1 USD minimum
    #[error("Deploy amount is below the 1 USD minimum")]
    DeployAmountBelowMinimum = 0x179F,
    /// 6048 - Epoch iteration duration must be greater than zero
    #[error("Epoch iteration duration must be greater than zero")]
    InvalidEpochIterationDuration = 0x17A0,
    /// 6049 - Unclaimed hashrate bps must not exceed 10_000
    #[error("Unclaimed hashrate bps must not exceed 10_000")]
    InvalidUnclaimedHashrateBps = 0x17A1,
    /// 6050 - Strike trigger modulus must be greater than zero
    #[error("Strike trigger modulus must be greater than zero")]
    InvalidStrikeTriggerModulus = 0x17A2,
    /// 6051 - Sats Vault round fee bps plus deploy fee bps must stay below 10_000
    #[error("Sats Vault round fee bps plus deploy fee bps must stay below 10_000")]
    InvalidSwapBps = 0x17A3,
}

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