@ckb-ccc/core 0.1.0 → 0.1.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 (83) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist.commonjs/address/address.advanced.js +28 -23
  3. package/dist.commonjs/address/advanced.js +17 -1
  4. package/dist.commonjs/address/index.js +15 -11
  5. package/dist.commonjs/advanced.js +31 -2
  6. package/dist.commonjs/advancedBarrel.js +21 -5
  7. package/dist.commonjs/barrel.js +41 -12
  8. package/dist.commonjs/bytes/advanced.js +2 -1
  9. package/dist.commonjs/bytes/index.js +12 -7
  10. package/dist.commonjs/ckb/advanced.js +32 -3
  11. package/dist.commonjs/ckb/index.js +19 -3
  12. package/dist.commonjs/ckb/molecule.advanced/generated.js +131 -64
  13. package/dist.commonjs/ckb/molecule.advanced/index.js +19 -2
  14. package/dist.commonjs/ckb/script.advanced.js +6 -3
  15. package/dist.commonjs/ckb/script.js +53 -23
  16. package/dist.commonjs/ckb/transaction.advanced.js +6 -3
  17. package/dist.commonjs/ckb/transaction.js +163 -122
  18. package/dist.commonjs/ckb/transactionLumos.js +2 -1
  19. package/dist.commonjs/client/advanced.js +22 -6
  20. package/dist.commonjs/client/cache/advanced.js +17 -1
  21. package/dist.commonjs/client/cache/cache.js +7 -3
  22. package/dist.commonjs/client/cache/index.js +18 -2
  23. package/dist.commonjs/client/cache/memory.advanced.js +28 -21
  24. package/dist.commonjs/client/cache/memory.js +23 -19
  25. package/dist.commonjs/client/client.js +25 -21
  26. package/dist.commonjs/client/clientPublicMainnet.advanced.js +25 -22
  27. package/dist.commonjs/client/clientPublicMainnet.js +15 -8
  28. package/dist.commonjs/client/clientPublicTestnet.advanced.js +25 -22
  29. package/dist.commonjs/client/clientPublicTestnet.js +15 -8
  30. package/dist.commonjs/client/clientTypes.advanced.js +6 -3
  31. package/dist.commonjs/client/clientTypes.js +43 -29
  32. package/dist.commonjs/client/index.js +22 -6
  33. package/dist.commonjs/client/jsonRpc/advanced.js +18 -2
  34. package/dist.commonjs/client/jsonRpc/index.js +41 -37
  35. package/dist.commonjs/client/jsonRpc/transformers.js +61 -57
  36. package/dist.commonjs/client/jsonRpc/types.js +2 -1
  37. package/dist.commonjs/client/transports/advanced.js +25 -8
  38. package/dist.commonjs/client/transports/http.js +5 -1
  39. package/dist.commonjs/client/transports/transport.js +2 -1
  40. package/dist.commonjs/client/transports/webSocket.js +10 -3
  41. package/dist.commonjs/fixedPoint/index.js +9 -4
  42. package/dist.commonjs/hasher/advanced.js +4 -1
  43. package/dist.commonjs/hasher/hasher.js +2 -1
  44. package/dist.commonjs/hasher/hasherCkb.js +20 -14
  45. package/dist.commonjs/hasher/hasherKeecak256.js +11 -7
  46. package/dist.commonjs/hasher/index.js +19 -3
  47. package/dist.commonjs/hex/index.js +6 -3
  48. package/dist.commonjs/index.js +31 -2
  49. package/dist.commonjs/keystore/index.js +25 -21
  50. package/dist.commonjs/molecule/codec.js +63 -48
  51. package/dist.commonjs/molecule/index.js +18 -2
  52. package/dist.commonjs/molecule/predefined.js +103 -77
  53. package/dist.commonjs/num/index.js +29 -17
  54. package/dist.commonjs/signer/btc/index.js +19 -3
  55. package/dist.commonjs/signer/btc/signerBtc.js +24 -20
  56. package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +8 -4
  57. package/dist.commonjs/signer/btc/verify.js +26 -17
  58. package/dist.commonjs/signer/ckb/index.js +21 -5
  59. package/dist.commonjs/signer/ckb/signerCkbPrivateKey.js +20 -16
  60. package/dist.commonjs/signer/ckb/signerCkbPublicKey.js +24 -20
  61. package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +12 -8
  62. package/dist.commonjs/signer/ckb/verifyCkbSecp256k1.js +16 -12
  63. package/dist.commonjs/signer/ckb/verifyJoyId.js +8 -5
  64. package/dist.commonjs/signer/doge/index.js +20 -4
  65. package/dist.commonjs/signer/doge/signerDoge.js +26 -19
  66. package/dist.commonjs/signer/doge/signerDogeAddressReadonly.js +6 -2
  67. package/dist.commonjs/signer/doge/signerDogePrivateKey.js +17 -13
  68. package/dist.commonjs/signer/doge/verify.js +15 -12
  69. package/dist.commonjs/signer/dummy/alwaysError.js +6 -2
  70. package/dist.commonjs/signer/dummy/dummy.js +7 -3
  71. package/dist.commonjs/signer/dummy/index.js +19 -3
  72. package/dist.commonjs/signer/dummy/openLink.js +6 -2
  73. package/dist.commonjs/signer/evm/index.js +19 -3
  74. package/dist.commonjs/signer/evm/signerEvm.js +35 -31
  75. package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +8 -4
  76. package/dist.commonjs/signer/evm/verify.js +7 -4
  77. package/dist.commonjs/signer/index.js +23 -7
  78. package/dist.commonjs/signer/nostr/index.js +18 -2
  79. package/dist.commonjs/signer/nostr/signerNostr.js +25 -21
  80. package/dist.commonjs/signer/nostr/verify.js +16 -12
  81. package/dist.commonjs/signer/signer/index.js +25 -19
  82. package/dist.commonjs/utils/index.js +12 -6
  83. package/package.json +6 -2
