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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::pubkey::Pubkey;
use crate::system_program;
use crate::transaction_builder::BuilderInstruction;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
pub enum SystemInstruction {
CreateAccount {
lamports: u64,
space: u64,
program_id: Pubkey,
},
Assign { program_id: Pubkey },
Move { lamports: u64 },
}
impl SystemInstruction {
pub fn new_program_account(
from_id: &Pubkey,
to_id: &Pubkey,
lamports: u64,
space: u64,
program_id: &Pubkey,
) -> BuilderInstruction {
BuilderInstruction::new(
system_program::id(),
&SystemInstruction::CreateAccount {
lamports,
space,
program_id: *program_id,
},
vec![(*from_id, true), (*to_id, false)],
)
}
pub fn new_move(from_id: &Pubkey, to_id: &Pubkey, lamports: u64) -> BuilderInstruction {
BuilderInstruction::new(
system_program::id(),
&SystemInstruction::Move { lamports },
vec![(*from_id, true), (*to_id, false)],
)
}
}