@provablehq/wasm 0.9.10-testnet-rc → 0.9.11

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.
@@ -19,7 +19,7 @@ export function verifyFunctionExecution(execution: Execution, verifying_key: Ver
19
19
  /**
20
20
  * Set test consensus version heights for testing.
21
21
  *
22
- * @params {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
22
+ * @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
23
23
  *
24
24
  * @example
25
25
  * import { getOrInitConsensusVersionHeights } from @provablehq/sdk;
@@ -156,6 +156,12 @@ export class Authorization {
156
156
  * @param {Uint8Array} bytes Left-endian bytes representing the Authorization.
157
157
  */
158
158
  static fromBytesLe(bytes: Uint8Array): Authorization;
159
+ /**
160
+ * Get the function name.
161
+ *
162
+ * @returns {string} The function name.
163
+ */
164
+ functionName(): string;
159
165
  /**
160
166
  * Returns `true` if the Authorization is for `credits.aleo/fee_public`.
161
167
  */
@@ -2331,26 +2337,31 @@ export class ProgramManager {
2331
2337
  * @returns {u64} Fee in microcredits
2332
2338
  */
2333
2339
  static estimateFinalizeFee(program: string, _function: string): bigint;
2340
+ /**
2341
+ * Execute an authorization.
2342
+ *
2343
+ * @param authorization The authorization to execute.
2344
+ * @param fee_authorization The fee authorization to execute.
2345
+ * @param program The program authorized to be executed.
2346
+ * @param imports The imports of the program being executed.
2347
+ * @param url The url to get the inclusion proving information from.
2348
+ * @param offline_query Optional offline query object if building a Transaction offline.
2349
+ */
2350
+ static executeAuthorization(authorization: Authorization, fee_authorization: Authorization | null | undefined, program: string, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, fee_proving_key?: ProvingKey | null, fee_verifying_key?: VerifyingKey | null, imports?: object | null, url?: string | null, offline_query?: OfflineQuery | null): Promise<Transaction>;
2334
2351
  /**
2335
2352
  * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
2336
2353
  * verifying keys will be stored in the ProgramManager's memory and used for subsequent
2337
2354
  * program executions.
2338
2355
  *
2339
- * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
2340
- *
2341
- * @param private_key The private key of the sender
2342
- * @param program The source code of the program to estimate the execution fee for
2343
- * @param function The name of the function to execute
2344
- * @param inputs A javascript array of inputs to the function
2345
- * @param url The url of the Aleo network node to send the transaction to
2356
+ * @param program The source code of the program to estimate the execution fee for.
2357
+ * @param function The name of the function to estimate the execution fee for.
2346
2358
  * @param imports (optional) Provide a list of imports to use for the fee estimation in the
2347
2359
  * form of a javascript object where the keys are a string of the program name and the values
2348
2360
  * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2349
- * @param proving_key (optional) Provide a verifying key to use for the fee estimation
2350
- * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
2361
+ * @param edition {
2351
2362
  * @returns {u64} Fee in microcredits
2352
2363
  */
2353
- static estimateExecutionFee(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, url?: string | null, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<bigint>;
2364
+ static estimateExecutionFee(program: string, _function: string, imports?: object | null, edition?: number | null): bigint;
2354
2365
  /**
2355
2366
  * Execute an arbitrary function locally
2356
2367
  *
@@ -2372,6 +2383,20 @@ export class ProgramManager {
2372
2383
  * @param {VerifyingKey | undefined} verifying_key (optional) Provide a verifying key to use for the function execution
2373
2384
  */
2374
2385
  static executeFunctionOffline(private_key: PrivateKey, program: string, _function: string, inputs: Array<any>, prove_execution: boolean, cache: boolean, imports?: object | null, proving_key?: ProvingKey | null, verifying_key?: VerifyingKey | null, url?: string | null, offline_query?: OfflineQuery | null, edition?: number | null): Promise<ExecutionResponse>;
2386
+ /**
2387
+ * Estimate Fee for an Authorization.
2388
+ *
2389
+ * @param authorization Authorization to estimate the fee for.
2390
+ * @param program The program the Authorization is for.
2391
+ * @param imports Provide a list of imports to use for the fee estimation in the
2392
+ * form of a javascript object where the keys are a string of the program name and the values
2393
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
2394
+ * @param offline_query The offline query object used to insert the global state root and state paths needed to create
2395
+ * a valid inclusion proof offline.
2396
+ * @param edition: Optional edition to estimate the fee for.
2397
+ * @returns {u64} Fee in microcredits
2398
+ */
2399
+ static estimateFeeForAuthorization(authorization: Authorization, program: string, imports?: object | null, edition?: number | null): bigint;
2375
2400
  /**
2376
2401
  * Execute Aleo function and create an Aleo execution transaction
2377
2402
  *
Binary file
@@ -267,7 +267,7 @@ function verifyFunctionExecution(execution, verifying_key, program, function_id,
267
267
  /**
268
268
  * Set test consensus version heights for testing.
269
269
  *
270
- * @params {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
270
+ * @param {string | undefined} heights The block heights at which each consensus version applies. This input should be a simple csv list of block heights and there should be one number for each consensus version. If left undefined, the default test heights will be applied.
271
271
  *
272
272
  * @example
273
273
  * import { getOrInitConsensusVersionHeights } from @provablehq/sdk;
@@ -307,7 +307,7 @@ function __wbg_adapter_40(arg0, arg1, arg2) {
307
307
  wasm.__wbindgen_export_6(arg0, arg1, addHeapObject(arg2));
308
308
  }
309
309
 
310
- function __wbg_adapter_867(arg0, arg1, arg2, arg3) {
310
+ function __wbg_adapter_870(arg0, arg1, arg2, arg3) {
311
311
  wasm.__wbindgen_export_7(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
312
312
  }
313
313
 
@@ -686,6 +686,36 @@ class Authorization {
686
686
  wasm.__wbindgen_add_to_stack_pointer(16);
687
687
  }
688
688
  }
689
+ /**
690
+ * Get the function name.
691
+ *
692
+ * @returns {string} The function name.
693
+ * @returns {string}
694
+ */
695
+ functionName() {
696
+ let deferred2_0;
697
+ let deferred2_1;
698
+ try {
699
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
700
+ wasm.authorization_functionName(retptr, this.__wbg_ptr);
701
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
702
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
703
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
704
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
705
+ var ptr1 = r0;
706
+ var len1 = r1;
707
+ if (r3) {
708
+ ptr1 = 0; len1 = 0;
709
+ throw takeObject(r2);
710
+ }
711
+ deferred2_0 = ptr1;
712
+ deferred2_1 = len1;
713
+ return getStringFromWasm0(ptr1, len1);
714
+ } finally {
715
+ wasm.__wbindgen_add_to_stack_pointer(16);
716
+ wasm.__wbindgen_export_2(deferred2_0, deferred2_1, 1);
717
+ }
718
+ }
689
719
  /**
690
720
  * Returns `true` if the Authorization is for `credits.aleo/fee_public`.
691
721
  * @returns {boolean}
@@ -7859,43 +7889,36 @@ class ProgramManager {
7859
7889
  }
7860
7890
  }
7861
7891
  /**
7862
- * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
7863
- * verifying keys will be stored in the ProgramManager's memory and used for subsequent
7864
- * program executions.
7865
- *
7866
- * Disclaimer: Fee estimation is experimental and may not represent a correct estimate on any current or future network
7892
+ * Execute an authorization.
7867
7893
  *
7868
- * @param private_key The private key of the sender
7869
- * @param program The source code of the program to estimate the execution fee for
7870
- * @param function The name of the function to execute
7871
- * @param inputs A javascript array of inputs to the function
7872
- * @param url The url of the Aleo network node to send the transaction to
7873
- * @param imports (optional) Provide a list of imports to use for the fee estimation in the
7874
- * form of a javascript object where the keys are a string of the program name and the values
7875
- * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
7876
- * @param proving_key (optional) Provide a verifying key to use for the fee estimation
7877
- * @param verifying_key (optional) Provide a verifying key to use for the fee estimation
7878
- * @returns {u64} Fee in microcredits
7879
- * @param {PrivateKey} private_key
7894
+ * @param authorization The authorization to execute.
7895
+ * @param fee_authorization The fee authorization to execute.
7896
+ * @param program The program authorized to be executed.
7897
+ * @param imports The imports of the program being executed.
7898
+ * @param url The url to get the inclusion proving information from.
7899
+ * @param offline_query Optional offline query object if building a Transaction offline.
7900
+ * @param {Authorization} authorization
7901
+ * @param {Authorization | null | undefined} fee_authorization
7880
7902
  * @param {string} program
7881
- * @param {string} _function
7882
- * @param {Array<any>} inputs
7883
- * @param {string | null} [url]
7884
- * @param {object | null} [imports]
7885
7903
  * @param {ProvingKey | null} [proving_key]
7886
7904
  * @param {VerifyingKey | null} [verifying_key]
7905
+ * @param {ProvingKey | null} [fee_proving_key]
7906
+ * @param {VerifyingKey | null} [fee_verifying_key]
7907
+ * @param {object | null} [imports]
7908
+ * @param {string | null} [url]
7887
7909
  * @param {OfflineQuery | null} [offline_query]
7888
- * @param {number | null} [edition]
7889
- * @returns {Promise<bigint>}
7910
+ * @returns {Promise<Transaction>}
7890
7911
  */
7891
- static estimateExecutionFee(private_key, program, _function, inputs, url, imports, proving_key, verifying_key, offline_query, edition) {
7892
- _assertClass(private_key, PrivateKey);
7893
- const ptr0 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7894
- const len0 = WASM_VECTOR_LEN;
7895
- const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7896
- const len1 = WASM_VECTOR_LEN;
7897
- var ptr2 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7898
- var len2 = WASM_VECTOR_LEN;
7912
+ static executeAuthorization(authorization, fee_authorization, program, proving_key, verifying_key, fee_proving_key, fee_verifying_key, imports, url, offline_query) {
7913
+ _assertClass(authorization, Authorization);
7914
+ var ptr0 = authorization.__destroy_into_raw();
7915
+ let ptr1 = 0;
7916
+ if (!isLikeNone(fee_authorization)) {
7917
+ _assertClass(fee_authorization, Authorization);
7918
+ ptr1 = fee_authorization.__destroy_into_raw();
7919
+ }
7920
+ const ptr2 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7921
+ const len2 = WASM_VECTOR_LEN;
7899
7922
  let ptr3 = 0;
7900
7923
  if (!isLikeNone(proving_key)) {
7901
7924
  _assertClass(proving_key, ProvingKey);
@@ -7907,13 +7930,62 @@ class ProgramManager {
7907
7930
  ptr4 = verifying_key.__destroy_into_raw();
7908
7931
  }
7909
7932
  let ptr5 = 0;
7933
+ if (!isLikeNone(fee_proving_key)) {
7934
+ _assertClass(fee_proving_key, ProvingKey);
7935
+ ptr5 = fee_proving_key.__destroy_into_raw();
7936
+ }
7937
+ let ptr6 = 0;
7938
+ if (!isLikeNone(fee_verifying_key)) {
7939
+ _assertClass(fee_verifying_key, VerifyingKey);
7940
+ ptr6 = fee_verifying_key.__destroy_into_raw();
7941
+ }
7942
+ var ptr7 = isLikeNone(url) ? 0 : passStringToWasm0(url, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7943
+ var len7 = WASM_VECTOR_LEN;
7944
+ let ptr8 = 0;
7910
7945
  if (!isLikeNone(offline_query)) {
7911
7946
  _assertClass(offline_query, OfflineQuery);
7912
- ptr5 = offline_query.__destroy_into_raw();
7947
+ ptr8 = offline_query.__destroy_into_raw();
7913
7948
  }
7914
- 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, isLikeNone(edition) ? 0xFFFFFF : edition);
7949
+ const ret = wasm.programmanager_executeAuthorization(ptr0, ptr1, ptr2, len2, ptr3, ptr4, ptr5, ptr6, isLikeNone(imports) ? 0 : addHeapObject(imports), ptr7, len7, ptr8);
7915
7950
  return takeObject(ret);
7916
7951
  }
7952
+ /**
7953
+ * Estimate Fee for Aleo function execution. Note if "cache" is set to true, the proving and
7954
+ * verifying keys will be stored in the ProgramManager's memory and used for subsequent
7955
+ * program executions.
7956
+ *
7957
+ * @param program The source code of the program to estimate the execution fee for.
7958
+ * @param function The name of the function to estimate the execution fee for.
7959
+ * @param imports (optional) Provide a list of imports to use for the fee estimation in the
7960
+ * form of a javascript object where the keys are a string of the program name and the values
7961
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
7962
+ * @param edition {
7963
+ * @returns {u64} Fee in microcredits
7964
+ * @param {string} program
7965
+ * @param {string} _function
7966
+ * @param {object | null} [imports]
7967
+ * @param {number | null} [edition]
7968
+ * @returns {bigint}
7969
+ */
7970
+ static estimateExecutionFee(program, _function, imports, edition) {
7971
+ try {
7972
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
7973
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7974
+ const len0 = WASM_VECTOR_LEN;
7975
+ const ptr1 = passStringToWasm0(_function, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
7976
+ const len1 = WASM_VECTOR_LEN;
7977
+ wasm.programmanager_estimateExecutionFee(retptr, ptr0, len0, ptr1, len1, isLikeNone(imports) ? 0 : addHeapObject(imports), isLikeNone(edition) ? 0xFFFFFF : edition);
7978
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
7979
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
7980
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
7981
+ if (r3) {
7982
+ throw takeObject(r2);
7983
+ }
7984
+ return BigInt.asUintN(64, r0);
7985
+ } finally {
7986
+ wasm.__wbindgen_add_to_stack_pointer(16);
7987
+ }
7988
+ }
7917
7989
  /**
7918
7990
  * Execute an arbitrary function locally
7919
7991
  *
@@ -7973,6 +8045,42 @@ class ProgramManager {
7973
8045
  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, isLikeNone(edition) ? 0xFFFFFF : edition);
7974
8046
  return takeObject(ret);
7975
8047
  }
8048
+ /**
8049
+ * Estimate Fee for an Authorization.
8050
+ *
8051
+ * @param authorization Authorization to estimate the fee for.
8052
+ * @param program The program the Authorization is for.
8053
+ * @param imports Provide a list of imports to use for the fee estimation in the
8054
+ * form of a javascript object where the keys are a string of the program name and the values
8055
+ * are a string representing the program source code \{ "hello.aleo": "hello.aleo source code" \}
8056
+ * @param offline_query The offline query object used to insert the global state root and state paths needed to create
8057
+ * a valid inclusion proof offline.
8058
+ * @param edition: Optional edition to estimate the fee for.
8059
+ * @returns {u64} Fee in microcredits
8060
+ * @param {Authorization} authorization
8061
+ * @param {string} program
8062
+ * @param {object | null} [imports]
8063
+ * @param {number | null} [edition]
8064
+ * @returns {bigint}
8065
+ */
8066
+ static estimateFeeForAuthorization(authorization, program, imports, edition) {
8067
+ try {
8068
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
8069
+ _assertClass(authorization, Authorization);
8070
+ const ptr0 = passStringToWasm0(program, wasm.__wbindgen_export_3, wasm.__wbindgen_export_4);
8071
+ const len0 = WASM_VECTOR_LEN;
8072
+ wasm.programmanager_estimateFeeForAuthorization(retptr, authorization.__wbg_ptr, ptr0, len0, isLikeNone(imports) ? 0 : addHeapObject(imports), isLikeNone(edition) ? 0xFFFFFF : edition);
8073
+ var r0 = getDataViewMemory0().getBigInt64(retptr + 8 * 0, true);
8074
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
8075
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
8076
+ if (r3) {
8077
+ throw takeObject(r2);
8078
+ }
8079
+ return BigInt.asUintN(64, r0);
8080
+ } finally {
8081
+ wasm.__wbindgen_add_to_stack_pointer(16);
8082
+ }
8083
+ }
7976
8084
  /**
7977
8085
  * Execute Aleo function and create an Aleo execution transaction
7978
8086
  *
@@ -13144,7 +13252,7 @@ function __wbg_get_imports() {
13144
13252
  const ret = getObject(arg0).length;
13145
13253
  return ret;
13146
13254
  };
13147
- imports.wbg.__wbg_log_bac25b70f2db29a3 = function(arg0, arg1) {
13255
+ imports.wbg.__wbg_log_bf427d7de6a9bf32 = function(arg0, arg1) {
13148
13256
  console.log(getStringFromWasm0(arg0, arg1));
13149
13257
  };
13150
13258
  imports.wbg.__wbg_msCrypto_0a36e2ec3a343d26 = function(arg0) {
@@ -13162,7 +13270,7 @@ function __wbg_get_imports() {
13162
13270
  const a = state0.a;
13163
13271
  state0.a = 0;
13164
13272
  try {
13165
- return __wbg_adapter_867(a, state0.b, arg0, arg1);
13273
+ return __wbg_adapter_870(a, state0.b, arg0, arg1);
13166
13274
  } finally {
13167
13275
  state0.a = a;
13168
13276
  }
@@ -13349,7 +13457,7 @@ function __wbg_get_imports() {
13349
13457
  const ret = Signature.__wrap(arg0);
13350
13458
  return addHeapObject(ret);
13351
13459
  };
13352
- imports.wbg.__wbg_spawnWorker_231c975bbb3598af = function(arg0, arg1, arg2, arg3) {
13460
+ imports.wbg.__wbg_spawnWorker_dbf0b39172b37e8e = function(arg0, arg1, arg2, arg3) {
13353
13461
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
13354
13462
  return addHeapObject(ret);
13355
13463
  };
@@ -13469,11 +13577,11 @@ function __wbg_get_imports() {
13469
13577
  const ret = false;
13470
13578
  return ret;
13471
13579
  };
13472
- imports.wbg.__wbindgen_closure_wrapper7347 = function(arg0, arg1, arg2) {
13580
+ imports.wbg.__wbindgen_closure_wrapper7380 = function(arg0, arg1, arg2) {
13473
13581
  const ret = makeMutClosure(arg0, arg1, 548, __wbg_adapter_40);
13474
13582
  return addHeapObject(ret);
13475
13583
  };
13476
- imports.wbg.__wbindgen_closure_wrapper7352 = function(arg0, arg1, arg2) {
13584
+ imports.wbg.__wbindgen_closure_wrapper7385 = function(arg0, arg1, arg2) {
13477
13585
  const ret = makeMutClosure(arg0, arg1, 548, __wbg_adapter_40);
13478
13586
  return addHeapObject(ret);
13479
13587
  };