Adapt to changes to native program entrypoint
This commit is contained in:
parent
9c88f8205b
commit
f2e7f0c32b
|
@ -14,4 +14,5 @@ getrandom = { version = "0.1", features = ["dummy"] }
|
||||||
num-derive = "0.3"
|
num-derive = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
solana-sdk = "=1.9.0"
|
solana-sdk = "=1.9.0"
|
||||||
|
solana-program-runtime = "=1.9.0"
|
||||||
spl-zk-token-sdk = { path = "../sdk" }
|
spl-zk-token-sdk = { path = "../sdk" }
|
||||||
|
|
|
@ -2,16 +2,15 @@
|
||||||
|
|
||||||
use {
|
use {
|
||||||
bytemuck::Pod,
|
bytemuck::Pod,
|
||||||
solana_sdk::{
|
solana_program_runtime::{ic_msg, invoke_context::InvokeContext},
|
||||||
ic_msg, instruction::InstructionError, process_instruction::InvokeContext, pubkey::Pubkey,
|
solana_sdk::instruction::InstructionError,
|
||||||
},
|
|
||||||
spl_zk_token_sdk::zk_token_proof_instruction::*,
|
spl_zk_token_sdk::zk_token_proof_instruction::*,
|
||||||
std::result::Result,
|
std::result::Result,
|
||||||
};
|
};
|
||||||
|
|
||||||
fn verify<T: Pod + Verifiable>(
|
fn verify<T: Pod + Verifiable>(
|
||||||
input: &[u8],
|
input: &[u8],
|
||||||
invoke_context: &mut dyn InvokeContext,
|
invoke_context: &mut InvokeContext,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
let proof = ProofInstruction::decode_data::<T>(input).ok_or_else(|| {
|
let proof = ProofInstruction::decode_data::<T>(input).ok_or_else(|| {
|
||||||
ic_msg!(invoke_context, "invalid proof data");
|
ic_msg!(invoke_context, "invalid proof data");
|
||||||
|
@ -25,9 +24,9 @@ fn verify<T: Pod + Verifiable>(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn process_instruction(
|
pub fn process_instruction(
|
||||||
program_id: &Pubkey,
|
_first_instruction_account: usize,
|
||||||
input: &[u8],
|
input: &[u8],
|
||||||
invoke_context: &mut dyn InvokeContext,
|
invoke_context: &mut InvokeContext,
|
||||||
) -> Result<(), InstructionError> {
|
) -> Result<(), InstructionError> {
|
||||||
if invoke_context.invoke_depth() != 1 {
|
if invoke_context.invoke_depth() != 1 {
|
||||||
// Not supported as an inner instruction
|
// Not supported as an inner instruction
|
||||||
|
@ -40,9 +39,7 @@ pub fn process_instruction(
|
||||||
compute_meter.borrow_mut().consume(25_000)?; // TODO: Tune the number of units consumed?
|
compute_meter.borrow_mut().consume(25_000)?; // TODO: Tune the number of units consumed?
|
||||||
}
|
}
|
||||||
|
|
||||||
match ProofInstruction::decode_type(program_id, input)
|
match ProofInstruction::decode_type(input).ok_or(InstructionError::InvalidInstructionData)? {
|
||||||
.ok_or(InstructionError::InvalidInstructionData)?
|
|
||||||
{
|
|
||||||
ProofInstruction::VerifyCloseAccount => {
|
ProofInstruction::VerifyCloseAccount => {
|
||||||
ic_msg!(invoke_context, "VerifyCloseAccount");
|
ic_msg!(invoke_context, "VerifyCloseAccount");
|
||||||
verify::<CloseAccountData>(input, invoke_context)
|
verify::<CloseAccountData>(input, invoke_context)
|
||||||
|
|
Loading…
Reference in New Issue