atlas_system_transaction/
lib.rs1use {
4 atlas_hash::Hash, atlas_keypair::Keypair, atlas_message::Message, atlas_pubkey::Pubkey,
5 atlas_signer::Signer, atlas_system_interface::instruction as system_instruction,
6 atlas_transaction::Transaction,
7};
8
9pub fn create_account(
11 from_keypair: &Keypair,
12 to_keypair: &Keypair,
13 recent_blockhash: Hash,
14 lamports: u64,
15 space: u64,
16 program_id: &Pubkey,
17) -> Transaction {
18 let from_pubkey = from_keypair.pubkey();
19 let to_pubkey = to_keypair.pubkey();
20 let instruction =
21 system_instruction::create_account(&from_pubkey, &to_pubkey, lamports, space, program_id);
22 let message = Message::new(&[instruction], Some(&from_pubkey));
23 Transaction::new(&[from_keypair, to_keypair], message, recent_blockhash)
24}
25
26pub fn allocate(
28 payer_keypair: &Keypair,
29 account_keypair: &Keypair,
30 recent_blockhash: Hash,
31 space: u64,
32) -> Transaction {
33 let payer_pubkey = payer_keypair.pubkey();
34 let account_pubkey = account_keypair.pubkey();
35 let instruction = system_instruction::allocate(&account_pubkey, space);
36 let message = Message::new(&[instruction], Some(&payer_pubkey));
37 Transaction::new(&[payer_keypair, account_keypair], message, recent_blockhash)
38}
39
40pub fn assign(from_keypair: &Keypair, recent_blockhash: Hash, program_id: &Pubkey) -> Transaction {
42 let from_pubkey = from_keypair.pubkey();
43 let instruction = system_instruction::assign(&from_pubkey, program_id);
44 let message = Message::new(&[instruction], Some(&from_pubkey));
45 Transaction::new(&[from_keypair], message, recent_blockhash)
46}
47
48pub fn transfer(
50 from_keypair: &Keypair,
51 to: &Pubkey,
52 lamports: u64,
53 recent_blockhash: Hash,
54) -> Transaction {
55 let from_pubkey = from_keypair.pubkey();
56 let instruction = system_instruction::transfer(&from_pubkey, to, lamports);
57 let message = Message::new(&[instruction], Some(&from_pubkey));
58 Transaction::new(&[from_keypair], message, recent_blockhash)
59}
60
61pub fn nonced_transfer(
63 from_keypair: &Keypair,
64 to: &Pubkey,
65 lamports: u64,
66 nonce_account: &Pubkey,
67 nonce_authority: &Keypair,
68 nonce_hash: Hash,
69) -> Transaction {
70 let from_pubkey = from_keypair.pubkey();
71 let instruction = system_instruction::transfer(&from_pubkey, to, lamports);
72 let message = Message::new_with_nonce(
73 vec![instruction],
74 Some(&from_pubkey),
75 nonce_account,
76 &nonce_authority.pubkey(),
77 );
78 Transaction::new(&[from_keypair, nonce_authority], message, nonce_hash)
79}