@provablehq/wasm 0.6.9

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