@solana/transactions 2.0.0-experimental.278784a → 2.0.0-experimental.2938d71

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 (52) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +314 -5
  3. package/dist/index.browser.cjs +198 -244
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.js +199 -247
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.development.js +743 -748
  8. package/dist/index.development.js.map +1 -1
  9. package/dist/index.native.js +199 -247
  10. package/dist/index.native.js.map +1 -1
  11. package/dist/index.node.cjs +198 -244
  12. package/dist/index.node.cjs.map +1 -1
  13. package/dist/index.node.js +199 -247
  14. package/dist/index.node.js.map +1 -1
  15. package/dist/index.production.min.js +17 -15
  16. package/dist/types/accounts.d.ts.map +1 -0
  17. package/dist/types/blockhash.d.ts.map +1 -0
  18. package/dist/types/compile-address-table-lookups.d.ts.map +1 -0
  19. package/dist/types/compile-header.d.ts.map +1 -0
  20. package/dist/types/compile-instructions.d.ts.map +1 -0
  21. package/dist/types/compile-lifetime-token.d.ts.map +1 -0
  22. package/dist/types/compile-static-accounts.d.ts.map +1 -0
  23. package/dist/types/compile-transaction.d.ts.map +1 -0
  24. package/dist/types/create-transaction.d.ts.map +1 -0
  25. package/dist/types/durable-nonce.d.ts +1 -0
  26. package/dist/types/durable-nonce.d.ts.map +1 -0
  27. package/dist/types/fee-payer.d.ts.map +1 -0
  28. package/dist/types/index.d.ts +1 -0
  29. package/dist/types/index.d.ts.map +1 -0
  30. package/dist/types/instructions.d.ts.map +1 -0
  31. package/dist/types/message.d.ts.map +1 -0
  32. package/dist/types/serializers/address-table-lookup.d.ts +5 -3
  33. package/dist/types/serializers/address-table-lookup.d.ts.map +1 -0
  34. package/dist/types/serializers/header.d.ts +4 -2
  35. package/dist/types/serializers/header.d.ts.map +1 -0
  36. package/dist/types/serializers/index.d.ts +2 -0
  37. package/dist/types/serializers/index.d.ts.map +1 -0
  38. package/dist/types/serializers/instruction.d.ts +4 -2
  39. package/dist/types/serializers/instruction.d.ts.map +1 -0
  40. package/dist/types/serializers/message.d.ts +4 -4
  41. package/dist/types/serializers/message.d.ts.map +1 -0
  42. package/dist/types/serializers/transaction-version.d.ts +4 -4
  43. package/dist/types/serializers/transaction-version.d.ts.map +1 -0
  44. package/dist/types/serializers/transaction.d.ts +5 -4
  45. package/dist/types/serializers/transaction.d.ts.map +1 -0
  46. package/dist/types/signatures.d.ts.map +1 -0
  47. package/dist/types/types.d.ts.map +1 -0
  48. package/dist/types/unsigned-transaction.d.ts.map +1 -0
  49. package/dist/types/wire-transaction.d.ts +1 -1
  50. package/dist/types/wire-transaction.d.ts.map +1 -0
  51. package/package.json +12 -8
  52. package/dist/types/serializers/unimplemented.d.ts +0 -3
@@ -9,82 +9,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
9
9
  return value;
10
10
  };
11
11
 
12
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
13
- var mergeBytes = (bytesArr) => {
14
- const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
15
- const result = new Uint8Array(totalLength);
16
- let offset = 0;
17
- bytesArr.forEach((arr) => {
18
- result.set(arr, offset);
19
- offset += arr.length;
20
- });
21
- return result;
22
- };
23
- var padBytes = (bytes2, length) => {
24
- if (bytes2.length >= length)
25
- return bytes2;
26
- const paddedBytes = new Uint8Array(length).fill(0);
27
- paddedBytes.set(bytes2);
28
- return paddedBytes;
29
- };
30
- var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
31
-
32
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
33
- var DeserializingEmptyBufferError = class extends Error {
34
- constructor(serializer) {
35
- super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
36
- __publicField(this, "name", "DeserializingEmptyBufferError");
37
- }
38
- };
39
- var NotEnoughBytesError = class extends Error {
40
- constructor(serializer, expected, actual) {
41
- super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
42
- __publicField(this, "name", "NotEnoughBytesError");
43
- }
44
- };
45
- var ExpectedFixedSizeSerializerError = class extends Error {
46
- constructor(message) {
47
- message ?? (message = "Expected a fixed-size serializer, got a variable-size one.");
48
- super(message);
49
- __publicField(this, "name", "ExpectedFixedSizeSerializerError");
50
- }
51
- };
52
-
53
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
54
- function fixSerializer(serializer, fixedBytes, description) {
55
- return {
56
- description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
57
- fixedSize: fixedBytes,
58
- maxSize: fixedBytes,
59
- serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
60
- deserialize: (buffer, offset = 0) => {
61
- buffer = buffer.slice(offset, offset + fixedBytes);
62
- if (buffer.length < fixedBytes) {
63
- throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
64
- }
65
- if (serializer.fixedSize !== null) {
66
- buffer = fixBytes(buffer, serializer.fixedSize);
67
- }
68
- const [value] = serializer.deserialize(buffer, 0);
69
- return [value, offset + fixedBytes];
70
- }
71
- };
72
- }
73
-
74
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
75
- function mapSerializer(serializer, unmap, map) {
76
- return {
77
- description: serializer.description,
78
- fixedSize: serializer.fixedSize,
79
- maxSize: serializer.maxSize,
80
- serialize: (value) => serializer.serialize(unmap(value)),
81
- deserialize: (buffer, offset = 0) => {
82
- const [value, length] = serializer.deserialize(buffer, offset);
83
- return map ? [map(value, buffer, offset), length] : [value, length];
84
- }
85
- };
86
- }
87
-
88
12
  // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