@@ -1,3 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WitnessArgs = exports.CellbaseWitness = exports.BlockV1 = exports.Block = exports.UncleBlock = exports.Header = exports.RawHeader = exports.Transaction = exports.RawTransaction = exports.CellDep = exports.CellOutput = exports.CellInput = exports.OutPoint = exports.Script = exports.CellOutputVec = exports.CellInputVec = exports.CellDepVec = exports.ProposalShortIdVec = exports.TransactionVec = exports.UncleBlockVec = exports.ProposalShortId = exports.ScriptOpt = exports.Byte32Vec = exports.BytesVec = exports.BytesOptVec = exports.BytesOpt = exports.Bytes = exports.Uint256 = exports.Byte32 = exports.Uint128 = exports.Uint64 = exports.Uint32 = void 0;
4
+ exports.SerializeUint32 = SerializeUint32;
5
+ exports.SerializeUint64 = SerializeUint64;
6
+ exports.SerializeUint128 = SerializeUint128;
7
+ exports.SerializeByte32 = SerializeByte32;
8
+ exports.SerializeUint256 = SerializeUint256;
9
+ exports.SerializeBytes = SerializeBytes;
10
+ exports.SerializeBytesOpt = SerializeBytesOpt;
11
+ exports.SerializeBytesOptVec = SerializeBytesOptVec;
12
+ exports.SerializeBytesVec = SerializeBytesVec;
13
+ exports.SerializeByte32Vec = SerializeByte32Vec;
14
+ exports.SerializeScriptOpt = SerializeScriptOpt;
15
+ exports.SerializeProposalShortId = SerializeProposalShortId;
16
+ exports.SerializeUncleBlockVec = SerializeUncleBlockVec;
17
+ exports.SerializeTransactionVec = SerializeTransactionVec;
18
+ exports.SerializeProposalShortIdVec = SerializeProposalShortIdVec;
19
+ exports.SerializeCellDepVec = SerializeCellDepVec;
20
+ exports.SerializeCellInputVec = SerializeCellInputVec;
21
+ exports.SerializeCellOutputVec = SerializeCellOutputVec;
22
+ exports.SerializeScript = SerializeScript;
23
+ exports.SerializeOutPoint = SerializeOutPoint;
24
+ exports.SerializeCellInput = SerializeCellInput;
25
+ exports.SerializeCellOutput = SerializeCellOutput;
26
+ exports.SerializeCellDep = SerializeCellDep;
27
+ exports.SerializeRawTransaction = SerializeRawTransaction;
28
+ exports.SerializeTransaction = SerializeTransaction;
29
+ exports.SerializeRawHeader = SerializeRawHeader;
30
+ exports.SerializeHeader = SerializeHeader;
31
+ exports.SerializeUncleBlock = SerializeUncleBlock;
32
+ exports.SerializeBlock = SerializeBlock;
33
+ exports.SerializeBlockV1 = SerializeBlockV1;
34
+ exports.SerializeCellbaseWitness = SerializeCellbaseWitness;
35
+ exports.SerializeWitnessArgs = SerializeWitnessArgs;
1
36
  function dataLengthError(actual, required) {
2
37
  throw new Error(`Invalid data length! Required: ${required}, actual: ${actual}`);
3
38
  }
