@solana/transactions 2.0.0-experimental.bb6ba5b → 2.0.0-experimental.be901cf

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 (53) hide show
  1. package/LICENSE +1 -1
  2. package/dist/index.browser.cjs +296 -185
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +291 -188
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.development.js +953 -238
  7. package/dist/index.development.js.map +1 -1
  8. package/dist/index.native.js +291 -188
  9. package/dist/index.native.js.map +1 -1
  10. package/dist/index.node.cjs +294 -187
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.js +291 -188
  13. package/dist/index.node.js.map +1 -1
  14. package/dist/index.production.min.js +17 -11
  15. package/dist/types/accounts.d.ts +1 -1
  16. package/dist/types/blockhash.d.ts +1 -1
  17. package/dist/types/durable-nonce.d.ts +5 -3
  18. package/dist/types/fee-payer.d.ts +2 -1
  19. package/dist/types/index.d.ts +1 -0
  20. package/dist/types/serializers/address-table-lookup.d.ts +5 -3
  21. package/dist/types/serializers/header.d.ts +4 -2
  22. package/dist/types/serializers/index.d.ts +2 -0
  23. package/dist/types/serializers/instruction.d.ts +4 -2
  24. package/dist/types/serializers/transaction-version.d.ts +4 -4
  25. package/dist/types/signatures.d.ts +10 -2
  26. package/dist/types/types.d.ts +7 -0
  27. package/dist/types/wire-transaction.d.ts +1 -1
  28. package/package.json +19 -14
  29. package/dist/types/accounts.d.ts.map +0 -1
  30. package/dist/types/blockhash.d.ts.map +0 -1
  31. package/dist/types/compile-address-table-lookups.d.ts.map +0 -1
  32. package/dist/types/compile-header.d.ts.map +0 -1
  33. package/dist/types/compile-instructions.d.ts.map +0 -1
  34. package/dist/types/compile-lifetime-token.d.ts.map +0 -1
  35. package/dist/types/compile-static-accounts.d.ts.map +0 -1
  36. package/dist/types/compile-transaction.d.ts.map +0 -1
  37. package/dist/types/create-transaction.d.ts.map +0 -1
  38. package/dist/types/durable-nonce.d.ts.map +0 -1
  39. package/dist/types/fee-payer.d.ts.map +0 -1
  40. package/dist/types/index.d.ts.map +0 -1
  41. package/dist/types/instructions.d.ts.map +0 -1
  42. package/dist/types/message.d.ts.map +0 -1
  43. package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
  44. package/dist/types/serializers/header.d.ts.map +0 -1
  45. package/dist/types/serializers/instruction.d.ts.map +0 -1
  46. package/dist/types/serializers/message.d.ts.map +0 -1
  47. package/dist/types/serializers/transaction-version.d.ts.map +0 -1
  48. package/dist/types/serializers/transaction.d.ts.map +0 -1
  49. package/dist/types/serializers/unimplemented.d.ts.map +0 -1
  50. package/dist/types/signatures.d.ts.map +0 -1
  51. package/dist/types/types.d.ts.map +0 -1
  52. package/dist/types/unsigned-transaction.d.ts.map +0 -1
  53. package/dist/types/wire-transaction.d.ts.map +0 -1
@@ -9,7 +9,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
9
9
  return value;
10
10
  };
11
11
 
12
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
12
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
13
13
  var mergeBytes = (bytesArr) => {
14
14
  const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
15
15
  const result = new Uint8Array(totalLength);
@@ -29,7 +29,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
29
29
  };
30
30
  var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
31
31
 
32
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
32
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
33
33
  var DeserializingEmptyBufferError = class extends Error {
34
34
  constructor(serializer) {
35
35
  super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
@@ -50,7 +50,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
50
50
  }
51
51
  };
52
52
 
53
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
53
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
54
54
  function fixSerializer(serializer, fixedBytes, description) {
55
55
  return {
56
56
  description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
@@ -71,7 +71,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
71
71
  };
72
72
  }
73
73
 
74
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
74
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
75
75
  function mapSerializer(serializer, unmap, map) {
76
76
  return {
77
77
  description: serializer.description,
@@ -85,7 +85,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
85
85
  };
86
86
  }
87
87
 
88
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
88
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
89
89
  var InvalidBaseStringError = class extends Error {
90
90
  constructor(value, base, cause) {
91
91
  const message = `Expected a string of base ${base}, got [${value}].`;
@@ -95,7 +95,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
95
95
  }
96
96
  };
97
97
 
98
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
98
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
99
99
  var baseX = (alphabet) => {
100
100
  const base = alphabet.length;
101
101
  const baseBigInt = BigInt(base);
@@ -149,16 +149,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
149
149
  };
150
150
  };
151
151
 
152
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
152
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
153
153
  var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
154
154
 
155
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
155
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
156
156
  var removeNullCharacters = (value) => (
157
157
  // eslint-disable-next-line no-control-regex
158
158
  value.replace(/\u0000/g, "")
159
159
  );
160
160
 
161
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
161
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
162
162
  var utf8 = {
163
163
  description: "utf8",
164
164
  fixedSize: null,
@@ -172,14 +172,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
172
172
  }
173
173
  };
174
174
 
175
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
175
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
176
176
  var Endian;
177
177
  (function(Endian2) {
178
178
  Endian2["Little"] = "le";
179
179
  Endian2["Big"] = "be";
180
180
  })(Endian || (Endian = {}));
181
181
 
182
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
182
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
183
183
  var NumberOutOfRangeError = class extends RangeError {
184
184
  constructor(serializer, min, max, actual) {
185
185
  super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
@@ -187,7 +187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
187
187
  }
188
188
  };
189
189
 
190
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
190
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
191
191
  function numberFactory(input) {
192
192
  let littleEndian;
193
193
  let defaultDescription = input.name;
@@ -231,17 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
231
231
  }
232
232
  };
233
233
 
234
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
235
- var u8 = (options = {}) => numberFactory({
236
- name: "u8",
237
- size: 1,
238
- range: [0, Number("0xff")],
239
- set: (view, value) => view.setUint8(0, Number(value)),
240
- get: (view) => view.getUint8(0),
241
- options
242
- });
243
-
244
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
234
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
245
235
  var u32 = (options = {}) => numberFactory({
246
236
  name: "u32",
247
237
  size: 4,
@@ -251,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
251
241
  options
252
242
  });
253
243
 
254
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
244
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
255
245
  var shortU16 = (options = {}) => ({
256
246
  description: options.description ?? "shortU16",
257
247
  fixedSize: null,
@@ -288,7 +278,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
288
278
  }
289
279
  });
290
280
 
291
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
281
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
292
282
  var InvalidNumberOfItemsError = class extends Error {
293
283
  constructor(serializer, expected, actual) {
294
284
  super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
@@ -308,12 +298,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
308
298
  }
309
299
  };
