@solana/transactions 2.0.0-experimental.5082935 → 2.0.0-experimental.5432cbe

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 (49) hide show
  1. package/dist/index.browser.cjs +216 -76
  2. package/dist/index.browser.cjs.map +1 -1
  3. package/dist/index.browser.js +210 -73
  4. package/dist/index.browser.js.map +1 -1
  5. package/dist/index.development.js +291 -148
  6. package/dist/index.development.js.map +1 -1
  7. package/dist/index.native.js +208 -73
  8. package/dist/index.native.js.map +1 -1
  9. package/dist/index.node.cjs +216 -76
  10. package/dist/index.node.cjs.map +1 -1
  11. package/dist/index.node.js +210 -73
  12. package/dist/index.node.js.map +1 -1
  13. package/dist/index.production.min.js +11 -6
  14. package/dist/types/accounts.d.ts +2 -2
  15. package/dist/types/blockhash.d.ts +9 -1
  16. package/dist/types/compile-address-table-lookups.d.ts +1 -1
  17. package/dist/types/compile-instructions.d.ts +1 -1
  18. package/dist/types/compile-static-accounts.d.ts +1 -1
  19. package/dist/types/compile-transaction.d.ts +11 -0
  20. package/dist/types/durable-nonce.d.ts +19 -7
  21. package/dist/types/fee-payer.d.ts +3 -2
  22. package/dist/types/index.d.ts +1 -0
  23. package/dist/types/serializers/transaction.d.ts +6 -0
  24. package/dist/types/signatures.d.ts +5 -6
  25. package/dist/types/types.d.ts +7 -0
  26. package/dist/types/unsigned-transaction.d.ts +4 -0
  27. package/dist/types/wire-transaction.d.ts +6 -0
  28. package/package.json +16 -18
  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/create-transaction.d.ts.map +0 -1
  37. package/dist/types/durable-nonce.d.ts.map +0 -1
  38. package/dist/types/fee-payer.d.ts.map +0 -1
  39. package/dist/types/index.d.ts.map +0 -1
  40. package/dist/types/instructions.d.ts.map +0 -1
  41. package/dist/types/message.d.ts.map +0 -1
  42. package/dist/types/serializers/address-table-lookup.d.ts.map +0 -1
  43. package/dist/types/serializers/header.d.ts.map +0 -1
  44. package/dist/types/serializers/instruction.d.ts.map +0 -1
  45. package/dist/types/serializers/message.d.ts.map +0 -1
  46. package/dist/types/serializers/transaction-version.d.ts.map +0 -1
  47. package/dist/types/serializers/unimplemented.d.ts.map +0 -1
  48. package/dist/types/signatures.d.ts.map +0 -1
  49. package/dist/types/types.d.ts.map +0 -1
@@ -9,79 +9,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
9
9
  return value;
10
10
  };
11
11
 
12
- // src/create-transaction.ts
13
- function createTransaction({
14
- version
15
- }) {
16
- const out = {
17
- instructions: [],
18
- version
19
- };
20
- Object.freeze(out);
21
- return out;
22
- }
23
-
24
- // src/fee-payer.ts
25
- function setTransactionFeePayer(feePayer, transaction) {
26
- if ("feePayer" in transaction && feePayer === transaction.feePayer) {
27
- return transaction;
28
- }
29
- let out;
30
- if ("signatures" in transaction) {
31
- const {
32
- signatures: _,
33
- // eslint-disable-line @typescript-eslint/no-unused-vars
34
- ...unsignedTransaction
35
- } = transaction;
36
- out = {
37
- ...unsignedTransaction,
38
- feePayer
39
- };
40
- } else {
41
- out = {
42
- ...transaction,
43
- feePayer
44
- };
45
- }
46
- Object.freeze(out);
47
- return out;
48
- }
49
-
50
- // src/instructions.ts
51
- function replaceInstructions(transaction, nextInstructions) {
52
- let out;
53
- if ("signatures" in transaction) {
54
- const {
55
- signatures: _,
56
- // eslint-disable-line @typescript-eslint/no-unused-vars
57
- ...unsignedTransaction
58
- } = transaction;
59
- out = {
60
- ...unsignedTransaction,
61
- instructions: nextInstructions
62
- };
63
- } else {
64
- out = {
65
- ...transaction,
66
- instructions: nextInstructions
67
- };
68
- }
69
- return out;
70
- }
71
- function appendTransactionInstruction(instruction, transaction) {
72
- const nextInstructions = [...transaction.instructions, instruction];
73
- const out = replaceInstructions(transaction, nextInstructions);
74
- Object.freeze(out);
75
- return out;
76
- }
77
- function prependTransactionInstruction(instruction, transaction) {
78
- const nextInstructions = [instruction, ...transaction.instructions];
79
- const out = replaceInstructions(transaction, nextInstructions);
80
- Object.freeze(out);
81
- return out;
82
- }
83
-
84
- // ../../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
85
13
  var mergeBytes = (bytesArr) => {
86
14
  const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
87
15
  const result = new Uint8Array(totalLength);
@@ -101,7 +29,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
101
29
  };
