saito-wasm 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "saito-wasm",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "js wrappings around saito-core using wasm",
5
5
  "scripts": {
6
6
  "test": "./node_modules/.bin/jest",
@@ -0,0 +1,421 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ /**
4
+ * @param {string} json
5
+ * @param {string} private_key
6
+ * @returns {Promise<any>}
7
+ */
8
+ export function initialize(json: string, private_key: string): Promise<any>;
9
+ /**
10
+ * @param {string} public_key
11
+ * @param {bigint} amount
12
+ * @param {bigint} fee
13
+ * @param {boolean} force_merge
14
+ * @returns {Promise<WasmTransaction>}
15
+ */
16
+ export function create_transaction(public_key: string, amount: bigint, fee: bigint, force_merge: boolean): Promise<WasmTransaction>;
17
+ /**
18
+ * @returns {Promise<string>}
19
+ */
20
+ export function get_latest_block_hash(): Promise<string>;
21
+ /**
22
+ * @param {string} block_hash
23
+ * @returns {Promise<WasmBlock>}
24
+ */
25
+ export function get_block(block_hash: string): Promise<WasmBlock>;
26
+ /**
27
+ * @param {bigint} index
28
+ * @param {any} peer_config
29
+ * @returns {Promise<void>}
30
+ */
31
+ export function process_new_peer(index: bigint, peer_config: any): Promise<void>;
32
+ /**
33
+ * @param {bigint} peer_index
34
+ * @returns {Promise<void>}
35
+ */
36
+ export function process_peer_disconnection(peer_index: bigint): Promise<void>;
37
+ /**
38
+ * @param {Uint8Array} buffer
39
+ * @param {bigint} peer_index
40
+ * @returns {Promise<void>}
41
+ */
42
+ export function process_msg_buffer_from_peer(buffer: Uint8Array, peer_index: bigint): Promise<void>;
43
+ /**
44
+ * @param {Uint8Array} buffer
45
+ * @param {Uint8Array} hash
46
+ * @param {bigint} peer_index
47
+ * @returns {Promise<void>}
48
+ */
49
+ export function process_fetched_block(buffer: Uint8Array, hash: Uint8Array, peer_index: bigint): Promise<void>;
50
+ /**
51
+ * @param {bigint} duration_in_ms
52
+ * @returns {Promise<void>}
53
+ */
54
+ export function process_timer_event(duration_in_ms: bigint): Promise<void>;
55
+ /**
56
+ * @param {Uint8Array} buffer
57
+ * @returns {string}
58
+ */
59
+ export function hash(buffer: Uint8Array): string;
60
+ /**
61
+ * @param {Uint8Array} buffer
62
+ * @param {string} private_key
63
+ * @returns {string}
64
+ */
65
+ export function sign_buffer(buffer: Uint8Array, private_key: string): string;
66
+ /**
67
+ * @param {Uint8Array} buffer
68
+ * @param {string} signature
69
+ * @param {string} public_key
70
+ * @returns {boolean}
71
+ */
72
+ export function verify_signature(buffer: Uint8Array, signature: string, public_key: string): boolean;
73
+ /**
74
+ * @returns {Promise<Array<any>>}
75
+ */
76
+ export function get_peers(): Promise<Array<any>>;
77
+ /**
78
+ * @param {bigint} peer_index
79
+ * @returns {Promise<WasmPeer | undefined>}
80
+ */
81
+ export function get_peer(peer_index: bigint): Promise<WasmPeer | undefined>;
82
+ /**
83
+ * @returns {string}
84
+ */
85
+ export function generate_private_key(): string;
86
+ /**
87
+ * @param {string} private_key
88
+ * @returns {string}
89
+ */
90
+ export function generate_public_key(private_key: string): string;
91
+ /**
92
+ * @param {WasmTransaction} tx
93
+ * @returns {Promise<void>}
94
+ */
95
+ export function propagate_transaction(tx: WasmTransaction): Promise<void>;
96
+ /**
97
+ * @param {Uint8Array} buffer
98
+ * @param {number} msg_index
99
+ * @param {bigint} peer_index
100
+ * @returns {Promise<void>}
101
+ */
102
+ export function send_api_call(buffer: Uint8Array, msg_index: number, peer_index: bigint): Promise<void>;
103
+ /**
104
+ * @param {Uint8Array} buffer
105
+ * @param {number} msg_index
106
+ * @param {bigint} peer_index
107
+ * @returns {Promise<void>}
108
+ */
109
+ export function send_api_success(buffer: Uint8Array, msg_index: number, peer_index: bigint): Promise<void>;
110
+ /**
111
+ * @param {Uint8Array} buffer
112
+ * @param {number} msg_index
113
+ * @param {bigint} peer_index
114
+ * @returns {Promise<void>}
115
+ */
116
+ export function send_api_error(buffer: Uint8Array, msg_index: number, peer_index: bigint): Promise<void>;
117
+ /**
118
+ * @returns {Promise<WasmWallet>}
119
+ */
120
+ export function get_wallet(): Promise<WasmWallet>;
121
+ /**
122
+ * @returns {Promise<WasmBlockchain>}
123
+ */
124
+ export function get_blockchain(): Promise<WasmBlockchain>;
125
+ /**
126
+ * @param {Uint8Array} buffer
127
+ */
128
+ export function test_buffer_in(buffer: Uint8Array): void;
129
+ /**
130
+ * @returns {Uint8Array}
131
+ */
132
+ export function test_buffer_out(): Uint8Array;
133
+ /**
134
+ * @returns {Promise<Uint8Array>}
135
+ */
136
+ export function test_buffer_out_async(): Promise<Uint8Array>;
137
+ /**
138
+ */
139
+ export class SaitoWasm {
140
+ free(): void;
141
+ }
142
+ /**
143
+ */
144
+ export class WasmBlock {
145
+ free(): void;
146
+ /**
147
+ */
148
+ constructor();
149
+ /**
150
+ * @returns {Uint8Array}
151
+ */
152
+ serialize(): Uint8Array;
153
+ /**
154
+ * @param {Uint8Array} buffer
155
+ * @returns {any}
156
+ */
157
+ deserialize(buffer: Uint8Array): any;
158
+ /**
159
+ * @param {Array<any>} keylist
160
+ * @returns {boolean}
161
+ */
162
+ has_keylist_txs(keylist: Array<any>): boolean;
163
+ /**
164
+ * @param {Array<any>} keylist
165
+ * @returns {WasmBlock}
166
+ */
167
+ generate_lite_block(keylist: Array<any>): WasmBlock;
168
+ /**
169
+ */
170
+ creator: string;
171
+ /**
172
+ */
173
+ readonly file_name: string;
174
+ /**
175
+ */
176
+ readonly force_loaded: boolean;
177
+ /**
178
+ */
179
+ readonly hash: string;
180
+ /**
181
+ */
182
+ id: bigint;
183
+ /**
184
+ */
185
+ readonly in_longest_chain: boolean;
186
+ /**
187
+ */
188
+ previous_block_hash: string;
189
+ /**
190
+ */
191
+ timestamp: bigint;
192
+ /**
193
+ */
194
+ readonly transactions: Array<any>;
195
+ /**
196
+ */
197
+ type: number;
198
+ }
199
+ /**
200
+ */
201
+ export class WasmBlockchain {
202
+ free(): void;
203
+ /**
204
+ * @returns {Promise<void>}
205
+ */
206
+ reset(): Promise<void>;
207
+ /**
208
+ * @returns {Promise<bigint>}
209
+ */
210
+ get_last_block_id(): Promise<bigint>;
211
+ /**
212
+ * @returns {Promise<bigint>}
213
+ */
214
+ get_last_timestamp(): Promise<bigint>;
215
+ /**
216
+ * @param {bigint} id
217
+ * @returns {Promise<string>}
218
+ */
219
+ get_longest_chain_hash_at(id: bigint): Promise<string>;
220
+ }
221
+ /**
222
+ */
223
+ export class WasmPeer {
224
+ free(): void;
225
+ /**
226
+ * @param {bigint} peer_index
227
+ */
228
+ constructor(peer_index: bigint);
229
+ /**
230
+ * @param {string} service
231
+ * @returns {boolean}
232
+ */
233
+ has_service(service: string): boolean;
234
+ /**
235
+ * @returns {boolean}
236
+ */
237
+ is_main_peer(): boolean;
238
+ /**
239
+ */
240
+ readonly key_list: Array<any>;
241
+ /**
242
+ */
243
+ readonly peer_index: bigint;
244
+ /**
245
+ */
246
+ readonly public_key: string;
247
+ /**
248
+ */
249
+ services: any;
250
+ /**
251
+ */
252
+ readonly sync_type: string;
253
+ }
254
+ /**
255
+ */
256
+ export class WasmPeerService {
257
+ free(): void;
258
+ /**
259
+ */
260
+ constructor();
261
+ /**
262
+ */
263
+ domain: string;
264
+ /**
265
+ */
266
+ name: string;
267
+ /**
268
+ */
269
+ service: string;
270
+ }
271
+ /**
272
+ */
273
+ export class WasmPeerServiceList {
274
+ free(): void;
275
+ /**
276
+ * @param {WasmPeerService} service
277
+ */
278
+ push(service: WasmPeerService): void;
279
+ /**
280
+ */
281
+ constructor();
282
+ }
283
+ /**
284
+ */
285
+ export class WasmSlip {
286
+ free(): void;
287
+ /**
288
+ */
289
+ constructor();
290
+ /**
291
+ */
292
+ amount: bigint;
293
+ /**
294
+ */
295
+ block_id: bigint;
296
+ /**
297
+ */
298
+ public_key: string;
299
+ /**
300
+ */
301
+ slip_index: number;
302
+ /**
303
+ */
304
+ slip_type: number;
305
+ /**
306
+ */
307
+ tx_ordinal: bigint;
308
+ /**
309
+ */
310
+ utxo_key: string;
311
+ }
312
+ /**
313
+ */
314
+ export class WasmTransaction {
315
+ free(): void;
316
+ /**
317
+ */
318
+ constructor();
319
+ /**
320
+ * @param {WasmSlip} slip
321
+ */
322
+ add_to_slip(slip: WasmSlip): void;
323
+ /**
324
+ * @param {WasmSlip} slip
325
+ */
326
+ add_from_slip(slip: WasmSlip): void;
327
+ /**
328
+ * @param {string} key
329
+ * @returns {boolean}
330
+ */
331
+ is_from(key: string): boolean;
332
+ /**
333
+ * @param {string} key
334
+ * @returns {boolean}
335
+ */
336
+ is_to(key: string): boolean;
337
+ /**
338
+ * @returns {Promise<void>}
339
+ */
340
+ sign(): Promise<void>;
341
+ /**
342
+ * @returns {Promise<void>}
343
+ */
344
+ sign_and_encrypt(): Promise<void>;
345
+ /**
346
+ * @returns {Uint8Array}
347
+ */
348
+ serialize(): Uint8Array;
349
+ /**
350
+ * @param {Uint8Array} buffer
351
+ * @returns {WasmTransaction}
352
+ */
353
+ static deserialize(buffer: Uint8Array): WasmTransaction;
354
+ /**
355
+ */
356
+ data: Uint8Array;
357
+ /**
358
+ */
359
+ readonly from: Array<any>;
360
+ /**
361
+ */
362
+ signature: string;
363
+ /**
364
+ */
365
+ timestamp: bigint;
366
+ /**
367
+ */
368
+ readonly to: Array<any>;
369
+ /**
370
+ */
371
+ readonly total_fees: bigint;
372
+ /**
373
+ */
374
+ txs_replacements: number;
375
+ /**
376
+ */
377
+ type: number;
378
+ }
379
+ /**
380
+ */
381
+ export class WasmWallet {
382
+ free(): void;
383
+ /**
384
+ * @returns {Promise<void>}
385
+ */
386
+ save(): Promise<void>;
387
+ /**
388
+ * @returns {Promise<void>}
389
+ */
390
+ reset(): Promise<void>;
391
+ /**
392
+ * @returns {Promise<void>}
393
+ */
394
+ load(): Promise<void>;
395
+ /**
396
+ * @returns {Promise<string>}
397
+ */
398
+ get_public_key(): Promise<string>;
399
+ /**
400
+ * @param {string} key
401
+ * @returns {Promise<void>}
402
+ */
403
+ set_public_key(key: string): Promise<void>;
404
+ /**
405
+ * @returns {Promise<string>}
406
+ */
407
+ get_private_key(): Promise<string>;
408
+ /**
409
+ * @param {string} key
410
+ * @returns {Promise<void>}
411
+ */
412
+ set_private_key(key: string): Promise<void>;
413
+ /**
414
+ * @returns {Promise<bigint>}
415
+ */
416
+ get_balance(): Promise<bigint>;
417
+ /**
418
+ * @returns {Promise<Array<any>>}
419
+ */
420
+ get_pending_txs(): Promise<Array<any>>;
421
+ }