@solana/web3.js 2.0.0-experimental.c5061ae → 2.0.0-experimental.c93679a

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.
@@ -12,8 +12,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
12
12
  var __esm = (fn, res) => function __init() {
13
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
14
  };
15
- var __commonJS = (cb, mod) => function __require() {
16
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ var __commonJS = (cb, mod2) => function __require() {
16
+ return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
17
17
  };
18
18
  var __copyProps = (to, from, except, desc) => {
19
19
  if (from && typeof from === "object" || typeof from === "function") {
@@ -23,13 +23,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
23
23
  }
24
24
  return to;
25
25
  };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
27
27
  // If the importer is in node compatibility mode or this is not an ESM
28
28
  // file that has been converted to a CommonJS file using a Babel-
29
29
  // compatible transform (i.e. "__esModule" has not been set), then set
30
30
  // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
31
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
32
+ mod2
33
33
  ));
34
34
  var __publicField = (obj, key, value) => {
35
35
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
@@ -122,53 +122,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
122
122
  // src/index.ts
123
123
  init_env_shim();
124
124
 
125
- // ../instructions/dist/index.browser.js
126
- init_env_shim();
127
- var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
128
- AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
129
- 3] = "WRITABLE_SIGNER";
130
- AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
131
- 2] = "READONLY_SIGNER";
132
- AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
133
- 1] = "WRITABLE";
134
- AccountRole22[AccountRole22["READONLY"] = /* 0 */
135
- 0] = "READONLY";
136
- return AccountRole22;
137
- })(AccountRole || {});
138
- var IS_SIGNER_BITMASK = 2;
139
- var IS_WRITABLE_BITMASK = 1;
140
- function downgradeRoleToNonSigner(role) {
141
- return role & ~IS_SIGNER_BITMASK;
142
- }
143
- function downgradeRoleToReadonly(role) {
144
- return role & ~IS_WRITABLE_BITMASK;
145
- }
146
- function isSignerRole(role) {
147
- return role >= 2;
148
- }
149
- function isWritableRole(role) {
150
- return (role & IS_WRITABLE_BITMASK) !== 0;
151
- }
152
- function mergeRoles(roleA, roleB) {
153
- return roleA | roleB;
154
- }
155
- function upgradeRoleToSigner(role) {
156
- return role | IS_SIGNER_BITMASK;
157
- }
158
- function upgradeRoleToWritable(role) {
159
- return role | IS_WRITABLE_BITMASK;
160
- }
161
-
162
- // ../keys/dist/index.browser.js
125
+ // ../addresses/dist/index.browser.js
163
126
  init_env_shim();
164
127
 
165
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
128
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
166
129
  init_env_shim();
167
130
 
168
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
131
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
169
132
  init_env_shim();
170
133
 
171
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
134
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
172
135
  init_env_shim();
173
136
  var mergeBytes = (bytesArr) => {
174
137
  const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
@@ -189,7 +152,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
189
152
  };
190
153
  var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
191
154
 
192
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
155
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
193
156
  init_env_shim();
194
157
  var DeserializingEmptyBufferError = class extends Error {
195
158
  constructor(serializer) {
@@ -211,7 +174,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
211
174
  }
212
175
  };
213
176
 
214
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
177
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
215
178
  init_env_shim();
216
179
  function fixSerializer(serializer, fixedBytes, description) {
217
180
  return {
@@ -233,7 +196,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
233
196
  };
234
197
  }
235
198
 
236
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
199
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
237
200
  init_env_shim();
238
201
  function mapSerializer(serializer, unmap, map) {
239
202
  return {
@@ -248,13 +211,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
248
211
  };
249
212
  }
250
213
 
251
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
214
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
252
215
  init_env_shim();
253
216
 
254
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
217
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
255
218
  init_env_shim();
256
219
 
257
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
220
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
258
221
  init_env_shim();
259
222
  var InvalidBaseStringError = class extends Error {
260
223
  constructor(value, base, cause) {
@@ -265,7 +228,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
265
228
  }
266
229
  };
267
230
 
268
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
231
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
269
232
  var baseX = (alphabet) => {
270
233
  const base = alphabet.length;
271
234
  const baseBigInt = BigInt(base);
@@ -319,18 +282,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
319
282
  };
320
283
  };
321
284
 
322
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
285
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
323
286
  init_env_shim();
324
287
  var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
325
288
 
326
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
289
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
327
290
  init_env_shim();
328
291
  var removeNullCharacters = (value) => (
329
292
  // eslint-disable-next-line no-control-regex
330
293
  value.replace(/\u0000/g, "")
331
294
  );
332
295
 
333
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
296
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
334
297
  init_env_shim();
335
298
  var utf8 = {
336
299
  description: "utf8",
@@ -345,10 +308,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
345
308
  }
346
309
  };
347
310
 
348
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
311
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
349
312
  init_env_shim();
350
313
 
351
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
314
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
352
315
  init_env_shim();
353
316
  var Endian;
354
317
  (function(Endian2) {
@@ -356,7 +319,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
356
319
  Endian2["Big"] = "be";
357
320
  })(Endian || (Endian = {}));
358
321
 
359
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
322
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
360
323
  init_env_shim();
361
324
  var NumberOutOfRangeError = class extends RangeError {
362
325
  constructor(serializer, min, max, actual) {
@@ -365,7 +328,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
365
328
  }
366
329
  };
367
330
 
368
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
331
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
369
332
  init_env_shim();
370
333
  function numberFactory(input) {
371
334
  let littleEndian;
@@ -410,7 +373,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
410
373
  }
411
374
  };
412
375
 
413
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
376
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
414
377
  init_env_shim();
415
378
  var u8 = (options = {}) => numberFactory({
416
379
  name: "u8",
@@ -421,7 +384,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
421
384
  options
422
385
  });
423
386
 
424
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
387
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
425
388
  init_env_shim();
426
389
  var u32 = (options = {}) => numberFactory({
427
390
  name: "u32",
@@ -432,7 +395,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
432
395
  options
433
396
  });
434
397
 
435
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
398
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
436
399
  init_env_shim();
437
400
  var shortU16 = (options = {}) => ({
438
401
  description: options.description ?? "shortU16",
@@ -470,10 +433,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
470
433
  }
471
434
  });
472
435
 
473
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
436
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
474
437
  init_env_shim();
475
438
 
476
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
439
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
477
440
  init_env_shim();
478
441
  var InvalidNumberOfItemsError = class extends Error {
479
442
  constructor(serializer, expected, actual) {
@@ -494,16 +457,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
494
457
  }
495
458
  };
496
459
 
497
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
460
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
498
461
  init_env_shim();
499
462
 
500
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
463
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
501
464
  init_env_shim();
502
465
  function sumSerializerSizes(sizes) {
503
466
  return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
504
467
  }
505
468
 
506
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
469
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
507
470
  function getResolvedSize(size, childrenSizes, bytes2, offset) {
508
471
  if (typeof size === "number") {
509
472
  return [size, offset];
@@ -539,7 +502,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
539
502
  return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
540
503
  }
541
504
 
542
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
505
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
543
506
  function array(item, options = {}) {
544
507
  const size = options.size ?? u32();
545
508
  if (size === "remainder" && item.fixedSize === null) {
@@ -572,7 +535,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
572
535
  };
573
536
  }
574
537
 
575
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
538
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
576
539
  init_env_shim();
577
540
  function bytes(options = {}) {
578
541
  const size = options.size ?? "variable";
@@ -620,7 +583,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
620
583
  };
621
584
  }
