@ckb-ccc/core 0.0.2-alpha.2 → 0.0.2

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 (185) hide show
  1. package/.prettierignore +12 -0
  2. package/dist/address/address.advanced.d.ts +29 -3
  3. package/dist/address/address.advanced.d.ts.map +1 -1
  4. package/dist/address/address.advanced.js +70 -28
  5. package/dist/address/advanced.d.ts +1 -28
  6. package/dist/address/advanced.d.ts.map +1 -1
  7. package/dist/address/advanced.js +1 -75
  8. package/dist/address/index.d.ts +10 -13
  9. package/dist/address/index.d.ts.map +1 -1
  10. package/dist/address/index.js +21 -25
  11. package/dist/advanced.js +2 -31
  12. package/dist/advancedBarrel.d.ts +1 -0
  13. package/dist/advancedBarrel.d.ts.map +1 -1
  14. package/dist/advancedBarrel.js +4 -19
  15. package/dist/barrel.d.ts +4 -2
  16. package/dist/barrel.d.ts.map +1 -1
  17. package/dist/barrel.js +10 -24
  18. package/dist/bytes/index.d.ts +7 -0
  19. package/dist/bytes/index.d.ts.map +1 -0
  20. package/dist/bytes/index.js +34 -0
  21. package/dist/ckb/advanced.d.ts +3 -2
  22. package/dist/ckb/advanced.d.ts.map +1 -1
  23. package/dist/ckb/advanced.js +3 -18
  24. package/dist/ckb/index.d.ts +2 -3
  25. package/dist/ckb/index.d.ts.map +1 -1
  26. package/dist/ckb/index.js +2 -19
  27. package/dist/ckb/molecule.advanced/generated.d.ts.map +1 -0
  28. package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +444 -231
  29. package/dist/ckb/molecule.advanced/index.d.ts +6 -0
  30. package/dist/ckb/molecule.advanced/index.d.ts.map +1 -0
  31. package/dist/ckb/molecule.advanced/index.js +7 -0
  32. package/dist/ckb/{types/script.advanced.d.ts → script.advanced.d.ts} +1 -0
  33. package/dist/ckb/script.advanced.d.ts.map +1 -0
  34. package/dist/ckb/script.advanced.js +13 -0
  35. package/dist/ckb/script.d.ts +29 -0
  36. package/dist/ckb/script.d.ts.map +1 -0
  37. package/dist/ckb/script.js +61 -0
  38. package/dist/ckb/{types/transaction.advanced.d.ts → transaction.advanced.d.ts} +1 -0
  39. package/dist/ckb/transaction.advanced.d.ts.map +1 -0
  40. package/dist/ckb/transaction.advanced.js +9 -0
  41. package/dist/ckb/transaction.d.ts +142 -0
  42. package/dist/ckb/transaction.d.ts.map +1 -0
  43. package/dist/ckb/transaction.js +227 -0
  44. package/dist/client/advanced.js +2 -18
  45. package/dist/client/client.d.ts +5 -4
  46. package/dist/client/client.d.ts.map +1 -1
  47. package/dist/client/client.js +2 -5
  48. package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
  49. package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
  50. package/dist/client/clientPublicMainnet.advanced.js +7 -10
  51. package/dist/client/clientPublicMainnet.d.ts +2 -2
  52. package/dist/client/clientPublicMainnet.d.ts.map +1 -1
  53. package/dist/client/clientPublicMainnet.js +4 -8
  54. package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
  55. package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
  56. package/dist/client/clientPublicTestnet.advanced.js +7 -10
  57. package/dist/client/clientPublicTestnet.d.ts +2 -2
  58. package/dist/client/clientPublicTestnet.d.ts.map +1 -1
  59. package/dist/client/clientPublicTestnet.js +4 -8
  60. package/dist/client/clientTypes.js +1 -2
  61. package/dist/client/index.js +4 -20
  62. package/dist/client/jsonRpc/advanced.d.ts +36 -36
  63. package/dist/client/jsonRpc/advanced.d.ts.map +1 -1
  64. package/dist/client/jsonRpc/advanced.js +13 -17
  65. package/dist/client/jsonRpc/index.d.ts.map +1 -1
  66. package/dist/client/jsonRpc/index.js +5 -13
  67. package/dist/fixedPoint/index.d.ts +7 -0
  68. package/dist/fixedPoint/index.d.ts.map +1 -0
  69. package/dist/fixedPoint/index.js +22 -0
  70. package/dist/{ckb/hasher.advanced.d.ts → hasher/advanced.d.ts} +1 -1
  71. package/dist/hasher/advanced.d.ts.map +1 -0
  72. package/dist/{ckb/hasher.d.ts → hasher/index.d.ts} +3 -2
  73. package/dist/hasher/index.d.ts.map +1 -0
  74. package/dist/hasher/index.js +18 -0
  75. package/dist/hex/index.d.ts +5 -0
  76. package/dist/hex/index.d.ts.map +1 -0
  77. package/dist/hex/index.js +5 -0
  78. package/dist/index.js +2 -31
  79. package/dist/num/index.d.ts +13 -0
  80. package/dist/num/index.d.ts.map +1 -0
  81. package/dist/num/index.js +36 -0
  82. package/dist/signer/helpers.d.ts +3 -3
  83. package/dist/signer/helpers.d.ts.map +1 -1
  84. package/dist/signer/helpers.js +9 -10
  85. package/dist/signer/index.d.ts +2 -0
  86. package/dist/signer/index.d.ts.map +1 -1
  87. package/dist/signer/index.js +4 -18
  88. package/dist/signer/signer.d.ts +12 -3
  89. package/dist/signer/signer.d.ts.map +1 -1
  90. package/dist/signer/signer.js +13 -6
  91. package/dist/signer/signerReadonly.d.ts +8 -0
  92. package/dist/signer/signerReadonly.d.ts.map +1 -0
  93. package/dist/signer/signerReadonly.js +9 -0
  94. package/dist/{ckb/viewerCkbScript.d.ts → signer/signerReadonlyCkbScript.d.ts} +6 -5
  95. package/dist/signer/signerReadonlyCkbScript.d.ts.map +1 -0
  96. package/dist/signer/signerReadonlyCkbScript.js +17 -0
  97. package/dist/utils/index.d.ts +7 -0
  98. package/dist/utils/index.d.ts.map +1 -0
  99. package/dist/utils/index.js +6 -0
  100. package/package.json +5 -3
  101. package/src/address/address.advanced.ts +76 -19
  102. package/src/address/advanced.ts +1 -59
  103. package/src/address/index.ts +46 -28
  104. package/src/advancedBarrel.ts +1 -0
  105. package/src/barrel.ts +4 -2
  106. package/src/bytes/index.ts +46 -0
  107. package/src/ckb/advanced.ts +3 -2
  108. package/src/ckb/index.ts +2 -3
  109. package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +18 -7
  110. package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +551 -123
  111. package/src/ckb/molecule.advanced/index.ts +11 -0
  112. package/src/ckb/{types/script.advanced.ts → script.advanced.ts} +1 -0
  113. package/src/ckb/script.ts +94 -0
  114. package/src/ckb/{types/transaction.advanced.ts → transaction.advanced.ts} +1 -0
  115. package/src/ckb/transaction.ts +357 -0
  116. package/src/client/client.ts +6 -4
  117. package/src/client/clientPublicMainnet.advanced.ts +2 -2
  118. package/src/client/clientPublicMainnet.ts +2 -2
  119. package/src/client/clientPublicTestnet.advanced.ts +2 -2
  120. package/src/client/clientPublicTestnet.ts +2 -2
  121. package/src/client/clientTypes.ts +1 -1
  122. package/src/client/jsonRpc/advanced.ts +25 -25
  123. package/src/client/jsonRpc/index.ts +1 -3
  124. package/src/fixedPoint/index.ts +30 -0
  125. package/src/hasher/advanced.ts +1 -0
  126. package/src/{ckb/hasher.ts → hasher/index.ts} +5 -5
  127. package/src/hex/index.ts +9 -0
  128. package/src/index.ts +1 -1
  129. package/src/num/index.ts +53 -0
  130. package/src/signer/helpers.ts +9 -6
  131. package/src/signer/index.ts +3 -1
  132. package/src/signer/signer.ts +23 -3
  133. package/src/signer/signerReadonly.ts +13 -0
  134. package/src/{ckb/viewerCkbScript.ts → signer/signerReadonlyCkbScript.ts} +8 -4
  135. package/src/utils/index.ts +28 -0
  136. package/dist/bytes.d.ts +0 -15
  137. package/dist/bytes.d.ts.map +0 -1
  138. package/dist/bytes.js +0 -114
  139. package/dist/ckb/hasher.advanced.d.ts.map +0 -1
  140. package/dist/ckb/hasher.advanced.js +0 -4
  141. package/dist/ckb/hasher.d.ts.map +0 -1
  142. package/dist/ckb/hasher.js +0 -26
  143. package/dist/ckb/types/advanced.d.ts +0 -4
  144. package/dist/ckb/types/advanced.d.ts.map +0 -1
  145. package/dist/ckb/types/advanced.js +0 -32
  146. package/dist/ckb/types/index.d.ts +0 -3
  147. package/dist/ckb/types/index.d.ts.map +0 -1
  148. package/dist/ckb/types/index.js +0 -18
  149. package/dist/ckb/types/molecule.advanced/generated.d.ts.map +0 -1
  150. package/dist/ckb/types/molecule.advanced/index.d.ts +0 -2
  151. package/dist/ckb/types/molecule.advanced/index.d.ts.map +0 -1
  152. package/dist/ckb/types/molecule.advanced/index.js +0 -17
  153. package/dist/ckb/types/script.advanced.d.ts.map +0 -1
  154. package/dist/ckb/types/script.advanced.js +0 -15
  155. package/dist/ckb/types/script.d.ts +0 -26
  156. package/dist/ckb/types/script.d.ts.map +0 -1
  157. package/dist/ckb/types/script.js +0 -75
  158. package/dist/ckb/types/transaction.advanced.d.ts.map +0 -1
  159. package/dist/ckb/types/transaction.advanced.js +0 -11
  160. package/dist/ckb/types/transaction.d.ts +0 -127
  161. package/dist/ckb/types/transaction.d.ts.map +0 -1
  162. package/dist/ckb/types/transaction.js +0 -266
  163. package/dist/ckb/viewerCkbScript.d.ts.map +0 -1
  164. package/dist/ckb/viewerCkbScript.js +0 -18
  165. package/dist/fixedPoint.d.ts +0 -9
  166. package/dist/fixedPoint.d.ts.map +0 -1
  167. package/dist/fixedPoint.js +0 -30
  168. package/dist/primitive.d.ts +0 -5
  169. package/dist/primitive.d.ts.map +0 -1
  170. package/dist/primitive.js +0 -2
  171. package/dist/viewer.d.ts +0 -12
  172. package/dist/viewer.d.ts.map +0 -1
  173. package/dist/viewer.js +0 -19
  174. package/src/bytes.ts +0 -127
  175. package/src/ckb/types/advanced.ts +0 -3
  176. package/src/ckb/types/index.ts +0 -2
  177. package/src/ckb/types/molecule.advanced/index.ts +0 -1
  178. package/src/ckb/types/script.ts +0 -70
  179. package/src/ckb/types/transaction.ts +0 -366
  180. package/src/fixedPoint.ts +0 -53
  181. package/src/primitive.ts +0 -8
  182. package/src/viewer.ts +0 -22
  183. /package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +0 -0
  184. /package/{src/ckb/hasher.advanced.ts → dist/hasher/advanced.js} +0 -0
  185. /package/src/ckb/{types/molecule.advanced → molecule.advanced}/blockchain.mol +0 -0
