@solana/codecs-data-structures 2.0.0-experimental.eeb355e → 2.0.0-experimental.ef09aec
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/index.browser.cjs
CHANGED
package/dist/index.browser.js
CHANGED
|
@@ -616,3 +616,5 @@ function getUnitCodec(config = {}) {
|
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
export { assertValidNumberOfItemsForCodec, decodeArrayLikeCodecSize, getArrayCodec, getArrayDecoder, getArrayEncoder, getArrayLikeCodecSizeDescription, getArrayLikeCodecSizeFromChildren, getArrayLikeCodecSizePrefix, getBitArrayCodec, getBitArrayDecoder, getBitArrayEncoder, getBooleanCodec, getBooleanDecoder, getBooleanEncoder, getBytesCodec, getBytesDecoder, getBytesEncoder, getDataEnumCodec, getDataEnumDecoder, getDataEnumEncoder, getMapCodec, getMapDecoder, getMapEncoder, getNullableCodec, getNullableDecoder, getNullableEncoder, getScalarEnumCodec, getScalarEnumDecoder, getScalarEnumEncoder, getSetCodec, getSetDecoder, getSetEncoder, getStructCodec, getStructDecoder, getStructEncoder, getTupleCodec, getTupleDecoder, getTupleEncoder, getUnitCodec, getUnitDecoder, getUnitEncoder };
|
|
619
|
+
//# sourceMappingURL=out.js.map
|
|
620
|
+
//# sourceMappingURL=index.browser.js.map
|
|
@@ -16,7 +16,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
16
16
|
}
|
|
17
17
|
function assertFixedSizeCodec(data, message) {
|
|
18
18
|
if (data.fixedSize === null) {
|
|
19
|
-
throw new Error(message
|
|
19
|
+
throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
var mergeBytes = (byteArrays) => {
|
|
@@ -62,7 +62,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
62
62
|
}
|
|
63
63
|
return {
|
|
64
64
|
decode: decoder.decode,
|
|
65
|
-
description: description
|
|
65
|
+
description: description != null ? description : encoder.description,
|
|
66
66
|
encode: encoder.encode,
|
|
67
67
|
fixedSize: encoder.fixedSize,
|
|
68
68
|
maxSize: encoder.maxSize
|
|
@@ -70,7 +70,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
70
70
|
}
|
|
71
71
|
function fixCodecHelper(data, fixedBytes, description) {
|
|
72
72
|
return {
|
|
73
|
-
description: description
|
|
73
|
+
description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
|
|
74
74
|
fixedSize: fixedBytes,
|
|
75
75
|
maxSize: fixedBytes
|
|
76
76
|
};
|
|
@@ -107,6 +107,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
function sharedNumberFactory(input) {
|
|
110
|
+
var _a;
|
|
110
111
|
let littleEndian;
|
|
111
112
|
let defaultDescription = input.name;
|
|
112
113
|
if (input.size > 1) {
|
|
@@ -114,7 +115,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
114
115
|
defaultDescription += littleEndian ? "(le)" : "(be)";
|
|
115
116
|
}
|
|
116
117
|
return {
|
|
117
|
-
description: input.config.description
|
|
118
|
+
description: (_a = input.config.description) != null ? _a : defaultDescription,
|
|
118
119
|
fixedSize: input.size,
|
|
119
120
|
littleEndian,
|
|
120
121
|
maxSize: input.size
|
|
@@ -151,8 +152,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
151
152
|
};
|
|
152
153
|
}
|
|
153
154
|
function toArrayBuffer(bytes, offset, length) {
|
|
154
|
-
const bytesOffset = bytes.byteOffset + (offset
|
|
155
|
-
const bytesLength = length
|
|
155
|
+
const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
|
|
156
|
+
const bytesLength = length != null ? length : bytes.byteLength;
|
|
156
157
|
return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
|
|
157
158
|
}
|
|
158
159
|
var getU32Encoder = (config = {}) => numberEncoderFactory({
|
|
@@ -244,13 +245,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
244
245
|
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
245
246
|
}
|
|
246
247
|
return {
|
|
247
|
-
description: description
|
|
248
|
+
description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
248
249
|
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
249
250
|
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
250
251
|
};
|
|
251
252
|
}
|
|
252
253
|
function getArrayEncoder(item, config = {}) {
|
|
253
|
-
|
|
254
|
+
var _a;
|
|
255
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
254
256
|
return {
|
|
255
257
|
...arrayCodecHelper(item, size, config.description),
|
|
256
258
|
encode: (value) => {
|
|
@@ -262,7 +264,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
262
264
|
};
|
|
263
265
|
}
|
|
264
266
|
function getArrayDecoder(item, config = {}) {
|
|
265
|
-
|
|
267
|
+
var _a;
|
|
268
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
266
269
|
return {
|
|
267
270
|
...arrayCodecHelper(item, size, config.description),
|
|
268
271
|
decode: (bytes, offset = 0) => {
|
|
@@ -287,17 +290,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
287
290
|
|
|
288
291
|
// src/bit-array.ts
|
|
289
292
|
var getBitArrayEncoder = (size, config = {}) => {
|
|
293
|
+
var _a, _b;
|
|
290
294
|
const parsedConfig = typeof config === "boolean" ? { backward: config } : config;
|
|
291
|
-
const backward = parsedConfig.backward
|
|
295
|
+
const backward = (_a = parsedConfig.backward) != null ? _a : false;
|
|
292
296
|
const backwardSuffix = backward ? "; backward" : "";
|
|
293
297
|
return {
|
|
294
|
-
description: parsedConfig.description
|
|
298
|
+
description: (_b = parsedConfig.description) != null ? _b : `bitArray(${size}${backwardSuffix})`,
|
|
295
299
|
encode(value) {
|
|
300
|
+
var _a2;
|
|
296
301
|
const bytes = [];
|
|
297
302
|
for (let i = 0; i < size; i += 1) {
|
|
298
303
|
let byte = 0;
|
|
299
304
|
for (let j = 0; j < 8; j += 1) {
|
|
300
|
-
const feature = Number(value[i * 8 + j]
|
|
305
|
+
const feature = Number((_a2 = value[i * 8 + j]) != null ? _a2 : 0);
|
|
301
306
|
byte |= feature << (backward ? j : 7 - j);
|
|
302
307
|
}
|
|
303
308
|
if (backward) {
|
|
@@ -313,8 +318,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
313
318
|
};
|
|
314
319
|
};
|
|
315
320
|
var getBitArrayDecoder = (size, config = {}) => {
|
|
321
|
+
var _a, _b;
|
|
316
322
|
const parsedConfig = typeof config === "boolean" ? { backward: config } : config;
|
|
317
|
-
const backward = parsedConfig.backward
|
|
323
|
+
const backward = (_a = parsedConfig.backward) != null ? _a : false;
|
|
318
324
|
const backwardSuffix = backward ? "; backward" : "";
|
|
319
325
|
return {
|
|
320
326
|
decode(bytes, offset = 0) {
|
|
@@ -335,7 +341,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
335
341
|
});
|
|
336
342
|
return [booleans, offset + size];
|
|
337
343
|
},
|
|
338
|
-
description: parsedConfig.description
|
|
344
|
+
description: (_b = parsedConfig.description) != null ? _b : `bitArray(${size}${backwardSuffix})`,
|
|
339
345
|
fixedSize: size,
|
|
340
346
|
maxSize: size
|
|
341
347
|
};
|
|
@@ -344,17 +350,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
344
350
|
|
|
345
351
|
// src/boolean.ts
|
|
346
352
|
function getBooleanEncoder(config = {}) {
|
|
347
|
-
|
|
353
|
+
var _a, _b;
|
|
354
|
+
const size = (_a = config.size) != null ? _a : getU8Encoder();
|
|
348
355
|
assertFixedSizeCodec(size, "Codec [bool] requires a fixed size.");
|
|
349
356
|
return {
|
|
350
|
-
description: config.description
|
|
357
|
+
description: (_b = config.description) != null ? _b : `bool(${size.description})`,
|
|
351
358
|
encode: (value) => size.encode(value ? 1 : 0),
|
|
352
359
|
fixedSize: size.fixedSize,
|
|
353
360
|
maxSize: size.fixedSize
|
|
354
361
|
};
|
|
355
362
|
}
|
|
356
363
|
function getBooleanDecoder(config = {}) {
|
|
357
|
-
|
|
364
|
+
var _a, _b;
|
|
365
|
+
const size = (_a = config.size) != null ? _a : getU8Decoder();
|
|
358
366
|
assertFixedSizeCodec(size, "Codec [bool] requires a fixed size.");
|
|
359
367
|
return {
|
|
360
368
|
decode: (bytes, offset = 0) => {
|
|
@@ -362,7 +370,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
362
370
|
const [value, vOffset] = size.decode(bytes, offset);
|
|
363
371
|
return [value === 1, vOffset];
|
|
364
372
|
},
|
|
365
|
-
description: config.description
|
|
373
|
+
description: (_b = config.description) != null ? _b : `bool(${size.description})`,
|
|
366
374
|
fixedSize: size.fixedSize,
|
|
367
375
|
maxSize: size.fixedSize
|
|
368
376
|
};
|
|
@@ -373,9 +381,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
373
381
|
|
|
374
382
|
// src/bytes.ts
|
|
375
383
|
function getBytesEncoder(config = {}) {
|
|
376
|
-
|
|
384
|
+
var _a, _b;
|
|
385
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
377
386
|
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
378
|
-
const description = config.description
|
|
387
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
379
388
|
const byteEncoder = {
|
|
380
389
|
description,
|
|
381
390
|
encode: (value) => value,
|
|
@@ -398,9 +407,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
398
407
|
};
|
|
399
408
|
}
|
|
400
409
|
function getBytesDecoder(config = {}) {
|
|
401
|
-
|
|
410
|
+
var _a, _b;
|
|
411
|
+
const size = (_a = config.size) != null ? _a : "variable";
|
|
402
412
|
const sizeDescription = typeof size === "object" ? size.description : `${size}`;
|
|
403
|
-
const description = config.description
|
|
413
|
+
const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
|
|
404
414
|
const byteDecoder = {
|
|
405
415
|
decode: (bytes, offset = 0) => {
|
|
406
416
|
const slice = bytes.slice(offset);
|
|
@@ -442,13 +452,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
442
452
|
const fixedVariantSize = allVariantHaveTheSameFixedSize ? variants[0][1].fixedSize : null;
|
|
443
453
|
const maxVariantSize = maxCodecSizes(variants.map(([, field]) => field.maxSize));
|
|
444
454
|
return {
|
|
445
|
-
description: description
|
|
455
|
+
description: description != null ? description : `dataEnum(${fieldDescriptions}; ${prefix.description})`,
|
|
446
456
|
fixedSize: variants.length === 0 ? prefix.fixedSize : sumCodecSizes([prefix.fixedSize, fixedVariantSize]),
|
|
447
457
|
maxSize: variants.length === 0 ? prefix.maxSize : sumCodecSizes([prefix.maxSize, maxVariantSize])
|
|
448
458
|
};
|
|
449
459
|
}
|
|
450
460
|
function getDataEnumEncoder(variants, config = {}) {
|
|
451
|
-
|
|
461
|
+
var _a;
|
|
462
|
+
const prefix = (_a = config.size) != null ? _a : getU8Encoder();
|
|
452
463
|
return {
|
|
453
464
|
...dataEnumCodecHelper(variants, prefix, config.description),
|
|
454
465
|
encode: (variant) => {
|
|
@@ -466,14 +477,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
466
477
|
};
|
|
467
478
|
}
|
|
468
479
|
function getDataEnumDecoder(variants, config = {}) {
|
|
469
|
-
|
|
480
|
+
var _a;
|
|
481
|
+
const prefix = (_a = config.size) != null ? _a : getU8Decoder();
|
|
470
482
|
return {
|
|
471
483
|
...dataEnumCodecHelper(variants, prefix, config.description),
|
|
472
484
|
decode: (bytes, offset = 0) => {
|
|
485
|
+
var _a2;
|
|
473
486
|
assertByteArrayIsNotEmptyForCodec("dataEnum", bytes, offset);
|
|
474
487
|
const [discriminator, dOffset] = prefix.decode(bytes, offset);
|
|
475
488
|
offset = dOffset;
|
|
476
|
-
const variantField = variants[Number(discriminator)]
|
|
489
|
+
const variantField = (_a2 = variants[Number(discriminator)]) != null ? _a2 : null;
|
|
477
490
|
if (!variantField) {
|
|
478
491
|
throw new Error(
|
|
479
492
|
`Enum discriminator out of range. Expected a number between 0 and ${variants.length - 1}, got ${discriminator}.`
|
|
@@ -481,7 +494,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
481
494
|
}
|
|
482
495
|
const [variant, vOffset] = variantField[1].decode(bytes, offset);
|
|
483
496
|
offset = vOffset;
|
|
484
|
-
return [{ __kind: variantField[0], ...variant
|
|
497
|
+
return [{ __kind: variantField[0], ...variant != null ? variant : {} }, offset];
|
|
485
498
|
}
|
|
486
499
|
};
|
|
487
500
|
}
|
|
@@ -495,13 +508,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
495
508
|
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
496
509
|
}
|
|
497
510
|
return {
|
|
498
|
-
description: description
|
|
511
|
+
description: description != null ? description : `map(${key.description}, ${value.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
499
512
|
fixedSize: getArrayLikeCodecSizeFromChildren(size, [key.fixedSize, value.fixedSize]),
|
|
500
513
|
maxSize: getArrayLikeCodecSizeFromChildren(size, [key.maxSize, value.maxSize])
|
|
501
514
|
};
|
|
502
515
|
}
|
|
503
516
|
function getMapEncoder(key, value, config = {}) {
|
|
504
|
-
|
|
517
|
+
var _a;
|
|
518
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
505
519
|
return {
|
|
506
520
|
...mapCodecHelper(key, value, size, config.description),
|
|
507
521
|
encode: (map) => {
|
|
@@ -514,7 +528,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
514
528
|
};
|
|
515
529
|
}
|
|
516
530
|
function getMapDecoder(key, value, config = {}) {
|
|
517
|
-
|
|
531
|
+
var _a;
|
|
532
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
518
533
|
return {
|
|
519
534
|
...mapCodecHelper(key, value, size, config.description),
|
|
520
535
|
decode: (bytes, offset = 0) => {
|
|
@@ -555,14 +570,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
555
570
|
fixedSize = prefix.fixedSize + item.fixedSize;
|
|
556
571
|
}
|
|
557
572
|
return {
|
|
558
|
-
description: description
|
|
573
|
+
description: description != null ? description : `nullable(${item.description + descriptionSuffix})`,
|
|
559
574
|
fixedSize,
|
|
560
575
|
maxSize: sumCodecSizes([prefix.maxSize, item.maxSize])
|
|
561
576
|
};
|
|
562
577
|
}
|
|
563
578
|
function getNullableEncoder(item, config = {}) {
|
|
564
|
-
|
|
565
|
-
const
|
|
579
|
+
var _a, _b;
|
|
580
|
+
const prefix = (_a = config.prefix) != null ? _a : getU8Encoder();
|
|
581
|
+
const fixed = (_b = config.fixed) != null ? _b : false;
|
|
566
582
|
return {
|
|
567
583
|
...nullableCodecHelper(item, prefix, fixed, config.description),
|
|
568
584
|
encode: (option) => {
|
|
@@ -574,15 +590,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
574
590
|
};
|
|
575
591
|
}
|
|
576
592
|
function getNullableDecoder(item, config = {}) {
|
|
577
|
-
|
|
578
|
-
const
|
|
593
|
+
var _a, _b;
|
|
594
|
+
const prefix = (_a = config.prefix) != null ? _a : getU8Decoder();
|
|
595
|
+
const fixed = (_b = config.fixed) != null ? _b : false;
|
|
579
596
|
return {
|
|
580
597
|
...nullableCodecHelper(item, prefix, fixed, config.description),
|
|
581
598
|
decode: (bytes, offset = 0) => {
|
|
599
|
+
var _a2, _b2;
|
|
582
600
|
if (bytes.length - offset <= 0) {
|
|
583
601
|
return [null, offset];
|
|
584
602
|
}
|
|
585
|
-
const fixedOffset = offset + (prefix.fixedSize
|
|
603
|
+
const fixedOffset = offset + ((_a2 = prefix.fixedSize) != null ? _a2 : 0) + ((_b2 = item.fixedSize) != null ? _b2 : 0);
|
|
586
604
|
const [isSome, prefixOffset] = prefix.decode(bytes, offset);
|
|
587
605
|
offset = prefixOffset;
|
|
588
606
|
if (isSome === 0) {
|
|
@@ -608,7 +626,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
608
626
|
const maxRange = isNumericEnum ? enumValues.length / 2 - 1 : enumValues.length - 1;
|
|
609
627
|
const stringValues = isNumericEnum ? [...enumKeys] : [.../* @__PURE__ */ new Set([...enumKeys, ...enumValues])];
|
|
610
628
|
return {
|
|
611
|
-
description: description
|
|
629
|
+
description: description != null ? description : `enum(${valueDescriptions}; ${prefix.description})`,
|
|
612
630
|
enumKeys,
|
|
613
631
|
enumValues,
|
|
614
632
|
fixedSize: prefix.fixedSize,
|
|
@@ -620,7 +638,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
620
638
|
};
|
|
621
639
|
}
|
|
622
640
|
function getScalarEnumEncoder(constructor, config = {}) {
|
|
623
|
-
|
|
641
|
+
var _a;
|
|
642
|
+
const prefix = (_a = config.size) != null ? _a : getU8Encoder();
|
|
624
643
|
const { description, fixedSize, maxSize, minRange, maxRange, stringValues, enumKeys, enumValues } = scalarEnumCoderHelper(constructor, prefix, config.description);
|
|
625
644
|
return {
|
|
626
645
|
description,
|
|
@@ -644,7 +663,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
644
663
|
};
|
|
645
664
|
}
|
|
646
665
|
function getScalarEnumDecoder(constructor, config = {}) {
|
|
647
|
-
|
|
666
|
+
var _a;
|
|
667
|
+
const prefix = (_a = config.size) != null ? _a : getU8Decoder();
|
|
648
668
|
const { description, fixedSize, maxSize, minRange, maxRange, isNumericEnum, enumValues } = scalarEnumCoderHelper(
|
|
649
669
|
constructor,
|
|
650
670
|
prefix,
|
|
@@ -678,13 +698,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
678
698
|
throw new Error('Codecs of "remainder" size must have fixed-size items.');
|
|
679
699
|
}
|
|
680
700
|
return {
|
|
681
|
-
description: description
|
|
701
|
+
description: description != null ? description : `set(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
|
|
682
702
|
fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
|
|
683
703
|
maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
|
|
684
704
|
};
|
|
685
705
|
}
|
|
686
706
|
function getSetEncoder(item, config = {}) {
|
|
687
|
-
|
|
707
|
+
var _a;
|
|
708
|
+
const size = (_a = config.size) != null ? _a : getU32Encoder();
|
|
688
709
|
return {
|
|
689
710
|
...setCodecHelper(item, size, config.description),
|
|
690
711
|
encode: (set) => {
|
|
@@ -697,7 +718,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
697
718
|
};
|
|
698
719
|
}
|
|
699
720
|
function getSetDecoder(item, config = {}) {
|
|
700
|
-
|
|
721
|
+
var _a;
|
|
722
|
+
const size = (_a = config.size) != null ? _a : getU32Decoder();
|
|
701
723
|
return {
|
|
702
724
|
...setCodecHelper(item, size, config.description),
|
|
703
725
|
decode: (bytes, offset = 0) => {
|
|
@@ -724,7 +746,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
724
746
|
function structCodecHelper(fields, description) {
|
|
725
747
|
const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
|
|
726
748
|
return {
|
|
727
|
-
description: description
|
|
749
|
+
description: description != null ? description : `struct(${fieldDescriptions})`,
|
|
728
750
|
fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
|
|
729
751
|
maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
|
|
730
752
|
};
|
|
@@ -760,7 +782,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
760
782
|
function tupleCodecHelper(items, description) {
|
|
761
783
|
const itemDescriptions = items.map((item) => item.description).join(", ");
|
|
762
784
|
return {
|
|
763
|
-
description: description
|
|
785
|
+
description: description != null ? description : `tuple(${itemDescriptions})`,
|
|
764
786
|
fixedSize: sumCodecSizes(items.map((item) => item.fixedSize)),
|
|
765
787
|
maxSize: sumCodecSizes(items.map((item) => item.maxSize))
|
|
766
788
|
};
|
|
@@ -797,17 +819,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
|
|
|
797
819
|
|
|
798
820
|
// src/unit.ts
|
|
799
821
|
function getUnitEncoder(config = {}) {
|
|
822
|
+
var _a;
|
|
800
823
|
return {
|
|
801
|
-
description: config.description
|
|
824
|
+
description: (_a = config.description) != null ? _a : "unit",
|
|
802
825
|
encode: () => new Uint8Array(),
|
|
803
826
|
fixedSize: 0,
|
|
804
827
|
maxSize: 0
|
|
805
828
|
};
|
|
806
829
|
}
|
|
807
830
|
function getUnitDecoder(config = {}) {
|
|
831
|
+
var _a;
|
|
808
832
|
return {
|
|
809
833
|
decode: (_bytes, offset = 0) => [void 0, offset],
|
|
810
|
-
description: config.description
|
|
834
|
+
description: (_a = config.description) != null ? _a : "unit",
|
|
811
835
|
fixedSize: 0,
|
|
812
836
|
maxSize: 0
|
|
813
837
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../codecs-core/src/assertions.ts","../../codecs-core/src/bytes.ts","../../codecs-core/src/combine-codec.ts","../../codecs-core/src/fix-codec.ts","../../codecs-numbers/dist/index.browser.js","../src/utils.ts","../src/array-like-codec-size.ts","../src/assertions.ts","../src/array.ts","../src/bit-array.ts","../src/boolean.ts","../src/bytes.ts","../src/data-enum.ts","../src/map.ts","../src/nullable.ts","../src/scalar-enum.ts","../src/set.ts","../src/struct.ts","../src/tuple.ts","../src/unit.ts"],"names":["newOffset"],"mappings":";AAKO,SAAS,kCAAkC,kBAA0B,OAAmB,SAAS,GAAG;AACvG,MAAI,MAAM,SAAS,UAAU,GAAG;AAE5B,UAAM,IAAI,MAAM,UAAU,gBAAgB,oCAAoC;EAClF;AACJ;AAKO,SAAS,sCACZ,kBACA,UACA,OACA,SAAS,GACX;AACE,QAAM,cAAc,MA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,IACnC,QAAQ,MAAM,IAAI,WAAW;AAAA,IAC7B,WAAW;AAAA,IACX,SAAS;AAAA,EACb;AACJ;AAOO,SAAS,eAAe,SAA+B,CAAC,GAAkB;AAC7E,SAAO;AAAA,IACH,QAAQ,CAAC,QAAoB,SAAS,MAAM,CAAC,QAAW,MAAM;AAAA,IAC9D,aAAa,OAAO,eAAe;AAAA,IACnC,WAAW;AAAA,IACX,SAAS;AAAA,EACb;AACJ;AAOO,SAAS,aAAa,SAA+B,CAAC,GAAgB;AACzE,SAAO,aAAa,eAAe,MAAM,GAAG,eAAe,MAAM,CAAC;AACtE","sourcesContent":["import { CodecData } from './codec';\n\n/**\n * Asserts that a given byte array is not empty.\n */\nexport function assertByteArrayIsNotEmptyForCodec(codecDescription: string, bytes: Uint8Array, offset = 0) {\n if (bytes.length - offset <= 0) {\n // TODO: Coded error.\n throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);\n }\n}\n\n/**\n * Asserts that a given byte array has enough bytes to decode.\n */\nexport function assertByteArrayHasEnoughBytesForCodec(\n codecDescription: string,\n expected: number,\n bytes: Uint8Array,\n offset = 0\n) {\n const bytesLength = bytes.length - offset;\n if (bytesLength < expected) {\n // TODO: Coded error.\n throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);\n }\n}\n\n/**\n * Asserts that a given codec is fixed-size codec.\n */\nexport function assertFixedSizeCodec(\n data: Pick<CodecData, 'fixedSize'>,\n message?: string\n): asserts data is { fixedSize: number } {\n if (data.fixedSize === null) {\n // TODO: Coded error.\n throw new Error(message ?? 'Expected a fixed-size codec, got a variable-size one.');\n }\n}\n","/**\n * Concatenates an array of `Uint8Array`s into a single `Uint8Array`.\n * Reuses the original byte array when applicable.\n */\nexport const mergeBytes = (byteArrays: Uint8Array[]): Uint8Array => {\n const nonEmptyByteArrays = byteArrays.filter(arr => arr.length);\n if (nonEmptyByteArrays.length === 0) {\n return byteArrays.length ? byteArrays[0] : new Uint8Array();\n }\n\n if (nonEmptyByteArrays.length === 1) {\n return nonEmptyByteArrays[0];\n }\n\n const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n nonEmptyByteArrays.forEach(arr => {\n result.set(arr, offset);\n offset += arr.length;\n });\n return result;\n};\n\n/**\n * Pads a `Uint8Array` with zeroes to the specified length.\n * If the array is longer than the specified length, it is returned as-is.\n */\nexport const padBytes = (bytes: Uint8Array, length: number): Uint8Array => {\n if (bytes.length >= length) return bytes;\n const paddedBytes = new Uint8Array(length).fill(0);\n paddedBytes.set(bytes);\n return paddedBytes;\n};\n\n/**\n * Fixes a `Uint8Array` to the specified length.\n * If the array is longer than the specified length, it is truncated.\n * If the array is shorter than the specified length, it is padded with zeroes.\n */\nexport const fixBytes = (bytes: Uint8Array, length: number): Uint8Array =>\n padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);\n","import { Codec, Decoder, Encoder } from './codec';\n\n/**\n * Combines an encoder and a decoder into a codec.\n * The encoder and decoder must have the same fixed size, max size and description.\n * If a description is provided, it will override the encoder and decoder descriptions.\n */\nexport function combineCodec<From, To extends From = From>(\n encoder: Encoder<From>,\n decoder: Decoder<To>,\n description?: string\n): Codec<From, To> {\n if (encoder.fixedSize !== decoder.fixedSize) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`\n );\n }\n\n if (encoder.maxSize !== decoder.maxSize) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`\n );\n }\n\n if (description === undefined && encoder.description !== decoder.description) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. ` +\n `Pass a custom description as a third argument if you want to override the description and bypass this error.`\n );\n }\n\n return {\n decode: decoder.decode,\n description: description ?? encoder.description,\n encode: encoder.encode,\n fixedSize: encoder.fixedSize,\n maxSize: encoder.maxSize,\n };\n}\n","import { assertByteArrayHasEnoughBytesForCodec } from './assertions';\nimport { fixBytes } from './bytes';\nimport { Codec, CodecData, Decoder, Encoder } from './codec';\nimport { combineCodec } from './combine-codec';\n\nfunction fixCodecHelper(data: CodecData, fixedBytes: number, description?: string): CodecData {\n return {\n description: description ?? `fixed(${fixedBytes}, ${data.description})`,\n fixedSize: fixedBytes,\n maxSize: fixedBytes,\n };\n}\n\n/**\n * Creates a fixed-size encoder from a given encoder.\n *\n * @param encoder - The encoder to wrap into a fixed-size encoder.\n * @param fixedBytes - The fixed number of bytes to write.\n * @param description - A custom description for the encoder.\n */\nexport function fixEncoder<T>(encoder: Encoder<T>, fixedBytes: number, description?: string): Encoder<T> {\n return {\n ...fixCodecHelper(encoder, fixedBytes, description),\n encode: (value: T) => fixBytes(encoder.encode(value), fixedBytes),\n };\n}\n\n/**\n * Creates a fixed-size decoder from a given decoder.\n *\n * @param decoder - The decoder to wrap into a fixed-size decoder.\n * @param fixedBytes - The fixed number of bytes to read.\n * @param description - A custom description for the decoder.\n */\nexport function fixDecoder<T>(decoder: Decoder<T>, fixedBytes: number, description?: string): Decoder<T> {\n return {\n ...fixCodecHelper(decoder, fixedBytes, description),\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayHasEnoughBytesForCodec('fixCodec', fixedBytes, bytes, offset);\n // Slice the byte array to the fixed size if necessary.\n if (offset > 0 || bytes.length > fixedBytes) {\n bytes = bytes.slice(offset, offset + fixedBytes);\n }\n // If the nested decoder is fixed-size, pad and truncate the byte array accordingly.\n if (decoder.fixedSize !== null) {\n bytes = fixBytes(bytes, decoder.fixedSize);\n }\n // Decode the value using the nested decoder.\n const [value] = decoder.decode(bytes, 0);\n return [value, offset + fixedBytes];\n },\n };\n}\n\n/**\n * Creates a fixed-size codec from a given codec.\n *\n * @param codec - The codec to wrap into a fixed-size codec.\n * @param fixedBytes - The fixed number of bytes to read/write.\n * @param description - A custom description for the codec.\n */\nexport function fixCodec<T, U extends T = T>(\n codec: Codec<T, U>,\n fixedBytes: number,\n description?: string\n): Codec<T, U> {\n return combineCodec(fixEncoder(codec, fixedBytes, description), fixDecoder(codec, fixedBytes, description));\n}\n","import { combineCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';\n\n// src/assertions.ts\nfunction assertNumberIsBetweenForCodec(codecDescription, min, max, value) {\n if (value < min || value > max) {\n throw new Error(\n `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`\n );\n }\n}\n\n// src/common.ts\nvar Endian = /* @__PURE__ */ ((Endian2) => {\n Endian2[Endian2[\"LITTLE\"] = 0] = \"LITTLE\";\n Endian2[Endian2[\"BIG\"] = 1] = \"BIG\";\n return Endian2;\n})(Endian || {});\nfunction sharedNumberFactory(input) {\n let littleEndian;\n let defaultDescription = input.name;\n if (input.size > 1) {\n littleEndian = !(\"endian\" in input.config) || input.config.endian === 0 /* LITTLE */;\n defaultDescription += littleEndian ? \"(le)\" : \"(be)\";\n }\n return {\n description: input.config.description ?? defaultDescription,\n fixedSize: input.size,\n littleEndian,\n maxSize: input.size\n };\n}\nfunction numberEncoderFactory(input) {\n const codecData = sharedNumberFactory(input);\n return {\n description: codecData.description,\n encode(value) {\n if (input.range) {\n assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);\n }\n const arrayBuffer = new ArrayBuffer(input.size);\n input.set(new DataView(arrayBuffer), value, codecData.littleEndian);\n return new Uint8Array(arrayBuffer);\n },\n fixedSize: codecData.fixedSize,\n maxSize: codecData.maxSize\n };\n}\nfunction numberDecoderFactory(input) {\n const codecData = sharedNumberFactory(input);\n return {\n decode(bytes, offset = 0) {\n assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);\n assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);\n const view = new DataView(toArrayBuffer(bytes, offset, input.size));\n return [input.get(view, codecData.littleEndian), offset + input.size];\n },\n description: codecData.description,\n fixedSize: codecData.fixedSize,\n maxSize: codecData.maxSize\n };\n}\nfunction toArrayBuffer(bytes, offset, length) {\n const bytesOffset = bytes.byteOffset + (offset ?? 0);\n const bytesLength = length ?? bytes.byteLength;\n return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);\n}\n\n// src/f32.ts\nvar getF32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f32\",\n set: (view, value, le) => view.setFloat32(0, value, le),\n size: 4\n});\nvar getF32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat32(0, le),\n name: \"f32\",\n size: 4\n});\nvar getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));\nvar getF64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f64\",\n set: (view, value, le) => view.setFloat64(0, value, le),\n size: 8\n});\nvar getF64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat64(0, le),\n name: \"f64\",\n size: 8\n});\nvar getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));\nvar getI128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i128\",\n range: [-BigInt(\"0x7fffffffffffffffffffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigInt64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getI128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigInt64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"i128\",\n size: 16\n});\nvar getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));\nvar getI16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i16\",\n range: [-Number(\"0x7fff\") - 1, Number(\"0x7fff\")],\n set: (view, value, le) => view.setInt16(0, value, le),\n size: 2\n});\nvar getI16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt16(0, le),\n name: \"i16\",\n size: 2\n});\nvar getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));\nvar getI32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i32\",\n range: [-Number(\"0x7fffffff\") - 1, Number(\"0x7fffffff\")],\n set: (view, value, le) => view.setInt32(0, value, le),\n size: 4\n});\nvar getI32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt32(0, le),\n name: \"i32\",\n size: 4\n});\nvar getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));\nvar getI64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i64\",\n range: [-BigInt(\"0x7fffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffff\")],\n set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),\n size: 8\n});\nvar getI64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigInt64(0, le),\n name: \"i64\",\n size: 8\n});\nvar getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));\nvar getI8Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i8\",\n range: [-Number(\"0x7f\") - 1, Number(\"0x7f\")],\n set: (view, value) => view.setInt8(0, value),\n size: 1\n});\nvar getI8Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view) => view.getInt8(0),\n name: \"i8\",\n size: 1\n});\nvar getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));\nvar getShortU16Encoder = (config = {}) => ({\n description: config.description ?? \"shortU16\",\n encode: (value) => {\n assertNumberIsBetweenForCodec(\"shortU16\", 0, 65535, value);\n const bytes = [0];\n for (let ii = 0; ; ii += 1) {\n const alignedValue = value >> ii * 7;\n if (alignedValue === 0) {\n break;\n }\n const nextSevenBits = 127 & alignedValue;\n bytes[ii] = nextSevenBits;\n if (ii > 0) {\n bytes[ii - 1] |= 128;\n }\n }\n return new Uint8Array(bytes);\n },\n fixedSize: null,\n maxSize: 3\n});\nvar getShortU16Decoder = (config = {}) => ({\n decode: (bytes, offset = 0) => {\n let value = 0;\n let byteCount = 0;\n while (++byteCount) {\n const byteIndex = byteCount - 1;\n const currentByte = bytes[offset + byteIndex];\n const nextSevenBits = 127 & currentByte;\n value |= nextSevenBits << byteIndex * 7;\n if ((currentByte & 128) === 0) {\n break;\n }\n }\n return [value, offset + byteCount];\n },\n description: config.description ?? \"shortU16\",\n fixedSize: null,\n maxSize: 3\n});\nvar getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));\nvar getU128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u128\",\n range: [0, BigInt(\"0xffffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigUint64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getU128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigUint64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"u128\",\n size: 16\n});\nvar getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));\nvar getU16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u16\",\n range: [0, Number(\"0xffff\")],\n set: (view, value, le) => view.setUint16(0, value, le),\n size: 2\n});\nvar getU16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint16(0, le),\n name: \"u16\",\n size: 2\n});\nvar getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));\nvar getU32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u32\",\n range: [0, Number(\"0xffffffff\")],\n set: (view, value, le) => view.setUint32(0, value, le),\n size: 4\n});\nvar getU32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint32(0, le),\n name: \"u32\",\n size: 4\n});\nvar getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));\nvar getU64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u64\",\n range: [0, BigInt(\"0xffffffffffffffff\")],\n set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),\n size: 8\n});\nvar getU64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigUint64(0, le),\n name: \"u64\",\n size: 8\n});\nvar getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));\nvar getU8Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u8\",\n range: [0, Number(\"0xff\")],\n set: (view, value) => view.setUint8(0, value),\n size: 1\n});\nvar getU8Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view) => view.getUint8(0),\n name: \"u8\",\n size: 1\n});\nvar getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));\n\nexport { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };\n","/** Returns the max size or null if at least one size is null. */\nexport function maxCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce(\n (all, size) => (all === null || size === null ? null : Math.max(all, size)),\n 0 as number | null\n );\n}\n\n/** Returns the sum of all sizes or null if at least one size is null. */\nexport function sumCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce((all, size) => (all === null || size === null ? null : all + size), 0 as number | null);\n}\n","import { CodecData, Offset } from '@solana/codecs-core';\nimport { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { sumCodecSizes } from './utils';\n\n/**\n * Represents all the size options for array-like codecs\n * — i.e. `array`, `map` and `set`.\n *\n * It can be one of the following:\n * - a {@link NumberCodec} that prefixes its content with its size.\n * - a fixed number of items.\n * - or `'remainder'` to infer the number of items by dividing\n * the rest of the byte array by the fixed size of its item.\n * Note that this option is only available for fixed-size items.\n */\nexport type ArrayLikeCodecSize<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder | CodecData> =\n | TPrefix\n | number\n | 'remainder';\n\n/** Resolves the size of an array-like codec. */\nexport function decodeArrayLikeCodecSize(\n size: ArrayLikeCodecSize<NumberDecoder>,\n childrenSizes: (number | null)[],\n bytes: Uint8Array,\n offset: Offset\n): [number | bigint, Offset] {\n if (typeof size === 'number') {\n return [size, offset];\n }\n\n if (typeof size === 'object') {\n return size.decode(bytes, offset);\n }\n\n if (size === 'remainder') {\n const childrenSize = sumCodecSizes(childrenSizes);\n if (childrenSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n const remainder = bytes.slice(offset).length;\n if (remainder % childrenSize !== 0) {\n // TODO: Coded error.\n throw new Error(\n `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. ` +\n `Codecs of \"remainder\" size must have a remainder that is a multiple of its item size. ` +\n `In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`\n );\n }\n return [remainder / childrenSize, offset];\n }\n\n // TODO: Coded error.\n throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);\n}\n\nexport function getArrayLikeCodecSizeDescription(size: ArrayLikeCodecSize<CodecData>): string {\n return typeof size === 'object' ? size.description : `${size}`;\n}\n\nexport function getArrayLikeCodecSizeFromChildren(\n size: ArrayLikeCodecSize<CodecData>,\n childrenSizes: (number | null)[]\n): number | null {\n if (typeof size !== 'number') return null;\n if (size === 0) return 0;\n const childrenSize = sumCodecSizes(childrenSizes);\n return childrenSize === null ? null : childrenSize * size;\n}\n\nexport function getArrayLikeCodecSizePrefix(size: ArrayLikeCodecSize<NumberEncoder>, realSize: number): Uint8Array {\n return typeof size === 'object' ? size.encode(realSize) : new Uint8Array();\n}\n","/** Checks the number of items in an array-like structure is expected. */\nexport function assertValidNumberOfItemsForCodec(\n codecDescription: string,\n expected: number | bigint,\n actual: number | bigint\n) {\n if (expected !== actual) {\n // TODO: Coded error.\n throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);\n }\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the configs for array codecs. */\nexport type ArrayCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the array.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction arrayCodecHelper(item: CodecData, size: ArrayLikeCodecSize<CodecData>, description?: string): CodecData {\n if (size === 'remainder' && item.fixedSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize]),\n };\n}\n\n/**\n * Encodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayEncoder<T>(item: Encoder<T>, config: ArrayCodecConfig<NumberEncoder> = {}): Encoder<T[]> {\n const size = config.size ?? getU32Encoder();\n return {\n ...arrayCodecHelper(item, size, config.description),\n encode: (value: T[]) => {\n if (typeof size === 'number') {\n assertValidNumberOfItemsForCodec('array', size, value.length);\n }\n return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map(v => item.encode(v))]);\n },\n };\n}\n\n/**\n * Decodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayDecoder<T>(item: Decoder<T>, config: ArrayCodecConfig<NumberDecoder> = {}): Decoder<T[]> {\n const size = config.size ?? getU32Decoder();\n return {\n ...arrayCodecHelper(item, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [[], offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);\n offset = newOffset;\n const values: T[] = [];\n for (let i = 0; i < resolvedSize; i += 1) {\n const [value, newOffset] = item.decode(bytes, offset);\n values.push(value);\n offset = newOffset;\n }\n return [values, offset];\n },\n };\n}\n\n/**\n * Creates a codec for an array of items.\n *\n * @param item - The codec to use for the array's items.\n * @param config - A set of config for the codec.\n */\nexport function getArrayCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: ArrayCodecConfig<NumberCodec> = {}\n): Codec<T[], U[]> {\n return combineCodec(getArrayEncoder(item, config), getArrayDecoder(item, config));\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\n\n/** Defines the config for bitArray codecs. */\nexport type BitArrayCodecConfig = BaseCodecConfig & {\n /**\n * Whether to read the bits in reverse order.\n * @defaultValue `false`\n */\n backward?: boolean;\n};\n\n/**\n * Encodes an array of booleans into bits.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the encoder.\n */\nexport const getBitArrayEncoder = (size: number, config: BitArrayCodecConfig | boolean = {}): Encoder<boolean[]> => {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n const backwardSuffix = backward ? '; backward' : '';\n return {\n description: parsedConfig.description ?? `bitArray(${size}${backwardSuffix})`,\n encode(value: boolean[]) {\n const bytes: number[] = [];\n\n for (let i = 0; i < size; i += 1) {\n let byte = 0;\n for (let j = 0; j < 8; j += 1) {\n const feature = Number(value[i * 8 + j] ?? 0);\n byte |= feature << (backward ? j : 7 - j);\n }\n if (backward) {\n bytes.unshift(byte);\n } else {\n bytes.push(byte);\n }\n }\n\n return new Uint8Array(bytes);\n },\n fixedSize: size,\n maxSize: size,\n };\n};\n\n/**\n * Decodes bits into an array of booleans.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the decoder.\n */\nexport const getBitArrayDecoder = (size: number, config: BitArrayCodecConfig | boolean = {}): Decoder<boolean[]> => {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n const backwardSuffix = backward ? '; backward' : '';\n return {\n decode(bytes, offset = 0) {\n assertByteArrayHasEnoughBytesForCodec('bitArray', size, bytes, offset);\n const booleans: boolean[] = [];\n let slice = bytes.slice(offset, offset + size);\n slice = backward ? slice.reverse() : slice;\n\n slice.forEach(byte => {\n for (let i = 0; i < 8; i += 1) {\n if (backward) {\n booleans.push(Boolean(byte & 1));\n byte >>= 1;\n } else {\n booleans.push(Boolean(byte & 0b1000_0000));\n byte <<= 1;\n }\n }\n });\n\n return [booleans, offset + size];\n },\n description: parsedConfig.description ?? `bitArray(${size}${backwardSuffix})`,\n fixedSize: size,\n maxSize: size,\n };\n};\n\n/**\n * An array of boolean codec that converts booleans to bits and vice versa.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the codec.\n */\nexport const getBitArrayCodec = (size: number, config: BitArrayCodecConfig | boolean = {}): Codec<boolean[]> =>\n combineCodec(getBitArrayEncoder(size, config), getBitArrayDecoder(size, config));\n","import {\n assertByteArrayIsNotEmptyForCodec,\n assertFixedSizeCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/** Defines the config for boolean codecs. */\nexport type BooleanCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The number codec to delegate to.\n * @defaultValue u8 size.\n */\n size?: TSize;\n};\n\n/**\n * Encodes booleans.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBooleanEncoder(config: BooleanCodecConfig<NumberEncoder> = {}): Encoder<boolean> {\n const size = config.size ?? getU8Encoder();\n assertFixedSizeCodec(size, 'Codec [bool] requires a fixed size.');\n\n return {\n description: config.description ?? `bool(${size.description})`,\n encode: (value: boolean) => size.encode(value ? 1 : 0),\n fixedSize: size.fixedSize,\n maxSize: size.fixedSize,\n };\n}\n\n/**\n * Decodes booleans.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBooleanDecoder(config: BooleanCodecConfig<NumberDecoder> = {}): Decoder<boolean> {\n const size = config.size ?? getU8Decoder();\n assertFixedSizeCodec(size, 'Codec [bool] requires a fixed size.');\n\n return {\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('bool', bytes, offset);\n const [value, vOffset] = size.decode(bytes, offset);\n return [value === 1, vOffset];\n },\n description: config.description ?? `bool(${size.description})`,\n fixedSize: size.fixedSize,\n maxSize: size.fixedSize,\n };\n}\n\n/**\n * Creates a boolean codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBooleanCodec(config: BooleanCodecConfig<NumberCodec> = {}): Codec<boolean> {\n return combineCodec(getBooleanEncoder(config), getBooleanDecoder(config));\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n fixDecoder,\n fixEncoder,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/** Defines the config for bytes codecs. */\nexport type BytesCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the byte array. It can be one of the following:\n * - a {@link NumberSerializer} that prefixes the byte array with its size.\n * - a fixed number of bytes.\n * - or `'variable'` to use the rest of the byte array.\n * @defaultValue `'variable'`\n */\n size?: TSize | number | 'variable';\n};\n\n/**\n * Encodes sized bytes.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBytesEncoder(config: BytesCodecConfig<NumberEncoder> = {}): Encoder<Uint8Array> {\n const size = config.size ?? 'variable';\n const sizeDescription = typeof size === 'object' ? size.description : `${size}`;\n const description = config.description ?? `bytes(${sizeDescription})`;\n\n const byteEncoder: Encoder<Uint8Array> = {\n description,\n encode: (value: Uint8Array) => value,\n fixedSize: null,\n maxSize: null,\n };\n\n if (size === 'variable') {\n return byteEncoder;\n }\n\n if (typeof size === 'number') {\n return fixEncoder(byteEncoder, size, description);\n }\n\n return {\n ...byteEncoder,\n encode: (value: Uint8Array) => {\n const contentBytes = byteEncoder.encode(value);\n const lengthBytes = size.encode(contentBytes.length);\n return mergeBytes([lengthBytes, contentBytes]);\n },\n };\n}\n\n/**\n * Decodes sized bytes.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBytesDecoder(config: BytesCodecConfig<NumberDecoder> = {}): Decoder<Uint8Array> {\n const size = config.size ?? 'variable';\n const sizeDescription = typeof size === 'object' ? size.description : `${size}`;\n const description = config.description ?? `bytes(${sizeDescription})`;\n\n const byteDecoder: Decoder<Uint8Array> = {\n decode: (bytes: Uint8Array, offset = 0) => {\n const slice = bytes.slice(offset);\n return [slice, offset + slice.length];\n },\n description,\n fixedSize: null,\n maxSize: null,\n };\n\n if (size === 'variable') {\n return byteDecoder;\n }\n\n if (typeof size === 'number') {\n return fixDecoder(byteDecoder, size, description);\n }\n\n return {\n ...byteDecoder,\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('bytes', bytes, offset);\n const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);\n const length = Number(lengthBigInt);\n offset = lengthOffset;\n const contentBytes = bytes.slice(offset, offset + length);\n assertByteArrayHasEnoughBytesForCodec('bytes', length, contentBytes);\n const [value, contentOffset] = byteDecoder.decode(contentBytes);\n offset += contentOffset;\n return [value, offset];\n },\n };\n}\n\n/**\n * Creates a sized bytes codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBytesCodec(config: BytesCodecConfig<NumberCodec> = {}): Codec<Uint8Array> {\n return combineCodec(getBytesEncoder(config), getBytesDecoder(config));\n}\n","import {\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { maxCodecSizes, sumCodecSizes } from './utils';\n\n/**\n * Defines a data enum using discriminated union types.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * ```\n */\nexport type DataEnum = { __kind: string };\n\n/**\n * Extracts a variant from a data enum.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * type ClickEvent = GetDataEnumKind<WebPageEvent, 'click'>;\n * // -> { __kind: 'click', x: number, y: number }\n * ```\n */\nexport type GetDataEnumKind<T extends DataEnum, K extends T['__kind']> = Extract<T, { __kind: K }>;\n\n/**\n * Extracts a variant from a data enum without its discriminator.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * type ClickEvent = GetDataEnumKindContent<WebPageEvent, 'click'>;\n * // -> { x: number, y: number }\n * ```\n */\nexport type GetDataEnumKindContent<T extends DataEnum, K extends T['__kind']> = Omit<\n Extract<T, { __kind: K }>,\n '__kind'\n>;\n\n/** Get the name and codec of each variant in a data enum. */\nexport type DataEnumToCodecTuple<T extends DataEnum, U extends T = T> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Codec<Omit<T, '__kind'>, Omit<U, '__kind'>> | Codec<void>\n : Codec<Omit<T, '__kind'>, Omit<U, '__kind'>>\n ]\n>;\n\n/** Get the name and encoder of each variant in a data enum. */\nexport type DataEnumToEncoderTuple<T extends DataEnum> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Encoder<Omit<T, '__kind'>> | Encoder<void>\n : Encoder<Omit<T, '__kind'>>\n ]\n>;\n\n/** Get the name and decoder of each variant in a data enum. */\nexport type DataEnumToDecoderTuple<T extends DataEnum> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Decoder<Omit<T, '__kind'>> | Decoder<void>\n : Decoder<Omit<T, '__kind'>>\n ]\n>;\n\n/** Defines the config for data enum codecs. */\nexport type DataEnumCodecConfig<TDiscriminator = NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The codec to use for the enum discriminator prefixing the variant.\n * @defaultValue u8 prefix.\n */\n size?: TDiscriminator;\n};\n\nfunction dataEnumCodecHelper(variants: Array<[string, CodecData]>, prefix: CodecData, description?: string): CodecData {\n const fieldDescriptions = variants\n .map(([name, codec]) => `${String(name)}${codec ? `: ${codec.description}` : ''}`)\n .join(', ');\n const allVariantHaveTheSameFixedSize = variants.every((one, _i, all) => one[1].fixedSize === all[0][1].fixedSize);\n const fixedVariantSize = allVariantHaveTheSameFixedSize ? variants[0][1].fixedSize : null;\n const maxVariantSize = maxCodecSizes(variants.map(([, field]) => field.maxSize));\n\n return {\n description: description ?? `dataEnum(${fieldDescriptions}; ${prefix.description})`,\n fixedSize: variants.length === 0 ? prefix.fixedSize : sumCodecSizes([prefix.fixedSize, fixedVariantSize]),\n maxSize: variants.length === 0 ? prefix.maxSize : sumCodecSizes([prefix.maxSize, maxVariantSize]),\n };\n}\n\n/**\n * Creates a data enum encoder.\n *\n * @param variants - The variant encoders of the data enum.\n * @param config - A set of config for the encoder.\n */\nexport function getDataEnumEncoder<T extends DataEnum>(\n variants: DataEnumToEncoderTuple<T>,\n config: DataEnumCodecConfig<NumberEncoder> = {}\n): Encoder<T> {\n const prefix = config.size ?? getU8Encoder();\n return {\n ...dataEnumCodecHelper(variants, prefix, config.description),\n encode: (variant: T) => {\n const discriminator = variants.findIndex(([key]) => variant.__kind === key);\n if (discriminator < 0) {\n // TODO: Coded error.\n throw new Error(\n `Invalid data enum variant. ` +\n `Expected one of [${variants.map(([key]) => key).join(', ')}], ` +\n `got \"${variant.__kind}\".`\n );\n }\n const variantPrefix = prefix.encode(discriminator);\n const variantSerializer = variants[discriminator][1];\n const variantBytes = variantSerializer.encode(variant as void & T);\n return mergeBytes([variantPrefix, variantBytes]);\n },\n };\n}\n\n/**\n * Creates a data enum decoder.\n *\n * @param variants - The variant decoders of the data enum.\n * @param config - A set of config for the decoder.\n */\nexport function getDataEnumDecoder<T extends DataEnum>(\n variants: DataEnumToDecoderTuple<T>,\n config: DataEnumCodecConfig<NumberDecoder> = {}\n): Decoder<T> {\n const prefix = config.size ?? getU8Decoder();\n return {\n ...dataEnumCodecHelper(variants, prefix, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('dataEnum', bytes, offset);\n const [discriminator, dOffset] = prefix.decode(bytes, offset);\n offset = dOffset;\n const variantField = variants[Number(discriminator)] ?? null;\n if (!variantField) {\n // TODO: Coded error.\n throw new Error(\n `Enum discriminator out of range. ` +\n `Expected a number between 0 and ${variants.length - 1}, got ${discriminator}.`\n );\n }\n const [variant, vOffset] = variantField[1].decode(bytes, offset);\n offset = vOffset;\n return [{ __kind: variantField[0], ...(variant ?? {}) } as T, offset];\n },\n };\n}\n\n/**\n * Creates a data enum codec.\n *\n * @param variants - The variant codecs of the data enum.\n * @param config - A set of config for the codec.\n */\nexport function getDataEnumCodec<T extends DataEnum, U extends T = T>(\n variants: DataEnumToCodecTuple<T, U>,\n config: DataEnumCodecConfig<NumberCodec> = {}\n): Codec<T, U> {\n return combineCodec(getDataEnumEncoder<T>(variants, config), getDataEnumDecoder<U>(variants, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the config for Map codecs. */\nexport type MapCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the array.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction mapCodecHelper(\n key: CodecData,\n value: CodecData,\n size: ArrayLikeCodecSize<CodecData>,\n description?: string\n): CodecData {\n if (size === 'remainder' && (key.fixedSize === null || value.fixedSize === null)) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description:\n description ?? `map(${key.description}, ${value.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [key.fixedSize, value.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [key.maxSize, value.maxSize]),\n };\n}\n\n/**\n * Creates a encoder for a map.\n *\n * @param key - The encoder to use for the map's keys.\n * @param value - The encoder to use for the map's values.\n * @param config - A set of config for the encoder.\n */\nexport function getMapEncoder<K, V>(\n key: Encoder<K>,\n value: Encoder<V>,\n config: MapCodecConfig<NumberEncoder> = {}\n): Encoder<Map<K, V>> {\n const size = config.size ?? getU32Encoder();\n return {\n ...mapCodecHelper(key, value, size, config.description),\n encode: (map: Map<K, V>) => {\n if (typeof size === 'number') {\n assertValidNumberOfItemsForCodec('map', size, map.size);\n }\n const itemBytes = Array.from(map, ([k, v]) => mergeBytes([key.encode(k), value.encode(v)]));\n return mergeBytes([getArrayLikeCodecSizePrefix(size, map.size), ...itemBytes]);\n },\n };\n}\n\n/**\n * Creates a decoder for a map.\n *\n * @param key - The decoder to use for the map's keys.\n * @param value - The decoder to use for the map's values.\n * @param config - A set of config for the decoder.\n */\nexport function getMapDecoder<K, V>(\n key: Decoder<K>,\n value: Decoder<V>,\n config: MapCodecConfig<NumberDecoder> = {}\n): Decoder<Map<K, V>> {\n const size = config.size ?? getU32Decoder();\n return {\n ...mapCodecHelper(key, value, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const map: Map<K, V> = new Map();\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [map, offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(\n size,\n [key.fixedSize, value.fixedSize],\n bytes,\n offset\n );\n offset = newOffset;\n for (let i = 0; i < resolvedSize; i += 1) {\n const [decodedKey, kOffset] = key.decode(bytes, offset);\n offset = kOffset;\n const [decodedValue, vOffset] = value.decode(bytes, offset);\n offset = vOffset;\n map.set(decodedKey, decodedValue);\n }\n return [map, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a map.\n *\n * @param key - The codec to use for the map's keys.\n * @param value - The codec to use for the map's values.\n * @param config - A set of config for the codec.\n */\nexport function getMapCodec<TK, TV, UK extends TK = TK, UV extends TV = TV>(\n key: Codec<TK, UK>,\n value: Codec<TV, UV>,\n config: MapCodecConfig<NumberCodec> = {}\n): Codec<Map<TK, TV>, Map<UK, UV>> {\n return combineCodec(getMapEncoder(key, value, config), getMapDecoder(key, value, config));\n}\n","import {\n assertFixedSizeCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n fixBytes,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { sumCodecSizes } from './utils';\n\n/** Defines the config for nullable codecs. */\nexport type NullableCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The codec to use for the boolean prefix.\n * @defaultValue u8 prefix.\n */\n prefix?: TPrefix;\n\n /**\n * Whether the item codec should be of fixed size.\n *\n * When this is true, a `null` value will skip the bytes that would\n * have been used for the item. Note that this will only work if the\n * item codec is of fixed size.\n * @defaultValue `false`\n */\n fixed?: boolean;\n};\n\nfunction nullableCodecHelper(item: CodecData, prefix: CodecData, fixed: boolean, description?: string): CodecData {\n let descriptionSuffix = `; ${prefix.description}`;\n let fixedSize = item.fixedSize === 0 ? prefix.fixedSize : null;\n if (fixed) {\n assertFixedSizeCodec(item, 'Fixed nullables can only be used with fixed-size codecs.');\n assertFixedSizeCodec(prefix, 'Fixed nullables can only be used with fixed-size prefix.');\n descriptionSuffix += '; fixed';\n fixedSize = prefix.fixedSize + item.fixedSize;\n }\n\n return {\n description: description ?? `nullable(${item.description + descriptionSuffix})`,\n fixedSize,\n maxSize: sumCodecSizes([prefix.maxSize, item.maxSize]),\n };\n}\n\n/**\n * Creates a encoder for an optional value using `null` as the `None` value.\n *\n * @param item - The encoder to use for the value that may be present.\n * @param config - A set of config for the encoder.\n */\nexport function getNullableEncoder<T>(\n item: Encoder<T>,\n config: NullableCodecConfig<NumberEncoder> = {}\n): Encoder<T | null> {\n const prefix = config.prefix ?? getU8Encoder();\n const fixed = config.fixed ?? false;\n return {\n ...nullableCodecHelper(item, prefix, fixed, config.description),\n encode: (option: T | null) => {\n const prefixByte = prefix.encode(Number(option !== null));\n let itemBytes = option !== null ? item.encode(option) : new Uint8Array();\n itemBytes = fixed ? fixBytes(itemBytes, item.fixedSize as number) : itemBytes;\n return mergeBytes([prefixByte, itemBytes]);\n },\n };\n}\n\n/**\n * Creates a decoder for an optional value using `null` as the `None` value.\n *\n * @param item - The decoder to use for the value that may be present.\n * @param config - A set of config for the decoder.\n */\nexport function getNullableDecoder<T>(\n item: Decoder<T>,\n config: NullableCodecConfig<NumberDecoder> = {}\n): Decoder<T | null> {\n const prefix = config.prefix ?? getU8Decoder();\n const fixed = config.fixed ?? false;\n return {\n ...nullableCodecHelper(item, prefix, fixed, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n if (bytes.length - offset <= 0) {\n return [null, offset];\n }\n const fixedOffset = offset + (prefix.fixedSize ?? 0) + (item.fixedSize ?? 0);\n const [isSome, prefixOffset] = prefix.decode(bytes, offset);\n offset = prefixOffset;\n if (isSome === 0) {\n return [null, fixed ? fixedOffset : offset];\n }\n const [value, newOffset] = item.decode(bytes, offset);\n offset = newOffset;\n return [value, fixed ? fixedOffset : offset];\n },\n };\n}\n\n/**\n * Creates a codec for an optional value using `null` as the `None` value.\n *\n * @param item - The codec to use for the value that may be present.\n * @param config - A set of config for the codec.\n */\nexport function getNullableCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: NullableCodecConfig<NumberCodec> = {}\n): Codec<T | null, U | null> {\n return combineCodec(getNullableEncoder<T>(item, config), getNullableDecoder<U>(item, config));\n}\n","import {\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/**\n * Defines a scalar enum as a type from its constructor.\n *\n * @example\n * ```ts\n * enum Direction { Left, Right };\n * type DirectionType = ScalarEnum<Direction>;\n * ```\n */\nexport type ScalarEnum<T> = ({ [key: number | string]: string | number | T } | number | T) & NonNullable<unknown>;\n\n/** Defines the config for scalar enum codecs. */\nexport type ScalarEnumCodecConfig<TDiscriminator extends NumberCodec | NumberEncoder | NumberDecoder> =\n BaseCodecConfig & {\n /**\n * The codec to use for the enum discriminator.\n * @defaultValue u8 discriminator.\n */\n size?: TDiscriminator;\n };\n\nfunction scalarEnumCoderHelper<T>(\n constructor: ScalarEnum<T>,\n prefix: CodecData,\n description?: string\n): CodecData & {\n enumKeys: string[];\n enumValues: T[];\n isNumericEnum: boolean;\n minRange: number;\n maxRange: number;\n stringValues: string[];\n} {\n const enumKeys = Object.keys(constructor);\n const enumValues = Object.values(constructor);\n const isNumericEnum = enumValues.some(v => typeof v === 'number');\n const valueDescriptions = enumValues.filter(v => typeof v === 'string').join(', ');\n const minRange = 0;\n const maxRange = isNumericEnum ? enumValues.length / 2 - 1 : enumValues.length - 1;\n const stringValues: string[] = isNumericEnum ? [...enumKeys] : [...new Set([...enumKeys, ...enumValues])];\n\n return {\n description: description ?? `enum(${valueDescriptions}; ${prefix.description})`,\n enumKeys,\n enumValues,\n fixedSize: prefix.fixedSize,\n isNumericEnum,\n maxRange,\n maxSize: prefix.maxSize,\n minRange,\n stringValues,\n };\n}\n\n/**\n * Creates a scalar enum encoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the encoder.\n */\nexport function getScalarEnumEncoder<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberEncoder> = {}\n): Encoder<T> {\n const prefix = config.size ?? getU8Encoder();\n const { description, fixedSize, maxSize, minRange, maxRange, stringValues, enumKeys, enumValues } =\n scalarEnumCoderHelper(constructor, prefix, config.description);\n return {\n description,\n encode: (value: T) => {\n const isInvalidNumber = typeof value === 'number' && (value < minRange || value > maxRange);\n const isInvalidString = typeof value === 'string' && !stringValues.includes(value);\n if (isInvalidNumber || isInvalidString) {\n // TODO: Coded error.\n throw new Error(\n `Invalid scalar enum variant. ` +\n `Expected one of [${stringValues.join(', ')}] ` +\n `or a number between ${minRange} and ${maxRange}, ` +\n `got \"${value}\".`\n );\n }\n if (typeof value === 'number') return prefix.encode(value);\n const valueIndex = enumValues.indexOf(value);\n if (valueIndex >= 0) return prefix.encode(valueIndex);\n return prefix.encode(enumKeys.indexOf(value as string));\n },\n fixedSize,\n maxSize,\n };\n}\n\n/**\n * Creates a scalar enum decoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the decoder.\n */\nexport function getScalarEnumDecoder<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberDecoder> = {}\n): Decoder<T> {\n const prefix = config.size ?? getU8Decoder();\n const { description, fixedSize, maxSize, minRange, maxRange, isNumericEnum, enumValues } = scalarEnumCoderHelper(\n constructor,\n prefix,\n config.description\n );\n return {\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('enum', bytes, offset);\n const [value, newOffset] = prefix.decode(bytes, offset);\n const valueAsNumber = Number(value);\n offset = newOffset;\n if (valueAsNumber < minRange || valueAsNumber > maxRange) {\n // TODO: Coded error.\n throw new Error(\n `Enum discriminator out of range. ` +\n `Expected a number between ${minRange} and ${maxRange}, got ${valueAsNumber}.`\n );\n }\n return [(isNumericEnum ? valueAsNumber : enumValues[valueAsNumber]) as T, offset];\n },\n description,\n fixedSize,\n maxSize,\n };\n}\n\n/**\n * Creates a scalar enum codec.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the codec.\n */\nexport function getScalarEnumCodec<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberCodec> = {}\n): Codec<T> {\n return combineCodec(getScalarEnumEncoder(constructor, config), getScalarEnumDecoder(constructor, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the config for set codecs. */\nexport type SetCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the set.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction setCodecHelper(item: CodecData, size: ArrayLikeCodecSize<CodecData>, description?: string): CodecData {\n if (size === 'remainder' && item.fixedSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description: description ?? `set(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize]),\n };\n}\n\n/**\n * Encodes an set of items.\n *\n * @param item - The encoder to use for the set's items.\n * @param config - A set of config for the encoder.\n */\nexport function getSetEncoder<T>(item: Encoder<T>, config: SetCodecConfig<NumberEncoder> = {}): Encoder<Set<T>> {\n const size = config.size ?? getU32Encoder();\n return {\n ...setCodecHelper(item, size, config.description),\n encode: (set: Set<T>) => {\n if (typeof size === 'number' && set.size !== size) {\n assertValidNumberOfItemsForCodec('set', size, set.size);\n }\n const itemBytes = Array.from(set, value => item.encode(value));\n return mergeBytes([getArrayLikeCodecSizePrefix(size, set.size), ...itemBytes]);\n },\n };\n}\n\n/**\n * Decodes an set of items.\n *\n * @param item - The encoder to use for the set's items.\n * @param config - A set of config for the encoder.\n */\nexport function getSetDecoder<T>(item: Decoder<T>, config: SetCodecConfig<NumberDecoder> = {}): Decoder<Set<T>> {\n const size = config.size ?? getU32Decoder();\n return {\n ...setCodecHelper(item, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const set: Set<T> = new Set();\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [set, offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);\n offset = newOffset;\n for (let i = 0; i < resolvedSize; i += 1) {\n const [value, newOffset] = item.decode(bytes, offset);\n offset = newOffset;\n set.add(value);\n }\n return [set, offset];\n },\n };\n}\n\n/**\n * Creates a codec for an set of items.\n *\n * @param item - The codec to use for the set's items.\n * @param config - A set of config for the codec.\n */\nexport function getSetCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: SetCodecConfig<NumberCodec> = {}\n): Codec<Set<T>, Set<U>> {\n return combineCodec(getSetEncoder(item, config), getSetDecoder(item, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\n\nimport { sumCodecSizes } from './utils';\n\n/** Get the name and encoder of each field in a struct. */\nexport type StructToEncoderTuple<T extends object> = Array<\n {\n [K in keyof T]: [K, Encoder<T[K]>];\n }[keyof T]\n>;\n\n/** Get the name and decoder of each field in a struct. */\nexport type StructToDecoderTuple<T extends object> = Array<\n {\n [K in keyof T]: [K, Decoder<T[K]>];\n }[keyof T]\n>;\n\n/** Get the name and codec of each field in a struct. */\nexport type StructToCodecTuple<T extends object, U extends T> = Array<\n {\n [K in keyof T]: [K, Codec<T[K], U[K]>];\n }[keyof T]\n>;\n\n/** Defines the config for struct codecs. */\nexport type StructCodecConfig = BaseCodecConfig;\n\nfunction structCodecHelper(fields: Array<[string | number | symbol, CodecData]>, description?: string): CodecData {\n const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(', ');\n\n return {\n description: description ?? `struct(${fieldDescriptions})`,\n fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),\n maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize)),\n };\n}\n\n/**\n * Creates a encoder for a custom object.\n *\n * @param fields - The name and encoder of each field.\n * @param config - A set of config for the encoder.\n */\nexport function getStructEncoder<T extends object>(\n fields: StructToEncoderTuple<T>,\n config: StructCodecConfig = {}\n): Encoder<T> {\n return {\n ...structCodecHelper(fields, config.description),\n encode: (struct: T) => {\n const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));\n return mergeBytes(fieldBytes);\n },\n };\n}\n\n/**\n * Creates a decoder for a custom object.\n *\n * @param fields - The name and decoder of each field.\n * @param config - A set of config for the decoder.\n */\nexport function getStructDecoder<T extends object>(\n fields: StructToDecoderTuple<T>,\n config: StructCodecConfig = {}\n): Decoder<T> {\n return {\n ...structCodecHelper(fields, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const struct: Partial<T> = {};\n fields.forEach(([key, codec]) => {\n const [value, newOffset] = codec.decode(bytes, offset);\n offset = newOffset;\n struct[key] = value;\n });\n return [struct as T, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a custom object.\n *\n * @param fields - The name and codec of each field.\n * @param config - A set of config for the codec.\n */\nexport function getStructCodec<T extends object, U extends T = T>(\n fields: StructToCodecTuple<T, U>,\n config: StructCodecConfig = {}\n): Codec<T, U> {\n return combineCodec(getStructEncoder(fields, config), getStructDecoder(fields, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\n\nimport { assertValidNumberOfItemsForCodec } from './assertions';\nimport { sumCodecSizes } from './utils';\n\n/** Defines the config for tuple codecs. */\nexport type TupleCodecConfig = BaseCodecConfig;\n\ntype WrapInEncoder<T> = {\n [P in keyof T]: Encoder<T[P]>;\n};\ntype WrapInDecoder<T> = {\n [P in keyof T]: Decoder<T[P]>;\n};\ntype WrapInCodec<T, U extends T = T> = {\n [P in keyof T]: Codec<T[P], U[P]>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyArray = any[];\n\nfunction tupleCodecHelper(items: Array<CodecData>, description?: string): CodecData {\n const itemDescriptions = items.map(item => item.description).join(', ');\n\n return {\n description: description ?? `tuple(${itemDescriptions})`,\n fixedSize: sumCodecSizes(items.map(item => item.fixedSize)),\n maxSize: sumCodecSizes(items.map(item => item.maxSize)),\n };\n}\n\n/**\n * Creates a encoder for a tuple-like array.\n *\n * @param items - The encoders to use for each item in the tuple.\n * @param config - A set of config for the encoder.\n */\nexport function getTupleEncoder<T extends AnyArray>(\n items: WrapInEncoder<[...T]>,\n config: TupleCodecConfig = {}\n): Encoder<T> {\n return {\n ...tupleCodecHelper(items, config.description),\n encode: (value: T) => {\n assertValidNumberOfItemsForCodec('tuple', items.length, value.length);\n return mergeBytes(items.map((item, index) => item.encode(value[index])));\n },\n };\n}\n\n/**\n * Creates a decoder for a tuple-like array.\n *\n * @param items - The decoders to use for each item in the tuple.\n * @param config - A set of config for the decoder.\n */\nexport function getTupleDecoder<T extends AnyArray>(\n items: WrapInDecoder<[...T]>,\n config: TupleCodecConfig = {}\n): Decoder<T> {\n return {\n ...tupleCodecHelper(items, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const values = [] as AnyArray as T;\n items.forEach(codec => {\n const [newValue, newOffset] = codec.decode(bytes, offset);\n values.push(newValue);\n offset = newOffset;\n });\n return [values, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a tuple-like array.\n *\n * @param items - The codecs to use for each item in the tuple.\n * @param config - A set of config for the codec.\n */\nexport function getTupleCodec<T extends AnyArray, U extends T = T>(\n items: WrapInCodec<[...T], [...U]>,\n config: TupleCodecConfig = {}\n): Codec<T, U> {\n return combineCodec(\n getTupleEncoder(items as WrapInEncoder<[...T]>, config),\n getTupleDecoder(items as WrapInDecoder<[...U]>, config)\n );\n}\n","import { BaseCodecConfig, Codec, combineCodec, Decoder, Encoder } from '@solana/codecs-core';\n\n/** Defines the config for unit codecs. */\nexport type UnitSerializerconfig = BaseCodecConfig;\n\n/**\n * Creates a void encoder.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getUnitEncoder(config: UnitSerializerconfig = {}): Encoder<void> {\n return {\n description: config.description ?? 'unit',\n encode: () => new Uint8Array(),\n fixedSize: 0,\n maxSize: 0,\n };\n}\n\n/**\n * Creates a void decoder.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getUnitDecoder(config: UnitSerializerconfig = {}): Decoder<void> {\n return {\n decode: (_bytes: Uint8Array, offset = 0) => [undefined, offset],\n description: config.description ?? 'unit',\n fixedSize: 0,\n maxSize: 0,\n };\n}\n\n/**\n * Creates a void codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getUnitCodec(config: UnitSerializerconfig = {}): Codec<void> {\n return combineCodec(getUnitEncoder(config), getUnitDecoder(config));\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../codecs-core/src/assertions.ts","../../codecs-core/src/bytes.ts","../../codecs-core/src/combine-codec.ts","../../codecs-core/src/fix-codec.ts","../../codecs-numbers/dist/index.browser.js","../src/utils.ts","../src/array-like-codec-size.ts","../src/assertions.ts","../src/array.ts","../src/bit-array.ts","../src/boolean.ts","../src/bytes.ts","../src/data-enum.ts","../src/map.ts","../src/nullable.ts","../src/scalar-enum.ts","../src/set.ts","../src/struct.ts","../src/tuple.ts","../src/unit.ts"],"names":["newOffset","_a","_b"],"mappings":";AAKO,SAAS,kCAAkC,kBAA0B,OAAmB,SAAS,GAAG;AACvG,MAAI,MAAM,SAAS,UAAU,GAAG;AAE5B,UAAM,IAAI,MAAM,UAAU,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A,EACJ;AACJ;AAQO,SAAS,gBACZ,OACA,SAA2B,CAAC,GAClB;AACV,SAAO;AAAA,IACH,GAAG,iBAAiB,OAAO,OAAO,WAAW;AAAA,IAC7C,QAAQ,CAAC,OAAmB,SAAS,MAAM;AACvC,YAAM,SAAS,CAAC;AAChB,YAAM,QAAQ,WAAS;AACnB,cAAM,CAAC,UAAU,SAAS,IAAI,MAAM,OAAO,OAAO,MAAM;AACxD,eAAO,KAAK,QAAQ;AACpB,iBAAS;AAAA,MACb,CAAC;AACD,aAAO,CAAC,QAAQ,MAAM;AAAA,IAC1B;AAAA,EACJ;AACJ;AAQO,SAAS,cACZ,OACA,SAA2B,CAAC,GACjB;AACX,SAAO;AAAA,IACH,gBAAgB,OAAgC,MAAM;AAAA,IACtD,gBAAgB,OAAgC,MAAM;AAAA,EAC1D;AACJ;;;AC9EO,SAAS,eAAe,SAA+B,CAAC,GAAkB;AAVjF;AAWI,SAAO;AAAA,IACH,cAAa,YAAO,gBAAP,YAAsB;AAAA,IACnC,QAAQ,MAAM,IAAI,WAAW;AAAA,IAC7B,WAAW;AAAA,IACX,SAAS;AAAA,EACb;AACJ;AAOO,SAAS,eAAe,SAA+B,CAAC,GAAkB;AAxBjF;AAyBI,SAAO;AAAA,IACH,QAAQ,CAAC,QAAoB,SAAS,MAAM,CAAC,QAAW,MAAM;AAAA,IAC9D,cAAa,YAAO,gBAAP,YAAsB;AAAA,IACnC,WAAW;AAAA,IACX,SAAS;AAAA,EACb;AACJ;AAOO,SAAS,aAAa,SAA+B,CAAC,GAAgB;AACzE,SAAO,aAAa,eAAe,MAAM,GAAG,eAAe,MAAM,CAAC;AACtE","sourcesContent":["import { CodecData } from './codec';\n\n/**\n * Asserts that a given byte array is not empty.\n */\nexport function assertByteArrayIsNotEmptyForCodec(codecDescription: string, bytes: Uint8Array, offset = 0) {\n if (bytes.length - offset <= 0) {\n // TODO: Coded error.\n throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);\n }\n}\n\n/**\n * Asserts that a given byte array has enough bytes to decode.\n */\nexport function assertByteArrayHasEnoughBytesForCodec(\n codecDescription: string,\n expected: number,\n bytes: Uint8Array,\n offset = 0\n) {\n const bytesLength = bytes.length - offset;\n if (bytesLength < expected) {\n // TODO: Coded error.\n throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);\n }\n}\n\n/**\n * Asserts that a given codec is fixed-size codec.\n */\nexport function assertFixedSizeCodec(\n data: Pick<CodecData, 'fixedSize'>,\n message?: string\n): asserts data is { fixedSize: number } {\n if (data.fixedSize === null) {\n // TODO: Coded error.\n throw new Error(message ?? 'Expected a fixed-size codec, got a variable-size one.');\n }\n}\n","/**\n * Concatenates an array of `Uint8Array`s into a single `Uint8Array`.\n * Reuses the original byte array when applicable.\n */\nexport const mergeBytes = (byteArrays: Uint8Array[]): Uint8Array => {\n const nonEmptyByteArrays = byteArrays.filter(arr => arr.length);\n if (nonEmptyByteArrays.length === 0) {\n return byteArrays.length ? byteArrays[0] : new Uint8Array();\n }\n\n if (nonEmptyByteArrays.length === 1) {\n return nonEmptyByteArrays[0];\n }\n\n const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n nonEmptyByteArrays.forEach(arr => {\n result.set(arr, offset);\n offset += arr.length;\n });\n return result;\n};\n\n/**\n * Pads a `Uint8Array` with zeroes to the specified length.\n * If the array is longer than the specified length, it is returned as-is.\n */\nexport const padBytes = (bytes: Uint8Array, length: number): Uint8Array => {\n if (bytes.length >= length) return bytes;\n const paddedBytes = new Uint8Array(length).fill(0);\n paddedBytes.set(bytes);\n return paddedBytes;\n};\n\n/**\n * Fixes a `Uint8Array` to the specified length.\n * If the array is longer than the specified length, it is truncated.\n * If the array is shorter than the specified length, it is padded with zeroes.\n */\nexport const fixBytes = (bytes: Uint8Array, length: number): Uint8Array =>\n padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);\n","import { Codec, Decoder, Encoder } from './codec';\n\n/**\n * Combines an encoder and a decoder into a codec.\n * The encoder and decoder must have the same fixed size, max size and description.\n * If a description is provided, it will override the encoder and decoder descriptions.\n */\nexport function combineCodec<From, To extends From = From>(\n encoder: Encoder<From>,\n decoder: Decoder<To>,\n description?: string\n): Codec<From, To> {\n if (encoder.fixedSize !== decoder.fixedSize) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`\n );\n }\n\n if (encoder.maxSize !== decoder.maxSize) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`\n );\n }\n\n if (description === undefined && encoder.description !== decoder.description) {\n // TODO: Coded error.\n throw new Error(\n `Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. ` +\n `Pass a custom description as a third argument if you want to override the description and bypass this error.`\n );\n }\n\n return {\n decode: decoder.decode,\n description: description ?? encoder.description,\n encode: encoder.encode,\n fixedSize: encoder.fixedSize,\n maxSize: encoder.maxSize,\n };\n}\n","import { assertByteArrayHasEnoughBytesForCodec } from './assertions';\nimport { fixBytes } from './bytes';\nimport { Codec, CodecData, Decoder, Encoder } from './codec';\nimport { combineCodec } from './combine-codec';\n\nfunction fixCodecHelper(data: CodecData, fixedBytes: number, description?: string): CodecData {\n return {\n description: description ?? `fixed(${fixedBytes}, ${data.description})`,\n fixedSize: fixedBytes,\n maxSize: fixedBytes,\n };\n}\n\n/**\n * Creates a fixed-size encoder from a given encoder.\n *\n * @param encoder - The encoder to wrap into a fixed-size encoder.\n * @param fixedBytes - The fixed number of bytes to write.\n * @param description - A custom description for the encoder.\n */\nexport function fixEncoder<T>(encoder: Encoder<T>, fixedBytes: number, description?: string): Encoder<T> {\n return {\n ...fixCodecHelper(encoder, fixedBytes, description),\n encode: (value: T) => fixBytes(encoder.encode(value), fixedBytes),\n };\n}\n\n/**\n * Creates a fixed-size decoder from a given decoder.\n *\n * @param decoder - The decoder to wrap into a fixed-size decoder.\n * @param fixedBytes - The fixed number of bytes to read.\n * @param description - A custom description for the decoder.\n */\nexport function fixDecoder<T>(decoder: Decoder<T>, fixedBytes: number, description?: string): Decoder<T> {\n return {\n ...fixCodecHelper(decoder, fixedBytes, description),\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayHasEnoughBytesForCodec('fixCodec', fixedBytes, bytes, offset);\n // Slice the byte array to the fixed size if necessary.\n if (offset > 0 || bytes.length > fixedBytes) {\n bytes = bytes.slice(offset, offset + fixedBytes);\n }\n // If the nested decoder is fixed-size, pad and truncate the byte array accordingly.\n if (decoder.fixedSize !== null) {\n bytes = fixBytes(bytes, decoder.fixedSize);\n }\n // Decode the value using the nested decoder.\n const [value] = decoder.decode(bytes, 0);\n return [value, offset + fixedBytes];\n },\n };\n}\n\n/**\n * Creates a fixed-size codec from a given codec.\n *\n * @param codec - The codec to wrap into a fixed-size codec.\n * @param fixedBytes - The fixed number of bytes to read/write.\n * @param description - A custom description for the codec.\n */\nexport function fixCodec<T, U extends T = T>(\n codec: Codec<T, U>,\n fixedBytes: number,\n description?: string\n): Codec<T, U> {\n return combineCodec(fixEncoder(codec, fixedBytes, description), fixDecoder(codec, fixedBytes, description));\n}\n","import { combineCodec, assertByteArrayIsNotEmptyForCodec, assertByteArrayHasEnoughBytesForCodec } from '@solana/codecs-core';\n\n// src/assertions.ts\nfunction assertNumberIsBetweenForCodec(codecDescription, min, max, value) {\n if (value < min || value > max) {\n throw new Error(\n `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`\n );\n }\n}\n\n// src/common.ts\nvar Endian = /* @__PURE__ */ ((Endian2) => {\n Endian2[Endian2[\"LITTLE\"] = 0] = \"LITTLE\";\n Endian2[Endian2[\"BIG\"] = 1] = \"BIG\";\n return Endian2;\n})(Endian || {});\nfunction sharedNumberFactory(input) {\n let littleEndian;\n let defaultDescription = input.name;\n if (input.size > 1) {\n littleEndian = !(\"endian\" in input.config) || input.config.endian === 0 /* LITTLE */;\n defaultDescription += littleEndian ? \"(le)\" : \"(be)\";\n }\n return {\n description: input.config.description ?? defaultDescription,\n fixedSize: input.size,\n littleEndian,\n maxSize: input.size\n };\n}\nfunction numberEncoderFactory(input) {\n const codecData = sharedNumberFactory(input);\n return {\n description: codecData.description,\n encode(value) {\n if (input.range) {\n assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);\n }\n const arrayBuffer = new ArrayBuffer(input.size);\n input.set(new DataView(arrayBuffer), value, codecData.littleEndian);\n return new Uint8Array(arrayBuffer);\n },\n fixedSize: codecData.fixedSize,\n maxSize: codecData.maxSize\n };\n}\nfunction numberDecoderFactory(input) {\n const codecData = sharedNumberFactory(input);\n return {\n decode(bytes, offset = 0) {\n assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);\n assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);\n const view = new DataView(toArrayBuffer(bytes, offset, input.size));\n return [input.get(view, codecData.littleEndian), offset + input.size];\n },\n description: codecData.description,\n fixedSize: codecData.fixedSize,\n maxSize: codecData.maxSize\n };\n}\nfunction toArrayBuffer(bytes, offset, length) {\n const bytesOffset = bytes.byteOffset + (offset ?? 0);\n const bytesLength = length ?? bytes.byteLength;\n return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);\n}\n\n// src/f32.ts\nvar getF32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f32\",\n set: (view, value, le) => view.setFloat32(0, value, le),\n size: 4\n});\nvar getF32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat32(0, le),\n name: \"f32\",\n size: 4\n});\nvar getF32Codec = (config = {}) => combineCodec(getF32Encoder(config), getF32Decoder(config));\nvar getF64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"f64\",\n set: (view, value, le) => view.setFloat64(0, value, le),\n size: 8\n});\nvar getF64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getFloat64(0, le),\n name: \"f64\",\n size: 8\n});\nvar getF64Codec = (config = {}) => combineCodec(getF64Encoder(config), getF64Decoder(config));\nvar getI128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i128\",\n range: [-BigInt(\"0x7fffffffffffffffffffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigInt64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getI128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigInt64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"i128\",\n size: 16\n});\nvar getI128Codec = (config = {}) => combineCodec(getI128Encoder(config), getI128Decoder(config));\nvar getI16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i16\",\n range: [-Number(\"0x7fff\") - 1, Number(\"0x7fff\")],\n set: (view, value, le) => view.setInt16(0, value, le),\n size: 2\n});\nvar getI16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt16(0, le),\n name: \"i16\",\n size: 2\n});\nvar getI16Codec = (config = {}) => combineCodec(getI16Encoder(config), getI16Decoder(config));\nvar getI32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i32\",\n range: [-Number(\"0x7fffffff\") - 1, Number(\"0x7fffffff\")],\n set: (view, value, le) => view.setInt32(0, value, le),\n size: 4\n});\nvar getI32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getInt32(0, le),\n name: \"i32\",\n size: 4\n});\nvar getI32Codec = (config = {}) => combineCodec(getI32Encoder(config), getI32Decoder(config));\nvar getI64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i64\",\n range: [-BigInt(\"0x7fffffffffffffff\") - 1n, BigInt(\"0x7fffffffffffffff\")],\n set: (view, value, le) => view.setBigInt64(0, BigInt(value), le),\n size: 8\n});\nvar getI64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigInt64(0, le),\n name: \"i64\",\n size: 8\n});\nvar getI64Codec = (config = {}) => combineCodec(getI64Encoder(config), getI64Decoder(config));\nvar getI8Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"i8\",\n range: [-Number(\"0x7f\") - 1, Number(\"0x7f\")],\n set: (view, value) => view.setInt8(0, value),\n size: 1\n});\nvar getI8Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view) => view.getInt8(0),\n name: \"i8\",\n size: 1\n});\nvar getI8Codec = (config = {}) => combineCodec(getI8Encoder(config), getI8Decoder(config));\nvar getShortU16Encoder = (config = {}) => ({\n description: config.description ?? \"shortU16\",\n encode: (value) => {\n assertNumberIsBetweenForCodec(\"shortU16\", 0, 65535, value);\n const bytes = [0];\n for (let ii = 0; ; ii += 1) {\n const alignedValue = value >> ii * 7;\n if (alignedValue === 0) {\n break;\n }\n const nextSevenBits = 127 & alignedValue;\n bytes[ii] = nextSevenBits;\n if (ii > 0) {\n bytes[ii - 1] |= 128;\n }\n }\n return new Uint8Array(bytes);\n },\n fixedSize: null,\n maxSize: 3\n});\nvar getShortU16Decoder = (config = {}) => ({\n decode: (bytes, offset = 0) => {\n let value = 0;\n let byteCount = 0;\n while (++byteCount) {\n const byteIndex = byteCount - 1;\n const currentByte = bytes[offset + byteIndex];\n const nextSevenBits = 127 & currentByte;\n value |= nextSevenBits << byteIndex * 7;\n if ((currentByte & 128) === 0) {\n break;\n }\n }\n return [value, offset + byteCount];\n },\n description: config.description ?? \"shortU16\",\n fixedSize: null,\n maxSize: 3\n});\nvar getShortU16Codec = (config = {}) => combineCodec(getShortU16Encoder(config), getShortU16Decoder(config));\nvar getU128Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u128\",\n range: [0, BigInt(\"0xffffffffffffffffffffffffffffffff\")],\n set: (view, value, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const rightMask = 0xffffffffffffffffn;\n view.setBigUint64(leftOffset, BigInt(value) >> 64n, le);\n view.setBigUint64(rightOffset, BigInt(value) & rightMask, le);\n },\n size: 16\n});\nvar getU128Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => {\n const leftOffset = le ? 8 : 0;\n const rightOffset = le ? 0 : 8;\n const left = view.getBigUint64(leftOffset, le);\n const right = view.getBigUint64(rightOffset, le);\n return (left << 64n) + right;\n },\n name: \"u128\",\n size: 16\n});\nvar getU128Codec = (config = {}) => combineCodec(getU128Encoder(config), getU128Decoder(config));\nvar getU16Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u16\",\n range: [0, Number(\"0xffff\")],\n set: (view, value, le) => view.setUint16(0, value, le),\n size: 2\n});\nvar getU16Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint16(0, le),\n name: \"u16\",\n size: 2\n});\nvar getU16Codec = (config = {}) => combineCodec(getU16Encoder(config), getU16Decoder(config));\nvar getU32Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u32\",\n range: [0, Number(\"0xffffffff\")],\n set: (view, value, le) => view.setUint32(0, value, le),\n size: 4\n});\nvar getU32Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getUint32(0, le),\n name: \"u32\",\n size: 4\n});\nvar getU32Codec = (config = {}) => combineCodec(getU32Encoder(config), getU32Decoder(config));\nvar getU64Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u64\",\n range: [0, BigInt(\"0xffffffffffffffff\")],\n set: (view, value, le) => view.setBigUint64(0, BigInt(value), le),\n size: 8\n});\nvar getU64Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view, le) => view.getBigUint64(0, le),\n name: \"u64\",\n size: 8\n});\nvar getU64Codec = (config = {}) => combineCodec(getU64Encoder(config), getU64Decoder(config));\nvar getU8Encoder = (config = {}) => numberEncoderFactory({\n config,\n name: \"u8\",\n range: [0, Number(\"0xff\")],\n set: (view, value) => view.setUint8(0, value),\n size: 1\n});\nvar getU8Decoder = (config = {}) => numberDecoderFactory({\n config,\n get: (view) => view.getUint8(0),\n name: \"u8\",\n size: 1\n});\nvar getU8Codec = (config = {}) => combineCodec(getU8Encoder(config), getU8Decoder(config));\n\nexport { Endian, assertNumberIsBetweenForCodec, getF32Codec, getF32Decoder, getF32Encoder, getF64Codec, getF64Decoder, getF64Encoder, getI128Codec, getI128Decoder, getI128Encoder, getI16Codec, getI16Decoder, getI16Encoder, getI32Codec, getI32Decoder, getI32Encoder, getI64Codec, getI64Decoder, getI64Encoder, getI8Codec, getI8Decoder, getI8Encoder, getShortU16Codec, getShortU16Decoder, getShortU16Encoder, getU128Codec, getU128Decoder, getU128Encoder, getU16Codec, getU16Decoder, getU16Encoder, getU32Codec, getU32Decoder, getU32Encoder, getU64Codec, getU64Decoder, getU64Encoder, getU8Codec, getU8Decoder, getU8Encoder };\n","/** Returns the max size or null if at least one size is null. */\nexport function maxCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce(\n (all, size) => (all === null || size === null ? null : Math.max(all, size)),\n 0 as number | null\n );\n}\n\n/** Returns the sum of all sizes or null if at least one size is null. */\nexport function sumCodecSizes(sizes: (number | null)[]): number | null {\n return sizes.reduce((all, size) => (all === null || size === null ? null : all + size), 0 as number | null);\n}\n","import { CodecData, Offset } from '@solana/codecs-core';\nimport { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { sumCodecSizes } from './utils';\n\n/**\n * Represents all the size options for array-like codecs\n * — i.e. `array`, `map` and `set`.\n *\n * It can be one of the following:\n * - a {@link NumberCodec} that prefixes its content with its size.\n * - a fixed number of items.\n * - or `'remainder'` to infer the number of items by dividing\n * the rest of the byte array by the fixed size of its item.\n * Note that this option is only available for fixed-size items.\n */\nexport type ArrayLikeCodecSize<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder | CodecData> =\n | TPrefix\n | number\n | 'remainder';\n\n/** Resolves the size of an array-like codec. */\nexport function decodeArrayLikeCodecSize(\n size: ArrayLikeCodecSize<NumberDecoder>,\n childrenSizes: (number | null)[],\n bytes: Uint8Array,\n offset: Offset\n): [number | bigint, Offset] {\n if (typeof size === 'number') {\n return [size, offset];\n }\n\n if (typeof size === 'object') {\n return size.decode(bytes, offset);\n }\n\n if (size === 'remainder') {\n const childrenSize = sumCodecSizes(childrenSizes);\n if (childrenSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n const remainder = bytes.slice(offset).length;\n if (remainder % childrenSize !== 0) {\n // TODO: Coded error.\n throw new Error(\n `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. ` +\n `Codecs of \"remainder\" size must have a remainder that is a multiple of its item size. ` +\n `In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`\n );\n }\n return [remainder / childrenSize, offset];\n }\n\n // TODO: Coded error.\n throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);\n}\n\nexport function getArrayLikeCodecSizeDescription(size: ArrayLikeCodecSize<CodecData>): string {\n return typeof size === 'object' ? size.description : `${size}`;\n}\n\nexport function getArrayLikeCodecSizeFromChildren(\n size: ArrayLikeCodecSize<CodecData>,\n childrenSizes: (number | null)[]\n): number | null {\n if (typeof size !== 'number') return null;\n if (size === 0) return 0;\n const childrenSize = sumCodecSizes(childrenSizes);\n return childrenSize === null ? null : childrenSize * size;\n}\n\nexport function getArrayLikeCodecSizePrefix(size: ArrayLikeCodecSize<NumberEncoder>, realSize: number): Uint8Array {\n return typeof size === 'object' ? size.encode(realSize) : new Uint8Array();\n}\n","/** Checks the number of items in an array-like structure is expected. */\nexport function assertValidNumberOfItemsForCodec(\n codecDescription: string,\n expected: number | bigint,\n actual: number | bigint\n) {\n if (expected !== actual) {\n // TODO: Coded error.\n throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);\n }\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the configs for array codecs. */\nexport type ArrayCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the array.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction arrayCodecHelper(item: CodecData, size: ArrayLikeCodecSize<CodecData>, description?: string): CodecData {\n if (size === 'remainder' && item.fixedSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize]),\n };\n}\n\n/**\n * Encodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayEncoder<T>(item: Encoder<T>, config: ArrayCodecConfig<NumberEncoder> = {}): Encoder<T[]> {\n const size = config.size ?? getU32Encoder();\n return {\n ...arrayCodecHelper(item, size, config.description),\n encode: (value: T[]) => {\n if (typeof size === 'number') {\n assertValidNumberOfItemsForCodec('array', size, value.length);\n }\n return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map(v => item.encode(v))]);\n },\n };\n}\n\n/**\n * Decodes an array of items.\n *\n * @param item - The encoder to use for the array's items.\n * @param config - A set of config for the encoder.\n */\nexport function getArrayDecoder<T>(item: Decoder<T>, config: ArrayCodecConfig<NumberDecoder> = {}): Decoder<T[]> {\n const size = config.size ?? getU32Decoder();\n return {\n ...arrayCodecHelper(item, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [[], offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);\n offset = newOffset;\n const values: T[] = [];\n for (let i = 0; i < resolvedSize; i += 1) {\n const [value, newOffset] = item.decode(bytes, offset);\n values.push(value);\n offset = newOffset;\n }\n return [values, offset];\n },\n };\n}\n\n/**\n * Creates a codec for an array of items.\n *\n * @param item - The codec to use for the array's items.\n * @param config - A set of config for the codec.\n */\nexport function getArrayCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: ArrayCodecConfig<NumberCodec> = {}\n): Codec<T[], U[]> {\n return combineCodec(getArrayEncoder(item, config), getArrayDecoder(item, config));\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\n\n/** Defines the config for bitArray codecs. */\nexport type BitArrayCodecConfig = BaseCodecConfig & {\n /**\n * Whether to read the bits in reverse order.\n * @defaultValue `false`\n */\n backward?: boolean;\n};\n\n/**\n * Encodes an array of booleans into bits.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the encoder.\n */\nexport const getBitArrayEncoder = (size: number, config: BitArrayCodecConfig | boolean = {}): Encoder<boolean[]> => {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n const backwardSuffix = backward ? '; backward' : '';\n return {\n description: parsedConfig.description ?? `bitArray(${size}${backwardSuffix})`,\n encode(value: boolean[]) {\n const bytes: number[] = [];\n\n for (let i = 0; i < size; i += 1) {\n let byte = 0;\n for (let j = 0; j < 8; j += 1) {\n const feature = Number(value[i * 8 + j] ?? 0);\n byte |= feature << (backward ? j : 7 - j);\n }\n if (backward) {\n bytes.unshift(byte);\n } else {\n bytes.push(byte);\n }\n }\n\n return new Uint8Array(bytes);\n },\n fixedSize: size,\n maxSize: size,\n };\n};\n\n/**\n * Decodes bits into an array of booleans.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the decoder.\n */\nexport const getBitArrayDecoder = (size: number, config: BitArrayCodecConfig | boolean = {}): Decoder<boolean[]> => {\n const parsedConfig: BitArrayCodecConfig = typeof config === 'boolean' ? { backward: config } : config;\n const backward = parsedConfig.backward ?? false;\n const backwardSuffix = backward ? '; backward' : '';\n return {\n decode(bytes, offset = 0) {\n assertByteArrayHasEnoughBytesForCodec('bitArray', size, bytes, offset);\n const booleans: boolean[] = [];\n let slice = bytes.slice(offset, offset + size);\n slice = backward ? slice.reverse() : slice;\n\n slice.forEach(byte => {\n for (let i = 0; i < 8; i += 1) {\n if (backward) {\n booleans.push(Boolean(byte & 1));\n byte >>= 1;\n } else {\n booleans.push(Boolean(byte & 0b1000_0000));\n byte <<= 1;\n }\n }\n });\n\n return [booleans, offset + size];\n },\n description: parsedConfig.description ?? `bitArray(${size}${backwardSuffix})`,\n fixedSize: size,\n maxSize: size,\n };\n};\n\n/**\n * An array of boolean codec that converts booleans to bits and vice versa.\n *\n * @param size - The amount of bytes to use for the bit array.\n * @param config - A set of config for the codec.\n */\nexport const getBitArrayCodec = (size: number, config: BitArrayCodecConfig | boolean = {}): Codec<boolean[]> =>\n combineCodec(getBitArrayEncoder(size, config), getBitArrayDecoder(size, config));\n","import {\n assertByteArrayIsNotEmptyForCodec,\n assertFixedSizeCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/** Defines the config for boolean codecs. */\nexport type BooleanCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The number codec to delegate to.\n * @defaultValue u8 size.\n */\n size?: TSize;\n};\n\n/**\n * Encodes booleans.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBooleanEncoder(config: BooleanCodecConfig<NumberEncoder> = {}): Encoder<boolean> {\n const size = config.size ?? getU8Encoder();\n assertFixedSizeCodec(size, 'Codec [bool] requires a fixed size.');\n\n return {\n description: config.description ?? `bool(${size.description})`,\n encode: (value: boolean) => size.encode(value ? 1 : 0),\n fixedSize: size.fixedSize,\n maxSize: size.fixedSize,\n };\n}\n\n/**\n * Decodes booleans.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBooleanDecoder(config: BooleanCodecConfig<NumberDecoder> = {}): Decoder<boolean> {\n const size = config.size ?? getU8Decoder();\n assertFixedSizeCodec(size, 'Codec [bool] requires a fixed size.');\n\n return {\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('bool', bytes, offset);\n const [value, vOffset] = size.decode(bytes, offset);\n return [value === 1, vOffset];\n },\n description: config.description ?? `bool(${size.description})`,\n fixedSize: size.fixedSize,\n maxSize: size.fixedSize,\n };\n}\n\n/**\n * Creates a boolean codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBooleanCodec(config: BooleanCodecConfig<NumberCodec> = {}): Codec<boolean> {\n return combineCodec(getBooleanEncoder(config), getBooleanDecoder(config));\n}\n","import {\n assertByteArrayHasEnoughBytesForCodec,\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n combineCodec,\n Decoder,\n Encoder,\n fixDecoder,\n fixEncoder,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/** Defines the config for bytes codecs. */\nexport type BytesCodecConfig<TSize extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the byte array. It can be one of the following:\n * - a {@link NumberSerializer} that prefixes the byte array with its size.\n * - a fixed number of bytes.\n * - or `'variable'` to use the rest of the byte array.\n * @defaultValue `'variable'`\n */\n size?: TSize | number | 'variable';\n};\n\n/**\n * Encodes sized bytes.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getBytesEncoder(config: BytesCodecConfig<NumberEncoder> = {}): Encoder<Uint8Array> {\n const size = config.size ?? 'variable';\n const sizeDescription = typeof size === 'object' ? size.description : `${size}`;\n const description = config.description ?? `bytes(${sizeDescription})`;\n\n const byteEncoder: Encoder<Uint8Array> = {\n description,\n encode: (value: Uint8Array) => value,\n fixedSize: null,\n maxSize: null,\n };\n\n if (size === 'variable') {\n return byteEncoder;\n }\n\n if (typeof size === 'number') {\n return fixEncoder(byteEncoder, size, description);\n }\n\n return {\n ...byteEncoder,\n encode: (value: Uint8Array) => {\n const contentBytes = byteEncoder.encode(value);\n const lengthBytes = size.encode(contentBytes.length);\n return mergeBytes([lengthBytes, contentBytes]);\n },\n };\n}\n\n/**\n * Decodes sized bytes.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getBytesDecoder(config: BytesCodecConfig<NumberDecoder> = {}): Decoder<Uint8Array> {\n const size = config.size ?? 'variable';\n const sizeDescription = typeof size === 'object' ? size.description : `${size}`;\n const description = config.description ?? `bytes(${sizeDescription})`;\n\n const byteDecoder: Decoder<Uint8Array> = {\n decode: (bytes: Uint8Array, offset = 0) => {\n const slice = bytes.slice(offset);\n return [slice, offset + slice.length];\n },\n description,\n fixedSize: null,\n maxSize: null,\n };\n\n if (size === 'variable') {\n return byteDecoder;\n }\n\n if (typeof size === 'number') {\n return fixDecoder(byteDecoder, size, description);\n }\n\n return {\n ...byteDecoder,\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('bytes', bytes, offset);\n const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);\n const length = Number(lengthBigInt);\n offset = lengthOffset;\n const contentBytes = bytes.slice(offset, offset + length);\n assertByteArrayHasEnoughBytesForCodec('bytes', length, contentBytes);\n const [value, contentOffset] = byteDecoder.decode(contentBytes);\n offset += contentOffset;\n return [value, offset];\n },\n };\n}\n\n/**\n * Creates a sized bytes codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getBytesCodec(config: BytesCodecConfig<NumberCodec> = {}): Codec<Uint8Array> {\n return combineCodec(getBytesEncoder(config), getBytesDecoder(config));\n}\n","import {\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { maxCodecSizes, sumCodecSizes } from './utils';\n\n/**\n * Defines a data enum using discriminated union types.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * ```\n */\nexport type DataEnum = { __kind: string };\n\n/**\n * Extracts a variant from a data enum.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * type ClickEvent = GetDataEnumKind<WebPageEvent, 'click'>;\n * // -> { __kind: 'click', x: number, y: number }\n * ```\n */\nexport type GetDataEnumKind<T extends DataEnum, K extends T['__kind']> = Extract<T, { __kind: K }>;\n\n/**\n * Extracts a variant from a data enum without its discriminator.\n *\n * @example\n * ```ts\n * type WebPageEvent =\n * | { __kind: 'pageview', url: string }\n * | { __kind: 'click', x: number, y: number };\n * type ClickEvent = GetDataEnumKindContent<WebPageEvent, 'click'>;\n * // -> { x: number, y: number }\n * ```\n */\nexport type GetDataEnumKindContent<T extends DataEnum, K extends T['__kind']> = Omit<\n Extract<T, { __kind: K }>,\n '__kind'\n>;\n\n/** Get the name and codec of each variant in a data enum. */\nexport type DataEnumToCodecTuple<T extends DataEnum, U extends T = T> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Codec<Omit<T, '__kind'>, Omit<U, '__kind'>> | Codec<void>\n : Codec<Omit<T, '__kind'>, Omit<U, '__kind'>>\n ]\n>;\n\n/** Get the name and encoder of each variant in a data enum. */\nexport type DataEnumToEncoderTuple<T extends DataEnum> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Encoder<Omit<T, '__kind'>> | Encoder<void>\n : Encoder<Omit<T, '__kind'>>\n ]\n>;\n\n/** Get the name and decoder of each variant in a data enum. */\nexport type DataEnumToDecoderTuple<T extends DataEnum> = Array<\n T extends never\n ? never\n : [\n T['__kind'],\n keyof Omit<T, '__kind'> extends never\n ? Decoder<Omit<T, '__kind'>> | Decoder<void>\n : Decoder<Omit<T, '__kind'>>\n ]\n>;\n\n/** Defines the config for data enum codecs. */\nexport type DataEnumCodecConfig<TDiscriminator = NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The codec to use for the enum discriminator prefixing the variant.\n * @defaultValue u8 prefix.\n */\n size?: TDiscriminator;\n};\n\nfunction dataEnumCodecHelper(variants: Array<[string, CodecData]>, prefix: CodecData, description?: string): CodecData {\n const fieldDescriptions = variants\n .map(([name, codec]) => `${String(name)}${codec ? `: ${codec.description}` : ''}`)\n .join(', ');\n const allVariantHaveTheSameFixedSize = variants.every((one, _i, all) => one[1].fixedSize === all[0][1].fixedSize);\n const fixedVariantSize = allVariantHaveTheSameFixedSize ? variants[0][1].fixedSize : null;\n const maxVariantSize = maxCodecSizes(variants.map(([, field]) => field.maxSize));\n\n return {\n description: description ?? `dataEnum(${fieldDescriptions}; ${prefix.description})`,\n fixedSize: variants.length === 0 ? prefix.fixedSize : sumCodecSizes([prefix.fixedSize, fixedVariantSize]),\n maxSize: variants.length === 0 ? prefix.maxSize : sumCodecSizes([prefix.maxSize, maxVariantSize]),\n };\n}\n\n/**\n * Creates a data enum encoder.\n *\n * @param variants - The variant encoders of the data enum.\n * @param config - A set of config for the encoder.\n */\nexport function getDataEnumEncoder<T extends DataEnum>(\n variants: DataEnumToEncoderTuple<T>,\n config: DataEnumCodecConfig<NumberEncoder> = {}\n): Encoder<T> {\n const prefix = config.size ?? getU8Encoder();\n return {\n ...dataEnumCodecHelper(variants, prefix, config.description),\n encode: (variant: T) => {\n const discriminator = variants.findIndex(([key]) => variant.__kind === key);\n if (discriminator < 0) {\n // TODO: Coded error.\n throw new Error(\n `Invalid data enum variant. ` +\n `Expected one of [${variants.map(([key]) => key).join(', ')}], ` +\n `got \"${variant.__kind}\".`\n );\n }\n const variantPrefix = prefix.encode(discriminator);\n const variantSerializer = variants[discriminator][1];\n const variantBytes = variantSerializer.encode(variant as void & T);\n return mergeBytes([variantPrefix, variantBytes]);\n },\n };\n}\n\n/**\n * Creates a data enum decoder.\n *\n * @param variants - The variant decoders of the data enum.\n * @param config - A set of config for the decoder.\n */\nexport function getDataEnumDecoder<T extends DataEnum>(\n variants: DataEnumToDecoderTuple<T>,\n config: DataEnumCodecConfig<NumberDecoder> = {}\n): Decoder<T> {\n const prefix = config.size ?? getU8Decoder();\n return {\n ...dataEnumCodecHelper(variants, prefix, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('dataEnum', bytes, offset);\n const [discriminator, dOffset] = prefix.decode(bytes, offset);\n offset = dOffset;\n const variantField = variants[Number(discriminator)] ?? null;\n if (!variantField) {\n // TODO: Coded error.\n throw new Error(\n `Enum discriminator out of range. ` +\n `Expected a number between 0 and ${variants.length - 1}, got ${discriminator}.`\n );\n }\n const [variant, vOffset] = variantField[1].decode(bytes, offset);\n offset = vOffset;\n return [{ __kind: variantField[0], ...(variant ?? {}) } as T, offset];\n },\n };\n}\n\n/**\n * Creates a data enum codec.\n *\n * @param variants - The variant codecs of the data enum.\n * @param config - A set of config for the codec.\n */\nexport function getDataEnumCodec<T extends DataEnum, U extends T = T>(\n variants: DataEnumToCodecTuple<T, U>,\n config: DataEnumCodecConfig<NumberCodec> = {}\n): Codec<T, U> {\n return combineCodec(getDataEnumEncoder<T>(variants, config), getDataEnumDecoder<U>(variants, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the config for Map codecs. */\nexport type MapCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the array.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction mapCodecHelper(\n key: CodecData,\n value: CodecData,\n size: ArrayLikeCodecSize<CodecData>,\n description?: string\n): CodecData {\n if (size === 'remainder' && (key.fixedSize === null || value.fixedSize === null)) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description:\n description ?? `map(${key.description}, ${value.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [key.fixedSize, value.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [key.maxSize, value.maxSize]),\n };\n}\n\n/**\n * Creates a encoder for a map.\n *\n * @param key - The encoder to use for the map's keys.\n * @param value - The encoder to use for the map's values.\n * @param config - A set of config for the encoder.\n */\nexport function getMapEncoder<K, V>(\n key: Encoder<K>,\n value: Encoder<V>,\n config: MapCodecConfig<NumberEncoder> = {}\n): Encoder<Map<K, V>> {\n const size = config.size ?? getU32Encoder();\n return {\n ...mapCodecHelper(key, value, size, config.description),\n encode: (map: Map<K, V>) => {\n if (typeof size === 'number') {\n assertValidNumberOfItemsForCodec('map', size, map.size);\n }\n const itemBytes = Array.from(map, ([k, v]) => mergeBytes([key.encode(k), value.encode(v)]));\n return mergeBytes([getArrayLikeCodecSizePrefix(size, map.size), ...itemBytes]);\n },\n };\n}\n\n/**\n * Creates a decoder for a map.\n *\n * @param key - The decoder to use for the map's keys.\n * @param value - The decoder to use for the map's values.\n * @param config - A set of config for the decoder.\n */\nexport function getMapDecoder<K, V>(\n key: Decoder<K>,\n value: Decoder<V>,\n config: MapCodecConfig<NumberDecoder> = {}\n): Decoder<Map<K, V>> {\n const size = config.size ?? getU32Decoder();\n return {\n ...mapCodecHelper(key, value, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const map: Map<K, V> = new Map();\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [map, offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(\n size,\n [key.fixedSize, value.fixedSize],\n bytes,\n offset\n );\n offset = newOffset;\n for (let i = 0; i < resolvedSize; i += 1) {\n const [decodedKey, kOffset] = key.decode(bytes, offset);\n offset = kOffset;\n const [decodedValue, vOffset] = value.decode(bytes, offset);\n offset = vOffset;\n map.set(decodedKey, decodedValue);\n }\n return [map, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a map.\n *\n * @param key - The codec to use for the map's keys.\n * @param value - The codec to use for the map's values.\n * @param config - A set of config for the codec.\n */\nexport function getMapCodec<TK, TV, UK extends TK = TK, UV extends TV = TV>(\n key: Codec<TK, UK>,\n value: Codec<TV, UV>,\n config: MapCodecConfig<NumberCodec> = {}\n): Codec<Map<TK, TV>, Map<UK, UV>> {\n return combineCodec(getMapEncoder(key, value, config), getMapDecoder(key, value, config));\n}\n","import {\n assertFixedSizeCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n fixBytes,\n mergeBytes,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport { sumCodecSizes } from './utils';\n\n/** Defines the config for nullable codecs. */\nexport type NullableCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The codec to use for the boolean prefix.\n * @defaultValue u8 prefix.\n */\n prefix?: TPrefix;\n\n /**\n * Whether the item codec should be of fixed size.\n *\n * When this is true, a `null` value will skip the bytes that would\n * have been used for the item. Note that this will only work if the\n * item codec is of fixed size.\n * @defaultValue `false`\n */\n fixed?: boolean;\n};\n\nfunction nullableCodecHelper(item: CodecData, prefix: CodecData, fixed: boolean, description?: string): CodecData {\n let descriptionSuffix = `; ${prefix.description}`;\n let fixedSize = item.fixedSize === 0 ? prefix.fixedSize : null;\n if (fixed) {\n assertFixedSizeCodec(item, 'Fixed nullables can only be used with fixed-size codecs.');\n assertFixedSizeCodec(prefix, 'Fixed nullables can only be used with fixed-size prefix.');\n descriptionSuffix += '; fixed';\n fixedSize = prefix.fixedSize + item.fixedSize;\n }\n\n return {\n description: description ?? `nullable(${item.description + descriptionSuffix})`,\n fixedSize,\n maxSize: sumCodecSizes([prefix.maxSize, item.maxSize]),\n };\n}\n\n/**\n * Creates a encoder for an optional value using `null` as the `None` value.\n *\n * @param item - The encoder to use for the value that may be present.\n * @param config - A set of config for the encoder.\n */\nexport function getNullableEncoder<T>(\n item: Encoder<T>,\n config: NullableCodecConfig<NumberEncoder> = {}\n): Encoder<T | null> {\n const prefix = config.prefix ?? getU8Encoder();\n const fixed = config.fixed ?? false;\n return {\n ...nullableCodecHelper(item, prefix, fixed, config.description),\n encode: (option: T | null) => {\n const prefixByte = prefix.encode(Number(option !== null));\n let itemBytes = option !== null ? item.encode(option) : new Uint8Array();\n itemBytes = fixed ? fixBytes(itemBytes, item.fixedSize as number) : itemBytes;\n return mergeBytes([prefixByte, itemBytes]);\n },\n };\n}\n\n/**\n * Creates a decoder for an optional value using `null` as the `None` value.\n *\n * @param item - The decoder to use for the value that may be present.\n * @param config - A set of config for the decoder.\n */\nexport function getNullableDecoder<T>(\n item: Decoder<T>,\n config: NullableCodecConfig<NumberDecoder> = {}\n): Decoder<T | null> {\n const prefix = config.prefix ?? getU8Decoder();\n const fixed = config.fixed ?? false;\n return {\n ...nullableCodecHelper(item, prefix, fixed, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n if (bytes.length - offset <= 0) {\n return [null, offset];\n }\n const fixedOffset = offset + (prefix.fixedSize ?? 0) + (item.fixedSize ?? 0);\n const [isSome, prefixOffset] = prefix.decode(bytes, offset);\n offset = prefixOffset;\n if (isSome === 0) {\n return [null, fixed ? fixedOffset : offset];\n }\n const [value, newOffset] = item.decode(bytes, offset);\n offset = newOffset;\n return [value, fixed ? fixedOffset : offset];\n },\n };\n}\n\n/**\n * Creates a codec for an optional value using `null` as the `None` value.\n *\n * @param item - The codec to use for the value that may be present.\n * @param config - A set of config for the codec.\n */\nexport function getNullableCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: NullableCodecConfig<NumberCodec> = {}\n): Codec<T | null, U | null> {\n return combineCodec(getNullableEncoder<T>(item, config), getNullableDecoder<U>(item, config));\n}\n","import {\n assertByteArrayIsNotEmptyForCodec,\n BaseCodecConfig,\n Codec,\n CodecData,\n combineCodec,\n Decoder,\n Encoder,\n} from '@solana/codecs-core';\nimport { getU8Decoder, getU8Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\n/**\n * Defines a scalar enum as a type from its constructor.\n *\n * @example\n * ```ts\n * enum Direction { Left, Right };\n * type DirectionType = ScalarEnum<Direction>;\n * ```\n */\nexport type ScalarEnum<T> = ({ [key: number | string]: string | number | T } | number | T) & NonNullable<unknown>;\n\n/** Defines the config for scalar enum codecs. */\nexport type ScalarEnumCodecConfig<TDiscriminator extends NumberCodec | NumberEncoder | NumberDecoder> =\n BaseCodecConfig & {\n /**\n * The codec to use for the enum discriminator.\n * @defaultValue u8 discriminator.\n */\n size?: TDiscriminator;\n };\n\nfunction scalarEnumCoderHelper<T>(\n constructor: ScalarEnum<T>,\n prefix: CodecData,\n description?: string\n): CodecData & {\n enumKeys: string[];\n enumValues: T[];\n isNumericEnum: boolean;\n minRange: number;\n maxRange: number;\n stringValues: string[];\n} {\n const enumKeys = Object.keys(constructor);\n const enumValues = Object.values(constructor);\n const isNumericEnum = enumValues.some(v => typeof v === 'number');\n const valueDescriptions = enumValues.filter(v => typeof v === 'string').join(', ');\n const minRange = 0;\n const maxRange = isNumericEnum ? enumValues.length / 2 - 1 : enumValues.length - 1;\n const stringValues: string[] = isNumericEnum ? [...enumKeys] : [...new Set([...enumKeys, ...enumValues])];\n\n return {\n description: description ?? `enum(${valueDescriptions}; ${prefix.description})`,\n enumKeys,\n enumValues,\n fixedSize: prefix.fixedSize,\n isNumericEnum,\n maxRange,\n maxSize: prefix.maxSize,\n minRange,\n stringValues,\n };\n}\n\n/**\n * Creates a scalar enum encoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the encoder.\n */\nexport function getScalarEnumEncoder<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberEncoder> = {}\n): Encoder<T> {\n const prefix = config.size ?? getU8Encoder();\n const { description, fixedSize, maxSize, minRange, maxRange, stringValues, enumKeys, enumValues } =\n scalarEnumCoderHelper(constructor, prefix, config.description);\n return {\n description,\n encode: (value: T) => {\n const isInvalidNumber = typeof value === 'number' && (value < minRange || value > maxRange);\n const isInvalidString = typeof value === 'string' && !stringValues.includes(value);\n if (isInvalidNumber || isInvalidString) {\n // TODO: Coded error.\n throw new Error(\n `Invalid scalar enum variant. ` +\n `Expected one of [${stringValues.join(', ')}] ` +\n `or a number between ${minRange} and ${maxRange}, ` +\n `got \"${value}\".`\n );\n }\n if (typeof value === 'number') return prefix.encode(value);\n const valueIndex = enumValues.indexOf(value);\n if (valueIndex >= 0) return prefix.encode(valueIndex);\n return prefix.encode(enumKeys.indexOf(value as string));\n },\n fixedSize,\n maxSize,\n };\n}\n\n/**\n * Creates a scalar enum decoder.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the decoder.\n */\nexport function getScalarEnumDecoder<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberDecoder> = {}\n): Decoder<T> {\n const prefix = config.size ?? getU8Decoder();\n const { description, fixedSize, maxSize, minRange, maxRange, isNumericEnum, enumValues } = scalarEnumCoderHelper(\n constructor,\n prefix,\n config.description\n );\n return {\n decode: (bytes: Uint8Array, offset = 0) => {\n assertByteArrayIsNotEmptyForCodec('enum', bytes, offset);\n const [value, newOffset] = prefix.decode(bytes, offset);\n const valueAsNumber = Number(value);\n offset = newOffset;\n if (valueAsNumber < minRange || valueAsNumber > maxRange) {\n // TODO: Coded error.\n throw new Error(\n `Enum discriminator out of range. ` +\n `Expected a number between ${minRange} and ${maxRange}, got ${valueAsNumber}.`\n );\n }\n return [(isNumericEnum ? valueAsNumber : enumValues[valueAsNumber]) as T, offset];\n },\n description,\n fixedSize,\n maxSize,\n };\n}\n\n/**\n * Creates a scalar enum codec.\n *\n * @param constructor - The constructor of the scalar enum.\n * @param config - A set of config for the codec.\n */\nexport function getScalarEnumCodec<T>(\n constructor: ScalarEnum<T>,\n config: ScalarEnumCodecConfig<NumberCodec> = {}\n): Codec<T> {\n return combineCodec(getScalarEnumEncoder(constructor, config), getScalarEnumDecoder(constructor, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\nimport { getU32Decoder, getU32Encoder, NumberCodec, NumberDecoder, NumberEncoder } from '@solana/codecs-numbers';\n\nimport {\n ArrayLikeCodecSize,\n decodeArrayLikeCodecSize,\n getArrayLikeCodecSizeDescription,\n getArrayLikeCodecSizeFromChildren,\n getArrayLikeCodecSizePrefix,\n} from './array-like-codec-size';\nimport { assertValidNumberOfItemsForCodec } from './assertions';\n\n/** Defines the config for set codecs. */\nexport type SetCodecConfig<TPrefix extends NumberCodec | NumberEncoder | NumberDecoder> = BaseCodecConfig & {\n /**\n * The size of the set.\n * @defaultValue u32 prefix.\n */\n size?: ArrayLikeCodecSize<TPrefix>;\n};\n\nfunction setCodecHelper(item: CodecData, size: ArrayLikeCodecSize<CodecData>, description?: string): CodecData {\n if (size === 'remainder' && item.fixedSize === null) {\n // TODO: Coded error.\n throw new Error('Codecs of \"remainder\" size must have fixed-size items.');\n }\n\n return {\n description: description ?? `set(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,\n fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),\n maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize]),\n };\n}\n\n/**\n * Encodes an set of items.\n *\n * @param item - The encoder to use for the set's items.\n * @param config - A set of config for the encoder.\n */\nexport function getSetEncoder<T>(item: Encoder<T>, config: SetCodecConfig<NumberEncoder> = {}): Encoder<Set<T>> {\n const size = config.size ?? getU32Encoder();\n return {\n ...setCodecHelper(item, size, config.description),\n encode: (set: Set<T>) => {\n if (typeof size === 'number' && set.size !== size) {\n assertValidNumberOfItemsForCodec('set', size, set.size);\n }\n const itemBytes = Array.from(set, value => item.encode(value));\n return mergeBytes([getArrayLikeCodecSizePrefix(size, set.size), ...itemBytes]);\n },\n };\n}\n\n/**\n * Decodes an set of items.\n *\n * @param item - The encoder to use for the set's items.\n * @param config - A set of config for the encoder.\n */\nexport function getSetDecoder<T>(item: Decoder<T>, config: SetCodecConfig<NumberDecoder> = {}): Decoder<Set<T>> {\n const size = config.size ?? getU32Decoder();\n return {\n ...setCodecHelper(item, size, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const set: Set<T> = new Set();\n if (typeof size === 'object' && bytes.slice(offset).length === 0) {\n return [set, offset];\n }\n const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);\n offset = newOffset;\n for (let i = 0; i < resolvedSize; i += 1) {\n const [value, newOffset] = item.decode(bytes, offset);\n offset = newOffset;\n set.add(value);\n }\n return [set, offset];\n },\n };\n}\n\n/**\n * Creates a codec for an set of items.\n *\n * @param item - The codec to use for the set's items.\n * @param config - A set of config for the codec.\n */\nexport function getSetCodec<T, U extends T = T>(\n item: Codec<T, U>,\n config: SetCodecConfig<NumberCodec> = {}\n): Codec<Set<T>, Set<U>> {\n return combineCodec(getSetEncoder(item, config), getSetDecoder(item, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\n\nimport { sumCodecSizes } from './utils';\n\n/** Get the name and encoder of each field in a struct. */\nexport type StructToEncoderTuple<T extends object> = Array<\n {\n [K in keyof T]: [K, Encoder<T[K]>];\n }[keyof T]\n>;\n\n/** Get the name and decoder of each field in a struct. */\nexport type StructToDecoderTuple<T extends object> = Array<\n {\n [K in keyof T]: [K, Decoder<T[K]>];\n }[keyof T]\n>;\n\n/** Get the name and codec of each field in a struct. */\nexport type StructToCodecTuple<T extends object, U extends T> = Array<\n {\n [K in keyof T]: [K, Codec<T[K], U[K]>];\n }[keyof T]\n>;\n\n/** Defines the config for struct codecs. */\nexport type StructCodecConfig = BaseCodecConfig;\n\nfunction structCodecHelper(fields: Array<[string | number | symbol, CodecData]>, description?: string): CodecData {\n const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(', ');\n\n return {\n description: description ?? `struct(${fieldDescriptions})`,\n fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),\n maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize)),\n };\n}\n\n/**\n * Creates a encoder for a custom object.\n *\n * @param fields - The name and encoder of each field.\n * @param config - A set of config for the encoder.\n */\nexport function getStructEncoder<T extends object>(\n fields: StructToEncoderTuple<T>,\n config: StructCodecConfig = {}\n): Encoder<T> {\n return {\n ...structCodecHelper(fields, config.description),\n encode: (struct: T) => {\n const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));\n return mergeBytes(fieldBytes);\n },\n };\n}\n\n/**\n * Creates a decoder for a custom object.\n *\n * @param fields - The name and decoder of each field.\n * @param config - A set of config for the decoder.\n */\nexport function getStructDecoder<T extends object>(\n fields: StructToDecoderTuple<T>,\n config: StructCodecConfig = {}\n): Decoder<T> {\n return {\n ...structCodecHelper(fields, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const struct: Partial<T> = {};\n fields.forEach(([key, codec]) => {\n const [value, newOffset] = codec.decode(bytes, offset);\n offset = newOffset;\n struct[key] = value;\n });\n return [struct as T, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a custom object.\n *\n * @param fields - The name and codec of each field.\n * @param config - A set of config for the codec.\n */\nexport function getStructCodec<T extends object, U extends T = T>(\n fields: StructToCodecTuple<T, U>,\n config: StructCodecConfig = {}\n): Codec<T, U> {\n return combineCodec(getStructEncoder(fields, config), getStructDecoder(fields, config));\n}\n","import { BaseCodecConfig, Codec, CodecData, combineCodec, Decoder, Encoder, mergeBytes } from '@solana/codecs-core';\n\nimport { assertValidNumberOfItemsForCodec } from './assertions';\nimport { sumCodecSizes } from './utils';\n\n/** Defines the config for tuple codecs. */\nexport type TupleCodecConfig = BaseCodecConfig;\n\ntype WrapInEncoder<T> = {\n [P in keyof T]: Encoder<T[P]>;\n};\ntype WrapInDecoder<T> = {\n [P in keyof T]: Decoder<T[P]>;\n};\ntype WrapInCodec<T, U extends T = T> = {\n [P in keyof T]: Codec<T[P], U[P]>;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyArray = any[];\n\nfunction tupleCodecHelper(items: Array<CodecData>, description?: string): CodecData {\n const itemDescriptions = items.map(item => item.description).join(', ');\n\n return {\n description: description ?? `tuple(${itemDescriptions})`,\n fixedSize: sumCodecSizes(items.map(item => item.fixedSize)),\n maxSize: sumCodecSizes(items.map(item => item.maxSize)),\n };\n}\n\n/**\n * Creates a encoder for a tuple-like array.\n *\n * @param items - The encoders to use for each item in the tuple.\n * @param config - A set of config for the encoder.\n */\nexport function getTupleEncoder<T extends AnyArray>(\n items: WrapInEncoder<[...T]>,\n config: TupleCodecConfig = {}\n): Encoder<T> {\n return {\n ...tupleCodecHelper(items, config.description),\n encode: (value: T) => {\n assertValidNumberOfItemsForCodec('tuple', items.length, value.length);\n return mergeBytes(items.map((item, index) => item.encode(value[index])));\n },\n };\n}\n\n/**\n * Creates a decoder for a tuple-like array.\n *\n * @param items - The decoders to use for each item in the tuple.\n * @param config - A set of config for the decoder.\n */\nexport function getTupleDecoder<T extends AnyArray>(\n items: WrapInDecoder<[...T]>,\n config: TupleCodecConfig = {}\n): Decoder<T> {\n return {\n ...tupleCodecHelper(items, config.description),\n decode: (bytes: Uint8Array, offset = 0) => {\n const values = [] as AnyArray as T;\n items.forEach(codec => {\n const [newValue, newOffset] = codec.decode(bytes, offset);\n values.push(newValue);\n offset = newOffset;\n });\n return [values, offset];\n },\n };\n}\n\n/**\n * Creates a codec for a tuple-like array.\n *\n * @param items - The codecs to use for each item in the tuple.\n * @param config - A set of config for the codec.\n */\nexport function getTupleCodec<T extends AnyArray, U extends T = T>(\n items: WrapInCodec<[...T], [...U]>,\n config: TupleCodecConfig = {}\n): Codec<T, U> {\n return combineCodec(\n getTupleEncoder(items as WrapInEncoder<[...T]>, config),\n getTupleDecoder(items as WrapInDecoder<[...U]>, config)\n );\n}\n","import { BaseCodecConfig, Codec, combineCodec, Decoder, Encoder } from '@solana/codecs-core';\n\n/** Defines the config for unit codecs. */\nexport type UnitSerializerconfig = BaseCodecConfig;\n\n/**\n * Creates a void encoder.\n *\n * @param config - A set of config for the encoder.\n */\nexport function getUnitEncoder(config: UnitSerializerconfig = {}): Encoder<void> {\n return {\n description: config.description ?? 'unit',\n encode: () => new Uint8Array(),\n fixedSize: 0,\n maxSize: 0,\n };\n}\n\n/**\n * Creates a void decoder.\n *\n * @param config - A set of config for the decoder.\n */\nexport function getUnitDecoder(config: UnitSerializerconfig = {}): Decoder<void> {\n return {\n decode: (_bytes: Uint8Array, offset = 0) => [undefined, offset],\n description: config.description ?? 'unit',\n fixedSize: 0,\n maxSize: 0,\n };\n}\n\n/**\n * Creates a void codec.\n *\n * @param config - A set of config for the codec.\n */\nexport function getUnitCodec(config: UnitSerializerconfig = {}): Codec<void> {\n return combineCodec(getUnitEncoder(config), getUnitDecoder(config));\n}\n"]}
|
package/dist/index.node.cjs
CHANGED
|
@@ -2,49 +2,49 @@ this.globalThis = this.globalThis || {};
|
|
|
2
2
|
this.globalThis.solanaWeb3 = (function (exports) {
|
|
3
3
|
'use strict';
|
|
4
4
|
|
|
5
|
-
function l(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function E(e,r,o,n=0){let t=o.length-n;if(t<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${t}.`)}function D(e,r){if(e.fixedSize===null)throw new Error(r??"Expected a fixed-size codec, got a variable-size one.")}var p=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let o=r.reduce((i,d)=>i+d.length,0),n=new Uint8Array(o),t=0;return r.forEach(i=>{n.set(i,t),t+=i.length;}),n},G=(e,r)=>{if(e.length>=r)return e;let o=new Uint8Array(r).fill(0);return o.set(e),o},w=(e,r)=>G(e.length<=r?e:e.slice(0,r),r);function f(e,r,o){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(o===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:o??e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function k(e,r,o){return {description:o??`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function I(e,r,o){return {...k(e,r,o),encode:n=>w(e.encode(n),r)}}function $(e,r,o){return {...k(e,r,o),decode:(n,t=0)=>{E("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),e.fixedSize!==null&&(n=w(n,e.fixedSize));let[i]=e.decode(n,0);return [i,t+r]}}}function q(e,r,o,n){if(n<r||n>o)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${o}], got ${n}.`)}function O(e){let r,o=e.name;return e.size>1&&(r=!("endian"in e.config)||e.config.endian===0,o+=r?"(le)":"(be)"),{description:e.config.description??o,fixedSize:e.size,littleEndian:r,maxSize:e.size}}function _(e){let r=O(e);return {description:r.description,encode(o){e.range&&q(e.name,e.range[0],e.range[1],o);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),o,r.littleEndian),new Uint8Array(n)},fixedSize:r.fixedSize,maxSize:r.maxSize}}function F(e){let r=O(e);return {decode(o,n=0){l(r.description,o,n),E(r.description,e.size,o,n);let t=new DataView(J(o,n,e.size));return [e.get(t,r.littleEndian),n+e.size]},description:r.description,fixedSize:r.fixedSize,maxSize:r.maxSize}}function J(e,r,o){let n=e.byteOffset+(r??0),t=o??e.byteLength;return e.buffer.slice(n,n+t)}var N=(e={})=>_({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,o,n)=>r.setUint32(0,o,n),size:4}),U=(e={})=>F({config:e,get:(r,o)=>r.getUint32(0,o),name:"u32",size:4});var S=(e={})=>_({config:e,name:"u8",range:[0,+"0xff"],set:(r,o)=>r.setUint8(0,o),size:1}),b=(e={})=>F({config:e,get:r=>r.getUint8(0),name:"u8",size:1});function V(e){return e.reduce((r,o)=>r===null||o===null?null:Math.max(r,o),0)}function x(e){return e.reduce((r,o)=>r===null||o===null?null:r+o,0)}function h(e,r,o,n){if(typeof e=="number")return [e,n];if(typeof e=="object")return e.decode(o,n);if(e==="remainder"){let t=x(r);if(t===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let i=o.slice(n).length;if(i%t!==0)throw new Error(`The remainder of the byte array (${i} bytes) cannot be split into chunks of ${t} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${i} modulo ${t} should be equal to zero.`);return [i/t,n]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function B(e){return typeof e=="object"?e.description:`${e}`}function g(e,r){if(typeof e!="number")return null;if(e===0)return 0;let o=x(r);return o===null?null:o*e}function A(e,r){return typeof e=="object"?e.encode(r):new Uint8Array}function y(e,r,o){if(r!==o)throw new Error(`Expected [${e}] to have ${r} items, got ${o}.`)}function L(e,r,o){if(r==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:o??`array(${e.description}; ${B(r)})`,fixedSize:g(r,[e.fixedSize]),maxSize:g(r,[e.maxSize])}}function Q(e,r={}){let o=r.size??N();return {...L(e,o,r.description),encode:n=>(typeof o=="number"&&y("array",o,n.length),p([A(o,n.length),...n.map(t=>e.encode(t))]))}}function X(e,r={}){let o=r.size??U();return {...L(e,o,r.description),decode:(n,t=0)=>{if(typeof o=="object"&&n.slice(t).length===0)return [[],t];let[i,d]=h(o,[e.fixedSize],n,t);t=d;let c=[];for(let a=0;a<i;a+=1){let[s,u]=e.decode(n,t);c.push(s),t=u;}return [c,t]}}}function We(e,r={}){return f(Q(e,r),X(e,r))}var Y=(e,r={})=>{let o=typeof r=="boolean"?{backward:r}:r,n=o.backward??!1,t=n?"; backward":"";return {description:o.description??`bitArray(${e}${t})`,encode(i){let d=[];for(let c=0;c<e;c+=1){let a=0;for(let s=0;s<8;s+=1){let u=Number(i[c*8+s]??0);a|=u<<(n?s:7-s);}n?d.unshift(a):d.push(a);}return new Uint8Array(d)},fixedSize:e,maxSize:e}},Z=(e,r={})=>{let o=typeof r=="boolean"?{backward:r}:r,n=o.backward??!1,t=n?"; backward":"";return {decode(i,d=0){E("bitArray",e,i,d);let c=[],a=i.slice(d,d+e);return a=n?a.reverse():a,a.forEach(s=>{for(let u=0;u<8;u+=1)n?(c.push(!!(s&1)),s>>=1):(c.push(!!(s&128)),s<<=1);}),[c,d+e]},description:o.description??`bitArray(${e}${t})`,fixedSize:e,maxSize:e}},er=(e,r={})=>f(Y(e,r),Z(e,r));function ee(e={}){let r=e.size??S();return D(r,"Codec [bool] requires a fixed size."),{description:e.description??`bool(${r.description})`,encode:o=>r.encode(o?1:0),fixedSize:r.fixedSize,maxSize:r.fixedSize}}function re(e={}){let r=e.size??b();return D(r,"Codec [bool] requires a fixed size."),{decode:(o,n=0)=>{l("bool",o,n);let[t,i]=r.decode(o,n);return [t===1,i]},description:e.description??`bool(${r.description})`,fixedSize:r.fixedSize,maxSize:r.fixedSize}}function mr(e={}){return f(ee(e),re(e))}function oe(e={}){let r=e.size??"variable",o=typeof r=="object"?r.description:`${r}`,n=e.description??`bytes(${o})`,t={description:n,encode:i=>i,fixedSize:null,maxSize:null};return r==="variable"?t:typeof r=="number"?I(t,r,n):{...t,encode:i=>{let d=t.encode(i),c=r.encode(d.length);return p([c,d])}}}function ne(e={}){let r=e.size??"variable",o=typeof r=="object"?r.description:`${r}`,n=e.description??`bytes(${o})`,t={decode:(i,d=0)=>{let c=i.slice(d);return [c,d+c.length]},description:n,fixedSize:null,maxSize:null};return r==="variable"?t:typeof r=="number"?$(t,r,n):{...t,decode:(i,d=0)=>{l("bytes",i,d);let[c,a]=r.decode(i,d),s=Number(c);d=a;let u=i.slice(d,d+s);E("bytes",s,u);let[m,T]=t.decode(u);return d+=T,[m,d]}}}function br(e={}){return f(oe(e),ne(e))}function K(e,r,o){let n=e.map(([c,a])=>`${String(c)}${a?`: ${a.description}`:""}`).join(", "),i=e.every((c,a,s)=>c[1].fixedSize===s[0][1].fixedSize)?e[0][1].fixedSize:null,d=V(e.map(([,c])=>c.maxSize));return {description:o??`dataEnum(${n}; ${r.description})`,fixedSize:e.length===0?r.fixedSize:x([r.fixedSize,i]),maxSize:e.length===0?r.maxSize:x([r.maxSize,d])}}function te(e,r={}){let o=r.size??S();return {...K(e,o,r.description),encode:n=>{let t=e.findIndex(([a])=>n.__kind===a);if(t<0)throw new Error(`Invalid data enum variant. Expected one of [${e.map(([a])=>a).join(", ")}], got "${n.__kind}".`);let i=o.encode(t),c=e[t][1].encode(n);return p([i,c])}}}function ie(e,r={}){let o=r.size??b();return {...K(e,o,r.description),decode:(n,t=0)=>{l("dataEnum",n,t);let[i,d]=o.decode(n,t);t=d;let c=e[Number(i)]??null;if(!c)throw new Error(`Enum discriminator out of range. Expected a number between 0 and ${e.length-1}, got ${i}.`);let[a,s]=c[1].decode(n,t);return t=s,[{__kind:c[0],...a??{}},t]}}}function $r(e,r={}){return f(te(e,r),ie(e,r))}function P(e,r,o,n){if(o==="remainder"&&(e.fixedSize===null||r.fixedSize===null))throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:n??`map(${e.description}, ${r.description}; ${B(o)})`,fixedSize:g(o,[e.fixedSize,r.fixedSize]),maxSize:g(o,[e.maxSize,r.maxSize])}}function de(e,r,o={}){let n=o.size??N();return {...P(e,r,n,o.description),encode:t=>{typeof n=="number"&&y("map",n,t.size);let i=Array.from(t,([d,c])=>p([e.encode(d),r.encode(c)]));return p([A(n,t.size),...i])}}}function ce(e,r,o={}){let n=o.size??U();return {...P(e,r,n,o.description),decode:(t,i=0)=>{let d=new Map;if(typeof n=="object"&&t.slice(i).length===0)return [d,i];let[c,a]=h(n,[e.fixedSize,r.fixedSize],t,i);i=a;for(let s=0;s<c;s+=1){let[u,m]=e.decode(t,i);i=m;let[T,v]=r.decode(t,i);i=v,d.set(u,T);}return [d,i]}}}function Qr(e,r,o={}){return f(de(e,r,o),ce(e,r,o))}function j(e,r,o,n){let t=`; ${r.description}`,i=e.fixedSize===0?r.fixedSize:null;return o&&(D(e,"Fixed nullables can only be used with fixed-size codecs."),D(r,"Fixed nullables can only be used with fixed-size prefix."),t+="; fixed",i=r.fixedSize+e.fixedSize),{description:n??`nullable(${e.description+t})`,fixedSize:i,maxSize:x([r.maxSize,e.maxSize])}}function ae(e,r={}){let o=r.prefix??S(),n=r.fixed??!1;return {...j(e,o,n,r.description),encode:t=>{let i=o.encode(+(t!==null)),d=t!==null?e.encode(t):new Uint8Array;return d=n?w(d,e.fixedSize):d,p([i,d])}}}function se(e,r={}){let o=r.prefix??b(),n=r.fixed??!1;return {...j(e,o,n,r.description),decode:(t,i=0)=>{if(t.length-i<=0)return [null,i];let d=i+(o.fixedSize??0)+(e.fixedSize??0),[c,a]=o.decode(t,i);if(i=a,c===0)return [null,n?d:i];let[s,u]=e.decode(t,i);return i=u,[s,n?d:i]}}}function uo(e,r={}){return f(ae(e,r),se(e,r))}function M(e,r,o){let n=Object.keys(e),t=Object.values(e),i=t.some(u=>typeof u=="number"),d=t.filter(u=>typeof u=="string").join(", "),c=0,a=i?t.length/2-1:t.length-1,s=i?[...n]:[...new Set([...n,...t])];return {description:o??`enum(${d}; ${r.description})`,enumKeys:n,enumValues:t,fixedSize:r.fixedSize,isNumericEnum:i,maxRange:a,maxSize:r.maxSize,minRange:c,stringValues:s}}function fe(e,r={}){let o=r.size??S(),{description:n,fixedSize:t,maxSize:i,minRange:d,maxRange:c,stringValues:a,enumKeys:s,enumValues:u}=M(e,o,r.description);return {description:n,encode:m=>{let T=typeof m=="number"&&(m<d||m>c),v=typeof m=="string"&&!a.includes(m);if(T||v)throw new Error(`Invalid scalar enum variant. Expected one of [${a.join(", ")}] or a number between ${d} and ${c}, got "${m}".`);if(typeof m=="number")return o.encode(m);let z=u.indexOf(m);return z>=0?o.encode(z):o.encode(s.indexOf(m))},fixedSize:t,maxSize:i}}function ue(e,r={}){let o=r.size??b(),{description:n,fixedSize:t,maxSize:i,minRange:d,maxRange:c,isNumericEnum:a,enumValues:s}=M(e,o,r.description);return {decode:(u,m=0)=>{l("enum",u,m);let[T,v]=o.decode(u,m),z=Number(T);if(m=v,z<d||z>c)throw new Error(`Enum discriminator out of range. Expected a number between ${d} and ${c}, got ${z}.`);return [a?z:s[z],m]},description:n,fixedSize:t,maxSize:i}}function Do(e,r={}){return f(fe(e,r),ue(e,r))}function H(e,r,o){if(r==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:o??`set(${e.description}; ${B(r)})`,fixedSize:g(r,[e.fixedSize]),maxSize:g(r,[e.maxSize])}}function me(e,r={}){let o=r.size??N();return {...H(e,o,r.description),encode:n=>{typeof o=="number"&&n.size!==o&&y("set",o,n.size);let t=Array.from(n,i=>e.encode(i));return p([A(o,n.size),...t])}}}function Ce(e,r={}){let o=r.size??U();return {...H(e,o,r.description),decode:(n,t=0)=>{let i=new Set;if(typeof o=="object"&&n.slice(t).length===0)return [i,t];let[d,c]=h(o,[e.fixedSize],n,t);t=c;for(let a=0;a<d;a+=1){let[s,u]=e.decode(n,t);t=u,i.add(s);}return [i,t]}}}function Ko(e,r={}){return f(me(e,r),Ce(e,r))}function R(e,r){let o=e.map(([n,t])=>`${String(n)}: ${t.description}`).join(", ");return {description:r??`struct(${o})`,fixedSize:x(e.map(([,n])=>n.fixedSize)),maxSize:x(e.map(([,n])=>n.maxSize))}}function pe(e,r={}){return {...R(e,r.description),encode:o=>{let n=e.map(([t,i])=>i.encode(o[t]));return p(n)}}}function xe(e,r={}){return {...R(e,r.description),decode:(o,n=0)=>{let t={};return e.forEach(([i,d])=>{let[c,a]=d.decode(o,n);n=a,t[i]=c;}),[t,n]}}}function Qo(e,r={}){return f(pe(e,r),xe(e,r))}function W(e,r){let o=e.map(n=>n.description).join(", ");return {description:r??`tuple(${o})`,fixedSize:x(e.map(n=>n.fixedSize)),maxSize:x(e.map(n=>n.maxSize))}}function le(e,r={}){return {...W(e,r.description),encode:o=>(y("tuple",e.length,o.length),p(e.map((n,t)=>n.encode(o[t]))))}}function ge(e,r={}){return {...W(e,r.description),decode:(o,n=0)=>{let t=[];return e.forEach(i=>{let[d,c]=i.decode(o,n);t.push(d),n=c;}),[t,n]}}}function an(e,r={}){return f(le(e,r),ge(e,r))}function ze(e={}){return {description:e.description??"unit",encode:()=>new Uint8Array,fixedSize:0,maxSize:0}}function Se(e={}){return {decode:(r,o=0)=>[void 0,o],description:e.description??"unit",fixedSize:0,maxSize:0}}function ln(e={}){return f(ze(e),Se(e))}
|
|
5
|
+
function S(e,r,o=0){if(r.length-o<=0)throw new Error(`Codec [${e}] cannot decode empty byte arrays.`)}function N(e,r,o,n=0){let t=o.length-n;if(t<r)throw new Error(`Codec [${e}] expected ${r} bytes, got ${t}.`)}function U(e,r){if(e.fixedSize===null)throw new Error(r!=null?r:"Expected a fixed-size codec, got a variable-size one.")}var l=e=>{let r=e.filter(i=>i.length);if(r.length===0)return e.length?e[0]:new Uint8Array;if(r.length===1)return r[0];let o=r.reduce((i,d)=>i+d.length,0),n=new Uint8Array(o),t=0;return r.forEach(i=>{n.set(i,t),t+=i.length;}),n},q=(e,r)=>{if(e.length>=r)return e;let o=new Uint8Array(r).fill(0);return o.set(e),o},k=(e,r)=>q(e.length<=r?e:e.slice(0,r),r);function C(e,r,o){if(e.fixedSize!==r.fixedSize)throw new Error(`Encoder and decoder must have the same fixed size, got [${e.fixedSize}] and [${r.fixedSize}].`);if(e.maxSize!==r.maxSize)throw new Error(`Encoder and decoder must have the same max size, got [${e.maxSize}] and [${r.maxSize}].`);if(o===void 0&&e.description!==r.description)throw new Error(`Encoder and decoder must have the same description, got [${e.description}] and [${r.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`);return {decode:r.decode,description:o!=null?o:e.description,encode:e.encode,fixedSize:e.fixedSize,maxSize:e.maxSize}}function I(e,r,o){return {description:o!=null?o:`fixed(${r}, ${e.description})`,fixedSize:r,maxSize:r}}function $(e,r,o){return {...I(e,r,o),encode:n=>k(e.encode(n),r)}}function O(e,r,o){return {...I(e,r,o),decode:(n,t=0)=>{N("fixCodec",r,n,t),(t>0||n.length>r)&&(n=n.slice(t,t+r)),e.fixedSize!==null&&(n=k(n,e.fixedSize));let[i]=e.decode(n,0);return [i,t+r]}}}function J(e,r,o,n){if(n<r||n>o)throw new Error(`Codec [${e}] expected number to be in the range [${r}, ${o}], got ${n}.`)}function _(e){var n;let r,o=e.name;return e.size>1&&(r=!("endian"in e.config)||e.config.endian===0,o+=r?"(le)":"(be)"),{description:(n=e.config.description)!=null?n:o,fixedSize:e.size,littleEndian:r,maxSize:e.size}}function F(e){let r=_(e);return {description:r.description,encode(o){e.range&&J(e.name,e.range[0],e.range[1],o);let n=new ArrayBuffer(e.size);return e.set(new DataView(n),o,r.littleEndian),new Uint8Array(n)},fixedSize:r.fixedSize,maxSize:r.maxSize}}function V(e){let r=_(e);return {decode(o,n=0){S(r.description,o,n),N(r.description,e.size,o,n);let t=new DataView(Q(o,n,e.size));return [e.get(t,r.littleEndian),n+e.size]},description:r.description,fixedSize:r.fixedSize,maxSize:r.maxSize}}function Q(e,r,o){let n=e.byteOffset+(r!=null?r:0),t=o!=null?o:e.byteLength;return e.buffer.slice(n,n+t)}var B=(e={})=>F({config:e,name:"u32",range:[0,+"0xffffffff"],set:(r,o,n)=>r.setUint32(0,o,n),size:4}),h=(e={})=>V({config:e,get:(r,o)=>r.getUint32(0,o),name:"u32",size:4});var T=(e={})=>F({config:e,name:"u8",range:[0,+"0xff"],set:(r,o)=>r.setUint8(0,o),size:1}),E=(e={})=>V({config:e,get:r=>r.getUint8(0),name:"u8",size:1});function L(e){return e.reduce((r,o)=>r===null||o===null?null:Math.max(r,o),0)}function p(e){return e.reduce((r,o)=>r===null||o===null?null:r+o,0)}function A(e,r,o,n){if(typeof e=="number")return [e,n];if(typeof e=="object")return e.decode(o,n);if(e==="remainder"){let t=p(r);if(t===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');let i=o.slice(n).length;if(i%t!==0)throw new Error(`The remainder of the byte array (${i} bytes) cannot be split into chunks of ${t} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${i} modulo ${t} should be equal to zero.`);return [i/t,n]}throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(e)}`)}function v(e){return typeof e=="object"?e.description:`${e}`}function b(e,r){if(typeof e!="number")return null;if(e===0)return 0;let o=p(r);return o===null?null:o*e}function w(e,r){return typeof e=="object"?e.encode(r):new Uint8Array}function D(e,r,o){if(r!==o)throw new Error(`Expected [${e}] to have ${r} items, got ${o}.`)}function K(e,r,o){if(r==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:o!=null?o:`array(${e.description}; ${v(r)})`,fixedSize:b(r,[e.fixedSize]),maxSize:b(r,[e.maxSize])}}function X(e,r={}){var n;let o=(n=r.size)!=null?n:B();return {...K(e,o,r.description),encode:t=>(typeof o=="number"&&D("array",o,t.length),l([w(o,t.length),...t.map(i=>e.encode(i))]))}}function Y(e,r={}){var n;let o=(n=r.size)!=null?n:h();return {...K(e,o,r.description),decode:(t,i=0)=>{if(typeof o=="object"&&t.slice(i).length===0)return [[],i];let[d,c]=A(o,[e.fixedSize],t,i);i=c;let a=[];for(let f=0;f<d;f+=1){let[s,m]=e.decode(t,i);a.push(s),i=m;}return [a,i]}}}function Ge(e,r={}){return C(X(e,r),Y(e,r))}var Z=(e,r={})=>{var i,d;let o=typeof r=="boolean"?{backward:r}:r,n=(i=o.backward)!=null?i:!1,t=n?"; backward":"";return {description:(d=o.description)!=null?d:`bitArray(${e}${t})`,encode(c){var f;let a=[];for(let s=0;s<e;s+=1){let m=0;for(let u=0;u<8;u+=1){let g=Number((f=c[s*8+u])!=null?f:0);m|=g<<(n?u:7-u);}n?a.unshift(m):a.push(m);}return new Uint8Array(a)},fixedSize:e,maxSize:e}},ee=(e,r={})=>{var i,d;let o=typeof r=="boolean"?{backward:r}:r,n=(i=o.backward)!=null?i:!1,t=n?"; backward":"";return {decode(c,a=0){N("bitArray",e,c,a);let f=[],s=c.slice(a,a+e);return s=n?s.reverse():s,s.forEach(m=>{for(let u=0;u<8;u+=1)n?(f.push(!!(m&1)),m>>=1):(f.push(!!(m&128)),m<<=1);}),[f,a+e]},description:(d=o.description)!=null?d:`bitArray(${e}${t})`,fixedSize:e,maxSize:e}},rr=(e,r={})=>C(Z(e,r),ee(e,r));function re(e={}){var o,n;let r=(o=e.size)!=null?o:T();return U(r,"Codec [bool] requires a fixed size."),{description:(n=e.description)!=null?n:`bool(${r.description})`,encode:t=>r.encode(t?1:0),fixedSize:r.fixedSize,maxSize:r.fixedSize}}function oe(e={}){var o,n;let r=(o=e.size)!=null?o:E();return U(r,"Codec [bool] requires a fixed size."),{decode:(t,i=0)=>{S("bool",t,i);let[d,c]=r.decode(t,i);return [d===1,c]},description:(n=e.description)!=null?n:`bool(${r.description})`,fixedSize:r.fixedSize,maxSize:r.fixedSize}}function Cr(e={}){return C(re(e),oe(e))}function ne(e={}){var i,d;let r=(i=e.size)!=null?i:"variable",o=typeof r=="object"?r.description:`${r}`,n=(d=e.description)!=null?d:`bytes(${o})`,t={description:n,encode:c=>c,fixedSize:null,maxSize:null};return r==="variable"?t:typeof r=="number"?$(t,r,n):{...t,encode:c=>{let a=t.encode(c),f=r.encode(a.length);return l([f,a])}}}function te(e={}){var i,d;let r=(i=e.size)!=null?i:"variable",o=typeof r=="object"?r.description:`${r}`,n=(d=e.description)!=null?d:`bytes(${o})`,t={decode:(c,a=0)=>{let f=c.slice(a);return [f,a+f.length]},description:n,fixedSize:null,maxSize:null};return r==="variable"?t:typeof r=="number"?O(t,r,n):{...t,decode:(c,a=0)=>{S("bytes",c,a);let[f,s]=r.decode(c,a),m=Number(f);a=s;let u=c.slice(a,a+m);N("bytes",m,u);let[g,z]=t.decode(u);return a+=z,[g,a]}}}function yr(e={}){return C(ne(e),te(e))}function P(e,r,o){let n=e.map(([c,a])=>`${String(c)}${a?`: ${a.description}`:""}`).join(", "),i=e.every((c,a,f)=>c[1].fixedSize===f[0][1].fixedSize)?e[0][1].fixedSize:null,d=L(e.map(([,c])=>c.maxSize));return {description:o!=null?o:`dataEnum(${n}; ${r.description})`,fixedSize:e.length===0?r.fixedSize:p([r.fixedSize,i]),maxSize:e.length===0?r.maxSize:p([r.maxSize,d])}}function ie(e,r={}){var n;let o=(n=r.size)!=null?n:T();return {...P(e,o,r.description),encode:t=>{let i=e.findIndex(([f])=>t.__kind===f);if(i<0)throw new Error(`Invalid data enum variant. Expected one of [${e.map(([f])=>f).join(", ")}], got "${t.__kind}".`);let d=o.encode(i),a=e[i][1].encode(t);return l([d,a])}}}function de(e,r={}){var n;let o=(n=r.size)!=null?n:E();return {...P(e,o,r.description),decode:(t,i=0)=>{var m;S("dataEnum",t,i);let[d,c]=o.decode(t,i);i=c;let a=(m=e[Number(d)])!=null?m:null;if(!a)throw new Error(`Enum discriminator out of range. Expected a number between 0 and ${e.length-1}, got ${d}.`);let[f,s]=a[1].decode(t,i);return i=s,[{__kind:a[0],...f!=null?f:{}},i]}}}function Or(e,r={}){return C(ie(e,r),de(e,r))}function j(e,r,o,n){if(o==="remainder"&&(e.fixedSize===null||r.fixedSize===null))throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:n!=null?n:`map(${e.description}, ${r.description}; ${v(o)})`,fixedSize:b(o,[e.fixedSize,r.fixedSize]),maxSize:b(o,[e.maxSize,r.maxSize])}}function ce(e,r,o={}){var t;let n=(t=o.size)!=null?t:B();return {...j(e,r,n,o.description),encode:i=>{typeof n=="number"&&D("map",n,i.size);let d=Array.from(i,([c,a])=>l([e.encode(c),r.encode(a)]));return l([w(n,i.size),...d])}}}function ae(e,r,o={}){var t;let n=(t=o.size)!=null?t:h();return {...j(e,r,n,o.description),decode:(i,d=0)=>{let c=new Map;if(typeof n=="object"&&i.slice(d).length===0)return [c,d];let[a,f]=A(n,[e.fixedSize,r.fixedSize],i,d);d=f;for(let s=0;s<a;s+=1){let[m,u]=e.decode(i,d);d=u;let[g,z]=r.decode(i,d);d=z,c.set(m,g);}return [c,d]}}}function Xr(e,r,o={}){return C(ce(e,r,o),ae(e,r,o))}function M(e,r,o,n){let t=`; ${r.description}`,i=e.fixedSize===0?r.fixedSize:null;return o&&(U(e,"Fixed nullables can only be used with fixed-size codecs."),U(r,"Fixed nullables can only be used with fixed-size prefix."),t+="; fixed",i=r.fixedSize+e.fixedSize),{description:n!=null?n:`nullable(${e.description+t})`,fixedSize:i,maxSize:p([r.maxSize,e.maxSize])}}function fe(e,r={}){var t,i;let o=(t=r.prefix)!=null?t:T(),n=(i=r.fixed)!=null?i:!1;return {...M(e,o,n,r.description),encode:d=>{let c=o.encode(+(d!==null)),a=d!==null?e.encode(d):new Uint8Array;return a=n?k(a,e.fixedSize):a,l([c,a])}}}function ue(e,r={}){var t,i;let o=(t=r.prefix)!=null?t:E(),n=(i=r.fixed)!=null?i:!1;return {...M(e,o,n,r.description),decode:(d,c=0)=>{var g,z;if(d.length-c<=0)return [null,c];let a=c+((g=o.fixedSize)!=null?g:0)+((z=e.fixedSize)!=null?z:0),[f,s]=o.decode(d,c);if(c=s,f===0)return [null,n?a:c];let[m,u]=e.decode(d,c);return c=u,[m,n?a:c]}}}function mo(e,r={}){return C(fe(e,r),ue(e,r))}function H(e,r,o){let n=Object.keys(e),t=Object.values(e),i=t.some(s=>typeof s=="number"),d=t.filter(s=>typeof s=="string").join(", "),c=0,a=i?t.length/2-1:t.length-1,f=i?[...n]:[...new Set([...n,...t])];return {description:o!=null?o:`enum(${d}; ${r.description})`,enumKeys:n,enumValues:t,fixedSize:r.fixedSize,isNumericEnum:i,maxRange:a,maxSize:r.maxSize,minRange:c,stringValues:f}}function se(e,r={}){var m;let o=(m=r.size)!=null?m:T(),{description:n,fixedSize:t,maxSize:i,minRange:d,maxRange:c,stringValues:a,enumKeys:f,enumValues:s}=H(e,o,r.description);return {description:n,encode:u=>{let g=typeof u=="number"&&(u<d||u>c),z=typeof u=="string"&&!a.includes(u);if(g||z)throw new Error(`Invalid scalar enum variant. Expected one of [${a.join(", ")}] or a number between ${d} and ${c}, got "${u}".`);if(typeof u=="number")return o.encode(u);let y=s.indexOf(u);return y>=0?o.encode(y):o.encode(f.indexOf(u))},fixedSize:t,maxSize:i}}function me(e,r={}){var s;let o=(s=r.size)!=null?s:E(),{description:n,fixedSize:t,maxSize:i,minRange:d,maxRange:c,isNumericEnum:a,enumValues:f}=H(e,o,r.description);return {decode:(m,u=0)=>{S("enum",m,u);let[g,z]=o.decode(m,u),y=Number(g);if(u=z,y<d||y>c)throw new Error(`Enum discriminator out of range. Expected a number between ${d} and ${c}, got ${y}.`);return [a?y:f[y],u]},description:n,fixedSize:t,maxSize:i}}function No(e,r={}){return C(se(e,r),me(e,r))}function R(e,r,o){if(r==="remainder"&&e.fixedSize===null)throw new Error('Codecs of "remainder" size must have fixed-size items.');return {description:o!=null?o:`set(${e.description}; ${v(r)})`,fixedSize:b(r,[e.fixedSize]),maxSize:b(r,[e.maxSize])}}function Ce(e,r={}){var n;let o=(n=r.size)!=null?n:B();return {...R(e,o,r.description),encode:t=>{typeof o=="number"&&t.size!==o&&D("set",o,t.size);let i=Array.from(t,d=>e.encode(d));return l([w(o,t.size),...i])}}}function xe(e,r={}){var n;let o=(n=r.size)!=null?n:h();return {...R(e,o,r.description),decode:(t,i=0)=>{let d=new Set;if(typeof o=="object"&&t.slice(i).length===0)return [d,i];let[c,a]=A(o,[e.fixedSize],t,i);i=a;for(let f=0;f<c;f+=1){let[s,m]=e.decode(t,i);i=m,d.add(s);}return [d,i]}}}function Po(e,r={}){return C(Ce(e,r),xe(e,r))}function W(e,r){let o=e.map(([n,t])=>`${String(n)}: ${t.description}`).join(", ");return {description:r!=null?r:`struct(${o})`,fixedSize:p(e.map(([,n])=>n.fixedSize)),maxSize:p(e.map(([,n])=>n.maxSize))}}function le(e,r={}){return {...W(e,r.description),encode:o=>{let n=e.map(([t,i])=>i.encode(o[t]));return l(n)}}}function pe(e,r={}){return {...W(e,r.description),decode:(o,n=0)=>{let t={};return e.forEach(([i,d])=>{let[c,a]=d.decode(o,n);n=a,t[i]=c;}),[t,n]}}}function Xo(e,r={}){return C(le(e,r),pe(e,r))}function G(e,r){let o=e.map(n=>n.description).join(", ");return {description:r!=null?r:`tuple(${o})`,fixedSize:p(e.map(n=>n.fixedSize)),maxSize:p(e.map(n=>n.maxSize))}}function ge(e,r={}){return {...G(e,r.description),encode:o=>(D("tuple",e.length,o.length),l(e.map((n,t)=>n.encode(o[t]))))}}function ze(e,r={}){return {...G(e,r.description),decode:(o,n=0)=>{let t=[];return e.forEach(i=>{let[d,c]=i.decode(o,n);t.push(d),n=c;}),[t,n]}}}function fn(e,r={}){return C(ge(e,r),ze(e,r))}function Se(e={}){var r;return {description:(r=e.description)!=null?r:"unit",encode:()=>new Uint8Array,fixedSize:0,maxSize:0}}function be(e={}){var r;return {decode:(o,n=0)=>[void 0,n],description:(r=e.description)!=null?r:"unit",fixedSize:0,maxSize:0}}function gn(e={}){return C(Se(e),be(e))}
|
|
6
6
|
|
|
7
|
-
exports.assertValidNumberOfItemsForCodec =
|
|
8
|
-
exports.decodeArrayLikeCodecSize =
|
|
9
|
-
exports.getArrayCodec =
|
|
10
|
-
exports.getArrayDecoder =
|
|
11
|
-
exports.getArrayEncoder =
|
|
12
|
-
exports.getArrayLikeCodecSizeDescription =
|
|
13
|
-
exports.getArrayLikeCodecSizeFromChildren =
|
|
14
|
-
exports.getArrayLikeCodecSizePrefix =
|
|
15
|
-
exports.getBitArrayCodec =
|
|
16
|
-
exports.getBitArrayDecoder =
|
|
17
|
-
exports.getBitArrayEncoder =
|
|
18
|
-
exports.getBooleanCodec =
|
|
19
|
-
exports.getBooleanDecoder =
|
|
20
|
-
exports.getBooleanEncoder =
|
|
21
|
-
exports.getBytesCodec =
|
|
22
|
-
exports.getBytesDecoder =
|
|
23
|
-
exports.getBytesEncoder =
|
|
24
|
-
exports.getDataEnumCodec =
|
|
25
|
-
exports.getDataEnumDecoder =
|
|
26
|
-
exports.getDataEnumEncoder =
|
|
27
|
-
exports.getMapCodec =
|
|
28
|
-
exports.getMapDecoder =
|
|
29
|
-
exports.getMapEncoder =
|
|
30
|
-
exports.getNullableCodec =
|
|
31
|
-
exports.getNullableDecoder =
|
|
32
|
-
exports.getNullableEncoder =
|
|
33
|
-
exports.getScalarEnumCodec =
|
|
34
|
-
exports.getScalarEnumDecoder =
|
|
35
|
-
exports.getScalarEnumEncoder =
|
|
36
|
-
exports.getSetCodec =
|
|
37
|
-
exports.getSetDecoder =
|
|
38
|
-
exports.getSetEncoder =
|
|
39
|
-
exports.getStructCodec =
|
|
40
|
-
exports.getStructDecoder =
|
|
41
|
-
exports.getStructEncoder =
|
|
42
|
-
exports.getTupleCodec =
|
|
43
|
-
exports.getTupleDecoder =
|
|
44
|
-
exports.getTupleEncoder =
|
|
45
|
-
exports.getUnitCodec =
|
|
46
|
-
exports.getUnitDecoder =
|
|
47
|
-
exports.getUnitEncoder =
|
|
7
|
+
exports.assertValidNumberOfItemsForCodec = D;
|
|
8
|
+
exports.decodeArrayLikeCodecSize = A;
|
|
9
|
+
exports.getArrayCodec = Ge;
|
|
10
|
+
exports.getArrayDecoder = Y;
|
|
11
|
+
exports.getArrayEncoder = X;
|
|
12
|
+
exports.getArrayLikeCodecSizeDescription = v;
|
|
13
|
+
exports.getArrayLikeCodecSizeFromChildren = b;
|
|
14
|
+
exports.getArrayLikeCodecSizePrefix = w;
|
|
15
|
+
exports.getBitArrayCodec = rr;
|
|
16
|
+
exports.getBitArrayDecoder = ee;
|
|
17
|
+
exports.getBitArrayEncoder = Z;
|
|
18
|
+
exports.getBooleanCodec = Cr;
|
|
19
|
+
exports.getBooleanDecoder = oe;
|
|
20
|
+
exports.getBooleanEncoder = re;
|
|
21
|
+
exports.getBytesCodec = yr;
|
|
22
|
+
exports.getBytesDecoder = te;
|
|
23
|
+
exports.getBytesEncoder = ne;
|
|
24
|
+
exports.getDataEnumCodec = Or;
|
|
25
|
+
exports.getDataEnumDecoder = de;
|
|
26
|
+
exports.getDataEnumEncoder = ie;
|
|
27
|
+
exports.getMapCodec = Xr;
|
|
28
|
+
exports.getMapDecoder = ae;
|
|
29
|
+
exports.getMapEncoder = ce;
|
|
30
|
+
exports.getNullableCodec = mo;
|
|
31
|
+
exports.getNullableDecoder = ue;
|
|
32
|
+
exports.getNullableEncoder = fe;
|
|
33
|
+
exports.getScalarEnumCodec = No;
|
|
34
|
+
exports.getScalarEnumDecoder = me;
|
|
35
|
+
exports.getScalarEnumEncoder = se;
|
|
36
|
+
exports.getSetCodec = Po;
|
|
37
|
+
exports.getSetDecoder = xe;
|
|
38
|
+
exports.getSetEncoder = Ce;
|
|
39
|
+
exports.getStructCodec = Xo;
|
|
40
|
+
exports.getStructDecoder = pe;
|
|
41
|
+
exports.getStructEncoder = le;
|
|
42
|
+
exports.getTupleCodec = fn;
|
|
43
|
+
exports.getTupleDecoder = ze;
|
|
44
|
+
exports.getTupleEncoder = ge;
|
|
45
|
+
exports.getUnitCodec = gn;
|
|
46
|
+
exports.getUnitDecoder = be;
|
|
47
|
+
exports.getUnitEncoder = Se;
|
|
48
48
|
|
|
49
49
|
return exports;
|
|
50
50
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/codecs-data-structures",
|
|
3
|
-
"version": "2.0.0-experimental.
|
|
3
|
+
"version": "2.0.0-experimental.ef09aec",
|
|
4
4
|
"description": "Codecs for various data structures",
|
|
5
5
|
"exports": {
|
|
6
6
|
"browser": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"node": ">=17.4"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@solana/codecs-core": "2.0.0-experimental.
|
|
53
|
-
"@solana/codecs-numbers": "2.0.0-experimental.
|
|
52
|
+
"@solana/codecs-core": "2.0.0-experimental.ef09aec",
|
|
53
|
+
"@solana/codecs-numbers": "2.0.0-experimental.ef09aec"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@solana/eslint-config-solana": "^1.0.2",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"jest-runner-eslint": "^2.1.2",
|
|
68
68
|
"jest-runner-prettier": "^1.0.0",
|
|
69
69
|
"prettier": "^2.8",
|
|
70
|
-
"tsup": "
|
|
70
|
+
"tsup": "^8.0.1",
|
|
71
71
|
"typescript": "^5.2.2",
|
|
72
72
|
"version-from-git": "^1.1.1",
|
|
73
|
-
"@solana/codecs-strings": "2.0.0-experimental.
|
|
73
|
+
"@solana/codecs-strings": "2.0.0-experimental.ef09aec",
|
|
74
74
|
"build-scripts": "0.0.0",
|
|
75
75
|
"test-config": "0.0.0",
|
|
76
76
|
"tsconfig": "0.0.0"
|