310
300
 
311
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
301
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
312
302
  function sumSerializerSizes(sizes) {
313
303
  return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
314
304
  }
315
305
 
316
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
306
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
317
307
  function getResolvedSize(size, childrenSizes, bytes2, offset) {
318
308
  if (typeof size === "number") {
319
309
  return [size, offset];
@@ -349,7 +339,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
349
339
  return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
350
340
  }
351
341
 
352
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
342
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
353
343
  function array(item, options = {}) {
354
344
  const size = options.size ?? u32();
355
345
  if (size === "remainder" && item.fixedSize === null) {
@@ -382,7 +372,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
382
372
  };
383
373
  }
384
374
 
385
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
375
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
386
376
  function bytes(options = {}) {
387
377
  const size = options.size ?? "variable";
388
378
  const description = options.description ?? `bytes(${getSizeDescription(size)})`;
@@ -429,7 +419,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
429
419
  };
430
420
  }
431
421
 
432
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
422
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
433
423
  function string(options = {}) {
434
424
  const size = options.size ?? u32();
435
425
  const encoding = options.encoding ?? utf8;
@@ -470,7 +460,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
470
460
  };
471
461
  }
472
462
 
473
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
463
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
474
464
  function struct(fields, options = {}) {
475
465
  const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
476
466
  return {
@@ -522,9 +512,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
522
512
  if (numBytes !== 32) {
523
513
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
524
514
  }
525
- } catch (e) {
515
+ } catch (e2) {
526
516
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
527
- cause: e
517
+ cause: e2
528
518
  });
529
519
  }
530
520
  }
