Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 71d5e3b

Browse files
committed
make append_zk_elgamal_proof function more general
1 parent 01e54df commit 71d5e3b

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

token/confidential-transfer/elgamal-registry/src/instruction.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,16 @@ pub fn create_registry(
115115
];
116116
let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location);
117117

118-
let registry_instruction = Instruction {
118+
let mut instructions = vec![Instruction {
119119
program_id: id(),
120120
accounts,
121121
data: RegistryInstruction::CreateRegistry {
122122
proof_instruction_offset,
123123
}
124124
.pack(),
125-
};
126-
append_zk_elgamal_proof(registry_instruction, proof_location)
125+
}];
126+
append_zk_elgamal_proof(&mut instructions, proof_location)?;
127+
Ok(instructions)
127128
}
128129

129130
/// Create a `RegistryInstruction::UpdateRegistry` instruction
@@ -137,15 +138,16 @@ pub fn update_registry(
137138
let proof_instruction_offset = proof_instruction_offset(&mut accounts, proof_location);
138139
accounts.push(AccountMeta::new_readonly(*owner_address, true));
139140

140-
let registry_instruction = Instruction {
141+
let mut instructions = vec![Instruction {
141142
program_id: id(),
142143
accounts,
143144
data: RegistryInstruction::UpdateRegistry {
144145
proof_instruction_offset,
145146
}
146147
.pack(),
147-
};
148-
append_zk_elgamal_proof(registry_instruction, proof_location)
148+
}];
149+
append_zk_elgamal_proof(&mut instructions, proof_location)?;
150+
Ok(instructions)
149151
}
150152

151153
/// Takes a `ProofLocation`, updates the list of accounts, and returns a
@@ -172,11 +174,9 @@ fn proof_instruction_offset(
172174
/// Takes a `RegistryInstruction` and appends the pubkey validity proof
173175
/// instruction
174176
fn append_zk_elgamal_proof(
175-
registry_instruction: Instruction,
177+
instructions: &mut Vec<Instruction>,
176178
proof_data_location: ProofLocation<PubkeyValidityProofData>,
177-
) -> Result<Vec<Instruction>, ProgramError> {
178-
let mut instructions = vec![registry_instruction];
179-
179+
) -> Result<(), ProgramError> {
180180
if let ProofLocation::InstructionOffset(proof_instruction_offset, proof_data) =
181181
proof_data_location
182182
{
@@ -193,5 +193,5 @@ fn append_zk_elgamal_proof(
193193
),
194194
}
195195
}
196-
Ok(instructions)
196+
Ok(())
197197
}

0 commit comments

Comments
 (0)