1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use crate::id;
use crate::ConfigState;
use solana_sdk::instruction::{AccountMeta, Instruction};
use solana_sdk::pubkey::Pubkey;
use solana_sdk::system_instruction;
pub fn create_account<T: ConfigState>(
from_account_pubkey: &Pubkey,
config_account_pubkey: &Pubkey,
lamports: u64,
) -> Instruction {
system_instruction::create_account(
from_account_pubkey,
config_account_pubkey,
lamports,
T::max_space(),
&id(),
)
}
pub fn store<T: ConfigState>(config_account_pubkey: &Pubkey, data: &T) -> Instruction {
let account_metas = vec![AccountMeta::new(*config_account_pubkey, true)];
Instruction::new(id(), data, account_metas)
}