1mod automation;
2mod board;
3mod config;
4mod miner;
5mod round;
6mod treasury;
7
8pub use automation::*;
9pub use board::*;
10pub use config::*;
11pub use miner::*;
12pub use round::*;
13pub use treasury::*;
14
15use crate::consts::*;
16
17use steel::*;
18
19#[repr(u8)]
20#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
21pub enum OreAccount {
22 Automation = 100,
23 Config = 101,
24 Miner = 103,
25 Treasury = 104,
26 Board = 105,
27 Round = 109,
28}
29
30#[repr(u8)]
31#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
32pub enum OreAccountV4 {
33 AutomationV4 = 100,
34 ConfigV4 = 101,
35 MinerV4 = 103,
36 TreasuryV4 = 104,
37 BoardV4 = 105,
38 RoundV4 = 109,
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 stats_pda() -> (Pubkey, u8) {
50 Pubkey::find_program_address(&[STATS], &crate::ID)
51}
52
53pub fn config_pda() -> (Pubkey, u8) {
54 Pubkey::find_program_address(&[CONFIG], &crate::ID)
55}
56
57pub fn miner_pda(authority: Pubkey) -> (Pubkey, u8) {
58 Pubkey::find_program_address(&[MINER, &authority.to_bytes()], &crate::ID)
59}
60
61pub fn round_pda(id: u64) -> (Pubkey, u8) {
62 Pubkey::find_program_address(&[ROUND, &id.to_le_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 let treasury_address = treasury_pda().0;
71 spl_associated_token_account::get_associated_token_address(&treasury_address, &MINT_ADDRESS)
72}