koilib 5.6.1 → 5.7.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.
Files changed (64) hide show
  1. package/LICENSE +21 -21
  2. package/dist/koinos.js +1493 -637
  3. package/dist/koinos.min.js +1 -1
  4. package/lib/Contract.d.ts +4 -4
  5. package/lib/Contract.js +4 -4
  6. package/lib/Contract.js.map +1 -1
  7. package/lib/Provider.d.ts +42 -12
  8. package/lib/Provider.js +99 -6
  9. package/lib/Provider.js.map +1 -1
  10. package/lib/Serializer.d.ts +20 -0
  11. package/lib/Serializer.js +4 -0
  12. package/lib/Serializer.js.map +1 -1
  13. package/lib/Signer.d.ts +0 -10
  14. package/lib/Signer.js +1 -123
  15. package/lib/Signer.js.map +1 -1
  16. package/lib/Transaction.d.ts +3 -3
  17. package/lib/Transaction.js +4 -4
  18. package/lib/Transaction.js.map +1 -1
  19. package/lib/browser/Contract.d.ts +4 -4
  20. package/lib/browser/Contract.js +4 -4
  21. package/lib/browser/Contract.js.map +1 -1
  22. package/lib/browser/Provider.d.ts +42 -12
  23. package/lib/browser/Provider.js +99 -6
  24. package/lib/browser/Provider.js.map +1 -1
  25. package/lib/browser/Serializer.d.ts +20 -0
  26. package/lib/browser/Serializer.js +4 -0
  27. package/lib/browser/Serializer.js.map +1 -1
  28. package/lib/browser/Signer.d.ts +0 -10
  29. package/lib/browser/Signer.js +1 -123
  30. package/lib/browser/Signer.js.map +1 -1
  31. package/lib/browser/Transaction.d.ts +3 -3
  32. package/lib/browser/Transaction.js +4 -4
  33. package/lib/browser/Transaction.js.map +1 -1
  34. package/lib/browser/index.d.ts +1 -1
  35. package/lib/browser/index.js +2 -2
  36. package/lib/browser/index.js.map +1 -1
  37. package/lib/browser/interface.d.ts +17 -2
  38. package/lib/browser/jsonDescriptors/chain-proto.json +74 -3
  39. package/lib/browser/jsonDescriptors/token-proto.json +5 -26
  40. package/lib/browser/protoModules/protocol-proto.js +823 -0
  41. package/lib/browser/protoModules/protocol-proto.js.map +1 -1
  42. package/lib/browser/utilsNode.d.ts +72 -117
  43. package/lib/index.d.ts +1 -1
  44. package/lib/index.js +2 -2
  45. package/lib/index.js.map +1 -1
  46. package/lib/interface.d.ts +17 -2
  47. package/lib/jsonDescriptors/chain-proto.json +74 -3
  48. package/lib/jsonDescriptors/token-proto.json +5 -26
  49. package/lib/protoModules/protocol-proto.js +823 -0
  50. package/lib/protoModules/protocol-proto.js.map +1 -1
  51. package/lib/utilsNode.d.ts +72 -117
  52. package/package.json +1 -1
  53. package/src/Contract.ts +6 -5
  54. package/src/Provider.ts +150 -20
  55. package/src/Serializer.ts +27 -0
  56. package/src/Signer.ts +1 -150
  57. package/src/Transaction.ts +8 -8
  58. package/src/index.ts +1 -1
  59. package/src/interface.ts +19 -2
  60. package/src/jsonDescriptors/chain-proto.json +74 -3
  61. package/src/jsonDescriptors/pow-proto.json +1 -1
  62. package/src/jsonDescriptors/token-proto.json +5 -26
  63. package/src/jsonDescriptors/value-proto.json +13 -23
  64. package/src/protoModules/protocol-proto.js +1043 -4
package/dist/koinos.js CHANGED
@@ -153,9 +153,9 @@ function bool(b) {
153
153
  exports.bool = bool;
154
154
  function bytes(b, ...lengths) {
155
155
  if (!(b instanceof Uint8Array))
156
- throw new Error('Expected Uint8Array');
156
+ throw new TypeError('Expected Uint8Array');
157
157
  if (lengths.length > 0 && !lengths.includes(b.length))
158
- throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
158
+ throw new TypeError(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
159
159
  }
160
160
  exports.bytes = bytes;
161
161
  function hash(hash) {
@@ -189,7 +189,7 @@ const assert = {
189
189
  output,
190
190
  };
191
191
  exports["default"] = assert;
192
- //# sourceMappingURL=_assert.js.map
192
+
193
193
 
194
194
  /***/ }),
195
195
 
@@ -282,16 +282,7 @@ class SHA2 extends utils_js_1.Hash {
282
282
  setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
283
283
  this.process(view, 0);
284
284
  const oview = (0, utils_js_1.createView)(out);
285
- const len = this.outputLen;
286
- // NOTE: we do division by 4 later, which should be fused in single op with modulo by JIT
287
- if (len % 4)
288
- throw new Error('_sha2: outputLen should be aligned to 32bit');
289
- const outLen = len / 4;
290
- const state = this.get();
291
- if (outLen > state.length)
292
- throw new Error('_sha2: outputLen bigger than state');
293
- for (let i = 0; i < outLen; i++)
294
- oview.setUint32(4 * i, state[i], isLE);
285
+ this.get().forEach((v, i) => oview.setUint32(4 * i, v, isLE));
295
286
  }
296
287
  digest() {
297
288
  const { buffer, outputLen } = this;
@@ -314,19 +305,22 @@ class SHA2 extends utils_js_1.Hash {
314
305
  }
315
306
  }
316
307
  exports.SHA2 = SHA2;
317
- //# sourceMappingURL=_sha2.js.map
308
+
318
309
 
319
310
  /***/ }),
320
311
 
321
- /***/ 1945:
312
+ /***/ 4421:
322
313
  /***/ ((__unused_webpack_module, exports) => {
323
314
 
324
315
  "use strict";
325
316
 
326
317
  Object.defineProperty(exports, "__esModule", ({ value: true }));
327
318
  exports.crypto = void 0;
328
- exports.crypto = typeof globalThis === 'object' && 'crypto' in globalThis ? globalThis.crypto : undefined;
329
- //# sourceMappingURL=crypto.js.map
319
+ exports.crypto = {
320
+ node: undefined,
321
+ web: typeof self === 'object' && 'crypto' in self ? self.crypto : undefined,
322
+ };
323
+
330
324
 
331
325
  /***/ }),
332
326
 
@@ -437,7 +431,7 @@ exports.RIPEMD160 = RIPEMD160;
437
431
  * @param message - msg that would be hashed
438
432
  */
439
433
  exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
440
- //# sourceMappingURL=ripemd160.js.map
434
+
441
435
 
442
436
  /***/ }),
443
437
 
@@ -447,7 +441,7 @@ exports.ripemd160 = (0, utils_js_1.wrapConstructor)(() => new RIPEMD160());
447
441
  "use strict";
448
442
 
449
443
  Object.defineProperty(exports, "__esModule", ({ value: true }));
450
- exports.sha224 = exports.sha256 = void 0;
444
+ exports.sha256 = void 0;
451
445
  const _sha2_js_1 = __webpack_require__(7505);
452
446
  const utils_js_1 = __webpack_require__(8089);
453
447
  // Choice: a ? b : c
@@ -550,28 +544,12 @@ class SHA256 extends _sha2_js_1.SHA2 {
550
544
  this.buffer.fill(0);
551
545
  }
552
546
  }
553
- // Constants from https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf
554
- class SHA224 extends SHA256 {
555
- constructor() {
556
- super();
557
- this.A = 0xc1059ed8 | 0;
558
- this.B = 0x367cd507 | 0;
559
- this.C = 0x3070dd17 | 0;
560
- this.D = 0xf70e5939 | 0;
561
- this.E = 0xffc00b31 | 0;
562
- this.F = 0x68581511 | 0;
563
- this.G = 0x64f98fa7 | 0;
564
- this.H = 0xbefa4fa4 | 0;
565
- this.outputLen = 28;
566
- }
567
- }
568
547
  /**
569
548
  * SHA2-256 hash function
570
549
  * @param message - data that would be hashed
571
550
  */
572
551
  exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256());
573
- exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());
574
- //# sourceMappingURL=sha256.js.map
552
+
575
553
 
576
554
  /***/ }),
577
555
 
@@ -582,15 +560,10 @@ exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224());
582
560
 
583
561
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
584
562
  Object.defineProperty(exports, "__esModule", ({ value: true }));
585
- exports.randomBytes = exports.wrapXOFConstructorWithOpts = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
586
- // We use WebCrypto aka globalThis.crypto, which exists in browsers and node.js 16+.
587
- // node.js versions earlier than v19 don't declare it in global scope.
588
- // For node.js, package.json#exports field mapping rewrites import
589
- // from `crypto` to `cryptoNode`, which imports native module.
590
- // Makes the utils un-importable in browsers without a bundler.
591
- // Once node.js 18 is deprecated, we can just drop the import.
592
- const crypto_1 = __webpack_require__(1945);
593
- const u8a = (a) => a instanceof Uint8Array;
563
+ exports.randomBytes = exports.wrapConstructorWithOpts = exports.wrapConstructor = exports.checkOpts = exports.Hash = exports.concatBytes = exports.toBytes = exports.utf8ToBytes = exports.asyncLoop = exports.nextTick = exports.hexToBytes = exports.bytesToHex = exports.isLE = exports.rotr = exports.createView = exports.u32 = exports.u8 = void 0;
564
+ // The import here is via the package name. This is to ensure
565
+ // that exports mapping/resolution does fall into place.
566
+ const crypto_1 = __webpack_require__(4421);
594
567
  // Cast array to different type
595
568
  const u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
596
569
  exports.u8 = u8;
@@ -602,36 +575,36 @@ exports.createView = createView;
602
575
  // The rotate right (circular right shift) operation for uint32
603
576
  const rotr = (word, shift) => (word << (32 - shift)) | (word >>> shift);
604
577
  exports.rotr = rotr;
605
- // big-endian hardware is rare. Just in case someone still decides to run hashes:
606
- // early-throw an error because we don't support BE yet.
607
578
  exports.isLE = new Uint8Array(new Uint32Array([0x11223344]).buffer)[0] === 0x44;
579
+ // There is almost no big endian hardware, but js typed arrays uses platform specific endianness.
580
+ // So, just to be sure not to corrupt anything.
608
581
  if (!exports.isLE)
609
582
  throw new Error('Non little-endian hardware is not supported');
610
583
  const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
611
584
  /**
612
- * @example bytesToHex(Uint8Array.from([0xca, 0xfe, 0x01, 0x23])) // 'cafe0123'
585
+ * @example bytesToHex(Uint8Array.from([0xde, 0xad, 0xbe, 0xef]))
613
586
  */