@@ -75,7 +110,7 @@ function serializeTable(buffers) {
75
110
  }
76
111
  return buffer;
77
112
  }
78
- export class Uint32 {
113
+ class Uint32 {
79
114
  constructor(reader, { validate = true } = {}) {
80
115
  this.view = new DataView(assertArrayBuffer(reader));
81
116
  if (validate) {
@@ -101,12 +136,13 @@ export class Uint32 {
101
136
  return 4;
102
137
  }
103
138
  }
104
- export function SerializeUint32(value) {
139
+ exports.Uint32 = Uint32;
140
+ function SerializeUint32(value) {
105
141
  const buffer = assertArrayBuffer(value);
106
142
  assertDataLength(buffer.byteLength, 4);
107
143
  return buffer;
108
144
  }
109
- export class Uint64 {
145
+ class Uint64 {
110
146
  constructor(reader, { validate = true } = {}) {
111
147
  this.view = new DataView(assertArrayBuffer(reader));
112
148
  if (validate) {
@@ -126,12 +162,13 @@ export class Uint64 {
126
162
  return 8;
127
163
  }
128
164
  }
129
- export function SerializeUint64(value) {
165
+ exports.Uint64 = Uint64;
166
+ function SerializeUint64(value) {
130
167
  const buffer = assertArrayBuffer(value);
131
168
  assertDataLength(buffer.byteLength, 8);
132
169
  return buffer;
133
170
  }
134
- export class Uint128 {
171
+ class Uint128 {
135
172
  constructor(reader, { validate = true } = {}) {
136
173
  this.view = new DataView(assertArrayBuffer(reader));
137
174
  if (validate) {
@@ -151,12 +188,13 @@ export class Uint128 {
151
188
  return 16;
152
189
  }
153
190
  }
154
- export function SerializeUint128(value) {
191
+ exports.Uint128 = Uint128;
192
+ function SerializeUint128(value) {
155
193
  const buffer = assertArrayBuffer(value);
156
194
  assertDataLength(buffer.byteLength, 16);
157
195
  return buffer;
158
196
  }
159
- export class Byte32 {
197
+ class Byte32 {
160
198
  constructor(reader, { validate = true } = {}) {
161
199
  this.view = new DataView(assertArrayBuffer(reader));
162
200
  if (validate) {
@@ -176,12 +214,13 @@ export class Byte32 {
176
214
  return 32;
177
215
  }
178
216
  }
179
- export function SerializeByte32(value) {
217
+ exports.Byte32 = Byte32;
218
+ function SerializeByte32(value) {
180
219
  const buffer = assertArrayBuffer(value);
181
220
  assertDataLength(buffer.byteLength, 32);
182
221
  return buffer;
183
222
  }
184
- export class Uint256 {
223
+ class Uint256 {
185
224
  constructor(reader, { validate = true } = {}) {
186
225
  this.view = new DataView(assertArrayBuffer(reader));
187
226
  if (validate) {
@@ -201,12 +240,13 @@ export class Uint256 {
201
240
  return 32;
202
241
  }
203
242
  }
204
- export function SerializeUint256(value) {
243
+ exports.Uint256 = Uint256;
244
+ function SerializeUint256(value) {
205
245
  const buffer = assertArrayBuffer(value);
206
246
  assertDataLength(buffer.byteLength, 32);
207
247
  return buffer;
208
248
  }
209
- export class Bytes {
249
+ class Bytes {
210
250
  constructor(reader, { validate = true } = {}) {
211
251
  this.view = new DataView(assertArrayBuffer(reader));
212
252
  if (validate) {
@@ -230,14 +270,15 @@ export class Bytes {
230
270
  return this.view.getUint32(0, true);
231
271
  }
232
272
  }
233
- export function SerializeBytes(value) {
273
+ exports.Bytes = Bytes;
274
+ function SerializeBytes(value) {
234
275
  const item = assertArrayBuffer(value);
235
276
  const array = new Uint8Array(4 + item.byteLength);
236
277
  new DataView(array.buffer).setUint32(0, item.byteLength, true);
237
278
  array.set(new Uint8Array(item), 4);
238
279
  return array.buffer;
239
280
  }
240
- export class BytesOpt {
281
+ class BytesOpt {
241
282
  constructor(reader, { validate = true } = {}) {
242
283
  this.view = new DataView(assertArrayBuffer(reader));
243
284
  if (validate) {
@@ -256,7 +297,8 @@ export class BytesOpt {
256
297
  return this.view.byteLength > 0;
257
298
  }
258
299
  }
259
- export function SerializeBytesOpt(value) {
300
+ exports.BytesOpt = BytesOpt;
301
+ function SerializeBytesOpt(value) {
260
302
  if (value) {
261
303
  return SerializeBytes(value);
262
304
  }
@@ -264,7 +306,7 @@ export function SerializeBytesOpt(value) {
264
306
  return new ArrayBuffer(0);
265
307
  }
266
308
  }
267
- export class BytesOptVec {
309
+ class BytesOptVec {
268
310
  constructor(reader, { validate = true } = {}) {
269
311
  this.view = new DataView(assertArrayBuffer(reader));
270
312
  if (validate) {
@@ -299,10 +341,11 @@ export class BytesOptVec {
299
341
  });
300
342
  }
301
343
  }
302
- export function SerializeBytesOptVec(value) {
344
+ exports.BytesOptVec = BytesOptVec;
345
+ function SerializeBytesOptVec(value) {
303
346
  return serializeTable(value.map((item) => SerializeBytesOpt(item)));
304
347
  }
305
- export class BytesVec {
348
+ class BytesVec {
306
349
  constructor(reader, { validate = true } = {}) {
307
350
  this.view = new DataView(assertArrayBuffer(reader));
308
351
  if (validate) {
@@ -337,10 +380,11 @@ export class BytesVec {
337
380
  });
338
381
  }
339
382
  }
340
- export function SerializeBytesVec(value) {
383
+ exports.BytesVec = BytesVec;
384
+ function SerializeBytesVec(value) {
341
385
  return serializeTable(value.map((item) => SerializeBytes(item)));
342
386
  }
343
- export class Byte32Vec {
387
+ class Byte32Vec {
344
388
  constructor(reader, { validate = true } = {}) {
345
389
  this.view = new DataView(assertArrayBuffer(reader));
346
390
  if (validate) {
@@ -365,7 +409,8 @@ export class Byte32Vec {
365
409
  return this.view.getUint32(0, true);
366
410
  }
367
411
  }
368
- export function SerializeByte32Vec(value) {
412
+ exports.Byte32Vec = Byte32Vec;
413
+ function SerializeByte32Vec(value) {
369
414
  const array = new Uint8Array(4 + Byte32.size() * value.length);
370
415
  new DataView(array.buffer).setUint32(0, value.length, true);
371
416
  for (let i = 0; i < value.length; i++) {
@@ -374,7 +419,7 @@ export function SerializeByte32Vec(value) {
374
419
  }
375
420
  return array.buffer;
376
421
  }
377
- export class ScriptOpt {
422
+ class ScriptOpt {
378
423
  constructor(reader, { validate = true } = {}) {
379
424
  this.view = new DataView(assertArrayBuffer(reader));
380
425
  if (validate) {
@@ -393,7 +438,8 @@ export class ScriptOpt {
393
438
  return this.view.byteLength > 0;
394
439
  }
395
440
  }
396
- export function SerializeScriptOpt(value) {
441
+ exports.ScriptOpt = ScriptOpt;
442
+ function SerializeScriptOpt(value) {
397
443
  if (value) {
398
444
  return SerializeScript(value);
399
445
  }
@@ -401,7 +447,7 @@ export function SerializeScriptOpt(value) {
401
447
  return new ArrayBuffer(0);
402
448
  }
403
449
  }
404
- export class ProposalShortId {
450
+ class ProposalShortId {
405
451
  constructor(reader, { validate = true } = {}) {
406
452
  this.view = new DataView(assertArrayBuffer(reader));
407
453
  if (validate) {
@@ -421,12 +467,13 @@ export class ProposalShortId {
421
467
  return 10;
422
468
  }
423
469
  }
424
- export function SerializeProposalShortId(value) {
470
+ exports.ProposalShortId = ProposalShortId;
471
+ function SerializeProposalShortId(value) {
425
472
  const buffer = assertArrayBuffer(value);
426
473
  assertDataLength(buffer.byteLength, 10);
427
474
  return buffer;
428
475
  }
429
- export class UncleBlockVec {
476
+ class UncleBlockVec {
430
477
  constructor(reader, { validate = true } = {}) {
431
478
  this.view = new DataView(assertArrayBuffer(reader));
432
479
  if (validate) {
@@ -461,10 +508,11 @@ export class UncleBlockVec {
461
508
  });
462
509
  }
463
510
  }
464
- export function SerializeUncleBlockVec(value) {
511
+ exports.UncleBlockVec = UncleBlockVec;
512
+ function SerializeUncleBlockVec(value) {
465
513
  return serializeTable(value.map((item) => SerializeUncleBlock(item)));
466
514
  }
467
- export class TransactionVec {
515
+ class TransactionVec {
468
516
  constructor(reader, { validate = true } = {}) {
469
517
  this.view = new DataView(assertArrayBuffer(reader));
470
518
  if (validate) {
@@ -499,10 +547,11 @@ export class TransactionVec {
499
547
  });
500
548
  }
501
549
  }
502
- export function SerializeTransactionVec(value) {
550
+ exports.TransactionVec = TransactionVec;
551
+ function SerializeTransactionVec(value) {
503
552
  return serializeTable(value.map((item) => SerializeTransaction(item)));
504
553
  }
505
- export class ProposalShortIdVec {
554
+ class ProposalShortIdVec {
506
555
  constructor(reader, { validate = true } = {}) {
507
556
  this.view = new DataView(assertArrayBuffer(reader));
508
557
  if (validate) {
@@ -527,7 +576,8 @@ export class ProposalShortIdVec {
527
576
  return this.view.getUint32(0, true);
528
577
  }
529
578
  }
530
- export function SerializeProposalShortIdVec(value) {
579
+ exports.ProposalShortIdVec = ProposalShortIdVec;
580
+ function SerializeProposalShortIdVec(value) {
531
581
  const array = new Uint8Array(4 + ProposalShortId.size() * value.length);
532
582
  new DataView(array.buffer).setUint32(0, value.length, true);
533
583
  for (let i = 0; i < value.length; i++) {
@@ -536,7 +586,7 @@ export function SerializeProposalShortIdVec(value) {
536
586
  }
537
587
  return array.buffer;
538
588
  }
539
- export class CellDepVec {
589
+ class CellDepVec {
540
590
  constructor(reader, { validate = true } = {}) {
541
591
  this.view = new DataView(assertArrayBuffer(reader));
542
592
  if (validate) {
@@ -561,7 +611,8 @@ export class CellDepVec {
561
611
  return this.view.getUint32(0, true);
562
612
  }
563
613
  }
564
- export function SerializeCellDepVec(value) {
614
+ exports.CellDepVec = CellDepVec;
615
+ function SerializeCellDepVec(value) {
565
616
  const array = new Uint8Array(4 + CellDep.size() * value.length);
566
617
  new DataView(array.buffer).setUint32(0, value.length, true);
567
618
  for (let i = 0; i < value.length; i++) {
@@ -570,7 +621,7 @@ export function SerializeCellDepVec(value) {
570
621
  }
571
622
  return array.buffer;
572
623
  }
573
- export class CellInputVec {
624
+ class CellInputVec {
574
625
  constructor(reader, { validate = true } = {}) {
575
626
  this.view = new DataView(assertArrayBuffer(reader));
576
627
  if (validate) {
@@ -595,7 +646,8 @@ export class CellInputVec {
595
646
  return this.view.getUint32(0, true);
596
647
  }
597
648
  }
598
- export function SerializeCellInputVec(value) {
649
+ exports.CellInputVec = CellInputVec;
650
+ function SerializeCellInputVec(value) {
599
651
  const array = new Uint8Array(4 + CellInput.size() * value.length);
600
652
  new DataView(array.buffer).setUint32(0, value.length, true);
601
653
  for (let i = 0; i < value.length; i++) {
@@ -604,7 +656,7 @@ export function SerializeCellInputVec(value) {
604
656
  }
605
657
  return array.buffer;
606
658
  }
607
- export class CellOutputVec {
659
+ class CellOutputVec {
608
660
  constructor(reader, { validate = true } = {}) {
609
661
  this.view = new DataView(assertArrayBuffer(reader));
610
662
  if (validate) {
@@ -639,10 +691,11 @@ export class CellOutputVec {
639
691
  });
640
692
  }
641
693
  }
642
- export function SerializeCellOutputVec(value) {
694
+ exports.CellOutputVec = CellOutputVec;
695
+ function SerializeCellOutputVec(value) {
643
696
  return serializeTable(value.map((item) => SerializeCellOutput(item)));
644
697
  }
645
- export class Script {
698
+ class Script {
646
699
  constructor(reader, { validate = true } = {}) {
647
700
  this.view = new DataView(assertArrayBuffer(reader));
648
701
  if (validate) {
@@ -684,7 +737,8 @@ export class Script {
684
737
  });
685
738
  }
686
739
  }
687
- export function SerializeScript(value) {
740
+ exports.Script = Script;
741
+ function SerializeScript(value) {
688
742
  const buffers = [];
689
743
  buffers.push(SerializeByte32(value.codeHash));
690
744
  const hashTypeView = new DataView(new ArrayBuffer(1));
@@ -693,7 +747,7 @@ export function SerializeScript(value) {
693
747
  buffers.push(SerializeBytes(value.args));
694
748
  return serializeTable(buffers);
695
749
  }
696
- export class OutPoint {
750
+ class OutPoint {
697
751
  constructor(reader, { validate = true } = {}) {
698
752
  this.view = new DataView(assertArrayBuffer(reader));
699
753
  if (validate) {
@@ -717,14 +771,15 @@ export class OutPoint {
717
771
  return 0 + Byte32.size() + Uint32.size();
718
772
  }
719
773
  }
720
- export function SerializeOutPoint(value) {
774
+ exports.OutPoint = OutPoint;
775
+ function SerializeOutPoint(value) {
721
776
  const array = new Uint8Array(0 + Byte32.size() + Uint32.size());
722
777
  const view = new DataView(array.buffer);
723
778
  array.set(new Uint8Array(SerializeByte32(value.txHash)), 0);
724
779
  array.set(new Uint8Array(SerializeUint32(value.index)), 0 + Byte32.size());
725
780
  return array.buffer;
726
781
  }
727
- export class CellInput {
782
+ class CellInput {
728
783
  constructor(reader, { validate = true } = {}) {
729
784
  this.view = new DataView(assertArrayBuffer(reader));
730
785
  if (validate) {
@@ -748,14 +803,15 @@ export class CellInput {
748
803
  return 0 + Uint64.size() + OutPoint.size();
749
804
  }
750
805
  }
751
- export function SerializeCellInput(value) {
806
+ exports.CellInput = CellInput;
807
+ function SerializeCellInput(value) {
752
808
  const array = new Uint8Array(0 + Uint64.size() + OutPoint.size());
753
809
  const view = new DataView(array.buffer);
754
810
  array.set(new Uint8Array(SerializeUint64(value.since)), 0);
755
811
  array.set(new Uint8Array(SerializeOutPoint(value.previousOutput)), 0 + Uint64.size());
756
812
  return array.buffer;
757
813
  }
758
- export class CellOutput {
814
+ class CellOutput {
759
815
  constructor(reader, { validate = true } = {}) {
760
816
  this.view = new DataView(assertArrayBuffer(reader));
761
817
  if (validate) {
@@ -799,14 +855,15 @@ export class CellOutput {
799
855
  });
800
856
  }
801
857
  }
802
- export function SerializeCellOutput(value) {
858
+ exports.CellOutput = CellOutput;
859
+ function SerializeCellOutput(value) {
803
860
  const buffers = [];
804
861
  buffers.push(SerializeUint64(value.capacity));
805
862
  buffers.push(SerializeScript(value.lock));
806
863
  buffers.push(SerializeScriptOpt(value.type));
807
864
  return serializeTable(buffers);
808
865
  }
809
- export class CellDep {
866
+ class CellDep {
810
867
  constructor(reader, { validate = true } = {}) {
811
868
  this.view = new DataView(assertArrayBuffer(reader));
812
869
  if (validate) {
@@ -829,14 +886,15 @@ export class CellDep {
829
886
  return 0 + OutPoint.size() + 1;
830
887
  }
831
888
  }
832
- export function SerializeCellDep(value) {
889
+ exports.CellDep = CellDep;
890
+ function SerializeCellDep(value) {
833
891
  const array = new Uint8Array(0 + OutPoint.size() + 1);
834
892
  const view = new DataView(array.buffer);
835
893
  array.set(new Uint8Array(SerializeOutPoint(value.outPoint)), 0);
836
894
  view.setUint8(0 + OutPoint.size(), value.depType);
837
895
  return array.buffer;
838
896
  }
839
- export class RawTransaction {
897
+ class RawTransaction {
840
898
  constructor(reader, { validate = true } = {}) {
841
899
  this.view = new DataView(assertArrayBuffer(reader));
842
900
  if (validate) {
@@ -913,7 +971,8 @@ export class RawTransaction {
913
971
  });
914
972
  }
915
973
  }
916
- export function SerializeRawTransaction(value) {
974
+ exports.RawTransaction = RawTransaction;
975
+ function SerializeRawTransaction(value) {
917
976
  const buffers = [];
918
977
  buffers.push(SerializeUint32(value.version));
919
978
  buffers.push(SerializeCellDepVec(value.cellDeps));
@@ -923,7 +982,7 @@ export function SerializeRawTransaction(value) {
923
982
  buffers.push(SerializeBytesVec(value.outputsData));
924
983
  return serializeTable(buffers);
925
984
  }
926
- export class Transaction {
985
+ class Transaction {
927
986
  constructor(reader, { validate = true } = {}) {
928
987
  this.view = new DataView(assertArrayBuffer(reader));
929
988
  if (validate) {
@@ -956,13 +1015,14 @@ export class Transaction {
956
1015
  });
957
1016
  }
958
1017
  }
959
- export function SerializeTransaction(value) {
1018
+ exports.Transaction = Transaction;
1019
+ function SerializeTransaction(value) {
960
1020
  const buffers = [];
961
1021
  buffers.push(SerializeRawTransaction(value.raw));
962
1022
  buffers.push(SerializeBytesVec(value.witnesses));
963
1023
  return serializeTable(buffers);
964
1024
  }
965
- export class RawHeader {
1025
+ class RawHeader {
966
1026
  constructor(reader, { validate = true } = {}) {
967
1027
  this.view = new DataView(assertArrayBuffer(reader));
968
1028
  if (validate) {
@@ -1108,7 +1168,8 @@ export class RawHeader {
1108
1168
  Byte32.size());
1109
1169
  }
1110
1170
  }
1111
- export function SerializeRawHeader(value) {
1171
+ exports.RawHeader = RawHeader;
1172
+ function SerializeRawHeader(value) {
1112
1173
  const array = new Uint8Array(0 +
1113
1174
  Uint32.size() +
1114
1175
  Uint32.size() +
@@ -1168,7 +1229,7 @@ export function SerializeRawHeader(value) {
1168
1229
  Byte32.size());
1169
1230
  return array.buffer;
1170
1231
  }
1171
- export class Header {
1232
+ class Header {
1172
1233
  constructor(reader, { validate = true } = {}) {
1173
1234
  this.view = new DataView(assertArrayBuffer(reader));
1174
1235
  if (validate) {
@@ -1192,14 +1253,15 @@ export class Header {
1192
1253
  return 0 + RawHeader.size() + Uint128.size();
1193
1254
  }
1194
1255
  }
1195
- export function SerializeHeader(value) {
1256
+ exports.Header = Header;
1257
+ function SerializeHeader(value) {
1196
1258
  const array = new Uint8Array(0 + RawHeader.size() + Uint128.size());
1197
1259
  const view = new DataView(array.buffer);
1198
1260
  array.set(new Uint8Array(SerializeRawHeader(value.raw)), 0);
1199
1261
  array.set(new Uint8Array(SerializeUint128(value.nonce)), 0 + RawHeader.size());
1200
1262
  return array.buffer;
1201
1263
  }
1202
- export class UncleBlock {
1264
+ class UncleBlock {
1203
1265
  constructor(reader, { validate = true } = {}) {
1204
1266
  this.view = new DataView(assertArrayBuffer(reader));
1205
1267
  if (validate) {
@@ -1232,13 +1294,14 @@ export class UncleBlock {
1232
1294
  });
1233
1295
  }
1234
1296
  }
1235
- export function SerializeUncleBlock(value) {
1297
+ exports.UncleBlock = UncleBlock;
1298
+ function SerializeUncleBlock(value) {
1236
1299
  const buffers = [];
1237
1300
  buffers.push(SerializeHeader(value.header));
1238
1301
  buffers.push(SerializeProposalShortIdVec(value.proposals));
1239
1302
  return serializeTable(buffers);
1240
1303
  }
1241
- export class Block {
1304
+ class Block {
1242
1305
  constructor(reader, { validate = true } = {}) {
1243
1306
  this.view = new DataView(assertArrayBuffer(reader));
1244
1307
  if (validate) {
@@ -1293,7 +1356,8 @@ export class Block {
1293
1356
  });
1294
1357
  }
1295
1358
  }
1296
- export function SerializeBlock(value) {
1359
+ exports.Block = Block;
1360
+ function SerializeBlock(value) {
1297
1361
  const buffers = [];
1298
1362
  buffers.push(SerializeHeader(value.header));
1299
1363
  buffers.push(SerializeUncleBlockVec(value.uncles));
@@ -1301,7 +1365,7 @@ export function SerializeBlock(value) {
1301
1365
  buffers.push(SerializeProposalShortIdVec(value.proposals));
1302
1366
  return serializeTable(buffers);
1303
1367
  }
1304
- export class BlockV1 {
1368
+ class BlockV1 {
1305
1369
  constructor(reader, { validate = true } = {}) {
1306
1370
  this.view = new DataView(assertArrayBuffer(reader));
1307
1371
  if (validate) {
@@ -1367,7 +1431,8 @@ export class BlockV1 {
1367
1431
  });
1368
1432
  }
1369
1433
  }
1370
- export function SerializeBlockV1(value) {
1434
+ exports.BlockV1 = BlockV1;
1435
+ function SerializeBlockV1(value) {
1371
1436
  const buffers = [];
1372
1437
  buffers.push(SerializeHeader(value.header));
1373
1438
  buffers.push(SerializeUncleBlockVec(value.uncles));
@@ -1376,7 +1441,7 @@ export function SerializeBlockV1(value) {
1376
1441
  buffers.push(SerializeBytes(value.extension));
1377
1442
  return serializeTable(buffers);
1378
1443
  }
1379
- export class CellbaseWitness {
1444
+ class CellbaseWitness {
1380
1445
  constructor(reader, { validate = true } = {}) {
1381
1446
  this.view = new DataView(assertArrayBuffer(reader));
1382
1447
  if (validate) {
@@ -1409,13 +1474,14 @@ export class CellbaseWitness {
1409
1474
  });
1410
1475
  }
1411
1476
  }
1412
- export function SerializeCellbaseWitness(value) {
1477
+ exports.CellbaseWitness = CellbaseWitness;
1478
+ function SerializeCellbaseWitness(value) {
1413
1479
  const buffers = [];
1414
1480
  buffers.push(SerializeScript(value.lock));
1415
1481
  buffers.push(SerializeBytes(value.message));
1416
1482
  return serializeTable(buffers);
1417
1483
  }
1418
- export class WitnessArgs {
1484
+ class WitnessArgs {
1419
1485
  constructor(reader, { validate = true } = {}) {
1420
1486
  this.view = new DataView(assertArrayBuffer(reader));
1421
1487
  if (validate) {
@@ -1459,7 +1525,8 @@ export class WitnessArgs {
1459
1525
  });
1460
1526
  }
1461
1527
  }
1462
- export function SerializeWitnessArgs(value) {
1528
+ exports.WitnessArgs = WitnessArgs;
1529
+ function SerializeWitnessArgs(value) {
1463
1530
  const buffers = [];
1464
1531
  buffers.push(SerializeBytesOpt(value.lock));
1465
1532
  buffers.push(SerializeBytesOpt(value.inputType));
@@ -1,5 +1,22 @@
1
- export * from "./generated.js";
2
- export function molOptional(mol) {
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.molOptional = molOptional;
18
+ __exportStar(require("./generated.js"), exports);
19
+ function molOptional(mol) {
3
20
  if (mol.hasValue()) {
4
21
  return mol.value();
5
22
  }
@@ -1,13 +1,16 @@
1
- export const HASH_TYPE_TO_NUM = {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HASH_TYPES = exports.NUM_TO_HASH_TYPE = exports.HASH_TYPE_TO_NUM = void 0;
4
+ exports.HASH_TYPE_TO_NUM = {
2
5
  type: 0x01,
3
6
  data: 0x00,
4
7
  data1: 0x02,
5
8
  data2: 0x04,
6
9
  };
7
- export const NUM_TO_HASH_TYPE = {
10
+ exports.NUM_TO_HASH_TYPE = {
8
11
  0x01: "type",
9
12
  0x00: "data",
10
13
  0x02: "data1",
11
14
  0x04: "data2",
12
15
  };
13
- export const HASH_TYPES = Object.keys(HASH_TYPE_TO_NUM);
16
+ exports.HASH_TYPES = Object.keys(exports.HASH_TYPE_TO_NUM);