@quantovainc/qcore 0.4.2 → 0.5.0

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.
@@ -1,5 +1,109 @@
1
1
  /* @ts-self-types="./qcore_js.d.ts" */
2
2
 
3
+ class SigningSession {
4
+ __destroy_into_raw() {
5
+ const ptr = this.__wbg_ptr;
6
+ this.__wbg_ptr = 0;
7
+ SigningSessionFinalization.unregister(this);
8
+ return ptr;
9
+ }
10
+ free() {
11
+ const ptr = this.__destroy_into_raw();
12
+ wasm.__wbg_signingsession_free(ptr, 0);
13
+ }
14
+ /**
15
+ * @param {string} address
16
+ */
17
+ checkTarget(address) {
18
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
19
+ const len0 = WASM_VECTOR_LEN;
20
+ const ret = wasm.signingsession_checkTarget(this.__wbg_ptr, ptr0, len0);
21
+ if (ret[1]) {
22
+ throw takeFromExternrefTable0(ret[0]);
23
+ }
24
+ }
25
+ /**
26
+ * @param {string} key
27
+ * @param {bigint} slot
28
+ * @returns {boolean}
29
+ */
30
+ isHeld(key, slot) {
31
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
32
+ const len0 = WASM_VECTOR_LEN;
33
+ const ret = wasm.signingsession_isHeld(this.__wbg_ptr, ptr0, len0, slot);
34
+ return ret !== 0;
35
+ }
36
+ /**
37
+ * @param {string[]} book
38
+ */
39
+ constructor(book) {
40
+ const ptr0 = passArrayJsValueToWasm0(book, wasm.__wbindgen_malloc);
41
+ const len0 = WASM_VECTOR_LEN;
42
+ const ret = wasm.signingsession_new(ptr0, len0);
43
+ if (ret[2]) {
44
+ throw takeFromExternrefTable0(ret[1]);
45
+ }
46
+ this.__wbg_ptr = ret[0];
47
+ SigningSessionFinalization.register(this, this.__wbg_ptr, this);
48
+ return this;
49
+ }
50
+ /**
51
+ * @param {string} key
52
+ * @returns {bigint | undefined}
53
+ */
54
+ nextNonce(key) {
55
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
56
+ const len0 = WASM_VECTOR_LEN;
57
+ const ret = wasm.signingsession_nextNonce(this.__wbg_ptr, ptr0, len0);
58
+ return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
59
+ }
60
+ /**
61
+ * @param {string} key
62
+ * @param {bigint} slot
63
+ * @param {boolean} accepted
64
+ */
65
+ outcome(key, slot, accepted) {
66
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
67
+ const len0 = WASM_VECTOR_LEN;
68
+ wasm.signingsession_outcome(this.__wbg_ptr, ptr0, len0, slot, accepted);
69
+ }
70
+ /**
71
+ * @param {string} address
72
+ */
73
+ rememberAddress(address) {
74
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
75
+ const len0 = WASM_VECTOR_LEN;
76
+ wasm.signingsession_rememberAddress(this.__wbg_ptr, ptr0, len0);
77
+ }
78
+ /**
79
+ * @param {string} key
80
+ * @param {bigint} slot
81
+ */
82
+ signed(key, slot) {
83
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
84
+ const len0 = WASM_VECTOR_LEN;
85
+ wasm.signingsession_signed(this.__wbg_ptr, ptr0, len0, slot);
86
+ }
87
+ /**
88
+ * @param {string} key
89
+ * @param {bigint} reported
90
+ * @param {bigint | null | undefined} expected
91
+ * @param {boolean} order
92
+ * @returns {bigint}
93
+ */
94
+ slot(key, reported, expected, order) {
95
+ const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
96
+ const len0 = WASM_VECTOR_LEN;
97
+ const ret = wasm.signingsession_slot(this.__wbg_ptr, ptr0, len0, reported, !isLikeNone(expected), isLikeNone(expected) ? BigInt(0) : expected, order);
98
+ if (ret[2]) {
99
+ throw takeFromExternrefTable0(ret[1]);
100
+ }
101
+ return BigInt.asUintN(64, ret[0]);
102
+ }
103
+ }
104
+ if (Symbol.dispose) SigningSession.prototype[Symbol.dispose] = SigningSession.prototype.free;
105
+ exports.SigningSession = SigningSession;
106
+
3
107
  /**
4
108
  * @param {string} address
5
109
  * @returns {string}
@@ -108,21 +212,42 @@ function block_by_height_body(height) {
108
212
  }
109
213
  exports.block_by_height_body = block_by_height_body;
110
214
 
215
+ /**
216
+ * @param {string} chain_name
217
+ * @param {bigint} head
218
+ * @param {bigint} wall_secs
219
+ * @param {bigint | null | undefined} floor
220
+ * @param {bigint} floor_age_secs
221
+ * @returns {bigint}
222
+ */
223
+ function boundedValidUntil(chain_name, head, wall_secs, floor, floor_age_secs) {
224
+ const ptr0 = passStringToWasm0(chain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
225
+ const len0 = WASM_VECTOR_LEN;
226
+ const ret = wasm.boundedValidUntil(ptr0, len0, head, wall_secs, !isLikeNone(floor), isLikeNone(floor) ? BigInt(0) : floor, floor_age_secs);
227
+ if (ret[2]) {
228
+ throw takeFromExternrefTable0(ret[1]);
229
+ }
230
+ return BigInt.asUintN(64, ret[0]);
231
+ }
232
+ exports.boundedValidUntil = boundedValidUntil;
233
+
111
234
  /**
112
235
  * @param {bigint} chain_id
113
236
  * @param {string} contract
114
237
  * @param {string} selector_hex
115
238
  * @param {bigint} scheme_off
116
239
  * @param {bigint} ptr_off
240
+ * @param {bigint} expiry_off
117
241
  * @param {string} field_offs_csv
118
242
  * @param {string} fields_csv
119
243
  * @param {bigint} region_off
120
244
  * @param {Uint8Array} owner_seed_bytes
121
245
  * @param {bigint} owner_index
122
246
  * @param {bigint} nonce
247
+ * @param {bigint} expiry
123
248
  * @returns {string}
124
249
  */
125
- function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, field_offs_csv, fields_csv, region_off, owner_seed_bytes, owner_index, nonce) {
250
+ function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, expiry_off, field_offs_csv, fields_csv, region_off, owner_seed_bytes, owner_index, nonce, expiry) {
126
251
  let deferred7_0;
127
252
  let deferred7_1;
128
253
  try {
@@ -136,7 +261,7 @@ function buildSignedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_
136
261
  const len3 = WASM_VECTOR_LEN;
137
262
  const ptr4 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
138
263
  const len4 = WASM_VECTOR_LEN;
139
- const ret = wasm.buildSignedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, ptr2, len2, ptr3, len3, region_off, ptr4, len4, owner_index, nonce);
264
+ const ret = wasm.buildSignedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, expiry_off, ptr2, len2, ptr3, len3, region_off, ptr4, len4, owner_index, nonce, expiry);
140
265
  var ptr6 = ret[0];