89
13
  var InvalidBaseStringError = class extends Error {
90
14
  constructor(value, base, cause) {
@@ -132,13 +56,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
132
56
  deserialize(buffer, offset = 0) {
133
57
  if (buffer.length === 0)
134
58
  return ["", 0];
135
- const bytes2 = buffer.slice(offset);
136
- let trailIndex = bytes2.findIndex((n) => n !== 0);
137
- trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
59
+ const bytes = buffer.slice(offset);
60
+ let trailIndex = bytes.findIndex((n) => n !== 0);
61
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
138
62
  const leadingZeroes = alphabet[0].repeat(trailIndex);
139
- if (trailIndex === bytes2.length)
63
+ if (trailIndex === bytes.length)
140
64
  return [leadingZeroes, buffer.length];
141
- let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
65
+ let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
142
66
  const tailChars = [];
143
67
  while (base10Number > 0n) {
144
68
  tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
@@ -152,347 +76,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
152
76
  // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
153
77
  var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
154
78
 
155
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
156
- var removeNullCharacters = (value) => (
157
- // eslint-disable-next-line no-control-regex
158
- value.replace(/\u0000/g, "")
159
- );
160
-
161
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
162
- var utf8 = {
163
- description: "utf8",
164
- fixedSize: null,
165
- maxSize: null,
166
- serialize(value) {
167
- return new TextEncoder().encode(value);
168
- },
169
- deserialize(buffer, offset = 0) {
170
- const value = new TextDecoder().decode(buffer.slice(offset));
171
- return [removeNullCharacters(value), buffer.length];
172
- }
173
- };
174
-
175
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
176
- var Endian;
177
- (function(Endian2) {
178
- Endian2["Little"] = "le";
179
- Endian2["Big"] = "be";
180
- })(Endian || (Endian = {}));
181
-
182
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
183
- var NumberOutOfRangeError = class extends RangeError {
184
- constructor(serializer, min, max, actual) {
185
- super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
186
- __publicField(this, "name", "NumberOutOfRangeError");
187
- }
188
- };
189
-
190
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
191
- function numberFactory(input) {
192
- let littleEndian;
193
- let defaultDescription = input.name;
194
- if (input.size > 1) {
195
- littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
196
- defaultDescription += littleEndian ? "(le)" : "(be)";
197
- }
198
- return {
199
- description: input.options.description ?? defaultDescription,
200
- fixedSize: input.size,
201
- maxSize: input.size,
202
- serialize(value) {
203
- if (input.range) {
204
- assertRange(input.name, input.range[0], input.range[1], value);
205
- }
206
- const buffer = new ArrayBuffer(input.size);
207
- input.set(new DataView(buffer), value, littleEndian);
208
- return new Uint8Array(buffer);
209
- },
210
- deserialize(bytes2, offset = 0) {
211
- const slice = bytes2.slice(offset, offset + input.size);
212
- assertEnoughBytes("i8", slice, input.size);
213
- const view = toDataView(slice);
214
- return [input.get(view, littleEndian), offset + input.size];
215
- }
216
- };
217
- }
218
- var toArrayBuffer = (array2) => array2.buffer.slice(array2.byteOffset, array2.byteLength + array2.byteOffset);
219
- var toDataView = (array2) => new DataView(toArrayBuffer(array2));
220
- var assertRange = (serializer, min, max, value) => {
221
- if (value < min || value > max) {
222
- throw new NumberOutOfRangeError(serializer, min, max, value);
223
- }
224
- };
225
- var assertEnoughBytes = (serializer, bytes2, expected) => {
226
- if (bytes2.length === 0) {
227
- throw new DeserializingEmptyBufferError(serializer);
228
- }
229
- if (bytes2.length < expected) {
230
- throw new NotEnoughBytesError(serializer, expected, bytes2.length);
231
- }
232
- };
233
-
234
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/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.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
245
- var u32 = (options = {}) => numberFactory({
246
- name: "u32",
247
- size: 4,
248
- range: [0, Number("0xffffffff")],
249
- set: (view, value, le) => view.setUint32(0, Number(value), le),
250
- get: (view, le) => view.getUint32(0, le),
251
- options
252
- });
253
-
254
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
255
- var shortU16 = (options = {}) => ({
256
- description: options.description ?? "shortU16",
257
- fixedSize: null,
258
- maxSize: 3,
259
- serialize: (value) => {
260
- assertRange("shortU16", 0, 65535, value);
261
- const bytes2 = [0];
262
- for (let ii = 0; ; ii += 1) {
263
- const alignedValue = value >> ii * 7;
264
- if (alignedValue === 0) {
265
- break;
266
- }
267
- const nextSevenBits = 127 & alignedValue;
268
- bytes2[ii] = nextSevenBits;
269
- if (ii > 0) {
270
- bytes2[ii - 1] |= 128;
271
- }
272
- }
273
- return new Uint8Array(bytes2);
274
- },
275
- deserialize: (bytes2, offset = 0) => {
276
- let value = 0;
277
- let byteCount = 0;
278
- while (++byteCount) {
279
- const byteIndex = byteCount - 1;
280
- const currentByte = bytes2[offset + byteIndex];
281
- const nextSevenBits = 127 & currentByte;
282
- value |= nextSevenBits << byteIndex * 7;
283
- if ((currentByte & 128) === 0) {
284
- break;
285
- }
286
- }
287
- return [value, offset + byteCount];
288
- }
289
- });
290
-
291
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
292
- var InvalidNumberOfItemsError = class extends Error {
293
- constructor(serializer, expected, actual) {
294
- super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
295
- __publicField(this, "name", "InvalidNumberOfItemsError");
296
- }
297
- };
298
- var InvalidArrayLikeRemainderSizeError = class extends Error {
299
- constructor(remainderSize, itemSize) {
300
- super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
301
- __publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
302
- }
303
- };
304
- var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
305
- constructor(size) {
306
- super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
307
- __publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
308
- }
309
- };
310
-
311
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
312
- function sumSerializerSizes(sizes) {
313
- return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
314
- }
315
-
316
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
317
- function getResolvedSize(size, childrenSizes, bytes2, offset) {
318
- if (typeof size === "number") {
319
- return [size, offset];
320
- }
321
- if (typeof size === "object") {
322
- return size.deserialize(bytes2, offset);
323
- }
324
- if (size === "remainder") {
325
- const childrenSize = sumSerializerSizes(childrenSizes);
326
- if (childrenSize === null) {
327
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
328
- }
329
- const remainder = bytes2.slice(offset).length;
330
- if (remainder % childrenSize !== 0) {
331
- throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
332
- }
333
- return [remainder / childrenSize, offset];
334
- }
335
- throw new UnrecognizedArrayLikeSerializerSizeError(size);
336
- }
337
- function getSizeDescription(size) {
338
- return typeof size === "object" ? size.description : `${size}`;
339
- }
340
- function getSizeFromChildren(size, childrenSizes) {
341
- if (typeof size !== "number")
342
- return null;
343
- if (size === 0)
344
- return 0;
345
- const childrenSize = sumSerializerSizes(childrenSizes);
346
- return childrenSize === null ? null : childrenSize * size;
347
- }
348
- function getSizePrefix(size, realSize) {
349
- return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
350
- }
351
-
352
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
353
- function array(item, options = {}) {
354
- const size = options.size ?? u32();
355
- if (size === "remainder" && item.fixedSize === null) {
356
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
357
- }
358
- return {
359
- description: options.description ?? `array(${item.description}; ${getSizeDescription(size)})`,
360
- fixedSize: getSizeFromChildren(size, [item.fixedSize]),
361
- maxSize: getSizeFromChildren(size, [item.maxSize]),
362
- serialize: (value) => {
363
- if (typeof size === "number" && value.length !== size) {
364
- throw new InvalidNumberOfItemsError("array", size, value.length);
365
- }
366
- return mergeBytes([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
367
- },
368
- deserialize: (bytes2, offset = 0) => {
369
- if (typeof size === "object" && bytes2.slice(offset).length === 0) {
370
- return [[], offset];
371
- }
372
- const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
373
- offset = newOffset;
374
- const values = [];
375
- for (let i = 0; i < resolvedSize; i += 1) {
376
- const [value, newOffset2] = item.deserialize(bytes2, offset);
377
- values.push(value);
378
- offset = newOffset2;
379
- }
380
- return [values, offset];
381
- }
382
- };
383
- }
384
-
385
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
386
- function bytes(options = {}) {
387
- const size = options.size ?? "variable";
388
- const description = options.description ?? `bytes(${getSizeDescription(size)})`;
389
- const byteSerializer = {
390
- description,
391
- fixedSize: null,
392
- maxSize: null,
393
- serialize: (value) => new Uint8Array(value),
394
- deserialize: (bytes2, offset = 0) => {
395
- const slice = bytes2.slice(offset);
396
- return [slice, offset + slice.length];
397
- }
398
- };
399
- if (size === "variable") {
400
- return byteSerializer;
401
- }
402
- if (typeof size === "number") {
403
- return fixSerializer(byteSerializer, size, description);
404
- }
405
- return {
406
- description,
407
- fixedSize: null,
408
- maxSize: null,
409
- serialize: (value) => {
410
- const contentBytes = byteSerializer.serialize(value);
411
- const lengthBytes = size.serialize(contentBytes.length);
412
- return mergeBytes([lengthBytes, contentBytes]);
413
- },
414
- deserialize: (buffer, offset = 0) => {
415
- if (buffer.slice(offset).length === 0) {
416
- throw new DeserializingEmptyBufferError("bytes");
417
- }
418
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
419
- const length = Number(lengthBigInt);
420
- offset = lengthOffset;
421
- const contentBuffer = buffer.slice(offset, offset + length);
422
- if (contentBuffer.length < length) {
423
- throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
424
- }
425
- const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
426
- offset += contentOffset;
427
- return [value, offset];
428
- }
429
- };
430
- }
431
-
432
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
433
- function string(options = {}) {
434
- const size = options.size ?? u32();
435
- const encoding = options.encoding ?? utf8;
436
- const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
437
- if (size === "variable") {
438
- return {
439
- ...encoding,
440
- description
441
- };
442
- }
443
- if (typeof size === "number") {
444
- return fixSerializer(encoding, size, description);
445
- }
446
- return {
447
- description,
448
- fixedSize: null,
449
- maxSize: null,
450
- serialize: (value) => {
451
- const contentBytes = encoding.serialize(value);
452
- const lengthBytes = size.serialize(contentBytes.length);
453
- return mergeBytes([lengthBytes, contentBytes]);
454
- },
455
- deserialize: (buffer, offset = 0) => {
456
- if (buffer.slice(offset).length === 0) {
457
- throw new DeserializingEmptyBufferError("string");
458
- }
459
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
460
- const length = Number(lengthBigInt);
461
- offset = lengthOffset;
462
- const contentBuffer = buffer.slice(offset, offset + length);
463
- if (contentBuffer.length < length) {
464
- throw new NotEnoughBytesError("string", length, contentBuffer.length);
465
- }
466
- const [value, contentOffset] = encoding.deserialize(contentBuffer);
467
- offset += contentOffset;
468
- return [value, offset];
469
- }
470
- };
471
- }
472
-
473
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
474
- function struct(fields, options = {}) {
475
- const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
476
- return {
477
- description: options.description ?? `struct(${fieldDescriptions})`,
478
- fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
479
- maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
480
- serialize: (struct2) => {
481
- const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
482
- return mergeBytes(fieldBytes);
483
- },
484
- deserialize: (bytes2, offset = 0) => {
485
- const struct2 = {};
486
- fields.forEach(([key, serializer]) => {
487
- const [value, newOffset] = serializer.deserialize(bytes2, offset);
488
- offset = newOffset;
489
- struct2[key] = value;
490
- });
491
- return [struct2, offset];
492
- }
493
- };
494
- }
495
-
496
79
  // src/unsigned-transaction.ts
497
80
  function getUnsignedTransaction(transaction) {
498
81
  if ("signatures" in transaction) {
@@ -517,14 +100,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
517
100
  ) {
518
101
  throw new Error("Expected input string to decode to a byte array of length 32.");
519
102
  }
520
- const bytes2 = base58.serialize(putativeBlockhash);
521
- const numBytes = bytes2.byteLength;
103
+ const bytes = base58.serialize(putativeBlockhash);
104
+ const numBytes = bytes.byteLength;
522
105
  if (numBytes !== 32) {
523
106
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
524
107
  }
525
- } catch (e) {
108
+ } catch (e2) {
526
109
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
527
- cause: e
110
+ cause: e2
528
111
  });
529
112
  }
530
113
  }
@@ -596,73 +179,482 @@ this.globalThis.solanaWeb3 = (function (exports) {
596
179
  data: new Uint8Array([4, 0, 0, 0]),
597
180
  programAddress: SYSTEM_PROGRAM_ADDRESS
598
181
  };
599
- }
600
- function isAdvanceNonceAccountInstruction(instruction) {
601
- return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
602
- instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
603
- instruction.accounts?.length === 3 && // First account is nonce account address
604
- instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
605
- instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
606
- instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
607
- }
608
- function isAdvanceNonceAccountInstructionData(data) {
609
- return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
610
- }
611
- function isDurableNonceTransaction(transaction) {
612
- return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
613
- }
614
- function setTransactionLifetimeUsingDurableNonce({
615
- nonce,
616
- nonceAccountAddress,
617
- nonceAuthorityAddress
618
- }, transaction) {
619
- const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
620
- if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
621
- return transaction;
182
+ }
183
+ function isAdvanceNonceAccountInstruction(instruction) {
184
+ return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
185
+ instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
186
+ instruction.accounts?.length === 3 && // First account is nonce account address
187
+ instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole.WRITABLE && // Second account is recent blockhashes sysvar
188
+ instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole.READONLY && // Third account is nonce authority account
189
+ instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole.READONLY_SIGNER;
190
+ }
191
+ function isAdvanceNonceAccountInstructionData(data) {
192
+ return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
193
+ }
194
+ function isDurableNonceTransaction(transaction) {
195
+ return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
196
+ }
197
+ function setTransactionLifetimeUsingDurableNonce({
198
+ nonce,
199
+ nonceAccountAddress,
200
+ nonceAuthorityAddress
201
+ }, transaction) {
202
+ const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
203
+ if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
204
+ return transaction;
205
+ }
206
+ const out = {
207
+ ...getUnsignedTransaction(transaction),
208
+ instructions: [
209
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
210
+ ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
211
+ ],
212
+ lifetimeConstraint: {
213
+ nonce
214
+ }
215
+ };
216
+ Object.freeze(out);
217
+ return out;
218
+ }
219
+
220
+ // src/fee-payer.ts
221
+ function setTransactionFeePayer(feePayer, transaction) {
222
+ if ("feePayer" in transaction && feePayer === transaction.feePayer) {
223
+ return transaction;
224
+ }
225
+ const out = {
226
+ ...getUnsignedTransaction(transaction),
227
+ feePayer
228
+ };
229
+ Object.freeze(out);
230
+ return out;
231
+ }
232
+
233
+ // src/instructions.ts
234
+ function appendTransactionInstruction(instruction, transaction) {
235
+ const out = {
236
+ ...getUnsignedTransaction(transaction),
237
+ instructions: [...transaction.instructions, instruction]
238
+ };
239
+ Object.freeze(out);
240
+ return out;
241
+ }
242
+ function prependTransactionInstruction(instruction, transaction) {
243
+ const out = {
244
+ ...getUnsignedTransaction(transaction),
245
+ instructions: [instruction, ...transaction.instructions]
246
+ };
247
+ Object.freeze(out);
248
+ return out;
249
+ }
250
+
251
+ // ../codecs-core/dist/index.browser.js
252
+ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
253
+ if (bytes.length - offset <= 0) {
254
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
255
+ }
256
+ }
257
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
258
+ const bytesLength = bytes.length - offset;
259
+ if (bytesLength < expected) {
260
+ throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
261
+ }
262
+ }
263
+ var mergeBytes = (byteArrays) => {
264
+ const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
265
+ if (nonEmptyByteArrays.length === 0) {
266
+ return byteArrays.length ? byteArrays[0] : new Uint8Array();
267
+ }
268
+ if (nonEmptyByteArrays.length === 1) {
269
+ return nonEmptyByteArrays[0];
270
+ }
271
+ const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
272
+ const result = new Uint8Array(totalLength);
273
+ let offset = 0;
274
+ nonEmptyByteArrays.forEach((arr) => {
275
+ result.set(arr, offset);
276
+ offset += arr.length;
277
+ });
278
+ return result;
279
+ };
280
+ var padBytes = (bytes, length) => {
281
+ if (bytes.length >= length)
282
+ return bytes;
283
+ const paddedBytes = new Uint8Array(length).fill(0);
284
+ paddedBytes.set(bytes);
285
+ return paddedBytes;
286
+ };
287
+ var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
288
+ function fixCodecHelper(data, fixedBytes, description) {
289
+ return {
290
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
291
+ fixedSize: fixedBytes,
292
+ maxSize: fixedBytes
293
+ };
294
+ }
295
+ function fixEncoder(encoder, fixedBytes, description) {
296
+ return {
297
+ ...fixCodecHelper(encoder, fixedBytes, description),
298
+ encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
299
+ };
300
+ }
301
+ function fixDecoder(decoder, fixedBytes, description) {
302
+ return {
303
+ ...fixCodecHelper(decoder, fixedBytes, description),
304
+ decode: (bytes, offset = 0) => {
305
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
306
+ if (offset > 0 || bytes.length > fixedBytes) {
307
+ bytes = bytes.slice(offset, offset + fixedBytes);
308
+ }
309
+ if (decoder.fixedSize !== null) {
310
+ bytes = fixBytes(bytes, decoder.fixedSize);
311
+ }
312
+ const [value] = decoder.decode(bytes, 0);
313
+ return [value, offset + fixedBytes];
314
+ }
315
+ };
316
+ }
317
+ function mapEncoder(encoder, unmap) {
318
+ return {
319
+ description: encoder.description,
320
+ encode: (value) => encoder.encode(unmap(value)),
321
+ fixedSize: encoder.fixedSize,
322
+ maxSize: encoder.maxSize
323
+ };
324
+ }
325
+
326
+ // ../codecs-numbers/dist/index.browser.js
327
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
328
+ if (value < min || value > max) {
329
+ throw new Error(
330
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
331
+ );
332
+ }
333
+ }
334
+ function sharedNumberFactory(input) {
335
+ let littleEndian;
336
+ let defaultDescription = input.name;
337
+ if (input.size > 1) {
338
+ littleEndian = !("endian" in input.options) || input.options.endian === 0;
339
+ defaultDescription += littleEndian ? "(le)" : "(be)";
340
+ }
341
+ return {
342
+ description: input.options.description ?? defaultDescription,
343
+ fixedSize: input.size,
344
+ littleEndian,
345
+ maxSize: input.size
346
+ };
347
+ }
348
+ function numberEncoderFactory(input) {
349
+ const codecData = sharedNumberFactory(input);
350
+ return {
351
+ description: codecData.description,
352
+ encode(value) {
353
+ if (input.range) {
354
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
355
+ }
356
+ const arrayBuffer = new ArrayBuffer(input.size);
357
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
358
+ return new Uint8Array(arrayBuffer);
359
+ },
360
+ fixedSize: codecData.fixedSize,
361
+ maxSize: codecData.maxSize
362
+ };
363
+ }
364
+ function numberDecoderFactory(input) {
365
+ const codecData = sharedNumberFactory(input);
366
+ return {
367
+ decode(bytes, offset = 0) {
368
+ assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
369
+ assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
370
+ const view = new DataView(toArrayBuffer(bytes, offset, input.size));
371
+ return [input.get(view, codecData.littleEndian), offset + input.size];
372
+ },
373
+ description: codecData.description,
374
+ fixedSize: codecData.fixedSize,
375
+ maxSize: codecData.maxSize
376
+ };
377
+ }
378
+ function toArrayBuffer(bytes, offset, length) {
379
+ const bytesOffset = bytes.byteOffset + (offset ?? 0);
380
+ const bytesLength = length ?? bytes.byteLength;
381
+ return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
382
+ }
383
+ var getShortU16Encoder = (options = {}) => ({
384
+ description: options.description ?? "shortU16",
385
+ encode: (value) => {
386
+ assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
387
+ const bytes = [0];
388
+ for (let ii = 0; ; ii += 1) {
389
+ const alignedValue = value >> ii * 7;
390
+ if (alignedValue === 0) {
391
+ break;
392
+ }
393
+ const nextSevenBits = 127 & alignedValue;
394
+ bytes[ii] = nextSevenBits;
395
+ if (ii > 0) {
396
+ bytes[ii - 1] |= 128;
397
+ }
398
+ }
399
+ return new Uint8Array(bytes);
400
+ },
401
+ fixedSize: null,
402
+ maxSize: 3
403
+ });
404
+ var getU32Encoder = (options = {}) => numberEncoderFactory({
405
+ name: "u32",
406
+ options,
407
+ range: [0, Number("0xffffffff")],
408
+ set: (view, value, le) => view.setUint32(0, value, le),
409
+ size: 4
410
+ });
411
+ var getU32Decoder = (options = {}) => numberDecoderFactory({
412
+ get: (view, le) => view.getUint32(0, le),
413
+ name: "u32",
414
+ options,
415
+ size: 4
416
+ });
417
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
418
+ name: "u8",
419
+ options,
420
+ range: [0, Number("0xff")],
421
+ set: (view, value) => view.setUint8(0, value),
422
+ size: 1
423
+ });
424
+
425
+ // ../codecs-data-structures/dist/index.browser.js
426
+ function sumCodecSizes(sizes) {
427
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
428
+ }
429
+ function getArrayLikeCodecSizeDescription(size) {
430
+ return typeof size === "object" ? size.description : `${size}`;
431
+ }
432
+ function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
433
+ if (typeof size !== "number")
434
+ return null;
435
+ if (size === 0)
436
+ return 0;
437
+ const childrenSize = sumCodecSizes(childrenSizes);
438
+ return childrenSize === null ? null : childrenSize * size;
439
+ }
440
+ function getArrayLikeCodecSizePrefix(size, realSize) {
441
+ return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
442
+ }
443
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
444
+ if (expected !== actual) {
445
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
446
+ }
447
+ }
448
+ function arrayCodecHelper(item, size, description) {
449
+ if (size === "remainder" && item.fixedSize === null) {
450
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
451
+ }
452
+ return {
453
+ description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
454
+ fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
455
+ maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
456
+ };
457
+ }
458
+ function getArrayEncoder(item, options = {}) {
459
+ const size = options.size ?? getU32Encoder();
460
+ return {
461
+ ...arrayCodecHelper(item, size, options.description),
462
+ encode: (value) => {
463
+ if (typeof size === "number") {
464
+ assertValidNumberOfItemsForCodec("array", size, value.length);
465
+ }
466
+ return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
467
+ }
468
+ };
469
+ }
470
+ function getBytesEncoder(options = {}) {
471
+ const size = options.size ?? "variable";
472
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
473
+ const description = options.description ?? `bytes(${sizeDescription})`;
474
+ const byteEncoder = {
475
+ description,
476
+ encode: (value) => value,
477
+ fixedSize: null,
478
+ maxSize: null
479
+ };
480
+ if (size === "variable") {
481
+ return byteEncoder;
482
+ }
483
+ if (typeof size === "number") {
484
+ return fixEncoder(byteEncoder, size, description);
485
+ }
486
+ return {
487
+ ...byteEncoder,
488
+ encode: (value) => {
489
+ const contentBytes = byteEncoder.encode(value);
490
+ const lengthBytes = size.encode(contentBytes.length);
491
+ return mergeBytes([lengthBytes, contentBytes]);
492
+ }
493
+ };
494
+ }
495
+ function structCodecHelper(fields, description) {
496
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
497
+ return {
498
+ description: description ?? `struct(${fieldDescriptions})`,
499
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
500
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
501
+ };
502
+ }
503
+ function getStructEncoder(fields, options = {}) {
504
+ return {
505
+ ...structCodecHelper(fields, options.description),
506
+ encode: (struct) => {
507
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
508
+ return mergeBytes(fieldBytes);
509
+ }
510
+ };
511
+ }
512
+
513
+ // ../codecs-strings/dist/index.browser.js
514
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
515
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
516
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
517
+ }
518
+ }
519
+ var getBaseXEncoder = (alphabet4) => {
520
+ const base = alphabet4.length;
521
+ const baseBigInt = BigInt(base);
522
+ return {
523
+ description: `base${base}`,
524
+ encode(value) {
525
+ assertValidBaseString(alphabet4, value);
526
+ if (value === "")
527
+ return new Uint8Array();
528
+ const chars = [...value];
529
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
530
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
531
+ const leadingZeroes = Array(trailIndex).fill(0);
532
+ if (trailIndex === chars.length)
533
+ return Uint8Array.from(leadingZeroes);
534
+ const tailChars = chars.slice(trailIndex);
535
+ let base10Number = 0n;
536
+ let baseXPower = 1n;
537
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
538
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
539
+ baseXPower *= baseBigInt;
540
+ }
541
+ const tailBytes = [];
542
+ while (base10Number > 0n) {
543
+ tailBytes.unshift(Number(base10Number % 256n));
544
+ base10Number /= 256n;
545
+ }
546
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
547
+ },
548
+ fixedSize: null,
549
+ maxSize: null
550
+ };
551
+ };
552
+ var getBaseXDecoder = (alphabet4) => {
553
+ const base = alphabet4.length;
554
+ const baseBigInt = BigInt(base);
555
+ return {
556
+ decode(rawBytes, offset = 0) {
557
+ const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
558
+ if (bytes.length === 0)
559
+ return ["", 0];
560
+ let trailIndex = bytes.findIndex((n) => n !== 0);
561
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
562
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
563
+ if (trailIndex === bytes.length)
564
+ return [leadingZeroes, rawBytes.length];
565
+ let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
566
+ const tailChars = [];
567
+ while (base10Number > 0n) {
568
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
569
+ base10Number /= baseBigInt;
570
+ }
571
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
572
+ },
573
+ description: `base${base}`,
574
+ fixedSize: null,
575
+ maxSize: null
576
+ };
577
+ };
578
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
579
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
580
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
581
+ var removeNullCharacters = (value) => (
582
+ // eslint-disable-next-line no-control-regex
583
+ value.replace(/\u0000/g, "")
584
+ );
585
+ var e = globalThis.TextDecoder;
586
+ var o = globalThis.TextEncoder;
587
+ var getUtf8Encoder = () => {
588
+ let textEncoder;
589
+ return {
590
+ description: "utf8",
591
+ encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
592
+ fixedSize: null,
593
+ maxSize: null
594
+ };
595
+ };
596
+ var getUtf8Decoder = () => {
597
+ let textDecoder;
598
+ return {
599
+ decode(bytes, offset = 0) {
600
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
601
+ return [removeNullCharacters(value), bytes.length];
602
+ },
603
+ description: "utf8",
604
+ fixedSize: null,
605
+ maxSize: null
606
+ };
607
+ };
608
+ var getStringEncoder = (options = {}) => {
609
+ const size = options.size ?? getU32Encoder();
610
+ const encoding = options.encoding ?? getUtf8Encoder();
611
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
612
+ if (size === "variable") {
613
+ return { ...encoding, description };
622
614
  }
623
- const out = {
624
- ...getUnsignedTransaction(transaction),
625
- instructions: [
626
- createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
627
- ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
628
- ],
629
- lifetimeConstraint: {
630
- nonce
631
- }
632
- };
633
- Object.freeze(out);
634
- return out;
635
- }
636
-
637
- // src/fee-payer.ts
638
- function setTransactionFeePayer(feePayer, transaction) {
639
- if ("feePayer" in transaction && feePayer === transaction.feePayer) {
640
- return transaction;
615
+ if (typeof size === "number") {
616
+ return fixEncoder(encoding, size, description);
641
617
  }
642
- const out = {
643
- ...getUnsignedTransaction(transaction),
644
- feePayer
645
- };
646
- Object.freeze(out);
647
- return out;
648
- }
649
-
650
- // src/instructions.ts
651
- function appendTransactionInstruction(instruction, transaction) {
652
- const out = {
653
- ...getUnsignedTransaction(transaction),
654
- instructions: [...transaction.instructions, instruction]
618
+ return {
619
+ description,
620
+ encode: (value) => {
621
+ const contentBytes = encoding.encode(value);
622
+ const lengthBytes = size.encode(contentBytes.length);
623
+ return mergeBytes([lengthBytes, contentBytes]);
624
+ },
625
+ fixedSize: null,
626
+ maxSize: null
655
627
  };
656
- Object.freeze(out);
657
- return out;
658
- }
659
- function prependTransactionInstruction(instruction, transaction) {
660
- const out = {
661
- ...getUnsignedTransaction(transaction),
662
- instructions: [instruction, ...transaction.instructions]
628
+ };
629
+ var getStringDecoder = (options = {}) => {
630
+ const size = options.size ?? getU32Decoder();
631
+ const encoding = options.encoding ?? getUtf8Decoder();
632
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
633
+ if (size === "variable") {
634
+ return { ...encoding, description };
635
+ }
636
+ if (typeof size === "number") {
637
+ return fixDecoder(encoding, size, description);
638
+ }
639
+ return {
640
+ decode: (bytes, offset = 0) => {
641
+ assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
642
+ const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
643
+ const length = Number(lengthBigInt);
644
+ offset = lengthOffset;
645
+ const contentBytes = bytes.slice(offset, offset + length);
646
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
647
+ const [value, contentOffset] = encoding.decode(contentBytes);
648
+ offset += contentOffset;
649
+ return [value, offset];
650
+ },
651
+ description,
652
+ fixedSize: null,
653
+ maxSize: null
663
654
  };
664
- Object.freeze(out);
665
- return out;
655
+ };
656
+ function getSizeDescription(size) {
657
+ return typeof size === "object" ? size.description : `${size}`;
666
658
  }
667
659
 
668
660
  // ../assertions/dist/index.browser.js
@@ -685,14 +677,63 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
677
  throw new Error("No signing implementation could be found");
686
678
  }
687
679
  }
688
- function getBase58EncodedAddressCodec(config) {
689
- return string({
690
- description: config?.description ?? ("A 32-byte account address" ),
691
- encoding: base58,
680
+
681
+ // ../addresses/dist/index.browser.js
682
+ var memoizedBase58Encoder;
683
+ var memoizedBase58Decoder;
684
+ function getMemoizedBase58Encoder() {
685
+ if (!memoizedBase58Encoder)
686
+ memoizedBase58Encoder = getBase58Encoder();
687
+ return memoizedBase58Encoder;
688
+ }
689
+ function getMemoizedBase58Decoder() {
690
+ if (!memoizedBase58Decoder)
691
+ memoizedBase58Decoder = getBase58Decoder();
692
+ return memoizedBase58Decoder;
693
+ }
694
+ function assertIsAddress(putativeBase58EncodedAddress) {
695
+ try {
696
+ if (
697
+ // Lowest address (32 bytes of zeroes)
698
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
699
+ putativeBase58EncodedAddress.length > 44
700
+ ) {
701
+ throw new Error("Expected input string to decode to a byte array of length 32.");
702
+ }
703
+ const base58Encoder = getMemoizedBase58Encoder();
704
+ const bytes = base58Encoder.encode(putativeBase58EncodedAddress);
705
+ const numBytes = bytes.byteLength;
706
+ if (numBytes !== 32) {
707
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
708
+ }
709
+ } catch (e2) {
710
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
711
+ cause: e2
712
+ });
713
+ }
714
+ }
715
+ function address(putativeBase58EncodedAddress) {
716
+ assertIsAddress(putativeBase58EncodedAddress);
717
+ return putativeBase58EncodedAddress;
718
+ }
719
+ function getAddressEncoder(config) {
720
+ return mapEncoder(
721
+ getStringEncoder({
722
+ description: config?.description ?? "Base58EncodedAddress",
723
+ encoding: getMemoizedBase58Encoder(),
724
+ size: 32
725
+ }),
726
+ (putativeAddress) => address(putativeAddress)
727
+ );
728
+ }
729
+ function getAddressDecoder(config) {
730
+ return getStringDecoder({
731
+ description: config?.description ?? "Base58EncodedAddress",
732
+ encoding: getMemoizedBase58Decoder(),
692
733
  size: 32
693
734
  });
694
735
  }
695
- function getBase58EncodedAddressComparator() {
736
+ function getAddressComparator() {
696
737
  return new Intl.Collator("en", {
697
738
  caseFirst: "lower",
698
739
  ignorePunctuation: false,
@@ -708,20 +749,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
708
749
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
709
750
  }
710
751
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
711
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
752
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
712
753
  return base58EncodedAddress;
713
754
  }
714
755
 
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
756
  // src/accounts.ts
723
- function upsert(addressMap, address, update) {
724
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
757
+ function upsert(addressMap, address2, update) {
758
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole.READONLY });
725
759
  }
726
760
  var TYPE = Symbol("AddressMapTypeProperty");
727
761
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -772,7 +806,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
772
806
  const shouldReplaceEntry = (
773
807
  // Consider using the new LOOKUP_TABLE if its address is different...
774
808
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
775
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
809
+ (addressComparator || (addressComparator = getAddressComparator()))(
776
810
  accountMeta.lookupTableAddress,
777
811
  entry.lookupTableAddress
778
812
  ) < 0
@@ -878,14 +912,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
878
912
  if (leftIsWritable !== isWritableRole(rightEntry.role)) {
879
913
  return leftIsWritable ? -1 : 1;
880
914
  }
881
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
915
+ addressComparator || (addressComparator = getAddressComparator());
882
916
  if (leftEntry[TYPE] === 1 /* LOOKUP_TABLE */ && rightEntry[TYPE] === 1 /* LOOKUP_TABLE */ && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
883
917
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
884
918
  } else {
885
919
  return addressComparator(leftAddress, rightAddress);
886
920
  }
887
- }).map(([address, addressMeta]) => ({
888
- address,
921
+ }).map(([address2, addressMeta]) => ({
922
+ address: address2,
889
923
  ...addressMeta
890
924
  }));
891
925
  return orderedAccounts;
@@ -909,7 +943,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
909
943
  entry.readableIndices.push(account.addressIndex);
910
944
  }
911
945
  }
912
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
946
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
913
947
  lookupTableAddress,
914
948
  ...index[lookupTableAddress]
915
949
  }));
