mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-13 15:09:57 +00:00
events
This commit is contained in:
@@ -2,11 +2,27 @@ use steel::*;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct BlockEvent {
|
||||
pub score: u64,
|
||||
pub block_reward: u64,
|
||||
pub boost_reward: u64,
|
||||
pub struct PayoutEvent {
|
||||
pub authority: Pubkey,
|
||||
pub amount: u64,
|
||||
pub ts: u64,
|
||||
}
|
||||
|
||||
event!(BlockEvent);
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct BetEvent {
|
||||
pub authority: Pubkey,
|
||||
pub amount: u64,
|
||||
pub ts: u64,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
|
||||
pub struct BuryEvent {
|
||||
pub amount: u64,
|
||||
pub ts: u64,
|
||||
}
|
||||
|
||||
event!(PayoutEvent);
|
||||
event!(BetEvent);
|
||||
event!(BuryEvent);
|
||||
|
||||
@@ -67,5 +67,13 @@ pub fn process_bet(accounts: &[AccountInfo<'_>], data: &[u8]) -> ProgramResult {
|
||||
amount,
|
||||
)?;
|
||||
|
||||
// Emit an event.
|
||||
BetEvent {
|
||||
authority: *signer_info.key,
|
||||
amount,
|
||||
ts: clock.unix_timestamp as u64,
|
||||
}
|
||||
.log();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ use steel::*;
|
||||
/// Swaps bets into ORE and buries the ORE.
|
||||
pub fn process_bury(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult {
|
||||
// Load accounts.
|
||||
let clock = Clock::get()?;
|
||||
let (required_accounts, meteora_accounts) = accounts.split_at(5);
|
||||
let [signer_info, block_info, block_bets_info, block_ore_info, bet_mint_info, ore_mint_info] =
|
||||
required_accounts
|
||||
@@ -67,5 +68,12 @@ pub fn process_bury(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResult
|
||||
block_bump,
|
||||
)?;
|
||||
|
||||
// Emit an event.
|
||||
BuryEvent {
|
||||
amount: block_ore.amount(),
|
||||
ts: clock.unix_timestamp as u64,
|
||||
}
|
||||
.log();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -63,5 +63,13 @@ pub fn process_payout(accounts: &[AccountInfo<'_>], _data: &[u8]) -> ProgramResu
|
||||
&[TREASURY],
|
||||
)?;
|
||||
|
||||
// Emit an event.
|
||||
PayoutEvent {
|
||||
authority: wager.authority,
|
||||
amount: block.reward,
|
||||
ts: clock.unix_timestamp as u64,
|
||||
}
|
||||
.log();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user