102
30
  var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
103
31
 
104
- // ../../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
105
33
  var DeserializingEmptyBufferError = class extends Error {
106
34
  constructor(serializer) {
107
35
  super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
@@ -122,7 +50,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
122
50
  }
123
51
  };
124
52
 
125
- // ../../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
126
54
  function fixSerializer(serializer, fixedBytes, description) {
127
55
  return {
128
56
  description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
@@ -143,7 +71,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
143
71
  };
144
72
  }
145
73
 
146
- // ../../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
147
75
  function mapSerializer(serializer, unmap, map) {
148
76
  return {
149
77
  description: serializer.description,
@@ -157,7 +85,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
157
85
  };
158
86
  }
159
87
 
160
- // ../../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
161
89
  var InvalidBaseStringError = class extends Error {
162
90
  constructor(value, base, cause) {
163
91
  const message = `Expected a string of base ${base}, got [${value}].`;
@@ -167,7 +95,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
167
95
  }
168
96
  };
169
97
 
170
- // ../../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
171
99
  var baseX = (alphabet) => {
172
100
  const base = alphabet.length;
173
101
  const baseBigInt = BigInt(base);
@@ -221,16 +149,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
221
149
  };
222
150
  };
223
151
 
224
- // ../../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
225
153
  var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
226
154
 
227
- // ../../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
228
156
  var removeNullCharacters = (value) => (
229
157
  // eslint-disable-next-line no-control-regex
230
158
  value.replace(/\u0000/g, "")
231
159
  );
232
160
 
233
- // ../../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
234
162
  var utf8 = {
235
163
  description: "utf8",
236
164
  fixedSize: null,
@@ -244,14 +172,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
244
172
  }
245
173
  };
246
174
 
247
- // ../../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
248
176
  var Endian;
249
177
  (function(Endian2) {
250
178
  Endian2["Little"] = "le";
251
179
  Endian2["Big"] = "be";
252
180
  })(Endian || (Endian = {}));
253
181
 
254
- // ../../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
255
183
  var NumberOutOfRangeError = class extends RangeError {
256
184
  constructor(serializer, min, max, actual) {
257
185
  super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
@@ -259,7 +187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
259
187
  }
260
188
  };
261
189
 
262
- // ../../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
263
191
  function numberFactory(input) {
264
192
  let littleEndian;
265
193
  let defaultDescription = input.name;
@@ -303,7 +231,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
303
231
  }
304
232
  };
305
233
 
306
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
234
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
307
235
  var u8 = (options = {}) => numberFactory({
308
236
  name: "u8",
309
237
  size: 1,
@@ -313,7 +241,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
313
241
  options
314
242
  });
315
243
 
316
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
244
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
317
245
  var u32 = (options = {}) => numberFactory({
318
246
  name: "u32",
319
247
  size: 4,
@@ -323,7 +251,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
323
251
  options
324
252
  });
325
253
 
326
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
254
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
327
255
  var shortU16 = (options = {}) => ({
328
256
  description: options.description ?? "shortU16",
329
257
  fixedSize: null,
@@ -360,7 +288,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
360
288
  }
361
289
  });
362
290
 
363
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
291
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
364
292
  var InvalidNumberOfItemsError = class extends Error {
365
293
  constructor(serializer, expected, actual) {
366
294
  super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
@@ -380,12 +308,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
380
308
  }
381
309
  };
382
310
 
383
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
311
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
384
312
  function sumSerializerSizes(sizes) {
385
313
  return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
386
314
  }
387
315
 