622
585
 
623
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
586
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
624
587
  init_env_shim();
625
588
  function string(options = {}) {
626
589
  const size = options.size ?? u32();
@@ -662,7 +625,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
662
625
  };
663
626
  }
664
627
 
665
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
628
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
666
629
  init_env_shim();
667
630
  function struct(fields, options = {}) {
668
631
  const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
@@ -685,43 +648,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
648
  }
686
649
  };
687
650
  }
688
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
689
- try {
690
- if (
691
- // Lowest address (32 bytes of zeroes)
692
- putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
693
- putativeBase58EncodedAddress.length > 44
694
- ) {
695
- throw new Error("Expected input string to decode to a byte array of length 32.");
696
- }
697
- const bytes2 = base58.serialize(putativeBase58EncodedAddress);
698
- const numBytes = bytes2.byteLength;
699
- if (numBytes !== 32) {
700
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
701
- }
702
- } catch (e2) {
703
- throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
704
- cause: e2
705
- });
706
- }
707
- }
708
- function getBase58EncodedAddressCodec(config) {
709
- return string({
710
- description: config?.description ?? ("A 32-byte account address" ),
711
- encoding: base58,
712
- size: 32
713
- });
714
- }
715
- function getBase58EncodedAddressComparator() {
716
- return new Intl.Collator("en", {
717
- caseFirst: "lower",
718
- ignorePunctuation: false,
719
- localeMatcher: "best fit",
720
- numeric: false,
721
- sensitivity: "variant",
722
- usage: "sort"
723
- }).compare;
724
- }
651
+
652
+ // ../assertions/dist/index.browser.js
653
+ init_env_shim();
725
654
  function assertIsSecureContext() {
726
655
  if (!globalThis.isSecureContext) {
727
656
  throw new Error(
@@ -751,6 +680,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
751
680
  return await cachedEd25519Decision;
752
681
  }
753
682
  }
683
+ async function assertDigestCapabilityIsAvailable() {
684
+ assertIsSecureContext();
685
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
686
+ throw new Error("No digest implementation could be found");
687
+ }
688
+ }
754
689
  async function assertKeyGenerationIsAvailable() {
755
690
  assertIsSecureContext();
756
691
  if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
@@ -780,6 +715,274 @@ this.globalThis.solanaWeb3 = (function (exports) {
780
715
  throw new Error("No signature verification implementation could be found");
781
716
  }
782
717
  }
718
+ function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
719
+ try {
720
+ if (
721
+ // Lowest address (32 bytes of zeroes)
722
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
723
+ putativeBase58EncodedAddress.length > 44
724
+ ) {
725
+ throw new Error("Expected input string to decode to a byte array of length 32.");
726
+ }
727
+ const bytes2 = base58.serialize(putativeBase58EncodedAddress);
728
+ const numBytes = bytes2.byteLength;
729
+ if (numBytes !== 32) {
730
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
731
+ }
732
+ } catch (e3) {
733
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
734
+ cause: e3
735
+ });
736
+ }
737
+ }
738
+ function getBase58EncodedAddressCodec(config) {
739
+ return string({
740
+ description: config?.description ?? ("A 32-byte account address" ),
741
+ encoding: base58,
742
+ size: 32
743
+ });
744
+ }
745
+ function getBase58EncodedAddressComparator() {
746
+ return new Intl.Collator("en", {
747
+ caseFirst: "lower",
748
+ ignorePunctuation: false,
749
+ localeMatcher: "best fit",
750
+ numeric: false,
751
+ sensitivity: "variant",
752
+ usage: "sort"
753
+ }).compare;
754
+ }
755
+ var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
756
+ var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
757
+ var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
758
+ function mod(a) {
759
+ const r = a % P;
760
+ return r >= 0n ? r : P + r;
761
+ }
762
+ function pow2(x, power) {
763
+ let r = x;
764
+ while (power-- > 0n) {
765
+ r *= r;
766
+ r %= P;
767
+ }
768
+ return r;
769
+ }
770
+ function pow_2_252_3(x) {
771
+ const x2 = x * x % P;
772
+ const b2 = x2 * x % P;
773
+ const b4 = pow2(b2, 2n) * b2 % P;
774
+ const b5 = pow2(b4, 1n) * x % P;
775
+ const b10 = pow2(b5, 5n) * b5 % P;
776
+ const b20 = pow2(b10, 10n) * b10 % P;
777
+ const b40 = pow2(b20, 20n) * b20 % P;
778
+ const b80 = pow2(b40, 40n) * b40 % P;
779
+ const b160 = pow2(b80, 80n) * b80 % P;
780
+ const b240 = pow2(b160, 80n) * b80 % P;
781
+ const b250 = pow2(b240, 10n) * b10 % P;
782
+ const pow_p_5_8 = pow2(b250, 2n) * x % P;
783
+ return pow_p_5_8;
784
+ }
785
+ function uvRatio(u, v) {
786
+ const v3 = mod(v * v * v);
787
+ const v7 = mod(v3 * v3 * v);
788
+ const pow = pow_2_252_3(u * v7);
789
+ let x = mod(u * v3 * pow);
790
+ const vx2 = mod(v * x * x);
791
+ const root1 = x;
792
+ const root2 = mod(x * RM1);
793
+ const useRoot1 = vx2 === u;
794
+ const useRoot2 = vx2 === mod(-u);
795
+ const noRoot = vx2 === mod(-u * RM1);
796
+ if (useRoot1)
797
+ x = root1;
798
+ if (useRoot2 || noRoot)
799
+ x = root2;
800
+ if ((mod(x) & 1n) === 1n)
801
+ x = mod(-x);
802
+ if (!useRoot1 && !useRoot2) {
803
+ return null;
804
+ }
805
+ return x;
806
+ }
807
+ function pointIsOnCurve(y, lastByte) {
808
+ const y2 = mod(y * y);
809
+ const u = mod(y2 - 1n);
810
+ const v = mod(D * y2 + 1n);
811
+ const x = uvRatio(u, v);
812
+ if (x === null) {
813
+ return false;
814
+ }
815
+ const isLastByteOdd = (lastByte & 128) !== 0;
816
+ if (x === 0n && isLastByteOdd) {
817
+ return false;
818
+ }
819
+ return true;
820
+ }
821
+ function byteToHex(byte) {
822
+ const hexString = byte.toString(16);
823
+ if (hexString.length === 1) {
824
+ return `0${hexString}`;
825
+ } else {
826
+ return hexString;
827
+ }
828
+ }
829
+ function decompressPointBytes(bytes2) {
830
+ const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
831
+ const integerLiteralString = `0x${hexString}`;
832
+ return BigInt(integerLiteralString);
833
+ }
834
+ async function compressedPointBytesAreOnCurve(bytes2) {
835
+ if (bytes2.byteLength !== 32) {
836
+ return false;
837
+ }
838
+ const y = decompressPointBytes(bytes2);
839
+ return pointIsOnCurve(y, bytes2[31]);
840
+ }
841
+ var MAX_SEED_LENGTH = 32;
842
+ var MAX_SEEDS = 16;
843
+ var PDA_MARKER_BYTES = [
844
+ // The string 'ProgramDerivedAddress'
845
+ 80,
846
+ 114,
847
+ 111,
848
+ 103,
849
+ 114,
850
+ 97,
851
+ 109,
852
+ 68,
853
+ 101,
854
+ 114,
855
+ 105,
856
+ 118,
857
+ 101,
858
+ 100,
859
+ 65,
860
+ 100,
861
+ 100,
862
+ 114,
863
+ 101,
864
+ 115,
865
+ 115
866
+ ];
867
+ var PointOnCurveError = class extends Error {
868
+ };
869
+ async function createProgramDerivedAddress({ programAddress, seeds }) {
870
+ await assertDigestCapabilityIsAvailable();
871
+ if (seeds.length > MAX_SEEDS) {
872
+ throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
873
+ }
874
+ let textEncoder;
875
+ const seedBytes = seeds.reduce((acc, seed, ii) => {
876
+ const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
877
+ if (bytes2.byteLength > MAX_SEED_LENGTH) {
878
+ throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
879
+ }
880
+ acc.push(...bytes2);
881
+ return acc;
882
+ }, []);
883
+ const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
884
+ const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
885
+ const addressBytesBuffer = await crypto.subtle.digest(
886
+ "SHA-256",
887
+ new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
888
+ );
889
+ const addressBytes = new Uint8Array(addressBytesBuffer);
890
+ if (await compressedPointBytesAreOnCurve(addressBytes)) {
891
+ throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
892
+ }
893
+ return base58EncodedAddressCodec.deserialize(addressBytes)[0];
894
+ }
895
+ async function getProgramDerivedAddress({ programAddress, seeds }) {
896
+ let bumpSeed = 255;
897
+ while (bumpSeed > 0) {
898
+ try {
899
+ return {
900
+ bumpSeed,
901
+ pda: await createProgramDerivedAddress({
902
+ programAddress,
903
+ seeds: [...seeds, new Uint8Array([bumpSeed])]
904
+ })
905
+ };
906
+ } catch (e3) {
907
+ if (e3 instanceof PointOnCurveError) {
908
+ bumpSeed--;
909
+ } else {
910
+ throw e3;
911
+ }
912
+ }
913
+ }
914
+ throw new Error("Unable to find a viable program address bump seed");
915
+ }
916
+ async function createAddressWithSeed({
917
+ baseAddress,
918
+ programAddress,
919
+ seed
920
+ }) {
921
+ const { serialize: serialize4, deserialize: deserialize2 } = getBase58EncodedAddressCodec();
922
+ const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
923
+ if (seedBytes.byteLength > MAX_SEED_LENGTH) {
924
+ throw new Error(`The seed exceeds the maximum length of 32 bytes`);
925
+ }
926
+ const programAddressBytes = serialize4(programAddress);
927
+ if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
928
+ throw new Error(`programAddress cannot end with the PDA marker`);
929
+ }
930
+ const addressBytesBuffer = await crypto.subtle.digest(
931
+ "SHA-256",
932
+ new Uint8Array([...serialize4(baseAddress), ...seedBytes, ...programAddressBytes])
933
+ );
934
+ const addressBytes = new Uint8Array(addressBytesBuffer);
935
+ return deserialize2(addressBytes)[0];
936
+ }
937
+ async function getAddressFromPublicKey(publicKey) {
938
+ await assertKeyExporterIsAvailable();
939
+ if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
940
+ throw new Error("The `CryptoKey` must be an `Ed25519` public key");
941
+ }
942
+ const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
943
+ const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
944
+ return base58EncodedAddress;
945
+ }
946
+
947
+ // ../instructions/dist/index.browser.js
948
+ init_env_shim();
949
+ var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
950
+ AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
951
+ 3] = "WRITABLE_SIGNER";
952
+ AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
953
+ 2] = "READONLY_SIGNER";
954
+ AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
955
+ 1] = "WRITABLE";
956
+ AccountRole22[AccountRole22["READONLY"] = /* 0 */
957
+ 0] = "READONLY";
958
+ return AccountRole22;
959
+ })(AccountRole || {});
960
+ var IS_SIGNER_BITMASK = 2;
961
+ var IS_WRITABLE_BITMASK = 1;
962
+ function downgradeRoleToNonSigner(role) {
963
+ return role & ~IS_SIGNER_BITMASK;
964
+ }
965
+ function downgradeRoleToReadonly(role) {
966
+ return role & ~IS_WRITABLE_BITMASK;
967
+ }
968
+ function isSignerRole(role) {
969
+ return role >= 2;
970
+ }
971
+ function isWritableRole(role) {
972
+ return (role & IS_WRITABLE_BITMASK) !== 0;
973
+ }
974
+ function mergeRoles(roleA, roleB) {
975
+ return roleA | roleB;
976
+ }
977
+ function upgradeRoleToSigner(role) {
978
+ return role | IS_SIGNER_BITMASK;
979
+ }
980
+ function upgradeRoleToWritable(role) {
981
+ return role | IS_WRITABLE_BITMASK;
982
+ }
983
+
984
+ // ../keys/dist/index.browser.js
985
+ init_env_shim();
783
986
  async function generateKeyPair() {
784
987
  await assertKeyGenerationIsAvailable();
785
988
  const keyPair = await crypto.subtle.generateKey(
@@ -794,15 +997,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
794
997
  );
795
998
  return keyPair;
796
999
  }