@@ -1,5 +1,7 @@
1
1
  function dataLengthError(actual, required) {
2
- throw new Error(`Invalid data length! Required: ${required}, actual: ${actual}`);
2
+ throw new Error(
3
+ `Invalid data length! Required: ${required}, actual: ${actual}`,
4
+ );
3
5
  }
4
6
 
5
7
  function assertDataLength(actual, required) {
@@ -13,10 +15,15 @@ function assertArrayBuffer(reader) {
13
15
  reader = reader.toArrayBuffer();
14
16
  }
15
17
  if (reader instanceof Uint8Array) {
16
- return reader.buffer.slice(reader.byteOffset, reader.byteLength + reader.byteOffset);
18
+ return reader.buffer.slice(
19
+ reader.byteOffset,
20
+ reader.byteLength + reader.byteOffset,
21
+ );
17
22
  }
18
23
  if (!(reader instanceof ArrayBuffer)) {
19
- throw new Error("Provided value must be an ArrayBuffer or can be transformed into ArrayBuffer!");
24
+ throw new Error(
25
+ "Provided value must be an ArrayBuffer or can be transformed into ArrayBuffer!",
26
+ );
20
27
  }
21
28
  return reader;
22
29
  }
@@ -39,9 +46,13 @@ function verifyAndExtractOffsets(view, expectedFieldCount, compatible) {
39
46
  }
40
47
  const itemCount = firstOffset / 4 - 1;
41
48
  if (itemCount < expectedFieldCount) {
42
- throw new Error(`Item count not enough! Required: ${expectedFieldCount}, actual: ${itemCount}`);
43
- } else if ((!compatible) && itemCount > expectedFieldCount) {
44
- throw new Error(`Item count is more than required! Required: ${expectedFieldCount}, actual: ${itemCount}`);
49
+ throw new Error(
50
+ `Item count not enough! Required: ${expectedFieldCount}, actual: ${itemCount}`,
51
+ );
52
+ } else if (!compatible && itemCount > expectedFieldCount) {
53
+ throw new Error(
54
+ `Item count is more than required! Required: ${expectedFieldCount}, actual: ${itemCount}`,
55
+ );
45
56
  }