@@ -665,6 +655,388 @@ this.globalThis.solanaWeb3 = (function (exports) {
665
655
  return out;
666
656
  }
667
657
 
658
+ // ../codecs-core/dist/index.browser.js
659
+ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
660
+ if (bytes2.length - offset <= 0) {
661
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
662
+ }
663
+ }
664
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
665
+ const bytesLength = bytes2.length - offset;
666
+ if (bytesLength < expected) {
667
+ throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
668
+ }
669
+ }
670
+ var mergeBytes2 = (byteArrays) => {
671
+ const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
672
+ if (nonEmptyByteArrays.length === 0) {
673
+ return byteArrays.length ? byteArrays[0] : new Uint8Array();
674
+ }
675
+ if (nonEmptyByteArrays.length === 1) {
676
+ return nonEmptyByteArrays[0];
677
+ }
678
+ const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
679
+ const result = new Uint8Array(totalLength);
680
+ let offset = 0;
681
+ nonEmptyByteArrays.forEach((arr) => {
682
+ result.set(arr, offset);
683
+ offset += arr.length;
684
+ });
685
+ return result;
686
+ };
687
+ var padBytes2 = (bytes2, length) => {
688
+ if (bytes2.length >= length)
689
+ return bytes2;
690
+ const paddedBytes = new Uint8Array(length).fill(0);
691
+ paddedBytes.set(bytes2);
692
+ return paddedBytes;
693
+ };
694
+ var fixBytes2 = (bytes2, length) => padBytes2(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
695
+ function combineCodec(encoder, decoder, description) {
696
+ if (encoder.fixedSize !== decoder.fixedSize) {
697
+ throw new Error(
698
+ `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
699
+ );
700
+ }
701
+ if (encoder.maxSize !== decoder.maxSize) {
702
+ throw new Error(
703
+ `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
704
+ );
705
+ }
706
+ if (description === void 0 && encoder.description !== decoder.description) {
707
+ throw new Error(
708
+ `Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
709
+ );
710
+ }
711
+ return {
712
+ decode: decoder.decode,
713
+ description: description ?? encoder.description,
714
+ encode: encoder.encode,
715
+ fixedSize: encoder.fixedSize,
716
+ maxSize: encoder.maxSize
717
+ };
718
+ }
719
+ function fixCodecHelper(data, fixedBytes, description) {
720
+ return {
721
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
722
+ fixedSize: fixedBytes,
723
+ maxSize: fixedBytes
724
+ };
725
+ }
726
+ function fixEncoder(encoder, fixedBytes, description) {
727
+ return {
728
+ ...fixCodecHelper(encoder, fixedBytes, description),
729
+ encode: (value) => fixBytes2(encoder.encode(value), fixedBytes)
730
+ };
731
+ }
732
+ function fixDecoder(decoder, fixedBytes, description) {
733
+ return {
734
+ ...fixCodecHelper(decoder, fixedBytes, description),
735
+ decode: (bytes2, offset = 0) => {
736
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
737
+ if (offset > 0 || bytes2.length > fixedBytes) {
738
+ bytes2 = bytes2.slice(offset, offset + fixedBytes);
739
+ }
740
+ if (decoder.fixedSize !== null) {
741
+ bytes2 = fixBytes2(bytes2, decoder.fixedSize);
742
+ }
743
+ const [value] = decoder.decode(bytes2, 0);
744
+ return [value, offset + fixedBytes];
745
+ }
746
+ };
747
+ }
748
+ function mapEncoder(encoder, unmap) {
749
+ return {
750
+ description: encoder.description,
751
+ encode: (value) => encoder.encode(unmap(value)),
752
+ fixedSize: encoder.fixedSize,
753
+ maxSize: encoder.maxSize
754
+ };
755
+ }
756
+ function mapDecoder(decoder, map) {
757
+ return {
758
+ decode: (bytes2, offset = 0) => {
759
+ const [value, length] = decoder.decode(bytes2, offset);
760
+ return [map(value, bytes2, offset), length];
761
+ },
762
+ description: decoder.description,
763
+ fixedSize: decoder.fixedSize,
764
+ maxSize: decoder.maxSize
765
+ };
766
+ }
767
+
768
+ // ../codecs-numbers/dist/index.browser.js
769
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
770
+ if (value < min || value > max) {
771
+ throw new Error(
772
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
773
+ );
774
+ }
775
+ }
776
+ function sharedNumberFactory(input) {
777
+ let littleEndian;
778
+ let defaultDescription = input.name;
779
+ if (input.size > 1) {
780
+ littleEndian = !("endian" in input.options) || input.options.endian === 0;
781
+ defaultDescription += littleEndian ? "(le)" : "(be)";
782
+ }
783
+ return {
784
+ description: input.options.description ?? defaultDescription,
785
+ fixedSize: input.size,
786
+ littleEndian,
787
+ maxSize: input.size
788
+ };
789
+ }
790
+ function numberEncoderFactory(input) {
791
+ const codecData = sharedNumberFactory(input);
792
+ return {
793
+ description: codecData.description,
794
+ encode(value) {
795
+ if (input.range) {
796
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
797
+ }
798
+ const arrayBuffer = new ArrayBuffer(input.size);
799
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
800
+ return new Uint8Array(arrayBuffer);
801
+ },
802
+ fixedSize: codecData.fixedSize,
803
+ maxSize: codecData.maxSize
804
+ };
805
+ }
806
+ function numberDecoderFactory(input) {
807
+ const codecData = sharedNumberFactory(input);
808
+ return {
809
+ decode(bytes2, offset = 0) {
810
+ assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
811
+ assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
812
+ const view = new DataView(toArrayBuffer2(bytes2, offset, input.size));
813
+ return [input.get(view, codecData.littleEndian), offset + input.size];
814
+ },
815
+ description: codecData.description,
816
+ fixedSize: codecData.fixedSize,
817
+ maxSize: codecData.maxSize
818
+ };
819
+ }
820
+ function toArrayBuffer2(bytes2, offset, length) {
821
+ const bytesOffset = bytes2.byteOffset + (offset ?? 0);
822
+ const bytesLength = length ?? bytes2.byteLength;
823
+ return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
824
+ }
825
+ var getShortU16Encoder = (options = {}) => ({
826
+ description: options.description ?? "shortU16",
827
+ encode: (value) => {
828
+ assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
829
+ const bytes2 = [0];
830
+ for (let ii = 0; ; ii += 1) {
831
+ const alignedValue = value >> ii * 7;
832
+ if (alignedValue === 0) {
833
+ break;
834
+ }
835
+ const nextSevenBits = 127 & alignedValue;
836
+ bytes2[ii] = nextSevenBits;
837
+ if (ii > 0) {
838
+ bytes2[ii - 1] |= 128;
839
+ }
840
+ }
841
+ return new Uint8Array(bytes2);
842
+ },
843
+ fixedSize: null,
844
+ maxSize: 3
845
+ });
846
+ var getShortU16Decoder = (options = {}) => ({
847
+ decode: (bytes2, offset = 0) => {
848
+ let value = 0;
849
+ let byteCount = 0;
850
+ while (++byteCount) {
851
+ const byteIndex = byteCount - 1;
852
+ const currentByte = bytes2[offset + byteIndex];
853
+ const nextSevenBits = 127 & currentByte;
854
+ value |= nextSevenBits << byteIndex * 7;
855
+ if ((currentByte & 128) === 0) {
856
+ break;
857
+ }
858
+ }
859
+ return [value, offset + byteCount];
860
+ },
861
+ description: options.description ?? "shortU16",
862
+ fixedSize: null,
863
+ maxSize: 3
864
+ });
865
+ var getU32Encoder = (options = {}) => numberEncoderFactory({
866
+ name: "u32",
867
+ options,
868
+ range: [0, Number("0xffffffff")],
869
+ set: (view, value, le) => view.setUint32(0, value, le),
870
+ size: 4
871
+ });
872
+ var getU32Decoder = (options = {}) => numberDecoderFactory({
873
+ get: (view, le) => view.getUint32(0, le),
874
+ name: "u32",
875
+ options,
876
+ size: 4
877
+ });
878
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
879
+ name: "u8",
880
+ options,
881
+ range: [0, Number("0xff")],
882
+ set: (view, value) => view.setUint8(0, value),
883
+ size: 1
884
+ });
885
+ var getU8Decoder = (options = {}) => numberDecoderFactory({
886
+ get: (view) => view.getUint8(0),
887
+ name: "u8",
888
+ options,
889
+ size: 1
890
+ });
891
+ var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
892
+
893
+ // ../codecs-strings/dist/index.browser.js
894
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
895
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
896
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
897
+ }
898
+ }
899
+ var getBaseXEncoder = (alphabet4) => {
900
+ const base = alphabet4.length;
901
+ const baseBigInt = BigInt(base);
902
+ return {
903
+ description: `base${base}`,
904
+ encode(value) {
905
+ assertValidBaseString(alphabet4, value);
906
+ if (value === "")
907
+ return new Uint8Array();
908
+ const chars = [...value];
909
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
910
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
911
+ const leadingZeroes = Array(trailIndex).fill(0);
912
+ if (trailIndex === chars.length)
913
+ return Uint8Array.from(leadingZeroes);
914
+ const tailChars = chars.slice(trailIndex);
915
+ let base10Number = 0n;
916
+ let baseXPower = 1n;
917
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
918
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
919
+ baseXPower *= baseBigInt;
920
+ }
921
+ const tailBytes = [];
922
+ while (base10Number > 0n) {
923
+ tailBytes.unshift(Number(base10Number % 256n));
924
+ base10Number /= 256n;
925
+ }
926
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
927
+ },
928
+ fixedSize: null,
929
+ maxSize: null
930
+ };
931
+ };
932
+ var getBaseXDecoder = (alphabet4) => {
933
+ const base = alphabet4.length;
934
+ const baseBigInt = BigInt(base);
935
+ return {
936
+ decode(rawBytes, offset = 0) {
937
+ const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
938
+ if (bytes2.length === 0)
939
+ return ["", 0];
940
+ let trailIndex = bytes2.findIndex((n) => n !== 0);
941
+ trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
942
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
943
+ if (trailIndex === bytes2.length)
944
+ return [leadingZeroes, rawBytes.length];
945
+ let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
946
+ const tailChars = [];
947
+ while (base10Number > 0n) {
948
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
949
+ base10Number /= baseBigInt;
950
+ }
951
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
952
+ },
953
+ description: `base${base}`,
954
+ fixedSize: null,
955
+ maxSize: null
956
+ };
957
+ };
958
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
959
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
960
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
961
+ var removeNullCharacters2 = (value) => (
962
+ // eslint-disable-next-line no-control-regex
963
+ value.replace(/\u0000/g, "")
964
+ );
965
+ var e = globalThis.TextDecoder;
966
+ var o = globalThis.TextEncoder;
967
+ var getUtf8Encoder = () => {
968
+ let textEncoder;
969
+ return {
970
+ description: "utf8",
971
+ encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
972
+ fixedSize: null,
973
+ maxSize: null
974
+ };
975
+ };
976
+ var getUtf8Decoder = () => {
977
+ let textDecoder;
978
+ return {
979
+ decode(bytes2, offset = 0) {
980
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
981
+ return [removeNullCharacters2(value), bytes2.length];
982
+ },
983
+ description: "utf8",
984
+ fixedSize: null,
985
+ maxSize: null
986
+ };
987
+ };
988
+ var getStringEncoder = (options = {}) => {
989
+ const size = options.size ?? getU32Encoder();
990
+ const encoding = options.encoding ?? getUtf8Encoder();
991
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
992
+ if (size === "variable") {
993
+ return { ...encoding, description };
994
+ }
995
+ if (typeof size === "number") {
996
+ return fixEncoder(encoding, size, description);
997
+ }
998
+ return {
999
+ description,
1000
+ encode: (value) => {
1001
+ const contentBytes = encoding.encode(value);
1002
+ const lengthBytes = size.encode(contentBytes.length);
1003
+ return mergeBytes2([lengthBytes, contentBytes]);
1004
+ },
1005
+ fixedSize: null,
1006
+ maxSize: null
1007
+ };
1008
+ };
1009
+ var getStringDecoder = (options = {}) => {
1010
+ const size = options.size ?? getU32Decoder();
1011
+ const encoding = options.encoding ?? getUtf8Decoder();
1012
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
1013
+ if (size === "variable") {
1014
+ return { ...encoding, description };
1015
+ }
1016
+ if (typeof size === "number") {
1017
+ return fixDecoder(encoding, size, description);
1018
+ }
1019
+ return {
1020
+ decode: (bytes2, offset = 0) => {
1021
+ assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
1022
+ const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
1023
+ const length = Number(lengthBigInt);
1024
+ offset = lengthOffset;
1025
+ const contentBytes = bytes2.slice(offset, offset + length);
1026
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
1027
+ const [value, contentOffset] = encoding.decode(contentBytes);
1028
+ offset += contentOffset;
1029
+ return [value, offset];
1030
+ },
1031
+ description,
1032
+ fixedSize: null,
1033
+ maxSize: null
1034
+ };
1035
+ };
1036
+ function getSizeDescription2(size) {
1037
+ return typeof size === "object" ? size.description : `${size}`;
1038
+ }
1039
+
668
1040
  // ../assertions/dist/index.browser.js
669
1041
  function assertIsSecureContext() {
670
1042
  if (!globalThis.isSecureContext) {
@@ -685,14 +1057,66 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
1057
  throw new Error("No signing implementation could be found");
686
1058
  }
687
1059
  }
688
- function getBase58EncodedAddressCodec(config) {
689
- return string({
690
- description: config?.description ?? ("A 32-byte account address" ),
691
- encoding: base58,
1060
+
1061
+ // ../addresses/dist/index.browser.js
1062
+ var memoizedBase58Encoder;
1063
+ var memoizedBase58Decoder;
1064
+ function getMemoizedBase58Encoder() {
1065
+ if (!memoizedBase58Encoder)
1066
+ memoizedBase58Encoder = getBase58Encoder();
1067
+ return memoizedBase58Encoder;
1068
+ }
1069
+ function getMemoizedBase58Decoder() {
1070
+ if (!memoizedBase58Decoder)
1071
+ memoizedBase58Decoder = getBase58Decoder();
1072
+ return memoizedBase58Decoder;
1073
+ }
1074
+ function assertIsAddress(putativeBase58EncodedAddress) {
1075
+ try {
1076
+ if (
1077
+ // Lowest address (32 bytes of zeroes)
1078
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
1079
+ putativeBase58EncodedAddress.length > 44
1080
+ ) {
1081
+ throw new Error("Expected input string to decode to a byte array of length 32.");
1082
+ }
1083
+ const base58Encoder = getMemoizedBase58Encoder();
1084
+ const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
1085
+ const numBytes = bytes2.byteLength;
1086
+ if (numBytes !== 32) {
1087
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1088
+ }
1089
+ } catch (e2) {
1090
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
1091
+ cause: e2
1092
+ });
1093
+ }
1094
+ }
1095
+ function address(putativeBase58EncodedAddress) {
1096
+ assertIsAddress(putativeBase58EncodedAddress);
1097
+ return putativeBase58EncodedAddress;
1098
+ }
1099
+ function getAddressEncoder(config) {
1100
+ return mapEncoder(
1101
+ getStringEncoder({
1102
+ description: config?.description ?? "Base58EncodedAddress",
1103
+ encoding: getMemoizedBase58Encoder(),
1104
+ size: 32
1105
+ }),
1106
+ (putativeAddress) => address(putativeAddress)
1107
+ );
1108
+ }
1109
+ function getAddressDecoder(config) {
1110
+ return getStringDecoder({
1111
+ description: config?.description ?? "Base58EncodedAddress",
1112
+ encoding: getMemoizedBase58Decoder(),
692
1113
  size: 32
693
1114
  });
694
1115
  }
695
- function getBase58EncodedAddressComparator() {
1116
+ function getAddressCodec(config) {
1117
+ return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
1118
+ }
1119
+ function getAddressComparator() {
696
1120
  return new Intl.Collator("en", {
697
1121
  caseFirst: "lower",
698
1122
  ignorePunctuation: false,
@@ -702,26 +1126,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
702
1126
  usage: "sort"
703
1127
  }).compare;
704
1128
  }
705
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
1129
+ async function getAddressFromPublicKey(publicKey) {
706
1130
  await assertKeyExporterIsAvailable();
707
1131
  if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
708
1132
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
709
1133
  }
710
1134
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
711
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
1135
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
712
1136
  return base58EncodedAddress;
713
1137
  }
714
1138
 
715
- // ../keys/dist/index.browser.js
716
- async function signBytes(key, data) {
717
- await assertSigningCapabilityIsAvailable();
718
- const signedData = await crypto.subtle.sign("Ed25519", key, data);
719
- return new Uint8Array(signedData);
720
- }
721
-
722
1139
  // src/accounts.ts
723
- function upsert(addressMap, address, update) {
724
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
1140
+ function upsert(addressMap, address2, update) {
1141
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
725
1142
  }
726
1143
  var TYPE = Symbol("AddressMapTypeProperty");
727
1144
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -772,7 +1189,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
772
1189
  const shouldReplaceEntry = (
773
1190
  // Consider using the new LOOKUP_TABLE if its address is different...
774
1191
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
775
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
1192
+ (addressComparator || (addressComparator = getAddressComparator()))(
776
1193
  accountMeta.lookupTableAddress,
777
1194
  entry.lookupTableAddress
778
1195
  ) < 0
@@ -878,14 +1295,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
878
1295
  if (leftIsWritable !== isWritableRole(rightEntry.role)) {
879
1296
  return leftIsWritable ? -1 : 1;
880
1297
  }
881
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
1298
+ addressComparator || (addressComparator = getAddressComparator());
882
1299
  if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
883
1300
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
884
1301
  } else {
885
1302
  return addressComparator(leftAddress, rightAddress);
886
1303
  }
887
- }).map(([address, addressMeta]) => ({
888
- address,
1304
+ }).map(([address2, addressMeta]) => ({
1305
+ address: address2,
889
1306
  ...addressMeta
890
1307
  }));
891
1308
  return orderedAccounts;
@@ -909,7 +1326,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
909
1326
  entry.readableIndices.push(account.addressIndex);
910
1327
  }
911
1328
  }
912
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
1329
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
913
1330
  lookupTableAddress,
914
1331
  ...index[lookupTableAddress]
915
1332
  }));
@@ -954,7 +1371,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
954
1371
  return instructions.map(({ accounts, data, programAddress }) => {
955
1372
  return {
956
1373
  programAddressIndex: accountIndex[programAddress],
957
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
1374
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
958
1375
  ...data ? { data } : null
959
1376
  };
960
1377
  });
@@ -972,7 +1389,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
972
1389
  function getCompiledStaticAccounts(orderedAccounts) {
973
1390
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
974
1391
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
975
- return orderedStaticAccounts.map(({ address }) => address);
1392
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
976
1393
  }
977
1394
 
978
1395
  // src/message.ts
@@ -989,145 +1406,365 @@ this.globalThis.solanaWeb3 = (function (exports) {
989
1406
  };
990
1407
  }
991
1408
 
992
- // src/serializers/address-table-lookup.ts
993
- function getAddressTableLookupCodec() {
994
- return struct(
995
- [
996
- [
997
- "lookupTableAddress",
998
- getBase58EncodedAddressCodec(
999
- {
1000
- description: "The address of the address lookup table account from which instruction addresses should be looked up"
1001
- }
1002
- )
1003
- ],
1004
- [
1005
- "writableIndices",
1006
- array(u8(), {
1007
- ...{
1008
- description: "The indices of the accounts in the lookup table that should be loaded as writeable"
1009
- } ,
1010
- size: shortU16()
1011
- })
1012
- ],
1013
- [
1014
- "readableIndices",
1015
- array(u8(), {
1016
- ...{
1017
- description: "The indices of the accounts in the lookup table that should be loaded as read-only"
1018
- } ,
1019
- size: shortU16()
1020
- })
1021
- ]
1022
- ],
1023
- {
1024
- description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
1025
- }
1026
- );
1027
- }
1028
-
1029
- // src/serializers/header.ts
1030
- function getMessageHeaderCodec() {
1031
- return struct(
1032
- [
1409
+ // src/compile-transaction.ts
1410
+ function getCompiledTransaction(transaction) {
1411
+ const compiledMessage = compileMessage(transaction);
1412
+ let signatures;
1413
+ if ("signatures" in transaction) {
1414
+ signatures = [];
1415
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1416
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1417
+ }
1418
+ } else {
1419
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1420
+ }
1421
+ return {
1422
+ compiledMessage,
1423
+ signatures
1424
+ };
1425
+ }
1426
+
1427
+ // ../codecs-data-structures/dist/index.browser.js
1428
+ function sumCodecSizes(sizes) {
1429
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1430
+ }
1431
+ function decodeArrayLikeCodecSize(size, childrenSizes, bytes2, offset) {
1432
+ if (typeof size === "number") {
1433
+ return [size, offset];
1434
+ }
1435
+ if (typeof size === "object") {
1436
+ return size.decode(bytes2, offset);
1437
+ }
1438
+ if (size === "remainder") {
1439
+ const childrenSize = sumCodecSizes(childrenSizes);
1440
+ if (childrenSize === null) {
1441
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1442
+ }
1443
+ const remainder = bytes2.slice(offset).length;
1444
+ if (remainder % childrenSize !== 0) {
1445
+ throw new Error(
1446
+ `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
1447
+ );
1448
+ }
1449
+ return [remainder / childrenSize, offset];
1450
+ }
1451
+ throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
1452
+ }
1453
+ function getArrayLikeCodecSizeDescription(size) {
1454
+ return typeof size === "object" ? size.description : `${size}`;
1455
+ }
1456
+ function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
1457
+ if (typeof size !== "number")
1458
+ return null;
1459
+ if (size === 0)
1460
+ return 0;
1461
+ const childrenSize = sumCodecSizes(childrenSizes);
1462
+ return childrenSize === null ? null : childrenSize * size;
1463
+ }
1464
+ function getArrayLikeCodecSizePrefix(size, realSize) {
1465
+ return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
1466
+ }
1467
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1468
+ if (expected !== actual) {
1469
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1470
+ }
1471
+ }
1472
+ function arrayCodecHelper(item, size, description) {
1473
+ if (size === "remainder" && item.fixedSize === null) {
1474
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1475
+ }
1476
+ return {
1477
+ description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
1478
+ fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
1479
+ maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
1480
+ };
1481
+ }
1482
+ function getArrayEncoder(item, options = {}) {
1483
+ const size = options.size ?? getU32Encoder();
1484
+ return {
1485
+ ...arrayCodecHelper(item, size, options.description),
1486
+ encode: (value) => {
1487
+ if (typeof size === "number") {
1488
+ assertValidNumberOfItemsForCodec("array", size, value.length);
1489
+ }
1490
+ return mergeBytes2([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
1491
+ }
1492
+ };
1493
+ }
1494
+ function getArrayDecoder(item, options = {}) {
1495
+ const size = options.size ?? getU32Decoder();
1496
+ return {
1497
+ ...arrayCodecHelper(item, size, options.description),
1498
+ decode: (bytes2, offset = 0) => {
1499
+ if (typeof size === "object" && bytes2.slice(offset).length === 0) {
1500
+ return [[], offset];
1501
+ }
1502
+ const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes2, offset);
1503
+ offset = newOffset;
1504
+ const values = [];
1505
+ for (let i = 0; i < resolvedSize; i += 1) {
1506
+ const [value, newOffset2] = item.decode(bytes2, offset);
1507
+ values.push(value);
1508
+ offset = newOffset2;
1509
+ }
1510
+ return [values, offset];
1511
+ }
1512
+ };
1513
+ }
1514
+ function getBytesEncoder(options = {}) {
1515
+ const size = options.size ?? "variable";
1516
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1517
+ const description = options.description ?? `bytes(${sizeDescription})`;
1518
+ const byteEncoder = {
1519
+ description,
1520
+ encode: (value) => value,
1521
+ fixedSize: null,
1522
+ maxSize: null
1523
+ };
1524
+ if (size === "variable") {
1525
+ return byteEncoder;
1526
+ }
1527
+ if (typeof size === "number") {
1528
+ return fixEncoder(byteEncoder, size, description);
1529
+ }
1530
+ return {
1531
+ ...byteEncoder,
1532
+ encode: (value) => {
1533
+ const contentBytes = byteEncoder.encode(value);
1534
+ const lengthBytes = size.encode(contentBytes.length);
1535
+ return mergeBytes2([lengthBytes, contentBytes]);
1536
+ }
1537
+ };
1538
+ }
1539
+ function getBytesDecoder(options = {}) {
1540
+ const size = options.size ?? "variable";
1541
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1542
+ const description = options.description ?? `bytes(${sizeDescription})`;
1543
+ const byteDecoder = {
1544
+ decode: (bytes2, offset = 0) => {
1545
+ const slice = bytes2.slice(offset);
1546
+ return [slice, offset + slice.length];
1547
+ },
1548
+ description,
1549
+ fixedSize: null,
1550
+ maxSize: null
1551
+ };
1552
+ if (size === "variable") {
1553
+ return byteDecoder;
1554
+ }
1555
+ if (typeof size === "number") {
1556
+ return fixDecoder(byteDecoder, size, description);
1557
+ }
1558
+ return {
1559
+ ...byteDecoder,
1560
+ decode: (bytes2, offset = 0) => {
1561
+ assertByteArrayIsNotEmptyForCodec("bytes", bytes2, offset);
1562
+ const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
1563
+ const length = Number(lengthBigInt);
1564
+ offset = lengthOffset;
1565
+ const contentBytes = bytes2.slice(offset, offset + length);
1566
+ assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
1567
+ const [value, contentOffset] = byteDecoder.decode(contentBytes);
1568
+ offset += contentOffset;
1569
+ return [value, offset];
1570
+ }
1571
+ };
1572
+ }
1573
+ function structCodecHelper(fields, description) {
1574
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1575
+ return {
1576
+ description: description ?? `struct(${fieldDescriptions})`,
1577
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1578
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1579
+ };
1580
+ }
1581
+ function getStructEncoder(fields, options = {}) {
1582
+ return {
1583
+ ...structCodecHelper(fields, options.description),
1584
+ encode: (struct2) => {
1585
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
1586
+ return mergeBytes2(fieldBytes);
1587
+ }
1588
+ };
1589
+ }
1590
+ function getStructDecoder(fields, options = {}) {
1591
+ return {
1592
+ ...structCodecHelper(fields, options.description),
1593
+ decode: (bytes2, offset = 0) => {
1594
+ const struct2 = {};
1595
+ fields.forEach(([key, codec]) => {
1596
+ const [value, newOffset] = codec.decode(bytes2, offset);
1597
+ offset = newOffset;
1598
+ struct2[key] = value;
1599
+ });
1600
+ return [struct2, offset];
1601
+ }
1602
+ };
1603
+ }
1604
+ function getStructCodec(fields, options = {}) {
1605
+ return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
1606
+ }
1607
+
1608
+ // src/serializers/address-table-lookup.ts
1609
+ var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1610
+ var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1611
+ var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1612
+ var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
1613
+ var memoizedAddressTableLookupEncoder;
1614
+ function getAddressTableLookupEncoder() {
1615
+ if (!memoizedAddressTableLookupEncoder) {
1616
+ memoizedAddressTableLookupEncoder = getStructEncoder(
1033
1617
  [
1034
- "numSignerAccounts",
1035
- u8(
1036
- {
1037
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1038
- }
1039
- )
1618
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1619
+ [
1620
+ "writableIndices",
1621
+ getArrayEncoder(getU8Encoder(), {
1622
+ description: writableIndicesDescription,
1623
+ size: getShortU16Encoder()
1624
+ })
1625
+ ],
1626
+ [
1627
+ "readableIndices",
1628
+ getArrayEncoder(getU8Encoder(), {
1629
+ description: readableIndicesDescription,
1630
+ size: getShortU16Encoder()
1631
+ })
1632
+ ]
1040
1633
  ],
1634
+ { description: addressTableLookupDescription }
1635
+ );
1636
+ }
1637
+ return memoizedAddressTableLookupEncoder;
1638
+ }
1639
+ var memoizedAddressTableLookupDecoder;
1640
+ function getAddressTableLookupDecoder() {
1641
+ if (!memoizedAddressTableLookupDecoder) {
1642
+ memoizedAddressTableLookupDecoder = getStructDecoder(
1041
1643
  [
1042
- "numReadonlySignerAccounts",
1043
- u8(
1044
- {
1045
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
1046
- }
1047
- )
1644
+ ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
1645
+ [
1646
+ "writableIndices",
1647
+ getArrayDecoder(getU8Decoder(), {
1648
+ description: writableIndicesDescription,
1649
+ size: getShortU16Decoder()
1650
+ })
1651
+ ],
1652
+ [
1653
+ "readableIndices",
1654
+ getArrayDecoder(getU8Decoder(), {
1655
+ description: readableIndicesDescription,
1656
+ size: getShortU16Decoder()
1657
+ })
1658
+ ]
1048
1659
  ],
1049
- [
1050
- "numReadonlyNonSignerAccounts",
1051
- u8(
1052
- {
1053
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1054
- }
1055
- )
1056
- ]
1660
+ { description: addressTableLookupDescription }
1661
+ );
1662
+ }
1663
+ return memoizedAddressTableLookupDecoder;
1664
+ }
1665
+ function getAddressTableLookupCodec() {
1666
+ return combineCodec(getAddressTableLookupEncoder(), getAddressTableLookupDecoder());
1667
+ }
1668
+
1669
+ // src/serializers/header.ts
1670
+ var memoizedU8Codec;
1671
+ function getMemoizedU8Codec() {
1672
+ if (!memoizedU8Codec)
1673
+ memoizedU8Codec = getU8Codec();
1674
+ return memoizedU8Codec;
1675
+ }
1676
+ function getMemoizedU8CodecDescription(description) {
1677
+ const codec = getMemoizedU8Codec();
1678
+ return {
1679
+ ...codec,
1680
+ description: description ?? codec.description
1681
+ };
1682
+ }
1683
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1684
+ var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
1685
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1686
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1687
+ function getMessageHeaderCodec() {
1688
+ return getStructCodec(
1689
+ [
1690
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
1691
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
1692
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
1057
1693
  ],
1058
1694
  {
1059
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1060
- }
1695
+ description: messageHeaderDescription
1696
+ }
1061
1697
  );
1062
1698
  }
