@provablehq/wasm 0.6.13 → 0.7.0

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.
@@ -0,0 +1,4570 @@
1
+ function spawnWorker(url, module, memory, address) {
2
+ return new Promise((resolve) => {
3
+ const worker = new Worker(url, {
4
+ type: "module",
5
+ });
6
+
7
+ worker.addEventListener("message", (event) => {
8
+ // This is needed in Node to wait one extra tick, so that way
9
+ // the Worker can fully initialize before we return.
10
+ setTimeout(() => {
11
+ resolve(worker);
12
+
13
+ // When running in Node, this allows the process to exit
14
+ // even though the Worker is still running.
15
+ if (worker.unref) {
16
+ worker.unref();
17
+ }
18
+ }, 0);
19
+ }, {
20
+ capture: true,
21
+ once: true,
22
+ });
23
+
24
+ worker.postMessage({
25
+ module,
26
+ memory,
27
+ address,
28
+ });
29
+ });
30
+ }
31
+
32
+ let wasm;
33
+
34
+ const heap = new Array(128).fill(undefined);
35
+
36
+ heap.push(undefined, null, true, false);
37
+
38
+ function getObject(idx) { return heap[idx]; }
39
+
40
+ let heap_next = heap.length;
41
+
42
+ function dropObject(idx) {
43
+ if (idx < 132) return;
44
+ heap[idx] = heap_next;
45
+ heap_next = idx;
46
+ }
47
+
48
+ function takeObject(idx) {
49
+ const ret = getObject(idx);
50
+ dropObject(idx);
51
+ return ret;
52
+ }
53
+
54
+ const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
55
+
56
+ if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }
57
+ let cachedUint8Memory0 = null;
58
+
59
+ function getUint8Memory0() {
60
+ if (cachedUint8Memory0 === null || cachedUint8Memory0.buffer !== wasm.memory.buffer) {
61
+ cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
62
+ }
63
+ return cachedUint8Memory0;
64
+ }
65
+
66
+ function getStringFromWasm0(ptr, len) {
67
+ ptr = ptr >>> 0;
68
+ return cachedTextDecoder.decode(getUint8Memory0().slice(ptr, ptr + len));
69
+ }
70
+
71
+ function addHeapObject(obj) {
72
+ if (heap_next === heap.length) heap.push(heap.length + 1);
73
+ const idx = heap_next;
74
+ heap_next = heap[idx];
75
+
76
+ heap[idx] = obj;
77
+ return idx;
78
+ }
79
+
80
+ let WASM_VECTOR_LEN = 0;
81
+
82
+ const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
83
+
84
+ const encodeString = function (arg, view) {
85
+ const buf = cachedTextEncoder.encode(arg);
86
+ view.set(buf);
87
+ return {
88
+ read: arg.length,
89
+ written: buf.length
90
+ };
91
+ };
92
+
93
+ function passStringToWasm0(arg, malloc, realloc) {
94
+
95
+ if (realloc === undefined) {
96
+ const buf = cachedTextEncoder.encode(arg);
97
+ const ptr = malloc(buf.length, 1) >>> 0;
98
+ getUint8Memory0().subarray(ptr, ptr + buf.length).set(buf);
99
+ WASM_VECTOR_LEN = buf.length;
100
+ return ptr;
101
+ }
102
+
103
+ let len = arg.length;
104
+ let ptr = malloc(len, 1) >>> 0;
105
+
106
+ const mem = getUint8Memory0();
107
+
108
+ let offset = 0;
109
+
110
+ for (; offset < len; offset++) {
111
+ const code = arg.charCodeAt(offset);
112
+ if (code > 0x7F) break;
113
+ mem[ptr + offset] = code;
114
+ }
115
+
116
+ if (offset !== len) {
117
+ if (offset !== 0) {
118
+ arg = arg.slice(offset);
119
+ }
120
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
121
+ const view = getUint8Memory0().subarray(ptr + offset, ptr + len);
122
+ const ret = encodeString(arg, view);
123
+
124
+ offset += ret.written;
125
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
126
+ }
127
+
128
+ WASM_VECTOR_LEN = offset;
129
+ return ptr;
130
+ }
131
+
132
+ function isLikeNone(x) {
133
+ return x === undefined || x === null;
134
+ }
135
+
136
+ let cachedInt32Memory0 = null;
137
+
138
+ function getInt32Memory0() {
139
+ if (cachedInt32Memory0 === null || cachedInt32Memory0.buffer !== wasm.memory.buffer) {
140
+ cachedInt32Memory0 = new Int32Array(wasm.memory.buffer);
141
+ }
142
+ return cachedInt32Memory0;
143
+ }
144
+
145
+ function debugString(val) {
146
+ // primitive types
147
+ const type = typeof val;
148
+ if (type == 'number' || type == 'boolean' || val == null) {
149
+ return `${val}`;
150
+ }
151
+ if (type == 'string') {
152
+ return `"${val}"`;
153
+ }
154
+ if (type == 'symbol') {
155
+ const description = val.description;
156
+ if (description == null) {
157
+ return 'Symbol';
158
+ } else {
159
+ return `Symbol(${description})`;
160
+ }
161
+ }
162
+ if (type == 'function') {
163
+ const name = val.name;
164
+ if (typeof name == 'string' && name.length > 0) {
165
+ return `Function(${name})`;
166
+ } else {
167
+ return 'Function';
168
+ }
169
+ }
170
+ // objects
171
+ if (Array.isArray(val)) {
172
+ const length = val.length;
173
+ let debug = '[';
174
+ if (length > 0) {
175
+ debug += debugString(val[0]);
176
+ }
177
+ for(let i = 1; i < length; i++) {
178
+ debug += ', ' + debugString(val[i]);
179
+ }
180
+ debug += ']';
181
+ return debug;
182
+ }
183
+ // Test for built-in
184
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
185
+ let className;
186
+ if (builtInMatches.length > 1) {
187
+ className = builtInMatches[1];
188
+ } else {
189
+ // Failed to match the standard '[object ClassName]'
190
+ return toString.call(val);
191
+ }
192
+ if (className == 'Object') {
193
+ // we're a user defined class or Object
194
+ // JSON.stringify avoids problems with cycles, and is generally much
195
+ // easier than looping through ownProperties of `val`.
196
+ try {
197
+ return 'Object(' + JSON.stringify(val) + ')';
198
+ } catch (_) {
199
+ return 'Object';
200
+ }
201
+ }
202
+ // errors
203
+ if (val instanceof Error) {
204
+ return `${val.name}: ${val.message}\n${val.stack}`;
205
+ }
206
+ // TODO we could test for more things here, like `Set`s and `Map`s.
207
+ return className;
208
+ }
209
+
210
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
211
+ ? { register: () => {}, unregister: () => {} }
212
+ : new FinalizationRegistry(state => {
213
+ wasm.__wbindgen_export_3.get(state.dtor)(state.a, state.b);
214
+ });
215
+
216
+ function makeMutClosure(arg0, arg1, dtor, f) {
217
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
218
+ const real = (...args) => {
219
+ // First up with a closure we increment the internal reference
220
+ // count. This ensures that the Rust closure environment won't
221
+ // be deallocated while we're invoking it.
222
+ state.cnt++;
223
+ const a = state.a;
224
+ state.a = 0;
225
+ try {
226
+ return f(a, state.b, ...args);
227
+ } finally {
228
+ if (--state.cnt === 0) {
229
+ wasm.__wbindgen_export_3.get(state.dtor)(a, state.b);
230
+ CLOSURE_DTORS.unregister(state);
231
+ } else {
232
+ state.a = a;
233
+ }
234
+ }
235
+ };
236
+ real.original = state;
237
+ CLOSURE_DTORS.register(real, state, state);
238
+ return real;
239
+ }
240
+ function __wbg_adapter_34(arg0, arg1, arg2) {
241
+ wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h35d22bc77031ed81(arg0, arg1, addHeapObject(arg2));
242
+ }
243
+
244
+ function _assertClass(instance, klass) {
245
+ if (!(instance instanceof klass)) {
246
+ throw new Error(`expected instance of ${klass.name}`);
247
+ }
248
+ return instance.ptr;
249
+ }
250
+
251
+ function passArray8ToWasm0(arg, malloc) {
252
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
253
+ getUint8Memory0().set(arg, ptr / 1);
254
+ WASM_VECTOR_LEN = arg.length;
255
+ return ptr;
256
+ }
257
+ /**
258
+ * Verify an execution with a single function and a single transition. Executions with multiple
259
+ * transitions or functions will fail to verify. Also, this does not verify that the state root of
260
+ * the execution is included in the Aleo Network ledger.
261
+ *
262
+ * @param {Execution} execution The function execution to verify
263
+ * @param {VerifyingKey} verifying_key The verifying key for the function
264
+ * @param {Program} program The program that the function execution belongs to
265
+ * @param {String} function_id The name of the function that was executed
266
+ * @returns {boolean} True if the execution is valid, false otherwise
267
+ * @param {Execution} execution
268
+ * @param {VerifyingKey} verifying_key
269
+ * @param {Program} program
270
+ * @param {string} function_id
271
+ * @returns {boolean}
272
+ */
273
+ function verifyFunctionExecution(execution, verifying_key, program, function_id) {
274
+ try {
275
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
276
+ _assertClass(execution, Execution);
277
+ _assertClass(verifying_key, VerifyingKey);
278
+ _assertClass(program, Program);
279
+ const ptr0 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
280
+ const len0 = WASM_VECTOR_LEN;
281
+ wasm.verifyFunctionExecution(retptr, execution.__wbg_ptr, verifying_key.__wbg_ptr, program.__wbg_ptr, ptr0, len0);
282
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
283
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
284
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
285
+ if (r2) {
286
+ throw takeObject(r1);
287
+ }
288
+ return r0 !== 0;
289
+ } finally {
290
+ wasm.__wbindgen_add_to_stack_pointer(16);
291
+ }
292
+ }
293
+
294
+ let cachedBigInt64Memory0 = null;
295
+
296
+ function getBigInt64Memory0() {
297
+ if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.buffer !== wasm.memory.buffer) {
298
+ cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
299
+ }
300
+ return cachedBigInt64Memory0;
301
+ }
302
+
303
+ function getArrayU8FromWasm0(ptr, len) {
304
+ ptr = ptr >>> 0;
305
+ return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
306
+ }
307
+ /**
308
+ * @param {number} receiver
309
+ */
310
+ function runRayonThread(receiver) {
311
+ wasm.runRayonThread(receiver);
312
+ }
313
+
314
+ /**
315
+ * @param {URL} url
316
+ * @param {number} num_threads
317
+ * @returns {Promise<void>}
318
+ */
319
+ function initThreadPool(url, num_threads) {
320
+ const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
321
+ return takeObject(ret);
322
+ }
323
+
324
+ function handleError(f, args) {
325
+ try {
326
+ return f.apply(this, args);
327
+ } catch (e) {
328
+ wasm.__wbindgen_exn_store(addHeapObject(e));
329
+ }
330
+ }
331
+ function __wbg_adapter_281(arg0, arg1, arg2, arg3) {
332
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__h3625646991d7d545(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
333
+ }
334
+
335
+ const AddressFinalization = (typeof FinalizationRegistry === 'undefined')
336
+ ? { register: () => {}, unregister: () => {} }
337
+ : new FinalizationRegistry(ptr => wasm.__wbg_address_free(ptr >>> 0));
338
+ /**
339
+ * Public address of an Aleo account
340
+ */
341
+ class Address {
342
+
343
+ static __wrap(ptr) {
344
+ ptr = ptr >>> 0;
345
+ const obj = Object.create(Address.prototype);
346
+ obj.__wbg_ptr = ptr;
347
+ AddressFinalization.register(obj, obj.__wbg_ptr, obj);
348
+ return obj;
349
+ }
350
+
351
+ __destroy_into_raw() {
352
+ const ptr = this.__wbg_ptr;
353
+ this.__wbg_ptr = 0;
354
+ AddressFinalization.unregister(this);
355
+ return ptr;
356
+ }
357
+
358
+ free() {
359
+ const ptr = this.__destroy_into_raw();
360
+ wasm.__wbg_address_free(ptr);
361
+ }
362
+ /**
363
+ * Derive an Aleo address from a private key
364
+ *
365
+ * @param {PrivateKey} private_key The private key to derive the address from
366
+ * @returns {Address} Address corresponding to the private key
367
+ * @param {PrivateKey} private_key
368
+ * @returns {Address}
369
+ */
370
+ static from_private_key(private_key) {
371
+ _assertClass(private_key, PrivateKey);
372
+ const ret = wasm.address_from_private_key(private_key.__wbg_ptr);
373
+ return Address.__wrap(ret);
374
+ }
375
+ /**
376
+ * Derive an Aleo address from a view key
377
+ *
378
+ * @param {ViewKey} view_key The view key to derive the address from
379
+ * @returns {Address} Address corresponding to the view key
380
+ * @param {ViewKey} view_key
381
+ * @returns {Address}
382
+ */
383
+ static from_view_key(view_key) {
384
+ _assertClass(view_key, ViewKey);
385
+ const ret = wasm.address_from_view_key(view_key.__wbg_ptr);
386
+ return Address.__wrap(ret);
387
+ }
388
+ /**
389
+ * Create an aleo address object from a string representation of an address
390
+ *
391
+ * @param {string} address String representation of an addressm
392
+ * @returns {Address} Address
393
+ * @param {string} address
394
+ * @returns {Address}
395
+ */
396
+ static from_string(address) {
397
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
398
+ const len0 = WASM_VECTOR_LEN;
399
+ const ret = wasm.address_from_string(ptr0, len0);
400
+ return Address.__wrap(ret);
401
+ }
402
+ /**
403
+ * Get a string representation of an Aleo address object
404
+ *
405
+ * @param {Address} Address
406
+ * @returns {string} String representation of the address
407
+ * @returns {string}
408
+ */
409
+ to_string() {
410
+ let deferred1_0;
411
+ let deferred1_1;
412
+ try {
413
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
414
+ wasm.address_to_string(retptr, this.__wbg_ptr);
415
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
416
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
417
+ deferred1_0 = r0;
418
+ deferred1_1 = r1;
419
+ return getStringFromWasm0(r0, r1);
420
+ } finally {
421
+ wasm.__wbindgen_add_to_stack_pointer(16);
422
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
423
+ }
424
+ }
425
+ /**
426
+ * Verify a signature for a message signed by the address
427
+ *
428
+ * @param {Uint8Array} Byte array representing a message signed by the address
429
+ * @returns {boolean} Boolean representing whether or not the signature is valid
430
+ * @param {Uint8Array} message
431
+ * @param {Signature} signature
432
+ * @returns {boolean}
433
+ */
434
+ verify(message, signature) {
435
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
436
+ const len0 = WASM_VECTOR_LEN;
437
+ _assertClass(signature, Signature);
438
+ const ret = wasm.address_verify(this.__wbg_ptr, ptr0, len0, signature.__wbg_ptr);
439
+ return ret !== 0;
440
+ }
441
+ }
442
+
443
+ const ExecutionFinalization = (typeof FinalizationRegistry === 'undefined')
444
+ ? { register: () => {}, unregister: () => {} }
445
+ : new FinalizationRegistry(ptr => wasm.__wbg_execution_free(ptr >>> 0));
446
+ /**
447
+ * Execution of an Aleo program.
448
+ */
449
+ class Execution {
450
+
451
+ static __wrap(ptr) {
452
+ ptr = ptr >>> 0;
453
+ const obj = Object.create(Execution.prototype);
454
+ obj.__wbg_ptr = ptr;
455
+ ExecutionFinalization.register(obj, obj.__wbg_ptr, obj);
456
+ return obj;
457
+ }
458
+
459
+ __destroy_into_raw() {
460
+ const ptr = this.__wbg_ptr;
461
+ this.__wbg_ptr = 0;
462
+ ExecutionFinalization.unregister(this);
463
+ return ptr;
464
+ }
465
+
466
+ free() {
467
+ const ptr = this.__destroy_into_raw();
468
+ wasm.__wbg_execution_free(ptr);
469
+ }
470
+ /**
471
+ * Returns the string representation of the execution.
472
+ * @returns {string}
473
+ */
474
+ toString() {
475
+ let deferred1_0;
476
+ let deferred1_1;
477
+ try {
478
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
479
+ wasm.execution_toString(retptr, this.__wbg_ptr);
480
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
481
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
482
+ deferred1_0 = r0;
483
+ deferred1_1 = r1;
484
+ return getStringFromWasm0(r0, r1);
485
+ } finally {
486
+ wasm.__wbindgen_add_to_stack_pointer(16);
487
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
488
+ }
489
+ }
490
+ /**
491
+ * Creates an execution object from a string representation of an execution.
492
+ * @param {string} execution
493
+ * @returns {Execution}
494
+ */
495
+ static fromString(execution) {
496
+ try {
497
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
498
+ const ptr0 = passStringToWasm0(execution, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
499
+ const len0 = WASM_VECTOR_LEN;
500
+ wasm.execution_fromString(retptr, ptr0, len0);
501
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
502
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
503
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
504
+ if (r2) {
505
+ throw takeObject(r1);
506
+ }
507
+ return Execution.__wrap(r0);
508
+ } finally {
509
+ wasm.__wbindgen_add_to_stack_pointer(16);
510
+ }
511
+ }
512
+ }
513
+
514
+ const ExecutionResponseFinalization = (typeof FinalizationRegistry === 'undefined')
515
+ ? { register: () => {}, unregister: () => {} }
516
+ : new FinalizationRegistry(ptr => wasm.__wbg_executionresponse_free(ptr >>> 0));
517
+ /**
518
+ * Webassembly Representation of an Aleo function execution response
519
+ *
520
+ * This object is returned by the execution of an Aleo function off-chain. It provides methods for
521
+ * retrieving the outputs of the function execution.
522
+ */
523
+ class ExecutionResponse {
524
+
525
+ static __wrap(ptr) {
526
+ ptr = ptr >>> 0;
527
+ const obj = Object.create(ExecutionResponse.prototype);
528
+ obj.__wbg_ptr = ptr;
529
+ ExecutionResponseFinalization.register(obj, obj.__wbg_ptr, obj);
530
+ return obj;
531
+ }
532
+
533
+ __destroy_into_raw() {
534
+ const ptr = this.__wbg_ptr;
535
+ this.__wbg_ptr = 0;
536
+ ExecutionResponseFinalization.unregister(this);
537
+ return ptr;
538
+ }
539
+
540
+ free() {
541
+ const ptr = this.__destroy_into_raw();
542
+ wasm.__wbg_executionresponse_free(ptr);
543
+ }
544
+ /**
545
+ * Get the outputs of the executed function
546
+ *
547
+ * @returns {Array} Array of strings representing the outputs of the function
548
+ * @returns {Array<any>}
549
+ */
550
+ getOutputs() {
551
+ const ret = wasm.executionresponse_getOutputs(this.__wbg_ptr);
552
+ return takeObject(ret);
553
+ }
554
+ /**
555
+ * Returns the execution object if present, null if otherwise.
556
+ *
557
+ * @returns {Execution | undefined} The execution object if present, null if otherwise
558
+ * @returns {Execution | undefined}
559
+ */
560
+ getExecution() {
561
+ const ret = wasm.executionresponse_getExecution(this.__wbg_ptr);
562
+ return ret === 0 ? undefined : Execution.__wrap(ret);
563
+ }
564
+ /**
565
+ * Returns the program keys if present
566
+ * @returns {KeyPair}
567
+ */
568
+ getKeys() {
569
+ try {
570
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
571
+ wasm.executionresponse_getKeys(retptr, this.__wbg_ptr);
572
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
573
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
574
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
575
+ if (r2) {
576
+ throw takeObject(r1);
577
+ }
578
+ return KeyPair.__wrap(r0);
579
+ } finally {
580
+ wasm.__wbindgen_add_to_stack_pointer(16);
581
+ }
582
+ }
583
+ /**
584
+ * Returns the proving_key if the proving key was cached in the Execution response.
585
+ * Note the proving key is removed from the response object after the first call to this
586
+ * function. Subsequent calls will return null.
587
+ *
588
+ * @returns {ProvingKey | undefined} The proving key
589
+ * @returns {ProvingKey | undefined}
590
+ */
591
+ getProvingKey() {
592
+ const ret = wasm.executionresponse_getProvingKey(this.__wbg_ptr);
593
+ return ret === 0 ? undefined : ProvingKey.__wrap(ret);
594
+ }
595
+ /**
596
+ * Returns the verifying_key associated with the program
597
+ *
598
+ * @returns {VerifyingKey} The verifying key
599
+ * @returns {VerifyingKey}
600
+ */
601
+ getVerifyingKey() {
602
+ const ret = wasm.executionresponse_getVerifyingKey(this.__wbg_ptr);
603
+ return VerifyingKey.__wrap(ret);
604
+ }
605
+ /**
606
+ * Returns the function identifier
607
+ * @returns {string}
608
+ */
609
+ getFunctionId() {
610
+ let deferred1_0;
611
+ let deferred1_1;
612
+ try {
613
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
614
+ wasm.executionresponse_getFunctionId(retptr, this.__wbg_ptr);
615
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
616
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
617
+ deferred1_0 = r0;
618
+ deferred1_1 = r1;
619
+ return getStringFromWasm0(r0, r1);
620
+ } finally {
621
+ wasm.__wbindgen_add_to_stack_pointer(16);
622
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
623
+ }
624
+ }
625
+ /**
626
+ * Returns the program
627
+ * @returns {Program}
628
+ */
629
+ getProgram() {
630
+ const ret = wasm.executionresponse_getProgram(this.__wbg_ptr);
631
+ return Program.__wrap(ret);
632
+ }
633
+ }
634
+
635
+ const FieldFinalization = (typeof FinalizationRegistry === 'undefined')
636
+ ? { register: () => {}, unregister: () => {} }
637
+ : new FinalizationRegistry(ptr => wasm.__wbg_field_free(ptr >>> 0));
638
+ /**
639
+ */
640
+ class Field {
641
+
642
+ static __wrap(ptr) {
643
+ ptr = ptr >>> 0;
644
+ const obj = Object.create(Field.prototype);
645
+ obj.__wbg_ptr = ptr;
646
+ FieldFinalization.register(obj, obj.__wbg_ptr, obj);
647
+ return obj;
648
+ }
649
+
650
+ __destroy_into_raw() {
651
+ const ptr = this.__wbg_ptr;
652
+ this.__wbg_ptr = 0;
653
+ FieldFinalization.unregister(this);
654
+ return ptr;
655
+ }
656
+
657
+ free() {
658
+ const ptr = this.__destroy_into_raw();
659
+ wasm.__wbg_field_free(ptr);
660
+ }
661
+ /**
662
+ * @returns {string}
663
+ */
664
+ toString() {
665
+ let deferred1_0;
666
+ let deferred1_1;
667
+ try {
668
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
669
+ wasm.field_toString(retptr, this.__wbg_ptr);
670
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
671
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
672
+ deferred1_0 = r0;
673
+ deferred1_1 = r1;
674
+ return getStringFromWasm0(r0, r1);
675
+ } finally {
676
+ wasm.__wbindgen_add_to_stack_pointer(16);
677
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
678
+ }
679
+ }
680
+ /**
681
+ * @param {string} field
682
+ * @returns {Field}
683
+ */
684
+ static fromString(field) {
685
+ try {
686
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
687
+ const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
688
+ const len0 = WASM_VECTOR_LEN;
689
+ wasm.field_fromString(retptr, ptr0, len0);
690
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
691
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
692
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
693
+ if (r2) {
694
+ throw takeObject(r1);
695
+ }
696
+ return Field.__wrap(r0);
697
+ } finally {
698
+ wasm.__wbindgen_add_to_stack_pointer(16);
699
+ }
700
+ }
701
+ }
702
+
703
+ const KeyPairFinalization = (typeof FinalizationRegistry === 'undefined')
704
+ ? { register: () => {}, unregister: () => {} }
705
+ : new FinalizationRegistry(ptr => wasm.__wbg_keypair_free(ptr >>> 0));
706
+ /**
707
+ * Key pair object containing both the function proving and verifying keys
708
+ */
709
+ class KeyPair {
710
+
711
+ static __wrap(ptr) {
712
+ ptr = ptr >>> 0;
713
+ const obj = Object.create(KeyPair.prototype);
714
+ obj.__wbg_ptr = ptr;
715
+ KeyPairFinalization.register(obj, obj.__wbg_ptr, obj);
716
+ return obj;
717
+ }
718
+
719
+ __destroy_into_raw() {
720
+ const ptr = this.__wbg_ptr;
721
+ this.__wbg_ptr = 0;
722
+ KeyPairFinalization.unregister(this);
723
+ return ptr;
724
+ }
725
+
726
+ free() {
727
+ const ptr = this.__destroy_into_raw();
728
+ wasm.__wbg_keypair_free(ptr);
729
+ }
730
+ /**
731
+ * Create new key pair from proving and verifying keys
732
+ *
733
+ * @param {ProvingKey} proving_key Proving key corresponding to a function in an Aleo program
734
+ * @param {VerifyingKey} verifying_key Verifying key corresponding to a function in an Aleo program
735
+ * @returns {KeyPair} Key pair object containing both the function proving and verifying keys
736
+ * @param {ProvingKey} proving_key
737
+ * @param {VerifyingKey} verifying_key
738
+ */
739
+ constructor(proving_key, verifying_key) {
740
+ _assertClass(proving_key, ProvingKey);
741
+ var ptr0 = proving_key.__destroy_into_raw();
742
+ _assertClass(verifying_key, VerifyingKey);
743
+ var ptr1 = verifying_key.__destroy_into_raw();
744
+ const ret = wasm.keypair_new(ptr0, ptr1);
745
+ this.__wbg_ptr = ret >>> 0;
746
+ return this;
747
+ }
748
+ /**
749
+ * Get the proving key. This method will remove the proving key from the key pair
750
+ *
751
+ * @returns {ProvingKey}
752
+ * @returns {ProvingKey}
753
+ */
754
+ provingKey() {
755
+ try {
756
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
757
+ wasm.keypair_provingKey(retptr, this.__wbg_ptr);
758
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
759
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
760
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
761
+ if (r2) {
762
+ throw takeObject(r1);
763
+ }
764
+ return ProvingKey.__wrap(r0);
765
+ } finally {
766
+ wasm.__wbindgen_add_to_stack_pointer(16);
767
+ }
768
+ }
769
+ /**
770
+ * Get the verifying key. This method will remove the verifying key from the key pair
771
+ *
772
+ * @returns {VerifyingKey}
773
+ * @returns {VerifyingKey}
774
+ */
775
+ verifyingKey() {
776
+ try {
777
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
778
+ wasm.keypair_verifyingKey(retptr, this.__wbg_ptr);
779
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
780
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
781
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
782
+ if (r2) {
783
+ throw takeObject(r1);
784
+ }
785
+ return VerifyingKey.__wrap(r0);
786
+ } finally {
787
+ wasm.__wbindgen_add_to_stack_pointer(16);
788
+ }
789
+ }
790
+ }
791
+
792
+ const MetadataFinalization = (typeof FinalizationRegistry === 'undefined')
793
+ ? { register: () => {}, unregister: () => {} }
794
+ : new FinalizationRegistry(ptr => wasm.__wbg_metadata_free(ptr >>> 0));
795
+ /**
796
+ */
797
+ class Metadata {
798
+
799
+ static __wrap(ptr) {
800
+ ptr = ptr >>> 0;
801
+ const obj = Object.create(Metadata.prototype);
802
+ obj.__wbg_ptr = ptr;
803
+ MetadataFinalization.register(obj, obj.__wbg_ptr, obj);
804
+ return obj;
805
+ }
806
+
807
+ __destroy_into_raw() {
808
+ const ptr = this.__wbg_ptr;
809
+ this.__wbg_ptr = 0;
810
+ MetadataFinalization.unregister(this);
811
+ return ptr;
812
+ }
813
+
814
+ free() {
815
+ const ptr = this.__destroy_into_raw();
816
+ wasm.__wbg_metadata_free(ptr);
817
+ }
818
+ /**
819
+ * @returns {string}
820
+ */
821
+ get name() {
822
+ let deferred1_0;
823
+ let deferred1_1;
824
+ try {
825
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
826
+ wasm.__wbg_get_metadata_name(retptr, this.__wbg_ptr);
827
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
828
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
829
+ deferred1_0 = r0;
830
+ deferred1_1 = r1;
831
+ return getStringFromWasm0(r0, r1);
832
+ } finally {
833
+ wasm.__wbindgen_add_to_stack_pointer(16);
834
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
835
+ }
836
+ }
837
+ /**
838
+ * @param {string} arg0
839
+ */
840
+ set name(arg0) {
841
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
842
+ const len0 = WASM_VECTOR_LEN;
843
+ wasm.__wbg_set_metadata_name(this.__wbg_ptr, ptr0, len0);
844
+ }
845
+ /**
846
+ * @returns {string}
847
+ */
848
+ get locator() {
849
+ let deferred1_0;
850
+ let deferred1_1;
851
+ try {
852
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
853
+ wasm.__wbg_get_metadata_locator(retptr, this.__wbg_ptr);
854
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
855
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
856
+ deferred1_0 = r0;
857
+ deferred1_1 = r1;
858
+ return getStringFromWasm0(r0, r1);
859
+ } finally {
860
+ wasm.__wbindgen_add_to_stack_pointer(16);
861
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
862
+ }
863
+ }
864
+ /**
865
+ * @param {string} arg0
866
+ */
867
+ set locator(arg0) {
868
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
869
+ const len0 = WASM_VECTOR_LEN;
870
+ wasm.__wbg_set_metadata_locator(this.__wbg_ptr, ptr0, len0);
871
+ }
872
+ /**
873
+ * @returns {string}
874
+ */
875
+ get prover() {
876
+ let deferred1_0;
877
+ let deferred1_1;
878
+ try {
879
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
880
+ wasm.__wbg_get_metadata_prover(retptr, this.__wbg_ptr);
881
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
882
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
883
+ deferred1_0 = r0;
884
+ deferred1_1 = r1;
885
+ return getStringFromWasm0(r0, r1);
886
+ } finally {
887
+ wasm.__wbindgen_add_to_stack_pointer(16);
888
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
889
+ }
890
+ }
891
+ /**
892
+ * @param {string} arg0
893
+ */
894
+ set prover(arg0) {
895
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
896
+ const len0 = WASM_VECTOR_LEN;
897
+ wasm.__wbg_set_metadata_prover(this.__wbg_ptr, ptr0, len0);
898
+ }
899
+ /**
900
+ * @returns {string}
901
+ */
902
+ get verifier() {
903
+ let deferred1_0;
904
+ let deferred1_1;
905
+ try {
906
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
907
+ wasm.__wbg_get_metadata_verifier(retptr, this.__wbg_ptr);
908
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
909
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
910
+ deferred1_0 = r0;
911
+ deferred1_1 = r1;
912
+ return getStringFromWasm0(r0, r1);
913
+ } finally {
914
+ wasm.__wbindgen_add_to_stack_pointer(16);
915
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
916
+ }
917
+ }
918
+ /**
919
+ * @param {string} arg0
920
+ */
921
+ set verifier(arg0) {
922
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
923
+ const len0 = WASM_VECTOR_LEN;
924
+ wasm.__wbg_set_metadata_verifier(this.__wbg_ptr, ptr0, len0);
925
+ }
926
+ /**
927
+ * @returns {string}
928
+ */
929
+ get verifyingKey() {
930
+ let deferred1_0;
931
+ let deferred1_1;
932
+ try {
933
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
934
+ wasm.__wbg_get_metadata_verifyingKey(retptr, this.__wbg_ptr);
935
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
936
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
937
+ deferred1_0 = r0;
938
+ deferred1_1 = r1;
939
+ return getStringFromWasm0(r0, r1);
940
+ } finally {
941
+ wasm.__wbindgen_add_to_stack_pointer(16);
942
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
943
+ }
944
+ }
945
+ /**
946
+ * @param {string} arg0
947
+ */
948
+ set verifyingKey(arg0) {
949
+ const ptr0 = passStringToWasm0(arg0, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
950
+ const len0 = WASM_VECTOR_LEN;
951
+ wasm.__wbg_set_metadata_verifyingKey(this.__wbg_ptr, ptr0, len0);
952
+ }
953
+ /**
954
+ * @returns {string}
955
+ */
956
+ static baseUrl() {
957
+ let deferred1_0;
958
+ let deferred1_1;
959
+ try {
960
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
961
+ wasm.metadata_baseUrl(retptr);
962
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
963
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
964
+ deferred1_0 = r0;
965
+ deferred1_1 = r1;
966
+ return getStringFromWasm0(r0, r1);
967
+ } finally {
968
+ wasm.__wbindgen_add_to_stack_pointer(16);
969
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
970
+ }
971
+ }
972
+ /**
973
+ * @returns {Metadata}
974
+ */
975
+ static bond_public() {
976
+ const ret = wasm.metadata_bond_public();
977
+ return Metadata.__wrap(ret);
978
+ }
979
+ /**
980
+ * @returns {Metadata}
981
+ */
982
+ static bond_validator() {
983
+ const ret = wasm.metadata_bond_validator();
984
+ return Metadata.__wrap(ret);
985
+ }
986
+ /**
987
+ * @returns {Metadata}
988
+ */
989
+ static claim_unbond_public() {
990
+ const ret = wasm.metadata_claim_unbond_public();
991
+ return Metadata.__wrap(ret);
992
+ }
993
+ /**
994
+ * @returns {Metadata}
995
+ */
996
+ static fee_private() {
997
+ const ret = wasm.metadata_fee_private();
998
+ return Metadata.__wrap(ret);
999
+ }
1000
+ /**
1001
+ * @returns {Metadata}
1002
+ */
1003
+ static fee_public() {
1004
+ const ret = wasm.metadata_fee_public();
1005
+ return Metadata.__wrap(ret);
1006
+ }
1007
+ /**
1008
+ * @returns {Metadata}
1009
+ */
1010
+ static inclusion() {
1011
+ const ret = wasm.metadata_inclusion();
1012
+ return Metadata.__wrap(ret);
1013
+ }
1014
+ /**
1015
+ * @returns {Metadata}
1016
+ */
1017
+ static join() {
1018
+ const ret = wasm.metadata_join();
1019
+ return Metadata.__wrap(ret);
1020
+ }
1021
+ /**
1022
+ * @returns {Metadata}
1023
+ */
1024
+ static set_validator_state() {
1025
+ const ret = wasm.metadata_set_validator_state();
1026
+ return Metadata.__wrap(ret);
1027
+ }
1028
+ /**
1029
+ * @returns {Metadata}
1030
+ */
1031
+ static split() {
1032
+ const ret = wasm.metadata_split();
1033
+ return Metadata.__wrap(ret);
1034
+ }
1035
+ /**
1036
+ * @returns {Metadata}
1037
+ */
1038
+ static transfer_private() {
1039
+ const ret = wasm.metadata_transfer_private();
1040
+ return Metadata.__wrap(ret);
1041
+ }
1042
+ /**
1043
+ * @returns {Metadata}
1044
+ */
1045
+ static transfer_private_to_public() {
1046
+ const ret = wasm.metadata_transfer_private_to_public();
1047
+ return Metadata.__wrap(ret);
1048
+ }
1049
+ /**
1050
+ * @returns {Metadata}
1051
+ */
1052
+ static transfer_public() {
1053
+ const ret = wasm.metadata_transfer_public();
1054
+ return Metadata.__wrap(ret);
1055
+ }
1056
+ /**
1057
+ * @returns {Metadata}
1058
+ */
1059
+ static transfer_public_as_signer() {
1060
+ const ret = wasm.metadata_transfer_public_as_signer();
1061
+ return Metadata.__wrap(ret);
1062
+ }
1063
+ /**
1064
+ * @returns {Metadata}
1065
+ */
1066
+ static transfer_public_to_private() {
1067
+ const ret = wasm.metadata_transfer_public_to_private();
1068
+ return Metadata.__wrap(ret);
1069
+ }
1070
+ /**
1071
+ * @returns {Metadata}
1072
+ */
1073
+ static unbond_public() {
1074
+ const ret = wasm.metadata_unbond_public();
1075
+ return Metadata.__wrap(ret);
1076
+ }
1077
+ }
1078
+
1079
+ const OfflineQueryFinalization = (typeof FinalizationRegistry === 'undefined')
1080
+ ? { register: () => {}, unregister: () => {} }
1081
+ : new FinalizationRegistry(ptr => wasm.__wbg_offlinequery_free(ptr >>> 0));
1082
+ /**
1083
+ * An offline query object used to insert the global state root and state paths needed to create
1084
+ * a valid inclusion proof offline.
1085
+ */
1086
+ class OfflineQuery {
1087
+
1088
+ static __wrap(ptr) {
1089
+ ptr = ptr >>> 0;
1090
+ const obj = Object.create(OfflineQuery.prototype);
1091
+ obj.__wbg_ptr = ptr;
1092
+ OfflineQueryFinalization.register(obj, obj.__wbg_ptr, obj);
1093
+ return obj;
1094
+ }
1095
+
1096
+ __destroy_into_raw() {
1097
+ const ptr = this.__wbg_ptr;
1098
+ this.__wbg_ptr = 0;
1099
+ OfflineQueryFinalization.unregister(this);
1100
+ return ptr;
1101
+ }
1102
+
1103
+ free() {
1104
+ const ptr = this.__destroy_into_raw();
1105
+ wasm.__wbg_offlinequery_free(ptr);
1106
+ }
1107
+ /**
1108
+ * Creates a new offline query object. The state root is required to be passed in as a string
1109
+ * @param {string} state_root
1110
+ */
1111
+ constructor(state_root) {
1112
+ try {
1113
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1114
+ const ptr0 = passStringToWasm0(state_root, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1115
+ const len0 = WASM_VECTOR_LEN;
1116
+ wasm.offlinequery_new(retptr, ptr0, len0);
1117
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1118
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1119
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1120
+ if (r2) {
1121
+ throw takeObject(r1);
1122
+ }
1123
+ this.__wbg_ptr = r0 >>> 0;
1124
+ return this;
1125
+ } finally {
1126
+ wasm.__wbindgen_add_to_stack_pointer(16);
1127
+ }
1128
+ }
1129
+ /**
1130
+ * Add a new state path to the offline query object.
1131
+ *
1132
+ * @param {string} commitment: The commitment corresponding to a record inpout
1133
+ * @param {string} state_path: The state path corresponding to the commitment
1134
+ * @param {string} commitment
1135
+ * @param {string} state_path
1136
+ */
1137
+ addStatePath(commitment, state_path) {
1138
+ try {
1139
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1140
+ const ptr0 = passStringToWasm0(commitment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1141
+ const len0 = WASM_VECTOR_LEN;
1142
+ const ptr1 = passStringToWasm0(state_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1143
+ const len1 = WASM_VECTOR_LEN;
1144
+ wasm.offlinequery_addStatePath(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1145
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1146
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1147
+ if (r1) {
1148
+ throw takeObject(r0);
1149
+ }
1150
+ } finally {
1151
+ wasm.__wbindgen_add_to_stack_pointer(16);
1152
+ }
1153
+ }
1154
+ /**
1155
+ * Get a json string representation of the offline query object
1156
+ * @returns {string}
1157
+ */
1158
+ toString() {
1159
+ let deferred1_0;
1160
+ let deferred1_1;
1161
+ try {
1162
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1163
+ wasm.offlinequery_toString(retptr, this.__wbg_ptr);
1164
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1165
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1166
+ deferred1_0 = r0;
1167
+ deferred1_1 = r1;
1168
+ return getStringFromWasm0(r0, r1);
1169
+ } finally {
1170
+ wasm.__wbindgen_add_to_stack_pointer(16);
1171
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1172
+ }
1173
+ }
1174
+ /**
1175
+ * Create an offline query object from a json string representation
1176
+ * @param {string} s
1177
+ * @returns {OfflineQuery}
1178
+ */
1179
+ static fromString(s) {
1180
+ try {
1181
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1182
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1183
+ const len0 = WASM_VECTOR_LEN;
1184
+ wasm.offlinequery_fromString(retptr, ptr0, len0);
1185
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1186
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1187
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1188
+ if (r2) {
1189
+ throw takeObject(r1);
1190
+ }
1191
+ return OfflineQuery.__wrap(r0);
1192
+ } finally {
1193
+ wasm.__wbindgen_add_to_stack_pointer(16);
1194
+ }
1195
+ }
1196
+ }
1197
+
1198
+ const PrivateKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1199
+ ? { register: () => {}, unregister: () => {} }
1200
+ : new FinalizationRegistry(ptr => wasm.__wbg_privatekey_free(ptr >>> 0));
1201
+ /**
1202
+ * Private key of an Aleo account
1203
+ */
1204
+ class PrivateKey {
1205
+
1206
+ static __wrap(ptr) {
1207
+ ptr = ptr >>> 0;
1208
+ const obj = Object.create(PrivateKey.prototype);
1209
+ obj.__wbg_ptr = ptr;
1210
+ PrivateKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1211
+ return obj;
1212
+ }
1213
+
1214
+ __destroy_into_raw() {
1215
+ const ptr = this.__wbg_ptr;
1216
+ this.__wbg_ptr = 0;
1217
+ PrivateKeyFinalization.unregister(this);
1218
+ return ptr;
1219
+ }
1220
+
1221
+ free() {
1222
+ const ptr = this.__destroy_into_raw();
1223
+ wasm.__wbg_privatekey_free(ptr);
1224
+ }
1225
+ /**
1226
+ * Generate a new private key using a cryptographically secure random number generator
1227
+ *
1228
+ * @returns {PrivateKey}
1229
+ */
1230
+ constructor() {
1231
+ const ret = wasm.privatekey_new();
1232
+ this.__wbg_ptr = ret >>> 0;
1233
+ return this;
1234
+ }
1235
+ /**
1236
+ * Get a private key from a series of unchecked bytes
1237
+ *
1238
+ * @param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key
1239
+ * @returns {PrivateKey}
1240
+ * @param {Uint8Array} seed
1241
+ * @returns {PrivateKey}
1242
+ */
1243
+ static from_seed_unchecked(seed) {
1244
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
1245
+ const len0 = WASM_VECTOR_LEN;
1246
+ const ret = wasm.privatekey_from_seed_unchecked(ptr0, len0);
1247
+ return PrivateKey.__wrap(ret);
1248
+ }
1249
+ /**
1250
+ * Get a private key from a string representation of a private key
1251
+ *
1252
+ * @param {string} seed String representation of a private key
1253
+ * @returns {PrivateKey}
1254
+ * @param {string} private_key
1255
+ * @returns {PrivateKey}
1256
+ */
1257
+ static from_string(private_key) {
1258
+ try {
1259
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1260
+ const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1261
+ const len0 = WASM_VECTOR_LEN;
1262
+ wasm.privatekey_from_string(retptr, ptr0, len0);
1263
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1264
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1265
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1266
+ if (r2) {
1267
+ throw takeObject(r1);
1268
+ }
1269
+ return PrivateKey.__wrap(r0);
1270
+ } finally {
1271
+ wasm.__wbindgen_add_to_stack_pointer(16);
1272
+ }
1273
+ }
1274
+ /**
1275
+ * Get a string representation of the private key. This function should be used very carefully
1276
+ * as it exposes the private key plaintext
1277
+ *
1278
+ * @returns {string} String representation of a private key
1279
+ * @returns {string}
1280
+ */
1281
+ to_string() {
1282
+ let deferred1_0;
1283
+ let deferred1_1;
1284
+ try {
1285
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1286
+ wasm.privatekey_to_string(retptr, this.__wbg_ptr);
1287
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1288
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1289
+ deferred1_0 = r0;
1290
+ deferred1_1 = r1;
1291
+ return getStringFromWasm0(r0, r1);
1292
+ } finally {
1293
+ wasm.__wbindgen_add_to_stack_pointer(16);
1294
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1295
+ }
1296
+ }
1297
+ /**
1298
+ * Get the view key corresponding to the private key
1299
+ *
1300
+ * @returns {ViewKey}
1301
+ * @returns {ViewKey}
1302
+ */
1303
+ to_view_key() {
1304
+ const ret = wasm.privatekey_to_view_key(this.__wbg_ptr);
1305
+ return ViewKey.__wrap(ret);
1306
+ }
1307
+ /**
1308
+ * Get the address corresponding to the private key
1309
+ *
1310
+ * @returns {Address}
1311
+ * @returns {Address}
1312
+ */
1313
+ to_address() {
1314
+ const ret = wasm.privatekey_to_address(this.__wbg_ptr);
1315
+ return Address.__wrap(ret);
1316
+ }
1317
+ /**
1318
+ * Sign a message with the private key
1319
+ *
1320
+ * @param {Uint8Array} Byte array representing a message signed by the address
1321
+ * @returns {Signature} Signature generated by signing the message with the address
1322
+ * @param {Uint8Array} message
1323
+ * @returns {Signature}
1324
+ */
1325
+ sign(message) {
1326
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
1327
+ const len0 = WASM_VECTOR_LEN;
1328
+ const ret = wasm.privatekey_sign(this.__wbg_ptr, ptr0, len0);
1329
+ return Signature.__wrap(ret);
1330
+ }
1331
+ /**
1332
+ * Get a new randomly generated private key ciphertext using a secret. The secret is sensitive
1333
+ * and will be needed to decrypt the private key later, so it should be stored securely
1334
+ *
1335
+ * @param {string} secret Secret used to encrypt the private key
1336
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
1337
+ * @param {string} secret
1338
+ * @returns {PrivateKeyCiphertext}
1339
+ */
1340
+ static newEncrypted(secret) {
1341
+ try {
1342
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1343
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1344
+ const len0 = WASM_VECTOR_LEN;
1345
+ wasm.privatekey_newEncrypted(retptr, ptr0, len0);
1346
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1347
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1348
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1349
+ if (r2) {
1350
+ throw takeObject(r1);
1351
+ }
1352
+ return PrivateKeyCiphertext.__wrap(r0);
1353
+ } finally {
1354
+ wasm.__wbindgen_add_to_stack_pointer(16);
1355
+ }
1356
+ }
1357
+ /**
1358
+ * Encrypt an existing private key with a secret. The secret is sensitive and will be needed to
1359
+ * decrypt the private key later, so it should be stored securely
1360
+ *
1361
+ * @param {string} secret Secret used to encrypt the private key
1362
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
1363
+ * @param {string} secret
1364
+ * @returns {PrivateKeyCiphertext}
1365
+ */
1366
+ toCiphertext(secret) {
1367
+ try {
1368
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1369
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1370
+ const len0 = WASM_VECTOR_LEN;
1371
+ wasm.privatekey_toCiphertext(retptr, this.__wbg_ptr, ptr0, len0);
1372
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1373
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1374
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1375
+ if (r2) {
1376
+ throw takeObject(r1);
1377
+ }
1378
+ return PrivateKeyCiphertext.__wrap(r0);
1379
+ } finally {
1380
+ wasm.__wbindgen_add_to_stack_pointer(16);
1381
+ }
1382
+ }
1383
+ /**
1384
+ * Get private key from a private key ciphertext and secret originally used to encrypt it
1385
+ *
1386
+ * @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
1387
+ * @param {string} secret Secret originally used to encrypt the private key
1388
+ * @returns {PrivateKey} Private key
1389
+ * @param {PrivateKeyCiphertext} ciphertext
1390
+ * @param {string} secret
1391
+ * @returns {PrivateKey}
1392
+ */
1393
+ static fromPrivateKeyCiphertext(ciphertext, secret) {
1394
+ try {
1395
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1396
+ _assertClass(ciphertext, PrivateKeyCiphertext);
1397
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1398
+ const len0 = WASM_VECTOR_LEN;
1399
+ wasm.privatekey_fromPrivateKeyCiphertext(retptr, ciphertext.__wbg_ptr, ptr0, len0);
1400
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1401
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1402
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1403
+ if (r2) {
1404
+ throw takeObject(r1);
1405
+ }
1406
+ return PrivateKey.__wrap(r0);
1407
+ } finally {
1408
+ wasm.__wbindgen_add_to_stack_pointer(16);
1409
+ }
1410
+ }
1411
+ }
1412
+
1413
+ const PrivateKeyCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1414
+ ? { register: () => {}, unregister: () => {} }
1415
+ : new FinalizationRegistry(ptr => wasm.__wbg_privatekeyciphertext_free(ptr >>> 0));
1416
+ /**
1417
+ * Private Key in ciphertext form
1418
+ */
1419
+ class PrivateKeyCiphertext {
1420
+
1421
+ static __wrap(ptr) {
1422
+ ptr = ptr >>> 0;
1423
+ const obj = Object.create(PrivateKeyCiphertext.prototype);
1424
+ obj.__wbg_ptr = ptr;
1425
+ PrivateKeyCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1426
+ return obj;
1427
+ }
1428
+
1429
+ __destroy_into_raw() {
1430
+ const ptr = this.__wbg_ptr;
1431
+ this.__wbg_ptr = 0;
1432
+ PrivateKeyCiphertextFinalization.unregister(this);
1433
+ return ptr;
1434
+ }
1435
+
1436
+ free() {
1437
+ const ptr = this.__destroy_into_raw();
1438
+ wasm.__wbg_privatekeyciphertext_free(ptr);
1439
+ }
1440
+ /**
1441
+ * Encrypt a private key using a secret string. The secret is sensitive and will be needed to
1442
+ * decrypt the private key later, so it should be stored securely
1443
+ *
1444
+ * @param {PrivateKey} private_key Private key to encrypt
1445
+ * @param {string} secret Secret to encrypt the private key with
1446
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
1447
+ * @param {PrivateKey} private_key
1448
+ * @param {string} secret
1449
+ * @returns {PrivateKeyCiphertext}
1450
+ */
1451
+ static encryptPrivateKey(private_key, secret) {
1452
+ try {
1453
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1454
+ _assertClass(private_key, PrivateKey);
1455
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1456
+ const len0 = WASM_VECTOR_LEN;
1457
+ wasm.privatekey_toCiphertext(retptr, private_key.__wbg_ptr, ptr0, len0);
1458
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1459
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1460
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1461
+ if (r2) {
1462
+ throw takeObject(r1);
1463
+ }
1464
+ return PrivateKeyCiphertext.__wrap(r0);
1465
+ } finally {
1466
+ wasm.__wbindgen_add_to_stack_pointer(16);
1467
+ }
1468
+ }
1469
+ /**
1470
+ * Decrypts a private ciphertext using a secret string. This must be the same secret used to
1471
+ * encrypt the private key
1472
+ *
1473
+ * @param {string} secret Secret used to encrypt the private key
1474
+ * @returns {PrivateKey} Private key
1475
+ * @param {string} secret
1476
+ * @returns {PrivateKey}
1477
+ */
1478
+ decryptToPrivateKey(secret) {
1479
+ try {
1480
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1481
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1482
+ const len0 = WASM_VECTOR_LEN;
1483
+ wasm.privatekeyciphertext_decryptToPrivateKey(retptr, this.__wbg_ptr, ptr0, len0);
1484
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1485
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1486
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1487
+ if (r2) {
1488
+ throw takeObject(r1);
1489
+ }
1490
+ return PrivateKey.__wrap(r0);
1491
+ } finally {
1492
+ wasm.__wbindgen_add_to_stack_pointer(16);
1493
+ }
1494
+ }
1495
+ /**
1496
+ * Returns the ciphertext string
1497
+ *
1498
+ * @returns {string} Ciphertext string
1499
+ * @returns {string}
1500
+ */
1501
+ toString() {
1502
+ let deferred1_0;
1503
+ let deferred1_1;
1504
+ try {
1505
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1506
+ wasm.privatekeyciphertext_toString(retptr, this.__wbg_ptr);
1507
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1508
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1509
+ deferred1_0 = r0;
1510
+ deferred1_1 = r1;
1511
+ return getStringFromWasm0(r0, r1);
1512
+ } finally {
1513
+ wasm.__wbindgen_add_to_stack_pointer(16);
1514
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1515
+ }
1516
+ }
1517
+ /**
1518
+ * Creates a PrivateKeyCiphertext from a string
1519
+ *
1520
+ * @param {string} ciphertext Ciphertext string
1521
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
1522
+ * @param {string} ciphertext
1523
+ * @returns {PrivateKeyCiphertext}
1524
+ */
1525
+ static fromString(ciphertext) {
1526
+ try {
1527
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1528
+ const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1529
+ const len0 = WASM_VECTOR_LEN;
1530
+ wasm.privatekeyciphertext_fromString(retptr, ptr0, len0);
1531
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1532
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1533
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1534
+ if (r2) {
1535
+ throw takeObject(r1);
1536
+ }
1537
+ return PrivateKeyCiphertext.__wrap(r0);
1538
+ } finally {
1539
+ wasm.__wbindgen_add_to_stack_pointer(16);
1540
+ }
1541
+ }
1542
+ }
1543
+
1544
+ const ProgramFinalization = (typeof FinalizationRegistry === 'undefined')
1545
+ ? { register: () => {}, unregister: () => {} }
1546
+ : new FinalizationRegistry(ptr => wasm.__wbg_program_free(ptr >>> 0));
1547
+ /**
1548
+ * Webassembly Representation of an Aleo program
1549
+ */
1550
+ class Program {
1551
+
1552
+ static __wrap(ptr) {
1553
+ ptr = ptr >>> 0;
1554
+ const obj = Object.create(Program.prototype);
1555
+ obj.__wbg_ptr = ptr;
1556
+ ProgramFinalization.register(obj, obj.__wbg_ptr, obj);
1557
+ return obj;
1558
+ }
1559
+
1560
+ __destroy_into_raw() {
1561
+ const ptr = this.__wbg_ptr;
1562
+ this.__wbg_ptr = 0;
1563
+ ProgramFinalization.unregister(this);
1564
+ return ptr;
1565
+ }
1566
+
1567
+ free() {
1568
+ const ptr = this.__destroy_into_raw();
1569
+ wasm.__wbg_program_free(ptr);
1570
+ }
1571
+ /**
1572
+ * Create a program from a program string
1573
+ *
1574
+ * @param {string} program Aleo program source code
1575
+ * @returns {Program} Program object
1576
+ * @param {string} program
1577
+ * @returns {Program}
1578
+ */
1579
+ static fromString(program) {
1580
+ try {
1581
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1582
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1583
+ const len0 = WASM_VECTOR_LEN;
1584
+ wasm.program_fromString(retptr, ptr0, len0);
1585
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1586
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1587
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1588
+ if (r2) {
1589
+ throw takeObject(r1);
1590
+ }
1591
+ return Program.__wrap(r0);
1592
+ } finally {
1593
+ wasm.__wbindgen_add_to_stack_pointer(16);
1594
+ }
1595
+ }
1596
+ /**
1597
+ * Get a string representation of the program
1598
+ *
1599
+ * @returns {string} String containing the program source code
1600
+ * @returns {string}
1601
+ */
1602
+ toString() {
1603
+ let deferred1_0;
1604
+ let deferred1_1;
1605
+ try {
1606
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1607
+ wasm.program_toString(retptr, this.__wbg_ptr);
1608
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1609
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1610
+ deferred1_0 = r0;
1611
+ deferred1_1 = r1;
1612
+ return getStringFromWasm0(r0, r1);
1613
+ } finally {
1614
+ wasm.__wbindgen_add_to_stack_pointer(16);
1615
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1616
+ }
1617
+ }
1618
+ /**
1619
+ * Determine if a function is present in the program
1620
+ *
1621
+ * @param {string} functionName Name of the function to check for
1622
+ * @returns {boolean} True if the program is valid, false otherwise
1623
+ * @param {string} function_name
1624
+ * @returns {boolean}
1625
+ */
1626
+ hasFunction(function_name) {
1627
+ const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1628
+ const len0 = WASM_VECTOR_LEN;
1629
+ const ret = wasm.program_hasFunction(this.__wbg_ptr, ptr0, len0);
1630
+ return ret !== 0;
1631
+ }
1632
+ /**
1633
+ * Get javascript array of functions names in the program
1634
+ *
1635
+ * @returns {Array} Array of all function names present in the program
1636
+ *
1637
+ * @example
1638
+ * const expected_functions = [
1639
+ * "mint",
1640
+ * "transfer_private",
1641
+ * "transfer_private_to_public",
1642
+ * "transfer_public",
1643
+ * "transfer_public_to_private",
1644
+ * "join",
1645
+ * "split",
1646
+ * "fee"
1647
+ * ]
1648
+ *
1649
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1650
+ * const credits_functions = credits_program.getFunctions();
1651
+ * console.log(credits_functions === expected_functions); // Output should be "true"
1652
+ * @returns {Array<any>}
1653
+ */
1654
+ getFunctions() {
1655
+ const ret = wasm.program_getFunctions(this.__wbg_ptr);
1656
+ return takeObject(ret);
1657
+ }
1658
+ /**
1659
+ * Get a javascript object representation of the function inputs and types. This can be used
1660
+ * to generate a web form to capture user inputs for an execution of a function.
1661
+ *
1662
+ * @param {string} function_name Name of the function to get inputs for
1663
+ * @returns {Array} Array of function inputs
1664
+ *
1665
+ * @example
1666
+ * const expected_inputs = [
1667
+ * {
1668
+ * type:"record",
1669
+ * visibility:"private",
1670
+ * record:"credits",
1671
+ * members:[
1672
+ * {
1673
+ * name:"microcredits",
1674
+ * type:"u64",
1675
+ * visibility:"private"
1676
+ * }
1677
+ * ],
1678
+ * register:"r0"
1679
+ * },
1680
+ * {
1681
+ * type:"address",
1682
+ * visibility:"private",
1683
+ * register:"r1"
1684
+ * },
1685
+ * {
1686
+ * type:"u64",
1687
+ * visibility:"private",
1688
+ * register:"r2"
1689
+ * }
1690
+ * ];
1691
+ *
1692
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1693
+ * const transfer_function_inputs = credits_program.getFunctionInputs("transfer_private");
1694
+ * console.log(transfer_function_inputs === expected_inputs); // Output should be "true"
1695
+ * @param {string} function_name
1696
+ * @returns {Array<any>}
1697
+ */
1698
+ getFunctionInputs(function_name) {
1699
+ try {
1700
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1701
+ const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1702
+ const len0 = WASM_VECTOR_LEN;
1703
+ wasm.program_getFunctionInputs(retptr, this.__wbg_ptr, ptr0, len0);
1704
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1705
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1706
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1707
+ if (r2) {
1708
+ throw takeObject(r1);
1709
+ }
1710
+ return takeObject(r0);
1711
+ } finally {
1712
+ wasm.__wbindgen_add_to_stack_pointer(16);
1713
+ }
1714
+ }
1715
+ /**
1716
+ * Get a the list of a program's mappings and the names/types of their keys and values.
1717
+ *
1718
+ * @returns {Array} - An array of objects representing the mappings in the program
1719
+ * @example
1720
+ * const expected_mappings = [
1721
+ * {
1722
+ * name: "account",
1723
+ * key_name: "owner",
1724
+ * key_type: "address",
1725
+ * value_name: "microcredits",
1726
+ * value_type: "u64"
1727
+ * }
1728
+ * ]
1729
+ *
1730
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1731
+ * const credits_mappings = credits_program.getMappings();
1732
+ * console.log(credits_mappings === expected_mappings); // Output should be "true"
1733
+ * @returns {Array<any>}
1734
+ */
1735
+ getMappings() {
1736
+ try {
1737
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1738
+ wasm.program_getMappings(retptr, this.__wbg_ptr);
1739
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1740
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1741
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1742
+ if (r2) {
1743
+ throw takeObject(r1);
1744
+ }
1745
+ return takeObject(r0);
1746
+ } finally {
1747
+ wasm.__wbindgen_add_to_stack_pointer(16);
1748
+ }
1749
+ }
1750
+ /**
1751
+ * Get a javascript object representation of a program record and its types
1752
+ *
1753
+ * @param {string} record_name Name of the record to get members for
1754
+ * @returns {Object} Object containing the record name, type, and members
1755
+ *
1756
+ * @example
1757
+ *
1758
+ * const expected_record = {
1759
+ * type: "record",
1760
+ * record: "Credits",
1761
+ * members: [
1762
+ * {
1763
+ * name: "owner",
1764
+ * type: "address",
1765
+ * visibility: "private"
1766
+ * },
1767
+ * {
1768
+ * name: "microcredits",
1769
+ * type: "u64",
1770
+ * visibility: "private"
1771
+ * }
1772
+ * ];
1773
+ * };
1774
+ *
1775
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1776
+ * const credits_record = credits_program.getRecordMembers("Credits");
1777
+ * console.log(credits_record === expected_record); // Output should be "true"
1778
+ * @param {string} record_name
1779
+ * @returns {object}
1780
+ */
1781
+ getRecordMembers(record_name) {
1782
+ try {
1783
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1784
+ const ptr0 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1785
+ const len0 = WASM_VECTOR_LEN;
1786
+ wasm.program_getRecordMembers(retptr, this.__wbg_ptr, ptr0, len0);
1787
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1788
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1789
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1790
+ if (r2) {
1791
+ throw takeObject(r1);
1792
+ }
1793
+ return takeObject(r0);
1794
+ } finally {
1795
+ wasm.__wbindgen_add_to_stack_pointer(16);
1796
+ }
1797
+ }
1798
+ /**
1799
+ * Get a javascript object representation of a program struct and its types
1800
+ *
1801
+ * @param {string} struct_name Name of the struct to get members for
1802
+ * @returns {Array} Array containing the struct members
1803
+ *
1804
+ * @example
1805
+ *
1806
+ * const STRUCT_PROGRAM = "program token_issue.aleo;
1807
+ *
1808
+ * struct token_metadata:
1809
+ * network as u32;
1810
+ * version as u32;
1811
+ *
1812
+ * struct token:
1813
+ * token_id as u32;
1814
+ * metadata as token_metadata;
1815
+ *
1816
+ * function no_op:
1817
+ * input r0 as u64;
1818
+ * output r0 as u64;"
1819
+ *
1820
+ * const expected_struct_members = [
1821
+ * {
1822
+ * name: "token_id",
1823
+ * type: "u32",
1824
+ * },
1825
+ * {
1826
+ * name: "metadata",
1827
+ * type: "struct",
1828
+ * struct_id: "token_metadata",
1829
+ * members: [
1830
+ * {
1831
+ * name: "network",
1832
+ * type: "u32",
1833
+ * }
1834
+ * {
1835
+ * name: "version",
1836
+ * type: "u32",
1837
+ * }
1838
+ * ]
1839
+ * }
1840
+ * ];
1841
+ *
1842
+ * const program = aleo_wasm.Program.fromString(STRUCT_PROGRAM);
1843
+ * const struct_members = program.getStructMembers("token");
1844
+ * console.log(struct_members === expected_struct_members); // Output should be "true"
1845
+ * @param {string} struct_name
1846
+ * @returns {Array<any>}
1847
+ */
1848
+ getStructMembers(struct_name) {
1849
+ try {
1850
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1851
+ const ptr0 = passStringToWasm0(struct_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1852
+ const len0 = WASM_VECTOR_LEN;
1853
+ wasm.program_getStructMembers(retptr, this.__wbg_ptr, ptr0, len0);
1854
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1855
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1856
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1857
+ if (r2) {
1858
+ throw takeObject(r1);
1859
+ }
1860
+ return takeObject(r0);
1861
+ } finally {
1862
+ wasm.__wbindgen_add_to_stack_pointer(16);
1863
+ }
1864
+ }
1865
+ /**
1866
+ * Get the credits.aleo program
1867
+ *
1868
+ * @returns {Program} The credits.aleo program
1869
+ * @returns {Program}
1870
+ */
1871
+ static getCreditsProgram() {
1872
+ const ret = wasm.program_getCreditsProgram();
1873
+ return Program.__wrap(ret);
1874
+ }
1875
+ /**
1876
+ * Get the id of the program
1877
+ *
1878
+ * @returns {string} The id of the program
1879
+ * @returns {string}
1880
+ */
1881
+ id() {
1882
+ let deferred1_0;
1883
+ let deferred1_1;
1884
+ try {
1885
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1886
+ wasm.program_id(retptr, this.__wbg_ptr);
1887
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1888
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1889
+ deferred1_0 = r0;
1890
+ deferred1_1 = r1;
1891
+ return getStringFromWasm0(r0, r1);
1892
+ } finally {
1893
+ wasm.__wbindgen_add_to_stack_pointer(16);
1894
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1895
+ }
1896
+ }
1897
+ /**
1898
+ * Get a unique address of the program
1899
+ *
1900
+ * @returns {Address} The address of the program
1901
+ * @returns {Address}
1902
+ */
1903
+ address() {
1904
+ try {
1905
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1906
+ wasm.program_address(retptr, this.__wbg_ptr);
1907
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1908
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1909
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1910
+ if (r2) {
1911
+ throw takeObject(r1);
1912
+ }
1913
+ return Address.__wrap(r0);
1914
+ } finally {
1915
+ wasm.__wbindgen_add_to_stack_pointer(16);
1916
+ }
1917
+ }
1918
+ /**
1919
+ * Determine equality with another program
1920
+ *
1921
+ * @param {Program} other The other program to compare
1922
+ * @returns {boolean} True if the programs are equal, false otherwise
1923
+ * @param {Program} other
1924
+ * @returns {boolean}
1925
+ */
1926
+ isEqual(other) {
1927
+ _assertClass(other, Program);
1928
+ const ret = wasm.program_isEqual(this.__wbg_ptr, other.__wbg_ptr);
1929
+ return ret !== 0;
1930
+ }
1931
+ /**
1932
+ * Get program_imports
1933
+ *
1934
+ * @returns {Array} The program imports
1935
+ *
1936
+ * @example
1937
+ *
1938
+ * const DOUBLE_TEST = "import multiply_test.aleo;
1939
+ *
1940
+ * program double_test.aleo;
1941
+ *
1942
+ * function double_it:
1943
+ * input r0 as u32.private;
1944
+ * call multiply_test.aleo/multiply 2u32 r0 into r1;
1945
+ * output r1 as u32.private;";
1946
+ *
1947
+ * const expected_imports = [
1948
+ * "multiply_test.aleo"
1949
+ * ];
1950
+ *
1951
+ * const program = aleo_wasm.Program.fromString(DOUBLE_TEST_PROGRAM);
1952
+ * const imports = program.getImports();
1953
+ * console.log(imports === expected_imports); // Output should be "true"
1954
+ * @returns {Array<any>}
1955
+ */
1956
+ getImports() {
1957
+ const ret = wasm.program_getImports(this.__wbg_ptr);
1958
+ return takeObject(ret);
1959
+ }
1960
+ }
1961
+
1962
+ const ProgramManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1963
+ ? { register: () => {}, unregister: () => {} }
1964
+ : new FinalizationRegistry(ptr => wasm.__wbg_programmanager_free(ptr >>> 0));
1965
+ /**
1966
+ */
1967
+ class ProgramManager {
1968
+
1969
+ __destroy_into_raw() {
1970
+ const ptr = this.__wbg_ptr;
1971
+ this.__wbg_ptr = 0;
1972
+ ProgramManagerFinalization.unregister(this);
1973
+ return ptr;
1974
+ }
1975
+
1976
+ free() {
1977
+ const ptr = this.__destroy_into_raw();
1978
+ wasm.__wbg_programmanager_free(ptr);
1979
+ }
1980
+ /**
1981
+ * Deploy an Aleo program
1982
+ *
1983
+ * @param private_key The private key of the sender
1984
+ * @param program The source code of the program being deployed
1985
+ * @param imports A javascript object holding the source code of any imported programs in the
1986
+ * form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
1987
+ * Note that all imported programs must be deployed on chain before the main program in order
1988
+ * for the deployment to succeed
1989
+ * @param fee_credits The amount of credits to pay as a fee
1990
+ * @param fee_record The record to spend the fee from
1991
+ * @param url The url of the Aleo network node to send the transaction to
1992
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
1993
+ * form of a javascript object where the keys are a string of the program name and the values
1994
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
1995
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
1996
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
1997
+ * @returns {Transaction}
1998
+ * @param {PrivateKey} private_key
1999
+ * @param {string} program
2000
+ * @param {number} fee_credits
2001
+ * @param {RecordPlaintext | undefined} [fee_record]
2002
+ * @param {string | undefined} [url]
2003
+ * @param {object | undefined} [imports]
2004
+ * @param {ProvingKey | undefined} [fee_proving_key]
2005
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2006
+ * @param {OfflineQuery | undefined} [offline_query]
2007
+ * @returns {Promise<Transaction>}
2008
+ */
2009
+ static buildDeploymentTransaction(private_key, program, fee_credits, fee_record, url, imports, fee_proving_key, fee_verifying_key, offline_query) {
2010
+ _assertClass(private_key, PrivateKey);
2011
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2012
+ const len0 = WASM_VECTOR_LEN;
2013
+ let ptr1 = 0;
2014
+ if (!isLikeNone(fee_record)) {
2015
+ _assertClass(fee_record, RecordPlaintext);
2016
+ ptr1 = fee_record.__destroy_into_raw();
2017
+ }
2018
+ var ptr2 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2019
+ var len2 = WASM_VECTOR_LEN;
2020
+ let ptr3 = 0;
2021
+ if (!isLikeNone(fee_proving_key)) {
2022
+ _assertClass(fee_proving_key, ProvingKey);
2023
+ ptr3 = fee_proving_key.__destroy_into_raw();
2024
+ }
2025
+ let ptr4 = 0;
2026
+ if (!isLikeNone(fee_verifying_key)) {
2027
+ _assertClass(fee_verifying_key, VerifyingKey);
2028
+ ptr4 = fee_verifying_key.__destroy_into_raw();
2029
+ }
2030
+ let ptr5 = 0;
2031
+ if (!isLikeNone(offline_query)) {
2032
+ _assertClass(offline_query, OfflineQuery);
2033
+ ptr5 = offline_query.__destroy_into_raw();
2034
+ }
2035
+ const ret = wasm.programmanager_buildDeploymentTransaction(private_key.__wbg_ptr, ptr0, len0, fee_credits, ptr1, ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr3, ptr4, ptr5);
2036
+ return takeObject(ret);
2037
+ }
2038
+ /**
2039
+ * Estimate the fee for a program deployment
2040
+ *
2041
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2042
+ *
2043
+ * @param program The source code of the program being deployed
2044
+ * @param imports (optional) Provide a list of imports to use for the deployment fee estimation
2045
+ * in the form of a javascript object where the keys are a string of the program name and the values
2046
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2047
+ * @returns {u64}
2048
+ * @param {string} program
2049
+ * @param {object | undefined} [imports]
2050
+ * @returns {Promise<bigint>}
2051
+ */
2052
+ static estimateDeploymentFee(program, imports) {
2053
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2054
+ const len0 = WASM_VECTOR_LEN;
2055
+ const ret = wasm.programmanager_estimateDeploymentFee(ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports));
2056
+ return takeObject(ret);
2057
+ }
2058
+ /**
2059
+ * Estimate the component of the deployment cost which comes from the fee for the program name.
2060
+ * Note that this cost does not represent the entire cost of deployment. It is additional to
2061
+ * the cost of the size (in bytes) of the deployment.
2062
+ *
2063
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2064
+ *
2065
+ * @param name The name of the program to be deployed
2066
+ * @returns {u64}
2067
+ * @param {string} name
2068
+ * @returns {bigint}
2069
+ */
2070
+ static estimateProgramNameCost(name) {
2071
+ try {
2072
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2073
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2074
+ const len0 = WASM_VECTOR_LEN;
2075
+ wasm.programmanager_estimateProgramNameCost(retptr, ptr0, len0);
2076
+ var r0 = getBigInt64Memory0()[retptr / 8 + 0];
2077
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2078
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2079
+ if (r3) {
2080
+ throw takeObject(r2);
2081
+ }
2082
+ return BigInt.asUintN(64, r0);
2083
+ } finally {
2084
+ wasm.__wbindgen_add_to_stack_pointer(16);
2085
+ }
2086
+ }
2087
+ /**
2088
+ * Execute an arbitrary function locally
2089
+ *
2090
+ * @param {PrivateKey} private_key The private key of the sender
2091
+ * @param {string} program The source code of the program being executed
2092
+ * @param {string} function The name of the function to execute
2093
+ * @param {Array} inputs A javascript array of inputs to the function
2094
+ * @param {boolean} prove_execution If true, the execution will be proven and an execution object
2095
+ * containing the proof and the encrypted inputs and outputs needed to verify the proof offline
2096
+ * will be returned.
2097
+ * @param {boolean} cache Cache the proving and verifying keys in the Execution response.
2098
+ * If this is set to 'true' the keys synthesized will be stored in the Execution Response
2099
+ * and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
2100
+ * method.
2101
+ * @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
2102
+ * form of a javascript object where the keys are a string of the program name and the values
2103
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2104
+ * @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
2105
+ * @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
2106
+ * @param {PrivateKey} private_key
2107
+ * @param {string} program
2108
+ * @param {string} _function
2109
+ * @param {Array<any>} inputs
2110
+ * @param {boolean} prove_execution
2111
+ * @param {boolean} cache
2112
+ * @param {object | undefined} [imports]
2113
+ * @param {ProvingKey | undefined} [proving_key]
2114
+ * @param {VerifyingKey | undefined} [verifying_key]
2115
+ * @param {string | undefined} [url]
2116
+ * @param {OfflineQuery | undefined} [offline_query]
2117
+ * @returns {Promise<ExecutionResponse>}
2118
+ */
2119
+ static executeFunctionOffline(private_key, program, _function, inputs, prove_execution, cache, imports, proving_key, verifying_key, url, offline_query) {
2120
+ _assertClass(private_key, PrivateKey);
2121
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2122
+ const len0 = WASM_VECTOR_LEN;
2123
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2124
+ const len1 = WASM_VECTOR_LEN;
2125
+ let ptr2 = 0;
2126
+ if (!isLikeNone(proving_key)) {
2127
+ _assertClass(proving_key, ProvingKey);
2128
+ ptr2 = proving_key.__destroy_into_raw();
2129
+ }
2130
+ let ptr3 = 0;
2131
+ if (!isLikeNone(verifying_key)) {
2132
+ _assertClass(verifying_key, VerifyingKey);
2133
+ ptr3 = verifying_key.__destroy_into_raw();
2134
+ }
2135
+ var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2136
+ var len4 = WASM_VECTOR_LEN;
2137
+ let ptr5 = 0;
2138
+ if (!isLikeNone(offline_query)) {
2139
+ _assertClass(offline_query, OfflineQuery);
2140
+ ptr5 = offline_query.__destroy_into_raw();
2141
+ }
2142
+ const ret = wasm.programmanager_executeFunctionOffline(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), prove_execution, cache, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr2, ptr3, ptr4, len4, ptr5);
2143
+ return takeObject(ret);
2144
+ }
2145
+ /**
2146
+ * Execute Aleo function and create an Aleo execution transaction
2147
+ *
2148
+ * @param private_key The private key of the sender
2149
+ * @param program The source code of the program being executed
2150
+ * @param function The name of the function to execute
2151
+ * @param inputs A javascript array of inputs to the function
2152
+ * @param fee_credits The amount of credits to pay as a fee
2153
+ * @param fee_record The record to spend the fee from
2154
+ * @param url The url of the Aleo network node to send the transaction to
2155
+ * If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
2156
+ * `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
2157
+ * and used for subsequent transactions. If this is set to 'false' the proving and verifying
2158
+ * keys will be deallocated from memory after the transaction is executed.
2159
+ * @param imports (optional) Provide a list of imports to use for the function execution in the
2160
+ * form of a javascript object where the keys are a string of the program name and the values
2161
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2162
+ * @param proving_key (optional) Provide a verifying key to use for the function execution
2163
+ * @param verifying_key (optional) Provide a verifying key to use for the function execution
2164
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2165
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2166
+ * @returns {Transaction}
2167
+ * @param {PrivateKey} private_key
2168
+ * @param {string} program
2169
+ * @param {string} _function
2170
+ * @param {Array<any>} inputs
2171
+ * @param {number} fee_credits
2172
+ * @param {RecordPlaintext | undefined} [fee_record]
2173
+ * @param {string | undefined} [url]
2174
+ * @param {object | undefined} [imports]
2175
+ * @param {ProvingKey | undefined} [proving_key]
2176
+ * @param {VerifyingKey | undefined} [verifying_key]
2177
+ * @param {ProvingKey | undefined} [fee_proving_key]
2178
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2179
+ * @param {OfflineQuery | undefined} [offline_query]
2180
+ * @returns {Promise<Transaction>}
2181
+ */
2182
+ static buildExecutionTransaction(private_key, program, _function, inputs, fee_credits, fee_record, url, imports, proving_key, verifying_key, fee_proving_key, fee_verifying_key, offline_query) {
2183
+ _assertClass(private_key, PrivateKey);
2184
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2185
+ const len0 = WASM_VECTOR_LEN;
2186
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2187
+ const len1 = WASM_VECTOR_LEN;
2188
+ let ptr2 = 0;
2189
+ if (!isLikeNone(fee_record)) {
2190
+ _assertClass(fee_record, RecordPlaintext);
2191
+ ptr2 = fee_record.__destroy_into_raw();
2192
+ }
2193
+ var ptr3 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2194
+ var len3 = WASM_VECTOR_LEN;
2195
+ let ptr4 = 0;
2196
+ if (!isLikeNone(proving_key)) {
2197
+ _assertClass(proving_key, ProvingKey);
2198
+ ptr4 = proving_key.__destroy_into_raw();
2199
+ }
2200
+ let ptr5 = 0;
2201
+ if (!isLikeNone(verifying_key)) {
2202
+ _assertClass(verifying_key, VerifyingKey);
2203
+ ptr5 = verifying_key.__destroy_into_raw();
2204
+ }
2205
+ let ptr6 = 0;
2206
+ if (!isLikeNone(fee_proving_key)) {
2207
+ _assertClass(fee_proving_key, ProvingKey);
2208
+ ptr6 = fee_proving_key.__destroy_into_raw();
2209
+ }
2210
+ let ptr7 = 0;
2211
+ if (!isLikeNone(fee_verifying_key)) {
2212
+ _assertClass(fee_verifying_key, VerifyingKey);
2213
+ ptr7 = fee_verifying_key.__destroy_into_raw();
2214
+ }
2215
+ let ptr8 = 0;
2216
+ if (!isLikeNone(offline_query)) {
2217
+ _assertClass(offline_query, OfflineQuery);
2218
+ ptr8 = offline_query.__destroy_into_raw();
2219
+ }
2220
+ const ret = wasm.programmanager_buildExecutionTransaction(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), fee_credits, ptr2, ptr3, len3, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr4, ptr5, ptr6, ptr7, ptr8);
2221
+ return takeObject(ret);
2222
+ }
2223
+ /**
2224
+ * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
2225
+ * verifying keys will be stored in the ProgramManager's memory and used for subsequent
2226
+ * program executions.
2227
+ *
2228
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2229
+ *
2230
+ * @param private_key The private key of the sender
2231
+ * @param program The source code of the program to estimate the execution fee for
2232
+ * @param function The name of the function to execute
2233
+ * @param inputs A javascript array of inputs to the function
2234
+ * @param url The url of the Aleo network node to send the transaction to
2235
+ * @param imports (optional) Provide a list of imports to use for the fee estimation in the
2236
+ * form of a javascript object where the keys are a string of the program name and the values
2237
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2238
+ * @param proving_key (optional) Provide a verifying key to use for the fee estimation
2239
+ * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
2240
+ * @returns {u64} Fee in microcredits
2241
+ * @param {PrivateKey} private_key
2242
+ * @param {string} program
2243
+ * @param {string} _function
2244
+ * @param {Array<any>} inputs
2245
+ * @param {string | undefined} [url]
2246
+ * @param {object | undefined} [imports]
2247
+ * @param {ProvingKey | undefined} [proving_key]
2248
+ * @param {VerifyingKey | undefined} [verifying_key]
2249
+ * @param {OfflineQuery | undefined} [offline_query]
2250
+ * @returns {Promise<bigint>}
2251
+ */
2252
+ static estimateExecutionFee(private_key, program, _function, inputs, url, imports, proving_key, verifying_key, offline_query) {
2253
+ _assertClass(private_key, PrivateKey);
2254
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2255
+ const len0 = WASM_VECTOR_LEN;
2256
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2257
+ const len1 = WASM_VECTOR_LEN;
2258
+ var ptr2 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2259
+ var len2 = WASM_VECTOR_LEN;
2260
+ let ptr3 = 0;
2261
+ if (!isLikeNone(proving_key)) {
2262
+ _assertClass(proving_key, ProvingKey);
2263
+ ptr3 = proving_key.__destroy_into_raw();
2264
+ }
2265
+ let ptr4 = 0;
2266
+ if (!isLikeNone(verifying_key)) {
2267
+ _assertClass(verifying_key, VerifyingKey);
2268
+ ptr4 = verifying_key.__destroy_into_raw();
2269
+ }
2270
+ let ptr5 = 0;
2271
+ if (!isLikeNone(offline_query)) {
2272
+ _assertClass(offline_query, OfflineQuery);
2273
+ ptr5 = offline_query.__destroy_into_raw();
2274
+ }
2275
+ const ret = wasm.programmanager_estimateExecutionFee(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr3, ptr4, ptr5);
2276
+ return takeObject(ret);
2277
+ }
2278
+ /**
2279
+ * Estimate the finalize fee component for executing a function. This fee is additional to the
2280
+ * size of the execution of the program in bytes. If the function does not have a finalize
2281
+ * step, then the finalize fee is 0.
2282
+ *
2283
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2284
+ *
2285
+ * @param program The program containing the function to estimate the finalize fee for
2286
+ * @param function The function to estimate the finalize fee for
2287
+ * @returns {u64} Fee in microcredits
2288
+ * @param {string} program
2289
+ * @param {string} _function
2290
+ * @returns {bigint}
2291
+ */
2292
+ static estimateFinalizeFee(program, _function) {
2293
+ try {
2294
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2295
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2296
+ const len0 = WASM_VECTOR_LEN;
2297
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2298
+ const len1 = WASM_VECTOR_LEN;
2299
+ wasm.programmanager_estimateFinalizeFee(retptr, ptr0, len0, ptr1, len1);
2300
+ var r0 = getBigInt64Memory0()[retptr / 8 + 0];
2301
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2302
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2303
+ if (r3) {
2304
+ throw takeObject(r2);
2305
+ }
2306
+ return BigInt.asUintN(64, r0);
2307
+ } finally {
2308
+ wasm.__wbindgen_add_to_stack_pointer(16);
2309
+ }
2310
+ }
2311
+ /**
2312
+ * Join two records together to create a new record with an amount of credits equal to the sum
2313
+ * of the credits of the two original records
2314
+ *
2315
+ * @param private_key The private key of the sender
2316
+ * @param record_1 The first record to combine
2317
+ * @param record_2 The second record to combine
2318
+ * @param fee_credits The amount of credits to pay as a fee
2319
+ * @param fee_record The record to spend the fee from
2320
+ * @param url The url of the Aleo network node to send the transaction to
2321
+ * @param join_proving_key (optional) Provide a proving key to use for the join function
2322
+ * @param join_verifying_key (optional) Provide a verifying key to use for the join function
2323
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2324
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2325
+ * @returns {Transaction} Transaction object
2326
+ * @param {PrivateKey} private_key
2327
+ * @param {RecordPlaintext} record_1
2328
+ * @param {RecordPlaintext} record_2
2329
+ * @param {number} fee_credits
2330
+ * @param {RecordPlaintext | undefined} [fee_record]
2331
+ * @param {string | undefined} [url]
2332
+ * @param {ProvingKey | undefined} [join_proving_key]
2333
+ * @param {VerifyingKey | undefined} [join_verifying_key]
2334
+ * @param {ProvingKey | undefined} [fee_proving_key]
2335
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2336
+ * @param {OfflineQuery | undefined} [offline_query]
2337
+ * @returns {Promise<Transaction>}
2338
+ */
2339
+ static buildJoinTransaction(private_key, record_1, record_2, fee_credits, fee_record, url, join_proving_key, join_verifying_key, fee_proving_key, fee_verifying_key, offline_query) {
2340
+ _assertClass(private_key, PrivateKey);
2341
+ _assertClass(record_1, RecordPlaintext);
2342
+ var ptr0 = record_1.__destroy_into_raw();
2343
+ _assertClass(record_2, RecordPlaintext);
2344
+ var ptr1 = record_2.__destroy_into_raw();
2345
+ let ptr2 = 0;
2346
+ if (!isLikeNone(fee_record)) {
2347
+ _assertClass(fee_record, RecordPlaintext);
2348
+ ptr2 = fee_record.__destroy_into_raw();
2349
+ }
2350
+ var ptr3 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2351
+ var len3 = WASM_VECTOR_LEN;
2352
+ let ptr4 = 0;
2353
+ if (!isLikeNone(join_proving_key)) {
2354
+ _assertClass(join_proving_key, ProvingKey);
2355
+ ptr4 = join_proving_key.__destroy_into_raw();
2356
+ }
2357
+ let ptr5 = 0;
2358
+ if (!isLikeNone(join_verifying_key)) {
2359
+ _assertClass(join_verifying_key, VerifyingKey);
2360
+ ptr5 = join_verifying_key.__destroy_into_raw();
2361
+ }
2362
+ let ptr6 = 0;
2363
+ if (!isLikeNone(fee_proving_key)) {
2364
+ _assertClass(fee_proving_key, ProvingKey);
2365
+ ptr6 = fee_proving_key.__destroy_into_raw();
2366
+ }
2367
+ let ptr7 = 0;
2368
+ if (!isLikeNone(fee_verifying_key)) {
2369
+ _assertClass(fee_verifying_key, VerifyingKey);
2370
+ ptr7 = fee_verifying_key.__destroy_into_raw();
2371
+ }
2372
+ let ptr8 = 0;
2373
+ if (!isLikeNone(offline_query)) {
2374
+ _assertClass(offline_query, OfflineQuery);
2375
+ ptr8 = offline_query.__destroy_into_raw();
2376
+ }
2377
+ const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7, ptr8);
2378
+ return takeObject(ret);
2379
+ }
2380
+ /**
2381
+ * Split an Aleo credits record into two separate records. This function does not require a fee.
2382
+ *
2383
+ * @param private_key The private key of the sender
2384
+ * @param split_amount The amount of the credit split. This amount will be subtracted from the
2385
+ * value of the record and two new records will be created with the split amount and the remainder
2386
+ * @param amount_record The record to split
2387
+ * @param url The url of the Aleo network node to send the transaction to
2388
+ * @param split_proving_key (optional) Provide a proving key to use for the split function
2389
+ * @param split_verifying_key (optional) Provide a verifying key to use for the split function
2390
+ * @returns {Transaction} Transaction object
2391
+ * @param {PrivateKey} private_key
2392
+ * @param {number} split_amount
2393
+ * @param {RecordPlaintext} amount_record
2394
+ * @param {string | undefined} [url]
2395
+ * @param {ProvingKey | undefined} [split_proving_key]
2396
+ * @param {VerifyingKey | undefined} [split_verifying_key]
2397
+ * @param {OfflineQuery | undefined} [offline_query]
2398
+ * @returns {Promise<Transaction>}
2399
+ */
2400
+ static buildSplitTransaction(private_key, split_amount, amount_record, url, split_proving_key, split_verifying_key, offline_query) {
2401
+ _assertClass(private_key, PrivateKey);
2402
+ _assertClass(amount_record, RecordPlaintext);
2403
+ var ptr0 = amount_record.__destroy_into_raw();
2404
+ var ptr1 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2405
+ var len1 = WASM_VECTOR_LEN;
2406
+ let ptr2 = 0;
2407
+ if (!isLikeNone(split_proving_key)) {
2408
+ _assertClass(split_proving_key, ProvingKey);
2409
+ ptr2 = split_proving_key.__destroy_into_raw();
2410
+ }
2411
+ let ptr3 = 0;
2412
+ if (!isLikeNone(split_verifying_key)) {
2413
+ _assertClass(split_verifying_key, VerifyingKey);
2414
+ ptr3 = split_verifying_key.__destroy_into_raw();
2415
+ }
2416
+ let ptr4 = 0;
2417
+ if (!isLikeNone(offline_query)) {
2418
+ _assertClass(offline_query, OfflineQuery);
2419
+ ptr4 = offline_query.__destroy_into_raw();
2420
+ }
2421
+ const ret = wasm.programmanager_buildSplitTransaction(private_key.__wbg_ptr, split_amount, ptr0, ptr1, len1, ptr2, ptr3, ptr4);
2422
+ return takeObject(ret);
2423
+ }
2424
+ /**
2425
+ * Send credits from one Aleo account to another
2426
+ *
2427
+ * @param private_key The private key of the sender
2428
+ * @param amount_credits The amount of credits to send
2429
+ * @param recipient The recipient of the transaction
2430
+ * @param transfer_type The type of the transfer (options: "private", "public", "private_to_public", "public_to_private")
2431
+ * @param amount_record The record to fund the amount from
2432
+ * @param fee_credits The amount of credits to pay as a fee
2433
+ * @param fee_record The record to spend the fee from
2434
+ * @param url The url of the Aleo network node to send the transaction to
2435
+ * @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer
2436
+ * function
2437
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2438
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2439
+ * @returns {Transaction}
2440
+ * @param {PrivateKey} private_key
2441
+ * @param {number} amount_credits
2442
+ * @param {string} recipient
2443
+ * @param {string} transfer_type
2444
+ * @param {RecordPlaintext | undefined} amount_record
2445
+ * @param {number} fee_credits
2446
+ * @param {RecordPlaintext | undefined} [fee_record]
2447
+ * @param {string | undefined} [url]
2448
+ * @param {ProvingKey | undefined} [transfer_proving_key]
2449
+ * @param {VerifyingKey | undefined} [transfer_verifying_key]
2450
+ * @param {ProvingKey | undefined} [fee_proving_key]
2451
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2452
+ * @param {OfflineQuery | undefined} [offline_query]
2453
+ * @returns {Promise<Transaction>}
2454
+ */
2455
+ static buildTransferTransaction(private_key, amount_credits, recipient, transfer_type, amount_record, fee_credits, fee_record, url, transfer_proving_key, transfer_verifying_key, fee_proving_key, fee_verifying_key, offline_query) {
2456
+ _assertClass(private_key, PrivateKey);
2457
+ const ptr0 = passStringToWasm0(recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2458
+ const len0 = WASM_VECTOR_LEN;
2459
+ const ptr1 = passStringToWasm0(transfer_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2460
+ const len1 = WASM_VECTOR_LEN;
2461
+ let ptr2 = 0;
2462
+ if (!isLikeNone(amount_record)) {
2463
+ _assertClass(amount_record, RecordPlaintext);
2464
+ ptr2 = amount_record.__destroy_into_raw();
2465
+ }
2466
+ let ptr3 = 0;
2467
+ if (!isLikeNone(fee_record)) {
2468
+ _assertClass(fee_record, RecordPlaintext);
2469
+ ptr3 = fee_record.__destroy_into_raw();
2470
+ }
2471
+ var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2472
+ var len4 = WASM_VECTOR_LEN;
2473
+ let ptr5 = 0;
2474
+ if (!isLikeNone(transfer_proving_key)) {
2475
+ _assertClass(transfer_proving_key, ProvingKey);
2476
+ ptr5 = transfer_proving_key.__destroy_into_raw();
2477
+ }
2478
+ let ptr6 = 0;
2479
+ if (!isLikeNone(transfer_verifying_key)) {
2480
+ _assertClass(transfer_verifying_key, VerifyingKey);
2481
+ ptr6 = transfer_verifying_key.__destroy_into_raw();
2482
+ }
2483
+ let ptr7 = 0;
2484
+ if (!isLikeNone(fee_proving_key)) {
2485
+ _assertClass(fee_proving_key, ProvingKey);
2486
+ ptr7 = fee_proving_key.__destroy_into_raw();
2487
+ }
2488
+ let ptr8 = 0;
2489
+ if (!isLikeNone(fee_verifying_key)) {
2490
+ _assertClass(fee_verifying_key, VerifyingKey);
2491
+ ptr8 = fee_verifying_key.__destroy_into_raw();
2492
+ }
2493
+ let ptr9 = 0;
2494
+ if (!isLikeNone(offline_query)) {
2495
+ _assertClass(offline_query, OfflineQuery);
2496
+ ptr9 = offline_query.__destroy_into_raw();
2497
+ }
2498
+ const ret = wasm.programmanager_buildTransferTransaction(private_key.__wbg_ptr, amount_credits, ptr0, len0, ptr1, len1, ptr2, fee_credits, ptr3, ptr4, len4, ptr5, ptr6, ptr7, ptr8, ptr9);
2499
+ return takeObject(ret);
2500
+ }
2501
+ /**
2502
+ * Synthesize proving and verifying keys for a program
2503
+ *
2504
+ * @param program {string} The program source code of the program to synthesize keys for
2505
+ * @param function_id {string} The function to synthesize keys for
2506
+ * @param inputs {Array} The inputs to the function
2507
+ * @param imports {Object | undefined} The imports for the program
2508
+ * @param {PrivateKey} private_key
2509
+ * @param {string} program
2510
+ * @param {string} function_id
2511
+ * @param {Array<any>} inputs
2512
+ * @param {object | undefined} [imports]
2513
+ * @returns {Promise<KeyPair>}
2514
+ */
2515
+ static synthesizeKeyPair(private_key, program, function_id, inputs, imports) {
2516
+ _assertClass(private_key, PrivateKey);
2517
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2518
+ const len0 = WASM_VECTOR_LEN;
2519
+ const ptr1 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2520
+ const len1 = WASM_VECTOR_LEN;
2521
+ const ret = wasm.programmanager_synthesizeKeyPair(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), isLikeNone(imports) ? 0 : addHeapObject(imports));
2522
+ return takeObject(ret);
2523
+ }
2524
+ }
2525
+
2526
+ const ProvingKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2527
+ ? { register: () => {}, unregister: () => {} }
2528
+ : new FinalizationRegistry(ptr => wasm.__wbg_provingkey_free(ptr >>> 0));
2529
+ /**
2530
+ * Proving key for a function within an Aleo program
2531
+ */
2532
+ class ProvingKey {
2533
+
2534
+ static __wrap(ptr) {
2535
+ ptr = ptr >>> 0;
2536
+ const obj = Object.create(ProvingKey.prototype);
2537
+ obj.__wbg_ptr = ptr;
2538
+ ProvingKeyFinalization.register(obj, obj.__wbg_ptr, obj);
2539
+ return obj;
2540
+ }
2541
+
2542
+ __destroy_into_raw() {
2543
+ const ptr = this.__wbg_ptr;
2544
+ this.__wbg_ptr = 0;
2545
+ ProvingKeyFinalization.unregister(this);
2546
+ return ptr;
2547
+ }
2548
+
2549
+ free() {
2550
+ const ptr = this.__destroy_into_raw();
2551
+ wasm.__wbg_provingkey_free(ptr);
2552
+ }
2553
+ /**
2554
+ * Verify if the proving key is for the bond_public function
2555
+ *
2556
+ * @example
2557
+ * const provingKey = ProvingKey.fromBytes("bond_public_proving_key.bin");
2558
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2559
+ *
2560
+ * @returns {boolean} returns true if the proving key is for the bond_public function, false if otherwise
2561
+ * @returns {boolean}
2562
+ */
2563
+ isBondPublicProver() {
2564
+ const ret = wasm.provingkey_isBondPublicProver(this.__wbg_ptr);
2565
+ return ret !== 0;
2566
+ }
2567
+ /**
2568
+ * Verify if the proving key is for the bond_validator function
2569
+ *
2570
+ * @example
2571
+ * const provingKey = ProvingKey.fromBytes("bond_validator_proving_key.bin");
2572
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2573
+ *
2574
+ * @returns {boolean} returns true if the proving key is for the bond_validator function, false if otherwise
2575
+ * @returns {boolean}
2576
+ */
2577
+ isBondValidatorProver() {
2578
+ const ret = wasm.provingkey_isBondValidatorProver(this.__wbg_ptr);
2579
+ return ret !== 0;
2580
+ }
2581
+ /**
2582
+ * Verify if the proving key is for the claim_unbond function
2583
+ *
2584
+ * @example
2585
+ * const provingKey = ProvingKey.fromBytes("claim_unbond_proving_key.bin");
2586
+ * provingKey.isClaimUnbondProver() ? console.log("Key verified") : throw new Error("Invalid key");
2587
+ *
2588
+ * @returns {boolean} returns true if the proving key is for the claim_unbond function, false if otherwise
2589
+ * @returns {boolean}
2590
+ */
2591
+ isClaimUnbondPublicProver() {
2592
+ const ret = wasm.provingkey_isClaimUnbondPublicProver(this.__wbg_ptr);
2593
+ return ret !== 0;
2594
+ }
2595
+ /**
2596
+ * Verify if the proving key is for the fee_private function
2597
+ *
2598
+ * @example
2599
+ * const provingKey = ProvingKey.fromBytes("fee_private_proving_key.bin");
2600
+ * provingKey.isFeePrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2601
+ *
2602
+ * @returns {boolean} returns true if the proving key is for the fee_private function, false if otherwise
2603
+ * @returns {boolean}
2604
+ */
2605
+ isFeePrivateProver() {
2606
+ const ret = wasm.provingkey_isFeePrivateProver(this.__wbg_ptr);
2607
+ return ret !== 0;
2608
+ }
2609
+ /**
2610
+ * Verify if the proving key is for the fee_public function
2611
+ *
2612
+ * @example
2613
+ * const provingKey = ProvingKey.fromBytes("fee_public_proving_key.bin");
2614
+ * provingKey.isFeePublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2615
+ *
2616
+ * @returns {boolean} returns true if the proving key is for the fee_public function, false if otherwise
2617
+ * @returns {boolean}
2618
+ */
2619
+ isFeePublicProver() {
2620
+ const ret = wasm.provingkey_isFeePublicProver(this.__wbg_ptr);
2621
+ return ret !== 0;
2622
+ }
2623
+ /**
2624
+ * Verify if the proving key is for the inclusion function
2625
+ *
2626
+ * @example
2627
+ * const provingKey = ProvingKey.fromBytes("inclusion_proving_key.bin");
2628
+ * provingKey.isInclusionProver() ? console.log("Key verified") : throw new Error("Invalid key");
2629
+ *
2630
+ * @returns {boolean} returns true if the proving key is for the inclusion function, false if otherwise
2631
+ * @returns {boolean}
2632
+ */
2633
+ isInclusionProver() {
2634
+ const ret = wasm.provingkey_isInclusionProver(this.__wbg_ptr);
2635
+ return ret !== 0;
2636
+ }
2637
+ /**
2638
+ * Verify if the proving key is for the join function
2639
+ *
2640
+ * @example
2641
+ * const provingKey = ProvingKey.fromBytes("join_proving_key.bin");
2642
+ * provingKey.isJoinProver() ? console.log("Key verified") : throw new Error("Invalid key");
2643
+ *
2644
+ * @returns {boolean} returns true if the proving key is for the join function, false if otherwise
2645
+ * @returns {boolean}
2646
+ */
2647
+ isJoinProver() {
2648
+ const ret = wasm.provingkey_isJoinProver(this.__wbg_ptr);
2649
+ return ret !== 0;
2650
+ }
2651
+ /**
2652
+ * Verify if the proving key is for the set_validator_state function
2653
+ *
2654
+ * @example
2655
+ * const provingKey = ProvingKey.fromBytes("set_validator_set_proving_key.bin");
2656
+ * provingKey.isSetValidatorStateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2657
+ *
2658
+ * @returns {boolean} returns true if the proving key is for the set_validator_state function, false if otherwise
2659
+ * @returns {boolean}
2660
+ */
2661
+ isSetValidatorStateProver() {
2662
+ const ret = wasm.provingkey_isSetValidatorStateProver(this.__wbg_ptr);
2663
+ return ret !== 0;
2664
+ }
2665
+ /**
2666
+ * Verify if the proving key is for the split function
2667
+ *
2668
+ * @example
2669
+ * const provingKey = ProvingKey.fromBytes("split_proving_key.bin");
2670
+ * provingKey.isSplitProver() ? console.log("Key verified") : throw new Error("Invalid key");
2671
+ *
2672
+ * @returns {boolean} returns true if the proving key is for the split function, false if otherwise
2673
+ * @returns {boolean}
2674
+ */
2675
+ isSplitProver() {
2676
+ const ret = wasm.provingkey_isSplitProver(this.__wbg_ptr);
2677
+ return ret !== 0;
2678
+ }
2679
+ /**
2680
+ * Verify if the proving key is for the transfer_private function
2681
+ *
2682
+ * @example
2683
+ * const provingKey = ProvingKey.fromBytes("transfer_private_proving_key.bin");
2684
+ * provingKey.isTransferPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2685
+ *
2686
+ * @returns {boolean} returns true if the proving key is for the transfer_private function, false if otherwise
2687
+ * @returns {boolean}
2688
+ */
2689
+ isTransferPrivateProver() {
2690
+ const ret = wasm.provingkey_isTransferPrivateProver(this.__wbg_ptr);
2691
+ return ret !== 0;
2692
+ }
2693
+ /**
2694
+ * Verify if the proving key is for the transfer_private_to_public function
2695
+ *
2696
+ * @example
2697
+ * const provingKey = ProvingKey.fromBytes("transfer_private_to_public_proving_key.bin");
2698
+ * provingKey.isTransferPrivateToPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2699
+ *
2700
+ * @returns {boolean} returns true if the proving key is for the transfer_private_to_public function, false if otherwise
2701
+ * @returns {boolean}
2702
+ */
2703
+ isTransferPrivateToPublicProver() {
2704
+ const ret = wasm.provingkey_isTransferPrivateToPublicProver(this.__wbg_ptr);
2705
+ return ret !== 0;
2706
+ }
2707
+ /**
2708
+ * Verify if the proving key is for the transfer_public function
2709
+ *
2710
+ * @example
2711
+ * const provingKey = ProvingKey.fromBytes("transfer_public_proving_key.bin");
2712
+ * provingKey.isTransferPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2713
+ *
2714
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
2715
+ * @returns {boolean}
2716
+ */
2717
+ isTransferPublicProver() {
2718
+ const ret = wasm.provingkey_isTransferPublicProver(this.__wbg_ptr);
2719
+ return ret !== 0;
2720
+ }
2721
+ /**
2722
+ * Verify if the proving key is for the transfer_public_as_signer function
2723
+ *
2724
+ * @example
2725
+ * const provingKey = ProvingKey.fromBytes("transfer_public_as_signer_proving_key.bin");
2726
+ * provingKey.isTransferPublicAsSignerProver() ? console.log("Key verified") : throw new Error("Invalid key");
2727
+ *
2728
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
2729
+ * @returns {boolean}
2730
+ */
2731
+ isTransferPublicAsSignerProver() {
2732
+ const ret = wasm.provingkey_isTransferPublicAsSignerProver(this.__wbg_ptr);
2733
+ return ret !== 0;
2734
+ }
2735
+ /**
2736
+ * Verify if the proving key is for the transfer_public_to_private function
2737
+ *
2738
+ * @example
2739
+ * const provingKey = ProvingKey.fromBytes("transfer_public_to_private_proving_key.bin");
2740
+ * provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2741
+ *
2742
+ * @returns {boolean} returns true if the proving key is for the transfer_public_to_private function, false if otherwise
2743
+ * @returns {boolean}
2744
+ */
2745
+ isTransferPublicToPrivateProver() {
2746
+ const ret = wasm.provingkey_isTransferPublicToPrivateProver(this.__wbg_ptr);
2747
+ return ret !== 0;
2748
+ }
2749
+ /**
2750
+ * Verify if the proving key is for the unbond_public function
2751
+ *
2752
+ * @example
2753
+ * const provingKey = ProvingKey.fromBytes("unbond_public.bin");
2754
+ * provingKey.isUnbondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2755
+ *
2756
+ * @returns {boolean} returns true if the proving key is for the unbond_public_prover function, false if otherwise
2757
+ * @returns {boolean}
2758
+ */
2759
+ isUnbondPublicProver() {
2760
+ const ret = wasm.provingkey_isUnbondPublicProver(this.__wbg_ptr);
2761
+ return ret !== 0;
2762
+ }
2763
+ /**
2764
+ * Return the checksum of the proving key
2765
+ *
2766
+ * @returns {string} Checksum of the proving key
2767
+ * @returns {string}
2768
+ */
2769
+ checksum() {
2770
+ let deferred1_0;
2771
+ let deferred1_1;
2772
+ try {
2773
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2774
+ wasm.provingkey_checksum(retptr, this.__wbg_ptr);
2775
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2776
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2777
+ deferred1_0 = r0;
2778
+ deferred1_1 = r1;
2779
+ return getStringFromWasm0(r0, r1);
2780
+ } finally {
2781
+ wasm.__wbindgen_add_to_stack_pointer(16);
2782
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2783
+ }
2784
+ }
2785
+ /**
2786
+ * Create a copy of the proving key
2787
+ *
2788
+ * @returns {ProvingKey} A copy of the proving key
2789
+ * @returns {ProvingKey}
2790
+ */
2791
+ copy() {
2792
+ const ret = wasm.provingkey_copy(this.__wbg_ptr);
2793
+ return ProvingKey.__wrap(ret);
2794
+ }
2795
+ /**
2796
+ * Construct a new proving key from a byte array
2797
+ *
2798
+ * @param {Uint8Array} bytes Byte array representation of a proving key
2799
+ * @returns {ProvingKey}
2800
+ * @param {Uint8Array} bytes
2801
+ * @returns {ProvingKey}
2802
+ */
2803
+ static fromBytes(bytes) {
2804
+ try {
2805
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2806
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
2807
+ const len0 = WASM_VECTOR_LEN;
2808
+ wasm.provingkey_fromBytes(retptr, ptr0, len0);
2809
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2810
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2811
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2812
+ if (r2) {
2813
+ throw takeObject(r1);
2814
+ }
2815
+ return ProvingKey.__wrap(r0);
2816
+ } finally {
2817
+ wasm.__wbindgen_add_to_stack_pointer(16);
2818
+ }
2819
+ }
2820
+ /**
2821
+ * Create a proving key from string
2822
+ *
2823
+ * @param {string} String representation of the proving key
2824
+ * @param {string} string
2825
+ * @returns {ProvingKey}
2826
+ */
2827
+ static fromString(string) {
2828
+ try {
2829
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2830
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2831
+ const len0 = WASM_VECTOR_LEN;
2832
+ wasm.provingkey_fromString(retptr, ptr0, len0);
2833
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2834
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2835
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2836
+ if (r2) {
2837
+ throw takeObject(r1);
2838
+ }
2839
+ return ProvingKey.__wrap(r0);
2840
+ } finally {
2841
+ wasm.__wbindgen_add_to_stack_pointer(16);
2842
+ }
2843
+ }
2844
+ /**
2845
+ * Return the byte representation of a proving key
2846
+ *
2847
+ * @returns {Uint8Array} Byte array representation of a proving key
2848
+ * @returns {Uint8Array}
2849
+ */
2850
+ toBytes() {
2851
+ try {
2852
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2853
+ wasm.provingkey_toBytes(retptr, this.__wbg_ptr);
2854
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2855
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2856
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2857
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2858
+ if (r3) {
2859
+ throw takeObject(r2);
2860
+ }
2861
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2862
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2863
+ return v1;
2864
+ } finally {
2865
+ wasm.__wbindgen_add_to_stack_pointer(16);
2866
+ }
2867
+ }
2868
+ /**
2869
+ * Get a string representation of the proving key
2870
+ *
2871
+ * @returns {string} String representation of the proving key
2872
+ * @returns {string}
2873
+ */
2874
+ toString() {
2875
+ let deferred1_0;
2876
+ let deferred1_1;
2877
+ try {
2878
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2879
+ wasm.provingkey_toString(retptr, this.__wbg_ptr);
2880
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2881
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2882
+ deferred1_0 = r0;
2883
+ deferred1_1 = r1;
2884
+ return getStringFromWasm0(r0, r1);
2885
+ } finally {
2886
+ wasm.__wbindgen_add_to_stack_pointer(16);
2887
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2888
+ }
2889
+ }
2890
+ }
2891
+
2892
+ const RecordCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
2893
+ ? { register: () => {}, unregister: () => {} }
2894
+ : new FinalizationRegistry(ptr => wasm.__wbg_recordciphertext_free(ptr >>> 0));
2895
+ /**
2896
+ * Encrypted Aleo record
2897
+ */
2898
+ class RecordCiphertext {
2899
+
2900
+ static __wrap(ptr) {
2901
+ ptr = ptr >>> 0;
2902
+ const obj = Object.create(RecordCiphertext.prototype);
2903
+ obj.__wbg_ptr = ptr;
2904
+ RecordCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
2905
+ return obj;
2906
+ }
2907
+
2908
+ __destroy_into_raw() {
2909
+ const ptr = this.__wbg_ptr;
2910
+ this.__wbg_ptr = 0;
2911
+ RecordCiphertextFinalization.unregister(this);
2912
+ return ptr;
2913
+ }
2914
+
2915
+ free() {
2916
+ const ptr = this.__destroy_into_raw();
2917
+ wasm.__wbg_recordciphertext_free(ptr);
2918
+ }
2919
+ /**
2920
+ * Create a record ciphertext from a string
2921
+ *
2922
+ * @param {string} record String representation of a record ciphertext
2923
+ * @returns {RecordCiphertext} Record ciphertext
2924
+ * @param {string} record
2925
+ * @returns {RecordCiphertext}
2926
+ */
2927
+ static fromString(record) {
2928
+ try {
2929
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2930
+ const ptr0 = passStringToWasm0(record, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2931
+ const len0 = WASM_VECTOR_LEN;
2932
+ wasm.recordciphertext_fromString(retptr, ptr0, len0);
2933
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2934
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2935
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2936
+ if (r2) {
2937
+ throw takeObject(r1);
2938
+ }
2939
+ return RecordCiphertext.__wrap(r0);
2940
+ } finally {
2941
+ wasm.__wbindgen_add_to_stack_pointer(16);
2942
+ }
2943
+ }
2944
+ /**
2945
+ * Return the string reprensentation of the record ciphertext
2946
+ *
2947
+ * @returns {string} String representation of the record ciphertext
2948
+ * @returns {string}
2949
+ */
2950
+ toString() {
2951
+ let deferred1_0;
2952
+ let deferred1_1;
2953
+ try {
2954
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2955
+ wasm.recordciphertext_toString(retptr, this.__wbg_ptr);
2956
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2957
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2958
+ deferred1_0 = r0;
2959
+ deferred1_1 = r1;
2960
+ return getStringFromWasm0(r0, r1);
2961
+ } finally {
2962
+ wasm.__wbindgen_add_to_stack_pointer(16);
2963
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2964
+ }
2965
+ }
2966
+ /**
2967
+ * Decrypt the record ciphertext into plaintext using the view key. The record will only
2968
+ * decrypt if the record was encrypted by the account corresponding to the view key
2969
+ *
2970
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
2971
+ * @returns {RecordPlaintext} Record plaintext object
2972
+ * @param {ViewKey} view_key
2973
+ * @returns {RecordPlaintext}
2974
+ */
2975
+ decrypt(view_key) {
2976
+ try {
2977
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2978
+ _assertClass(view_key, ViewKey);
2979
+ wasm.recordciphertext_decrypt(retptr, this.__wbg_ptr, view_key.__wbg_ptr);
2980
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2981
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2982
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2983
+ if (r2) {
2984
+ throw takeObject(r1);
2985
+ }
2986
+ return RecordPlaintext.__wrap(r0);
2987
+ } finally {
2988
+ wasm.__wbindgen_add_to_stack_pointer(16);
2989
+ }
2990
+ }
2991
+ /**
2992
+ * Determines if the account corresponding to the view key is the owner of the record
2993
+ *
2994
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
2995
+ * @returns {boolean}
2996
+ * @param {ViewKey} view_key
2997
+ * @returns {boolean}
2998
+ */
2999
+ isOwner(view_key) {
3000
+ _assertClass(view_key, ViewKey);
3001
+ const ret = wasm.recordciphertext_isOwner(this.__wbg_ptr, view_key.__wbg_ptr);
3002
+ return ret !== 0;
3003
+ }
3004
+ }
3005
+
3006
+ const RecordPlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
3007
+ ? { register: () => {}, unregister: () => {} }
3008
+ : new FinalizationRegistry(ptr => wasm.__wbg_recordplaintext_free(ptr >>> 0));
3009
+ /**
3010
+ * Plaintext representation of an Aleo record
3011
+ */
3012
+ class RecordPlaintext {
3013
+
3014
+ static __wrap(ptr) {
3015
+ ptr = ptr >>> 0;
3016
+ const obj = Object.create(RecordPlaintext.prototype);
3017
+ obj.__wbg_ptr = ptr;
3018
+ RecordPlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
3019
+ return obj;
3020
+ }
3021
+
3022
+ __destroy_into_raw() {
3023
+ const ptr = this.__wbg_ptr;
3024
+ this.__wbg_ptr = 0;
3025
+ RecordPlaintextFinalization.unregister(this);
3026
+ return ptr;
3027
+ }
3028
+
3029
+ free() {
3030
+ const ptr = this.__destroy_into_raw();
3031
+ wasm.__wbg_recordplaintext_free(ptr);
3032
+ }
3033
+ /**
3034
+ * @param {string} program_id
3035
+ * @param {string} record_name
3036
+ * @returns {Field}
3037
+ */
3038
+ commitment(program_id, record_name) {
3039
+ try {
3040
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3041
+ const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3042
+ const len0 = WASM_VECTOR_LEN;
3043
+ const ptr1 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3044
+ const len1 = WASM_VECTOR_LEN;
3045
+ wasm.recordplaintext_commitment(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
3046
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3047
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3048
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3049
+ if (r2) {
3050
+ throw takeObject(r1);
3051
+ }
3052
+ return Field.__wrap(r0);
3053
+ } finally {
3054
+ wasm.__wbindgen_add_to_stack_pointer(16);
3055
+ }
3056
+ }
3057
+ /**
3058
+ * Return a record plaintext from a string.
3059
+ *
3060
+ * @param {string} record String representation of a plaintext representation of an Aleo record
3061
+ * @returns {RecordPlaintext} Record plaintext
3062
+ * @param {string} record
3063
+ * @returns {RecordPlaintext}
3064
+ */
3065
+ static fromString(record) {
3066
+ try {
3067
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3068
+ const ptr0 = passStringToWasm0(record, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3069
+ const len0 = WASM_VECTOR_LEN;
3070
+ wasm.recordplaintext_fromString(retptr, ptr0, len0);
3071
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3072
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3073
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3074
+ if (r2) {
3075
+ throw takeObject(r1);
3076
+ }
3077
+ return RecordPlaintext.__wrap(r0);
3078
+ } finally {
3079
+ wasm.__wbindgen_add_to_stack_pointer(16);
3080
+ }
3081
+ }
3082
+ /**
3083
+ * Returns the record plaintext string
3084
+ *
3085
+ * @returns {string} String representation of the record plaintext
3086
+ * @returns {string}
3087
+ */
3088
+ toString() {
3089
+ let deferred1_0;
3090
+ let deferred1_1;
3091
+ try {
3092
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3093
+ wasm.recordplaintext_toString(retptr, this.__wbg_ptr);
3094
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3095
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3096
+ deferred1_0 = r0;
3097
+ deferred1_1 = r1;
3098
+ return getStringFromWasm0(r0, r1);
3099
+ } finally {
3100
+ wasm.__wbindgen_add_to_stack_pointer(16);
3101
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3102
+ }
3103
+ }
3104
+ /**
3105
+ * Returns the amount of microcredits in the record
3106
+ *
3107
+ * @returns {u64} Amount of microcredits in the record
3108
+ * @returns {bigint}
3109
+ */
3110
+ microcredits() {
3111
+ const ret = wasm.recordplaintext_microcredits(this.__wbg_ptr);
3112
+ return BigInt.asUintN(64, ret);
3113
+ }
3114
+ /**
3115
+ * Returns the nonce of the record. This can be used to uniquely identify a record.
3116
+ *
3117
+ * @returns {string} Nonce of the record
3118
+ * @returns {string}
3119
+ */
3120
+ nonce() {
3121
+ let deferred1_0;
3122
+ let deferred1_1;
3123
+ try {
3124
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3125
+ wasm.recordplaintext_nonce(retptr, this.__wbg_ptr);
3126
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3127
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3128
+ deferred1_0 = r0;
3129
+ deferred1_1 = r1;
3130
+ return getStringFromWasm0(r0, r1);
3131
+ } finally {
3132
+ wasm.__wbindgen_add_to_stack_pointer(16);
3133
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3134
+ }
3135
+ }
3136
+ /**
3137
+ * Attempt to get the serial number of a record to determine whether or not is has been spent
3138
+ *
3139
+ * @param {PrivateKey} private_key Private key of the account that owns the record
3140
+ * @param {string} program_id Program ID of the program that the record is associated with
3141
+ * @param {string} record_name Name of the record
3142
+ * @returns {string} Serial number of the record
3143
+ * @param {PrivateKey} private_key
3144
+ * @param {string} program_id
3145
+ * @param {string} record_name
3146
+ * @returns {string}
3147
+ */
3148
+ serialNumberString(private_key, program_id, record_name) {
3149
+ let deferred4_0;
3150
+ let deferred4_1;
3151
+ try {
3152
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3153
+ _assertClass(private_key, PrivateKey);
3154
+ const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3155
+ const len0 = WASM_VECTOR_LEN;
3156
+ const ptr1 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3157
+ const len1 = WASM_VECTOR_LEN;
3158
+ wasm.recordplaintext_serialNumberString(retptr, this.__wbg_ptr, private_key.__wbg_ptr, ptr0, len0, ptr1, len1);
3159
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3160
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3161
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3162
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3163
+ var ptr3 = r0;
3164
+ var len3 = r1;
3165
+ if (r3) {
3166
+ ptr3 = 0; len3 = 0;
3167
+ throw takeObject(r2);
3168
+ }
3169
+ deferred4_0 = ptr3;
3170
+ deferred4_1 = len3;
3171
+ return getStringFromWasm0(ptr3, len3);
3172
+ } finally {
3173
+ wasm.__wbindgen_add_to_stack_pointer(16);
3174
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3175
+ }
3176
+ }
3177
+ }
3178
+
3179
+ const SignatureFinalization = (typeof FinalizationRegistry === 'undefined')
3180
+ ? { register: () => {}, unregister: () => {} }
3181
+ : new FinalizationRegistry(ptr => wasm.__wbg_signature_free(ptr >>> 0));
3182
+ /**
3183
+ * Cryptographic signature of a message signed by an Aleo account
3184
+ */
3185
+ class Signature {
3186
+
3187
+ static __wrap(ptr) {
3188
+ ptr = ptr >>> 0;
3189
+ const obj = Object.create(Signature.prototype);
3190
+ obj.__wbg_ptr = ptr;
3191
+ SignatureFinalization.register(obj, obj.__wbg_ptr, obj);
3192
+ return obj;
3193
+ }
3194
+
3195
+ __destroy_into_raw() {
3196
+ const ptr = this.__wbg_ptr;
3197
+ this.__wbg_ptr = 0;
3198
+ SignatureFinalization.unregister(this);
3199
+ return ptr;
3200
+ }
3201
+
3202
+ free() {
3203
+ const ptr = this.__destroy_into_raw();
3204
+ wasm.__wbg_signature_free(ptr);
3205
+ }
3206
+ /**
3207
+ * Sign a message with a private key
3208
+ *
3209
+ * @param {PrivateKey} private_key The private key to sign the message with
3210
+ * @param {Uint8Array} message Byte representation of the message to sign
3211
+ * @returns {Signature} Signature of the message
3212
+ * @param {PrivateKey} private_key
3213
+ * @param {Uint8Array} message
3214
+ * @returns {Signature}
3215
+ */
3216
+ static sign(private_key, message) {
3217
+ _assertClass(private_key, PrivateKey);
3218
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
3219
+ const len0 = WASM_VECTOR_LEN;
3220
+ const ret = wasm.privatekey_sign(private_key.__wbg_ptr, ptr0, len0);
3221
+ return Signature.__wrap(ret);
3222
+ }
3223
+ /**
3224
+ * Verify a signature of a message with an address
3225
+ *
3226
+ * @param {Address} address The address to verify the signature with
3227
+ * @param {Uint8Array} message Byte representation of the message to verify
3228
+ * @returns {boolean} True if the signature is valid, false otherwise
3229
+ * @param {Address} address
3230
+ * @param {Uint8Array} message
3231
+ * @returns {boolean}
3232
+ */
3233
+ verify(address, message) {
3234
+ _assertClass(address, Address);
3235
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
3236
+ const len0 = WASM_VECTOR_LEN;
3237
+ const ret = wasm.signature_verify(this.__wbg_ptr, address.__wbg_ptr, ptr0, len0);
3238
+ return ret !== 0;
3239
+ }
3240
+ /**
3241
+ * Get a signature from a string representation of a signature
3242
+ *
3243
+ * @param {string} signature String representation of a signature
3244
+ * @returns {Signature} Signature
3245
+ * @param {string} signature
3246
+ * @returns {Signature}
3247
+ */
3248
+ static from_string(signature) {
3249
+ const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3250
+ const len0 = WASM_VECTOR_LEN;
3251
+ const ret = wasm.signature_from_string(ptr0, len0);
3252
+ return Signature.__wrap(ret);
3253
+ }
3254
+ /**
3255
+ * Get a string representation of a signature
3256
+ *
3257
+ * @returns {string} String representation of a signature
3258
+ * @returns {string}
3259
+ */
3260
+ to_string() {
3261
+ let deferred1_0;
3262
+ let deferred1_1;
3263
+ try {
3264
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3265
+ wasm.signature_to_string(retptr, this.__wbg_ptr);
3266
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3267
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3268
+ deferred1_0 = r0;
3269
+ deferred1_1 = r1;
3270
+ return getStringFromWasm0(r0, r1);
3271
+ } finally {
3272
+ wasm.__wbindgen_add_to_stack_pointer(16);
3273
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3274
+ }
3275
+ }
3276
+ }
3277
+
3278
+ const TransactionFinalization = (typeof FinalizationRegistry === 'undefined')
3279
+ ? { register: () => {}, unregister: () => {} }
3280
+ : new FinalizationRegistry(ptr => wasm.__wbg_transaction_free(ptr >>> 0));
3281
+ /**
3282
+ * Webassembly Representation of an Aleo transaction
3283
+ *
3284
+ * This object is created when generating an on-chain function deployment or execution and is the
3285
+ * object that should be submitted to the Aleo Network in order to deploy or execute a function.
3286
+ */
3287
+ class Transaction {
3288
+
3289
+ static __wrap(ptr) {
3290
+ ptr = ptr >>> 0;
3291
+ const obj = Object.create(Transaction.prototype);
3292
+ obj.__wbg_ptr = ptr;
3293
+ TransactionFinalization.register(obj, obj.__wbg_ptr, obj);
3294
+ return obj;
3295
+ }
3296
+
3297
+ __destroy_into_raw() {
3298
+ const ptr = this.__wbg_ptr;
3299
+ this.__wbg_ptr = 0;
3300
+ TransactionFinalization.unregister(this);
3301
+ return ptr;
3302
+ }
3303
+
3304
+ free() {
3305
+ const ptr = this.__destroy_into_raw();
3306
+ wasm.__wbg_transaction_free(ptr);
3307
+ }
3308
+ /**
3309
+ * Create a transaction from a string
3310
+ *
3311
+ * @param {string} transaction String representation of a transaction
3312
+ * @returns {Transaction}
3313
+ * @param {string} transaction
3314
+ * @returns {Transaction}
3315
+ */
3316
+ static fromString(transaction) {
3317
+ try {
3318
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3319
+ const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3320
+ const len0 = WASM_VECTOR_LEN;
3321
+ wasm.transaction_fromString(retptr, ptr0, len0);
3322
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3323
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3324
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3325
+ if (r2) {
3326
+ throw takeObject(r1);
3327
+ }
3328
+ return Transaction.__wrap(r0);
3329
+ } finally {
3330
+ wasm.__wbindgen_add_to_stack_pointer(16);
3331
+ }
3332
+ }
3333
+ /**
3334
+ * Get the transaction as a string. If you want to submit this transaction to the Aleo Network
3335
+ * this function will create the string that should be submitted in the `POST` data.
3336
+ *
3337
+ * @returns {string} String representation of the transaction
3338
+ * @returns {string}
3339
+ */
3340
+ toString() {
3341
+ let deferred1_0;
3342
+ let deferred1_1;
3343
+ try {
3344
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3345
+ wasm.transaction_toString(retptr, this.__wbg_ptr);
3346
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3347
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3348
+ deferred1_0 = r0;
3349
+ deferred1_1 = r1;
3350
+ return getStringFromWasm0(r0, r1);
3351
+ } finally {
3352
+ wasm.__wbindgen_add_to_stack_pointer(16);
3353
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3354
+ }
3355
+ }
3356
+ /**
3357
+ * Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
3358
+ *
3359
+ * This value can be used to query the status of the transaction on the Aleo Network to see
3360
+ * if it was successful. If successful, the transaction will be included in a block and this
3361
+ * value can be used to lookup the transaction data on-chain.
3362
+ *
3363
+ * @returns {string} Transaction id
3364
+ * @returns {string}
3365
+ */
3366
+ transactionId() {
3367
+ let deferred1_0;
3368
+ let deferred1_1;
3369
+ try {
3370
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3371
+ wasm.transaction_transactionId(retptr, this.__wbg_ptr);
3372
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3373
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3374
+ deferred1_0 = r0;
3375
+ deferred1_1 = r1;
3376
+ return getStringFromWasm0(r0, r1);
3377
+ } finally {
3378
+ wasm.__wbindgen_add_to_stack_pointer(16);
3379
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3380
+ }
3381
+ }
3382
+ /**
3383
+ * Get the type of the transaction (will return "deploy" or "execute")
3384
+ *
3385
+ * @returns {string} Transaction type
3386
+ * @returns {string}
3387
+ */
3388
+ transactionType() {
3389
+ let deferred1_0;
3390
+ let deferred1_1;
3391
+ try {
3392
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3393
+ wasm.transaction_transactionType(retptr, this.__wbg_ptr);
3394
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3395
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3396
+ deferred1_0 = r0;
3397
+ deferred1_1 = r1;
3398
+ return getStringFromWasm0(r0, r1);
3399
+ } finally {
3400
+ wasm.__wbindgen_add_to_stack_pointer(16);
3401
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3402
+ }
3403
+ }
3404
+ }
3405
+
3406
+ const VerifyingKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3407
+ ? { register: () => {}, unregister: () => {} }
3408
+ : new FinalizationRegistry(ptr => wasm.__wbg_verifyingkey_free(ptr >>> 0));
3409
+ /**
3410
+ * Verifying key for a function within an Aleo program
3411
+ */
3412
+ class VerifyingKey {
3413
+
3414
+ static __wrap(ptr) {
3415
+ ptr = ptr >>> 0;
3416
+ const obj = Object.create(VerifyingKey.prototype);
3417
+ obj.__wbg_ptr = ptr;
3418
+ VerifyingKeyFinalization.register(obj, obj.__wbg_ptr, obj);
3419
+ return obj;
3420
+ }
3421
+
3422
+ __destroy_into_raw() {
3423
+ const ptr = this.__wbg_ptr;
3424
+ this.__wbg_ptr = 0;
3425
+ VerifyingKeyFinalization.unregister(this);
3426
+ return ptr;
3427
+ }
3428
+
3429
+ free() {
3430
+ const ptr = this.__destroy_into_raw();
3431
+ wasm.__wbg_verifyingkey_free(ptr);
3432
+ }
3433
+ /**
3434
+ * Returns the verifying key for the bond_public function
3435
+ *
3436
+ * @returns {VerifyingKey} Verifying key for the bond_public function
3437
+ * @returns {VerifyingKey}
3438
+ */
3439
+ static bondPublicVerifier() {
3440
+ const ret = wasm.verifyingkey_bondPublicVerifier();
3441
+ return VerifyingKey.__wrap(ret);
3442
+ }
3443
+ /**
3444
+ * Returns the verifying key for the bond_validator function
3445
+ *
3446
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
3447
+ * @returns {VerifyingKey}
3448
+ */
3449
+ static bondValidatorVerifier() {
3450
+ const ret = wasm.verifyingkey_bondValidatorVerifier();
3451
+ return VerifyingKey.__wrap(ret);
3452
+ }
3453
+ /**
3454
+ * Returns the verifying key for the claim_delegator function
3455
+ *
3456
+ * @returns {VerifyingKey} Verifying key for the claim_unbond_public function
3457
+ * @returns {VerifyingKey}
3458
+ */
3459
+ static claimUnbondPublicVerifier() {
3460
+ const ret = wasm.verifyingkey_claimUnbondPublicVerifier();
3461
+ return VerifyingKey.__wrap(ret);
3462
+ }
3463
+ /**
3464
+ * Returns the verifying key for the fee_private function
3465
+ *
3466
+ * @returns {VerifyingKey} Verifying key for the fee_private function
3467
+ * @returns {VerifyingKey}
3468
+ */
3469
+ static feePrivateVerifier() {
3470
+ const ret = wasm.verifyingkey_feePrivateVerifier();
3471
+ return VerifyingKey.__wrap(ret);
3472
+ }
3473
+ /**
3474
+ * Returns the verifying key for the fee_public function
3475
+ *
3476
+ * @returns {VerifyingKey} Verifying key for the fee_public function
3477
+ * @returns {VerifyingKey}
3478
+ */
3479
+ static feePublicVerifier() {
3480
+ const ret = wasm.verifyingkey_feePublicVerifier();
3481
+ return VerifyingKey.__wrap(ret);
3482
+ }
3483
+ /**
3484
+ * Returns the verifying key for the inclusion function
3485
+ *
3486
+ * @returns {VerifyingKey} Verifying key for the inclusion function
3487
+ * @returns {VerifyingKey}
3488
+ */
3489
+ static inclusionVerifier() {
3490
+ const ret = wasm.verifyingkey_inclusionVerifier();
3491
+ return VerifyingKey.__wrap(ret);
3492
+ }
3493
+ /**
3494
+ * Returns the verifying key for the join function
3495
+ *
3496
+ * @returns {VerifyingKey} Verifying key for the join function
3497
+ * @returns {VerifyingKey}
3498
+ */
3499
+ static joinVerifier() {
3500
+ const ret = wasm.verifyingkey_joinVerifier();
3501
+ return VerifyingKey.__wrap(ret);
3502
+ }
3503
+ /**
3504
+ * Returns the verifying key for the set_validator_state function
3505
+ *
3506
+ * @returns {VerifyingKey} Verifying key for the set_validator_state function
3507
+ * @returns {VerifyingKey}
3508
+ */
3509
+ static setValidatorStateVerifier() {
3510
+ const ret = wasm.verifyingkey_setValidatorStateVerifier();
3511
+ return VerifyingKey.__wrap(ret);
3512
+ }
3513
+ /**
3514
+ * Returns the verifying key for the split function
3515
+ *
3516
+ * @returns {VerifyingKey} Verifying key for the split function
3517
+ * @returns {VerifyingKey}
3518
+ */
3519
+ static splitVerifier() {
3520
+ const ret = wasm.verifyingkey_splitVerifier();
3521
+ return VerifyingKey.__wrap(ret);
3522
+ }
3523
+ /**
3524
+ * Returns the verifying key for the transfer_private function
3525
+ *
3526
+ * @returns {VerifyingKey} Verifying key for the transfer_private function
3527
+ * @returns {VerifyingKey}
3528
+ */
3529
+ static transferPrivateVerifier() {
3530
+ const ret = wasm.verifyingkey_transferPrivateVerifier();
3531
+ return VerifyingKey.__wrap(ret);
3532
+ }
3533
+ /**
3534
+ * Returns the verifying key for the transfer_private_to_public function
3535
+ *
3536
+ * @returns {VerifyingKey} Verifying key for the transfer_private_to_public function
3537
+ * @returns {VerifyingKey}
3538
+ */
3539
+ static transferPrivateToPublicVerifier() {
3540
+ const ret = wasm.verifyingkey_transferPrivateToPublicVerifier();
3541
+ return VerifyingKey.__wrap(ret);
3542
+ }
3543
+ /**
3544
+ * Returns the verifying key for the transfer_public function
3545
+ *
3546
+ * @returns {VerifyingKey} Verifying key for the transfer_public function
3547
+ * @returns {VerifyingKey}
3548
+ */
3549
+ static transferPublicVerifier() {
3550
+ const ret = wasm.verifyingkey_transferPublicVerifier();
3551
+ return VerifyingKey.__wrap(ret);
3552
+ }
3553
+ /**
3554
+ * Returns the verifying key for the transfer_public_as_signer function
3555
+ *
3556
+ * @returns {VerifyingKey} Verifying key for the transfer_public_as_signer function
3557
+ * @returns {VerifyingKey}
3558
+ */
3559
+ static transferPublicAsSignerVerifier() {
3560
+ const ret = wasm.verifyingkey_transferPublicAsSignerVerifier();
3561
+ return VerifyingKey.__wrap(ret);
3562
+ }
3563
+ /**
3564
+ * Returns the verifying key for the transfer_public_to_private function
3565
+ *
3566
+ * @returns {VerifyingKey} Verifying key for the transfer_public_to_private function
3567
+ * @returns {VerifyingKey}
3568
+ */
3569
+ static transferPublicToPrivateVerifier() {
3570
+ const ret = wasm.verifyingkey_transferPublicToPrivateVerifier();
3571
+ return VerifyingKey.__wrap(ret);
3572
+ }
3573
+ /**
3574
+ * Returns the verifying key for the unbond_public function
3575
+ *
3576
+ * @returns {VerifyingKey} Verifying key for the unbond_public function
3577
+ * @returns {VerifyingKey}
3578
+ */
3579
+ static unbondPublicVerifier() {
3580
+ const ret = wasm.verifyingkey_unbondPublicVerifier();
3581
+ return VerifyingKey.__wrap(ret);
3582
+ }
3583
+ /**
3584
+ * Returns the verifying key for the bond_public function
3585
+ *
3586
+ * @returns {VerifyingKey} Verifying key for the bond_public function
3587
+ * @returns {boolean}
3588
+ */
3589
+ isBondPublicVerifier() {
3590
+ const ret = wasm.verifyingkey_isBondPublicVerifier(this.__wbg_ptr);
3591
+ return ret !== 0;
3592
+ }
3593
+ /**
3594
+ * Returns the verifying key for the bond_validator function
3595
+ *
3596
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
3597
+ * @returns {boolean}
3598
+ */
3599
+ isBondValidatorVerifier() {
3600
+ const ret = wasm.verifyingkey_isBondValidatorVerifier(this.__wbg_ptr);
3601
+ return ret !== 0;
3602
+ }
3603
+ /**
3604
+ * Verifies the verifying key is for the claim_delegator function
3605
+ *
3606
+ * @returns {bool}
3607
+ * @returns {boolean}
3608
+ */
3609
+ isClaimUnbondPublicVerifier() {
3610
+ const ret = wasm.verifyingkey_isClaimUnbondPublicVerifier(this.__wbg_ptr);
3611
+ return ret !== 0;
3612
+ }
3613
+ /**
3614
+ * Verifies the verifying key is for the fee_private function
3615
+ *
3616
+ * @returns {bool}
3617
+ * @returns {boolean}
3618
+ */
3619
+ isFeePrivateVerifier() {
3620
+ const ret = wasm.verifyingkey_isFeePrivateVerifier(this.__wbg_ptr);
3621
+ return ret !== 0;
3622
+ }
3623
+ /**
3624
+ * Verifies the verifying key is for the fee_public function
3625
+ *
3626
+ * @returns {bool}
3627
+ * @returns {boolean}
3628
+ */
3629
+ isFeePublicVerifier() {
3630
+ const ret = wasm.verifyingkey_isFeePublicVerifier(this.__wbg_ptr);
3631
+ return ret !== 0;
3632
+ }
3633
+ /**
3634
+ * Verifies the verifying key is for the inclusion function
3635
+ *
3636
+ * @returns {bool}
3637
+ * @returns {boolean}
3638
+ */
3639
+ isInclusionVerifier() {
3640
+ const ret = wasm.verifyingkey_isInclusionVerifier(this.__wbg_ptr);
3641
+ return ret !== 0;
3642
+ }
3643
+ /**
3644
+ * Verifies the verifying key is for the join function
3645
+ *
3646
+ * @returns {bool}
3647
+ * @returns {boolean}
3648
+ */
3649
+ isJoinVerifier() {
3650
+ const ret = wasm.verifyingkey_isJoinVerifier(this.__wbg_ptr);
3651
+ return ret !== 0;
3652
+ }
3653
+ /**
3654
+ * Verifies the verifying key is for the set_validator_state function
3655
+ *
3656
+ * @returns {bool}
3657
+ * @returns {boolean}
3658
+ */
3659
+ isSetValidatorStateVerifier() {
3660
+ const ret = wasm.verifyingkey_isSetValidatorStateVerifier(this.__wbg_ptr);
3661
+ return ret !== 0;
3662
+ }
3663
+ /**
3664
+ * Verifies the verifying key is for the split function
3665
+ *
3666
+ * @returns {bool}
3667
+ * @returns {boolean}
3668
+ */
3669
+ isSplitVerifier() {
3670
+ const ret = wasm.verifyingkey_isSplitVerifier(this.__wbg_ptr);
3671
+ return ret !== 0;
3672
+ }
3673
+ /**
3674
+ * Verifies the verifying key is for the transfer_private function
3675
+ *
3676
+ * @returns {bool}
3677
+ * @returns {boolean}
3678
+ */
3679
+ isTransferPrivateVerifier() {
3680
+ const ret = wasm.verifyingkey_isTransferPrivateVerifier(this.__wbg_ptr);
3681
+ return ret !== 0;
3682
+ }
3683
+ /**
3684
+ * Verifies the verifying key is for the transfer_private_to_public function
3685
+ *
3686
+ * @returns {bool}
3687
+ * @returns {boolean}
3688
+ */
3689
+ isTransferPrivateToPublicVerifier() {
3690
+ const ret = wasm.verifyingkey_isTransferPrivateToPublicVerifier(this.__wbg_ptr);
3691
+ return ret !== 0;
3692
+ }
3693
+ /**
3694
+ * Verifies the verifying key is for the transfer_public function
3695
+ *
3696
+ * @returns {bool}
3697
+ * @returns {boolean}
3698
+ */
3699
+ isTransferPublicVerifier() {
3700
+ const ret = wasm.verifyingkey_isTransferPublicVerifier(this.__wbg_ptr);
3701
+ return ret !== 0;
3702
+ }
3703
+ /**
3704
+ * Verifies the verifying key is for the transfer_public_as_signer function
3705
+ *
3706
+ * @returns {bool}
3707
+ * @returns {boolean}
3708
+ */
3709
+ isTransferPublicAsSignerVerifier() {
3710
+ const ret = wasm.verifyingkey_isTransferPublicAsSignerVerifier(this.__wbg_ptr);
3711
+ return ret !== 0;
3712
+ }
3713
+ /**
3714
+ * Verifies the verifying key is for the transfer_public_to_private function
3715
+ *
3716
+ * @returns {bool}
3717
+ * @returns {boolean}
3718
+ */
3719
+ isTransferPublicToPrivateVerifier() {
3720
+ const ret = wasm.verifyingkey_isTransferPublicToPrivateVerifier(this.__wbg_ptr);
3721
+ return ret !== 0;
3722
+ }
3723
+ /**
3724
+ * Verifies the verifying key is for the unbond_public function
3725
+ *
3726
+ * @returns {bool}
3727
+ * @returns {boolean}
3728
+ */
3729
+ isUnbondPublicVerifier() {
3730
+ const ret = wasm.verifyingkey_isUnbondPublicVerifier(this.__wbg_ptr);
3731
+ return ret !== 0;
3732
+ }
3733
+ /**
3734
+ * Get the checksum of the verifying key
3735
+ *
3736
+ * @returns {string} Checksum of the verifying key
3737
+ * @returns {string}
3738
+ */
3739
+ checksum() {
3740
+ let deferred1_0;
3741
+ let deferred1_1;
3742
+ try {
3743
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3744
+ wasm.verifyingkey_checksum(retptr, this.__wbg_ptr);
3745
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3746
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3747
+ deferred1_0 = r0;
3748
+ deferred1_1 = r1;
3749
+ return getStringFromWasm0(r0, r1);
3750
+ } finally {
3751
+ wasm.__wbindgen_add_to_stack_pointer(16);
3752
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3753
+ }
3754
+ }
3755
+ /**
3756
+ * Create a copy of the verifying key
3757
+ *
3758
+ * @returns {VerifyingKey} A copy of the verifying key
3759
+ * @returns {VerifyingKey}
3760
+ */
3761
+ copy() {
3762
+ const ret = wasm.verifyingkey_copy(this.__wbg_ptr);
3763
+ return VerifyingKey.__wrap(ret);
3764
+ }
3765
+ /**
3766
+ * Construct a new verifying key from a byte array
3767
+ *
3768
+ * @param {Uint8Array} bytes Byte representation of a verifying key
3769
+ * @returns {VerifyingKey}
3770
+ * @param {Uint8Array} bytes
3771
+ * @returns {VerifyingKey}
3772
+ */
3773
+ static fromBytes(bytes) {
3774
+ try {
3775
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3776
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
3777
+ const len0 = WASM_VECTOR_LEN;
3778
+ wasm.verifyingkey_fromBytes(retptr, ptr0, len0);
3779
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3780
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3781
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3782
+ if (r2) {
3783
+ throw takeObject(r1);
3784
+ }
3785
+ return VerifyingKey.__wrap(r0);
3786
+ } finally {
3787
+ wasm.__wbindgen_add_to_stack_pointer(16);
3788
+ }
3789
+ }
3790
+ /**
3791
+ * Create a verifying key from string
3792
+ *
3793
+ * @param {String} string String representation of a verifying key
3794
+ * @returns {VerifyingKey}
3795
+ * @param {string} string
3796
+ * @returns {VerifyingKey}
3797
+ */
3798
+ static fromString(string) {
3799
+ try {
3800
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3801
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3802
+ const len0 = WASM_VECTOR_LEN;
3803
+ wasm.verifyingkey_fromString(retptr, ptr0, len0);
3804
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3805
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3806
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3807
+ if (r2) {
3808
+ throw takeObject(r1);
3809
+ }
3810
+ return VerifyingKey.__wrap(r0);
3811
+ } finally {
3812
+ wasm.__wbindgen_add_to_stack_pointer(16);
3813
+ }
3814
+ }
3815
+ /**
3816
+ * Create a byte array from a verifying key
3817
+ *
3818
+ * @returns {Uint8Array} Byte representation of a verifying key
3819
+ * @returns {Uint8Array}
3820
+ */
3821
+ toBytes() {
3822
+ try {
3823
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3824
+ wasm.verifyingkey_toBytes(retptr, this.__wbg_ptr);
3825
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3826
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3827
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3828
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3829
+ if (r3) {
3830
+ throw takeObject(r2);
3831
+ }
3832
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3833
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
3834
+ return v1;
3835
+ } finally {
3836
+ wasm.__wbindgen_add_to_stack_pointer(16);
3837
+ }
3838
+ }
3839
+ /**
3840
+ * Get a string representation of the verifying key
3841
+ *
3842
+ * @returns {String} String representation of the verifying key
3843
+ * @returns {string}
3844
+ */
3845
+ toString() {
3846
+ let deferred1_0;
3847
+ let deferred1_1;
3848
+ try {
3849
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3850
+ wasm.verifyingkey_toString(retptr, this.__wbg_ptr);
3851
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3852
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3853
+ deferred1_0 = r0;
3854
+ deferred1_1 = r1;
3855
+ return getStringFromWasm0(r0, r1);
3856
+ } finally {
3857
+ wasm.__wbindgen_add_to_stack_pointer(16);
3858
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3859
+ }
3860
+ }
3861
+ }
3862
+
3863
+ const ViewKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3864
+ ? { register: () => {}, unregister: () => {} }
3865
+ : new FinalizationRegistry(ptr => wasm.__wbg_viewkey_free(ptr >>> 0));
3866
+ /**
3867
+ */
3868
+ class ViewKey {
3869
+
3870
+ static __wrap(ptr) {
3871
+ ptr = ptr >>> 0;
3872
+ const obj = Object.create(ViewKey.prototype);
3873
+ obj.__wbg_ptr = ptr;
3874
+ ViewKeyFinalization.register(obj, obj.__wbg_ptr, obj);
3875
+ return obj;
3876
+ }
3877
+
3878
+ __destroy_into_raw() {
3879
+ const ptr = this.__wbg_ptr;
3880
+ this.__wbg_ptr = 0;
3881
+ ViewKeyFinalization.unregister(this);
3882
+ return ptr;
3883
+ }
3884
+
3885
+ free() {
3886
+ const ptr = this.__destroy_into_raw();
3887
+ wasm.__wbg_viewkey_free(ptr);
3888
+ }
3889
+ /**
3890
+ * Create a new view key from a private key
3891
+ *
3892
+ * @param {PrivateKey} private_key Private key
3893
+ * @returns {ViewKey} View key
3894
+ * @param {PrivateKey} private_key
3895
+ * @returns {ViewKey}
3896
+ */
3897
+ static from_private_key(private_key) {
3898
+ _assertClass(private_key, PrivateKey);
3899
+ const ret = wasm.privatekey_to_view_key(private_key.__wbg_ptr);
3900
+ return ViewKey.__wrap(ret);
3901
+ }
3902
+ /**
3903
+ * Create a new view key from a string representation of a view key
3904
+ *
3905
+ * @param {string} view_key String representation of a view key
3906
+ * @returns {ViewKey} View key
3907
+ * @param {string} view_key
3908
+ * @returns {ViewKey}
3909
+ */
3910
+ static from_string(view_key) {
3911
+ const ptr0 = passStringToWasm0(view_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3912
+ const len0 = WASM_VECTOR_LEN;
3913
+ const ret = wasm.viewkey_from_string(ptr0, len0);
3914
+ return ViewKey.__wrap(ret);
3915
+ }
3916
+ /**
3917
+ * Get a string representation of a view key
3918
+ *
3919
+ * @returns {string} String representation of a view key
3920
+ * @returns {string}
3921
+ */
3922
+ to_string() {
3923
+ let deferred1_0;
3924
+ let deferred1_1;
3925
+ try {
3926
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3927
+ wasm.viewkey_to_string(retptr, this.__wbg_ptr);
3928
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3929
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3930
+ deferred1_0 = r0;
3931
+ deferred1_1 = r1;
3932
+ return getStringFromWasm0(r0, r1);
3933
+ } finally {
3934
+ wasm.__wbindgen_add_to_stack_pointer(16);
3935
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3936
+ }
3937
+ }
3938
+ /**
3939
+ * Get the address corresponding to a view key
3940
+ *
3941
+ * @returns {Address} Address
3942
+ * @returns {Address}
3943
+ */
3944
+ to_address() {
3945
+ const ret = wasm.address_from_view_key(this.__wbg_ptr);
3946
+ return Address.__wrap(ret);
3947
+ }
3948
+ /**
3949
+ * Decrypt a record ciphertext with a view key
3950
+ *
3951
+ * @param {string} ciphertext String representation of a record ciphertext
3952
+ * @returns {string} String representation of a record plaintext
3953
+ * @param {string} ciphertext
3954
+ * @returns {string}
3955
+ */
3956
+ decrypt(ciphertext) {
3957
+ let deferred3_0;
3958
+ let deferred3_1;
3959
+ try {
3960
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3961
+ const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3962
+ const len0 = WASM_VECTOR_LEN;
3963
+ wasm.viewkey_decrypt(retptr, this.__wbg_ptr, ptr0, len0);
3964
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3965
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3966
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3967
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3968
+ var ptr2 = r0;
3969
+ var len2 = r1;
3970
+ if (r3) {
3971
+ ptr2 = 0; len2 = 0;
3972
+ throw takeObject(r2);
3973
+ }
3974
+ deferred3_0 = ptr2;
3975
+ deferred3_1 = len2;
3976
+ return getStringFromWasm0(ptr2, len2);
3977
+ } finally {
3978
+ wasm.__wbindgen_add_to_stack_pointer(16);
3979
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3980
+ }
3981
+ }
3982
+ }
3983
+
3984
+ async function __wbg_load(module, imports) {
3985
+ if (typeof Response === 'function' && module instanceof Response) {
3986
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
3987
+ try {
3988
+ return await WebAssembly.instantiateStreaming(module, imports);
3989
+
3990
+ } catch (e) {
3991
+ if (module.headers.get('Content-Type') != 'application/wasm') {
3992
+ console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
3993
+
3994
+ } else {
3995
+ throw e;
3996
+ }
3997
+ }
3998
+ }
3999
+
4000
+ const bytes = await module.arrayBuffer();
4001
+ return await WebAssembly.instantiate(bytes, imports);
4002
+
4003
+ } else {
4004
+ const instance = await WebAssembly.instantiate(module, imports);
4005
+
4006
+ if (instance instanceof WebAssembly.Instance) {
4007
+ return { instance, module };
4008
+
4009
+ } else {
4010
+ return instance;
4011
+ }
4012
+ }
4013
+ }
4014
+
4015
+ function __wbg_get_imports() {
4016
+ const imports = {};
4017
+ imports.wbg = {};
4018
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
4019
+ takeObject(arg0);
4020
+ };
4021
+ imports.wbg.__wbg_new_71801a555ad9f2aa = function() { return handleError(function () {
4022
+ const ret = new XMLHttpRequest();
4023
+ return addHeapObject(ret);
4024
+ }, arguments) };
4025
+ imports.wbg.__wbg_overrideMimeType_ee9c51919ceb418b = function() { return handleError(function (arg0, arg1, arg2) {
4026
+ getObject(arg0).overrideMimeType(getStringFromWasm0(arg1, arg2));
4027
+ }, arguments) };
4028
+ imports.wbg.__wbg_open_c9eb0cf2c9d95679 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
4029
+ getObject(arg0).open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), arg5 !== 0);
4030
+ }, arguments) };
4031
+ imports.wbg.__wbg_send_80d29985093c1ec5 = function() { return handleError(function (arg0) {
4032
+ getObject(arg0).send();
4033
+ }, arguments) };
4034
+ imports.wbg.__wbg_response_7c2e2759084f7279 = function() { return handleError(function (arg0) {
4035
+ const ret = getObject(arg0).response;
4036
+ return addHeapObject(ret);
4037
+ }, arguments) };
4038
+ imports.wbg.__wbg_status_d485fb5a478426fb = function() { return handleError(function (arg0) {
4039
+ const ret = getObject(arg0).status;
4040
+ return ret;
4041
+ }, arguments) };
4042
+ imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() {
4043
+ const ret = new Object();
4044
+ return addHeapObject(ret);
4045
+ };
4046
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
4047
+ const ret = getStringFromWasm0(arg0, arg1);
4048
+ return addHeapObject(ret);
4049
+ };
4050
+ imports.wbg.__wbg_set_1f9b04f170055d33 = function() { return handleError(function (arg0, arg1, arg2) {
4051
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
4052
+ return ret;
4053
+ }, arguments) };
4054
+ imports.wbg.__wbg_new_ab6fd82b10560829 = function() { return handleError(function () {
4055
+ const ret = new Headers();
4056
+ return addHeapObject(ret);
4057
+ }, arguments) };
4058
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
4059
+ const ret = getObject(arg0);
4060
+ return addHeapObject(ret);
4061
+ };
4062
+ imports.wbg.__wbg_new_0d76b0581eca6298 = function() { return handleError(function () {
4063
+ const ret = new AbortController();
4064
+ return addHeapObject(ret);
4065
+ }, arguments) };
4066
+ imports.wbg.__wbg_signal_a61f78a3478fd9bc = function(arg0) {
4067
+ const ret = getObject(arg0).signal;
4068
+ return addHeapObject(ret);
4069
+ };
4070
+ imports.wbg.__wbg_append_7bfcb4937d1d5e29 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4071
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4072
+ }, arguments) };
4073
+ imports.wbg.__wbg_instanceof_Response_849eb93e75734b6e = function(arg0) {
4074
+ let result;
4075
+ try {
4076
+ result = getObject(arg0) instanceof Response;
4077
+ } catch (_) {
4078
+ result = false;
4079
+ }
4080
+ const ret = result;
4081
+ return ret;
4082
+ };
4083
+ imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) {
4084
+ const ret = getObject(arg0).status;
4085
+ return ret;
4086
+ };
4087
+ imports.wbg.__wbg_url_5f6dc4009ac5f99d = function(arg0, arg1) {
4088
+ const ret = getObject(arg1).url;
4089
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4090
+ const len1 = WASM_VECTOR_LEN;
4091
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4092
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4093
+ };
4094
+ imports.wbg.__wbg_headers_9620bfada380764a = function(arg0) {
4095
+ const ret = getObject(arg0).headers;
4096
+ return addHeapObject(ret);
4097
+ };
4098
+ imports.wbg.__wbg_iterator_2cee6dadfd956dfa = function() {
4099
+ const ret = Symbol.iterator;
4100
+ return addHeapObject(ret);
4101
+ };
4102
+ imports.wbg.__wbg_get_e3c254076557e348 = function() { return handleError(function (arg0, arg1) {
4103
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
4104
+ return addHeapObject(ret);
4105
+ }, arguments) };
4106
+ imports.wbg.__wbindgen_is_function = function(arg0) {
4107
+ const ret = typeof(getObject(arg0)) === 'function';
4108
+ return ret;
4109
+ };
4110
+ imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {
4111
+ const ret = getObject(arg0).call(getObject(arg1));
4112
+ return addHeapObject(ret);
4113
+ }, arguments) };
4114
+ imports.wbg.__wbindgen_is_object = function(arg0) {
4115
+ const val = getObject(arg0);
4116
+ const ret = typeof(val) === 'object' && val !== null;
4117
+ return ret;
4118
+ };
4119
+ imports.wbg.__wbg_next_40fc327bfc8770e6 = function(arg0) {
4120
+ const ret = getObject(arg0).next;
4121
+ return addHeapObject(ret);
4122
+ };
4123
+ imports.wbg.__wbg_next_196c84450b364254 = function() { return handleError(function (arg0) {
4124
+ const ret = getObject(arg0).next();
4125
+ return addHeapObject(ret);
4126
+ }, arguments) };
4127
+ imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) {
4128
+ const ret = getObject(arg0).done;
4129
+ return ret;
4130
+ };
4131
+ imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) {
4132
+ const ret = getObject(arg0).value;
4133
+ return addHeapObject(ret);
4134
+ };
4135
+ imports.wbg.__wbg_abort_2aa7521d5690750e = function(arg0) {
4136
+ getObject(arg0).abort();
4137
+ };
4138
+ imports.wbg.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
4139
+ const ret = JSON.stringify(getObject(arg0));
4140
+ return addHeapObject(ret);
4141
+ }, arguments) };
4142
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
4143
+ const obj = getObject(arg1);
4144
+ const ret = typeof(obj) === 'string' ? obj : undefined;
4145
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4146
+ var len1 = WASM_VECTOR_LEN;
4147
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4148
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4149
+ };
4150
+ imports.wbg.__wbg_log_9388602cb1684929 = function(arg0, arg1) {
4151
+ console.log(getStringFromWasm0(arg0, arg1));
4152
+ };
4153
+ imports.wbg.__wbg_newwithlength_66ae46612e7f0234 = function(arg0) {
4154
+ const ret = new Array(arg0 >>> 0);
4155
+ return addHeapObject(ret);
4156
+ };
4157
+ imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
4158
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
4159
+ };
4160
+ imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {
4161
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
4162
+ return addHeapObject(ret);
4163
+ }, arguments) };
4164
+ imports.wbg.__wbg_transaction_new = function(arg0) {
4165
+ const ret = Transaction.__wrap(arg0);
4166
+ return addHeapObject(ret);
4167
+ };
4168
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
4169
+ const ret = BigInt.asUintN(64, arg0);
4170
+ return addHeapObject(ret);
4171
+ };
4172
+ imports.wbg.__wbg_keypair_new = function(arg0) {
4173
+ const ret = KeyPair.__wrap(arg0);
4174
+ return addHeapObject(ret);
4175
+ };
4176
+ imports.wbg.__wbg_executionresponse_new = function(arg0) {
4177
+ const ret = ExecutionResponse.__wrap(arg0);
4178
+ return addHeapObject(ret);
4179
+ };
4180
+ imports.wbg.__wbindgen_module = function() {
4181
+ const ret = __wbg_init.__wbindgen_wasm_module;
4182
+ return addHeapObject(ret);
4183
+ };
4184
+ imports.wbg.__wbindgen_memory = function() {
4185
+ const ret = wasm.memory;
4186
+ return addHeapObject(ret);
4187
+ };
4188
+ imports.wbg.__wbg_spawnWorker_df78bbd4c32ac5b6 = function(arg0, arg1, arg2, arg3) {
4189
+ const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
4190
+ return addHeapObject(ret);
4191
+ };
4192
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
4193
+ const obj = takeObject(arg0).original;
4194
+ if (obj.cnt-- == 1) {
4195
+ obj.a = 0;
4196
+ return true;
4197
+ }
4198
+ const ret = false;
4199
+ return ret;
4200
+ };
4201
+ imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
4202
+ const ret = new Array();
4203
+ return addHeapObject(ret);
4204
+ };
4205
+ imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) {
4206
+ const ret = getObject(arg0).push(getObject(arg1));
4207
+ return ret;
4208
+ };
4209
+ imports.wbg.__wbg_arrayBuffer_29931d52c7206b02 = function() { return handleError(function (arg0) {
4210
+ const ret = getObject(arg0).arrayBuffer();
4211
+ return addHeapObject(ret);
4212
+ }, arguments) };
4213
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
4214
+ const ret = new Uint8Array(getObject(arg0));
4215
+ return addHeapObject(ret);
4216
+ };
4217
+ imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
4218
+ const ret = getObject(arg0).length;
4219
+ return ret;
4220
+ };
4221
+ imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) {
4222
+ try {
4223
+ var state0 = {a: arg0, b: arg1};
4224
+ var cb0 = (arg0, arg1) => {
4225
+ const a = state0.a;
4226
+ state0.a = 0;
4227
+ try {
4228
+ return __wbg_adapter_281(a, state0.b, arg0, arg1);
4229
+ } finally {
4230
+ state0.a = a;
4231
+ }
4232
+ };
4233
+ const ret = new Promise(cb0);
4234
+ return addHeapObject(ret);
4235
+ } finally {
4236
+ state0.a = state0.b = 0;
4237
+ }
4238
+ };
4239
+ imports.wbg.__wbindgen_number_new = function(arg0) {
4240
+ const ret = arg0;
4241
+ return addHeapObject(ret);
4242
+ };
4243
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
4244
+ const ret = new Error();
4245
+ return addHeapObject(ret);
4246
+ };
4247
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
4248
+ const ret = getObject(arg1).stack;
4249
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4250
+ const len1 = WASM_VECTOR_LEN;
4251
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4252
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4253
+ };
4254
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
4255
+ let deferred0_0;
4256
+ let deferred0_1;
4257
+ try {
4258
+ deferred0_0 = arg0;
4259
+ deferred0_1 = arg1;
4260
+ console.error(getStringFromWasm0(arg0, arg1));
4261
+ } finally {
4262
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
4263
+ }
4264
+ };
4265
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
4266
+ const ret = getObject(arg0).buffer;
4267
+ return addHeapObject(ret);
4268
+ };
4269
+ imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
4270
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
4271
+ return addHeapObject(ret);
4272
+ };
4273
+ imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {
4274
+ getObject(arg0).randomFillSync(takeObject(arg1));
4275
+ }, arguments) };
4276
+ imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {
4277
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
4278
+ return addHeapObject(ret);
4279
+ };
4280
+ imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
4281
+ getObject(arg0).getRandomValues(getObject(arg1));
4282
+ }, arguments) };
4283
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
4284
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4285
+ };
4286
+ imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
4287
+ const ret = getObject(arg0).crypto;
4288
+ return addHeapObject(ret);
4289
+ };
4290
+ imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) {
4291
+ const ret = getObject(arg0).process;
4292
+ return addHeapObject(ret);
4293
+ };
4294
+ imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) {
4295
+ const ret = getObject(arg0).versions;
4296
+ return addHeapObject(ret);
4297
+ };
4298
+ imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {
4299
+ const ret = getObject(arg0).node;
4300
+ return addHeapObject(ret);
4301
+ };
4302
+ imports.wbg.__wbindgen_is_string = function(arg0) {
4303
+ const ret = typeof(getObject(arg0)) === 'string';
4304
+ return ret;
4305
+ };
4306
+ imports.wbg.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () {
4307
+ const ret = module.require;
4308
+ return addHeapObject(ret);
4309
+ }, arguments) };
4310
+ imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
4311
+ const ret = getObject(arg0).msCrypto;
4312
+ return addHeapObject(ret);
4313
+ };
4314
+ imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {
4315
+ const ret = new Uint8Array(arg0 >>> 0);
4316
+ return addHeapObject(ret);
4317
+ };
4318
+ imports.wbg.__wbg_length_cd7af8117672b8b8 = function(arg0) {
4319
+ const ret = getObject(arg0).length;
4320
+ return ret;
4321
+ };
4322
+ imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {
4323
+ const ret = getObject(arg0)[arg1 >>> 0];
4324
+ return addHeapObject(ret);
4325
+ };
4326
+ imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {
4327
+ const ret = self.self;
4328
+ return addHeapObject(ret);
4329
+ }, arguments) };
4330
+ imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {
4331
+ const ret = window.window;
4332
+ return addHeapObject(ret);
4333
+ }, arguments) };
4334
+ imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {
4335
+ const ret = globalThis.globalThis;
4336
+ return addHeapObject(ret);
4337
+ }, arguments) };
4338
+ imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () {
4339
+ const ret = global.global;
4340
+ return addHeapObject(ret);
4341
+ }, arguments) };
4342
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
4343
+ const ret = getObject(arg0) === undefined;
4344
+ return ret;
4345
+ };
4346
+ imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
4347
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
4348
+ return addHeapObject(ret);
4349
+ };
4350
+ imports.wbg.__wbg_has_0af94d20077affa2 = function() { return handleError(function (arg0, arg1) {
4351
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
4352
+ return ret;
4353
+ }, arguments) };
4354
+ imports.wbg.__wbg_fetch_bc7c8e27076a5c84 = function(arg0) {
4355
+ const ret = fetch(getObject(arg0));
4356
+ return addHeapObject(ret);
4357
+ };
4358
+ imports.wbg.__wbg_fetch_921fad6ef9e883dd = function(arg0, arg1) {
4359
+ const ret = getObject(arg0).fetch(getObject(arg1));
4360
+ return addHeapObject(ret);
4361
+ };
4362
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
4363
+ const ret = debugString(getObject(arg1));
4364
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4365
+ const len1 = WASM_VECTOR_LEN;
4366
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4367
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4368
+ };
4369
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
4370
+ throw new Error(getStringFromWasm0(arg0, arg1));
4371
+ };
4372
+ imports.wbg.__wbindgen_rethrow = function(arg0) {
4373
+ throw takeObject(arg0);
4374
+ };
4375
+ imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) {
4376
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
4377
+ return addHeapObject(ret);
4378
+ };
4379
+ imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) {
4380
+ const ret = getObject(arg0).then(getObject(arg1));
4381
+ return addHeapObject(ret);
4382
+ };
4383
+ imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) {
4384
+ queueMicrotask(getObject(arg0));
4385
+ };
4386
+ imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) {
4387
+ const ret = getObject(arg0).queueMicrotask;
4388
+ return addHeapObject(ret);
4389
+ };
4390
+ imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) {
4391
+ const ret = Promise.resolve(getObject(arg0));
4392
+ return addHeapObject(ret);
4393
+ };
4394
+ imports.wbg.__wbg_waitAsync_5d743fc9058ba01a = function() {
4395
+ const ret = Atomics.waitAsync;
4396
+ return addHeapObject(ret);
4397
+ };
4398
+ imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) {
4399
+ const ret = new Int32Array(getObject(arg0));
4400
+ return addHeapObject(ret);
4401
+ };
4402
+ imports.wbg.__wbg_waitAsync_46d5c36955b71a79 = function(arg0, arg1, arg2) {
4403
+ const ret = Atomics.waitAsync(getObject(arg0), arg1, arg2);
4404
+ return addHeapObject(ret);
4405
+ };
4406
+ imports.wbg.__wbg_async_19c0400d97cc72fe = function(arg0) {
4407
+ const ret = getObject(arg0).async;
4408
+ return ret;
4409
+ };
4410
+ imports.wbg.__wbg_value_571d60108110e917 = function(arg0) {
4411
+ const ret = getObject(arg0).value;
4412
+ return addHeapObject(ret);
4413
+ };
4414
+ imports.wbg.__wbindgen_link_fc1eedd35dc7e0a6 = function(arg0) {
4415
+ const ret = "data:application/javascript," + encodeURIComponent(`onmessage = function (ev) {
4416
+ let [ia, index, value] = ev.data;
4417
+ ia = new Int32Array(ia.buffer);
4418
+ let result = Atomics.wait(ia, index, value);
4419
+ postMessage(result);
4420
+ };
4421
+ `);
4422
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4423
+ const len1 = WASM_VECTOR_LEN;
4424
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4425
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4426
+ };
4427
+ imports.wbg.__wbg_new_d1187ae36d662ef9 = function() { return handleError(function (arg0, arg1) {
4428
+ const ret = new Worker(getStringFromWasm0(arg0, arg1));
4429
+ return addHeapObject(ret);
4430
+ }, arguments) };
4431
+ imports.wbg.__wbg_setonmessage_503809e5bb51bd33 = function(arg0, arg1) {
4432
+ getObject(arg0).onmessage = getObject(arg1);
4433
+ };
4434
+ imports.wbg.__wbg_of_6a70eed8d41f469c = function(arg0, arg1, arg2) {
4435
+ const ret = Array.of(getObject(arg0), getObject(arg1), getObject(arg2));
4436
+ return addHeapObject(ret);
4437
+ };
4438
+ imports.wbg.__wbg_postMessage_7380d10e8b8269df = function() { return handleError(function (arg0, arg1) {
4439
+ getObject(arg0).postMessage(getObject(arg1));
4440
+ }, arguments) };
4441
+ imports.wbg.__wbg_data_3ce7c145ca4fbcdc = function(arg0) {
4442
+ const ret = getObject(arg0).data;
4443
+ return addHeapObject(ret);
4444
+ };
4445
+ imports.wbg.__wbg_newwithstrandinit_3fd6fba4083ff2d0 = function() { return handleError(function (arg0, arg1, arg2) {
4446
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
4447
+ return addHeapObject(ret);
4448
+ }, arguments) };
4449
+ imports.wbg.__wbg_responseText_c67ed2d48db10769 = function() { return handleError(function (arg0, arg1) {
4450
+ const ret = getObject(arg1).responseText;
4451
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4452
+ var len1 = WASM_VECTOR_LEN;
4453
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4454
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4455
+ }, arguments) };
4456
+ imports.wbg.__wbindgen_closure_wrapper5975 = function(arg0, arg1, arg2) {
4457
+ const ret = makeMutClosure(arg0, arg1, 622, __wbg_adapter_34);
4458
+ return addHeapObject(ret);
4459
+ };
4460
+ imports.wbg.__wbindgen_closure_wrapper6001 = function(arg0, arg1, arg2) {
4461
+ const ret = makeMutClosure(arg0, arg1, 622, __wbg_adapter_34);
4462
+ return addHeapObject(ret);
4463
+ };
4464
+
4465
+ return imports;
4466
+ }
4467
+
4468
+ function __wbg_init_memory(imports, maybe_memory) {
4469
+ imports.wbg.memory = maybe_memory || new WebAssembly.Memory({initial:25,maximum:65536,shared:true});
4470
+ }
4471
+
4472
+ function __wbg_finalize_init(instance, module) {
4473
+ wasm = instance.exports;
4474
+ __wbg_init.__wbindgen_wasm_module = module;
4475
+ cachedBigInt64Memory0 = null;
4476
+ cachedInt32Memory0 = null;
4477
+ cachedUint8Memory0 = null;
4478
+
4479
+ wasm.__wbindgen_start();
4480
+ return wasm;
4481
+ }
4482
+
4483
+ function initSync(module, maybe_memory) {
4484
+ if (wasm !== undefined) return wasm;
4485
+
4486
+ const imports = __wbg_get_imports();
4487
+
4488
+ __wbg_init_memory(imports, maybe_memory);
4489
+
4490
+ if (!(module instanceof WebAssembly.Module)) {
4491
+ module = new WebAssembly.Module(module);
4492
+ }
4493
+
4494
+ const instance = new WebAssembly.Instance(module, imports);
4495
+
4496
+ return __wbg_finalize_init(instance, module);
4497
+ }
4498
+
4499
+ async function __wbg_init(input, maybe_memory) {
4500
+ if (wasm !== undefined) return wasm;
4501
+
4502
+
4503
+ const imports = __wbg_get_imports();
4504
+
4505
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
4506
+ input = fetch(input);
4507
+ }
4508
+
4509
+ __wbg_init_memory(imports, maybe_memory);
4510
+
4511
+ const { instance, module } = await __wbg_load(await input, imports);
4512
+
4513
+ return __wbg_finalize_init(instance, module);
4514
+ }
4515
+
4516
+ var exports = /*#__PURE__*/Object.freeze({
4517
+ __proto__: null,
4518
+ Address: Address,
4519
+ Execution: Execution,
4520
+ ExecutionResponse: ExecutionResponse,
4521
+ Field: Field,
4522
+ KeyPair: KeyPair,
4523
+ Metadata: Metadata,
4524
+ OfflineQuery: OfflineQuery,
4525
+ PrivateKey: PrivateKey,
4526
+ PrivateKeyCiphertext: PrivateKeyCiphertext,
4527
+ Program: Program,
4528
+ ProgramManager: ProgramManager,
4529
+ ProvingKey: ProvingKey,
4530
+ RecordCiphertext: RecordCiphertext,
4531
+ RecordPlaintext: RecordPlaintext,
4532
+ Signature: Signature,
4533
+ Transaction: Transaction,
4534
+ VerifyingKey: VerifyingKey,
4535
+ ViewKey: ViewKey,
4536
+ default: __wbg_init,
4537
+ initSync: initSync,
4538
+ initThreadPool: initThreadPool,
4539
+ runRayonThread: runRayonThread,
4540
+ verifyFunctionExecution: verifyFunctionExecution
4541
+ });
4542
+
4543
+ const wasm_path = "aleo_wasm.wasm";
4544
+
4545
+
4546
+ var Cargo = async (opt = {}) => {
4547
+ let {importHook, serverPath, initializeHook} = opt;
4548
+
4549
+ let final_path = wasm_path;
4550
+
4551
+ if (serverPath != null) {
4552
+ final_path = serverPath + /[^\/\\]*$/.exec(final_path)[0];
4553
+ }
4554
+
4555
+ if (importHook != null) {
4556
+ final_path = importHook(final_path);
4557
+ }
4558
+
4559
+ if (initializeHook != null) {
4560
+ await initializeHook(__wbg_init, final_path);
4561
+
4562
+ } else {
4563
+ await __wbg_init(final_path);
4564
+ }
4565
+
4566
+ return exports;
4567
+ };
4568
+
4569
+ export { Cargo as default };
4570
+ //# sourceMappingURL=aleo_wasm.js.map