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