mirror of
https://github.com/d0zingcat/ore.git
synced 2026-05-14 07:26:51 +00:00
add DeclareProof instruction
This commit is contained in:
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 close;
|
||||
mod initialize;
|
||||
mod declare_proof;
|
||||
mod mine;
|
||||
mod open;
|
||||
mod reset;
|
||||
@@ -11,6 +12,7 @@ mod upgrade;
|
||||
use claim::*;
|
||||
use close::*;
|
||||
use initialize::*;
|
||||
use declare_proof::*;
|
||||
use mine::*;
|
||||
use open::*;
|
||||
use reset::*;
|
||||
@@ -45,6 +47,7 @@ pub fn process_instruction(
|
||||
match OreInstruction::try_from(*tag).or(Err(ProgramError::InvalidInstructionData))? {
|
||||
OreInstruction::Claim => process_claim(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::Open => process_open(program_id, accounts, data)?,
|
||||
OreInstruction::Reset => process_reset(program_id, accounts, data)?,
|
||||
|
||||
Reference in New Issue
Block a user