@ckb-ccc/core 0.0.2-alpha.1 → 0.0.2-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +12 -0
- package/dist/address/address.advanced.d.ts +29 -3
- package/dist/address/address.advanced.d.ts.map +1 -1
- package/dist/address/address.advanced.js +69 -22
- package/dist/address/advanced.d.ts +1 -28
- package/dist/address/advanced.d.ts.map +1 -1
- package/dist/address/advanced.js +3 -61
- package/dist/address/index.d.ts +10 -13
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +18 -18
- package/dist/advancedBarrel.d.ts +1 -0
- package/dist/advancedBarrel.d.ts.map +1 -1
- package/dist/advancedBarrel.js +1 -0
- package/dist/barrel.d.ts +4 -2
- package/dist/barrel.d.ts.map +1 -1
- package/dist/barrel.js +4 -2
- package/dist/bytes/index.d.ts +7 -0
- package/dist/bytes/index.d.ts.map +1 -0
- package/dist/bytes/index.js +41 -0
- package/dist/ckb/advanced.d.ts +3 -2
- package/dist/ckb/advanced.d.ts.map +1 -1
- package/dist/ckb/advanced.js +16 -2
- package/dist/ckb/index.d.ts +2 -3
- package/dist/ckb/index.d.ts.map +1 -1
- package/dist/ckb/index.js +2 -3
- package/dist/ckb/molecule.advanced/generated.d.ts.map +1 -0
- package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +378 -97
- package/dist/ckb/molecule.advanced/index.d.ts +6 -0
- package/dist/ckb/molecule.advanced/index.d.ts.map +1 -0
- package/dist/ckb/{types/molecule.advanced → molecule.advanced}/index.js +8 -0
- package/dist/ckb/{types/script.advanced.d.ts → script.advanced.d.ts} +1 -0
- package/dist/ckb/script.advanced.d.ts.map +1 -0
- package/dist/ckb/{types/script.advanced.js → script.advanced.js} +2 -1
- package/dist/ckb/script.d.ts +29 -0
- package/dist/ckb/script.d.ts.map +1 -0
- package/dist/ckb/script.js +91 -0
- package/dist/ckb/{types/transaction.advanced.d.ts → transaction.advanced.d.ts} +1 -0
- package/dist/ckb/transaction.advanced.d.ts.map +1 -0
- package/dist/ckb/{types/transaction.advanced.js → transaction.advanced.js} +2 -1
- package/dist/ckb/transaction.d.ts +142 -0
- package/dist/ckb/transaction.d.ts.map +1 -0
- package/dist/ckb/transaction.js +262 -0
- package/dist/client/client.d.ts +4 -4
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.d.ts +2 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts +2 -2
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.d.ts +2 -2
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/jsonRpc/advanced.d.ts +36 -36
- package/dist/client/jsonRpc/advanced.d.ts.map +1 -1
- package/dist/client/jsonRpc/advanced.js +11 -11
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +1 -1
- package/dist/fixedPoint/index.d.ts +7 -0
- package/dist/fixedPoint/index.d.ts.map +1 -0
- package/dist/{fixedPoint.js → fixedPoint/index.js} +9 -12
- package/dist/{ckb/hasher.advanced.d.ts → hasher/advanced.d.ts} +1 -1
- package/dist/hasher/advanced.d.ts.map +1 -0
- package/dist/{ckb/hasher.d.ts → hasher/index.d.ts} +3 -2
- package/dist/hasher/index.d.ts.map +1 -0
- package/dist/{ckb/hasher.js → hasher/index.js} +4 -4
- package/dist/hex/index.d.ts +5 -0
- package/dist/hex/index.d.ts.map +1 -0
- package/dist/hex/index.js +9 -0
- package/dist/num/index.d.ts +13 -0
- package/dist/num/index.d.ts.map +1 -0
- package/dist/num/index.js +47 -0
- package/dist/signer/helpers.d.ts +3 -3
- package/dist/signer/helpers.d.ts.map +1 -1
- package/dist/signer/helpers.js +7 -4
- package/dist/signer/index.d.ts +2 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +2 -0
- package/dist/signer/signer.d.ts +12 -3
- package/dist/signer/signer.d.ts.map +1 -1
- package/dist/signer/signer.js +13 -2
- package/dist/signer/signerReadonly.d.ts +8 -0
- package/dist/signer/signerReadonly.d.ts.map +1 -0
- package/dist/signer/signerReadonly.js +13 -0
- package/dist/{ckb/viewerCkbScript.d.ts → signer/signerReadonlyCkbScript.d.ts} +6 -5
- package/dist/signer/signerReadonlyCkbScript.d.ts.map +1 -0
- package/dist/{ckb/viewerCkbScript.js → signer/signerReadonlyCkbScript.js} +7 -4
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +10 -0
- package/package.json +5 -3
- package/src/address/address.advanced.ts +76 -19
- package/src/address/advanced.ts +1 -59
- package/src/address/index.ts +46 -28
- package/src/advancedBarrel.ts +1 -0
- package/src/barrel.ts +4 -2
- package/src/bytes/index.ts +46 -0
- package/src/ckb/advanced.ts +3 -2
- package/src/ckb/index.ts +2 -3
- package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +18 -7
- package/src/ckb/{types/molecule.advanced → molecule.advanced}/generated.js +551 -123
- package/src/ckb/molecule.advanced/index.ts +11 -0
- package/src/ckb/{types/script.advanced.ts → script.advanced.ts} +1 -0
- package/src/ckb/script.ts +94 -0
- package/src/ckb/{types/transaction.advanced.ts → transaction.advanced.ts} +1 -0
- package/src/ckb/transaction.ts +357 -0
- package/src/client/client.ts +4 -4
- package/src/client/clientPublicMainnet.advanced.ts +2 -2
- package/src/client/clientPublicMainnet.ts +2 -2
- package/src/client/clientPublicTestnet.advanced.ts +2 -2
- package/src/client/clientPublicTestnet.ts +2 -2
- package/src/client/clientTypes.ts +1 -1
- package/src/client/jsonRpc/advanced.ts +25 -25
- package/src/client/jsonRpc/index.ts +1 -3
- package/src/fixedPoint/index.ts +30 -0
- package/src/{ckb/hasher.ts → hasher/index.ts} +5 -5
- package/src/hex/index.ts +9 -0
- package/src/index.ts +1 -1
- package/src/num/index.ts +53 -0
- package/src/signer/helpers.ts +9 -6
- package/src/signer/index.ts +3 -1
- package/src/signer/signer.ts +23 -3
- package/src/signer/signerReadonly.ts +13 -0
- package/src/{ckb/viewerCkbScript.ts → signer/signerReadonlyCkbScript.ts} +8 -4
- package/src/utils/index.ts +28 -0
- package/dist/bytes.d.ts +0 -15
- package/dist/bytes.d.ts.map +0 -1
- package/dist/bytes.js +0 -114
- package/dist/ckb/hasher.advanced.d.ts.map +0 -1
- package/dist/ckb/hasher.d.ts.map +0 -1
- package/dist/ckb/types/advanced.d.ts +0 -4
- package/dist/ckb/types/advanced.d.ts.map +0 -1
- package/dist/ckb/types/advanced.js +0 -32
- package/dist/ckb/types/index.d.ts +0 -3
- package/dist/ckb/types/index.d.ts.map +0 -1
- package/dist/ckb/types/index.js +0 -18
- package/dist/ckb/types/molecule.advanced/generated.d.ts.map +0 -1
- package/dist/ckb/types/molecule.advanced/index.d.ts +0 -2
- package/dist/ckb/types/molecule.advanced/index.d.ts.map +0 -1
- package/dist/ckb/types/script.advanced.d.ts.map +0 -1
- package/dist/ckb/types/script.d.ts +0 -26
- package/dist/ckb/types/script.d.ts.map +0 -1
- package/dist/ckb/types/script.js +0 -75
- package/dist/ckb/types/transaction.advanced.d.ts.map +0 -1
- package/dist/ckb/types/transaction.d.ts +0 -127
- package/dist/ckb/types/transaction.d.ts.map +0 -1
- package/dist/ckb/types/transaction.js +0 -266
- package/dist/ckb/viewerCkbScript.d.ts.map +0 -1
- package/dist/fixedPoint.d.ts +0 -9
- package/dist/fixedPoint.d.ts.map +0 -1
- package/dist/primitive.d.ts +0 -5
- package/dist/primitive.d.ts.map +0 -1
- package/dist/primitive.js +0 -2
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/viewer.d.ts +0 -12
- package/dist/viewer.d.ts.map +0 -1
- package/dist/viewer.js +0 -19
- package/src/bytes.ts +0 -127
- package/src/ckb/types/advanced.ts +0 -3
- package/src/ckb/types/index.ts +0 -2
- package/src/ckb/types/molecule.advanced/index.ts +0 -1
- package/src/ckb/types/script.ts +0 -70
- package/src/ckb/types/transaction.ts +0 -366
- package/src/fixedPoint.ts +0 -53
- package/src/primitive.ts +0 -8
- package/src/viewer.ts +0 -22
- /package/dist/ckb/{types/molecule.advanced → molecule.advanced}/generated.d.ts +0 -0
- /package/dist/{ckb/hasher.advanced.js → hasher/advanced.js} +0 -0
- /package/src/ckb/{types/molecule.advanced → molecule.advanced}/blockchain.mol +0 -0
- /package/src/{ckb/hasher.advanced.ts → hasher/advanced.ts} +0 -0
|
@@ -42,7 +42,7 @@ function verifyAndExtractOffsets(view, expectedFieldCount, compatible) {
|
|
|
42
42
|
if (itemCount < expectedFieldCount) {
|
|
43
43
|
throw new Error(`Item count not enough! Required: ${expectedFieldCount}, actual: ${itemCount}`);
|
|
44
44
|
}
|
|
45
|
-
else if (
|
|
45
|
+
else if (!compatible && itemCount > expectedFieldCount) {
|
|
46
46
|
throw new Error(`Item count is more than required! Required: ${expectedFieldCount}, actual: ${itemCount}`);
|
|
47
47
|
}
|
|
48
48
|
if (requiredByteLength < firstOffset) {
|
|
@@ -248,7 +248,7 @@ exports.Bytes = Bytes;
|
|
|
248
248
|
function SerializeBytes(value) {
|
|
249
249
|
const item = assertArrayBuffer(value);
|
|
250
250
|
const array = new Uint8Array(4 + item.byteLength);
|
|
251
|
-
|
|
251
|
+
new DataView(array.buffer).setUint32(0, item.byteLength, true);
|
|
252
252
|
array.set(new Uint8Array(item), 4);
|
|
253
253
|
return array.buffer;
|
|
254
254
|
}
|
|
@@ -292,7 +292,9 @@ class BytesOptVec {
|
|
|
292
292
|
validate(compatible = false) {
|
|
293
293
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
294
294
|
for (let i = 0; i < offsets.length - 1; i++) {
|
|
295
|
-
new BytesOpt(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
295
|
+
new BytesOpt(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
296
|
+
validate: false,
|
|
297
|
+
}).validate();
|
|
296
298
|
}
|
|
297
299
|
}
|
|
298
300
|
length() {
|
|
@@ -310,12 +312,14 @@ class BytesOptVec {
|
|
|
310
312
|
if (i + 1 < this.length()) {
|
|
311
313
|
offset_end = this.view.getUint32(start + 4, true);
|
|
312
314
|
}
|
|
313
|
-
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
315
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
316
|
+
validate: false,
|
|
317
|
+
});
|
|
314
318
|
}
|
|
315
319
|
}
|
|
316
320
|
exports.BytesOptVec = BytesOptVec;
|
|
317
321
|
function SerializeBytesOptVec(value) {
|
|
318
|
-
return serializeTable(value.map(item => SerializeBytesOpt(item)));
|
|
322
|
+
return serializeTable(value.map((item) => SerializeBytesOpt(item)));
|
|
319
323
|
}
|
|
320
324
|
exports.SerializeBytesOptVec = SerializeBytesOptVec;
|
|
321
325
|
class BytesVec {
|
|
@@ -328,7 +332,9 @@ class BytesVec {
|
|
|
328
332
|
validate(compatible = false) {
|
|
329
333
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
330
334
|
for (let i = 0; i < offsets.length - 1; i++) {
|
|
331
|
-
new Bytes(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
335
|
+
new Bytes(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
336
|
+
validate: false,
|
|
337
|
+
}).validate();
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
length() {
|
|
@@ -346,12 +352,14 @@ class BytesVec {
|
|
|
346
352
|
if (i + 1 < this.length()) {
|
|
347
353
|
offset_end = this.view.getUint32(start + 4, true);
|
|
348
354
|
}
|
|
349
|
-
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
355
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
356
|
+
validate: false,
|
|
357
|
+
});
|
|
350
358
|
}
|
|
351
359
|
}
|
|
352
360
|
exports.BytesVec = BytesVec;
|
|
353
361
|
function SerializeBytesVec(value) {
|
|
354
|
-
return serializeTable(value.map(item => SerializeBytes(item)));
|
|
362
|
+
return serializeTable(value.map((item) => SerializeBytes(item)));
|
|
355
363
|
}
|
|
356
364
|
exports.SerializeBytesVec = SerializeBytesVec;
|
|
357
365
|
class Byte32Vec {
|
|
@@ -382,7 +390,7 @@ class Byte32Vec {
|
|
|
382
390
|
exports.Byte32Vec = Byte32Vec;
|
|
383
391
|
function SerializeByte32Vec(value) {
|
|
384
392
|
const array = new Uint8Array(4 + Byte32.size() * value.length);
|
|
385
|
-
|
|
393
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
386
394
|
for (let i = 0; i < value.length; i++) {
|
|
387
395
|
const itemBuffer = SerializeByte32(value[i]);
|
|
388
396
|
array.set(new Uint8Array(itemBuffer), 4 + i * Byte32.size());
|
|
@@ -456,7 +464,9 @@ class UncleBlockVec {
|
|
|
456
464
|
validate(compatible = false) {
|
|
457
465
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
458
466
|
for (let i = 0; i < offsets.length - 1; i++) {
|
|
459
|
-
new UncleBlock(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
467
|
+
new UncleBlock(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
468
|
+
validate: false,
|
|
469
|
+
}).validate();
|
|
460
470
|
}
|
|
461
471
|
}
|
|
462
472
|
length() {
|
|
@@ -474,12 +484,14 @@ class UncleBlockVec {
|
|
|
474
484
|
if (i + 1 < this.length()) {
|
|
475
485
|
offset_end = this.view.getUint32(start + 4, true);
|
|
476
486
|
}
|
|
477
|
-
return new UncleBlock(this.view.buffer.slice(offset, offset_end), {
|
|
487
|
+
return new UncleBlock(this.view.buffer.slice(offset, offset_end), {
|
|
488
|
+
validate: false,
|
|
489
|
+
});
|
|
478
490
|
}
|
|
479
491
|
}
|
|
480
492
|
exports.UncleBlockVec = UncleBlockVec;
|
|
481
493
|
function SerializeUncleBlockVec(value) {
|
|
482
|
-
return serializeTable(value.map(item => SerializeUncleBlock(item)));
|
|
494
|
+
return serializeTable(value.map((item) => SerializeUncleBlock(item)));
|
|
483
495
|
}
|
|
484
496
|
exports.SerializeUncleBlockVec = SerializeUncleBlockVec;
|
|
485
497
|
class TransactionVec {
|
|
@@ -492,7 +504,9 @@ class TransactionVec {
|
|
|
492
504
|
validate(compatible = false) {
|
|
493
505
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
494
506
|
for (let i = 0; i < offsets.length - 1; i++) {
|
|
495
|
-
new Transaction(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
507
|
+
new Transaction(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
508
|
+
validate: false,
|
|
509
|
+
}).validate();
|
|
496
510
|
}
|
|
497
511
|
}
|
|
498
512
|
length() {
|
|
@@ -510,12 +524,14 @@ class TransactionVec {
|
|
|
510
524
|
if (i + 1 < this.length()) {
|
|
511
525
|
offset_end = this.view.getUint32(start + 4, true);
|
|
512
526
|
}
|
|
513
|
-
return new Transaction(this.view.buffer.slice(offset, offset_end), {
|
|
527
|
+
return new Transaction(this.view.buffer.slice(offset, offset_end), {
|
|
528
|
+
validate: false,
|
|
529
|
+
});
|
|
514
530
|
}
|
|
515
531
|
}
|
|
516
532
|
exports.TransactionVec = TransactionVec;
|
|
517
533
|
function SerializeTransactionVec(value) {
|
|
518
|
-
return serializeTable(value.map(item => SerializeTransaction(item)));
|
|
534
|
+
return serializeTable(value.map((item) => SerializeTransaction(item)));
|
|
519
535
|
}
|
|
520
536
|
exports.SerializeTransactionVec = SerializeTransactionVec;
|
|
521
537
|
class ProposalShortIdVec {
|
|
@@ -546,7 +562,7 @@ class ProposalShortIdVec {
|
|
|
546
562
|
exports.ProposalShortIdVec = ProposalShortIdVec;
|
|
547
563
|
function SerializeProposalShortIdVec(value) {
|
|
548
564
|
const array = new Uint8Array(4 + ProposalShortId.size() * value.length);
|
|
549
|
-
|
|
565
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
550
566
|
for (let i = 0; i < value.length; i++) {
|
|
551
567
|
const itemBuffer = SerializeProposalShortId(value[i]);
|
|
552
568
|
array.set(new Uint8Array(itemBuffer), 4 + i * ProposalShortId.size());
|
|
@@ -582,7 +598,7 @@ class CellDepVec {
|
|
|
582
598
|
exports.CellDepVec = CellDepVec;
|
|
583
599
|
function SerializeCellDepVec(value) {
|
|
584
600
|
const array = new Uint8Array(4 + CellDep.size() * value.length);
|
|
585
|
-
|
|
601
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
586
602
|
for (let i = 0; i < value.length; i++) {
|
|
587
603
|
const itemBuffer = SerializeCellDep(value[i]);
|
|
588
604
|
array.set(new Uint8Array(itemBuffer), 4 + i * CellDep.size());
|
|
@@ -618,7 +634,7 @@ class CellInputVec {
|
|
|
618
634
|
exports.CellInputVec = CellInputVec;
|
|
619
635
|
function SerializeCellInputVec(value) {
|
|
620
636
|
const array = new Uint8Array(4 + CellInput.size() * value.length);
|
|
621
|
-
|
|
637
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
622
638
|
for (let i = 0; i < value.length; i++) {
|
|
623
639
|
const itemBuffer = SerializeCellInput(value[i]);
|
|
624
640
|
array.set(new Uint8Array(itemBuffer), 4 + i * CellInput.size());
|
|
@@ -636,7 +652,9 @@ class CellOutputVec {
|
|
|
636
652
|
validate(compatible = false) {
|
|
637
653
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
638
654
|
for (let i = 0; i < offsets.length - 1; i++) {
|
|
639
|
-
new CellOutput(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
655
|
+
new CellOutput(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
656
|
+
validate: false,
|
|
657
|
+
}).validate();
|
|
640
658
|
}
|
|
641
659
|
}
|
|
642
660
|
length() {
|
|
@@ -654,12 +672,14 @@ class CellOutputVec {
|
|
|
654
672
|
if (i + 1 < this.length()) {
|
|
655
673
|
offset_end = this.view.getUint32(start + 4, true);
|
|
656
674
|
}
|
|
657
|
-
return new CellOutput(this.view.buffer.slice(offset, offset_end), {
|
|
675
|
+
return new CellOutput(this.view.buffer.slice(offset, offset_end), {
|
|
676
|
+
validate: false,
|
|
677
|
+
});
|
|
658
678
|
}
|
|
659
679
|
}
|
|
660
680
|
exports.CellOutputVec = CellOutputVec;
|
|
661
681
|
function SerializeCellOutputVec(value) {
|
|
662
|
-
return serializeTable(value.map(item => SerializeCellOutput(item)));
|
|
682
|
+
return serializeTable(value.map((item) => SerializeCellOutput(item)));
|
|
663
683
|
}
|
|
664
684
|
exports.SerializeCellOutputVec = SerializeCellOutputVec;
|
|
665
685
|
class Script {
|
|
@@ -671,17 +691,23 @@ class Script {
|
|
|
671
691
|
}
|
|
672
692
|
validate(compatible = false) {
|
|
673
693
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
674
|
-
new Byte32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
694
|
+
new Byte32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
695
|
+
validate: false,
|
|
696
|
+
}).validate();
|
|
675
697
|
if (offsets[2] - offsets[1] !== 1) {
|
|
676
698
|
throw new Error(`Invalid offset for hashType: ${offsets[1]} - ${offsets[2]}`);
|
|
677
699
|
}
|
|
678
|
-
new Bytes(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
700
|
+
new Bytes(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
701
|
+
validate: false,
|
|
702
|
+
}).validate();
|
|
679
703
|
}
|
|
680
704
|
getCodeHash() {
|
|
681
705
|
const start = 4;
|
|
682
706
|
const offset = this.view.getUint32(start, true);
|
|
683
707
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
684
|
-
return new Byte32(this.view.buffer.slice(offset, offset_end), {
|
|
708
|
+
return new Byte32(this.view.buffer.slice(offset, offset_end), {
|
|
709
|
+
validate: false,
|
|
710
|
+
});
|
|
685
711
|
}
|
|
686
712
|
getHashType() {
|
|
687
713
|
const start = 8;
|
|
@@ -693,7 +719,9 @@ class Script {
|
|
|
693
719
|
const start = 12;
|
|
694
720
|
const offset = this.view.getUint32(start, true);
|
|
695
721
|
const offset_end = this.view.byteLength;
|
|
696
|
-
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
722
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
723
|
+
validate: false,
|
|
724
|
+
});
|
|
697
725
|
}
|
|
698
726
|
}
|
|
699
727
|
exports.Script = Script;
|
|
@@ -715,7 +743,9 @@ class OutPoint {
|
|
|
715
743
|
}
|
|
716
744
|
}
|
|
717
745
|
getTxHash() {
|
|
718
|
-
return new Byte32(this.view.buffer.slice(0, 0 + Byte32.size()), {
|
|
746
|
+
return new Byte32(this.view.buffer.slice(0, 0 + Byte32.size()), {
|
|
747
|
+
validate: false,
|
|
748
|
+
});
|
|
719
749
|
}
|
|
720
750
|
getIndex() {
|
|
721
751
|
return new Uint32(this.view.buffer.slice(0 + Byte32.size(), 0 + Byte32.size() + Uint32.size()), { validate: false });
|
|
@@ -746,7 +776,9 @@ class CellInput {
|
|
|
746
776
|
}
|
|
747
777
|
}
|
|
748
778
|
getSince() {
|
|
749
|
-
return new Uint64(this.view.buffer.slice(0, 0 + Uint64.size()), {
|
|
779
|
+
return new Uint64(this.view.buffer.slice(0, 0 + Uint64.size()), {
|
|
780
|
+
validate: false,
|
|
781
|
+
});
|
|
750
782
|
}
|
|
751
783
|
getPreviousOutput() {
|
|
752
784
|
return new OutPoint(this.view.buffer.slice(0 + Uint64.size(), 0 + Uint64.size() + OutPoint.size()), { validate: false });
|
|
@@ -778,27 +810,39 @@ class CellOutput {
|
|
|
778
810
|
}
|
|
779
811
|
validate(compatible = false) {
|
|
780
812
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
781
|
-
new Uint64(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
782
|
-
|
|
783
|
-
|
|
813
|
+
new Uint64(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
814
|
+
validate: false,
|
|
815
|
+
}).validate();
|
|
816
|
+
new Script(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
817
|
+
validate: false,
|
|
818
|
+
}).validate();
|
|
819
|
+
new ScriptOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
820
|
+
validate: false,
|
|
821
|
+
}).validate();
|
|
784
822
|
}
|
|
785
823
|
getCapacity() {
|
|
786
824
|
const start = 4;
|
|
787
825
|
const offset = this.view.getUint32(start, true);
|
|
788
826
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
789
|
-
return new Uint64(this.view.buffer.slice(offset, offset_end), {
|
|
827
|
+
return new Uint64(this.view.buffer.slice(offset, offset_end), {
|
|
828
|
+
validate: false,
|
|
829
|
+
});
|
|
790
830
|
}
|
|
791
831
|
getLock() {
|
|
792
832
|
const start = 8;
|
|
793
833
|
const offset = this.view.getUint32(start, true);
|
|
794
834
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
795
|
-
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
835
|
+
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
836
|
+
validate: false,
|
|
837
|
+
});
|
|
796
838
|
}
|
|
797
839
|
getType() {
|
|
798
840
|
const start = 12;
|
|
799
841
|
const offset = this.view.getUint32(start, true);
|
|
800
842
|
const offset_end = this.view.byteLength;
|
|
801
|
-
return new ScriptOpt(this.view.buffer.slice(offset, offset_end), {
|
|
843
|
+
return new ScriptOpt(this.view.buffer.slice(offset, offset_end), {
|
|
844
|
+
validate: false,
|
|
845
|
+
});
|
|
802
846
|
}
|
|
803
847
|
}
|
|
804
848
|
exports.CellOutput = CellOutput;
|
|
@@ -818,7 +862,9 @@ class CellDep {
|
|
|
818
862
|
}
|
|
819
863
|
}
|
|
820
864
|
getOutPoint() {
|
|
821
|
-
return new OutPoint(this.view.buffer.slice(0, 0 + OutPoint.size()), {
|
|
865
|
+
return new OutPoint(this.view.buffer.slice(0, 0 + OutPoint.size()), {
|
|
866
|
+
validate: false,
|
|
867
|
+
});
|
|
822
868
|
}
|
|
823
869
|
getDepType() {
|
|
824
870
|
return this.view.getUint8(0 + OutPoint.size());
|
|
@@ -849,48 +895,72 @@ class RawTransaction {
|
|
|
849
895
|
}
|
|
850
896
|
validate(compatible = false) {
|
|
851
897
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
852
|
-
new Uint32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
new
|
|
856
|
-
|
|
857
|
-
|
|
898
|
+
new Uint32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
899
|
+
validate: false,
|
|
900
|
+
}).validate();
|
|
901
|
+
new CellDepVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
902
|
+
validate: false,
|
|
903
|
+
}).validate();
|
|
904
|
+
new Byte32Vec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
905
|
+
validate: false,
|
|
906
|
+
}).validate();
|
|
907
|
+
new CellInputVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
908
|
+
validate: false,
|
|
909
|
+
}).validate();
|
|
910
|
+
new CellOutputVec(this.view.buffer.slice(offsets[4], offsets[5]), {
|
|
911
|
+
validate: false,
|
|
912
|
+
}).validate();
|
|
913
|
+
new BytesVec(this.view.buffer.slice(offsets[5], offsets[6]), {
|
|
914
|
+
validate: false,
|
|
915
|
+
}).validate();
|
|
858
916
|
}
|
|
859
917
|
getVersion() {
|
|
860
918
|
const start = 4;
|
|
861
919
|
const offset = this.view.getUint32(start, true);
|
|
862
920
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
863
|
-
return new Uint32(this.view.buffer.slice(offset, offset_end), {
|
|
921
|
+
return new Uint32(this.view.buffer.slice(offset, offset_end), {
|
|
922
|
+
validate: false,
|
|
923
|
+
});
|
|
864
924
|
}
|
|
865
925
|
getCellDeps() {
|
|
866
926
|
const start = 8;
|
|
867
927
|
const offset = this.view.getUint32(start, true);
|
|
868
928
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
869
|
-
return new CellDepVec(this.view.buffer.slice(offset, offset_end), {
|
|
929
|
+
return new CellDepVec(this.view.buffer.slice(offset, offset_end), {
|
|
930
|
+
validate: false,
|
|
931
|
+
});
|
|
870
932
|
}
|
|
871
933
|
getHeaderDeps() {
|
|
872
934
|
const start = 12;
|
|
873
935
|
const offset = this.view.getUint32(start, true);
|
|
874
936
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
875
|
-
return new Byte32Vec(this.view.buffer.slice(offset, offset_end), {
|
|
937
|
+
return new Byte32Vec(this.view.buffer.slice(offset, offset_end), {
|
|
938
|
+
validate: false,
|
|
939
|
+
});
|
|
876
940
|
}
|
|
877
941
|
getInputs() {
|
|
878
942
|
const start = 16;
|
|
879
943
|
const offset = this.view.getUint32(start, true);
|
|
880
944
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
881
|
-
return new CellInputVec(this.view.buffer.slice(offset, offset_end), {
|
|
945
|
+
return new CellInputVec(this.view.buffer.slice(offset, offset_end), {
|
|
946
|
+
validate: false,
|
|
947
|
+
});
|
|
882
948
|
}
|
|
883
949
|
getOutputs() {
|
|
884
950
|
const start = 20;
|
|
885
951
|
const offset = this.view.getUint32(start, true);
|
|
886
952
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
887
|
-
return new CellOutputVec(this.view.buffer.slice(offset, offset_end), {
|
|
953
|
+
return new CellOutputVec(this.view.buffer.slice(offset, offset_end), {
|
|
954
|
+
validate: false,
|
|
955
|
+
});
|
|
888
956
|
}
|
|
889
957
|
getOutputsData() {
|
|
890
958
|
const start = 24;
|
|
891
959
|
const offset = this.view.getUint32(start, true);
|
|
892
960
|
const offset_end = this.view.byteLength;
|
|
893
|
-
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
961
|
+
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
962
|
+
validate: false,
|
|
963
|
+
});
|
|
894
964
|
}
|
|
895
965
|
}
|
|
896
966
|
exports.RawTransaction = RawTransaction;
|
|
@@ -914,20 +984,28 @@ class Transaction {
|
|
|
914
984
|
}
|
|
915
985
|
validate(compatible = false) {
|
|
916
986
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
917
|
-
new RawTransaction(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
918
|
-
|
|
987
|
+
new RawTransaction(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
988
|
+
validate: false,
|
|
989
|
+
}).validate();
|
|
990
|
+
new BytesVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
991
|
+
validate: false,
|
|
992
|
+
}).validate();
|
|
919
993
|
}
|
|
920
994
|
getRaw() {
|
|
921
995
|
const start = 4;
|
|
922
996
|
const offset = this.view.getUint32(start, true);
|
|
923
997
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
924
|
-
return new RawTransaction(this.view.buffer.slice(offset, offset_end), {
|
|
998
|
+
return new RawTransaction(this.view.buffer.slice(offset, offset_end), {
|
|
999
|
+
validate: false,
|
|
1000
|
+
});
|
|
925
1001
|
}
|
|
926
1002
|
getWitnesses() {
|
|
927
1003
|
const start = 8;
|
|
928
1004
|
const offset = this.view.getUint32(start, true);
|
|
929
1005
|
const offset_end = this.view.byteLength;
|
|
930
|
-
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
1006
|
+
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
1007
|
+
validate: false,
|
|
1008
|
+
});
|
|
931
1009
|
}
|
|
932
1010
|
}
|
|
933
1011
|
exports.Transaction = Transaction;
|
|
@@ -946,7 +1024,9 @@ class RawHeader {
|
|
|
946
1024
|
}
|
|
947
1025
|
}
|
|
948
1026
|
getVersion() {
|
|
949
|
-
return new Uint32(this.view.buffer.slice(0, 0 + Uint32.size()), {
|
|
1027
|
+
return new Uint32(this.view.buffer.slice(0, 0 + Uint32.size()), {
|
|
1028
|
+
validate: false,
|
|
1029
|
+
});
|
|
950
1030
|
}
|
|
951
1031
|
getCompactTarget() {
|
|
952
1032
|
return new Uint32(this.view.buffer.slice(0 + Uint32.size(), 0 + Uint32.size() + Uint32.size()), { validate: false });
|
|
@@ -958,22 +1038,102 @@ class RawHeader {
|
|
|
958
1038
|
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 });
|
|
959
1039
|
}
|
|
960
1040
|
getEpoch() {
|
|
961
|
-
return new Uint64(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(), 0 +
|
|
1041
|
+
return new Uint64(this.view.buffer.slice(0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(), 0 +
|
|
1042
|
+
Uint32.size() +
|
|
1043
|
+
Uint32.size() +
|
|
1044
|
+
Uint64.size() +
|
|
1045
|
+
Uint64.size() +
|
|
1046
|
+
Uint64.size()), { validate: false });
|
|
962
1047
|
}
|
|
963
1048
|
getParentHash() {
|
|
964
|
-
return new Byte32(this.view.buffer.slice(0 +
|
|
1049
|
+
return new Byte32(this.view.buffer.slice(0 +
|
|
1050
|
+
Uint32.size() +
|
|
1051
|
+
Uint32.size() +
|
|
1052
|
+
Uint64.size() +
|
|
1053
|
+
Uint64.size() +
|
|
1054
|
+
Uint64.size(), 0 +
|
|
1055
|
+
Uint32.size() +
|
|
1056
|
+
Uint32.size() +
|
|
1057
|
+
Uint64.size() +
|
|
1058
|
+
Uint64.size() +
|
|
1059
|
+
Uint64.size() +
|
|
1060
|
+
Byte32.size()), { validate: false });
|
|
965
1061
|
}
|
|
966
1062
|
getTransactionsRoot() {
|
|
967
|
-
return new Byte32(this.view.buffer.slice(0 +
|
|
1063
|
+
return new Byte32(this.view.buffer.slice(0 +
|
|
1064
|
+
Uint32.size() +
|
|
1065
|
+
Uint32.size() +
|
|
1066
|
+
Uint64.size() +
|
|
1067
|
+
Uint64.size() +
|
|
1068
|
+
Uint64.size() +
|
|
1069
|
+
Byte32.size(), 0 +
|
|
1070
|
+
Uint32.size() +
|
|
1071
|
+
Uint32.size() +
|
|
1072
|
+
Uint64.size() +
|
|
1073
|
+
Uint64.size() +
|
|
1074
|
+
Uint64.size() +
|
|
1075
|
+
Byte32.size() +
|
|
1076
|
+
Byte32.size()), { validate: false });
|
|
968
1077
|
}
|
|
969
1078
|
getProposalsHash() {
|
|
970
|
-
return new Byte32(this.view.buffer.slice(0 +
|
|
1079
|
+
return new Byte32(this.view.buffer.slice(0 +
|
|
1080
|
+
Uint32.size() +
|
|
1081
|
+
Uint32.size() +
|
|
1082
|
+
Uint64.size() +
|
|
1083
|
+
Uint64.size() +
|
|
1084
|
+
Uint64.size() +
|
|
1085
|
+
Byte32.size() +
|
|
1086
|
+
Byte32.size(), 0 +
|
|
1087
|
+
Uint32.size() +
|
|
1088
|
+
Uint32.size() +
|
|
1089
|
+
Uint64.size() +
|
|
1090
|
+
Uint64.size() +
|
|
1091
|
+
Uint64.size() +
|
|
1092
|
+
Byte32.size() +
|
|
1093
|
+
Byte32.size() +
|
|
1094
|
+
Byte32.size()), { validate: false });
|
|
971
1095
|
}
|
|
972
1096
|
getExtraHash() {
|
|
973
|
-
return new Byte32(this.view.buffer.slice(0 +
|
|
1097
|
+
return new Byte32(this.view.buffer.slice(0 +
|
|
1098
|
+
Uint32.size() +
|
|
1099
|
+
Uint32.size() +
|
|
1100
|
+
Uint64.size() +
|
|
1101
|
+
Uint64.size() +
|
|
1102
|
+
Uint64.size() +
|
|
1103
|
+
Byte32.size() +
|
|
1104
|
+
Byte32.size() +
|
|
1105
|
+
Byte32.size(), 0 +
|
|
1106
|
+
Uint32.size() +
|
|
1107
|
+
Uint32.size() +
|
|
1108
|
+
Uint64.size() +
|
|
1109
|
+
Uint64.size() +
|
|
1110
|
+
Uint64.size() +
|
|
1111
|
+
Byte32.size() +
|
|
1112
|
+
Byte32.size() +
|
|
1113
|
+
Byte32.size() +
|
|
1114
|
+
Byte32.size()), { validate: false });
|
|
974
1115
|
}
|
|
975
1116
|
getDao() {
|
|
976
|
-
return new Byte32(this.view.buffer.slice(0 +
|
|
1117
|
+
return new Byte32(this.view.buffer.slice(0 +
|
|
1118
|
+
Uint32.size() +
|
|
1119
|
+
Uint32.size() +
|
|
1120
|
+
Uint64.size() +
|
|
1121
|
+
Uint64.size() +
|
|
1122
|
+
Uint64.size() +
|
|
1123
|
+
Byte32.size() +
|
|
1124
|
+
Byte32.size() +
|
|
1125
|
+
Byte32.size() +
|
|
1126
|
+
Byte32.size(), 0 +
|
|
1127
|
+
Uint32.size() +
|
|
1128
|
+
Uint32.size() +
|
|
1129
|
+
Uint64.size() +
|
|
1130
|
+
Uint64.size() +
|
|
1131
|
+
Uint64.size() +
|
|
1132
|
+
Byte32.size() +
|
|
1133
|
+
Byte32.size() +
|
|
1134
|
+
Byte32.size() +
|
|
1135
|
+
Byte32.size() +
|
|
1136
|
+
Byte32.size()), { validate: false });
|
|
977
1137
|
}
|
|
978
1138
|
validate(compatible = false) {
|
|
979
1139
|
assertDataLength(this.view.byteLength, RawHeader.size());
|
|
@@ -989,23 +1149,78 @@ class RawHeader {
|
|
|
989
1149
|
this.getDao().validate(compatible);
|
|
990
1150
|
}
|
|
991
1151
|
static size() {
|
|
992
|
-
return 0 +
|
|
1152
|
+
return (0 +
|
|
1153
|
+
Uint32.size() +
|
|
1154
|
+
Uint32.size() +
|
|
1155
|
+
Uint64.size() +
|
|
1156
|
+
Uint64.size() +
|
|
1157
|
+
Uint64.size() +
|
|
1158
|
+
Byte32.size() +
|
|
1159
|
+
Byte32.size() +
|
|
1160
|
+
Byte32.size() +
|
|
1161
|
+
Byte32.size() +
|
|
1162
|
+
Byte32.size());
|
|
993
1163
|
}
|
|
994
1164
|
}
|
|
995
1165
|
exports.RawHeader = RawHeader;
|
|
996
1166
|
function SerializeRawHeader(value) {
|
|
997
|
-
const array = new Uint8Array(0 +
|
|
1167
|
+
const array = new Uint8Array(0 +
|
|
1168
|
+
Uint32.size() +
|
|
1169
|
+
Uint32.size() +
|
|
1170
|
+
Uint64.size() +
|
|
1171
|
+
Uint64.size() +
|
|
1172
|
+
Uint64.size() +
|
|
1173
|
+
Byte32.size() +
|
|
1174
|
+
Byte32.size() +
|
|
1175
|
+
Byte32.size() +
|
|
1176
|
+
Byte32.size() +
|
|
1177
|
+
Byte32.size());
|
|
998
1178
|
const view = new DataView(array.buffer);
|
|
999
1179
|
array.set(new Uint8Array(SerializeUint32(value.version)), 0);
|
|
1000
1180
|
array.set(new Uint8Array(SerializeUint32(value.compactTarget)), 0 + Uint32.size());
|
|
1001
1181
|
array.set(new Uint8Array(SerializeUint64(value.timestamp)), 0 + Uint32.size() + Uint32.size());
|
|
1002
1182
|
array.set(new Uint8Array(SerializeUint64(value.number)), 0 + Uint32.size() + Uint32.size() + Uint64.size());
|
|
1003
1183
|
array.set(new Uint8Array(SerializeUint64(value.epoch)), 0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size());
|
|
1004
|
-
array.set(new Uint8Array(SerializeByte32(value.parentHash)), 0 +
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1184
|
+
array.set(new Uint8Array(SerializeByte32(value.parentHash)), 0 +
|
|
1185
|
+
Uint32.size() +
|
|
1186
|
+
Uint32.size() +
|
|
1187
|
+
Uint64.size() +
|
|
1188
|
+
Uint64.size() +
|
|
1189
|
+
Uint64.size());
|
|
1190
|
+
array.set(new Uint8Array(SerializeByte32(value.transactionsRoot)), 0 +
|
|
1191
|
+
Uint32.size() +
|
|
1192
|
+
Uint32.size() +
|
|
1193
|
+
Uint64.size() +
|
|
1194
|
+
Uint64.size() +
|
|
1195
|
+
Uint64.size() +
|
|
1196
|
+
Byte32.size());
|
|
1197
|
+
array.set(new Uint8Array(SerializeByte32(value.proposalsHash)), 0 +
|
|
1198
|
+
Uint32.size() +
|
|
1199
|
+
Uint32.size() +
|
|
1200
|
+
Uint64.size() +
|
|
1201
|
+
Uint64.size() +
|
|
1202
|
+
Uint64.size() +
|
|
1203
|
+
Byte32.size() +
|
|
1204
|
+
Byte32.size());
|
|
1205
|
+
array.set(new Uint8Array(SerializeByte32(value.extraHash)), 0 +
|
|
1206
|
+
Uint32.size() +
|
|
1207
|
+
Uint32.size() +
|
|
1208
|
+
Uint64.size() +
|
|
1209
|
+
Uint64.size() +
|
|
1210
|
+
Uint64.size() +
|
|
1211
|
+
Byte32.size() +
|
|
1212
|
+
Byte32.size() +
|
|
1213
|
+
Byte32.size());
|
|
1214
|
+
array.set(new Uint8Array(SerializeByte32(value.dao)), 0 +
|
|
1215
|
+
Uint32.size() +
|
|
1216
|
+
Uint32.size() +
|
|
1217
|
+
Uint64.size() +
|
|
1218
|
+
Uint64.size() +
|
|
1219
|
+
Uint64.size() +
|
|
1220
|
+
Byte32.size() +
|
|
1221
|
+
Byte32.size() +
|
|
1222
|
+
Byte32.size() +
|
|
1223
|
+
Byte32.size());
|
|
1009
1224
|
return array.buffer;
|
|
1010
1225
|
}
|
|
1011
1226
|
exports.SerializeRawHeader = SerializeRawHeader;
|
|
@@ -1017,7 +1232,9 @@ class Header {
|
|
|
1017
1232
|
}
|
|
1018
1233
|
}
|
|
1019
1234
|
getRaw() {
|
|
1020
|
-
return new RawHeader(this.view.buffer.slice(0, 0 + RawHeader.size()), {
|
|
1235
|
+
return new RawHeader(this.view.buffer.slice(0, 0 + RawHeader.size()), {
|
|
1236
|
+
validate: false,
|
|
1237
|
+
});
|
|
1021
1238
|
}
|
|
1022
1239
|
getNonce() {
|
|
1023
1240
|
return new Uint128(this.view.buffer.slice(0 + RawHeader.size(), 0 + RawHeader.size() + Uint128.size()), { validate: false });
|
|
@@ -1049,20 +1266,28 @@ class UncleBlock {
|
|
|
1049
1266
|
}
|
|
1050
1267
|
validate(compatible = false) {
|
|
1051
1268
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1052
|
-
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1053
|
-
|
|
1269
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1270
|
+
validate: false,
|
|
1271
|
+
}).validate();
|
|
1272
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1273
|
+
validate: false,
|
|
1274
|
+
}).validate();
|
|
1054
1275
|
}
|
|
1055
1276
|
getHeader() {
|
|
1056
1277
|
const start = 4;
|
|
1057
1278
|
const offset = this.view.getUint32(start, true);
|
|
1058
1279
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1059
|
-
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1280
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1281
|
+
validate: false,
|
|
1282
|
+
});
|
|
1060
1283
|
}
|
|
1061
1284
|
getProposals() {
|
|
1062
1285
|
const start = 8;
|
|
1063
1286
|
const offset = this.view.getUint32(start, true);
|
|
1064
1287
|
const offset_end = this.view.byteLength;
|
|
1065
|
-
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1288
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1289
|
+
validate: false,
|
|
1290
|
+
});
|
|
1066
1291
|
}
|
|
1067
1292
|
}
|
|
1068
1293
|
exports.UncleBlock = UncleBlock;
|
|
@@ -1082,34 +1307,50 @@ class Block {
|
|
|
1082
1307
|
}
|
|
1083
1308
|
validate(compatible = false) {
|
|
1084
1309
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1085
|
-
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
new
|
|
1310
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1311
|
+
validate: false,
|
|
1312
|
+
}).validate();
|
|
1313
|
+
new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1314
|
+
validate: false,
|
|
1315
|
+
}).validate();
|
|
1316
|
+
new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1317
|
+
validate: false,
|
|
1318
|
+
}).validate();
|
|
1319
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
1320
|
+
validate: false,
|
|
1321
|
+
}).validate();
|
|
1089
1322
|
}
|
|
1090
1323
|
getHeader() {
|
|
1091
1324
|
const start = 4;
|
|
1092
1325
|
const offset = this.view.getUint32(start, true);
|
|
1093
1326
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1094
|
-
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1327
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1328
|
+
validate: false,
|
|
1329
|
+
});
|
|
1095
1330
|
}
|
|
1096
1331
|
getUncles() {
|
|
1097
1332
|
const start = 8;
|
|
1098
1333
|
const offset = this.view.getUint32(start, true);
|
|
1099
1334
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1100
|
-
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1335
|
+
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1336
|
+
validate: false,
|
|
1337
|
+
});
|
|
1101
1338
|
}
|
|
1102
1339
|
getTransactions() {
|
|
1103
1340
|
const start = 12;
|
|
1104
1341
|
const offset = this.view.getUint32(start, true);
|
|
1105
1342
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1106
|
-
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1343
|
+
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1344
|
+
validate: false,
|
|
1345
|
+
});
|
|
1107
1346
|
}
|
|
1108
1347
|
getProposals() {
|
|
1109
1348
|
const start = 16;
|
|
1110
1349
|
const offset = this.view.getUint32(start, true);
|
|
1111
1350
|
const offset_end = this.view.byteLength;
|
|
1112
|
-
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1351
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1352
|
+
validate: false,
|
|
1353
|
+
});
|
|
1113
1354
|
}
|
|
1114
1355
|
}
|
|
1115
1356
|
exports.Block = Block;
|
|
@@ -1131,41 +1372,61 @@ class BlockV1 {
|
|
|
1131
1372
|
}
|
|
1132
1373
|
validate(compatible = false) {
|
|
1133
1374
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1134
|
-
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
new
|
|
1138
|
-
|
|
1375
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1376
|
+
validate: false,
|
|
1377
|
+
}).validate();
|
|
1378
|
+
new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1379
|
+
validate: false,
|
|
1380
|
+
}).validate();
|
|
1381
|
+
new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1382
|
+
validate: false,
|
|
1383
|
+
}).validate();
|
|
1384
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
1385
|
+
validate: false,
|
|
1386
|
+
}).validate();
|
|
1387
|
+
new Bytes(this.view.buffer.slice(offsets[4], offsets[5]), {
|
|
1388
|
+
validate: false,
|
|
1389
|
+
}).validate();
|
|
1139
1390
|
}
|
|
1140
1391
|
getHeader() {
|
|
1141
1392
|
const start = 4;
|
|
1142
1393
|
const offset = this.view.getUint32(start, true);
|
|
1143
1394
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1144
|
-
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1395
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1396
|
+
validate: false,
|
|
1397
|
+
});
|
|
1145
1398
|
}
|
|
1146
1399
|
getUncles() {
|
|
1147
1400
|
const start = 8;
|
|
1148
1401
|
const offset = this.view.getUint32(start, true);
|
|
1149
1402
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1150
|
-
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1403
|
+
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1404
|
+
validate: false,
|
|
1405
|
+
});
|
|
1151
1406
|
}
|
|
1152
1407
|
getTransactions() {
|
|
1153
1408
|
const start = 12;
|
|
1154
1409
|
const offset = this.view.getUint32(start, true);
|
|
1155
1410
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1156
|
-
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1411
|
+
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1412
|
+
validate: false,
|
|
1413
|
+
});
|
|
1157
1414
|
}
|
|
1158
1415
|
getProposals() {
|
|
1159
1416
|
const start = 16;
|
|
1160
1417
|
const offset = this.view.getUint32(start, true);
|
|
1161
1418
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1162
|
-
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1419
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1420
|
+
validate: false,
|
|
1421
|
+
});
|
|
1163
1422
|
}
|
|
1164
1423
|
getExtension() {
|
|
1165
1424
|
const start = 20;
|
|
1166
1425
|
const offset = this.view.getUint32(start, true);
|
|
1167
1426
|
const offset_end = this.view.byteLength;
|
|
1168
|
-
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1427
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1428
|
+
validate: false,
|
|
1429
|
+
});
|
|
1169
1430
|
}
|
|
1170
1431
|
}
|
|
1171
1432
|
exports.BlockV1 = BlockV1;
|
|
@@ -1188,20 +1449,28 @@ class CellbaseWitness {
|
|
|
1188
1449
|
}
|
|
1189
1450
|
validate(compatible = false) {
|
|
1190
1451
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1191
|
-
new Script(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1192
|
-
|
|
1452
|
+
new Script(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1453
|
+
validate: false,
|
|
1454
|
+
}).validate();
|
|
1455
|
+
new Bytes(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1456
|
+
validate: false,
|
|
1457
|
+
}).validate();
|
|
1193
1458
|
}
|
|
1194
1459
|
getLock() {
|
|
1195
1460
|
const start = 4;
|
|
1196
1461
|
const offset = this.view.getUint32(start, true);
|
|
1197
1462
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1198
|
-
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
1463
|
+
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
1464
|
+
validate: false,
|
|
1465
|
+
});
|
|
1199
1466
|
}
|
|
1200
1467
|
getMessage() {
|
|
1201
1468
|
const start = 8;
|
|
1202
1469
|
const offset = this.view.getUint32(start, true);
|
|
1203
1470
|
const offset_end = this.view.byteLength;
|
|
1204
|
-
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1471
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1472
|
+
validate: false,
|
|
1473
|
+
});
|
|
1205
1474
|
}
|
|
1206
1475
|
}
|
|
1207
1476
|
exports.CellbaseWitness = CellbaseWitness;
|
|
@@ -1221,27 +1490,39 @@ class WitnessArgs {
|
|
|
1221
1490
|
}
|
|
1222
1491
|
validate(compatible = false) {
|
|
1223
1492
|
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1224
|
-
new BytesOpt(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1225
|
-
|
|
1226
|
-
|
|
1493
|
+
new BytesOpt(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1494
|
+
validate: false,
|
|
1495
|
+
}).validate();
|
|
1496
|
+
new BytesOpt(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1497
|
+
validate: false,
|
|
1498
|
+
}).validate();
|
|
1499
|
+
new BytesOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1500
|
+
validate: false,
|
|
1501
|
+
}).validate();
|
|
1227
1502
|
}
|
|
1228
1503
|
getLock() {
|
|
1229
1504
|
const start = 4;
|
|
1230
1505
|
const offset = this.view.getUint32(start, true);
|
|
1231
1506
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1232
|
-
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1507
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1508
|
+
validate: false,
|
|
1509
|
+
});
|
|
1233
1510
|
}
|
|
1234
1511
|
getInputType() {
|
|
1235
1512
|
const start = 8;
|
|
1236
1513
|
const offset = this.view.getUint32(start, true);
|
|
1237
1514
|
const offset_end = this.view.getUint32(start + 4, true);
|
|
1238
|
-
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1515
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1516
|
+
validate: false,
|
|
1517
|
+
});
|
|
1239
1518
|
}
|
|
1240
1519
|
getOutputType() {
|
|
1241
1520
|
const start = 12;
|
|
1242
1521
|
const offset = this.view.getUint32(start, true);
|
|
1243
1522
|
const offset_end = this.view.byteLength;
|
|
1244
|
-
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1523
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1524
|
+
validate: false,
|
|
1525
|
+
});
|
|
1245
1526
|
}
|
|
1246
1527
|
}
|
|
1247
1528
|
exports.WitnessArgs = WitnessArgs;
|