@solana/kit 8.3.0 → 8.4.0-canary-20260918134912

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.
@@ -292,6 +292,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
292
292
  var SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_BYTES = 8078025;
293
293
  var SOLANA_ERROR__CODECS__INVALID_UTF8_BYTES = 8078026;
294
294
  var SOLANA_ERROR__CODECS__INVALID_UTF8_STRING = 8078027;
295
+ var SOLANA_ERROR__CODECS__SENTINEL_MISSING_AT_END_OF_BYTES = 8078028;
296
+ var SOLANA_ERROR__CODECS__SENTINEL_MUST_NOT_BE_EMPTY = 8078029;
295
297
  var SOLANA_ERROR__FIXED_POINTS__INVALID_TOTAL_BITS = 809e4;
296
298
  var SOLANA_ERROR__FIXED_POINTS__INVALID_FRACTIONAL_BITS = 8090001;
297
299
  var SOLANA_ERROR__FIXED_POINTS__INVALID_DECIMALS = 8090002;
@@ -381,7 +383,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
381
383
  [SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE]: "Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",
382
384
  [SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE]: "Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",
383
385
  [SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE]: "Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",
386
+ [SOLANA_ERROR__CODECS__SENTINEL_MISSING_AT_END_OF_BYTES]: "Codec [$codecDescription] expected sentinel [$hexSentinel] to terminate the collection, but reached the end of the byte array without it.",
384
387
  [SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES]: "Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",
388
+ [SOLANA_ERROR__CODECS__SENTINEL_MUST_NOT_BE_EMPTY]: "The sentinel must not be empty.",
385
389
  [SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE]: "Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",
386
390
  [SOLANA_ERROR__CODECS__EXPECTED_DECODER_TO_CONSUME_ENTIRE_BYTE_ARRAY]: "This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",
387
391
  [SOLANA_ERROR__CODECS__INVALID_PATTERN_MATCH_VALUE]: "Invalid pattern match value. The provided value does not match any of the specified patterns.",
@@ -1763,7 +1767,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1763
1767
  bytes.set([n], offset);
1764
1768
  return 1 + offset;
1765
1769
  }
1766
- const hexBytes2 = new Uint8Array(al);
1770
+ const hexBytes3 = new Uint8Array(al);
1767
1771
  for (let i = 0, j = 0; i < al; i++) {
1768
1772
  const c1 = value.charCodeAt(j++);
1769
1773
  const c2 = value.charCodeAt(j++);
@@ -1775,10 +1779,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1775
1779
  value
1776
1780
  });
1777
1781
  }
1778
- hexBytes2[i] = !Number.isNaN(c2) ? n1 << 4 | (n2 != null ? n2 : 0) : n1;
1782
+ hexBytes3[i] = !Number.isNaN(c2) ? n1 << 4 | (n2 != null ? n2 : 0) : n1;
1779
1783
  }
1780
- bytes.set(hexBytes2, offset);
1781
- return hexBytes2.length + offset;
1784
+ bytes.set(hexBytes3, offset);
1785
+ return hexBytes3.length + offset;
1782
1786
  }
1783
1787
  });
