solidity-codecs 0.0.1-beta.3 → 0.0.1-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/codecs/BytesX.d.ts +2 -0
- package/dist/codecs/Fixed.d.ts +6 -3
- package/dist/codecs/Int.d.ts +3 -6
- package/dist/codecs/Uint.d.ts +3 -5
- package/dist/codecs/Vector.d.ts +2 -6
- package/dist/codecs/bytes.d.ts +1 -0
- package/dist/codecs/index.d.ts +5 -4
- package/dist/solidity-codecs.cjs.development.js +282 -124
- package/dist/solidity-codecs.cjs.development.js.map +3 -3
- package/dist/solidity-codecs.cjs.production.min.js +1 -1
- package/dist/solidity-codecs.cjs.production.min.js.map +3 -3
- package/dist/solidity-codecs.js +282 -124
- package/dist/solidity-codecs.js.map +3 -3
- package/dist/solidity-codecs.mjs +282 -124
- package/dist/solidity-codecs.mjs.map +3 -3
- package/dist/types.d.ts +0 -4
- package/dist/utils.d.ts +0 -5
- package/package.json +1 -1
package/dist/solidity-codecs.mjs
CHANGED
@@ -50,16 +50,16 @@ function fromHex(hexString) {
|
|
50
50
|
const isOdd = hexString.length % 2;
|
51
51
|
const base = (hexString[1] === "x" ? 2 : 0) + isOdd;
|
52
52
|
const nBytes = (hexString.length - base) / 2 + isOdd;
|
53
|
-
const
|
53
|
+
const bytes33 = new Uint8Array(nBytes);
|
54
54
|
if (isOdd)
|
55
|
-
|
55
|
+
bytes33[0] = 0 | HEX_MAP[hexString[2]];
|
56
56
|
for (let i = 0; i < nBytes; ) {
|
57
57
|
const idx = base + i * 2;
|
58
58
|
const a = HEX_MAP[hexString[idx]];
|
59
59
|
const b = HEX_MAP[hexString[idx + 1]];
|
60
|
-
|
60
|
+
bytes33[isOdd + i++] = a << 4 | b;
|
61
61
|
}
|
62
|
-
return
|
62
|
+
return bytes33;
|
63
63
|
}
|
64
64
|
var InternalUint8Array = class extends Uint8Array {
|
65
65
|
constructor(buffer) {
|
@@ -86,6 +86,9 @@ var mergeUint8 = (...inputs) => {
|
|
86
86
|
return result;
|
87
87
|
};
|
88
88
|
|
89
|
+
// src/internal/range32.ts
|
90
|
+
var range32 = Array(32).fill(0).map((_, idx) => idx + 1);
|
91
|
+
|
89
92
|
// src/codecs/Uint.ts
|
90
93
|
var getCodec = (nBytes) => {
|
91
94
|
const n64 = Math.ceil(nBytes / 8);
|
@@ -98,37 +101,58 @@ var getCodec = (nBytes) => {
|
|
98
101
|
input >>= 64n;
|
99
102
|
}
|
100
103
|
return result;
|
101
|
-
}, toInternalBytes((
|
104
|
+
}, toInternalBytes((bytes33) => {
|
102
105
|
let result = 0n;
|
103
|
-
const nextBlock =
|
104
|
-
for (let idx =
|
105
|
-
result = result << 64n |
|
106
|
-
|
106
|
+
const nextBlock = bytes33.i + 32;
|
107
|
+
for (let idx = bytes33.i + (32 - n64 * 8); idx < nextBlock; idx += 8)
|
108
|
+
result = result << 64n | bytes33.v.getBigUint64(idx);
|
109
|
+
bytes33.i = nextBlock;
|
107
110
|
return result;
|
108
111
|
}));
|
109
112
|
};
|
110
|
-
var
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
113
|
+
var [
|
114
|
+
uint8,
|
115
|
+
uint16,
|
116
|
+
uint24,
|
117
|
+
uint32,
|
118
|
+
uint40,
|
119
|
+
uint48,
|
120
|
+
uint56,
|
121
|
+
uint64,
|
122
|
+
uint72,
|
123
|
+
uint80,
|
124
|
+
uint88,
|
125
|
+
uint96,
|
126
|
+
uint104,
|
127
|
+
uint112,
|
128
|
+
uint120,
|
129
|
+
uint128,
|
130
|
+
uint136,
|
131
|
+
uint144,
|
132
|
+
uint152,
|
133
|
+
uint160,
|
134
|
+
uint168,
|
135
|
+
uint176,
|
136
|
+
uint184,
|
137
|
+
uint192,
|
138
|
+
uint200,
|
139
|
+
uint208,
|
140
|
+
uint226,
|
141
|
+
uint224,
|
142
|
+
uint232,
|
143
|
+
uint240,
|
144
|
+
uint248,
|
145
|
+
uint256
|
146
|
+
] = range32.map(getCodec);
|
147
|
+
var uint = uint256;
|
148
|
+
var address = uint160;
|
122
149
|
|
123
150
|
// src/codecs/bool.ts
|
124
|
-
var bool = enhanceCodec(
|
151
|
+
var bool = enhanceCodec(uint8, (value) => value ? 1n : 0n, Boolean);
|
125
152
|
|
126
|
-
// src/codecs/
|
127
|
-
var
|
128
|
-
|
129
|
-
var strEnc = (str2) => {
|
130
|
-
const val = textEncoder.encode(str2);
|
131
|
-
const args = [uint256.enc(BigInt(val.length)), val];
|
153
|
+
// src/codecs/bytes.ts
|
154
|
+
var bytesEnc = (val) => {
|
155
|
+
const args = [uint[0](BigInt(val.length)), val];
|
132
156
|
const extra = val.length % 32;
|
133
157
|
if (extra > 0) {
|
134
158
|
;
|
@@ -136,36 +160,69 @@ var strEnc = (str2) => {
|
|
136
160
|
}
|
137
161
|
return mergeUint8(...args);
|
138
162
|
};
|
139
|
-
|
140
|
-
var
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
const padding = extra && 32 - extra;
|
146
|
-
bytes.i += nElements + padding;
|
147
|
-
return textDecoder.decode(dv);
|
163
|
+
bytesEnc.dyn = true;
|
164
|
+
var bytesDec = toInternalBytes((bytes33) => {
|
165
|
+
let nElements = Number(uint[1](bytes33));
|
166
|
+
const result = new Uint8Array(bytes33.buffer, bytes33.i, nElements);
|
167
|
+
bytes33.i += nElements + nElements % 32;
|
168
|
+
return result;
|
148
169
|
});
|
149
|
-
|
150
|
-
var
|
151
|
-
|
170
|
+
bytesDec.dyn = true;
|
171
|
+
var bytes = createCodec(bytesEnc, bytesDec);
|
172
|
+
bytes.dyn = true;
|
173
|
+
|
174
|
+
// src/codecs/str.ts
|
175
|
+
var textEncoder = new TextEncoder();
|
176
|
+
var textDecoder = new TextDecoder();
|
177
|
+
var str = enhanceCodec(bytes, textEncoder.encode.bind(textEncoder), textDecoder.decode.bind(textDecoder));
|
152
178
|
|
153
|
-
// src/codecs/
|
154
|
-
var
|
155
|
-
if (
|
156
|
-
return
|
179
|
+
// src/codecs/BytesX.ts
|
180
|
+
var bytesEnc2 = (nBytes) => (bytes33) => {
|
181
|
+
if (bytes33.length === nBytes && nBytes === 32)
|
182
|
+
return bytes33;
|
157
183
|
const result = new Uint8Array(32);
|
158
|
-
result.set(
|
184
|
+
result.set(bytes33.length === nBytes ? bytes33 : bytes33.slice(0, nBytes));
|
159
185
|
return result;
|
160
186
|
};
|
161
|
-
var
|
162
|
-
const result = new Uint8Array(
|
163
|
-
|
187
|
+
var bytesDec2 = (nBytes) => toInternalBytes((bytes33) => {
|
188
|
+
const result = new Uint8Array(bytes33.buffer, bytes33.i, nBytes);
|
189
|
+
bytes33.i += 32;
|
164
190
|
return result;
|
165
191
|
});
|
166
|
-
var
|
167
|
-
|
168
|
-
|
192
|
+
var [
|
193
|
+
bytes1,
|
194
|
+
bytes2,
|
195
|
+
bytes3,
|
196
|
+
bytes4,
|
197
|
+
bytes5,
|
198
|
+
bytes6,
|
199
|
+
bytes7,
|
200
|
+
bytes8,
|
201
|
+
bytes9,
|
202
|
+
bytes10,
|
203
|
+
bytes11,
|
204
|
+
bytes12,
|
205
|
+
bytes13,
|
206
|
+
bytes14,
|
207
|
+
bytes15,
|
208
|
+
bytes16,
|
209
|
+
bytes17,
|
210
|
+
bytes18,
|
211
|
+
bytes19,
|
212
|
+
bytes20,
|
213
|
+
bytes21,
|
214
|
+
bytes22,
|
215
|
+
bytes23,
|
216
|
+
bytes24,
|
217
|
+
bytes25,
|
218
|
+
bytes26,
|
219
|
+
bytes27,
|
220
|
+
bytes28,
|
221
|
+
bytes29,
|
222
|
+
bytes30,
|
223
|
+
bytes31,
|
224
|
+
bytes32
|
225
|
+
] = range32.map((nBytes) => createCodec(bytesEnc2(nBytes), bytesDec2(nBytes)));
|
169
226
|
|
170
227
|
// src/codecs/Int.ts
|
171
228
|
var signGetters = {
|
@@ -206,62 +263,71 @@ var getCodec2 = (nBytes) => {
|
|
206
263
|
}
|
207
264
|
let idx = 32;
|
208
265
|
for (let i = sequence.length - 1; i > 0; i--) {
|
209
|
-
const [
|
210
|
-
idx -=
|
211
|
-
dv[usignSetters[
|
266
|
+
const [bytes34, shift, fn2] = sequence[i];
|
267
|
+
idx -= bytes34;
|
268
|
+
dv[usignSetters[bytes34]](idx, fn2(input));
|
212
269
|
input >>= shift;
|
213
270
|
}
|
214
|
-
const [
|
215
|
-
idx -=
|
216
|
-
dv[signSetters[
|
271
|
+
const [bytes33, , fn] = sequence[0];
|
272
|
+
idx -= bytes33;
|
273
|
+
dv[signSetters[bytes33]](idx, fn(input));
|
217
274
|
return result;
|
218
275
|
};
|
219
|
-
const dec = toInternalBytes((
|
220
|
-
let idx =
|
276
|
+
const dec = toInternalBytes((bytes33) => {
|
277
|
+
let idx = bytes33.i + 32 - nBytes;
|
221
278
|
const bits = sequence[0][0];
|
222
|
-
let result = BigInt(
|
279
|
+
let result = BigInt(bytes33.v[signGetters[bits]](idx));
|
223
280
|
idx += bits;
|
224
281
|
for (let i = 1; i < sequence.length; i++) {
|
225
282
|
const [bits2, shift] = sequence[i];
|
226
|
-
result = result << shift | BigInt(
|
283
|
+
result = result << shift | BigInt(bytes33.v[usignGetters[bits2]](idx));
|
227
284
|
idx += bits2;
|
228
285
|
}
|
229
|
-
|
286
|
+
bytes33.i += 32;
|
230
287
|
return result;
|
231
288
|
});
|
232
289
|
return createCodec(enc, dec);
|
233
290
|
};
|
234
|
-
var
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
291
|
+
var [
|
292
|
+
int8,
|
293
|
+
int16,
|
294
|
+
int24,
|
295
|
+
int32,
|
296
|
+
int40,
|
297
|
+
int48,
|
298
|
+
int56,
|
299
|
+
int64,
|
300
|
+
int72,
|
301
|
+
int80,
|
302
|
+
int88,
|
303
|
+
int96,
|
304
|
+
int104,
|
305
|
+
int112,
|
306
|
+
int120,
|
307
|
+
int128,
|
308
|
+
int136,
|
309
|
+
int144,
|
310
|
+
int152,
|
311
|
+
int160,
|
312
|
+
int168,
|
313
|
+
int176,
|
314
|
+
int184,
|
315
|
+
int192,
|
316
|
+
int200,
|
317
|
+
int208,
|
318
|
+
int226,
|
319
|
+
int224,
|
320
|
+
int232,
|
321
|
+
int240,
|
322
|
+
int248,
|
323
|
+
int256
|
324
|
+
] = range32.map(getCodec2);
|
325
|
+
var int = int256;
|
246
326
|
|
247
327
|
// src/codecs/Fixed.ts
|
248
|
-
var
|
249
|
-
const cache3 = /* @__PURE__ */ new Map();
|
250
|
-
return (nBits, decimals) => {
|
251
|
-
const key = decimals << 8 | nBits;
|
252
|
-
let cached = cache3.get(key);
|
253
|
-
if (cached)
|
254
|
-
return cached;
|
255
|
-
cached = enhanceCodec(codec(nBits), (x) => x.value, (value) => ({ value, decimals }));
|
256
|
-
cache3.set(key, cached);
|
257
|
-
return cached;
|
258
|
-
};
|
259
|
-
};
|
260
|
-
var Fixed = creator(Int);
|
261
|
-
var Ufixed = creator(Uint);
|
328
|
+
var Fixed = (baseCodec, decimals) => enhanceCodec(baseCodec, (x) => x.value, (value) => ({ value, decimals }));
|
262
329
|
|
263
330
|
// src/codecs/Tuple.ts
|
264
|
-
var uint2562 = Uint(256);
|
265
331
|
var dynamicEnc = (...encoders) => {
|
266
332
|
const res = (values) => {
|
267
333
|
const mapped = values.map((value, idx) => encoders[idx](value));
|
@@ -278,7 +344,7 @@ var dynamicEnc = (...encoders) => {
|
|
278
344
|
}
|
279
345
|
}
|
280
346
|
dinamics.forEach((idx) => {
|
281
|
-
resultArray[idx] =
|
347
|
+
resultArray[idx] = uint[0](len);
|
282
348
|
const data = mapped[idx];
|
283
349
|
resultArray.push(data);
|
284
350
|
len += BigInt(data.length);
|
@@ -289,20 +355,20 @@ var dynamicEnc = (...encoders) => {
|
|
289
355
|
return res;
|
290
356
|
};
|
291
357
|
var staticEnc = (...encoders) => (values) => mergeUint8(...values.map((value, idx) => encoders[idx](value)));
|
292
|
-
var staticDec = (...decoders) => toInternalBytes((
|
358
|
+
var staticDec = (...decoders) => toInternalBytes((bytes33) => decoders.map((decoder) => decoder(bytes33)));
|
293
359
|
var dynamicDec = (...decoders) => {
|
294
|
-
const res = toInternalBytes((
|
360
|
+
const res = toInternalBytes((bytes33) => {
|
295
361
|
const result = new Array(decoders.length);
|
296
|
-
let start =
|
362
|
+
let start = bytes33.i;
|
297
363
|
for (let i = 0; i < decoders.length; i++) {
|
298
364
|
if (decoders[i].dyn) {
|
299
|
-
const offset = Number(
|
300
|
-
const current =
|
301
|
-
|
302
|
-
result[i] = decoders[i](
|
303
|
-
|
365
|
+
const offset = Number(uint[1](bytes33));
|
366
|
+
const current = bytes33.i;
|
367
|
+
bytes33.i = start + offset;
|
368
|
+
result[i] = decoders[i](bytes33);
|
369
|
+
bytes33.i = current;
|
304
370
|
} else {
|
305
|
-
result[i] = decoders[i](
|
371
|
+
result[i] = decoders[i](bytes33);
|
306
372
|
}
|
307
373
|
}
|
308
374
|
return result;
|
@@ -325,53 +391,145 @@ var Struct = (codecs) => {
|
|
325
391
|
};
|
326
392
|
|
327
393
|
// src/codecs/Vector.ts
|
328
|
-
var uint2563 = Uint(256);
|
329
394
|
var vectorEnc = (inner, size) => {
|
330
395
|
if (size >= 0) {
|
331
|
-
const
|
332
|
-
|
333
|
-
return
|
396
|
+
const encoder2 = (value) => mergeUint8(...value.map(inner));
|
397
|
+
encoder2.dyn = inner.dyn;
|
398
|
+
return encoder2;
|
334
399
|
}
|
335
|
-
const
|
336
|
-
|
337
|
-
return
|
400
|
+
const encoder = (value) => mergeUint8(uint[0](BigInt(value.length)), ...value.map(inner));
|
401
|
+
encoder.dyn = true;
|
402
|
+
return encoder;
|
338
403
|
};
|
339
404
|
var vectorDec = (getter, size) => {
|
340
|
-
const
|
341
|
-
const nElements = size >= 0 ? size : Number(
|
342
|
-
const
|
405
|
+
const decoder = toInternalBytes((bytes33) => {
|
406
|
+
const nElements = size >= 0 ? size : Number(uint[1](bytes33));
|
407
|
+
const decoded = new Array(nElements);
|
343
408
|
for (let i = 0; i < nElements; i++) {
|
344
|
-
|
409
|
+
decoded[i] = getter(bytes33);
|
345
410
|
}
|
346
|
-
return
|
411
|
+
return decoded;
|
347
412
|
});
|
348
413
|
if (size == null)
|
349
|
-
|
350
|
-
return
|
414
|
+
decoder.dyn = true;
|
415
|
+
return decoder;
|
351
416
|
};
|
352
417
|
var Vector = (inner, size) => {
|
353
|
-
const
|
418
|
+
const codec = createCodec(vectorEnc(inner[0], size), vectorDec(inner[1], size));
|
354
419
|
if (size == null)
|
355
|
-
|
356
|
-
return
|
420
|
+
codec.dyn = true;
|
421
|
+
return codec;
|
357
422
|
};
|
358
|
-
Vector.enc = vectorEnc;
|
359
|
-
Vector.dec = vectorDec;
|
360
423
|
export {
|
361
|
-
Bytes,
|
362
424
|
Fixed,
|
363
|
-
Int,
|
364
425
|
Struct,
|
365
426
|
Tuple,
|
366
|
-
Ufixed,
|
367
|
-
Uint,
|
368
427
|
Vector,
|
428
|
+
address,
|
369
429
|
bool,
|
430
|
+
bytes,
|
431
|
+
bytes1,
|
432
|
+
bytes10,
|
433
|
+
bytes11,
|
434
|
+
bytes12,
|
435
|
+
bytes13,
|
436
|
+
bytes14,
|
437
|
+
bytes15,
|
438
|
+
bytes16,
|
439
|
+
bytes17,
|
440
|
+
bytes18,
|
441
|
+
bytes19,
|
442
|
+
bytes2,
|
443
|
+
bytes20,
|
444
|
+
bytes21,
|
445
|
+
bytes22,
|
446
|
+
bytes23,
|
447
|
+
bytes24,
|
448
|
+
bytes25,
|
449
|
+
bytes26,
|
450
|
+
bytes27,
|
451
|
+
bytes28,
|
452
|
+
bytes29,
|
453
|
+
bytes3,
|
454
|
+
bytes30,
|
455
|
+
bytes31,
|
456
|
+
bytes32,
|
457
|
+
bytes4,
|
458
|
+
bytes5,
|
459
|
+
bytes6,
|
460
|
+
bytes7,
|
461
|
+
bytes8,
|
462
|
+
bytes9,
|
370
463
|
createCodec,
|
371
|
-
dyn,
|
372
464
|
enhanceCodec,
|
373
465
|
enhanceDecoder,
|
374
466
|
enhanceEncoder,
|
375
|
-
|
467
|
+
int,
|
468
|
+
int104,
|
469
|
+
int112,
|
470
|
+
int120,
|
471
|
+
int128,
|
472
|
+
int136,
|
473
|
+
int144,
|
474
|
+
int152,
|
475
|
+
int16,
|
476
|
+
int160,
|
477
|
+
int168,
|
478
|
+
int176,
|
479
|
+
int184,
|
480
|
+
int192,
|
481
|
+
int200,
|
482
|
+
int208,
|
483
|
+
int224,
|
484
|
+
int226,
|
485
|
+
int232,
|
486
|
+
int24,
|
487
|
+
int240,
|
488
|
+
int248,
|
489
|
+
int256,
|
490
|
+
int32,
|
491
|
+
int40,
|
492
|
+
int48,
|
493
|
+
int56,
|
494
|
+
int64,
|
495
|
+
int72,
|
496
|
+
int8,
|
497
|
+
int80,
|
498
|
+
int88,
|
499
|
+
int96,
|
500
|
+
str,
|
501
|
+
uint,
|
502
|
+
uint104,
|
503
|
+
uint112,
|
504
|
+
uint120,
|
505
|
+
uint128,
|
506
|
+
uint136,
|
507
|
+
uint144,
|
508
|
+
uint152,
|
509
|
+
uint16,
|
510
|
+
uint160,
|
511
|
+
uint168,
|
512
|
+
uint176,
|
513
|
+
uint184,
|
514
|
+
uint192,
|
515
|
+
uint200,
|
516
|
+
uint208,
|
517
|
+
uint224,
|
518
|
+
uint226,
|
519
|
+
uint232,
|
520
|
+
uint24,
|
521
|
+
uint240,
|
522
|
+
uint248,
|
523
|
+
uint256,
|
524
|
+
uint32,
|
525
|
+
uint40,
|
526
|
+
uint48,
|
527
|
+
uint56,
|
528
|
+
uint64,
|
529
|
+
uint72,
|
530
|
+
uint8,
|
531
|
+
uint80,
|
532
|
+
uint88,
|
533
|
+
uint96
|
376
534
|
};
|
377
535
|
//# sourceMappingURL=solidity-codecs.js.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"version": 3,
|
3
|
-
"sources": ["../src/utils.ts", "../src/internal/toInternalBytes.ts", "../src/internal/mergeUint8.ts", "../src/codecs/Uint.ts", "../src/codecs/bool.ts", "../src/codecs/str.ts", "../src/codecs/
|
4
|
-
"sourcesContent": ["import type { Codec, Decoder, Encoder } from \"./types\"\n\nexport const createCodec = <T>(\n encoder: Encoder<T>,\n decoder: Decoder<T>,\n): Codec<T> => {\n const result = [encoder, decoder] as any\n result.enc = encoder\n result.dec = decoder\n return result\n}\n\nexport const dyn = <T extends { dyn?: boolean }>(\n input: { dyn?: boolean },\n output: T,\n): T => {\n if (input.dyn) output.dyn = true\n return output\n}\n\nexport const enhanceEncoder = <I, O>(\n encoder: Encoder<I>,\n mapper: (value: O) => I,\n): Encoder<O> => dyn(encoder, ((value) => encoder(mapper(value))) as Encoder<O>)\n\nexport const enhanceDecoder = <I, O>(\n decoder: Decoder<I>,\n mapper: (value: I) => O,\n): Decoder<O> => dyn(decoder, ((value) => mapper(decoder(value))) as Decoder<O>)\n\nexport const enhanceCodec = <I, O>(\n codec: Codec<I>,\n toFrom: (value: O) => I,\n fromTo: (value: I) => O,\n): Codec<O> =>\n dyn(\n codec,\n createCodec(\n enhanceEncoder(codec[0], toFrom),\n enhanceDecoder(codec[1], fromTo),\n ),\n )\n", "import { Decoder } from \"../types\"\n\n// https://jsben.ch/URe1X\nconst HEX_MAP: Record<string, number> = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n a: 10,\n b: 11,\n c: 12,\n d: 13,\n e: 14,\n f: 15,\n A: 10,\n B: 11,\n C: 12,\n D: 13,\n E: 14,\n F: 15,\n}\nexport function fromHex(hexString: string): Uint8Array {\n const isOdd = hexString.length % 2\n /* istanbul ignore next */\n const base = (hexString[1] === \"x\" ? 2 : 0) + isOdd\n const nBytes = (hexString.length - base) / 2 + isOdd\n const bytes = new Uint8Array(nBytes)\n\n if (isOdd) bytes[0] = 0 | HEX_MAP[hexString[2]]\n\n for (let i = 0; i < nBytes; ) {\n const idx = base + i * 2\n const a = HEX_MAP[hexString[idx]]\n const b = HEX_MAP[hexString[idx + 1]]\n bytes[isOdd + i++] = (a << 4) | b\n }\n\n return bytes\n}\n\nclass InternalUint8Array extends Uint8Array {\n i: number = 0\n v: DataView\n\n constructor(buffer: ArrayBuffer) {\n super(buffer)\n this.v = new DataView(buffer)\n }\n}\n\nexport const toInternalBytes =\n <T>(fn: (input: InternalUint8Array) => T): Decoder<T> =>\n (buffer: string | ArrayBuffer | Uint8Array | InternalUint8Array) =>\n fn(\n buffer instanceof InternalUint8Array\n ? buffer\n : new InternalUint8Array(\n buffer instanceof Uint8Array\n ? buffer.buffer\n : typeof buffer === \"string\"\n ? fromHex(buffer).buffer\n : buffer,\n ),\n )\n", "export const mergeUint8 = (...inputs: Array<Uint8Array>): Uint8Array => {\n const len = inputs.length\n let totalLen = 0\n for (let i = 0; i < len; i++) totalLen += inputs[i].byteLength\n const result = new Uint8Array(totalLen)\n\n for (let idx = 0, at = 0; idx < len; idx++) {\n const current = inputs[idx]\n result.set(current, at)\n at += current.byteLength\n }\n\n return result\n}\n", "import { Codec } from \"../types\"\nimport { toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst getCodec = (nBytes: number): Codec<bigint> => {\n const n64 = Math.ceil(nBytes / 8)\n return createCodec(\n (input) => {\n const result = new Uint8Array(32)\n const dv = new DataView(result.buffer)\n\n const idxLimit = 32 - n64 * 8\n for (let idx = 24; idx >= idxLimit; idx -= 8) {\n dv.setBigUint64(idx, input)\n input >>= 64n\n }\n\n return result\n },\n toInternalBytes((bytes) => {\n let result = 0n\n\n const nextBlock = bytes.i + 32\n for (let idx = bytes.i + (32 - n64 * 8); idx < nextBlock; idx += 8)\n result = (result << 64n) | bytes.v.getBigUint64(idx)\n\n bytes.i = nextBlock\n return result\n }),\n )\n}\n\nconst cache: Map<number, Codec<bigint>> = new Map()\nexport const Uint = (nBits: number): Codec<bigint> => {\n let cached = cache.get(nBits)\n if (cached) return cached\n\n const nBytes = nBits / 8\n cached = getCodec(nBytes)\n cache.set(nBits, cached)\n return cached\n}\n\nUint.enc = (nBits: number) => Uint(nBits).enc\nUint.dec = (nBits: number) => Uint(nBits).dec\n", "import { Codec } from \"../types\"\nimport { enhanceCodec } from \"../\"\nimport { Uint } from \"./Uint\"\n\nexport const bool: Codec<boolean> = enhanceCodec(\n Uint(8),\n (value: boolean) => (value ? 1n : 0n),\n Boolean,\n)\n", "import { createCodec, Decoder, Encoder } from \"../\"\nimport { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { Uint } from \"./Uint\"\n\nconst uint256 = Uint(256)\nconst textEncoder = new TextEncoder()\nconst strEnc: Encoder<string> = (str) => {\n const val = textEncoder.encode(str)\n const args = [uint256.enc(BigInt(val.length)), val] as const\n const extra = val.length % 32\n if (extra > 0) {\n ;(args as any).push(new Uint8Array(32 - extra))\n }\n return mergeUint8(...args)\n}\nstrEnc.dyn = true\n\nconst textDecoder = new TextDecoder()\nconst strDec: Decoder<string> = toInternalBytes((bytes) => {\n let nElements = Number(uint256.dec(bytes))\n const dv = new DataView(bytes.buffer, bytes.i, nElements)\n const extra = nElements % 32\n const padding = extra && 32 - extra\n bytes.i += nElements + padding\n return textDecoder.decode(dv)\n})\nstrDec.dyn = true\n\nexport const str = createCodec(strEnc, strDec)\nstr.dyn = true\n", "import { Encoder, Decoder, Codec } from \"../types\"\nimport { createCodec } from \"../\"\nimport { toInternalBytes } from \"../internal\"\n\nconst bytesEnc =\n (nBytes: number): Encoder<Uint8Array> =>\n (bytes) => {\n if (bytes.length === 32) return bytes\n const result = new Uint8Array(32)\n result.set(bytes.length === nBytes ? bytes : bytes.slice(0, nBytes))\n return result\n }\n\nconst bytesDec = (nBytes: number): Decoder<Uint8Array> =>\n toInternalBytes((bytes) => {\n const result = new Uint8Array(bytes.buffer, bytes.i, nBytes)\n bytes.i += 32\n return result\n })\n\nexport const Bytes = (nBytes: number): Codec<Uint8Array> =>\n createCodec(bytesEnc(nBytes), bytesDec(nBytes))\n\nBytes.enc = bytesEnc\nBytes.dec = bytesDec\n", "import { Encoder, Codec } from \"../types\"\nimport { toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst signGetters: Record<1 | 2 | 8, \"getBigInt64\" | \"getInt16\" | \"getInt8\"> = {\n \"1\": \"getInt8\",\n \"2\": \"getInt16\",\n \"8\": \"getBigInt64\",\n}\n\nconst signSetters: Record<1 | 2 | 8, \"setBigInt64\" | \"setInt16\" | \"setInt8\"> = {\n \"1\": \"setInt8\",\n \"2\": \"setInt16\",\n \"8\": \"setBigInt64\",\n}\n\nconst usignGetters: Record<\n 1 | 2 | 8,\n \"getBigUint64\" | \"getUint16\" | \"getUint8\"\n> = {\n \"1\": \"getUint8\",\n \"2\": \"getUint16\",\n \"8\": \"getBigUint64\",\n}\n\nconst usignSetters: Record<\n 1 | 2 | 8,\n \"setBigUint64\" | \"setUint16\" | \"setUint8\"\n> = {\n \"1\": \"setUint8\",\n \"2\": \"setUint16\",\n \"8\": \"setBigUint64\",\n}\n\nconst getCodec = (nBytes: number): Codec<bigint> => {\n const n64 = (nBytes / 8) | 0\n const n16 = ((nBytes % 8) / 2) | 0\n const sequence = [\n ...Array(n64).fill([8, 64n, (x: bigint) => x]),\n ...Array(n16).fill([2, 16n, (x: bigint) => Number(x & 65535n)]),\n ]\n if (nBytes % 2) sequence.push([1, 8n, (x: bigint) => Number(x & 255n)])\n\n const enc: Encoder<bigint> = (input) => {\n const result = new Uint8Array(32)\n const dv = new DataView(result.buffer)\n\n if (input < 0n) {\n for (let i = 0; i < 32 - nBytes; i += 8) dv.setBigInt64(i, -1n)\n }\n\n let idx = 32\n for (let i = sequence.length - 1; i > 0; i--) {\n const [bytes, shift, fn] = sequence[i] as [1, 8n, (x: bigint) => any]\n idx -= bytes\n dv[usignSetters[bytes]](idx, fn(input) as never)\n input >>= shift\n }\n const [bytes, , fn] = sequence[0] as [1, 8n, (x: bigint) => any]\n idx -= bytes\n dv[signSetters[bytes]](idx, fn(input) as never)\n\n return result\n }\n\n const dec = toInternalBytes((bytes) => {\n let idx = bytes.i + 32 - nBytes\n\n const bits = sequence[0][0] as 8\n let result = BigInt(bytes.v[signGetters[bits]](idx))\n idx += bits\n\n for (let i = 1; i < sequence.length; i++) {\n const [bits, shift] = sequence[i] as [1, 8n]\n result = (result << shift) | BigInt(bytes.v[usignGetters[bits]](idx))\n idx += bits\n }\n\n bytes.i += 32\n return result\n })\n\n return createCodec(enc, dec)\n}\n\nconst cache: Map<number, Codec<bigint>> = new Map()\nexport const Int = (nBits: number): Codec<bigint> => {\n let cached = cache.get(nBits)\n if (cached) return cached\n\n const nBytes = nBits / 8\n cached = getCodec(nBytes)\n cache.set(nBits, cached)\n return cached\n}\n\nInt.enc = (nBits: number) => Int(nBits).enc\nInt.dec = (nBits: number) => Int(nBits).dec\n", "import { Codec, Decimal } from \"../types\"\nimport { enhanceCodec } from \"../utils\"\nimport { Int } from \"./Int\"\nimport { Uint } from \"./Uint\"\n\nconst creator = (codec: (nBits: number) => Codec<bigint>) => {\n const cache: Map<number, Codec<Decimal>> = new Map()\n return (nBits: number, decimals: number): Codec<Decimal> => {\n const key = (decimals << 8) | nBits\n let cached = cache.get(key)\n if (cached) return cached\n\n cached = enhanceCodec(\n codec(nBits),\n (x) => x.value,\n (value) => ({ value, decimals }),\n )\n cache.set(key, cached)\n return cached\n }\n}\n\nexport const Fixed = creator(Int)\nexport const Ufixed = creator(Uint)\n", "import { Codec, Decoder, Encoder } from \"../types\"\nimport { Uint } from \"./Uint\"\nimport { mergeUint8, toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst uint256 = Uint(256)\nconst dynamicEnc = <\n A extends Array<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n>(\n ...encoders: A\n): Encoder<[...OT]> => {\n const res: Encoder<[...OT]> = (values) => {\n const mapped = values.map((value, idx) => encoders[idx](value))\n const resultArray = new Array<Uint8Array>(encoders.length)\n const dinamics = []\n let len = 0n\n for (let i = 0; i < encoders.length; i++) {\n if (encoders[i].dyn) {\n dinamics.push(i)\n len += 32n\n } else {\n resultArray[i] = mapped[i]\n len += BigInt(mapped[i].length)\n }\n }\n\n dinamics.forEach((idx) => {\n resultArray[idx] = uint256.enc(len)\n const data = mapped[idx]\n resultArray.push(data)\n len += BigInt(data.length)\n })\n\n return mergeUint8(...resultArray)\n }\n\n res.dyn = true\n return res\n}\n\nconst staticEnc =\n <\n A extends Array<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n >(\n ...encoders: A\n ): Encoder<[...OT]> =>\n (values) =>\n mergeUint8(...values.map((value, idx) => encoders[idx](value)))\n\nconst staticDec = <\n A extends Array<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n ...decoders: A\n): Decoder<[...OT]> =>\n toInternalBytes(\n (bytes) => decoders.map((decoder) => decoder(bytes)) as [...OT],\n )\nconst dynamicDec = <\n A extends Array<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n ...decoders: A\n): Decoder<[...OT]> => {\n const res: Decoder<[...OT]> = toInternalBytes((bytes) => {\n const result = new Array(decoders.length) as [...OT]\n let start = bytes.i\n for (let i = 0; i < decoders.length; i++) {\n if (decoders[i].dyn) {\n const offset = Number(uint256.dec(bytes))\n const current = bytes.i\n bytes.i = start + offset\n result[i] = decoders[i](bytes)\n bytes.i = current\n } else {\n result[i] = decoders[i](bytes)\n }\n }\n return result\n })\n res.dyn = true\n return res\n}\n\nexport const Tuple = <\n A extends Array<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n ...codecs: A\n): Codec<[...OT]> => {\n const isDyn = codecs.some((c) => c.dyn)\n const [enc, dec] = isDyn\n ? ([dynamicEnc, dynamicDec] as const)\n : ([staticEnc, staticDec] as const)\n\n const res: Codec<[...OT]> = createCodec(\n enc(...codecs.map(([encoder]) => encoder)),\n dec(...codecs.map(([, decoder]) => decoder)),\n )\n res.dyn = isDyn\n return res\n}\n", "import { Codec, StringRecord } from \"../types\"\nimport { enhanceCodec } from \"../utils\"\nimport { Tuple } from \"./Tuple\"\n\nexport const Struct = <\n A extends StringRecord<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n codecs: A,\n): Codec<OT> => {\n const keys = Object.keys(codecs)\n return enhanceCodec(\n Tuple(...Object.values(codecs)),\n (input: OT) => keys.map((k) => input[k]),\n (tuple: Array<any>) =>\n Object.fromEntries(tuple.map((value, idx) => [keys[idx], value])) as OT,\n )\n}\n", "import { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { createCodec } from \"../utils\"\nimport { Codec, Decoder, Encoder } from \"../types\"\nimport { Uint } from \"./Uint\"\n\nconst uint256 = Uint(256)\nconst vectorEnc = <T>(inner: Encoder<T>, size?: number): Encoder<Array<T>> => {\n if (size! >= 0) {\n const res: Encoder<Array<T>> = (value) => mergeUint8(...value.map(inner))\n res.dyn = inner.dyn\n return res\n }\n const result: Encoder<Array<T>> = (value) =>\n mergeUint8(uint256.enc(BigInt(value.length)), ...value.map(inner))\n result.dyn = true\n return result\n}\n\nconst vectorDec = <T>(getter: Decoder<T>, size?: number): Decoder<Array<T>> => {\n const result = toInternalBytes((bytes) => {\n const nElements = size! >= 0 ? size! : Number(uint256.dec(bytes))\n const result = new Array(nElements)\n\n for (let i = 0; i < nElements; i++) {\n result[i] = getter(bytes)\n }\n\n return result\n })\n if (size == null) result.dyn = true\n return result\n}\n\nexport const Vector = <T>(inner: Codec<T>, size?: number): Codec<Array<T>> => {\n const result = createCodec(\n vectorEnc(inner[0], size),\n vectorDec(inner[1], size),\n )\n if (size == null) result.dyn = true\n return result\n}\n\nVector.enc = vectorEnc\nVector.dec = vectorDec\n"],
|
5
|
-
"mappings": ";;;;;;;;AAEO,IAAM,cAAc,CACzB,SACA,YACa;AACb,QAAM,SAAS,CAAC,SAAS,OAAO;AAChC,SAAO,MAAM;AACb,SAAO,MAAM;AACb,SAAO;AACT;
|
3
|
+
"sources": ["../src/utils.ts", "../src/internal/toInternalBytes.ts", "../src/internal/mergeUint8.ts", "../src/internal/range32.ts", "../src/codecs/Uint.ts", "../src/codecs/bool.ts", "../src/codecs/bytes.ts", "../src/codecs/str.ts", "../src/codecs/BytesX.ts", "../src/codecs/Int.ts", "../src/codecs/Fixed.ts", "../src/codecs/Tuple.ts", "../src/codecs/Struct.ts", "../src/codecs/Vector.ts"],
|
4
|
+
"sourcesContent": ["import type { Codec, Decoder, Encoder } from \"./types\"\n\nexport const createCodec = <T>(\n encoder: Encoder<T>,\n decoder: Decoder<T>,\n): Codec<T> => {\n const result = [encoder, decoder] as any\n result.enc = encoder\n result.dec = decoder\n return result\n}\n\nconst dyn = <T extends { dyn?: boolean }>(\n input: { dyn?: boolean },\n output: T,\n): T => {\n if (input.dyn) output.dyn = true\n return output\n}\n\nexport const enhanceEncoder = <I, O>(\n encoder: Encoder<I>,\n mapper: (value: O) => I,\n): Encoder<O> => dyn(encoder, ((value) => encoder(mapper(value))) as Encoder<O>)\n\nexport const enhanceDecoder = <I, O>(\n decoder: Decoder<I>,\n mapper: (value: I) => O,\n): Decoder<O> => dyn(decoder, ((value) => mapper(decoder(value))) as Decoder<O>)\n\nexport const enhanceCodec = <I, O>(\n codec: Codec<I>,\n toFrom: (value: O) => I,\n fromTo: (value: I) => O,\n): Codec<O> =>\n dyn(\n codec,\n createCodec(\n enhanceEncoder(codec[0], toFrom),\n enhanceDecoder(codec[1], fromTo),\n ),\n )\n", "import { Decoder } from \"../types\"\n\n// https://jsben.ch/URe1X\nconst HEX_MAP: Record<string, number> = {\n 0: 0,\n 1: 1,\n 2: 2,\n 3: 3,\n 4: 4,\n 5: 5,\n 6: 6,\n 7: 7,\n 8: 8,\n 9: 9,\n a: 10,\n b: 11,\n c: 12,\n d: 13,\n e: 14,\n f: 15,\n A: 10,\n B: 11,\n C: 12,\n D: 13,\n E: 14,\n F: 15,\n}\nexport function fromHex(hexString: string): Uint8Array {\n const isOdd = hexString.length % 2\n /* istanbul ignore next */\n const base = (hexString[1] === \"x\" ? 2 : 0) + isOdd\n const nBytes = (hexString.length - base) / 2 + isOdd\n const bytes = new Uint8Array(nBytes)\n\n if (isOdd) bytes[0] = 0 | HEX_MAP[hexString[2]]\n\n for (let i = 0; i < nBytes; ) {\n const idx = base + i * 2\n const a = HEX_MAP[hexString[idx]]\n const b = HEX_MAP[hexString[idx + 1]]\n bytes[isOdd + i++] = (a << 4) | b\n }\n\n return bytes\n}\n\nclass InternalUint8Array extends Uint8Array {\n i: number = 0\n v: DataView\n\n constructor(buffer: ArrayBuffer) {\n super(buffer)\n this.v = new DataView(buffer)\n }\n}\n\nexport const toInternalBytes =\n <T>(fn: (input: InternalUint8Array) => T): Decoder<T> =>\n (buffer: string | ArrayBuffer | Uint8Array | InternalUint8Array) =>\n fn(\n buffer instanceof InternalUint8Array\n ? buffer\n : new InternalUint8Array(\n buffer instanceof Uint8Array\n ? buffer.buffer\n : typeof buffer === \"string\"\n ? fromHex(buffer).buffer\n : buffer,\n ),\n )\n", "export const mergeUint8 = (...inputs: Array<Uint8Array>): Uint8Array => {\n const len = inputs.length\n let totalLen = 0\n for (let i = 0; i < len; i++) totalLen += inputs[i].byteLength\n const result = new Uint8Array(totalLen)\n\n for (let idx = 0, at = 0; idx < len; idx++) {\n const current = inputs[idx]\n result.set(current, at)\n at += current.byteLength\n }\n\n return result\n}\n", "export const range32 = Array(32)\n .fill(0)\n .map((_, idx) => idx + 1)\n", "import { Codec } from \"../types\"\nimport { range32, toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst getCodec = (nBytes: number): Codec<bigint> => {\n const n64 = Math.ceil(nBytes / 8)\n return createCodec(\n (input) => {\n const result = new Uint8Array(32)\n const dv = new DataView(result.buffer)\n\n const idxLimit = 32 - n64 * 8\n for (let idx = 24; idx >= idxLimit; idx -= 8) {\n dv.setBigUint64(idx, input)\n input >>= 64n\n }\n\n return result\n },\n toInternalBytes((bytes) => {\n let result = 0n\n\n const nextBlock = bytes.i + 32\n for (let idx = bytes.i + (32 - n64 * 8); idx < nextBlock; idx += 8)\n result = (result << 64n) | bytes.v.getBigUint64(idx)\n\n bytes.i = nextBlock\n return result\n }),\n )\n}\n\nexport const [\n uint8,\n uint16,\n uint24,\n uint32,\n uint40,\n uint48,\n uint56,\n uint64,\n uint72,\n uint80,\n uint88,\n uint96,\n uint104,\n uint112,\n uint120,\n uint128,\n uint136,\n uint144,\n uint152,\n uint160,\n uint168,\n uint176,\n uint184,\n uint192,\n uint200,\n uint208,\n uint226,\n uint224,\n uint232,\n uint240,\n uint248,\n uint256,\n] = range32.map(getCodec)\nexport const uint = uint256\nexport const address = uint160\n", "import { Codec } from \"../types\"\nimport { enhanceCodec } from \"../\"\nimport { uint8 } from \"./Uint\"\n\nexport const bool: Codec<boolean> = enhanceCodec(\n uint8,\n (value: boolean) => (value ? 1n : 0n),\n Boolean,\n)\n", "import { createCodec, Decoder, Encoder } from \"../\"\nimport { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { uint } from \"./Uint\"\n\nconst bytesEnc: Encoder<Uint8Array> = (val) => {\n const args = [uint[0](BigInt(val.length)), val] as const\n const extra = val.length % 32\n if (extra > 0) {\n ;(args as any).push(new Uint8Array(32 - extra))\n }\n return mergeUint8(...args)\n}\nbytesEnc.dyn = true\n\nconst bytesDec: Decoder<Uint8Array> = toInternalBytes((bytes) => {\n let nElements = Number(uint[1](bytes))\n const result = new Uint8Array(bytes.buffer, bytes.i, nElements)\n bytes.i += nElements + (nElements % 32)\n return result\n})\nbytesDec.dyn = true\n\nexport const bytes = createCodec(bytesEnc, bytesDec)\nbytes.dyn = true\n", "import { enhanceCodec } from \"../\"\nimport { bytes } from \"./bytes\"\n\nconst textEncoder = new TextEncoder()\nconst textDecoder = new TextDecoder()\n\nexport const str = enhanceCodec<Uint8Array, string>(\n bytes,\n textEncoder.encode.bind(textEncoder),\n textDecoder.decode.bind(textDecoder),\n)\n", "import { Encoder, Decoder, Codec } from \"../types\"\nimport { createCodec } from \"../\"\nimport { range32, toInternalBytes } from \"../internal\"\n\nconst bytesEnc =\n (nBytes: number): Encoder<Uint8Array> =>\n (bytes) => {\n if (bytes.length === nBytes && nBytes === 32) return bytes\n const result = new Uint8Array(32)\n result.set(bytes.length === nBytes ? bytes : bytes.slice(0, nBytes))\n return result\n }\n\nconst bytesDec = (nBytes: number): Decoder<Uint8Array> =>\n toInternalBytes((bytes) => {\n const result = new Uint8Array(bytes.buffer, bytes.i, nBytes)\n bytes.i += 32\n return result\n })\n\nexport const [\n bytes1,\n bytes2,\n bytes3,\n bytes4,\n bytes5,\n bytes6,\n bytes7,\n bytes8,\n bytes9,\n bytes10,\n bytes11,\n bytes12,\n bytes13,\n bytes14,\n bytes15,\n bytes16,\n bytes17,\n bytes18,\n bytes19,\n bytes20,\n bytes21,\n bytes22,\n bytes23,\n bytes24,\n bytes25,\n bytes26,\n bytes27,\n bytes28,\n bytes29,\n bytes30,\n bytes31,\n bytes32,\n] = range32.map(\n (nBytes: number): Codec<Uint8Array> =>\n createCodec(bytesEnc(nBytes), bytesDec(nBytes)),\n)\n", "import { Encoder, Codec } from \"../types\"\nimport { range32, toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst signGetters: Record<1 | 2 | 8, \"getBigInt64\" | \"getInt16\" | \"getInt8\"> = {\n \"1\": \"getInt8\",\n \"2\": \"getInt16\",\n \"8\": \"getBigInt64\",\n}\n\nconst signSetters: Record<1 | 2 | 8, \"setBigInt64\" | \"setInt16\" | \"setInt8\"> = {\n \"1\": \"setInt8\",\n \"2\": \"setInt16\",\n \"8\": \"setBigInt64\",\n}\n\nconst usignGetters: Record<\n 1 | 2 | 8,\n \"getBigUint64\" | \"getUint16\" | \"getUint8\"\n> = {\n \"1\": \"getUint8\",\n \"2\": \"getUint16\",\n \"8\": \"getBigUint64\",\n}\n\nconst usignSetters: Record<\n 1 | 2 | 8,\n \"setBigUint64\" | \"setUint16\" | \"setUint8\"\n> = {\n \"1\": \"setUint8\",\n \"2\": \"setUint16\",\n \"8\": \"setBigUint64\",\n}\n\nconst getCodec = (nBytes: number): Codec<bigint> => {\n const n64 = (nBytes / 8) | 0\n const n16 = ((nBytes % 8) / 2) | 0\n const sequence = [\n ...Array(n64).fill([8, 64n, (x: bigint) => x]),\n ...Array(n16).fill([2, 16n, (x: bigint) => Number(x & 65535n)]),\n ]\n if (nBytes % 2) sequence.push([1, 8n, (x: bigint) => Number(x & 255n)])\n\n const enc: Encoder<bigint> = (input) => {\n const result = new Uint8Array(32)\n const dv = new DataView(result.buffer)\n\n if (input < 0n) {\n for (let i = 0; i < 32 - nBytes; i += 8) dv.setBigInt64(i, -1n)\n }\n\n let idx = 32\n for (let i = sequence.length - 1; i > 0; i--) {\n const [bytes, shift, fn] = sequence[i] as [1, 8n, (x: bigint) => any]\n idx -= bytes\n dv[usignSetters[bytes]](idx, fn(input) as never)\n input >>= shift\n }\n const [bytes, , fn] = sequence[0] as [1, 8n, (x: bigint) => any]\n idx -= bytes\n dv[signSetters[bytes]](idx, fn(input) as never)\n\n return result\n }\n\n const dec = toInternalBytes((bytes) => {\n let idx = bytes.i + 32 - nBytes\n\n const bits = sequence[0][0] as 8\n let result = BigInt(bytes.v[signGetters[bits]](idx))\n idx += bits\n\n for (let i = 1; i < sequence.length; i++) {\n const [bits, shift] = sequence[i] as [1, 8n]\n result = (result << shift) | BigInt(bytes.v[usignGetters[bits]](idx))\n idx += bits\n }\n\n bytes.i += 32\n return result\n })\n\n return createCodec(enc, dec)\n}\n\nexport const [\n int8,\n int16,\n int24,\n int32,\n int40,\n int48,\n int56,\n int64,\n int72,\n int80,\n int88,\n int96,\n int104,\n int112,\n int120,\n int128,\n int136,\n int144,\n int152,\n int160,\n int168,\n int176,\n int184,\n int192,\n int200,\n int208,\n int226,\n int224,\n int232,\n int240,\n int248,\n int256,\n] = range32.map(getCodec)\nexport const int = int256\n", "import { Codec } from \"../types\"\nimport { enhanceCodec } from \"../utils\"\n\nexport interface Decimal<T extends number = number> {\n value: bigint\n decimals: T\n}\n\nexport const Fixed = <D extends number>(\n baseCodec: Codec<bigint>,\n decimals: D,\n) =>\n enhanceCodec<bigint, Decimal<D>>(\n baseCodec,\n (x) => x.value,\n (value) => ({ value, decimals }),\n )\n", "import { Codec, Decoder, Encoder } from \"../types\"\nimport { uint } from \"./Uint\"\nimport { mergeUint8, toInternalBytes } from \"../internal\"\nimport { createCodec } from \"../utils\"\n\nconst dynamicEnc = <\n A extends Array<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n>(\n ...encoders: A\n): Encoder<[...OT]> => {\n const res: Encoder<[...OT]> = (values) => {\n const mapped = values.map((value, idx) => encoders[idx](value))\n const resultArray = new Array<Uint8Array>(encoders.length)\n const dinamics = []\n let len = 0n\n for (let i = 0; i < encoders.length; i++) {\n if (encoders[i].dyn) {\n dinamics.push(i)\n len += 32n\n } else {\n resultArray[i] = mapped[i]\n len += BigInt(mapped[i].length)\n }\n }\n\n dinamics.forEach((idx) => {\n resultArray[idx] = uint[0](len)\n const data = mapped[idx]\n resultArray.push(data)\n len += BigInt(data.length)\n })\n\n return mergeUint8(...resultArray)\n }\n\n res.dyn = true\n return res\n}\n\nconst staticEnc =\n <\n A extends Array<Encoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Encoder<infer D> ? D : unknown },\n >(\n ...encoders: A\n ): Encoder<[...OT]> =>\n (values) =>\n mergeUint8(...values.map((value, idx) => encoders[idx](value)))\n\nconst staticDec = <\n A extends Array<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n ...decoders: A\n): Decoder<[...OT]> =>\n toInternalBytes(\n (bytes) => decoders.map((decoder) => decoder(bytes)) as [...OT],\n )\nconst dynamicDec = <\n A extends Array<Decoder<any>>,\n OT extends { [K in keyof A]: A[K] extends Decoder<infer D> ? D : unknown },\n>(\n ...decoders: A\n): Decoder<[...OT]> => {\n const res: Decoder<[...OT]> = toInternalBytes((bytes) => {\n const result = new Array(decoders.length) as [...OT]\n let start = bytes.i\n for (let i = 0; i < decoders.length; i++) {\n if (decoders[i].dyn) {\n const offset = Number(uint[1](bytes))\n const current = bytes.i\n bytes.i = start + offset\n result[i] = decoders[i](bytes)\n bytes.i = current\n } else {\n result[i] = decoders[i](bytes)\n }\n }\n return result\n })\n res.dyn = true\n return res\n}\n\nexport const Tuple = <\n A extends Array<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n ...codecs: A\n): Codec<[...OT]> => {\n const isDyn = codecs.some((c) => c.dyn)\n const [enc, dec] = isDyn\n ? ([dynamicEnc, dynamicDec] as const)\n : ([staticEnc, staticDec] as const)\n\n const res: Codec<[...OT]> = createCodec(\n enc(...codecs.map(([encoder]) => encoder)),\n dec(...codecs.map(([, decoder]) => decoder)),\n )\n res.dyn = isDyn\n return res\n}\n", "import { Codec, StringRecord } from \"../types\"\nimport { enhanceCodec } from \"../utils\"\nimport { Tuple } from \"./Tuple\"\n\nexport const Struct = <\n A extends StringRecord<Codec<any>>,\n OT extends { [K in keyof A]: A[K] extends Codec<infer D> ? D : unknown },\n>(\n codecs: A,\n): Codec<OT> => {\n const keys = Object.keys(codecs)\n return enhanceCodec(\n Tuple(...Object.values(codecs)),\n (input: OT) => keys.map((k) => input[k]),\n (tuple: Array<any>) =>\n Object.fromEntries(tuple.map((value, idx) => [keys[idx], value])) as OT,\n )\n}\n", "import { toInternalBytes, mergeUint8 } from \"../internal\"\nimport { createCodec } from \"../utils\"\nimport { Codec, Decoder, Encoder } from \"../types\"\nimport { uint } from \"./Uint\"\n\nconst vectorEnc = <T>(inner: Encoder<T>, size?: number): Encoder<Array<T>> => {\n if (size! >= 0) {\n const encoder: Encoder<Array<T>> = (value) =>\n mergeUint8(...value.map(inner))\n encoder.dyn = inner.dyn\n return encoder\n }\n const encoder: Encoder<Array<T>> = (value) =>\n mergeUint8(uint[0](BigInt(value.length)), ...value.map(inner))\n encoder.dyn = true\n return encoder\n}\n\nconst vectorDec = <T>(getter: Decoder<T>, size?: number): Decoder<Array<T>> => {\n const decoder = toInternalBytes((bytes) => {\n const nElements = size! >= 0 ? size! : Number(uint[1](bytes))\n const decoded = new Array(nElements)\n\n for (let i = 0; i < nElements; i++) {\n decoded[i] = getter(bytes)\n }\n\n return decoded\n })\n if (size == null) decoder.dyn = true\n return decoder\n}\n\nexport const Vector = <T>(inner: Codec<T>, size?: number): Codec<Array<T>> => {\n const codec = createCodec(\n vectorEnc(inner[0], size),\n vectorDec(inner[1], size),\n )\n if (size == null) codec.dyn = true\n return codec\n}\n"],
|
5
|
+
"mappings": ";;;;;;;;AAEO,IAAM,cAAc,CACzB,SACA,YACa;AACb,QAAM,SAAS,CAAC,SAAS,OAAO;AAChC,SAAO,MAAM;AACb,SAAO,MAAM;AACb,SAAO;AACT;AAEA,IAAM,MAAM,CACV,OACA,WACM;AACN,MAAI,MAAM;AAAK,WAAO,MAAM;AAC5B,SAAO;AACT;AAEO,IAAM,iBAAiB,CAC5B,SACA,WACe,IAAI,SAAU,CAAC,UAAU,QAAQ,OAAO,KAAK,CAAC,CAAgB;AAExE,IAAM,iBAAiB,CAC5B,SACA,WACe,IAAI,SAAU,CAAC,UAAU,OAAO,QAAQ,KAAK,CAAC,CAAgB;AAExE,IAAM,eAAe,CAC1B,OACA,QACA,WAEA,IACE,OACA,YACE,eAAe,MAAM,IAAI,MAAM,GAC/B,eAAe,MAAM,IAAI,MAAM,CACjC,CACF;;;ACtCF,IAAM,UAAkC;AAAA,EACtC,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;AAAA,EACH,GAAG;A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