miracle-api 0.6.0

Miracle is a pay2e protocol for sovereign individuals living in Mirascape Horizon.
Documentation
mod config;
mod metrics;
mod proof;
mod snapshot;
mod treasury;

pub use config::*;
pub use metrics::*;
pub use proof::*;
pub use snapshot::*;
pub use treasury::*;

use steel::*;

use crate::consts::*;

#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum MiracleAccount {
    Config = 100,
    Proof = 101,
    Treasury = 102,
    Snapshot = 103,
    Metrics = 104,
}

/// Derive the PDA of the config account.
pub fn config_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[CONFIG], &crate::id())
}

/// Derive the PDA of a proof account.
pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
    Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
}

/// Derive the PDA of the treasury account.
pub fn treasury_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[TREASURY], &crate::id())
}

/// Derive the PDA of the snapshot account.
pub fn snapshot_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[SNAPSHOT], &crate::id())
}

/// Derive the PDA of the metrics account.
pub fn metrics_pda() -> (Pubkey, u8) {
    Pubkey::find_program_address(&[METRICS], &crate::id())
}