388
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
316
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
389
317
  function getResolvedSize(size, childrenSizes, bytes2, offset) {
390
318
  if (typeof size === "number") {
391
319
  return [size, offset];
@@ -421,7 +349,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
421
349
  return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
422
350
  }
423
351
 
424
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
352
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
425
353
  function array(item, options = {}) {
426
354
  const size = options.size ?? u32();
427
355
  if (size === "remainder" && item.fixedSize === null) {
@@ -454,7 +382,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
454
382
  };
455
383
  }
456
384
 
457
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
385
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
458
386
  function bytes(options = {}) {
459
387
  const size = options.size ?? "variable";
460
388
  const description = options.description ?? `bytes(${getSizeDescription(size)})`;
@@ -501,7 +429,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
501
429
  };
502
430
  }
503
431
 
504
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
432
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
505
433
  function string(options = {}) {
506
434
  const size = options.size ?? u32();
507
435
  const encoding = options.encoding ?? utf8;
@@ -542,7 +470,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
542
470
  };
543
471
  }
544
472
 
545
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.2/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
473
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
546
474
  function struct(fields, options = {}) {
547
475
  const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
548
476
  return {
@@ -564,23 +492,180 @@ this.globalThis.solanaWeb3 = (function (exports) {
564
492
  }
565
493
  };
566
494
  }
567
- function getBase58EncodedAddressCodec(config) {
568
- return string({
569
- description: config?.description ?? ("A 32-byte account address" ),
570
- encoding: base58,
571
- size: 32
572
- });
495
+
496
+ // src/unsigned-transaction.ts
497
+ function getUnsignedTransaction(transaction) {
498
+ if ("signatures" in transaction) {
499
+ const {
500
+ signatures: _,
501
+ // eslint-disable-line @typescript-eslint/no-unused-vars
502
+ ...unsignedTransaction
503
+ } = transaction;
504
+ return unsignedTransaction;
505
+ } else {
506
+ return transaction;
507
+ }
573
508
  }
574
- function getBase58EncodedAddressComparator() {
575
- return new Intl.Collator("en", {
576
- caseFirst: "lower",
577
- ignorePunctuation: false,
578
- localeMatcher: "best fit",
579
- numeric: false,
580
- sensitivity: "variant",
581
- usage: "sort"
582
- }).compare;
509
+
510
+ // src/blockhash.ts
511
+ function assertIsBlockhash(putativeBlockhash) {
512
+ try {
513
+ if (
514
+ // Lowest value (32 bytes of zeroes)
515
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
516
+ putativeBlockhash.length > 44
517
+ ) {
518
+ throw new Error("Expected input string to decode to a byte array of length 32.");
519
+ }
520
+ const bytes2 = base58.serialize(putativeBlockhash);
521
+ const numBytes = bytes2.byteLength;
522
+ if (numBytes !== 32) {
523
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
524
+ }
525
+ } catch (e) {
526
+ throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
527
+ cause: e
528
+ });
529
+ }
530
+ }
531
+ function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
532
+ if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
533
+ return transaction;
534
+ }
535
+ const out = {
536
+ ...getUnsignedTransaction(transaction),
537
+ lifetimeConstraint: blockhashLifetimeConstraint
538
+ };
539
+ Object.freeze(out);
540
+ return out;
583
541
  }
