rialo_s_system_transaction/
lib.rs1use rialo_s_keypair::Keypair;
4use rialo_s_message::Message;
5use rialo_s_pubkey::Pubkey;
6use rialo_s_signer::Signer;
7use rialo_s_system_interface::instruction as system_instruction;
8use rialo_s_transaction::Transaction;
9
10pub fn create_account(
12 from_keypair: &Keypair,
13 to_keypair: &Keypair,
14 valid_from: i64,
15 kelvins: u64,
16 space: u64,
17 program_id: &Pubkey,
18) -> Transaction {
19 let from_pubkey = from_keypair.pubkey();
20 let to_pubkey = to_keypair.pubkey();
21 let instruction =
22 system_instruction::create_account(&from_pubkey, &to_pubkey, kelvins, space, program_id);
23 let message = Message::new(&[instruction], Some(&from_pubkey));
24 Transaction::new(&[from_keypair, to_keypair], message, valid_from)
25}
26
27pub fn allocate(
29 payer_keypair: &Keypair,
30 account_keypair: &Keypair,
31 valid_from: i64,
32 space: u64,
33) -> Transaction {
34 let payer_pubkey = payer_keypair.pubkey();
35 let account_pubkey = account_keypair.pubkey();
36 let instruction = system_instruction::allocate(&account_pubkey, space);
37 let message = Message::new(&[instruction], Some(&payer_pubkey));
38 Transaction::new(&[payer_keypair, account_keypair], message, valid_from)
39}
40
41pub fn assign(from_keypair: &Keypair, valid_from: i64, program_id: &Pubkey) -> Transaction {
43 let from_pubkey = from_keypair.pubkey();
44 let instruction = system_instruction::assign(&from_pubkey, program_id);
45 let message = Message::new(&[instruction], Some(&from_pubkey));
46 Transaction::new(&[from_keypair], message, valid_from)
47}
48
49pub fn transfer(from_keypair: &Keypair, to: &Pubkey, kelvins: u64, valid_from: i64) -> Transaction {
51 let from_pubkey = from_keypair.pubkey();
52 let instruction = system_instruction::transfer(&from_pubkey, to, kelvins);
53 let message = Message::new(&[instruction], Some(&from_pubkey));
54 Transaction::new(&[from_keypair], message, valid_from)
55}