@provablehq/wasm 0.6.13 → 0.7.1

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,4578 @@
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__h1503081f6025e61c(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_282(arg0, arg1, arg2, arg3) {
332
+ wasm.wasm_bindgen__convert__closures__invoke2_mut__hc5c49be524f0cde8(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 {number} block_height
1110
+ * @param {string} state_root
1111
+ */
1112
+ constructor(block_height, state_root) {
1113
+ try {
1114
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1115
+ const ptr0 = passStringToWasm0(state_root, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1116
+ const len0 = WASM_VECTOR_LEN;
1117
+ wasm.offlinequery_new(retptr, block_height, ptr0, len0);
1118
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1119
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1120
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1121
+ if (r2) {
1122
+ throw takeObject(r1);
1123
+ }
1124
+ this.__wbg_ptr = r0 >>> 0;
1125
+ return this;
1126
+ } finally {
1127
+ wasm.__wbindgen_add_to_stack_pointer(16);
1128
+ }
1129
+ }
1130
+ /**
1131
+ * Add a new block height to the offline query object.
1132
+ * @param {number} block_height
1133
+ */
1134
+ addBlockHeight(block_height) {
1135
+ wasm.offlinequery_addBlockHeight(this.__wbg_ptr, block_height);
1136
+ }
1137
+ /**
1138
+ * Add a new state path to the offline query object.
1139
+ *
1140
+ * @param {string} commitment: The commitment corresponding to a record inpout
1141
+ * @param {string} state_path: The state path corresponding to the commitment
1142
+ * @param {string} commitment
1143
+ * @param {string} state_path
1144
+ */
1145
+ addStatePath(commitment, state_path) {
1146
+ try {
1147
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1148
+ const ptr0 = passStringToWasm0(commitment, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1149
+ const len0 = WASM_VECTOR_LEN;
1150
+ const ptr1 = passStringToWasm0(state_path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1151
+ const len1 = WASM_VECTOR_LEN;
1152
+ wasm.offlinequery_addStatePath(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
1153
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1154
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1155
+ if (r1) {
1156
+ throw takeObject(r0);
1157
+ }
1158
+ } finally {
1159
+ wasm.__wbindgen_add_to_stack_pointer(16);
1160
+ }
1161
+ }
1162
+ /**
1163
+ * Get a json string representation of the offline query object
1164
+ * @returns {string}
1165
+ */
1166
+ toString() {
1167
+ let deferred1_0;
1168
+ let deferred1_1;
1169
+ try {
1170
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1171
+ wasm.offlinequery_toString(retptr, this.__wbg_ptr);
1172
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1173
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1174
+ deferred1_0 = r0;
1175
+ deferred1_1 = r1;
1176
+ return getStringFromWasm0(r0, r1);
1177
+ } finally {
1178
+ wasm.__wbindgen_add_to_stack_pointer(16);
1179
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1180
+ }
1181
+ }
1182
+ /**
1183
+ * Create an offline query object from a json string representation
1184
+ * @param {string} s
1185
+ * @returns {OfflineQuery}
1186
+ */
1187
+ static fromString(s) {
1188
+ try {
1189
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1190
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1191
+ const len0 = WASM_VECTOR_LEN;
1192
+ wasm.offlinequery_fromString(retptr, ptr0, len0);
1193
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1194
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1195
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1196
+ if (r2) {
1197
+ throw takeObject(r1);
1198
+ }
1199
+ return OfflineQuery.__wrap(r0);
1200
+ } finally {
1201
+ wasm.__wbindgen_add_to_stack_pointer(16);
1202
+ }
1203
+ }
1204
+ }
1205
+
1206
+ const PrivateKeyFinalization = (typeof FinalizationRegistry === 'undefined')
1207
+ ? { register: () => {}, unregister: () => {} }
1208
+ : new FinalizationRegistry(ptr => wasm.__wbg_privatekey_free(ptr >>> 0));
1209
+ /**
1210
+ * Private key of an Aleo account
1211
+ */
1212
+ class PrivateKey {
1213
+
1214
+ static __wrap(ptr) {
1215
+ ptr = ptr >>> 0;
1216
+ const obj = Object.create(PrivateKey.prototype);
1217
+ obj.__wbg_ptr = ptr;
1218
+ PrivateKeyFinalization.register(obj, obj.__wbg_ptr, obj);
1219
+ return obj;
1220
+ }
1221
+
1222
+ __destroy_into_raw() {
1223
+ const ptr = this.__wbg_ptr;
1224
+ this.__wbg_ptr = 0;
1225
+ PrivateKeyFinalization.unregister(this);
1226
+ return ptr;
1227
+ }
1228
+
1229
+ free() {
1230
+ const ptr = this.__destroy_into_raw();
1231
+ wasm.__wbg_privatekey_free(ptr);
1232
+ }
1233
+ /**
1234
+ * Generate a new private key using a cryptographically secure random number generator
1235
+ *
1236
+ * @returns {PrivateKey}
1237
+ */
1238
+ constructor() {
1239
+ const ret = wasm.privatekey_new();
1240
+ this.__wbg_ptr = ret >>> 0;
1241
+ return this;
1242
+ }
1243
+ /**
1244
+ * Get a private key from a series of unchecked bytes
1245
+ *
1246
+ * @param {Uint8Array} seed Unchecked 32 byte long Uint8Array acting as the seed for the private key
1247
+ * @returns {PrivateKey}
1248
+ * @param {Uint8Array} seed
1249
+ * @returns {PrivateKey}
1250
+ */
1251
+ static from_seed_unchecked(seed) {
1252
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
1253
+ const len0 = WASM_VECTOR_LEN;
1254
+ const ret = wasm.privatekey_from_seed_unchecked(ptr0, len0);
1255
+ return PrivateKey.__wrap(ret);
1256
+ }
1257
+ /**
1258
+ * Get a private key from a string representation of a private key
1259
+ *
1260
+ * @param {string} seed String representation of a private key
1261
+ * @returns {PrivateKey}
1262
+ * @param {string} private_key
1263
+ * @returns {PrivateKey}
1264
+ */
1265
+ static from_string(private_key) {
1266
+ try {
1267
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1268
+ const ptr0 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1269
+ const len0 = WASM_VECTOR_LEN;
1270
+ wasm.privatekey_from_string(retptr, ptr0, len0);
1271
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1272
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1273
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1274
+ if (r2) {
1275
+ throw takeObject(r1);
1276
+ }
1277
+ return PrivateKey.__wrap(r0);
1278
+ } finally {
1279
+ wasm.__wbindgen_add_to_stack_pointer(16);
1280
+ }
1281
+ }
1282
+ /**
1283
+ * Get a string representation of the private key. This function should be used very carefully
1284
+ * as it exposes the private key plaintext
1285
+ *
1286
+ * @returns {string} String representation of a private key
1287
+ * @returns {string}
1288
+ */
1289
+ to_string() {
1290
+ let deferred1_0;
1291
+ let deferred1_1;
1292
+ try {
1293
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1294
+ wasm.privatekey_to_string(retptr, this.__wbg_ptr);
1295
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1296
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1297
+ deferred1_0 = r0;
1298
+ deferred1_1 = r1;
1299
+ return getStringFromWasm0(r0, r1);
1300
+ } finally {
1301
+ wasm.__wbindgen_add_to_stack_pointer(16);
1302
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1303
+ }
1304
+ }
1305
+ /**
1306
+ * Get the view key corresponding to the private key
1307
+ *
1308
+ * @returns {ViewKey}
1309
+ * @returns {ViewKey}
1310
+ */
1311
+ to_view_key() {
1312
+ const ret = wasm.privatekey_to_view_key(this.__wbg_ptr);
1313
+ return ViewKey.__wrap(ret);
1314
+ }
1315
+ /**
1316
+ * Get the address corresponding to the private key
1317
+ *
1318
+ * @returns {Address}
1319
+ * @returns {Address}
1320
+ */
1321
+ to_address() {
1322
+ const ret = wasm.privatekey_to_address(this.__wbg_ptr);
1323
+ return Address.__wrap(ret);
1324
+ }
1325
+ /**
1326
+ * Sign a message with the private key
1327
+ *
1328
+ * @param {Uint8Array} Byte array representing a message signed by the address
1329
+ * @returns {Signature} Signature generated by signing the message with the address
1330
+ * @param {Uint8Array} message
1331
+ * @returns {Signature}
1332
+ */
1333
+ sign(message) {
1334
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
1335
+ const len0 = WASM_VECTOR_LEN;
1336
+ const ret = wasm.privatekey_sign(this.__wbg_ptr, ptr0, len0);
1337
+ return Signature.__wrap(ret);
1338
+ }
1339
+ /**
1340
+ * Get a new randomly generated private key ciphertext using a secret. The secret is sensitive
1341
+ * and will be needed to decrypt the private key later, so it should be stored securely
1342
+ *
1343
+ * @param {string} secret Secret used to encrypt the private key
1344
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
1345
+ * @param {string} secret
1346
+ * @returns {PrivateKeyCiphertext}
1347
+ */
1348
+ static newEncrypted(secret) {
1349
+ try {
1350
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1351
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1352
+ const len0 = WASM_VECTOR_LEN;
1353
+ wasm.privatekey_newEncrypted(retptr, ptr0, len0);
1354
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1355
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1356
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1357
+ if (r2) {
1358
+ throw takeObject(r1);
1359
+ }
1360
+ return PrivateKeyCiphertext.__wrap(r0);
1361
+ } finally {
1362
+ wasm.__wbindgen_add_to_stack_pointer(16);
1363
+ }
1364
+ }
1365
+ /**
1366
+ * Encrypt an existing private key with a secret. The secret is sensitive and will be needed to
1367
+ * decrypt the private key later, so it should be stored securely
1368
+ *
1369
+ * @param {string} secret Secret used to encrypt the private key
1370
+ * @returns {PrivateKeyCiphertext} Ciphertext representation of the private key
1371
+ * @param {string} secret
1372
+ * @returns {PrivateKeyCiphertext}
1373
+ */
1374
+ toCiphertext(secret) {
1375
+ try {
1376
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1377
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1378
+ const len0 = WASM_VECTOR_LEN;
1379
+ wasm.privatekey_toCiphertext(retptr, this.__wbg_ptr, ptr0, len0);
1380
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1381
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1382
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1383
+ if (r2) {
1384
+ throw takeObject(r1);
1385
+ }
1386
+ return PrivateKeyCiphertext.__wrap(r0);
1387
+ } finally {
1388
+ wasm.__wbindgen_add_to_stack_pointer(16);
1389
+ }
1390
+ }
1391
+ /**
1392
+ * Get private key from a private key ciphertext and secret originally used to encrypt it
1393
+ *
1394
+ * @param {PrivateKeyCiphertext} ciphertext Ciphertext representation of the private key
1395
+ * @param {string} secret Secret originally used to encrypt the private key
1396
+ * @returns {PrivateKey} Private key
1397
+ * @param {PrivateKeyCiphertext} ciphertext
1398
+ * @param {string} secret
1399
+ * @returns {PrivateKey}
1400
+ */
1401
+ static fromPrivateKeyCiphertext(ciphertext, secret) {
1402
+ try {
1403
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1404
+ _assertClass(ciphertext, PrivateKeyCiphertext);
1405
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1406
+ const len0 = WASM_VECTOR_LEN;
1407
+ wasm.privatekey_fromPrivateKeyCiphertext(retptr, ciphertext.__wbg_ptr, ptr0, len0);
1408
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1409
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1410
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1411
+ if (r2) {
1412
+ throw takeObject(r1);
1413
+ }
1414
+ return PrivateKey.__wrap(r0);
1415
+ } finally {
1416
+ wasm.__wbindgen_add_to_stack_pointer(16);
1417
+ }
1418
+ }
1419
+ }
1420
+
1421
+ const PrivateKeyCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
1422
+ ? { register: () => {}, unregister: () => {} }
1423
+ : new FinalizationRegistry(ptr => wasm.__wbg_privatekeyciphertext_free(ptr >>> 0));
1424
+ /**
1425
+ * Private Key in ciphertext form
1426
+ */
1427
+ class PrivateKeyCiphertext {
1428
+
1429
+ static __wrap(ptr) {
1430
+ ptr = ptr >>> 0;
1431
+ const obj = Object.create(PrivateKeyCiphertext.prototype);
1432
+ obj.__wbg_ptr = ptr;
1433
+ PrivateKeyCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
1434
+ return obj;
1435
+ }
1436
+
1437
+ __destroy_into_raw() {
1438
+ const ptr = this.__wbg_ptr;
1439
+ this.__wbg_ptr = 0;
1440
+ PrivateKeyCiphertextFinalization.unregister(this);
1441
+ return ptr;
1442
+ }
1443
+
1444
+ free() {
1445
+ const ptr = this.__destroy_into_raw();
1446
+ wasm.__wbg_privatekeyciphertext_free(ptr);
1447
+ }
1448
+ /**
1449
+ * Encrypt a private key using a secret string. The secret is sensitive and will be needed to
1450
+ * decrypt the private key later, so it should be stored securely
1451
+ *
1452
+ * @param {PrivateKey} private_key Private key to encrypt
1453
+ * @param {string} secret Secret to encrypt the private key with
1454
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
1455
+ * @param {PrivateKey} private_key
1456
+ * @param {string} secret
1457
+ * @returns {PrivateKeyCiphertext}
1458
+ */
1459
+ static encryptPrivateKey(private_key, secret) {
1460
+ try {
1461
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1462
+ _assertClass(private_key, PrivateKey);
1463
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1464
+ const len0 = WASM_VECTOR_LEN;
1465
+ wasm.privatekey_toCiphertext(retptr, private_key.__wbg_ptr, ptr0, len0);
1466
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1467
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1468
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1469
+ if (r2) {
1470
+ throw takeObject(r1);
1471
+ }
1472
+ return PrivateKeyCiphertext.__wrap(r0);
1473
+ } finally {
1474
+ wasm.__wbindgen_add_to_stack_pointer(16);
1475
+ }
1476
+ }
1477
+ /**
1478
+ * Decrypts a private ciphertext using a secret string. This must be the same secret used to
1479
+ * encrypt the private key
1480
+ *
1481
+ * @param {string} secret Secret used to encrypt the private key
1482
+ * @returns {PrivateKey} Private key
1483
+ * @param {string} secret
1484
+ * @returns {PrivateKey}
1485
+ */
1486
+ decryptToPrivateKey(secret) {
1487
+ try {
1488
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1489
+ const ptr0 = passStringToWasm0(secret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1490
+ const len0 = WASM_VECTOR_LEN;
1491
+ wasm.privatekeyciphertext_decryptToPrivateKey(retptr, this.__wbg_ptr, ptr0, len0);
1492
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1493
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1494
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1495
+ if (r2) {
1496
+ throw takeObject(r1);
1497
+ }
1498
+ return PrivateKey.__wrap(r0);
1499
+ } finally {
1500
+ wasm.__wbindgen_add_to_stack_pointer(16);
1501
+ }
1502
+ }
1503
+ /**
1504
+ * Returns the ciphertext string
1505
+ *
1506
+ * @returns {string} Ciphertext string
1507
+ * @returns {string}
1508
+ */
1509
+ toString() {
1510
+ let deferred1_0;
1511
+ let deferred1_1;
1512
+ try {
1513
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1514
+ wasm.privatekeyciphertext_toString(retptr, this.__wbg_ptr);
1515
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1516
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1517
+ deferred1_0 = r0;
1518
+ deferred1_1 = r1;
1519
+ return getStringFromWasm0(r0, r1);
1520
+ } finally {
1521
+ wasm.__wbindgen_add_to_stack_pointer(16);
1522
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1523
+ }
1524
+ }
1525
+ /**
1526
+ * Creates a PrivateKeyCiphertext from a string
1527
+ *
1528
+ * @param {string} ciphertext Ciphertext string
1529
+ * @returns {PrivateKeyCiphertext} Private key ciphertext
1530
+ * @param {string} ciphertext
1531
+ * @returns {PrivateKeyCiphertext}
1532
+ */
1533
+ static fromString(ciphertext) {
1534
+ try {
1535
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1536
+ const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1537
+ const len0 = WASM_VECTOR_LEN;
1538
+ wasm.privatekeyciphertext_fromString(retptr, ptr0, len0);
1539
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1540
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1541
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1542
+ if (r2) {
1543
+ throw takeObject(r1);
1544
+ }
1545
+ return PrivateKeyCiphertext.__wrap(r0);
1546
+ } finally {
1547
+ wasm.__wbindgen_add_to_stack_pointer(16);
1548
+ }
1549
+ }
1550
+ }
1551
+
1552
+ const ProgramFinalization = (typeof FinalizationRegistry === 'undefined')
1553
+ ? { register: () => {}, unregister: () => {} }
1554
+ : new FinalizationRegistry(ptr => wasm.__wbg_program_free(ptr >>> 0));
1555
+ /**
1556
+ * Webassembly Representation of an Aleo program
1557
+ */
1558
+ class Program {
1559
+
1560
+ static __wrap(ptr) {
1561
+ ptr = ptr >>> 0;
1562
+ const obj = Object.create(Program.prototype);
1563
+ obj.__wbg_ptr = ptr;
1564
+ ProgramFinalization.register(obj, obj.__wbg_ptr, obj);
1565
+ return obj;
1566
+ }
1567
+
1568
+ __destroy_into_raw() {
1569
+ const ptr = this.__wbg_ptr;
1570
+ this.__wbg_ptr = 0;
1571
+ ProgramFinalization.unregister(this);
1572
+ return ptr;
1573
+ }
1574
+
1575
+ free() {
1576
+ const ptr = this.__destroy_into_raw();
1577
+ wasm.__wbg_program_free(ptr);
1578
+ }
1579
+ /**
1580
+ * Create a program from a program string
1581
+ *
1582
+ * @param {string} program Aleo program source code
1583
+ * @returns {Program} Program object
1584
+ * @param {string} program
1585
+ * @returns {Program}
1586
+ */
1587
+ static fromString(program) {
1588
+ try {
1589
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1590
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1591
+ const len0 = WASM_VECTOR_LEN;
1592
+ wasm.program_fromString(retptr, ptr0, len0);
1593
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1594
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1595
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1596
+ if (r2) {
1597
+ throw takeObject(r1);
1598
+ }
1599
+ return Program.__wrap(r0);
1600
+ } finally {
1601
+ wasm.__wbindgen_add_to_stack_pointer(16);
1602
+ }
1603
+ }
1604
+ /**
1605
+ * Get a string representation of the program
1606
+ *
1607
+ * @returns {string} String containing the program source code
1608
+ * @returns {string}
1609
+ */
1610
+ toString() {
1611
+ let deferred1_0;
1612
+ let deferred1_1;
1613
+ try {
1614
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1615
+ wasm.program_toString(retptr, this.__wbg_ptr);
1616
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1617
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1618
+ deferred1_0 = r0;
1619
+ deferred1_1 = r1;
1620
+ return getStringFromWasm0(r0, r1);
1621
+ } finally {
1622
+ wasm.__wbindgen_add_to_stack_pointer(16);
1623
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1624
+ }
1625
+ }
1626
+ /**
1627
+ * Determine if a function is present in the program
1628
+ *
1629
+ * @param {string} functionName Name of the function to check for
1630
+ * @returns {boolean} True if the program is valid, false otherwise
1631
+ * @param {string} function_name
1632
+ * @returns {boolean}
1633
+ */
1634
+ hasFunction(function_name) {
1635
+ const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1636
+ const len0 = WASM_VECTOR_LEN;
1637
+ const ret = wasm.program_hasFunction(this.__wbg_ptr, ptr0, len0);
1638
+ return ret !== 0;
1639
+ }
1640
+ /**
1641
+ * Get javascript array of functions names in the program
1642
+ *
1643
+ * @returns {Array} Array of all function names present in the program
1644
+ *
1645
+ * @example
1646
+ * const expected_functions = [
1647
+ * "mint",
1648
+ * "transfer_private",
1649
+ * "transfer_private_to_public",
1650
+ * "transfer_public",
1651
+ * "transfer_public_to_private",
1652
+ * "join",
1653
+ * "split",
1654
+ * "fee"
1655
+ * ]
1656
+ *
1657
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1658
+ * const credits_functions = credits_program.getFunctions();
1659
+ * console.log(credits_functions === expected_functions); // Output should be "true"
1660
+ * @returns {Array<any>}
1661
+ */
1662
+ getFunctions() {
1663
+ const ret = wasm.program_getFunctions(this.__wbg_ptr);
1664
+ return takeObject(ret);
1665
+ }
1666
+ /**
1667
+ * Get a javascript object representation of the function inputs and types. This can be used
1668
+ * to generate a web form to capture user inputs for an execution of a function.
1669
+ *
1670
+ * @param {string} function_name Name of the function to get inputs for
1671
+ * @returns {Array} Array of function inputs
1672
+ *
1673
+ * @example
1674
+ * const expected_inputs = [
1675
+ * {
1676
+ * type:"record",
1677
+ * visibility:"private",
1678
+ * record:"credits",
1679
+ * members:[
1680
+ * {
1681
+ * name:"microcredits",
1682
+ * type:"u64",
1683
+ * visibility:"private"
1684
+ * }
1685
+ * ],
1686
+ * register:"r0"
1687
+ * },
1688
+ * {
1689
+ * type:"address",
1690
+ * visibility:"private",
1691
+ * register:"r1"
1692
+ * },
1693
+ * {
1694
+ * type:"u64",
1695
+ * visibility:"private",
1696
+ * register:"r2"
1697
+ * }
1698
+ * ];
1699
+ *
1700
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1701
+ * const transfer_function_inputs = credits_program.getFunctionInputs("transfer_private");
1702
+ * console.log(transfer_function_inputs === expected_inputs); // Output should be "true"
1703
+ * @param {string} function_name
1704
+ * @returns {Array<any>}
1705
+ */
1706
+ getFunctionInputs(function_name) {
1707
+ try {
1708
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1709
+ const ptr0 = passStringToWasm0(function_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1710
+ const len0 = WASM_VECTOR_LEN;
1711
+ wasm.program_getFunctionInputs(retptr, this.__wbg_ptr, ptr0, len0);
1712
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1713
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1714
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1715
+ if (r2) {
1716
+ throw takeObject(r1);
1717
+ }
1718
+ return takeObject(r0);
1719
+ } finally {
1720
+ wasm.__wbindgen_add_to_stack_pointer(16);
1721
+ }
1722
+ }
1723
+ /**
1724
+ * Get a the list of a program's mappings and the names/types of their keys and values.
1725
+ *
1726
+ * @returns {Array} - An array of objects representing the mappings in the program
1727
+ * @example
1728
+ * const expected_mappings = [
1729
+ * {
1730
+ * name: "account",
1731
+ * key_name: "owner",
1732
+ * key_type: "address",
1733
+ * value_name: "microcredits",
1734
+ * value_type: "u64"
1735
+ * }
1736
+ * ]
1737
+ *
1738
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1739
+ * const credits_mappings = credits_program.getMappings();
1740
+ * console.log(credits_mappings === expected_mappings); // Output should be "true"
1741
+ * @returns {Array<any>}
1742
+ */
1743
+ getMappings() {
1744
+ try {
1745
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1746
+ wasm.program_getMappings(retptr, this.__wbg_ptr);
1747
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1748
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1749
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1750
+ if (r2) {
1751
+ throw takeObject(r1);
1752
+ }
1753
+ return takeObject(r0);
1754
+ } finally {
1755
+ wasm.__wbindgen_add_to_stack_pointer(16);
1756
+ }
1757
+ }
1758
+ /**
1759
+ * Get a javascript object representation of a program record and its types
1760
+ *
1761
+ * @param {string} record_name Name of the record to get members for
1762
+ * @returns {Object} Object containing the record name, type, and members
1763
+ *
1764
+ * @example
1765
+ *
1766
+ * const expected_record = {
1767
+ * type: "record",
1768
+ * record: "Credits",
1769
+ * members: [
1770
+ * {
1771
+ * name: "owner",
1772
+ * type: "address",
1773
+ * visibility: "private"
1774
+ * },
1775
+ * {
1776
+ * name: "microcredits",
1777
+ * type: "u64",
1778
+ * visibility: "private"
1779
+ * }
1780
+ * ];
1781
+ * };
1782
+ *
1783
+ * const credits_program = aleo_wasm.Program.getCreditsProgram();
1784
+ * const credits_record = credits_program.getRecordMembers("Credits");
1785
+ * console.log(credits_record === expected_record); // Output should be "true"
1786
+ * @param {string} record_name
1787
+ * @returns {object}
1788
+ */
1789
+ getRecordMembers(record_name) {
1790
+ try {
1791
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1792
+ const ptr0 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1793
+ const len0 = WASM_VECTOR_LEN;
1794
+ wasm.program_getRecordMembers(retptr, this.__wbg_ptr, ptr0, len0);
1795
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1796
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1797
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1798
+ if (r2) {
1799
+ throw takeObject(r1);
1800
+ }
1801
+ return takeObject(r0);
1802
+ } finally {
1803
+ wasm.__wbindgen_add_to_stack_pointer(16);
1804
+ }
1805
+ }
1806
+ /**
1807
+ * Get a javascript object representation of a program struct and its types
1808
+ *
1809
+ * @param {string} struct_name Name of the struct to get members for
1810
+ * @returns {Array} Array containing the struct members
1811
+ *
1812
+ * @example
1813
+ *
1814
+ * const STRUCT_PROGRAM = "program token_issue.aleo;
1815
+ *
1816
+ * struct token_metadata:
1817
+ * network as u32;
1818
+ * version as u32;
1819
+ *
1820
+ * struct token:
1821
+ * token_id as u32;
1822
+ * metadata as token_metadata;
1823
+ *
1824
+ * function no_op:
1825
+ * input r0 as u64;
1826
+ * output r0 as u64;"
1827
+ *
1828
+ * const expected_struct_members = [
1829
+ * {
1830
+ * name: "token_id",
1831
+ * type: "u32",
1832
+ * },
1833
+ * {
1834
+ * name: "metadata",
1835
+ * type: "struct",
1836
+ * struct_id: "token_metadata",
1837
+ * members: [
1838
+ * {
1839
+ * name: "network",
1840
+ * type: "u32",
1841
+ * }
1842
+ * {
1843
+ * name: "version",
1844
+ * type: "u32",
1845
+ * }
1846
+ * ]
1847
+ * }
1848
+ * ];
1849
+ *
1850
+ * const program = aleo_wasm.Program.fromString(STRUCT_PROGRAM);
1851
+ * const struct_members = program.getStructMembers("token");
1852
+ * console.log(struct_members === expected_struct_members); // Output should be "true"
1853
+ * @param {string} struct_name
1854
+ * @returns {Array<any>}
1855
+ */
1856
+ getStructMembers(struct_name) {
1857
+ try {
1858
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1859
+ const ptr0 = passStringToWasm0(struct_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1860
+ const len0 = WASM_VECTOR_LEN;
1861
+ wasm.program_getStructMembers(retptr, this.__wbg_ptr, ptr0, len0);
1862
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1863
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1864
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1865
+ if (r2) {
1866
+ throw takeObject(r1);
1867
+ }
1868
+ return takeObject(r0);
1869
+ } finally {
1870
+ wasm.__wbindgen_add_to_stack_pointer(16);
1871
+ }
1872
+ }
1873
+ /**
1874
+ * Get the credits.aleo program
1875
+ *
1876
+ * @returns {Program} The credits.aleo program
1877
+ * @returns {Program}
1878
+ */
1879
+ static getCreditsProgram() {
1880
+ const ret = wasm.program_getCreditsProgram();
1881
+ return Program.__wrap(ret);
1882
+ }
1883
+ /**
1884
+ * Get the id of the program
1885
+ *
1886
+ * @returns {string} The id of the program
1887
+ * @returns {string}
1888
+ */
1889
+ id() {
1890
+ let deferred1_0;
1891
+ let deferred1_1;
1892
+ try {
1893
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1894
+ wasm.program_id(retptr, this.__wbg_ptr);
1895
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1896
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1897
+ deferred1_0 = r0;
1898
+ deferred1_1 = r1;
1899
+ return getStringFromWasm0(r0, r1);
1900
+ } finally {
1901
+ wasm.__wbindgen_add_to_stack_pointer(16);
1902
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1903
+ }
1904
+ }
1905
+ /**
1906
+ * Get a unique address of the program
1907
+ *
1908
+ * @returns {Address} The address of the program
1909
+ * @returns {Address}
1910
+ */
1911
+ address() {
1912
+ try {
1913
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1914
+ wasm.program_address(retptr, this.__wbg_ptr);
1915
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
1916
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
1917
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
1918
+ if (r2) {
1919
+ throw takeObject(r1);
1920
+ }
1921
+ return Address.__wrap(r0);
1922
+ } finally {
1923
+ wasm.__wbindgen_add_to_stack_pointer(16);
1924
+ }
1925
+ }
1926
+ /**
1927
+ * Determine equality with another program
1928
+ *
1929
+ * @param {Program} other The other program to compare
1930
+ * @returns {boolean} True if the programs are equal, false otherwise
1931
+ * @param {Program} other
1932
+ * @returns {boolean}
1933
+ */
1934
+ isEqual(other) {
1935
+ _assertClass(other, Program);
1936
+ const ret = wasm.program_isEqual(this.__wbg_ptr, other.__wbg_ptr);
1937
+ return ret !== 0;
1938
+ }
1939
+ /**
1940
+ * Get program_imports
1941
+ *
1942
+ * @returns {Array} The program imports
1943
+ *
1944
+ * @example
1945
+ *
1946
+ * const DOUBLE_TEST = "import multiply_test.aleo;
1947
+ *
1948
+ * program double_test.aleo;
1949
+ *
1950
+ * function double_it:
1951
+ * input r0 as u32.private;
1952
+ * call multiply_test.aleo/multiply 2u32 r0 into r1;
1953
+ * output r1 as u32.private;";
1954
+ *
1955
+ * const expected_imports = [
1956
+ * "multiply_test.aleo"
1957
+ * ];
1958
+ *
1959
+ * const program = aleo_wasm.Program.fromString(DOUBLE_TEST_PROGRAM);
1960
+ * const imports = program.getImports();
1961
+ * console.log(imports === expected_imports); // Output should be "true"
1962
+ * @returns {Array<any>}
1963
+ */
1964
+ getImports() {
1965
+ const ret = wasm.program_getImports(this.__wbg_ptr);
1966
+ return takeObject(ret);
1967
+ }
1968
+ }
1969
+
1970
+ const ProgramManagerFinalization = (typeof FinalizationRegistry === 'undefined')
1971
+ ? { register: () => {}, unregister: () => {} }
1972
+ : new FinalizationRegistry(ptr => wasm.__wbg_programmanager_free(ptr >>> 0));
1973
+ /**
1974
+ */
1975
+ class ProgramManager {
1976
+
1977
+ __destroy_into_raw() {
1978
+ const ptr = this.__wbg_ptr;
1979
+ this.__wbg_ptr = 0;
1980
+ ProgramManagerFinalization.unregister(this);
1981
+ return ptr;
1982
+ }
1983
+
1984
+ free() {
1985
+ const ptr = this.__destroy_into_raw();
1986
+ wasm.__wbg_programmanager_free(ptr);
1987
+ }
1988
+ /**
1989
+ * Deploy an Aleo program
1990
+ *
1991
+ * @param private_key The private key of the sender
1992
+ * @param program The source code of the program being deployed
1993
+ * @param imports A javascript object holding the source code of any imported programs in the
1994
+ * form \{"program_name1": "program_source_code", "program_name2": "program_source_code", ..\}.
1995
+ * Note that all imported programs must be deployed on chain before the main program in order
1996
+ * for the deployment to succeed
1997
+ * @param fee_credits The amount of credits to pay as a fee
1998
+ * @param fee_record The record to spend the fee from
1999
+ * @param url The url of the Aleo network node to send the transaction to
2000
+ * @param imports (optional) Provide a list of imports to use for the program deployment in the
2001
+ * form of a javascript object where the keys are a string of the program name and the values
2002
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2003
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2004
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2005
+ * @returns {Transaction}
2006
+ * @param {PrivateKey} private_key
2007
+ * @param {string} program
2008
+ * @param {number} fee_credits
2009
+ * @param {RecordPlaintext | undefined} [fee_record]
2010
+ * @param {string | undefined} [url]
2011
+ * @param {object | undefined} [imports]
2012
+ * @param {ProvingKey | undefined} [fee_proving_key]
2013
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2014
+ * @param {OfflineQuery | undefined} [offline_query]
2015
+ * @returns {Promise<Transaction>}
2016
+ */
2017
+ static buildDeploymentTransaction(private_key, program, fee_credits, fee_record, url, imports, fee_proving_key, fee_verifying_key, offline_query) {
2018
+ _assertClass(private_key, PrivateKey);
2019
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2020
+ const len0 = WASM_VECTOR_LEN;
2021
+ let ptr1 = 0;
2022
+ if (!isLikeNone(fee_record)) {
2023
+ _assertClass(fee_record, RecordPlaintext);
2024
+ ptr1 = fee_record.__destroy_into_raw();
2025
+ }
2026
+ var ptr2 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2027
+ var len2 = WASM_VECTOR_LEN;
2028
+ let ptr3 = 0;
2029
+ if (!isLikeNone(fee_proving_key)) {
2030
+ _assertClass(fee_proving_key, ProvingKey);
2031
+ ptr3 = fee_proving_key.__destroy_into_raw();
2032
+ }
2033
+ let ptr4 = 0;
2034
+ if (!isLikeNone(fee_verifying_key)) {
2035
+ _assertClass(fee_verifying_key, VerifyingKey);
2036
+ ptr4 = fee_verifying_key.__destroy_into_raw();
2037
+ }
2038
+ let ptr5 = 0;
2039
+ if (!isLikeNone(offline_query)) {
2040
+ _assertClass(offline_query, OfflineQuery);
2041
+ ptr5 = offline_query.__destroy_into_raw();
2042
+ }
2043
+ const ret = wasm.programmanager_buildDeploymentTransaction(private_key.__wbg_ptr, ptr0, len0, fee_credits, ptr1, ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr3, ptr4, ptr5);
2044
+ return takeObject(ret);
2045
+ }
2046
+ /**
2047
+ * Estimate the fee for a program deployment
2048
+ *
2049
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2050
+ *
2051
+ * @param program The source code of the program being deployed
2052
+ * @param imports (optional) Provide a list of imports to use for the deployment fee estimation
2053
+ * in the form of a javascript object where the keys are a string of the program name and the values
2054
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2055
+ * @returns {u64}
2056
+ * @param {string} program
2057
+ * @param {object | undefined} [imports]
2058
+ * @returns {Promise<bigint>}
2059
+ */
2060
+ static estimateDeploymentFee(program, imports) {
2061
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2062
+ const len0 = WASM_VECTOR_LEN;
2063
+ const ret = wasm.programmanager_estimateDeploymentFee(ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports));
2064
+ return takeObject(ret);
2065
+ }
2066
+ /**
2067
+ * Estimate the component of the deployment cost which comes from the fee for the program name.
2068
+ * Note that this cost does not represent the entire cost of deployment. It is additional to
2069
+ * the cost of the size (in bytes) of the deployment.
2070
+ *
2071
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2072
+ *
2073
+ * @param name The name of the program to be deployed
2074
+ * @returns {u64}
2075
+ * @param {string} name
2076
+ * @returns {bigint}
2077
+ */
2078
+ static estimateProgramNameCost(name) {
2079
+ try {
2080
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2081
+ const ptr0 = passStringToWasm0(name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2082
+ const len0 = WASM_VECTOR_LEN;
2083
+ wasm.programmanager_estimateProgramNameCost(retptr, ptr0, len0);
2084
+ var r0 = getBigInt64Memory0()[retptr / 8 + 0];
2085
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2086
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2087
+ if (r3) {
2088
+ throw takeObject(r2);
2089
+ }
2090
+ return BigInt.asUintN(64, r0);
2091
+ } finally {
2092
+ wasm.__wbindgen_add_to_stack_pointer(16);
2093
+ }
2094
+ }
2095
+ /**
2096
+ * Execute an arbitrary function locally
2097
+ *
2098
+ * @param {PrivateKey} private_key The private key of the sender
2099
+ * @param {string} program The source code of the program being executed
2100
+ * @param {string} function The name of the function to execute
2101
+ * @param {Array} inputs A javascript array of inputs to the function
2102
+ * @param {boolean} prove_execution If true, the execution will be proven and an execution object
2103
+ * containing the proof and the encrypted inputs and outputs needed to verify the proof offline
2104
+ * will be returned.
2105
+ * @param {boolean} cache Cache the proving and verifying keys in the Execution response.
2106
+ * If this is set to 'true' the keys synthesized will be stored in the Execution Response
2107
+ * and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
2108
+ * method.
2109
+ * @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
2110
+ * form of a javascript object where the keys are a string of the program name and the values
2111
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2112
+ * @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
2113
+ * @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
2114
+ * @param {PrivateKey} private_key
2115
+ * @param {string} program
2116
+ * @param {string} _function
2117
+ * @param {Array<any>} inputs
2118
+ * @param {boolean} prove_execution
2119
+ * @param {boolean} cache
2120
+ * @param {object | undefined} [imports]
2121
+ * @param {ProvingKey | undefined} [proving_key]
2122
+ * @param {VerifyingKey | undefined} [verifying_key]
2123
+ * @param {string | undefined} [url]
2124
+ * @param {OfflineQuery | undefined} [offline_query]
2125
+ * @returns {Promise<ExecutionResponse>}
2126
+ */
2127
+ static executeFunctionOffline(private_key, program, _function, inputs, prove_execution, cache, imports, proving_key, verifying_key, url, offline_query) {
2128
+ _assertClass(private_key, PrivateKey);
2129
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2130
+ const len0 = WASM_VECTOR_LEN;
2131
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2132
+ const len1 = WASM_VECTOR_LEN;
2133
+ let ptr2 = 0;
2134
+ if (!isLikeNone(proving_key)) {
2135
+ _assertClass(proving_key, ProvingKey);
2136
+ ptr2 = proving_key.__destroy_into_raw();
2137
+ }
2138
+ let ptr3 = 0;
2139
+ if (!isLikeNone(verifying_key)) {
2140
+ _assertClass(verifying_key, VerifyingKey);
2141
+ ptr3 = verifying_key.__destroy_into_raw();
2142
+ }
2143
+ var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2144
+ var len4 = WASM_VECTOR_LEN;
2145
+ let ptr5 = 0;
2146
+ if (!isLikeNone(offline_query)) {
2147
+ _assertClass(offline_query, OfflineQuery);
2148
+ ptr5 = offline_query.__destroy_into_raw();
2149
+ }
2150
+ 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);
2151
+ return takeObject(ret);
2152
+ }
2153
+ /**
2154
+ * Execute Aleo function and create an Aleo execution transaction
2155
+ *
2156
+ * @param private_key The private key of the sender
2157
+ * @param program The source code of the program being executed
2158
+ * @param function The name of the function to execute
2159
+ * @param inputs A javascript array of inputs to the function
2160
+ * @param fee_credits The amount of credits to pay as a fee
2161
+ * @param fee_record The record to spend the fee from
2162
+ * @param url The url of the Aleo network node to send the transaction to
2163
+ * If this is set to 'true' the keys synthesized (or passed in as optional parameters via the
2164
+ * `proving_key` and `verifying_key` arguments) will be stored in the ProgramManager's memory
2165
+ * and used for subsequent transactions. If this is set to 'false' the proving and verifying
2166
+ * keys will be deallocated from memory after the transaction is executed.
2167
+ * @param imports (optional) Provide a list of imports to use for the function execution in the
2168
+ * form of a javascript object where the keys are a string of the program name and the values
2169
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2170
+ * @param proving_key (optional) Provide a verifying key to use for the function execution
2171
+ * @param verifying_key (optional) Provide a verifying key to use for the function execution
2172
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2173
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2174
+ * @returns {Transaction}
2175
+ * @param {PrivateKey} private_key
2176
+ * @param {string} program
2177
+ * @param {string} _function
2178
+ * @param {Array<any>} inputs
2179
+ * @param {number} fee_credits
2180
+ * @param {RecordPlaintext | undefined} [fee_record]
2181
+ * @param {string | undefined} [url]
2182
+ * @param {object | undefined} [imports]
2183
+ * @param {ProvingKey | undefined} [proving_key]
2184
+ * @param {VerifyingKey | undefined} [verifying_key]
2185
+ * @param {ProvingKey | undefined} [fee_proving_key]
2186
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2187
+ * @param {OfflineQuery | undefined} [offline_query]
2188
+ * @returns {Promise<Transaction>}
2189
+ */
2190
+ 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) {
2191
+ _assertClass(private_key, PrivateKey);
2192
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2193
+ const len0 = WASM_VECTOR_LEN;
2194
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2195
+ const len1 = WASM_VECTOR_LEN;
2196
+ let ptr2 = 0;
2197
+ if (!isLikeNone(fee_record)) {
2198
+ _assertClass(fee_record, RecordPlaintext);
2199
+ ptr2 = fee_record.__destroy_into_raw();
2200
+ }
2201
+ var ptr3 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2202
+ var len3 = WASM_VECTOR_LEN;
2203
+ let ptr4 = 0;
2204
+ if (!isLikeNone(proving_key)) {
2205
+ _assertClass(proving_key, ProvingKey);
2206
+ ptr4 = proving_key.__destroy_into_raw();
2207
+ }
2208
+ let ptr5 = 0;
2209
+ if (!isLikeNone(verifying_key)) {
2210
+ _assertClass(verifying_key, VerifyingKey);
2211
+ ptr5 = verifying_key.__destroy_into_raw();
2212
+ }
2213
+ let ptr6 = 0;
2214
+ if (!isLikeNone(fee_proving_key)) {
2215
+ _assertClass(fee_proving_key, ProvingKey);
2216
+ ptr6 = fee_proving_key.__destroy_into_raw();
2217
+ }
2218
+ let ptr7 = 0;
2219
+ if (!isLikeNone(fee_verifying_key)) {
2220
+ _assertClass(fee_verifying_key, VerifyingKey);
2221
+ ptr7 = fee_verifying_key.__destroy_into_raw();
2222
+ }
2223
+ let ptr8 = 0;
2224
+ if (!isLikeNone(offline_query)) {
2225
+ _assertClass(offline_query, OfflineQuery);
2226
+ ptr8 = offline_query.__destroy_into_raw();
2227
+ }
2228
+ 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);
2229
+ return takeObject(ret);
2230
+ }
2231
+ /**
2232
+ * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
2233
+ * verifying keys will be stored in the ProgramManager's memory and used for subsequent
2234
+ * program executions.
2235
+ *
2236
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2237
+ *
2238
+ * @param private_key The private key of the sender
2239
+ * @param program The source code of the program to estimate the execution fee for
2240
+ * @param function The name of the function to execute
2241
+ * @param inputs A javascript array of inputs to the function
2242
+ * @param url The url of the Aleo network node to send the transaction to
2243
+ * @param imports (optional) Provide a list of imports to use for the fee estimation in the
2244
+ * form of a javascript object where the keys are a string of the program name and the values
2245
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2246
+ * @param proving_key (optional) Provide a verifying key to use for the fee estimation
2247
+ * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
2248
+ * @returns {u64} Fee in microcredits
2249
+ * @param {PrivateKey} private_key
2250
+ * @param {string} program
2251
+ * @param {string} _function
2252
+ * @param {Array<any>} inputs
2253
+ * @param {string | undefined} [url]
2254
+ * @param {object | undefined} [imports]
2255
+ * @param {ProvingKey | undefined} [proving_key]
2256
+ * @param {VerifyingKey | undefined} [verifying_key]
2257
+ * @param {OfflineQuery | undefined} [offline_query]
2258
+ * @returns {Promise<bigint>}
2259
+ */
2260
+ static estimateExecutionFee(private_key, program, _function, inputs, url, imports, proving_key, verifying_key, offline_query) {
2261
+ _assertClass(private_key, PrivateKey);
2262
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2263
+ const len0 = WASM_VECTOR_LEN;
2264
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2265
+ const len1 = WASM_VECTOR_LEN;
2266
+ var ptr2 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2267
+ var len2 = WASM_VECTOR_LEN;
2268
+ let ptr3 = 0;
2269
+ if (!isLikeNone(proving_key)) {
2270
+ _assertClass(proving_key, ProvingKey);
2271
+ ptr3 = proving_key.__destroy_into_raw();
2272
+ }
2273
+ let ptr4 = 0;
2274
+ if (!isLikeNone(verifying_key)) {
2275
+ _assertClass(verifying_key, VerifyingKey);
2276
+ ptr4 = verifying_key.__destroy_into_raw();
2277
+ }
2278
+ let ptr5 = 0;
2279
+ if (!isLikeNone(offline_query)) {
2280
+ _assertClass(offline_query, OfflineQuery);
2281
+ ptr5 = offline_query.__destroy_into_raw();
2282
+ }
2283
+ 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);
2284
+ return takeObject(ret);
2285
+ }
2286
+ /**
2287
+ * Estimate the finalize fee component for executing a function. This fee is additional to the
2288
+ * size of the execution of the program in bytes. If the function does not have a finalize
2289
+ * step, then the finalize fee is 0.
2290
+ *
2291
+ * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2292
+ *
2293
+ * @param program The program containing the function to estimate the finalize fee for
2294
+ * @param function The function to estimate the finalize fee for
2295
+ * @returns {u64} Fee in microcredits
2296
+ * @param {string} program
2297
+ * @param {string} _function
2298
+ * @returns {bigint}
2299
+ */
2300
+ static estimateFinalizeFee(program, _function) {
2301
+ try {
2302
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2303
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2304
+ const len0 = WASM_VECTOR_LEN;
2305
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2306
+ const len1 = WASM_VECTOR_LEN;
2307
+ wasm.programmanager_estimateFinalizeFee(retptr, ptr0, len0, ptr1, len1);
2308
+ var r0 = getBigInt64Memory0()[retptr / 8 + 0];
2309
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2310
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2311
+ if (r3) {
2312
+ throw takeObject(r2);
2313
+ }
2314
+ return BigInt.asUintN(64, r0);
2315
+ } finally {
2316
+ wasm.__wbindgen_add_to_stack_pointer(16);
2317
+ }
2318
+ }
2319
+ /**
2320
+ * Join two records together to create a new record with an amount of credits equal to the sum
2321
+ * of the credits of the two original records
2322
+ *
2323
+ * @param private_key The private key of the sender
2324
+ * @param record_1 The first record to combine
2325
+ * @param record_2 The second record to combine
2326
+ * @param fee_credits The amount of credits to pay as a fee
2327
+ * @param fee_record The record to spend the fee from
2328
+ * @param url The url of the Aleo network node to send the transaction to
2329
+ * @param join_proving_key (optional) Provide a proving key to use for the join function
2330
+ * @param join_verifying_key (optional) Provide a verifying key to use for the join function
2331
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2332
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2333
+ * @returns {Transaction} Transaction object
2334
+ * @param {PrivateKey} private_key
2335
+ * @param {RecordPlaintext} record_1
2336
+ * @param {RecordPlaintext} record_2
2337
+ * @param {number} fee_credits
2338
+ * @param {RecordPlaintext | undefined} [fee_record]
2339
+ * @param {string | undefined} [url]
2340
+ * @param {ProvingKey | undefined} [join_proving_key]
2341
+ * @param {VerifyingKey | undefined} [join_verifying_key]
2342
+ * @param {ProvingKey | undefined} [fee_proving_key]
2343
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2344
+ * @param {OfflineQuery | undefined} [offline_query]
2345
+ * @returns {Promise<Transaction>}
2346
+ */
2347
+ 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) {
2348
+ _assertClass(private_key, PrivateKey);
2349
+ _assertClass(record_1, RecordPlaintext);
2350
+ var ptr0 = record_1.__destroy_into_raw();
2351
+ _assertClass(record_2, RecordPlaintext);
2352
+ var ptr1 = record_2.__destroy_into_raw();
2353
+ let ptr2 = 0;
2354
+ if (!isLikeNone(fee_record)) {
2355
+ _assertClass(fee_record, RecordPlaintext);
2356
+ ptr2 = fee_record.__destroy_into_raw();
2357
+ }
2358
+ var ptr3 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2359
+ var len3 = WASM_VECTOR_LEN;
2360
+ let ptr4 = 0;
2361
+ if (!isLikeNone(join_proving_key)) {
2362
+ _assertClass(join_proving_key, ProvingKey);
2363
+ ptr4 = join_proving_key.__destroy_into_raw();
2364
+ }
2365
+ let ptr5 = 0;
2366
+ if (!isLikeNone(join_verifying_key)) {
2367
+ _assertClass(join_verifying_key, VerifyingKey);
2368
+ ptr5 = join_verifying_key.__destroy_into_raw();
2369
+ }
2370
+ let ptr6 = 0;
2371
+ if (!isLikeNone(fee_proving_key)) {
2372
+ _assertClass(fee_proving_key, ProvingKey);
2373
+ ptr6 = fee_proving_key.__destroy_into_raw();
2374
+ }
2375
+ let ptr7 = 0;
2376
+ if (!isLikeNone(fee_verifying_key)) {
2377
+ _assertClass(fee_verifying_key, VerifyingKey);
2378
+ ptr7 = fee_verifying_key.__destroy_into_raw();
2379
+ }
2380
+ let ptr8 = 0;
2381
+ if (!isLikeNone(offline_query)) {
2382
+ _assertClass(offline_query, OfflineQuery);
2383
+ ptr8 = offline_query.__destroy_into_raw();
2384
+ }
2385
+ const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7, ptr8);
2386
+ return takeObject(ret);
2387
+ }
2388
+ /**
2389
+ * Split an Aleo credits record into two separate records. This function does not require a fee.
2390
+ *
2391
+ * @param private_key The private key of the sender
2392
+ * @param split_amount The amount of the credit split. This amount will be subtracted from the
2393
+ * value of the record and two new records will be created with the split amount and the remainder
2394
+ * @param amount_record The record to split
2395
+ * @param url The url of the Aleo network node to send the transaction to
2396
+ * @param split_proving_key (optional) Provide a proving key to use for the split function
2397
+ * @param split_verifying_key (optional) Provide a verifying key to use for the split function
2398
+ * @returns {Transaction} Transaction object
2399
+ * @param {PrivateKey} private_key
2400
+ * @param {number} split_amount
2401
+ * @param {RecordPlaintext} amount_record
2402
+ * @param {string | undefined} [url]
2403
+ * @param {ProvingKey | undefined} [split_proving_key]
2404
+ * @param {VerifyingKey | undefined} [split_verifying_key]
2405
+ * @param {OfflineQuery | undefined} [offline_query]
2406
+ * @returns {Promise<Transaction>}
2407
+ */
2408
+ static buildSplitTransaction(private_key, split_amount, amount_record, url, split_proving_key, split_verifying_key, offline_query) {
2409
+ _assertClass(private_key, PrivateKey);
2410
+ _assertClass(amount_record, RecordPlaintext);
2411
+ var ptr0 = amount_record.__destroy_into_raw();
2412
+ var ptr1 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2413
+ var len1 = WASM_VECTOR_LEN;
2414
+ let ptr2 = 0;
2415
+ if (!isLikeNone(split_proving_key)) {
2416
+ _assertClass(split_proving_key, ProvingKey);
2417
+ ptr2 = split_proving_key.__destroy_into_raw();
2418
+ }
2419
+ let ptr3 = 0;
2420
+ if (!isLikeNone(split_verifying_key)) {
2421
+ _assertClass(split_verifying_key, VerifyingKey);
2422
+ ptr3 = split_verifying_key.__destroy_into_raw();
2423
+ }
2424
+ let ptr4 = 0;
2425
+ if (!isLikeNone(offline_query)) {
2426
+ _assertClass(offline_query, OfflineQuery);
2427
+ ptr4 = offline_query.__destroy_into_raw();
2428
+ }
2429
+ const ret = wasm.programmanager_buildSplitTransaction(private_key.__wbg_ptr, split_amount, ptr0, ptr1, len1, ptr2, ptr3, ptr4);
2430
+ return takeObject(ret);
2431
+ }
2432
+ /**
2433
+ * Send credits from one Aleo account to another
2434
+ *
2435
+ * @param private_key The private key of the sender
2436
+ * @param amount_credits The amount of credits to send
2437
+ * @param recipient The recipient of the transaction
2438
+ * @param transfer_type The type of the transfer (options: "private", "public", "private_to_public", "public_to_private")
2439
+ * @param amount_record The record to fund the amount from
2440
+ * @param fee_credits The amount of credits to pay as a fee
2441
+ * @param fee_record The record to spend the fee from
2442
+ * @param url The url of the Aleo network node to send the transaction to
2443
+ * @param transfer_verifying_key (optional) Provide a verifying key to use for the transfer
2444
+ * function
2445
+ * @param fee_proving_key (optional) Provide a proving key to use for the fee execution
2446
+ * @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
2447
+ * @returns {Transaction}
2448
+ * @param {PrivateKey} private_key
2449
+ * @param {number} amount_credits
2450
+ * @param {string} recipient
2451
+ * @param {string} transfer_type
2452
+ * @param {RecordPlaintext | undefined} amount_record
2453
+ * @param {number} fee_credits
2454
+ * @param {RecordPlaintext | undefined} [fee_record]
2455
+ * @param {string | undefined} [url]
2456
+ * @param {ProvingKey | undefined} [transfer_proving_key]
2457
+ * @param {VerifyingKey | undefined} [transfer_verifying_key]
2458
+ * @param {ProvingKey | undefined} [fee_proving_key]
2459
+ * @param {VerifyingKey | undefined} [fee_verifying_key]
2460
+ * @param {OfflineQuery | undefined} [offline_query]
2461
+ * @returns {Promise<Transaction>}
2462
+ */
2463
+ 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) {
2464
+ _assertClass(private_key, PrivateKey);
2465
+ const ptr0 = passStringToWasm0(recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2466
+ const len0 = WASM_VECTOR_LEN;
2467
+ const ptr1 = passStringToWasm0(transfer_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2468
+ const len1 = WASM_VECTOR_LEN;
2469
+ let ptr2 = 0;
2470
+ if (!isLikeNone(amount_record)) {
2471
+ _assertClass(amount_record, RecordPlaintext);
2472
+ ptr2 = amount_record.__destroy_into_raw();
2473
+ }
2474
+ let ptr3 = 0;
2475
+ if (!isLikeNone(fee_record)) {
2476
+ _assertClass(fee_record, RecordPlaintext);
2477
+ ptr3 = fee_record.__destroy_into_raw();
2478
+ }
2479
+ var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2480
+ var len4 = WASM_VECTOR_LEN;
2481
+ let ptr5 = 0;
2482
+ if (!isLikeNone(transfer_proving_key)) {
2483
+ _assertClass(transfer_proving_key, ProvingKey);
2484
+ ptr5 = transfer_proving_key.__destroy_into_raw();
2485
+ }
2486
+ let ptr6 = 0;
2487
+ if (!isLikeNone(transfer_verifying_key)) {
2488
+ _assertClass(transfer_verifying_key, VerifyingKey);
2489
+ ptr6 = transfer_verifying_key.__destroy_into_raw();
2490
+ }
2491
+ let ptr7 = 0;
2492
+ if (!isLikeNone(fee_proving_key)) {
2493
+ _assertClass(fee_proving_key, ProvingKey);
2494
+ ptr7 = fee_proving_key.__destroy_into_raw();
2495
+ }
2496
+ let ptr8 = 0;
2497
+ if (!isLikeNone(fee_verifying_key)) {
2498
+ _assertClass(fee_verifying_key, VerifyingKey);
2499
+ ptr8 = fee_verifying_key.__destroy_into_raw();
2500
+ }
2501
+ let ptr9 = 0;
2502
+ if (!isLikeNone(offline_query)) {
2503
+ _assertClass(offline_query, OfflineQuery);
2504
+ ptr9 = offline_query.__destroy_into_raw();
2505
+ }
2506
+ 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);
2507
+ return takeObject(ret);
2508
+ }
2509
+ /**
2510
+ * Synthesize proving and verifying keys for a program
2511
+ *
2512
+ * @param program {string} The program source code of the program to synthesize keys for
2513
+ * @param function_id {string} The function to synthesize keys for
2514
+ * @param inputs {Array} The inputs to the function
2515
+ * @param imports {Object | undefined} The imports for the program
2516
+ * @param {PrivateKey} private_key
2517
+ * @param {string} program
2518
+ * @param {string} function_id
2519
+ * @param {Array<any>} inputs
2520
+ * @param {object | undefined} [imports]
2521
+ * @returns {Promise<KeyPair>}
2522
+ */
2523
+ static synthesizeKeyPair(private_key, program, function_id, inputs, imports) {
2524
+ _assertClass(private_key, PrivateKey);
2525
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2526
+ const len0 = WASM_VECTOR_LEN;
2527
+ const ptr1 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2528
+ const len1 = WASM_VECTOR_LEN;
2529
+ const ret = wasm.programmanager_synthesizeKeyPair(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), isLikeNone(imports) ? 0 : addHeapObject(imports));
2530
+ return takeObject(ret);
2531
+ }
2532
+ }
2533
+
2534
+ const ProvingKeyFinalization = (typeof FinalizationRegistry === 'undefined')
2535
+ ? { register: () => {}, unregister: () => {} }
2536
+ : new FinalizationRegistry(ptr => wasm.__wbg_provingkey_free(ptr >>> 0));
2537
+ /**
2538
+ * Proving key for a function within an Aleo program
2539
+ */
2540
+ class ProvingKey {
2541
+
2542
+ static __wrap(ptr) {
2543
+ ptr = ptr >>> 0;
2544
+ const obj = Object.create(ProvingKey.prototype);
2545
+ obj.__wbg_ptr = ptr;
2546
+ ProvingKeyFinalization.register(obj, obj.__wbg_ptr, obj);
2547
+ return obj;
2548
+ }
2549
+
2550
+ __destroy_into_raw() {
2551
+ const ptr = this.__wbg_ptr;
2552
+ this.__wbg_ptr = 0;
2553
+ ProvingKeyFinalization.unregister(this);
2554
+ return ptr;
2555
+ }
2556
+
2557
+ free() {
2558
+ const ptr = this.__destroy_into_raw();
2559
+ wasm.__wbg_provingkey_free(ptr);
2560
+ }
2561
+ /**
2562
+ * Verify if the proving key is for the bond_public function
2563
+ *
2564
+ * @example
2565
+ * const provingKey = ProvingKey.fromBytes("bond_public_proving_key.bin");
2566
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2567
+ *
2568
+ * @returns {boolean} returns true if the proving key is for the bond_public function, false if otherwise
2569
+ * @returns {boolean}
2570
+ */
2571
+ isBondPublicProver() {
2572
+ const ret = wasm.provingkey_isBondPublicProver(this.__wbg_ptr);
2573
+ return ret !== 0;
2574
+ }
2575
+ /**
2576
+ * Verify if the proving key is for the bond_validator function
2577
+ *
2578
+ * @example
2579
+ * const provingKey = ProvingKey.fromBytes("bond_validator_proving_key.bin");
2580
+ * provingKey.isBondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2581
+ *
2582
+ * @returns {boolean} returns true if the proving key is for the bond_validator function, false if otherwise
2583
+ * @returns {boolean}
2584
+ */
2585
+ isBondValidatorProver() {
2586
+ const ret = wasm.provingkey_isBondValidatorProver(this.__wbg_ptr);
2587
+ return ret !== 0;
2588
+ }
2589
+ /**
2590
+ * Verify if the proving key is for the claim_unbond function
2591
+ *
2592
+ * @example
2593
+ * const provingKey = ProvingKey.fromBytes("claim_unbond_proving_key.bin");
2594
+ * provingKey.isClaimUnbondProver() ? console.log("Key verified") : throw new Error("Invalid key");
2595
+ *
2596
+ * @returns {boolean} returns true if the proving key is for the claim_unbond function, false if otherwise
2597
+ * @returns {boolean}
2598
+ */
2599
+ isClaimUnbondPublicProver() {
2600
+ const ret = wasm.provingkey_isClaimUnbondPublicProver(this.__wbg_ptr);
2601
+ return ret !== 0;
2602
+ }
2603
+ /**
2604
+ * Verify if the proving key is for the fee_private function
2605
+ *
2606
+ * @example
2607
+ * const provingKey = ProvingKey.fromBytes("fee_private_proving_key.bin");
2608
+ * provingKey.isFeePrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2609
+ *
2610
+ * @returns {boolean} returns true if the proving key is for the fee_private function, false if otherwise
2611
+ * @returns {boolean}
2612
+ */
2613
+ isFeePrivateProver() {
2614
+ const ret = wasm.provingkey_isFeePrivateProver(this.__wbg_ptr);
2615
+ return ret !== 0;
2616
+ }
2617
+ /**
2618
+ * Verify if the proving key is for the fee_public function
2619
+ *
2620
+ * @example
2621
+ * const provingKey = ProvingKey.fromBytes("fee_public_proving_key.bin");
2622
+ * provingKey.isFeePublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2623
+ *
2624
+ * @returns {boolean} returns true if the proving key is for the fee_public function, false if otherwise
2625
+ * @returns {boolean}
2626
+ */
2627
+ isFeePublicProver() {
2628
+ const ret = wasm.provingkey_isFeePublicProver(this.__wbg_ptr);
2629
+ return ret !== 0;
2630
+ }
2631
+ /**
2632
+ * Verify if the proving key is for the inclusion function
2633
+ *
2634
+ * @example
2635
+ * const provingKey = ProvingKey.fromBytes("inclusion_proving_key.bin");
2636
+ * provingKey.isInclusionProver() ? console.log("Key verified") : throw new Error("Invalid key");
2637
+ *
2638
+ * @returns {boolean} returns true if the proving key is for the inclusion function, false if otherwise
2639
+ * @returns {boolean}
2640
+ */
2641
+ isInclusionProver() {
2642
+ const ret = wasm.provingkey_isInclusionProver(this.__wbg_ptr);
2643
+ return ret !== 0;
2644
+ }
2645
+ /**
2646
+ * Verify if the proving key is for the join function
2647
+ *
2648
+ * @example
2649
+ * const provingKey = ProvingKey.fromBytes("join_proving_key.bin");
2650
+ * provingKey.isJoinProver() ? console.log("Key verified") : throw new Error("Invalid key");
2651
+ *
2652
+ * @returns {boolean} returns true if the proving key is for the join function, false if otherwise
2653
+ * @returns {boolean}
2654
+ */
2655
+ isJoinProver() {
2656
+ const ret = wasm.provingkey_isJoinProver(this.__wbg_ptr);
2657
+ return ret !== 0;
2658
+ }
2659
+ /**
2660
+ * Verify if the proving key is for the set_validator_state function
2661
+ *
2662
+ * @example
2663
+ * const provingKey = ProvingKey.fromBytes("set_validator_set_proving_key.bin");
2664
+ * provingKey.isSetValidatorStateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2665
+ *
2666
+ * @returns {boolean} returns true if the proving key is for the set_validator_state function, false if otherwise
2667
+ * @returns {boolean}
2668
+ */
2669
+ isSetValidatorStateProver() {
2670
+ const ret = wasm.provingkey_isSetValidatorStateProver(this.__wbg_ptr);
2671
+ return ret !== 0;
2672
+ }
2673
+ /**
2674
+ * Verify if the proving key is for the split function
2675
+ *
2676
+ * @example
2677
+ * const provingKey = ProvingKey.fromBytes("split_proving_key.bin");
2678
+ * provingKey.isSplitProver() ? console.log("Key verified") : throw new Error("Invalid key");
2679
+ *
2680
+ * @returns {boolean} returns true if the proving key is for the split function, false if otherwise
2681
+ * @returns {boolean}
2682
+ */
2683
+ isSplitProver() {
2684
+ const ret = wasm.provingkey_isSplitProver(this.__wbg_ptr);
2685
+ return ret !== 0;
2686
+ }
2687
+ /**
2688
+ * Verify if the proving key is for the transfer_private function
2689
+ *
2690
+ * @example
2691
+ * const provingKey = ProvingKey.fromBytes("transfer_private_proving_key.bin");
2692
+ * provingKey.isTransferPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2693
+ *
2694
+ * @returns {boolean} returns true if the proving key is for the transfer_private function, false if otherwise
2695
+ * @returns {boolean}
2696
+ */
2697
+ isTransferPrivateProver() {
2698
+ const ret = wasm.provingkey_isTransferPrivateProver(this.__wbg_ptr);
2699
+ return ret !== 0;
2700
+ }
2701
+ /**
2702
+ * Verify if the proving key is for the transfer_private_to_public function
2703
+ *
2704
+ * @example
2705
+ * const provingKey = ProvingKey.fromBytes("transfer_private_to_public_proving_key.bin");
2706
+ * provingKey.isTransferPrivateToPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2707
+ *
2708
+ * @returns {boolean} returns true if the proving key is for the transfer_private_to_public function, false if otherwise
2709
+ * @returns {boolean}
2710
+ */
2711
+ isTransferPrivateToPublicProver() {
2712
+ const ret = wasm.provingkey_isTransferPrivateToPublicProver(this.__wbg_ptr);
2713
+ return ret !== 0;
2714
+ }
2715
+ /**
2716
+ * Verify if the proving key is for the transfer_public function
2717
+ *
2718
+ * @example
2719
+ * const provingKey = ProvingKey.fromBytes("transfer_public_proving_key.bin");
2720
+ * provingKey.isTransferPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2721
+ *
2722
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
2723
+ * @returns {boolean}
2724
+ */
2725
+ isTransferPublicProver() {
2726
+ const ret = wasm.provingkey_isTransferPublicProver(this.__wbg_ptr);
2727
+ return ret !== 0;
2728
+ }
2729
+ /**
2730
+ * Verify if the proving key is for the transfer_public_as_signer function
2731
+ *
2732
+ * @example
2733
+ * const provingKey = ProvingKey.fromBytes("transfer_public_as_signer_proving_key.bin");
2734
+ * provingKey.isTransferPublicAsSignerProver() ? console.log("Key verified") : throw new Error("Invalid key");
2735
+ *
2736
+ * @returns {boolean} returns true if the proving key is for the transfer_public function, false if otherwise
2737
+ * @returns {boolean}
2738
+ */
2739
+ isTransferPublicAsSignerProver() {
2740
+ const ret = wasm.provingkey_isTransferPublicAsSignerProver(this.__wbg_ptr);
2741
+ return ret !== 0;
2742
+ }
2743
+ /**
2744
+ * Verify if the proving key is for the transfer_public_to_private function
2745
+ *
2746
+ * @example
2747
+ * const provingKey = ProvingKey.fromBytes("transfer_public_to_private_proving_key.bin");
2748
+ * provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
2749
+ *
2750
+ * @returns {boolean} returns true if the proving key is for the transfer_public_to_private function, false if otherwise
2751
+ * @returns {boolean}
2752
+ */
2753
+ isTransferPublicToPrivateProver() {
2754
+ const ret = wasm.provingkey_isTransferPublicToPrivateProver(this.__wbg_ptr);
2755
+ return ret !== 0;
2756
+ }
2757
+ /**
2758
+ * Verify if the proving key is for the unbond_public function
2759
+ *
2760
+ * @example
2761
+ * const provingKey = ProvingKey.fromBytes("unbond_public.bin");
2762
+ * provingKey.isUnbondPublicProver() ? console.log("Key verified") : throw new Error("Invalid key");
2763
+ *
2764
+ * @returns {boolean} returns true if the proving key is for the unbond_public_prover function, false if otherwise
2765
+ * @returns {boolean}
2766
+ */
2767
+ isUnbondPublicProver() {
2768
+ const ret = wasm.provingkey_isUnbondPublicProver(this.__wbg_ptr);
2769
+ return ret !== 0;
2770
+ }
2771
+ /**
2772
+ * Return the checksum of the proving key
2773
+ *
2774
+ * @returns {string} Checksum of the proving key
2775
+ * @returns {string}
2776
+ */
2777
+ checksum() {
2778
+ let deferred1_0;
2779
+ let deferred1_1;
2780
+ try {
2781
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2782
+ wasm.provingkey_checksum(retptr, this.__wbg_ptr);
2783
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2784
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2785
+ deferred1_0 = r0;
2786
+ deferred1_1 = r1;
2787
+ return getStringFromWasm0(r0, r1);
2788
+ } finally {
2789
+ wasm.__wbindgen_add_to_stack_pointer(16);
2790
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2791
+ }
2792
+ }
2793
+ /**
2794
+ * Create a copy of the proving key
2795
+ *
2796
+ * @returns {ProvingKey} A copy of the proving key
2797
+ * @returns {ProvingKey}
2798
+ */
2799
+ copy() {
2800
+ const ret = wasm.provingkey_copy(this.__wbg_ptr);
2801
+ return ProvingKey.__wrap(ret);
2802
+ }
2803
+ /**
2804
+ * Construct a new proving key from a byte array
2805
+ *
2806
+ * @param {Uint8Array} bytes Byte array representation of a proving key
2807
+ * @returns {ProvingKey}
2808
+ * @param {Uint8Array} bytes
2809
+ * @returns {ProvingKey}
2810
+ */
2811
+ static fromBytes(bytes) {
2812
+ try {
2813
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2814
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
2815
+ const len0 = WASM_VECTOR_LEN;
2816
+ wasm.provingkey_fromBytes(retptr, ptr0, len0);
2817
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2818
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2819
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2820
+ if (r2) {
2821
+ throw takeObject(r1);
2822
+ }
2823
+ return ProvingKey.__wrap(r0);
2824
+ } finally {
2825
+ wasm.__wbindgen_add_to_stack_pointer(16);
2826
+ }
2827
+ }
2828
+ /**
2829
+ * Create a proving key from string
2830
+ *
2831
+ * @param {string} String representation of the proving key
2832
+ * @param {string} string
2833
+ * @returns {ProvingKey}
2834
+ */
2835
+ static fromString(string) {
2836
+ try {
2837
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2838
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2839
+ const len0 = WASM_VECTOR_LEN;
2840
+ wasm.provingkey_fromString(retptr, ptr0, len0);
2841
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2842
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2843
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2844
+ if (r2) {
2845
+ throw takeObject(r1);
2846
+ }
2847
+ return ProvingKey.__wrap(r0);
2848
+ } finally {
2849
+ wasm.__wbindgen_add_to_stack_pointer(16);
2850
+ }
2851
+ }
2852
+ /**
2853
+ * Return the byte representation of a proving key
2854
+ *
2855
+ * @returns {Uint8Array} Byte array representation of a proving key
2856
+ * @returns {Uint8Array}
2857
+ */
2858
+ toBytes() {
2859
+ try {
2860
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2861
+ wasm.provingkey_toBytes(retptr, this.__wbg_ptr);
2862
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2863
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2864
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2865
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
2866
+ if (r3) {
2867
+ throw takeObject(r2);
2868
+ }
2869
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
2870
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
2871
+ return v1;
2872
+ } finally {
2873
+ wasm.__wbindgen_add_to_stack_pointer(16);
2874
+ }
2875
+ }
2876
+ /**
2877
+ * Get a string representation of the proving key
2878
+ *
2879
+ * @returns {string} String representation of the proving key
2880
+ * @returns {string}
2881
+ */
2882
+ toString() {
2883
+ let deferred1_0;
2884
+ let deferred1_1;
2885
+ try {
2886
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2887
+ wasm.provingkey_toString(retptr, this.__wbg_ptr);
2888
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2889
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2890
+ deferred1_0 = r0;
2891
+ deferred1_1 = r1;
2892
+ return getStringFromWasm0(r0, r1);
2893
+ } finally {
2894
+ wasm.__wbindgen_add_to_stack_pointer(16);
2895
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2896
+ }
2897
+ }
2898
+ }
2899
+
2900
+ const RecordCiphertextFinalization = (typeof FinalizationRegistry === 'undefined')
2901
+ ? { register: () => {}, unregister: () => {} }
2902
+ : new FinalizationRegistry(ptr => wasm.__wbg_recordciphertext_free(ptr >>> 0));
2903
+ /**
2904
+ * Encrypted Aleo record
2905
+ */
2906
+ class RecordCiphertext {
2907
+
2908
+ static __wrap(ptr) {
2909
+ ptr = ptr >>> 0;
2910
+ const obj = Object.create(RecordCiphertext.prototype);
2911
+ obj.__wbg_ptr = ptr;
2912
+ RecordCiphertextFinalization.register(obj, obj.__wbg_ptr, obj);
2913
+ return obj;
2914
+ }
2915
+
2916
+ __destroy_into_raw() {
2917
+ const ptr = this.__wbg_ptr;
2918
+ this.__wbg_ptr = 0;
2919
+ RecordCiphertextFinalization.unregister(this);
2920
+ return ptr;
2921
+ }
2922
+
2923
+ free() {
2924
+ const ptr = this.__destroy_into_raw();
2925
+ wasm.__wbg_recordciphertext_free(ptr);
2926
+ }
2927
+ /**
2928
+ * Create a record ciphertext from a string
2929
+ *
2930
+ * @param {string} record String representation of a record ciphertext
2931
+ * @returns {RecordCiphertext} Record ciphertext
2932
+ * @param {string} record
2933
+ * @returns {RecordCiphertext}
2934
+ */
2935
+ static fromString(record) {
2936
+ try {
2937
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2938
+ const ptr0 = passStringToWasm0(record, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
2939
+ const len0 = WASM_VECTOR_LEN;
2940
+ wasm.recordciphertext_fromString(retptr, ptr0, len0);
2941
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2942
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2943
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2944
+ if (r2) {
2945
+ throw takeObject(r1);
2946
+ }
2947
+ return RecordCiphertext.__wrap(r0);
2948
+ } finally {
2949
+ wasm.__wbindgen_add_to_stack_pointer(16);
2950
+ }
2951
+ }
2952
+ /**
2953
+ * Return the string reprensentation of the record ciphertext
2954
+ *
2955
+ * @returns {string} String representation of the record ciphertext
2956
+ * @returns {string}
2957
+ */
2958
+ toString() {
2959
+ let deferred1_0;
2960
+ let deferred1_1;
2961
+ try {
2962
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2963
+ wasm.recordciphertext_toString(retptr, this.__wbg_ptr);
2964
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2965
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2966
+ deferred1_0 = r0;
2967
+ deferred1_1 = r1;
2968
+ return getStringFromWasm0(r0, r1);
2969
+ } finally {
2970
+ wasm.__wbindgen_add_to_stack_pointer(16);
2971
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
2972
+ }
2973
+ }
2974
+ /**
2975
+ * Decrypt the record ciphertext into plaintext using the view key. The record will only
2976
+ * decrypt if the record was encrypted by the account corresponding to the view key
2977
+ *
2978
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
2979
+ * @returns {RecordPlaintext} Record plaintext object
2980
+ * @param {ViewKey} view_key
2981
+ * @returns {RecordPlaintext}
2982
+ */
2983
+ decrypt(view_key) {
2984
+ try {
2985
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
2986
+ _assertClass(view_key, ViewKey);
2987
+ wasm.recordciphertext_decrypt(retptr, this.__wbg_ptr, view_key.__wbg_ptr);
2988
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
2989
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
2990
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
2991
+ if (r2) {
2992
+ throw takeObject(r1);
2993
+ }
2994
+ return RecordPlaintext.__wrap(r0);
2995
+ } finally {
2996
+ wasm.__wbindgen_add_to_stack_pointer(16);
2997
+ }
2998
+ }
2999
+ /**
3000
+ * Determines if the account corresponding to the view key is the owner of the record
3001
+ *
3002
+ * @param {ViewKey} view_key View key used to decrypt the ciphertext
3003
+ * @returns {boolean}
3004
+ * @param {ViewKey} view_key
3005
+ * @returns {boolean}
3006
+ */
3007
+ isOwner(view_key) {
3008
+ _assertClass(view_key, ViewKey);
3009
+ const ret = wasm.recordciphertext_isOwner(this.__wbg_ptr, view_key.__wbg_ptr);
3010
+ return ret !== 0;
3011
+ }
3012
+ }
3013
+
3014
+ const RecordPlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
3015
+ ? { register: () => {}, unregister: () => {} }
3016
+ : new FinalizationRegistry(ptr => wasm.__wbg_recordplaintext_free(ptr >>> 0));
3017
+ /**
3018
+ * Plaintext representation of an Aleo record
3019
+ */
3020
+ class RecordPlaintext {
3021
+
3022
+ static __wrap(ptr) {
3023
+ ptr = ptr >>> 0;
3024
+ const obj = Object.create(RecordPlaintext.prototype);
3025
+ obj.__wbg_ptr = ptr;
3026
+ RecordPlaintextFinalization.register(obj, obj.__wbg_ptr, obj);
3027
+ return obj;
3028
+ }
3029
+
3030
+ __destroy_into_raw() {
3031
+ const ptr = this.__wbg_ptr;
3032
+ this.__wbg_ptr = 0;
3033
+ RecordPlaintextFinalization.unregister(this);
3034
+ return ptr;
3035
+ }
3036
+
3037
+ free() {
3038
+ const ptr = this.__destroy_into_raw();
3039
+ wasm.__wbg_recordplaintext_free(ptr);
3040
+ }
3041
+ /**
3042
+ * @param {string} program_id
3043
+ * @param {string} record_name
3044
+ * @returns {Field}
3045
+ */
3046
+ commitment(program_id, record_name) {
3047
+ try {
3048
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3049
+ const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3050
+ const len0 = WASM_VECTOR_LEN;
3051
+ const ptr1 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3052
+ const len1 = WASM_VECTOR_LEN;
3053
+ wasm.recordplaintext_commitment(retptr, this.__wbg_ptr, ptr0, len0, ptr1, len1);
3054
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3055
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3056
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3057
+ if (r2) {
3058
+ throw takeObject(r1);
3059
+ }
3060
+ return Field.__wrap(r0);
3061
+ } finally {
3062
+ wasm.__wbindgen_add_to_stack_pointer(16);
3063
+ }
3064
+ }
3065
+ /**
3066
+ * Return a record plaintext from a string.
3067
+ *
3068
+ * @param {string} record String representation of a plaintext representation of an Aleo record
3069
+ * @returns {RecordPlaintext} Record plaintext
3070
+ * @param {string} record
3071
+ * @returns {RecordPlaintext}
3072
+ */
3073
+ static fromString(record) {
3074
+ try {
3075
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3076
+ const ptr0 = passStringToWasm0(record, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3077
+ const len0 = WASM_VECTOR_LEN;
3078
+ wasm.recordplaintext_fromString(retptr, ptr0, len0);
3079
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3080
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3081
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3082
+ if (r2) {
3083
+ throw takeObject(r1);
3084
+ }
3085
+ return RecordPlaintext.__wrap(r0);
3086
+ } finally {
3087
+ wasm.__wbindgen_add_to_stack_pointer(16);
3088
+ }
3089
+ }
3090
+ /**
3091
+ * Returns the record plaintext string
3092
+ *
3093
+ * @returns {string} String representation of the record plaintext
3094
+ * @returns {string}
3095
+ */
3096
+ toString() {
3097
+ let deferred1_0;
3098
+ let deferred1_1;
3099
+ try {
3100
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3101
+ wasm.recordplaintext_toString(retptr, this.__wbg_ptr);
3102
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3103
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3104
+ deferred1_0 = r0;
3105
+ deferred1_1 = r1;
3106
+ return getStringFromWasm0(r0, r1);
3107
+ } finally {
3108
+ wasm.__wbindgen_add_to_stack_pointer(16);
3109
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3110
+ }
3111
+ }
3112
+ /**
3113
+ * Returns the amount of microcredits in the record
3114
+ *
3115
+ * @returns {u64} Amount of microcredits in the record
3116
+ * @returns {bigint}
3117
+ */
3118
+ microcredits() {
3119
+ const ret = wasm.recordplaintext_microcredits(this.__wbg_ptr);
3120
+ return BigInt.asUintN(64, ret);
3121
+ }
3122
+ /**
3123
+ * Returns the nonce of the record. This can be used to uniquely identify a record.
3124
+ *
3125
+ * @returns {string} Nonce of the record
3126
+ * @returns {string}
3127
+ */
3128
+ nonce() {
3129
+ let deferred1_0;
3130
+ let deferred1_1;
3131
+ try {
3132
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3133
+ wasm.recordplaintext_nonce(retptr, this.__wbg_ptr);
3134
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3135
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3136
+ deferred1_0 = r0;
3137
+ deferred1_1 = r1;
3138
+ return getStringFromWasm0(r0, r1);
3139
+ } finally {
3140
+ wasm.__wbindgen_add_to_stack_pointer(16);
3141
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3142
+ }
3143
+ }
3144
+ /**
3145
+ * Attempt to get the serial number of a record to determine whether or not is has been spent
3146
+ *
3147
+ * @param {PrivateKey} private_key Private key of the account that owns the record
3148
+ * @param {string} program_id Program ID of the program that the record is associated with
3149
+ * @param {string} record_name Name of the record
3150
+ * @returns {string} Serial number of the record
3151
+ * @param {PrivateKey} private_key
3152
+ * @param {string} program_id
3153
+ * @param {string} record_name
3154
+ * @returns {string}
3155
+ */
3156
+ serialNumberString(private_key, program_id, record_name) {
3157
+ let deferred4_0;
3158
+ let deferred4_1;
3159
+ try {
3160
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3161
+ _assertClass(private_key, PrivateKey);
3162
+ const ptr0 = passStringToWasm0(program_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3163
+ const len0 = WASM_VECTOR_LEN;
3164
+ const ptr1 = passStringToWasm0(record_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3165
+ const len1 = WASM_VECTOR_LEN;
3166
+ wasm.recordplaintext_serialNumberString(retptr, this.__wbg_ptr, private_key.__wbg_ptr, ptr0, len0, ptr1, len1);
3167
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3168
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3169
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3170
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3171
+ var ptr3 = r0;
3172
+ var len3 = r1;
3173
+ if (r3) {
3174
+ ptr3 = 0; len3 = 0;
3175
+ throw takeObject(r2);
3176
+ }
3177
+ deferred4_0 = ptr3;
3178
+ deferred4_1 = len3;
3179
+ return getStringFromWasm0(ptr3, len3);
3180
+ } finally {
3181
+ wasm.__wbindgen_add_to_stack_pointer(16);
3182
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
3183
+ }
3184
+ }
3185
+ }
3186
+
3187
+ const SignatureFinalization = (typeof FinalizationRegistry === 'undefined')
3188
+ ? { register: () => {}, unregister: () => {} }
3189
+ : new FinalizationRegistry(ptr => wasm.__wbg_signature_free(ptr >>> 0));
3190
+ /**
3191
+ * Cryptographic signature of a message signed by an Aleo account
3192
+ */
3193
+ class Signature {
3194
+
3195
+ static __wrap(ptr) {
3196
+ ptr = ptr >>> 0;
3197
+ const obj = Object.create(Signature.prototype);
3198
+ obj.__wbg_ptr = ptr;
3199
+ SignatureFinalization.register(obj, obj.__wbg_ptr, obj);
3200
+ return obj;
3201
+ }
3202
+
3203
+ __destroy_into_raw() {
3204
+ const ptr = this.__wbg_ptr;
3205
+ this.__wbg_ptr = 0;
3206
+ SignatureFinalization.unregister(this);
3207
+ return ptr;
3208
+ }
3209
+
3210
+ free() {
3211
+ const ptr = this.__destroy_into_raw();
3212
+ wasm.__wbg_signature_free(ptr);
3213
+ }
3214
+ /**
3215
+ * Sign a message with a private key
3216
+ *
3217
+ * @param {PrivateKey} private_key The private key to sign the message with
3218
+ * @param {Uint8Array} message Byte representation of the message to sign
3219
+ * @returns {Signature} Signature of the message
3220
+ * @param {PrivateKey} private_key
3221
+ * @param {Uint8Array} message
3222
+ * @returns {Signature}
3223
+ */
3224
+ static sign(private_key, message) {
3225
+ _assertClass(private_key, PrivateKey);
3226
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
3227
+ const len0 = WASM_VECTOR_LEN;
3228
+ const ret = wasm.privatekey_sign(private_key.__wbg_ptr, ptr0, len0);
3229
+ return Signature.__wrap(ret);
3230
+ }
3231
+ /**
3232
+ * Verify a signature of a message with an address
3233
+ *
3234
+ * @param {Address} address The address to verify the signature with
3235
+ * @param {Uint8Array} message Byte representation of the message to verify
3236
+ * @returns {boolean} True if the signature is valid, false otherwise
3237
+ * @param {Address} address
3238
+ * @param {Uint8Array} message
3239
+ * @returns {boolean}
3240
+ */
3241
+ verify(address, message) {
3242
+ _assertClass(address, Address);
3243
+ const ptr0 = passArray8ToWasm0(message, wasm.__wbindgen_malloc);
3244
+ const len0 = WASM_VECTOR_LEN;
3245
+ const ret = wasm.signature_verify(this.__wbg_ptr, address.__wbg_ptr, ptr0, len0);
3246
+ return ret !== 0;
3247
+ }
3248
+ /**
3249
+ * Get a signature from a string representation of a signature
3250
+ *
3251
+ * @param {string} signature String representation of a signature
3252
+ * @returns {Signature} Signature
3253
+ * @param {string} signature
3254
+ * @returns {Signature}
3255
+ */
3256
+ static from_string(signature) {
3257
+ const ptr0 = passStringToWasm0(signature, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3258
+ const len0 = WASM_VECTOR_LEN;
3259
+ const ret = wasm.signature_from_string(ptr0, len0);
3260
+ return Signature.__wrap(ret);
3261
+ }
3262
+ /**
3263
+ * Get a string representation of a signature
3264
+ *
3265
+ * @returns {string} String representation of a signature
3266
+ * @returns {string}
3267
+ */
3268
+ to_string() {
3269
+ let deferred1_0;
3270
+ let deferred1_1;
3271
+ try {
3272
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3273
+ wasm.signature_to_string(retptr, this.__wbg_ptr);
3274
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3275
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3276
+ deferred1_0 = r0;
3277
+ deferred1_1 = r1;
3278
+ return getStringFromWasm0(r0, r1);
3279
+ } finally {
3280
+ wasm.__wbindgen_add_to_stack_pointer(16);
3281
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3282
+ }
3283
+ }
3284
+ }
3285
+
3286
+ const TransactionFinalization = (typeof FinalizationRegistry === 'undefined')
3287
+ ? { register: () => {}, unregister: () => {} }
3288
+ : new FinalizationRegistry(ptr => wasm.__wbg_transaction_free(ptr >>> 0));
3289
+ /**
3290
+ * Webassembly Representation of an Aleo transaction
3291
+ *
3292
+ * This object is created when generating an on-chain function deployment or execution and is the
3293
+ * object that should be submitted to the Aleo Network in order to deploy or execute a function.
3294
+ */
3295
+ class Transaction {
3296
+
3297
+ static __wrap(ptr) {
3298
+ ptr = ptr >>> 0;
3299
+ const obj = Object.create(Transaction.prototype);
3300
+ obj.__wbg_ptr = ptr;
3301
+ TransactionFinalization.register(obj, obj.__wbg_ptr, obj);
3302
+ return obj;
3303
+ }
3304
+
3305
+ __destroy_into_raw() {
3306
+ const ptr = this.__wbg_ptr;
3307
+ this.__wbg_ptr = 0;
3308
+ TransactionFinalization.unregister(this);
3309
+ return ptr;
3310
+ }
3311
+
3312
+ free() {
3313
+ const ptr = this.__destroy_into_raw();
3314
+ wasm.__wbg_transaction_free(ptr);
3315
+ }
3316
+ /**
3317
+ * Create a transaction from a string
3318
+ *
3319
+ * @param {string} transaction String representation of a transaction
3320
+ * @returns {Transaction}
3321
+ * @param {string} transaction
3322
+ * @returns {Transaction}
3323
+ */
3324
+ static fromString(transaction) {
3325
+ try {
3326
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3327
+ const ptr0 = passStringToWasm0(transaction, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3328
+ const len0 = WASM_VECTOR_LEN;
3329
+ wasm.transaction_fromString(retptr, ptr0, len0);
3330
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3331
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3332
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3333
+ if (r2) {
3334
+ throw takeObject(r1);
3335
+ }
3336
+ return Transaction.__wrap(r0);
3337
+ } finally {
3338
+ wasm.__wbindgen_add_to_stack_pointer(16);
3339
+ }
3340
+ }
3341
+ /**
3342
+ * Get the transaction as a string. If you want to submit this transaction to the Aleo Network
3343
+ * this function will create the string that should be submitted in the `POST` data.
3344
+ *
3345
+ * @returns {string} String representation of the transaction
3346
+ * @returns {string}
3347
+ */
3348
+ toString() {
3349
+ let deferred1_0;
3350
+ let deferred1_1;
3351
+ try {
3352
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3353
+ wasm.transaction_toString(retptr, this.__wbg_ptr);
3354
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3355
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3356
+ deferred1_0 = r0;
3357
+ deferred1_1 = r1;
3358
+ return getStringFromWasm0(r0, r1);
3359
+ } finally {
3360
+ wasm.__wbindgen_add_to_stack_pointer(16);
3361
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3362
+ }
3363
+ }
3364
+ /**
3365
+ * Get the id of the transaction. This is the merkle root of the transaction's inclusion proof.
3366
+ *
3367
+ * This value can be used to query the status of the transaction on the Aleo Network to see
3368
+ * if it was successful. If successful, the transaction will be included in a block and this
3369
+ * value can be used to lookup the transaction data on-chain.
3370
+ *
3371
+ * @returns {string} Transaction id
3372
+ * @returns {string}
3373
+ */
3374
+ transactionId() {
3375
+ let deferred1_0;
3376
+ let deferred1_1;
3377
+ try {
3378
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3379
+ wasm.transaction_transactionId(retptr, this.__wbg_ptr);
3380
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3381
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3382
+ deferred1_0 = r0;
3383
+ deferred1_1 = r1;
3384
+ return getStringFromWasm0(r0, r1);
3385
+ } finally {
3386
+ wasm.__wbindgen_add_to_stack_pointer(16);
3387
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3388
+ }
3389
+ }
3390
+ /**
3391
+ * Get the type of the transaction (will return "deploy" or "execute")
3392
+ *
3393
+ * @returns {string} Transaction type
3394
+ * @returns {string}
3395
+ */
3396
+ transactionType() {
3397
+ let deferred1_0;
3398
+ let deferred1_1;
3399
+ try {
3400
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3401
+ wasm.transaction_transactionType(retptr, this.__wbg_ptr);
3402
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3403
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3404
+ deferred1_0 = r0;
3405
+ deferred1_1 = r1;
3406
+ return getStringFromWasm0(r0, r1);
3407
+ } finally {
3408
+ wasm.__wbindgen_add_to_stack_pointer(16);
3409
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3410
+ }
3411
+ }
3412
+ }
3413
+
3414
+ const VerifyingKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3415
+ ? { register: () => {}, unregister: () => {} }
3416
+ : new FinalizationRegistry(ptr => wasm.__wbg_verifyingkey_free(ptr >>> 0));
3417
+ /**
3418
+ * Verifying key for a function within an Aleo program
3419
+ */
3420
+ class VerifyingKey {
3421
+
3422
+ static __wrap(ptr) {
3423
+ ptr = ptr >>> 0;
3424
+ const obj = Object.create(VerifyingKey.prototype);
3425
+ obj.__wbg_ptr = ptr;
3426
+ VerifyingKeyFinalization.register(obj, obj.__wbg_ptr, obj);
3427
+ return obj;
3428
+ }
3429
+
3430
+ __destroy_into_raw() {
3431
+ const ptr = this.__wbg_ptr;
3432
+ this.__wbg_ptr = 0;
3433
+ VerifyingKeyFinalization.unregister(this);
3434
+ return ptr;
3435
+ }
3436
+
3437
+ free() {
3438
+ const ptr = this.__destroy_into_raw();
3439
+ wasm.__wbg_verifyingkey_free(ptr);
3440
+ }
3441
+ /**
3442
+ * Returns the verifying key for the bond_public function
3443
+ *
3444
+ * @returns {VerifyingKey} Verifying key for the bond_public function
3445
+ * @returns {VerifyingKey}
3446
+ */
3447
+ static bondPublicVerifier() {
3448
+ const ret = wasm.verifyingkey_bondPublicVerifier();
3449
+ return VerifyingKey.__wrap(ret);
3450
+ }
3451
+ /**
3452
+ * Returns the verifying key for the bond_validator function
3453
+ *
3454
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
3455
+ * @returns {VerifyingKey}
3456
+ */
3457
+ static bondValidatorVerifier() {
3458
+ const ret = wasm.verifyingkey_bondValidatorVerifier();
3459
+ return VerifyingKey.__wrap(ret);
3460
+ }
3461
+ /**
3462
+ * Returns the verifying key for the claim_delegator function
3463
+ *
3464
+ * @returns {VerifyingKey} Verifying key for the claim_unbond_public function
3465
+ * @returns {VerifyingKey}
3466
+ */
3467
+ static claimUnbondPublicVerifier() {
3468
+ const ret = wasm.verifyingkey_claimUnbondPublicVerifier();
3469
+ return VerifyingKey.__wrap(ret);
3470
+ }
3471
+ /**
3472
+ * Returns the verifying key for the fee_private function
3473
+ *
3474
+ * @returns {VerifyingKey} Verifying key for the fee_private function
3475
+ * @returns {VerifyingKey}
3476
+ */
3477
+ static feePrivateVerifier() {
3478
+ const ret = wasm.verifyingkey_feePrivateVerifier();
3479
+ return VerifyingKey.__wrap(ret);
3480
+ }
3481
+ /**
3482
+ * Returns the verifying key for the fee_public function
3483
+ *
3484
+ * @returns {VerifyingKey} Verifying key for the fee_public function
3485
+ * @returns {VerifyingKey}
3486
+ */
3487
+ static feePublicVerifier() {
3488
+ const ret = wasm.verifyingkey_feePublicVerifier();
3489
+ return VerifyingKey.__wrap(ret);
3490
+ }
3491
+ /**
3492
+ * Returns the verifying key for the inclusion function
3493
+ *
3494
+ * @returns {VerifyingKey} Verifying key for the inclusion function
3495
+ * @returns {VerifyingKey}
3496
+ */
3497
+ static inclusionVerifier() {
3498
+ const ret = wasm.verifyingkey_inclusionVerifier();
3499
+ return VerifyingKey.__wrap(ret);
3500
+ }
3501
+ /**
3502
+ * Returns the verifying key for the join function
3503
+ *
3504
+ * @returns {VerifyingKey} Verifying key for the join function
3505
+ * @returns {VerifyingKey}
3506
+ */
3507
+ static joinVerifier() {
3508
+ const ret = wasm.verifyingkey_joinVerifier();
3509
+ return VerifyingKey.__wrap(ret);
3510
+ }
3511
+ /**
3512
+ * Returns the verifying key for the set_validator_state function
3513
+ *
3514
+ * @returns {VerifyingKey} Verifying key for the set_validator_state function
3515
+ * @returns {VerifyingKey}
3516
+ */
3517
+ static setValidatorStateVerifier() {
3518
+ const ret = wasm.verifyingkey_setValidatorStateVerifier();
3519
+ return VerifyingKey.__wrap(ret);
3520
+ }
3521
+ /**
3522
+ * Returns the verifying key for the split function
3523
+ *
3524
+ * @returns {VerifyingKey} Verifying key for the split function
3525
+ * @returns {VerifyingKey}
3526
+ */
3527
+ static splitVerifier() {
3528
+ const ret = wasm.verifyingkey_splitVerifier();
3529
+ return VerifyingKey.__wrap(ret);
3530
+ }
3531
+ /**
3532
+ * Returns the verifying key for the transfer_private function
3533
+ *
3534
+ * @returns {VerifyingKey} Verifying key for the transfer_private function
3535
+ * @returns {VerifyingKey}
3536
+ */
3537
+ static transferPrivateVerifier() {
3538
+ const ret = wasm.verifyingkey_transferPrivateVerifier();
3539
+ return VerifyingKey.__wrap(ret);
3540
+ }
3541
+ /**
3542
+ * Returns the verifying key for the transfer_private_to_public function
3543
+ *
3544
+ * @returns {VerifyingKey} Verifying key for the transfer_private_to_public function
3545
+ * @returns {VerifyingKey}
3546
+ */
3547
+ static transferPrivateToPublicVerifier() {
3548
+ const ret = wasm.verifyingkey_transferPrivateToPublicVerifier();
3549
+ return VerifyingKey.__wrap(ret);
3550
+ }
3551
+ /**
3552
+ * Returns the verifying key for the transfer_public function
3553
+ *
3554
+ * @returns {VerifyingKey} Verifying key for the transfer_public function
3555
+ * @returns {VerifyingKey}
3556
+ */
3557
+ static transferPublicVerifier() {
3558
+ const ret = wasm.verifyingkey_transferPublicVerifier();
3559
+ return VerifyingKey.__wrap(ret);
3560
+ }
3561
+ /**
3562
+ * Returns the verifying key for the transfer_public_as_signer function
3563
+ *
3564
+ * @returns {VerifyingKey} Verifying key for the transfer_public_as_signer function
3565
+ * @returns {VerifyingKey}
3566
+ */
3567
+ static transferPublicAsSignerVerifier() {
3568
+ const ret = wasm.verifyingkey_transferPublicAsSignerVerifier();
3569
+ return VerifyingKey.__wrap(ret);
3570
+ }
3571
+ /**
3572
+ * Returns the verifying key for the transfer_public_to_private function
3573
+ *
3574
+ * @returns {VerifyingKey} Verifying key for the transfer_public_to_private function
3575
+ * @returns {VerifyingKey}
3576
+ */
3577
+ static transferPublicToPrivateVerifier() {
3578
+ const ret = wasm.verifyingkey_transferPublicToPrivateVerifier();
3579
+ return VerifyingKey.__wrap(ret);
3580
+ }
3581
+ /**
3582
+ * Returns the verifying key for the unbond_public function
3583
+ *
3584
+ * @returns {VerifyingKey} Verifying key for the unbond_public function
3585
+ * @returns {VerifyingKey}
3586
+ */
3587
+ static unbondPublicVerifier() {
3588
+ const ret = wasm.verifyingkey_unbondPublicVerifier();
3589
+ return VerifyingKey.__wrap(ret);
3590
+ }
3591
+ /**
3592
+ * Returns the verifying key for the bond_public function
3593
+ *
3594
+ * @returns {VerifyingKey} Verifying key for the bond_public function
3595
+ * @returns {boolean}
3596
+ */
3597
+ isBondPublicVerifier() {
3598
+ const ret = wasm.verifyingkey_isBondPublicVerifier(this.__wbg_ptr);
3599
+ return ret !== 0;
3600
+ }
3601
+ /**
3602
+ * Returns the verifying key for the bond_validator function
3603
+ *
3604
+ * @returns {VerifyingKey} Verifying key for the bond_validator function
3605
+ * @returns {boolean}
3606
+ */
3607
+ isBondValidatorVerifier() {
3608
+ const ret = wasm.verifyingkey_isBondValidatorVerifier(this.__wbg_ptr);
3609
+ return ret !== 0;
3610
+ }
3611
+ /**
3612
+ * Verifies the verifying key is for the claim_delegator function
3613
+ *
3614
+ * @returns {bool}
3615
+ * @returns {boolean}
3616
+ */
3617
+ isClaimUnbondPublicVerifier() {
3618
+ const ret = wasm.verifyingkey_isClaimUnbondPublicVerifier(this.__wbg_ptr);
3619
+ return ret !== 0;
3620
+ }
3621
+ /**
3622
+ * Verifies the verifying key is for the fee_private function
3623
+ *
3624
+ * @returns {bool}
3625
+ * @returns {boolean}
3626
+ */
3627
+ isFeePrivateVerifier() {
3628
+ const ret = wasm.verifyingkey_isFeePrivateVerifier(this.__wbg_ptr);
3629
+ return ret !== 0;
3630
+ }
3631
+ /**
3632
+ * Verifies the verifying key is for the fee_public function
3633
+ *
3634
+ * @returns {bool}
3635
+ * @returns {boolean}
3636
+ */
3637
+ isFeePublicVerifier() {
3638
+ const ret = wasm.verifyingkey_isFeePublicVerifier(this.__wbg_ptr);
3639
+ return ret !== 0;
3640
+ }
3641
+ /**
3642
+ * Verifies the verifying key is for the inclusion function
3643
+ *
3644
+ * @returns {bool}
3645
+ * @returns {boolean}
3646
+ */
3647
+ isInclusionVerifier() {
3648
+ const ret = wasm.verifyingkey_isInclusionVerifier(this.__wbg_ptr);
3649
+ return ret !== 0;
3650
+ }
3651
+ /**
3652
+ * Verifies the verifying key is for the join function
3653
+ *
3654
+ * @returns {bool}
3655
+ * @returns {boolean}
3656
+ */
3657
+ isJoinVerifier() {
3658
+ const ret = wasm.verifyingkey_isJoinVerifier(this.__wbg_ptr);
3659
+ return ret !== 0;
3660
+ }
3661
+ /**
3662
+ * Verifies the verifying key is for the set_validator_state function
3663
+ *
3664
+ * @returns {bool}
3665
+ * @returns {boolean}
3666
+ */
3667
+ isSetValidatorStateVerifier() {
3668
+ const ret = wasm.verifyingkey_isSetValidatorStateVerifier(this.__wbg_ptr);
3669
+ return ret !== 0;
3670
+ }
3671
+ /**
3672
+ * Verifies the verifying key is for the split function
3673
+ *
3674
+ * @returns {bool}
3675
+ * @returns {boolean}
3676
+ */
3677
+ isSplitVerifier() {
3678
+ const ret = wasm.verifyingkey_isSplitVerifier(this.__wbg_ptr);
3679
+ return ret !== 0;
3680
+ }
3681
+ /**
3682
+ * Verifies the verifying key is for the transfer_private function
3683
+ *
3684
+ * @returns {bool}
3685
+ * @returns {boolean}
3686
+ */
3687
+ isTransferPrivateVerifier() {
3688
+ const ret = wasm.verifyingkey_isTransferPrivateVerifier(this.__wbg_ptr);
3689
+ return ret !== 0;
3690
+ }
3691
+ /**
3692
+ * Verifies the verifying key is for the transfer_private_to_public function
3693
+ *
3694
+ * @returns {bool}
3695
+ * @returns {boolean}
3696
+ */
3697
+ isTransferPrivateToPublicVerifier() {
3698
+ const ret = wasm.verifyingkey_isTransferPrivateToPublicVerifier(this.__wbg_ptr);
3699
+ return ret !== 0;
3700
+ }
3701
+ /**
3702
+ * Verifies the verifying key is for the transfer_public function
3703
+ *
3704
+ * @returns {bool}
3705
+ * @returns {boolean}
3706
+ */
3707
+ isTransferPublicVerifier() {
3708
+ const ret = wasm.verifyingkey_isTransferPublicVerifier(this.__wbg_ptr);
3709
+ return ret !== 0;
3710
+ }
3711
+ /**
3712
+ * Verifies the verifying key is for the transfer_public_as_signer function
3713
+ *
3714
+ * @returns {bool}
3715
+ * @returns {boolean}
3716
+ */
3717
+ isTransferPublicAsSignerVerifier() {
3718
+ const ret = wasm.verifyingkey_isTransferPublicAsSignerVerifier(this.__wbg_ptr);
3719
+ return ret !== 0;
3720
+ }
3721
+ /**
3722
+ * Verifies the verifying key is for the transfer_public_to_private function
3723
+ *
3724
+ * @returns {bool}
3725
+ * @returns {boolean}
3726
+ */
3727
+ isTransferPublicToPrivateVerifier() {
3728
+ const ret = wasm.verifyingkey_isTransferPublicToPrivateVerifier(this.__wbg_ptr);
3729
+ return ret !== 0;
3730
+ }
3731
+ /**
3732
+ * Verifies the verifying key is for the unbond_public function
3733
+ *
3734
+ * @returns {bool}
3735
+ * @returns {boolean}
3736
+ */
3737
+ isUnbondPublicVerifier() {
3738
+ const ret = wasm.verifyingkey_isUnbondPublicVerifier(this.__wbg_ptr);
3739
+ return ret !== 0;
3740
+ }
3741
+ /**
3742
+ * Get the checksum of the verifying key
3743
+ *
3744
+ * @returns {string} Checksum of the verifying key
3745
+ * @returns {string}
3746
+ */
3747
+ checksum() {
3748
+ let deferred1_0;
3749
+ let deferred1_1;
3750
+ try {
3751
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3752
+ wasm.verifyingkey_checksum(retptr, this.__wbg_ptr);
3753
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3754
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3755
+ deferred1_0 = r0;
3756
+ deferred1_1 = r1;
3757
+ return getStringFromWasm0(r0, r1);
3758
+ } finally {
3759
+ wasm.__wbindgen_add_to_stack_pointer(16);
3760
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3761
+ }
3762
+ }
3763
+ /**
3764
+ * Create a copy of the verifying key
3765
+ *
3766
+ * @returns {VerifyingKey} A copy of the verifying key
3767
+ * @returns {VerifyingKey}
3768
+ */
3769
+ copy() {
3770
+ const ret = wasm.verifyingkey_copy(this.__wbg_ptr);
3771
+ return VerifyingKey.__wrap(ret);
3772
+ }
3773
+ /**
3774
+ * Construct a new verifying key from a byte array
3775
+ *
3776
+ * @param {Uint8Array} bytes Byte representation of a verifying key
3777
+ * @returns {VerifyingKey}
3778
+ * @param {Uint8Array} bytes
3779
+ * @returns {VerifyingKey}
3780
+ */
3781
+ static fromBytes(bytes) {
3782
+ try {
3783
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3784
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
3785
+ const len0 = WASM_VECTOR_LEN;
3786
+ wasm.verifyingkey_fromBytes(retptr, ptr0, len0);
3787
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3788
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3789
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3790
+ if (r2) {
3791
+ throw takeObject(r1);
3792
+ }
3793
+ return VerifyingKey.__wrap(r0);
3794
+ } finally {
3795
+ wasm.__wbindgen_add_to_stack_pointer(16);
3796
+ }
3797
+ }
3798
+ /**
3799
+ * Create a verifying key from string
3800
+ *
3801
+ * @param {String} string String representation of a verifying key
3802
+ * @returns {VerifyingKey}
3803
+ * @param {string} string
3804
+ * @returns {VerifyingKey}
3805
+ */
3806
+ static fromString(string) {
3807
+ try {
3808
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3809
+ const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3810
+ const len0 = WASM_VECTOR_LEN;
3811
+ wasm.verifyingkey_fromString(retptr, ptr0, len0);
3812
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3813
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3814
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3815
+ if (r2) {
3816
+ throw takeObject(r1);
3817
+ }
3818
+ return VerifyingKey.__wrap(r0);
3819
+ } finally {
3820
+ wasm.__wbindgen_add_to_stack_pointer(16);
3821
+ }
3822
+ }
3823
+ /**
3824
+ * Create a byte array from a verifying key
3825
+ *
3826
+ * @returns {Uint8Array} Byte representation of a verifying key
3827
+ * @returns {Uint8Array}
3828
+ */
3829
+ toBytes() {
3830
+ try {
3831
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3832
+ wasm.verifyingkey_toBytes(retptr, this.__wbg_ptr);
3833
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3834
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3835
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3836
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3837
+ if (r3) {
3838
+ throw takeObject(r2);
3839
+ }
3840
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
3841
+ wasm.__wbindgen_free(r0, r1 * 1, 1);
3842
+ return v1;
3843
+ } finally {
3844
+ wasm.__wbindgen_add_to_stack_pointer(16);
3845
+ }
3846
+ }
3847
+ /**
3848
+ * Get a string representation of the verifying key
3849
+ *
3850
+ * @returns {String} String representation of the verifying key
3851
+ * @returns {string}
3852
+ */
3853
+ toString() {
3854
+ let deferred1_0;
3855
+ let deferred1_1;
3856
+ try {
3857
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3858
+ wasm.verifyingkey_toString(retptr, this.__wbg_ptr);
3859
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3860
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3861
+ deferred1_0 = r0;
3862
+ deferred1_1 = r1;
3863
+ return getStringFromWasm0(r0, r1);
3864
+ } finally {
3865
+ wasm.__wbindgen_add_to_stack_pointer(16);
3866
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3867
+ }
3868
+ }
3869
+ }
3870
+
3871
+ const ViewKeyFinalization = (typeof FinalizationRegistry === 'undefined')
3872
+ ? { register: () => {}, unregister: () => {} }
3873
+ : new FinalizationRegistry(ptr => wasm.__wbg_viewkey_free(ptr >>> 0));
3874
+ /**
3875
+ */
3876
+ class ViewKey {
3877
+
3878
+ static __wrap(ptr) {
3879
+ ptr = ptr >>> 0;
3880
+ const obj = Object.create(ViewKey.prototype);
3881
+ obj.__wbg_ptr = ptr;
3882
+ ViewKeyFinalization.register(obj, obj.__wbg_ptr, obj);
3883
+ return obj;
3884
+ }
3885
+
3886
+ __destroy_into_raw() {
3887
+ const ptr = this.__wbg_ptr;
3888
+ this.__wbg_ptr = 0;
3889
+ ViewKeyFinalization.unregister(this);
3890
+ return ptr;
3891
+ }
3892
+
3893
+ free() {
3894
+ const ptr = this.__destroy_into_raw();
3895
+ wasm.__wbg_viewkey_free(ptr);
3896
+ }
3897
+ /**
3898
+ * Create a new view key from a private key
3899
+ *
3900
+ * @param {PrivateKey} private_key Private key
3901
+ * @returns {ViewKey} View key
3902
+ * @param {PrivateKey} private_key
3903
+ * @returns {ViewKey}
3904
+ */
3905
+ static from_private_key(private_key) {
3906
+ _assertClass(private_key, PrivateKey);
3907
+ const ret = wasm.privatekey_to_view_key(private_key.__wbg_ptr);
3908
+ return ViewKey.__wrap(ret);
3909
+ }
3910
+ /**
3911
+ * Create a new view key from a string representation of a view key
3912
+ *
3913
+ * @param {string} view_key String representation of a view key
3914
+ * @returns {ViewKey} View key
3915
+ * @param {string} view_key
3916
+ * @returns {ViewKey}
3917
+ */
3918
+ static from_string(view_key) {
3919
+ const ptr0 = passStringToWasm0(view_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3920
+ const len0 = WASM_VECTOR_LEN;
3921
+ const ret = wasm.viewkey_from_string(ptr0, len0);
3922
+ return ViewKey.__wrap(ret);
3923
+ }
3924
+ /**
3925
+ * Get a string representation of a view key
3926
+ *
3927
+ * @returns {string} String representation of a view key
3928
+ * @returns {string}
3929
+ */
3930
+ to_string() {
3931
+ let deferred1_0;
3932
+ let deferred1_1;
3933
+ try {
3934
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3935
+ wasm.viewkey_to_string(retptr, this.__wbg_ptr);
3936
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3937
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3938
+ deferred1_0 = r0;
3939
+ deferred1_1 = r1;
3940
+ return getStringFromWasm0(r0, r1);
3941
+ } finally {
3942
+ wasm.__wbindgen_add_to_stack_pointer(16);
3943
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
3944
+ }
3945
+ }
3946
+ /**
3947
+ * Get the address corresponding to a view key
3948
+ *
3949
+ * @returns {Address} Address
3950
+ * @returns {Address}
3951
+ */
3952
+ to_address() {
3953
+ const ret = wasm.address_from_view_key(this.__wbg_ptr);
3954
+ return Address.__wrap(ret);
3955
+ }
3956
+ /**
3957
+ * Decrypt a record ciphertext with a view key
3958
+ *
3959
+ * @param {string} ciphertext String representation of a record ciphertext
3960
+ * @returns {string} String representation of a record plaintext
3961
+ * @param {string} ciphertext
3962
+ * @returns {string}
3963
+ */
3964
+ decrypt(ciphertext) {
3965
+ let deferred3_0;
3966
+ let deferred3_1;
3967
+ try {
3968
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
3969
+ const ptr0 = passStringToWasm0(ciphertext, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
3970
+ const len0 = WASM_VECTOR_LEN;
3971
+ wasm.viewkey_decrypt(retptr, this.__wbg_ptr, ptr0, len0);
3972
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
3973
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
3974
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
3975
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
3976
+ var ptr2 = r0;
3977
+ var len2 = r1;
3978
+ if (r3) {
3979
+ ptr2 = 0; len2 = 0;
3980
+ throw takeObject(r2);
3981
+ }
3982
+ deferred3_0 = ptr2;
3983
+ deferred3_1 = len2;
3984
+ return getStringFromWasm0(ptr2, len2);
3985
+ } finally {
3986
+ wasm.__wbindgen_add_to_stack_pointer(16);
3987
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
3988
+ }
3989
+ }
3990
+ }
3991
+
3992
+ async function __wbg_load(module, imports) {
3993
+ if (typeof Response === 'function' && module instanceof Response) {
3994
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
3995
+ try {
3996
+ return await WebAssembly.instantiateStreaming(module, imports);
3997
+
3998
+ } catch (e) {
3999
+ if (module.headers.get('Content-Type') != 'application/wasm') {
4000
+ 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);
4001
+
4002
+ } else {
4003
+ throw e;
4004
+ }
4005
+ }
4006
+ }
4007
+
4008
+ const bytes = await module.arrayBuffer();
4009
+ return await WebAssembly.instantiate(bytes, imports);
4010
+
4011
+ } else {
4012
+ const instance = await WebAssembly.instantiate(module, imports);
4013
+
4014
+ if (instance instanceof WebAssembly.Instance) {
4015
+ return { instance, module };
4016
+
4017
+ } else {
4018
+ return instance;
4019
+ }
4020
+ }
4021
+ }
4022
+
4023
+ function __wbg_get_imports() {
4024
+ const imports = {};
4025
+ imports.wbg = {};
4026
+ imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
4027
+ takeObject(arg0);
4028
+ };
4029
+ imports.wbg.__wbg_new_71801a555ad9f2aa = function() { return handleError(function () {
4030
+ const ret = new XMLHttpRequest();
4031
+ return addHeapObject(ret);
4032
+ }, arguments) };
4033
+ imports.wbg.__wbg_overrideMimeType_ee9c51919ceb418b = function() { return handleError(function (arg0, arg1, arg2) {
4034
+ getObject(arg0).overrideMimeType(getStringFromWasm0(arg1, arg2));
4035
+ }, arguments) };
4036
+ imports.wbg.__wbg_open_c9eb0cf2c9d95679 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
4037
+ getObject(arg0).open(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4), arg5 !== 0);
4038
+ }, arguments) };
4039
+ imports.wbg.__wbg_send_80d29985093c1ec5 = function() { return handleError(function (arg0) {
4040
+ getObject(arg0).send();
4041
+ }, arguments) };
4042
+ imports.wbg.__wbg_response_7c2e2759084f7279 = function() { return handleError(function (arg0) {
4043
+ const ret = getObject(arg0).response;
4044
+ return addHeapObject(ret);
4045
+ }, arguments) };
4046
+ imports.wbg.__wbg_status_d485fb5a478426fb = function() { return handleError(function (arg0) {
4047
+ const ret = getObject(arg0).status;
4048
+ return ret;
4049
+ }, arguments) };
4050
+ imports.wbg.__wbg_new_72fb9a18b5ae2624 = function() {
4051
+ const ret = new Object();
4052
+ return addHeapObject(ret);
4053
+ };
4054
+ imports.wbg.__wbindgen_string_new = function(arg0, arg1) {
4055
+ const ret = getStringFromWasm0(arg0, arg1);
4056
+ return addHeapObject(ret);
4057
+ };
4058
+ imports.wbg.__wbg_set_1f9b04f170055d33 = function() { return handleError(function (arg0, arg1, arg2) {
4059
+ const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
4060
+ return ret;
4061
+ }, arguments) };
4062
+ imports.wbg.__wbg_new_ab6fd82b10560829 = function() { return handleError(function () {
4063
+ const ret = new Headers();
4064
+ return addHeapObject(ret);
4065
+ }, arguments) };
4066
+ imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
4067
+ const ret = getObject(arg0);
4068
+ return addHeapObject(ret);
4069
+ };
4070
+ imports.wbg.__wbg_new_0d76b0581eca6298 = function() { return handleError(function () {
4071
+ const ret = new AbortController();
4072
+ return addHeapObject(ret);
4073
+ }, arguments) };
4074
+ imports.wbg.__wbg_signal_a61f78a3478fd9bc = function(arg0) {
4075
+ const ret = getObject(arg0).signal;
4076
+ return addHeapObject(ret);
4077
+ };
4078
+ imports.wbg.__wbg_append_7bfcb4937d1d5e29 = function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
4079
+ getObject(arg0).append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
4080
+ }, arguments) };
4081
+ imports.wbg.__wbg_instanceof_Response_849eb93e75734b6e = function(arg0) {
4082
+ let result;
4083
+ try {
4084
+ result = getObject(arg0) instanceof Response;
4085
+ } catch (_) {
4086
+ result = false;
4087
+ }
4088
+ const ret = result;
4089
+ return ret;
4090
+ };
4091
+ imports.wbg.__wbg_status_61a01141acd3cf74 = function(arg0) {
4092
+ const ret = getObject(arg0).status;
4093
+ return ret;
4094
+ };
4095
+ imports.wbg.__wbg_url_5f6dc4009ac5f99d = function(arg0, arg1) {
4096
+ const ret = getObject(arg1).url;
4097
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4098
+ const len1 = WASM_VECTOR_LEN;
4099
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4100
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4101
+ };
4102
+ imports.wbg.__wbg_headers_9620bfada380764a = function(arg0) {
4103
+ const ret = getObject(arg0).headers;
4104
+ return addHeapObject(ret);
4105
+ };
4106
+ imports.wbg.__wbg_iterator_2cee6dadfd956dfa = function() {
4107
+ const ret = Symbol.iterator;
4108
+ return addHeapObject(ret);
4109
+ };
4110
+ imports.wbg.__wbg_get_e3c254076557e348 = function() { return handleError(function (arg0, arg1) {
4111
+ const ret = Reflect.get(getObject(arg0), getObject(arg1));
4112
+ return addHeapObject(ret);
4113
+ }, arguments) };
4114
+ imports.wbg.__wbindgen_is_function = function(arg0) {
4115
+ const ret = typeof(getObject(arg0)) === 'function';
4116
+ return ret;
4117
+ };
4118
+ imports.wbg.__wbg_call_27c0f87801dedf93 = function() { return handleError(function (arg0, arg1) {
4119
+ const ret = getObject(arg0).call(getObject(arg1));
4120
+ return addHeapObject(ret);
4121
+ }, arguments) };
4122
+ imports.wbg.__wbindgen_is_object = function(arg0) {
4123
+ const val = getObject(arg0);
4124
+ const ret = typeof(val) === 'object' && val !== null;
4125
+ return ret;
4126
+ };
4127
+ imports.wbg.__wbg_next_40fc327bfc8770e6 = function(arg0) {
4128
+ const ret = getObject(arg0).next;
4129
+ return addHeapObject(ret);
4130
+ };
4131
+ imports.wbg.__wbg_next_196c84450b364254 = function() { return handleError(function (arg0) {
4132
+ const ret = getObject(arg0).next();
4133
+ return addHeapObject(ret);
4134
+ }, arguments) };
4135
+ imports.wbg.__wbg_done_298b57d23c0fc80c = function(arg0) {
4136
+ const ret = getObject(arg0).done;
4137
+ return ret;
4138
+ };
4139
+ imports.wbg.__wbg_value_d93c65011f51a456 = function(arg0) {
4140
+ const ret = getObject(arg0).value;
4141
+ return addHeapObject(ret);
4142
+ };
4143
+ imports.wbg.__wbg_abort_2aa7521d5690750e = function(arg0) {
4144
+ getObject(arg0).abort();
4145
+ };
4146
+ imports.wbg.__wbg_stringify_8887fe74e1c50d81 = function() { return handleError(function (arg0) {
4147
+ const ret = JSON.stringify(getObject(arg0));
4148
+ return addHeapObject(ret);
4149
+ }, arguments) };
4150
+ imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
4151
+ const obj = getObject(arg1);
4152
+ const ret = typeof(obj) === 'string' ? obj : undefined;
4153
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4154
+ var len1 = WASM_VECTOR_LEN;
4155
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4156
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4157
+ };
4158
+ imports.wbg.__wbg_log_eb85b4536c227931 = function(arg0, arg1) {
4159
+ console.log(getStringFromWasm0(arg0, arg1));
4160
+ };
4161
+ imports.wbg.__wbindgen_bigint_from_u64 = function(arg0) {
4162
+ const ret = BigInt.asUintN(64, arg0);
4163
+ return addHeapObject(ret);
4164
+ };
4165
+ imports.wbg.__wbg_call_b3ca7c6051f9bec1 = function() { return handleError(function (arg0, arg1, arg2) {
4166
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
4167
+ return addHeapObject(ret);
4168
+ }, arguments) };
4169
+ imports.wbg.__wbg_keypair_new = function(arg0) {
4170
+ const ret = KeyPair.__wrap(arg0);
4171
+ return addHeapObject(ret);
4172
+ };
4173
+ imports.wbg.__wbg_transaction_new = function(arg0) {
4174
+ const ret = Transaction.__wrap(arg0);
4175
+ return addHeapObject(ret);
4176
+ };
4177
+ imports.wbg.__wbg_executionresponse_new = function(arg0) {
4178
+ const ret = ExecutionResponse.__wrap(arg0);
4179
+ return addHeapObject(ret);
4180
+ };
4181
+ imports.wbg.__wbg_newwithlength_66ae46612e7f0234 = function(arg0) {
4182
+ const ret = new Array(arg0 >>> 0);
4183
+ return addHeapObject(ret);
4184
+ };
4185
+ imports.wbg.__wbg_set_d4638f722068f043 = function(arg0, arg1, arg2) {
4186
+ getObject(arg0)[arg1 >>> 0] = takeObject(arg2);
4187
+ };
4188
+ imports.wbg.__wbindgen_module = function() {
4189
+ const ret = __wbg_init.__wbindgen_wasm_module;
4190
+ return addHeapObject(ret);
4191
+ };
4192
+ imports.wbg.__wbindgen_memory = function() {
4193
+ const ret = wasm.memory;
4194
+ return addHeapObject(ret);
4195
+ };
4196
+ imports.wbg.__wbg_spawnWorker_4026f00664f3193f = function(arg0, arg1, arg2, arg3) {
4197
+ const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
4198
+ return addHeapObject(ret);
4199
+ };
4200
+ imports.wbg.__wbindgen_cb_drop = function(arg0) {
4201
+ const obj = takeObject(arg0).original;
4202
+ if (obj.cnt-- == 1) {
4203
+ obj.a = 0;
4204
+ return true;
4205
+ }
4206
+ const ret = false;
4207
+ return ret;
4208
+ };
4209
+ imports.wbg.__wbg_new_16b304a2cfa7ff4a = function() {
4210
+ const ret = new Array();
4211
+ return addHeapObject(ret);
4212
+ };
4213
+ imports.wbg.__wbg_push_a5b05aedc7234f9f = function(arg0, arg1) {
4214
+ const ret = getObject(arg0).push(getObject(arg1));
4215
+ return ret;
4216
+ };
4217
+ imports.wbg.__wbg_arrayBuffer_29931d52c7206b02 = function() { return handleError(function (arg0) {
4218
+ const ret = getObject(arg0).arrayBuffer();
4219
+ return addHeapObject(ret);
4220
+ }, arguments) };
4221
+ imports.wbg.__wbg_new_63b92bc8671ed464 = function(arg0) {
4222
+ const ret = new Uint8Array(getObject(arg0));
4223
+ return addHeapObject(ret);
4224
+ };
4225
+ imports.wbg.__wbg_length_c20a40f15020d68a = function(arg0) {
4226
+ const ret = getObject(arg0).length;
4227
+ return ret;
4228
+ };
4229
+ imports.wbg.__wbg_new_81740750da40724f = function(arg0, arg1) {
4230
+ try {
4231
+ var state0 = {a: arg0, b: arg1};
4232
+ var cb0 = (arg0, arg1) => {
4233
+ const a = state0.a;
4234
+ state0.a = 0;
4235
+ try {
4236
+ return __wbg_adapter_282(a, state0.b, arg0, arg1);
4237
+ } finally {
4238
+ state0.a = a;
4239
+ }
4240
+ };
4241
+ const ret = new Promise(cb0);
4242
+ return addHeapObject(ret);
4243
+ } finally {
4244
+ state0.a = state0.b = 0;
4245
+ }
4246
+ };
4247
+ imports.wbg.__wbindgen_number_new = function(arg0) {
4248
+ const ret = arg0;
4249
+ return addHeapObject(ret);
4250
+ };
4251
+ imports.wbg.__wbg_new_abda76e883ba8a5f = function() {
4252
+ const ret = new Error();
4253
+ return addHeapObject(ret);
4254
+ };
4255
+ imports.wbg.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) {
4256
+ const ret = getObject(arg1).stack;
4257
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4258
+ const len1 = WASM_VECTOR_LEN;
4259
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4260
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4261
+ };
4262
+ imports.wbg.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) {
4263
+ let deferred0_0;
4264
+ let deferred0_1;
4265
+ try {
4266
+ deferred0_0 = arg0;
4267
+ deferred0_1 = arg1;
4268
+ console.error(getStringFromWasm0(arg0, arg1));
4269
+ } finally {
4270
+ wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
4271
+ }
4272
+ };
4273
+ imports.wbg.__wbg_buffer_12d079cc21e14bdb = function(arg0) {
4274
+ const ret = getObject(arg0).buffer;
4275
+ return addHeapObject(ret);
4276
+ };
4277
+ imports.wbg.__wbg_newwithbyteoffsetandlength_aa4a17c33a06e5cb = function(arg0, arg1, arg2) {
4278
+ const ret = new Uint8Array(getObject(arg0), arg1 >>> 0, arg2 >>> 0);
4279
+ return addHeapObject(ret);
4280
+ };
4281
+ imports.wbg.__wbg_randomFillSync_5c9c955aa56b6049 = function() { return handleError(function (arg0, arg1) {
4282
+ getObject(arg0).randomFillSync(takeObject(arg1));
4283
+ }, arguments) };
4284
+ imports.wbg.__wbg_subarray_a1f73cd4b5b42fe1 = function(arg0, arg1, arg2) {
4285
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
4286
+ return addHeapObject(ret);
4287
+ };
4288
+ imports.wbg.__wbg_getRandomValues_3aa56aa6edec874c = function() { return handleError(function (arg0, arg1) {
4289
+ getObject(arg0).getRandomValues(getObject(arg1));
4290
+ }, arguments) };
4291
+ imports.wbg.__wbg_set_a47bac70306a19a7 = function(arg0, arg1, arg2) {
4292
+ getObject(arg0).set(getObject(arg1), arg2 >>> 0);
4293
+ };
4294
+ imports.wbg.__wbg_crypto_1d1f22824a6a080c = function(arg0) {
4295
+ const ret = getObject(arg0).crypto;
4296
+ return addHeapObject(ret);
4297
+ };
4298
+ imports.wbg.__wbg_process_4a72847cc503995b = function(arg0) {
4299
+ const ret = getObject(arg0).process;
4300
+ return addHeapObject(ret);
4301
+ };
4302
+ imports.wbg.__wbg_versions_f686565e586dd935 = function(arg0) {
4303
+ const ret = getObject(arg0).versions;
4304
+ return addHeapObject(ret);
4305
+ };
4306
+ imports.wbg.__wbg_node_104a2ff8d6ea03a2 = function(arg0) {
4307
+ const ret = getObject(arg0).node;
4308
+ return addHeapObject(ret);
4309
+ };
4310
+ imports.wbg.__wbindgen_is_string = function(arg0) {
4311
+ const ret = typeof(getObject(arg0)) === 'string';
4312
+ return ret;
4313
+ };
4314
+ imports.wbg.__wbg_require_cca90b1a94a0255b = function() { return handleError(function () {
4315
+ const ret = module.require;
4316
+ return addHeapObject(ret);
4317
+ }, arguments) };
4318
+ imports.wbg.__wbg_msCrypto_eb05e62b530a1508 = function(arg0) {
4319
+ const ret = getObject(arg0).msCrypto;
4320
+ return addHeapObject(ret);
4321
+ };
4322
+ imports.wbg.__wbg_newwithlength_e9b4878cebadb3d3 = function(arg0) {
4323
+ const ret = new Uint8Array(arg0 >>> 0);
4324
+ return addHeapObject(ret);
4325
+ };
4326
+ imports.wbg.__wbg_length_cd7af8117672b8b8 = function(arg0) {
4327
+ const ret = getObject(arg0).length;
4328
+ return ret;
4329
+ };
4330
+ imports.wbg.__wbg_get_bd8e338fbd5f5cc8 = function(arg0, arg1) {
4331
+ const ret = getObject(arg0)[arg1 >>> 0];
4332
+ return addHeapObject(ret);
4333
+ };
4334
+ imports.wbg.__wbg_self_ce0dbfc45cf2f5be = function() { return handleError(function () {
4335
+ const ret = self.self;
4336
+ return addHeapObject(ret);
4337
+ }, arguments) };
4338
+ imports.wbg.__wbg_window_c6fb939a7f436783 = function() { return handleError(function () {
4339
+ const ret = window.window;
4340
+ return addHeapObject(ret);
4341
+ }, arguments) };
4342
+ imports.wbg.__wbg_globalThis_d1e6af4856ba331b = function() { return handleError(function () {
4343
+ const ret = globalThis.globalThis;
4344
+ return addHeapObject(ret);
4345
+ }, arguments) };
4346
+ imports.wbg.__wbg_global_207b558942527489 = function() { return handleError(function () {
4347
+ const ret = global.global;
4348
+ return addHeapObject(ret);
4349
+ }, arguments) };
4350
+ imports.wbg.__wbindgen_is_undefined = function(arg0) {
4351
+ const ret = getObject(arg0) === undefined;
4352
+ return ret;
4353
+ };
4354
+ imports.wbg.__wbg_newnoargs_e258087cd0daa0ea = function(arg0, arg1) {
4355
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
4356
+ return addHeapObject(ret);
4357
+ };
4358
+ imports.wbg.__wbg_has_0af94d20077affa2 = function() { return handleError(function (arg0, arg1) {
4359
+ const ret = Reflect.has(getObject(arg0), getObject(arg1));
4360
+ return ret;
4361
+ }, arguments) };
4362
+ imports.wbg.__wbg_fetch_bc7c8e27076a5c84 = function(arg0) {
4363
+ const ret = fetch(getObject(arg0));
4364
+ return addHeapObject(ret);
4365
+ };
4366
+ imports.wbg.__wbg_fetch_921fad6ef9e883dd = function(arg0, arg1) {
4367
+ const ret = getObject(arg0).fetch(getObject(arg1));
4368
+ return addHeapObject(ret);
4369
+ };
4370
+ imports.wbg.__wbindgen_debug_string = function(arg0, arg1) {
4371
+ const ret = debugString(getObject(arg1));
4372
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4373
+ const len1 = WASM_VECTOR_LEN;
4374
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4375
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4376
+ };
4377
+ imports.wbg.__wbindgen_throw = function(arg0, arg1) {
4378
+ throw new Error(getStringFromWasm0(arg0, arg1));
4379
+ };
4380
+ imports.wbg.__wbindgen_rethrow = function(arg0) {
4381
+ throw takeObject(arg0);
4382
+ };
4383
+ imports.wbg.__wbg_then_a73caa9a87991566 = function(arg0, arg1, arg2) {
4384
+ const ret = getObject(arg0).then(getObject(arg1), getObject(arg2));
4385
+ return addHeapObject(ret);
4386
+ };
4387
+ imports.wbg.__wbg_then_0c86a60e8fcfe9f6 = function(arg0, arg1) {
4388
+ const ret = getObject(arg0).then(getObject(arg1));
4389
+ return addHeapObject(ret);
4390
+ };
4391
+ imports.wbg.__wbg_queueMicrotask_481971b0d87f3dd4 = function(arg0) {
4392
+ queueMicrotask(getObject(arg0));
4393
+ };
4394
+ imports.wbg.__wbg_queueMicrotask_3cbae2ec6b6cd3d6 = function(arg0) {
4395
+ const ret = getObject(arg0).queueMicrotask;
4396
+ return addHeapObject(ret);
4397
+ };
4398
+ imports.wbg.__wbg_resolve_b0083a7967828ec8 = function(arg0) {
4399
+ const ret = Promise.resolve(getObject(arg0));
4400
+ return addHeapObject(ret);
4401
+ };
4402
+ imports.wbg.__wbg_waitAsync_5d743fc9058ba01a = function() {
4403
+ const ret = Atomics.waitAsync;
4404
+ return addHeapObject(ret);
4405
+ };
4406
+ imports.wbg.__wbg_new_8cccba86b0f574cb = function(arg0) {
4407
+ const ret = new Int32Array(getObject(arg0));
4408
+ return addHeapObject(ret);
4409
+ };
4410
+ imports.wbg.__wbg_waitAsync_46d5c36955b71a79 = function(arg0, arg1, arg2) {
4411
+ const ret = Atomics.waitAsync(getObject(arg0), arg1, arg2);
4412
+ return addHeapObject(ret);
4413
+ };
4414
+ imports.wbg.__wbg_async_19c0400d97cc72fe = function(arg0) {
4415
+ const ret = getObject(arg0).async;
4416
+ return ret;
4417
+ };
4418
+ imports.wbg.__wbg_value_571d60108110e917 = function(arg0) {
4419
+ const ret = getObject(arg0).value;
4420
+ return addHeapObject(ret);
4421
+ };
4422
+ imports.wbg.__wbindgen_link_fc1eedd35dc7e0a6 = function(arg0) {
4423
+ const ret = "data:application/javascript," + encodeURIComponent(`onmessage = function (ev) {
4424
+ let [ia, index, value] = ev.data;
4425
+ ia = new Int32Array(ia.buffer);
4426
+ let result = Atomics.wait(ia, index, value);
4427
+ postMessage(result);
4428
+ };
4429
+ `);
4430
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4431
+ const len1 = WASM_VECTOR_LEN;
4432
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4433
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4434
+ };
4435
+ imports.wbg.__wbg_new_d1187ae36d662ef9 = function() { return handleError(function (arg0, arg1) {
4436
+ const ret = new Worker(getStringFromWasm0(arg0, arg1));
4437
+ return addHeapObject(ret);
4438
+ }, arguments) };
4439
+ imports.wbg.__wbg_setonmessage_503809e5bb51bd33 = function(arg0, arg1) {
4440
+ getObject(arg0).onmessage = getObject(arg1);
4441
+ };
4442
+ imports.wbg.__wbg_of_6a70eed8d41f469c = function(arg0, arg1, arg2) {
4443
+ const ret = Array.of(getObject(arg0), getObject(arg1), getObject(arg2));
4444
+ return addHeapObject(ret);
4445
+ };
4446
+ imports.wbg.__wbg_postMessage_7380d10e8b8269df = function() { return handleError(function (arg0, arg1) {
4447
+ getObject(arg0).postMessage(getObject(arg1));
4448
+ }, arguments) };
4449
+ imports.wbg.__wbg_data_3ce7c145ca4fbcdc = function(arg0) {
4450
+ const ret = getObject(arg0).data;
4451
+ return addHeapObject(ret);
4452
+ };
4453
+ imports.wbg.__wbg_newwithstrandinit_3fd6fba4083ff2d0 = function() { return handleError(function (arg0, arg1, arg2) {
4454
+ const ret = new Request(getStringFromWasm0(arg0, arg1), getObject(arg2));
4455
+ return addHeapObject(ret);
4456
+ }, arguments) };
4457
+ imports.wbg.__wbg_responseText_c67ed2d48db10769 = function() { return handleError(function (arg0, arg1) {
4458
+ const ret = getObject(arg1).responseText;
4459
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
4460
+ var len1 = WASM_VECTOR_LEN;
4461
+ getInt32Memory0()[arg0 / 4 + 1] = len1;
4462
+ getInt32Memory0()[arg0 / 4 + 0] = ptr1;
4463
+ }, arguments) };
4464
+ imports.wbg.__wbindgen_closure_wrapper5994 = function(arg0, arg1, arg2) {
4465
+ const ret = makeMutClosure(arg0, arg1, 622, __wbg_adapter_34);
4466
+ return addHeapObject(ret);
4467
+ };
4468
+ imports.wbg.__wbindgen_closure_wrapper6020 = function(arg0, arg1, arg2) {
4469
+ const ret = makeMutClosure(arg0, arg1, 622, __wbg_adapter_34);
4470
+ return addHeapObject(ret);
4471
+ };
4472
+
4473
+ return imports;
4474
+ }
4475
+
4476
+ function __wbg_init_memory(imports, maybe_memory) {
4477
+ imports.wbg.memory = maybe_memory || new WebAssembly.Memory({initial:25,maximum:65536,shared:true});
4478
+ }
4479
+
4480
+ function __wbg_finalize_init(instance, module) {
4481
+ wasm = instance.exports;
4482
+ __wbg_init.__wbindgen_wasm_module = module;
4483
+ cachedBigInt64Memory0 = null;
4484
+ cachedInt32Memory0 = null;
4485
+ cachedUint8Memory0 = null;
4486
+
4487
+ wasm.__wbindgen_start();
4488
+ return wasm;
4489
+ }
4490
+
4491
+ function initSync(module, maybe_memory) {
4492
+ if (wasm !== undefined) return wasm;
4493
+
4494
+ const imports = __wbg_get_imports();
4495
+
4496
+ __wbg_init_memory(imports, maybe_memory);
4497
+
4498
+ if (!(module instanceof WebAssembly.Module)) {
4499
+ module = new WebAssembly.Module(module);
4500
+ }
4501
+
4502
+ const instance = new WebAssembly.Instance(module, imports);
4503
+
4504
+ return __wbg_finalize_init(instance, module);
4505
+ }
4506
+
4507
+ async function __wbg_init(input, maybe_memory) {
4508
+ if (wasm !== undefined) return wasm;
4509
+
4510
+
4511
+ const imports = __wbg_get_imports();
4512
+
4513
+ if (typeof input === 'string' || (typeof Request === 'function' && input instanceof Request) || (typeof URL === 'function' && input instanceof URL)) {
4514
+ input = fetch(input);
4515
+ }
4516
+
4517
+ __wbg_init_memory(imports, maybe_memory);
4518
+
4519
+ const { instance, module } = await __wbg_load(await input, imports);
4520
+
4521
+ return __wbg_finalize_init(instance, module);
4522
+ }
4523
+
4524
+ var exports = /*#__PURE__*/Object.freeze({
4525
+ __proto__: null,
4526
+ Address: Address,
4527
+ Execution: Execution,
4528
+ ExecutionResponse: ExecutionResponse,
4529
+ Field: Field,
4530
+ KeyPair: KeyPair,
4531
+ Metadata: Metadata,
4532
+ OfflineQuery: OfflineQuery,
4533
+ PrivateKey: PrivateKey,
4534
+ PrivateKeyCiphertext: PrivateKeyCiphertext,
4535
+ Program: Program,
4536
+ ProgramManager: ProgramManager,
4537
+ ProvingKey: ProvingKey,
4538
+ RecordCiphertext: RecordCiphertext,
4539
+ RecordPlaintext: RecordPlaintext,
4540
+ Signature: Signature,
4541
+ Transaction: Transaction,
4542
+ VerifyingKey: VerifyingKey,
4543
+ ViewKey: ViewKey,
4544
+ default: __wbg_init,
4545
+ initSync: initSync,
4546
+ initThreadPool: initThreadPool,
4547
+ runRayonThread: runRayonThread,
4548
+ verifyFunctionExecution: verifyFunctionExecution
4549
+ });
4550
+
4551
+ const wasm_path = "aleo_wasm.wasm";
4552
+
4553
+
4554
+ var Cargo = async (opt = {}) => {
4555
+ let {importHook, serverPath, initializeHook} = opt;
4556
+
4557
+ let final_path = wasm_path;
4558
+
4559
+ if (serverPath != null) {
4560
+ final_path = serverPath + /[^\/\\]*$/.exec(final_path)[0];
4561
+ }
4562
+
4563
+ if (importHook != null) {
4564
+ final_path = importHook(final_path);
4565
+ }
4566
+
4567
+ if (initializeHook != null) {
4568
+ await initializeHook(__wbg_init, final_path);
4569
+
4570
+ } else {
4571
+ await __wbg_init(final_path);
4572
+ }
4573
+
4574
+ return exports;
4575
+ };
4576
+
4577
+ export { Cargo as default };
4578
+ //# sourceMappingURL=aleo_wasm.js.map