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