@puzzlehq/aleo-wasm-web 0.6.11 → 0.6.12
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
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { spawnWorker } from './snippets/aleo-wasm-
|
|
1
|
+
import { spawnWorker } from './snippets/aleo-wasm-7414781f25a5869a/inline0.js';
|
|
2
2
|
|
|
3
3
|
let wasm;
|
|
4
4
|
|
|
@@ -22,24 +22,6 @@ function takeObject(idx) {
|
|
|
22
22
|
return ret;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } );
|
|
26
|
-
|
|
27
|
-
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); };
|
|
28
|
-
|
|
29
|
-
let cachedUint8Memory0 = null;
|
|
30
|
-
|
|
31
|
-
function getUint8Memory0() {
|
|
32
|
-
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) {
|
|
33
|
-
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer);
|
|
34
|
-
}
|
|
35
|
-
return cachedUint8Memory0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function getStringFromWasm0(ptr, len) {
|
|
39
|
-
ptr = ptr >>> 0;
|
|
40
|
-
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
25
|
function addHeapObject(obj) {
|
|
44
26
|
if (heap_next === heap.length) heap.push(heap.length + 1);
|
|
45
27
|
const idx = heap_next;
|
|
@@ -51,6 +33,15 @@ function addHeapObject(obj) {
|
|
|
51
33
|
|
|
52
34
|
let WASM_VECTOR_LEN = 0;
|
|
53
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
|
+
|
|
54
45
|
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } );
|
|
55
46
|
|
|
56
47
|
const encodeString = (typeof cachedTextEncoder.encodeInto === 'function'
|
|
@@ -118,6 +109,15 @@ function getInt32Memory0() {
|
|
|
118
109
|
return cachedInt32Memory0;
|
|
119
110
|
}
|
|
120
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
121
|
function debugString(val) {
|
|
122
122
|
// primitive types
|
|
123
123
|
const type = typeof val;
|
|
@@ -231,10 +231,42 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
231
231
|
return ptr;
|
|
232
232
|
}
|
|
233
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
|
+
|
|
234
243
|
function getArrayU8FromWasm0(ptr, len) {
|
|
235
244
|
ptr = ptr >>> 0;
|
|
236
245
|
return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
|
|
237
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
|
+
|
|
238
270
|
/**
|
|
239
271
|
* Verify an execution with a single function and a single transition. Executions with multiple
|
|
240
272
|
* transitions or functions will fail to verify. Also, this does not verify that the state root of
|
|
@@ -272,37 +304,6 @@ export function verifyFunctionExecution(execution, verifying_key, program, funct
|
|
|
272
304
|
}
|
|
273
305
|
}
|
|
274
306
|
|
|
275
|
-
/**
|
|
276
|
-
* @param {number} receiver
|
|
277
|
-
*/
|
|
278
|
-
export function runRayonThread(receiver) {
|
|
279
|
-
wasm.runRayonThread(receiver);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
let cachedBigInt64Memory0 = null;
|
|
283
|
-
|
|
284
|
-
function getBigInt64Memory0() {
|
|
285
|
-
if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) {
|
|
286
|
-
cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer);
|
|
287
|
-
}
|
|
288
|
-
return cachedBigInt64Memory0;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
*/
|
|
292
|
-
export function init_panic_hook() {
|
|
293
|
-
wasm.init_panic_hook();
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* @param {URL} url
|
|
298
|
-
* @param {number} num_threads
|
|
299
|
-
* @returns {Promise<void>}
|
|
300
|
-
*/
|
|
301
|
-
export function initThreadPool(url, num_threads) {
|
|
302
|
-
const ret = wasm.initThreadPool(addHeapObject(url), num_threads);
|
|
303
|
-
return takeObject(ret);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
307
|
function handleError(f, args) {
|
|
307
308
|
try {
|
|
308
309
|
return f.apply(this, args);
|
|
@@ -310,7 +311,7 @@ function handleError(f, args) {
|
|
|
310
311
|
wasm.__wbindgen_exn_store(addHeapObject(e));
|
|
311
312
|
}
|
|
312
313
|
}
|
|
313
|
-
function
|
|
314
|
+
function __wbg_adapter_295(arg0, arg1, arg2, arg3) {
|
|
314
315
|
wasm.wasm_bindgen__convert__closures__invoke2_mut__h69b3d6b389ddc7fb(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
|
|
315
316
|
}
|
|
316
317
|
|
|
@@ -422,6 +423,72 @@ export class Address {
|
|
|
422
423
|
}
|
|
423
424
|
}
|
|
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
|
+
|
|
425
492
|
const ExecutionFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
426
493
|
? { register: () => {}, unregister: () => {} }
|
|
427
494
|
: new FinalizationRegistry(ptr => wasm.__wbg_execution_free(ptr >>> 0));
|
|
@@ -1770,219 +1837,252 @@ export class ProgramManager {
|
|
|
1770
1837
|
wasm.__wbg_programmanager_free(ptr);
|
|
1771
1838
|
}
|
|
1772
1839
|
/**
|
|
1773
|
-
*
|
|
1774
|
-
*
|
|
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
|
|
1775
1863
|
*
|
|
1776
|
-
* @param private_key The private key of the sender
|
|
1777
|
-
* @param
|
|
1778
|
-
* @param
|
|
1779
|
-
* @param
|
|
1780
|
-
* @param
|
|
1781
|
-
*
|
|
1782
|
-
*
|
|
1783
|
-
* @param
|
|
1784
|
-
*
|
|
1785
|
-
*
|
|
1786
|
-
*
|
|
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
|
|
1787
1880
|
* @param {PrivateKey} private_key
|
|
1788
|
-
* @param {
|
|
1789
|
-
* @param {
|
|
1790
|
-
* @param {
|
|
1791
|
-
* @param {
|
|
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]
|
|
1792
1889
|
* @param {string | undefined} [url]
|
|
1793
|
-
* @param {ProvingKey | undefined} [join_proving_key]
|
|
1794
|
-
* @param {VerifyingKey | undefined} [join_verifying_key]
|
|
1795
|
-
* @param {ProvingKey | undefined} [fee_proving_key]
|
|
1796
|
-
* @param {VerifyingKey | undefined} [fee_verifying_key]
|
|
1797
1890
|
* @param {OfflineQuery | undefined} [offline_query]
|
|
1798
|
-
* @returns {Promise<
|
|
1891
|
+
* @returns {Promise<ExecutionResponse>}
|
|
1799
1892
|
*/
|
|
1800
|
-
static
|
|
1893
|
+
static executeFunctionOffline(private_key, program, _function, inputs, prove_execution, cache, imports, proving_key, verifying_key, url, offline_query) {
|
|
1801
1894
|
_assertClass(private_key, PrivateKey);
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
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;
|
|
1806
1899
|
let ptr2 = 0;
|
|
1807
|
-
if (!isLikeNone(
|
|
1808
|
-
_assertClass(
|
|
1809
|
-
ptr2 =
|
|
1900
|
+
if (!isLikeNone(proving_key)) {
|
|
1901
|
+
_assertClass(proving_key, ProvingKey);
|
|
1902
|
+
ptr2 = proving_key.__destroy_into_raw();
|
|
1810
1903
|
}
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
_assertClass(join_proving_key, ProvingKey);
|
|
1816
|
-
ptr4 = join_proving_key.__destroy_into_raw();
|
|
1904
|
+
let ptr3 = 0;
|
|
1905
|
+
if (!isLikeNone(verifying_key)) {
|
|
1906
|
+
_assertClass(verifying_key, VerifyingKey);
|
|
1907
|
+
ptr3 = verifying_key.__destroy_into_raw();
|
|
1817
1908
|
}
|
|
1909
|
+
var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1910
|
+
var len4 = WASM_VECTOR_LEN;
|
|
1818
1911
|
let ptr5 = 0;
|
|
1819
|
-
if (!isLikeNone(
|
|
1820
|
-
_assertClass(
|
|
1821
|
-
ptr5 =
|
|
1822
|
-
}
|
|
1823
|
-
let ptr6 = 0;
|
|
1824
|
-
if (!isLikeNone(fee_proving_key)) {
|
|
1825
|
-
_assertClass(fee_proving_key, ProvingKey);
|
|
1826
|
-
ptr6 = fee_proving_key.__destroy_into_raw();
|
|
1912
|
+
if (!isLikeNone(offline_query)) {
|
|
1913
|
+
_assertClass(offline_query, OfflineQuery);
|
|
1914
|
+
ptr5 = offline_query.__destroy_into_raw();
|
|
1827
1915
|
}
|
|
1828
|
-
|
|
1829
|
-
if (!isLikeNone(fee_verifying_key)) {
|
|
1830
|
-
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1831
|
-
ptr7 = fee_verifying_key.__destroy_into_raw();
|
|
1832
|
-
}
|
|
1833
|
-
let ptr8 = 0;
|
|
1834
|
-
if (!isLikeNone(offline_query)) {
|
|
1835
|
-
_assertClass(offline_query, OfflineQuery);
|
|
1836
|
-
ptr8 = offline_query.__destroy_into_raw();
|
|
1837
|
-
}
|
|
1838
|
-
const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7, ptr8);
|
|
1839
|
-
return takeObject(ret);
|
|
1840
|
-
}
|
|
1841
|
-
/**
|
|
1842
|
-
* Split an Aleo credits record into two separate records. This function does not require a fee.
|
|
1843
|
-
*
|
|
1844
|
-
* @param private_key The private key of the sender
|
|
1845
|
-
* @param split_amount The amount of the credit split. This amount will be subtracted from the
|
|
1846
|
-
* value of the record and two new records will be created with the split amount and the remainder
|
|
1847
|
-
* @param amount_record The record to split
|
|
1848
|
-
* @param url The url of the Aleo network node to send the transaction to
|
|
1849
|
-
* @param split_proving_key (optional) Provide a proving key to use for the split function
|
|
1850
|
-
* @param split_verifying_key (optional) Provide a verifying key to use for the split function
|
|
1851
|
-
* @returns {Transaction | Error} Transaction object
|
|
1852
|
-
* @param {PrivateKey} private_key
|
|
1853
|
-
* @param {number} split_amount
|
|
1854
|
-
* @param {RecordPlaintext} amount_record
|
|
1855
|
-
* @param {string | undefined} [url]
|
|
1856
|
-
* @param {ProvingKey | undefined} [split_proving_key]
|
|
1857
|
-
* @param {VerifyingKey | undefined} [split_verifying_key]
|
|
1858
|
-
* @param {OfflineQuery | undefined} [offline_query]
|
|
1859
|
-
* @returns {Promise<Transaction>}
|
|
1860
|
-
*/
|
|
1861
|
-
static buildSplitTransaction(private_key, split_amount, amount_record, url, split_proving_key, split_verifying_key, offline_query) {
|
|
1862
|
-
_assertClass(private_key, PrivateKey);
|
|
1863
|
-
_assertClass(amount_record, RecordPlaintext);
|
|
1864
|
-
var ptr0 = amount_record.__destroy_into_raw();
|
|
1865
|
-
var ptr1 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1866
|
-
var len1 = WASM_VECTOR_LEN;
|
|
1867
|
-
let ptr2 = 0;
|
|
1868
|
-
if (!isLikeNone(split_proving_key)) {
|
|
1869
|
-
_assertClass(split_proving_key, ProvingKey);
|
|
1870
|
-
ptr2 = split_proving_key.__destroy_into_raw();
|
|
1871
|
-
}
|
|
1872
|
-
let ptr3 = 0;
|
|
1873
|
-
if (!isLikeNone(split_verifying_key)) {
|
|
1874
|
-
_assertClass(split_verifying_key, VerifyingKey);
|
|
1875
|
-
ptr3 = split_verifying_key.__destroy_into_raw();
|
|
1876
|
-
}
|
|
1877
|
-
let ptr4 = 0;
|
|
1878
|
-
if (!isLikeNone(offline_query)) {
|
|
1879
|
-
_assertClass(offline_query, OfflineQuery);
|
|
1880
|
-
ptr4 = offline_query.__destroy_into_raw();
|
|
1881
|
-
}
|
|
1882
|
-
const ret = wasm.programmanager_buildSplitTransaction(private_key.__wbg_ptr, split_amount, ptr0, ptr1, len1, ptr2, ptr3, ptr4);
|
|
1883
|
-
return takeObject(ret);
|
|
1884
|
-
}
|
|
1885
|
-
/**
|
|
1886
|
-
* Synthesize proving and verifying keys for a program
|
|
1887
|
-
*
|
|
1888
|
-
* @param program {string} The program source code of the program to synthesize keys for
|
|
1889
|
-
* @param function_id {string} The function to synthesize keys for
|
|
1890
|
-
* @param inputs {Array} The inputs to the function
|
|
1891
|
-
* @param imports {Object | undefined} The imports for the program
|
|
1892
|
-
* @param {PrivateKey} private_key
|
|
1893
|
-
* @param {string} program
|
|
1894
|
-
* @param {string} function_id
|
|
1895
|
-
* @param {Array<any>} inputs
|
|
1896
|
-
* @param {object | undefined} [imports]
|
|
1897
|
-
* @returns {Promise<KeyPair>}
|
|
1898
|
-
*/
|
|
1899
|
-
static synthesizeKeyPair(private_key, program, function_id, inputs, imports) {
|
|
1900
|
-
_assertClass(private_key, PrivateKey);
|
|
1901
|
-
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1902
|
-
const len0 = WASM_VECTOR_LEN;
|
|
1903
|
-
const ptr1 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1904
|
-
const len1 = WASM_VECTOR_LEN;
|
|
1905
|
-
const ret = wasm.programmanager_synthesizeKeyPair(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), isLikeNone(imports) ? 0 : addHeapObject(imports));
|
|
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);
|
|
1906
1917
|
return takeObject(ret);
|
|
1907
1918
|
}
|
|
1908
1919
|
/**
|
|
1909
|
-
*
|
|
1920
|
+
* Execute Aleo function and create an Aleo execution transaction
|
|
1910
1921
|
*
|
|
1911
1922
|
* @param private_key The private key of the sender
|
|
1912
|
-
* @param
|
|
1913
|
-
* @param
|
|
1914
|
-
* @param
|
|
1915
|
-
* @param amount_record The record to fund the amount from
|
|
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
|
|
1916
1926
|
* @param fee_credits The amount of credits to pay as a fee
|
|
1917
1927
|
* @param fee_record The record to spend the fee from
|
|
1918
1928
|
* @param url The url of the Aleo network node to send the transaction to
|
|
1919
|
-
*
|
|
1920
|
-
*
|
|
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
|
|
1921
1938
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
1922
1939
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
1923
1940
|
* @returns {Transaction | Error}
|
|
1924
1941
|
* @param {PrivateKey} private_key
|
|
1925
|
-
* @param {
|
|
1926
|
-
* @param {string}
|
|
1927
|
-
* @param {
|
|
1928
|
-
* @param {RecordPlaintext | undefined} amount_record
|
|
1942
|
+
* @param {string} program
|
|
1943
|
+
* @param {string} _function
|
|
1944
|
+
* @param {Array<any>} inputs
|
|
1929
1945
|
* @param {number} fee_credits
|
|
1930
1946
|
* @param {RecordPlaintext | undefined} [fee_record]
|
|
1931
1947
|
* @param {string | undefined} [url]
|
|
1932
|
-
* @param {
|
|
1933
|
-
* @param {
|
|
1948
|
+
* @param {object | undefined} [imports]
|
|
1949
|
+
* @param {ProvingKey | undefined} [proving_key]
|
|
1950
|
+
* @param {VerifyingKey | undefined} [verifying_key]
|
|
1934
1951
|
* @param {ProvingKey | undefined} [fee_proving_key]
|
|
1935
1952
|
* @param {VerifyingKey | undefined} [fee_verifying_key]
|
|
1936
1953
|
* @param {OfflineQuery | undefined} [offline_query]
|
|
1937
1954
|
* @returns {Promise<Transaction>}
|
|
1938
1955
|
*/
|
|
1939
|
-
static
|
|
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) {
|
|
1940
1957
|
_assertClass(private_key, PrivateKey);
|
|
1941
|
-
const ptr0 = passStringToWasm0(
|
|
1958
|
+
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1942
1959
|
const len0 = WASM_VECTOR_LEN;
|
|
1943
|
-
const ptr1 = passStringToWasm0(
|
|
1960
|
+
const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1944
1961
|
const len1 = WASM_VECTOR_LEN;
|
|
1945
1962
|
let ptr2 = 0;
|
|
1946
|
-
if (!isLikeNone(amount_record)) {
|
|
1947
|
-
_assertClass(amount_record, RecordPlaintext);
|
|
1948
|
-
ptr2 = amount_record.__destroy_into_raw();
|
|
1949
|
-
}
|
|
1950
|
-
let ptr3 = 0;
|
|
1951
1963
|
if (!isLikeNone(fee_record)) {
|
|
1952
1964
|
_assertClass(fee_record, RecordPlaintext);
|
|
1953
|
-
|
|
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();
|
|
1954
1973
|
}
|
|
1955
|
-
var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1956
|
-
var len4 = WASM_VECTOR_LEN;
|
|
1957
1974
|
let ptr5 = 0;
|
|
1958
|
-
if (!isLikeNone(
|
|
1959
|
-
_assertClass(
|
|
1960
|
-
ptr5 =
|
|
1975
|
+
if (!isLikeNone(verifying_key)) {
|
|
1976
|
+
_assertClass(verifying_key, VerifyingKey);
|
|
1977
|
+
ptr5 = verifying_key.__destroy_into_raw();
|
|
1961
1978
|
}
|
|
1962
1979
|
let ptr6 = 0;
|
|
1963
|
-
if (!isLikeNone(transfer_verifying_key)) {
|
|
1964
|
-
_assertClass(transfer_verifying_key, VerifyingKey);
|
|
1965
|
-
ptr6 = transfer_verifying_key.__destroy_into_raw();
|
|
1966
|
-
}
|
|
1967
|
-
let ptr7 = 0;
|
|
1968
1980
|
if (!isLikeNone(fee_proving_key)) {
|
|
1969
1981
|
_assertClass(fee_proving_key, ProvingKey);
|
|
1970
|
-
|
|
1982
|
+
ptr6 = fee_proving_key.__destroy_into_raw();
|
|
1971
1983
|
}
|
|
1972
|
-
let
|
|
1984
|
+
let ptr7 = 0;
|
|
1973
1985
|
if (!isLikeNone(fee_verifying_key)) {
|
|
1974
1986
|
_assertClass(fee_verifying_key, VerifyingKey);
|
|
1975
|
-
|
|
1987
|
+
ptr7 = fee_verifying_key.__destroy_into_raw();
|
|
1976
1988
|
}
|
|
1977
|
-
let
|
|
1989
|
+
let ptr8 = 0;
|
|
1978
1990
|
if (!isLikeNone(offline_query)) {
|
|
1979
1991
|
_assertClass(offline_query, OfflineQuery);
|
|
1980
|
-
|
|
1992
|
+
ptr8 = offline_query.__destroy_into_raw();
|
|
1981
1993
|
}
|
|
1982
|
-
const ret = wasm.
|
|
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);
|
|
1983
1995
|
return takeObject(ret);
|
|
1984
1996
|
}
|
|
1985
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
|
+
/**
|
|
1986
2086
|
* Deploy an Aleo program
|
|
1987
2087
|
*
|
|
1988
2088
|
* @param private_key The private key of the sender
|
|
@@ -2090,124 +2190,83 @@ export class ProgramManager {
|
|
|
2090
2190
|
}
|
|
2091
2191
|
}
|
|
2092
2192
|
/**
|
|
2093
|
-
*
|
|
2094
|
-
* @param {string} function_id
|
|
2095
|
-
* @param {Array<any>} inputs_str
|
|
2096
|
-
* @param {string} private_key
|
|
2097
|
-
* @param {object | undefined} [imports]
|
|
2098
|
-
* @returns {Promise<string>}
|
|
2099
|
-
*/
|
|
2100
|
-
static authExecute(program, function_id, inputs_str, private_key, imports) {
|
|
2101
|
-
const ptr0 = passStringToWasm0(program, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2102
|
-
const len0 = WASM_VECTOR_LEN;
|
|
2103
|
-
const ptr1 = passStringToWasm0(function_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2104
|
-
const len1 = WASM_VECTOR_LEN;
|
|
2105
|
-
const ptr2 = passStringToWasm0(private_key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2106
|
-
const len2 = WASM_VECTOR_LEN;
|
|
2107
|
-
const ret = wasm.programmanager_authExecute(ptr0, len0, ptr1, len1, addHeapObject(inputs_str), ptr2, len2, isLikeNone(imports) ? 0 : addHeapObject(imports));
|
|
2108
|
-
return takeObject(ret);
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Execute an arbitrary function locally
|
|
2193
|
+
* Split an Aleo credits record into two separate records. This function does not require a fee.
|
|
2112
2194
|
*
|
|
2113
|
-
* @param
|
|
2114
|
-
* @param
|
|
2115
|
-
*
|
|
2116
|
-
* @param
|
|
2117
|
-
* @param
|
|
2118
|
-
*
|
|
2119
|
-
*
|
|
2120
|
-
* @
|
|
2121
|
-
* If this is set to 'true' the keys synthesized will be stored in the Execution Response
|
|
2122
|
-
* and the `ProvingKey` and `VerifyingKey` can be retrieved from the response via the `.getKeys()`
|
|
2123
|
-
* method.
|
|
2124
|
-
* @param {Object | undefined} imports (optional) Provide a list of imports to use for the function execution in the
|
|
2125
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
2126
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2127
|
-
* @param {ProvingKey | undefined} proving_key (optional) Provide a verifying key to use for the function execution
|
|
2128
|
-
* @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
|
|
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
|
|
2129
2203
|
* @param {PrivateKey} private_key
|
|
2130
|
-
* @param {
|
|
2131
|
-
* @param {
|
|
2132
|
-
* @param {Array<any>} inputs
|
|
2133
|
-
* @param {boolean} prove_execution
|
|
2134
|
-
* @param {boolean} cache
|
|
2135
|
-
* @param {object | undefined} [imports]
|
|
2136
|
-
* @param {ProvingKey | undefined} [proving_key]
|
|
2137
|
-
* @param {VerifyingKey | undefined} [verifying_key]
|
|
2204
|
+
* @param {number} split_amount
|
|
2205
|
+
* @param {RecordPlaintext} amount_record
|
|
2138
2206
|
* @param {string | undefined} [url]
|
|
2207
|
+
* @param {ProvingKey | undefined} [split_proving_key]
|
|
2208
|
+
* @param {VerifyingKey | undefined} [split_verifying_key]
|
|
2139
2209
|
* @param {OfflineQuery | undefined} [offline_query]
|
|
2140
|
-
* @returns {Promise<
|
|
2210
|
+
* @returns {Promise<Transaction>}
|
|
2141
2211
|
*/
|
|
2142
|
-
static
|
|
2212
|
+
static buildSplitTransaction(private_key, split_amount, amount_record, url, split_proving_key, split_verifying_key, offline_query) {
|
|
2143
2213
|
_assertClass(private_key, PrivateKey);
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
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;
|
|
2148
2218
|
let ptr2 = 0;
|
|
2149
|
-
if (!isLikeNone(
|
|
2150
|
-
_assertClass(
|
|
2151
|
-
ptr2 =
|
|
2219
|
+
if (!isLikeNone(split_proving_key)) {
|
|
2220
|
+
_assertClass(split_proving_key, ProvingKey);
|
|
2221
|
+
ptr2 = split_proving_key.__destroy_into_raw();
|
|
2152
2222
|
}
|
|
2153
2223
|
let ptr3 = 0;
|
|
2154
|
-
if (!isLikeNone(
|
|
2155
|
-
_assertClass(
|
|
2156
|
-
ptr3 =
|
|
2224
|
+
if (!isLikeNone(split_verifying_key)) {
|
|
2225
|
+
_assertClass(split_verifying_key, VerifyingKey);
|
|
2226
|
+
ptr3 = split_verifying_key.__destroy_into_raw();
|
|
2157
2227
|
}
|
|
2158
|
-
|
|
2159
|
-
var len4 = WASM_VECTOR_LEN;
|
|
2160
|
-
let ptr5 = 0;
|
|
2228
|
+
let ptr4 = 0;
|
|
2161
2229
|
if (!isLikeNone(offline_query)) {
|
|
2162
2230
|
_assertClass(offline_query, OfflineQuery);
|
|
2163
|
-
|
|
2231
|
+
ptr4 = offline_query.__destroy_into_raw();
|
|
2164
2232
|
}
|
|
2165
|
-
const ret = wasm.
|
|
2233
|
+
const ret = wasm.programmanager_buildSplitTransaction(private_key.__wbg_ptr, split_amount, ptr0, ptr1, len1, ptr2, ptr3, ptr4);
|
|
2166
2234
|
return takeObject(ret);
|
|
2167
2235
|
}
|
|
2168
2236
|
/**
|
|
2169
|
-
*
|
|
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
|
|
2170
2239
|
*
|
|
2171
2240
|
* @param private_key The private key of the sender
|
|
2172
|
-
* @param
|
|
2173
|
-
* @param
|
|
2174
|
-
* @param inputs A javascript array of inputs to the function
|
|
2241
|
+
* @param record_1 The first record to combine
|
|
2242
|
+
* @param record_2 The second record to combine
|
|
2175
2243
|
* @param fee_credits The amount of credits to pay as a fee
|
|
2176
2244
|
* @param fee_record The record to spend the fee from
|
|
2177
2245
|
* @param url The url of the Aleo network node to send the transaction to
|
|
2178
|
-
*
|
|
2179
|
-
*
|
|
2180
|
-
* and used for subsequent transactions. If this is set to 'false' the proving and verifying
|
|
2181
|
-
* keys will be deallocated from memory after the transaction is executed.
|
|
2182
|
-
* @param imports (optional) Provide a list of imports to use for the function execution in the
|
|
2183
|
-
* form of a javascript object where the keys are a string of the program name and the values
|
|
2184
|
-
* are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
|
|
2185
|
-
* @param proving_key (optional) Provide a verifying key to use for the function execution
|
|
2186
|
-
* @param verifying_key (optional) Provide a verifying key to use for the function execution
|
|
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
|
|
2187
2248
|
* @param fee_proving_key (optional) Provide a proving key to use for the fee execution
|
|
2188
2249
|
* @param fee_verifying_key (optional) Provide a verifying key to use for the fee execution
|
|
2189
|
-
* @returns {Transaction | Error}
|
|
2250
|
+
* @returns {Transaction | Error} Transaction object
|
|
2190
2251
|
* @param {PrivateKey} private_key
|
|
2191
|
-
* @param {
|
|
2192
|
-
* @param {
|
|
2193
|
-
* @param {Array<any>} inputs
|
|
2252
|
+
* @param {RecordPlaintext} record_1
|
|
2253
|
+
* @param {RecordPlaintext} record_2
|
|
2194
2254
|
* @param {number} fee_credits
|
|
2195
2255
|
* @param {RecordPlaintext | undefined} [fee_record]
|
|
2196
2256
|
* @param {string | undefined} [url]
|
|
2197
|
-
* @param {
|
|
2198
|
-
* @param {
|
|
2199
|
-
* @param {VerifyingKey | undefined} [verifying_key]
|
|
2257
|
+
* @param {ProvingKey | undefined} [join_proving_key]
|
|
2258
|
+
* @param {VerifyingKey | undefined} [join_verifying_key]
|
|
2200
2259
|
* @param {ProvingKey | undefined} [fee_proving_key]
|
|
2201
2260
|
* @param {VerifyingKey | undefined} [fee_verifying_key]
|
|
2202
2261
|
* @param {OfflineQuery | undefined} [offline_query]
|
|
2203
2262
|
* @returns {Promise<Transaction>}
|
|
2204
2263
|
*/
|
|
2205
|
-
static
|
|
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) {
|
|
2206
2265
|
_assertClass(private_key, PrivateKey);
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
|
|
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();
|
|
2211
2270
|
let ptr2 = 0;
|
|
2212
2271
|
if (!isLikeNone(fee_record)) {
|
|
2213
2272
|
_assertClass(fee_record, RecordPlaintext);
|
|
@@ -2216,14 +2275,14 @@ export class ProgramManager {
|
|
|
2216
2275
|
var ptr3 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2217
2276
|
var len3 = WASM_VECTOR_LEN;
|
|
2218
2277
|
let ptr4 = 0;
|
|
2219
|
-
if (!isLikeNone(
|
|
2220
|
-
_assertClass(
|
|
2221
|
-
ptr4 =
|
|
2278
|
+
if (!isLikeNone(join_proving_key)) {
|
|
2279
|
+
_assertClass(join_proving_key, ProvingKey);
|
|
2280
|
+
ptr4 = join_proving_key.__destroy_into_raw();
|
|
2222
2281
|
}
|
|
2223
2282
|
let ptr5 = 0;
|
|
2224
|
-
if (!isLikeNone(
|
|
2225
|
-
_assertClass(
|
|
2226
|
-
ptr5 =
|
|
2283
|
+
if (!isLikeNone(join_verifying_key)) {
|
|
2284
|
+
_assertClass(join_verifying_key, VerifyingKey);
|
|
2285
|
+
ptr5 = join_verifying_key.__destroy_into_raw();
|
|
2227
2286
|
}
|
|
2228
2287
|
let ptr6 = 0;
|
|
2229
2288
|
if (!isLikeNone(fee_proving_key)) {
|
|
@@ -2240,96 +2299,108 @@ export class ProgramManager {
|
|
|
2240
2299
|
_assertClass(offline_query, OfflineQuery);
|
|
2241
2300
|
ptr8 = offline_query.__destroy_into_raw();
|
|
2242
2301
|
}
|
|
2243
|
-
const ret = wasm.
|
|
2302
|
+
const ret = wasm.programmanager_buildJoinTransaction(private_key.__wbg_ptr, ptr0, ptr1, fee_credits, ptr2, ptr3, len3, ptr4, ptr5, ptr6, ptr7, ptr8);
|
|
2244
2303
|
return takeObject(ret);
|
|
2245
2304
|
}
|
|
2246
2305
|
/**
|
|
2247
|
-
*
|
|
2248
|
-
* verifying keys will be stored in the ProgramManager's memory and used for subsequent
|
|
2249
|
-
* program executions.
|
|
2250
|
-
*
|
|
2251
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2306
|
+
* Send credits from one Aleo account to another
|
|
2252
2307
|
*
|
|
2253
2308
|
* @param private_key The private key of the sender
|
|
2254
|
-
* @param
|
|
2255
|
-
* @param
|
|
2256
|
-
* @param
|
|
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
|
|
2257
2315
|
* @param url The url of the Aleo network node to send the transaction to
|
|
2258
|
-
* @param
|
|
2259
|
-
*
|
|
2260
|
-
*
|
|
2261
|
-
* @param
|
|
2262
|
-
* @
|
|
2263
|
-
* @returns {u64 | Error} Fee in microcredits
|
|
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}
|
|
2264
2321
|
* @param {PrivateKey} private_key
|
|
2265
|
-
* @param {
|
|
2266
|
-
* @param {string}
|
|
2267
|
-
* @param {
|
|
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]
|
|
2268
2328
|
* @param {string | undefined} [url]
|
|
2269
|
-
* @param {
|
|
2270
|
-
* @param {
|
|
2271
|
-
* @param {
|
|
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]
|
|
2272
2333
|
* @param {OfflineQuery | undefined} [offline_query]
|
|
2273
|
-
* @returns {Promise<
|
|
2334
|
+
* @returns {Promise<Transaction>}
|
|
2274
2335
|
*/
|
|
2275
|
-
static
|
|
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) {
|
|
2276
2337
|
_assertClass(private_key, PrivateKey);
|
|
2277
|
-
const ptr0 = passStringToWasm0(
|
|
2338
|
+
const ptr0 = passStringToWasm0(recipient, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2278
2339
|
const len0 = WASM_VECTOR_LEN;
|
|
2279
|
-
const ptr1 = passStringToWasm0(
|
|
2340
|
+
const ptr1 = passStringToWasm0(transfer_type, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2280
2341
|
const len1 = WASM_VECTOR_LEN;
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
_assertClass(proving_key, ProvingKey);
|
|
2286
|
-
ptr3 = proving_key.__destroy_into_raw();
|
|
2342
|
+
let ptr2 = 0;
|
|
2343
|
+
if (!isLikeNone(amount_record)) {
|
|
2344
|
+
_assertClass(amount_record, RecordPlaintext);
|
|
2345
|
+
ptr2 = amount_record.__destroy_into_raw();
|
|
2287
2346
|
}
|
|
2288
|
-
let
|
|
2289
|
-
if (!isLikeNone(
|
|
2290
|
-
_assertClass(
|
|
2291
|
-
|
|
2347
|
+
let ptr3 = 0;
|
|
2348
|
+
if (!isLikeNone(fee_record)) {
|
|
2349
|
+
_assertClass(fee_record, RecordPlaintext);
|
|
2350
|
+
ptr3 = fee_record.__destroy_into_raw();
|
|
2292
2351
|
}
|
|
2352
|
+
var ptr4 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2353
|
+
var len4 = WASM_VECTOR_LEN;
|
|
2293
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;
|
|
2294
2375
|
if (!isLikeNone(offline_query)) {
|
|
2295
2376
|
_assertClass(offline_query, OfflineQuery);
|
|
2296
|
-
|
|
2377
|
+
ptr9 = offline_query.__destroy_into_raw();
|
|
2297
2378
|
}
|
|
2298
|
-
const ret = wasm.
|
|
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);
|
|
2299
2380
|
return takeObject(ret);
|
|
2300
2381
|
}
|
|
2301
|
-
/**
|
|
2302
|
-
*
|
|
2303
|
-
* size of the execution of the program in bytes. If the function does not have a finalize
|
|
2304
|
-
* step, then the finalize fee is 0.
|
|
2305
|
-
*
|
|
2306
|
-
* Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
|
|
2382
|
+
/**
|
|
2383
|
+
* Synthesize proving and verifying keys for a program
|
|
2307
2384
|
*
|
|
2308
|
-
* @param program The program
|
|
2309
|
-
* @param
|
|
2310
|
-
* @
|
|
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
|
|
2311
2390
|
* @param {string} program
|
|
2312
|
-
* @param {string}
|
|
2313
|
-
* @
|
|
2391
|
+
* @param {string} function_id
|
|
2392
|
+
* @param {Array<any>} inputs
|
|
2393
|
+
* @param {object | undefined} [imports]
|
|
2394
|
+
* @returns {Promise<KeyPair>}
|
|
2314
2395
|
*/
|
|
2315
|
-
static
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
var r0 = getBigInt64Memory0()[retptr / 8 + 0];
|
|
2324
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2325
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
2326
|
-
if (r3) {
|
|
2327
|
-
throw takeObject(r2);
|
|
2328
|
-
}
|
|
2329
|
-
return BigInt.asUintN(64, r0);
|
|
2330
|
-
} finally {
|
|
2331
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2332
|
-
}
|
|
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);
|
|
2333
2404
|
}
|
|
2334
2405
|
}
|
|
2335
2406
|
|
|
@@ -2361,133 +2432,6 @@ export class ProvingKey {
|
|
|
2361
2432
|
wasm.__wbg_provingkey_free(ptr);
|
|
2362
2433
|
}
|
|
2363
2434
|
/**
|
|
2364
|
-
* Return the checksum of the proving key
|
|
2365
|
-
*
|
|
2366
|
-
* @returns {string} Checksum of the proving key
|
|
2367
|
-
* @returns {string}
|
|
2368
|
-
*/
|
|
2369
|
-
checksum() {
|
|
2370
|
-
let deferred1_0;
|
|
2371
|
-
let deferred1_1;
|
|
2372
|
-
try {
|
|
2373
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2374
|
-
wasm.provingkey_checksum(retptr, this.__wbg_ptr);
|
|
2375
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2376
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2377
|
-
deferred1_0 = r0;
|
|
2378
|
-
deferred1_1 = r1;
|
|
2379
|
-
return getStringFromWasm0(r0, r1);
|
|
2380
|
-
} finally {
|
|
2381
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2382
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2385
|
-
/**
|
|
2386
|
-
* Create a copy of the proving key
|
|
2387
|
-
*
|
|
2388
|
-
* @returns {ProvingKey} A copy of the proving key
|
|
2389
|
-
* @returns {ProvingKey}
|
|
2390
|
-
*/
|
|
2391
|
-
copy() {
|
|
2392
|
-
const ret = wasm.provingkey_copy(this.__wbg_ptr);
|
|
2393
|
-
return ProvingKey.__wrap(ret);
|
|
2394
|
-
}
|
|
2395
|
-
/**
|
|
2396
|
-
* Construct a new proving key from a byte array
|
|
2397
|
-
*
|
|
2398
|
-
* @param {Uint8Array} bytes Byte array representation of a proving key
|
|
2399
|
-
* @returns {ProvingKey | Error}
|
|
2400
|
-
* @param {Uint8Array} bytes
|
|
2401
|
-
* @returns {ProvingKey}
|
|
2402
|
-
*/
|
|
2403
|
-
static fromBytes(bytes) {
|
|
2404
|
-
try {
|
|
2405
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2406
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
2407
|
-
const len0 = WASM_VECTOR_LEN;
|
|
2408
|
-
wasm.provingkey_fromBytes(retptr, ptr0, len0);
|
|
2409
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2410
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2411
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2412
|
-
if (r2) {
|
|
2413
|
-
throw takeObject(r1);
|
|
2414
|
-
}
|
|
2415
|
-
return ProvingKey.__wrap(r0);
|
|
2416
|
-
} finally {
|
|
2417
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2418
|
-
}
|
|
2419
|
-
}
|
|
2420
|
-
/**
|
|
2421
|
-
* Create a proving key from string
|
|
2422
|
-
*
|
|
2423
|
-
* @param {string | Error} String representation of the proving key
|
|
2424
|
-
* @param {string} string
|
|
2425
|
-
* @returns {ProvingKey}
|
|
2426
|
-
*/
|
|
2427
|
-
static fromString(string) {
|
|
2428
|
-
try {
|
|
2429
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2430
|
-
const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
2431
|
-
const len0 = WASM_VECTOR_LEN;
|
|
2432
|
-
wasm.provingkey_fromString(retptr, ptr0, len0);
|
|
2433
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2434
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2435
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2436
|
-
if (r2) {
|
|
2437
|
-
throw takeObject(r1);
|
|
2438
|
-
}
|
|
2439
|
-
return ProvingKey.__wrap(r0);
|
|
2440
|
-
} finally {
|
|
2441
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2442
|
-
}
|
|
2443
|
-
}
|
|
2444
|
-
/**
|
|
2445
|
-
* Return the byte representation of a proving key
|
|
2446
|
-
*
|
|
2447
|
-
* @returns {Uint8Array | Error} Byte array representation of a proving key
|
|
2448
|
-
* @returns {Uint8Array}
|
|
2449
|
-
*/
|
|
2450
|
-
toBytes() {
|
|
2451
|
-
try {
|
|
2452
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2453
|
-
wasm.provingkey_toBytes(retptr, this.__wbg_ptr);
|
|
2454
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2455
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2456
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
2457
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
2458
|
-
if (r3) {
|
|
2459
|
-
throw takeObject(r2);
|
|
2460
|
-
}
|
|
2461
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
2462
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
2463
|
-
return v1;
|
|
2464
|
-
} finally {
|
|
2465
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
/**
|
|
2469
|
-
* Get a string representation of the proving key
|
|
2470
|
-
*
|
|
2471
|
-
* @returns {string} String representation of the proving key
|
|
2472
|
-
* @returns {string}
|
|
2473
|
-
*/
|
|
2474
|
-
toString() {
|
|
2475
|
-
let deferred1_0;
|
|
2476
|
-
let deferred1_1;
|
|
2477
|
-
try {
|
|
2478
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
2479
|
-
wasm.provingkey_toString(retptr, this.__wbg_ptr);
|
|
2480
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
2481
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
2482
|
-
deferred1_0 = r0;
|
|
2483
|
-
deferred1_1 = r1;
|
|
2484
|
-
return getStringFromWasm0(r0, r1);
|
|
2485
|
-
} finally {
|
|
2486
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
2487
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
2488
|
-
}
|
|
2489
|
-
}
|
|
2490
|
-
/**
|
|
2491
2435
|
* Verify if the proving key is for the bond_public function
|
|
2492
2436
|
*
|
|
2493
2437
|
* @example
|
|
@@ -2642,46 +2586,173 @@ export class ProvingKey {
|
|
|
2642
2586
|
return ret !== 0;
|
|
2643
2587
|
}
|
|
2644
2588
|
/**
|
|
2645
|
-
* Verify if the proving key is for the transfer_public_to_private function
|
|
2646
|
-
*
|
|
2647
|
-
* @example
|
|
2648
|
-
* const provingKey = ProvingKey.fromBytes("transfer_public_to_private_proving_key.bin");
|
|
2649
|
-
* provingKey.isTransferPublicToPrivateProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
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
|
|
2650
2689
|
*
|
|
2651
|
-
* @
|
|
2652
|
-
* @
|
|
2690
|
+
* @param {string | Error} String representation of the proving key
|
|
2691
|
+
* @param {string} string
|
|
2692
|
+
* @returns {ProvingKey}
|
|
2653
2693
|
*/
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
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
|
+
}
|
|
2657
2710
|
}
|
|
2658
2711
|
/**
|
|
2659
|
-
*
|
|
2660
|
-
*
|
|
2661
|
-
* @example
|
|
2662
|
-
* const provingKey = ProvingKey.fromBytes("unbond_delegator_as_validator_proving_key.bin");
|
|
2663
|
-
* provingKey.isUnbondDelegatorAsValidatorProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2712
|
+
* Return the byte representation of a proving key
|
|
2664
2713
|
*
|
|
2665
|
-
* @returns {
|
|
2666
|
-
* @returns {
|
|
2714
|
+
* @returns {Uint8Array | Error} Byte array representation of a proving key
|
|
2715
|
+
* @returns {Uint8Array}
|
|
2667
2716
|
*/
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
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
|
+
}
|
|
2671
2734
|
}
|
|
2672
2735
|
/**
|
|
2673
|
-
*
|
|
2674
|
-
*
|
|
2675
|
-
* @example
|
|
2676
|
-
* const provingKey = ProvingKey.fromBytes("unbond_delegator_as_delegator_proving_key.bin");
|
|
2677
|
-
* provingKey.isUnbondDelegatorAsDelegatorProver() ? console.log("Key verified") : throw new Error("Invalid key");
|
|
2736
|
+
* Get a string representation of the proving key
|
|
2678
2737
|
*
|
|
2679
|
-
* @returns {
|
|
2680
|
-
* @returns {
|
|
2738
|
+
* @returns {string} String representation of the proving key
|
|
2739
|
+
* @returns {string}
|
|
2681
2740
|
*/
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
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
|
+
}
|
|
2685
2756
|
}
|
|
2686
2757
|
}
|
|
2687
2758
|
|
|
@@ -3122,91 +3193,248 @@ export class Transaction {
|
|
|
3122
3193
|
wasm.__wbg_transaction_free(ptr);
|
|
3123
3194
|
}
|
|
3124
3195
|
/**
|
|
3125
|
-
* Create a transaction from a string
|
|
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
|
|
3126
3354
|
*
|
|
3127
|
-
* @param {
|
|
3128
|
-
* @returns {
|
|
3129
|
-
* @param {
|
|
3130
|
-
* @returns {
|
|
3355
|
+
* @param {Uint8Array} bytes Byte representation of a verifying key
|
|
3356
|
+
* @returns {VerifyingKey | Error}
|
|
3357
|
+
* @param {Uint8Array} bytes
|
|
3358
|
+
* @returns {VerifyingKey}
|
|
3131
3359
|
*/
|
|
3132
|
-
static
|
|
3360
|
+
static fromBytes(bytes) {
|
|
3133
3361
|
try {
|
|
3134
3362
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3135
|
-
const ptr0 =
|
|
3363
|
+
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
3136
3364
|
const len0 = WASM_VECTOR_LEN;
|
|
3137
|
-
wasm.
|
|
3365
|
+
wasm.verifyingkey_fromBytes(retptr, ptr0, len0);
|
|
3138
3366
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3139
3367
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3140
3368
|
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3141
3369
|
if (r2) {
|
|
3142
3370
|
throw takeObject(r1);
|
|
3143
3371
|
}
|
|
3144
|
-
return
|
|
3372
|
+
return VerifyingKey.__wrap(r0);
|
|
3145
3373
|
} finally {
|
|
3146
3374
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3147
3375
|
}
|
|
3148
3376
|
}
|
|
3149
3377
|
/**
|
|
3150
|
-
*
|
|
3151
|
-
* this function will create the string that should be submitted in the `POST` data.
|
|
3378
|
+
* Create a verifying key from string
|
|
3152
3379
|
*
|
|
3153
|
-
* @
|
|
3154
|
-
* @returns {
|
|
3380
|
+
* @param {String} string String representation of a verifying key
|
|
3381
|
+
* @returns {VerifyingKey | Error}
|
|
3382
|
+
* @param {string} string
|
|
3383
|
+
* @returns {VerifyingKey}
|
|
3155
3384
|
*/
|
|
3156
|
-
|
|
3157
|
-
let deferred1_0;
|
|
3158
|
-
let deferred1_1;
|
|
3385
|
+
static fromString(string) {
|
|
3159
3386
|
try {
|
|
3160
3387
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3161
|
-
wasm.
|
|
3388
|
+
const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3389
|
+
const len0 = WASM_VECTOR_LEN;
|
|
3390
|
+
wasm.verifyingkey_fromString(retptr, ptr0, len0);
|
|
3162
3391
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3163
3392
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3393
|
+
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3394
|
+
if (r2) {
|
|
3395
|
+
throw takeObject(r1);
|
|
3396
|
+
}
|
|
3397
|
+
return VerifyingKey.__wrap(r0);
|
|
3167
3398
|
} finally {
|
|
3168
3399
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3169
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3170
3400
|
}
|
|
3171
3401
|
}
|
|
3172
3402
|
/**
|
|
3173
|
-
*
|
|
3174
|
-
*
|
|
3175
|
-
* This value can be used to query the status of the transaction on the Aleo Network to see
|
|
3176
|
-
* if it was successful. If successful, the transaction will be included in a block and this
|
|
3177
|
-
* value can be used to lookup the transaction data on-chain.
|
|
3403
|
+
* Create a byte array from a verifying key
|
|
3178
3404
|
*
|
|
3179
|
-
* @returns {
|
|
3180
|
-
* @returns {
|
|
3405
|
+
* @returns {Uint8Array | Error} Byte representation of a verifying key
|
|
3406
|
+
* @returns {Uint8Array}
|
|
3181
3407
|
*/
|
|
3182
|
-
|
|
3183
|
-
let deferred1_0;
|
|
3184
|
-
let deferred1_1;
|
|
3408
|
+
toBytes() {
|
|
3185
3409
|
try {
|
|
3186
3410
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3187
|
-
wasm.
|
|
3411
|
+
wasm.verifyingkey_toBytes(retptr, this.__wbg_ptr);
|
|
3188
3412
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3189
3413
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
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;
|
|
3193
3422
|
} finally {
|
|
3194
3423
|
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3195
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3196
3424
|
}
|
|
3197
3425
|
}
|
|
3198
3426
|
/**
|
|
3199
|
-
* Get
|
|
3427
|
+
* Get a string representation of the verifying key
|
|
3200
3428
|
*
|
|
3201
|
-
* @returns {
|
|
3429
|
+
* @returns {String} String representation of the verifying key
|
|
3202
3430
|
* @returns {string}
|
|
3203
3431
|
*/
|
|
3204
|
-
|
|
3432
|
+
toString() {
|
|
3205
3433
|
let deferred1_0;
|
|
3206
3434
|
let deferred1_1;
|
|
3207
3435
|
try {
|
|
3208
3436
|
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3209
|
-
wasm.
|
|
3437
|
+
wasm.verifyingkey_toString(retptr, this.__wbg_ptr);
|
|
3210
3438
|
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3211
3439
|
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3212
3440
|
deferred1_0 = r0;
|
|
@@ -3217,35 +3445,6 @@ export class Transaction {
|
|
|
3217
3445
|
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3218
3446
|
}
|
|
3219
3447
|
}
|
|
3220
|
-
}
|
|
3221
|
-
|
|
3222
|
-
const VerifyingKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
3223
|
-
? { register: () => {}, unregister: () => {} }
|
|
3224
|
-
: new FinalizationRegistry(ptr => wasm.__wbg_verifyingkey_free(ptr >>> 0));
|
|
3225
|
-
/**
|
|
3226
|
-
* Verifying key for a function within an Aleo program
|
|
3227
|
-
*/
|
|
3228
|
-
export class VerifyingKey {
|
|
3229
|
-
|
|
3230
|
-
static __wrap(ptr) {
|
|
3231
|
-
ptr = ptr >>> 0;
|
|
3232
|
-
const obj = Object.create(VerifyingKey.prototype);
|
|
3233
|
-
obj.__wbg_ptr = ptr;
|
|
3234
|
-
VerifyingKeyFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
3235
|
-
return obj;
|
|
3236
|
-
}
|
|
3237
|
-
|
|
3238
|
-
__destroy_into_raw() {
|
|
3239
|
-
const ptr = this.__wbg_ptr;
|
|
3240
|
-
this.__wbg_ptr = 0;
|
|
3241
|
-
VerifyingKeyFinalization.unregister(this);
|
|
3242
|
-
return ptr;
|
|
3243
|
-
}
|
|
3244
|
-
|
|
3245
|
-
free() {
|
|
3246
|
-
const ptr = this.__destroy_into_raw();
|
|
3247
|
-
wasm.__wbg_verifyingkey_free(ptr);
|
|
3248
|
-
}
|
|
3249
3448
|
/**
|
|
3250
3449
|
* Returns the verifying key for the bond_public function
|
|
3251
3450
|
*
|
|
@@ -3526,134 +3725,6 @@ export class VerifyingKey {
|
|
|
3526
3725
|
const ret = wasm.verifyingkey_isUnbondPublicVerifier(this.__wbg_ptr);
|
|
3527
3726
|
return ret !== 0;
|
|
3528
3727
|
}
|
|
3529
|
-
/**
|
|
3530
|
-
* Get the checksum of the verifying key
|
|
3531
|
-
*
|
|
3532
|
-
* @returns {string} Checksum of the verifying key
|
|
3533
|
-
* @returns {string}
|
|
3534
|
-
*/
|
|
3535
|
-
checksum() {
|
|
3536
|
-
let deferred1_0;
|
|
3537
|
-
let deferred1_1;
|
|
3538
|
-
try {
|
|
3539
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3540
|
-
wasm.verifyingkey_checksum(retptr, this.__wbg_ptr);
|
|
3541
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3542
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3543
|
-
deferred1_0 = r0;
|
|
3544
|
-
deferred1_1 = r1;
|
|
3545
|
-
return getStringFromWasm0(r0, r1);
|
|
3546
|
-
} finally {
|
|
3547
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3548
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3549
|
-
}
|
|
3550
|
-
}
|
|
3551
|
-
/**
|
|
3552
|
-
* Create a copy of the verifying key
|
|
3553
|
-
*
|
|
3554
|
-
* @returns {VerifyingKey} A copy of the verifying key
|
|
3555
|
-
* @returns {VerifyingKey}
|
|
3556
|
-
*/
|
|
3557
|
-
copy() {
|
|
3558
|
-
const ret = wasm.verifyingkey_copy(this.__wbg_ptr);
|
|
3559
|
-
return VerifyingKey.__wrap(ret);
|
|
3560
|
-
}
|
|
3561
|
-
/**
|
|
3562
|
-
* Construct a new verifying key from a byte array
|
|
3563
|
-
*
|
|
3564
|
-
* @param {Uint8Array} bytes Byte representation of a verifying key
|
|
3565
|
-
* @returns {VerifyingKey | Error}
|
|
3566
|
-
* @param {Uint8Array} bytes
|
|
3567
|
-
* @returns {VerifyingKey}
|
|
3568
|
-
*/
|
|
3569
|
-
static fromBytes(bytes) {
|
|
3570
|
-
try {
|
|
3571
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3572
|
-
const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
|
|
3573
|
-
const len0 = WASM_VECTOR_LEN;
|
|
3574
|
-
wasm.verifyingkey_fromBytes(retptr, ptr0, len0);
|
|
3575
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3576
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3577
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3578
|
-
if (r2) {
|
|
3579
|
-
throw takeObject(r1);
|
|
3580
|
-
}
|
|
3581
|
-
return VerifyingKey.__wrap(r0);
|
|
3582
|
-
} finally {
|
|
3583
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3584
|
-
}
|
|
3585
|
-
}
|
|
3586
|
-
/**
|
|
3587
|
-
* Create a verifying key from string
|
|
3588
|
-
*
|
|
3589
|
-
* @param {String} string String representation of a verifying key
|
|
3590
|
-
* @returns {VerifyingKey | Error}
|
|
3591
|
-
* @param {string} string
|
|
3592
|
-
* @returns {VerifyingKey}
|
|
3593
|
-
*/
|
|
3594
|
-
static fromString(string) {
|
|
3595
|
-
try {
|
|
3596
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3597
|
-
const ptr0 = passStringToWasm0(string, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
3598
|
-
const len0 = WASM_VECTOR_LEN;
|
|
3599
|
-
wasm.verifyingkey_fromString(retptr, ptr0, len0);
|
|
3600
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3601
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3602
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3603
|
-
if (r2) {
|
|
3604
|
-
throw takeObject(r1);
|
|
3605
|
-
}
|
|
3606
|
-
return VerifyingKey.__wrap(r0);
|
|
3607
|
-
} finally {
|
|
3608
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3609
|
-
}
|
|
3610
|
-
}
|
|
3611
|
-
/**
|
|
3612
|
-
* Create a byte array from a verifying key
|
|
3613
|
-
*
|
|
3614
|
-
* @returns {Uint8Array | Error} Byte representation of a verifying key
|
|
3615
|
-
* @returns {Uint8Array}
|
|
3616
|
-
*/
|
|
3617
|
-
toBytes() {
|
|
3618
|
-
try {
|
|
3619
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3620
|
-
wasm.verifyingkey_toBytes(retptr, this.__wbg_ptr);
|
|
3621
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3622
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3623
|
-
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
|
3624
|
-
var r3 = getInt32Memory0()[retptr / 4 + 3];
|
|
3625
|
-
if (r3) {
|
|
3626
|
-
throw takeObject(r2);
|
|
3627
|
-
}
|
|
3628
|
-
var v1 = getArrayU8FromWasm0(r0, r1).slice();
|
|
3629
|
-
wasm.__wbindgen_free(r0, r1 * 1, 1);
|
|
3630
|
-
return v1;
|
|
3631
|
-
} finally {
|
|
3632
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3633
|
-
}
|
|
3634
|
-
}
|
|
3635
|
-
/**
|
|
3636
|
-
* Get a string representation of the verifying key
|
|
3637
|
-
*
|
|
3638
|
-
* @returns {String} String representation of the verifying key
|
|
3639
|
-
* @returns {string}
|
|
3640
|
-
*/
|
|
3641
|
-
toString() {
|
|
3642
|
-
let deferred1_0;
|
|
3643
|
-
let deferred1_1;
|
|
3644
|
-
try {
|
|
3645
|
-
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
3646
|
-
wasm.verifyingkey_toString(retptr, this.__wbg_ptr);
|
|
3647
|
-
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
|
3648
|
-
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
|
3649
|
-
deferred1_0 = r0;
|
|
3650
|
-
deferred1_1 = r1;
|
|
3651
|
-
return getStringFromWasm0(r0, r1);
|
|
3652
|
-
} finally {
|
|
3653
|
-
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
3654
|
-
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
3655
|
-
}
|
|
3656
|
-
}
|
|
3657
3728
|
}
|
|
3658
3729
|
|
|
3659
3730
|
const ViewKeyFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -3854,11 +3925,11 @@ function __wbg_get_imports() {
|
|
|
3854
3925
|
imports.wbg.__wbindgen_object_drop_ref = function(arg0) {
|
|
3855
3926
|
takeObject(arg0);
|
|
3856
3927
|
};
|
|
3857
|
-
imports.wbg.
|
|
3928
|
+
imports.wbg.__wbg_log_0159ca40cddf5b15 = function(arg0, arg1) {
|
|
3858
3929
|
console.log(getStringFromWasm0(arg0, arg1));
|
|
3859
3930
|
};
|
|
3860
|
-
imports.wbg.
|
|
3861
|
-
const ret =
|
|
3931
|
+
imports.wbg.__wbindgen_object_clone_ref = function(arg0) {
|
|
3932
|
+
const ret = getObject(arg0);
|
|
3862
3933
|
return addHeapObject(ret);
|
|
3863
3934
|
};
|
|
3864
3935
|
imports.wbg.__wbindgen_string_get = function(arg0, arg1) {
|
|
@@ -3869,6 +3940,14 @@ function __wbg_get_imports() {
|
|
|
3869
3940
|
getInt32Memory0()[arg0 / 4 + 1] = len1;
|
|
3870
3941
|
getInt32Memory0()[arg0 / 4 + 0] = ptr1;
|
|
3871
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
|
+
};
|
|
3872
3951
|
imports.wbg.__wbg_transaction_new = function(arg0) {
|
|
3873
3952
|
const ret = Transaction.__wrap(arg0);
|
|
3874
3953
|
return addHeapObject(ret);
|
|
@@ -3877,19 +3956,15 @@ function __wbg_get_imports() {
|
|
|
3877
3956
|
const ret = BigInt.asUintN(64, arg0);
|
|
3878
3957
|
return addHeapObject(ret);
|
|
3879
3958
|
};
|
|
3880
|
-
imports.wbg.__wbg_keypair_new = function(arg0) {
|
|
3881
|
-
const ret = KeyPair.__wrap(arg0);
|
|
3882
|
-
return addHeapObject(ret);
|
|
3883
|
-
};
|
|
3884
3959
|
imports.wbg.__wbg_executionresponse_new = function(arg0) {
|
|
3885
3960
|
const ret = ExecutionResponse.__wrap(arg0);
|
|
3886
3961
|
return addHeapObject(ret);
|
|
3887
3962
|
};
|
|
3888
|
-
imports.wbg.
|
|
3889
|
-
const ret =
|
|
3963
|
+
imports.wbg.__wbg_keypair_new = function(arg0) {
|
|
3964
|
+
const ret = KeyPair.__wrap(arg0);
|
|
3890
3965
|
return addHeapObject(ret);
|
|
3891
3966
|
};
|
|
3892
|
-
imports.wbg.
|
|
3967
|
+
imports.wbg.__wbg_spawnWorker_f6acaddb2e29dc4a = function(arg0, arg1, arg2, arg3) {
|
|
3893
3968
|
const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
|
|
3894
3969
|
return addHeapObject(ret);
|
|
3895
3970
|
};
|
|
@@ -4163,7 +4238,7 @@ function __wbg_get_imports() {
|
|
|
4163
4238
|
const a = state0.a;
|
|
4164
4239
|
state0.a = 0;
|
|
4165
4240
|
try {
|
|
4166
|
-
return
|
|
4241
|
+
return __wbg_adapter_295(a, state0.b, arg0, arg1);
|
|
4167
4242
|
} finally {
|
|
4168
4243
|
state0.a = a;
|
|
4169
4244
|
}
|
|
@@ -4243,8 +4318,8 @@ function __wbg_get_imports() {
|
|
|
4243
4318
|
const ret = wasm.memory;
|
|
4244
4319
|
return addHeapObject(ret);
|
|
4245
4320
|
};
|
|
4246
|
-
imports.wbg.
|
|
4247
|
-
const ret = makeMutClosure(arg0, arg1,
|
|
4321
|
+
imports.wbg.__wbindgen_closure_wrapper6115 = function(arg0, arg1, arg2) {
|
|
4322
|
+
const ret = makeMutClosure(arg0, arg1, 862, __wbg_adapter_32);
|
|
4248
4323
|
return addHeapObject(ret);
|
|
4249
4324
|
};
|
|
4250
4325
|
|