@@ -954,7 +988,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
954
988
  return instructions.map(({ accounts, data, programAddress }) => {
955
989
  return {
956
990
  programAddressIndex: accountIndex[programAddress],
957
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
991
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
958
992
  ...data ? { data } : null
959
993
  };
960
994
  });
@@ -972,7 +1006,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
972
1006
  function getCompiledStaticAccounts(orderedAccounts) {
973
1007
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
974
1008
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
975
- return orderedStaticAccounts.map(({ address }) => address);
1009
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
976
1010
  }
977
1011
 
978
1012
  // src/message.ts
@@ -989,145 +1023,121 @@ this.globalThis.solanaWeb3 = (function (exports) {
989
1023
  };
990
1024
  }
991
1025
 
1026
+ // src/compile-transaction.ts
1027
+ function getCompiledTransaction(transaction) {
1028
+ const compiledMessage = compileMessage(transaction);
1029
+ let signatures;
1030
+ if ("signatures" in transaction) {
1031
+ signatures = [];
1032
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1033
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1034
+ }
1035
+ } else {
1036
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1037
+ }
1038
+ return {
1039
+ compiledMessage,
1040
+ signatures
1041
+ };
1042
+ }
1043
+
992
1044
  // src/serializers/address-table-lookup.ts
993
- function getAddressTableLookupCodec() {
994
- return struct(
995
- [
1045
+ var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1046
+ var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1047
+ var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1048
+ 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" ;
1049
+ var memoizedAddressTableLookupEncoder;
1050
+ function getAddressTableLookupEncoder() {
1051
+ if (!memoizedAddressTableLookupEncoder) {
1052
+ memoizedAddressTableLookupEncoder = getStructEncoder(
996
1053
  [
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
- )
1054
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1055
+ [
1056
+ "writableIndices",
1057
+ getArrayEncoder(getU8Encoder(), {
1058
+ description: writableIndicesDescription,
1059
+ size: getShortU16Encoder()
1060
+ })
1061
+ ],
1062
+ [
1063
+ "readableIndices",
1064
+ getArrayEncoder(getU8Encoder(), {
1065
+ description: readableIndicesDescription,
1066
+ size: getShortU16Encoder()
1067
+ })
1068
+ ]
1003
1069
  ],
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
- );
1070
+ { description: addressTableLookupDescription }
1071
+ );
1072
+ }
1073
+ return memoizedAddressTableLookupEncoder;
1027
1074
  }
1028
1075
 
1029
1076
  // src/serializers/header.ts
1030
- function getMessageHeaderCodec() {
1031
- return struct(
1077
+ var memoizedU8Encoder;
1078
+ function getMemoizedU8Encoder() {
1079
+ if (!memoizedU8Encoder)
1080
+ memoizedU8Encoder = getU8Encoder();
1081
+ return memoizedU8Encoder;
1082
+ }
1083
+ function getMemoizedU8EncoderDescription(description) {
1084
+ const encoder = getMemoizedU8Encoder();
1085
+ return {
1086
+ ...encoder,
1087
+ description: description ?? encoder.description
1088
+ };
1089
+ }
1090
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1091
+ 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" ;
1092
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1093
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1094
+ function getMessageHeaderEncoder() {
1095
+ return getStructEncoder(
1032
1096
  [
1033
- [
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
- )
1040
- ],
1041
- [
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
- )
1048
- ],
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
- ]
1097
+ ["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
1098
+ ["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
1099
+ ["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
1057
1100
  ],
1058
1101
  {
1059
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1060
- }
1102
+ description: messageHeaderDescription
1103
+ }
1061
1104
  );
1062
1105
  }
1063
1106
 
1064
1107
  // 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;
1108
+ var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1109
+ var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1110
+ 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" ;
1111
+ var dataDescription = "An optional buffer of data passed to the instruction" ;
1112
+ var memoizedGetInstructionEncoder;
1113
+ function getInstructionEncoder() {
1114
+ if (!memoizedGetInstructionEncoder) {
1115
+ memoizedGetInstructionEncoder = mapEncoder(
1116
+ getStructEncoder([
1117
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1118
+ [
1119
+ "accountIndices",
1120
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1121
+ description: accountIndicesDescription,
1122
+ size: getShortU16Encoder()
1123
+ })
1124
+ ],
1125
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1126
+ ]),
1127
+ // Convert an instruction to have all fields defined
1128
+ (instruction) => {
1129
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1130
+ return instruction;
1131
+ }
1132
+ return {
1133
+ ...instruction,
1134
+ accountIndices: instruction.accountIndices ?? [],
1135
+ data: instruction.data ?? new Uint8Array(0)
1136
+ };
1109
1137
  }
1110
- const { accountIndices, data, ...rest } = value;
1111
- return {
1112
- ...rest,
1113
- ...accountIndices.length ? { accountIndices } : null,
1114
- ...data.byteLength ? { data } : null
1115
- };
1116
- }
1117
- );
1118
- }
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
- );
1126
- }
1127
- function getUnimplementedDecoder(name) {
1128
- return () => {
1129
- throw getError("decoder", name);
1130
- };
1138
+ );
1139
+ }
1140
+ return memoizedGetInstructionEncoder;
1131
1141
  }