797
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
798
- await assertKeyExporterIsAvailable();
799
- if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
800
- throw new Error("The `CryptoKey` must be an `Ed25519` public key");
801
- }
802
- const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
803
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
804
- return base58EncodedAddress;
805
- }
806
1000
  async function signBytes(key, data) {
807
1001
  await assertSigningCapabilityIsAvailable();
808
1002
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
@@ -841,9 +1035,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
841
1035
  if (numBytes !== 32) {
842
1036
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
843
1037
  }
844
- } catch (e2) {
1038
+ } catch (e3) {
845
1039
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
846
- cause: e2
1040
+ cause: e3
847
1041
  });
848
1042
  }
849
1043
  }
@@ -896,6 +1090,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
896
1090
  throw new Error("Transaction is not a durable nonce transaction");
897
1091
  }
898
1092
  }
1093
+ function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
1094
+ return {
1095
+ accounts: [
1096
+ { address: nonceAccountAddress, role: AccountRole2.WRITABLE },
1097
+ {
1098
+ address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
1099
+ role: AccountRole2.READONLY
1100
+ },
1101
+ { address: nonceAuthorityAddress, role: AccountRole2.READONLY_SIGNER }
1102
+ ],
1103
+ data: new Uint8Array([4, 0, 0, 0]),
1104
+ programAddress: SYSTEM_PROGRAM_ADDRESS
1105
+ };
1106
+ }
899
1107
  function isAdvanceNonceAccountInstruction(instruction) {
900
1108
  return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
901
1109
  instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
@@ -910,6 +1118,28 @@ this.globalThis.solanaWeb3 = (function (exports) {
910
1118
  function isDurableNonceTransaction(transaction) {
911
1119
  return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
912
1120
  }
1121
+ function setTransactionLifetimeUsingDurableNonce({
1122
+ nonce,
1123
+ nonceAccountAddress,
1124
+ nonceAuthorityAddress
1125
+ }, transaction) {
1126
+ const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
1127
+ if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
1128
+ return transaction;
1129
+ }
1130
+ const out = {
1131
+ ...getUnsignedTransaction(transaction),
1132
+ instructions: [
1133
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1134
+ ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
1135
+ ],
1136
+ lifetimeConstraint: {
1137
+ nonce
1138
+ }
1139
+ };
1140
+ Object.freeze(out);
1141
+ return out;
1142
+ }
913
1143
  function setTransactionFeePayer(feePayer, transaction) {
914
1144
  if ("feePayer" in transaction && feePayer === transaction.feePayer) {
915
1145
  return transaction;
@@ -1275,7 +1505,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1275
1505
  )
1276
1506
  ],
1277
1507
  [
1278
- "addressIndices",
1508
+ "accountIndices",
1279
1509
  array(
1280
1510
  u8({
1281
1511
  description: "The index of an account, according to the well-ordered accounts list for this transaction"
@@ -1295,23 +1525,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
1295
1525
  ]
1296
1526
  ]),
1297
1527
  (value) => {
1298
- if (value.addressIndices !== void 0 && value.data !== void 0) {
1528
+ if (value.accountIndices !== void 0 && value.data !== void 0) {
1299
1529
  return value;
1300
1530
  }
1301
1531
  return {
1302
1532
  ...value,
1303
- addressIndices: value.addressIndices ?? [],
1533
+ accountIndices: value.accountIndices ?? [],
1304
1534
  data: value.data ?? new Uint8Array(0)
1305
1535
  };
1306
1536
  },
1307
1537
  (value) => {
1308
- if (value.addressIndices.length && value.data.byteLength) {
1538
+ if (value.accountIndices.length && value.data.byteLength) {
1309
1539
  return value;
1310
1540
  }
1311
- const { addressIndices, data, ...rest } = value;
1541
+ const { accountIndices, data, ...rest } = value;
1312
1542
  return {
1313
1543
  ...rest,
1314
- ...addressIndices.length ? { addressIndices } : null,
1544
+ ...accountIndices.length ? { accountIndices } : null,
1315
1545
  ...data.byteLength ? { data } : null
1316
1546
  };
1317
1547
  }
@@ -1434,7 +1664,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1434
1664
  async function signTransaction(keyPair, transaction) {
1435
1665
  const compiledMessage = compileMessage(transaction);
1436
1666
  const [signerPublicKey, signature] = await Promise.all([
1437
- getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
1667
+ getAddressFromPublicKey(keyPair.publicKey),
1438
1668
  getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1439
1669
  ]);
1440
1670
  const nextSignatures = {
@@ -1527,85 +1757,246 @@ this.globalThis.solanaWeb3 = (function (exports) {
1527
1757
  return visitNode(params, [], onIntegerOverflow);
1528
1758
  }
1529
1759
  var KEYPATH_WILDCARD = {};
1530
- var ALLOWED_NUMERIC_KEYPATHS = {
1531
- getAccountInfo: [
1532
- // parsed AddressTableLookup account
1533
- ["value", "data", "parsed", "info", "lastExtendedSlotStartIndex"],
1534
- // parsed Config account
1535
- ["value", "data", "parsed", "info", "slashPenalty"],
1536
- ["value", "data", "parsed", "info", "warmupCooldownRate"],
1537
- // parsed Token/Token22 token account
1538
- ["value", "data", "parsed", "info", "tokenAmount", "decimals"],
1539
- ["value", "data", "parsed", "info", "tokenAmount", "uiAmount"],
1540
- ["value", "data", "parsed", "info", "rentExemptReserve", "decimals"],
1541
- ["value", "data", "parsed", "info", "delegatedAmount", "decimals"],
1542
- [
1543
- "value",
1544
- "data",
1545
- "parsed",
1546
- "info",
1547
- "extensions",
1548
- KEYPATH_WILDCARD,
1549
- "state",
1550
- "olderTransferFee",
1551
- "transferFeeBasisPoints"
1552
- ],
1553
- [
1554
- "value",
1555
- "data",
1556
- "parsed",
1557
- "info",
1558
- "extensions",
1559
- KEYPATH_WILDCARD,
1560
- "state",
1561
- "newerTransferFee",
1562
- "transferFeeBasisPoints"
1563
- ],
1564
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
1565
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"],
1566
- // parsed Token/Token22 mint account
1567
- ["value", "data", "parsed", "info", "decimals"],
1568
- // parsed Token/Token22 multisig account
1569
- ["value", "data", "parsed", "info", "numRequiredSigners"],
1570
- ["value", "data", "parsed", "info", "numValidSigners"],
1571
- // parsed Stake account
1572
- ["value", "data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
1573
- // parsed Sysvar rent account
1574
- ["value", "data", "parsed", "info", "exemptionThreshold"],
1575
- ["value", "data", "parsed", "info", "burnPercent"],
1576
- // parsed Vote account
1577
- ["value", "data", "parsed", "info", "commission"],
1578
- ["value", "data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
1579
- ],
1580
- getBlockTime: [[]],
1581
- getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
1582
- getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
1583
- getTokenLargestAccounts: [
1584
- ["value", KEYPATH_WILDCARD, "decimals"],
1585
- ["value", KEYPATH_WILDCARD, "uiAmount"]
1586
- ],
1587
- getTransaction: [
1588
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1589
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1590
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1591
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1592
- ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
1593
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
1594
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1595
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1596
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
1597
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
1598
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1599
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1600
- ["transaction", "message", "header", "numReadonlySignedAccounts"],
1601
- ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
1602
- ["transaction", "message", "header", "numRequiredSignatures"]
1603
- ],
1604
- getVoteAccounts: [
1605
- ["current", KEYPATH_WILDCARD, "commission"],
1606
- ["delinquent", KEYPATH_WILDCARD, "commission"]
1607
- ]
1608
- };
1760
+ var memoizedNotificationKeypaths;
1761
+ var memoizedResponseKeypaths;
1762
+ function getAllowedNumericKeypathsForNotification() {
1763
+ if (!memoizedNotificationKeypaths) {
1764
+ memoizedNotificationKeypaths = {};
1765
+ }
1766
+ return memoizedNotificationKeypaths;
1767
+ }
1768
+ function getAllowedNumericKeypathsForResponse() {
1769
+ if (!memoizedResponseKeypaths) {
1770
+ const jsonParsedTokenAccountsConfigs = [
1771
+ // parsed Token/Token22 token account
1772
+ ["data", "parsed", "info", "tokenAmount", "decimals"],
1773
+ ["data", "parsed", "info", "tokenAmount", "uiAmount"],
1774
+ ["data", "parsed", "info", "rentExemptReserve", "decimals"],
1775
+ ["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
1776
+ ["data", "parsed", "info", "delegatedAmount", "decimals"],
1777
+ ["data", "parsed", "info", "delegatedAmount", "uiAmount"],
1778
+ [
1779
+ "data",
1780
+ "parsed",
1781
+ "info",
1782
+ "extensions",
1783
+ KEYPATH_WILDCARD,
1784
+ "state",
1785
+ "olderTransferFee",
1786
+ "transferFeeBasisPoints"
1787
+ ],
1788
+ [
1789
+ "data",
1790
+ "parsed",
1791
+ "info",
1792
+ "extensions",
1793
+ KEYPATH_WILDCARD,
1794
+ "state",
1795
+ "newerTransferFee",
1796
+ "transferFeeBasisPoints"
1797
+ ],
1798
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
1799
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
1800
+ ];
1801
+ const jsonParsedAccountsConfigs = [
1802
+ ...jsonParsedTokenAccountsConfigs,
1803
+ // parsed AddressTableLookup account
1804
+ ["data", "parsed", "info", "lastExtendedSlotStartIndex"],
1805
+ // parsed Config account
1806
+ ["data", "parsed", "info", "slashPenalty"],
1807
+ ["data", "parsed", "info", "warmupCooldownRate"],
1808
+ // parsed Token/Token22 mint account
1809
+ ["data", "parsed", "info", "decimals"],
1810
+ // parsed Token/Token22 multisig account
1811
+ ["data", "parsed", "info", "numRequiredSigners"],
1812
+ ["data", "parsed", "info", "numValidSigners"],
1813
+ // parsed Stake account
1814
+ ["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
1815
+ // parsed Sysvar rent account
1816
+ ["data", "parsed", "info", "exemptionThreshold"],
1817
+ ["data", "parsed", "info", "burnPercent"],
1818
+ // parsed Vote account
1819
+ ["data", "parsed", "info", "commission"],
1820
+ ["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
1821
+ ];
1822
+ memoizedResponseKeypaths = {
1823
+ getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
1824
+ getBlock: [
1825
+ ["blockTime"],
1826
+ ["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1827
+ [
1828
+ "transactions",
1829
+ KEYPATH_WILDCARD,
1830
+ "meta",
1831
+ "preTokenBalances",
1832
+ KEYPATH_WILDCARD,
1833
+ "uiTokenAmount",
1834
+ "decimals"
1835
+ ],
1836
+ ["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1837
+ [
1838
+ "transactions",
1839
+ KEYPATH_WILDCARD,
1840
+ "meta",
1841
+ "postTokenBalances",
1842
+ KEYPATH_WILDCARD,
1843
+ "uiTokenAmount",
1844
+ "decimals"
1845
+ ],
1846
+ ["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
1847
+ ["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
1848
+ [
1849
+ "transactions",
1850
+ KEYPATH_WILDCARD,
1851
+ "meta",
1852
+ "innerInstructions",
1853
+ KEYPATH_WILDCARD,
1854
+ "instructions",
1855
+ KEYPATH_WILDCARD,
1856
+ "programIdIndex"
1857
+ ],
1858
+ [
1859
+ "transactions",
1860
+ KEYPATH_WILDCARD,
1861
+ "meta",
1862
+ "innerInstructions",
1863
+ KEYPATH_WILDCARD,
1864
+ "instructions",
1865
+ KEYPATH_WILDCARD,
1866
+ "accounts",
1867
+ KEYPATH_WILDCARD
1868
+ ],
1869
+ [
1870
+ "transactions",
1871
+ KEYPATH_WILDCARD,
1872
+ "transaction",
1873
+ "message",
1874
+ "addressTableLookups",
1875
+ KEYPATH_WILDCARD,
1876
+ "writableIndexes",
1877
+ KEYPATH_WILDCARD
1878
+ ],
1879
+ [
1880
+ "transactions",
1881
+ KEYPATH_WILDCARD,
1882
+ "transaction",
1883
+ "message",
1884
+ "addressTableLookups",
1885
+ KEYPATH_WILDCARD,
1886
+ "readonlyIndexes",
1887
+ KEYPATH_WILDCARD
1888
+ ],
1889
+ [
1890
+ "transactions",
1891
+ KEYPATH_WILDCARD,
1892
+ "transaction",
1893
+ "message",
1894
+ "instructions",
1895
+ KEYPATH_WILDCARD,
1896
+ "programIdIndex"
1897
+ ],
1898
+ [
1899
+ "transactions",
1900
+ KEYPATH_WILDCARD,
1901
+ "transaction",
1902
+ "message",
1903
+ "instructions",
1904
+ KEYPATH_WILDCARD,
1905
+ "accounts",
1906
+ KEYPATH_WILDCARD
1907
+ ],
1908
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
1909
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
1910
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
1911
+ ["rewards", KEYPATH_WILDCARD, "commission"]
1912
+ ],
1913
+ getBlockTime: [[]],
1914
+ getClusterNodes: [
1915
+ [KEYPATH_WILDCARD, "featureSet"],
1916
+ [KEYPATH_WILDCARD, "shredVersion"]
1917
+ ],
1918
+ getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
1919
+ getInflationRate: [["foundation"], ["total"], ["validator"]],
1920
+ getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
1921
+ getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
1922
+ getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
1923
+ ["value", KEYPATH_WILDCARD, "account", ...c],
1924
+ [KEYPATH_WILDCARD, "account", ...c]
1925
+ ]),
1926
+ getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
1927
+ getTokenAccountBalance: [
1928
+ ["value", "decimals"],
1929
+ ["value", "uiAmount"]
1930
+ ],
1931
+ getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
1932
+ "value",
1933
+ KEYPATH_WILDCARD,
1934
+ "account",
1935
+ ...c
1936
+ ]),
1937
+ getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
1938
+ "value",
1939
+ KEYPATH_WILDCARD,
1940
+ "account",
1941
+ ...c
1942
+ ]),
1943
+ getTokenLargestAccounts: [
1944
+ ["value", KEYPATH_WILDCARD, "decimals"],
1945
+ ["value", KEYPATH_WILDCARD, "uiAmount"]
1946
+ ],
1947
+ getTokenSupply: [
1948
+ ["value", "decimals"],
1949
+ ["value", "uiAmount"]
1950
+ ],
1951
+ getTransaction: [
1952
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1953
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1954
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1955
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1956
+ ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
1957
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
1958
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1959
+ [
1960
+ "meta",
1961
+ "innerInstructions",
1962
+ KEYPATH_WILDCARD,
1963
+ "instructions",
1964
+ KEYPATH_WILDCARD,
1965
+ "accounts",
1966
+ KEYPATH_WILDCARD
1967
+ ],
1968
+ [
1969
+ "transaction",
1970
+ "message",
1971
+ "addressTableLookups",
1972
+ KEYPATH_WILDCARD,
1973
+ "writableIndexes",
1974
+ KEYPATH_WILDCARD
1975
+ ],
1976
+ [
1977
+ "transaction",
1978
+ "message",
1979
+ "addressTableLookups",
1980
+ KEYPATH_WILDCARD,
1981
+ "readonlyIndexes",
1982
+ KEYPATH_WILDCARD
1983
+ ],
1984
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1985
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1986
+ ["transaction", "message", "header", "numReadonlySignedAccounts"],
1987
+ ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
1988
+ ["transaction", "message", "header", "numRequiredSignatures"]
1989
+ ],
1990
+ getVersion: [["feature-set"]],
1991
+ getVoteAccounts: [
1992
+ ["current", KEYPATH_WILDCARD, "commission"],
1993
+ ["delinquent", KEYPATH_WILDCARD, "commission"]
1994
+ ],
1995
+ simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
1996
+ };
1997
+ }
1998
+ return memoizedResponseKeypaths;
1999
+ }
1609
2000
  function getNextAllowedKeypaths(keyPaths, property) {
1610
2001
  return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
1611
2002
  }
@@ -1632,7 +2023,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1632
2023
  }
1633
2024
  }
1634
2025
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
1635
- const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
2026
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
2027
+ return visitNode2(rawResponse, allowedKeypaths ?? []);
2028
+ }
2029
+ function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
2030
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
1636
2031
  return visitNode2(rawResponse, allowedKeypaths ?? []);
1637
2032
  }
1638
2033
  function createSolanaRpcApi(config) {
@@ -1661,6 +2056,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
1661
2056
  }
1662
2057
  });
1663
2058
  }
2059
+ function createSolanaRpcSubscriptionsApi(config) {
2060
+ return new Proxy({}, {
2061
+ defineProperty() {
2062
+ return false;
2063
+ },
2064
+ deleteProperty() {
2065
+ return false;
2066
+ },
2067
+ get(...args) {
2068
+ const [_, p] = args;
2069
+ const notificationName = p.toString();
2070
+ return function(...rawParams) {
2071
+ const handleIntegerOverflow = config?.onIntegerOverflow;
2072
+ const params = patchParamsForSolanaLabsRpc(
2073
+ rawParams,
2074
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
2075
+ );
2076
+ return {
2077
+ params,
2078
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
2079
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
2080
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
2081
+ };
2082
+ };
2083
+ }
2084
+ });
2085
+ }
1664
2086
 
1665
2087
  // ../rpc-transport/dist/index.browser.js
1666
2088
  init_env_shim();
@@ -1727,6 +2149,100 @@ this.globalThis.solanaWeb3 = (function (exports) {
1727
2149
  function createJsonRpc(rpcConfig) {
1728
2150
  return makeProxy(rpcConfig);
1729
2151
  }
2152
+ function registerIterableCleanup(iterable, cleanupFn) {
2153
+ (async () => {
2154
+ try {
2155
+ for await (const _ of iterable)
2156
+ ;
2157
+ } catch {
2158
+ } finally {
2159
+ cleanupFn();
2160
+ }
2161
+ })();
2162
+ }
2163
+ function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
2164
+ return {
2165
+ async subscribe(options) {
2166
+ options?.abortSignal?.throwIfAborted();
2167
+ let subscriptionId;
2168
+ function handleCleanup() {
2169
+ if (subscriptionId !== void 0) {
2170
+ const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
2171
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
2172
+ connectionAbortController.abort();
2173
+ });
2174
+ } else {
2175
+ connectionAbortController.abort();
2176
+ }
2177
+ }
2178
+ options?.abortSignal?.addEventListener("abort", handleCleanup);
2179
+ const connectionAbortController = new AbortController();
2180
+ const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
2181
+ const connection = await rpcConfig.transport({
2182
+ payload: subscribeMessage,
2183
+ signal: connectionAbortController.signal
2184
+ });
2185
+ function handleConnectionCleanup() {
2186
+ options?.abortSignal?.removeEventListener("abort", handleCleanup);
2187
+ }
2188
+ registerIterableCleanup(connection, handleConnectionCleanup);
2189
+ for await (const message of connection) {
2190
+ if ("id" in message && message.id === subscribeMessage.id) {
2191
+ if ("error" in message) {
2192
+ throw new SolanaJsonRpcError(message.error);
2193
+ } else {
2194
+ subscriptionId = message.result;
2195
+ break;
2196
+ }
2197
+ }
2198
+ }
2199
+ if (subscriptionId == null) {
2200
+ throw new Error("Failed to obtain a subscription id from the server");
2201
+ }
2202
+ return {
2203
+ async *[Symbol.asyncIterator]() {
2204
+ for await (const message of connection) {
2205
+ if (!("params" in message) || message.params.subscription !== subscriptionId) {
2206
+ continue;
2207
+ }
2208
+ const notification = message.params.result;
2209
+ yield responseProcessor ? responseProcessor(notification) : notification;
2210
+ }
2211
+ }
2212
+ };
2213
+ }
2214
+ };
2215
+ }
2216
+ function makeProxy2(rpcConfig) {
2217
+ return new Proxy(rpcConfig.api, {
2218
+ defineProperty() {
2219
+ return false;
2220
+ },
2221
+ deleteProperty() {
2222
+ return false;
2223
+ },
2224
+ get(target, p, receiver) {
2225
+ return function(...rawParams) {
2226
+ const methodName = p.toString();
2227
+ const createRpcSubscription = Reflect.get(target, methodName, receiver);
2228
+ if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
2229
+ throw new Error(
2230
+ "Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
2231
+ );
2232
+ }
2233
+ const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
2234
+ params: rawParams,
2235
+ subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
2236
+ unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
2237
+ };
2238
+ return createPendingRpcSubscription(rpcConfig, newRequest);
2239
+ };
2240
+ }
2241
+ });
2242
+ }
2243
+ function createJsonSubscriptionRpc(rpcConfig) {
2244
+ return makeProxy2(rpcConfig);
2245
+ }
1730
2246
  var e = globalThis.fetch;
1731
2247
  var SolanaHttpError = class extends Error {
1732
2248
  constructor(details) {
@@ -1825,6 +2341,166 @@ this.globalThis.solanaWeb3 = (function (exports) {
1825
2341
  return await response.json();
1826
2342
  };
1827
2343
  }
2344
+ var e2 = globalThis.WebSocket;
2345
+ async function createWebSocketConnection({
2346
+ sendBufferHighWatermark,
2347
+ signal,
2348
+ url
2349
+ }) {
2350
+ return new Promise((resolve, reject) => {
2351
+ signal.addEventListener("abort", handleAbort, { once: true });
2352
+ const iteratorState = /* @__PURE__ */ new Map();
2353
+ function handleAbort() {
2354
+ if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
2355
+ webSocket.close(1e3);
2356
+ }
2357
+ }
2358
+ function handleClose(ev) {
2359
+ bufferDrainWatcher?.onCancel();
2360
+ signal.removeEventListener("abort", handleAbort);
2361
+ webSocket.removeEventListener("close", handleClose);
2362
+ webSocket.removeEventListener("error", handleError);
2363
+ webSocket.removeEventListener("open", handleOpen);
2364
+ webSocket.removeEventListener("message", handleMessage);
2365
+ iteratorState.forEach((state, iteratorKey) => {
2366
+ if (state.__hasPolled) {
2367
+ const { onError } = state;
2368
+ iteratorState.delete(iteratorKey);
2369
+ onError(ev);
2370
+ } else {
2371
+ iteratorState.delete(iteratorKey);
2372
+ }
2373
+ });
2374
+ }
2375
+ function handleError(ev) {
2376
+ if (!hasConnected) {
2377
+ reject(
2378
+ // TODO: Coded error
2379
+ new Error("WebSocket failed to connect", { cause: ev })
2380
+ );
2381
+ }
2382
+ }
2383
+ let hasConnected = false;
2384
+ let bufferDrainWatcher;
2385
+ function handleOpen() {
2386
+ hasConnected = true;
2387
+ resolve({
2388
+ async send(payload) {
2389
+ const message = JSON.stringify(payload);
2390
+ if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
2391
+ let onCancel;
2392
+ const promise = new Promise((resolve2, reject2) => {
2393
+ const intervalId = setInterval(() => {
2394
+ if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
2395
+ clearInterval(intervalId);
2396
+ bufferDrainWatcher = void 0;
2397
+ resolve2();
2398
+ }
2399
+ }, 16);
2400
+ onCancel = () => {
2401
+ bufferDrainWatcher = void 0;
2402
+ clearInterval(intervalId);
2403
+ reject2(
2404
+ // TODO: Coded error
2405
+ new Error("WebSocket was closed before payload could be sent")
2406
+ );
2407
+ };
2408
+ });
2409
+ bufferDrainWatcher = {
2410
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2411
+ // @ts-ignore
2412
+ onCancel,
2413
+ promise
2414
+ };
2415
+ }
2416
+ if (bufferDrainWatcher) {
2417
+ await bufferDrainWatcher.promise;
2418
+ }
2419
+ webSocket.send(message);
2420
+ },
2421
+ async *[Symbol.asyncIterator]() {
2422
+ const iteratorKey = Symbol();
2423
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
2424
+ try {
2425
+ while (true) {
2426
+ const state = iteratorState.get(iteratorKey);
2427
+ if (!state) {
2428
+ throw new Error("Invariant: WebSocket message iterator is missing state storage");
2429
+ }
2430
+ if (state.__hasPolled) {
2431
+ throw new Error(
2432
+ "Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
2433
+ );
2434
+ }
2435
+ const queuedMessages = state.queuedMessages;
2436
+ if (queuedMessages.length) {
2437
+ state.queuedMessages = [];
2438
+ yield* queuedMessages;
2439
+ } else {
2440
+ try {
2441
+ yield await new Promise((onMessage, onError) => {
2442
+ iteratorState.set(iteratorKey, {
2443
+ __hasPolled: true,
2444
+ onError,
2445
+ onMessage
2446
+ });
2447
+ });
2448
+ } catch (e3) {
2449
+ if (e3 !== null && typeof e3 === "object" && "type" in e3 && e3.type === "close" && "wasClean" in e3 && e3.wasClean) {
2450
+ return;
2451
+ } else {
2452
+ throw new Error("WebSocket connection closed", { cause: e3 });
2453
+ }
2454
+ }
2455
+ }
2456
+ }
2457
+ } finally {
2458
+ iteratorState.delete(iteratorKey);
2459
+ }
2460
+ }
2461
+ });
2462
+ }
2463
+ function handleMessage({ data }) {
2464
+ const message = JSON.parse(data);
2465
+ iteratorState.forEach((state, iteratorKey) => {
2466
+ if (state.__hasPolled) {
2467
+ const { onMessage } = state;
2468
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
2469
+ onMessage(message);
2470
+ } else {
2471
+ state.queuedMessages.push(message);
2472
+ }
2473
+ });
2474
+ }
2475
+ const webSocket = new e2(url);
2476
+ webSocket.addEventListener("close", handleClose);
2477
+ webSocket.addEventListener("error", handleError);
2478
+ webSocket.addEventListener("open", handleOpen);
2479
+ webSocket.addEventListener("message", handleMessage);
2480
+ });
2481
+ }
2482
+ function createWebSocketTransport({ sendBufferHighWatermark, url }) {
2483
+ if (/^wss?:/i.test(url) === false) {
2484
+ const protocolMatch = url.match(/^([^:]+):/);
2485
+ throw new DOMException(
2486
+ protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
2487
+ );
2488
+ }
2489
+ return async function sendWebSocketMessage({ payload, signal }) {
2490
+ signal?.throwIfAborted();
2491
+ const connection = await createWebSocketConnection({
2492
+ sendBufferHighWatermark,
2493
+ signal,
2494
+ url
2495
+ });
2496
+ signal?.throwIfAborted();
2497
+ await connection.send(payload);
2498
+ return {
2499
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
2500
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
2501
+ };
2502
+ };
2503
+ }
1828
2504
 
