ore_api/state/
mod.rs

1mod automation;
2mod board;
3mod config;
4mod miner;
5mod round;
6mod stake;
7mod treasury;
8
9pub use automation::*;
10pub use board::*;
11pub use config::*;
12pub use miner::*;
13pub use round::*;
14pub use stake::*;
15pub use treasury::*;
16
17use crate::consts::*;
18
19use steel::*;
20
21#[repr(u8)]
22#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
23pub enum OreAccount {
24    Automation = 100,
25    Config = 101,
26    Miner = 103,
27    Treasury = 104,
28    Board = 105,
29    Stake = 108,
30    Round = 109,
31}
32
33#[repr(u8)]
34#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
35pub enum OreAccountOLD {
36    BoardOLD = 105,
37}
38
39pub fn automation_pda(authority: Pubkey) -> (Pubkey, u8) {
40    Pubkey::find_program_address(&[AUTOMATION, &authority.to_bytes()], &crate::ID)
41}
42
43pub fn board_pda() -> (Pubkey, u8) {
44    Pubkey::find_program_address(&[BOARD], &crate::ID)
45}
46
47pub fn config_pda() -> (Pubkey, u8) {
48    Pubkey::find_program_address(&[CONFIG], &crate::ID)
49}
50
51pub fn miner_pda(authority: Pubkey) -> (Pubkey, u8) {
52    Pubkey::find_program_address(&[MINER, &authority.to_bytes()], &crate::ID)
53}
54
55pub fn round_pda(id: u64) -> (Pubkey, u8) {
56    Pubkey::find_program_address(&[ROUND, &id.to_le_bytes()], &crate::ID)
57}
58
59pub fn stake_pda(authority: Pubkey) -> (Pubkey, u8) {
60    Pubkey::find_program_address(&[STAKE, &authority.to_bytes()], &crate::ID)
61}
62
63pub fn treasury_pda() -> (Pubkey, u8) {
64    Pubkey::find_program_address(&[TREASURY], &crate::ID)
65}
66
67pub fn treasury_tokens_address() -> Pubkey {
68    spl_associated_token_account::get_associated_token_address(&TREASURY_ADDRESS, &MINT_ADDRESS)
69}