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