1784
1788
  var getBase16Decoder = () => createDecoder({
@@ -2735,13 +2739,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
2735
2739
  function getArrayEncoder(item, config = {}) {
2736
2740
  var _a, _b;
2737
2741
  const size = (_a = config.size) != null ? _a : getU32Encoder();
2742
+ assertValidSize(size);
2738
2743
  const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
2739
2744
  const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
2740
2745
  return createEncoder({
2741
2746
  ...fixedSize !== null ? { fixedSize } : {
2742
2747
  getSizeFromValue: (array) => {
2743
- const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0;
2744
- return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
2748
+ const prefixSize = isPrefixSize(size) ? getEncodedSize(array.length, size) : 0;
2749
+ const suffixSize = isSentinelSize(size) && size.strategy !== "omitted" ? size.sentinel.length : 0;
2750
+ return prefixSize + suffixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
2745
2751
  },
2746
2752
  maxSize
2747
2753
  },
@@ -2750,12 +2756,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
2750
2756
  if (typeof size === "number") {
2751
2757
  assertValidNumberOfItemsForCodec((_a2 = config.description) != null ? _a2 : "array", size, array.length);
2752
2758
  }
2753
- if (typeof size === "object") {
2759
+ if (isPrefixSize(size)) {
2754
2760
  offset = size.write(array.length, bytes, offset);
2755
2761
  }
2756
2762
  array.forEach((value) => {
2757
2763
  offset = item.write(value, bytes, offset);
2758
2764
  });
2765
+ if (isSentinelSize(size) && size.strategy !== "omitted") {
2766
+ bytes.set(size.sentinel, offset);
2767
+ offset += size.sentinel.length;
2768
+ }
2759
2769
  return offset;
2760
2770
  }
2761
2771
  });
@@ -2763,14 +2773,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
2763
2773
  function getArrayDecoder(item, config = {}) {
2764
2774
  var _a, _b;
2765
2775
  const size = (_a = config.size) != null ? _a : getU32Decoder();
2776
+ assertValidSize(size);
2766
2777
  const itemSize = getFixedSize(item);
2767
2778
  const fixedSize = computeArrayLikeCodecSize(size, itemSize);
2768
2779
  const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
2769
2780
  return createDecoder({
2770
2781
  ...fixedSize !== null ? { fixedSize } : { maxSize },
2771
2782
  read: (bytes, offset) => {
2783
+ var _a2;
2772
2784
  const array = [];
2773
- if (typeof size === "object" && !config.requireSizePrefix && offset >= bytes.length) {
2785
+ if (isPrefixSize(size) && !config.requireSizePrefix && offset >= bytes.length) {
2774
2786
  return [array, offset];
2775
2787
  }
2776
2788
  if (size === "remainder") {
@@ -2781,6 +2793,29 @@ this.globalThis.solanaWeb3 = (function (exports) {
2781
2793
  }
2782
2794
  return [array, offset];
2783
2795
  }
2796
+ if (isSentinelSize(size)) {
2797
+ const { sentinel, strategy = "required" } = size;
2798
+ while (true) {
2799
+ if (offset + sentinel.length > bytes.length) {
2800
+ if (strategy === "required") {
2801
+ throw new SolanaError(SOLANA_ERROR__CODECS__SENTINEL_MISSING_AT_END_OF_BYTES, {
2802
+ codecDescription: (_a2 = config.description) != null ? _a2 : "array",
2803
+ hexSentinel: hexBytes2(sentinel),
2804
+ sentinel
2805
+ });
2806
+ }
2807
+ break;
2808
+ }
2809
+ if (containsBytes(bytes, sentinel, offset)) {
2810
+ offset += sentinel.length;
2811
+ break;
2812
+ }
2813
+ const [value, newOffset2] = item.read(bytes, offset);
2814
+ offset = newOffset2;
2815
+ array.push(value);
2816
+ }
2817
+ return [array, offset];
2818
+ }
2784
2819
  const [resolvedSize, newOffset] = typeof size === "number" ? [size, offset] : size.read(bytes, offset);
2785
2820
  offset = newOffset;
2786
2821
  for (let i = 0; i < resolvedSize; i += 1) {
@@ -2800,6 +2835,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
2800
2835
  if (size === 0) return 0;
2801
2836
  return itemSize === null ? null : itemSize * size;
2802
2837
  }
2838
+ function isPrefixSize(size) {
2839
+ return typeof size === "object" && size !== null && !isSentinelSize(size);
2840
+ }
2841
+ function isSentinelSize(size) {
2842
+ return typeof size === "object" && size !== null && "__kind" in size && size.__kind === "sentinel";
2843
+ }
2844
+ function assertValidSize(size) {
2845
+ if (isSentinelSize(size) && size.sentinel.length === 0) {
2846
+ throw new SolanaError(SOLANA_ERROR__CODECS__SENTINEL_MUST_NOT_BE_EMPTY);
2847
+ }
2848
+ }
2849
+ function hexBytes2(bytes) {
2850
+ return bytes.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
2851
+ }
2803
2852
  function getBitArrayEncoder(size, config = {}) {
2804
2853
  var _a;
2805
2854
  const parsedConfig = typeof config === "boolean" ? { backward: config } : config;
@@ -7576,9 +7625,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
7576
7625
  getInstruction,
7577
7626
  totalSize
7578
7627
  }) {
7579
- const numberOfInstructions = Math.ceil(totalSize / REALLOC_LIMIT);
7580
- const lastInstructionSize = totalSize % REALLOC_LIMIT;
7581
- const instructions = new Array(numberOfInstructions).fill(0).map((_, i) => getInstruction(i === numberOfInstructions - 1 ? lastInstructionSize : REALLOC_LIMIT));
7628
+ const instructions = [];
7629
+ for (let remaining = totalSize; remaining > 0; remaining -= REALLOC_LIMIT) {
7630
+ instructions.push(getInstruction(Math.min(REALLOC_LIMIT, remaining)));
7631
+ }
7582
7632
  return getMessagePackerInstructionPlanFromInstructions(instructions);
7583
7633
  }
7584
7634
  function appendTransactionMessageInstructionPlan(instructionPlan, transactionMessage) {
@@ -10965,7 +11015,7 @@ ${lastLines.map((line) => ` > ${line}
10965
11015
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
10966
11016
  ...{
10967
11017
  // Keep these headers lowercase so they will override any user-supplied headers above.
10968
- "solana-client": `js/${"8.3.0"}`
11018
+ "solana-client": `js/${"8.4.0-canary-20260918134912"}`
10969
11019
  }
10970
11020
  }
10971
11021
  }),
@@ -13447,7 +13497,9 @@ ${lastLines.map((line) => ` > ${line}
13447
13497
  exports.SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE = SOLANA_ERROR__CODECS__LITERAL_UNION_DISCRIMINATOR_OUT_OF_RANGE;
13448
13498
  exports.SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE = SOLANA_ERROR__CODECS__NUMBER_OUT_OF_RANGE;
13449
13499
  exports.SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE = SOLANA_ERROR__CODECS__OFFSET_OUT_OF_RANGE;
13500
+ exports.SOLANA_ERROR__CODECS__SENTINEL_MISSING_AT_END_OF_BYTES = SOLANA_ERROR__CODECS__SENTINEL_MISSING_AT_END_OF_BYTES;
13450
13501
  exports.SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES = SOLANA_ERROR__CODECS__SENTINEL_MISSING_IN_DECODED_BYTES;
13502
+ exports.SOLANA_ERROR__CODECS__SENTINEL_MUST_NOT_BE_EMPTY = SOLANA_ERROR__CODECS__SENTINEL_MUST_NOT_BE_EMPTY;
13451
13503
  exports.SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE = SOLANA_ERROR__CODECS__UNION_VARIANT_OUT_OF_RANGE;
13452
13504
  exports.SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED;
13453
13505
  exports.SOLANA_ERROR__FAILED_TO_SEND_TRANSACTION = SOLANA_ERROR__FAILED_TO_SEND_TRANSACTION;