mirror of
https://github.com/d0zingcat/ore.git
synced 2026-06-08 23:26:48 +00:00
add DeclareProof instruction
This commit is contained in:
@@ -89,6 +89,10 @@ pub enum OreInstruction {
|
|||||||
#[account(6, name = "mint_v1", desc = "Ore v1 token mint account", writable)]
|
#[account(6, name = "mint_v1", desc = "Ore v1 token mint account", writable)]
|
||||||
#[account(7, name = "token_program", desc = "SPL token program")]
|
#[account(7, name = "token_program", desc = "SPL token program")]
|
||||||
Upgrade = 7,
|
Upgrade = 7,
|
||||||
|
|
||||||
|
#[account(0, name = "ore_program", desc = "Ore program")]
|
||||||
|
#[account(1, name = "proof", desc = "Ore proof account")]
|
||||||
|
DeclareProof = 8,
|
||||||
|
|
||||||
#[account(0, name = "ore_program", desc = "Ore program")]
|
#[account(0, name = "ore_program", desc = "Ore program")]
|
||||||
#[account(1, name = "signer", desc = "Admin signer", signer)]
|
#[account(1, name = "signer", desc = "Admin signer", signer)]
|
||||||
|
|||||||
34
program/src/declare_proof.rs
Normal file
34
program/src/declare_proof.rs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
use solana_program::{
|
||||||
|
account_info::AccountInfo,
|
||||||
|
entrypoint::ProgramResult,
|
||||||
|
program_error::ProgramError,
|
||||||
|
pubkey::Pubkey,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/// DeclareProof is used by other instructions in the same transaction.
|
||||||
|
/// - Other instructions will use transaction introspection to ensure they
|
||||||
|
/// only process the declared proof.
|
||||||
|
/// - Other instructions that need to validate the declared proof will only
|
||||||
|
/// look at the first and second instructions in the transaction
|
||||||
|
///
|
||||||
|
/// Safety requirements:
|
||||||
|
/// - No safety requirements are required in this instruction to keep cu's as
|
||||||
|
/// low as possible. Other instructions that use the declared proof handle
|
||||||
|
/// validation via the loader.
|
||||||
|
pub fn process_declare_proof<'a, 'info>(
|
||||||
|
_program_id: &Pubkey,
|
||||||
|
accounts: &'a [AccountInfo<'info>],
|
||||||
|
_data: &[u8],
|
||||||
|
) -> ProgramResult {
|
||||||
|
// Ensure one account info is provided
|
||||||
|
// Validation of this proof is handled by the mine ix
|
||||||
|
let [_proof_info] =
|
||||||
|
accounts
|
||||||
|
else {
|
||||||
|
return Err(ProgramError::NotEnoughAccountKeys);
|
||||||
|
};
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
mod claim;
|
mod claim;
|
||||||
mod close;
|
mod close;
|
||||||
mod initialize;
|
mod initialize;
|
||||||
|
mod declare_proof;
|
||||||
mod mine;
|
mod mine;
|
||||||
mod open;
|
mod open;
|
||||||
mod reset;
|
mod reset;
|
||||||
@@ -11,6 +12,7 @@ mod upgrade;
|
|||||||
use claim::*;
|
use claim::*;
|
||||||
use close::*;
|
use close::*;
|
||||||
use initialize::*;
|
use initialize::*;
|
||||||
|
use declare_proof::*;
|
||||||
use mine::*;
|
use mine::*;
|
||||||
use open::*;
|
use open::*;
|
||||||
use reset::*;
|
use reset::*;
|
||||||
@@ -45,6 +47,7 @@ pub fn process_instruction(
|
|||||||
match OreInstruction::try_from(*tag).or(Err(ProgramError::InvalidInstructionData))? {
|
match OreInstruction::try_from(*tag).or(Err(ProgramError::InvalidInstructionData))? {
|
||||||
OreInstruction::Claim => process_claim(program_id, accounts, data)?,
|
OreInstruction::Claim => process_claim(program_id, accounts, data)?,
|
||||||
OreInstruction::Close => process_close(program_id, accounts, data)?,
|
OreInstruction::Close => process_close(program_id, accounts, data)?,
|
||||||
|
OreInstruction::DeclareProof => process_declare_proof(program_id, accounts, data)?,
|
||||||
OreInstruction::Mine => process_mine(program_id, accounts, data)?,
|
OreInstruction::Mine => process_mine(program_id, accounts, data)?,
|
||||||
OreInstruction::Open => process_open(program_id, accounts, data)?,
|
OreInstruction::Open => process_open(program_id, accounts, data)?,
|
||||||
OreInstruction::Reset => process_reset(program_id, accounts, data)?,
|
OreInstruction::Reset => process_reset(program_id, accounts, data)?,
|
||||||
|
|||||||
Reference in New Issue
Block a user