ore_api/state/
mod.rs

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