1132
1142
 
1133
1143
  // src/serializers/transaction-version.ts
@@ -1137,16 +1147,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1137
1147
  fixedSize: null,
1138
1148
  maxSize: 1
1139
1149
  };
1140
- function deserialize(bytes2, offset = 0) {
1141
- const firstByte = bytes2[offset];
1142
- if ((firstByte & VERSION_FLAG_MASK) === 0) {
1143
- return ["legacy", offset];
1144
- } else {
1145
- const version = firstByte ^ VERSION_FLAG_MASK;
1146
- return [version, offset + 1];
1147
- }
1148
- }
1149
- function serialize(value) {
1150
+ function encode(value) {
1150
1151
  if (value === "legacy") {
1151
1152
  return new Uint8Array();
1152
1153
  }
@@ -1155,83 +1156,119 @@ this.globalThis.solanaWeb3 = (function (exports) {
1155
1156
  }
1156
1157
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1157
1158
  }
1158
- function getTransactionVersionCodec() {
1159
+ function getTransactionVersionEncoder() {
1159
1160
  return {
1160
1161
  ...BASE_CONFIG,
1161
- deserialize,
1162
- serialize
1162
+ encode
1163
1163
  };
1164
1164
  }
1165
1165
 
1166
1166
  // src/serializers/message.ts
1167
- var BASE_CONFIG2 = {
1168
- description: "The wire format of a Solana transaction message" ,
1169
- fixedSize: null,
1170
- maxSize: null
1171
- };
1172
- function serialize2(compiledMessage) {
1173
- if (compiledMessage.version === "legacy") {
1174
- return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1175
- } else {
1176
- return mapSerializer(
1177
- struct([
1178
- ...getPreludeStructSerializerTuple(),
1179
- ["addressTableLookups", getAddressTableLookupsSerializer()]
1180
- ]),
1181
- (value) => {
1182
- if (value.version === "legacy") {
1183
- return value;
1184
- }
1185
- return {
1186
- ...value,
1187
- addressTableLookups: value.addressTableLookups ?? []
1188
- };
1167
+ var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
1168
+ var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
1169
+ var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
1170
+ var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
1171
+ function getCompiledMessageLegacyEncoder() {
1172
+ return getStructEncoder(getPreludeStructEncoderTuple());
1173
+ }
1174
+ function getCompiledMessageVersionedEncoder() {
1175
+ return mapEncoder(
1176
+ getStructEncoder([
1177
+ ...getPreludeStructEncoderTuple(),
1178
+ ["addressTableLookups", getAddressTableLookupArrayEncoder()]
1179
+ ]),
1180
+ (value) => {
1181
+ if (value.version === "legacy") {
1182
+ return value;
1189
1183
  }
1190
- ).serialize(compiledMessage);
1191
- }
1184
+ return {
1185
+ ...value,
1186
+ addressTableLookups: value.addressTableLookups ?? []
1187
+ };
1188
+ }
1189
+ );
1192
1190
  }
1193
- function getPreludeStructSerializerTuple() {
1191
+ function getPreludeStructEncoderTuple() {
1194
1192
  return [
1195
- ["version", getTransactionVersionCodec()],
1196
- ["header", getMessageHeaderCodec()],
1193
+ ["version", getTransactionVersionEncoder()],
1194
+ ["header", getMessageHeaderEncoder()],
1197
1195
  [
1198
1196
  "staticAccounts",
1199
- array(getBase58EncodedAddressCodec(), {
1200
- description: "A compact-array of static account addresses belonging to this transaction" ,
1201
- size: shortU16()
1197
+ getArrayEncoder(getAddressEncoder(), {
1198
+ description: staticAccountsDescription,
1199
+ size: getShortU16Encoder()
1202
1200
  })
1203
1201
  ],
1204
1202
  [
1205
1203
  "lifetimeToken",
1206
- string({
1207
- description: "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ,
1208
- encoding: base58,
1204
+ getStringEncoder({
1205
+ description: lifetimeTokenDescription,
1206
+ encoding: getBase58Encoder(),
1209
1207
  size: 32
1210
1208
  })
1211
1209
  ],
1212
1210
  [
1213
1211
  "instructions",
1214
- array(getInstructionCodec(), {
1215
- description: "A compact-array of instructions belonging to this transaction" ,
1216
- size: shortU16()
1212
+ getArrayEncoder(getInstructionEncoder(), {
1213
+ description: instructionsDescription,
1214
+ size: getShortU16Encoder()
1217
1215
  })
1218
1216
  ]
1219
1217
  ];
1220
1218
  }
1221
- function getAddressTableLookupsSerializer() {
1222
- return array(getAddressTableLookupCodec(), {
1223
- ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
1224
- size: shortU16()
1219
+ function getAddressTableLookupArrayEncoder() {
1220
+ return getArrayEncoder(getAddressTableLookupEncoder(), {
1221
+ description: addressTableLookupsDescription,
1222
+ size: getShortU16Encoder()
1225
1223
  });
1226
1224
  }
1225
+ var messageDescription = "The wire format of a Solana transaction message" ;
1227
1226
  function getCompiledMessageEncoder() {
1228
1227
  return {
1229
- ...BASE_CONFIG2,
1230
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1231
- serialize: serialize2
1228
+ description: messageDescription,
1229
+ encode: (compiledMessage) => {
1230
+ if (compiledMessage.version === "legacy") {
1231
+ return getCompiledMessageLegacyEncoder().encode(compiledMessage);
1232
+ } else {
1233
+ return getCompiledMessageVersionedEncoder().encode(compiledMessage);
1234
+ }
1235
+ },
1236
+ fixedSize: null,
1237
+ maxSize: null
1232
1238
  };
1233
1239
  }
1234
1240
 
1241
+ // src/serializers/transaction.ts
1242
+ var transactionDescription = "The wire format of a Solana transaction" ;
1243
+ var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
1244
+ function getCompiledTransactionEncoder() {
1245
+ return getStructEncoder(
1246
+ [
1247
+ [
1248
+ "signatures",
1249
+ getArrayEncoder(getBytesEncoder({ size: 64 }), {
1250
+ description: signaturesDescription,
1251
+ size: getShortU16Encoder()
1252
+ })
1253
+ ],
1254
+ ["compiledMessage", getCompiledMessageEncoder()]
1255
+ ],
1256
+ {
1257
+ description: transactionDescription
1258
+ }
1259
+ );
1260
+ }
1261
+ function getTransactionEncoder() {
1262
+ return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
1263
+ }
1264
+
1265
+ // ../keys/dist/index.browser.js
1266
+ async function signBytes(key, data) {
1267
+ await assertSigningCapabilityIsAvailable();
1268
+ const signedData = await crypto.subtle.sign("Ed25519", key, data);
1269
+ return new Uint8Array(signedData);
1270
+ }
1271
+
1235
1272
  // src/signatures.ts
1236
1273
  function assertIsTransactionSignature(putativeTransactionSignature) {
1237
1274
  try {
@@ -1242,14 +1279,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1242
1279
  ) {
1243
1280
  throw new Error("Expected input string to decode to a byte array of length 64.");
1244
1281
  }
1245
- const bytes2 = base58.serialize(putativeTransactionSignature);
1246
- const numBytes = bytes2.byteLength;
1282
+ const bytes = base58.serialize(putativeTransactionSignature);
1283
+ const numBytes = bytes.byteLength;
1247
1284
  if (numBytes !== 64) {
1248
1285
  throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
1249
1286
  }
1250
- } catch (e) {
1287
+ } catch (e2) {
1251
1288
  throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
1252
- cause: e
1289
+ cause: e2
1253
1290
  });
1254
1291
  }
1255
1292
  }
@@ -1261,26 +1298,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
1261
1298
  ) {
1262
1299
  return false;
1263
1300
  }
1264
- const bytes2 = base58.serialize(putativeTransactionSignature);
1265
- const numBytes = bytes2.byteLength;
1301
+ const bytes = base58.serialize(putativeTransactionSignature);
1302
+ const numBytes = bytes.byteLength;
1266
1303
  if (numBytes !== 64) {
1267
1304
  return false;
1268
1305
  }
1269
1306
  return true;
1270
1307
  }
1271
1308
  async function getCompiledMessageSignature(message, secretKey) {
1272
- const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1309
+ const wireMessageBytes = getCompiledMessageEncoder().encode(message);
1273
1310
  const signature = await signBytes(secretKey, wireMessageBytes);
1274
1311
  return signature;
1275
1312
  }
1276
1313
  function getSignatureFromTransaction(transaction) {
1277
- const signature = transaction.signatures[transaction.feePayer];
1278
- if (!signature) {
1314
+ const signatureBytes = transaction.signatures[transaction.feePayer];
1315
+ if (!signatureBytes) {
1279
1316
  throw new Error(
1280
1317
  "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
1281
1318
  );
1282
1319
  }
1283
- return signature;
1320
+ const transactionSignature2 = base58.deserialize(signatureBytes)[0];
1321
+ return transactionSignature2;
1284
1322
  }
1285
1323
  async function signTransaction(keyPairs, transaction) {
1286
1324
  const compiledMessage = compileMessage(transaction);
@@ -1308,54 +1346,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
1308
1346
  return putativeTransactionSignature;
1309
1347
  }
1310
1348
 
1311
- // src/compile-transaction.ts
1312
- function getCompiledTransaction(transaction) {
1313
- const compiledMessage = compileMessage(transaction);
1314
- let signatures;
1315
- if ("signatures" in transaction) {
1316
- signatures = [];
1317
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1318
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1319
- }
1320
- } else {
1321
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1322
- }
1323
- return {
1324
- compiledMessage,
1325
- signatures
1326
- };
1327
- }
1328
-
1329
- // src/serializers/transaction.ts
1330
- var BASE_CONFIG3 = {
1331
- description: "The wire format of a Solana transaction" ,
1332
- fixedSize: null,
1333
- maxSize: null
1334
- };
1335
- function serialize3(transaction) {
1336
- const compiledTransaction = getCompiledTransaction(transaction);
1337
- return struct([
1338
- [
1339
- "signatures",
1340
- array(bytes({ size: 64 }), {
1341
- ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1342
- size: shortU16()
1343
- })
1344
- ],
1345
- ["compiledMessage", getCompiledMessageEncoder()]
1346
- ]).serialize(compiledTransaction);
1347
- }
1348
- function getTransactionEncoder() {
1349
- return {
1350
- ...BASE_CONFIG3,
1351
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1352
- serialize: serialize3
1353
- };
1354
- }
1355
-
1356
1349
  // src/wire-transaction.ts
1357
1350
  function getBase64EncodedWireTransaction(transaction) {
1358
- const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
1351
+ const wireTransactionBytes = getTransactionEncoder().encode(transaction);
1359
1352
  {
1360
1353
  return btoa(String.fromCharCode(...wireTransactionBytes));
1361
1354
  }
@@ -1368,6 +1361,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1368
1361
  exports.createTransaction = createTransaction;
1369
1362
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
1370
1363
  exports.getSignatureFromTransaction = getSignatureFromTransaction;
1364
+ exports.getTransactionEncoder = getTransactionEncoder;
1365
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
1371
1366
  exports.isTransactionSignature = isTransactionSignature;
1372
1367
  exports.prependTransactionInstruction = prependTransactionInstruction;
1373
1368
  exports.setTransactionFeePayer = setTransactionFeePayer;