1063
1699
 
1064
1700
  // src/serializers/instruction.ts
1065
- function getInstructionCodec() {
1066
- return mapSerializer(
1067
- struct([
1068
- [
1069
- "programAddressIndex",
1070
- u8(
1071
- {
1072
- description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
1073
- }
1074
- )
1075
- ],
1076
- [
1077
- "accountIndices",
1078
- array(
1079
- u8({
1080
- description: "The index of an account, according to the well-ordered accounts list for this transaction"
1081
- }),
1082
- {
1083
- description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
1084
- size: shortU16()
1085
- }
1086
- )
1087
- ],
1088
- [
1089
- "data",
1090
- bytes({
1091
- description: "An optional buffer of data passed to the instruction" ,
1092
- size: shortU16()
1093
- })
1094
- ]
1095
- ]),
1096
- (value) => {
1097
- if (value.accountIndices !== void 0 && value.data !== void 0) {
1098
- return value;
1099
- }
1100
- return {
1101
- ...value,
1102
- accountIndices: value.accountIndices ?? [],
1103
- data: value.data ?? new Uint8Array(0)
1104
- };
1105
- },
1106
- (value) => {
1107
- if (value.accountIndices.length && value.data.byteLength) {
1108
- return value;
1701
+ var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1702
+ var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1703
+ var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
1704
+ var dataDescription = "An optional buffer of data passed to the instruction" ;
1705
+ var memoizedGetInstructionEncoder;
1706
+ function getInstructionEncoder() {
1707
+ if (!memoizedGetInstructionEncoder) {
1708
+ memoizedGetInstructionEncoder = mapEncoder(
1709
+ getStructEncoder([
1710
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1711
+ [
1712
+ "accountIndices",
1713
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1714
+ description: accountIndicesDescription,
1715
+ size: getShortU16Encoder()
1716
+ })
1717
+ ],
1718
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1719
+ ]),
1720
+ // Convert an instruction to have all fields defined
1721
+ (instruction) => {
1722
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1723
+ return instruction;
1724
+ }
1725
+ return {
1726
+ ...instruction,
1727
+ accountIndices: instruction.accountIndices ?? [],
1728
+ data: instruction.data ?? new Uint8Array(0)
1729
+ };
1109
1730
  }
1110
- const { accountIndices, data, ...rest } = value;
1111
- return {
1112
- ...rest,
1113
- ...accountIndices.length ? { accountIndices } : null,
1114
- ...data.byteLength ? { data } : null
1115
- };
1116
- }
1117
- );
1731
+ );
1732
+ }
1733
+ return memoizedGetInstructionEncoder;
1118
1734
  }