614
- function bytesToHex(bytes) {
615
- if (!u8a(bytes))
616
- throw new Error('Uint8Array expected');
587
+ function bytesToHex(uint8a) {
617
588
  // pre-caching improves the speed 6x
589
+ if (!(uint8a instanceof Uint8Array))
590
+ throw new Error('Uint8Array expected');
618
591
  let hex = '';
619
- for (let i = 0; i < bytes.length; i++) {
620
- hex += hexes[bytes[i]];
592
+ for (let i = 0; i < uint8a.length; i++) {
593
+ hex += hexes[uint8a[i]];
621
594
  }
622
595
  return hex;
623
596
  }
624
597
  exports.bytesToHex = bytesToHex;
625
598
  /**
626
- * @example hexToBytes('cafe0123') // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])
599
+ * @example hexToBytes('deadbeef')
627
600
  */
628
601
  function hexToBytes(hex) {
629
- if (typeof hex !== 'string')
630
- throw new Error('hex string expected, got ' + typeof hex);
631
- const len = hex.length;
632
- if (len % 2)
633
- throw new Error('padded hex string expected, got unpadded hex of length ' + len);
634
- const array = new Uint8Array(len / 2);
602
+ if (typeof hex !== 'string') {
603
+ throw new TypeError('hexToBytes: expected string, got ' + typeof hex);
604
+ }
605
+ if (hex.length % 2)
606
+ throw new Error('hexToBytes: received invalid unpadded hex');
607
+ const array = new Uint8Array(hex.length / 2);
635
608
  for (let i = 0; i < array.length; i++) {
636
609
  const j = i * 2;
637
610
  const hexByte = hex.slice(j, j + 2);
@@ -643,9 +616,8 @@ function hexToBytes(hex) {
643
616
  return array;
644
617
  }
645
618
  exports.hexToBytes = hexToBytes;
646
- // There is no setImmediate in browser and setTimeout is slow.
647
- // call of async fn will return Promise, which will be fullfiled only on
648
- // next scheduler queue processing step and this is exactly what we need.
619
+ // There is no setImmediate in browser and setTimeout is slow. However, call to async function will return Promise
620
+ // which will be fullfiled only on next scheduler queue processing step and this is exactly what we need.
649
621
  const nextTick = async () => { };
650
622
  exports.nextTick = nextTick;
651
623
  // Returns control to thread each 'tick' ms to avoid blocking
@@ -662,41 +634,38 @@ async function asyncLoop(iters, tick, cb) {
662
634
  }
663
635
  }
664
636
  exports.asyncLoop = asyncLoop;
665
- /**
666
- * @example utf8ToBytes('abc') // new Uint8Array([97, 98, 99])
667
- */
668
637
  function utf8ToBytes(str) {
669
- if (typeof str !== 'string')
670
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
671
- return new Uint8Array(new TextEncoder().encode(str)); // https://bugzil.la/1681809
638
+ if (typeof str !== 'string') {
639
+ throw new TypeError(`utf8ToBytes expected string, got ${typeof str}`);
640
+ }
641
+ return new TextEncoder().encode(str);
672
642
  }
673
643
  exports.utf8ToBytes = utf8ToBytes;
674
- /**
675
- * Normalizes (non-hex) string or Uint8Array to Uint8Array.
676
- * Warning: when Uint8Array is passed, it would NOT get copied.
677
- * Keep in mind for future mutable operations.
678
- */
679
644
  function toBytes(data) {
680
645
  if (typeof data === 'string')
681
646
  data = utf8ToBytes(data);
682
- if (!u8a(data))
683
- throw new Error(`expected Uint8Array, got ${typeof data}`);
647
+ if (!(data instanceof Uint8Array))
648
+ throw new TypeError(`Expected input type is Uint8Array (got ${typeof data})`);
684
649
  return data;
685
650
  }
686
651
  exports.toBytes = toBytes;
687
652
  /**
688
- * Copies several Uint8Arrays into one.
653
+ * Concats Uint8Array-s into one; like `Buffer.concat([buf1, buf2])`
654
+ * @example concatBytes(buf1, buf2)
689
655
  */
690
656
  function concatBytes(...arrays) {
691
- const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
692
- let pad = 0; // walk through each item, ensure they have proper type
693
- arrays.forEach((a) => {
694
- if (!u8a(a))
695
- throw new Error('Uint8Array expected');
696
- r.set(a, pad);
697
- pad += a.length;
698
- });
699
- return r;
657
+ if (!arrays.every((a) => a instanceof Uint8Array))
658
+ throw new Error('Uint8Array list expected');
659
+ if (arrays.length === 1)
660
+ return arrays[0];
661
+ const length = arrays.reduce((a, arr) => a + arr.length, 0);
662
+ const result = new Uint8Array(length);
663
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
664
+ const arr = arrays[i];
665
+ result.set(arr, pad);
666
+ pad += arr.length;
667
+ }
668
+ return result;
700
669
  }
701
670
  exports.concatBytes = concatBytes;
702
671
  // For runtime check if class implements interface
@@ -711,17 +680,17 @@ exports.Hash = Hash;
711
680
  const isPlainObject = (obj) => Object.prototype.toString.call(obj) === '[object Object]' && obj.constructor === Object;
712
681
  function checkOpts(defaults, opts) {
713
682
  if (opts !== undefined && (typeof opts !== 'object' || !isPlainObject(opts)))
714
- throw new Error('Options should be object or undefined');
683
+ throw new TypeError('Options should be object or undefined');
715
684
  const merged = Object.assign(defaults, opts);
716
685
  return merged;
717
686
  }
718
687
  exports.checkOpts = checkOpts;
719
- function wrapConstructor(hashCons) {
720
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
721
- const tmp = hashCons();
688
+ function wrapConstructor(hashConstructor) {
689
+ const hashC = (message) => hashConstructor().update(toBytes(message)).digest();
690
+ const tmp = hashConstructor();
722
691
  hashC.outputLen = tmp.outputLen;
723
692
  hashC.blockLen = tmp.blockLen;
724
- hashC.create = () => hashCons();
693
+ hashC.create = () => hashConstructor();
725
694
  return hashC;
726
695
  }
727
696
  exports.wrapConstructor = wrapConstructor;
@@ -734,26 +703,22 @@ function wrapConstructorWithOpts(hashCons) {
734
703
  return hashC;
735
704
  }
736
705
  exports.wrapConstructorWithOpts = wrapConstructorWithOpts;
737
- function wrapXOFConstructorWithOpts(hashCons) {
738
- const hashC = (msg, opts) => hashCons(opts).update(toBytes(msg)).digest();
739
- const tmp = hashCons({});
740
- hashC.outputLen = tmp.outputLen;
741
- hashC.blockLen = tmp.blockLen;
742
- hashC.create = (opts) => hashCons(opts);
743
- return hashC;
744
- }
745
- exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
746
706
  /**
747
- * Secure PRNG. Uses `crypto.getRandomValues`, which defers to OS.
707
+ * Secure PRNG
748
708
  */
749
709
  function randomBytes(bytesLength = 32) {
750
- if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === 'function') {
751
- return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
710
+ if (crypto_1.crypto.web) {
711
+ return crypto_1.crypto.web.getRandomValues(new Uint8Array(bytesLength));
712
+ }
713
+ else if (crypto_1.crypto.node) {
714
+ return new Uint8Array(crypto_1.crypto.node.randomBytes(bytesLength).buffer);
715
+ }
716
+ else {
717
+ throw new Error("The environment doesn't have randomBytes function");
752
718
  }
753
- throw new Error('crypto.getRandomValues must be defined');
754
719
  }
755
720
  exports.randomBytes = randomBytes;
756
- //# sourceMappingURL=utils.js.map
721
+
757
722
 
758
723
  /***/ }),
759
724
 
@@ -771,64 +736,25 @@ const _1n = BigInt(1);
771
736
  const _2n = BigInt(2);
772
737
  const _3n = BigInt(3);
773
738
  const _8n = BigInt(8);
774
- const CURVE = Object.freeze({
739
+ const POW_2_256 = _2n ** BigInt(256);
740
+ const CURVE = {
775
741
  a: _0n,
776
742
  b: BigInt(7),
777
- P: BigInt('0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f'),
778
- n: BigInt('0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141'),
743
+ P: POW_2_256 - _2n ** BigInt(32) - BigInt(977),
744
+ n: POW_2_256 - BigInt('432420386565659656852420866394968145599'),
779
745
  h: _1n,
780
746
  Gx: BigInt('55066263022277343669578718895168534326250603453777594175500187360389116729240'),
781
747
  Gy: BigInt('32670510020758816978083085130507043184471273380659243275938904335757337482424'),
782
748
  beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
783
- });
784
- exports.CURVE = CURVE;
785
- const divNearest = (a, b) => (a + b / _2n) / b;
786
- const endo = {
787
- beta: BigInt('0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee'),
788
- splitScalar(k) {
789
- const { n } = CURVE;
790
- const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');
791
- const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
792
- const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
793
- const b2 = a1;
794
- const POW_2_128 = BigInt('0x100000000000000000000000000000000');
795
- const c1 = divNearest(b2 * k, n);
796
- const c2 = divNearest(-b1 * k, n);
797
- let k1 = mod(k - c1 * a1 - c2 * a2, n);
798
- let k2 = mod(-c1 * b1 - c2 * b2, n);
799
- const k1neg = k1 > POW_2_128;
800
- const k2neg = k2 > POW_2_128;
801
- if (k1neg)
802
- k1 = n - k1;
803
- if (k2neg)
804
- k2 = n - k2;
805
- if (k1 > POW_2_128 || k2 > POW_2_128) {
806
- throw new Error('splitScalarEndo: Endomorphism failed, k=' + k);
807
- }
808
- return { k1neg, k1, k2neg, k2 };
809
- },
810
749
  };
811
- const fieldLen = 32;
812
- const groupLen = 32;
813
- const hashLen = 32;
814
- const compressedLen = fieldLen + 1;
815
- const uncompressedLen = 2 * fieldLen + 1;
816
- function weierstrass(x) {
750
+ exports.CURVE = CURVE;
751
+ function weistrass(x) {
817
752
  const { a, b } = CURVE;
818
753
  const x2 = mod(x * x);
819
754
  const x3 = mod(x2 * x);
820
755
  return mod(x3 + a * x + b);
821
756
  }
822
757
  const USE_ENDOMORPHISM = CURVE.a === _0n;
823
- class ShaError extends Error {
824
- constructor(message) {
825
- super(message);
826
- }
827
- }
828
- function assertJacPoint(other) {
829
- if (!(other instanceof JacobianPoint))
830
- throw new TypeError('JacobianPoint expected');
831
- }
832
758
  class JacobianPoint {
833
759
  constructor(x, y, z) {
834
760
  this.x = x;
@@ -839,8 +765,6 @@ class JacobianPoint {
839
765
  if (!(p instanceof Point)) {
840
766
  throw new TypeError('JacobianPoint#fromAffine: expected Point');
841
767
  }
842
- if (p.equals(Point.ZERO))
843
- return JacobianPoint.ZERO;
844
768
  return new JacobianPoint(p.x, p.y, _1n);
845
769
  }
846
770
  static toAffineBatch(points) {
@@ -851,11 +775,12 @@ class JacobianPoint {
851
775
  return JacobianPoint.toAffineBatch(points).map(JacobianPoint.fromAffine);
852
776
  }
853
777
  equals(other) {
854
- assertJacPoint(other);
778
+ if (!(other instanceof JacobianPoint))
779
+ throw new TypeError('JacobianPoint expected');
855
780
  const { x: X1, y: Y1, z: Z1 } = this;
856
781
  const { x: X2, y: Y2, z: Z2 } = other;
857
- const Z1Z1 = mod(Z1 * Z1);
858
- const Z2Z2 = mod(Z2 * Z2);
782
+ const Z1Z1 = mod(Z1 ** _2n);
783
+ const Z2Z2 = mod(Z2 ** _2n);
859
784
  const U1 = mod(X1 * Z2Z2);
860
785
  const U2 = mod(X2 * Z1Z1);
861
786
  const S1 = mod(mod(Y1 * Z2) * Z2Z2);
@@ -867,28 +792,28 @@ class JacobianPoint {
867
792
  }
868
793
  double() {
869
794
  const { x: X1, y: Y1, z: Z1 } = this;
870
- const A = mod(X1 * X1);
871
- const B = mod(Y1 * Y1);
872
- const C = mod(B * B);
873
- const x1b = X1 + B;
874
- const D = mod(_2n * (mod(x1b * x1b) - A - C));
795
+ const A = mod(X1 ** _2n);
796
+ const B = mod(Y1 ** _2n);
797
+ const C = mod(B ** _2n);
798
+ const D = mod(_2n * (mod((X1 + B) ** _2n) - A - C));
875
799
  const E = mod(_3n * A);
876
- const F = mod(E * E);
800
+ const F = mod(E ** _2n);
877
801
  const X3 = mod(F - _2n * D);
878
802
  const Y3 = mod(E * (D - X3) - _8n * C);
879
803
  const Z3 = mod(_2n * Y1 * Z1);
880
804
  return new JacobianPoint(X3, Y3, Z3);
881
805
  }
882
806
  add(other) {
883
- assertJacPoint(other);
807
+ if (!(other instanceof JacobianPoint))
808
+ throw new TypeError('JacobianPoint expected');
884
809
  const { x: X1, y: Y1, z: Z1 } = this;
885
810
  const { x: X2, y: Y2, z: Z2 } = other;
886
811
  if (X2 === _0n || Y2 === _0n)
887
812
  return this;
888
813
  if (X1 === _0n || Y1 === _0n)
889
814
  return other;
890
- const Z1Z1 = mod(Z1 * Z1);
891
- const Z2Z2 = mod(Z2 * Z2);
815
+ const Z1Z1 = mod(Z1 ** _2n);
816
+ const Z2Z2 = mod(Z2 ** _2n);
892
817
  const U1 = mod(X1 * Z2Z2);
893
818
  const U2 = mod(X2 * Z1Z1);
894
819
  const S1 = mod(mod(Y1 * Z2) * Z2Z2);
@@ -903,10 +828,10 @@ class JacobianPoint {
903
828
  return JacobianPoint.ZERO;
904
829
  }
905
830
  }
906
- const HH = mod(H * H);
831
+ const HH = mod(H ** _2n);
907
832
  const HHH = mod(H * HH);
908
833
  const V = mod(U1 * HH);
909
- const X3 = mod(r * r - HHH - _2n * V);
834
+ const X3 = mod(r ** _2n - HHH - _2n * V);
910
835
  const Y3 = mod(r * (V - X3) - S1 * HHH);
911
836
  const Z3 = mod(Z1 * Z2 * H);
912
837
  return new JacobianPoint(X3, Y3, Z3);
@@ -932,7 +857,7 @@ class JacobianPoint {
932
857
  }
933
858
  return p;
934
859
  }
935
- let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
860
+ let { k1neg, k1, k2neg, k2 } = splitScalarEndo(n);
936
861
  let k1p = P0;
937
862
  let k2p = P0;
938
863
  let d = this;
@@ -949,7 +874,7 @@ class JacobianPoint {
949
874
  k1p = k1p.negate();
950
875
  if (k2neg)
951
876
  k2p = k2p.negate();
952
- k2p = new JacobianPoint(mod(k2p.x * endo.beta), k2p.y, k2p.z);
877
+ k2p = new JacobianPoint(mod(k2p.x * CURVE.beta), k2p.y, k2p.z);
953
878
  return k1p.add(k2p);
954
879
  }
955
880
  precomputeWindow(W) {
@@ -984,7 +909,7 @@ class JacobianPoint {
984
909
  }
985
910
  }
986
911
  let p = JacobianPoint.ZERO;
987
- let f = JacobianPoint.BASE;
912
+ let f = JacobianPoint.ZERO;
988
913
  const windows = 1 + (USE_ENDOMORPHISM ? 128 / W : 256 / W);
989
914
  const windowSize = 2 ** (W - 1);
990
915
  const mask = BigInt(2 ** W - 1);
@@ -998,15 +923,17 @@ class JacobianPoint {
998
923
  wbits -= maxNumber;
999
924
  n += _1n;
1000
925
  }
1001
- const offset1 = offset;
1002
- const offset2 = offset + Math.abs(wbits) - 1;
1003
- const cond1 = window % 2 !== 0;
1004
- const cond2 = wbits < 0;
1005
926
  if (wbits === 0) {
1006
- f = f.add(constTimeNegate(cond1, precomputes[offset1]));
927
+ let pr = precomputes[offset];
928
+ if (window % 2)
929
+ pr = pr.negate();
930
+ f = f.add(pr);
1007
931
  }
1008
932
  else {
1009
- p = p.add(constTimeNegate(cond2, precomputes[offset2]));
933
+ let cached = precomputes[offset + Math.abs(wbits) - 1];
934
+ if (wbits < 0)
935
+ cached = cached.negate();
936
+ p = p.add(cached);
1010
937
  }
1011
938
  }
1012
939
  return { p, f };
@@ -1016,12 +943,14 @@ class JacobianPoint {
1016
943
  let point;
1017
944
  let fake;
1018
945
  if (USE_ENDOMORPHISM) {
1019
- const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
946
+ const { k1neg, k1, k2neg, k2 } = splitScalarEndo(n);
1020
947
  let { p: k1p, f: f1p } = this.wNAF(k1, affinePoint);
1021
948
  let { p: k2p, f: f2p } = this.wNAF(k2, affinePoint);
1022
- k1p = constTimeNegate(k1neg, k1p);
1023
- k2p = constTimeNegate(k2neg, k2p);
1024
- k2p = new JacobianPoint(mod(k2p.x * endo.beta), k2p.y, k2p.z);
949
+ if (k1neg)
950
+ k1p = k1p.negate();
951
+ if (k2neg)
952
+ k2p = k2p.negate();
953
+ k2p = new JacobianPoint(mod(k2p.x * CURVE.beta), k2p.y, k2p.z);
1025
954
  point = k1p.add(k2p);
1026
955
  fake = f1p.add(f2p);
1027
956
  }
@@ -1032,19 +961,14 @@ class JacobianPoint {
1032
961
  }
1033
962
  return JacobianPoint.normalizeZ([point, fake])[0];
1034
963
  }
1035
- toAffine(invZ) {
964
+ toAffine(invZ = invert(this.z)) {
1036
965
  const { x, y, z } = this;
1037
- const is0 = this.equals(JacobianPoint.ZERO);
1038
- if (invZ == null)
1039
- invZ = is0 ? _8n : invert(z);
1040
966
  const iz1 = invZ;
1041
967
  const iz2 = mod(iz1 * iz1);
1042
968
  const iz3 = mod(iz2 * iz1);
1043
969
  const ax = mod(x * iz2);
1044
970
  const ay = mod(y * iz3);
1045
971
  const zz = mod(z * iz1);
1046
- if (is0)
1047
- return Point.ZERO;
1048
972
  if (zz !== _1n)
1049
973
  throw new Error('invZ was invalid');
1050
974
  return new Point(ax, ay);
@@ -1052,10 +976,6 @@ class JacobianPoint {
1052
976
  }
1053
977
  JacobianPoint.BASE = new JacobianPoint(CURVE.Gx, CURVE.Gy, _1n);
1054
978
  JacobianPoint.ZERO = new JacobianPoint(_0n, _1n, _0n);
1055
- function constTimeNegate(condition, item) {
1056
- const neg = item.negate();
1057
- return condition ? neg : item;
1058
- }
1059
979
  const pointPrecomputes = new WeakMap();
1060
980
  class Point {
1061
981
  constructor(x, y) {
@@ -1066,15 +986,12 @@ class Point {
1066
986
  this._WINDOW_SIZE = windowSize;
1067
987
  pointPrecomputes.delete(this);
1068
988
  }
1069
- hasEvenY() {
1070
- return this.y % _2n === _0n;
1071
- }
1072
989
  static fromCompressedHex(bytes) {
1073
990
  const isShort = bytes.length === 32;
1074
991
  const x = bytesToNumber(isShort ? bytes : bytes.subarray(1));
1075
992
  if (!isValidFieldElement(x))
1076
993
  throw new Error('Point is not on curve');
1077
- const y2 = weierstrass(x);
994
+ const y2 = weistrass(x);
1078
995
  let y = sqrtMod(y2);
1079
996
  const isYOdd = (y & _1n) === _1n;
1080
997
  if (isShort) {
@@ -1091,8 +1008,8 @@ class Point {
1091
1008
  return point;
1092
1009
  }
1093
1010
  static fromUncompressedHex(bytes) {
1094
- const x = bytesToNumber(bytes.subarray(1, fieldLen + 1));
1095
- const y = bytesToNumber(bytes.subarray(fieldLen + 1, fieldLen * 2 + 1));
1011
+ const x = bytesToNumber(bytes.subarray(1, 33));
1012
+ const y = bytesToNumber(bytes.subarray(33, 65));
1096
1013
  const point = new Point(x, y);
1097
1014
  point.assertValidity();
1098
1015
  return point;
@@ -1101,30 +1018,29 @@ class Point {
1101
1018
  const bytes = ensureBytes(hex);
1102
1019
  const len = bytes.length;
1103
1020
  const header = bytes[0];
1104
- if (len === fieldLen)
1105
- return this.fromCompressedHex(bytes);
1106
- if (len === compressedLen && (header === 0x02 || header === 0x03)) {
1021
+ if (len === 32 || (len === 33 && (header === 0x02 || header === 0x03))) {
1107
1022
  return this.fromCompressedHex(bytes);
1108
1023
  }
1109
- if (len === uncompressedLen && header === 0x04)
1024
+ if (len === 65 && header === 0x04)
1110
1025
  return this.fromUncompressedHex(bytes);
1111
- throw new Error(`Point.fromHex: received invalid point. Expected 32-${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes, not ${len}`);
1026
+ throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${len}`);
1112
1027
  }
1113
1028
  static fromPrivateKey(privateKey) {
1114
1029
  return Point.BASE.multiply(normalizePrivateKey(privateKey));
1115
1030
  }
1116
1031
  static fromSignature(msgHash, signature, recovery) {
1032
+ msgHash = ensureBytes(msgHash);
1033
+ const h = truncateHash(msgHash);
1117
1034
  const { r, s } = normalizeSignature(signature);
1118
- if (![0, 1, 2, 3].includes(recovery))
1119
- throw new Error('Cannot recover: invalid recovery bit');
1120
- const h = truncateHash(ensureBytes(msgHash));
1035
+ if (recovery !== 0 && recovery !== 1) {
1036
+ throw new Error('Cannot recover signature: invalid recovery bit');
1037
+ }
1038
+ const prefix = recovery & 1 ? '03' : '02';
1039
+ const R = Point.fromHex(prefix + numTo32bStr(r));
1121
1040
  const { n } = CURVE;
1122
- const radj = recovery === 2 || recovery === 3 ? r + n : r;
1123
- const rinv = invert(radj, n);
1041
+ const rinv = invert(r, n);
1124
1042
  const u1 = mod(-h * rinv, n);
1125
1043
  const u2 = mod(s * rinv, n);
1126
- const prefix = recovery & 1 ? '03' : '02';
1127
- const R = Point.fromHex(prefix + numTo32bStr(radj));
1128
1044
  const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2);
1129
1045
  if (!Q)
1130
1046
  throw new Error('Cannot recover signature: point at infinify');
@@ -1137,7 +1053,7 @@ class Point {
1137
1053
  toHex(isCompressed = false) {
1138
1054
  const x = numTo32bStr(this.x);
1139
1055
  if (isCompressed) {
1140
- const prefix = this.hasEvenY() ? '02' : '03';
1056
+ const prefix = this.y & _1n ? '03' : '02';
1141
1057
  return `${prefix}${x}`;
1142
1058
  }
1143
1059
  else {
@@ -1156,7 +1072,7 @@ class Point {
1156
1072
  if (!isValidFieldElement(x) || !isValidFieldElement(y))
1157
1073
  throw new Error(msg);
1158
1074
  const left = mod(y * y);
1159
- const right = weierstrass(x);
1075
+ const right = weistrass(x);
1160
1076
  if (mod(left - right) !== _0n)
1161
1077
  throw new Error(msg);
1162
1078
  }
@@ -1227,7 +1143,7 @@ class Signature {
1227
1143
  this.assertValidity();
1228
1144
  }
1229
1145
  static fromCompact(hex) {
1230
- const arr = hex instanceof Uint8Array;
1146
+ const arr = isUint8a(hex);
1231
1147
  const name = 'Signature.fromCompact';
1232
1148
  if (typeof hex !== 'string' && !arr)
1233
1149
  throw new TypeError(`${name}: Expected string or Uint8Array`);
@@ -1237,7 +1153,7 @@ class Signature {
1237
1153
  return new Signature(hexToNumber(str.slice(0, 64)), hexToNumber(str.slice(64, 128)));
1238
1154
  }
1239
1155
  static fromDER(hex) {
1240
- const arr = hex instanceof Uint8Array;
1156
+ const arr = isUint8a(hex);
1241
1157
  if (typeof hex !== 'string' && !arr)
1242
1158
  throw new TypeError(`Signature.fromDER: Expected string or Uint8Array`);
1243
1159
  const { r, s } = parseDERSignature(arr ? hex : hexToBytes(hex));
@@ -1258,19 +1174,19 @@ class Signature {
1258
1174
  return this.s > HALF;
1259
1175
  }
1260
1176
  normalizeS() {
1261
- return this.hasHighS() ? new Signature(this.r, mod(-this.s, CURVE.n)) : this;
1177
+ return this.hasHighS() ? new Signature(this.r, CURVE.n - this.s) : this;
1262
1178
  }
1263
- toDERRawBytes() {
1264
- return hexToBytes(this.toDERHex());
1179
+ toDERRawBytes(isCompressed = false) {
1180
+ return hexToBytes(this.toDERHex(isCompressed));
1265
1181
  }
1266
- toDERHex() {
1182
+ toDERHex(isCompressed = false) {
1267
1183
  const sHex = sliceDER(numberToHexUnpadded(this.s));
1184
+ if (isCompressed)
1185
+ return sHex;
1268
1186
  const rHex = sliceDER(numberToHexUnpadded(this.r));
1269
- const sHexL = sHex.length / 2;
1270
- const rHexL = rHex.length / 2;
1271
- const sLen = numberToHexUnpadded(sHexL);
1272
- const rLen = numberToHexUnpadded(rHexL);
1273
- const length = numberToHexUnpadded(rHexL + sHexL + 4);
1187
+ const rLen = numberToHexUnpadded(rHex.length / 2);
1188
+ const sLen = numberToHexUnpadded(sHex.length / 2);
1189
+ const length = numberToHexUnpadded(rHex.length / 2 + sHex.length / 2 + 4);
1274
1190
  return `30${length}02${rLen}${rHex}02${sLen}${sHex}`;
1275
1191
  }
1276
1192
  toRawBytes() {
@@ -1288,7 +1204,7 @@ class Signature {
1288
1204
  }
1289
1205
  exports.Signature = Signature;
1290
1206
  function concatBytes(...arrays) {
1291
- if (!arrays.every((b) => b instanceof Uint8Array))
1207
+ if (!arrays.every(isUint8a))
1292
1208
  throw new Error('Uint8Array list expected');
1293
1209
  if (arrays.length === 1)
1294
1210
  return arrays[0];
@@ -1301,6 +1217,9 @@ function concatBytes(...arrays) {
1301
1217
  }
1302
1218
  return result;
1303
1219
  }
1220
+ function isUint8a(bytes) {
1221
+ return bytes instanceof Uint8Array;
1222
+ }
1304
1223
  const hexes = Array.from({ length: 256 }, (v, i) => i.toString(16).padStart(2, '0'));
1305
1224
  function bytesToHex(uint8a) {
1306
1225
  if (!(uint8a instanceof Uint8Array))
@@ -1311,19 +1230,13 @@ function bytesToHex(uint8a) {
1311
1230
  }
1312
1231
  return hex;
1313
1232
  }
1314
- const POW_2_256 = BigInt('0x10000000000000000000000000000000000000000000000000000000000000000');
1315
1233
  function numTo32bStr(num) {
1316
- if (typeof num !== 'bigint')
1317
- throw new Error('Expected bigint');
1318
- if (!(_0n <= num && num < POW_2_256))
1319
- throw new Error('Expected number 0 <= n < 2^256');
1234
+ if (num > POW_2_256)
1235
+ throw new Error('Expected number < 2^256');
1320
1236
  return num.toString(16).padStart(64, '0');
1321
1237
  }
1322
1238
  function numTo32b(num) {
1323
- const b = hexToBytes(numTo32bStr(num));
1324
- if (b.length !== 32)
1325
- throw new Error('Error: expected 32 bytes');
1326
- return b;
1239
+ return hexToBytes(numTo32bStr(num));
1327
1240
  }
1328
1241
  function numberToHexUnpadded(num) {
1329
1242
  const hex = num.toString(16);
@@ -1399,11 +1312,7 @@ function sqrtMod(x) {
1399
1312
  const b223 = (pow2(b220, _3n) * b3) % P;
1400
1313
  const t1 = (pow2(b223, _23n) * b22) % P;
1401
1314
  const t2 = (pow2(t1, _6n) * b2) % P;
1402
- const rt = pow2(t2, _2n);
1403
- const xc = (rt * rt) % P;
1404
- if (xc !== x)
1405
- throw new Error('Cannot find square root');
1406
- return rt;
1315
+ return pow2(t2, _2n);
1407
1316
  }
1408
1317
  function invert(number, modulo = CURVE.P) {
1409
1318
  if (number === _0n || modulo <= _0n) {
@@ -1441,45 +1350,61 @@ function invertBatch(nums, p = CURVE.P) {
1441
1350
  }, inverted);
1442
1351
  return scratch;
1443
1352
  }
1444
- function bits2int_2(bytes) {
1445
- const delta = bytes.length * 8 - groupLen * 8;
1446
- const num = bytesToNumber(bytes);
1447
- return delta > 0 ? num >> BigInt(delta) : num;
1353
+ const divNearest = (a, b) => (a + b / _2n) / b;
1354
+ const POW_2_128 = _2n ** BigInt(128);
1355
+ function splitScalarEndo(k) {
1356
+ const { n } = CURVE;
1357
+ const a1 = BigInt('0x3086d221a7d46bcde86c90e49284eb15');
1358
+ const b1 = -_1n * BigInt('0xe4437ed6010e88286f547fa90abfe4c3');
1359
+ const a2 = BigInt('0x114ca50f7a8e2f3f657c1108d9d44cfd8');
1360
+ const b2 = a1;
1361
+ const c1 = divNearest(b2 * k, n);
1362
+ const c2 = divNearest(-b1 * k, n);
1363
+ let k1 = mod(k - c1 * a1 - c2 * a2, n);
1364
+ let k2 = mod(-c1 * b1 - c2 * b2, n);
1365
+ const k1neg = k1 > POW_2_128;
1366
+ const k2neg = k2 > POW_2_128;
1367
+ if (k1neg)
1368
+ k1 = n - k1;
1369
+ if (k2neg)
1370
+ k2 = n - k2;
1371
+ if (k1 > POW_2_128 || k2 > POW_2_128) {
1372
+ throw new Error('splitScalarEndo: Endomorphism failed, k=' + k);
1373
+ }
1374
+ return { k1neg, k1, k2neg, k2 };
1448
1375
  }
1449
- function truncateHash(hash, truncateOnly = false) {
1450
- const h = bits2int_2(hash);
1451
- if (truncateOnly)
1452
- return h;
1376
+ function truncateHash(hash) {
1453
1377
  const { n } = CURVE;
1454
- return h >= n ? h - n : h;
1378
+ const byteLength = hash.length;
1379
+ const delta = byteLength * 8 - 256;
1380
+ let h = bytesToNumber(hash);
1381
+ if (delta > 0)
1382
+ h = h >> BigInt(delta);
1383
+ if (h >= n)
1384
+ h -= n;
1385
+ return h;
1455
1386
  }
1456
- let _sha256Sync;
1457
- let _hmacSha256Sync;
1458
1387
  class HmacDrbg {
1459
- constructor(hashLen, qByteLen) {
1460
- this.hashLen = hashLen;
1461
- this.qByteLen = qByteLen;
1462
- if (typeof hashLen !== 'number' || hashLen < 2)
1463
- throw new Error('hashLen must be a number');
1464
- if (typeof qByteLen !== 'number' || qByteLen < 2)
1465
- throw new Error('qByteLen must be a number');
1466
- this.v = new Uint8Array(hashLen).fill(1);
1467
- this.k = new Uint8Array(hashLen).fill(0);
1388
+ constructor() {
1389
+ this.v = new Uint8Array(32).fill(1);
1390
+ this.k = new Uint8Array(32).fill(0);
1468
1391
  this.counter = 0;
1469
1392
  }
1470
1393
  hmac(...values) {
1471
1394
  return exports.utils.hmacSha256(this.k, ...values);
1472
1395
  }
1473
1396
  hmacSync(...values) {
1474
- return _hmacSha256Sync(this.k, ...values);
1475
- }
1476
- checkSync() {
1477
- if (typeof _hmacSha256Sync !== 'function')
1478
- throw new ShaError('hmacSha256Sync needs to be set');
1397
+ if (typeof exports.utils.hmacSha256Sync !== 'function')
1398
+ throw new Error('utils.hmacSha256Sync is undefined, you need to set it');
1399
+ const res = exports.utils.hmacSha256Sync(this.k, ...values);
1400
+ if (res instanceof Promise)
1401
+ throw new Error('To use sync sign(), ensure utils.hmacSha256 is sync');
1402
+ return res;
1479
1403
  }
1480
1404
  incr() {
1481
- if (this.counter >= 1000)
1405
+ if (this.counter >= 1000) {
1482
1406
  throw new Error('Tried 1,000 k values for sign(), all were invalid');
1407
+ }
1483
1408
  this.counter += 1;
1484
1409
  }
1485
1410
  async reseed(seed = new Uint8Array()) {
@@ -1491,7 +1416,6 @@ class HmacDrbg {
1491
1416
  this.v = await this.hmac(this.v);
1492
1417
  }
1493
1418
  reseedSync(seed = new Uint8Array()) {
1494
- this.checkSync();
1495
1419
  this.k = this.hmacSync(this.v, Uint8Array.from([0x00]), seed);
1496
1420
  this.v = this.hmacSync(this.v);
1497
1421
  if (seed.length === 0)
@@ -1501,28 +1425,13 @@ class HmacDrbg {
1501
1425
  }
1502
1426
  async generate() {
1503
1427
  this.incr();
1504
- let len = 0;
1505
- const out = [];
1506
- while (len < this.qByteLen) {
1507
- this.v = await this.hmac(this.v);
1508
- const sl = this.v.slice();
1509
- out.push(sl);
1510
- len += this.v.length;
1511
- }
1512
- return concatBytes(...out);
1428
+ this.v = await this.hmac(this.v);
1429
+ return this.v;
1513
1430
  }
1514
1431
  generateSync() {
1515
- this.checkSync();
1516
1432
  this.incr();
1517
- let len = 0;
1518
- const out = [];
1519
- while (len < this.qByteLen) {
1520
- this.v = this.hmacSync(this.v);
1521
- const sl = this.v.slice();
1522
- out.push(sl);
1523
- len += this.v.length;
1524
- }
1525
- return concatBytes(...out);
1433
+ this.v = this.hmacSync(this.v);
1434
+ return this.v;
1526
1435
  }
1527
1436
  }
1528
1437
  function isWithinCurveOrder(num) {
@@ -1531,25 +1440,20 @@ function isWithinCurveOrder(num) {
1531
1440
  function isValidFieldElement(num) {
1532
1441
  return _0n < num && num < CURVE.P;
1533
1442
  }
1534
- function kmdToSig(kBytes, m, d, lowS = true) {
1535
- const { n } = CURVE;
1536
- const k = truncateHash(kBytes, true);
1443
+ function kmdToSig(kBytes, m, d) {
1444
+ const k = bytesToNumber(kBytes);
1537
1445
  if (!isWithinCurveOrder(k))
1538
1446
  return;
1539
- const kinv = invert(k, n);
1447
+ const { n } = CURVE;
1540
1448
  const q = Point.BASE.multiply(k);
1541
1449
  const r = mod(q.x, n);
1542
1450
  if (r === _0n)
1543
1451
  return;
1544
- const s = mod(kinv * mod(m + d * r, n), n);
1452
+ const s = mod(invert(k, n) * mod(m + d * r, n), n);
1545
1453
  if (s === _0n)
1546
1454
  return;
1547
- let sig = new Signature(r, s);
1548
- let recovery = (q.x === sig.r ? 0 : 2) | Number(q.y & _1n);
1549
- if (lowS && sig.hasHighS()) {
1550
- sig = sig.normalizeS();
1551
- recovery ^= 1;
1552
- }
1455
+ const sig = new Signature(r, s);
1456
+ const recovery = (q.x === sig.r ? 0 : 2) | Number(q.y & _1n);
1553
1457
  return { sig, recovery };
1554
1458
  }
1555
1459
  function normalizePrivateKey(key) {
@@ -1561,12 +1465,12 @@ function normalizePrivateKey(key) {
1561
1465
  num = BigInt(key);
1562
1466
  }
1563
1467
  else if (typeof key === 'string') {
1564
- if (key.length !== 2 * groupLen)
1468
+ if (key.length !== 64)
1565
1469
  throw new Error('Expected 32 bytes of private key');
1566
1470
  num = hexToNumber(key);
1567
1471
  }
1568
- else if (key instanceof Uint8Array) {
1569
- if (key.length !== groupLen)
1472
+ else if (isUint8a(key)) {
1473
+ if (key.length !== 32)
1570
1474
  throw new Error('Expected 32 bytes of private key');
1571
1475
  num = bytesToNumber(key);
1572
1476
  }
@@ -1606,22 +1510,22 @@ function recoverPublicKey(msgHash, signature, recovery, isCompressed = false) {
1606
1510
  return Point.fromSignature(msgHash, signature, recovery).toRawBytes(isCompressed);
1607
1511
  }
1608
1512
  exports.recoverPublicKey = recoverPublicKey;
1609
- function isProbPub(item) {
1610
- const arr = item instanceof Uint8Array;
1513
+ function isPub(item) {
1514
+ const arr = isUint8a(item);
1611
1515
  const str = typeof item === 'string';
1612
1516
  const len = (arr || str) && item.length;
1613
1517
  if (arr)
1614
- return len === compressedLen || len === uncompressedLen;
1518
+ return len === 33 || len === 65;
1615
1519
  if (str)
1616
- return len === compressedLen * 2 || len === uncompressedLen * 2;
1520
+ return len === 66 || len === 130;
1617
1521
  if (item instanceof Point)
1618
1522
  return true;
1619
1523
  return false;
1620
1524
  }
1621
1525
  function getSharedSecret(privateA, publicB, isCompressed = false) {
1622
- if (isProbPub(privateA))
1526
+ if (isPub(privateA))
1623
1527
  throw new TypeError('getSharedSecret: first arg must be private key');
1624
- if (!isProbPub(publicB))
1528
+ if (!isPub(publicB))
1625
1529
  throw new TypeError('getSharedSecret: second arg must be public key');
1626
1530
  const b = normalizePublicKey(publicB);
1627
1531
  b.assertValidity();
@@ -1629,7 +1533,7 @@ function getSharedSecret(privateA, publicB, isCompressed = false) {
1629
1533
  }
1630
1534
  exports.getSharedSecret = getSharedSecret;
1631
1535
  function bits2int(bytes) {
1632
- const slice = bytes.length > fieldLen ? bytes.slice(0, fieldLen) : bytes;
1536
+ const slice = bytes.length > 32 ? bytes.slice(0, 32) : bytes;
1633
1537
  return bytesToNumber(slice);
1634
1538
  }
1635
1539
  function bits2octets(bytes) {
@@ -1638,7 +1542,10 @@ function bits2octets(bytes) {
1638
1542
  return int2octets(z2 < _0n ? z1 : z2);
1639
1543
  }
1640
1544
  function int2octets(num) {
1641
- return numTo32b(num);
1545
+ if (typeof num !== 'bigint')
1546
+ throw new Error('Expected bigint');
1547
+ const hex = numTo32bStr(num);
1548
+ return hexToBytes(hex);
1642
1549
  }
1643
1550
  function initSigArgs(msgHash, privateKey, extraEntropy) {
1644
1551
  if (msgHash == null)
@@ -1648,10 +1555,10 @@ function initSigArgs(msgHash, privateKey, extraEntropy) {
1648
1555
  const seedArgs = [int2octets(d), bits2octets(h1)];
1649
1556
  if (extraEntropy != null) {
1650
1557
  if (extraEntropy === true)
1651
- extraEntropy = exports.utils.randomBytes(fieldLen);
1558
+ extraEntropy = exports.utils.randomBytes(32);
1652
1559
  const e = ensureBytes(extraEntropy);
1653
- if (e.length !== fieldLen)
1654
- throw new Error(`sign: Expected ${fieldLen} bytes of extra data`);
1560
+ if (e.length !== 32)
1561
+ throw new Error('sign: Expected 32 bytes of extra data');
1655
1562
  seedArgs.push(e);
1656
1563
  }
1657
1564
  const seed = concatBytes(...seedArgs);
@@ -1659,27 +1566,31 @@ function initSigArgs(msgHash, privateKey, extraEntropy) {
1659
1566
  return { seed, m, d };
1660
1567
  }
1661
1568
  function finalizeSig(recSig, opts) {
1662
- const { sig, recovery } = recSig;
1663
- const { der, recovered } = Object.assign({ canonical: true, der: true }, opts);
1569
+ let { sig, recovery } = recSig;
1570
+ const { canonical, der, recovered } = Object.assign({ canonical: true, der: true }, opts);
1571
+ if (canonical && sig.hasHighS()) {
1572
+ sig = sig.normalizeS();
1573
+ recovery ^= 1;
1574
+ }
1664
1575
  const hashed = der ? sig.toDERRawBytes() : sig.toCompactRawBytes();
1665
1576
  return recovered ? [hashed, recovery] : hashed;
1666
1577
  }
1667
1578
  async function sign(msgHash, privKey, opts = {}) {
1668
1579
  const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
1669
- const drbg = new HmacDrbg(hashLen, groupLen);
1670
- await drbg.reseed(seed);
1671
1580
  let sig;
1672
- while (!(sig = kmdToSig(await drbg.generate(), m, d, opts.canonical)))
1581
+ const drbg = new HmacDrbg();
1582
+ await drbg.reseed(seed);
1583
+ while (!(sig = kmdToSig(await drbg.generate(), m, d)))
1673
1584
  await drbg.reseed();
1674
1585
  return finalizeSig(sig, opts);
1675
1586
  }
1676
1587
  exports.sign = sign;
1677
1588
  function signSync(msgHash, privKey, opts = {}) {
1678
1589
  const { seed, m, d } = initSigArgs(msgHash, privKey, opts.extraEntropy);
1679
- const drbg = new HmacDrbg(hashLen, groupLen);
1680
- drbg.reseedSync(seed);
1681
1590
  let sig;
1682
- while (!(sig = kmdToSig(drbg.generateSync(), m, d, opts.canonical)))
1591
+ const drbg = new HmacDrbg();
1592
+ drbg.reseedSync(seed);
1593
+ while (!(sig = kmdToSig(drbg.generateSync(), m, d)))
1683
1594
  drbg.reseedSync();
1684
1595
  return finalizeSig(sig, opts);
1685
1596
  }
@@ -1716,9 +1627,12 @@ function verify(signature, msgHash, publicKey, opts = vopts) {
1716
1627
  return v === r;
1717
1628
  }
1718
1629
  exports.verify = verify;
1719
- function schnorrChallengeFinalize(ch) {
1630
+ function finalizeSchnorrChallenge(ch) {
1720
1631
  return mod(bytesToNumber(ch), CURVE.n);
1721
1632
  }
1633
+ function hasEvenY(point) {
1634
+ return (point.y & _1n) === _0n;
1635
+ }
1722
1636
  class SchnorrSignature {
1723
1637
  constructor(r, s) {
1724
1638
  this.r = r;
@@ -1748,67 +1662,55 @@ class SchnorrSignature {
1748
1662
  function schnorrGetPublicKey(privateKey) {
1749
1663
  return Point.fromPrivateKey(privateKey).toRawX();
1750
1664
  }
1751
- class InternalSchnorrSignature {
1752
- constructor(message, privateKey, auxRand = exports.utils.randomBytes()) {
1753
- if (message == null)
1754
- throw new TypeError(`sign: Expected valid message, not "${message}"`);
1755
- this.m = ensureBytes(message);
1756
- const { x, scalar } = this.getScalar(normalizePrivateKey(privateKey));
1757
- this.px = x;
1758
- this.d = scalar;
1759
- this.rand = ensureBytes(auxRand);
1760
- if (this.rand.length !== 32)
1761
- throw new TypeError('sign: Expected 32 bytes of aux randomness');
1762
- }
1763
- getScalar(priv) {
1764
- const point = Point.fromPrivateKey(priv);
1765
- const scalar = point.hasEvenY() ? priv : CURVE.n - priv;
1766
- return { point, scalar, x: point.toRawX() };
1767
- }
1768
- initNonce(d, t0h) {
1769
- return numTo32b(d ^ bytesToNumber(t0h));
1770
- }
1771
- finalizeNonce(k0h) {
1772
- const k0 = mod(bytesToNumber(k0h), CURVE.n);
1773
- if (k0 === _0n)
1774
- throw new Error('sign: Creation of signature failed. k is zero');
1775
- const { point: R, x: rx, scalar: k } = this.getScalar(k0);
1776
- return { R, rx, k };
1777
- }
1778
- finalizeSig(R, k, e, d) {
1779
- return new SchnorrSignature(R.x, mod(k + e * d, CURVE.n)).toRawBytes();
1780
- }
1781
- error() {
1782
- throw new Error('sign: Invalid signature produced');
1783
- }
1784
- async calc() {
1785
- const { m, d, px, rand } = this;
1786
- const tag = exports.utils.taggedHash;
1787
- const t = this.initNonce(d, await tag(TAGS.aux, rand));
1788
- const { R, rx, k } = this.finalizeNonce(await tag(TAGS.nonce, t, px, m));
1789
- const e = schnorrChallengeFinalize(await tag(TAGS.challenge, rx, px, m));
1790
- const sig = this.finalizeSig(R, k, e, d);
1791
- if (!(await schnorrVerify(sig, m, px)))
1792
- this.error();
1793
- return sig;
1794
- }
1795
- calcSync() {
1796
- const { m, d, px, rand } = this;
1797
- const tag = exports.utils.taggedHashSync;
1798
- const t = this.initNonce(d, tag(TAGS.aux, rand));
1799
- const { R, rx, k } = this.finalizeNonce(tag(TAGS.nonce, t, px, m));
1800
- const e = schnorrChallengeFinalize(tag(TAGS.challenge, rx, px, m));
1801
- const sig = this.finalizeSig(R, k, e, d);
1802
- if (!schnorrVerifySync(sig, m, px))
1803
- this.error();
1804
- return sig;
1805
- }
1665
+ function initSchnorrSigArgs(message, privateKey, auxRand) {
1666
+ if (message == null)
1667
+ throw new TypeError(`sign: Expected valid message, not "${message}"`);
1668
+ const m = ensureBytes(message);
1669
+ const d0 = normalizePrivateKey(privateKey);
1670
+ const rand = ensureBytes(auxRand);
1671
+ if (rand.length !== 32)
1672
+ throw new TypeError('sign: Expected 32 bytes of aux randomness');
1673
+ const P = Point.fromPrivateKey(d0);
1674
+ const px = P.toRawX();
1675
+ const d = hasEvenY(P) ? d0 : CURVE.n - d0;
1676
+ return { m, P, px, d, rand };
1677
+ }
1678
+ function initSchnorrNonce(d, t0h) {
1679
+ return numTo32b(d ^ bytesToNumber(t0h));
1806
1680
  }
1807
- async function schnorrSign(msg, privKey, auxRand) {
1808
- return new InternalSchnorrSignature(msg, privKey, auxRand).calc();
1681
+ function finalizeSchnorrNonce(k0h) {
1682
+ const k0 = mod(bytesToNumber(k0h), CURVE.n);
1683
+ if (k0 === _0n)
1684
+ throw new Error('sign: Creation of signature failed. k is zero');
1685
+ const R = Point.fromPrivateKey(k0);
1686
+ const rx = R.toRawX();
1687
+ const k = hasEvenY(R) ? k0 : CURVE.n - k0;
1688
+ return { R, rx, k };
1809
1689
  }
1810
- function schnorrSignSync(msg, privKey, auxRand) {
1811
- return new InternalSchnorrSignature(msg, privKey, auxRand).calcSync();
1690
+ function finalizeSchnorrSig(R, k, e, d) {
1691
+ return new SchnorrSignature(R.x, mod(k + e * d, CURVE.n)).toRawBytes();
1692
+ }
1693
+ async function schnorrSign(message, privateKey, auxRand = exports.utils.randomBytes()) {
1694
+ const { m, px, d, rand } = initSchnorrSigArgs(message, privateKey, auxRand);
1695
+ const t = initSchnorrNonce(d, await exports.utils.taggedHash(TAGS.aux, rand));
1696
+ const { R, rx, k } = finalizeSchnorrNonce(await exports.utils.taggedHash(TAGS.nonce, t, px, m));
1697
+ const e = finalizeSchnorrChallenge(await exports.utils.taggedHash(TAGS.challenge, rx, px, m));
1698
+ const sig = finalizeSchnorrSig(R, k, e, d);
1699
+ const isValid = await schnorrVerify(sig, m, px);
1700
+ if (!isValid)
1701
+ throw new Error('sign: Invalid signature produced');
1702
+ return sig;
1703
+ }
1704
+ function schnorrSignSync(message, privateKey, auxRand = exports.utils.randomBytes()) {
1705
+ const { m, px, d, rand } = initSchnorrSigArgs(message, privateKey, auxRand);
1706
+ const t = initSchnorrNonce(d, exports.utils.taggedHashSync(TAGS.aux, rand));
1707
+ const { R, rx, k } = finalizeSchnorrNonce(exports.utils.taggedHashSync(TAGS.nonce, t, px, m));
1708
+ const e = finalizeSchnorrChallenge(exports.utils.taggedHashSync(TAGS.challenge, rx, px, m));
1709
+ const sig = finalizeSchnorrSig(R, k, e, d);
1710
+ const isValid = schnorrVerifySync(sig, m, px);
1711
+ if (!isValid)
1712
+ throw new Error('sign: Invalid signature produced');
1713
+ return sig;
1812
1714
  }
1813
1715
  function initSchnorrVerify(signature, message, publicKey) {
1814
1716
  const raw = signature instanceof SchnorrSignature;
@@ -1823,14 +1725,14 @@ function initSchnorrVerify(signature, message, publicKey) {
1823
1725
  }
1824
1726
  function finalizeSchnorrVerify(r, P, s, e) {
1825
1727
  const R = Point.BASE.multiplyAndAddUnsafe(P, normalizePrivateKey(s), mod(-e, CURVE.n));
1826
- if (!R || !R.hasEvenY() || R.x !== r)
1728
+ if (!R || !hasEvenY(R) || R.x !== r)
1827
1729
  return false;
1828
1730
  return true;
1829
1731
  }
1830
1732
  async function schnorrVerify(signature, message, publicKey) {
1831
1733
  try {
1832
1734
  const { r, s, m, P } = initSchnorrVerify(signature, message, publicKey);
1833
- const e = schnorrChallengeFinalize(await exports.utils.taggedHash(TAGS.challenge, numTo32b(r), P.toRawX(), m));
1735
+ const e = finalizeSchnorrChallenge(await exports.utils.taggedHash(TAGS.challenge, numTo32b(r), P.toRawX(), m));
1834
1736
  return finalizeSchnorrVerify(r, P, s, e);
1835
1737
  }
1836
1738
  catch (error) {
@@ -1840,12 +1742,10 @@ async function schnorrVerify(signature, message, publicKey) {
1840
1742
  function schnorrVerifySync(signature, message, publicKey) {
1841
1743
  try {
1842
1744
  const { r, s, m, P } = initSchnorrVerify(signature, message, publicKey);
1843
- const e = schnorrChallengeFinalize(exports.utils.taggedHashSync(TAGS.challenge, numTo32b(r), P.toRawX(), m));
1745
+ const e = finalizeSchnorrChallenge(exports.utils.taggedHashSync(TAGS.challenge, numTo32b(r), P.toRawX(), m));
1844
1746
  return finalizeSchnorrVerify(r, P, s, e);
1845
1747
  }
1846
1748
  catch (error) {
1847
- if (error instanceof ShaError)
1848
- throw error;
1849
1749
  return false;
1850
1750
  }
1851
1751
  }
@@ -1869,11 +1769,6 @@ const TAGS = {
1869
1769
  };
1870
1770
  const TAGGED_HASH_PREFIXES = {};
1871
1771
  exports.utils = {
1872
- bytesToHex,
1873
- hexToBytes,
1874
- concatBytes,
1875
- mod,
1876
- invert,
1877
1772
  isValidPrivateKey(privateKey) {
1878
1773
  try {
1879
1774
  normalizePrivateKey(privateKey);
@@ -1883,14 +1778,32 @@ exports.utils = {
1883
1778
  return false;
1884
1779
  }
1885
1780
  },
1886
- _bigintTo32Bytes: numTo32b,
1887
- _normalizePrivateKey: normalizePrivateKey,
1781
+ privateAdd: (privateKey, tweak) => {
1782
+ const p = normalizePrivateKey(privateKey);
1783
+ const t = normalizePrivateKey(tweak);
1784
+ return numTo32b(mod(p + t, CURVE.n));
1785
+ },
1786
+ privateNegate: (privateKey) => {
1787
+ const p = normalizePrivateKey(privateKey);
1788
+ return numTo32b(CURVE.n - p);
1789
+ },
1790
+ pointAddScalar: (p, tweak, isCompressed) => {
1791
+ const P = Point.fromHex(p);
1792
+ const t = normalizePrivateKey(tweak);
1793
+ const Q = Point.BASE.multiplyAndAddUnsafe(P, t, _1n);
1794
+ if (!Q)
1795
+ throw new Error('Tweaked point at infinity');
1796
+ return Q.toRawBytes(isCompressed);
1797
+ },
1798
+ pointMultiply: (p, tweak, isCompressed) => {
1799
+ const P = Point.fromHex(p);
1800
+ const t = bytesToNumber(ensureBytes(tweak));
1801
+ return P.multiply(t).toRawBytes(isCompressed);
1802
+ },
1888
1803
  hashToPrivateKey: (hash) => {
1889
1804
  hash = ensureBytes(hash);
1890
- const minLen = groupLen + 8;
1891
- if (hash.length < minLen || hash.length > 1024) {
1892
- throw new Error(`Expected valid bytes of private key as per FIPS 186`);
1893
- }
1805
+ if (hash.length < 40 || hash.length > 1024)
1806
+ throw new Error('Expected 40-1024 bytes of private key as per FIPS 186');
1894
1807
  const num = mod(bytesToNumber(hash), CURVE.n - _1n) + _1n;
1895
1808
  return numTo32b(num);
1896
1809
  },
@@ -1906,13 +1819,14 @@ exports.utils = {
1906
1819
  throw new Error("The environment doesn't have randomBytes function");
1907
1820
  }
1908
1821
  },
1909
- randomPrivateKey: () => exports.utils.hashToPrivateKey(exports.utils.randomBytes(groupLen + 8)),
1910
- precompute(windowSize = 8, point = Point.BASE) {
1911
- const cached = point === Point.BASE ? point : new Point(point.x, point.y);
1912
- cached._setWindowSize(windowSize);
1913
- cached.multiply(_3n);
1914
- return cached;
1822
+ randomPrivateKey: () => {
1823
+ return exports.utils.hashToPrivateKey(exports.utils.randomBytes(40));
1915
1824
  },
1825
+ bytesToHex,
1826
+ hexToBytes,
1827
+ concatBytes,
1828
+ mod,
1829
+ invert,
1916
1830
  sha256: async (...messages) => {
1917
1831
  if (crypto.web) {
1918
1832
  const buffer = await crypto.web.subtle.digest('SHA-256', concatBytes(...messages));
@@ -1957,40 +1871,23 @@ exports.utils = {
1957
1871
  return exports.utils.sha256(tagP, ...messages);
1958
1872
  },
1959
1873
  taggedHashSync: (tag, ...messages) => {
1960
- if (typeof _sha256Sync !== 'function')
1961
- throw new ShaError('sha256Sync is undefined, you need to set it');
1874
+ if (typeof exports.utils.sha256Sync !== 'function')
1875
+ throw new Error('utils.sha256Sync is undefined, you need to set it');
1962
1876
  let tagP = TAGGED_HASH_PREFIXES[tag];
1963
1877
  if (tagP === undefined) {
1964
- const tagH = _sha256Sync(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
1878
+ const tagH = exports.utils.sha256Sync(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
1965
1879
  tagP = concatBytes(tagH, tagH);
1966
1880
  TAGGED_HASH_PREFIXES[tag] = tagP;
1967
1881
  }
1968
- return _sha256Sync(tagP, ...messages);
1882
+ return exports.utils.sha256Sync(tagP, ...messages);
1969
1883
  },
1970
- _JacobianPoint: JacobianPoint,
1971
- };
1972
- Object.defineProperties(exports.utils, {
1973
- sha256Sync: {
1974
- configurable: false,
1975
- get() {
1976
- return _sha256Sync;
1977
- },
1978
- set(val) {
1979
- if (!_sha256Sync)
1980
- _sha256Sync = val;
1981
- },
1982
- },
1983
- hmacSha256Sync: {
1984
- configurable: false,
1985
- get() {
1986
- return _hmacSha256Sync;
1987
- },
1988
- set(val) {
1989
- if (!_hmacSha256Sync)
1990
- _hmacSha256Sync = val;
1991
- },
1884
+ precompute(windowSize = 8, point = Point.BASE) {
1885
+ const cached = point === Point.BASE ? point : new Point(point.x, point.y);
1886
+ cached._setWindowSize(windowSize);
1887
+ cached.multiply(_3n);
1888
+ return cached;
1992
1889
  },
1993
- });
1890
+ };
1994
1891
 
1995
1892
 
1996
1893
  /***/ }),
@@ -15116,21 +15013,13 @@ var Enum = __webpack_require__(7025),
15116
15013
  * @ignore
15117
15014
  */
15118
15015
  function genValuePartial_fromObject(gen, field, fieldIndex, prop) {
15119
- var defaultAlreadyEmitted = false;
15120
15016
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
15121
15017
  if (field.resolvedType) {
15122
15018
  if (field.resolvedType instanceof Enum) { gen
15123
15019
  ("switch(d%s){", prop);
15124
15020
  for (var values = field.resolvedType.values, keys = Object.keys(values), i = 0; i < keys.length; ++i) {
15125
- // enum unknown values passthrough
15126
- if (values[keys[i]] === field.typeDefault && !defaultAlreadyEmitted) { gen
15127
- ("default:")
15128
- ("if(typeof(d%s)===\"number\"){m%s=d%s;break}", prop, prop, prop);
15129
- if (!field.repeated) gen // fallback to default value only for
15130
- // arrays, to avoid leaving holes.
15131
- ("break"); // for non-repeated fields, just ignore
15132
- defaultAlreadyEmitted = true;
15133
- }
15021
+ if (field.repeated && values[keys[i]] === field.typeDefault) gen
15022
+ ("default:");
15134
15023
  gen
15135
15024
  ("case%j:", keys[i])
15136
15025
  ("case %i:", values[keys[i]])
@@ -15262,7 +15151,7 @@ function genValuePartial_toObject(gen, field, fieldIndex, prop) {
15262
15151
  /* eslint-disable no-unexpected-multiline, block-scoped-var, no-redeclare */
15263
15152
  if (field.resolvedType) {
15264
15153
  if (field.resolvedType instanceof Enum) gen
15265
- ("d%s=o.enums===String?(types[%i].values[m%s]===undefined?m%s:types[%i].values[m%s]):m%s", prop, fieldIndex, prop, prop, fieldIndex, prop, prop);
15154
+ ("d%s=o.enums===String?types[%i].values[m%s]:m%s", prop, fieldIndex, prop, prop);
15266
15155
  else gen
15267
15156
  ("d%s=types[%i].toObject(m%s,o)", prop, fieldIndex, prop);
15268
15157
  } else {
@@ -15670,9 +15559,8 @@ var Namespace = __webpack_require__(9313),
15670
15559
  * @param {Object.<string,*>} [options] Declared options
15671
15560
  * @param {string} [comment] The comment for this enum
15672
15561
  * @param {Object.<string,string>} [comments] The value comments for this enum
15673
- * @param {Object.<string,Object<string,*>>|undefined} [valuesOptions] The value options for this enum
15674
15562
  */
15675
- function Enum(name, values, options, comment, comments, valuesOptions) {
15563
+ function Enum(name, values, options, comment, comments) {
15676
15564
  ReflectionObject.call(this, name, options);
15677
15565
 
15678
15566
  if (values && typeof values !== "object")
@@ -15702,12 +15590,6 @@ function Enum(name, values, options, comment, comments, valuesOptions) {
15702
15590
  */
15703
15591
  this.comments = comments || {};
15704
15592
 
15705
- /**
15706
- * Values options, if any
15707
- * @type {Object<string, Object<string, *>>|undefined}
15708
- */
15709
- this.valuesOptions = valuesOptions;
15710
-
15711
15593
  /**
15712
15594
  * Reserved ranges, if any.
15713
15595
  * @type {Array.<number[]|string>}
@@ -15752,12 +15634,11 @@ Enum.fromJSON = function fromJSON(name, json) {
15752
15634
  Enum.prototype.toJSON = function toJSON(toJSONOptions) {
15753
15635
  var keepComments = toJSONOptions ? Boolean(toJSONOptions.keepComments) : false;
15754
15636
  return util.toObject([
15755
- "options" , this.options,
15756
- "valuesOptions" , this.valuesOptions,
15757
- "values" , this.values,
15758
- "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
15759
- "comment" , keepComments ? this.comment : undefined,
15760
- "comments" , keepComments ? this.comments : undefined
15637
+ "options" , this.options,
15638
+ "values" , this.values,
15639
+ "reserved" , this.reserved && this.reserved.length ? this.reserved : undefined,
15640
+ "comment" , keepComments ? this.comment : undefined,
15641
+ "comments" , keepComments ? this.comments : undefined
15761
15642
  ]);
15762
15643
  };
15763
15644
 
@@ -15766,12 +15647,11 @@ Enum.prototype.toJSON = function toJSON(toJSONOptions) {
15766
15647
  * @param {string} name Value name
15767
15648
  * @param {number} id Value id
15768
15649
  * @param {string} [comment] Comment, if any
15769
- * @param {Object.<string, *>|undefined} [options] Options, if any
15770
15650
  * @returns {Enum} `this`
15771
15651
  * @throws {TypeError} If arguments are invalid
15772
15652
  * @throws {Error} If there is already a value with this name or id
15773
15653
  */
15774
- Enum.prototype.add = function add(name, id, comment, options) {
15654
+ Enum.prototype.add = function add(name, id, comment) {
15775
15655
  // utilized by the parser but not by .fromJSON
15776
15656
 
15777
15657
  if (!util.isString(name))
@@ -15796,12 +15676,6 @@ Enum.prototype.add = function add(name, id, comment, options) {
15796
15676
  } else
15797
15677
  this.valuesById[this.values[name] = id] = name;
15798
15678
 
15799
- if (options) {
15800
- if (this.valuesOptions === undefined)
15801
- this.valuesOptions = {};
15802
- this.valuesOptions[name] = options || null;
15803
- }
15804
-
15805
15679
  this.comments[name] = comment || null;
15806
15680
  return this;
15807
15681
  };
@@ -15825,8 +15699,6 @@ Enum.prototype.remove = function remove(name) {
15825
15699
  delete this.valuesById[val];
15826
15700
  delete this.values[name];
15827
15701
  delete this.comments[name];
15828
- if (this.valuesOptions)
15829
- delete this.valuesOptions[name];
15830
15702
 
15831
15703
  return this;
15832
15704
  };
@@ -16873,8 +16745,7 @@ var ReflectionObject = __webpack_require__(3243);
16873
16745
  ((Namespace.prototype = Object.create(ReflectionObject.prototype)).constructor = Namespace).className = "Namespace";
16874
16746
 
16875
16747
  var Field = __webpack_require__(3548),
16876
- util = __webpack_require__(9935),
16877
- OneOf = __webpack_require__(7598);
16748
+ util = __webpack_require__(9935);
16878
16749
 
16879
16750
  var Type, // cyclic
16880
16751
  Service,
@@ -17010,8 +16881,9 @@ Object.defineProperty(Namespace.prototype, "nestedArray", {
17010
16881
  /**
17011
16882
  * Any nested object descriptor.
17012
16883
  * @typedef AnyNestedObject
17013
- * @type {IEnum|IType|IService|AnyExtensionField|INamespace|IOneOf}
16884
+ * @type {IEnum|IType|IService|AnyExtensionField|INamespace}
17014
16885
  */
16886
+ // ^ BEWARE: VSCode hangs forever when using more than 5 types (that's why AnyExtensionField exists in the first place)
17015
16887
 
17016
16888
  /**
17017
16889
  * Converts this namespace to a namespace descriptor.
@@ -17084,7 +16956,7 @@ Namespace.prototype.getEnum = function getEnum(name) {
17084
16956
  */
17085
16957
  Namespace.prototype.add = function add(object) {
17086
16958
 
17087
- if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof OneOf || object instanceof Enum || object instanceof Service || object instanceof Namespace))
16959
+ if (!(object instanceof Field && object.extend !== undefined || object instanceof Type || object instanceof Enum || object instanceof Service || object instanceof Namespace))
17088
16960
  throw TypeError("object must be a valid nested object");
17089
16961
 
17090
16962
  if (!this.nested)
@@ -18130,16 +18002,6 @@ function parse(source, root, options) {
18130
18002
  parseGroup(parent, rule);
18131
18003
  return;
18132
18004
  }
18133
- // Type names can consume multiple tokens, in multiple variants:
18134
- // package.subpackage field tokens: "package.subpackage" [TYPE NAME ENDS HERE] "field"
18135
- // package . subpackage field tokens: "package" "." "subpackage" [TYPE NAME ENDS HERE] "field"
18136
- // package. subpackage field tokens: "package." "subpackage" [TYPE NAME ENDS HERE] "field"
18137
- // package .subpackage field tokens: "package" ".subpackage" [TYPE NAME ENDS HERE] "field"
18138
- // Keep reading tokens until we get a type name with no period at the end,
18139
- // and the next token does not start with a period.
18140
- while (type.endsWith(".") || peek().startsWith(".")) {
18141
- type += next();
18142
- }
18143
18005
 
18144
18006
  /* istanbul ignore if */
18145
18007
  if (!typeRefRe.test(type))
@@ -18223,14 +18085,6 @@ function parse(source, root, options) {
18223
18085
  }
18224
18086
  break;
18225
18087
 
18226
- case "message":
18227
- parseType(type, token);
18228
- break;
18229
-
18230
- case "enum":
18231
- parseEnum(type, token);
18232
- break;
18233
-
18234
18088
  /* istanbul ignore next */
18235
18089
  default:
18236
18090
  throw illegal(token); // there are no groups with proto3 semantics
@@ -18331,14 +18185,7 @@ function parse(source, root, options) {
18331
18185
 
18332
18186
  skip("=");
18333
18187
  var value = parseId(next(), true),
18334
- dummy = {
18335
- options: undefined
18336
- };
18337
- dummy.setOption = function(name, value) {
18338
- if (this.options === undefined)
18339
- this.options = {};
18340
- this.options[name] = value;
18341
- };
18188
+ dummy = {};
18342
18189
  ifBlock(dummy, function parseEnumValue_block(token) {
18343
18190
 
18344
18191
  /* istanbul ignore else */
@@ -18351,7 +18198,7 @@ function parse(source, root, options) {
18351
18198
  }, function parseEnumValue_line() {
18352
18199
  parseInlineOptions(dummy); // skip
18353
18200
  });
18354
- parent.add(token, value, dummy.comment, dummy.options);
18201
+ parent.add(token, value, dummy.comment);
18355
18202
  }
18356
18203
 
18357
18204
  function parseOption(parent, token) {
@@ -19270,7 +19117,6 @@ Root.prototype.load = function load(filename, options, callback) {
19270
19117
 
19271
19118
  // Fetches a single file
19272
19119
  function fetch(filename, weak) {
19273
- filename = getBundledFileName(filename) || filename;
19274
19120
 
19275
19121
  // Skip if already loaded / attempted
19276
19122
  if (self.files.indexOf(filename) > -1)
@@ -19399,10 +19245,6 @@ function tryHandleExtension(root, field) {
19399
19245
  var extendedType = field.parent.lookup(field.extend);
19400
19246
  if (extendedType) {
19401
19247
  var sisterField = new Field(field.fullName, field.id, field.type, field.rule, undefined, field.options);
19402
- //do not allow to extend same field twice to prevent the error
19403
- if (extendedType.get(sisterField.name)) {
19404
- return true;
19405
- }
19406
19248
  sisterField.declaringField = field;
19407
19249
  field.extensionField = sisterField;
19408
19250
  extendedType.add(sisterField);
@@ -21299,7 +21141,7 @@ util.decorateEnum = function decorateEnum(object) {
21299
21141
  util.setProperty = function setProperty(dst, path, value) {
21300
21142
  function setProp(dst, path, value) {
21301
21143
  var part = path.shift();
21302
- if (part === "__proto__" || part === "prototype") {
21144
+ if (part === "__proto__") {
21303
21145
  return dst;
21304
21146
  }
21305
21147
  if (path.length > 0) {
@@ -21337,7 +21179,7 @@ Object.defineProperty(util, "decorateRoot", {
21337
21179
 
21338
21180
  /***/ }),
21339
21181
 
21340
- /***/ 2630:
21182
+ /***/ 1945:
21341
21183
  /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
21342
21184
 
21343
21185
  "use strict";
@@ -21574,7 +21416,7 @@ util.utf8 = __webpack_require__(4997);
21574
21416
  util.pool = __webpack_require__(6662);
21575
21417
 
21576
21418
  // utility to work with the low and high bits of a 64 bit value
21577
- util.LongBits = __webpack_require__(2630);
21419
+ util.LongBits = __webpack_require__(1945);
21578
21420
 
21579
21421
  /**
21580
21422
  * Whether running within node or not.
@@ -21839,7 +21681,7 @@ function newError(name) {
21839
21681
  configurable: true,
21840
21682
  },
21841
21683
  name: {
21842
- get: function get() { return name; },
21684
+ get() { return name; },
21843
21685
  set: undefined,
21844
21686
  enumerable: false,
21845
21687
  // configurable: false would accurately preserve the behavior of
@@ -21849,7 +21691,7 @@ function newError(name) {
21849
21691
  configurable: true,
21850
21692
  },
21851
21693
  toString: {
21852
- value: function value() { return this.name + ": " + this.message; },
21694
+ value() { return this.name + ": " + this.message; },
21853
21695
  writable: true,
21854
21696
  enumerable: false,
21855
21697
  configurable: true,
@@ -22998,8 +22840,6 @@ class Contract {
22998
22840
  Object.keys(this.abi.methods).forEach((name) => {
22999
22841
  this.functions[name] = async (argu = {}, options) => {
23000
22842
  var _a;
23001
- if (!this.provider)
23002
- throw new Error("provider not found");
23003
22843
  if (!this.abi || !this.abi.methods)
23004
22844
  throw new Error("Methods are not defined");
23005
22845
  if (!this.abi.methods[name])
@@ -23020,6 +22860,8 @@ class Contract {
23020
22860
  if (opts.onlyOperation) {
23021
22861
  return { operation };
23022
22862
  }
22863
+ if (!this.provider)
22864
+ throw new Error("provider not found");
23023
22865
  if (readOnly) {
23024
22866
  if (!output)
23025
22867
  throw new Error(`No output defined for ${name}`);
@@ -23180,7 +23022,7 @@ class Contract {
23180
23022
  * @returns Operation encoded
23181
23023
  * @example
23182
23024
  * ```ts
23183
- * const opEncoded = contract.encodeOperation({
23025
+ * const opEncoded = await contract.encodeOperation({
23184
23026
  * name: "transfer",
23185
23027
  * args: {
23186
23028
  * from: "12fN2CQnuJM8cMnWZ1hPtM4knjLME8E4PD",
@@ -23223,7 +23065,7 @@ class Contract {
23223
23065
  * Decodes a contract operation to be human readable
23224
23066
  * @example
23225
23067
  * ```ts
23226
- * const opDecoded = contract.decodeOperation({
23068
+ * const opDecoded = await contract.decodeOperation({
23227
23069
  * call_contract: {
23228
23070
  * contract_id: "19JntSm8pSNETT9aHTwAUHC5RMoaSmgZPJ",
23229
23071
  * entry_point: 0x27f576ca,
@@ -23325,6 +23167,7 @@ exports.Provider = void 0;
23325
23167
  // @ts-ignore
23326
23168
  const protocol_proto_js_1 = __webpack_require__(9104);
23327
23169
  const utils_1 = __webpack_require__(8593);
23170
+ const Serializer_1 = __webpack_require__(7187);
23328
23171
  /* eslint-disable @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access */
23329
23172
  async function sleep(ms) {
23330
23173
  return new Promise((r) => setTimeout(r, ms));
@@ -23464,11 +23307,11 @@ class Provider {
23464
23307
  transaction_ids: transactionIds,
23465
23308
  });
23466
23309
  }
23467
- async getBlocksById(blockIds) {
23310
+ async getBlocksById(blockIds, opts) {
23468
23311
  return this.call("block_store.get_blocks_by_id", {
23469
23312
  block_ids: blockIds,
23470
- return_block: true,
23471
- return_receipt: false,
23313
+ return_block: opts && opts.returnBlock !== undefined ? opts.returnBlock : true,
23314
+ return_receipt: opts && opts.returnReceipt !== undefined ? opts.returnReceipt : false,
23472
23315
  });
23473
23316
  }
23474
23317
  /**
@@ -23492,7 +23335,7 @@ class Provider {
23492
23335
  * This ID must be from a greater block height. By default it
23493
23336
  * gets the ID from the block head.
23494
23337
  */
23495
- async getBlocks(height, numBlocks = 1, idRef) {
23338
+ async getBlocks(height, numBlocks = 1, idRef, opts) {
23496
23339
  let blockIdRef = idRef;
23497
23340
  if (!blockIdRef) {
23498
23341
  const head = await this.getHeadInfo();
@@ -23502,8 +23345,8 @@ class Provider {
23502
23345
  head_block_id: blockIdRef,
23503
23346
  ancestor_start_height: height,
23504
23347
  num_blocks: numBlocks,
23505
- return_block: true,
23506
- return_receipt: false,
23348
+ return_block: opts && opts.returnBlock !== undefined ? opts.returnBlock : true,
23349
+ return_receipt: opts && opts.returnReceipt !== undefined ? opts.returnReceipt : false,
23507
23350
  })).block_items;
23508
23351
  }
23509
23352
  /**
@@ -23643,6 +23486,98 @@ class Provider {
23643
23486
  async readContract(operation) {
23644
23487
  return this.call("chain.read_contract", operation);
23645
23488
  }
23489
+ /**
23490
+ * Function to call "chain.get_fork_heads" to get fork heads
23491
+ */
23492
+ async getForkHeads() {
23493
+ return this.call("chain.get_fork_heads", {});
23494
+ }
23495
+ /**
23496
+ * Funciont to call "chain.get_resource_limits" to get
23497
+ * resource limits
23498
+ */
23499
+ async getResourceLimits() {
23500
+ return this.call("chain.get_resource_limits", {});
23501
+ }
23502
+ /**
23503
+ * Function to call "chain.invoke_system_call" to invoke a system
23504
+ * call.
23505
+ */
23506
+ async invokeSystemCall(serializer, nameOrId, args, callerData) {
23507
+ if (!serializer.argumentsTypeName)
23508
+ throw new Error("argumentsTypeName not defined");
23509
+ if (!serializer.returnTypeName)
23510
+ throw new Error("returnTypeName not defined");
23511
+ const argsEncoded = await serializer.serialize(args, serializer.argumentsTypeName);
23512
+ const response = await this.call("chain.invoke_system_call", {
23513
+ ...(typeof nameOrId === "number" && { id: nameOrId }),
23514
+ ...(typeof nameOrId === "string" && { name: nameOrId }),
23515
+ args: (0, utils_1.encodeBase64url)(argsEncoded),
23516
+ caller_data: callerData,
23517
+ });
23518
+ if (!response || !response.value)
23519
+ throw new Error("no value in the response");
23520
+ const result = await serializer.deserialize(response.value, serializer.returnTypeName);
23521
+ return result;
23522
+ }
23523
+ async invokeGetContractMetadata(contractId) {
23524
+ const serializer = new Serializer_1.Serializer({
23525
+ nested: {
23526
+ get_contract_metadata_arguments: {
23527
+ fields: {
23528
+ contract_id: {
23529
+ type: "bytes",
23530
+ id: 1,
23531
+ options: {
23532
+ "(koinos.btype)": "CONTRACT_ID",
23533
+ },
23534
+ },
23535
+ },
23536
+ },
23537
+ get_contract_metadata_result: {
23538
+ fields: {
23539
+ value: {
23540
+ type: "contract_metadata_object",
23541
+ id: 1,
23542
+ },
23543
+ },
23544
+ },
23545
+ contract_metadata_object: {
23546
+ fields: {
23547
+ hash: {
23548
+ type: "bytes",
23549
+ id: 1,
23550
+ options: {
23551
+ "(koinos.btype)": "HEX",
23552
+ },
23553
+ },
23554
+ system: {
23555
+ type: "bool",
23556
+ id: 2,
23557
+ },
23558
+ authorizes_call_contract: {
23559
+ type: "bool",
23560
+ id: 3,
23561
+ },
23562
+ authorizes_transaction_application: {
23563
+ type: "bool",
23564
+ id: 4,
23565
+ },
23566
+ authorizes_upload_contract: {
23567
+ type: "bool",
23568
+ id: 5,
23569
+ },
23570
+ },
23571
+ },
23572
+ },
23573
+ }, {
23574
+ argumentsTypeName: "get_contract_metadata_arguments",
23575
+ returnTypeName: "get_contract_metadata_result",
23576
+ });
23577
+ return this.invokeSystemCall(serializer, "get_contract_metadata", {
23578
+ contract_id: contractId,
23579
+ });
23580
+ }
23646
23581
  }
23647
23582
  exports.Provider = Provider;
23648
23583
  exports["default"] = Provider;
@@ -23786,6 +23721,10 @@ class Serializer {
23786
23721
  }
23787
23722
  if (opts === null || opts === void 0 ? void 0 : opts.defaultTypeName)
23788
23723
  this.defaultType = this.root.lookupType(opts.defaultTypeName);
23724
+ if (opts === null || opts === void 0 ? void 0 : opts.argumentsTypeName)
23725
+ this.argumentsTypeName = opts.argumentsTypeName;
23726
+ if (opts === null || opts === void 0 ? void 0 : opts.returnTypeName)
23727
+ this.returnTypeName = opts.returnTypeName;
23789
23728
  if (opts && typeof opts.bytesConversion !== "undefined")
23790
23729
  this.bytesConversion = opts.bytesConversion;
23791
23730
  }
@@ -24005,53 +23944,6 @@ const btypeTransactionHeader = {
24005
23944
  payer: { type: "bytes", btype: "ADDRESS" },
24006
23945
  payee: { type: "bytes", btype: "ADDRESS" },
24007
23946
  };
24008
- const btypesOperation = {
24009
- upload_contract: {
24010
- type: "object",
24011
- subtypes: {
24012
- contract_id: { type: "bytes", btype: "CONTRACT_ID" },
24013
- bytecode: { type: "bytes" },
24014
- abi: { type: "string" },
24015
- authorizes_call_contract: { type: "bool" },
24016
- authorizes_transaction_application: { type: "bool" },
24017
- authorizes_upload_contract: { type: "bool" },
24018
- },
24019
- },
24020
- call_contract: {
24021
- type: "object",
24022
- subtypes: {
24023
- contract_id: { type: "bytes", btype: "CONTRACT_ID" },
24024
- entry_point: { type: "uint32" },
24025
- args: { type: "bytes" },
24026
- },
24027
- },
24028
- set_system_call: {
24029
- type: "object",
24030
- subtypes: {
24031
- call_id: { type: "uint32" },
24032
- target: {
24033
- type: "object",
24034
- subtypes: {
24035
- thunk_id: { type: "uint32" },
24036
- system_call_bundle: {
24037
- type: "object",
24038
- subtypes: {
24039
- contract_id: { type: "bytes", btype: "CONTRACT_ID" },
24040
- entry_point: { type: "uint32" },
24041
- },
24042
- },
24043
- },
24044
- },
24045
- },
24046
- },
24047
- set_system_contract: {
24048
- type: "object",
24049
- subtypes: {
24050
- contract_id: { type: "bytes", btype: "CONTRACT_ID" },
24051
- system_contract: { type: "bool" },
24052
- },
24053
- },
24054
- };
24055
23947
  /**
24056
23948
  * The Signer Class contains the private key needed to sign transactions.
24057
23949
  * It can be created using the seed, wif, or private key
@@ -24212,7 +24104,7 @@ class Signer {
24212
24104
  * // 5KEX4TMHG66fT7cM9HMZLmdp4hVq4LC4X2Fkg6zeypM5UteWmtd
24213
24105
  * ```
24214
24106
  */
24215
- getPrivateKey(format = "hex", compressed = false) {
24107
+ getPrivateKey(format = "hex", compressed = true) {
24216
24108
  let stringPrivateKey;
24217
24109
  if (this.privateKey instanceof Uint8Array) {
24218
24110
  stringPrivateKey = (0, utils_1.toHexString)(this.privateKey);
@@ -24477,81 +24369,6 @@ class Signer {
24477
24369
  const publicKeys = await this.recoverPublicKeys(txOrBlock, opts);
24478
24370
  return publicKeys.map((publicKey) => (0, utils_1.bitcoinAddress)((0, utils_1.toUint8Array)(publicKey)));
24479
24371
  }
24480
- /**
24481
- * Function to prepare a transaction
24482
- * @deprecated - Use [[Transaction.prepareTransaction]] instead.
24483
- * @param tx - Do not set the nonce to get it from the blockchain
24484
- * using the provider. The rc_limit is 1e8 by default.
24485
- * @returns A prepared transaction.
24486
- */
24487
- async prepareTransaction(tx) {
24488
- var _a, _b;
24489
- if (!tx.header) {
24490
- tx.header = {};
24491
- }
24492
- const payer = (_a = tx.header.payer) !== null && _a !== void 0 ? _a : this.address;
24493
- const { payee } = tx.header;
24494
- let nonce;
24495
- if (tx.header.nonce === undefined) {
24496
- if (!this.provider)
24497
- throw new Error("Cannot get the nonce because provider is undefined. To skip this call set a nonce in the transaction header");
24498
- nonce = await this.provider.getNextNonce(payee || payer);
24499
- }
24500
- else {
24501
- nonce = tx.header.nonce;
24502
- }
24503
- let rcLimit;
24504
- if (tx.header.rc_limit === undefined) {
24505
- if (!this.provider)
24506
- throw new Error("Cannot get the rc_limit because provider is undefined. To skip this call set a rc_limit in the transaction header");
24507
- rcLimit = await this.provider.getAccountRc(payer);
24508
- }
24509
- else {
24510
- rcLimit = tx.header.rc_limit;
24511
- }
24512
- let chainId = tx.header.chain_id || this.chainId;
24513
- if (!chainId) {
24514
- if (!this.provider)
24515
- throw new Error("Cannot get the chain_id because provider is undefined. To skip this call set a chain_id in the Signer");
24516
- chainId = await this.provider.getChainId();
24517
- this.chainId = chainId;
24518
- }
24519
- const operationsHashes = [];
24520
- if (tx.operations) {
24521
- for (let index = 0; index < ((_b = tx.operations) === null || _b === void 0 ? void 0 : _b.length); index += 1) {
24522
- const operationDecoded = (0, utils_1.btypeDecode)(tx.operations[index], btypesOperation, false);
24523
- const message = protocol_proto_js_1.koinos.protocol.operation.create(operationDecoded);
24524
- const operationEncoded = protocol_proto_js_1.koinos.protocol.operation
24525
- .encode(message)
24526
- .finish();
24527
- operationsHashes.push((0, sha256_1.sha256)(operationEncoded));
24528
- }
24529
- }
24530
- const operationMerkleRoot = (0, utils_1.encodeBase64url)(new Uint8Array([
24531
- // multihash sha256: 18, 32
24532
- 18,
24533
- 32,
24534
- ...(0, utils_1.calculateMerkleRoot)(operationsHashes),
24535
- ]));
24536
- tx.header = {
24537
- chain_id: chainId,
24538
- rc_limit: rcLimit,
24539
- nonce,
24540
- operation_merkle_root: operationMerkleRoot,
24541
- payer,
24542
- ...(payee && { payee }),
24543
- // TODO: Option to resolve names (payer, payee)
24544
- };
24545
- const headerDecoded = (0, utils_1.btypeDecode)(tx.header, btypeTransactionHeader, false);
24546
- const message = protocol_proto_js_1.koinos.protocol.transaction_header.create(headerDecoded);
24547
- const headerBytes = protocol_proto_js_1.koinos.protocol.transaction_header
24548
- .encode(message)
24549
- .finish();
24550
- const hash = (0, sha256_1.sha256)(headerBytes);
24551
- // multihash 0x1220. 12: code sha2-256. 20: length (32 bytes)
24552
- tx.id = `0x1220${(0, utils_1.toHexString)(hash)}`;
24553
- return tx;
24554
- }
24555
24372
  /**
24556
24373
  * Function to prepare a block
24557
24374
  * @param block -
@@ -24915,7 +24732,10 @@ class Transaction {
24915
24732
  };
24916
24733
  if (!this.transaction.id)
24917
24734
  await this.prepare();
24918
- if (this.signer && this.signer.provider) {
24735
+ if (!this.transaction.signatures || !this.transaction.signatures.length) {
24736
+ if (!this.signer) {
24737
+ throw new Error("transaction without signatures and no signer defined");
24738
+ }
24919
24739
  const { transaction: tx, receipt } = await this.signer.sendTransaction(this.transaction, opts);
24920
24740
  this.transaction = tx;
24921
24741
  this.waitFunction = tx.wait;
@@ -24923,9 +24743,6 @@ class Transaction {
24923
24743
  }
24924
24744
  if (!this.provider)
24925
24745
  throw new Error("provider not defined");
24926
- if (!this.transaction.signatures || !this.transaction.signatures.length) {
24927
- throw new Error("transaction without signatures and no signer defined");
24928
- }
24929
24746
  if (opts.beforeSend) {
24930
24747
  await opts.beforeSend(this.transaction, opts);
24931
24748
  }
@@ -25548,6 +25365,285 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
25548
25365
  */
25549
25366
  var protocol = {};
25550
25367
 
25368
+ protocol.object_space = (function () {
25369
+ /**
25370
+ * Properties of an object_space.
25371
+ * @memberof koinos.protocol
25372
+ * @interface Iobject_space
25373
+ * @property {boolean|null} [system] object_space system
25374
+ * @property {Uint8Array|null} [zone] object_space zone
25375
+ * @property {number|null} [id] object_space id
25376
+ */
25377
+
25378
+ /**
25379
+ * Constructs a new object_space.
25380
+ * @memberof koinos.protocol
25381
+ * @classdesc Represents an object_space.
25382
+ * @implements Iobject_space
25383
+ * @constructor
25384
+ * @param {koinos.protocol.Iobject_space=} [properties] Properties to set
25385
+ */
25386
+ function object_space(properties) {
25387
+ if (properties)
25388
+ for (
25389
+ var keys = Object.keys(properties), i = 0;
25390
+ i < keys.length;
25391
+ ++i
25392
+ )
25393
+ if (properties[keys[i]] != null)
25394
+ this[keys[i]] = properties[keys[i]];
25395
+ }
25396
+
25397
+ /**
25398
+ * object_space system.
25399
+ * @member {boolean} system
25400
+ * @memberof koinos.protocol.object_space
25401
+ * @instance
25402
+ */
25403
+ object_space.prototype.system = false;
25404
+
25405
+ /**
25406
+ * object_space zone.
25407
+ * @member {Uint8Array} zone
25408
+ * @memberof koinos.protocol.object_space
25409
+ * @instance
25410
+ */
25411
+ object_space.prototype.zone = $util.newBuffer([]);
25412
+
25413
+ /**
25414
+ * object_space id.
25415
+ * @member {number} id
25416
+ * @memberof koinos.protocol.object_space
25417
+ * @instance
25418
+ */
25419
+ object_space.prototype.id = 0;
25420
+
25421
+ /**
25422
+ * Creates a new object_space instance using the specified properties.
25423
+ * @function create
25424
+ * @memberof koinos.protocol.object_space
25425
+ * @static
25426
+ * @param {koinos.protocol.Iobject_space=} [properties] Properties to set
25427
+ * @returns {koinos.protocol.object_space} object_space instance
25428
+ */
25429
+ object_space.create = function create(properties) {
25430
+ return new object_space(properties);
25431
+ };
25432
+
25433
+ /**
25434
+ * Encodes the specified object_space message. Does not implicitly {@link koinos.protocol.object_space.verify|verify} messages.
25435
+ * @function encode
25436
+ * @memberof koinos.protocol.object_space
25437
+ * @static
25438
+ * @param {koinos.protocol.Iobject_space} message object_space message or plain object to encode
25439
+ * @param {$protobuf.Writer} [writer] Writer to encode to
25440
+ * @returns {$protobuf.Writer} Writer
25441
+ */
25442
+ object_space.encode = function encode(message, writer) {
25443
+ if (!writer) writer = $Writer.create();
25444
+ if (
25445
+ message.system != null &&
25446
+ Object.hasOwnProperty.call(message, "system")
25447
+ )
25448
+ writer.uint32(/* id 1, wireType 0 =*/ 8).bool(message.system);
25449
+ if (
25450
+ message.zone != null &&
25451
+ Object.hasOwnProperty.call(message, "zone")
25452
+ )
25453
+ writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.zone);
25454
+ if (message.id != null && Object.hasOwnProperty.call(message, "id"))
25455
+ writer.uint32(/* id 3, wireType 0 =*/ 24).uint32(message.id);
25456
+ return writer;
25457
+ };
25458
+
25459
+ /**
25460
+ * Encodes the specified object_space message, length delimited. Does not implicitly {@link koinos.protocol.object_space.verify|verify} messages.
25461
+ * @function encodeDelimited
25462
+ * @memberof koinos.protocol.object_space
25463
+ * @static
25464
+ * @param {koinos.protocol.Iobject_space} message object_space message or plain object to encode
25465
+ * @param {$protobuf.Writer} [writer] Writer to encode to
25466
+ * @returns {$protobuf.Writer} Writer
25467
+ */
25468
+ object_space.encodeDelimited = function encodeDelimited(
25469
+ message,
25470
+ writer
25471
+ ) {
25472
+ return this.encode(message, writer).ldelim();
25473
+ };
25474
+
25475
+ /**
25476
+ * Decodes an object_space message from the specified reader or buffer.
25477
+ * @function decode
25478
+ * @memberof koinos.protocol.object_space
25479
+ * @static
25480
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
25481
+ * @param {number} [length] Message length if known beforehand
25482
+ * @returns {koinos.protocol.object_space} object_space
25483
+ * @throws {Error} If the payload is not a reader or valid buffer
25484
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
25485
+ */
25486
+ object_space.decode = function decode(reader, length) {
25487
+ if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
25488
+ var end = length === undefined ? reader.len : reader.pos + length,
25489
+ message = new $root.koinos.protocol.object_space();
25490
+ while (reader.pos < end) {
25491
+ var tag = reader.uint32();
25492
+ switch (tag >>> 3) {
25493
+ case 1: {
25494
+ message.system = reader.bool();
25495
+ break;
25496
+ }
25497
+ case 2: {
25498
+ message.zone = reader.bytes();
25499
+ break;
25500
+ }
25501
+ case 3: {
25502
+ message.id = reader.uint32();
25503
+ break;
25504
+ }
25505
+ default:
25506
+ reader.skipType(tag & 7);
25507
+ break;
25508
+ }
25509
+ }
25510
+ return message;
25511
+ };
25512
+
25513
+ /**
25514
+ * Decodes an object_space message from the specified reader or buffer, length delimited.
25515
+ * @function decodeDelimited
25516
+ * @memberof koinos.protocol.object_space
25517
+ * @static
25518
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
25519
+ * @returns {koinos.protocol.object_space} object_space
25520
+ * @throws {Error} If the payload is not a reader or valid buffer
25521
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
25522
+ */
25523
+ object_space.decodeDelimited = function decodeDelimited(reader) {
25524
+ if (!(reader instanceof $Reader)) reader = new $Reader(reader);
25525
+ return this.decode(reader, reader.uint32());
25526
+ };
25527
+
25528
+ /**
25529
+ * Verifies an object_space message.
25530
+ * @function verify
25531
+ * @memberof koinos.protocol.object_space
25532
+ * @static
25533
+ * @param {Object.<string,*>} message Plain object to verify
25534
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
25535
+ */
25536
+ object_space.verify = function verify(message) {
25537
+ if (typeof message !== "object" || message === null)
25538
+ return "object expected";
25539
+ if (message.system != null && message.hasOwnProperty("system"))
25540
+ if (typeof message.system !== "boolean")
25541
+ return "system: boolean expected";
25542
+ if (message.zone != null && message.hasOwnProperty("zone"))
25543
+ if (
25544
+ !(
25545
+ (message.zone && typeof message.zone.length === "number") ||
25546
+ $util.isString(message.zone)
25547
+ )
25548
+ )
25549
+ return "zone: buffer expected";
25550
+ if (message.id != null && message.hasOwnProperty("id"))
25551
+ if (!$util.isInteger(message.id)) return "id: integer expected";
25552
+ return null;
25553
+ };
25554
+
25555
+ /**
25556
+ * Creates an object_space message from a plain object. Also converts values to their respective internal types.
25557
+ * @function fromObject
25558
+ * @memberof koinos.protocol.object_space
25559
+ * @static
25560
+ * @param {Object.<string,*>} object Plain object
25561
+ * @returns {koinos.protocol.object_space} object_space
25562
+ */
25563
+ object_space.fromObject = function fromObject(object) {
25564
+ if (object instanceof $root.koinos.protocol.object_space)
25565
+ return object;
25566
+ var message = new $root.koinos.protocol.object_space();
25567
+ if (object.system != null) message.system = Boolean(object.system);
25568
+ if (object.zone != null)
25569
+ if (typeof object.zone === "string")
25570
+ $util.base64.decode(
25571
+ object.zone,
25572
+ (message.zone = $util.newBuffer(
25573
+ $util.base64.length(object.zone)
25574
+ )),
25575
+ 0
25576
+ );
25577
+ else if (object.zone.length >= 0) message.zone = object.zone;
25578
+ if (object.id != null) message.id = object.id >>> 0;
25579
+ return message;
25580
+ };
25581
+
25582
+ /**
25583
+ * Creates a plain object from an object_space message. Also converts values to other types if specified.
25584
+ * @function toObject
25585
+ * @memberof koinos.protocol.object_space
25586
+ * @static
25587
+ * @param {koinos.protocol.object_space} message object_space
25588
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
25589
+ * @returns {Object.<string,*>} Plain object
25590
+ */
25591
+ object_space.toObject = function toObject(message, options) {
25592
+ if (!options) options = {};
25593
+ var object = {};
25594
+ if (options.defaults) {
25595
+ object.system = false;
25596
+ if (options.bytes === String) object.zone = "";
25597
+ else {
25598
+ object.zone = [];
25599
+ if (options.bytes !== Array)
25600
+ object.zone = $util.newBuffer(object.zone);
25601
+ }
25602
+ object.id = 0;
25603
+ }
25604
+ if (message.system != null && message.hasOwnProperty("system"))
25605
+ object.system = message.system;
25606
+ if (message.zone != null && message.hasOwnProperty("zone"))
25607
+ object.zone =
25608
+ options.bytes === String
25609
+ ? $util.base64.encode(message.zone, 0, message.zone.length)
25610
+ : options.bytes === Array
25611
+ ? Array.prototype.slice.call(message.zone)
25612
+ : message.zone;
25613
+ if (message.id != null && message.hasOwnProperty("id"))
25614
+ object.id = message.id;
25615
+ return object;
25616
+ };
25617
+
25618
+ /**
25619
+ * Converts this object_space to JSON.
25620
+ * @function toJSON
25621
+ * @memberof koinos.protocol.object_space
25622
+ * @instance
25623
+ * @returns {Object.<string,*>} JSON object
25624
+ */
25625
+ object_space.prototype.toJSON = function toJSON() {
25626
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
25627
+ };
25628
+
25629
+ /**
25630
+ * Gets the default type url for object_space
25631
+ * @function getTypeUrl
25632
+ * @memberof koinos.protocol.object_space
25633
+ * @static
25634
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
25635
+ * @returns {string} The default type url
25636
+ */
25637
+ object_space.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
25638
+ if (typeUrlPrefix === undefined) {
25639
+ typeUrlPrefix = "type.googleapis.com";
25640
+ }
25641
+ return typeUrlPrefix + "/koinos.protocol.object_space";
25642
+ };
25643
+
25644
+ return object_space;
25645
+ })();
25646
+
25551
25647
  protocol.event_data = (function () {
25552
25648
  /**
25553
25649
  * Properties of an event_data.
@@ -29252,6 +29348,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29252
29348
  * @property {boolean|null} [reverted] transaction_receipt reverted
29253
29349
  * @property {Array.<koinos.protocol.Ievent_data>|null} [events] transaction_receipt events
29254
29350
  * @property {Array.<string>|null} [logs] transaction_receipt logs
29351
+ * @property {Array.<koinos.protocol.Istate_delta_entry>|null} [state_delta_entries] transaction_receipt state_delta_entries
29255
29352
  */
29256
29353
 
29257
29354
  /**
@@ -29265,6 +29362,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29265
29362
  function transaction_receipt(properties) {
29266
29363
  this.events = [];
29267
29364
  this.logs = [];
29365
+ this.state_delta_entries = [];
29268
29366
  if (properties)
29269
29367
  for (
29270
29368
  var keys = Object.keys(properties), i = 0;
@@ -29375,6 +29473,14 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29375
29473
  */
29376
29474
  transaction_receipt.prototype.logs = $util.emptyArray;
29377
29475
 
29476
+ /**
29477
+ * transaction_receipt state_delta_entries.
29478
+ * @member {Array.<koinos.protocol.Istate_delta_entry>} state_delta_entries
29479
+ * @memberof koinos.protocol.transaction_receipt
29480
+ * @instance
29481
+ */
29482
+ transaction_receipt.prototype.state_delta_entries = $util.emptyArray;
29483
+
29378
29484
  /**
29379
29485
  * Creates a new transaction_receipt instance using the specified properties.
29380
29486
  * @function create
@@ -29461,6 +29567,17 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29461
29567
  writer
29462
29568
  .uint32(/* id 11, wireType 2 =*/ 90)
29463
29569
  .string(message.logs[i]);
29570
+ if (
29571
+ message.state_delta_entries != null &&
29572
+ message.state_delta_entries.length
29573
+ )
29574
+ for (var i = 0; i < message.state_delta_entries.length; ++i)
29575
+ $root.koinos.protocol.state_delta_entry
29576
+ .encode(
29577
+ message.state_delta_entries[i],
29578
+ writer.uint32(/* id 12, wireType 2 =*/ 98).fork()
29579
+ )
29580
+ .ldelim();
29464
29581
  return writer;
29465
29582
  };
29466
29583
 
@@ -29550,6 +29667,22 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29550
29667
  message.logs.push(reader.string());
29551
29668
  break;
29552
29669
  }
29670
+ case 12: {
29671
+ if (
29672
+ !(
29673
+ message.state_delta_entries &&
29674
+ message.state_delta_entries.length
29675
+ )
29676
+ )
29677
+ message.state_delta_entries = [];
29678
+ message.state_delta_entries.push(
29679
+ $root.koinos.protocol.state_delta_entry.decode(
29680
+ reader,
29681
+ reader.uint32()
29682
+ )
29683
+ );
29684
+ break;
29685
+ }
29553
29686
  default:
29554
29687
  reader.skipType(tag & 7);
29555
29688
  break;
@@ -29690,6 +29823,19 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29690
29823
  if (!$util.isString(message.logs[i]))
29691
29824
  return "logs: string[] expected";
29692
29825
  }
29826
+ if (
29827
+ message.state_delta_entries != null &&
29828
+ message.hasOwnProperty("state_delta_entries")
29829
+ ) {
29830
+ if (!Array.isArray(message.state_delta_entries))
29831
+ return "state_delta_entries: array expected";
29832
+ for (var i = 0; i < message.state_delta_entries.length; ++i) {
29833
+ var error = $root.koinos.protocol.state_delta_entry.verify(
29834
+ message.state_delta_entries[i]
29835
+ );
29836
+ if (error) return "state_delta_entries." + error;
29837
+ }
29838
+ }
29693
29839
  return null;
29694
29840
  };
29695
29841
 
@@ -29843,6 +29989,23 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29843
29989
  for (var i = 0; i < object.logs.length; ++i)
29844
29990
  message.logs[i] = String(object.logs[i]);
29845
29991
  }
29992
+ if (object.state_delta_entries) {
29993
+ if (!Array.isArray(object.state_delta_entries))
29994
+ throw TypeError(
29995
+ ".koinos.protocol.transaction_receipt.state_delta_entries: array expected"
29996
+ );
29997
+ message.state_delta_entries = [];
29998
+ for (var i = 0; i < object.state_delta_entries.length; ++i) {
29999
+ if (typeof object.state_delta_entries[i] !== "object")
30000
+ throw TypeError(
30001
+ ".koinos.protocol.transaction_receipt.state_delta_entries: object expected"
30002
+ );
30003
+ message.state_delta_entries[i] =
30004
+ $root.koinos.protocol.state_delta_entry.fromObject(
30005
+ object.state_delta_entries[i]
30006
+ );
30007
+ }
30008
+ }
29846
30009
  return message;
29847
30010
  };
29848
30011
 
@@ -29861,6 +30024,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
29861
30024
  if (options.arrays || options.defaults) {
29862
30025
  object.events = [];
29863
30026
  object.logs = [];
30027
+ object.state_delta_entries = [];
29864
30028
  }
29865
30029
  if (options.defaults) {
29866
30030
  if (options.bytes === String) object.id = "";
@@ -30079,6 +30243,18 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
30079
30243
  for (var j = 0; j < message.logs.length; ++j)
30080
30244
  object.logs[j] = message.logs[j];
30081
30245
  }
30246
+ if (
30247
+ message.state_delta_entries &&
30248
+ message.state_delta_entries.length
30249
+ ) {
30250
+ object.state_delta_entries = [];
30251
+ for (var j = 0; j < message.state_delta_entries.length; ++j)
30252
+ object.state_delta_entries[j] =
30253
+ $root.koinos.protocol.state_delta_entry.toObject(
30254
+ message.state_delta_entries[j],
30255
+ options
30256
+ );
30257
+ }
30082
30258
  return object;
30083
30259
  };
30084
30260
 
@@ -31156,6 +31332,10 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31156
31332
  * @property {Array.<koinos.protocol.Ievent_data>|null} [events] block_receipt events
31157
31333
  * @property {Array.<koinos.protocol.Itransaction_receipt>|null} [transaction_receipts] block_receipt transaction_receipts
31158
31334
  * @property {Array.<string>|null} [logs] block_receipt logs
31335
+ * @property {number|Long|null} [disk_storage_charged] block_receipt disk_storage_charged
31336
+ * @property {number|Long|null} [network_bandwidth_charged] block_receipt network_bandwidth_charged
31337
+ * @property {number|Long|null} [compute_bandwidth_charged] block_receipt compute_bandwidth_charged
31338
+ * @property {Array.<koinos.protocol.Istate_delta_entry>|null} [state_delta_entries] block_receipt state_delta_entries
31159
31339
  */
31160
31340
 
31161
31341
  /**
@@ -31170,6 +31350,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31170
31350
  this.events = [];
31171
31351
  this.transaction_receipts = [];
31172
31352
  this.logs = [];
31353
+ this.state_delta_entries = [];
31173
31354
  if (properties)
31174
31355
  for (
31175
31356
  var keys = Object.keys(properties), i = 0;
@@ -31260,6 +31441,44 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31260
31441
  */
31261
31442
  block_receipt.prototype.logs = $util.emptyArray;
31262
31443
 
31444
+ /**
31445
+ * block_receipt disk_storage_charged.
31446
+ * @member {number|Long} disk_storage_charged
31447
+ * @memberof koinos.protocol.block_receipt
31448
+ * @instance
31449
+ */
31450
+ block_receipt.prototype.disk_storage_charged = $util.Long
31451
+ ? $util.Long.fromBits(0, 0, true)
31452
+ : 0;
31453
+
31454
+ /**
31455
+ * block_receipt network_bandwidth_charged.
31456
+ * @member {number|Long} network_bandwidth_charged
31457
+ * @memberof koinos.protocol.block_receipt
31458
+ * @instance
31459
+ */
31460
+ block_receipt.prototype.network_bandwidth_charged = $util.Long
31461
+ ? $util.Long.fromBits(0, 0, true)
31462
+ : 0;
31463
+
31464
+ /**
31465
+ * block_receipt compute_bandwidth_charged.
31466
+ * @member {number|Long} compute_bandwidth_charged
31467
+ * @memberof koinos.protocol.block_receipt
31468
+ * @instance
31469
+ */
31470
+ block_receipt.prototype.compute_bandwidth_charged = $util.Long
31471
+ ? $util.Long.fromBits(0, 0, true)
31472
+ : 0;
31473
+
31474
+ /**
31475
+ * block_receipt state_delta_entries.
31476
+ * @member {Array.<koinos.protocol.Istate_delta_entry>} state_delta_entries
31477
+ * @memberof koinos.protocol.block_receipt
31478
+ * @instance
31479
+ */
31480
+ block_receipt.prototype.state_delta_entries = $util.emptyArray;
31481
+
31263
31482
  /**
31264
31483
  * Creates a new block_receipt instance using the specified properties.
31265
31484
  * @function create
@@ -31340,6 +31559,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31340
31559
  if (message.logs != null && message.logs.length)
31341
31560
  for (var i = 0; i < message.logs.length; ++i)
31342
31561
  writer.uint32(/* id 9, wireType 2 =*/ 74).string(message.logs[i]);
31562
+ if (
31563
+ message.disk_storage_charged != null &&
31564
+ Object.hasOwnProperty.call(message, "disk_storage_charged")
31565
+ )
31566
+ writer
31567
+ .uint32(/* id 10, wireType 0 =*/ 80)
31568
+ .uint64(message.disk_storage_charged);
31569
+ if (
31570
+ message.network_bandwidth_charged != null &&
31571
+ Object.hasOwnProperty.call(message, "network_bandwidth_charged")
31572
+ )
31573
+ writer
31574
+ .uint32(/* id 11, wireType 0 =*/ 88)
31575
+ .uint64(message.network_bandwidth_charged);
31576
+ if (
31577
+ message.compute_bandwidth_charged != null &&
31578
+ Object.hasOwnProperty.call(message, "compute_bandwidth_charged")
31579
+ )
31580
+ writer
31581
+ .uint32(/* id 12, wireType 0 =*/ 96)
31582
+ .uint64(message.compute_bandwidth_charged);
31583
+ if (
31584
+ message.state_delta_entries != null &&
31585
+ message.state_delta_entries.length
31586
+ )
31587
+ for (var i = 0; i < message.state_delta_entries.length; ++i)
31588
+ $root.koinos.protocol.state_delta_entry
31589
+ .encode(
31590
+ message.state_delta_entries[i],
31591
+ writer.uint32(/* id 13, wireType 2 =*/ 106).fork()
31592
+ )
31593
+ .ldelim();
31343
31594
  return writer;
31344
31595
  };
31345
31596
 
@@ -31433,6 +31684,34 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31433
31684
  message.logs.push(reader.string());
31434
31685
  break;
31435
31686
  }
31687
+ case 10: {
31688
+ message.disk_storage_charged = reader.uint64();
31689
+ break;
31690
+ }
31691
+ case 11: {
31692
+ message.network_bandwidth_charged = reader.uint64();
31693
+ break;
31694
+ }
31695
+ case 12: {
31696
+ message.compute_bandwidth_charged = reader.uint64();
31697
+ break;
31698
+ }
31699
+ case 13: {
31700
+ if (
31701
+ !(
31702
+ message.state_delta_entries &&
31703
+ message.state_delta_entries.length
31704
+ )
31705
+ )
31706
+ message.state_delta_entries = [];
31707
+ message.state_delta_entries.push(
31708
+ $root.koinos.protocol.state_delta_entry.decode(
31709
+ reader,
31710
+ reader.uint32()
31711
+ )
31712
+ );
31713
+ break;
31714
+ }
31436
31715
  default:
31437
31716
  reader.skipType(tag & 7);
31438
31717
  break;
@@ -31564,6 +31843,58 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31564
31843
  if (!$util.isString(message.logs[i]))
31565
31844
  return "logs: string[] expected";
31566
31845
  }
31846
+ if (
31847
+ message.disk_storage_charged != null &&
31848
+ message.hasOwnProperty("disk_storage_charged")
31849
+ )
31850
+ if (
31851
+ !$util.isInteger(message.disk_storage_charged) &&
31852
+ !(
31853
+ message.disk_storage_charged &&
31854
+ $util.isInteger(message.disk_storage_charged.low) &&
31855
+ $util.isInteger(message.disk_storage_charged.high)
31856
+ )
31857
+ )
31858
+ return "disk_storage_charged: integer|Long expected";
31859
+ if (
31860
+ message.network_bandwidth_charged != null &&
31861
+ message.hasOwnProperty("network_bandwidth_charged")
31862
+ )
31863
+ if (
31864
+ !$util.isInteger(message.network_bandwidth_charged) &&
31865
+ !(
31866
+ message.network_bandwidth_charged &&
31867
+ $util.isInteger(message.network_bandwidth_charged.low) &&
31868
+ $util.isInteger(message.network_bandwidth_charged.high)
31869
+ )
31870
+ )
31871
+ return "network_bandwidth_charged: integer|Long expected";
31872
+ if (
31873
+ message.compute_bandwidth_charged != null &&
31874
+ message.hasOwnProperty("compute_bandwidth_charged")
31875
+ )
31876
+ if (
31877
+ !$util.isInteger(message.compute_bandwidth_charged) &&
31878
+ !(
31879
+ message.compute_bandwidth_charged &&
31880
+ $util.isInteger(message.compute_bandwidth_charged.low) &&
31881
+ $util.isInteger(message.compute_bandwidth_charged.high)
31882
+ )
31883
+ )
31884
+ return "compute_bandwidth_charged: integer|Long expected";
31885
+ if (
31886
+ message.state_delta_entries != null &&
31887
+ message.hasOwnProperty("state_delta_entries")
31888
+ ) {
31889
+ if (!Array.isArray(message.state_delta_entries))
31890
+ return "state_delta_entries: array expected";
31891
+ for (var i = 0; i < message.state_delta_entries.length; ++i) {
31892
+ var error = $root.koinos.protocol.state_delta_entry.verify(
31893
+ message.state_delta_entries[i]
31894
+ );
31895
+ if (error) return "state_delta_entries." + error;
31896
+ }
31897
+ }
31567
31898
  return null;
31568
31899
  };
31569
31900
 
@@ -31705,6 +32036,76 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31705
32036
  for (var i = 0; i < object.logs.length; ++i)
31706
32037
  message.logs[i] = String(object.logs[i]);
31707
32038
  }
32039
+ if (object.disk_storage_charged != null)
32040
+ if ($util.Long)
32041
+ (message.disk_storage_charged = $util.Long.fromValue(
32042
+ object.disk_storage_charged
32043
+ )).unsigned = true;
32044
+ else if (typeof object.disk_storage_charged === "string")
32045
+ message.disk_storage_charged = parseInt(
32046
+ object.disk_storage_charged,
32047
+ 10
32048
+ );
32049
+ else if (typeof object.disk_storage_charged === "number")
32050
+ message.disk_storage_charged = object.disk_storage_charged;
32051
+ else if (typeof object.disk_storage_charged === "object")
32052
+ message.disk_storage_charged = new $util.LongBits(
32053
+ object.disk_storage_charged.low >>> 0,
32054
+ object.disk_storage_charged.high >>> 0
32055
+ ).toNumber(true);
32056
+ if (object.network_bandwidth_charged != null)
32057
+ if ($util.Long)
32058
+ (message.network_bandwidth_charged = $util.Long.fromValue(
32059
+ object.network_bandwidth_charged
32060
+ )).unsigned = true;
32061
+ else if (typeof object.network_bandwidth_charged === "string")
32062
+ message.network_bandwidth_charged = parseInt(
32063
+ object.network_bandwidth_charged,
32064
+ 10
32065
+ );
32066
+ else if (typeof object.network_bandwidth_charged === "number")
32067
+ message.network_bandwidth_charged =
32068
+ object.network_bandwidth_charged;
32069
+ else if (typeof object.network_bandwidth_charged === "object")
32070
+ message.network_bandwidth_charged = new $util.LongBits(
32071
+ object.network_bandwidth_charged.low >>> 0,
32072
+ object.network_bandwidth_charged.high >>> 0
32073
+ ).toNumber(true);
32074
+ if (object.compute_bandwidth_charged != null)
32075
+ if ($util.Long)
32076
+ (message.compute_bandwidth_charged = $util.Long.fromValue(
32077
+ object.compute_bandwidth_charged
32078
+ )).unsigned = true;
32079
+ else if (typeof object.compute_bandwidth_charged === "string")
32080
+ message.compute_bandwidth_charged = parseInt(
32081
+ object.compute_bandwidth_charged,
32082
+ 10
32083
+ );
32084
+ else if (typeof object.compute_bandwidth_charged === "number")
32085
+ message.compute_bandwidth_charged =
32086
+ object.compute_bandwidth_charged;
32087
+ else if (typeof object.compute_bandwidth_charged === "object")
32088
+ message.compute_bandwidth_charged = new $util.LongBits(
32089
+ object.compute_bandwidth_charged.low >>> 0,
32090
+ object.compute_bandwidth_charged.high >>> 0
32091
+ ).toNumber(true);
32092
+ if (object.state_delta_entries) {
32093
+ if (!Array.isArray(object.state_delta_entries))
32094
+ throw TypeError(
32095
+ ".koinos.protocol.block_receipt.state_delta_entries: array expected"
32096
+ );
32097
+ message.state_delta_entries = [];
32098
+ for (var i = 0; i < object.state_delta_entries.length; ++i) {
32099
+ if (typeof object.state_delta_entries[i] !== "object")
32100
+ throw TypeError(
32101
+ ".koinos.protocol.block_receipt.state_delta_entries: object expected"
32102
+ );
32103
+ message.state_delta_entries[i] =
32104
+ $root.koinos.protocol.state_delta_entry.fromObject(
32105
+ object.state_delta_entries[i]
32106
+ );
32107
+ }
32108
+ }
31708
32109
  return message;
31709
32110
  };
31710
32111
 
@@ -31724,6 +32125,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31724
32125
  object.events = [];
31725
32126
  object.transaction_receipts = [];
31726
32127
  object.logs = [];
32128
+ object.state_delta_entries = [];
31727
32129
  }
31728
32130
  if (options.defaults) {
31729
32131
  if (options.bytes === String) object.id = "";
@@ -31781,6 +32183,38 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31781
32183
  object.state_merkle_root
31782
32184
  );
31783
32185
  }
32186
+ if ($util.Long) {
32187
+ var long = new $util.Long(0, 0, true);
32188
+ object.disk_storage_charged =
32189
+ options.longs === String
32190
+ ? long.toString()
32191
+ : options.longs === Number
32192
+ ? long.toNumber()
32193
+ : long;
32194
+ } else
32195
+ object.disk_storage_charged = options.longs === String ? "0" : 0;
32196
+ if ($util.Long) {
32197
+ var long = new $util.Long(0, 0, true);
32198
+ object.network_bandwidth_charged =
32199
+ options.longs === String
32200
+ ? long.toString()
32201
+ : options.longs === Number
32202
+ ? long.toNumber()
32203
+ : long;
32204
+ } else
32205
+ object.network_bandwidth_charged =
32206
+ options.longs === String ? "0" : 0;
32207
+ if ($util.Long) {
32208
+ var long = new $util.Long(0, 0, true);
32209
+ object.compute_bandwidth_charged =
32210
+ options.longs === String
32211
+ ? long.toString()
32212
+ : options.longs === Number
32213
+ ? long.toNumber()
32214
+ : long;
32215
+ } else
32216
+ object.compute_bandwidth_charged =
32217
+ options.longs === String ? "0" : 0;
31784
32218
  }
31785
32219
  if (message.id != null && message.hasOwnProperty("id"))
31786
32220
  object.id =
@@ -31907,6 +32341,81 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31907
32341
  for (var j = 0; j < message.logs.length; ++j)
31908
32342
  object.logs[j] = message.logs[j];
31909
32343
  }
32344
+ if (
32345
+ message.disk_storage_charged != null &&
32346
+ message.hasOwnProperty("disk_storage_charged")
32347
+ )
32348
+ if (typeof message.disk_storage_charged === "number")
32349
+ object.disk_storage_charged =
32350
+ options.longs === String
32351
+ ? String(message.disk_storage_charged)
32352
+ : message.disk_storage_charged;
32353
+ else
32354
+ object.disk_storage_charged =
32355
+ options.longs === String
32356
+ ? $util.Long.prototype.toString.call(
32357
+ message.disk_storage_charged
32358
+ )
32359
+ : options.longs === Number
32360
+ ? new $util.LongBits(
32361
+ message.disk_storage_charged.low >>> 0,
32362
+ message.disk_storage_charged.high >>> 0
32363
+ ).toNumber(true)
32364
+ : message.disk_storage_charged;
32365
+ if (
32366
+ message.network_bandwidth_charged != null &&
32367
+ message.hasOwnProperty("network_bandwidth_charged")
32368
+ )
32369
+ if (typeof message.network_bandwidth_charged === "number")
32370
+ object.network_bandwidth_charged =
32371
+ options.longs === String
32372
+ ? String(message.network_bandwidth_charged)
32373
+ : message.network_bandwidth_charged;
32374
+ else
32375
+ object.network_bandwidth_charged =
32376
+ options.longs === String
32377
+ ? $util.Long.prototype.toString.call(
32378
+ message.network_bandwidth_charged
32379
+ )
32380
+ : options.longs === Number
32381
+ ? new $util.LongBits(
32382
+ message.network_bandwidth_charged.low >>> 0,
32383
+ message.network_bandwidth_charged.high >>> 0
32384
+ ).toNumber(true)
32385
+ : message.network_bandwidth_charged;
32386
+ if (
32387
+ message.compute_bandwidth_charged != null &&
32388
+ message.hasOwnProperty("compute_bandwidth_charged")
32389
+ )
32390
+ if (typeof message.compute_bandwidth_charged === "number")
32391
+ object.compute_bandwidth_charged =
32392
+ options.longs === String
32393
+ ? String(message.compute_bandwidth_charged)
32394
+ : message.compute_bandwidth_charged;
32395
+ else
32396
+ object.compute_bandwidth_charged =
32397
+ options.longs === String
32398
+ ? $util.Long.prototype.toString.call(
32399
+ message.compute_bandwidth_charged
32400
+ )
32401
+ : options.longs === Number
32402
+ ? new $util.LongBits(
32403
+ message.compute_bandwidth_charged.low >>> 0,
32404
+ message.compute_bandwidth_charged.high >>> 0
32405
+ ).toNumber(true)
32406
+ : message.compute_bandwidth_charged;
32407
+ if (
32408
+ message.state_delta_entries &&
32409
+ message.state_delta_entries.length
32410
+ ) {
32411
+ object.state_delta_entries = [];
32412
+ for (var j = 0; j < message.state_delta_entries.length; ++j)
32413
+ object.state_delta_entries[j] =
32414
+ $root.koinos.protocol.state_delta_entry.toObject(
32415
+ message.state_delta_entries[j],
32416
+ options
32417
+ );
32418
+ }
31910
32419
  return object;
31911
32420
  };
31912
32421
 
@@ -31939,6 +32448,353 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
31939
32448
  return block_receipt;
31940
32449
  })();
31941
32450
 
32451
+ protocol.state_delta_entry = (function () {
32452
+ /**
32453
+ * Properties of a state_delta_entry.
32454
+ * @memberof koinos.protocol
32455
+ * @interface Istate_delta_entry
32456
+ * @property {koinos.protocol.Iobject_space|null} [object_space] state_delta_entry object_space
32457
+ * @property {Uint8Array|null} [key] state_delta_entry key
32458
+ * @property {Uint8Array|null} [value] state_delta_entry value
32459
+ */
32460
+
32461
+ /**
32462
+ * Constructs a new state_delta_entry.
32463
+ * @memberof koinos.protocol
32464
+ * @classdesc Represents a state_delta_entry.
32465
+ * @implements Istate_delta_entry
32466
+ * @constructor
32467
+ * @param {koinos.protocol.Istate_delta_entry=} [properties] Properties to set
32468
+ */
32469
+ function state_delta_entry(properties) {
32470
+ if (properties)
32471
+ for (
32472
+ var keys = Object.keys(properties), i = 0;
32473
+ i < keys.length;
32474
+ ++i
32475
+ )
32476
+ if (properties[keys[i]] != null)
32477
+ this[keys[i]] = properties[keys[i]];
32478
+ }
32479
+
32480
+ /**
32481
+ * state_delta_entry object_space.
32482
+ * @member {koinos.protocol.Iobject_space|null|undefined} object_space
32483
+ * @memberof koinos.protocol.state_delta_entry
32484
+ * @instance
32485
+ */
32486
+ state_delta_entry.prototype.object_space = null;
32487
+
32488
+ /**
32489
+ * state_delta_entry key.
32490
+ * @member {Uint8Array} key
32491
+ * @memberof koinos.protocol.state_delta_entry
32492
+ * @instance
32493
+ */
32494
+ state_delta_entry.prototype.key = $util.newBuffer([]);
32495
+
32496
+ /**
32497
+ * state_delta_entry value.
32498
+ * @member {Uint8Array|null|undefined} value
32499
+ * @memberof koinos.protocol.state_delta_entry
32500
+ * @instance
32501
+ */
32502
+ state_delta_entry.prototype.value = null;
32503
+
32504
+ // OneOf field names bound to virtual getters and setters
32505
+ var $oneOfFields;
32506
+
32507
+ /**
32508
+ * state_delta_entry _value.
32509
+ * @member {"value"|undefined} _value
32510
+ * @memberof koinos.protocol.state_delta_entry
32511
+ * @instance
32512
+ */
32513
+ Object.defineProperty(state_delta_entry.prototype, "_value", {
32514
+ get: $util.oneOfGetter(($oneOfFields = ["value"])),
32515
+ set: $util.oneOfSetter($oneOfFields),
32516
+ });
32517
+
32518
+ /**
32519
+ * Creates a new state_delta_entry instance using the specified properties.
32520
+ * @function create
32521
+ * @memberof koinos.protocol.state_delta_entry
32522
+ * @static
32523
+ * @param {koinos.protocol.Istate_delta_entry=} [properties] Properties to set
32524
+ * @returns {koinos.protocol.state_delta_entry} state_delta_entry instance
32525
+ */
32526
+ state_delta_entry.create = function create(properties) {
32527
+ return new state_delta_entry(properties);
32528
+ };
32529
+
32530
+ /**
32531
+ * Encodes the specified state_delta_entry message. Does not implicitly {@link koinos.protocol.state_delta_entry.verify|verify} messages.
32532
+ * @function encode
32533
+ * @memberof koinos.protocol.state_delta_entry
32534
+ * @static
32535
+ * @param {koinos.protocol.Istate_delta_entry} message state_delta_entry message or plain object to encode
32536
+ * @param {$protobuf.Writer} [writer] Writer to encode to
32537
+ * @returns {$protobuf.Writer} Writer
32538
+ */
32539
+ state_delta_entry.encode = function encode(message, writer) {
32540
+ if (!writer) writer = $Writer.create();
32541
+ if (
32542
+ message.object_space != null &&
32543
+ Object.hasOwnProperty.call(message, "object_space")
32544
+ )
32545
+ $root.koinos.protocol.object_space
32546
+ .encode(
32547
+ message.object_space,
32548
+ writer.uint32(/* id 1, wireType 2 =*/ 10).fork()
32549
+ )
32550
+ .ldelim();
32551
+ if (message.key != null && Object.hasOwnProperty.call(message, "key"))
32552
+ writer.uint32(/* id 2, wireType 2 =*/ 18).bytes(message.key);
32553
+ if (
32554
+ message.value != null &&
32555
+ Object.hasOwnProperty.call(message, "value")
32556
+ )
32557
+ writer.uint32(/* id 3, wireType 2 =*/ 26).bytes(message.value);
32558
+ return writer;
32559
+ };
32560
+
32561
+ /**
32562
+ * Encodes the specified state_delta_entry message, length delimited. Does not implicitly {@link koinos.protocol.state_delta_entry.verify|verify} messages.
32563
+ * @function encodeDelimited
32564
+ * @memberof koinos.protocol.state_delta_entry
32565
+ * @static
32566
+ * @param {koinos.protocol.Istate_delta_entry} message state_delta_entry message or plain object to encode
32567
+ * @param {$protobuf.Writer} [writer] Writer to encode to
32568
+ * @returns {$protobuf.Writer} Writer
32569
+ */
32570
+ state_delta_entry.encodeDelimited = function encodeDelimited(
32571
+ message,
32572
+ writer
32573
+ ) {
32574
+ return this.encode(message, writer).ldelim();
32575
+ };
32576
+
32577
+ /**
32578
+ * Decodes a state_delta_entry message from the specified reader or buffer.
32579
+ * @function decode
32580
+ * @memberof koinos.protocol.state_delta_entry
32581
+ * @static
32582
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
32583
+ * @param {number} [length] Message length if known beforehand
32584
+ * @returns {koinos.protocol.state_delta_entry} state_delta_entry
32585
+ * @throws {Error} If the payload is not a reader or valid buffer
32586
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
32587
+ */
32588
+ state_delta_entry.decode = function decode(reader, length) {
32589
+ if (!(reader instanceof $Reader)) reader = $Reader.create(reader);
32590
+ var end = length === undefined ? reader.len : reader.pos + length,
32591
+ message = new $root.koinos.protocol.state_delta_entry();
32592
+ while (reader.pos < end) {
32593
+ var tag = reader.uint32();
32594
+ switch (tag >>> 3) {
32595
+ case 1: {
32596
+ message.object_space =
32597
+ $root.koinos.protocol.object_space.decode(
32598
+ reader,
32599
+ reader.uint32()
32600
+ );
32601
+ break;
32602
+ }
32603
+ case 2: {
32604
+ message.key = reader.bytes();
32605
+ break;
32606
+ }
32607
+ case 3: {
32608
+ message.value = reader.bytes();
32609
+ break;
32610
+ }
32611
+ default:
32612
+ reader.skipType(tag & 7);
32613
+ break;
32614
+ }
32615
+ }
32616
+ return message;
32617
+ };
32618
+
32619
+ /**
32620
+ * Decodes a state_delta_entry message from the specified reader or buffer, length delimited.
32621
+ * @function decodeDelimited
32622
+ * @memberof koinos.protocol.state_delta_entry
32623
+ * @static
32624
+ * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from
32625
+ * @returns {koinos.protocol.state_delta_entry} state_delta_entry
32626
+ * @throws {Error} If the payload is not a reader or valid buffer
32627
+ * @throws {$protobuf.util.ProtocolError} If required fields are missing
32628
+ */
32629
+ state_delta_entry.decodeDelimited = function decodeDelimited(reader) {
32630
+ if (!(reader instanceof $Reader)) reader = new $Reader(reader);
32631
+ return this.decode(reader, reader.uint32());
32632
+ };
32633
+
32634
+ /**
32635
+ * Verifies a state_delta_entry message.
32636
+ * @function verify
32637
+ * @memberof koinos.protocol.state_delta_entry
32638
+ * @static
32639
+ * @param {Object.<string,*>} message Plain object to verify
32640
+ * @returns {string|null} `null` if valid, otherwise the reason why it is not
32641
+ */
32642
+ state_delta_entry.verify = function verify(message) {
32643
+ if (typeof message !== "object" || message === null)
32644
+ return "object expected";
32645
+ var properties = {};
32646
+ if (
32647
+ message.object_space != null &&
32648
+ message.hasOwnProperty("object_space")
32649
+ ) {
32650
+ var error = $root.koinos.protocol.object_space.verify(
32651
+ message.object_space
32652
+ );
32653
+ if (error) return "object_space." + error;
32654
+ }
32655
+ if (message.key != null && message.hasOwnProperty("key"))
32656
+ if (
32657
+ !(
32658
+ (message.key && typeof message.key.length === "number") ||
32659
+ $util.isString(message.key)
32660
+ )
32661
+ )
32662
+ return "key: buffer expected";
32663
+ if (message.value != null && message.hasOwnProperty("value")) {
32664
+ properties._value = 1;
32665
+ if (
32666
+ !(
32667
+ (message.value && typeof message.value.length === "number") ||
32668
+ $util.isString(message.value)
32669
+ )
32670
+ )
32671
+ return "value: buffer expected";
32672
+ }
32673
+ return null;
32674
+ };
32675
+
32676
+ /**
32677
+ * Creates a state_delta_entry message from a plain object. Also converts values to their respective internal types.
32678
+ * @function fromObject
32679
+ * @memberof koinos.protocol.state_delta_entry
32680
+ * @static
32681
+ * @param {Object.<string,*>} object Plain object
32682
+ * @returns {koinos.protocol.state_delta_entry} state_delta_entry
32683
+ */
32684
+ state_delta_entry.fromObject = function fromObject(object) {
32685
+ if (object instanceof $root.koinos.protocol.state_delta_entry)
32686
+ return object;
32687
+ var message = new $root.koinos.protocol.state_delta_entry();
32688
+ if (object.object_space != null) {
32689
+ if (typeof object.object_space !== "object")
32690
+ throw TypeError(
32691
+ ".koinos.protocol.state_delta_entry.object_space: object expected"
32692
+ );
32693
+ message.object_space =
32694
+ $root.koinos.protocol.object_space.fromObject(
32695
+ object.object_space
32696
+ );
32697
+ }
32698
+ if (object.key != null)
32699
+ if (typeof object.key === "string")
32700
+ $util.base64.decode(
32701
+ object.key,
32702
+ (message.key = $util.newBuffer(
32703
+ $util.base64.length(object.key)
32704
+ )),
32705
+ 0
32706
+ );
32707
+ else if (object.key.length >= 0) message.key = object.key;
32708
+ if (object.value != null)
32709
+ if (typeof object.value === "string")
32710
+ $util.base64.decode(
32711
+ object.value,
32712
+ (message.value = $util.newBuffer(
32713
+ $util.base64.length(object.value)
32714
+ )),
32715
+ 0
32716
+ );
32717
+ else if (object.value.length >= 0) message.value = object.value;
32718
+ return message;
32719
+ };
32720
+
32721
+ /**
32722
+ * Creates a plain object from a state_delta_entry message. Also converts values to other types if specified.
32723
+ * @function toObject
32724
+ * @memberof koinos.protocol.state_delta_entry
32725
+ * @static
32726
+ * @param {koinos.protocol.state_delta_entry} message state_delta_entry
32727
+ * @param {$protobuf.IConversionOptions} [options] Conversion options
32728
+ * @returns {Object.<string,*>} Plain object
32729
+ */
32730
+ state_delta_entry.toObject = function toObject(message, options) {
32731
+ if (!options) options = {};
32732
+ var object = {};
32733
+ if (options.defaults) {
32734
+ object.object_space = null;
32735
+ if (options.bytes === String) object.key = "";
32736
+ else {
32737
+ object.key = [];
32738
+ if (options.bytes !== Array)
32739
+ object.key = $util.newBuffer(object.key);
32740
+ }
32741
+ }
32742
+ if (
32743
+ message.object_space != null &&
32744
+ message.hasOwnProperty("object_space")
32745
+ )
32746
+ object.object_space = $root.koinos.protocol.object_space.toObject(
32747
+ message.object_space,
32748
+ options
32749
+ );
32750
+ if (message.key != null && message.hasOwnProperty("key"))
32751
+ object.key =
32752
+ options.bytes === String
32753
+ ? $util.base64.encode(message.key, 0, message.key.length)
32754
+ : options.bytes === Array
32755
+ ? Array.prototype.slice.call(message.key)
32756
+ : message.key;
32757
+ if (message.value != null && message.hasOwnProperty("value")) {
32758
+ object.value =
32759
+ options.bytes === String
32760
+ ? $util.base64.encode(message.value, 0, message.value.length)
32761
+ : options.bytes === Array
32762
+ ? Array.prototype.slice.call(message.value)
32763
+ : message.value;
32764
+ if (options.oneofs) object._value = "value";
32765
+ }
32766
+ return object;
32767
+ };
32768
+
32769
+ /**
32770
+ * Converts this state_delta_entry to JSON.
32771
+ * @function toJSON
32772
+ * @memberof koinos.protocol.state_delta_entry
32773
+ * @instance
32774
+ * @returns {Object.<string,*>} JSON object
32775
+ */
32776
+ state_delta_entry.prototype.toJSON = function toJSON() {
32777
+ return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
32778
+ };
32779
+
32780
+ /**
32781
+ * Gets the default type url for state_delta_entry
32782
+ * @function getTypeUrl
32783
+ * @memberof koinos.protocol.state_delta_entry
32784
+ * @static
32785
+ * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com")
32786
+ * @returns {string} The default type url
32787
+ */
32788
+ state_delta_entry.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
32789
+ if (typeUrlPrefix === undefined) {
32790
+ typeUrlPrefix = "type.googleapis.com";
32791
+ }
32792
+ return typeUrlPrefix + "/koinos.protocol.state_delta_entry";
32793
+ };
32794
+
32795
+ return state_delta_entry;
32796
+ })();
32797
+
31942
32798
  return protocol;
