@provablehq/wasm 0.9.16-rc → 0.9.17

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.
@@ -56,9 +56,10 @@ export class Address {
56
56
  */
57
57
  static fromFields(fields: Array<any>): Address;
58
58
  /**
59
- * Create an aleo address object from a string representation of an address
59
+ * Create an aleo address object from a string representation of an address.
60
+ * The input is automatically lowercased before parsing.
60
61
  *
61
- * @param {string} address String representation of an addressm
62
+ * @param {string} address String representation of an address
62
63
  * @returns {Address} Address
63
64
  */
64
65
  static from_string(address: string): Address;
@@ -120,6 +121,15 @@ export class Address {
120
121
  * @returns {boolean} Boolean representing whether or not the signature is valid
121
122
  */
122
123
  verify(message: Uint8Array, signature: Signature): boolean;
124
+ /**
125
+ * Check if the input is a valid Aleo address.
126
+ * String addresses are automatically lowercased before validation.
127
+ *
128
+ * @param {string | Uint8Array} address - Either a string representation of an address
129
+ * or a Uint8Array of bytes in little-endian format.
130
+ * @returns {boolean} True if the input is a valid address, false otherwise.
131
+ */
132
+ static isValid(address: any): boolean;
123
133
  /**
124
134
  * Get the group representation of the address object.
125
135
  */
@@ -1678,7 +1688,7 @@ export class Pedersen64 {
1678
1688
  *
1679
1689
  * @example
1680
1690
  * // Get the bond state of an existing address.
1681
- * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
1691
+ * const bondState = await fetch(https://api.provable.com/v2/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
1682
1692
  * // Convert the bond state to a Plaintext object.
1683
1693
  * const bondStatePlaintext = Plaintext.fromString(bond_state);
1684
1694
  * // Convert the Plaintext object to a JS object.
@@ -2292,7 +2302,7 @@ export class ProgramManager {
2292
2302
  * @param broadcast (optional) Flag to indicate if the transaction should be broadcast
2293
2303
  * @returns {Authorization}
2294
2304
  */
2295
- static buildProvingRequest(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, base_fee_credits: number, priority_fee_credits: number, fee_record: RecordPlaintext | null | undefined, imports: object | null | undefined, broadcast: boolean, unchecked: boolean, edition?: number | null): Promise<ProvingRequest>;
2305
+ static buildProvingRequest(private_key: PrivateKey, program: string, function_name: string, inputs: Array<any>, base_fee_credits: number, priority_fee_credits: number, fee_record: RecordPlaintext | null | undefined, imports: object | null | undefined, broadcast: boolean, unchecked: boolean, edition: number | null | undefined, use_fee_master: boolean): Promise<ProvingRequest>;
2296
2306
  /**
2297
2307
  * Join two records together to create a new record with an amount of credits equal to the sum
2298
2308
  * of the credits of the two original records
@@ -4342,6 +4352,20 @@ export class ViewKey {
4342
4352
  * @returns {ViewKey} View key
4343
4353
  */
4344
4354
  static from_string(view_key: string): ViewKey;
4355
+ /**
4356
+ * Get the underlying bytes of a view key.
4357
+ *
4358
+ * @returns {Uint8Array} Left endian byte array representation of the view key.
4359
+ */
4360
+ toBytesLe(): Uint8Array;
4361
+ /**
4362
+ * Get a ViewKey from a series of bytes.
4363
+ *
4364
+ * @param {Uint8Array} bytes A left endian byte array representing the view key.
4365
+ *
4366
+ * @returns {ViewKey} The view key object.
4367
+ */
4368
+ static fromBytesLe(bytes: Uint8Array): ViewKey;
4345
4369
  /**
4346
4370
  * Create a new view key from a private key
4347
4371
  *
Binary file
@@ -384,12 +384,16 @@ function getArrayJsValueFromWasm0(ptr, len) {
384
384
  }
385
385
  return result;
386
386
  }
387
- function __wasm_bindgen_func_elem_7844(arg0, arg1, arg2) {
388
- wasm.__wasm_bindgen_func_elem_7844(arg0, arg1, addHeapObject(arg2));
387
+ function __wasm_bindgen_func_elem_6535(arg0, arg1) {
388
+ wasm.__wasm_bindgen_func_elem_6535(arg0, arg1);
389
389
  }
390
390
 
391
- function __wasm_bindgen_func_elem_6787(arg0, arg1, arg2, arg3) {
392
- wasm.__wasm_bindgen_func_elem_6787(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
391
+ function __wasm_bindgen_func_elem_7853(arg0, arg1, arg2) {
392
+ wasm.__wasm_bindgen_func_elem_7853(arg0, arg1, addHeapObject(arg2));
393
+ }
394
+
395
+ function __wasm_bindgen_func_elem_6806(arg0, arg1, arg2, arg3) {
396
+ wasm.__wasm_bindgen_func_elem_6806(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
393
397
  }
394
398
 
395
399
  const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
@@ -471,9 +475,10 @@ class Address {
471
475
  }
472
476
  }
473
477
  /**
474
- * Create an aleo address object from a string representation of an address
478
+ * Create an aleo address object from a string representation of an address.
479
+ * The input is automatically lowercased before parsing.
475
480
  *
476
- * @param {string} address String representation of an addressm
481
+ * @param {string} address String representation of an address
477
482
  * @returns {Address} Address
478
483
  * @param {string} address
479
484
  * @returns {Address}
@@ -638,6 +643,20 @@ class Address {
638
643
  const ret = wasm.address_verify(this.__wbg_ptr, ptr0, len0, signature.__wbg_ptr);
639
644
  return ret !== 0;
640
645
  }
646
+ /**
647
+ * Check if the input is a valid Aleo address.
648
+ * String addresses are automatically lowercased before validation.
649
+ *
650
+ * @param {string | Uint8Array} address - Either a string representation of an address
651
+ * or a Uint8Array of bytes in little-endian format.
652
+ * @returns {boolean} True if the input is a valid address, false otherwise.
653
+ * @param {any} address
654
+ * @returns {boolean}
655
+ */
656
+ static isValid(address) {
657
+ const ret = wasm.address_isValid(addHeapObject(address));
658
+ return ret !== 0;
659
+ }
641
660
  /**
642
661
  * Get the group representation of the address object.
643
662
  * @returns {Group}
@@ -6057,7 +6076,7 @@ const PlaintextFinalization = (typeof FinalizationRegistry === 'undefined')
6057
6076
  *
6058
6077
  * @example
6059
6078
  * // Get the bond state of an existing address.
6060
- * const bondState = await fetch(https://api.explorer.provable.com/v1/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
6079
+ * const bondState = await fetch(https://api.provable.com/v2/mainnet/program/credits.aleo/mapping/bond_state/aleo12zlythl7htjdtjjjz3ahdj4vl6wk3zuzm37s80l86qpx8fyx95fqnxcn2f);
6061
6080
  * // Convert the bond state to a Plaintext object.
6062
6081
  * const bondStatePlaintext = Plaintext.fromString(bond_state);
6063
6082
  * // Convert the Plaintext object to a JS object.
@@ -7757,10 +7776,11 @@ class ProgramManager {
7757
7776
  * @param {object | null | undefined} imports
7758
7777
  * @param {boolean} broadcast
7759
7778
  * @param {boolean} unchecked
7760
- * @param {number | null} [edition]
7779
+ * @param {number | null | undefined} edition
7780
+ * @param {boolean} use_fee_master
7761
7781
  * @returns {Promise<ProvingRequest>}
7762
7782
  */
7763
- static buildProvingRequest(private_key, program, function_name, inputs, base_fee_credits, priority_fee_credits, fee_record, imports, broadcast, unchecked, edition) {
7783
+ static buildProvingRequest(private_key, program, function_name, inputs, base_fee_credits, priority_fee_credits, fee_record, imports, broadcast, unchecked, edition, use_fee_master) {
7764
7784
  _assertClass(private_key, PrivateKey);
7765
7785
  const ptr0 = passStringToWasm0(program, wasm.__wbindgen_export, wasm.__wbindgen_export2);
7766
7786
  const len0 = WASM_VECTOR_LEN;
@@ -7771,7 +7791,7 @@ class ProgramManager {
7771
7791
  _assertClass(fee_record, RecordPlaintext);
7772
7792
  ptr2 = fee_record.__destroy_into_raw();
7773
7793
  }
7774
- const ret = wasm.programmanager_buildProvingRequest(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), base_fee_credits, priority_fee_credits, ptr2, isLikeNone(imports) ? 0 : addHeapObject(imports), broadcast, unchecked, isLikeNone(edition) ? 0xFFFFFF : edition);
7794
+ const ret = wasm.programmanager_buildProvingRequest(private_key.__wbg_ptr, ptr0, len0, ptr1, len1, addHeapObject(inputs), base_fee_credits, priority_fee_credits, ptr2, isLikeNone(imports) ? 0 : addHeapObject(imports), broadcast, unchecked, isLikeNone(edition) ? 0xFFFFFF : edition, use_fee_master);
7775
7795
  return takeObject(ret);
7776
7796
  }
7777
7797
  /**
@@ -13330,6 +13350,56 @@ class ViewKey {
13330
13350
  const ret = wasm.viewkey_from_string(ptr0, len0);
13331
13351
  return ViewKey.__wrap(ret);
13332
13352
  }
13353
+ /**
13354
+ * Get the underlying bytes of a view key.
13355
+ *
13356
+ * @returns {Uint8Array} Left endian byte array representation of the view key.
13357
+ * @returns {Uint8Array}
13358
+ */
13359
+ toBytesLe() {
13360
+ try {
13361
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
13362
+ wasm.viewkey_toBytesLe(retptr, this.__wbg_ptr);
13363
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
13364
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
13365
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
13366
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
13367
+ if (r3) {
13368
+ throw takeObject(r2);
13369
+ }
13370
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
13371
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
13372
+ return v1;
13373
+ } finally {
13374
+ wasm.__wbindgen_add_to_stack_pointer(16);
13375
+ }
13376
+ }
13377
+ /**
13378
+ * Get a ViewKey from a series of bytes.
13379
+ *
13380
+ * @param {Uint8Array} bytes A left endian byte array representing the view key.
13381
+ *
13382
+ * @returns {ViewKey} The view key object.
13383
+ * @param {Uint8Array} bytes
13384
+ * @returns {ViewKey}
13385
+ */
13386
+ static fromBytesLe(bytes) {
13387
+ try {
13388
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
13389
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_export);
13390
+ const len0 = WASM_VECTOR_LEN;
13391
+ wasm.viewkey_fromBytesLe(retptr, ptr0, len0);
13392
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
13393
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
13394
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
13395
+ if (r2) {
13396
+ throw takeObject(r1);
13397
+ }
13398
+ return ViewKey.__wrap(r0);
13399
+ } finally {
13400
+ wasm.__wbindgen_add_to_stack_pointer(16);
13401
+ }
13402
+ }
13333
13403
  /**
13334
13404
  * Create a new view key from a private key
13335
13405
  *
@@ -13559,6 +13629,10 @@ function __wbg_get_imports(memory) {
13559
13629
  const ret = Ciphertext.__wrap(arg0);
13560
13630
  return addHeapObject(ret);
13561
13631
  };
13632
+ imports.wbg.__wbg_clearTimeout_5a54f8841c30079a = function(arg0) {
13633
+ const ret = clearTimeout(takeObject(arg0));
13634
+ return addHeapObject(ret);
13635
+ };
13562
13636
  imports.wbg.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
13563
13637
  const ret = getObject(arg0).crypto;
13564
13638
  return addHeapObject(ret);
@@ -13635,6 +13709,16 @@ function __wbg_get_imports(memory) {
13635
13709
  const ret = result;
13636
13710
  return ret;
13637
13711
  };
13712
+ imports.wbg.__wbg_instanceof_Uint8Array_20c8e73002f7af98 = function(arg0) {
13713
+ let result;
13714
+ try {
13715
+ result = getObject(arg0) instanceof Uint8Array;
13716
+ } catch (_) {
13717
+ result = false;
13718
+ }
13719
+ const ret = result;
13720
+ return ret;
13721
+ };
13638
13722
  imports.wbg.__wbg_iterator_e5822695327a3c39 = function() {
13639
13723
  const ret = Symbol.iterator;
13640
13724
  return addHeapObject(ret);
@@ -13655,7 +13739,7 @@ function __wbg_get_imports(memory) {
13655
13739
  const ret = getObject(arg0).length;
13656
13740
  return ret;
13657
13741
  };
13658
- imports.wbg.__wbg_log_c4f23d8ab0ebf7c1 = function(arg0, arg1) {
13742
+ imports.wbg.__wbg_log_da706f3ee1a5f304 = function(arg0, arg1) {
13659
13743
  console.log(getStringFromWasm0(arg0, arg1));
13660
13744
  };
13661
13745
  imports.wbg.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
@@ -13677,7 +13761,7 @@ function __wbg_get_imports(memory) {
13677
13761
  const a = state0.a;
13678
13762
  state0.a = 0;
13679
13763
  try {
13680
- return __wasm_bindgen_func_elem_6787(a, state0.b, arg0, arg1);
13764
+ return __wasm_bindgen_func_elem_6806(a, state0.b, arg0, arg1);
13681
13765
  } finally {
13682
13766
  state0.a = a;
13683
13767
  }
@@ -13824,6 +13908,10 @@ function __wbg_get_imports(memory) {
13824
13908
  imports.wbg.__wbg_send_2e90b7c1fa1cdaf6 = function() { return handleError(function (arg0) {
13825
13909
  getObject(arg0).send();
13826
13910
  }, arguments) };
13911
+ imports.wbg.__wbg_setTimeout_db2dbaeefb6f39c7 = function() { return handleError(function (arg0, arg1) {
13912
+ const ret = setTimeout(getObject(arg0), arg1);
13913
+ return addHeapObject(ret);
13914
+ }, arguments) };
13827
13915
  imports.wbg.__wbg_set_body_3c365989753d61f4 = function(arg0, arg1) {
13828
13916
  getObject(arg0).body = getObject(arg1);
13829
13917
  };
@@ -13860,7 +13948,7 @@ function __wbg_get_imports(memory) {
13860
13948
  const ret = Signature.__wrap(arg0);
13861
13949
  return addHeapObject(ret);
13862
13950
  };
13863
- imports.wbg.__wbg_spawnWorker_ac6256d3825045f7 = function(arg0, arg1, arg2, arg3) {
13951
+ imports.wbg.__wbg_spawnWorker_7eb1fa5a91d68539 = function(arg0, arg1, arg2, arg3) {
13864
13952
  const ret = spawnWorker(getObject(arg0), getObject(arg1), getObject(arg2), arg3 >>> 0);
13865
13953
  return addHeapObject(ret);
13866
13954
  };
@@ -13950,6 +14038,16 @@ function __wbg_get_imports(memory) {
13950
14038
  const ret = Atomics.waitAsync(getObject(arg0), arg1 >>> 0, arg2);
13951
14039
  return addHeapObject(ret);
13952
14040
  };
14041
+ imports.wbg.__wbindgen_cast_06d105bd9273956e = function(arg0, arg1) {
14042
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 418, function: Function { arguments: [], shim_idx: 507, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
14043
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_6534, __wasm_bindgen_func_elem_6535);
14044
+ return addHeapObject(ret);
14045
+ };
14046
+ imports.wbg.__wbindgen_cast_07555e2579ff3863 = function(arg0, arg1) {
14047
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 418, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 419, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
14048
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_6534, __wasm_bindgen_func_elem_7853);
14049
+ return addHeapObject(ret);
14050
+ };
13953
14051
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
13954
14052
  // Cast intrinsic for `Ref(String) -> Externref`.
13955
14053
  const ret = getStringFromWasm0(arg0, arg1);
@@ -13960,16 +14058,16 @@ function __wbg_get_imports(memory) {
13960
14058
  const ret = (BigInt.asUintN(64, arg0) | (arg1 << BigInt(64)));
13961
14059
  return addHeapObject(ret);
13962
14060
  };
13963
- imports.wbg.__wbindgen_cast_3e8b1a28e9899889 = function(arg0, arg1) {
13964
- // Cast intrinsic for `Closure(Closure { dtor_idx: 416, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 417, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
13965
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7843, __wasm_bindgen_func_elem_7844);
13966
- return addHeapObject(ret);
13967
- };
13968
14061
  imports.wbg.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
13969
14062
  // Cast intrinsic for `U64 -> Externref`.
13970
14063
  const ret = BigInt.asUintN(64, arg0);
13971
14064
  return addHeapObject(ret);
13972
14065
  };
14066
+ imports.wbg.__wbindgen_cast_72bd42f236eeae61 = function(arg0, arg1) {
14067
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 418, function: Function { arguments: [Externref], shim_idx: 419, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
14068
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_6534, __wasm_bindgen_func_elem_7853);
14069
+ return addHeapObject(ret);
14070
+ };
13973
14071
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
13974
14072
  // Cast intrinsic for `I64 -> Externref`.
13975
14073
  const ret = arg0;
@@ -13990,11 +14088,6 @@ function __wbg_get_imports(memory) {
13990
14088
  const ret = (BigInt.asUintN(64, arg0) | (BigInt.asUintN(64, arg1) << BigInt(64)));
13991
14089
  return addHeapObject(ret);
13992
14090
  };
13993
- imports.wbg.__wbindgen_cast_f45fc07d50d9127c = function(arg0, arg1) {
13994
- // Cast intrinsic for `Closure(Closure { dtor_idx: 416, function: Function { arguments: [Externref], shim_idx: 417, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
13995
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_7843, __wasm_bindgen_func_elem_7844);
13996
- return addHeapObject(ret);
13997
- };
13998
14091
  imports.wbg.__wbindgen_link_b9f45ffe079ef2c1 = function(arg0) {
13999
14092
  const val = `onmessage = function (ev) {
14000
14093
  let [ia, index, value] = ev.data;