mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-20 23:16:46 +00:00
cleanup
This commit is contained in:
69
api/src/state/mod.rs
Normal file
69
api/src/state/mod.rs
Normal file
@@ -0,0 +1,69 @@
|
||||
mod block;
|
||||
mod config;
|
||||
mod market;
|
||||
mod miner;
|
||||
mod permit;
|
||||
mod stake;
|
||||
mod treasury;
|
||||
|
||||
pub use block::*;
|
||||
pub use config::*;
|
||||
pub use market::*;
|
||||
pub use miner::*;
|
||||
pub use permit::*;
|
||||
pub use stake::*;
|
||||
pub use treasury::*;
|
||||
|
||||
use crate::consts::*;
|
||||
|
||||
use steel::*;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||
pub enum OreAccount {
|
||||
Block = 100,
|
||||
Config = 101,
|
||||
Market = 102,
|
||||
Miner = 103,
|
||||
Permit = 104,
|
||||
Stake = 105,
|
||||
Treasury = 106,
|
||||
}
|
||||
|
||||
pub fn block_pda(id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[BLOCK, &id.to_le_bytes()], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn config_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[CONFIG], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn market_pda(id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[MARKET, &id.to_le_bytes()], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn miner_pda(authority: Pubkey) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[MINER, &authority.to_bytes()], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn mint_pda(id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[MINT, &id.to_le_bytes()], &crate::ID)
|
||||
}
|
||||
|
||||
pub fn permit_pda(authority: Pubkey, block_id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(
|
||||
&[PERMIT, &authority.to_bytes(), &block_id.to_le_bytes()],
|
||||
&crate::ID,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn stake_pda(authority: Pubkey, block_id: u64) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(
|
||||
&[STAKE, &authority.to_bytes(), &block_id.to_le_bytes()],
|
||||
&crate::ID,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn treasury_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[TREASURY], &crate::ID)
|
||||
}
|
||||
Reference in New Issue
Block a user