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
29    //
30    Board = 105,
31    Stake = 108,
32    Round = 109,
33}
34
35#[repr(u8)]
36#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
37pub enum OreAccountOLD {
38    ConfigOLD = 101,
39}
40
41pub fn automation_pda(authority: Pubkey) -> (Pubkey, u8) {
42    Pubkey::find_program_address(&[AUTOMATION, &authority.to_bytes()], &crate::ID)
43}
44
45pub fn board_pda() -> (Pubkey, u8) {
46    Pubkey::find_program_address(&[BOARD], &crate::ID)
47}
48
49pub fn config_pda() -> (Pubkey, u8) {
50    Pubkey::find_program_address(&[CONFIG], &crate::ID)
51}
52
53pub fn miner_pda(authority: Pubkey) -> (Pubkey, u8) {
54    Pubkey::find_program_address(&[MINER, &authority.to_bytes()], &crate::ID)
55}
56
57pub fn round_pda(id: u64) -> (Pubkey, u8) {
58    Pubkey::find_program_address(&[ROUND, &id.to_le_bytes()], &crate::ID)
59}
60
61pub fn stake_pda(authority: Pubkey) -> (Pubkey, u8) {
62    Pubkey::find_program_address(&[STAKE, &authority.to_bytes()], &crate::ID)
63}
64
65pub fn treasury_pda() -> (Pubkey, u8) {
66    Pubkey::find_program_address(&[TREASURY], &crate::ID)
67}
68
69pub fn treasury_tokens_address() -> Pubkey {
70    spl_associated_token_account::get_associated_token_address(&TREASURY_ADDRESS, &MINT_ADDRESS)
71}