46
57
  if (requiredByteLength < firstOffset) {
47
58
  throw new Error(`First offset is larger than byte length: ${firstOffset}`);
@@ -54,7 +65,9 @@ function verifyAndExtractOffsets(view, expectedFieldCount, compatible) {
54
65
  offsets.push(requiredByteLength);
55
66
  for (let i = 0; i < offsets.length - 1; i++) {
56
67
  if (offsets[i] > offsets[i + 1]) {
57
- throw new Error(`Offset index ${i}: ${offsets[i]} is larger than offset index ${i + 1}: ${offsets[i + 1]}`);
68
+ throw new Error(
69
+ `Offset index ${i}: ${offsets[i]} is larger than offset index ${i + 1}: ${offsets[i + 1]}`,
70
+ );
58
71
  }
59
72
  }
60
73
  return offsets;
@@ -255,7 +268,7 @@ export class Bytes {
255
268
 
256
269
  validate(compatible = false) {
257
270
  if (this.view.byteLength < 4) {
258
- dataLengthError(this.view.byteLength, ">4")
271
+ dataLengthError(this.view.byteLength, ">4");
259
272
  }
260
273
  const requiredByteLength = this.length() + 4;
261
274
  assertDataLength(this.view.byteLength, requiredByteLength);
@@ -277,7 +290,7 @@ export class Bytes {
277
290
  export function SerializeBytes(value) {
278
291
  const item = assertArrayBuffer(value);
279
292
  const array = new Uint8Array(4 + item.byteLength);
280
- (new DataView(array.buffer)).setUint32(0, item.byteLength, true);
293
+ new DataView(array.buffer).setUint32(0, item.byteLength, true);
281
294
  array.set(new Uint8Array(item), 4);
282
295
  return array.buffer;
283
296
  }
@@ -324,7 +337,9 @@ export class BytesOptVec {
324
337
  validate(compatible = false) {
325
338
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
326
339
  for (let i = 0; i < offsets.length - 1; i++) {
327
- new BytesOpt(this.view.buffer.slice(offsets[i], offsets[i + 1]), { validate: false }).validate();
340
+ new BytesOpt(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
341
+ validate: false,
342
+ }).validate();
328
343
  }
329
344
  }
330
345
 
@@ -343,12 +358,14 @@ export class BytesOptVec {
343
358
  if (i + 1 < this.length()) {
344
359
  offset_end = this.view.getUint32(start + 4, true);
345
360
  }
346
- return new BytesOpt(this.view.buffer.slice(offset, offset_end), { validate: false });
361
+ return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
362
+ validate: false,
363
+ });
347
364
  }
348
365
  }
349
366
 
350
367
  export function SerializeBytesOptVec(value) {
351
- return serializeTable(value.map(item => SerializeBytesOpt(item)));
368
+ return serializeTable(value.map((item) => SerializeBytesOpt(item)));
352
369
  }
353
370
 
354
371
  export class BytesVec {
@@ -362,7 +379,9 @@ export class BytesVec {
362
379
  validate(compatible = false) {
363
380
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
364
381
  for (let i = 0; i < offsets.length - 1; i++) {
365
- new Bytes(this.view.buffer.slice(offsets[i], offsets[i + 1]), { validate: false }).validate();
382
+ new Bytes(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
383
+ validate: false,
384
+ }).validate();
366
385
  }
367
386
  }
368
387
 
@@ -381,12 +400,14 @@ export class BytesVec {
381
400
  if (i + 1 < this.length()) {
382
401
  offset_end = this.view.getUint32(start + 4, true);
383
402
  }
384
- return new Bytes(this.view.buffer.slice(offset, offset_end), { validate: false });
403
+ return new Bytes(this.view.buffer.slice(offset, offset_end), {
404
+ validate: false,
405
+ });
385
406
  }
386
407
  }
387
408
 
388
409
  export function SerializeBytesVec(value) {
389
- return serializeTable(value.map(item => SerializeBytes(item)));
410
+ return serializeTable(value.map((item) => SerializeBytes(item)));
390
411
  }
391
412
 
392
413
  export class Byte32Vec {
@@ -410,7 +431,13 @@ export class Byte32Vec {
410
431
  }
411
432
 
412
433
  indexAt(i) {
413
- return new Byte32(this.view.buffer.slice(4 + i * Byte32.size(), 4 + (i + 1) * Byte32.size()), { validate: false });
434
+ return new Byte32(
435
+ this.view.buffer.slice(
436
+ 4 + i * Byte32.size(),
437
+ 4 + (i + 1) * Byte32.size(),
438
+ ),
439
+ { validate: false },
440
+ );
414
441
  }
415
442
 
416
443
  length() {
@@ -420,7 +447,7 @@ export class Byte32Vec {
420
447
 
421
448
  export function SerializeByte32Vec(value) {
422
449
  const array = new Uint8Array(4 + Byte32.size() * value.length);
423
- (new DataView(array.buffer)).setUint32(0, value.length, true);
450
+ new DataView(array.buffer).setUint32(0, value.length, true);
424
451
  for (let i = 0; i < value.length; i++) {
425
452
  const itemBuffer = SerializeByte32(value[i]);
426
453
  array.set(new Uint8Array(itemBuffer), 4 + i * Byte32.size());
@@ -501,7 +528,9 @@ export class UncleBlockVec {
501
528
  validate(compatible = false) {
502
529
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
503
530
  for (let i = 0; i < offsets.length - 1; i++) {
504
- new UncleBlock(this.view.buffer.slice(offsets[i], offsets[i + 1]), { validate: false }).validate();
531
+ new UncleBlock(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
532
+ validate: false,
533
+ }).validate();
505
534
  }
506
535
  }
507
536
 
@@ -520,12 +549,14 @@ export class UncleBlockVec {
520
549
  if (i + 1 < this.length()) {
521
550
  offset_end = this.view.getUint32(start + 4, true);
522
551
  }
523
- return new UncleBlock(this.view.buffer.slice(offset, offset_end), { validate: false });
552
+ return new UncleBlock(this.view.buffer.slice(offset, offset_end), {
553
+ validate: false,
554
+ });
524
555
  }
525
556
  }
526
557
 
527
558
  export function SerializeUncleBlockVec(value) {
528
- return serializeTable(value.map(item => SerializeUncleBlock(item)));
559
+ return serializeTable(value.map((item) => SerializeUncleBlock(item)));
529
560
  }
530
561
 
531
562
  export class TransactionVec {
@@ -539,7 +570,9 @@ export class TransactionVec {
539
570
  validate(compatible = false) {
540
571
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
541
572
  for (let i = 0; i < offsets.length - 1; i++) {
542
- new Transaction(this.view.buffer.slice(offsets[i], offsets[i + 1]), { validate: false }).validate();
573
+ new Transaction(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
574
+ validate: false,
575
+ }).validate();
543
576
  }
544
577
  }
545
578
 
@@ -558,12 +591,14 @@ export class TransactionVec {
558
591
  if (i + 1 < this.length()) {
559
592
  offset_end = this.view.getUint32(start + 4, true);
560
593
  }
561
- return new Transaction(this.view.buffer.slice(offset, offset_end), { validate: false });
594
+ return new Transaction(this.view.buffer.slice(offset, offset_end), {
595
+ validate: false,
596
+ });
562
597
  }
563
598
  }
564
599
 
565
600
  export function SerializeTransactionVec(value) {
566
- return serializeTable(value.map(item => SerializeTransaction(item)));
601
+ return serializeTable(value.map((item) => SerializeTransaction(item)));
567
602
  }
568
603
 
569
604
  export class ProposalShortIdVec {
@@ -587,7 +622,13 @@ export class ProposalShortIdVec {
587
622
  }
588
623
 
589
624
  indexAt(i) {
590
- return new ProposalShortId(this.view.buffer.slice(4 + i * ProposalShortId.size(), 4 + (i + 1) * ProposalShortId.size()), { validate: false });
625
+ return new ProposalShortId(
626
+ this.view.buffer.slice(
627
+ 4 + i * ProposalShortId.size(),
628
+ 4 + (i + 1) * ProposalShortId.size(),
629
+ ),
630
+ { validate: false },
631
+ );
591
632
  }
592
633
 
593
634
  length() {
@@ -597,7 +638,7 @@ export class ProposalShortIdVec {
597
638
 
598
639
  export function SerializeProposalShortIdVec(value) {
599
640
  const array = new Uint8Array(4 + ProposalShortId.size() * value.length);
600
- (new DataView(array.buffer)).setUint32(0, value.length, true);
641
+ new DataView(array.buffer).setUint32(0, value.length, true);
601
642
  for (let i = 0; i < value.length; i++) {
602
643
  const itemBuffer = SerializeProposalShortId(value[i]);
603
644
  array.set(new Uint8Array(itemBuffer), 4 + i * ProposalShortId.size());
@@ -626,7 +667,13 @@ export class CellDepVec {
626
667
  }
627
668
 
628
669
  indexAt(i) {
629
- return new CellDep(this.view.buffer.slice(4 + i * CellDep.size(), 4 + (i + 1) * CellDep.size()), { validate: false });
670
+ return new CellDep(
671
+ this.view.buffer.slice(
672
+ 4 + i * CellDep.size(),
673
+ 4 + (i + 1) * CellDep.size(),
674
+ ),
675
+ { validate: false },
676
+ );
630
677
  }
631
678
 
632
679
  length() {
@@ -636,7 +683,7 @@ export class CellDepVec {
636
683
 
637
684
  export function SerializeCellDepVec(value) {
638
685
  const array = new Uint8Array(4 + CellDep.size() * value.length);
639
- (new DataView(array.buffer)).setUint32(0, value.length, true);
686
+ new DataView(array.buffer).setUint32(0, value.length, true);
640
687
  for (let i = 0; i < value.length; i++) {
641
688
  const itemBuffer = SerializeCellDep(value[i]);
642
689
  array.set(new Uint8Array(itemBuffer), 4 + i * CellDep.size());
@@ -665,7 +712,13 @@ export class CellInputVec {
665
712
  }
666
713
 
667
714
  indexAt(i) {
668
- return new CellInput(this.view.buffer.slice(4 + i * CellInput.size(), 4 + (i + 1) * CellInput.size()), { validate: false });
715
+ return new CellInput(
716
+ this.view.buffer.slice(
717
+ 4 + i * CellInput.size(),
718
+ 4 + (i + 1) * CellInput.size(),
719
+ ),
720
+ { validate: false },
721
+ );
669
722
  }
670
723
 
671
724
  length() {
@@ -675,7 +728,7 @@ export class CellInputVec {
675
728
 
676
729
  export function SerializeCellInputVec(value) {
677
730
  const array = new Uint8Array(4 + CellInput.size() * value.length);
678
- (new DataView(array.buffer)).setUint32(0, value.length, true);
731
+ new DataView(array.buffer).setUint32(0, value.length, true);
679
732
  for (let i = 0; i < value.length; i++) {
680
733
  const itemBuffer = SerializeCellInput(value[i]);
681
734
  array.set(new Uint8Array(itemBuffer), 4 + i * CellInput.size());
@@ -694,7 +747,9 @@ export class CellOutputVec {
694
747
  validate(compatible = false) {
695
748
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
696
749
  for (let i = 0; i < offsets.length - 1; i++) {
697
- new CellOutput(this.view.buffer.slice(offsets[i], offsets[i + 1]), { validate: false }).validate();
750
+ new CellOutput(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
751
+ validate: false,
752
+ }).validate();
698
753
  }
699
754
  }
700
755
 
@@ -713,12 +768,14 @@ export class CellOutputVec {
713
768
  if (i + 1 < this.length()) {
714
769
  offset_end = this.view.getUint32(start + 4, true);
715
770
  }
716
- return new CellOutput(this.view.buffer.slice(offset, offset_end), { validate: false });
771
+ return new CellOutput(this.view.buffer.slice(offset, offset_end), {
772
+ validate: false,
773
+ });
717
774
  }
718
775
  }
719
776
 
720
777
  export function SerializeCellOutputVec(value) {
721
- return serializeTable(value.map(item => SerializeCellOutput(item)));
778
+ return serializeTable(value.map((item) => SerializeCellOutput(item)));
722
779
  }
723
780
 
724
781
  export class Script {
@@ -731,18 +788,26 @@ export class Script {
731
788
 
732
789
  validate(compatible = false) {
733
790
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
734
- new Byte32(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
791
+ new Byte32(this.view.buffer.slice(offsets[0], offsets[1]), {
792
+ validate: false,
793
+ }).validate();
735
794
  if (offsets[2] - offsets[1] !== 1) {
736
- throw new Error(`Invalid offset for hashType: ${offsets[1]} - ${offsets[2]}`)
795
+ throw new Error(
796
+ `Invalid offset for hashType: ${offsets[1]} - ${offsets[2]}`,
797
+ );
737
798
  }
738
- new Bytes(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
799
+ new Bytes(this.view.buffer.slice(offsets[2], offsets[3]), {
800
+ validate: false,
801
+ }).validate();
739
802
  }
740
803
 
741
804
  getCodeHash() {
742
805
  const start = 4;
743
806
  const offset = this.view.getUint32(start, true);
744
807
  const offset_end = this.view.getUint32(start + 4, true);
745
- return new Byte32(this.view.buffer.slice(offset, offset_end), { validate: false });
808
+ return new Byte32(this.view.buffer.slice(offset, offset_end), {
809
+ validate: false,
810
+ });
746
811
  }
747
812
 
748
813
  getHashType() {
@@ -756,7 +821,9 @@ export class Script {
756
821
  const start = 12;
757
822
  const offset = this.view.getUint32(start, true);
758
823
  const offset_end = this.view.byteLength;
759
- return new Bytes(this.view.buffer.slice(offset, offset_end), { validate: false });
824
+ return new Bytes(this.view.buffer.slice(offset, offset_end), {
825
+ validate: false,
826
+ });
760
827
  }
761
828
  }
762
829
 
@@ -765,7 +832,7 @@ export function SerializeScript(value) {
765
832
  buffers.push(SerializeByte32(value.codeHash));
766
833
  const hashTypeView = new DataView(new ArrayBuffer(1));
767
834
  hashTypeView.setUint8(0, value.hashType);
768
- buffers.push(hashTypeView.buffer)
835
+ buffers.push(hashTypeView.buffer);
769
836
  buffers.push(SerializeBytes(value.args));
770
837
  return serializeTable(buffers);
771
838
  }
@@ -779,11 +846,19 @@ export class OutPoint {
779
846
  }
780
847
 
781
848
  getTxHash() {
782
- return new Byte32(this.view.buffer.slice(0, 0 + Byte32.size()), { validate: false });
849
+ return new Byte32(this.view.buffer.slice(0, 0 + Byte32.size()), {
850
+ validate: false,
851
+ });
783
852
  }
784
853
 
785
854
  getIndex() {
786
- return new Uint32(this.view.buffer.slice(0 + Byte32.size(), 0 + Byte32.size() + Uint32.size()), { validate: false });
855
+ return new Uint32(
856
+ this.view.buffer.slice(
857
+ 0 + Byte32.size(),
858
+ 0 + Byte32.size() + Uint32.size(),
859
+ ),
860
+ { validate: false },
861
+ );
787
862
  }
788
863
 
789
864
  validate(compatible = false) {
@@ -813,11 +888,19 @@ export class CellInput {
813
888
  }
814
889
 
815
890
  getSince() {
816
- return new Uint64(this.view.buffer.slice(0, 0 + Uint64.size()), { validate: false });
891
+ return new Uint64(this.view.buffer.slice(0, 0 + Uint64.size()), {
892
+ validate: false,
893
+ });
817
894
  }
818
895
 
819
896
  getPreviousOutput() {
820
- return new OutPoint(this.view.buffer.slice(0 + Uint64.size(), 0 + Uint64.size() + OutPoint.size()), { validate: false });
897
+ return new OutPoint(
898
+ this.view.buffer.slice(
899
+ 0 + Uint64.size(),
900
+ 0 + Uint64.size() + OutPoint.size(),
901
+ ),
902
+ { validate: false },
903
+ );
821
904
  }
822
905
 
823
906
  validate(compatible = false) {
@@ -834,7 +917,10 @@ export function SerializeCellInput(value) {
834
917
  const array = new Uint8Array(0 + Uint64.size() + OutPoint.size());
835
918
  const view = new DataView(array.buffer);
836
919
  array.set(new Uint8Array(SerializeUint64(value.since)), 0);
837
- array.set(new Uint8Array(SerializeOutPoint(value.previousOutput)), 0 + Uint64.size());
920
+ array.set(
921
+ new Uint8Array(SerializeOutPoint(value.previousOutput)),
922
+ 0 + Uint64.size(),
923
+ );
838
924
  return array.buffer;
839
925
  }
840
926
 
@@ -848,30 +934,42 @@ export class CellOutput {
848
934
 
849
935
  validate(compatible = false) {
850
936
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
851
- new Uint64(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
852
- new Script(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
853
- new ScriptOpt(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
937
+ new Uint64(this.view.buffer.slice(offsets[0], offsets[1]), {
938
+ validate: false,
939
+ }).validate();
940
+ new Script(this.view.buffer.slice(offsets[1], offsets[2]), {
941
+ validate: false,
942
+ }).validate();
943
+ new ScriptOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
944
+ validate: false,
945
+ }).validate();
854
946
  }
855
947
 
856
948
  getCapacity() {
857
949
  const start = 4;
858
950
  const offset = this.view.getUint32(start, true);
859
951
  const offset_end = this.view.getUint32(start + 4, true);
860
- return new Uint64(this.view.buffer.slice(offset, offset_end), { validate: false });
952
+ return new Uint64(this.view.buffer.slice(offset, offset_end), {
953
+ validate: false,
954
+ });
861
955
  }
862
956
 
863
957
  getLock() {
864
958
  const start = 8;
865
959
  const offset = this.view.getUint32(start, true);
866
960
  const offset_end = this.view.getUint32(start + 4, true);
867
- return new Script(this.view.buffer.slice(offset, offset_end), { validate: false });
961
+ return new Script(this.view.buffer.slice(offset, offset_end), {
962
+ validate: false,
963
+ });
868
964
  }
869
965
 
870
966
  getType() {
871
967
  const start = 12;
872
968
  const offset = this.view.getUint32(start, true);
873
969
  const offset_end = this.view.byteLength;
874
- return new ScriptOpt(this.view.buffer.slice(offset, offset_end), { validate: false });
970
+ return new ScriptOpt(this.view.buffer.slice(offset, offset_end), {
971
+ validate: false,
972
+ });
875
973
  }
876
974
  }
877
975
 
@@ -892,7 +990,9 @@ export class CellDep {
892
990
  }
893
991
 
894
992
  getOutPoint() {
895
- return new OutPoint(this.view.buffer.slice(0, 0 + OutPoint.size()), { validate: false });
993
+ return new OutPoint(this.view.buffer.slice(0, 0 + OutPoint.size()), {
994
+ validate: false,
995
+ });
896
996
  }
897
997
 
898
998
  getDepType() {
@@ -926,54 +1026,78 @@ export class RawTransaction {
926
1026
 
927
1027
  validate(compatible = false) {
928
1028
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
929
- new Uint32(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
930
- new CellDepVec(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
931
- new Byte32Vec(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
932
- new CellInputVec(this.view.buffer.slice(offsets[3], offsets[4]), { validate: false }).validate();
933
- new CellOutputVec(this.view.buffer.slice(offsets[4], offsets[5]), { validate: false }).validate();
934
- new BytesVec(this.view.buffer.slice(offsets[5], offsets[6]), { validate: false }).validate();
1029
+ new Uint32(this.view.buffer.slice(offsets[0], offsets[1]), {
1030
+ validate: false,
1031
+ }).validate();
1032
+ new CellDepVec(this.view.buffer.slice(offsets[1], offsets[2]), {
1033
+ validate: false,
1034
+ }).validate();
1035
+ new Byte32Vec(this.view.buffer.slice(offsets[2], offsets[3]), {
1036
+ validate: false,
1037
+ }).validate();
1038
+ new CellInputVec(this.view.buffer.slice(offsets[3], offsets[4]), {
1039
+ validate: false,
1040
+ }).validate();
1041
+ new CellOutputVec(this.view.buffer.slice(offsets[4], offsets[5]), {
1042
+ validate: false,
1043
+ }).validate();
1044
+ new BytesVec(this.view.buffer.slice(offsets[5], offsets[6]), {
1045
+ validate: false,
1046
+ }).validate();
935
1047
  }
936
1048
 
937
1049
  getVersion() {
938
1050
  const start = 4;
939
1051
  const offset = this.view.getUint32(start, true);
940
1052
  const offset_end = this.view.getUint32(start + 4, true);
941
- return new Uint32(this.view.buffer.slice(offset, offset_end), { validate: false });
1053
+ return new Uint32(this.view.buffer.slice(offset, offset_end), {
1054
+ validate: false,
1055
+ });
942
1056
  }
943
1057
 
944
1058
  getCellDeps() {
945
1059
  const start = 8;
946
1060
  const offset = this.view.getUint32(start, true);
947
1061
  const offset_end = this.view.getUint32(start + 4, true);
948
- return new CellDepVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1062
+ return new CellDepVec(this.view.buffer.slice(offset, offset_end), {
1063
+ validate: false,
1064
+ });
949
1065
  }
950
1066
 
951
1067
  getHeaderDeps() {
952
1068
  const start = 12;
953
1069
  const offset = this.view.getUint32(start, true);
954
1070
  const offset_end = this.view.getUint32(start + 4, true);
955
- return new Byte32Vec(this.view.buffer.slice(offset, offset_end), { validate: false });
1071
+ return new Byte32Vec(this.view.buffer.slice(offset, offset_end), {
1072
+ validate: false,
1073
+ });
956
1074
  }
957
1075
 
958
1076
  getInputs() {
959
1077
  const start = 16;
960
1078
  const offset = this.view.getUint32(start, true);
961
1079
  const offset_end = this.view.getUint32(start + 4, true);
962
- return new CellInputVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1080
+ return new CellInputVec(this.view.buffer.slice(offset, offset_end), {
1081
+ validate: false,
1082
+ });
963
1083
  }
964
1084
 
965
1085
  getOutputs() {
966
1086
  const start = 20;
967
1087
  const offset = this.view.getUint32(start, true);
968
1088
  const offset_end = this.view.getUint32(start + 4, true);
969
- return new CellOutputVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1089
+ return new CellOutputVec(this.view.buffer.slice(offset, offset_end), {
1090
+ validate: false,
1091
+ });
970
1092
  }
971
1093
 
972
1094
  getOutputsData() {
973
1095
  const start = 24;
974
1096
  const offset = this.view.getUint32(start, true);
975
1097
  const offset_end = this.view.byteLength;
976
- return new BytesVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1098
+ return new BytesVec(this.view.buffer.slice(offset, offset_end), {
1099
+ validate: false,
1100
+ });
977
1101
  }
978
1102
  }
979
1103
 
@@ -998,22 +1122,30 @@ export class Transaction {
998
1122
 
999
1123
  validate(compatible = false) {
1000
1124
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1001
- new RawTransaction(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1002
- new BytesVec(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1125
+ new RawTransaction(this.view.buffer.slice(offsets[0], offsets[1]), {
1126
+ validate: false,
1127
+ }).validate();
1128
+ new BytesVec(this.view.buffer.slice(offsets[1], offsets[2]), {
1129
+ validate: false,
1130
+ }).validate();
1003
1131
  }
1004
1132
 
1005
1133
  getRaw() {
1006
1134
  const start = 4;
1007
1135
  const offset = this.view.getUint32(start, true);
1008
1136
  const offset_end = this.view.getUint32(start + 4, true);
1009
- return new RawTransaction(this.view.buffer.slice(offset, offset_end), { validate: false });
1137
+ return new RawTransaction(this.view.buffer.slice(offset, offset_end), {
1138
+ validate: false,
1139
+ });
1010
1140
  }
1011
1141
 
1012
1142
  getWitnesses() {
1013
1143
  const start = 8;
1014
1144
  const offset = this.view.getUint32(start, true);
1015
1145
  const offset_end = this.view.byteLength;
1016
- return new BytesVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1146
+ return new BytesVec(this.view.buffer.slice(offset, offset_end), {
1147
+ validate: false,
1148
+ });
1017
1149
  }
1018
1150
  }
1019
1151
 
@@ -1033,43 +1165,179 @@ export class RawHeader {
1033
1165
  }
1034
1166
 
1035
1167
  getVersion() {
1036
- return new Uint32(this.view.buffer.slice(0, 0 + Uint32.size()), { validate: false });
1168
+ return new Uint32(this.view.buffer.slice(0, 0 + Uint32.size()), {
1169
+ validate: false,
1170
+ });
1037
1171
  }
1038
1172
 
1039
1173
  getCompactTarget() {
1040
- return new Uint32(this.view.buffer.slice(0 + Uint32.size(), 0 + Uint32.size() + Uint32.size()), { validate: false });
1174
+ return new Uint32(
1175
+ this.view.buffer.slice(
1176
+ 0 + Uint32.size(),
1177
+ 0 + Uint32.size() + Uint32.size(),
1178
+ ),
1179
+ { validate: false },
1180
+ );
1041
1181
  }
1042
1182
 
1043
1183
  getTimestamp() {
1044
- return new Uint64(this.view.buffer.slice(0 + Uint32.size() + Uint32.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size()), { validate: false });
1184
+ return new Uint64(
1185
+ this.view.buffer.slice(
1186
+ 0 + Uint32.size() + Uint32.size(),
1187
+ 0 + Uint32.size() + Uint32.size() + Uint64.size(),
1188
+ ),
1189
+ { validate: false },
1190
+ );
1045
1191
  }
1046
1192
 
1047
1193
  getNumber() {
1048
- return new Uint64(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size()), { validate: false });
1194
+ return new Uint64(
1195
+ this.view.buffer.slice(
1196
+ 0 + Uint32.size() + Uint32.size() + Uint64.size(),
1197
+ 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
1198
+ ),
1199
+ { validate: false },
1200
+ );
1049
1201
  }
1050
1202
 
1051
1203
  getEpoch() {
1052
- return new Uint64(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size()), { validate: false });
1204
+ return new Uint64(
1205
+ this.view.buffer.slice(
1206
+ 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
1207
+ 0 +
1208
+ Uint32.size() +
1209
+ Uint32.size() +
1210
+ Uint64.size() +
1211
+ Uint64.size() +
1212
+ Uint64.size(),
1213
+ ),
1214
+ { validate: false },
1215
+ );
1053
1216
  }
1054
1217
 
1055
1218
  getParentHash() {
1056
- return new Byte32(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size()), { validate: false });
1219
+ return new Byte32(
1220
+ this.view.buffer.slice(
1221
+ 0 +
1222
+ Uint32.size() +
1223
+ Uint32.size() +
1224
+ Uint64.size() +
1225
+ Uint64.size() +
1226
+ Uint64.size(),
1227
+ 0 +
1228
+ Uint32.size() +
1229
+ Uint32.size() +
1230
+ Uint64.size() +
1231
+ Uint64.size() +
1232
+ Uint64.size() +
1233
+ Byte32.size(),
1234
+ ),
1235
+ { validate: false },
1236
+ );
1057
1237
  }
1058
1238
 
1059
1239
  getTransactionsRoot() {
1060
- return new Byte32(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size()), { validate: false });
1240
+ return new Byte32(
1241
+ this.view.buffer.slice(
1242
+ 0 +
1243
+ Uint32.size() +
1244
+ Uint32.size() +
1245
+ Uint64.size() +
1246
+ Uint64.size() +
1247
+ Uint64.size() +
1248
+ Byte32.size(),
1249
+ 0 +
1250
+ Uint32.size() +
1251
+ Uint32.size() +
1252
+ Uint64.size() +
1253
+ Uint64.size() +
1254
+ Uint64.size() +
1255
+ Byte32.size() +
1256
+ Byte32.size(),
1257
+ ),
1258
+ { validate: false },
1259
+ );
1061
1260
  }
1062
1261
 
1063
1262
  getProposalsHash() {
1064
- return new Byte32(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size()), { validate: false });
1263
+ return new Byte32(
1264
+ this.view.buffer.slice(
1265
+ 0 +
1266
+ Uint32.size() +
1267
+ Uint32.size() +
1268
+ Uint64.size() +
1269
+ Uint64.size() +
1270
+ Uint64.size() +
1271
+ Byte32.size() +
1272
+ Byte32.size(),
1273
+ 0 +
1274
+ Uint32.size() +
1275
+ Uint32.size() +
1276
+ Uint64.size() +
1277
+ Uint64.size() +
1278
+ Uint64.size() +
1279
+ Byte32.size() +
1280
+ Byte32.size() +
1281
+ Byte32.size(),
1282
+ ),
1283
+ { validate: false },
1284
+ );
1065
1285
  }
1066
1286
 
1067
1287
  getExtraHash() {
1068
- return new Byte32(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size()), { validate: false });
1288
+ return new Byte32(
1289
+ this.view.buffer.slice(
1290
+ 0 +
1291
+ Uint32.size() +
1292
+ Uint32.size() +
1293
+ Uint64.size() +
1294
+ Uint64.size() +
1295
+ Uint64.size() +
1296
+ Byte32.size() +
1297
+ Byte32.size() +
1298
+ Byte32.size(),
1299
+ 0 +
1300
+ Uint32.size() +
1301
+ Uint32.size() +
1302
+ Uint64.size() +
1303
+ Uint64.size() +
1304
+ Uint64.size() +
1305
+ Byte32.size() +
1306
+ Byte32.size() +
1307
+ Byte32.size() +
1308
+ Byte32.size(),
1309
+ ),
1310
+ { validate: false },
1311
+ );
1069
1312
  }
1070
1313
 
1071
1314
  getDao() {
1072
- return new Byte32(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size(), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size()), { validate: false });
1315
+ return new Byte32(
1316
+ this.view.buffer.slice(
1317
+ 0 +
1318
+ Uint32.size() +
1319
+ Uint32.size() +
1320
+ Uint64.size() +
1321
+ Uint64.size() +
1322
+ Uint64.size() +
1323
+ Byte32.size() +
1324
+ Byte32.size() +
1325
+ Byte32.size() +
1326
+ Byte32.size(),
1327
+ 0 +
1328
+ Uint32.size() +
1329
+ Uint32.size() +
1330
+ Uint64.size() +
1331
+ Uint64.size() +
1332
+ Uint64.size() +
1333
+ Byte32.size() +
1334
+ Byte32.size() +
1335
+ Byte32.size() +
1336
+ Byte32.size() +
1337
+ Byte32.size(),
1338
+ ),
1339
+ { validate: false },
1340
+ );
1073
1341
  }
1074
1342
 
1075
1343
  validate(compatible = false) {
@@ -1086,23 +1354,109 @@ export class RawHeader {
1086
1354
  this.getDao().validate(compatible);
1087
1355
  }
1088
1356
  static size() {
1089
- return 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size();
1357
+ return (
1358
+ 0 +
1359
+ Uint32.size() +
1360
+ Uint32.size() +
1361
+ Uint64.size() +
1362
+ Uint64.size() +
1363
+ Uint64.size() +
1364
+ Byte32.size() +
1365
+ Byte32.size() +
1366
+ Byte32.size() +
1367
+ Byte32.size() +
1368
+ Byte32.size()
1369
+ );
1090
1370
  }
1091
1371
  }
1092
1372
 
1093
1373
  export function SerializeRawHeader(value) {
1094
- const array = new Uint8Array(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size());
1374
+ const array = new Uint8Array(
1375
+ 0 +
1376
+ Uint32.size() +
1377
+ Uint32.size() +
1378
+ Uint64.size() +
1379
+ Uint64.size() +
1380
+ Uint64.size() +
1381
+ Byte32.size() +
1382
+ Byte32.size() +
1383
+ Byte32.size() +
1384
+ Byte32.size() +
1385
+ Byte32.size(),
1386
+ );
1095
1387
  const view = new DataView(array.buffer);
1096
1388
  array.set(new Uint8Array(SerializeUint32(value.version)), 0);
1097
- array.set(new Uint8Array(SerializeUint32(value.compactTarget)), 0 + Uint32.size());
1098
- array.set(new Uint8Array(SerializeUint64(value.timestamp)), 0 + Uint32.size() + Uint32.size());
1099
- array.set(new Uint8Array(SerializeUint64(value.number)), 0 + Uint32.size() + Uint32.size() + Uint64.size());
1100
- array.set(new Uint8Array(SerializeUint64(value.epoch)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size());
1101
- array.set(new Uint8Array(SerializeByte32(value.parentHash)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size());
1102
- array.set(new Uint8Array(SerializeByte32(value.transactionsRoot)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size());
1103
- array.set(new Uint8Array(SerializeByte32(value.proposalsHash)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size());
1104
- array.set(new Uint8Array(SerializeByte32(value.extraHash)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size());
1105
- array.set(new Uint8Array(SerializeByte32(value.dao)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size() + Uint64.size() + Byte32.size() + Byte32.size() + Byte32.size() + Byte32.size());
1389
+ array.set(
1390
+ new Uint8Array(SerializeUint32(value.compactTarget)),
1391
+ 0 + Uint32.size(),
1392
+ );
1393
+ array.set(
1394
+ new Uint8Array(SerializeUint64(value.timestamp)),
1395
+ 0 + Uint32.size() + Uint32.size(),
1396
+ );
1397
+ array.set(
1398
+ new Uint8Array(SerializeUint64(value.number)),
1399
+ 0 + Uint32.size() + Uint32.size() + Uint64.size(),
1400
+ );
1401
+ array.set(
1402
+ new Uint8Array(SerializeUint64(value.epoch)),
1403
+ 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
1404
+ );
1405
+ array.set(
1406
+ new Uint8Array(SerializeByte32(value.parentHash)),
1407
+ 0 +
1408
+ Uint32.size() +
1409
+ Uint32.size() +
1410
+ Uint64.size() +
1411
+ Uint64.size() +
1412
+ Uint64.size(),
1413
+ );
1414
+ array.set(
1415
+ new Uint8Array(SerializeByte32(value.transactionsRoot)),
1416
+ 0 +
1417
+ Uint32.size() +
1418
+ Uint32.size() +
1419
+ Uint64.size() +
1420
+ Uint64.size() +
1421
+ Uint64.size() +
1422
+ Byte32.size(),
1423
+ );
1424
+ array.set(
1425
+ new Uint8Array(SerializeByte32(value.proposalsHash)),
1426
+ 0 +
1427
+ Uint32.size() +
1428
+ Uint32.size() +
1429
+ Uint64.size() +
1430
+ Uint64.size() +
1431
+ Uint64.size() +
1432
+ Byte32.size() +
1433
+ Byte32.size(),
1434
+ );
1435
+ array.set(
1436
+ new Uint8Array(SerializeByte32(value.extraHash)),
1437
+ 0 +
1438
+ Uint32.size() +
1439
+ Uint32.size() +
1440
+ Uint64.size() +
1441
+ Uint64.size() +
1442
+ Uint64.size() +
1443
+ Byte32.size() +
1444
+ Byte32.size() +
1445
+ Byte32.size(),
1446
+ );
1447
+ array.set(
1448
+ new Uint8Array(SerializeByte32(value.dao)),
1449
+ 0 +
1450
+ Uint32.size() +
1451
+ Uint32.size() +
1452
+ Uint64.size() +
1453
+ Uint64.size() +
1454
+ Uint64.size() +
1455
+ Byte32.size() +
1456
+ Byte32.size() +
1457
+ Byte32.size() +
1458
+ Byte32.size(),
1459
+ );
1106
1460
  return array.buffer;
1107
1461
  }
1108
1462
 
@@ -1115,11 +1469,19 @@ export class Header {
1115
1469
  }
1116
1470
 
1117
1471
  getRaw() {
1118
- return new RawHeader(this.view.buffer.slice(0, 0 + RawHeader.size()), { validate: false });
1472
+ return new RawHeader(this.view.buffer.slice(0, 0 + RawHeader.size()), {
1473
+ validate: false,
1474
+ });
1119
1475
  }
1120
1476
 
1121
1477
  getNonce() {
1122
- return new Uint128(this.view.buffer.slice(0 + RawHeader.size(), 0 + RawHeader.size() + Uint128.size()), { validate: false });
1478
+ return new Uint128(
1479
+ this.view.buffer.slice(
1480
+ 0 + RawHeader.size(),
1481
+ 0 + RawHeader.size() + Uint128.size(),
1482
+ ),
1483
+ { validate: false },
1484
+ );
1123
1485
  }
1124
1486
 
1125
1487
  validate(compatible = false) {
@@ -1136,7 +1498,10 @@ export function SerializeHeader(value) {
1136
1498
  const array = new Uint8Array(0 + RawHeader.size() + Uint128.size());
1137
1499
  const view = new DataView(array.buffer);
1138
1500
  array.set(new Uint8Array(SerializeRawHeader(value.raw)), 0);
1139
- array.set(new Uint8Array(SerializeUint128(value.nonce)), 0 + RawHeader.size());
1501
+ array.set(
1502
+ new Uint8Array(SerializeUint128(value.nonce)),
1503
+ 0 + RawHeader.size(),
1504
+ );
1140
1505
  return array.buffer;
1141
1506
  }
1142
1507
 
@@ -1150,22 +1515,30 @@ export class UncleBlock {
1150
1515
 
1151
1516
  validate(compatible = false) {
1152
1517
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1153
- new Header(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1154
- new ProposalShortIdVec(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1518
+ new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
1519
+ validate: false,
1520
+ }).validate();
1521
+ new ProposalShortIdVec(this.view.buffer.slice(offsets[1], offsets[2]), {
1522
+ validate: false,
1523
+ }).validate();
1155
1524
  }
1156
1525
 
1157
1526
  getHeader() {
1158
1527
  const start = 4;
1159
1528
  const offset = this.view.getUint32(start, true);
1160
1529
  const offset_end = this.view.getUint32(start + 4, true);
1161
- return new Header(this.view.buffer.slice(offset, offset_end), { validate: false });
1530
+ return new Header(this.view.buffer.slice(offset, offset_end), {
1531
+ validate: false,
1532
+ });
1162
1533
  }
1163
1534
 
1164
1535
  getProposals() {
1165
1536
  const start = 8;
1166
1537
  const offset = this.view.getUint32(start, true);
1167
1538
  const offset_end = this.view.byteLength;
1168
- return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1539
+ return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
1540
+ validate: false,
1541
+ });
1169
1542
  }
1170
1543
  }
1171
1544
 
@@ -1186,38 +1559,54 @@ export class Block {
1186
1559
 
1187
1560
  validate(compatible = false) {
1188
1561
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1189
- new Header(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1190
- new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1191
- new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
1192
- new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), { validate: false }).validate();
1562
+ new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
1563
+ validate: false,
1564
+ }).validate();
1565
+ new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
1566
+ validate: false,
1567
+ }).validate();
1568
+ new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
1569
+ validate: false,
1570
+ }).validate();
1571
+ new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
1572
+ validate: false,
1573
+ }).validate();
1193
1574
  }
1194
1575
 
1195
1576
  getHeader() {
1196
1577
  const start = 4;
1197
1578
  const offset = this.view.getUint32(start, true);
1198
1579
  const offset_end = this.view.getUint32(start + 4, true);
1199
- return new Header(this.view.buffer.slice(offset, offset_end), { validate: false });
1580
+ return new Header(this.view.buffer.slice(offset, offset_end), {
1581
+ validate: false,
1582
+ });
1200
1583
  }
1201
1584
 
1202
1585
  getUncles() {
1203
1586
  const start = 8;
1204
1587
  const offset = this.view.getUint32(start, true);
1205
1588
  const offset_end = this.view.getUint32(start + 4, true);
1206
- return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1589
+ return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
1590
+ validate: false,
1591
+ });
1207
1592
  }
1208
1593
 
1209
1594
  getTransactions() {
1210
1595
  const start = 12;
1211
1596
  const offset = this.view.getUint32(start, true);
1212
1597
  const offset_end = this.view.getUint32(start + 4, true);
1213
- return new TransactionVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1598
+ return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
1599
+ validate: false,
1600
+ });
1214
1601
  }
1215
1602
 
1216
1603
  getProposals() {
1217
1604
  const start = 16;
1218
1605
  const offset = this.view.getUint32(start, true);
1219
1606
  const offset_end = this.view.byteLength;
1220
- return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1607
+ return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
1608
+ validate: false,
1609
+ });
1221
1610
  }
1222
1611
  }
1223
1612
 
@@ -1240,46 +1629,66 @@ export class BlockV1 {
1240
1629
 
1241
1630
  validate(compatible = false) {
1242
1631
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1243
- new Header(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1244
- new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1245
- new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
1246
- new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), { validate: false }).validate();
1247
- new Bytes(this.view.buffer.slice(offsets[4], offsets[5]), { validate: false }).validate();
1632
+ new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
1633
+ validate: false,
1634
+ }).validate();
1635
+ new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
1636
+ validate: false,
1637
+ }).validate();
1638
+ new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
1639
+ validate: false,
1640
+ }).validate();
1641
+ new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
1642
+ validate: false,
1643
+ }).validate();
1644
+ new Bytes(this.view.buffer.slice(offsets[4], offsets[5]), {
1645
+ validate: false,
1646
+ }).validate();
1248
1647
  }
1249
1648
 
1250
1649
  getHeader() {
1251
1650
  const start = 4;
1252
1651
  const offset = this.view.getUint32(start, true);
1253
1652
  const offset_end = this.view.getUint32(start + 4, true);
1254
- return new Header(this.view.buffer.slice(offset, offset_end), { validate: false });
1653
+ return new Header(this.view.buffer.slice(offset, offset_end), {
1654
+ validate: false,
1655
+ });
1255
1656
  }
1256
1657
 
1257
1658
  getUncles() {
1258
1659
  const start = 8;
1259
1660
  const offset = this.view.getUint32(start, true);
1260
1661
  const offset_end = this.view.getUint32(start + 4, true);
1261
- return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1662
+ return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
1663
+ validate: false,
1664
+ });
1262
1665
  }
1263
1666
 
1264
1667
  getTransactions() {
1265
1668
  const start = 12;
1266
1669
  const offset = this.view.getUint32(start, true);
1267
1670
  const offset_end = this.view.getUint32(start + 4, true);
1268
- return new TransactionVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1671
+ return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
1672
+ validate: false,
1673
+ });
1269
1674
  }
1270
1675
 
1271
1676
  getProposals() {
1272
1677
  const start = 16;
1273
1678
  const offset = this.view.getUint32(start, true);
1274
1679
  const offset_end = this.view.getUint32(start + 4, true);
1275
- return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), { validate: false });
1680
+ return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
1681
+ validate: false,
1682
+ });
1276
1683
  }
