mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 15:10:13 +00:00
scaffold bury ix
This commit is contained in:
@@ -5,9 +5,10 @@ use steel::*;
|
||||
pub enum OreInstruction {
|
||||
// User
|
||||
Bet = 0,
|
||||
Close = 1,
|
||||
Payout = 2,
|
||||
Reset = 3,
|
||||
Bury = 1,
|
||||
Close = 2,
|
||||
Payout = 3,
|
||||
Reset = 4,
|
||||
|
||||
// Admin
|
||||
Initialize = 100,
|
||||
@@ -20,6 +21,10 @@ pub struct Bet {
|
||||
pub seed: [u8; 32],
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct Bury {}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, Pod, Zeroable)]
|
||||
pub struct Close {}
|
||||
@@ -37,6 +42,7 @@ pub struct Payout {}
|
||||
pub struct Initialize {}
|
||||
|
||||
instruction!(OreInstruction, Bet);
|
||||
instruction!(OreInstruction, Bury);
|
||||
instruction!(OreInstruction, Close);
|
||||
instruction!(OreInstruction, Payout);
|
||||
instruction!(OreInstruction, Reset);
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
use steel::*;
|
||||
|
||||
use crate::{consts::*, instruction::*, state::*};
|
||||
use crate::{instruction::*, state::*};
|
||||
|
||||
pub fn bet(
|
||||
signer: Pubkey,
|
||||
mint: Pubkey,
|
||||
amount: u64,
|
||||
id: u64,
|
||||
round: u64,
|
||||
seed: Option<[u8; 32]>,
|
||||
) -> Instruction {
|
||||
let sender = spl_associated_token_account::get_associated_token_address(&signer, &mint);
|
||||
let block = block_pda().0;
|
||||
let block_bets = spl_associated_token_account::get_associated_token_address(&signer, &mint);
|
||||
let wager = wager_pda(round, id).0;
|
||||
Instruction {
|
||||
program_id: crate::ID,
|
||||
accounts: vec![
|
||||
AccountMeta::new(signer, true),
|
||||
AccountMeta::new(block, false),
|
||||
AccountMeta::new(block_bets, false),
|
||||
AccountMeta::new(sender, false),
|
||||
AccountMeta::new(wager, false),
|
||||
AccountMeta::new_readonly(spl_token::ID, false),
|
||||
AccountMeta::new_readonly(spl_associated_token_account::ID, false),
|
||||
AccountMeta::new_readonly(sysvar::slot_hashes::ID, false),
|
||||
],
|
||||
data: Bet {
|
||||
amount: amount.to_le_bytes(),
|
||||
seed: seed.unwrap_or([0; 32]),
|
||||
}
|
||||
.to_bytes(),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user