solana_program/
loader_instruction.rs1use crate::{
6 instruction::{AccountMeta, Instruction},
7 pubkey::Pubkey,
8 sysvar::rent,
9};
10
11#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
12pub enum LoaderInstruction {
13 Write {
18 offset: u32,
20
21 #[serde(with = "serde_bytes")]
23 bytes: Vec<u8>,
24 },
25
26 Finalize,
35}
36
37pub fn write(
38 account_pubkey: &Pubkey,
39 program_id: &Pubkey,
40 offset: u32,
41 bytes: Vec<u8>,
42) -> Instruction {
43 let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
44 Instruction::new_with_bincode(
45 *program_id,
46 &LoaderInstruction::Write { offset, bytes },
47 account_metas,
48 )
49}
50
51pub fn finalize(account_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction {
52 let account_metas = vec![
53 AccountMeta::new(*account_pubkey, true),
54 AccountMeta::new_readonly(rent::id(), false),
55 ];
56 Instruction::new_with_bincode(*program_id, &LoaderInstruction::Finalize, account_metas)
57}