Skip to content

Commit

Permalink
transfer hook example with PDAs
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Aug 15, 2023
1 parent d04376f commit 2b93141
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions token/transfer-hook-example/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,27 @@ fn check_token_account_is_transferring(account_info: &AccountInfo) -> Result<(),
}
}

fn check_extra_meta(
account_info: &AccountInfo,
extra_meta: &AccountMeta,
) -> Result<(), ProgramError> {
if !(&extra_meta.pubkey == account_info.key
&& extra_meta.is_signer == account_info.is_signer
&& extra_meta.is_writable == account_info.is_writable)
{
return Err(TransferHookError::IncorrectAccount.into());
}
Ok(())
}

fn next_extra_account_meta<'a>(
extra_account_metas_iter: &mut impl Iterator<Item = &'a ExtraAccountMeta>,
) -> Result<&'a ExtraAccountMeta, ProgramError> {
extra_account_metas_iter
.next()
.ok_or(ProgramError::NotEnoughAccountKeys)
}

/// Processes an [Execute](enum.TransferHookInstruction.html) instruction.
pub fn process_execute(
program_id: &Pubkey,
Expand Down

0 comments on commit 2b93141

Please sign in to comment.