1119
-
1120
- // src/serializers/unimplemented.ts
1121
- function getError(type, name) {
1122
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1123
- return new Error(
1124
- `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
1125
- );
1735
+ var memoizedGetInstructionDecoder;
1736
+ function getInstructionDecoder() {
1737
+ if (!memoizedGetInstructionDecoder) {
1738
+ memoizedGetInstructionDecoder = mapDecoder(
1739
+ getStructDecoder([
1740
+ ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
1741
+ [
1742
+ "accountIndices",
1743
+ getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
1744
+ description: accountIndicesDescription,
1745
+ size: getShortU16Decoder()
1746
+ })
1747
+ ],
1748
+ ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
1749
+ ]),
1750
+ // Convert an instruction to exclude optional fields if they are empty
1751
+ (instruction) => {
1752
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
1753
+ return instruction;
1754
+ }
1755
+ const { accountIndices, data, ...rest } = instruction;
1756
+ return {
1757
+ ...rest,
1758
+ ...accountIndices.length ? { accountIndices } : null,
1759
+ ...data.byteLength ? { data } : null
1760
+ };
1761
+ }
1762
+ );
1763
+ }
1764
+ return memoizedGetInstructionDecoder;
1126
1765
  }
1127
- function getUnimplementedDecoder(name) {
1128
- return () => {
1129
- throw getError("decoder", name);
1130
- };
1766
+ function getInstructionCodec() {
1767
+ return combineCodec(getInstructionEncoder(), getInstructionDecoder());
1131
1768
  }
1132
1769
 
1133
1770
  // src/serializers/transaction-version.ts
@@ -1137,7 +1774,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1137
1774
  fixedSize: null,
1138
1775
  maxSize: 1
1139
1776
  };
1140
- function deserialize(bytes2, offset = 0) {
1777
+ function decode(bytes2, offset = 0) {
1141
1778
  const firstByte = bytes2[offset];
1142
1779
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
1143
1780
  return ["legacy", offset];
@@ -1146,7 +1783,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1146
1783
  return [version, offset + 1];
1147
1784
  }
1148
1785
  }
1149
- function serialize(value) {
1786
+ function encode(value) {
1150
1787
  if (value === "legacy") {
1151
1788
  return new Uint8Array();
1152
1789
  }
@@ -1155,11 +1792,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
1155
1792
  }
1156
1793
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1157
1794
  }
1158
- function getTransactionVersionCodec() {
1795
+ function getTransactionVersionDecoder() {
1159
1796
  return {
1160
1797
  ...BASE_CONFIG,
1161
- deserialize,
1162
- serialize
1798
+ decode
1799
+ };
1800
+ }
1801
+ function getTransactionVersionEncoder() {
1802
+ return {
1803
+ ...BASE_CONFIG,
1804
+ encode
1805
+ };
1806
+ }
1807
+ function getTransactionVersionCodec() {
1808
+ return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
1809
+ }
1810
+
1811
+ // src/serializers/unimplemented.ts
1812
+ function getError(type, name) {
1813
+ const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1814
+ return new Error(
1815
+ `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
1816
+ );
1817
+ }
1818
+ function getUnimplementedDecoder(name) {
1819
+ return () => {
1820
+ throw getError("decoder", name);
1163
1821
  };
1164
1822
  }
