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.
///
/// Data expected by this instruction:
/// `TransferWithFeeInstructionData`
/// `TransferInstructionData`
///
TransferWithFee,
@ -418,7 +418,8 @@ pub struct WithdrawInstructionData {
pub proof_instruction_offset: i8,
}
/// Data expected by `ConfidentialTransferInstruction::Transfer`
/// Data expected by `ConfidentialTransferInstruction::Transfer` and
/// `ConfidentialTransferInstruction::TransferWithFee`
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct TransferInstructionData {
@ -429,17 +430,6 @@ pub struct TransferInstructionData {
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`
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
@ -834,7 +824,7 @@ pub fn inner_transfer_with_fee(
accounts,
TokenInstruction::ConfidentialTransferExtension,
ConfidentialTransferInstruction::TransferWithFee,
&TransferWithFeeInstructionData {
&TransferInstructionData {
new_source_decryptable_available_balance,
proof_instruction_offset,
},

View File

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