1#![cfg(target_arch = "wasm32")]
3#![allow(non_snake_case)]
4use {
5 crate::instruction::{
6 advance_nonce_account, allocate, allocate_with_seed, assign, assign_with_seed,
7 authorize_nonce_account, create_account, create_account_with_seed, create_nonce_account,
8 transfer, transfer_with_seed, withdraw_nonce_account, SystemInstruction,
9 },
10 solana_instruction::Instruction,
11 solana_pubkey::Pubkey,
12 wasm_bindgen::prelude::*,
13};
14
15#[wasm_bindgen]
16impl SystemInstruction {
17 pub fn createAccount(
18 from_pubkey: &Pubkey,
19 to_pubkey: &Pubkey,
20 lamports: u64,
21 space: u64,
22 owner: &Pubkey,
23 ) -> Instruction {
24 create_account(from_pubkey, to_pubkey, lamports, space, owner)
25 }
26
27 pub fn createAccountWithSeed(
28 from_pubkey: &Pubkey,
29 to_pubkey: &Pubkey,
30 base: &Pubkey,
31 seed: &str,
32 lamports: u64,
33 space: u64,
34 owner: &Pubkey,
35 ) -> Instruction {
36 create_account_with_seed(from_pubkey, to_pubkey, base, seed, lamports, space, owner)
37 }
38
39 pub fn assign(pubkey: &Pubkey, owner: &Pubkey) -> Instruction {
40 assign(pubkey, owner)
41 }
42
43 pub fn assignWithSeed(
44 pubkey: &Pubkey,
45 base: &Pubkey,
46 seed: &str,
47 owner: &Pubkey,
48 ) -> Instruction {
49 assign_with_seed(pubkey, base, seed, owner)
50 }
51
52 pub fn transfer(from_pubkey: &Pubkey, to_pubkey: &Pubkey, lamports: u64) -> Instruction {
53 transfer(from_pubkey, to_pubkey, lamports)
54 }
55
56 pub fn transferWithSeed(
57 from_pubkey: &Pubkey,
58 from_base: &Pubkey,
59 from_seed: String,
60 from_owner: &Pubkey,
61 to_pubkey: &Pubkey,
62 lamports: u64,
63 ) -> Instruction {
64 transfer_with_seed(
65 from_pubkey,
66 from_base,
67 from_seed,
68 from_owner,
69 to_pubkey,
70 lamports,
71 )
72 }
73
74 pub fn allocate(pubkey: &Pubkey, space: u64) -> Instruction {
75 allocate(pubkey, space)
76 }
77
78 pub fn allocateWithSeed(
79 address: &Pubkey,
80 base: &Pubkey,
81 seed: &str,
82 space: u64,
83 owner: &Pubkey,
84 ) -> Instruction {
85 allocate_with_seed(address, base, seed, space, owner)
86 }
87
88 pub fn createNonceAccount(
89 from_pubkey: &Pubkey,
90 nonce_pubkey: &Pubkey,
91 authority: &Pubkey,
92 lamports: u64,
93 ) -> js_sys::Array {
94 let instructions = create_nonce_account(from_pubkey, nonce_pubkey, authority, lamports);
95 instructions.into_iter().map(JsValue::from).collect()
96 }
97
98 pub fn advanceNonceAccount(nonce_pubkey: &Pubkey, authorized_pubkey: &Pubkey) -> Instruction {
99 advance_nonce_account(nonce_pubkey, authorized_pubkey)
100 }
101
102 pub fn withdrawNonceAccount(
103 nonce_pubkey: &Pubkey,
104 authorized_pubkey: &Pubkey,
105 to_pubkey: &Pubkey,
106 lamports: u64,
107 ) -> Instruction {
108 withdraw_nonce_account(nonce_pubkey, authorized_pubkey, to_pubkey, lamports)
109 }
110
111 pub fn authorizeNonceAccount(
112 nonce_pubkey: &Pubkey,
113 authorized_pubkey: &Pubkey,
114 new_authority: &Pubkey,
115 ) -> Instruction {
116 authorize_nonce_account(nonce_pubkey, authorized_pubkey, new_authority)
117 }
118}