token-2022: merge instruction data for confidential Transfer and TransferWithFee (#3410)

This commit is contained in:
samkim-crypto 2022-08-03 12:15:31 +09:00 committed by GitHub
parent 8f75f5905c
commit c98609850f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 15 deletions

View File

@ -219,7 +219,7 @@ pub enum ConfidentialTransferInstruction {
/// 6.. `[signer]` Required M signer accounts for the SPL Token Multisig account. /// 6.. `[signer]` Required M signer accounts for the SPL Token Multisig account.
/// ///
/// Data expected by this instruction: /// Data expected by this instruction:
/// `TransferWithFeeInstructionData` /// `TransferInstructionData`
/// ///
TransferWithFee, TransferWithFee,
@ -418,7 +418,8 @@ pub struct WithdrawInstructionData {
pub proof_instruction_offset: i8, pub proof_instruction_offset: i8,
} }
/// Data expected by `ConfidentialTransferInstruction::Transfer` /// Data expected by `ConfidentialTransferInstruction::Transfer` and
/// `ConfidentialTransferInstruction::TransferWithFee`
#[derive(Clone, Copy, Pod, Zeroable)] #[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
pub struct TransferInstructionData { pub struct TransferInstructionData {
@ -429,17 +430,6 @@ pub struct TransferInstructionData {
pub proof_instruction_offset: i8, pub proof_instruction_offset: i8,
} }
/// Data expected by `ConfidentialTransferInstruction::TransferWithFee`
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct TransferWithFeeInstructionData {
/// The new source decryptable balance if the transfer succeeds
pub new_source_decryptable_available_balance: DecryptableBalance,
/// Relative location of the `ProofInstruction::VerifyTransfer` instruction to the
/// `Transfer` instruction in the transaction
pub proof_instruction_offset: i8,
}
/// Data expected by `ConfidentialTransferInstruction::ApplyPendingBalance` /// Data expected by `ConfidentialTransferInstruction::ApplyPendingBalance`
#[derive(Clone, Copy, Pod, Zeroable)] #[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)] #[repr(C)]
@ -834,7 +824,7 @@ pub fn inner_transfer_with_fee(
accounts, accounts,
TokenInstruction::ConfidentialTransferExtension, TokenInstruction::ConfidentialTransferExtension,
ConfidentialTransferInstruction::TransferWithFee, ConfidentialTransferInstruction::TransferWithFee,
&TransferWithFeeInstructionData { &TransferInstructionData {
new_source_decryptable_available_balance, new_source_decryptable_available_balance,
proof_instruction_offset, proof_instruction_offset,
}, },

View File

@ -1236,7 +1236,7 @@ pub(crate) fn process_instruction(
msg!("ConfidentialTransferInstruction::TransferWithFee"); msg!("ConfidentialTransferInstruction::TransferWithFee");
#[cfg(feature = "zk-ops")] #[cfg(feature = "zk-ops")]
{ {
let data = decode_instruction_data::<TransferWithFeeInstructionData>(input)?; let data = decode_instruction_data::<TransferInstructionData>(input)?;
process_transfer( process_transfer(
program_id, program_id,
accounts, accounts,