Skip to main content

miner_api/
error.rs

1use solana_program::program_error::ProgramError;
2
3/// Program errors (mapped to ProgramError::Custom).
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[repr(u32)]
6pub enum MinerError {
7    /// Hash does not meet the required difficulty.
8    InvalidHash = 0,
9    /// Account does not match the expected PDA / owner.
10    InvalidAccount = 1,
11    /// Wrong account discriminator.
12    InvalidDiscriminator = 2,
13    /// Signer is not authorized (neither authority nor session key).
14    Unauthorized = 3,
15    /// The given round is not the current round.
16    RoundMismatch = 4,
17    /// Miner already submitted in this round.
18    AlreadySubmitted = 5,
19    /// Round is still open (crank too early).
20    RoundStillOpen = 6,
21    /// Round too fresh to close (retention).
22    RoundNotExpired = 7,
23    /// Nothing to claim.
24    NothingToClaim = 8,
25    /// Token account mismatch (mint/owner/ATA).
26    InvalidTokenAccount = 9,
27    /// Mint does not meet the requirements (authority/decimals/freeze).
28    InvalidMint = 10,
29    /// Arithmetic overflow.
30    Overflow = 11,
31    /// Settling the previous round requires its account.
32    SettlementRequired = 12,
33}
34
35impl From<MinerError> for ProgramError {
36    fn from(e: MinerError) -> Self {
37        ProgramError::Custom(e as u32)
38    }
39}