ore_api/state/
mod.rs

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