pinocchio_token/instructions/
close_account.rs1use solana_account_view::AccountView;
2use solana_instruction_view::{
3 cpi::{invoke_signed, Signer},
4 InstructionAccount, InstructionView,
5};
6use solana_program_error::ProgramResult;
7
8pub struct CloseAccount<'a> {
15 pub account: &'a AccountView,
17 pub destination: &'a AccountView,
19 pub authority: &'a AccountView,
21}
22
23impl CloseAccount<'_> {
24 #[inline(always)]
25 pub fn invoke(&self) -> ProgramResult {
26 self.invoke_signed(&[])
27 }
28
29 #[inline(always)]
30 pub fn invoke_signed(&self, signers: &[Signer]) -> ProgramResult {
31 let instruction_accounts: [InstructionAccount; 3] = [
33 InstructionAccount::writable(self.account.address()),
34 InstructionAccount::writable(self.destination.address()),
35 InstructionAccount::readonly_signer(self.authority.address()),
36 ];
37
38 let instruction = InstructionView {
39 program_id: &crate::ID,
40 accounts: &instruction_accounts,
41 data: &[9],
42 };
43
44 invoke_signed(
45 &instruction,
46 &[self.account, self.destination, self.authority],
47 signers,
48 )
49 }
50}