1829
2505
  // src/rpc-default-config.ts
1830
2506
  init_env_shim();
@@ -1873,6 +2549,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
1873
2549
  api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
1874
2550
  });
1875
2551
  }
2552
+ function createSolanaRpcSubscriptions(config) {
2553
+ return createJsonSubscriptionRpc({
2554
+ ...config,
2555
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
2556
+ });
2557
+ }
1876
2558
 
1877
2559
  // src/rpc-transport.ts
1878
2560
  init_env_shim();
@@ -1909,14 +2591,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1909
2591
  if (signal) {
1910
2592
  const responsePromise = coalescedRequest.responsePromise;
1911
2593
  return await new Promise((resolve, reject) => {
1912
- const handleAbort = (e2) => {
2594
+ const handleAbort = (e3) => {
1913
2595
  signal.removeEventListener("abort", handleAbort);
1914
2596
  coalescedRequest.numConsumers -= 1;
1915
2597
  if (coalescedRequest.numConsumers === 0) {
1916
2598
  const abortController = coalescedRequest.abortController;
1917
2599
  abortController.abort();
1918
2600
  }
1919
- const abortError = new DOMException(e2.target.reason, "AbortError");
2601
+ const abortError = new DOMException(e3.target.reason, "AbortError");
1920
2602
  reject(abortError);
1921
2603
  };
1922
2604
  signal.addEventListener("abort", handleAbort);
@@ -1966,27 +2648,213 @@ this.globalThis.solanaWeb3 = (function (exports) {
1966
2648
  );
1967
2649
  }
1968
2650
 
2651
+ // src/rpc-websocket-transport.ts
2652
+ init_env_shim();
2653
+
2654
+ // src/rpc-websocket-autopinger.ts
2655
+ init_env_shim();
2656
+ var PING_PAYLOAD = {
2657
+ jsonrpc: "2.0",
2658
+ method: "ping"
2659
+ };
2660
+ function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
2661
+ const pingableConnections = /* @__PURE__ */ new Map();
2662
+ return async (...args) => {
2663
+ const connection = await transport(...args);
2664
+ let intervalId;
2665
+ function sendPing() {
2666
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
2667
+ }
2668
+ function restartPingTimer() {
2669
+ clearInterval(intervalId);
2670
+ intervalId = setInterval(sendPing, intervalMs);
2671
+ }
2672
+ if (pingableConnections.has(connection) === false) {
2673
+ pingableConnections.set(connection, {
2674
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
2675
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
2676
+ restartPingTimer();
2677
+ return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
2678
+ }
2679
+ });
2680
+ (async () => {
2681
+ try {
2682
+ for await (const _ of connection) {
2683
+ restartPingTimer();
2684
+ }
2685
+ } catch {
2686
+ } finally {
2687
+ pingableConnections.delete(connection);
2688
+ clearInterval(intervalId);
2689
+ if (handleOffline) {
2690
+ globalThis.window.removeEventListener("offline", handleOffline);
2691
+ }
2692
+ if (handleOnline) {
2693
+ globalThis.window.removeEventListener("online", handleOnline);
2694
+ }
2695
+ }
2696
+ })();
2697
+ if (globalThis.navigator.onLine) {
2698
+ restartPingTimer();
2699
+ }
2700
+ let handleOffline;
2701
+ let handleOnline;
2702
+ {
2703
+ handleOffline = () => {
2704
+ clearInterval(intervalId);
2705
+ };
2706
+ handleOnline = () => {
2707
+ sendPing();
2708
+ restartPingTimer();
2709
+ };
2710
+ globalThis.window.addEventListener("offline", handleOffline);
2711
+ globalThis.window.addEventListener("online", handleOnline);
2712
+ }
2713
+ }
2714
+ return pingableConnections.get(connection);
2715
+ };
2716
+ }
2717
+
2718
+ // src/rpc-websocket-connection-sharding.ts
2719
+ init_env_shim();
2720
+ var NULL_SHARD_CACHE_KEY = Symbol(
2721
+ "Cache key to use when there is no connection sharding strategy"
2722
+ );
2723
+ function registerIterableCleanup2(iterable, cleanupFn) {
2724
+ (async () => {
2725
+ try {
2726
+ for await (const _ of iterable)
2727
+ ;
2728
+ } catch {
2729
+ } finally {
2730
+ cleanupFn();
2731
+ }
2732
+ })();
2733
+ }
2734
+ function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
2735
+ const cache = /* @__PURE__ */ new Map();
2736
+ function updateCache(shardKey, updater) {
2737
+ const currentCacheEntry = cache.get(shardKey);
2738
+ if (!currentCacheEntry) {
2739
+ throw new Error(`Found no cache entry for connection with shard key \`${shardKey.toString()}\``);
2740
+ }
2741
+ const nextCacheEntry = updater(currentCacheEntry);
2742
+ cache.set(shardKey, nextCacheEntry);
2743
+ return nextCacheEntry;
2744
+ }
2745
+ return async (...args) => {
2746
+ const { payload, signal, ...rest } = args[0];
2747
+ const shardKey = getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY;
2748
+ function cleanup() {
2749
+ cache.delete(shardKey);
2750
+ signal.removeEventListener("abort", handleAbort);
2751
+ }
2752
+ function handleAbort() {
2753
+ if (cache.get(shardKey)?.purgeScheduled !== true) {
2754
+ updateCache(shardKey, (currentCacheEntry) => ({
2755
+ ...currentCacheEntry,
2756
+ purgeScheduled: true
2757
+ }));
2758
+ globalThis.queueMicrotask(() => {
2759
+ const cacheEntryAtEndOfRunloop = cache.get(shardKey);
2760
+ if (!cacheEntryAtEndOfRunloop) {
2761
+ return;
2762
+ }
2763
+ if (cacheEntryAtEndOfRunloop.referenceCount === 0) {
2764
+ cacheEntry.abortController.abort();
2765
+ cleanup();
2766
+ }
2767
+ });
2768
+ }
2769
+ const cacheEntry = updateCache(shardKey, (currentCacheEntry) => ({
2770
+ ...currentCacheEntry,
2771
+ referenceCount: currentCacheEntry.referenceCount - 1
2772
+ }));
2773
+ }
2774
+ signal.addEventListener("abort", handleAbort);
2775
+ try {
2776
+ const cacheEntry = cache.get(shardKey);
2777
+ if (!cacheEntry) {
2778
+ const connectionAbortController = new AbortController();
2779
+ const newConnectionPromise = transport({
2780
+ payload,
2781
+ signal: connectionAbortController.signal,
2782
+ ...rest
2783
+ });
2784
+ const newCacheEntry = {
2785
+ abortController: connectionAbortController,
2786
+ connection: newConnectionPromise,
2787
+ purgeScheduled: false,
2788
+ referenceCount: 1
2789
+ };
2790
+ cache.set(shardKey, newCacheEntry);
2791
+ const newConnection = await newConnectionPromise;
2792
+ registerIterableCleanup2(newConnection, cleanup);
2793
+ updateCache(shardKey, (currentCacheEntry) => ({
2794
+ ...currentCacheEntry,
2795
+ connection: newConnection
2796
+ }));
2797
+ return newConnection;
2798
+ } else {
2799
+ updateCache(shardKey, (currentCacheEntry) => ({
2800
+ ...currentCacheEntry,
2801
+ referenceCount: currentCacheEntry.referenceCount + 1
2802
+ }));
2803
+ const connectionOrConnectionPromise = cacheEntry.connection;
2804
+ const cachedConnection = "then" in connectionOrConnectionPromise ? await connectionOrConnectionPromise : connectionOrConnectionPromise;
2805
+ registerIterableCleanup2(cachedConnection, cleanup);
2806
+ await cachedConnection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload);
2807
+ return cachedConnection;
2808
+ }
2809
+ } catch (e3) {
2810
+ cleanup();
2811
+ throw e3;
2812
+ }
2813
+ };
2814
+ }
2815
+
2816
+ // src/rpc-websocket-transport.ts
2817
+ function createDefaultRpcSubscriptionsTransport(config) {
2818
+ const { getShard, intervalMs, ...rest } = config;
2819
+ return getWebSocketTransportWithAutoping({
2820
+ intervalMs: intervalMs ?? 5e3,
2821
+ transport: getWebSocketTransportWithConnectionSharding({
2822
+ getShard,
2823
+ transport: createWebSocketTransport({
2824
+ ...rest,
2825
+ sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
2826
+ 131072
2827
+ })
2828
+ })
2829
+ });
2830
+ }
2831
+
1969
2832
  exports.AccountRole = AccountRole;