542
+
543
+ // src/create-transaction.ts
544
+ function createTransaction({
545
+ version
546
+ }) {
547
+ const out = {
548
+ instructions: [],
549
+ version
550
+ };
551
+ Object.freeze(out);
552
+ return out;
553
+ }
554
+
555
+ // ../instructions/dist/index.browser.js
556
+ var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
557
+ AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
558
+ 3] = "WRITABLE_SIGNER";
559
+ AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
560
+ 2] = "READONLY_SIGNER";
561
+ AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
562
+ 1] = "WRITABLE";
563
+ AccountRole2[AccountRole2["READONLY"] = /* 0 */
564
+ 0] = "READONLY";
565
+ return AccountRole2;
566
+ })(AccountRole || {});
567
+ var IS_WRITABLE_BITMASK = 1;
568
+ function isSignerRole(role) {
569
+ return role >= 2;
570
+ }
571
+ function isWritableRole(role) {
572
+ return (role & IS_WRITABLE_BITMASK) !== 0;
573
+ }
574
+ function mergeRoles(roleA, roleB) {
575
+ return roleA | roleB;
576
+ }
577
+
578
+ // src/durable-nonce.ts
579
+ var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
580
+ var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
581
+ function assertIsDurableNonceTransaction(transaction) {
582
+ if (!isDurableNonceTransaction(transaction)) {
583
+ throw new Error("Transaction is not a durable nonce transaction");
584
+ }
585
+ }
586
+ function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
587
+ return {
588
+ accounts: [
589
+ { address: nonceAccountAddress, role: AccountRole.WRITABLE },
590
+ {
591
+ address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
592
+ role: AccountRole.READONLY
593
+ },
594
+ { address: nonceAuthorityAddress, role: AccountRole.READONLY_SIGNER }
595
+ ],
596
+ data: new Uint8Array([4, 0, 0, 0]),
597
+ programAddress: SYSTEM_PROGRAM_ADDRESS
598
+ };
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;
622
+ }
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;
641
+ }
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]
655
+ };
656
+ Object.freeze(out);
657
+ return out;
658
+ }
659
+ function prependTransactionInstruction(instruction, transaction) {
660
+ const out = {
661
+ ...getUnsignedTransaction(transaction),
662
+ instructions: [instruction, ...transaction.instructions]
663
+ };
664
+ Object.freeze(out);
665
+ return out;
666
+ }
667
+
668
+ // ../assertions/dist/index.browser.js
584
669
  function assertIsSecureContext() {
585
670
  if (!globalThis.isSecureContext) {
586
671
  throw new Error(
@@ -600,7 +685,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
600
685
  throw new Error("No signing implementation could be found");
601
686
  }
602
687
  }
603
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
688
+ function getBase58EncodedAddressCodec(config) {
689
+ return string({
690
+ description: config?.description ?? ("A 32-byte account address" ),
691
+ encoding: base58,
692
+ size: 32
693
+ });
694
+ }
695
+ function getBase58EncodedAddressComparator() {
696
+ return new Intl.Collator("en", {
697
+ caseFirst: "lower",
698
+ ignorePunctuation: false,
699
+ localeMatcher: "best fit",
700
+ numeric: false,
701
+ sensitivity: "variant",
702
+ usage: "sort"
703
+ }).compare;
704
+ }
705
+ async function getAddressFromPublicKey(publicKey) {
604
706
  await assertKeyExporterIsAvailable();
605
707
  if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
606
708
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
@@ -609,35 +711,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
609
711
  const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
610
712
  return base58EncodedAddress;
611
713
  }
714
+
715
+ // ../keys/dist/index.browser.js
612
716
  async function signBytes(key, data) {
613
717
  await assertSigningCapabilityIsAvailable();
614
718
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
615
719
  return new Uint8Array(signedData);
616
720
  }
617
721
 
618
- // ../instructions/dist/index.browser.js
619
- var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
620
- AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
621
- 3] = "WRITABLE_SIGNER";
622
- AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
623
- 2] = "READONLY_SIGNER";
624
- AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
625
- 1] = "WRITABLE";
626
- AccountRole2[AccountRole2["READONLY"] = /* 0 */
627
- 0] = "READONLY";
628
- return AccountRole2;
629
- })(AccountRole || {});
630
- var IS_WRITABLE_BITMASK = 1;
631
- function isSignerRole(role) {
632
- return role >= 2;
633
- }
634
- function isWritableRole(role) {
635
- return (role & IS_WRITABLE_BITMASK) !== 0;
636
- }
637
- function mergeRoles(roleA, roleB) {
638
- return roleA | roleB;
639
- }
640
-
641
722
  // src/accounts.ts
642
723
  function upsert(addressMap, address, update) {
643
724
  addressMap[address] = update(addressMap[address] ?? { role: AccountRole.READONLY });
@@ -993,7 +1074,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
993
1074
  )
994
1075
  ],