1165
1823
 
@@ -1169,7 +1827,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1169
1827
  fixedSize: null,
1170
1828
  maxSize: null
1171
1829
  };
1172
- function serialize2(compiledMessage) {
1830
+ function serialize(compiledMessage) {
1173
1831
  if (compiledMessage.version === "legacy") {
1174
1832
  return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1175
1833
  } else {
@@ -1190,13 +1848,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1190
1848
  ).serialize(compiledMessage);
1191
1849
  }
1192
1850
  }
1851
+ function toSerializer(codec) {
1852
+ return {
1853
+ description: codec.description,
1854
+ deserialize: codec.decode,
1855
+ fixedSize: codec.fixedSize,
1856
+ maxSize: codec.maxSize,
1857
+ serialize: codec.encode
1858
+ };
1859
+ }
1193
1860
  function getPreludeStructSerializerTuple() {
1194
1861
  return [
1195
- ["version", getTransactionVersionCodec()],
1196
- ["header", getMessageHeaderCodec()],
1862
+ ["version", toSerializer(getTransactionVersionCodec())],
1863
+ ["header", toSerializer(getMessageHeaderCodec())],
1197
1864
  [
1198
1865
  "staticAccounts",
1199
- array(getBase58EncodedAddressCodec(), {
1866
+ array(toSerializer(getAddressCodec()), {
1200
1867
  description: "A compact-array of static account addresses belonging to this transaction" ,
1201
1868
  size: shortU16()
1202
1869
  })
@@ -1211,7 +1878,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1211
1878
  ],
1212
1879
  [
1213
1880
  "instructions",
1214
- array(getInstructionCodec(), {
1881
+ array(toSerializer(getInstructionCodec()), {
1215
1882
  description: "A compact-array of instructions belonging to this transaction" ,
1216
1883
  size: shortU16()
1217
1884
  })
@@ -1219,7 +1886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1219
1886
  ];
1220
1887
  }
1221
1888
  function getAddressTableLookupsSerializer() {
1222
- return array(getAddressTableLookupCodec(), {
1889
+ return array(toSerializer(getAddressTableLookupCodec()), {
1223
1890
  ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
1224
1891
  size: shortU16()
1225
1892
  });
@@ -1228,49 +1895,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1228
1895
  return {
1229
1896
  ...BASE_CONFIG2,
1230
1897
  deserialize: getUnimplementedDecoder("CompiledMessage"),
1231
- serialize: serialize2
1232
- };
1233
- }
1234
-
1235
- // src/signatures.ts
1236
- async function getCompiledMessageSignature(message, secretKey) {
1237
- const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1238
- const signature = await signBytes(secretKey, wireMessageBytes);
1239
- return signature;
1240
- }
1241
- async function signTransaction(keyPair, transaction) {
1242
- const compiledMessage = compileMessage(transaction);
1243
- const [signerPublicKey, signature] = await Promise.all([
1244
- getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
1245
- getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1246
- ]);
1247
- const nextSignatures = {
1248
- ..."signatures" in transaction ? transaction.signatures : null,
1249
- ...{ [signerPublicKey]: signature }
1250
- };
1251
- const out = {
1252
- ...transaction,
1253
- signatures: nextSignatures
1254
- };
1255
- Object.freeze(out);
1256
- return out;
1257
- }
1258
-
1259
- // src/compile-transaction.ts
1260
- function getCompiledTransaction(transaction) {
1261
- const compiledMessage = compileMessage(transaction);
1262
- let signatures;
1263
- if ("signatures" in transaction) {
1264
- signatures = [];
1265
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1266
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1267
- }
1268
- } else {
1269
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1270
- }
1271
- return {
1272
- compiledMessage,
1273
- signatures
1898
+ serialize
1274
1899
  };
1275
1900
  }
1276
1901
 
@@ -1280,7 +1905,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1280
1905
  fixedSize: null,
1281
1906
  maxSize: null
1282
1907
  };
1283
- function serialize3(transaction) {
1908
+ function serialize2(transaction) {
1284
1909
  const compiledTransaction = getCompiledTransaction(transaction);
1285
1910
  return struct([
1286
1911
  [
@@ -1297,8 +1922,92 @@ this.globalThis.solanaWeb3 = (function (exports) {
1297
1922
  return {
1298
1923
  ...BASE_CONFIG3,
1299
1924
  deserialize: getUnimplementedDecoder("CompiledMessage"),
1300
- serialize: serialize3
1925
+ serialize: serialize2
1926
+ };
1927
+ }
1928
+
1929
+ // ../keys/dist/index.browser.js
1930
+ async function signBytes(key, data) {
1931
+ await assertSigningCapabilityIsAvailable();
1932
+ const signedData = await crypto.subtle.sign("Ed25519", key, data);
1933
+ return new Uint8Array(signedData);
1934
+ }
1935
+
1936
+ // src/signatures.ts
1937
+ function assertIsTransactionSignature(putativeTransactionSignature) {
1938
+ try {
1939
+ if (
1940
+ // Lowest value (64 bytes of zeroes)
1941
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
1942
+ putativeTransactionSignature.length > 88
1943
+ ) {
1944
+ throw new Error("Expected input string to decode to a byte array of length 64.");
1945
+ }
1946
+ const bytes2 = base58.serialize(putativeTransactionSignature);
1947
+ const numBytes = bytes2.byteLength;
1948
+ if (numBytes !== 64) {
1949
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
1950
+ }
1951
+ } catch (e2) {
1952
+ throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
1953
+ cause: e2
1954
+ });
1955
+ }
1956
+ }
1957
+ function isTransactionSignature(putativeTransactionSignature) {
1958
+ if (
1959
+ // Lowest value (64 bytes of zeroes)
1960
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
1961
+ putativeTransactionSignature.length > 88
1962
+ ) {
1963
+ return false;
1964
+ }
1965
+ const bytes2 = base58.serialize(putativeTransactionSignature);
1966
+ const numBytes = bytes2.byteLength;
1967
+ if (numBytes !== 64) {
1968
+ return false;
1969
+ }
1970
+ return true;
1971
+ }
1972
+ async function getCompiledMessageSignature(message, secretKey) {
1973
+ const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1974
+ const signature = await signBytes(secretKey, wireMessageBytes);
1975
+ return signature;
1976
+ }
1977
+ function getSignatureFromTransaction(transaction) {
1978
+ const signatureBytes = transaction.signatures[transaction.feePayer];
1979
+ if (!signatureBytes) {
1980
+ throw new Error(
1981
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
1982
+ );
1983
+ }
1984
+ const transactionSignature2 = base58.deserialize(signatureBytes)[0];
1985
+ return transactionSignature2;
1986
+ }
1987
+ async function signTransaction(keyPairs, transaction) {
1988
+ const compiledMessage = compileMessage(transaction);
1989
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
1990
+ const publicKeySignaturePairs = await Promise.all(
1991
+ keyPairs.map(
1992
+ (keyPair) => Promise.all([
1993
+ getAddressFromPublicKey(keyPair.publicKey),
1994
+ getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1995
+ ])
1996
+ )
1997
+ );
1998
+ for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
1999
+ nextSignatures[signerPublicKey] = signature;
2000
+ }
2001
+ const out = {
2002
+ ...transaction,
2003
+ signatures: nextSignatures
1301
2004
  };
2005
+ Object.freeze(out);
2006
+ return out;
2007
+ }
2008
+ function transactionSignature(putativeTransactionSignature) {
2009
+ assertIsTransactionSignature(putativeTransactionSignature);
2010
+ return putativeTransactionSignature;
1302
2011
  }
1303
2012
 
1304
2013
  // src/wire-transaction.ts
@@ -1312,13 +2021,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
1312
2021
  exports.appendTransactionInstruction = appendTransactionInstruction;
1313
2022
  exports.assertIsBlockhash = assertIsBlockhash;
1314
2023
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
2024
+ exports.assertIsTransactionSignature = assertIsTransactionSignature;
1315
2025
  exports.createTransaction = createTransaction;
1316
2026
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
2027
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
2028
+ exports.getTransactionEncoder = getTransactionEncoder;
2029
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
2030
+ exports.isTransactionSignature = isTransactionSignature;
1317
2031
  exports.prependTransactionInstruction = prependTransactionInstruction;
1318
2032
  exports.setTransactionFeePayer = setTransactionFeePayer;
1319
2033
  exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
1320
2034
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
1321
2035
  exports.signTransaction = signTransaction;
2036
+ exports.transactionSignature = transactionSignature;
1322
2037
 
1323
2038
  return exports;
1324
2039