@ckb-ccc/core 0.0.5-alpha.8 → 0.0.7-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/address/address.advanced.d.ts.map +1 -1
- package/dist/address/address.advanced.js +2 -5
- package/dist/address/index.d.ts +1 -1
- package/dist/address/index.d.ts.map +1 -1
- package/dist/address/index.js +2 -5
- package/dist/ckb/script.d.ts +43 -1
- package/dist/ckb/script.d.ts.map +1 -1
- package/dist/ckb/script.js +51 -0
- package/dist/ckb/transaction.d.ts +215 -27
- package/dist/ckb/transaction.d.ts.map +1 -1
- package/dist/ckb/transaction.js +472 -32
- package/dist/client/advanced.d.ts +2 -0
- package/dist/client/advanced.d.ts.map +1 -1
- package/dist/client/advanced.js +2 -0
- package/dist/client/client.advanced.d.ts +10 -0
- package/dist/client/client.advanced.d.ts.map +1 -0
- package/dist/client/client.advanced.js +80 -0
- package/dist/client/client.d.ts +50 -13
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +145 -15
- package/dist/client/clientPublicMainnet.advanced.d.ts +4 -2
- package/dist/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.advanced.js +103 -0
- package/dist/client/clientPublicMainnet.d.ts +4 -2
- package/dist/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist/client/clientPublicMainnet.js +9 -1
- package/dist/client/clientPublicTestnet.advanced.d.ts +4 -2
- package/dist/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.advanced.js +155 -0
- package/dist/client/clientPublicTestnet.d.ts +4 -2
- package/dist/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist/client/clientPublicTestnet.js +6 -1
- package/dist/client/clientTypes.advanced.d.ts +23 -0
- package/dist/client/clientTypes.advanced.d.ts.map +1 -0
- package/dist/client/clientTypes.advanced.js +4 -0
- package/dist/client/clientTypes.d.ts +22 -36
- package/dist/client/clientTypes.d.ts.map +1 -1
- package/dist/client/clientTypes.js +15 -12
- package/dist/client/jsonRpc/index.d.ts +3 -3
- package/dist/client/jsonRpc/index.d.ts.map +1 -1
- package/dist/client/jsonRpc/index.js +3 -3
- package/dist/client/jsonRpc/transformers.d.ts +5 -7
- package/dist/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist/client/jsonRpc/transformers.js +8 -6
- package/dist/hasher/index.d.ts +1 -1
- package/dist/hasher/index.d.ts.map +1 -1
- package/dist/hasher/index.js +4 -2
- package/dist/num/index.d.ts +12 -0
- package/dist/num/index.d.ts.map +1 -1
- package/dist/num/index.js +21 -0
- package/dist/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist/signer/btc/signerBtc.js +6 -3
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts +0 -6
- package/dist/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist/signer/btc/signerBtcPublicKeyReadonly.js +0 -8
- package/dist/signer/btc/verify.d.ts.map +1 -1
- package/dist/signer/btc/verify.js +5 -2
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts +0 -6
- package/dist/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist/signer/ckb/signerCkbScriptReadonly.js +0 -8
- package/dist/signer/dummy/alwaysError.d.ts +0 -1
- package/dist/signer/dummy/alwaysError.d.ts.map +1 -1
- package/dist/signer/dummy/alwaysError.js +0 -3
- package/dist/signer/dummy/openLink.d.ts +0 -1
- package/dist/signer/dummy/openLink.d.ts.map +1 -1
- package/dist/signer/dummy/openLink.js +0 -3
- package/dist/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist/signer/evm/signerEvm.js +7 -5
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts +0 -6
- package/dist/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist/signer/evm/signerEvmAddressReadonly.js +0 -8
- package/dist/signer/index.d.ts +1 -0
- package/dist/signer/index.d.ts.map +1 -1
- package/dist/signer/index.js +1 -0
- package/dist/signer/nostr/index.d.ts +2 -0
- package/dist/signer/nostr/index.d.ts.map +1 -0
- package/dist/signer/nostr/index.js +1 -0
- package/dist/signer/nostr/signerNostr.d.ts +66 -0
- package/dist/signer/nostr/signerNostr.d.ts.map +1 -0
- package/dist/signer/nostr/signerNostr.js +85 -0
- package/dist/signer/nostr/verify.d.ts +5 -0
- package/dist/signer/nostr/verify.d.ts.map +1 -0
- package/dist/signer/nostr/verify.js +48 -0
- package/dist/signer/signer/index.d.ts +7 -12
- package/dist/signer/signer/index.d.ts.map +1 -1
- package/dist/signer/signer/index.js +11 -4
- package/dist/utils/index.d.ts +59 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +17 -0
- package/dist.commonjs/address/address.advanced.d.ts +29 -24
- package/dist.commonjs/address/address.advanced.d.ts.map +1 -1
- package/dist.commonjs/address/address.advanced.js +115 -92
- package/dist.commonjs/address/advanced.d.ts +1 -1
- package/dist.commonjs/address/advanced.js +30 -14
- package/dist.commonjs/address/index.d.ts +51 -44
- package/dist.commonjs/address/index.d.ts.map +1 -1
- package/dist.commonjs/address/index.js +84 -68
- package/dist.commonjs/advanced.d.ts +1 -1
- package/dist.commonjs/advanced.js +47 -22
- package/dist.commonjs/advancedBarrel.d.ts +1 -1
- package/dist.commonjs/advancedBarrel.js +30 -14
- package/dist.commonjs/barrel.d.ts +1 -1
- package/dist.commonjs/barrel.js +30 -14
- package/dist.commonjs/bytes/advanced.d.ts +11 -2
- package/dist.commonjs/bytes/index.d.ts +9 -3
- package/dist.commonjs/bytes/index.js +28 -26
- package/dist.commonjs/ckb/advanced.d.ts +1 -1
- package/dist.commonjs/ckb/advanced.js +47 -22
- package/dist.commonjs/ckb/index.d.ts +1 -1
- package/dist.commonjs/ckb/index.js +30 -14
- package/dist.commonjs/ckb/molecule.advanced/generated.d.ts +420 -260
- package/dist.commonjs/ckb/molecule.advanced/generated.js +1536 -1332
- package/dist.commonjs/ckb/molecule.advanced/index.d.ts +3 -3
- package/dist.commonjs/ckb/molecule.advanced/index.js +34 -18
- package/dist.commonjs/ckb/script.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/script.advanced.js +12 -9
- package/dist.commonjs/ckb/script.d.ts +123 -77
- package/dist.commonjs/ckb/script.d.ts.map +1 -1
- package/dist.commonjs/ckb/script.js +221 -126
- package/dist.commonjs/ckb/transaction.advanced.d.ts +1 -1
- package/dist.commonjs/ckb/transaction.advanced.js +4 -4
- package/dist.commonjs/ckb/transaction.d.ts +796 -533
- package/dist.commonjs/ckb/transaction.d.ts.map +1 -1
- package/dist.commonjs/ckb/transaction.js +1372 -702
- package/dist.commonjs/client/advanced.d.ts +3 -1
- package/dist.commonjs/client/advanced.d.ts.map +1 -1
- package/dist.commonjs/client/advanced.js +32 -14
- package/dist.commonjs/client/client.advanced.d.ts +27 -0
- package/dist.commonjs/client/client.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/client.advanced.js +116 -0
- package/dist.commonjs/client/client.d.ts +118 -21
- package/dist.commonjs/client/client.d.ts.map +1 -1
- package/dist.commonjs/client/client.js +219 -55
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts +9 -3
- package/dist.commonjs/client/clientPublicMainnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.advanced.js +144 -24
- package/dist.commonjs/client/clientPublicMainnet.d.ts +9 -5
- package/dist.commonjs/client/clientPublicMainnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicMainnet.js +18 -8
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts +8 -3
- package/dist.commonjs/client/clientPublicTestnet.advanced.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.advanced.js +204 -24
- package/dist.commonjs/client/clientPublicTestnet.d.ts +9 -5
- package/dist.commonjs/client/clientPublicTestnet.d.ts.map +1 -1
- package/dist.commonjs/client/clientPublicTestnet.js +14 -9
- package/dist.commonjs/client/clientTypes.advanced.d.ts +23 -0
- package/dist.commonjs/client/clientTypes.advanced.d.ts.map +1 -0
- package/dist.commonjs/client/clientTypes.advanced.js +8 -0
- package/dist.commonjs/client/clientTypes.d.ts +57 -46
- package/dist.commonjs/client/clientTypes.d.ts.map +1 -1
- package/dist.commonjs/client/clientTypes.js +60 -22
- package/dist.commonjs/client/index.d.ts +1 -1
- package/dist.commonjs/client/index.js +30 -14
- package/dist.commonjs/client/jsonRpc/advanced.d.ts +1 -1
- package/dist.commonjs/client/jsonRpc/advanced.js +30 -14
- package/dist.commonjs/client/jsonRpc/index.d.ts +94 -75
- package/dist.commonjs/client/jsonRpc/index.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/index.js +135 -108
- package/dist.commonjs/client/jsonRpc/transformers.d.ts +76 -38
- package/dist.commonjs/client/jsonRpc/transformers.d.ts.map +1 -1
- package/dist.commonjs/client/jsonRpc/transformers.js +174 -150
- package/dist.commonjs/client/jsonRpc/types.d.ts +38 -38
- package/dist.commonjs/fixedPoint/index.d.ts +9 -3
- package/dist.commonjs/fixedPoint/index.js +26 -20
- package/dist.commonjs/fixedPoint/index.test.d.ts +1 -1
- package/dist.commonjs/fixedPoint/index.test.js +42 -36
- package/dist.commonjs/hasher/advanced.d.ts +1 -1
- package/dist.commonjs/hasher/index.d.ts +37 -37
- package/dist.commonjs/hasher/index.d.ts.map +1 -1
- package/dist.commonjs/hasher/index.js +55 -46
- package/dist.commonjs/hex/index.d.ts +1 -1
- package/dist.commonjs/hex/index.js +1 -1
- package/dist.commonjs/index.d.ts +1 -1
- package/dist.commonjs/index.js +47 -22
- package/dist.commonjs/num/index.d.ts +13 -1
- package/dist.commonjs/num/index.d.ts.map +1 -1
- package/dist.commonjs/num/index.js +53 -19
- package/dist.commonjs/signer/btc/index.d.ts +1 -1
- package/dist.commonjs/signer/btc/index.js +30 -14
- package/dist.commonjs/signer/btc/signerBtc.d.ts +47 -47
- package/dist.commonjs/signer/btc/signerBtc.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtc.js +89 -63
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts +45 -51
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/signerBtcPublicKeyReadonly.js +52 -60
- package/dist.commonjs/signer/btc/verify.d.ts +6 -2
- package/dist.commonjs/signer/btc/verify.d.ts.map +1 -1
- package/dist.commonjs/signer/btc/verify.js +13 -3
- package/dist.commonjs/signer/ckb/index.d.ts +1 -1
- package/dist.commonjs/signer/ckb/index.js +30 -14
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts +45 -51
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/ckb/signerCkbScriptReadonly.js +56 -64
- package/dist.commonjs/signer/ckb/verifyJoyId.d.ts +6 -2
- package/dist.commonjs/signer/ckb/verifyJoyId.js +11 -8
- package/dist.commonjs/signer/dummy/alwaysError.d.ts +4 -5
- package/dist.commonjs/signer/dummy/alwaysError.d.ts.map +1 -1
- package/dist.commonjs/signer/dummy/alwaysError.js +7 -10
- package/dist.commonjs/signer/dummy/dummy.d.ts +7 -7
- package/dist.commonjs/signer/dummy/dummy.js +16 -16
- package/dist.commonjs/signer/dummy/index.d.ts +1 -1
- package/dist.commonjs/signer/dummy/index.js +30 -14
- package/dist.commonjs/signer/dummy/openLink.d.ts +4 -5
- package/dist.commonjs/signer/dummy/openLink.d.ts.map +1 -1
- package/dist.commonjs/signer/dummy/openLink.js +7 -10
- package/dist.commonjs/signer/evm/index.d.ts +1 -1
- package/dist.commonjs/signer/evm/index.js +30 -14
- package/dist.commonjs/signer/evm/signerEvm.d.ts +42 -38
- package/dist.commonjs/signer/evm/signerEvm.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvm.js +106 -69
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts +37 -43
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.d.ts.map +1 -1
- package/dist.commonjs/signer/evm/signerEvmAddressReadonly.js +42 -50
- package/dist.commonjs/signer/evm/verify.d.ts +6 -2
- package/dist.commonjs/signer/evm/verify.js +7 -2
- package/dist.commonjs/signer/index.d.ts +2 -1
- package/dist.commonjs/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/index.js +31 -14
- package/dist.commonjs/signer/nostr/index.d.ts +2 -0
- package/dist.commonjs/signer/nostr/index.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/index.js +33 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts +66 -0
- package/dist.commonjs/signer/nostr/signerNostr.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/signerNostr.js +118 -0
- package/dist.commonjs/signer/nostr/verify.d.ts +11 -0
- package/dist.commonjs/signer/nostr/verify.d.ts.map +1 -0
- package/dist.commonjs/signer/nostr/verify.js +64 -0
- package/dist.commonjs/signer/signer/index.d.ts +156 -155
- package/dist.commonjs/signer/signer/index.d.ts.map +1 -1
- package/dist.commonjs/signer/signer/index.js +209 -175
- package/dist.commonjs/utils/index.d.ts +95 -6
- package/dist.commonjs/utils/index.d.ts.map +1 -1
- package/dist.commonjs/utils/index.js +30 -6
- package/package.json +4 -3
- package/src/address/address.advanced.ts +2 -5
- package/src/address/index.ts +2 -5
- package/src/ckb/script.ts +62 -2
- package/src/ckb/transaction.ts +678 -58
- package/src/client/advanced.ts +2 -0
- package/src/client/client.advanced.ts +134 -0
- package/src/client/client.ts +236 -25
- package/src/client/clientPublicMainnet.advanced.ts +117 -2
- package/src/client/clientPublicMainnet.ts +14 -3
- package/src/client/clientPublicTestnet.advanced.ts +176 -2
- package/src/client/clientPublicTestnet.ts +9 -3
- package/src/client/clientTypes.advanced.ts +26 -0
- package/src/client/clientTypes.ts +41 -43
- package/src/client/jsonRpc/index.ts +4 -4
- package/src/client/jsonRpc/transformers.ts +13 -11
- package/src/hasher/index.ts +4 -2
- package/src/num/index.ts +22 -0
- package/src/signer/btc/signerBtc.ts +6 -8
- package/src/signer/btc/signerBtcPublicKeyReadonly.ts +0 -9
- package/src/signer/btc/verify.ts +6 -3
- package/src/signer/ckb/signerCkbScriptReadonly.ts +0 -9
- package/src/signer/dummy/alwaysError.ts +0 -4
- package/src/signer/dummy/openLink.ts +0 -4
- package/src/signer/evm/signerEvm.ts +11 -11
- package/src/signer/evm/signerEvmAddressReadonly.ts +0 -9
- package/src/signer/index.ts +1 -0
- package/src/signer/nostr/index.ts +1 -0
- package/src/signer/nostr/signerNostr.ts +135 -0
- package/src/signer/nostr/verify.ts +63 -0
- package/src/signer/signer/index.ts +15 -11
- package/src/utils/index.ts +108 -0
|
@@ -1,1536 +1,1740 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SerializeTransaction =
|
|
4
|
-
exports.
|
|
3
|
+
exports.SerializeTransaction =
|
|
4
|
+
exports.Transaction =
|
|
5
|
+
exports.SerializeRawTransaction =
|
|
6
|
+
exports.RawTransaction =
|
|
7
|
+
exports.SerializeCellDep =
|
|
8
|
+
exports.CellDep =
|
|
9
|
+
exports.SerializeCellOutput =
|
|
10
|
+
exports.CellOutput =
|
|
11
|
+
exports.SerializeCellInput =
|
|
12
|
+
exports.CellInput =
|
|
13
|
+
exports.SerializeOutPoint =
|
|
14
|
+
exports.OutPoint =
|
|
15
|
+
exports.SerializeScript =
|
|
16
|
+
exports.Script =
|
|
17
|
+
exports.SerializeCellOutputVec =
|
|
18
|
+
exports.CellOutputVec =
|
|
19
|
+
exports.SerializeCellInputVec =
|
|
20
|
+
exports.CellInputVec =
|
|
21
|
+
exports.SerializeCellDepVec =
|
|
22
|
+
exports.CellDepVec =
|
|
23
|
+
exports.SerializeProposalShortIdVec =
|
|
24
|
+
exports.ProposalShortIdVec =
|
|
25
|
+
exports.SerializeTransactionVec =
|
|
26
|
+
exports.TransactionVec =
|
|
27
|
+
exports.SerializeUncleBlockVec =
|
|
28
|
+
exports.UncleBlockVec =
|
|
29
|
+
exports.SerializeProposalShortId =
|
|
30
|
+
exports.ProposalShortId =
|
|
31
|
+
exports.SerializeScriptOpt =
|
|
32
|
+
exports.ScriptOpt =
|
|
33
|
+
exports.SerializeByte32Vec =
|
|
34
|
+
exports.Byte32Vec =
|
|
35
|
+
exports.SerializeBytesVec =
|
|
36
|
+
exports.BytesVec =
|
|
37
|
+
exports.SerializeBytesOptVec =
|
|
38
|
+
exports.BytesOptVec =
|
|
39
|
+
exports.SerializeBytesOpt =
|
|
40
|
+
exports.BytesOpt =
|
|
41
|
+
exports.SerializeBytes =
|
|
42
|
+
exports.Bytes =
|
|
43
|
+
exports.SerializeUint256 =
|
|
44
|
+
exports.Uint256 =
|
|
45
|
+
exports.SerializeByte32 =
|
|
46
|
+
exports.Byte32 =
|
|
47
|
+
exports.SerializeUint128 =
|
|
48
|
+
exports.Uint128 =
|
|
49
|
+
exports.SerializeUint64 =
|
|
50
|
+
exports.Uint64 =
|
|
51
|
+
exports.SerializeUint32 =
|
|
52
|
+
exports.Uint32 =
|
|
53
|
+
void 0;
|
|
54
|
+
exports.SerializeWitnessArgs =
|
|
55
|
+
exports.WitnessArgs =
|
|
56
|
+
exports.SerializeCellbaseWitness =
|
|
57
|
+
exports.CellbaseWitness =
|
|
58
|
+
exports.SerializeBlockV1 =
|
|
59
|
+
exports.BlockV1 =
|
|
60
|
+
exports.SerializeBlock =
|
|
61
|
+
exports.Block =
|
|
62
|
+
exports.SerializeUncleBlock =
|
|
63
|
+
exports.UncleBlock =
|
|
64
|
+
exports.SerializeHeader =
|
|
65
|
+
exports.Header =
|
|
66
|
+
exports.SerializeRawHeader =
|
|
67
|
+
exports.RawHeader =
|
|
68
|
+
void 0;
|
|
5
69
|
function dataLengthError(actual, required) {
|
|
6
|
-
|
|
70
|
+
throw new Error(
|
|
71
|
+
`Invalid data length! Required: ${required}, actual: ${actual}`,
|
|
72
|
+
);
|
|
7
73
|
}
|
|
8
74
|
function assertDataLength(actual, required) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
75
|
+
if (actual !== required) {
|
|
76
|
+
dataLengthError(actual, required);
|
|
77
|
+
}
|
|
12
78
|
}
|
|
13
79
|
function assertArrayBuffer(reader) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
80
|
+
if (reader instanceof Object && reader.toArrayBuffer instanceof Function) {
|
|
81
|
+
reader = reader.toArrayBuffer();
|
|
82
|
+
}
|
|
83
|
+
if (reader instanceof Uint8Array) {
|
|
84
|
+
return reader.buffer.slice(
|
|
85
|
+
reader.byteOffset,
|
|
86
|
+
reader.byteLength + reader.byteOffset,
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
if (!(reader instanceof ArrayBuffer)) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"Provided value must be an ArrayBuffer or can be transformed into ArrayBuffer!",
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
return reader;
|
|
24
95
|
}
|
|
25
96
|
function verifyAndExtractOffsets(view, expectedFieldCount, compatible) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
97
|
+
if (view.byteLength < 4) {
|
|
98
|
+
dataLengthError(view.byteLength, ">4");
|
|
99
|
+
}
|
|
100
|
+
const requiredByteLength = view.getUint32(0, true);
|
|
101
|
+
assertDataLength(view.byteLength, requiredByteLength);
|
|
102
|
+
if (requiredByteLength === 4) {
|
|
103
|
+
return [requiredByteLength];
|
|
104
|
+
}
|
|
105
|
+
if (requiredByteLength < 8) {
|
|
106
|
+
dataLengthError(view.byteLength, ">8");
|
|
107
|
+
}
|
|
108
|
+
const firstOffset = view.getUint32(4, true);
|
|
109
|
+
if (firstOffset % 4 !== 0 || firstOffset < 8) {
|
|
110
|
+
throw new Error(`Invalid first offset: ${firstOffset}`);
|
|
111
|
+
}
|
|
112
|
+
const itemCount = firstOffset / 4 - 1;
|
|
113
|
+
if (itemCount < expectedFieldCount) {
|
|
114
|
+
throw new Error(
|
|
115
|
+
`Item count not enough! Required: ${expectedFieldCount}, actual: ${itemCount}`,
|
|
116
|
+
);
|
|
117
|
+
} else if (!compatible && itemCount > expectedFieldCount) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Item count is more than required! Required: ${expectedFieldCount}, actual: ${itemCount}`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
if (requiredByteLength < firstOffset) {
|
|
123
|
+
throw new Error(`First offset is larger than byte length: ${firstOffset}`);
|
|
124
|
+
}
|
|
125
|
+
const offsets = [];
|
|
126
|
+
for (let i = 0; i < itemCount; i++) {
|
|
127
|
+
const start = 4 + i * 4;
|
|
128
|
+
offsets.push(view.getUint32(start, true));
|
|
129
|
+
}
|
|
130
|
+
offsets.push(requiredByteLength);
|
|
131
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
132
|
+
if (offsets[i] > offsets[i + 1]) {
|
|
133
|
+
throw new Error(
|
|
134
|
+
`Offset index ${i}: ${offsets[i]} is larger than offset index ${i + 1}: ${offsets[i + 1]}`,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return offsets;
|
|
63
139
|
}
|
|
64
140
|
function serializeTable(buffers) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
141
|
+
const itemCount = buffers.length;
|
|
142
|
+
let totalSize = 4 * (itemCount + 1);
|
|
143
|
+
const offsets = [];
|
|
144
|
+
for (let i = 0; i < itemCount; i++) {
|
|
145
|
+
offsets.push(totalSize);
|
|
146
|
+
totalSize += buffers[i].byteLength;
|
|
147
|
+
}
|
|
148
|
+
const buffer = new ArrayBuffer(totalSize);
|
|
149
|
+
const array = new Uint8Array(buffer);
|
|
150
|
+
const view = new DataView(buffer);
|
|
151
|
+
view.setUint32(0, totalSize, true);
|
|
152
|
+
for (let i = 0; i < itemCount; i++) {
|
|
153
|
+
view.setUint32(4 + i * 4, offsets[i], true);
|
|
154
|
+
array.set(new Uint8Array(buffers[i]), offsets[i]);
|
|
155
|
+
}
|
|
156
|
+
return buffer;
|
|
81
157
|
}
|
|
82
158
|
class Uint32 {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
159
|
+
constructor(reader, { validate = true } = {}) {
|
|
160
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
161
|
+
if (validate) {
|
|
162
|
+
this.validate();
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
validate(compatible = false) {
|
|
166
|
+
assertDataLength(this.view.byteLength, 4);
|
|
167
|
+
}
|
|
168
|
+
indexAt(i) {
|
|
169
|
+
return this.view.getUint8(i);
|
|
170
|
+
}
|
|
171
|
+
raw() {
|
|
172
|
+
return this.view.buffer;
|
|
173
|
+
}
|
|
174
|
+
toBigEndianUint32() {
|
|
175
|
+
return this.view.getUint32(0, false);
|
|
176
|
+
}
|
|
177
|
+
toLittleEndianUint32() {
|
|
178
|
+
return this.view.getUint32(0, true);
|
|
179
|
+
}
|
|
180
|
+
static size() {
|
|
181
|
+
return 4;
|
|
182
|
+
}
|
|
107
183
|
}
|
|
108
184
|
exports.Uint32 = Uint32;
|
|
109
185
|
function SerializeUint32(value) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
186
|
+
const buffer = assertArrayBuffer(value);
|
|
187
|
+
assertDataLength(buffer.byteLength, 4);
|
|
188
|
+
return buffer;
|
|
113
189
|
}
|
|
114
190
|
exports.SerializeUint32 = SerializeUint32;
|
|
115
191
|
class Uint64 {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
192
|
+
constructor(reader, { validate = true } = {}) {
|
|
193
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
194
|
+
if (validate) {
|
|
195
|
+
this.validate();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
validate(compatible = false) {
|
|
199
|
+
assertDataLength(this.view.byteLength, 8);
|
|
200
|
+
}
|
|
201
|
+
indexAt(i) {
|
|
202
|
+
return this.view.getUint8(i);
|
|
203
|
+
}
|
|
204
|
+
raw() {
|
|
205
|
+
return this.view.buffer;
|
|
206
|
+
}
|
|
207
|
+
static size() {
|
|
208
|
+
return 8;
|
|
209
|
+
}
|
|
134
210
|
}
|
|
135
211
|
exports.Uint64 = Uint64;
|
|
136
212
|
function SerializeUint64(value) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
213
|
+
const buffer = assertArrayBuffer(value);
|
|
214
|
+
assertDataLength(buffer.byteLength, 8);
|
|
215
|
+
return buffer;
|
|
140
216
|
}
|
|
141
217
|
exports.SerializeUint64 = SerializeUint64;
|
|
142
218
|
class Uint128 {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
219
|
+
constructor(reader, { validate = true } = {}) {
|
|
220
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
221
|
+
if (validate) {
|
|
222
|
+
this.validate();
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
validate(compatible = false) {
|
|
226
|
+
assertDataLength(this.view.byteLength, 16);
|
|
227
|
+
}
|
|
228
|
+
indexAt(i) {
|
|
229
|
+
return this.view.getUint8(i);
|
|
230
|
+
}
|
|
231
|
+
raw() {
|
|
232
|
+
return this.view.buffer;
|
|
233
|
+
}
|
|
234
|
+
static size() {
|
|
235
|
+
return 16;
|
|
236
|
+
}
|
|
161
237
|
}
|
|
162
238
|
exports.Uint128 = Uint128;
|
|
163
239
|
function SerializeUint128(value) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
240
|
+
const buffer = assertArrayBuffer(value);
|
|
241
|
+
assertDataLength(buffer.byteLength, 16);
|
|
242
|
+
return buffer;
|
|
167
243
|
}
|
|
168
244
|
exports.SerializeUint128 = SerializeUint128;
|
|
169
245
|
class Byte32 {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
246
|
+
constructor(reader, { validate = true } = {}) {
|
|
247
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
248
|
+
if (validate) {
|
|
249
|
+
this.validate();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
validate(compatible = false) {
|
|
253
|
+
assertDataLength(this.view.byteLength, 32);
|
|
254
|
+
}
|
|
255
|
+
indexAt(i) {
|
|
256
|
+
return this.view.getUint8(i);
|
|
257
|
+
}
|
|
258
|
+
raw() {
|
|
259
|
+
return this.view.buffer;
|
|
260
|
+
}
|
|
261
|
+
static size() {
|
|
262
|
+
return 32;
|
|
263
|
+
}
|
|
188
264
|
}
|
|
189
265
|
exports.Byte32 = Byte32;
|
|
190
266
|
function SerializeByte32(value) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
267
|
+
const buffer = assertArrayBuffer(value);
|
|
268
|
+
assertDataLength(buffer.byteLength, 32);
|
|
269
|
+
return buffer;
|
|
194
270
|
}
|
|
195
271
|
exports.SerializeByte32 = SerializeByte32;
|
|
196
272
|
class Uint256 {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
273
|
+
constructor(reader, { validate = true } = {}) {
|
|
274
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
275
|
+
if (validate) {
|
|
276
|
+
this.validate();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
validate(compatible = false) {
|
|
280
|
+
assertDataLength(this.view.byteLength, 32);
|
|
281
|
+
}
|
|
282
|
+
indexAt(i) {
|
|
283
|
+
return this.view.getUint8(i);
|
|
284
|
+
}
|
|
285
|
+
raw() {
|
|
286
|
+
return this.view.buffer;
|
|
287
|
+
}
|
|
288
|
+
static size() {
|
|
289
|
+
return 32;
|
|
290
|
+
}
|
|
215
291
|
}
|
|
216
292
|
exports.Uint256 = Uint256;
|
|
217
293
|
function SerializeUint256(value) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
294
|
+
const buffer = assertArrayBuffer(value);
|
|
295
|
+
assertDataLength(buffer.byteLength, 32);
|
|
296
|
+
return buffer;
|
|
221
297
|
}
|
|
222
298
|
exports.SerializeUint256 = SerializeUint256;
|
|
223
299
|
class Bytes {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
300
|
+
constructor(reader, { validate = true } = {}) {
|
|
301
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
302
|
+
if (validate) {
|
|
303
|
+
this.validate();
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
validate(compatible = false) {
|
|
307
|
+
if (this.view.byteLength < 4) {
|
|
308
|
+
dataLengthError(this.view.byteLength, ">4");
|
|
309
|
+
}
|
|
310
|
+
const requiredByteLength = this.length() + 4;
|
|
311
|
+
assertDataLength(this.view.byteLength, requiredByteLength);
|
|
312
|
+
}
|
|
313
|
+
raw() {
|
|
314
|
+
return this.view.buffer.slice(4);
|
|
315
|
+
}
|
|
316
|
+
indexAt(i) {
|
|
317
|
+
return this.view.getUint8(4 + i);
|
|
318
|
+
}
|
|
319
|
+
length() {
|
|
320
|
+
return this.view.getUint32(0, true);
|
|
321
|
+
}
|
|
246
322
|
}
|
|
247
323
|
exports.Bytes = Bytes;
|
|
248
324
|
function SerializeBytes(value) {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
325
|
+
const item = assertArrayBuffer(value);
|
|
326
|
+
const array = new Uint8Array(4 + item.byteLength);
|
|
327
|
+
new DataView(array.buffer).setUint32(0, item.byteLength, true);
|
|
328
|
+
array.set(new Uint8Array(item), 4);
|
|
329
|
+
return array.buffer;
|
|
254
330
|
}
|
|
255
331
|
exports.SerializeBytes = SerializeBytes;
|
|
256
332
|
class BytesOpt {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
333
|
+
constructor(reader, { validate = true } = {}) {
|
|
334
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
335
|
+
if (validate) {
|
|
336
|
+
this.validate();
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
validate(compatible = false) {
|
|
340
|
+
if (this.hasValue()) {
|
|
341
|
+
this.value().validate(compatible);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
value() {
|
|
345
|
+
return new Bytes(this.view.buffer, { validate: false });
|
|
346
|
+
}
|
|
347
|
+
hasValue() {
|
|
348
|
+
return this.view.byteLength > 0;
|
|
349
|
+
}
|
|
274
350
|
}
|
|
275
351
|
exports.BytesOpt = BytesOpt;
|
|
276
352
|
function SerializeBytesOpt(value) {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
353
|
+
if (value) {
|
|
354
|
+
return SerializeBytes(value);
|
|
355
|
+
} else {
|
|
356
|
+
return new ArrayBuffer(0);
|
|
357
|
+
}
|
|
283
358
|
}
|
|
284
359
|
exports.SerializeBytesOpt = SerializeBytesOpt;
|
|
285
360
|
class BytesOptVec {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
361
|
+
constructor(reader, { validate = true } = {}) {
|
|
362
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
363
|
+
if (validate) {
|
|
364
|
+
this.validate();
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
validate(compatible = false) {
|
|
368
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
369
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
370
|
+
new BytesOpt(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
371
|
+
validate: false,
|
|
372
|
+
}).validate();
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
length() {
|
|
376
|
+
if (this.view.byteLength < 8) {
|
|
377
|
+
return 0;
|
|
378
|
+
} else {
|
|
379
|
+
return this.view.getUint32(4, true) / 4 - 1;
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
indexAt(i) {
|
|
383
|
+
const start = 4 + i * 4;
|
|
384
|
+
const offset = this.view.getUint32(start, true);
|
|
385
|
+
let offset_end = this.view.byteLength;
|
|
386
|
+
if (i + 1 < this.length()) {
|
|
387
|
+
offset_end = this.view.getUint32(start + 4, true);
|
|
388
|
+
}
|
|
389
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
390
|
+
validate: false,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
319
393
|
}
|
|
320
394
|
exports.BytesOptVec = BytesOptVec;
|
|
321
395
|
function SerializeBytesOptVec(value) {
|
|
322
|
-
|
|
396
|
+
return serializeTable(value.map((item) => SerializeBytesOpt(item)));
|
|
323
397
|
}
|
|
324
398
|
exports.SerializeBytesOptVec = SerializeBytesOptVec;
|
|
325
399
|
class BytesVec {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
}
|
|
400
|
+
constructor(reader, { validate = true } = {}) {
|
|
401
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
402
|
+
if (validate) {
|
|
403
|
+
this.validate();
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
validate(compatible = false) {
|
|
407
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
408
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
409
|
+
new Bytes(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
410
|
+
validate: false,
|
|
411
|
+
}).validate();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
length() {
|
|
415
|
+
if (this.view.byteLength < 8) {
|
|
416
|
+
return 0;
|
|
417
|
+
} else {
|
|
418
|
+
return this.view.getUint32(4, true) / 4 - 1;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
indexAt(i) {
|
|
422
|
+
const start = 4 + i * 4;
|
|
423
|
+
const offset = this.view.getUint32(start, true);
|
|
424
|
+
let offset_end = this.view.byteLength;
|
|
425
|
+
if (i + 1 < this.length()) {
|
|
426
|
+
offset_end = this.view.getUint32(start + 4, true);
|
|
427
|
+
}
|
|
428
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
429
|
+
validate: false,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
359
432
|
}
|
|
360
433
|
exports.BytesVec = BytesVec;
|
|
361
434
|
function SerializeBytesVec(value) {
|
|
362
|
-
|
|
435
|
+
return serializeTable(value.map((item) => SerializeBytes(item)));
|
|
363
436
|
}
|
|
364
437
|
exports.SerializeBytesVec = SerializeBytesVec;
|
|
365
438
|
class Byte32Vec {
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
439
|
+
constructor(reader, { validate = true } = {}) {
|
|
440
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
441
|
+
if (validate) {
|
|
442
|
+
this.validate();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
validate(compatible = false) {
|
|
446
|
+
if (this.view.byteLength < 4) {
|
|
447
|
+
dataLengthError(this.view.byteLength, ">4");
|
|
448
|
+
}
|
|
449
|
+
const requiredByteLength = this.length() * Byte32.size() + 4;
|
|
450
|
+
assertDataLength(this.view.byteLength, requiredByteLength);
|
|
451
|
+
for (let i = 0; i < 0; i++) {
|
|
452
|
+
const item = this.indexAt(i);
|
|
453
|
+
item.validate(compatible);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
indexAt(i) {
|
|
457
|
+
return new Byte32(
|
|
458
|
+
this.view.buffer.slice(
|
|
459
|
+
4 + i * Byte32.size(),
|
|
460
|
+
4 + (i + 1) * Byte32.size(),
|
|
461
|
+
),
|
|
462
|
+
{ validate: false },
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
length() {
|
|
466
|
+
return this.view.getUint32(0, true);
|
|
467
|
+
}
|
|
389
468
|
}
|
|
390
469
|
exports.Byte32Vec = Byte32Vec;
|
|
391
470
|
function SerializeByte32Vec(value) {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
471
|
+
const array = new Uint8Array(4 + Byte32.size() * value.length);
|
|
472
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
473
|
+
for (let i = 0; i < value.length; i++) {
|
|
474
|
+
const itemBuffer = SerializeByte32(value[i]);
|
|
475
|
+
array.set(new Uint8Array(itemBuffer), 4 + i * Byte32.size());
|
|
476
|
+
}
|
|
477
|
+
return array.buffer;
|
|
399
478
|
}
|
|
400
479
|
exports.SerializeByte32Vec = SerializeByte32Vec;
|
|
401
480
|
class ScriptOpt {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
481
|
+
constructor(reader, { validate = true } = {}) {
|
|
482
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
483
|
+
if (validate) {
|
|
484
|
+
this.validate();
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
validate(compatible = false) {
|
|
488
|
+
if (this.hasValue()) {
|
|
489
|
+
this.value().validate(compatible);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
value() {
|
|
493
|
+
return new Script(this.view.buffer, { validate: false });
|
|
494
|
+
}
|
|
495
|
+
hasValue() {
|
|
496
|
+
return this.view.byteLength > 0;
|
|
497
|
+
}
|
|
419
498
|
}
|
|
420
499
|
exports.ScriptOpt = ScriptOpt;
|
|
421
500
|
function SerializeScriptOpt(value) {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
}
|
|
501
|
+
if (value) {
|
|
502
|
+
return SerializeScript(value);
|
|
503
|
+
} else {
|
|
504
|
+
return new ArrayBuffer(0);
|
|
505
|
+
}
|
|
428
506
|
}
|
|
429
507
|
exports.SerializeScriptOpt = SerializeScriptOpt;
|
|
430
508
|
class ProposalShortId {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
509
|
+
constructor(reader, { validate = true } = {}) {
|
|
510
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
511
|
+
if (validate) {
|
|
512
|
+
this.validate();
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
validate(compatible = false) {
|
|
516
|
+
assertDataLength(this.view.byteLength, 10);
|
|
517
|
+
}
|
|
518
|
+
indexAt(i) {
|
|
519
|
+
return this.view.getUint8(i);
|
|
520
|
+
}
|
|
521
|
+
raw() {
|
|
522
|
+
return this.view.buffer;
|
|
523
|
+
}
|
|
524
|
+
static size() {
|
|
525
|
+
return 10;
|
|
526
|
+
}
|
|
449
527
|
}
|
|
450
528
|
exports.ProposalShortId = ProposalShortId;
|
|
451
529
|
function SerializeProposalShortId(value) {
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
530
|
+
const buffer = assertArrayBuffer(value);
|
|
531
|
+
assertDataLength(buffer.byteLength, 10);
|
|
532
|
+
return buffer;
|
|
455
533
|
}
|
|
456
534
|
exports.SerializeProposalShortId = SerializeProposalShortId;
|
|
457
535
|
class UncleBlockVec {
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
}
|
|
536
|
+
constructor(reader, { validate = true } = {}) {
|
|
537
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
538
|
+
if (validate) {
|
|
539
|
+
this.validate();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
validate(compatible = false) {
|
|
543
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
544
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
545
|
+
new UncleBlock(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
546
|
+
validate: false,
|
|
547
|
+
}).validate();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
length() {
|
|
551
|
+
if (this.view.byteLength < 8) {
|
|
552
|
+
return 0;
|
|
553
|
+
} else {
|
|
554
|
+
return this.view.getUint32(4, true) / 4 - 1;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
indexAt(i) {
|
|
558
|
+
const start = 4 + i * 4;
|
|
559
|
+
const offset = this.view.getUint32(start, true);
|
|
560
|
+
let offset_end = this.view.byteLength;
|
|
561
|
+
if (i + 1 < this.length()) {
|
|
562
|
+
offset_end = this.view.getUint32(start + 4, true);
|
|
563
|
+
}
|
|
564
|
+
return new UncleBlock(this.view.buffer.slice(offset, offset_end), {
|
|
565
|
+
validate: false,
|
|
566
|
+
});
|
|
567
|
+
}
|
|
491
568
|
}
|
|
492
569
|
exports.UncleBlockVec = UncleBlockVec;
|
|
493
570
|
function SerializeUncleBlockVec(value) {
|
|
494
|
-
|
|
571
|
+
return serializeTable(value.map((item) => SerializeUncleBlock(item)));
|
|
495
572
|
}
|
|
496
573
|
exports.SerializeUncleBlockVec = SerializeUncleBlockVec;
|
|
497
574
|
class TransactionVec {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
}
|
|
575
|
+
constructor(reader, { validate = true } = {}) {
|
|
576
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
577
|
+
if (validate) {
|
|
578
|
+
this.validate();
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
validate(compatible = false) {
|
|
582
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
583
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
584
|
+
new Transaction(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
585
|
+
validate: false,
|
|
586
|
+
}).validate();
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
length() {
|
|
590
|
+
if (this.view.byteLength < 8) {
|
|
591
|
+
return 0;
|
|
592
|
+
} else {
|
|
593
|
+
return this.view.getUint32(4, true) / 4 - 1;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
indexAt(i) {
|
|
597
|
+
const start = 4 + i * 4;
|
|
598
|
+
const offset = this.view.getUint32(start, true);
|
|
599
|
+
let offset_end = this.view.byteLength;
|
|
600
|
+
if (i + 1 < this.length()) {
|
|
601
|
+
offset_end = this.view.getUint32(start + 4, true);
|
|
602
|
+
}
|
|
603
|
+
return new Transaction(this.view.buffer.slice(offset, offset_end), {
|
|
604
|
+
validate: false,
|
|
605
|
+
});
|
|
606
|
+
}
|
|
531
607
|
}
|
|
532
608
|
exports.TransactionVec = TransactionVec;
|
|
533
609
|
function SerializeTransactionVec(value) {
|
|
534
|
-
|
|
610
|
+
return serializeTable(value.map((item) => SerializeTransaction(item)));
|
|
535
611
|
}
|
|
536
612
|
exports.SerializeTransactionVec = SerializeTransactionVec;
|
|
537
613
|
class ProposalShortIdVec {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
614
|
+
constructor(reader, { validate = true } = {}) {
|
|
615
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
616
|
+
if (validate) {
|
|
617
|
+
this.validate();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
validate(compatible = false) {
|
|
621
|
+
if (this.view.byteLength < 4) {
|
|
622
|
+
dataLengthError(this.view.byteLength, ">4");
|
|
623
|
+
}
|
|
624
|
+
const requiredByteLength = this.length() * ProposalShortId.size() + 4;
|
|
625
|
+
assertDataLength(this.view.byteLength, requiredByteLength);
|
|
626
|
+
for (let i = 0; i < 0; i++) {
|
|
627
|
+
const item = this.indexAt(i);
|
|
628
|
+
item.validate(compatible);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
indexAt(i) {
|
|
632
|
+
return new ProposalShortId(
|
|
633
|
+
this.view.buffer.slice(
|
|
634
|
+
4 + i * ProposalShortId.size(),
|
|
635
|
+
4 + (i + 1) * ProposalShortId.size(),
|
|
636
|
+
),
|
|
637
|
+
{ validate: false },
|
|
638
|
+
);
|
|
639
|
+
}
|
|
640
|
+
length() {
|
|
641
|
+
return this.view.getUint32(0, true);
|
|
642
|
+
}
|
|
561
643
|
}
|
|
562
644
|
exports.ProposalShortIdVec = ProposalShortIdVec;
|
|
563
645
|
function SerializeProposalShortIdVec(value) {
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
646
|
+
const array = new Uint8Array(4 + ProposalShortId.size() * value.length);
|
|
647
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
648
|
+
for (let i = 0; i < value.length; i++) {
|
|
649
|
+
const itemBuffer = SerializeProposalShortId(value[i]);
|
|
650
|
+
array.set(new Uint8Array(itemBuffer), 4 + i * ProposalShortId.size());
|
|
651
|
+
}
|
|
652
|
+
return array.buffer;
|
|
571
653
|
}
|
|
572
654
|
exports.SerializeProposalShortIdVec = SerializeProposalShortIdVec;
|
|
573
655
|
class CellDepVec {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
656
|
+
constructor(reader, { validate = true } = {}) {
|
|
657
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
658
|
+
if (validate) {
|
|
659
|
+
this.validate();
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
validate(compatible = false) {
|
|
663
|
+
if (this.view.byteLength < 4) {
|
|
664
|
+
dataLengthError(this.view.byteLength, ">4");
|
|
665
|
+
}
|
|
666
|
+
const requiredByteLength = this.length() * CellDep.size() + 4;
|
|
667
|
+
assertDataLength(this.view.byteLength, requiredByteLength);
|
|
668
|
+
for (let i = 0; i < 0; i++) {
|
|
669
|
+
const item = this.indexAt(i);
|
|
670
|
+
item.validate(compatible);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
indexAt(i) {
|
|
674
|
+
return new CellDep(
|
|
675
|
+
this.view.buffer.slice(
|
|
676
|
+
4 + i * CellDep.size(),
|
|
677
|
+
4 + (i + 1) * CellDep.size(),
|
|
678
|
+
),
|
|
679
|
+
{ validate: false },
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
length() {
|
|
683
|
+
return this.view.getUint32(0, true);
|
|
684
|
+
}
|
|
597
685
|
}
|
|
598
686
|
exports.CellDepVec = CellDepVec;
|
|
599
687
|
function SerializeCellDepVec(value) {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
688
|
+
const array = new Uint8Array(4 + CellDep.size() * value.length);
|
|
689
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
690
|
+
for (let i = 0; i < value.length; i++) {
|
|
691
|
+
const itemBuffer = SerializeCellDep(value[i]);
|
|
692
|
+
array.set(new Uint8Array(itemBuffer), 4 + i * CellDep.size());
|
|
693
|
+
}
|
|
694
|
+
return array.buffer;
|
|
607
695
|
}
|
|
608
696
|
exports.SerializeCellDepVec = SerializeCellDepVec;
|
|
609
697
|
class CellInputVec {
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
698
|
+
constructor(reader, { validate = true } = {}) {
|
|
699
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
700
|
+
if (validate) {
|
|
701
|
+
this.validate();
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
validate(compatible = false) {
|
|
705
|
+
if (this.view.byteLength < 4) {
|
|
706
|
+
dataLengthError(this.view.byteLength, ">4");
|
|
707
|
+
}
|
|
708
|
+
const requiredByteLength = this.length() * CellInput.size() + 4;
|
|
709
|
+
assertDataLength(this.view.byteLength, requiredByteLength);
|
|
710
|
+
for (let i = 0; i < 0; i++) {
|
|
711
|
+
const item = this.indexAt(i);
|
|
712
|
+
item.validate(compatible);
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
indexAt(i) {
|
|
716
|
+
return new CellInput(
|
|
717
|
+
this.view.buffer.slice(
|
|
718
|
+
4 + i * CellInput.size(),
|
|
719
|
+
4 + (i + 1) * CellInput.size(),
|
|
720
|
+
),
|
|
721
|
+
{ validate: false },
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
length() {
|
|
725
|
+
return this.view.getUint32(0, true);
|
|
726
|
+
}
|
|
633
727
|
}
|
|
634
728
|
exports.CellInputVec = CellInputVec;
|
|
635
729
|
function SerializeCellInputVec(value) {
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
730
|
+
const array = new Uint8Array(4 + CellInput.size() * value.length);
|
|
731
|
+
new DataView(array.buffer).setUint32(0, value.length, true);
|
|
732
|
+
for (let i = 0; i < value.length; i++) {
|
|
733
|
+
const itemBuffer = SerializeCellInput(value[i]);
|
|
734
|
+
array.set(new Uint8Array(itemBuffer), 4 + i * CellInput.size());
|
|
735
|
+
}
|
|
736
|
+
return array.buffer;
|
|
643
737
|
}
|
|
644
738
|
exports.SerializeCellInputVec = SerializeCellInputVec;
|
|
645
739
|
class CellOutputVec {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
}
|
|
740
|
+
constructor(reader, { validate = true } = {}) {
|
|
741
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
742
|
+
if (validate) {
|
|
743
|
+
this.validate();
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
validate(compatible = false) {
|
|
747
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
748
|
+
for (let i = 0; i < offsets.length - 1; i++) {
|
|
749
|
+
new CellOutput(this.view.buffer.slice(offsets[i], offsets[i + 1]), {
|
|
750
|
+
validate: false,
|
|
751
|
+
}).validate();
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
length() {
|
|
755
|
+
if (this.view.byteLength < 8) {
|
|
756
|
+
return 0;
|
|
757
|
+
} else {
|
|
758
|
+
return this.view.getUint32(4, true) / 4 - 1;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
indexAt(i) {
|
|
762
|
+
const start = 4 + i * 4;
|
|
763
|
+
const offset = this.view.getUint32(start, true);
|
|
764
|
+
let offset_end = this.view.byteLength;
|
|
765
|
+
if (i + 1 < this.length()) {
|
|
766
|
+
offset_end = this.view.getUint32(start + 4, true);
|
|
767
|
+
}
|
|
768
|
+
return new CellOutput(this.view.buffer.slice(offset, offset_end), {
|
|
769
|
+
validate: false,
|
|
770
|
+
});
|
|
771
|
+
}
|
|
679
772
|
}
|
|
680
773
|
exports.CellOutputVec = CellOutputVec;
|
|
681
774
|
function SerializeCellOutputVec(value) {
|
|
682
|
-
|
|
775
|
+
return serializeTable(value.map((item) => SerializeCellOutput(item)));
|
|
683
776
|
}
|
|
684
777
|
exports.SerializeCellOutputVec = SerializeCellOutputVec;
|
|
685
778
|
class Script {
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
779
|
+
constructor(reader, { validate = true } = {}) {
|
|
780
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
781
|
+
if (validate) {
|
|
782
|
+
this.validate();
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
validate(compatible = false) {
|
|
786
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
787
|
+
new Byte32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
788
|
+
validate: false,
|
|
789
|
+
}).validate();
|
|
790
|
+
if (offsets[2] - offsets[1] !== 1) {
|
|
791
|
+
throw new Error(
|
|
792
|
+
`Invalid offset for hashType: ${offsets[1]} - ${offsets[2]}`,
|
|
793
|
+
);
|
|
794
|
+
}
|
|
795
|
+
new Bytes(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
796
|
+
validate: false,
|
|
797
|
+
}).validate();
|
|
798
|
+
}
|
|
799
|
+
getCodeHash() {
|
|
800
|
+
const start = 4;
|
|
801
|
+
const offset = this.view.getUint32(start, true);
|
|
802
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
803
|
+
return new Byte32(this.view.buffer.slice(offset, offset_end), {
|
|
804
|
+
validate: false,
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
getHashType() {
|
|
808
|
+
const start = 8;
|
|
809
|
+
const offset = this.view.getUint32(start, true);
|
|
810
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
811
|
+
return new DataView(this.view.buffer.slice(offset, offset_end)).getUint8(0);
|
|
812
|
+
}
|
|
813
|
+
getArgs() {
|
|
814
|
+
const start = 12;
|
|
815
|
+
const offset = this.view.getUint32(start, true);
|
|
816
|
+
const offset_end = this.view.byteLength;
|
|
817
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
818
|
+
validate: false,
|
|
819
|
+
});
|
|
820
|
+
}
|
|
726
821
|
}
|
|
727
822
|
exports.Script = Script;
|
|
728
823
|
function SerializeScript(value) {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
824
|
+
const buffers = [];
|
|
825
|
+
buffers.push(SerializeByte32(value.codeHash));
|
|
826
|
+
const hashTypeView = new DataView(new ArrayBuffer(1));
|
|
827
|
+
hashTypeView.setUint8(0, value.hashType);
|
|
828
|
+
buffers.push(hashTypeView.buffer);
|
|
829
|
+
buffers.push(SerializeBytes(value.args));
|
|
830
|
+
return serializeTable(buffers);
|
|
736
831
|
}
|
|
737
832
|
exports.SerializeScript = SerializeScript;
|
|
738
833
|
class OutPoint {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
834
|
+
constructor(reader, { validate = true } = {}) {
|
|
835
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
836
|
+
if (validate) {
|
|
837
|
+
this.validate();
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
getTxHash() {
|
|
841
|
+
return new Byte32(this.view.buffer.slice(0, 0 + Byte32.size()), {
|
|
842
|
+
validate: false,
|
|
843
|
+
});
|
|
844
|
+
}
|
|
845
|
+
getIndex() {
|
|
846
|
+
return new Uint32(
|
|
847
|
+
this.view.buffer.slice(
|
|
848
|
+
0 + Byte32.size(),
|
|
849
|
+
0 + Byte32.size() + Uint32.size(),
|
|
850
|
+
),
|
|
851
|
+
{ validate: false },
|
|
852
|
+
);
|
|
853
|
+
}
|
|
854
|
+
validate(compatible = false) {
|
|
855
|
+
assertDataLength(this.view.byteLength, OutPoint.size());
|
|
856
|
+
this.getTxHash().validate(compatible);
|
|
857
|
+
this.getIndex().validate(compatible);
|
|
858
|
+
}
|
|
859
|
+
static size() {
|
|
860
|
+
return 0 + Byte32.size() + Uint32.size();
|
|
861
|
+
}
|
|
761
862
|
}
|
|
762
863
|
exports.OutPoint = OutPoint;
|
|
763
864
|
function SerializeOutPoint(value) {
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
865
|
+
const array = new Uint8Array(0 + Byte32.size() + Uint32.size());
|
|
866
|
+
const view = new DataView(array.buffer);
|
|
867
|
+
array.set(new Uint8Array(SerializeByte32(value.txHash)), 0);
|
|
868
|
+
array.set(new Uint8Array(SerializeUint32(value.index)), 0 + Byte32.size());
|
|
869
|
+
return array.buffer;
|
|
769
870
|
}
|
|
770
871
|
exports.SerializeOutPoint = SerializeOutPoint;
|
|
771
872
|
class CellInput {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
873
|
+
constructor(reader, { validate = true } = {}) {
|
|
874
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
875
|
+
if (validate) {
|
|
876
|
+
this.validate();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
getSince() {
|
|
880
|
+
return new Uint64(this.view.buffer.slice(0, 0 + Uint64.size()), {
|
|
881
|
+
validate: false,
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
getPreviousOutput() {
|
|
885
|
+
return new OutPoint(
|
|
886
|
+
this.view.buffer.slice(
|
|
887
|
+
0 + Uint64.size(),
|
|
888
|
+
0 + Uint64.size() + OutPoint.size(),
|
|
889
|
+
),
|
|
890
|
+
{ validate: false },
|
|
891
|
+
);
|
|
892
|
+
}
|
|
893
|
+
validate(compatible = false) {
|
|
894
|
+
assertDataLength(this.view.byteLength, CellInput.size());
|
|
895
|
+
this.getSince().validate(compatible);
|
|
896
|
+
this.getPreviousOutput().validate(compatible);
|
|
897
|
+
}
|
|
898
|
+
static size() {
|
|
899
|
+
return 0 + Uint64.size() + OutPoint.size();
|
|
900
|
+
}
|
|
794
901
|
}
|
|
795
902
|
exports.CellInput = CellInput;
|
|
796
903
|
function SerializeCellInput(value) {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
904
|
+
const array = new Uint8Array(0 + Uint64.size() + OutPoint.size());
|
|
905
|
+
const view = new DataView(array.buffer);
|
|
906
|
+
array.set(new Uint8Array(SerializeUint64(value.since)), 0);
|
|
907
|
+
array.set(
|
|
908
|
+
new Uint8Array(SerializeOutPoint(value.previousOutput)),
|
|
909
|
+
0 + Uint64.size(),
|
|
910
|
+
);
|
|
911
|
+
return array.buffer;
|
|
802
912
|
}
|
|
803
913
|
exports.SerializeCellInput = SerializeCellInput;
|
|
804
914
|
class CellOutput {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
915
|
+
constructor(reader, { validate = true } = {}) {
|
|
916
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
917
|
+
if (validate) {
|
|
918
|
+
this.validate();
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
validate(compatible = false) {
|
|
922
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
923
|
+
new Uint64(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
924
|
+
validate: false,
|
|
925
|
+
}).validate();
|
|
926
|
+
new Script(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
927
|
+
validate: false,
|
|
928
|
+
}).validate();
|
|
929
|
+
new ScriptOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
930
|
+
validate: false,
|
|
931
|
+
}).validate();
|
|
932
|
+
}
|
|
933
|
+
getCapacity() {
|
|
934
|
+
const start = 4;
|
|
935
|
+
const offset = this.view.getUint32(start, true);
|
|
936
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
937
|
+
return new Uint64(this.view.buffer.slice(offset, offset_end), {
|
|
938
|
+
validate: false,
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
getLock() {
|
|
942
|
+
const start = 8;
|
|
943
|
+
const offset = this.view.getUint32(start, true);
|
|
944
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
945
|
+
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
946
|
+
validate: false,
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
getType() {
|
|
950
|
+
const start = 12;
|
|
951
|
+
const offset = this.view.getUint32(start, true);
|
|
952
|
+
const offset_end = this.view.byteLength;
|
|
953
|
+
return new ScriptOpt(this.view.buffer.slice(offset, offset_end), {
|
|
954
|
+
validate: false,
|
|
955
|
+
});
|
|
956
|
+
}
|
|
847
957
|
}
|
|
848
958
|
exports.CellOutput = CellOutput;
|
|
849
959
|
function SerializeCellOutput(value) {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
960
|
+
const buffers = [];
|
|
961
|
+
buffers.push(SerializeUint64(value.capacity));
|
|
962
|
+
buffers.push(SerializeScript(value.lock));
|
|
963
|
+
buffers.push(SerializeScriptOpt(value.type));
|
|
964
|
+
return serializeTable(buffers);
|
|
855
965
|
}
|
|
856
966
|
exports.SerializeCellOutput = SerializeCellOutput;
|
|
857
967
|
class CellDep {
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
968
|
+
constructor(reader, { validate = true } = {}) {
|
|
969
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
970
|
+
if (validate) {
|
|
971
|
+
this.validate();
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
getOutPoint() {
|
|
975
|
+
return new OutPoint(this.view.buffer.slice(0, 0 + OutPoint.size()), {
|
|
976
|
+
validate: false,
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
getDepType() {
|
|
980
|
+
return this.view.getUint8(0 + OutPoint.size());
|
|
981
|
+
}
|
|
982
|
+
validate(compatible = false) {
|
|
983
|
+
assertDataLength(this.view.byteLength, CellDep.size());
|
|
984
|
+
this.getOutPoint().validate(compatible);
|
|
985
|
+
}
|
|
986
|
+
static size() {
|
|
987
|
+
return 0 + OutPoint.size() + 1;
|
|
988
|
+
}
|
|
879
989
|
}
|
|
880
990
|
exports.CellDep = CellDep;
|
|
881
991
|
function SerializeCellDep(value) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
992
|
+
const array = new Uint8Array(0 + OutPoint.size() + 1);
|
|
993
|
+
const view = new DataView(array.buffer);
|
|
994
|
+
array.set(new Uint8Array(SerializeOutPoint(value.outPoint)), 0);
|
|
995
|
+
view.setUint8(0 + OutPoint.size(), value.depType);
|
|
996
|
+
return array.buffer;
|
|
887
997
|
}
|
|
888
998
|
exports.SerializeCellDep = SerializeCellDep;
|
|
889
999
|
class RawTransaction {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
1000
|
+
constructor(reader, { validate = true } = {}) {
|
|
1001
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1002
|
+
if (validate) {
|
|
1003
|
+
this.validate();
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
validate(compatible = false) {
|
|
1007
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1008
|
+
new Uint32(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1009
|
+
validate: false,
|
|
1010
|
+
}).validate();
|
|
1011
|
+
new CellDepVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1012
|
+
validate: false,
|
|
1013
|
+
}).validate();
|
|
1014
|
+
new Byte32Vec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1015
|
+
validate: false,
|
|
1016
|
+
}).validate();
|
|
1017
|
+
new CellInputVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
1018
|
+
validate: false,
|
|
1019
|
+
}).validate();
|
|
1020
|
+
new CellOutputVec(this.view.buffer.slice(offsets[4], offsets[5]), {
|
|
1021
|
+
validate: false,
|
|
1022
|
+
}).validate();
|
|
1023
|
+
new BytesVec(this.view.buffer.slice(offsets[5], offsets[6]), {
|
|
1024
|
+
validate: false,
|
|
1025
|
+
}).validate();
|
|
1026
|
+
}
|
|
1027
|
+
getVersion() {
|
|
1028
|
+
const start = 4;
|
|
1029
|
+
const offset = this.view.getUint32(start, true);
|
|
1030
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1031
|
+
return new Uint32(this.view.buffer.slice(offset, offset_end), {
|
|
1032
|
+
validate: false,
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
1035
|
+
getCellDeps() {
|
|
1036
|
+
const start = 8;
|
|
1037
|
+
const offset = this.view.getUint32(start, true);
|
|
1038
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1039
|
+
return new CellDepVec(this.view.buffer.slice(offset, offset_end), {
|
|
1040
|
+
validate: false,
|
|
1041
|
+
});
|
|
1042
|
+
}
|
|
1043
|
+
getHeaderDeps() {
|
|
1044
|
+
const start = 12;
|
|
1045
|
+
const offset = this.view.getUint32(start, true);
|
|
1046
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1047
|
+
return new Byte32Vec(this.view.buffer.slice(offset, offset_end), {
|
|
1048
|
+
validate: false,
|
|
1049
|
+
});
|
|
1050
|
+
}
|
|
1051
|
+
getInputs() {
|
|
1052
|
+
const start = 16;
|
|
1053
|
+
const offset = this.view.getUint32(start, true);
|
|
1054
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1055
|
+
return new CellInputVec(this.view.buffer.slice(offset, offset_end), {
|
|
1056
|
+
validate: false,
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
getOutputs() {
|
|
1060
|
+
const start = 20;
|
|
1061
|
+
const offset = this.view.getUint32(start, true);
|
|
1062
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1063
|
+
return new CellOutputVec(this.view.buffer.slice(offset, offset_end), {
|
|
1064
|
+
validate: false,
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
getOutputsData() {
|
|
1068
|
+
const start = 24;
|
|
1069
|
+
const offset = this.view.getUint32(start, true);
|
|
1070
|
+
const offset_end = this.view.byteLength;
|
|
1071
|
+
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
1072
|
+
validate: false,
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
965
1075
|
}
|
|
966
1076
|
exports.RawTransaction = RawTransaction;
|
|
967
1077
|
function SerializeRawTransaction(value) {
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
1078
|
+
const buffers = [];
|
|
1079
|
+
buffers.push(SerializeUint32(value.version));
|
|
1080
|
+
buffers.push(SerializeCellDepVec(value.cellDeps));
|
|
1081
|
+
buffers.push(SerializeByte32Vec(value.headerDeps));
|
|
1082
|
+
buffers.push(SerializeCellInputVec(value.inputs));
|
|
1083
|
+
buffers.push(SerializeCellOutputVec(value.outputs));
|
|
1084
|
+
buffers.push(SerializeBytesVec(value.outputsData));
|
|
1085
|
+
return serializeTable(buffers);
|
|
976
1086
|
}
|
|
977
1087
|
exports.SerializeRawTransaction = SerializeRawTransaction;
|
|
978
1088
|
class Transaction {
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1089
|
+
constructor(reader, { validate = true } = {}) {
|
|
1090
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1091
|
+
if (validate) {
|
|
1092
|
+
this.validate();
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
validate(compatible = false) {
|
|
1096
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1097
|
+
new RawTransaction(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1098
|
+
validate: false,
|
|
1099
|
+
}).validate();
|
|
1100
|
+
new BytesVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1101
|
+
validate: false,
|
|
1102
|
+
}).validate();
|
|
1103
|
+
}
|
|
1104
|
+
getRaw() {
|
|
1105
|
+
const start = 4;
|
|
1106
|
+
const offset = this.view.getUint32(start, true);
|
|
1107
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1108
|
+
return new RawTransaction(this.view.buffer.slice(offset, offset_end), {
|
|
1109
|
+
validate: false,
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
getWitnesses() {
|
|
1113
|
+
const start = 8;
|
|
1114
|
+
const offset = this.view.getUint32(start, true);
|
|
1115
|
+
const offset_end = this.view.byteLength;
|
|
1116
|
+
return new BytesVec(this.view.buffer.slice(offset, offset_end), {
|
|
1117
|
+
validate: false,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1010
1120
|
}
|
|
1011
1121
|
exports.Transaction = Transaction;
|
|
1012
1122
|
function SerializeTransaction(value) {
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1123
|
+
const buffers = [];
|
|
1124
|
+
buffers.push(SerializeRawTransaction(value.raw));
|
|
1125
|
+
buffers.push(SerializeBytesVec(value.witnesses));
|
|
1126
|
+
return serializeTable(buffers);
|
|
1017
1127
|
}
|
|
1018
1128
|
exports.SerializeTransaction = SerializeTransaction;
|
|
1019
1129
|
class RawHeader {
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1130
|
+
constructor(reader, { validate = true } = {}) {
|
|
1131
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1132
|
+
if (validate) {
|
|
1133
|
+
this.validate();
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
getVersion() {
|
|
1137
|
+
return new Uint32(this.view.buffer.slice(0, 0 + Uint32.size()), {
|
|
1138
|
+
validate: false,
|
|
1139
|
+
});
|
|
1140
|
+
}
|
|
1141
|
+
getCompactTarget() {
|
|
1142
|
+
return new Uint32(
|
|
1143
|
+
this.view.buffer.slice(
|
|
1144
|
+
0 + Uint32.size(),
|
|
1145
|
+
0 + Uint32.size() + Uint32.size(),
|
|
1146
|
+
),
|
|
1147
|
+
{ validate: false },
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
getTimestamp() {
|
|
1151
|
+
return new Uint64(
|
|
1152
|
+
this.view.buffer.slice(
|
|
1153
|
+
0 + Uint32.size() + Uint32.size(),
|
|
1154
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size(),
|
|
1155
|
+
),
|
|
1156
|
+
{ validate: false },
|
|
1157
|
+
);
|
|
1158
|
+
}
|
|
1159
|
+
getNumber() {
|
|
1160
|
+
return new Uint64(
|
|
1161
|
+
this.view.buffer.slice(
|
|
1162
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size(),
|
|
1163
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
|
|
1164
|
+
),
|
|
1165
|
+
{ validate: false },
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
getEpoch() {
|
|
1169
|
+
return new Uint64(
|
|
1170
|
+
this.view.buffer.slice(
|
|
1171
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
|
|
1172
|
+
0 +
|
|
1173
|
+
Uint32.size() +
|
|
1174
|
+
Uint32.size() +
|
|
1175
|
+
Uint64.size() +
|
|
1176
|
+
Uint64.size() +
|
|
1177
|
+
Uint64.size(),
|
|
1178
|
+
),
|
|
1179
|
+
{ validate: false },
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
getParentHash() {
|
|
1183
|
+
return new Byte32(
|
|
1184
|
+
this.view.buffer.slice(
|
|
1185
|
+
0 +
|
|
1186
|
+
Uint32.size() +
|
|
1187
|
+
Uint32.size() +
|
|
1188
|
+
Uint64.size() +
|
|
1189
|
+
Uint64.size() +
|
|
1190
|
+
Uint64.size(),
|
|
1191
|
+
0 +
|
|
1192
|
+
Uint32.size() +
|
|
1193
|
+
Uint32.size() +
|
|
1194
|
+
Uint64.size() +
|
|
1195
|
+
Uint64.size() +
|
|
1196
|
+
Uint64.size() +
|
|
1197
|
+
Byte32.size(),
|
|
1198
|
+
),
|
|
1199
|
+
{ validate: false },
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
getTransactionsRoot() {
|
|
1203
|
+
return new Byte32(
|
|
1204
|
+
this.view.buffer.slice(
|
|
1205
|
+
0 +
|
|
1206
|
+
Uint32.size() +
|
|
1207
|
+
Uint32.size() +
|
|
1208
|
+
Uint64.size() +
|
|
1209
|
+
Uint64.size() +
|
|
1210
|
+
Uint64.size() +
|
|
1211
|
+
Byte32.size(),
|
|
1212
|
+
0 +
|
|
1213
|
+
Uint32.size() +
|
|
1214
|
+
Uint32.size() +
|
|
1215
|
+
Uint64.size() +
|
|
1216
|
+
Uint64.size() +
|
|
1217
|
+
Uint64.size() +
|
|
1218
|
+
Byte32.size() +
|
|
1219
|
+
Byte32.size(),
|
|
1220
|
+
),
|
|
1221
|
+
{ validate: false },
|
|
1222
|
+
);
|
|
1223
|
+
}
|
|
1224
|
+
getProposalsHash() {
|
|
1225
|
+
return new Byte32(
|
|
1226
|
+
this.view.buffer.slice(
|
|
1227
|
+
0 +
|
|
1228
|
+
Uint32.size() +
|
|
1229
|
+
Uint32.size() +
|
|
1230
|
+
Uint64.size() +
|
|
1231
|
+
Uint64.size() +
|
|
1232
|
+
Uint64.size() +
|
|
1233
|
+
Byte32.size() +
|
|
1234
|
+
Byte32.size(),
|
|
1235
|
+
0 +
|
|
1236
|
+
Uint32.size() +
|
|
1237
|
+
Uint32.size() +
|
|
1238
|
+
Uint64.size() +
|
|
1239
|
+
Uint64.size() +
|
|
1240
|
+
Uint64.size() +
|
|
1241
|
+
Byte32.size() +
|
|
1242
|
+
Byte32.size() +
|
|
1243
|
+
Byte32.size(),
|
|
1244
|
+
),
|
|
1245
|
+
{ validate: false },
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
getExtraHash() {
|
|
1249
|
+
return new Byte32(
|
|
1250
|
+
this.view.buffer.slice(
|
|
1251
|
+
0 +
|
|
1252
|
+
Uint32.size() +
|
|
1253
|
+
Uint32.size() +
|
|
1254
|
+
Uint64.size() +
|
|
1255
|
+
Uint64.size() +
|
|
1256
|
+
Uint64.size() +
|
|
1257
|
+
Byte32.size() +
|
|
1258
|
+
Byte32.size() +
|
|
1259
|
+
Byte32.size(),
|
|
1260
|
+
0 +
|
|
1261
|
+
Uint32.size() +
|
|
1262
|
+
Uint32.size() +
|
|
1263
|
+
Uint64.size() +
|
|
1264
|
+
Uint64.size() +
|
|
1265
|
+
Uint64.size() +
|
|
1266
|
+
Byte32.size() +
|
|
1267
|
+
Byte32.size() +
|
|
1268
|
+
Byte32.size() +
|
|
1269
|
+
Byte32.size(),
|
|
1270
|
+
),
|
|
1271
|
+
{ validate: false },
|
|
1272
|
+
);
|
|
1273
|
+
}
|
|
1274
|
+
getDao() {
|
|
1275
|
+
return new Byte32(
|
|
1276
|
+
this.view.buffer.slice(
|
|
1277
|
+
0 +
|
|
1278
|
+
Uint32.size() +
|
|
1279
|
+
Uint32.size() +
|
|
1280
|
+
Uint64.size() +
|
|
1281
|
+
Uint64.size() +
|
|
1282
|
+
Uint64.size() +
|
|
1283
|
+
Byte32.size() +
|
|
1284
|
+
Byte32.size() +
|
|
1285
|
+
Byte32.size() +
|
|
1286
|
+
Byte32.size(),
|
|
1287
|
+
0 +
|
|
1288
|
+
Uint32.size() +
|
|
1289
|
+
Uint32.size() +
|
|
1290
|
+
Uint64.size() +
|
|
1291
|
+
Uint64.size() +
|
|
1292
|
+
Uint64.size() +
|
|
1293
|
+
Byte32.size() +
|
|
1294
|
+
Byte32.size() +
|
|
1295
|
+
Byte32.size() +
|
|
1296
|
+
Byte32.size() +
|
|
1297
|
+
Byte32.size(),
|
|
1298
|
+
),
|
|
1299
|
+
{ validate: false },
|
|
1300
|
+
);
|
|
1301
|
+
}
|
|
1302
|
+
validate(compatible = false) {
|
|
1303
|
+
assertDataLength(this.view.byteLength, RawHeader.size());
|
|
1304
|
+
this.getVersion().validate(compatible);
|
|
1305
|
+
this.getCompactTarget().validate(compatible);
|
|
1306
|
+
this.getTimestamp().validate(compatible);
|
|
1307
|
+
this.getNumber().validate(compatible);
|
|
1308
|
+
this.getEpoch().validate(compatible);
|
|
1309
|
+
this.getParentHash().validate(compatible);
|
|
1310
|
+
this.getTransactionsRoot().validate(compatible);
|
|
1311
|
+
this.getProposalsHash().validate(compatible);
|
|
1312
|
+
this.getExtraHash().validate(compatible);
|
|
1313
|
+
this.getDao().validate(compatible);
|
|
1314
|
+
}
|
|
1315
|
+
static size() {
|
|
1316
|
+
return (
|
|
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
|
+
Byte32.size()
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1164
1330
|
}
|
|
1165
1331
|
exports.RawHeader = RawHeader;
|
|
1166
1332
|
function SerializeRawHeader(value) {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1333
|
+
const array = new Uint8Array(
|
|
1334
|
+
0 +
|
|
1335
|
+
Uint32.size() +
|
|
1336
|
+
Uint32.size() +
|
|
1337
|
+
Uint64.size() +
|
|
1338
|
+
Uint64.size() +
|
|
1339
|
+
Uint64.size() +
|
|
1340
|
+
Byte32.size() +
|
|
1341
|
+
Byte32.size() +
|
|
1342
|
+
Byte32.size() +
|
|
1343
|
+
Byte32.size() +
|
|
1344
|
+
Byte32.size(),
|
|
1345
|
+
);
|
|
1346
|
+
const view = new DataView(array.buffer);
|
|
1347
|
+
array.set(new Uint8Array(SerializeUint32(value.version)), 0);
|
|
1348
|
+
array.set(
|
|
1349
|
+
new Uint8Array(SerializeUint32(value.compactTarget)),
|
|
1350
|
+
0 + Uint32.size(),
|
|
1351
|
+
);
|
|
1352
|
+
array.set(
|
|
1353
|
+
new Uint8Array(SerializeUint64(value.timestamp)),
|
|
1354
|
+
0 + Uint32.size() + Uint32.size(),
|
|
1355
|
+
);
|
|
1356
|
+
array.set(
|
|
1357
|
+
new Uint8Array(SerializeUint64(value.number)),
|
|
1358
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size(),
|
|
1359
|
+
);
|
|
1360
|
+
array.set(
|
|
1361
|
+
new Uint8Array(SerializeUint64(value.epoch)),
|
|
1362
|
+
0 + Uint32.size() + Uint32.size() + Uint64.size() + Uint64.size(),
|
|
1363
|
+
);
|
|
1364
|
+
array.set(
|
|
1365
|
+
new Uint8Array(SerializeByte32(value.parentHash)),
|
|
1366
|
+
0 +
|
|
1367
|
+
Uint32.size() +
|
|
1368
|
+
Uint32.size() +
|
|
1369
|
+
Uint64.size() +
|
|
1370
|
+
Uint64.size() +
|
|
1371
|
+
Uint64.size(),
|
|
1372
|
+
);
|
|
1373
|
+
array.set(
|
|
1374
|
+
new Uint8Array(SerializeByte32(value.transactionsRoot)),
|
|
1375
|
+
0 +
|
|
1376
|
+
Uint32.size() +
|
|
1377
|
+
Uint32.size() +
|
|
1378
|
+
Uint64.size() +
|
|
1379
|
+
Uint64.size() +
|
|
1380
|
+
Uint64.size() +
|
|
1381
|
+
Byte32.size(),
|
|
1382
|
+
);
|
|
1383
|
+
array.set(
|
|
1384
|
+
new Uint8Array(SerializeByte32(value.proposalsHash)),
|
|
1385
|
+
0 +
|
|
1386
|
+
Uint32.size() +
|
|
1387
|
+
Uint32.size() +
|
|
1388
|
+
Uint64.size() +
|
|
1389
|
+
Uint64.size() +
|
|
1390
|
+
Uint64.size() +
|
|
1391
|
+
Byte32.size() +
|
|
1392
|
+
Byte32.size(),
|
|
1393
|
+
);
|
|
1394
|
+
array.set(
|
|
1395
|
+
new Uint8Array(SerializeByte32(value.extraHash)),
|
|
1396
|
+
0 +
|
|
1397
|
+
Uint32.size() +
|
|
1398
|
+
Uint32.size() +
|
|
1399
|
+
Uint64.size() +
|
|
1400
|
+
Uint64.size() +
|
|
1401
|
+
Uint64.size() +
|
|
1402
|
+
Byte32.size() +
|
|
1403
|
+
Byte32.size() +
|
|
1404
|
+
Byte32.size(),
|
|
1405
|
+
);
|
|
1406
|
+
array.set(
|
|
1407
|
+
new Uint8Array(SerializeByte32(value.dao)),
|
|
1408
|
+
0 +
|
|
1409
|
+
Uint32.size() +
|
|
1410
|
+
Uint32.size() +
|
|
1411
|
+
Uint64.size() +
|
|
1412
|
+
Uint64.size() +
|
|
1413
|
+
Uint64.size() +
|
|
1414
|
+
Byte32.size() +
|
|
1415
|
+
Byte32.size() +
|
|
1416
|
+
Byte32.size() +
|
|
1417
|
+
Byte32.size(),
|
|
1418
|
+
);
|
|
1419
|
+
return array.buffer;
|
|
1225
1420
|
}
|
|
1226
1421
|
exports.SerializeRawHeader = SerializeRawHeader;
|
|
1227
1422
|
class Header {
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1423
|
+
constructor(reader, { validate = true } = {}) {
|
|
1424
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1425
|
+
if (validate) {
|
|
1426
|
+
this.validate();
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
getRaw() {
|
|
1430
|
+
return new RawHeader(this.view.buffer.slice(0, 0 + RawHeader.size()), {
|
|
1431
|
+
validate: false,
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
getNonce() {
|
|
1435
|
+
return new Uint128(
|
|
1436
|
+
this.view.buffer.slice(
|
|
1437
|
+
0 + RawHeader.size(),
|
|
1438
|
+
0 + RawHeader.size() + Uint128.size(),
|
|
1439
|
+
),
|
|
1440
|
+
{ validate: false },
|
|
1441
|
+
);
|
|
1442
|
+
}
|
|
1443
|
+
validate(compatible = false) {
|
|
1444
|
+
assertDataLength(this.view.byteLength, Header.size());
|
|
1445
|
+
this.getRaw().validate(compatible);
|
|
1446
|
+
this.getNonce().validate(compatible);
|
|
1447
|
+
}
|
|
1448
|
+
static size() {
|
|
1449
|
+
return 0 + RawHeader.size() + Uint128.size();
|
|
1450
|
+
}
|
|
1250
1451
|
}
|
|
1251
1452
|
exports.Header = Header;
|
|
1252
1453
|
function SerializeHeader(value) {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1454
|
+
const array = new Uint8Array(0 + RawHeader.size() + Uint128.size());
|
|
1455
|
+
const view = new DataView(array.buffer);
|
|
1456
|
+
array.set(new Uint8Array(SerializeRawHeader(value.raw)), 0);
|
|
1457
|
+
array.set(
|
|
1458
|
+
new Uint8Array(SerializeUint128(value.nonce)),
|
|
1459
|
+
0 + RawHeader.size(),
|
|
1460
|
+
);
|
|
1461
|
+
return array.buffer;
|
|
1258
1462
|
}
|
|
1259
1463
|
exports.SerializeHeader = SerializeHeader;
|
|
1260
1464
|
class UncleBlock {
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1465
|
+
constructor(reader, { validate = true } = {}) {
|
|
1466
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1467
|
+
if (validate) {
|
|
1468
|
+
this.validate();
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
validate(compatible = false) {
|
|
1472
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1473
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1474
|
+
validate: false,
|
|
1475
|
+
}).validate();
|
|
1476
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1477
|
+
validate: false,
|
|
1478
|
+
}).validate();
|
|
1479
|
+
}
|
|
1480
|
+
getHeader() {
|
|
1481
|
+
const start = 4;
|
|
1482
|
+
const offset = this.view.getUint32(start, true);
|
|
1483
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1484
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1485
|
+
validate: false,
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
getProposals() {
|
|
1489
|
+
const start = 8;
|
|
1490
|
+
const offset = this.view.getUint32(start, true);
|
|
1491
|
+
const offset_end = this.view.byteLength;
|
|
1492
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1493
|
+
validate: false,
|
|
1494
|
+
});
|
|
1495
|
+
}
|
|
1292
1496
|
}
|
|
1293
1497
|
exports.UncleBlock = UncleBlock;
|
|
1294
1498
|
function SerializeUncleBlock(value) {
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1499
|
+
const buffers = [];
|
|
1500
|
+
buffers.push(SerializeHeader(value.header));
|
|
1501
|
+
buffers.push(SerializeProposalShortIdVec(value.proposals));
|
|
1502
|
+
return serializeTable(buffers);
|
|
1299
1503
|
}
|
|
1300
1504
|
exports.SerializeUncleBlock = SerializeUncleBlock;
|
|
1301
1505
|
class Block {
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1506
|
+
constructor(reader, { validate = true } = {}) {
|
|
1507
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1508
|
+
if (validate) {
|
|
1509
|
+
this.validate();
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
validate(compatible = false) {
|
|
1513
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1514
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1515
|
+
validate: false,
|
|
1516
|
+
}).validate();
|
|
1517
|
+
new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1518
|
+
validate: false,
|
|
1519
|
+
}).validate();
|
|
1520
|
+
new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1521
|
+
validate: false,
|
|
1522
|
+
}).validate();
|
|
1523
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
1524
|
+
validate: false,
|
|
1525
|
+
}).validate();
|
|
1526
|
+
}
|
|
1527
|
+
getHeader() {
|
|
1528
|
+
const start = 4;
|
|
1529
|
+
const offset = this.view.getUint32(start, true);
|
|
1530
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1531
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1532
|
+
validate: false,
|
|
1533
|
+
});
|
|
1534
|
+
}
|
|
1535
|
+
getUncles() {
|
|
1536
|
+
const start = 8;
|
|
1537
|
+
const offset = this.view.getUint32(start, true);
|
|
1538
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1539
|
+
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1540
|
+
validate: false,
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
getTransactions() {
|
|
1544
|
+
const start = 12;
|
|
1545
|
+
const offset = this.view.getUint32(start, true);
|
|
1546
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1547
|
+
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1548
|
+
validate: false,
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
getProposals() {
|
|
1552
|
+
const start = 16;
|
|
1553
|
+
const offset = this.view.getUint32(start, true);
|
|
1554
|
+
const offset_end = this.view.byteLength;
|
|
1555
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1556
|
+
validate: false,
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1355
1559
|
}
|
|
1356
1560
|
exports.Block = Block;
|
|
1357
1561
|
function SerializeBlock(value) {
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1562
|
+
const buffers = [];
|
|
1563
|
+
buffers.push(SerializeHeader(value.header));
|
|
1564
|
+
buffers.push(SerializeUncleBlockVec(value.uncles));
|
|
1565
|
+
buffers.push(SerializeTransactionVec(value.transactions));
|
|
1566
|
+
buffers.push(SerializeProposalShortIdVec(value.proposals));
|
|
1567
|
+
return serializeTable(buffers);
|
|
1364
1568
|
}
|
|
1365
1569
|
exports.SerializeBlock = SerializeBlock;
|
|
1366
1570
|
class BlockV1 {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1571
|
+
constructor(reader, { validate = true } = {}) {
|
|
1572
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1573
|
+
if (validate) {
|
|
1574
|
+
this.validate();
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
validate(compatible = false) {
|
|
1578
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1579
|
+
new Header(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1580
|
+
validate: false,
|
|
1581
|
+
}).validate();
|
|
1582
|
+
new UncleBlockVec(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1583
|
+
validate: false,
|
|
1584
|
+
}).validate();
|
|
1585
|
+
new TransactionVec(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1586
|
+
validate: false,
|
|
1587
|
+
}).validate();
|
|
1588
|
+
new ProposalShortIdVec(this.view.buffer.slice(offsets[3], offsets[4]), {
|
|
1589
|
+
validate: false,
|
|
1590
|
+
}).validate();
|
|
1591
|
+
new Bytes(this.view.buffer.slice(offsets[4], offsets[5]), {
|
|
1592
|
+
validate: false,
|
|
1593
|
+
}).validate();
|
|
1594
|
+
}
|
|
1595
|
+
getHeader() {
|
|
1596
|
+
const start = 4;
|
|
1597
|
+
const offset = this.view.getUint32(start, true);
|
|
1598
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1599
|
+
return new Header(this.view.buffer.slice(offset, offset_end), {
|
|
1600
|
+
validate: false,
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
getUncles() {
|
|
1604
|
+
const start = 8;
|
|
1605
|
+
const offset = this.view.getUint32(start, true);
|
|
1606
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1607
|
+
return new UncleBlockVec(this.view.buffer.slice(offset, offset_end), {
|
|
1608
|
+
validate: false,
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
getTransactions() {
|
|
1612
|
+
const start = 12;
|
|
1613
|
+
const offset = this.view.getUint32(start, true);
|
|
1614
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1615
|
+
return new TransactionVec(this.view.buffer.slice(offset, offset_end), {
|
|
1616
|
+
validate: false,
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
getProposals() {
|
|
1620
|
+
const start = 16;
|
|
1621
|
+
const offset = this.view.getUint32(start, true);
|
|
1622
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1623
|
+
return new ProposalShortIdVec(this.view.buffer.slice(offset, offset_end), {
|
|
1624
|
+
validate: false,
|
|
1625
|
+
});
|
|
1626
|
+
}
|
|
1627
|
+
getExtension() {
|
|
1628
|
+
const start = 20;
|
|
1629
|
+
const offset = this.view.getUint32(start, true);
|
|
1630
|
+
const offset_end = this.view.byteLength;
|
|
1631
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1632
|
+
validate: false,
|
|
1633
|
+
});
|
|
1634
|
+
}
|
|
1431
1635
|
}
|
|
1432
1636
|
exports.BlockV1 = BlockV1;
|
|
1433
1637
|
function SerializeBlockV1(value) {
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1638
|
+
const buffers = [];
|
|
1639
|
+
buffers.push(SerializeHeader(value.header));
|
|
1640
|
+
buffers.push(SerializeUncleBlockVec(value.uncles));
|
|
1641
|
+
buffers.push(SerializeTransactionVec(value.transactions));
|
|
1642
|
+
buffers.push(SerializeProposalShortIdVec(value.proposals));
|
|
1643
|
+
buffers.push(SerializeBytes(value.extension));
|
|
1644
|
+
return serializeTable(buffers);
|
|
1441
1645
|
}
|
|
1442
1646
|
exports.SerializeBlockV1 = SerializeBlockV1;
|
|
1443
1647
|
class CellbaseWitness {
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1648
|
+
constructor(reader, { validate = true } = {}) {
|
|
1649
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1650
|
+
if (validate) {
|
|
1651
|
+
this.validate();
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
validate(compatible = false) {
|
|
1655
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1656
|
+
new Script(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1657
|
+
validate: false,
|
|
1658
|
+
}).validate();
|
|
1659
|
+
new Bytes(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1660
|
+
validate: false,
|
|
1661
|
+
}).validate();
|
|
1662
|
+
}
|
|
1663
|
+
getLock() {
|
|
1664
|
+
const start = 4;
|
|
1665
|
+
const offset = this.view.getUint32(start, true);
|
|
1666
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1667
|
+
return new Script(this.view.buffer.slice(offset, offset_end), {
|
|
1668
|
+
validate: false,
|
|
1669
|
+
});
|
|
1670
|
+
}
|
|
1671
|
+
getMessage() {
|
|
1672
|
+
const start = 8;
|
|
1673
|
+
const offset = this.view.getUint32(start, true);
|
|
1674
|
+
const offset_end = this.view.byteLength;
|
|
1675
|
+
return new Bytes(this.view.buffer.slice(offset, offset_end), {
|
|
1676
|
+
validate: false,
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1475
1679
|
}
|
|
1476
1680
|
exports.CellbaseWitness = CellbaseWitness;
|
|
1477
1681
|
function SerializeCellbaseWitness(value) {
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1682
|
+
const buffers = [];
|
|
1683
|
+
buffers.push(SerializeScript(value.lock));
|
|
1684
|
+
buffers.push(SerializeBytes(value.message));
|
|
1685
|
+
return serializeTable(buffers);
|
|
1482
1686
|
}
|
|
1483
1687
|
exports.SerializeCellbaseWitness = SerializeCellbaseWitness;
|
|
1484
1688
|
class WitnessArgs {
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1689
|
+
constructor(reader, { validate = true } = {}) {
|
|
1690
|
+
this.view = new DataView(assertArrayBuffer(reader));
|
|
1691
|
+
if (validate) {
|
|
1692
|
+
this.validate();
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
validate(compatible = false) {
|
|
1696
|
+
const offsets = verifyAndExtractOffsets(this.view, 0, true);
|
|
1697
|
+
new BytesOpt(this.view.buffer.slice(offsets[0], offsets[1]), {
|
|
1698
|
+
validate: false,
|
|
1699
|
+
}).validate();
|
|
1700
|
+
new BytesOpt(this.view.buffer.slice(offsets[1], offsets[2]), {
|
|
1701
|
+
validate: false,
|
|
1702
|
+
}).validate();
|
|
1703
|
+
new BytesOpt(this.view.buffer.slice(offsets[2], offsets[3]), {
|
|
1704
|
+
validate: false,
|
|
1705
|
+
}).validate();
|
|
1706
|
+
}
|
|
1707
|
+
getLock() {
|
|
1708
|
+
const start = 4;
|
|
1709
|
+
const offset = this.view.getUint32(start, true);
|
|
1710
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1711
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1712
|
+
validate: false,
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
getInputType() {
|
|
1716
|
+
const start = 8;
|
|
1717
|
+
const offset = this.view.getUint32(start, true);
|
|
1718
|
+
const offset_end = this.view.getUint32(start + 4, true);
|
|
1719
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1720
|
+
validate: false,
|
|
1721
|
+
});
|
|
1722
|
+
}
|
|
1723
|
+
getOutputType() {
|
|
1724
|
+
const start = 12;
|
|
1725
|
+
const offset = this.view.getUint32(start, true);
|
|
1726
|
+
const offset_end = this.view.byteLength;
|
|
1727
|
+
return new BytesOpt(this.view.buffer.slice(offset, offset_end), {
|
|
1728
|
+
validate: false,
|
|
1729
|
+
});
|
|
1730
|
+
}
|
|
1527
1731
|
}
|
|
1528
1732
|
exports.WitnessArgs = WitnessArgs;
|
|
1529
1733
|
function SerializeWitnessArgs(value) {
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1734
|
+
const buffers = [];
|
|
1735
|
+
buffers.push(SerializeBytesOpt(value.lock));
|
|
1736
|
+
buffers.push(SerializeBytesOpt(value.inputType));
|
|
1737
|
+
buffers.push(SerializeBytesOpt(value.outputType));
|
|
1738
|
+
return serializeTable(buffers);
|
|
1535
1739
|
}
|
|
1536
1740
|
exports.SerializeWitnessArgs = SerializeWitnessArgs;
|