141
266
  var len6 = ret[1];
142
267
  if (ret[3]) {
@@ -158,14 +283,16 @@ exports.buildSignedOrderCall = buildSignedOrderCall;
158
283
  * @param {string} selector_hex
159
284
  * @param {bigint} scheme_off
160
285
  * @param {bigint} ptr_off
286
+ * @param {bigint} expiry_off
161
287
  * @param {bigint} region_off
162
288
  * @param {string} fields_json
163
289
  * @param {Uint8Array} owner_seed_bytes
164
290
  * @param {bigint} owner_index
165
291
  * @param {bigint} nonce
292
+ * @param {bigint} expiry
166
293
  * @returns {string}
167
294
  */
168
- function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, region_off, fields_json, owner_seed_bytes, owner_index, nonce) {
295
+ function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_off, expiry_off, region_off, fields_json, owner_seed_bytes, owner_index, nonce, expiry) {
169
296
  let deferred6_0;
170
297
  let deferred6_1;
171
298
  try {
@@ -177,7 +304,7 @@ function buildTypedOrderCall(chain_id, contract, selector_hex, scheme_off, ptr_o
177
304
  const len2 = WASM_VECTOR_LEN;
178
305
  const ptr3 = passArray8ToWasm0(owner_seed_bytes, wasm.__wbindgen_malloc);
179
306
  const len3 = WASM_VECTOR_LEN;
180
- const ret = wasm.buildTypedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, region_off, ptr2, len2, ptr3, len3, owner_index, nonce);
307
+ const ret = wasm.buildTypedOrderCall(chain_id, ptr0, len0, ptr1, len1, scheme_off, ptr_off, expiry_off, region_off, ptr2, len2, ptr3, len3, owner_index, nonce, expiry);
181
308
  var ptr5 = ret[0];
182
309
  var len5 = ret[1];
183
310
  if (ret[3]) {
@@ -205,6 +332,19 @@ function chainIdFromName(name) {
205
332
  }
206
333
  exports.chainIdFromName = chainIdFromName;
207
334
 
335
+ /**
336
+ * @param {string} response
337
+ */
338
+ function checkGatewayJson(response) {
339
+ const ptr0 = passStringToWasm0(response, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
340
+ const len0 = WASM_VECTOR_LEN;
341
+ const ret = wasm.checkGatewayJson(ptr0, len0);
342
+ if (ret[1]) {
343
+ throw takeFromExternrefTable0(ret[0]);
344
+ }
345
+ }
346
+ exports.checkGatewayJson = checkGatewayJson;
347
+
208
348
  /**
209
349
  * @param {bigint} valid_until
210
350
  * @param {bigint} head
@@ -253,6 +393,31 @@ function eventsBody(height) {
253
393
  }
254
394
  exports.eventsBody = eventsBody;
255
395
 
396
+ /**
397
+ * @param {string} chain_name
398
+ * @returns {bigint}
399
+ */
400
+ function genesisSecs(chain_name) {
401
+ const ptr0 = passStringToWasm0(chain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
402
+ const len0 = WASM_VECTOR_LEN;
403
+ const ret = wasm.genesisSecs(ptr0, len0);
404
+ return BigInt.asUintN(64, ret);
405
+ }
406
+ exports.genesisSecs = genesisSecs;
407
+
408
+ /**
409
+ * @param {string} chain_name
410
+ * @param {bigint} wall_secs
411
+ * @returns {bigint}
412
+ */
413
+ function headCeiling(chain_name, wall_secs) {
414
+ const ptr0 = passStringToWasm0(chain_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
415
+ const len0 = WASM_VECTOR_LEN;
416
+ const ret = wasm.headCeiling(ptr0, len0, wall_secs);
417
+ return BigInt.asUintN(64, ret);
418
+ }
419
+ exports.headCeiling = headCeiling;
420
+
256
421
  /**
257
422
  * @returns {bigint}
258
423
  */
@@ -348,18 +513,35 @@ exports.mapSlotKey = mapSlotKey;
348
513
 
349
514
  /**
350
515
  * @param {Uint8Array} seed_bytes
351
- * @returns {any}
516
+ * @returns {Uint8Array}
352
517
  */
353
518
  function mnemonicFromSeed(seed_bytes) {
354
519
  const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
355
520
  const len0 = WASM_VECTOR_LEN;
356
521
  const ret = wasm.mnemonicFromSeed(ptr0, len0);
522
+ if (ret[3]) {
523
+ throw takeFromExternrefTable0(ret[2]);
524
+ }
525
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
526
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
527
+ return v2;
528
+ }
529
+ exports.mnemonicFromSeed = mnemonicFromSeed;
530
+
531
+ /**
532
+ * @param {Uint8Array} seed_bytes
533
+ * @returns {any}
534
+ */
535
+ function mnemonicFromSeedText(seed_bytes) {
536
+ const ptr0 = passArray8ToWasm0(seed_bytes, wasm.__wbindgen_malloc);
537
+ const len0 = WASM_VECTOR_LEN;
538
+ const ret = wasm.mnemonicFromSeedText(ptr0, len0);
357
539
  if (ret[2]) {
358
540
  throw takeFromExternrefTable0(ret[1]);
359
541
  }
360
542
  return takeFromExternrefTable0(ret[0]);
361
543
  }
362
- exports.mnemonicFromSeed = mnemonicFromSeed;
544
+ exports.mnemonicFromSeedText = mnemonicFromSeedText;
363
545
 
364
546
  /**
365
547
  * @param {string} label
@@ -522,6 +704,23 @@ function seedFromMnemonic(phrase) {
522
704
  }
523
705
  exports.seedFromMnemonic = seedFromMnemonic;
524
706
 
707
+ /**
708
+ * @param {Uint8Array} phrase
709
+ * @returns {Uint8Array}
710
+ */
711
+ function seedFromMnemonicBytes(phrase) {
712
+ const ptr0 = passArray8ToWasm0(phrase, wasm.__wbindgen_malloc);
713
+ const len0 = WASM_VECTOR_LEN;
714
+ const ret = wasm.seedFromMnemonicBytes(ptr0, len0);
715
+ if (ret[3]) {
716
+ throw takeFromExternrefTable0(ret[2]);
717
+ }
718
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
719
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
720
+ return v2;
721
+ }
722
+ exports.seedFromMnemonicBytes = seedFromMnemonicBytes;
723
+
525
724
  /**
526
725
  * @param {Uint8Array} seed_bytes
527
726
  * @param {bigint} index
@@ -816,6 +1015,40 @@ function testnetChainId() {
816
1015
  }
817
1016
  exports.testnetChainId = testnetChainId;
818
1017
 
1018
+ /**
1019
+ * @returns {string}
1020
+ */
1021
+ function testnetChainName() {
1022
+ let deferred1_0;
1023
+ let deferred1_1;
1024
+ try {
1025
+ const ret = wasm.testnetChainName();
1026
+ deferred1_0 = ret[0];
1027
+ deferred1_1 = ret[1];
1028
+ return getStringFromWasm0(ret[0], ret[1]);
1029
+ } finally {
1030
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1031
+ }
1032
+ }
1033
+ exports.testnetChainName = testnetChainName;
1034
+
1035
+ /**
1036
+ * @returns {string}
1037
+ */
1038
+ function testnetRpcUrl() {
1039
+ let deferred1_0;
1040
+ let deferred1_1;
1041
+ try {
1042
+ const ret = wasm.testnetRpcUrl();
1043
+ deferred1_0 = ret[0];
1044
+ deferred1_1 = ret[1];
1045
+ return getStringFromWasm0(ret[0], ret[1]);
1046
+ } finally {
1047
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1048
+ }
1049
+ }
1050
+ exports.testnetRpcUrl = testnetRpcUrl;
1051
+
819
1052
  /**
820
1053
  * @returns {bigint}
821
1054
  */
@@ -884,6 +1117,15 @@ function valid_address(address) {
884
1117
  }
885
1118
  exports.valid_address = valid_address;
886
1119
 
1120
+ /**
1121
+ * @returns {bigint}
1122
+ */
1123
+ function validityBlocks() {
1124
+ const ret = wasm.validityBlocks();
1125
+ return BigInt.asUintN(64, ret);
1126
+ }
1127
+ exports.validityBlocks = validityBlocks;
1128
+
887
1129
  /**
888
1130
  * @param {string} transfer_fee
889
1131
  * @param {bigint} meter_limit
@@ -966,6 +1208,10 @@ function __wbg_get_imports() {
966
1208
  };
967
1209
  }
968
1210
 
1211
+ const SigningSessionFinalization = (typeof FinalizationRegistry === 'undefined')
1212
+ ? { register: () => {}, unregister: () => {} }
1213
+ : new FinalizationRegistry(ptr => wasm.__wbg_signingsession_free(ptr, 1));
1214
+
969
1215
  function addToExternrefTable0(obj) {
970
1216
  const idx = wasm.__externref_table_alloc();
971
1217
  wasm.__wbindgen_externrefs.set(idx, obj);
Binary file