31943
32799
  })();
31944
32800
 
@@ -33661,7 +34517,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
33661
34517
  /***/ ((module) => {
33662
34518
 
33663
34519
  "use strict";
33664
- module.exports = JSON.parse('{"nested":{"koinos":{"nested":{"contracts":{"nested":{"token":{"options":{"go_package":"github.com/koinos/koinos-proto-golang/koinos/contracts/token"},"nested":{"name_arguments":{"fields":{}},"name_result":{"fields":{"value":{"type":"string","id":1}}},"symbol_arguments":{"fields":{}},"symbol_result":{"fields":{"value":{"type":"string","id":1}}},"decimals_arguments":{"fields":{}},"decimals_result":{"fields":{"value":{"type":"uint32","id":1}}},"total_supply_arguments":{"fields":{}},"total_supply_result":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"balance_of_arguments":{"fields":{"owner":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}}}},"balance_of_result":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"transfer_arguments":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"to":{"type":"bytes","id":2,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":3,"options":{"jstype":"JS_STRING"}}}},"transfer_result":{"fields":{}},"mint_arguments":{"fields":{"to":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"mint_result":{"fields":{}},"burn_arguments":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"burn_result":{"fields":{}},"balance_object":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"mana_balance_object":{"fields":{"balance":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}},"mana":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}},"last_mana_update":{"type":"uint64","id":3,"options":{"jstype":"JS_STRING"}}}},"burn_event":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"mint_event":{"fields":{"to":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"transfer_event":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"to":{"type":"bytes","id":2,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":3,"options":{"jstype":"JS_STRING"}}}}}}}}}}}}');
34520
+ module.exports = JSON.parse('{"nested":{"koinos":{"nested":{"contracts":{"nested":{"token":{"options":{"go_package":"github.com/koinos/koinos-proto-golang/v2/koinos/contracts/token"},"nested":{"name_arguments":{"fields":{}},"name_result":{"fields":{"value":{"type":"string","id":1}}},"symbol_arguments":{"fields":{}},"symbol_result":{"fields":{"value":{"type":"string","id":1}}},"decimals_arguments":{"fields":{}},"decimals_result":{"fields":{"value":{"type":"uint32","id":1}}},"total_supply_arguments":{"fields":{}},"total_supply_result":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"balance_of_arguments":{"fields":{"owner":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}}}},"balance_of_result":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"transfer_arguments":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"to":{"type":"bytes","id":2,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":3,"options":{"jstype":"JS_STRING"}},"memo":{"type":"string","id":4}}},"transfer_result":{"fields":{}},"mint_arguments":{"fields":{"to":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"mint_result":{"fields":{}},"burn_arguments":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"burn_result":{"fields":{}},"balance_object":{"fields":{"value":{"type":"uint64","id":1,"options":{"jstype":"JS_STRING"}}}},"burn_event":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"mint_event":{"fields":{"to":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":2,"options":{"jstype":"JS_STRING"}}}},"transfer_event":{"fields":{"from":{"type":"bytes","id":1,"options":{"(btype)":"ADDRESS"}},"to":{"type":"bytes","id":2,"options":{"(btype)":"ADDRESS"}},"value":{"type":"uint64","id":3,"options":{"jstype":"JS_STRING"}}}}}}}}}}}}');
33665
34521
 
33666
34522
  /***/ })
33667
34523