From 71d5e3b16055c6af3bb42bc81d679811a98fcf9c Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Tue, 22 Oct 2024 07:55:36 +0900 Subject: [PATCH] make `append_zk_elgamal_proof` function more general --- .../elgamal-registry/src/instruction.rs | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/token/confidential-transfer/elgamal-registry/src/instruction.rs b/token/confidential-transfer/elgamal-registry/src/instruction.rs index aedd4177f0d..10fc164016c 100644 --- a/token/confidential-transfer/elgamal-registry/src/instruction.rs +++ b/token/confidential-transfer/elgamal-registry/src/instruction.rs @@ -115,15 +115,16 @@ pub fn create_registry( ]; let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location); - let registry_instruction = Instruction { + let mut instructions = vec![Instruction { program_id: id(), accounts, data: RegistryInstruction::CreateRegistry { proof_instruction_offset, } .pack(), - }; - append_zk_elgamal_proof(registry_instruction, proof_location) + }]; + append_zk_elgamal_proof(&mut instructions, proof_location)?; + Ok(instructions) } /// Create a `RegistryInstruction::UpdateRegistry` instruction @@ -137,15 +138,16 @@ pub fn update_registry( let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location); accounts.push(AccountMeta::new_readonly(*owner_address, true)); - let registry_instruction = Instruction { + let mut instructions = vec![Instruction { program_id: id(), accounts, data: RegistryInstruction::UpdateRegistry { proof_instruction_offset, } .pack(), - }; - append_zk_elgamal_proof(registry_instruction, proof_location) + }]; + append_zk_elgamal_proof(&mut instructions, proof_location)?; + Ok(instructions) } /// Takes a `ProofLocation`, updates the list of accounts, and returns a @@ -172,11 +174,9 @@ fn proof_instruction_offset( /// Takes a `RegistryInstruction` and appends the pubkey validity proof /// instruction fn append_zk_elgamal_proof( - registry_instruction: Instruction, + instructions: &mut Vec, proof_data_location: ProofLocation, -) -> Result, ProgramError> { - let mut instructions = vec![registry_instruction]; - +) -> Result<(), ProgramError> { if let ProofLocation::InstructionOffset(proof_instruction_offset, proof_data) = proof_data_location { @@ -193,5 +193,5 @@ fn append_zk_elgamal_proof( ), } } - Ok(instructions) + Ok(()) }