pinocchio_token/instructions/
revoke.rs

1use solana_account_view::AccountView;
2use solana_instruction_view::{
3    cpi::{invoke_signed, Signer},
4    InstructionAccount, InstructionView,
5};
6use solana_program_error::ProgramResult;
7
8/// Revokes the delegate's authority.
9///
10/// ### Accounts:
11///   0. `[WRITE]` The source account.
12///   1. `[SIGNER]` The source account owner.
13pub struct Revoke<'a> {
14    /// Source Account.
15    pub source: &'a AccountView,
16    ///  Source Owner Account.
17    pub authority: &'a AccountView,
18}
19
20impl Revoke<'_> {
21    #[inline(always)]
22    pub fn invoke(&self) -> ProgramResult {
23        self.invoke_signed(&[])
24    }
25
26    #[inline(always)]
27    pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
28        // Instruction accounts
29        let instruction_accounts: [InstructionAccount; 2] = [
30            InstructionAccount::writable(self.source.address()),
31            InstructionAccount::readonly_signer(self.authority.address()),
32        ];
33
34        let instruction = InstructionView {
35            program_id: &crate::ID,
36            accounts: &instruction_accounts,
37            data: &[5],
38        };
39
40        invoke_signed(&instruction, &[self.source, self.authority], signers)
41    }
42}