zk-token-sdk: add verify transfer with fee instruction (#22924)

This commit is contained in:
samkim-crypto 2022-02-04 08:52:49 -05:00 committed by GitHub
parent f73b470ec0
commit a47b76afcc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -53,5 +53,9 @@ pub fn process_instruction(
ic_msg!(invoke_context, "VerifyTransfer");
verify::<TransferData>(input, invoke_context)
}
ProofInstruction::VerifyTransferWithFee => {
ic_msg!(invoke_context, "VerifyTransferWithFee");
verify::<TransferWithFeeData>(input, invoke_context)
}
}
}

View File

@ -14,7 +14,10 @@ use {
},
curve25519_dalek::scalar::Scalar,
};
pub use {close_account::CloseAccountData, transfer::TransferData, withdraw::WithdrawData};
pub use {
close_account::CloseAccountData, transfer::TransferData,
transfer_with_fee::TransferWithFeeData, withdraw::WithdrawData,
};
/// Constant for 2^32
#[cfg(not(target_arch = "bpf"))]

View File

@ -39,6 +39,16 @@ pub enum ProofInstruction {
/// `TransferData`
///
VerifyTransfer,
/// Verify a `TransferWithFeeData` struct
///
/// Accounts expected by this instruction:
/// None
///
/// Data expected by this instruction:
/// `TransferWithFeeData`
///
VerifyTransferWithFee,
}
impl ProofInstruction {
@ -76,3 +86,7 @@ pub fn verify_withdraw(proof_data: &WithdrawData) -> Instruction {
pub fn verify_transfer(proof_data: &TransferData) -> Instruction {
ProofInstruction::VerifyTransfer.encode(proof_data)
}
pub fn verify_transfer_with_fee(proof_data: &TransferWithFeeData) -> Instruction {
ProofInstruction::VerifyTransferWithFee.encode(proof_data)
}