1277
1684
 
1278
1685
  getExtension() {
1279
1686
  const start = 20;
1280
1687
  const offset = this.view.getUint32(start, true);
1281
1688
  const offset_end = this.view.byteLength;
1282
- return new Bytes(this.view.buffer.slice(offset, offset_end), { validate: false });
1689
+ return new Bytes(this.view.buffer.slice(offset, offset_end), {
1690
+ validate: false,
1691
+ });
1283
1692
  }
1284
1693
  }
1285
1694
 
@@ -1303,22 +1712,30 @@ export class CellbaseWitness {
1303
1712
 
1304
1713
  validate(compatible = false) {
1305
1714
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1306
- new Script(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1307
- new Bytes(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1715
+ new Script(this.view.buffer.slice(offsets[0], offsets[1]), {
1716
+ validate: false,
1717
+ }).validate();
1718
+ new Bytes(this.view.buffer.slice(offsets[1], offsets[2]), {
1719
+ validate: false,
1720
+ }).validate();
1308
1721
  }
1309
1722
 
1310
1723
  getLock() {
1311
1724
  const start = 4;
1312
1725
  const offset = this.view.getUint32(start, true);
1313
1726
  const offset_end = this.view.getUint32(start + 4, true);
1314
- return new Script(this.view.buffer.slice(offset, offset_end), { validate: false });
1727
+ return new Script(this.view.buffer.slice(offset, offset_end), {
1728
+ validate: false,
1729
+ });
1315
1730
  }
1316
1731
 
1317
1732
  getMessage() {
1318
1733
  const start = 8;
1319
1734
  const offset = this.view.getUint32(start, true);
1320
1735
  const offset_end = this.view.byteLength;
1321
- return new Bytes(this.view.buffer.slice(offset, offset_end), { validate: false });
1736
+ return new Bytes(this.view.buffer.slice(offset, offset_end), {
1737
+ validate: false,
1738
+ });
1322
1739
  }
1323
1740
  }
1324
1741
 
@@ -1339,30 +1756,42 @@ export class WitnessArgs {
1339
1756
 
1340
1757
  validate(compatible = false) {
1341
1758
  const offsets = verifyAndExtractOffsets(this.view, 0, true);
1342
- new BytesOpt(this.view.buffer.slice(offsets[0], offsets[1]), { validate: false }).validate();
1343
- new BytesOpt(this.view.buffer.slice(offsets[1], offsets[2]), { validate: false }).validate();
1344
- new BytesOpt(this.view.buffer.slice(offsets[2], offsets[3]), { validate: false }).validate();
1759
+ new BytesOpt(this.view.buffer.slice(offsets[0], offsets[1]), {
1760
+ validate: false,
1761
+ }).validate();
1762
+ new BytesOpt(this.view.buffer.slice(offsets[1], offsets[2]), {
1763
+ validate: false,
1764
+ }).validate();
1765
+ new BytesOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
1766
+ validate: false,
1767
+ }).validate();
1345
1768
  }
1346
1769
 
1347
1770
  getLock() {
1348
1771
  const start = 4;
1349
1772
  const offset = this.view.getUint32(start, true);
1350
1773
  const offset_end = this.view.getUint32(start + 4, true);
1351
- return new BytesOpt(this.view.buffer.slice(offset, offset_end), { validate: false });
1774
+ return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
1775
+ validate: false,
1776
+ });
1352
1777
  }
1353
1778
 
1354
1779
  getInputType() {
1355
1780
  const start = 8;
1356
1781
  const offset = this.view.getUint32(start, true);
1357
1782
  const offset_end = this.view.getUint32(start + 4, true);
1358
- return new BytesOpt(this.view.buffer.slice(offset, offset_end), { validate: false });
1783
+ return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
1784
+ validate: false,
1785
+ });
1359
1786
  }
1360
1787
 
1361
1788
  getOutputType() {
1362
1789
  const start = 12;
1363
1790
  const offset = this.view.getUint32(start, true);
1364
1791
  const offset_end = this.view.byteLength;
1365
- return new BytesOpt(this.view.buffer.slice(offset, offset_end), { validate: false });
1792
+ return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
1793
+ validate: false,
1794
+ });
1366
1795
  }
1367
1796
  }
1368
1797
 
@@ -1373,4 +1802,3 @@ export function SerializeWitnessArgs(value) {
1373
1802
  buffers.push(SerializeBytesOpt(value.outputType));
1374
1803
  return serializeTable(buffers);
1375
1804
  }
1376
-