@solana/codecs-data-structures 2.0.0-experimental.be901cf → 2.0.0-experimental.c156b67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/index.browser.cjs +96 -94
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +94 -94
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.development.js +145 -121
  6. package/dist/index.development.js.map +1 -1
  7. package/dist/index.native.js +94 -94
  8. package/dist/index.native.js.map +1 -1
  9. package/dist/index.node.cjs +94 -94
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.js +96 -94
  12. package/dist/index.node.js.map +1 -1
  13. package/dist/index.production.min.js +40 -40
  14. package/dist/types/array-like-codec-size.d.ts.map +1 -0
  15. package/dist/types/array.d.ts +9 -9
  16. package/dist/types/array.d.ts.map +1 -0
  17. package/dist/types/assertions.d.ts.map +1 -0
  18. package/dist/types/bit-array.d.ts +9 -9
  19. package/dist/types/bit-array.d.ts.map +1 -0
  20. package/dist/types/boolean.d.ts +9 -9
  21. package/dist/types/boolean.d.ts.map +1 -0
  22. package/dist/types/bytes.d.ts +9 -9
  23. package/dist/types/bytes.d.ts.map +1 -0
  24. package/dist/types/data-enum.d.ts +9 -9
  25. package/dist/types/data-enum.d.ts.map +1 -0
  26. package/dist/types/index.d.ts.map +1 -0
  27. package/dist/types/map.d.ts +9 -9
  28. package/dist/types/map.d.ts.map +1 -0
  29. package/dist/types/nullable.d.ts +9 -9
  30. package/dist/types/nullable.d.ts.map +1 -0
  31. package/dist/types/scalar-enum.d.ts +9 -9
  32. package/dist/types/scalar-enum.d.ts.map +1 -0
  33. package/dist/types/set.d.ts +9 -9
  34. package/dist/types/set.d.ts.map +1 -0
  35. package/dist/types/struct.d.ts +9 -9
  36. package/dist/types/struct.d.ts.map +1 -0
  37. package/dist/types/tuple.d.ts +9 -9
  38. package/dist/types/tuple.d.ts.map +1 -0
  39. package/dist/types/unit.d.ts +9 -9
  40. package/dist/types/unit.d.ts.map +1 -0
  41. package/dist/types/utils.d.ts.map +1 -0
  42. package/package.json +6 -6
@@ -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 ?? "Expected a fixed-size codec, got a variable-size one.");
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 ?? encoder.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 ?? `fixed(${fixedBytes}, ${data.description})`,
73
+ description: description != null ? description : `fixed(${fixedBytes}, ${data.description})`,
74
74
  fixedSize: fixedBytes,
75
75
  maxSize: fixedBytes
76
76
  };
@@ -107,14 +107,15 @@ 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) {
113
- littleEndian = !("endian" in input.options) || input.options.endian === 0;
114
+ littleEndian = !("endian" in input.config) || input.config.endian === 0;
114
115
  defaultDescription += littleEndian ? "(le)" : "(be)";
115
116
  }
116
117
  return {
117
- description: input.options.description ?? defaultDescription,
118
+ description: (_a = input.config.description) != null ? _a : defaultDescription,
118
119
  fixedSize: input.size,
119
120
  littleEndian,
120
121
  maxSize: input.size
@@ -151,34 +152,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
151
152
  };
152
153
  }
