mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-20 23:16:46 +00:00
log base reward after boost rewards
This commit is contained in:
@@ -16,9 +16,9 @@ const-crypto.workspace = true
|
||||
drillx.workspace = true
|
||||
mpl-token-metadata.workspace = true
|
||||
num_enum.workspace = true
|
||||
ore-utils.workspace = true
|
||||
solana-program.workspace = true
|
||||
spl-token.workspace = true
|
||||
spl-associated-token-account.workspace = true
|
||||
static_assertions.workspace = true
|
||||
steel.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use num_enum::IntoPrimitive;
|
||||
use ore_utils::*;
|
||||
use thiserror::Error;
|
||||
use steel::*;
|
||||
|
||||
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
|
||||
#[repr(u32)]
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
use steel::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
@@ -16,5 +14,6 @@ pub struct BoostEvent {
|
||||
pub mint: Pubkey,
|
||||
pub reward: u64,
|
||||
}
|
||||
|
||||
event!(MineEvent);
|
||||
event!(BoostEvent);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use num_enum::TryFromPrimitive;
|
||||
use ore_utils::*;
|
||||
use steel::*;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
|
||||
|
||||
@@ -6,6 +6,16 @@ pub mod loaders;
|
||||
pub mod sdk;
|
||||
pub mod state;
|
||||
|
||||
use solana_program::declare_id;
|
||||
pub mod prelude {
|
||||
pub use crate::consts::*;
|
||||
pub use crate::error::*;
|
||||
pub use crate::event::*;
|
||||
pub use crate::instruction::*;
|
||||
pub use crate::loaders::*;
|
||||
pub use crate::sdk::*;
|
||||
pub use crate::state::*;
|
||||
}
|
||||
|
||||
use steel::*;
|
||||
|
||||
declare_id!("7dNmnKiRRazHV9c6qzy39iJMLobSAx487XvD3C1hVgvt");
|
||||
|
||||
@@ -1,234 +1,28 @@
|
||||
use ore_utils::*;
|
||||
use solana_program::{account_info::AccountInfo, program_error::ProgramError, pubkey::Pubkey};
|
||||
use steel::*;
|
||||
|
||||
use crate::{
|
||||
consts::*,
|
||||
state::{Bus, Config, Proof, Treasury},
|
||||
state::{Config, Treasury},
|
||||
};
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Address does not match the expected bus address.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a bus account.
|
||||
/// - Bus ID does not match the expected ID.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_bus(info: &AccountInfo<'_>, id: u64, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.key.ne(&BUS_ADDRESSES[id as usize]) {
|
||||
return Err(ProgramError::InvalidSeeds);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
let bus_data = info.data.borrow();
|
||||
let bus = Bus::try_from_bytes(&bus_data)?;
|
||||
|
||||
if bus.id.ne(&id) {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
pub trait OreAccountInfoValidation {
|
||||
fn is_config(&self) -> Result<&Self, ProgramError>;
|
||||
fn is_treasury(&self) -> Result<&Self, ProgramError>;
|
||||
fn is_treasury_tokens(&self) -> Result<&Self, ProgramError>;
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a bus account.
|
||||
/// - Bus ID is not in the expected range.
|
||||
/// - Address is not in set of valid bus address.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_any_bus(info: &AccountInfo<'_>, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
impl OreAccountInfoValidation for AccountInfo<'_> {
|
||||
fn is_config(&self) -> Result<&Self, ProgramError> {
|
||||
self.has_address(&CONFIG_ADDRESS)?
|
||||
.is_type::<Config>(&crate::ID)
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
fn is_treasury(&self) -> Result<&Self, ProgramError> {
|
||||
self.has_address(&TREASURY_ADDRESS)?
|
||||
.is_type::<Treasury>(&crate::ID)
|
||||
}
|
||||
|
||||
if info.data.borrow()[0].ne(&(Bus::discriminator() as u8)) {
|
||||
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||
fn is_treasury_tokens(&self) -> Result<&Self, ProgramError> {
|
||||
self.has_address(&TREASURY_TOKENS_ADDRESS)
|
||||
}
|
||||
|
||||
if !BUS_ADDRESSES.contains(info.key) {
|
||||
return Err(ProgramError::InvalidSeeds);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Address does not match the expected address.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a config account.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_config(info: &AccountInfo<'_>, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.key.ne(&CONFIG_ADDRESS) {
|
||||
return Err(ProgramError::InvalidSeeds);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
if info.data.borrow()[0].ne(&(Config::discriminator() as u8)) {
|
||||
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a proof account.
|
||||
/// - Proof authority does not match the expected address.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_proof(
|
||||
info: &AccountInfo<'_>,
|
||||
authority: &Pubkey,
|
||||
is_writable: bool,
|
||||
) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
let proof_data = info.data.borrow();
|
||||
let proof = Proof::try_from_bytes(&proof_data)?;
|
||||
|
||||
if proof.authority.ne(&authority) {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a proof account.
|
||||
/// - Proof miner does not match the expected address.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_proof_with_miner(
|
||||
info: &AccountInfo<'_>,
|
||||
miner: &Pubkey,
|
||||
is_writable: bool,
|
||||
) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
let proof_data = info.data.borrow();
|
||||
let proof = Proof::try_from_bytes(&proof_data)?;
|
||||
|
||||
if proof.miner.ne(&miner) {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a proof account.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_any_proof(info: &AccountInfo<'_>, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
if info.data.borrow()[0].ne(&(Proof::discriminator() as u8)) {
|
||||
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Owner is not Ore program.
|
||||
/// - Address does not match the expected address.
|
||||
/// - Data is empty.
|
||||
/// - Data cannot deserialize into a treasury account.
|
||||
/// - Expected to be writable, but is not.
|
||||
pub fn load_treasury(info: &AccountInfo<'_>, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.owner.ne(&crate::id()) {
|
||||
return Err(ProgramError::InvalidAccountOwner);
|
||||
}
|
||||
|
||||
if info.key.ne(&TREASURY_ADDRESS) {
|
||||
return Err(ProgramError::InvalidSeeds);
|
||||
}
|
||||
|
||||
if info.data_is_empty() {
|
||||
return Err(ProgramError::UninitializedAccount);
|
||||
}
|
||||
|
||||
if info.data.borrow()[0].ne(&(Treasury::discriminator() as u8)) {
|
||||
return Err(solana_program::program_error::ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
if is_writable && !info.is_writable {
|
||||
return Err(ProgramError::InvalidAccountData);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Errors if:
|
||||
/// - Address does not match the expected treasury tokens address.
|
||||
/// - Cannot load as a token account
|
||||
pub fn load_treasury_tokens(info: &AccountInfo<'_>, is_writable: bool) -> Result<(), ProgramError> {
|
||||
if info.key.ne(&TREASURY_TOKENS_ADDRESS) {
|
||||
return Err(ProgramError::InvalidSeeds);
|
||||
}
|
||||
|
||||
load_token_account(info, Some(&TREASURY_ADDRESS), &MINT_ADDRESS, is_writable)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
use drillx::Solution;
|
||||
use solana_program::{
|
||||
instruction::{AccountMeta, Instruction},
|
||||
pubkey::Pubkey,
|
||||
system_program, sysvar,
|
||||
};
|
||||
use steel::*;
|
||||
|
||||
use crate::{
|
||||
consts::*,
|
||||
@@ -23,19 +19,15 @@ pub fn auth(proof: Pubkey) -> Instruction {
|
||||
/// Builds a claim instruction.
|
||||
pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
|
||||
let proof = proof_pda(signer).0;
|
||||
let treasury_tokens = spl_associated_token_account::get_associated_token_address(
|
||||
&TREASURY_ADDRESS,
|
||||
&MINT_ADDRESS,
|
||||
);
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(beneficiary, false),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(TREASURY_ADDRESS, false),
|
||||
AccountMeta::new(treasury_tokens, false),
|
||||
AccountMeta::new_readonly(spl_token::id(), false),
|
||||
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
],
|
||||
data: Claim {
|
||||
amount: amount.to_le_bytes(),
|
||||
@@ -48,11 +40,11 @@ pub fn claim(signer: Pubkey, beneficiary: Pubkey, amount: u64) -> Instruction {
|
||||
pub fn close(signer: Pubkey) -> Instruction {
|
||||
let proof = proof_pda(signer).0;
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(solana_program::system_program::id(), false),
|
||||
AccountMeta::new_readonly(solana_program::system_program::ID, false),
|
||||
],
|
||||
data: Close {}.to_bytes(),
|
||||
}
|
||||
@@ -67,22 +59,21 @@ pub fn mine(
|
||||
boost_accounts: Vec<Pubkey>,
|
||||
) -> Instruction {
|
||||
let proof = proof_pda(authority).0;
|
||||
let accounts = vec![
|
||||
let required_accounts = vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(bus, false),
|
||||
AccountMeta::new_readonly(CONFIG_ADDRESS, false),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new_readonly(sysvar::instructions::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::instructions::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
];
|
||||
let boost_accounts = boost_accounts
|
||||
let optional_accounts = boost_accounts
|
||||
.into_iter()
|
||||
.map(|pk| AccountMeta::new_readonly(pk, false))
|
||||
.collect();
|
||||
let accounts = [accounts, boost_accounts].concat();
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
accounts,
|
||||
program_id: crate::ID,
|
||||
accounts: [required_accounts, optional_accounts].concat(),
|
||||
data: Mine {
|
||||
digest: solution.d,
|
||||
nonce: solution.n,
|
||||
@@ -95,14 +86,14 @@ pub fn mine(
|
||||
pub fn open(signer: Pubkey, miner: Pubkey, payer: Pubkey) -> Instruction {
|
||||
let proof_pda = proof_pda(signer);
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new_readonly(miner, false),
|
||||
AccountMeta::new(payer, true),
|
||||
AccountMeta::new(proof_pda.0, false),
|
||||
AccountMeta::new_readonly(solana_program::system_program::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::id(), false),
|
||||
AccountMeta::new_readonly(solana_program::system_program::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
],
|
||||
data: Open { bump: proof_pda.1 }.to_bytes(),
|
||||
}
|
||||
@@ -110,12 +101,8 @@ pub fn open(signer: Pubkey, miner: Pubkey, payer: Pubkey) -> Instruction {
|
||||
|
||||
/// Builds a reset instruction.
|
||||
pub fn reset(signer: Pubkey) -> Instruction {
|
||||
let treasury_tokens = spl_associated_token_account::get_associated_token_address(
|
||||
&TREASURY_ADDRESS,
|
||||
&MINT_ADDRESS,
|
||||
);
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(BUS_ADDRESSES[0], false),
|
||||
@@ -129,8 +116,8 @@ pub fn reset(signer: Pubkey) -> Instruction {
|
||||
AccountMeta::new(CONFIG_ADDRESS, false),
|
||||
AccountMeta::new(MINT_ADDRESS, false),
|
||||
AccountMeta::new(TREASURY_ADDRESS, false),
|
||||
AccountMeta::new(treasury_tokens, false),
|
||||
AccountMeta::new_readonly(spl_token::id(), false),
|
||||
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
],
|
||||
data: Reset {}.to_bytes(),
|
||||
}
|
||||
@@ -139,18 +126,14 @@ pub fn reset(signer: Pubkey) -> Instruction {
|
||||
/// Build a stake instruction.
|
||||
pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
|
||||
let proof = proof_pda(signer).0;
|
||||
let treasury_tokens = spl_associated_token_account::get_associated_token_address(
|
||||
&TREASURY_ADDRESS,
|
||||
&MINT_ADDRESS,
|
||||
);
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(proof, false),
|
||||
AccountMeta::new(sender, false),
|
||||
AccountMeta::new(treasury_tokens, false),
|
||||
AccountMeta::new_readonly(spl_token::id(), false),
|
||||
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
],
|
||||
data: Stake {
|
||||
amount: amount.to_le_bytes(),
|
||||
@@ -163,7 +146,7 @@ pub fn stake(signer: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
|
||||
pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction {
|
||||
let proof = proof_pda(signer).0;
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new_readonly(miner, false),
|
||||
@@ -176,7 +159,7 @@ pub fn update(signer: Pubkey, miner: Pubkey) -> Instruction {
|
||||
// Build an upgrade instruction.
|
||||
pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64) -> Instruction {
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(beneficiary, false),
|
||||
@@ -184,7 +167,7 @@ pub fn upgrade(signer: Pubkey, beneficiary: Pubkey, sender: Pubkey, amount: u64)
|
||||
AccountMeta::new(MINT_V1_ADDRESS, false),
|
||||
AccountMeta::new(sender, false),
|
||||
AccountMeta::new(TREASURY_ADDRESS, false),
|
||||
AccountMeta::new_readonly(spl_token::id(), false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
],
|
||||
data: Upgrade {
|
||||
amount: amount.to_le_bytes(),
|
||||
@@ -206,10 +189,8 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
bus_pda(7),
|
||||
];
|
||||
let config_pda = config_pda();
|
||||
let mint_pda = Pubkey::find_program_address(&[MINT, MINT_NOISE.as_slice()], &crate::id());
|
||||
let mint_pda = Pubkey::find_program_address(&[MINT, MINT_NOISE.as_slice()], &crate::ID);
|
||||
let treasury_pda = treasury_pda();
|
||||
let treasury_tokens =
|
||||
spl_associated_token_account::get_associated_token_address(&treasury_pda.0, &mint_pda.0);
|
||||
let metadata_pda = Pubkey::find_program_address(
|
||||
&[
|
||||
METADATA,
|
||||
@@ -219,7 +200,7 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
&mpl_token_metadata::ID,
|
||||
);
|
||||
Instruction {
|
||||
program_id: crate::id(),
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(bus_pdas[0].0, false),
|
||||
@@ -234,12 +215,12 @@ pub fn initialize(signer: Pubkey) -> Instruction {
|
||||
AccountMeta::new(metadata_pda.0, false),
|
||||
AccountMeta::new(mint_pda.0, false),
|
||||
AccountMeta::new(treasury_pda.0, false),
|
||||
AccountMeta::new(treasury_tokens, false),
|
||||
AccountMeta::new_readonly(system_program::id(), false),
|
||||
AccountMeta::new_readonly(spl_token::id(), false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::id(), false),
|
||||
AccountMeta::new(TREASURY_TOKENS_ADDRESS, false),
|
||||
AccountMeta::new_readonly(system_program::ID, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
AccountMeta::new_readonly(mpl_token_metadata::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::rent::id(), false),
|
||||
AccountMeta::new_readonly(sysvar::rent::ID, false),
|
||||
],
|
||||
data: Initialize {
|
||||
bus_0_bump: bus_pdas[0].1,
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
use crate::consts::BUS;
|
||||
use steel::*;
|
||||
|
||||
use super::OreAccount;
|
||||
|
||||
@@ -25,9 +21,4 @@ pub struct Bus {
|
||||
pub top_balance: u64,
|
||||
}
|
||||
|
||||
/// Fetch the PDA of a bus account.
|
||||
pub fn bus_pda(id: u8) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[BUS, &[id]], &crate::id())
|
||||
}
|
||||
|
||||
account!(OreAccount, Bus);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
use crate::consts::CONFIG;
|
||||
use steel::*;
|
||||
|
||||
use super::OreAccount;
|
||||
|
||||
@@ -23,9 +19,4 @@ pub struct Config {
|
||||
pub top_balance: u64,
|
||||
}
|
||||
|
||||
/// Derive the PDA of the config account.
|
||||
pub fn config_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[CONFIG], &crate::id())
|
||||
}
|
||||
|
||||
account!(OreAccount, Config);
|
||||
|
||||
@@ -8,7 +8,9 @@ pub use config::*;
|
||||
pub use proof::*;
|
||||
pub use treasury::*;
|
||||
|
||||
use num_enum::{IntoPrimitive, TryFromPrimitive};
|
||||
use steel::*;
|
||||
|
||||
use crate::consts::*;
|
||||
|
||||
#[repr(u8)]
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
|
||||
@@ -18,3 +20,23 @@ pub enum OreAccount {
|
||||
Proof = 102,
|
||||
Treasury = 103,
|
||||
}
|
||||
|
||||
/// Fetch the PDA of a bus account.
|
||||
pub fn bus_pda(id: u8) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[BUS, &[id]], &crate::id())
|
||||
}
|
||||
|
||||
/// Derive the PDA of the config account.
|
||||
pub fn config_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[CONFIG], &crate::id())
|
||||
}
|
||||
|
||||
/// Derive the PDA of a proof account.
|
||||
pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
|
||||
}
|
||||
|
||||
/// Derive the PDA of the treasury account.
|
||||
pub fn treasury_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[TREASURY], &crate::id())
|
||||
}
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
use crate::consts::PROOF;
|
||||
use steel::*;
|
||||
|
||||
use super::OreAccount;
|
||||
|
||||
@@ -39,9 +35,4 @@ pub struct Proof {
|
||||
pub total_rewards: u64,
|
||||
}
|
||||
|
||||
/// Derive the PDA of a proof account.
|
||||
pub fn proof_pda(authority: Pubkey) -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[PROOF, authority.as_ref()], &crate::id())
|
||||
}
|
||||
|
||||
account!(OreAccount, Proof);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
use bytemuck::{Pod, Zeroable};
|
||||
use ore_utils::*;
|
||||
use solana_program::pubkey::Pubkey;
|
||||
|
||||
use crate::consts::TREASURY;
|
||||
use steel::*;
|
||||
|
||||
use super::OreAccount;
|
||||
|
||||
@@ -12,9 +8,4 @@ use super::OreAccount;
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct Treasury {}
|
||||
|
||||
/// Derive the PDA of the treasury account.
|
||||
pub fn treasury_pda() -> (Pubkey, u8) {
|
||||
Pubkey::find_program_address(&[TREASURY], &crate::id())
|
||||
}
|
||||
|
||||
account!(OreAccount, Treasury);
|
||||
|
||||
Reference in New Issue
Block a user