This commit is contained in:
Hardhat Chad
2025-05-29 09:58:05 -07:00
parent 6507372413
commit 79a9ac3b40
17 changed files with 182 additions and 167 deletions

View File

@@ -5,7 +5,7 @@ use super::OreAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Block {
/// The cumulative amount risked in the current round.
/// The cumulative amount deployed in the current round.
pub cumulative_sum: u64,
/// The current round.
@@ -14,7 +14,7 @@ pub struct Block {
/// The slot at which the current round ends.
pub ends_at: u64,
/// The mint used for wagers of the current round.
/// The mint used for commits of the current round.
pub mint: Pubkey,
/// The noise used for the current round for provably fair randomness.
@@ -29,8 +29,8 @@ pub struct Block {
/// The time the current round started at.
pub started_at: u64,
/// The number of wagers made in the current round.
pub total_wagers: u64,
/// The number of commits made in the current round.
pub total_commits: u64,
}
account!(OreAccount, Block);

27
api/src/state/commit.rs Normal file
View File

@@ -0,0 +1,27 @@
use steel::*;
use super::OreAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Commit {
/// The amount deployed in this commit.
pub amount: u64,
/// The signer authorized to use this commit.
pub authority: Pubkey,
/// The cumulative amount deployed in the current round prior to this commit.
pub cumulative_sum: u64,
/// The current round this commit is for.
pub round: u64,
/// The ID of the commit, used for provably fair randomness.
pub seed: [u8; 32],
/// The timestamp of the commit.
pub timestamp: u64,
}
account!(OreAccount, Commit);

View File

@@ -1,12 +1,12 @@
mod block;
mod commit;
mod proof;
mod treasury;
mod wager;
pub use block::*;
pub use commit::*;
pub use proof::*;
pub use treasury::*;
pub use wager::*;
use steel::*;
@@ -18,7 +18,7 @@ pub enum OreAccount {
Proof = 102,
Treasury = 103,
Block = 104,
Wager = 105,
Commit = 105,
}
pub fn block_pda() -> (Pubkey, u8) {
@@ -33,6 +33,6 @@ pub fn treasury_pda() -> (Pubkey, u8) {
Pubkey::find_program_address(&[TREASURY], &crate::ID)
}
pub fn wager_pda(round: u64, seed: [u8; 32]) -> (Pubkey, u8) {
Pubkey::find_program_address(&[WAGER, &round.to_le_bytes(), &seed], &crate::ID)
pub fn commit_pda(round: u64, seed: [u8; 32]) -> (Pubkey, u8) {
Pubkey::find_program_address(&[COMMIT, &round.to_le_bytes(), &seed], &crate::ID)
}

View File

@@ -1,27 +0,0 @@
use steel::*;
use super::OreAccount;
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Wager {
/// The amount bet in this wager.
pub amount: u64,
/// The signer authorized to use this wager.
pub authority: Pubkey,
/// The cumulative amount bet in the current round prior to this wager.
pub cumulative_sum: u64,
/// The current round this wager is for.
pub round: u64,
/// The ID of the wager, used for provably fair randomness.
pub seed: [u8; 32],
/// The timestamp of the wager.
pub timestamp: u64,
}
account!(OreAccount, Wager);