From a47b76afccabcf3ca3e0da601d42a43bb0301185 Mon Sep 17 00:00:00 2001 From: samkim-crypto Date: Fri, 4 Feb 2022 08:52:49 -0500 Subject: [PATCH] zk-token-sdk: add verify transfer with fee instruction (#22924) --- programs/zk-token-proof/src/lib.rs | 4 ++++ zk-token-sdk/src/instruction/mod.rs | 5 ++++- zk-token-sdk/src/zk_token_proof_instruction.rs | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/programs/zk-token-proof/src/lib.rs b/programs/zk-token-proof/src/lib.rs index 2635e8d77..d81f1f336 100644 --- a/programs/zk-token-proof/src/lib.rs +++ b/programs/zk-token-proof/src/lib.rs @@ -53,5 +53,9 @@ pub fn process_instruction( ic_msg!(invoke_context, "VerifyTransfer"); verify::(input, invoke_context) } + ProofInstruction::VerifyTransferWithFee => { + ic_msg!(invoke_context, "VerifyTransferWithFee"); + verify::(input, invoke_context) + } } } diff --git a/zk-token-sdk/src/instruction/mod.rs b/zk-token-sdk/src/instruction/mod.rs index 49b0f5f1b..73698dbfc 100644 --- a/zk-token-sdk/src/instruction/mod.rs +++ b/zk-token-sdk/src/instruction/mod.rs @@ -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"))] diff --git a/zk-token-sdk/src/zk_token_proof_instruction.rs b/zk-token-sdk/src/zk_token_proof_instruction.rs index c35ef4853..d40e9f56e 100644 --- a/zk-token-sdk/src/zk_token_proof_instruction.rs +++ b/zk-token-sdk/src/zk_token_proof_instruction.rs @@ -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) +}