995
1076
  [
996
- "addressIndices",
1077
+ "accountIndices",
997
1078
  array(
998
1079
  u8({
999
1080
  description: "The index of an account, according to the well-ordered accounts list for this transaction"
@@ -1013,23 +1094,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
1013
1094
  ]
1014
1095
  ]),
1015
1096
  (value) => {
1016
- if (value.addressIndices !== void 0 && value.data !== void 0) {
1097
+ if (value.accountIndices !== void 0 && value.data !== void 0) {
1017
1098
  return value;
1018
1099
  }
1019
1100
  return {
1020
1101
  ...value,
1021
- addressIndices: value.addressIndices ?? [],
1102
+ accountIndices: value.accountIndices ?? [],
1022
1103
  data: value.data ?? new Uint8Array(0)
1023
1104
  };
1024
1105
  },
1025
1106
  (value) => {
1026
- if (value.addressIndices.length && value.data.byteLength) {
1107
+ if (value.accountIndices.length && value.data.byteLength) {
1027
1108
  return value;
1028
1109
  }
1029
- const { addressIndices, data, ...rest } = value;
1110
+ const { accountIndices, data, ...rest } = value;
1030
1111
  return {
1031
1112
  ...rest,
1032
- ...addressIndices.length ? { addressIndices } : null,
1113
+ ...accountIndices.length ? { accountIndices } : null,
1033
1114
  ...data.byteLength ? { data } : null
1034
1115
  };
1035
1116
  }
@@ -1157,16 +1238,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
1157
1238
  const signature = await signBytes(secretKey, wireMessageBytes);
1158
1239
  return signature;
1159
1240
  }
1160
- async function signTransaction(keyPair, transaction) {
1241
+ async function signTransaction(keyPairs, transaction) {
1161
1242
  const compiledMessage = compileMessage(transaction);
1162
- const [signerPublicKey, signature] = await Promise.all([
1163
- getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
1164
- getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1165
- ]);
1166
- const nextSignatures = {
1167
- ..."signatures" in transaction ? transaction.signatures : null,
1168
- ...{ [signerPublicKey]: signature }
1169
- };
1243
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
1244
+ const publicKeySignaturePairs = await Promise.all(
1245
+ keyPairs.map(
1246
+ (keyPair) => Promise.all([
1247
+ getAddressFromPublicKey(keyPair.publicKey),
1248
+ getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1249
+ ])
1250
+ )
1251
+ );
1252
+ for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
1253
+ nextSignatures[signerPublicKey] = signature;
1254
+ }
1170
1255
  const out = {
1171
1256
  ...transaction,
1172
1257
  signatures: nextSignatures
@@ -1175,10 +1260,68 @@ this.globalThis.solanaWeb3 = (function (exports) {
1175
1260
  return out;
1176
1261
  }
1177
1262
 
1263
+ // src/compile-transaction.ts
1264
+ function getCompiledTransaction(transaction) {
1265
+ const compiledMessage = compileMessage(transaction);
1266
+ let signatures;
1267
+ if ("signatures" in transaction) {
1268
+ signatures = [];
1269
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1270
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1271
+ }
1272
+ } else {
1273
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1274
+ }
1275
+ return {
1276
+ compiledMessage,
1277
+ signatures
1278
+ };
1279
+ }
1280
+
1281
+ // src/serializers/transaction.ts
1282
+ var BASE_CONFIG3 = {
1283
+ description: "The wire format of a Solana transaction" ,
1284
+ fixedSize: null,
1285
+ maxSize: null
1286
+ };
1287
+ function serialize3(transaction) {
1288
+ const compiledTransaction = getCompiledTransaction(transaction);
1289
+ return struct([
1290
+ [
1291
+ "signatures",
1292
+ array(bytes({ size: 64 }), {
1293
+ ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1294
+ size: shortU16()
1295
+ })
1296
+ ],
1297
+ ["compiledMessage", getCompiledMessageEncoder()]
1298
+ ]).serialize(compiledTransaction);
1299
+ }
1300
+ function getTransactionEncoder() {
1301
+ return {
1302
+ ...BASE_CONFIG3,
1303
+ deserialize: getUnimplementedDecoder("CompiledMessage"),
1304
+ serialize: serialize3
1305
+ };
1306
+ }
1307
+
1308
+ // src/wire-transaction.ts
1309
+ function getBase64EncodedWireTransaction(transaction) {
1310
+ const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
1311
+ {
1312
+ return btoa(String.fromCharCode(...wireTransactionBytes));
1313
+ }
1314
+ }
1315
+
1178
1316
  exports.appendTransactionInstruction = appendTransactionInstruction;
1317
+ exports.assertIsBlockhash = assertIsBlockhash;
1318
+ exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
1179
1319
  exports.createTransaction = createTransaction;
1320
+ exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
1180
1321
  exports.prependTransactionInstruction = prependTransactionInstruction;
1181
1322
  exports.setTransactionFeePayer = setTransactionFeePayer;
1323
+ exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
1324
+ exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
1182
1325
  exports.signTransaction = signTransaction;
1183
1326
 
1184
1327
  return exports;