@puzzlehq/aleo-wasm-web 0.6.11 → 0.6.13

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