1970
2833
  exports.appendTransactionInstruction = appendTransactionInstruction;
1971
2834
  exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
1972
2835
  exports.assertIsBlockhash = assertIsBlockhash;
1973
2836
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
2837
+ exports.createAddressWithSeed = createAddressWithSeed;
2838
+ exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
1974
2839
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
1975
2840
  exports.createSolanaRpc = createSolanaRpc;
2841
+ exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
1976
2842
  exports.createTransaction = createTransaction;
1977
2843
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
1978
2844
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
1979
2845
  exports.generateKeyPair = generateKeyPair;
2846
+ exports.getAddressFromPublicKey = getAddressFromPublicKey;
1980
2847
  exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
1981
2848
  exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
1982
- exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
1983
2849
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
2850
+ exports.getProgramDerivedAddress = getProgramDerivedAddress;
1984
2851
  exports.isSignerRole = isSignerRole;
1985
2852
  exports.isWritableRole = isWritableRole;
1986
2853
  exports.mergeRoles = mergeRoles;
1987
2854
  exports.prependTransactionInstruction = prependTransactionInstruction;
1988
2855
  exports.setTransactionFeePayer = setTransactionFeePayer;
1989
2856
  exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
2857
+ exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
1990
2858
  exports.signBytes = signBytes;
1991
2859
  exports.signTransaction = signTransaction;
1992
2860
  exports.upgradeRoleToSigner = upgradeRoleToSigner;