gemachain_program/
loader_instruction.rs1use crate::{
2 instruction::{AccountMeta, Instruction},
3 pubkey::Pubkey,
4 sysvar::rent,
5};
6
7#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Clone)]
8pub enum LoaderInstruction {
9 Write {
14 offset: u32,
16
17 #[serde(with = "serde_bytes")]
19 bytes: Vec<u8>,
20 },
21
22 Finalize,
31}
32
33pub fn write(
34 account_pubkey: &Pubkey,
35 program_id: &Pubkey,
36 offset: u32,
37 bytes: Vec<u8>,
38) -> Instruction {
39 let account_metas = vec![AccountMeta::new(*account_pubkey, true)];
40 Instruction::new_with_bincode(
41 *program_id,
42 &LoaderInstruction::Write { offset, bytes },
43 account_metas,
44 )
45}
46
47pub fn finalize(account_pubkey: &Pubkey, program_id: &Pubkey) -> Instruction {
48 let account_metas = vec![
49 AccountMeta::new(*account_pubkey, true),
50 AccountMeta::new_readonly(rent::id(), false),
51 ];
52 Instruction::new_with_bincode(*program_id, &LoaderInstruction::Finalize, account_metas)
53}