miracle_api/state/
mod.rs

1mod config;
2mod metrics;
3mod proof;
4mod snapshot;
5mod treasury;
6
7pub use config::*;
8pub use metrics::*;
9pub use proof::*;
10pub use snapshot::*;
11pub use treasury::*;
12
13use steel::*;
14
15use crate::consts::*;
16
17#[repr(u8)]
18#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
19pub enum MiracleAccount {
20    Config = 100,
21    Proof = 101,
22    Treasury = 102,
23    Snapshot = 103,
24    Metrics = 104,
25}
26
27/// Derive the PDA of the config account.
28pub fn config_pda() -> (Pubkey, u8) {
29    Pubkey::find_program_address(&[CONFIG], &crate::id())
30}
31
32/// Derive the PDA of a proof account.
33pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
34    Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
35}
36
37/// Derive the PDA of the treasury account.
38pub fn treasury_pda() -> (Pubkey, u8) {
39    Pubkey::find_program_address(&[TREASURY], &crate::id())
40}
41
42/// Derive the PDA of the snapshot account.
43pub fn snapshot_pda() -> (Pubkey, u8) {
44    Pubkey::find_program_address(&[SNAPSHOT], &crate::id())
45}
46
47/// Derive the PDA of the metrics account.
48pub fn metrics_pda() -> (Pubkey, u8) {
49    Pubkey::find_program_address(&[METRICS], &crate::id())
50}