@nockbox/iris-wasm 0.1.2 → 0.2.0-alpha.1

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/iris_wasm.js CHANGED
@@ -220,51 +220,91 @@ function takeFromExternrefTable0(idx) {
220
220
  return value;
221
221
  }
222
222
 
223
- function _assertClass(instance, klass) {
224
- if (!(instance instanceof klass)) {
225
- throw new Error(`expected instance of ${klass.name}`);
223
+ function passArray8ToWasm0(arg, malloc) {
224
+ const ptr = malloc(arg.length * 1, 1) >>> 0;
225
+ getUint8ArrayMemory0().set(arg, ptr / 1);
226
+ WASM_VECTOR_LEN = arg.length;
227
+ return ptr;
228
+ }
229
+ /**
230
+ * Verify a signature with a public key
231
+ * @param {Uint8Array} public_key_bytes
232
+ * @param {Signature} signature
233
+ * @param {string} message
234
+ * @returns {boolean}
235
+ */
236
+ export function verifySignature(public_key_bytes, signature, message) {
237
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
238
+ const len0 = WASM_VECTOR_LEN;
239
+ const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
240
+ const len1 = WASM_VECTOR_LEN;
241
+ const ret = wasm.verifySignature(ptr0, len0, signature, ptr1, len1);
242
+ if (ret[2]) {
243
+ throw takeFromExternrefTable0(ret[1]);
226
244
  }
245
+ return ret[0] !== 0;
227
246
  }
228
247
 
229
- function getArrayJsValueFromWasm0(ptr, len) {
230
- ptr = ptr >>> 0;
231
- const mem = getDataViewMemory0();
232
- const result = [];
233
- for (let i = ptr; i < ptr + 4 * len; i += 4) {
234
- result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
235
- }
236
- wasm.__externref_drop_slice(ptr, len);
237
- return result;
248
+ /**
249
+ * Derive master key from seed bytes
250
+ * @param {Uint8Array} seed
251
+ * @returns {ExtendedKey}
252
+ */
253
+ export function deriveMasterKey(seed) {
254
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
255
+ const len0 = WASM_VECTOR_LEN;
256
+ const ret = wasm.deriveMasterKey(ptr0, len0);
257
+ return ExtendedKey.__wrap(ret);
238
258
  }
239
259
 
240
- function passArrayJsValueToWasm0(array, malloc) {
241
- const ptr = malloc(array.length * 4, 4) >>> 0;
242
- for (let i = 0; i < array.length; i++) {
243
- const add = addToExternrefTable0(array[i]);
244
- getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
260
+ /**
261
+ * Hash a u64 value
262
+ * @param {bigint} value
263
+ * @returns {string}
264
+ */
265
+ export function hashU64(value) {
266
+ let deferred1_0;
267
+ let deferred1_1;
268
+ try {
269
+ const ret = wasm.hashU64(value);
270
+ deferred1_0 = ret[0];
271
+ deferred1_1 = ret[1];
272
+ return getStringFromWasm0(ret[0], ret[1]);
273
+ } finally {
274
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
245
275
  }
246
- WASM_VECTOR_LEN = array.length;
247
- return ptr;
248
276
  }
249
277
 
250
- function passArray8ToWasm0(arg, malloc) {
251
- const ptr = malloc(arg.length * 1, 1) >>> 0;
252
- getUint8ArrayMemory0().set(arg, ptr / 1);
253
- WASM_VECTOR_LEN = arg.length;
254
- return ptr;
278
+ /**
279
+ * Derive master key from BIP39 mnemonic phrase
280
+ * @param {string} mnemonic
281
+ * @param {string | null} [passphrase]
282
+ * @returns {ExtendedKey}
283
+ */
284
+ export function deriveMasterKeyFromMnemonic(mnemonic, passphrase) {
285
+ const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
286
+ const len0 = WASM_VECTOR_LEN;
287
+ var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
288
+ var len1 = WASM_VECTOR_LEN;
289
+ const ret = wasm.deriveMasterKeyFromMnemonic(ptr0, len0, ptr1, len1);
290
+ if (ret[2]) {
291
+ throw takeFromExternrefTable0(ret[1]);
292
+ }
293
+ return ExtendedKey.__wrap(ret[0]);
255
294
  }
295
+
256
296
  /**
257
- * Hash a noun (jam as input)
258
- * @param {Uint8Array} noun
297
+ * Hash a public key to get its digest (for use in PKH)
298
+ * @param {Uint8Array} public_key_bytes
259
299
  * @returns {string}
260
300
  */
261
- export function hashNoun(noun) {
301
+ export function hashPublicKey(public_key_bytes) {
262
302
  let deferred3_0;
263
303
  let deferred3_1;
264
304
  try {
265
- const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
305
+ const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
266
306
  const len0 = WASM_VECTOR_LEN;
267
- const ret = wasm.hashNoun(ptr0, len0);
307
+ const ret = wasm.hashPublicKey(ptr0, len0);
268
308
  var ptr2 = ret[0];
269
309
  var len2 = ret[1];
270
310
  if (ret[3]) {
@@ -280,37 +320,35 @@ export function hashNoun(noun) {
280
320
  }
281
321
 
282
322
  /**
283
- * Verify a signature with a public key
284
- * @param {Uint8Array} public_key_bytes
285
- * @param {Signature} signature
323
+ * Sign a message string with a private key
324
+ * @param {Uint8Array} private_key_bytes
286
325
  * @param {string} message
287
- * @returns {boolean}
326
+ * @returns {Signature}
288
327
  */
289
- export function verifySignature(public_key_bytes, signature, message) {
290
- const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
328
+ export function signMessage(private_key_bytes, message) {
329
+ const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
291
330
  const len0 = WASM_VECTOR_LEN;
292
- _assertClass(signature, Signature);
293
331
  const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
294
332
  const len1 = WASM_VECTOR_LEN;
295
- const ret = wasm.verifySignature(ptr0, len0, signature.__wbg_ptr, ptr1, len1);
333
+ const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
296
334
  if (ret[2]) {
297
335
  throw takeFromExternrefTable0(ret[1]);
298
336
  }
299
- return ret[0] !== 0;
337
+ return takeFromExternrefTable0(ret[0]);
300
338
  }
301
339
 
302
340
  /**
303
- * Hash a public key to get its digest (for use in PKH)
304
- * @param {Uint8Array} public_key_bytes
341
+ * Hash a noun (jam as input)
342
+ * @param {Uint8Array} noun
305
343
  * @returns {string}
306
344
  */
307
- export function hashPublicKey(public_key_bytes) {
345
+ export function hashNoun(noun) {
308
346
  let deferred3_0;
309
347
  let deferred3_1;
310
348
  try {
311
- const ptr0 = passArray8ToWasm0(public_key_bytes, wasm.__wbindgen_malloc);
349
+ const ptr0 = passArray8ToWasm0(noun, wasm.__wbindgen_malloc);
312
350
  const len0 = WASM_VECTOR_LEN;
313
- const ret = wasm.hashPublicKey(ptr0, len0);
351
+ const ret = wasm.hashNoun(ptr0, len0);
314
352
  var ptr2 = ret[0];
315
353
  var len2 = ret[1];
316
354
  if (ret[3]) {
@@ -326,63 +364,100 @@ export function hashPublicKey(public_key_bytes) {
326
364
  }
327
365
 
328
366
  /**
329
- * Derive master key from seed bytes
330
- * @param {Uint8Array} seed
331
- * @returns {ExtendedKey}
367
+ * @param {Uint8Array} jam
368
+ * @returns {Noun}
332
369
  */
333
- export function deriveMasterKey(seed) {
334
- const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_malloc);
370
+ export function cue(jam) {
371
+ const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
335
372
  const len0 = WASM_VECTOR_LEN;
336
- const ret = wasm.deriveMasterKey(ptr0, len0);
337
- return ExtendedKey.__wrap(ret);
373
+ const ret = wasm.cue(ptr0, len0);
374
+ if (ret[2]) {
375
+ throw takeFromExternrefTable0(ret[1]);
376
+ }
377
+ return takeFromExternrefTable0(ret[0]);
338
378
  }
339
379
 
340
380
  /**
341
- * Sign a message string with a private key
342
- * @param {Uint8Array} private_key_bytes
343
- * @param {string} message
344
- * @returns {Signature}
381
+ * @param {Noun} noun
382
+ * @returns {Uint8Array}
345
383
  */
346
- export function signMessage(private_key_bytes, message) {
347
- const ptr0 = passArray8ToWasm0(private_key_bytes, wasm.__wbindgen_malloc);
348
- const len0 = WASM_VECTOR_LEN;
349
- const ptr1 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
350
- const len1 = WASM_VECTOR_LEN;
351
- const ret = wasm.signMessage(ptr0, len0, ptr1, len1);
352
- if (ret[2]) {
353
- throw takeFromExternrefTable0(ret[1]);
384
+ export function jam(noun) {
385
+ const ret = wasm.jam(noun);
386
+ if (ret[3]) {
387
+ throw takeFromExternrefTable0(ret[2]);
388
+ }
389
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
390
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
391
+ return v1;
392
+ }
393
+
394
+ function getArrayJsValueFromWasm0(ptr, len) {
395
+ ptr = ptr >>> 0;
396
+ const mem = getDataViewMemory0();
397
+ const result = [];
398
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
399
+ result.push(wasm.__wbindgen_externrefs.get(mem.getUint32(i, true)));
400
+ }
401
+ wasm.__externref_drop_slice(ptr, len);
402
+ return result;
403
+ }
404
+
405
+ function passArrayJsValueToWasm0(array, malloc) {
406
+ const ptr = malloc(array.length * 4, 4) >>> 0;
407
+ for (let i = 0; i < array.length; i++) {
408
+ const add = addToExternrefTable0(array[i]);
409
+ getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
354
410
  }
355
- return Signature.__wrap(ret[0]);
411
+ WASM_VECTOR_LEN = array.length;
412
+ return ptr;
356
413
  }
357
414
 
415
+ function _assertClass(instance, klass) {
416
+ if (!(instance instanceof klass)) {
417
+ throw new Error(`expected instance of ${klass.name}`);
418
+ }
419
+ }
358
420
  /**
359
- * Derive master key from BIP39 mnemonic phrase
360
- * @param {string} mnemonic
361
- * @param {string | null} [passphrase]
362
- * @returns {ExtendedKey}
421
+ * @param {string} s
422
+ * @returns {Digest}
363
423
  */
364
- export function deriveMasterKeyFromMnemonic(mnemonic, passphrase) {
365
- const ptr0 = passStringToWasm0(mnemonic, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
424
+ export function hex_to_digest(s) {
425
+ const ptr0 = passStringToWasm0(s, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
366
426
  const len0 = WASM_VECTOR_LEN;
367
- var ptr1 = isLikeNone(passphrase) ? 0 : passStringToWasm0(passphrase, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
368
- var len1 = WASM_VECTOR_LEN;
369
- const ret = wasm.deriveMasterKeyFromMnemonic(ptr0, len0, ptr1, len1);
427
+ const ret = wasm.hex_to_digest(ptr0, len0);
370
428
  if (ret[2]) {
371
429
  throw takeFromExternrefTable0(ret[1]);
372
430
  }
373
- return ExtendedKey.__wrap(ret[0]);
431
+ return takeFromExternrefTable0(ret[0]);
374
432
  }
375
433
 
376
434
  /**
377
- * Hash a u64 value
378
- * @param {bigint} value
435
+ * @param {Note} note
436
+ * @returns {Digest}
437
+ */
438
+ export function note_hash(note) {
439
+ const ret = wasm.note_hash(note);
440
+ return ret;
441
+ }
442
+
443
+ /**
444
+ * @param {Note} note
445
+ * @returns {PbCom2Note}
446
+ */
447
+ export function note_to_protobuf(note) {
448
+ const ret = wasm.note_to_protobuf(note);
449
+ return ret;
450
+ }
451
+
452
+ /**
453
+ * @param {Digest} d
379
454
  * @returns {string}
380
455
  */
381
- export function hashU64(value) {
456
+ export function digest_to_hex(d) {
382
457
  let deferred1_0;
383
458
  let deferred1_1;
384
459
  try {
385
- const ret = wasm.hashU64(value);
460
+ const ret = wasm.digest_to_hex(d);
386
461
  deferred1_0 = ret[0];
387
462
  deferred1_1 = ret[1];
388
463
  return getStringFromWasm0(ret[0], ret[1]);
@@ -391,6 +466,75 @@ export function hashU64(value) {
391
466
  }
392
467
  }
393
468
 
469
+ /**
470
+ * @param {number} origin_page
471
+ * @param {bigint} sig_m
472
+ * @param {Uint8Array[]} sig_pubkeys
473
+ * @param {Digest} source_hash
474
+ * @param {boolean} is_coinbase
475
+ * @param {Timelock | null | undefined} timelock
476
+ * @param {Nicks} assets
477
+ * @returns {Note}
478
+ */
479
+ export function create_note_v0(origin_page, sig_m, sig_pubkeys, source_hash, is_coinbase, timelock, assets) {
480
+ const ptr0 = passArrayJsValueToWasm0(sig_pubkeys, wasm.__wbindgen_malloc);
481
+ const len0 = WASM_VECTOR_LEN;
482
+ const ret = wasm.create_note_v0(origin_page, sig_m, ptr0, len0, source_hash, is_coinbase, isLikeNone(timelock) ? 0 : addToExternrefTable0(timelock), assets);
483
+ if (ret[2]) {
484
+ throw takeFromExternrefTable0(ret[1]);
485
+ }
486
+ return takeFromExternrefTable0(ret[0]);
487
+ }
488
+
489
+ /**
490
+ * @param {PbCom1Hash} value
491
+ * @returns {Digest}
492
+ */
493
+ export function digest_from_protobuf(value) {
494
+ const ret = wasm.digest_from_protobuf(value);
495
+ if (ret[2]) {
496
+ throw takeFromExternrefTable0(ret[1]);
497
+ }
498
+ return takeFromExternrefTable0(ret[0]);
499
+ }
500
+
501
+ /**
502
+ * @param {Digest} d
503
+ * @returns {PbCom1Hash}
504
+ */
505
+ export function digest_to_protobuf(d) {
506
+ const ret = wasm.digest_to_protobuf(d);
507
+ return ret;
508
+ }
509
+
510
+ /**
511
+ * @param {PbCom2Note} value
512
+ * @returns {Note}
513
+ */
514
+ export function note_from_protobuf(value) {
515
+ const ret = wasm.note_from_protobuf(value);
516
+ if (ret[2]) {
517
+ throw takeFromExternrefTable0(ret[1]);
518
+ }
519
+ return takeFromExternrefTable0(ret[0]);
520
+ }
521
+
522
+ /**
523
+ * @param {Version} version
524
+ * @param {number} origin_page
525
+ * @param {Name} name
526
+ * @param {NoteData} note_data
527
+ * @param {Nicks} assets
528
+ * @returns {Note}
529
+ */
530
+ export function create_note_v1(version, origin_page, name, note_data, assets) {
531
+ const ret = wasm.create_note_v1(version, origin_page, name, note_data, assets);
532
+ if (ret[2]) {
533
+ throw takeFromExternrefTable0(ret[1]);
534
+ }
535
+ return takeFromExternrefTable0(ret[0]);
536
+ }
537
+
394
538
  function wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b(arg0, arg1, arg2) {
395
539
  wasm.wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b(arg0, arg1, arg2);
396
540
  }
@@ -411,133 +555,51 @@ const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate
411
555
 
412
556
  const __wbindgen_enum_RequestRedirect = ["follow", "error", "manual"];
413
557
 
414
- const DigestFinalization = (typeof FinalizationRegistry === 'undefined')
558
+ const ExtendedKeyFinalization = (typeof FinalizationRegistry === 'undefined')
415
559
  ? { register: () => {}, unregister: () => {} }
416
- : new FinalizationRegistry(ptr => wasm.__wbg_digest_free(ptr >>> 0, 1));
560
+ : new FinalizationRegistry(ptr => wasm.__wbg_extendedkey_free(ptr >>> 0, 1));
417
561
 
418
- export class Digest {
562
+ export class ExtendedKey {
419
563
 
420
564
  static __wrap(ptr) {
421
565
  ptr = ptr >>> 0;
422
- const obj = Object.create(Digest.prototype);
566
+ const obj = Object.create(ExtendedKey.prototype);
423
567
  obj.__wbg_ptr = ptr;
424
- DigestFinalization.register(obj, obj.__wbg_ptr, obj);
568
+ ExtendedKeyFinalization.register(obj, obj.__wbg_ptr, obj);
425
569
  return obj;
426
570
  }
427
571
 
428
- static __unwrap(jsValue) {
429
- if (!(jsValue instanceof Digest)) {
430
- return 0;
431
- }
432
- return jsValue.__destroy_into_raw();
433
- }
434
-
435
572
  __destroy_into_raw() {
436
573
  const ptr = this.__wbg_ptr;
437
574
  this.__wbg_ptr = 0;
438
- DigestFinalization.unregister(this);
575
+ ExtendedKeyFinalization.unregister(this);
439
576
  return ptr;
440
577
  }
441
578
 
442
579
  free() {
443
580
  const ptr = this.__destroy_into_raw();
444
- wasm.__wbg_digest_free(ptr, 0);
581
+ wasm.__wbg_extendedkey_free(ptr, 0);
445
582
  }
446
583
  /**
447
- * @returns {any}
584
+ * @returns {Uint8Array}
448
585
  */
449
- toProtobuf() {
450
- const ret = wasm.digest_toProtobuf(this.__wbg_ptr);
451
- if (ret[2]) {
452
- throw takeFromExternrefTable0(ret[1]);
453
- }
454
- return takeFromExternrefTable0(ret[0]);
586
+ get chainCode() {
587
+ const ret = wasm.extendedkey_chainCode(this.__wbg_ptr);
588
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
589
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
590
+ return v1;
455
591
  }
456
592
  /**
457
- * @param {any} value
458
- * @returns {Digest}
593
+ * @returns {Uint8Array}
459
594
  */
460
- static fromProtobuf(value) {
461
- const ret = wasm.digest_fromProtobuf(value);
462
- if (ret[2]) {
463
- throw takeFromExternrefTable0(ret[1]);
464
- }
465
- return Digest.__wrap(ret[0]);
595
+ get publicKey() {
596
+ const ret = wasm.extendedkey_publicKey(this.__wbg_ptr);
597
+ var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
598
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
599
+ return v1;
466
600
  }
467
601
  /**
468
- * @param {string} value
469
- */
470
- constructor(value) {
471
- const ptr0 = passStringToWasm0(value, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
472
- const len0 = WASM_VECTOR_LEN;
473
- const ret = wasm.digest_new(ptr0, len0);
474
- this.__wbg_ptr = ret >>> 0;
475
- DigestFinalization.register(this, this.__wbg_ptr, this);
476
- return this;
477
- }
478
- /**
479
- * @returns {string}
480
- */
481
- get value() {
482
- let deferred1_0;
483
- let deferred1_1;
484
- try {
485
- const ret = wasm.digest_value(this.__wbg_ptr);
486
- deferred1_0 = ret[0];
487
- deferred1_1 = ret[1];
488
- return getStringFromWasm0(ret[0], ret[1]);
489
- } finally {
490
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
491
- }
492
- }
493
- }
494
- if (Symbol.dispose) Digest.prototype[Symbol.dispose] = Digest.prototype.free;
495
-
496
- const ExtendedKeyFinalization = (typeof FinalizationRegistry === 'undefined')
497
- ? { register: () => {}, unregister: () => {} }
498
- : new FinalizationRegistry(ptr => wasm.__wbg_extendedkey_free(ptr >>> 0, 1));
499
-
500
- export class ExtendedKey {
501
-
502
- static __wrap(ptr) {
503
- ptr = ptr >>> 0;
504
- const obj = Object.create(ExtendedKey.prototype);
505
- obj.__wbg_ptr = ptr;
506
- ExtendedKeyFinalization.register(obj, obj.__wbg_ptr, obj);
507
- return obj;
508
- }
509
-
510
- __destroy_into_raw() {
511
- const ptr = this.__wbg_ptr;
512
- this.__wbg_ptr = 0;
513
- ExtendedKeyFinalization.unregister(this);
514
- return ptr;
515
- }
516
-
517
- free() {
518
- const ptr = this.__destroy_into_raw();
519
- wasm.__wbg_extendedkey_free(ptr, 0);
520
- }
521
- /**
522
- * @returns {Uint8Array}
523
- */
524
- get chainCode() {
525
- const ret = wasm.extendedkey_chainCode(this.__wbg_ptr);
526
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
527
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
528
- return v1;
529
- }
530
- /**
531
- * @returns {Uint8Array}
532
- */
533
- get publicKey() {
534
- const ret = wasm.extendedkey_publicKey(this.__wbg_ptr);
535
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
536
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
537
- return v1;
538
- }
539
- /**
540
- * @returns {Uint8Array | undefined}
602
+ * @returns {Uint8Array | undefined}
541
603
  */
542
604
  get privateKey() {
543
605
  const ret = wasm.extendedkey_privateKey(this.__wbg_ptr);
@@ -582,8 +644,8 @@ export class GrpcClient {
582
644
  }
583
645
  /**
584
646
  * Send a transaction
585
- * @param {any} raw_tx
586
- * @returns {Promise<any>}
647
+ * @param {PbCom2RawTransaction} raw_tx
648
+ * @returns {Promise<string>}
587
649
  */
588
650
  sendTransaction(raw_tx) {
589
651
  const ret = wasm.grpcclient_sendTransaction(this.__wbg_ptr, raw_tx);
@@ -603,7 +665,7 @@ export class GrpcClient {
603
665
  /**
604
666
  * Get balance for a wallet address
605
667
  * @param {string} address
606
- * @returns {Promise<any>}
668
+ * @returns {Promise<PbCom2Balance>}
607
669
  */
608
670
  getBalanceByAddress(address) {
609
671
  const ptr0 = passStringToWasm0(address, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -614,7 +676,7 @@ export class GrpcClient {
614
676
  /**
615
677
  * Get balance for a first name
616
678
  * @param {string} first_name
617
- * @returns {Promise<any>}
679
+ * @returns {Promise<PbCom2Balance>}
618
680
  */
619
681
  getBalanceByFirstName(first_name) {
620
682
  const ptr0 = passStringToWasm0(first_name, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -636,46 +698,6 @@ export class GrpcClient {
636
698
  }
637
699
  if (Symbol.dispose) GrpcClient.prototype[Symbol.dispose] = GrpcClient.prototype.free;
638
700
 
639
- const HaxFinalization = (typeof FinalizationRegistry === 'undefined')
640
- ? { register: () => {}, unregister: () => {} }
641
- : new FinalizationRegistry(ptr => wasm.__wbg_hax_free(ptr >>> 0, 1));
642
-
643
- export class Hax {
644
-
645
- __destroy_into_raw() {
646
- const ptr = this.__wbg_ptr;
647
- this.__wbg_ptr = 0;
648
- HaxFinalization.unregister(this);
649
- return ptr;
650
- }
651
-
652
- free() {
653
- const ptr = this.__destroy_into_raw();
654
- wasm.__wbg_hax_free(ptr, 0);
655
- }
656
- /**
657
- * @param {Digest[]} digests
658
- */
659
- constructor(digests) {
660
- const ptr0 = passArrayJsValueToWasm0(digests, wasm.__wbindgen_malloc);
661
- const len0 = WASM_VECTOR_LEN;
662
- const ret = wasm.hax_new(ptr0, len0);
663
- this.__wbg_ptr = ret >>> 0;
664
- HaxFinalization.register(this, this.__wbg_ptr, this);
665
- return this;
666
- }
667
- /**
668
- * @returns {Digest[]}
669
- */
670
- get digests() {
671
- const ret = wasm.hax_digests(this.__wbg_ptr);
672
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
673
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
674
- return v1;
675
- }
676
- }
677
- if (Symbol.dispose) Hax.prototype[Symbol.dispose] = Hax.prototype.free;
678
-
679
701
  const IntoUnderlyingByteSourceFinalization = (typeof FinalizationRegistry === 'undefined')
680
702
  ? { register: () => {}, unregister: () => {} }
681
703
  : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingbytesource_free(ptr >>> 0, 1));
@@ -756,1321 +778,54 @@ export class IntoUnderlyingSink {
756
778
  }
757
779
  /**
758
780
  * @returns {Promise<any>}
759
- */
760
- close() {
761
- const ptr = this.__destroy_into_raw();
762
- const ret = wasm.intounderlyingsink_close(ptr);
763
- return ret;
764
- }
765
- /**
766
- * @param {any} chunk
767
- * @returns {Promise<any>}
768
- */
769
- write(chunk) {
770
- const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
771
- return ret;
772
- }
773
- }
774
- if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
775
-
776
- const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
777
- ? { register: () => {}, unregister: () => {} }
778
- : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
779
-
780
- export class IntoUnderlyingSource {
781
-
782
- __destroy_into_raw() {
783
- const ptr = this.__wbg_ptr;
784
- this.__wbg_ptr = 0;
785
- IntoUnderlyingSourceFinalization.unregister(this);
786
- return ptr;
787
- }
788
-
789
- free() {
790
- const ptr = this.__destroy_into_raw();
791
- wasm.__wbg_intounderlyingsource_free(ptr, 0);
792
- }
793
- /**
794
- * @param {ReadableStreamDefaultController} controller
795
- * @returns {Promise<any>}
796
- */
797
- pull(controller) {
798
- const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
799
- return ret;
800
- }
801
- cancel() {
802
- const ptr = this.__destroy_into_raw();
803
- wasm.intounderlyingsource_cancel(ptr);
804
- }
805
- }
806
- if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
807
-
808
- const LockPrimitiveFinalization = (typeof FinalizationRegistry === 'undefined')
809
- ? { register: () => {}, unregister: () => {} }
810
- : new FinalizationRegistry(ptr => wasm.__wbg_lockprimitive_free(ptr >>> 0, 1));
811
-
812
- export class LockPrimitive {
813
-
814
- static __wrap(ptr) {
815
- ptr = ptr >>> 0;
816
- const obj = Object.create(LockPrimitive.prototype);
817
- obj.__wbg_ptr = ptr;
818
- LockPrimitiveFinalization.register(obj, obj.__wbg_ptr, obj);
819
- return obj;
820
- }
821
-
822
- static __unwrap(jsValue) {
823
- if (!(jsValue instanceof LockPrimitive)) {
824
- return 0;
825
- }
826
- return jsValue.__destroy_into_raw();
827
- }
828
-
829
- __destroy_into_raw() {
830
- const ptr = this.__wbg_ptr;
831
- this.__wbg_ptr = 0;
832
- LockPrimitiveFinalization.unregister(this);
833
- return ptr;
834
- }
835
-
836
- free() {
837
- const ptr = this.__destroy_into_raw();
838
- wasm.__wbg_lockprimitive_free(ptr, 0);
839
- }
840
- /**
841
- * @returns {any}
842
- */
843
- toProtobuf() {
844
- const ret = wasm.lockprimitive_toProtobuf(this.__wbg_ptr);
845
- if (ret[2]) {
846
- throw takeFromExternrefTable0(ret[1]);
847
- }
848
- return takeFromExternrefTable0(ret[0]);
849
- }
850
- /**
851
- * @param {any} value
852
- * @returns {LockPrimitive}
853
- */
854
- static fromProtobuf(value) {
855
- const ret = wasm.lockprimitive_fromProtobuf(value);
856
- if (ret[2]) {
857
- throw takeFromExternrefTable0(ret[1]);
858
- }
859
- return LockPrimitive.__wrap(ret[0]);
860
- }
861
- /**
862
- * @returns {LockPrimitive}
863
- */
864
- static newBrn() {
865
- const ret = wasm.lockprimitive_newBrn();
866
- return LockPrimitive.__wrap(ret);
867
- }
868
- /**
869
- * @param {Hax} hax
870
- * @returns {LockPrimitive}
871
- */
872
- static newHax(hax) {
873
- _assertClass(hax, Hax);
874
- var ptr0 = hax.__destroy_into_raw();
875
- const ret = wasm.lockprimitive_newHax(ptr0);
876
- return LockPrimitive.__wrap(ret);
877
- }
878
- /**
879
- * @param {Pkh} pkh
880
- * @returns {LockPrimitive}
881
- */
882
- static newPkh(pkh) {
883
- _assertClass(pkh, Pkh);
884
- var ptr0 = pkh.__destroy_into_raw();
885
- const ret = wasm.lockprimitive_newPkh(ptr0);
886
- return LockPrimitive.__wrap(ret);
887
- }
888
- /**
889
- * @param {LockTim} tim
890
- * @returns {LockPrimitive}
891
- */
892
- static newTim(tim) {
893
- _assertClass(tim, LockTim);
894
- var ptr0 = tim.__destroy_into_raw();
895
- const ret = wasm.lockprimitive_newTim(ptr0);
896
- return LockPrimitive.__wrap(ret);
897
- }
898
- }
899
- if (Symbol.dispose) LockPrimitive.prototype[Symbol.dispose] = LockPrimitive.prototype.free;
900
-
901
- const LockRootFinalization = (typeof FinalizationRegistry === 'undefined')
902
- ? { register: () => {}, unregister: () => {} }
903
- : new FinalizationRegistry(ptr => wasm.__wbg_lockroot_free(ptr >>> 0, 1));
904
-
905
- export class LockRoot {
906
-
907
- static __wrap(ptr) {
908
- ptr = ptr >>> 0;
909
- const obj = Object.create(LockRoot.prototype);
910
- obj.__wbg_ptr = ptr;
911
- LockRootFinalization.register(obj, obj.__wbg_ptr, obj);
912
- return obj;
913
- }
914
-
915
- __destroy_into_raw() {
916
- const ptr = this.__wbg_ptr;
917
- this.__wbg_ptr = 0;
918
- LockRootFinalization.unregister(this);
919
- return ptr;
920
- }
921
-
922
- free() {
923
- const ptr = this.__destroy_into_raw();
924
- wasm.__wbg_lockroot_free(ptr, 0);
925
- }
926
- /**
927
- * @param {SpendCondition} cond
928
- * @returns {LockRoot}
929
- */
930
- static fromSpendCondition(cond) {
931
- _assertClass(cond, SpendCondition);
932
- var ptr0 = cond.__destroy_into_raw();
933
- const ret = wasm.lockroot_fromSpendCondition(ptr0);
934
- if (ret[2]) {
935
- throw takeFromExternrefTable0(ret[1]);
936
- }
937
- return LockRoot.__wrap(ret[0]);
938
- }
939
- /**
940
- * @returns {Digest}
941
- */
942
- get hash() {
943
- const ret = wasm.lockroot_hash(this.__wbg_ptr);
944
- return Digest.__wrap(ret);
945
- }
946
- /**
947
- * @returns {SpendCondition | undefined}
948
- */
949
- get lock() {
950
- const ret = wasm.lockroot_lock(this.__wbg_ptr);
951
- return ret === 0 ? undefined : SpendCondition.__wrap(ret);
952
- }
953
- /**
954
- * @param {Digest} hash
955
- * @returns {LockRoot}
956
- */
957
- static fromHash(hash) {
958
- _assertClass(hash, Digest);
959
- var ptr0 = hash.__destroy_into_raw();
960
- const ret = wasm.lockroot_fromHash(ptr0);
961
- if (ret[2]) {
962
- throw takeFromExternrefTable0(ret[1]);
963
- }
964
- return LockRoot.__wrap(ret[0]);
965
- }
966
- }
967
- if (Symbol.dispose) LockRoot.prototype[Symbol.dispose] = LockRoot.prototype.free;
968
-
969
- const LockTimFinalization = (typeof FinalizationRegistry === 'undefined')
970
- ? { register: () => {}, unregister: () => {} }
971
- : new FinalizationRegistry(ptr => wasm.__wbg_locktim_free(ptr >>> 0, 1));
972
-
973
- export class LockTim {
974
-
975
- static __wrap(ptr) {
976
- ptr = ptr >>> 0;
977
- const obj = Object.create(LockTim.prototype);
978
- obj.__wbg_ptr = ptr;
979
- LockTimFinalization.register(obj, obj.__wbg_ptr, obj);
980
- return obj;
981
- }
982
-
983
- __destroy_into_raw() {
984
- const ptr = this.__wbg_ptr;
985
- this.__wbg_ptr = 0;
986
- LockTimFinalization.unregister(this);
987
- return ptr;
988
- }
989
-
990
- free() {
991
- const ptr = this.__destroy_into_raw();
992
- wasm.__wbg_locktim_free(ptr, 0);
993
- }
994
- /**
995
- * @returns {any}
996
- */
997
- toProtobuf() {
998
- const ret = wasm.locktim_toProtobuf(this.__wbg_ptr);
999
- if (ret[2]) {
1000
- throw takeFromExternrefTable0(ret[1]);
1001
- }
1002
- return takeFromExternrefTable0(ret[0]);
1003
- }
1004
- /**
1005
- * @param {any} value
1006
- * @returns {LockTim}
1007
- */
1008
- static fromProtobuf(value) {
1009
- const ret = wasm.locktim_fromProtobuf(value);
1010
- if (ret[2]) {
1011
- throw takeFromExternrefTable0(ret[1]);
1012
- }
1013
- return LockTim.__wrap(ret[0]);
1014
- }
1015
- /**
1016
- * @returns {TimelockRange}
1017
- */
1018
- get abs() {
1019
- const ret = wasm.locktim_abs(this.__wbg_ptr);
1020
- return TimelockRange.__wrap(ret);
1021
- }
1022
- /**
1023
- * @param {TimelockRange} rel
1024
- * @param {TimelockRange} abs
1025
- */
1026
- constructor(rel, abs) {
1027
- _assertClass(rel, TimelockRange);
1028
- var ptr0 = rel.__destroy_into_raw();
1029
- _assertClass(abs, TimelockRange);
1030
- var ptr1 = abs.__destroy_into_raw();
1031
- const ret = wasm.locktim_new(ptr0, ptr1);
1032
- this.__wbg_ptr = ret >>> 0;
1033
- LockTimFinalization.register(this, this.__wbg_ptr, this);
1034
- return this;
1035
- }
1036
- /**
1037
- * @returns {TimelockRange}
1038
- */
1039
- get rel() {
1040
- const ret = wasm.locktim_rel(this.__wbg_ptr);
1041
- return TimelockRange.__wrap(ret);
1042
- }
1043
- /**
1044
- * @returns {LockTim}
1045
- */
1046
- static coinbase() {
1047
- const ret = wasm.locktim_coinbase();
1048
- return LockTim.__wrap(ret);
1049
- }
1050
- }
1051
- if (Symbol.dispose) LockTim.prototype[Symbol.dispose] = LockTim.prototype.free;
1052
-
1053
- const NameFinalization = (typeof FinalizationRegistry === 'undefined')
1054
- ? { register: () => {}, unregister: () => {} }
1055
- : new FinalizationRegistry(ptr => wasm.__wbg_name_free(ptr >>> 0, 1));
1056
-
1057
- export class Name {
1058
-
1059
- static __wrap(ptr) {
1060
- ptr = ptr >>> 0;
1061
- const obj = Object.create(Name.prototype);
1062
- obj.__wbg_ptr = ptr;
1063
- NameFinalization.register(obj, obj.__wbg_ptr, obj);
1064
- return obj;
1065
- }
1066
-
1067
- __destroy_into_raw() {
1068
- const ptr = this.__wbg_ptr;
1069
- this.__wbg_ptr = 0;
1070
- NameFinalization.unregister(this);
1071
- return ptr;
1072
- }
1073
-
1074
- free() {
1075
- const ptr = this.__destroy_into_raw();
1076
- wasm.__wbg_name_free(ptr, 0);
1077
- }
1078
- /**
1079
- * @returns {any}
1080
- */
1081
- toProtobuf() {
1082
- const ret = wasm.name_toProtobuf(this.__wbg_ptr);
1083
- if (ret[2]) {
1084
- throw takeFromExternrefTable0(ret[1]);
1085
- }
1086
- return takeFromExternrefTable0(ret[0]);
1087
- }
1088
- /**
1089
- * @param {any} value
1090
- * @returns {Name}
1091
- */
1092
- static fromProtobuf(value) {
1093
- const ret = wasm.name_fromProtobuf(value);
1094
- if (ret[2]) {
1095
- throw takeFromExternrefTable0(ret[1]);
1096
- }
1097
- return Name.__wrap(ret[0]);
1098
- }
1099
- /**
1100
- * @param {string} first
1101
- * @param {string} last
1102
- */
1103
- constructor(first, last) {
1104
- const ptr0 = passStringToWasm0(first, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1105
- const len0 = WASM_VECTOR_LEN;
1106
- const ptr1 = passStringToWasm0(last, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1107
- const len1 = WASM_VECTOR_LEN;
1108
- const ret = wasm.name_new(ptr0, len0, ptr1, len1);
1109
- if (ret[2]) {
1110
- throw takeFromExternrefTable0(ret[1]);
1111
- }
1112
- this.__wbg_ptr = ret[0] >>> 0;
1113
- NameFinalization.register(this, this.__wbg_ptr, this);
1114
- return this;
1115
- }
1116
- /**
1117
- * @returns {string}
1118
- */
1119
- get last() {
1120
- let deferred1_0;
1121
- let deferred1_1;
1122
- try {
1123
- const ret = wasm.name_last(this.__wbg_ptr);
1124
- deferred1_0 = ret[0];
1125
- deferred1_1 = ret[1];
1126
- return getStringFromWasm0(ret[0], ret[1]);
1127
- } finally {
1128
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1129
- }
1130
- }
1131
- /**
1132
- * @returns {string}
1133
- */
1134
- get first() {
1135
- let deferred1_0;
1136
- let deferred1_1;
1137
- try {
1138
- const ret = wasm.name_first(this.__wbg_ptr);
1139
- deferred1_0 = ret[0];
1140
- deferred1_1 = ret[1];
1141
- return getStringFromWasm0(ret[0], ret[1]);
1142
- } finally {
1143
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1144
- }
1145
- }
1146
- }
1147
- if (Symbol.dispose) Name.prototype[Symbol.dispose] = Name.prototype.free;
1148
-
1149
- const NockchainTxFinalization = (typeof FinalizationRegistry === 'undefined')
1150
- ? { register: () => {}, unregister: () => {} }
1151
- : new FinalizationRegistry(ptr => wasm.__wbg_nockchaintx_free(ptr >>> 0, 1));
1152
-
1153
- export class NockchainTx {
1154
-
1155
- static __wrap(ptr) {
1156
- ptr = ptr >>> 0;
1157
- const obj = Object.create(NockchainTx.prototype);
1158
- obj.__wbg_ptr = ptr;
1159
- NockchainTxFinalization.register(obj, obj.__wbg_ptr, obj);
1160
- return obj;
1161
- }
1162
-
1163
- __destroy_into_raw() {
1164
- const ptr = this.__wbg_ptr;
1165
- this.__wbg_ptr = 0;
1166
- NockchainTxFinalization.unregister(this);
1167
- return ptr;
1168
- }
1169
-
1170
- free() {
1171
- const ptr = this.__destroy_into_raw();
1172
- wasm.__wbg_nockchaintx_free(ptr, 0);
1173
- }
1174
- /**
1175
- * @returns {Digest}
1176
- */
1177
- get id() {
1178
- const ret = wasm.nockchaintx_id(this.__wbg_ptr);
1179
- return Digest.__wrap(ret);
1180
- }
1181
- /**
1182
- * @returns {string}
1183
- */
1184
- get name() {
1185
- let deferred1_0;
1186
- let deferred1_1;
1187
- try {
1188
- const ret = wasm.nockchaintx_name(this.__wbg_ptr);
1189
- deferred1_0 = ret[0];
1190
- deferred1_1 = ret[1];
1191
- return getStringFromWasm0(ret[0], ret[1]);
1192
- } finally {
1193
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1194
- }
1195
- }
1196
- /**
1197
- * Convert to jammed transaction file for inspecting through CLI
1198
- * @returns {Uint8Array}
1199
- */
1200
- toJam() {
1201
- const ret = wasm.nockchaintx_toJam(this.__wbg_ptr);
1202
- return ret;
1203
- }
1204
- /**
1205
- * @returns {Note[]}
1206
- */
1207
- outputs() {
1208
- const ret = wasm.nockchaintx_outputs(this.__wbg_ptr);
1209
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1210
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1211
- return v1;
1212
- }
1213
- /**
1214
- * @returns {Version}
1215
- */
1216
- get version() {
1217
- const ret = wasm.nockchaintx_version(this.__wbg_ptr);
1218
- return Version.__wrap(ret);
1219
- }
1220
- /**
1221
- * Convert from CLI-compatible jammed transaction file
1222
- * @param {Uint8Array} jam
1223
- * @returns {NockchainTx}
1224
- */
1225
- static fromJam(jam) {
1226
- const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
1227
- const len0 = WASM_VECTOR_LEN;
1228
- const ret = wasm.nockchaintx_fromJam(ptr0, len0);
1229
- if (ret[2]) {
1230
- throw takeFromExternrefTable0(ret[1]);
1231
- }
1232
- return NockchainTx.__wrap(ret[0]);
1233
- }
1234
- /**
1235
- * @returns {RawTx}
1236
- */
1237
- toRawTx() {
1238
- const ret = wasm.nockchaintx_toRawTx(this.__wbg_ptr);
1239
- return RawTx.__wrap(ret);
1240
- }
1241
- }
1242
- if (Symbol.dispose) NockchainTx.prototype[Symbol.dispose] = NockchainTx.prototype.free;
1243
-
1244
- const NoteFinalization = (typeof FinalizationRegistry === 'undefined')
1245
- ? { register: () => {}, unregister: () => {} }
1246
- : new FinalizationRegistry(ptr => wasm.__wbg_note_free(ptr >>> 0, 1));
1247
-
1248
- export class Note {
1249
-
1250
- static __wrap(ptr) {
1251
- ptr = ptr >>> 0;
1252
- const obj = Object.create(Note.prototype);
1253
- obj.__wbg_ptr = ptr;
1254
- NoteFinalization.register(obj, obj.__wbg_ptr, obj);
1255
- return obj;
1256
- }
1257
-
1258
- static __unwrap(jsValue) {
1259
- if (!(jsValue instanceof Note)) {
1260
- return 0;
1261
- }
1262
- return jsValue.__destroy_into_raw();
1263
- }
1264
-
1265
- __destroy_into_raw() {
1266
- const ptr = this.__wbg_ptr;
1267
- this.__wbg_ptr = 0;
1268
- NoteFinalization.unregister(this);
1269
- return ptr;
1270
- }
1271
-
1272
- free() {
1273
- const ptr = this.__destroy_into_raw();
1274
- wasm.__wbg_note_free(ptr, 0);
1275
- }
1276
- /**
1277
- * @returns {bigint}
1278
- */
1279
- get originPage() {
1280
- const ret = wasm.note_originPage(this.__wbg_ptr);
1281
- return BigInt.asUintN(64, ret);
1282
- }
1283
- /**
1284
- * @returns {any}
1285
- */
1286
- toProtobuf() {
1287
- const ret = wasm.note_toProtobuf(this.__wbg_ptr);
1288
- if (ret[2]) {
1289
- throw takeFromExternrefTable0(ret[1]);
1290
- }
1291
- return takeFromExternrefTable0(ret[0]);
1292
- }
1293
- /**
1294
- * Create a WasmNote from a protobuf Note object (from get_balance response)
1295
- * Expects response.notes[i].note (handles version internally)
1296
- * @param {any} pb_note
1297
- * @returns {Note}
1298
- */
1299
- static fromProtobuf(pb_note) {
1300
- const ret = wasm.note_fromProtobuf(pb_note);
1301
- if (ret[2]) {
1302
- throw takeFromExternrefTable0(ret[1]);
1303
- }
1304
- return Note.__wrap(ret[0]);
1305
- }
1306
- /**
1307
- * @param {Version} version
1308
- * @param {bigint} origin_page
1309
- * @param {Name} name
1310
- * @param {NoteData} note_data
1311
- * @param {bigint} assets
1312
- */
1313
- constructor(version, origin_page, name, note_data, assets) {
1314
- _assertClass(version, Version);
1315
- var ptr0 = version.__destroy_into_raw();
1316
- _assertClass(name, Name);
1317
- var ptr1 = name.__destroy_into_raw();
1318
- _assertClass(note_data, NoteData);
1319
- var ptr2 = note_data.__destroy_into_raw();
1320
- const ret = wasm.note_new(ptr0, origin_page, ptr1, ptr2, assets);
1321
- this.__wbg_ptr = ret >>> 0;
1322
- NoteFinalization.register(this, this.__wbg_ptr, this);
1323
- return this;
1324
- }
1325
- /**
1326
- * @returns {Digest}
1327
- */
1328
- hash() {
1329
- const ret = wasm.note_hash(this.__wbg_ptr);
1330
- if (ret[2]) {
1331
- throw takeFromExternrefTable0(ret[1]);
1332
- }
1333
- return Digest.__wrap(ret[0]);
1334
- }
1335
- /**
1336
- * @returns {Name}
1337
- */
1338
- get name() {
1339
- const ret = wasm.note_name(this.__wbg_ptr);
1340
- return Name.__wrap(ret);
1341
- }
1342
- /**
1343
- * @returns {bigint}
1344
- */
1345
- get assets() {
1346
- const ret = wasm.note_assets(this.__wbg_ptr);
1347
- return BigInt.asUintN(64, ret);
1348
- }
1349
- /**
1350
- * @returns {Version}
1351
- */
1352
- get version() {
1353
- const ret = wasm.note_version(this.__wbg_ptr);
1354
- return Version.__wrap(ret);
1355
- }
1356
- /**
1357
- * @returns {NoteData}
1358
- */
1359
- get noteData() {
1360
- const ret = wasm.note_noteData(this.__wbg_ptr);
1361
- return NoteData.__wrap(ret);
1362
- }
1363
- }
1364
- if (Symbol.dispose) Note.prototype[Symbol.dispose] = Note.prototype.free;
1365
-
1366
- const NoteDataFinalization = (typeof FinalizationRegistry === 'undefined')
1367
- ? { register: () => {}, unregister: () => {} }
1368
- : new FinalizationRegistry(ptr => wasm.__wbg_notedata_free(ptr >>> 0, 1));
1369
-
1370
- export class NoteData {
1371
-
1372
- static __wrap(ptr) {
1373
- ptr = ptr >>> 0;
1374
- const obj = Object.create(NoteData.prototype);
1375
- obj.__wbg_ptr = ptr;
1376
- NoteDataFinalization.register(obj, obj.__wbg_ptr, obj);
1377
- return obj;
1378
- }
1379
-
1380
- __destroy_into_raw() {
1381
- const ptr = this.__wbg_ptr;
1382
- this.__wbg_ptr = 0;
1383
- NoteDataFinalization.unregister(this);
1384
- return ptr;
1385
- }
1386
-
1387
- free() {
1388
- const ptr = this.__destroy_into_raw();
1389
- wasm.__wbg_notedata_free(ptr, 0);
1390
- }
1391
- /**
1392
- * @returns {any}
1393
- */
1394
- toProtobuf() {
1395
- const ret = wasm.notedata_toProtobuf(this.__wbg_ptr);
1396
- if (ret[2]) {
1397
- throw takeFromExternrefTable0(ret[1]);
1398
- }
1399
- return takeFromExternrefTable0(ret[0]);
1400
- }
1401
- /**
1402
- * @param {any} value
1403
- * @returns {NoteData}
1404
- */
1405
- static fromProtobuf(value) {
1406
- const ret = wasm.notedata_fromProtobuf(value);
1407
- if (ret[2]) {
1408
- throw takeFromExternrefTable0(ret[1]);
1409
- }
1410
- return NoteData.__wrap(ret[0]);
1411
- }
1412
- /**
1413
- * @param {NoteDataEntry[]} entries
1414
- */
1415
- constructor(entries) {
1416
- const ptr0 = passArrayJsValueToWasm0(entries, wasm.__wbindgen_malloc);
1417
- const len0 = WASM_VECTOR_LEN;
1418
- const ret = wasm.notedata_new(ptr0, len0);
1419
- this.__wbg_ptr = ret >>> 0;
1420
- NoteDataFinalization.register(this, this.__wbg_ptr, this);
1421
- return this;
1422
- }
1423
- /**
1424
- * @returns {NoteData}
1425
- */
1426
- static empty() {
1427
- const ret = wasm.notedata_empty();
1428
- return NoteData.__wrap(ret);
1429
- }
1430
- /**
1431
- * @returns {NoteDataEntry[]}
1432
- */
1433
- get entries() {
1434
- const ret = wasm.notedata_entries(this.__wbg_ptr);
1435
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1436
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1437
- return v1;
1438
- }
1439
- /**
1440
- * @param {Pkh} pkh
1441
- * @returns {NoteData}
1442
- */
1443
- static fromPkh(pkh) {
1444
- _assertClass(pkh, Pkh);
1445
- var ptr0 = pkh.__destroy_into_raw();
1446
- const ret = wasm.notedata_fromPkh(ptr0);
1447
- if (ret[2]) {
1448
- throw takeFromExternrefTable0(ret[1]);
1449
- }
1450
- return NoteData.__wrap(ret[0]);
1451
- }
1452
- }
1453
- if (Symbol.dispose) NoteData.prototype[Symbol.dispose] = NoteData.prototype.free;
1454
-
1455
- const NoteDataEntryFinalization = (typeof FinalizationRegistry === 'undefined')
1456
- ? { register: () => {}, unregister: () => {} }
1457
- : new FinalizationRegistry(ptr => wasm.__wbg_notedataentry_free(ptr >>> 0, 1));
1458
-
1459
- export class NoteDataEntry {
1460
-
1461
- static __wrap(ptr) {
1462
- ptr = ptr >>> 0;
1463
- const obj = Object.create(NoteDataEntry.prototype);
1464
- obj.__wbg_ptr = ptr;
1465
- NoteDataEntryFinalization.register(obj, obj.__wbg_ptr, obj);
1466
- return obj;
1467
- }
1468
-
1469
- static __unwrap(jsValue) {
1470
- if (!(jsValue instanceof NoteDataEntry)) {
1471
- return 0;
1472
- }
1473
- return jsValue.__destroy_into_raw();
1474
- }
1475
-
1476
- __destroy_into_raw() {
1477
- const ptr = this.__wbg_ptr;
1478
- this.__wbg_ptr = 0;
1479
- NoteDataEntryFinalization.unregister(this);
1480
- return ptr;
1481
- }
1482
-
1483
- free() {
1484
- const ptr = this.__destroy_into_raw();
1485
- wasm.__wbg_notedataentry_free(ptr, 0);
1486
- }
1487
- /**
1488
- * @returns {any}
1489
- */
1490
- toProtobuf() {
1491
- const ret = wasm.notedataentry_toProtobuf(this.__wbg_ptr);
1492
- if (ret[2]) {
1493
- throw takeFromExternrefTable0(ret[1]);
1494
- }
1495
- return takeFromExternrefTable0(ret[0]);
1496
- }
1497
- /**
1498
- * @param {any} value
1499
- * @returns {NoteDataEntry}
1500
- */
1501
- static fromProtobuf(value) {
1502
- const ret = wasm.notedataentry_fromProtobuf(value);
1503
- if (ret[2]) {
1504
- throw takeFromExternrefTable0(ret[1]);
1505
- }
1506
- return NoteDataEntry.__wrap(ret[0]);
1507
- }
1508
- /**
1509
- * @returns {string}
1510
- */
1511
- get key() {
1512
- let deferred1_0;
1513
- let deferred1_1;
1514
- try {
1515
- const ret = wasm.notedataentry_key(this.__wbg_ptr);
1516
- deferred1_0 = ret[0];
1517
- deferred1_1 = ret[1];
1518
- return getStringFromWasm0(ret[0], ret[1]);
1519
- } finally {
1520
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1521
- }
1522
- }
1523
- /**
1524
- * @param {string} key
1525
- * @param {Uint8Array} blob
1526
- */
1527
- constructor(key, blob) {
1528
- const ptr0 = passStringToWasm0(key, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1529
- const len0 = WASM_VECTOR_LEN;
1530
- const ptr1 = passArray8ToWasm0(blob, wasm.__wbindgen_malloc);
1531
- const len1 = WASM_VECTOR_LEN;
1532
- const ret = wasm.notedataentry_new(ptr0, len0, ptr1, len1);
1533
- this.__wbg_ptr = ret >>> 0;
1534
- NoteDataEntryFinalization.register(this, this.__wbg_ptr, this);
1535
- return this;
1536
- }
1537
- /**
1538
- * @returns {Uint8Array}
1539
- */
1540
- get blob() {
1541
- const ret = wasm.notedataentry_blob(this.__wbg_ptr);
1542
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1543
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1544
- return v1;
1545
- }
1546
- }
1547
- if (Symbol.dispose) NoteDataEntry.prototype[Symbol.dispose] = NoteDataEntry.prototype.free;
1548
-
1549
- const NounFinalization = (typeof FinalizationRegistry === 'undefined')
1550
- ? { register: () => {}, unregister: () => {} }
1551
- : new FinalizationRegistry(ptr => wasm.__wbg_noun_free(ptr >>> 0, 1));
1552
-
1553
- export class Noun {
1554
-
1555
- static __wrap(ptr) {
1556
- ptr = ptr >>> 0;
1557
- const obj = Object.create(Noun.prototype);
1558
- obj.__wbg_ptr = ptr;
1559
- NounFinalization.register(obj, obj.__wbg_ptr, obj);
1560
- return obj;
1561
- }
1562
-
1563
- __destroy_into_raw() {
1564
- const ptr = this.__wbg_ptr;
1565
- this.__wbg_ptr = 0;
1566
- NounFinalization.unregister(this);
1567
- return ptr;
1568
- }
1569
-
1570
- free() {
1571
- const ptr = this.__destroy_into_raw();
1572
- wasm.__wbg_noun_free(ptr, 0);
1573
- }
1574
- /**
1575
- * @param {Uint8Array} jam
1576
- * @returns {Noun}
1577
- */
1578
- static cue(jam) {
1579
- const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
1580
- const len0 = WASM_VECTOR_LEN;
1581
- const ret = wasm.noun_cue(ptr0, len0);
1582
- if (ret[2]) {
1583
- throw takeFromExternrefTable0(ret[1]);
1584
- }
1585
- return Noun.__wrap(ret[0]);
1586
- }
1587
- /**
1588
- * @returns {Uint8Array}
1589
- */
1590
- jam() {
1591
- const ret = wasm.noun_jam(this.__wbg_ptr);
1592
- if (ret[3]) {
1593
- throw takeFromExternrefTable0(ret[2]);
1594
- }
1595
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
1596
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
1597
- return v1;
1598
- }
1599
- /**
1600
- * @param {any} value
1601
- * @returns {Noun}
1602
- */
1603
- static fromJs(value) {
1604
- const ret = wasm.noun_fromJs(value);
1605
- if (ret[2]) {
1606
- throw takeFromExternrefTable0(ret[1]);
1607
- }
1608
- return Noun.__wrap(ret[0]);
1609
- }
1610
- /**
1611
- * @returns {any}
1612
- */
1613
- toJs() {
1614
- const ret = wasm.noun_toJs(this.__wbg_ptr);
1615
- if (ret[2]) {
1616
- throw takeFromExternrefTable0(ret[1]);
1617
- }
1618
- return takeFromExternrefTable0(ret[0]);
1619
- }
1620
- }
1621
- if (Symbol.dispose) Noun.prototype[Symbol.dispose] = Noun.prototype.free;
1622
-
1623
- const PkhFinalization = (typeof FinalizationRegistry === 'undefined')
1624
- ? { register: () => {}, unregister: () => {} }
1625
- : new FinalizationRegistry(ptr => wasm.__wbg_pkh_free(ptr >>> 0, 1));
1626
-
1627
- export class Pkh {
1628
-
1629
- static __wrap(ptr) {
1630
- ptr = ptr >>> 0;
1631
- const obj = Object.create(Pkh.prototype);
1632
- obj.__wbg_ptr = ptr;
1633
- PkhFinalization.register(obj, obj.__wbg_ptr, obj);
1634
- return obj;
1635
- }
1636
-
1637
- __destroy_into_raw() {
1638
- const ptr = this.__wbg_ptr;
1639
- this.__wbg_ptr = 0;
1640
- PkhFinalization.unregister(this);
1641
- return ptr;
1642
- }
1643
-
1644
- free() {
1645
- const ptr = this.__destroy_into_raw();
1646
- wasm.__wbg_pkh_free(ptr, 0);
1647
- }
1648
- /**
1649
- * @returns {any}
1650
- */
1651
- toProtobuf() {
1652
- const ret = wasm.pkh_toProtobuf(this.__wbg_ptr);
1653
- if (ret[2]) {
1654
- throw takeFromExternrefTable0(ret[1]);
1655
- }
1656
- return takeFromExternrefTable0(ret[0]);
1657
- }
1658
- /**
1659
- * @param {any} value
1660
- * @returns {Pkh}
1661
- */
1662
- static fromProtobuf(value) {
1663
- const ret = wasm.pkh_fromProtobuf(value);
1664
- if (ret[2]) {
1665
- throw takeFromExternrefTable0(ret[1]);
1666
- }
1667
- return Pkh.__wrap(ret[0]);
1668
- }
1669
- /**
1670
- * @returns {bigint}
1671
- */
1672
- get m() {
1673
- const ret = wasm.pkh_m(this.__wbg_ptr);
1674
- return BigInt.asUintN(64, ret);
1675
- }
1676
- /**
1677
- * @param {bigint} m
1678
- * @param {string[]} hashes
1679
- */
1680
- constructor(m, hashes) {
1681
- const ptr0 = passArrayJsValueToWasm0(hashes, wasm.__wbindgen_malloc);
1682
- const len0 = WASM_VECTOR_LEN;
1683
- const ret = wasm.pkh_new(m, ptr0, len0);
1684
- this.__wbg_ptr = ret >>> 0;
1685
- PkhFinalization.register(this, this.__wbg_ptr, this);
1686
- return this;
1687
- }
1688
- /**
1689
- * @returns {string[]}
1690
- */
1691
- get hashes() {
1692
- const ret = wasm.pkh_hashes(this.__wbg_ptr);
1693
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1694
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1695
- return v1;
1696
- }
1697
- /**
1698
- * @param {string} hash
1699
- * @returns {Pkh}
1700
- */
1701
- static single(hash) {
1702
- const ptr0 = passStringToWasm0(hash, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
1703
- const len0 = WASM_VECTOR_LEN;
1704
- const ret = wasm.pkh_single(ptr0, len0);
1705
- return Pkh.__wrap(ret);
1706
- }
1707
- }
1708
- if (Symbol.dispose) Pkh.prototype[Symbol.dispose] = Pkh.prototype.free;
1709
-
1710
- const RawTxFinalization = (typeof FinalizationRegistry === 'undefined')
1711
- ? { register: () => {}, unregister: () => {} }
1712
- : new FinalizationRegistry(ptr => wasm.__wbg_rawtx_free(ptr >>> 0, 1));
1713
-
1714
- export class RawTx {
1715
-
1716
- static __wrap(ptr) {
1717
- ptr = ptr >>> 0;
1718
- const obj = Object.create(RawTx.prototype);
1719
- obj.__wbg_ptr = ptr;
1720
- RawTxFinalization.register(obj, obj.__wbg_ptr, obj);
1721
- return obj;
1722
- }
1723
-
1724
- __destroy_into_raw() {
1725
- const ptr = this.__wbg_ptr;
1726
- this.__wbg_ptr = 0;
1727
- RawTxFinalization.unregister(this);
1728
- return ptr;
1729
- }
1730
-
1731
- free() {
1732
- const ptr = this.__destroy_into_raw();
1733
- wasm.__wbg_rawtx_free(ptr, 0);
1734
- }
1735
- /**
1736
- * Convert to protobuf RawTransaction for sending via gRPC
1737
- * @returns {any}
1738
- */
1739
- toProtobuf() {
1740
- const ret = wasm.rawtx_toProtobuf(this.__wbg_ptr);
1741
- if (ret[2]) {
1742
- throw takeFromExternrefTable0(ret[1]);
1743
- }
1744
- return takeFromExternrefTable0(ret[0]);
1745
- }
1746
- /**
1747
- * @param {any} value
1748
- * @returns {RawTx}
1749
- */
1750
- static fromProtobuf(value) {
1751
- const ret = wasm.rawtx_fromProtobuf(value);
1752
- if (ret[2]) {
1753
- throw takeFromExternrefTable0(ret[1]);
1754
- }
1755
- return RawTx.__wrap(ret[0]);
1756
- }
1757
- /**
1758
- * @returns {NockchainTx}
1759
- */
1760
- toNockchainTx() {
1761
- const ret = wasm.rawtx_toNockchainTx(this.__wbg_ptr);
1762
- return NockchainTx.__wrap(ret);
1763
- }
1764
- /**
1765
- * @returns {Digest}
1766
- */
1767
- get id() {
1768
- const ret = wasm.rawtx_id(this.__wbg_ptr);
1769
- return Digest.__wrap(ret);
1770
- }
1771
- /**
1772
- * @returns {string}
1773
- */
1774
- get name() {
1775
- let deferred1_0;
1776
- let deferred1_1;
1777
- try {
1778
- const ret = wasm.rawtx_name(this.__wbg_ptr);
1779
- deferred1_0 = ret[0];
1780
- deferred1_1 = ret[1];
1781
- return getStringFromWasm0(ret[0], ret[1]);
1782
- } finally {
1783
- wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
1784
- }
1785
- }
1786
- /**
1787
- * Convert to jammed transaction file for inspecting through CLI
1788
- * @returns {Uint8Array}
1789
- */
1790
- toJam() {
1791
- const ret = wasm.rawtx_toJam(this.__wbg_ptr);
1792
- return ret;
1793
- }
1794
- /**
1795
- * Calculate output notes from the transaction spends.
1796
- * @returns {Note[]}
1797
- */
1798
- outputs() {
1799
- const ret = wasm.rawtx_outputs(this.__wbg_ptr);
1800
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
1801
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
1802
- return v1;
1803
- }
1804
- /**
1805
- * @returns {Version}
1806
- */
1807
- get version() {
1808
- const ret = wasm.rawtx_version(this.__wbg_ptr);
1809
- return Version.__wrap(ret);
1810
- }
1811
- /**
1812
- * @param {Uint8Array} jam
1813
- * @returns {RawTx}
1814
- */
1815
- static fromJam(jam) {
1816
- const ptr0 = passArray8ToWasm0(jam, wasm.__wbindgen_malloc);
1817
- const len0 = WASM_VECTOR_LEN;
1818
- const ret = wasm.rawtx_fromJam(ptr0, len0);
1819
- if (ret[2]) {
1820
- throw takeFromExternrefTable0(ret[1]);
1821
- }
1822
- return RawTx.__wrap(ret[0]);
1823
- }
1824
- }
1825
- if (Symbol.dispose) RawTx.prototype[Symbol.dispose] = RawTx.prototype.free;
1826
-
1827
- const SeedFinalization = (typeof FinalizationRegistry === 'undefined')
1828
- ? { register: () => {}, unregister: () => {} }
1829
- : new FinalizationRegistry(ptr => wasm.__wbg_seed_free(ptr >>> 0, 1));
1830
-
1831
- export class Seed {
1832
-
1833
- static __wrap(ptr) {
1834
- ptr = ptr >>> 0;
1835
- const obj = Object.create(Seed.prototype);
1836
- obj.__wbg_ptr = ptr;
1837
- SeedFinalization.register(obj, obj.__wbg_ptr, obj);
1838
- return obj;
1839
- }
1840
-
1841
- __destroy_into_raw() {
1842
- const ptr = this.__wbg_ptr;
1843
- this.__wbg_ptr = 0;
1844
- SeedFinalization.unregister(this);
1845
- return ptr;
1846
- }
1847
-
1848
- free() {
1849
- const ptr = this.__destroy_into_raw();
1850
- wasm.__wbg_seed_free(ptr, 0);
1851
- }
1852
- /**
1853
- * @returns {Digest}
1854
- */
1855
- get parentHash() {
1856
- const ret = wasm.seed_parentHash(this.__wbg_ptr);
1857
- return Digest.__wrap(ret);
1858
- }
1859
- /**
1860
- * @returns {Source | undefined}
1861
- */
1862
- get outputSource() {
1863
- const ret = wasm.seed_outputSource(this.__wbg_ptr);
1864
- return ret === 0 ? undefined : Source.__wrap(ret);
1865
- }
1866
- /**
1867
- * @param {LockRoot} lock_root
1868
- */
1869
- set lockRoot(lock_root) {
1870
- _assertClass(lock_root, LockRoot);
1871
- var ptr0 = lock_root.__destroy_into_raw();
1872
- wasm.seed_set_lockRoot(this.__wbg_ptr, ptr0);
1873
- }
1874
- /**
1875
- * @param {NoteData} note_data
1876
- */
1877
- set noteData(note_data) {
1878
- _assertClass(note_data, NoteData);
1879
- var ptr0 = note_data.__destroy_into_raw();
1880
- wasm.seed_set_noteData(this.__wbg_ptr, ptr0);
1881
- }
1882
- /**
1883
- * @param {Digest} pkh
1884
- * @param {bigint} gift
1885
- * @param {Digest} parent_hash
1886
- * @param {boolean} include_lock_data
1887
- * @returns {Seed}
1888
- */
1889
- static newSinglePkh(pkh, gift, parent_hash, include_lock_data) {
1890
- _assertClass(pkh, Digest);
1891
- var ptr0 = pkh.__destroy_into_raw();
1892
- _assertClass(parent_hash, Digest);
1893
- var ptr1 = parent_hash.__destroy_into_raw();
1894
- const ret = wasm.seed_newSinglePkh(ptr0, gift, ptr1, include_lock_data);
1895
- if (ret[2]) {
1896
- throw takeFromExternrefTable0(ret[1]);
1897
- }
1898
- return Seed.__wrap(ret[0]);
1899
- }
1900
- /**
1901
- * @param {Digest} parent_hash
1902
- */
1903
- set parentHash(parent_hash) {
1904
- _assertClass(parent_hash, Digest);
1905
- var ptr0 = parent_hash.__destroy_into_raw();
1906
- wasm.seed_set_parentHash(this.__wbg_ptr, ptr0);
1907
- }
1908
- /**
1909
- * @param {Source | null} [output_source]
1910
- */
1911
- set outputSource(output_source) {
1912
- let ptr0 = 0;
1913
- if (!isLikeNone(output_source)) {
1914
- _assertClass(output_source, Source);
1915
- ptr0 = output_source.__destroy_into_raw();
1916
- }
1917
- wasm.seed_set_outputSource(this.__wbg_ptr, ptr0);
1918
- }
1919
- /**
1920
- * @param {Source | null | undefined} output_source
1921
- * @param {LockRoot} lock_root
1922
- * @param {bigint} gift
1923
- * @param {NoteData} note_data
1924
- * @param {Digest} parent_hash
1925
- */
1926
- constructor(output_source, lock_root, gift, note_data, parent_hash) {
1927
- let ptr0 = 0;
1928
- if (!isLikeNone(output_source)) {
1929
- _assertClass(output_source, Source);
1930
- ptr0 = output_source.__destroy_into_raw();
1931
- }
1932
- _assertClass(lock_root, LockRoot);
1933
- var ptr1 = lock_root.__destroy_into_raw();
1934
- _assertClass(note_data, NoteData);
1935
- var ptr2 = note_data.__destroy_into_raw();
1936
- _assertClass(parent_hash, Digest);
1937
- var ptr3 = parent_hash.__destroy_into_raw();
1938
- const ret = wasm.seed_new(ptr0, ptr1, gift, ptr2, ptr3);
1939
- this.__wbg_ptr = ret >>> 0;
1940
- SeedFinalization.register(this, this.__wbg_ptr, this);
1941
- return this;
1942
- }
1943
- /**
1944
- * @returns {bigint}
1945
- */
1946
- get gift() {
1947
- const ret = wasm.seed_gift(this.__wbg_ptr);
1948
- return BigInt.asUintN(64, ret);
1949
- }
1950
- /**
1951
- * @param {bigint} gift
1952
- */
1953
- set gift(gift) {
1954
- wasm.seed_set_gift(this.__wbg_ptr, gift);
1955
- }
1956
- /**
1957
- * @returns {LockRoot}
1958
- */
1959
- get lockRoot() {
1960
- const ret = wasm.seed_lockRoot(this.__wbg_ptr);
1961
- return LockRoot.__wrap(ret);
1962
- }
1963
- /**
1964
- * @returns {NoteData}
1965
- */
1966
- get noteData() {
1967
- const ret = wasm.seed_noteData(this.__wbg_ptr);
1968
- return NoteData.__wrap(ret);
1969
- }
1970
- }
1971
- if (Symbol.dispose) Seed.prototype[Symbol.dispose] = Seed.prototype.free;
1972
-
1973
- const SignatureFinalization = (typeof FinalizationRegistry === 'undefined')
1974
- ? { register: () => {}, unregister: () => {} }
1975
- : new FinalizationRegistry(ptr => wasm.__wbg_signature_free(ptr >>> 0, 1));
1976
-
1977
- export class Signature {
1978
-
1979
- static __wrap(ptr) {
1980
- ptr = ptr >>> 0;
1981
- const obj = Object.create(Signature.prototype);
1982
- obj.__wbg_ptr = ptr;
1983
- SignatureFinalization.register(obj, obj.__wbg_ptr, obj);
1984
- return obj;
1985
- }
1986
-
1987
- __destroy_into_raw() {
1988
- const ptr = this.__wbg_ptr;
1989
- this.__wbg_ptr = 0;
1990
- SignatureFinalization.unregister(this);
1991
- return ptr;
1992
- }
1993
-
1994
- free() {
1995
- const ptr = this.__destroy_into_raw();
1996
- wasm.__wbg_signature_free(ptr, 0);
1997
- }
1998
- /**
1999
- * @returns {Uint8Array}
2000
- */
2001
- get c() {
2002
- const ret = wasm.signature_c(this.__wbg_ptr);
2003
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2004
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2005
- return v1;
2006
- }
2007
- /**
2008
- * @returns {Uint8Array}
2009
- */
2010
- get s() {
2011
- const ret = wasm.signature_s(this.__wbg_ptr);
2012
- var v1 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
2013
- wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
2014
- return v1;
781
+ */
782
+ close() {
783
+ const ptr = this.__destroy_into_raw();
784
+ const ret = wasm.intounderlyingsink_close(ptr);
785
+ return ret;
2015
786
  }
2016
787
  /**
2017
- * @param {Uint8Array} c
2018
- * @param {Uint8Array} s
788
+ * @param {any} chunk
789
+ * @returns {Promise<any>}
2019
790
  */
2020
- constructor(c, s) {
2021
- const ptr0 = passArray8ToWasm0(c, wasm.__wbindgen_malloc);
2022
- const len0 = WASM_VECTOR_LEN;
2023
- const ptr1 = passArray8ToWasm0(s, wasm.__wbindgen_malloc);
2024
- const len1 = WASM_VECTOR_LEN;
2025
- const ret = wasm.signature_new(ptr0, len0, ptr1, len1);
2026
- this.__wbg_ptr = ret >>> 0;
2027
- SignatureFinalization.register(this, this.__wbg_ptr, this);
2028
- return this;
791
+ write(chunk) {
792
+ const ret = wasm.intounderlyingsink_write(this.__wbg_ptr, chunk);
793
+ return ret;
2029
794
  }
2030
795
  }
2031
- if (Symbol.dispose) Signature.prototype[Symbol.dispose] = Signature.prototype.free;
796
+ if (Symbol.dispose) IntoUnderlyingSink.prototype[Symbol.dispose] = IntoUnderlyingSink.prototype.free;
2032
797
 
2033
- const SourceFinalization = (typeof FinalizationRegistry === 'undefined')
798
+ const IntoUnderlyingSourceFinalization = (typeof FinalizationRegistry === 'undefined')
2034
799
  ? { register: () => {}, unregister: () => {} }
2035
- : new FinalizationRegistry(ptr => wasm.__wbg_source_free(ptr >>> 0, 1));
2036
-
2037
- export class Source {
800
+ : new FinalizationRegistry(ptr => wasm.__wbg_intounderlyingsource_free(ptr >>> 0, 1));
2038
801
 
2039
- static __wrap(ptr) {
2040
- ptr = ptr >>> 0;
2041
- const obj = Object.create(Source.prototype);
2042
- obj.__wbg_ptr = ptr;
2043
- SourceFinalization.register(obj, obj.__wbg_ptr, obj);
2044
- return obj;
2045
- }
802
+ export class IntoUnderlyingSource {
2046
803
 
2047
804
  __destroy_into_raw() {
2048
805
  const ptr = this.__wbg_ptr;
2049
806
  this.__wbg_ptr = 0;
2050
- SourceFinalization.unregister(this);
807
+ IntoUnderlyingSourceFinalization.unregister(this);
2051
808
  return ptr;
2052
809
  }
2053
810
 
2054
811
  free() {
2055
812
  const ptr = this.__destroy_into_raw();
2056
- wasm.__wbg_source_free(ptr, 0);
813
+ wasm.__wbg_intounderlyingsource_free(ptr, 0);
2057
814
  }
2058
815
  /**
2059
- * @returns {boolean}
816
+ * @param {ReadableStreamDefaultController} controller
817
+ * @returns {Promise<any>}
2060
818
  */
2061
- get isCoinbase() {
2062
- const ret = wasm.source_isCoinbase(this.__wbg_ptr);
2063
- return ret !== 0;
819
+ pull(controller) {
820
+ const ret = wasm.intounderlyingsource_pull(this.__wbg_ptr, controller);
821
+ return ret;
2064
822
  }
2065
- /**
2066
- * @returns {Digest}
2067
- */
2068
- get hash() {
2069
- const ret = wasm.source_hash(this.__wbg_ptr);
2070
- return Digest.__wrap(ret);
823
+ cancel() {
824
+ const ptr = this.__destroy_into_raw();
825
+ wasm.intounderlyingsource_cancel(ptr);
2071
826
  }
2072
827
  }
2073
- if (Symbol.dispose) Source.prototype[Symbol.dispose] = Source.prototype.free;
828
+ if (Symbol.dispose) IntoUnderlyingSource.prototype[Symbol.dispose] = IntoUnderlyingSource.prototype.free;
2074
829
 
2075
830
  const SpendBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
2076
831
  ? { register: () => {}, unregister: () => {} }
@@ -2098,17 +853,13 @@ export class SpendBuilder {
2098
853
  wasm.__wbg_spendbuilder_free(ptr, 0);
2099
854
  }
2100
855
  /**
2101
- * Get current refund
2102
- * @returns {Seed | undefined}
856
+ * @returns {SeedV1 | undefined}
2103
857
  */
2104
858
  curRefund() {
2105
859
  const ret = wasm.spendbuilder_curRefund(this.__wbg_ptr);
2106
- return ret === 0 ? undefined : Seed.__wrap(ret);
860
+ return ret;
2107
861
  }
2108
862
  /**
2109
- * Checks whether note.assets = seeds + fee
2110
- *
2111
- * This function needs to return true for `TxBuilder::validate` to pass
2112
863
  * @returns {boolean}
2113
864
  */
2114
865
  isBalanced() {
@@ -2116,7 +867,6 @@ export class SpendBuilder {
2116
867
  return ret !== 0;
2117
868
  }
2118
869
  /**
2119
- * Attatch a preimage to this spend
2120
870
  * @param {Uint8Array} preimage_jam
2121
871
  * @returns {Digest | undefined}
2122
872
  */
@@ -2127,35 +877,19 @@ export class SpendBuilder {
2127
877
  if (ret[2]) {
2128
878
  throw takeFromExternrefTable0(ret[1]);
2129
879
  }
2130
- return ret[0] === 0 ? undefined : Digest.__wrap(ret[0]);
880
+ return takeFromExternrefTable0(ret[0]);
2131
881
  }
2132
882
  /**
2133
- * Compute refund from any spare assets, given `refund_lock` was passed
2134
883
  * @param {boolean} include_lock_data
2135
884
  */
2136
885
  computeRefund(include_lock_data) {
2137
886
  wasm.spendbuilder_computeRefund(this.__wbg_ptr, include_lock_data);
2138
887
  }
2139
- /**
2140
- * Manually invalidate signatures
2141
- *
2142
- * Each spend's fee+seeds are bound to one or more signatures. If they get changed, the
2143
- * signature becomes invalid. This builder automatically invalidates signatures upon relevant
2144
- * modifications, but this functionality is provided nonetheless.
2145
- */
2146
888
  invalidateSigs() {
2147
889
  wasm.spendbuilder_invalidateSigs(this.__wbg_ptr);
2148
890
  }
2149
891
  /**
2150
- * Get the list of missing "unlocks"
2151
- *
2152
- * An unlock is a spend condition to be satisfied. For instance, for a `Pkh` spend condition,
2153
- * if the transaction is unsigned, this function will return a Pkh type missing unlock, with
2154
- * the list of valid PKH's and number of signatures needed. This will not return PKHs that are
2155
- * already attatched to the spend (relevant for multisigs). For `Hax` spend condition, this
2156
- * will return any missing preimages. This function will return a list of not-yet-validated
2157
- * spend conditions.
2158
- * @returns {any[]}
892
+ * @returns {MissingUnlocks[]}
2159
893
  */
2160
894
  missingUnlocks() {
2161
895
  const ret = wasm.spendbuilder_missingUnlocks(this.__wbg_ptr);
@@ -2167,8 +901,7 @@ export class SpendBuilder {
2167
901
  return v1;
2168
902
  }
2169
903
  /**
2170
- * Set the fee of this spend
2171
- * @param {bigint} fee
904
+ * @param {Nicks} fee
2172
905
  */
2173
906
  fee(fee) {
2174
907
  wasm.spendbuilder_fee(this.__wbg_ptr, fee);
@@ -2176,20 +909,11 @@ export class SpendBuilder {
2176
909
  /**
2177
910
  * Create a new `SpendBuilder` with a given note and spend condition
2178
911
  * @param {Note} note
2179
- * @param {SpendCondition} spend_condition
912
+ * @param {SpendCondition | null} [spend_condition]
2180
913
  * @param {SpendCondition | null} [refund_lock]
2181
914
  */
2182
915
  constructor(note, spend_condition, refund_lock) {
2183
- _assertClass(note, Note);
2184
- var ptr0 = note.__destroy_into_raw();
2185
- _assertClass(spend_condition, SpendCondition);
2186
- var ptr1 = spend_condition.__destroy_into_raw();
2187
- let ptr2 = 0;
2188
- if (!isLikeNone(refund_lock)) {
2189
- _assertClass(refund_lock, SpendCondition);
2190
- ptr2 = refund_lock.__destroy_into_raw();
2191
- }
2192
- const ret = wasm.spendbuilder_new(ptr0, ptr1, ptr2);
916
+ const ret = wasm.spendbuilder_new(note, isLikeNone(spend_condition) ? 0 : addToExternrefTable0(spend_condition), isLikeNone(refund_lock) ? 0 : addToExternrefTable0(refund_lock));
2193
917
  if (ret[2]) {
2194
918
  throw takeFromExternrefTable0(ret[1]);
2195
919
  }
@@ -2198,24 +922,15 @@ export class SpendBuilder {
2198
922
  return this;
2199
923
  }
2200
924
  /**
2201
- * Add seed to this spend
2202
- *
2203
- * Seed is an output with a recipient (as defined by the spend condition).
2204
- *
2205
- * Nockchain transaction engine will take all seeds with matching lock from all spends in the
2206
- * transaction, and merge them into one output note.
2207
- * @param {Seed} seed
925
+ * @param {SeedV1} seed
2208
926
  */
2209
927
  seed(seed) {
2210
- _assertClass(seed, Seed);
2211
- var ptr0 = seed.__destroy_into_raw();
2212
- const ret = wasm.spendbuilder_seed(this.__wbg_ptr, ptr0);
928
+ const ret = wasm.spendbuilder_seed(this.__wbg_ptr, seed);
2213
929
  if (ret[1]) {
2214
930
  throw takeFromExternrefTable0(ret[0]);
2215
931
  }
2216
932
  }
2217
933
  /**
2218
- * Sign the transaction with a given private key
2219
934
  * @param {Uint8Array} signing_key_bytes
2220
935
  * @returns {boolean}
2221
936
  */
@@ -2231,155 +946,6 @@ export class SpendBuilder {
2231
946
  }
2232
947
  if (Symbol.dispose) SpendBuilder.prototype[Symbol.dispose] = SpendBuilder.prototype.free;
2233
948
 
2234
- const SpendConditionFinalization = (typeof FinalizationRegistry === 'undefined')
2235
- ? { register: () => {}, unregister: () => {} }
2236
- : new FinalizationRegistry(ptr => wasm.__wbg_spendcondition_free(ptr >>> 0, 1));
2237
-
2238
- export class SpendCondition {
2239
-
2240
- static __wrap(ptr) {
2241
- ptr = ptr >>> 0;
2242
- const obj = Object.create(SpendCondition.prototype);
2243
- obj.__wbg_ptr = ptr;
2244
- SpendConditionFinalization.register(obj, obj.__wbg_ptr, obj);
2245
- return obj;
2246
- }
2247
-
2248
- static __unwrap(jsValue) {
2249
- if (!(jsValue instanceof SpendCondition)) {
2250
- return 0;
2251
- }
2252
- return jsValue.__destroy_into_raw();
2253
- }
2254
-
2255
- __destroy_into_raw() {
2256
- const ptr = this.__wbg_ptr;
2257
- this.__wbg_ptr = 0;
2258
- SpendConditionFinalization.unregister(this);
2259
- return ptr;
2260
- }
2261
-
2262
- free() {
2263
- const ptr = this.__destroy_into_raw();
2264
- wasm.__wbg_spendcondition_free(ptr, 0);
2265
- }
2266
- /**
2267
- * @returns {Digest}
2268
- */
2269
- firstName() {
2270
- const ret = wasm.spendcondition_firstName(this.__wbg_ptr);
2271
- if (ret[2]) {
2272
- throw takeFromExternrefTable0(ret[1]);
2273
- }
2274
- return Digest.__wrap(ret[0]);
2275
- }
2276
- /**
2277
- * @returns {any}
2278
- */
2279
- toProtobuf() {
2280
- const ret = wasm.spendcondition_toProtobuf(this.__wbg_ptr);
2281
- if (ret[2]) {
2282
- throw takeFromExternrefTable0(ret[1]);
2283
- }
2284
- return takeFromExternrefTable0(ret[0]);
2285
- }
2286
- /**
2287
- * @param {any} value
2288
- * @returns {SpendCondition}
2289
- */
2290
- static fromProtobuf(value) {
2291
- const ret = wasm.spendcondition_fromProtobuf(value);
2292
- if (ret[2]) {
2293
- throw takeFromExternrefTable0(ret[1]);
2294
- }
2295
- return SpendCondition.__wrap(ret[0]);
2296
- }
2297
- /**
2298
- * @param {LockPrimitive[]} primitives
2299
- */
2300
- constructor(primitives) {
2301
- const ptr0 = passArrayJsValueToWasm0(primitives, wasm.__wbindgen_malloc);
2302
- const len0 = WASM_VECTOR_LEN;
2303
- const ret = wasm.spendcondition_new(ptr0, len0);
2304
- this.__wbg_ptr = ret >>> 0;
2305
- SpendConditionFinalization.register(this, this.__wbg_ptr, this);
2306
- return this;
2307
- }
2308
- /**
2309
- * @returns {Digest}
2310
- */
2311
- hash() {
2312
- const ret = wasm.spendcondition_hash(this.__wbg_ptr);
2313
- if (ret[2]) {
2314
- throw takeFromExternrefTable0(ret[1]);
2315
- }
2316
- return Digest.__wrap(ret[0]);
2317
- }
2318
- /**
2319
- * @param {Pkh} pkh
2320
- * @returns {SpendCondition}
2321
- */
2322
- static newPkh(pkh) {
2323
- _assertClass(pkh, Pkh);
2324
- var ptr0 = pkh.__destroy_into_raw();
2325
- const ret = wasm.spendcondition_newPkh(ptr0);
2326
- return SpendCondition.__wrap(ret);
2327
- }
2328
- }
2329
- if (Symbol.dispose) SpendCondition.prototype[Symbol.dispose] = SpendCondition.prototype.free;
2330
-
2331
- const TimelockRangeFinalization = (typeof FinalizationRegistry === 'undefined')
2332
- ? { register: () => {}, unregister: () => {} }
2333
- : new FinalizationRegistry(ptr => wasm.__wbg_timelockrange_free(ptr >>> 0, 1));
2334
-
2335
- export class TimelockRange {
2336
-
2337
- static __wrap(ptr) {
2338
- ptr = ptr >>> 0;
2339
- const obj = Object.create(TimelockRange.prototype);
2340
- obj.__wbg_ptr = ptr;
2341
- TimelockRangeFinalization.register(obj, obj.__wbg_ptr, obj);
2342
- return obj;
2343
- }
2344
-
2345
- __destroy_into_raw() {
2346
- const ptr = this.__wbg_ptr;
2347
- this.__wbg_ptr = 0;
2348
- TimelockRangeFinalization.unregister(this);
2349
- return ptr;
2350
- }
2351
-
2352
- free() {
2353
- const ptr = this.__destroy_into_raw();
2354
- wasm.__wbg_timelockrange_free(ptr, 0);
2355
- }
2356
- /**
2357
- * @returns {bigint | undefined}
2358
- */
2359
- get max() {
2360
- const ret = wasm.timelockrange_max(this.__wbg_ptr);
2361
- return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2362
- }
2363
- /**
2364
- * @returns {bigint | undefined}
2365
- */
2366
- get min() {
2367
- const ret = wasm.timelockrange_min(this.__wbg_ptr);
2368
- return ret[0] === 0 ? undefined : BigInt.asUintN(64, ret[1]);
2369
- }
2370
- /**
2371
- * @param {bigint | null} [min]
2372
- * @param {bigint | null} [max]
2373
- */
2374
- constructor(min, max) {
2375
- const ret = wasm.timelockrange_new(!isLikeNone(min), isLikeNone(min) ? BigInt(0) : min, !isLikeNone(max), isLikeNone(max) ? BigInt(0) : max);
2376
- this.__wbg_ptr = ret >>> 0;
2377
- TimelockRangeFinalization.register(this, this.__wbg_ptr, this);
2378
- return this;
2379
- }
2380
- }
2381
- if (Symbol.dispose) TimelockRange.prototype[Symbol.dispose] = TimelockRange.prototype.free;
2382
-
2383
949
  const TxBuilderFinalization = (typeof FinalizationRegistry === 'undefined')
2384
950
  ? { register: () => {}, unregister: () => {} }
2385
951
  : new FinalizationRegistry(ptr => wasm.__wbg_txbuilder_free(ptr >>> 0, 1));
@@ -2415,7 +981,6 @@ export class TxBuilder {
2415
981
  return v1;
2416
982
  }
2417
983
  /**
2418
- * Appends `preimage_jam` to all spend conditions that expect this preimage.
2419
984
  * @param {Uint8Array} preimage_jam
2420
985
  * @returns {Digest | undefined}
2421
986
  */
@@ -2426,47 +991,14 @@ export class TxBuilder {
2426
991
  if (ret[2]) {
2427
992
  throw takeFromExternrefTable0(ret[1]);
2428
993
  }
2429
- return ret[0] === 0 ? undefined : Digest.__wrap(ret[0]);
994
+ return takeFromExternrefTable0(ret[0]);
2430
995
  }
2431
996
  /**
2432
- * Perform a simple-spend on this builder.
2433
- *
2434
- * It is HIGHLY recommended to not mix `simpleSpend` with other types of spends.
2435
- *
2436
- * This performs a fairly complex set of operations, in order to mimic behavior of nockchain
2437
- * CLI wallet's create-tx option. Note that we do not do 1-1 mapping of that functionality,
2438
- * most notably - if `recipient` is the same as `refund_pkh`, we will create 1 seed, while the
2439
- * CLI wallet will create 2.
2440
- *
2441
- * Another difference is that you should call `sign` and `validate` after calling this method.
2442
- *
2443
- * Internally, the transaction builder takes ALL of the `notes` provided, and stores them for
2444
- * fee adjustments. If there are multiple notes being used, our fee setup also differs from
2445
- * the CLI, because we first greedily spend the notes out, and then take fees from any
2446
- * remaining refunds.
2447
- *
2448
- * This function prioritizes using the least number of notes possible, because that lowers the
2449
- * fee used.
2450
- *
2451
- * You may choose to override the fee with `fee_override`, but do note that `validate` will
2452
- * fail, in case this fee is too small.
2453
- *
2454
- * `include_lock_data` can be used to include `%lock` key in note-data, with the
2455
- * `SpendCondition` used. However, note-data costs 1 << 15 nicks, which means, it can get
2456
- * expensive.
2457
- *
2458
- * Optional parameter `remove_unused_notes`, if set to false, will keep the notes in the
2459
- * transaction builder. This is meant to be used whenever additional operations are performed
2460
- * on the builder, such as additional spends, or `addPreimage` calls. All of these increase
2461
- * the required fee (which can be checked with `calcFee`), and unused notes can then be used
2462
- * to adjust fees with `setFeeAndBalanceRefund` or `recalcAndSetFee`. Once all operations are
2463
- * done, one should call `removeUnusedNotes` to ensure these notes are not used within the
2464
- * transaction.
2465
997
  * @param {Note[]} notes
2466
998
  * @param {SpendCondition[]} spend_conditions
2467
999
  * @param {Digest} recipient
2468
- * @param {bigint} gift
2469
- * @param {bigint | null | undefined} fee_override
1000
+ * @param {Nicks} gift
1001
+ * @param {Nicks | null | undefined} fee_override
2470
1002
  * @param {Digest} refund_pkh
2471
1003
  * @param {boolean} include_lock_data
2472
1004
  */
@@ -2475,17 +1007,12 @@ export class TxBuilder {
2475
1007
  const len0 = WASM_VECTOR_LEN;
2476
1008
  const ptr1 = passArrayJsValueToWasm0(spend_conditions, wasm.__wbindgen_malloc);
2477
1009
  const len1 = WASM_VECTOR_LEN;
2478
- _assertClass(recipient, Digest);
2479
- var ptr2 = recipient.__destroy_into_raw();
2480
- _assertClass(refund_pkh, Digest);
2481
- var ptr3 = refund_pkh.__destroy_into_raw();
2482
- const ret = wasm.txbuilder_simpleSpend(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, gift, !isLikeNone(fee_override), isLikeNone(fee_override) ? BigInt(0) : fee_override, ptr3, include_lock_data);
1010
+ const ret = wasm.txbuilder_simpleSpend(this.__wbg_ptr, ptr0, len0, ptr1, len1, recipient, gift, isLikeNone(fee_override) ? 0 : addToExternrefTable0(fee_override), refund_pkh, include_lock_data);
2483
1011
  if (ret[1]) {
2484
1012
  throw takeFromExternrefTable0(ret[0]);
2485
1013
  }
2486
1014
  }
2487
1015
  /**
2488
- * Recalculate fee and set it, balancing things out with refunds
2489
1016
  * @param {boolean} include_lock_data
2490
1017
  */
2491
1018
  recalcAndSetFee(include_lock_data) {
@@ -2495,14 +1022,7 @@ export class TxBuilder {
2495
1022
  }
2496
1023
  }
2497
1024
  /**
2498
- * Distributes `fee` across builder's spends, and balances refunds out
2499
- *
2500
- * `adjust_fee` parameter allows the fee to be slightly tweaked, whenever notes are added or
2501
- * removed to/from the builder's fee note pool. This is because using more or less notes
2502
- * impacts the exact fee being required. If the caller estimates fee and sets it, adding more
2503
- * notes will change the exact fee needed, and setting this parameter to true will allow one
2504
- * to not have to call this function multiple times.
2505
- * @param {bigint} fee
1025
+ * @param {Nicks} fee
2506
1026
  * @param {boolean} adjust_fee
2507
1027
  * @param {boolean} include_lock_data
2508
1028
  */
@@ -2514,7 +1034,7 @@ export class TxBuilder {
2514
1034
  }
2515
1035
  /**
2516
1036
  * Create an empty transaction builder
2517
- * @param {bigint} fee_per_word
1037
+ * @param {Nicks} fee_per_word
2518
1038
  */
2519
1039
  constructor(fee_per_word) {
2520
1040
  const ret = wasm.txbuilder_new(fee_per_word);
@@ -2523,9 +1043,6 @@ export class TxBuilder {
2523
1043
  return this;
2524
1044
  }
2525
1045
  /**
2526
- * Sign the transaction with a private key.
2527
- *
2528
- * This will sign all spends that are still missing signature from
2529
1046
  * @param {Uint8Array} signing_key_bytes
2530
1047
  */
2531
1048
  sign(signing_key_bytes) {
@@ -2544,7 +1061,7 @@ export class TxBuilder {
2544
1061
  if (ret[2]) {
2545
1062
  throw takeFromExternrefTable0(ret[1]);
2546
1063
  }
2547
- return NockchainTx.__wrap(ret[0]);
1064
+ return takeFromExternrefTable0(ret[0]);
2548
1065
  }
2549
1066
  /**
2550
1067
  * Append a `SpendBuilder` to this transaction
@@ -2558,54 +1075,37 @@ export class TxBuilder {
2558
1075
  return ret === 0 ? undefined : SpendBuilder.__wrap(ret);
2559
1076
  }
2560
1077
  /**
2561
- * Gets the current fee set on all spends.
2562
- * @returns {bigint}
1078
+ * @returns {Nicks}
2563
1079
  */
2564
1080
  curFee() {
2565
1081
  const ret = wasm.txbuilder_curFee(this.__wbg_ptr);
2566
- return BigInt.asUintN(64, ret);
1082
+ return ret;
2567
1083
  }
2568
1084
  /**
2569
1085
  * Reconstruct a builder from raw transaction and its input notes.
2570
- *
2571
- * To get the builder back, you must pass the notes and their corresponding spend conditions.
2572
- * If serializing the builder, call `WasmTxBuilder::all_notes`.
2573
1086
  * @param {RawTx} tx
2574
1087
  * @param {Note[]} notes
2575
1088
  * @param {SpendCondition[]} spend_conditions
2576
1089
  * @returns {TxBuilder}
2577
1090
  */
2578
1091
  static fromTx(tx, notes, spend_conditions) {
2579
- _assertClass(tx, RawTx);
2580
- var ptr0 = tx.__destroy_into_raw();
2581
- const ptr1 = passArrayJsValueToWasm0(notes, wasm.__wbindgen_malloc);
1092
+ const ptr0 = passArrayJsValueToWasm0(notes, wasm.__wbindgen_malloc);
1093
+ const len0 = WASM_VECTOR_LEN;
1094
+ const ptr1 = passArrayJsValueToWasm0(spend_conditions, wasm.__wbindgen_malloc);
2582
1095
  const len1 = WASM_VECTOR_LEN;
2583
- const ptr2 = passArrayJsValueToWasm0(spend_conditions, wasm.__wbindgen_malloc);
2584
- const len2 = WASM_VECTOR_LEN;
2585
- const ret = wasm.txbuilder_fromTx(ptr0, ptr1, len1, ptr2, len2);
1096
+ const ret = wasm.txbuilder_fromTx(tx, ptr0, len0, ptr1, len1);
2586
1097
  if (ret[2]) {
2587
1098
  throw takeFromExternrefTable0(ret[1]);
2588
1099
  }
2589
1100
  return TxBuilder.__wrap(ret[0]);
2590
1101
  }
2591
1102
  /**
2592
- * Calculates the fee needed for the transaction.
2593
- *
2594
- * NOTE: if the transaction is unsigned, this function will estimate the fee needed, supposing
2595
- * all signatures are added. However, this heuristic is only accurate for one signature. In
2596
- * addition, this fee calculation does not estimate the size of missing preimages.
2597
- *
2598
- * So, first, add missing preimages, and only then calc the fee. If you're building a multisig
2599
- * transaction, this value might be incorrect.
2600
- * @returns {bigint}
1103
+ * @returns {Nicks}
2601
1104
  */
2602
1105
  calcFee() {
2603
1106
  const ret = wasm.txbuilder_calcFee(this.__wbg_ptr);
2604
- return BigInt.asUintN(64, ret);
1107
+ return ret;
2605
1108
  }
2606
- /**
2607
- * Validate the transaction.
2608
- */
2609
1109
  validate() {
2610
1110
  const ret = wasm.txbuilder_validate(this.__wbg_ptr);
2611
1111
  if (ret[1]) {
@@ -2617,155 +1117,13 @@ export class TxBuilder {
2617
1117
  */
2618
1118
  allNotes() {
2619
1119
  const ret = wasm.txbuilder_allNotes(this.__wbg_ptr);
2620
- return TxNotes.__wrap(ret);
2621
- }
2622
- }
2623
- if (Symbol.dispose) TxBuilder.prototype[Symbol.dispose] = TxBuilder.prototype.free;
2624
-
2625
- const TxNotesFinalization = (typeof FinalizationRegistry === 'undefined')
2626
- ? { register: () => {}, unregister: () => {} }
2627
- : new FinalizationRegistry(ptr => wasm.__wbg_txnotes_free(ptr >>> 0, 1));
2628
-
2629
- export class TxNotes {
2630
-
2631
- static __wrap(ptr) {
2632
- ptr = ptr >>> 0;
2633
- const obj = Object.create(TxNotes.prototype);
2634
- obj.__wbg_ptr = ptr;
2635
- TxNotesFinalization.register(obj, obj.__wbg_ptr, obj);
2636
- return obj;
2637
- }
2638
-
2639
- __destroy_into_raw() {
2640
- const ptr = this.__wbg_ptr;
2641
- this.__wbg_ptr = 0;
2642
- TxNotesFinalization.unregister(this);
2643
- return ptr;
2644
- }
2645
-
2646
- free() {
2647
- const ptr = this.__destroy_into_raw();
2648
- wasm.__wbg_txnotes_free(ptr, 0);
2649
- }
2650
- /**
2651
- * @returns {SpendCondition[]}
2652
- */
2653
- get spendConditions() {
2654
- const ret = wasm.txnotes_spendConditions(this.__wbg_ptr);
2655
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2656
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2657
- return v1;
2658
- }
2659
- /**
2660
- * @returns {Note[]}
2661
- */
2662
- get notes() {
2663
- const ret = wasm.txnotes_notes(this.__wbg_ptr);
2664
- var v1 = getArrayJsValueFromWasm0(ret[0], ret[1]).slice();
2665
- wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
2666
- return v1;
2667
- }
2668
- }
2669
- if (Symbol.dispose) TxNotes.prototype[Symbol.dispose] = TxNotes.prototype.free;
2670
-
2671
- const VersionFinalization = (typeof FinalizationRegistry === 'undefined')
2672
- ? { register: () => {}, unregister: () => {} }
2673
- : new FinalizationRegistry(ptr => wasm.__wbg_version_free(ptr >>> 0, 1));
2674
-
2675
- export class Version {
2676
-
2677
- static __wrap(ptr) {
2678
- ptr = ptr >>> 0;
2679
- const obj = Object.create(Version.prototype);
2680
- obj.__wbg_ptr = ptr;
2681
- VersionFinalization.register(obj, obj.__wbg_ptr, obj);
2682
- return obj;
2683
- }
2684
-
2685
- __destroy_into_raw() {
2686
- const ptr = this.__wbg_ptr;
2687
- this.__wbg_ptr = 0;
2688
- VersionFinalization.unregister(this);
2689
- return ptr;
2690
- }
2691
-
2692
- free() {
2693
- const ptr = this.__destroy_into_raw();
2694
- wasm.__wbg_version_free(ptr, 0);
2695
- }
2696
- /**
2697
- * @returns {Version}
2698
- */
2699
- static V0() {
2700
- const ret = wasm.version_V0();
2701
- return Version.__wrap(ret);
2702
- }
2703
- /**
2704
- * @returns {Version}
2705
- */
2706
- static V1() {
2707
- const ret = wasm.version_V1();
2708
- return Version.__wrap(ret);
2709
- }
2710
- /**
2711
- * @returns {Version}
2712
- */
2713
- static V2() {
2714
- const ret = wasm.version_V2();
2715
- return Version.__wrap(ret);
2716
- }
2717
- /**
2718
- * @param {number} version
2719
- */
2720
- constructor(version) {
2721
- const ret = wasm.version_new(version);
2722
- this.__wbg_ptr = ret >>> 0;
2723
- VersionFinalization.register(this, this.__wbg_ptr, this);
2724
- return this;
2725
- }
2726
- }
2727
- if (Symbol.dispose) Version.prototype[Symbol.dispose] = Version.prototype.free;
2728
-
2729
- const WasmSeedFinalization = (typeof FinalizationRegistry === 'undefined')
2730
- ? { register: () => {}, unregister: () => {} }
2731
- : new FinalizationRegistry(ptr => wasm.__wbg_wasmseed_free(ptr >>> 0, 1));
2732
-
2733
- export class WasmSeed {
2734
-
2735
- __destroy_into_raw() {
2736
- const ptr = this.__wbg_ptr;
2737
- this.__wbg_ptr = 0;
2738
- WasmSeedFinalization.unregister(this);
2739
- return ptr;
2740
- }
2741
-
2742
- free() {
2743
- const ptr = this.__destroy_into_raw();
2744
- wasm.__wbg_wasmseed_free(ptr, 0);
2745
- }
2746
- /**
2747
- * @returns {any}
2748
- */
2749
- toProtobuf() {
2750
- const ret = wasm.wasmseed_toProtobuf(this.__wbg_ptr);
2751
1120
  if (ret[2]) {
2752
1121
  throw takeFromExternrefTable0(ret[1]);
2753
1122
  }
2754
1123
  return takeFromExternrefTable0(ret[0]);
2755
1124
  }
2756
- /**
2757
- * @param {any} value
2758
- * @returns {Seed}
2759
- */
2760
- static fromProtobuf(value) {
2761
- const ret = wasm.wasmseed_fromProtobuf(value);
2762
- if (ret[2]) {
2763
- throw takeFromExternrefTable0(ret[1]);
2764
- }
2765
- return Seed.__wrap(ret[0]);
2766
- }
2767
1125
  }
2768
- if (Symbol.dispose) WasmSeed.prototype[Symbol.dispose] = WasmSeed.prototype.free;
1126
+ if (Symbol.dispose) TxBuilder.prototype[Symbol.dispose] = TxBuilder.prototype.free;
2769
1127
 
2770
1128
  const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
2771
1129
 
@@ -2936,14 +1294,6 @@ function __wbg_get_imports() {
2936
1294
  imports.wbg.__wbg_close_6956df845478561a = function() { return handleError(function (arg0) {
2937
1295
  arg0.close();
2938
1296
  }, arguments) };
2939
- imports.wbg.__wbg_digest_new = function(arg0) {
2940
- const ret = Digest.__wrap(arg0);
2941
- return ret;
2942
- };
2943
- imports.wbg.__wbg_digest_unwrap = function(arg0) {
2944
- const ret = Digest.__unwrap(arg0);
2945
- return ret;
2946
- };
2947
1297
  imports.wbg.__wbg_done_2042aa2670fb1db1 = function(arg0) {
2948
1298
  const ret = arg0.done;
2949
1299
  return ret;
@@ -3045,10 +1395,6 @@ function __wbg_get_imports() {
3045
1395
  const ret = arg0.length;
3046
1396
  return ret;
3047
1397
  };
3048
- imports.wbg.__wbg_lockprimitive_unwrap = function(arg0) {
3049
- const ret = LockPrimitive.__unwrap(arg0);
3050
- return ret;
3051
- };
3052
1398
  imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
3053
1399
  const ret = new Object();
3054
1400
  return ret;
@@ -3111,22 +1457,6 @@ function __wbg_get_imports() {
3111
1457
  const ret = arg0.next;
3112
1458
  return ret;
3113
1459
  };
3114
- imports.wbg.__wbg_note_new = function(arg0) {
3115
- const ret = Note.__wrap(arg0);
3116
- return ret;
3117
- };
3118
- imports.wbg.__wbg_note_unwrap = function(arg0) {
3119
- const ret = Note.__unwrap(arg0);
3120
- return ret;
3121
- };
3122
- imports.wbg.__wbg_notedataentry_new = function(arg0) {
3123
- const ret = NoteDataEntry.__wrap(arg0);
3124
- return ret;
3125
- };
3126
- imports.wbg.__wbg_notedataentry_unwrap = function(arg0) {
3127
- const ret = NoteDataEntry.__unwrap(arg0);
3128
- return ret;
3129
- };
3130
1460
  imports.wbg.__wbg_prototypesetcall_2a6620b6922694b2 = function(arg0, arg1, arg2) {
3131
1461
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
3132
1462
  };
@@ -3194,14 +1524,6 @@ function __wbg_get_imports() {
3194
1524
  const ret = SpendBuilder.__wrap(arg0);
3195
1525
  return ret;
3196
1526
  };
3197
- imports.wbg.__wbg_spendcondition_new = function(arg0) {
3198
- const ret = SpendCondition.__wrap(arg0);
3199
- return ret;
3200
- };
3201
- imports.wbg.__wbg_spendcondition_unwrap = function(arg0) {
3202
- const ret = SpendCondition.__unwrap(arg0);
3203
- return ret;
3204
- };
3205
1527
  imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
3206
1528
  const ret = typeof global === 'undefined' ? null : global;
3207
1529
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -3242,6 +1564,11 @@ function __wbg_get_imports() {
3242
1564
  const ret = arg0.view;
3243
1565
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
3244
1566
  };
1567
+ imports.wbg.__wbindgen_cast_08298b8ed11def05 = function(arg0, arg1) {
1568
+ // Cast intrinsic for `Closure(Closure { dtor_idx: 335, function: Function { arguments: [Externref], shim_idx: 336, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1569
+ const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
1570
+ return ret;
1571
+ };
3245
1572
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
3246
1573
  // Cast intrinsic for `Ref(String) -> Externref`.
3247
1574
  const ret = getStringFromWasm0(arg0, arg1);
@@ -3252,11 +1579,6 @@ function __wbg_get_imports() {
3252
1579
  const ret = BigInt.asUintN(64, arg0);
3253
1580
  return ret;
3254
1581
  };
3255
- imports.wbg.__wbindgen_cast_726db96c89a75f21 = function(arg0, arg1) {
3256
- // Cast intrinsic for `Closure(Closure { dtor_idx: 277, function: Function { arguments: [Externref], shim_idx: 278, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
3257
- const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h20e54f17b0de8c43, wasm_bindgen__convert__closures_____invoke__hbf186e27576c509b);
3258
- return ret;
3259
- };
3260
1582
  imports.wbg.__wbindgen_cast_9ae0607507abb057 = function(arg0) {
3261
1583
  // Cast intrinsic for `I64 -> Externref`.
3262
1584
  const ret = arg0;