153
154
  function toArrayBuffer(bytes, offset, length) {
154
- const bytesOffset = bytes.byteOffset + (offset ?? 0);
155
- const bytesLength = length ?? bytes.byteLength;
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
- var getU32Encoder = (options = {}) => numberEncoderFactory({
159
+ var getU32Encoder = (config = {}) => numberEncoderFactory({
160
+ config,
159
161
  name: "u32",
160
- options,
161
162
  range: [0, Number("0xffffffff")],
162
163
  set: (view, value, le) => view.setUint32(0, value, le),
163
164
  size: 4
164
165
  });
165
- var getU32Decoder = (options = {}) => numberDecoderFactory({
166
+ var getU32Decoder = (config = {}) => numberDecoderFactory({
167
+ config,
166
168
  get: (view, le) => view.getUint32(0, le),
167
169
  name: "u32",
168
- options,
169
170
  size: 4
170
171
  });
171
- var getU8Encoder = (options = {}) => numberEncoderFactory({
172
+ var getU8Encoder = (config = {}) => numberEncoderFactory({
173
+ config,
172
174
  name: "u8",
173
- options,
174
175
  range: [0, Number("0xff")],
175
176
  set: (view, value) => view.setUint8(0, value),
176
177
  size: 1
177
178
  });
178
- var getU8Decoder = (options = {}) => numberDecoderFactory({
179
+ var getU8Decoder = (config = {}) => numberDecoderFactory({
180
+ config,
179
181
  get: (view) => view.getUint8(0),
180
182
  name: "u8",
181
- options,
182
183
  size: 1
183
184
  });
184
185
 
@@ -244,15 +245,16 @@ 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 ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
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
- function getArrayEncoder(item, options = {}) {
253
- const size = options.size ?? getU32Encoder();
253
+ function getArrayEncoder(item, config = {}) {
254
+ var _a;
255
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
254
256
  return {
255
- ...arrayCodecHelper(item, size, options.description),
257
+ ...arrayCodecHelper(item, size, config.description),
256
258
  encode: (value) => {
257
259
  if (typeof size === "number") {
258
260
  assertValidNumberOfItemsForCodec("array", size, value.length);
@@ -261,10 +263,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
261
263
  }
262
264
  };
263
265
  }
264
- function getArrayDecoder(item, options = {}) {
265
- const size = options.size ?? getU32Decoder();
266
+ function getArrayDecoder(item, config = {}) {
267
+ var _a;
268
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
266
269
  return {
267
- ...arrayCodecHelper(item, size, options.description),
270
+ ...arrayCodecHelper(item, size, config.description),
268
271
  decode: (bytes, offset = 0) => {
269
272
  if (typeof size === "object" && bytes.slice(offset).length === 0) {
270
273
  return [[], offset];
@@ -281,23 +284,25 @@ this.globalThis.solanaWeb3 = (function (exports) {
281
284
  }
282
285
  };
283
286
  }
284
- function getArrayCodec(item, options = {}) {
285
- return combineCodec(getArrayEncoder(item, options), getArrayDecoder(item, options));
287
+ function getArrayCodec(item, config = {}) {
288
+ return combineCodec(getArrayEncoder(item, config), getArrayDecoder(item, config));
286
289
  }
287
290
 
288
291
  // src/bit-array.ts
289
- var getBitArrayEncoder = (size, options = {}) => {
290
- const parsedOptions = typeof options === "boolean" ? { backward: options } : options;
291
- const backward = parsedOptions.backward ?? false;
292
+ var getBitArrayEncoder = (size, config = {}) => {
293
+ var _a, _b;
294
+ const parsedConfig = typeof config === "boolean" ? { backward: config } : config;
295
+ const backward = (_a = parsedConfig.backward) != null ? _a : false;
292
296
  const backwardSuffix = backward ? "; backward" : "";
293
297
  return {
294
- description: parsedOptions.description ?? `bitArray(${size}${backwardSuffix})`,
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] ?? 0);
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) {
@@ -312,9 +317,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
312
317
  maxSize: size
313
318
  };
314
319
  };
315
- var getBitArrayDecoder = (size, options = {}) => {
316
- const parsedOptions = typeof options === "boolean" ? { backward: options } : options;
317
- const backward = parsedOptions.backward ?? false;
320
+ var getBitArrayDecoder = (size, config = {}) => {
321
+ var _a, _b;
322
+ const parsedConfig = typeof config === "boolean" ? { backward: config } : config;
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,26 +341,28 @@ this.globalThis.solanaWeb3 = (function (exports) {
335
341
  });
336
342
  return [booleans, offset + size];
337
343
  },
338
- description: parsedOptions.description ?? `bitArray(${size}${backwardSuffix})`,
344
+ description: (_b = parsedConfig.description) != null ? _b : `bitArray(${size}${backwardSuffix})`,
339
345
  fixedSize: size,
340
346
  maxSize: size
341
347
  };
342
348
  };
343
- var getBitArrayCodec = (size, options = {}) => combineCodec(getBitArrayEncoder(size, options), getBitArrayDecoder(size, options));
349
+ var getBitArrayCodec = (size, config = {}) => combineCodec(getBitArrayEncoder(size, config), getBitArrayDecoder(size, config));
344
350
 
345
351
  // src/boolean.ts
346
- function getBooleanEncoder(options = {}) {
347
- const size = options.size ?? getU8Encoder();
352
+ function getBooleanEncoder(config = {}) {
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: options.description ?? `bool(${size.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
- function getBooleanDecoder(options = {}) {
357
- const size = options.size ?? getU8Decoder();
363
+ function getBooleanDecoder(config = {}) {
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,20 +370,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
362
370
  const [value, vOffset] = size.decode(bytes, offset);
363
371
  return [value === 1, vOffset];
364
372
  },
365
- description: options.description ?? `bool(${size.description})`,
373
+ description: (_b = config.description) != null ? _b : `bool(${size.description})`,
366
374
  fixedSize: size.fixedSize,
367
375
  maxSize: size.fixedSize
368
376
  };
369
377
  }
370
- function getBooleanCodec(options = {}) {
371
- return combineCodec(getBooleanEncoder(options), getBooleanDecoder(options));
378
+ function getBooleanCodec(config = {}) {
379
+ return combineCodec(getBooleanEncoder(config), getBooleanDecoder(config));
372
380
  }
373
381
 
374
382
  // src/bytes.ts
375
- function getBytesEncoder(options = {}) {
376
- const size = options.size ?? "variable";
383
+ function getBytesEncoder(config = {}) {
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 = options.description ?? `bytes(${sizeDescription})`;
387
+ const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
379
388
  const byteEncoder = {
380
389
  description,
381
390
  encode: (value) => value,
@@ -397,10 +406,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
397
406
  }
398
407
  };
399
408
  }
400
- function getBytesDecoder(options = {}) {
401
- const size = options.size ?? "variable";
409
+ function getBytesDecoder(config = {}) {
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 = options.description ?? `bytes(${sizeDescription})`;
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);
@@ -431,8 +441,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
431
441
  }
432
442
  };
433
443
  }
434
- function getBytesCodec(options = {}) {
435
- return combineCodec(getBytesEncoder(options), getBytesDecoder(options));
444
+ function getBytesCodec(config = {}) {
445
+ return combineCodec(getBytesEncoder(config), getBytesDecoder(config));
436
446
  }
437
447
 
438
448
  // src/data-enum.ts
@@ -442,15 +452,16 @@ 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 ?? `dataEnum(${fieldDescriptions}; ${prefix.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
- function getDataEnumEncoder(variants, options = {}) {
451
- const prefix = options.size ?? getU8Encoder();
460
+ function getDataEnumEncoder(variants, config = {}) {
461
+ var _a;
462
+ const prefix = (_a = config.size) != null ? _a : getU8Encoder();
452
463
  return {
453
- ...dataEnumCodecHelper(variants, prefix, options.description),
464
+ ...dataEnumCodecHelper(variants, prefix, config.description),
454
465
  encode: (variant) => {
455
466
  const discriminator = variants.findIndex(([key]) => variant.__kind === key);
456
467
  if (discriminator < 0) {
@@ -465,15 +476,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
465
476
  }
466
477
  };
467
478
  }
468
- function getDataEnumDecoder(variants, options = {}) {
469
- const prefix = options.size ?? getU8Decoder();
479
+ function getDataEnumDecoder(variants, config = {}) {
480
+ var _a;
481
+ const prefix = (_a = config.size) != null ? _a : getU8Decoder();
470
482
  return {
471
- ...dataEnumCodecHelper(variants, prefix, options.description),
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)] ?? null;
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,12 +494,12 @@ 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 ?? {} }, offset];
497
+ return [{ __kind: variantField[0], ...variant != null ? variant : {} }, offset];
485
498
  }
486
499
  };
487
500
  }
488
- function getDataEnumCodec(variants, options = {}) {
489
- return combineCodec(getDataEnumEncoder(variants, options), getDataEnumDecoder(variants, options));
501
+ function getDataEnumCodec(variants, config = {}) {
502
+ return combineCodec(getDataEnumEncoder(variants, config), getDataEnumDecoder(variants, config));
490
503
  }
491
504
 
492
505
  // src/map.ts
@@ -495,15 +508,16 @@ 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 ?? `map(${key.description}, ${value.description}; ${getArrayLikeCodecSizeDescription(size)})`,
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
- function getMapEncoder(key, value, options = {}) {
504
- const size = options.size ?? getU32Encoder();
516
+ function getMapEncoder(key, value, config = {}) {
517
+ var _a;
518
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
505
519
  return {
506
- ...mapCodecHelper(key, value, size, options.description),
520
+ ...mapCodecHelper(key, value, size, config.description),
507
521
  encode: (map) => {
508
522
  if (typeof size === "number") {
509
523
  assertValidNumberOfItemsForCodec("map", size, map.size);
@@ -513,10 +527,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
513
527
  }
514
528
  };
515
529
  }
516
- function getMapDecoder(key, value, options = {}) {
517
- const size = options.size ?? getU32Decoder();
530
+ function getMapDecoder(key, value, config = {}) {
531
+ var _a;
532
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
518
533
  return {
519
- ...mapCodecHelper(key, value, size, options.description),
534
+ ...mapCodecHelper(key, value, size, config.description),
520
535
  decode: (bytes, offset = 0) => {
521
536
  const map = /* @__PURE__ */ new Map();
522
537
  if (typeof size === "object" && bytes.slice(offset).length === 0) {
@@ -540,8 +555,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
540
555
  }
541
556
  };
542
557
  }
543
- function getMapCodec(key, value, options = {}) {
544
- return combineCodec(getMapEncoder(key, value, options), getMapDecoder(key, value, options));
558
+ function getMapCodec(key, value, config = {}) {
559
+ return combineCodec(getMapEncoder(key, value, config), getMapDecoder(key, value, config));
545
560
  }
546
561
 
547
562
  // src/nullable.ts
@@ -555,16 +570,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
555
570
  fixedSize = prefix.fixedSize + item.fixedSize;
556
571
  }
557
572
  return {
558
- description: description ?? `nullable(${item.description + descriptionSuffix})`,
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
- function getNullableEncoder(item, options = {}) {
564
- const prefix = options.prefix ?? getU8Encoder();
565
- const fixed = options.fixed ?? false;
578
+ function getNullableEncoder(item, config = {}) {
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
- ...nullableCodecHelper(item, prefix, fixed, options.description),
583
+ ...nullableCodecHelper(item, prefix, fixed, config.description),
568
584
  encode: (option) => {
569
585
  const prefixByte = prefix.encode(Number(option !== null));
570
586
  let itemBytes = option !== null ? item.encode(option) : new Uint8Array();
@@ -573,16 +589,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
573
589
  }
574
590
  };
575
591
  }
576
- function getNullableDecoder(item, options = {}) {
577
- const prefix = options.prefix ?? getU8Decoder();
578
- const fixed = options.fixed ?? false;
592
+ function getNullableDecoder(item, config = {}) {
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
- ...nullableCodecHelper(item, prefix, fixed, options.description),
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 ?? 0) + (item.fixedSize ?? 0);
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) {
@@ -594,8 +612,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
594
612
  }
595
613
  };
596
614
  }
597
- function getNullableCodec(item, options = {}) {
598
- return combineCodec(getNullableEncoder(item, options), getNullableDecoder(item, options));
615
+ function getNullableCodec(item, config = {}) {
616
+ return combineCodec(getNullableEncoder(item, config), getNullableDecoder(item, config));
599
617
  }
600
618
 
601
619
  // src/scalar-enum.ts
@@ -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 ?? `enum(${valueDescriptions}; ${prefix.description})`,
629
+ description: description != null ? description : `enum(${valueDescriptions}; ${prefix.description})`,
612
630
  enumKeys,
613
631
  enumValues,
614
632
  fixedSize: prefix.fixedSize,
@@ -619,9 +637,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
619
637
  stringValues
620
638
  };
621
639
  }
622
- function getScalarEnumEncoder(constructor, options = {}) {
623
- const prefix = options.size ?? getU8Encoder();
624
- const { description, fixedSize, maxSize, minRange, maxRange, stringValues, enumKeys, enumValues } = scalarEnumCoderHelper(constructor, prefix, options.description);
640
+ function getScalarEnumEncoder(constructor, config = {}) {
641
+ var _a;
642
+ const prefix = (_a = config.size) != null ? _a : getU8Encoder();
643
+ const { description, fixedSize, maxSize, minRange, maxRange, stringValues, enumKeys, enumValues } = scalarEnumCoderHelper(constructor, prefix, config.description);
625
644
  return {
626
645
  description,
627
646
  encode: (value) => {
@@ -643,12 +662,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
643
662
  maxSize
644
663
  };
645
664
  }
646
- function getScalarEnumDecoder(constructor, options = {}) {
647
- const prefix = options.size ?? getU8Decoder();
665
+ function getScalarEnumDecoder(constructor, config = {}) {
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,
651
- options.description
671
+ config.description
652
672
  );
653
673
  return {
654
674
  decode: (bytes, offset = 0) => {
@@ -668,8 +688,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
668
688
  maxSize
669
689
  };
670
690
  }
671
- function getScalarEnumCodec(constructor, options = {}) {
672
- return combineCodec(getScalarEnumEncoder(constructor, options), getScalarEnumDecoder(constructor, options));
691
+ function getScalarEnumCodec(constructor, config = {}) {
692
+ return combineCodec(getScalarEnumEncoder(constructor, config), getScalarEnumDecoder(constructor, config));
673
693
  }
674
694
 
675
695
  // src/set.ts
@@ -678,15 +698,16 @@ 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 ?? `set(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
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
- function getSetEncoder(item, options = {}) {
687
- const size = options.size ?? getU32Encoder();
706
+ function getSetEncoder(item, config = {}) {
707
+ var _a;
708
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
688
709
  return {
689
- ...setCodecHelper(item, size, options.description),
710
+ ...setCodecHelper(item, size, config.description),
690
711
  encode: (set) => {
691
712
  if (typeof size === "number" && set.size !== size) {
692
713
  assertValidNumberOfItemsForCodec("set", size, set.size);
@@ -696,10 +717,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
696
717
  }
697
718
  };
698
719
  }
699
- function getSetDecoder(item, options = {}) {
700
- const size = options.size ?? getU32Decoder();
720
+ function getSetDecoder(item, config = {}) {
721
+ var _a;
722
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
701
723
  return {
702
- ...setCodecHelper(item, size, options.description),
724
+ ...setCodecHelper(item, size, config.description),
703
725
  decode: (bytes, offset = 0) => {
704
726
  const set = /* @__PURE__ */ new Set();
705
727
  if (typeof size === "object" && bytes.slice(offset).length === 0) {
@@ -716,31 +738,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
716
738
  }
717
739
  };
718
740
  }
719
- function getSetCodec(item, options = {}) {
720
- return combineCodec(getSetEncoder(item, options), getSetDecoder(item, options));
741
+ function getSetCodec(item, config = {}) {
742
+ return combineCodec(getSetEncoder(item, config), getSetDecoder(item, config));
721
743
  }
722
744
 
723
745
  // src/struct.ts
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 ?? `struct(${fieldDescriptions})`,
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
  };
731
753
  }
732
- function getStructEncoder(fields, options = {}) {
754
+ function getStructEncoder(fields, config = {}) {
733
755
  return {
734
- ...structCodecHelper(fields, options.description),
756
+ ...structCodecHelper(fields, config.description),
735
757
  encode: (struct) => {
736
758
  const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
737
759
  return mergeBytes(fieldBytes);
738
760
  }
739
761
  };
740
762
  }
741
- function getStructDecoder(fields, options = {}) {
763
+ function getStructDecoder(fields, config = {}) {
742
764
  return {
743
- ...structCodecHelper(fields, options.description),
765
+ ...structCodecHelper(fields, config.description),
744
766
  decode: (bytes, offset = 0) => {
745
767
  const struct = {};
746
768
  fields.forEach(([key, codec]) => {
@@ -752,31 +774,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
752
774
  }
753
775
  };
754
776
  }
755
- function getStructCodec(fields, options = {}) {
756
- return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
777
+ function getStructCodec(fields, config = {}) {
778
+ return combineCodec(getStructEncoder(fields, config), getStructDecoder(fields, config));
757
779
  }
758
780
 
759
781
  // src/tuple.ts
760
782
  function tupleCodecHelper(items, description) {
761
783
  const itemDescriptions = items.map((item) => item.description).join(", ");
762
784
  return {
763
- description: description ?? `tuple(${itemDescriptions})`,
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
  };
767
789
  }
768
- function getTupleEncoder(items, options = {}) {
790
+ function getTupleEncoder(items, config = {}) {
769
791
  return {
770
- ...tupleCodecHelper(items, options.description),
792
+ ...tupleCodecHelper(items, config.description),
771
793
  encode: (value) => {
772
794
  assertValidNumberOfItemsForCodec("tuple", items.length, value.length);
773
795
  return mergeBytes(items.map((item, index) => item.encode(value[index])));
774
796
  }
775
797
  };
776
798
  }
777
- function getTupleDecoder(items, options = {}) {
799
+ function getTupleDecoder(items, config = {}) {
778
800
  return {
779
- ...tupleCodecHelper(items, options.description),
801
+ ...tupleCodecHelper(items, config.description),
780
802
  decode: (bytes, offset = 0) => {
781
803
  const values = [];
782
804
  items.forEach((codec) => {
@@ -788,32 +810,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
788
810
  }
789
811
  };
790
812
  }
791
- function getTupleCodec(items, options = {}) {
813
+ function getTupleCodec(items, config = {}) {
792
814
  return combineCodec(
793
- getTupleEncoder(items, options),
794
- getTupleDecoder(items, options)
815
+ getTupleEncoder(items, config),
816
+ getTupleDecoder(items, config)
795
817
  );
796
818
  }
797
819
 
798
820
  // src/unit.ts
799
- function getUnitEncoder(options = {}) {
821
+ function getUnitEncoder(config = {}) {
822
+ var _a;
800
823
  return {
801
- description: options.description ?? "unit",
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
- function getUnitDecoder(options = {}) {
830
+ function getUnitDecoder(config = {}) {
831
+ var _a;
808
832
  return {
809
833
  decode: (_bytes, offset = 0) => [void 0, offset],
810
- description: options.description ?? "unit",
834
+ description: (_a = config.description) != null ? _a : "unit",
811
835
  fixedSize: 0,
812
836
  maxSize: 0
813
837
  };
814
838
  }
815
- function getUnitCodec(options = {}) {
816
- return combineCodec(getUnitEncoder(options), getUnitDecoder(options));
839
+ function getUnitCodec(config = {}) {
840
+ return combineCodec(getUnitEncoder(config), getUnitDecoder(config));
817
841
  }
818
842
 
819
843
  exports.assertValidNumberOfItemsForCodec = assertValidNumberOfItemsForCodec;