This commit is contained in:
Hardhat Chad
2025-06-06 10:02:28 -07:00
parent 42fc923cb1
commit 87cf3603c3
51 changed files with 704 additions and 36 deletions

View File

@@ -0,0 +1,2 @@
/// The seed of the delegate account PDA.
pub const DELEGATE: &[u8] = b"delegate";

View File

@@ -0,0 +1,10 @@
use steel::*;
#[derive(Debug, Error, Clone, Copy, PartialEq, Eq, IntoPrimitive)]
#[repr(u32)]
pub enum OreError {
#[error("Placeholder error")]
Dummy = 0,
}
error!(OreError);

View File

@@ -0,0 +1 @@
use steel::*;

View File

@@ -0,0 +1,37 @@
use steel::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
pub enum OreDelegateInstruction {
Deposit = 0,
Withdraw = 1,
Crank = 2,
Payout = 3,
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Deposit {
pub amount: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Withdraw {
pub amount: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Crank {
pub amount: [u8; 8],
}
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
pub struct Payout {}
instruction!(OreDelegateInstruction, Deposit);
instruction!(OreDelegateInstruction, Withdraw);
instruction!(OreDelegateInstruction, Crank);
instruction!(OreDelegateInstruction, Payout);

View File

@@ -0,0 +1,18 @@
pub mod consts;
pub mod error;
pub mod event;
pub mod instruction;
pub mod sdk;
pub mod state;
pub mod prelude {
pub use crate::consts::*;
pub use crate::error::*;
pub use crate::event::*;
pub use crate::instruction::*;
pub use crate::state::*;
}
use steel::*;
declare_id!("oreV2ZymfyeXgNgBdqMkumTqqAprVqgBWQfoYkrtKWQ");

View File

@@ -0,0 +1,3 @@
use steel::*;
use crate::{instruction::*, state::*};

View File

@@ -0,0 +1,21 @@
use steel::*;
use super::OreDelegateAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Delegate {
/// The authority of the delegate.
pub authority: Pubkey,
/// The number of hash tokens deposited for mining.
pub balance: u64,
/// The block these hash tokens are associated with.
pub block_id: u64,
/// The fee to payout per crank (lamports).
pub fee: u64,
}
account!(OreDelegateAccount, Delegate);

View File

@@ -0,0 +1,20 @@
mod delegate;
pub use delegate::*;
use crate::consts::*;
use steel::*;
#[repr(u8)]
#[derive(Clone, Copy, Debug, Eq, PartialEq, IntoPrimitive, TryFromPrimitive)]
pub enum OreDelegateAccount {
Delegate = 100,
}
pub fn delegate_pda(authority: Pubkey, block_id: u64) -> (Pubkey, u8) {
Pubkey::find_program_address(
&[DELEGATE, &authority.to_bytes(), &block_id.to_le_bytes()],
&crate::ID,
)
}