pinocchio_token/instructions/
initialize_account.rs1use solana_account_view::AccountView;
2use solana_instruction_view::{cpi::invoke, InstructionAccount, InstructionView};
3use solana_program_error::ProgramResult;
4
5pub struct InitializeAccount<'a> {
13 pub account: &'a AccountView,
15 pub mint: &'a AccountView,
17 pub owner: &'a AccountView,
19 pub rent_sysvar: &'a AccountView,
21}
22
23impl InitializeAccount<'_> {
24 #[inline(always)]
25 pub fn invoke(&self) -> ProgramResult {
26 let instruction_accounts: [InstructionAccount; 4] = [
28 InstructionAccount::writable(self.account.address()),
29 InstructionAccount::readonly(self.mint.address()),
30 InstructionAccount::readonly(self.owner.address()),
31 InstructionAccount::readonly(self.rent_sysvar.address()),
32 ];
33
34 let instruction = InstructionView {
35 program_id: &crate::ID,
36 accounts: &instruction_accounts,
37 data: &[1],
38 };
39
40 invoke(
41 &instruction,
42 &[self.account, self.mint, self.owner, self.rent_sysvar],
43 )
44 }
45}