@solana/web3.js 2.0.0-experimental.7b06723 → 2.0.0-experimental.7d44763

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,79 +122,215 @@ this.globalThis.solanaWeb3 = (function (exports) {
122
122
  // src/index.ts
123
123
  init_env_shim();
124
124
 
125
- // ../instructions/dist/index.browser.js
125
+ // ../addresses/dist/index.browser.js
126
126
  init_env_shim();
127
- var AccountRole = /* @__PURE__ */ ((AccountRole2) => {
128
- AccountRole2[AccountRole2["WRITABLE_SIGNER"] = /* 3 */
129
- 3] = "WRITABLE_SIGNER";
130
- AccountRole2[AccountRole2["READONLY_SIGNER"] = /* 2 */
131
- 2] = "READONLY_SIGNER";
132
- AccountRole2[AccountRole2["WRITABLE"] = /* 1 */
133
- 1] = "WRITABLE";
134
- AccountRole2[AccountRole2["READONLY"] = /* 0 */
135
- 0] = "READONLY";
136
- return AccountRole2;
137
- })(AccountRole || {});
138
- var IS_SIGNER_BITMASK = 2;
139
- var IS_WRITABLE_BITMASK = 1;
140
- function downgradeRoleToNonSigner(role) {
141
- return role & ~IS_SIGNER_BITMASK;
127
+
128
+ // ../codecs-core/dist/index.browser.js
129
+ init_env_shim();
130
+ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes2, offset = 0) {
131
+ if (bytes2.length - offset <= 0) {
132
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
133
+ }
142
134
  }
143
- function downgradeRoleToReadonly(role) {
144
- return role & ~IS_WRITABLE_BITMASK;
135
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes2, offset = 0) {
136
+ const bytesLength = bytes2.length - offset;
137
+ if (bytesLength < expected) {
138
+ throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
139
+ }
145
140
  }
146
- function isSignerRole(role) {
147
- return role >= 2;
141
+ var mergeBytes = (byteArrays) => {
142
+ const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
143
+ if (nonEmptyByteArrays.length === 0) {
144
+ return byteArrays.length ? byteArrays[0] : new Uint8Array();
145
+ }
146
+ if (nonEmptyByteArrays.length === 1) {
147
+ return nonEmptyByteArrays[0];
148
+ }
149
+ const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
150
+ const result = new Uint8Array(totalLength);
151
+ let offset = 0;
152
+ nonEmptyByteArrays.forEach((arr) => {
153
+ result.set(arr, offset);
154
+ offset += arr.length;
155
+ });
156
+ return result;
157
+ };
158
+ var padBytes = (bytes2, length) => {
159
+ if (bytes2.length >= length)
160
+ return bytes2;
161
+ const paddedBytes = new Uint8Array(length).fill(0);
162
+ paddedBytes.set(bytes2);
163
+ return paddedBytes;
164
+ };
165
+ var fixBytes = (bytes2, length) => padBytes(bytes2.length <= length ? bytes2 : bytes2.slice(0, length), length);
166
+ function combineCodec(encoder, decoder, description) {
167
+ if (encoder.fixedSize !== decoder.fixedSize) {
168
+ throw new Error(
169
+ `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
170
+ );
171
+ }
172
+ if (encoder.maxSize !== decoder.maxSize) {
173
+ throw new Error(
174
+ `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
175
+ );
176
+ }
177
+ if (description === void 0 && encoder.description !== decoder.description) {
178
+ throw new Error(
179
+ `Encoder and decoder must have the same description, got [${encoder.description}] and [${decoder.description}]. Pass a custom description as a third argument if you want to override the description and bypass this error.`
180
+ );
181
+ }
182
+ return {
183
+ decode: decoder.decode,
184
+ description: description ?? encoder.description,
185
+ encode: encoder.encode,
186
+ fixedSize: encoder.fixedSize,
187
+ maxSize: encoder.maxSize
188
+ };
148
189
  }
149
- function isWritableRole(role) {
150
- return (role & IS_WRITABLE_BITMASK) !== 0;
190
+ function fixCodecHelper(data, fixedBytes, description) {
191
+ return {
192
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
193
+ fixedSize: fixedBytes,
194
+ maxSize: fixedBytes
195
+ };
151
196
  }
152
- function mergeRoles(roleA, roleB) {
153
- return roleA | roleB;
197
+ function fixEncoder(encoder, fixedBytes, description) {
198
+ return {
199
+ ...fixCodecHelper(encoder, fixedBytes, description),
200
+ encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
201
+ };
154
202
  }
155
- function upgradeRoleToSigner(role) {
156
- return role | IS_SIGNER_BITMASK;
203
+ function fixDecoder(decoder, fixedBytes, description) {
204
+ return {
205
+ ...fixCodecHelper(decoder, fixedBytes, description),
206
+ decode: (bytes2, offset = 0) => {
207
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes2, offset);
208
+ if (offset > 0 || bytes2.length > fixedBytes) {
209
+ bytes2 = bytes2.slice(offset, offset + fixedBytes);
210
+ }
211
+ if (decoder.fixedSize !== null) {
212
+ bytes2 = fixBytes(bytes2, decoder.fixedSize);
213
+ }
214
+ const [value] = decoder.decode(bytes2, 0);
215
+ return [value, offset + fixedBytes];
216
+ }
217
+ };
157
218
  }
158
- function upgradeRoleToWritable(role) {
159
- return role | IS_WRITABLE_BITMASK;
219
+ function mapEncoder(encoder, unmap) {
220
+ return {
221
+ description: encoder.description,
222
+ encode: (value) => encoder.encode(unmap(value)),
223
+ fixedSize: encoder.fixedSize,
224
+ maxSize: encoder.maxSize
225
+ };
160
226
  }
161
227
 
162
- // ../keys/dist/index.browser.js
163
- init_env_shim();
164
-
165
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
228
+ // ../codecs-strings/dist/index.browser.js
166
229
  init_env_shim();
167
230
 
168
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
231
+ // ../codecs-numbers/dist/index.browser.js
169
232
  init_env_shim();
170
-
171
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
172
- init_env_shim();
173
- var InvalidBaseStringError = class extends Error {
174
- constructor(value, base, cause) {
175
- const message = `Expected a string of base ${base}, got [${value}].`;
176
- super(message);
177
- __publicField(this, "name", "InvalidBaseStringError");
178
- this.cause = cause;
233
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
234
+ if (value < min || value > max) {
235
+ throw new Error(
236
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
237
+ );
179
238
  }
180
- };
239
+ }
240
+ function sharedNumberFactory(input) {
241
+ let littleEndian;
242
+ let defaultDescription = input.name;
243
+ if (input.size > 1) {
244
+ littleEndian = !("endian" in input.options) || input.options.endian === 0;
245
+ defaultDescription += littleEndian ? "(le)" : "(be)";
246
+ }
247
+ return {
248
+ description: input.options.description ?? defaultDescription,
249
+ fixedSize: input.size,
250
+ littleEndian,
251
+ maxSize: input.size
252
+ };
253
+ }
254
+ function numberEncoderFactory(input) {
255
+ const codecData = sharedNumberFactory(input);
256
+ return {
257
+ description: codecData.description,
258
+ encode(value) {
259
+ if (input.range) {
260
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
261
+ }
262
+ const arrayBuffer = new ArrayBuffer(input.size);
263
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
264
+ return new Uint8Array(arrayBuffer);
265
+ },
266
+ fixedSize: codecData.fixedSize,
267
+ maxSize: codecData.maxSize
268
+ };
269
+ }
270
+ function numberDecoderFactory(input) {
271
+ const codecData = sharedNumberFactory(input);
272
+ return {
273
+ decode(bytes2, offset = 0) {
274
+ assertByteArrayIsNotEmptyForCodec(codecData.description, bytes2, offset);
275
+ assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes2, offset);
276
+ const view = new DataView(toArrayBuffer(bytes2, offset, input.size));
277
+ return [input.get(view, codecData.littleEndian), offset + input.size];
278
+ },
279
+ description: codecData.description,
280
+ fixedSize: codecData.fixedSize,
281
+ maxSize: codecData.maxSize
282
+ };
283
+ }
284
+ function toArrayBuffer(bytes2, offset, length) {
285
+ const bytesOffset = bytes2.byteOffset + (offset ?? 0);
286
+ const bytesLength = length ?? bytes2.byteLength;
287
+ return bytes2.buffer.slice(bytesOffset, bytesOffset + bytesLength);
288
+ }
289
+ var getU32Encoder = (options = {}) => numberEncoderFactory({
290
+ name: "u32",
291
+ options,
292
+ range: [0, Number("0xffffffff")],
293
+ set: (view, value, le) => view.setUint32(0, value, le),
294
+ size: 4
295
+ });
296
+ var getU32Decoder = (options = {}) => numberDecoderFactory({
297
+ get: (view, le) => view.getUint32(0, le),
298
+ name: "u32",
299
+ options,
300
+ size: 4
301
+ });
302
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
303
+ name: "u8",
304
+ options,
305
+ range: [0, Number("0xff")],
306
+ set: (view, value) => view.setUint8(0, value),
307
+ size: 1
308
+ });
309
+ var getU8Decoder = (options = {}) => numberDecoderFactory({
310
+ get: (view) => view.getUint8(0),
311
+ name: "u8",
312
+ options,
313
+ size: 1
314
+ });
315
+ var getU8Codec = (options = {}) => combineCodec(getU8Encoder(options), getU8Decoder(options));
181
316
 
182
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
183
- var baseX = (alphabet) => {
184
- const base = alphabet.length;
317
+ // ../codecs-strings/dist/index.browser.js
318
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
319
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
320
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
321
+ }
322
+ }
323
+ var getBaseXEncoder = (alphabet4) => {
324
+ const base = alphabet4.length;
185
325
  const baseBigInt = BigInt(base);
186
326
  return {
187
327
  description: `base${base}`,
188
- fixedSize: null,
189
- maxSize: null,
190
- serialize(value) {
191
- if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
192
- throw new InvalidBaseStringError(value, base);
193
- }
328
+ encode(value) {
329
+ assertValidBaseString(alphabet4, value);
194
330
  if (value === "")
195
331
  return new Uint8Array();
196
332
  const chars = [...value];
197
- let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
333
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
198
334
  trailIndex = trailIndex === -1 ? chars.length : trailIndex;
199
335
  const leadingZeroes = Array(trailIndex).fill(0);
200
336
  if (trailIndex === chars.length)
@@ -203,7 +339,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
203
339
  let base10Number = 0n;
204
340
  let baseXPower = 1n;
205
341
  for (let i = tailChars.length - 1; i >= 0; i -= 1) {
206
- base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
342
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
207
343
  baseXPower *= baseBigInt;
208
344
  }
209
345
  const tailBytes = [];
@@ -213,32 +349,215 @@ this.globalThis.solanaWeb3 = (function (exports) {
213
349
  }
214
350
  return Uint8Array.from(leadingZeroes.concat(tailBytes));
215
351
  },
216
- deserialize(buffer, offset = 0) {
217
- if (buffer.length === 0)
352
+ fixedSize: null,
353
+ maxSize: null
354
+ };
355
+ };
356
+ var getBaseXDecoder = (alphabet4) => {
357
+ const base = alphabet4.length;
358
+ const baseBigInt = BigInt(base);
359
+ return {
360
+ decode(rawBytes, offset = 0) {
361
+ const bytes2 = offset === 0 ? rawBytes : rawBytes.slice(offset);
362
+ if (bytes2.length === 0)
218
363
  return ["", 0];
219
- const bytes = buffer.slice(offset);
220
- let trailIndex = bytes.findIndex((n) => n !== 0);
221
- trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
222
- const leadingZeroes = alphabet[0].repeat(trailIndex);
223
- if (trailIndex === bytes.length)
224
- return [leadingZeroes, buffer.length];
225
- let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
364
+ let trailIndex = bytes2.findIndex((n) => n !== 0);
365
+ trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
366
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
367
+ if (trailIndex === bytes2.length)
368
+ return [leadingZeroes, rawBytes.length];
369
+ let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
226
370
  const tailChars = [];
227
371
  while (base10Number > 0n) {
228
- tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
372
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
229
373
  base10Number /= baseBigInt;
230
374
  }
231
- return [leadingZeroes + tailChars.join(""), buffer.length];
232
- }
375
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
376
+ },
377
+ description: `base${base}`,
378
+ fixedSize: null,
379
+ maxSize: null
380
+ };
381
+ };
382
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
383
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
384
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
385
+ var removeNullCharacters = (value) => (
386
+ // eslint-disable-next-line no-control-regex
387
+ value.replace(/\u0000/g, "")
388
+ );
389
+ var e = globalThis.TextDecoder;
390
+ var o = globalThis.TextEncoder;
391
+ var getUtf8Encoder = () => {
392
+ let textEncoder;
393
+ return {
394
+ description: "utf8",
395
+ encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
396
+ fixedSize: null,
397
+ maxSize: null
398
+ };
399
+ };
400
+ var getUtf8Decoder = () => {
401
+ let textDecoder;
402
+ return {
403
+ decode(bytes2, offset = 0) {
404
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes2.slice(offset));
405
+ return [removeNullCharacters(value), bytes2.length];
406
+ },
407
+ description: "utf8",
408
+ fixedSize: null,
409
+ maxSize: null
410
+ };
411
+ };
412
+ var getStringEncoder = (options = {}) => {
413
+ const size = options.size ?? getU32Encoder();
414
+ const encoding = options.encoding ?? getUtf8Encoder();
415
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
416
+ if (size === "variable") {
417
+ return { ...encoding, description };
418
+ }
419
+ if (typeof size === "number") {
420
+ return fixEncoder(encoding, size, description);
421
+ }
422
+ return {
423
+ description,
424
+ encode: (value) => {
425
+ const contentBytes = encoding.encode(value);
426
+ const lengthBytes = size.encode(contentBytes.length);
427
+ return mergeBytes([lengthBytes, contentBytes]);
428
+ },
429
+ fixedSize: null,
430
+ maxSize: null
431
+ };
432
+ };
433
+ var getStringDecoder = (options = {}) => {
434
+ const size = options.size ?? getU32Decoder();
435
+ const encoding = options.encoding ?? getUtf8Decoder();
436
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
437
+ if (size === "variable") {
438
+ return { ...encoding, description };
439
+ }
440
+ if (typeof size === "number") {
441
+ return fixDecoder(encoding, size, description);
442
+ }
443
+ return {
444
+ decode: (bytes2, offset = 0) => {
445
+ assertByteArrayIsNotEmptyForCodec("string", bytes2, offset);
446
+ const [lengthBigInt, lengthOffset] = size.decode(bytes2, offset);
447
+ const length = Number(lengthBigInt);
448
+ offset = lengthOffset;
449
+ const contentBytes = bytes2.slice(offset, offset + length);
450
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
451
+ const [value, contentOffset] = encoding.decode(contentBytes);
452
+ offset += contentOffset;
453
+ return [value, offset];
454
+ },
455
+ description,
456
+ fixedSize: null,
457
+ maxSize: null
233
458
  };
234
459
  };
460
+ function getSizeDescription(size) {
461
+ return typeof size === "object" ? size.description : `${size}`;
462
+ }
235
463
 
236
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
464
+ // ../assertions/dist/index.browser.js
237
465
  init_env_shim();
238
- var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
466
+ function assertIsSecureContext() {
467
+ if (!globalThis.isSecureContext) {
468
+ throw new Error(
469
+ "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts"
470
+ );
471
+ }
472
+ }
473
+ var cachedEd25519Decision;
474
+ async function isEd25519CurveSupported(subtle) {
475
+ if (cachedEd25519Decision === void 0) {
476
+ cachedEd25519Decision = new Promise((resolve) => {
477
+ subtle.generateKey(
478
+ "Ed25519",
479
+ /* extractable */
480
+ false,
481
+ ["sign", "verify"]
482
+ ).catch(() => {
483
+ resolve(cachedEd25519Decision = false);
484
+ }).then(() => {
485
+ resolve(cachedEd25519Decision = true);
486
+ });
487
+ });
488
+ }
489
+ if (typeof cachedEd25519Decision === "boolean") {
490
+ return cachedEd25519Decision;
491
+ } else {
492
+ return await cachedEd25519Decision;
493
+ }
494
+ }
495
+ async function assertDigestCapabilityIsAvailable() {
496
+ assertIsSecureContext();
497
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
498
+ throw new Error("No digest implementation could be found");
499
+ }
500
+ }
501
+ async function assertKeyGenerationIsAvailable() {
502
+ assertIsSecureContext();
503
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
504
+ throw new Error("No key generation implementation could be found");
505
+ }
506
+ if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
507
+ throw new Error(
508
+ "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall and import `@solana/webcrypto-ed25519-polyfill` before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20"
509
+ );
510
+ }
511
+ }
512
+ async function assertKeyExporterIsAvailable() {
513
+ assertIsSecureContext();
514
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") {
515
+ throw new Error("No key export implementation could be found");
516
+ }
517
+ }
518
+ async function assertSigningCapabilityIsAvailable() {
519
+ assertIsSecureContext();
520
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.sign !== "function") {
521
+ throw new Error("No signing implementation could be found");
522
+ }
523
+ }
524
+ async function assertVerificationCapabilityIsAvailable() {
525
+ assertIsSecureContext();
526
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.verify !== "function") {
527
+ throw new Error("No signature verification implementation could be found");
528
+ }
529
+ }
239
530
 
240
- // ../keys/dist/index.browser.js
241
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
531
+ // ../addresses/dist/index.browser.js
532
+ var memoizedBase58Encoder;
533
+ var memoizedBase58Decoder;
534
+ function getMemoizedBase58Encoder() {
535
+ if (!memoizedBase58Encoder)
536
+ memoizedBase58Encoder = getBase58Encoder();
537
+ return memoizedBase58Encoder;
538
+ }
539
+ function getMemoizedBase58Decoder() {
540
+ if (!memoizedBase58Decoder)
541
+ memoizedBase58Decoder = getBase58Decoder();
542
+ return memoizedBase58Decoder;
543
+ }
544
+ function isAddress(putativeBase58EncodedAddress) {
545
+ if (
546
+ // Lowest address (32 bytes of zeroes)
547
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
548
+ putativeBase58EncodedAddress.length > 44
549
+ ) {
550
+ return false;
551
+ }
552
+ const base58Encoder = getMemoizedBase58Encoder();
553
+ const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
554
+ const numBytes = bytes2.byteLength;
555
+ if (numBytes !== 32) {
556
+ return false;
557
+ }
558
+ return true;
559
+ }
560
+ function assertIsAddress(putativeBase58EncodedAddress) {
242
561
  try {
243
562
  if (
244
563
  // Lowest address (32 bytes of zeroes)
@@ -247,18 +566,43 @@ this.globalThis.solanaWeb3 = (function (exports) {
247
566
  ) {
248
567
  throw new Error("Expected input string to decode to a byte array of length 32.");
249
568
  }
250
- const bytes = base58.serialize(putativeBase58EncodedAddress);
251
- const numBytes = bytes.byteLength;
569
+ const base58Encoder = getMemoizedBase58Encoder();
570
+ const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
571
+ const numBytes = bytes2.byteLength;
252
572
  if (numBytes !== 32) {
253
573
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
254
574
  }
255
- } catch (e2) {
575
+ } catch (e3) {
256
576
  throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
257
- cause: e2
577
+ cause: e3
258
578
  });
259
579
  }
260
580
  }
261
- function getBase58EncodedAddressComparator() {
581
+ function address(putativeBase58EncodedAddress) {
582
+ assertIsAddress(putativeBase58EncodedAddress);
583
+ return putativeBase58EncodedAddress;
584
+ }
585
+ function getAddressEncoder(config) {
586
+ return mapEncoder(
587
+ getStringEncoder({
588
+ description: config?.description ?? "Base58EncodedAddress",
589
+ encoding: getMemoizedBase58Encoder(),
590
+ size: 32
591
+ }),
592
+ (putativeAddress) => address(putativeAddress)
593
+ );
594
+ }
595
+ function getAddressDecoder(config) {
596
+ return getStringDecoder({
597
+ description: config?.description ?? "Base58EncodedAddress",
598
+ encoding: getMemoizedBase58Decoder(),
599
+ size: 32
600
+ });
601
+ }
602
+ function getAddressCodec(config) {
603
+ return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
604
+ }
605
+ function getAddressComparator() {
262
606
  return new Intl.Collator("en", {
263
607
  caseFirst: "lower",
264
608
  ignorePunctuation: false,
@@ -268,12 +612,1721 @@ this.globalThis.solanaWeb3 = (function (exports) {
268
612
  usage: "sort"
269
613
  }).compare;
270
614
  }
615
+ var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
616
+ var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
617
+ var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
618
+ function mod(a) {
619
+ const r = a % P;
620
+ return r >= 0n ? r : P + r;
621
+ }
622
+ function pow2(x, power) {
623
+ let r = x;
624
+ while (power-- > 0n) {
625
+ r *= r;
626
+ r %= P;
627
+ }
628
+ return r;
629
+ }
630
+ function pow_2_252_3(x) {
631
+ const x2 = x * x % P;
632
+ const b2 = x2 * x % P;
633
+ const b4 = pow2(b2, 2n) * b2 % P;
634
+ const b5 = pow2(b4, 1n) * x % P;
635
+ const b10 = pow2(b5, 5n) * b5 % P;
636
+ const b20 = pow2(b10, 10n) * b10 % P;
637
+ const b40 = pow2(b20, 20n) * b20 % P;
638
+ const b80 = pow2(b40, 40n) * b40 % P;
639
+ const b160 = pow2(b80, 80n) * b80 % P;
640
+ const b240 = pow2(b160, 80n) * b80 % P;
641
+ const b250 = pow2(b240, 10n) * b10 % P;
642
+ const pow_p_5_8 = pow2(b250, 2n) * x % P;
643
+ return pow_p_5_8;
644
+ }
645
+ function uvRatio(u, v) {
646
+ const v3 = mod(v * v * v);
647
+ const v7 = mod(v3 * v3 * v);
648
+ const pow = pow_2_252_3(u * v7);
649
+ let x = mod(u * v3 * pow);
650
+ const vx2 = mod(v * x * x);
651
+ const root1 = x;
652
+ const root2 = mod(x * RM1);
653
+ const useRoot1 = vx2 === u;
654
+ const useRoot2 = vx2 === mod(-u);
655
+ const noRoot = vx2 === mod(-u * RM1);
656
+ if (useRoot1)
657
+ x = root1;
658
+ if (useRoot2 || noRoot)
659
+ x = root2;
660
+ if ((mod(x) & 1n) === 1n)
661
+ x = mod(-x);
662
+ if (!useRoot1 && !useRoot2) {
663
+ return null;
664
+ }
665
+ return x;
666
+ }
667
+ function pointIsOnCurve(y, lastByte) {
668
+ const y2 = mod(y * y);
669
+ const u = mod(y2 - 1n);
670
+ const v = mod(D * y2 + 1n);
671
+ const x = uvRatio(u, v);
672
+ if (x === null) {
673
+ return false;
674
+ }
675
+ const isLastByteOdd = (lastByte & 128) !== 0;
676
+ if (x === 0n && isLastByteOdd) {
677
+ return false;
678
+ }
679
+ return true;
680
+ }
681
+ function byteToHex(byte) {
682
+ const hexString = byte.toString(16);
683
+ if (hexString.length === 1) {
684
+ return `0${hexString}`;
685
+ } else {
686
+ return hexString;
687
+ }
688
+ }
689
+ function decompressPointBytes(bytes2) {
690
+ const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
691
+ const integerLiteralString = `0x${hexString}`;
692
+ return BigInt(integerLiteralString);
693
+ }
694
+ async function compressedPointBytesAreOnCurve(bytes2) {
695
+ if (bytes2.byteLength !== 32) {
696
+ return false;
697
+ }
698
+ const y = decompressPointBytes(bytes2);
699
+ return pointIsOnCurve(y, bytes2[31]);
700
+ }
701
+ function isProgramDerivedAddress(value) {
702
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);
703
+ }
704
+ function assertIsProgramDerivedAddress(value) {
705
+ const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
706
+ if (!validFormat) {
707
+ throw new Error(
708
+ `Expected given program derived address to have the following format: [Base58EncodedAddress, ProgramDerivedAddressBump].`
709
+ );
710
+ }
711
+ if (value[1] < 0 || value[1] > 255) {
712
+ throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
713
+ }
714
+ assertIsAddress(value[0]);
715
+ }
716
+ var MAX_SEED_LENGTH = 32;
717
+ var MAX_SEEDS = 16;
718
+ var PDA_MARKER_BYTES = [
719
+ // The string 'ProgramDerivedAddress'
720
+ 80,
721
+ 114,
722
+ 111,
723
+ 103,
724
+ 114,
725
+ 97,
726
+ 109,
727
+ 68,
728
+ 101,
729
+ 114,
730
+ 105,
731
+ 118,
732
+ 101,
733
+ 100,
734
+ 65,
735
+ 100,
736
+ 100,
737
+ 114,
738
+ 101,
739
+ 115,
740
+ 115
741
+ ];
742
+ var PointOnCurveError = class extends Error {
743
+ };
744
+ async function createProgramDerivedAddress({
745
+ programAddress,
746
+ seeds
747
+ }) {
748
+ await assertDigestCapabilityIsAvailable();
749
+ if (seeds.length > MAX_SEEDS) {
750
+ throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
751
+ }
752
+ let textEncoder;
753
+ const seedBytes = seeds.reduce((acc, seed, ii) => {
754
+ const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
755
+ if (bytes2.byteLength > MAX_SEED_LENGTH) {
756
+ throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
757
+ }
758
+ acc.push(...bytes2);
759
+ return acc;
760
+ }, []);
761
+ const base58EncodedAddressCodec = getAddressCodec();
762
+ const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
763
+ const addressBytesBuffer = await crypto.subtle.digest(
764
+ "SHA-256",
765
+ new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
766
+ );
767
+ const addressBytes = new Uint8Array(addressBytesBuffer);
768
+ if (await compressedPointBytesAreOnCurve(addressBytes)) {
769
+ throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
770
+ }
771
+ return base58EncodedAddressCodec.decode(addressBytes)[0];
772
+ }
773
+ async function getProgramDerivedAddress({
774
+ programAddress,
775
+ seeds
776
+ }) {
777
+ let bumpSeed = 255;
778
+ while (bumpSeed > 0) {
779
+ try {
780
+ const address2 = await createProgramDerivedAddress({
781
+ programAddress,
782
+ seeds: [...seeds, new Uint8Array([bumpSeed])]
783
+ });
784
+ return [address2, bumpSeed];
785
+ } catch (e3) {
786
+ if (e3 instanceof PointOnCurveError) {
787
+ bumpSeed--;
788
+ } else {
789
+ throw e3;
790
+ }
791
+ }
792
+ }
793
+ throw new Error("Unable to find a viable program address bump seed");
794
+ }
795
+ async function createAddressWithSeed({
796
+ baseAddress,
797
+ programAddress,
798
+ seed
799
+ }) {
800
+ const { encode: encode2, decode: decode2 } = getAddressCodec();
801
+ const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
802
+ if (seedBytes.byteLength > MAX_SEED_LENGTH) {
803
+ throw new Error(`The seed exceeds the maximum length of 32 bytes`);
804
+ }
805
+ const programAddressBytes = encode2(programAddress);
806
+ if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
807
+ throw new Error(`programAddress cannot end with the PDA marker`);
808
+ }
809
+ const addressBytesBuffer = await crypto.subtle.digest(
810
+ "SHA-256",
811
+ new Uint8Array([...encode2(baseAddress), ...seedBytes, ...programAddressBytes])
812
+ );
813
+ const addressBytes = new Uint8Array(addressBytesBuffer);
814
+ return decode2(addressBytes)[0];
815
+ }
816
+ async function getAddressFromPublicKey(publicKey) {
817
+ await assertKeyExporterIsAvailable();
818
+ if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
819
+ throw new Error("The `CryptoKey` must be an `Ed25519` public key");
820
+ }
821
+ const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
822
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
823
+ return base58EncodedAddress;
824
+ }
271
825
 
272
- // src/rpc.ts
826
+ // ../instructions/dist/index.browser.js
827
+ init_env_shim();
828
+ var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
829
+ AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
830
+ 3] = "WRITABLE_SIGNER";
831
+ AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
832
+ 2] = "READONLY_SIGNER";
833
+ AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
834
+ 1] = "WRITABLE";
835
+ AccountRole22[AccountRole22["READONLY"] = /* 0 */
836
+ 0] = "READONLY";
837
+ return AccountRole22;
838
+ })(AccountRole || {});
839
+ var IS_SIGNER_BITMASK = 2;
840
+ var IS_WRITABLE_BITMASK = 1;
841
+ function downgradeRoleToNonSigner(role) {
842
+ return role & ~IS_SIGNER_BITMASK;
843
+ }
844
+ function downgradeRoleToReadonly(role) {
845
+ return role & ~IS_WRITABLE_BITMASK;
846
+ }
847
+ function isSignerRole(role) {
848
+ return role >= 2;
849
+ }
850
+ function isWritableRole(role) {
851
+ return (role & IS_WRITABLE_BITMASK) !== 0;
852
+ }
853
+ function mergeRoles(roleA, roleB) {
854
+ return roleA | roleB;
855
+ }
856
+ function upgradeRoleToSigner(role) {
857
+ return role | IS_SIGNER_BITMASK;
858
+ }
859
+ function upgradeRoleToWritable(role) {
860
+ return role | IS_WRITABLE_BITMASK;
861
+ }
862
+
863
+ // ../keys/dist/index.browser.js
864
+ init_env_shim();
865
+ async function generateKeyPair() {
866
+ await assertKeyGenerationIsAvailable();
867
+ const keyPair = await crypto.subtle.generateKey(
868
+ /* algorithm */
869
+ "Ed25519",
870
+ // Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20
871
+ /* extractable */
872
+ false,
873
+ // Prevents the bytes of the private key from being visible to JS.
874
+ /* allowed uses */
875
+ ["sign", "verify"]
876
+ );
877
+ return keyPair;
878
+ }
879
+ async function signBytes(key, data) {
880
+ await assertSigningCapabilityIsAvailable();
881
+ const signedData = await crypto.subtle.sign("Ed25519", key, data);
882
+ return new Uint8Array(signedData);
883
+ }
884
+ async function verifySignature(key, signature, data) {
885
+ await assertVerificationCapabilityIsAvailable();
886
+ return await crypto.subtle.verify("Ed25519", key, signature, data);
887
+ }
888
+
889
+ // ../transactions/dist/index.browser.js
273
890
  init_env_shim();
274
891
 
275
- // ../rpc-core/dist/index.browser.js
892
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
893
+ init_env_shim();
894
+
895
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
276
896
  init_env_shim();
897
+
898
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
899
+ init_env_shim();
900
+ var mergeBytes2 = (bytesArr) => {
901
+ const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
902
+ const result = new Uint8Array(totalLength);
903
+ let offset = 0;
904
+ bytesArr.forEach((arr) => {
905
+ result.set(arr, offset);
906
+ offset += arr.length;
907
+ });
908
+ return result;
909
+ };
910
+ var padBytes2 = (bytes2, length) => {
911
+ if (bytes2.length >= length)
912
+ return bytes2;
913
+ const paddedBytes = new Uint8Array(length).fill(0);
914
+ paddedBytes.set(bytes2);
915
+ return paddedBytes;
916
+ };
917
+ var fixBytes2 = (bytes2, length) => padBytes2(bytes2.slice(0, length), length);
918
+
919
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
920
+ init_env_shim();
921
+ var DeserializingEmptyBufferError = class extends Error {
922
+ constructor(serializer) {
923
+ super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
924
+ __publicField(this, "name", "DeserializingEmptyBufferError");
925
+ }
926
+ };
927
+ var NotEnoughBytesError = class extends Error {
928
+ constructor(serializer, expected, actual) {
929
+ super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
930
+ __publicField(this, "name", "NotEnoughBytesError");
931
+ }
932
+ };
933
+ var ExpectedFixedSizeSerializerError = class extends Error {
934
+ constructor(message) {
935
+ message ?? (message = "Expected a fixed-size serializer, got a variable-size one.");
936
+ super(message);
937
+ __publicField(this, "name", "ExpectedFixedSizeSerializerError");
938
+ }
939
+ };
940
+
941
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
942
+ init_env_shim();
943
+ function fixSerializer(serializer, fixedBytes, description) {
944
+ return {
945
+ description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
946
+ fixedSize: fixedBytes,
947
+ maxSize: fixedBytes,
948
+ serialize: (value) => fixBytes2(serializer.serialize(value), fixedBytes),
949
+ deserialize: (buffer, offset = 0) => {
950
+ buffer = buffer.slice(offset, offset + fixedBytes);
951
+ if (buffer.length < fixedBytes) {
952
+ throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
953
+ }
954
+ if (serializer.fixedSize !== null) {
955
+ buffer = fixBytes2(buffer, serializer.fixedSize);
956
+ }
957
+ const [value] = serializer.deserialize(buffer, 0);
958
+ return [value, offset + fixedBytes];
959
+ }
960
+ };
961
+ }
962
+
963
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.9/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
964
+ init_env_shim();
965
+ function mapSerializer(serializer, unmap, map) {
966
+ return {
967
+ description: serializer.description,
968
+ fixedSize: serializer.fixedSize,
969
+ maxSize: serializer.maxSize,
970
+ serialize: (value) => serializer.serialize(unmap(value)),
971
+ deserialize: (buffer, offset = 0) => {
972
+ const [value, length] = serializer.deserialize(buffer, offset);
973
+ return map ? [map(value, buffer, offset), length] : [value, length];
974
+ }
975
+ };
976
+ }
977
+
978
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
979
+ init_env_shim();
980
+
981
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
982
+ init_env_shim();
983
+
984
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
985
+ init_env_shim();
986
+ var InvalidBaseStringError = class extends Error {
987
+ constructor(value, base, cause) {
988
+ const message = `Expected a string of base ${base}, got [${value}].`;
989
+ super(message);
990
+ __publicField(this, "name", "InvalidBaseStringError");
991
+ this.cause = cause;
992
+ }
993
+ };
994
+
995
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
996
+ var baseX = (alphabet) => {
997
+ const base = alphabet.length;
998
+ const baseBigInt = BigInt(base);
999
+ return {
1000
+ description: `base${base}`,
1001
+ fixedSize: null,
1002
+ maxSize: null,
1003
+ serialize(value) {
1004
+ if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
1005
+ throw new InvalidBaseStringError(value, base);
1006
+ }
1007
+ if (value === "")
1008
+ return new Uint8Array();
1009
+ const chars = [...value];
1010
+ let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
1011
+ trailIndex = trailIndex === -1 ? chars.length : trailIndex;
1012
+ const leadingZeroes = Array(trailIndex).fill(0);
1013
+ if (trailIndex === chars.length)
1014
+ return Uint8Array.from(leadingZeroes);
1015
+ const tailChars = chars.slice(trailIndex);
1016
+ let base10Number = 0n;
1017
+ let baseXPower = 1n;
1018
+ for (let i = tailChars.length - 1; i >= 0; i -= 1) {
1019
+ base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
1020
+ baseXPower *= baseBigInt;
1021
+ }
1022
+ const tailBytes = [];
1023
+ while (base10Number > 0n) {
1024
+ tailBytes.unshift(Number(base10Number % 256n));
1025
+ base10Number /= 256n;
1026
+ }
1027
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
1028
+ },
1029
+ deserialize(buffer, offset = 0) {
1030
+ if (buffer.length === 0)
1031
+ return ["", 0];
1032
+ const bytes2 = buffer.slice(offset);
1033
+ let trailIndex = bytes2.findIndex((n) => n !== 0);
1034
+ trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
1035
+ const leadingZeroes = alphabet[0].repeat(trailIndex);
1036
+ if (trailIndex === bytes2.length)
1037
+ return [leadingZeroes, buffer.length];
1038
+ let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
1039
+ const tailChars = [];
1040
+ while (base10Number > 0n) {
1041
+ tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
1042
+ base10Number /= baseBigInt;
1043
+ }
1044
+ return [leadingZeroes + tailChars.join(""), buffer.length];
1045
+ }
1046
+ };
1047
+ };
1048
+
1049
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
1050
+ init_env_shim();
1051
+ var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1052
+
1053
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base64.mjs
1054
+ init_env_shim();
1055
+
1056
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseXReslice.mjs
1057
+ init_env_shim();
1058
+ var baseXReslice = (alphabet, bits) => {
1059
+ const base = alphabet.length;
1060
+ const reslice = (input, inputBits, outputBits, useRemainder) => {
1061
+ const output = [];
1062
+ let accumulator = 0;
1063
+ let bitsInAccumulator = 0;
1064
+ const mask = (1 << outputBits) - 1;
1065
+ for (const value of input) {
1066
+ accumulator = accumulator << inputBits | value;
1067
+ bitsInAccumulator += inputBits;
1068
+ while (bitsInAccumulator >= outputBits) {
1069
+ bitsInAccumulator -= outputBits;
1070
+ output.push(accumulator >> bitsInAccumulator & mask);
1071
+ }
1072
+ }
1073
+ if (useRemainder && bitsInAccumulator > 0) {
1074
+ output.push(accumulator << outputBits - bitsInAccumulator & mask);
1075
+ }
1076
+ return output;
1077
+ };
1078
+ return {
1079
+ description: `base${base}`,
1080
+ fixedSize: null,
1081
+ maxSize: null,
1082
+ serialize(value) {
1083
+ if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
1084
+ throw new InvalidBaseStringError(value, base);
1085
+ }
1086
+ if (value === "")
1087
+ return new Uint8Array();
1088
+ const charIndices = [...value].map((c) => alphabet.indexOf(c));
1089
+ const bytes2 = reslice(charIndices, bits, 8, false);
1090
+ return Uint8Array.from(bytes2);
1091
+ },
1092
+ deserialize(buffer, offset = 0) {
1093
+ if (buffer.length === 0)
1094
+ return ["", 0];
1095
+ const bytes2 = [...buffer.slice(offset)];
1096
+ const charIndices = reslice(bytes2, 8, bits, true);
1097
+ return [charIndices.map((i) => alphabet[i]).join(""), buffer.length];
1098
+ }
1099
+ };
1100
+ };
1101
+
1102
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base64.mjs
1103
+ var base64 = mapSerializer(baseXReslice("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", 6), (value) => value.replace(/=/g, ""), (value) => value.padEnd(Math.ceil(value.length / 4) * 4, "="));
1104
+
1105
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
1106
+ init_env_shim();
1107
+ var removeNullCharacters2 = (value) => (
1108
+ // eslint-disable-next-line no-control-regex
1109
+ value.replace(/\u0000/g, "")
1110
+ );
1111
+
1112
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
1113
+ init_env_shim();
1114
+ var utf8 = {
1115
+ description: "utf8",
1116
+ fixedSize: null,
1117
+ maxSize: null,
1118
+ serialize(value) {
1119
+ return new TextEncoder().encode(value);
1120
+ },
1121
+ deserialize(buffer, offset = 0) {
1122
+ const value = new TextDecoder().decode(buffer.slice(offset));
1123
+ return [removeNullCharacters2(value), buffer.length];
1124
+ }
1125
+ };
1126
+
1127
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
1128
+ init_env_shim();
1129
+
1130
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
1131
+ init_env_shim();
1132
+ var Endian;
1133
+ (function(Endian2) {
1134
+ Endian2["Little"] = "le";
1135
+ Endian2["Big"] = "be";
1136
+ })(Endian || (Endian = {}));
1137
+
1138
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
1139
+ init_env_shim();
1140
+ var NumberOutOfRangeError = class extends RangeError {
1141
+ constructor(serializer, min, max, actual) {
1142
+ super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
1143
+ __publicField(this, "name", "NumberOutOfRangeError");
1144
+ }
1145
+ };
1146
+
1147
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
1148
+ init_env_shim();
1149
+ function numberFactory(input) {
1150
+ let littleEndian;
1151
+ let defaultDescription = input.name;
1152
+ if (input.size > 1) {
1153
+ littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
1154
+ defaultDescription += littleEndian ? "(le)" : "(be)";
1155
+ }
1156
+ return {
1157
+ description: input.options.description ?? defaultDescription,
1158
+ fixedSize: input.size,
1159
+ maxSize: input.size,
1160
+ serialize(value) {
1161
+ if (input.range) {
1162
+ assertRange(input.name, input.range[0], input.range[1], value);
1163
+ }
1164
+ const buffer = new ArrayBuffer(input.size);
1165
+ input.set(new DataView(buffer), value, littleEndian);
1166
+ return new Uint8Array(buffer);
1167
+ },
1168
+ deserialize(bytes2, offset = 0) {
1169
+ const slice = bytes2.slice(offset, offset + input.size);
1170
+ assertEnoughBytes("i8", slice, input.size);
1171
+ const view = toDataView(slice);
1172
+ return [input.get(view, littleEndian), offset + input.size];
1173
+ }
1174
+ };
1175
+ }
1176
+ var toArrayBuffer2 = (array2) => array2.buffer.slice(array2.byteOffset, array2.byteLength + array2.byteOffset);
1177
+ var toDataView = (array2) => new DataView(toArrayBuffer2(array2));
1178
+ var assertRange = (serializer, min, max, value) => {
1179
+ if (value < min || value > max) {
1180
+ throw new NumberOutOfRangeError(serializer, min, max, value);
1181
+ }
1182
+ };
1183
+ var assertEnoughBytes = (serializer, bytes2, expected) => {
1184
+ if (bytes2.length === 0) {
1185
+ throw new DeserializingEmptyBufferError(serializer);
1186
+ }
1187
+ if (bytes2.length < expected) {
1188
+ throw new NotEnoughBytesError(serializer, expected, bytes2.length);
1189
+ }
1190
+ };
1191
+
1192
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
1193
+ init_env_shim();
1194
+ var u8 = (options = {}) => numberFactory({
1195
+ name: "u8",
1196
+ size: 1,
1197
+ range: [0, Number("0xff")],
1198
+ set: (view, value) => view.setUint8(0, Number(value)),
1199
+ get: (view) => view.getUint8(0),
1200
+ options
1201
+ });
1202
+
1203
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
1204
+ init_env_shim();
1205
+ var u32 = (options = {}) => numberFactory({
1206
+ name: "u32",
1207
+ size: 4,
1208
+ range: [0, Number("0xffffffff")],
1209
+ set: (view, value, le) => view.setUint32(0, Number(value), le),
1210
+ get: (view, le) => view.getUint32(0, le),
1211
+ options
1212
+ });
1213
+
1214
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
1215
+ init_env_shim();
1216
+ var shortU16 = (options = {}) => ({
1217
+ description: options.description ?? "shortU16",
1218
+ fixedSize: null,
1219
+ maxSize: 3,
1220
+ serialize: (value) => {
1221
+ assertRange("shortU16", 0, 65535, value);
1222
+ const bytes2 = [0];
1223
+ for (let ii = 0; ; ii += 1) {
1224
+ const alignedValue = value >> ii * 7;
1225
+ if (alignedValue === 0) {
1226
+ break;
1227
+ }
1228
+ const nextSevenBits = 127 & alignedValue;
1229
+ bytes2[ii] = nextSevenBits;
1230
+ if (ii > 0) {
1231
+ bytes2[ii - 1] |= 128;
1232
+ }
1233
+ }
1234
+ return new Uint8Array(bytes2);
1235
+ },
1236
+ deserialize: (bytes2, offset = 0) => {
1237
+ let value = 0;
1238
+ let byteCount = 0;
1239
+ while (++byteCount) {
1240
+ const byteIndex = byteCount - 1;
1241
+ const currentByte = bytes2[offset + byteIndex];
1242
+ const nextSevenBits = 127 & currentByte;
1243
+ value |= nextSevenBits << byteIndex * 7;
1244
+ if ((currentByte & 128) === 0) {
1245
+ break;
1246
+ }
1247
+ }
1248
+ return [value, offset + byteCount];
1249
+ }
1250
+ });
1251
+
1252
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
1253
+ init_env_shim();
1254
+
1255
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
1256
+ init_env_shim();
1257
+ var InvalidNumberOfItemsError = class extends Error {
1258
+ constructor(serializer, expected, actual) {
1259
+ super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
1260
+ __publicField(this, "name", "InvalidNumberOfItemsError");
1261
+ }
1262
+ };
1263
+ var InvalidArrayLikeRemainderSizeError = class extends Error {
1264
+ constructor(remainderSize, itemSize) {
1265
+ super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
1266
+ __publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
1267
+ }
1268
+ };
1269
+ var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
1270
+ constructor(size) {
1271
+ super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
1272
+ __publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
1273
+ }
1274
+ };
1275
+
1276
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
1277
+ init_env_shim();
1278
+
1279
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
1280
+ init_env_shim();
1281
+ function sumSerializerSizes(sizes) {
1282
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1283
+ }
1284
+
1285
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
1286
+ function getResolvedSize(size, childrenSizes, bytes2, offset) {
1287
+ if (typeof size === "number") {
1288
+ return [size, offset];
1289
+ }
1290
+ if (typeof size === "object") {
1291
+ return size.deserialize(bytes2, offset);
1292
+ }
1293
+ if (size === "remainder") {
1294
+ const childrenSize = sumSerializerSizes(childrenSizes);
1295
+ if (childrenSize === null) {
1296
+ throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
1297
+ }
1298
+ const remainder = bytes2.slice(offset).length;
1299
+ if (remainder % childrenSize !== 0) {
1300
+ throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
1301
+ }
1302
+ return [remainder / childrenSize, offset];
1303
+ }
1304
+ throw new UnrecognizedArrayLikeSerializerSizeError(size);
1305
+ }
1306
+ function getSizeDescription2(size) {
1307
+ return typeof size === "object" ? size.description : `${size}`;
1308
+ }
1309
+ function getSizeFromChildren(size, childrenSizes) {
1310
+ if (typeof size !== "number")
1311
+ return null;
1312
+ if (size === 0)
1313
+ return 0;
1314
+ const childrenSize = sumSerializerSizes(childrenSizes);
1315
+ return childrenSize === null ? null : childrenSize * size;
1316
+ }
1317
+ function getSizePrefix(size, realSize) {
1318
+ return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
1319
+ }
1320
+
1321
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
1322
+ function array(item, options = {}) {
1323
+ const size = options.size ?? u32();
1324
+ if (size === "remainder" && item.fixedSize === null) {
1325
+ throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
1326
+ }
1327
+ return {
1328
+ description: options.description ?? `array(${item.description}; ${getSizeDescription2(size)})`,
1329
+ fixedSize: getSizeFromChildren(size, [item.fixedSize]),
1330
+ maxSize: getSizeFromChildren(size, [item.maxSize]),
1331
+ serialize: (value) => {
1332
+ if (typeof size === "number" && value.length !== size) {
1333
+ throw new InvalidNumberOfItemsError("array", size, value.length);
1334
+ }
1335
+ return mergeBytes2([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
1336
+ },
1337
+ deserialize: (bytes2, offset = 0) => {
1338
+ if (typeof size === "object" && bytes2.slice(offset).length === 0) {
1339
+ return [[], offset];
1340
+ }
1341
+ const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
1342
+ offset = newOffset;
1343
+ const values = [];
1344
+ for (let i = 0; i < resolvedSize; i += 1) {
1345
+ const [value, newOffset2] = item.deserialize(bytes2, offset);
1346
+ values.push(value);
1347
+ offset = newOffset2;
1348
+ }
1349
+ return [values, offset];
1350
+ }
1351
+ };
1352
+ }
1353
+
1354
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
1355
+ init_env_shim();
1356
+ function bytes(options = {}) {
1357
+ const size = options.size ?? "variable";
1358
+ const description = options.description ?? `bytes(${getSizeDescription2(size)})`;
1359
+ const byteSerializer = {
1360
+ description,
1361
+ fixedSize: null,
1362
+ maxSize: null,
1363
+ serialize: (value) => new Uint8Array(value),
1364
+ deserialize: (bytes2, offset = 0) => {
1365
+ const slice = bytes2.slice(offset);
1366
+ return [slice, offset + slice.length];
1367
+ }
1368
+ };
1369
+ if (size === "variable") {
1370
+ return byteSerializer;
1371
+ }
1372
+ if (typeof size === "number") {
1373
+ return fixSerializer(byteSerializer, size, description);
1374
+ }
1375
+ return {
1376
+ description,
1377
+ fixedSize: null,
1378
+ maxSize: null,
1379
+ serialize: (value) => {
1380
+ const contentBytes = byteSerializer.serialize(value);
1381
+ const lengthBytes = size.serialize(contentBytes.length);
1382
+ return mergeBytes2([lengthBytes, contentBytes]);
1383
+ },
1384
+ deserialize: (buffer, offset = 0) => {
1385
+ if (buffer.slice(offset).length === 0) {
1386
+ throw new DeserializingEmptyBufferError("bytes");
1387
+ }
1388
+ const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
1389
+ const length = Number(lengthBigInt);
1390
+ offset = lengthOffset;
1391
+ const contentBuffer = buffer.slice(offset, offset + length);
1392
+ if (contentBuffer.length < length) {
1393
+ throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
1394
+ }
1395
+ const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
1396
+ offset += contentOffset;
1397
+ return [value, offset];
1398
+ }
1399
+ };
1400
+ }
1401
+
1402
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
1403
+ init_env_shim();
1404
+ function string(options = {}) {
1405
+ const size = options.size ?? u32();
1406
+ const encoding = options.encoding ?? utf8;
1407
+ const description = options.description ?? `string(${encoding.description}; ${getSizeDescription2(size)})`;
1408
+ if (size === "variable") {
1409
+ return {
1410
+ ...encoding,
1411
+ description
1412
+ };
1413
+ }
1414
+ if (typeof size === "number") {
1415
+ return fixSerializer(encoding, size, description);
1416
+ }
1417
+ return {
1418
+ description,
1419
+ fixedSize: null,
1420
+ maxSize: null,
1421
+ serialize: (value) => {
1422
+ const contentBytes = encoding.serialize(value);
1423
+ const lengthBytes = size.serialize(contentBytes.length);
1424
+ return mergeBytes2([lengthBytes, contentBytes]);
1425
+ },
1426
+ deserialize: (buffer, offset = 0) => {
1427
+ if (buffer.slice(offset).length === 0) {
1428
+ throw new DeserializingEmptyBufferError("string");
1429
+ }
1430
+ const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
1431
+ const length = Number(lengthBigInt);
1432
+ offset = lengthOffset;
1433
+ const contentBuffer = buffer.slice(offset, offset + length);
1434
+ if (contentBuffer.length < length) {
1435
+ throw new NotEnoughBytesError("string", length, contentBuffer.length);
1436
+ }
1437
+ const [value, contentOffset] = encoding.deserialize(contentBuffer);
1438
+ offset += contentOffset;
1439
+ return [value, offset];
1440
+ }
1441
+ };
1442
+ }
1443
+
1444
+ // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
1445
+ init_env_shim();
1446
+ function struct(fields, options = {}) {
1447
+ const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
1448
+ return {
1449
+ description: options.description ?? `struct(${fieldDescriptions})`,
1450
+ fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
1451
+ maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
1452
+ serialize: (struct2) => {
1453
+ const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
1454
+ return mergeBytes2(fieldBytes);
1455
+ },
1456
+ deserialize: (bytes2, offset = 0) => {
1457
+ const struct2 = {};
1458
+ fields.forEach(([key, serializer]) => {
1459
+ const [value, newOffset] = serializer.deserialize(bytes2, offset);
1460
+ offset = newOffset;
1461
+ struct2[key] = value;
1462
+ });
1463
+ return [struct2, offset];
1464
+ }
1465
+ };
1466
+ }
1467
+
1468
+ // ../codecs-data-structures/dist/index.browser.js
1469
+ init_env_shim();
1470
+ function sumCodecSizes(sizes) {
1471
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1472
+ }
1473
+ function structCodecHelper(fields, description) {
1474
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1475
+ return {
1476
+ description: description ?? `struct(${fieldDescriptions})`,
1477
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1478
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1479
+ };
1480
+ }
1481
+ function getStructEncoder(fields, options = {}) {
1482
+ return {
1483
+ ...structCodecHelper(fields, options.description),
1484
+ encode: (struct2) => {
1485
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct2[key]));
1486
+ return mergeBytes(fieldBytes);
1487
+ }
1488
+ };
1489
+ }
1490
+ function getStructDecoder(fields, options = {}) {
1491
+ return {
1492
+ ...structCodecHelper(fields, options.description),
1493
+ decode: (bytes2, offset = 0) => {
1494
+ const struct2 = {};
1495
+ fields.forEach(([key, codec]) => {
1496
+ const [value, newOffset] = codec.decode(bytes2, offset);
1497
+ offset = newOffset;
1498
+ struct2[key] = value;
1499
+ });
1500
+ return [struct2, offset];
1501
+ }
1502
+ };
1503
+ }
1504
+ function getStructCodec(fields, options = {}) {
1505
+ return combineCodec(getStructEncoder(fields, options), getStructDecoder(fields, options));
1506
+ }
1507
+ function getUnsignedTransaction(transaction) {
1508
+ if ("signatures" in transaction) {
1509
+ const {
1510
+ signatures: _,
1511
+ // eslint-disable-line @typescript-eslint/no-unused-vars
1512
+ ...unsignedTransaction
1513
+ } = transaction;
1514
+ return unsignedTransaction;
1515
+ } else {
1516
+ return transaction;
1517
+ }
1518
+ }
1519
+ function assertIsBlockhash(putativeBlockhash) {
1520
+ try {
1521
+ if (
1522
+ // Lowest value (32 bytes of zeroes)
1523
+ putativeBlockhash.length < 32 || // Highest value (32 bytes of 255)
1524
+ putativeBlockhash.length > 44
1525
+ ) {
1526
+ throw new Error("Expected input string to decode to a byte array of length 32.");
1527
+ }
1528
+ const bytes3 = base58.serialize(putativeBlockhash);
1529
+ const numBytes = bytes3.byteLength;
1530
+ if (numBytes !== 32) {
1531
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1532
+ }
1533
+ } catch (e3) {
1534
+ throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
1535
+ cause: e3
1536
+ });
1537
+ }
1538
+ }
1539
+ function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
1540
+ if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
1541
+ return transaction;
1542
+ }
1543
+ const out = {
1544
+ ...getUnsignedTransaction(transaction),
1545
+ lifetimeConstraint: blockhashLifetimeConstraint
1546
+ };
1547
+ Object.freeze(out);
1548
+ return out;
1549
+ }
1550
+ function createTransaction({
1551
+ version
1552
+ }) {
1553
+ const out = {
1554
+ instructions: [],
1555
+ version
1556
+ };
1557
+ Object.freeze(out);
1558
+ return out;
1559
+ }
1560
+ var AccountRole2 = /* @__PURE__ */ ((AccountRole22) => {
1561
+ AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
1562
+ 3] = "WRITABLE_SIGNER";
1563
+ AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
1564
+ 2] = "READONLY_SIGNER";
1565
+ AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
1566
+ 1] = "WRITABLE";
1567
+ AccountRole22[AccountRole22["READONLY"] = /* 0 */
1568
+ 0] = "READONLY";
1569
+ return AccountRole22;
1570
+ })(AccountRole2 || {});
1571
+ var IS_WRITABLE_BITMASK2 = 1;
1572
+ function isSignerRole2(role) {
1573
+ return role >= 2;
1574
+ }
1575
+ function isWritableRole2(role) {
1576
+ return (role & IS_WRITABLE_BITMASK2) !== 0;
1577
+ }
1578
+ function mergeRoles2(roleA, roleB) {
1579
+ return roleA | roleB;
1580
+ }
1581
+ var RECENT_BLOCKHASHES_SYSVAR_ADDRESS = "SysvarRecentB1ockHashes11111111111111111111";
1582
+ var SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
1583
+ function assertIsDurableNonceTransaction(transaction) {
1584
+ if (!isDurableNonceTransaction(transaction)) {
1585
+ throw new Error("Transaction is not a durable nonce transaction");
1586
+ }
1587
+ }
1588
+ function createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress) {
1589
+ return {
1590
+ accounts: [
1591
+ { address: nonceAccountAddress, role: AccountRole2.WRITABLE },
1592
+ {
1593
+ address: RECENT_BLOCKHASHES_SYSVAR_ADDRESS,
1594
+ role: AccountRole2.READONLY
1595
+ },
1596
+ { address: nonceAuthorityAddress, role: AccountRole2.READONLY_SIGNER }
1597
+ ],
1598
+ data: new Uint8Array([4, 0, 0, 0]),
1599
+ programAddress: SYSTEM_PROGRAM_ADDRESS
1600
+ };
1601
+ }
1602
+ function isAdvanceNonceAccountInstruction(instruction) {
1603
+ return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
1604
+ instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
1605
+ instruction.accounts?.length === 3 && // First account is nonce account address
1606
+ instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
1607
+ instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
1608
+ instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole2.READONLY_SIGNER;
1609
+ }
1610
+ function isAdvanceNonceAccountInstructionData(data) {
1611
+ return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
1612
+ }
1613
+ function isDurableNonceTransaction(transaction) {
1614
+ return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
1615
+ }
1616
+ function setTransactionLifetimeUsingDurableNonce({
1617
+ nonce,
1618
+ nonceAccountAddress,
1619
+ nonceAuthorityAddress
1620
+ }, transaction) {
1621
+ const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
1622
+ if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
1623
+ return transaction;
1624
+ }
1625
+ const out = {
1626
+ ...getUnsignedTransaction(transaction),
1627
+ instructions: [
1628
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1629
+ ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
1630
+ ],
1631
+ lifetimeConstraint: {
1632
+ nonce
1633
+ }
1634
+ };
1635
+ Object.freeze(out);
1636
+ return out;
1637
+ }
1638
+ function setTransactionFeePayer(feePayer, transaction) {
1639
+ if ("feePayer" in transaction && feePayer === transaction.feePayer) {
1640
+ return transaction;
1641
+ }
1642
+ const out = {
1643
+ ...getUnsignedTransaction(transaction),
1644
+ feePayer
1645
+ };
1646
+ Object.freeze(out);
1647
+ return out;
1648
+ }
1649
+ function appendTransactionInstruction(instruction, transaction) {
1650
+ const out = {
1651
+ ...getUnsignedTransaction(transaction),
1652
+ instructions: [...transaction.instructions, instruction]
1653
+ };
1654
+ Object.freeze(out);
1655
+ return out;
1656
+ }
1657
+ function prependTransactionInstruction(instruction, transaction) {
1658
+ const out = {
1659
+ ...getUnsignedTransaction(transaction),
1660
+ instructions: [instruction, ...transaction.instructions]
1661
+ };
1662
+ Object.freeze(out);
1663
+ return out;
1664
+ }
1665
+ function upsert(addressMap, address2, update) {
1666
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
1667
+ }
1668
+ var TYPE = Symbol("AddressMapTypeProperty");
1669
+ function getAddressMapFromInstructions(feePayer, instructions) {
1670
+ const addressMap = {
1671
+ [feePayer]: { [TYPE]: 0, role: AccountRole2.WRITABLE_SIGNER }
1672
+ };
1673
+ const addressesOfInvokedPrograms = /* @__PURE__ */ new Set();
1674
+ for (const instruction of instructions) {
1675
+ upsert(addressMap, instruction.programAddress, (entry) => {
1676
+ addressesOfInvokedPrograms.add(instruction.programAddress);
1677
+ if (TYPE in entry) {
1678
+ if (isWritableRole2(entry.role)) {
1679
+ switch (entry[TYPE]) {
1680
+ case 0:
1681
+ throw new Error(
1682
+ `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and set as the fee payer. Program addresses may not pay fees.`
1683
+ );
1684
+ default:
1685
+ throw new Error(
1686
+ `This transaction includes an address (\`${instruction.programAddress}\`) which is both invoked and marked writable. Program addresses may not be writable.`
1687
+ );
1688
+ }
1689
+ }
1690
+ if (entry[TYPE] === 2) {
1691
+ return entry;
1692
+ }
1693
+ }
1694
+ return { [TYPE]: 2, role: AccountRole2.READONLY };
1695
+ });
1696
+ let addressComparator;
1697
+ if (!instruction.accounts) {
1698
+ continue;
1699
+ }
1700
+ for (const account of instruction.accounts) {
1701
+ upsert(addressMap, account.address, (entry) => {
1702
+ const {
1703
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
1704
+ address: _,
1705
+ ...accountMeta
1706
+ } = account;
1707
+ if (TYPE in entry) {
1708
+ switch (entry[TYPE]) {
1709
+ case 0:
1710
+ return entry;
1711
+ case 1: {
1712
+ const nextRole = mergeRoles2(entry.role, accountMeta.role);
1713
+ if ("lookupTableAddress" in accountMeta) {
1714
+ const shouldReplaceEntry = (
1715
+ // Consider using the new LOOKUP_TABLE if its address is different...
1716
+ entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
1717
+ (addressComparator || (addressComparator = getAddressComparator()))(
1718
+ accountMeta.lookupTableAddress,
1719
+ entry.lookupTableAddress
1720
+ ) < 0
1721
+ );
1722
+ if (shouldReplaceEntry) {
1723
+ return {
1724
+ [TYPE]: 1,
1725
+ ...accountMeta,
1726
+ role: nextRole
1727
+ };
1728
+ }
1729
+ } else if (isSignerRole2(accountMeta.role)) {
1730
+ return {
1731
+ [TYPE]: 2,
1732
+ role: nextRole
1733
+ };
1734
+ }
1735
+ if (entry.role !== nextRole) {
1736
+ return {
1737
+ ...entry,
1738
+ role: nextRole
1739
+ };
1740
+ } else {
1741
+ return entry;
1742
+ }
1743
+ }
1744
+ case 2: {
1745
+ const nextRole = mergeRoles2(entry.role, accountMeta.role);
1746
+ if (
1747
+ // Check to see if this address represents a program that is invoked
1748
+ // in this transaction.
1749
+ addressesOfInvokedPrograms.has(account.address)
1750
+ ) {
1751
+ if (isWritableRole2(accountMeta.role)) {
1752
+ throw new Error(
1753
+ `This transaction includes an address (\`${account.address}\`) which is both invoked and marked writable. Program addresses may not be writable.`
1754
+ );
1755
+ }
1756
+ if (entry.role !== nextRole) {
1757
+ return {
1758
+ ...entry,
1759
+ role: nextRole
1760
+ };
1761
+ } else {
1762
+ return entry;
1763
+ }
1764
+ } else if ("lookupTableAddress" in accountMeta && // Static accounts can be 'upgraded' to lookup table accounts as
1765
+ // long as they are not require to sign the transaction.
1766
+ !isSignerRole2(entry.role)) {
1767
+ return {
1768
+ ...accountMeta,
1769
+ [TYPE]: 1,
1770
+ role: nextRole
1771
+ };
1772
+ } else {
1773
+ if (entry.role !== nextRole) {
1774
+ return {
1775
+ ...entry,
1776
+ role: nextRole
1777
+ };
1778
+ } else {
1779
+ return entry;
1780
+ }
1781
+ }
1782
+ }
1783
+ }
1784
+ }
1785
+ if ("lookupTableAddress" in accountMeta) {
1786
+ return {
1787
+ ...accountMeta,
1788
+ [TYPE]: 1
1789
+ /* LOOKUP_TABLE */
1790
+ };
1791
+ } else {
1792
+ return {
1793
+ ...accountMeta,
1794
+ [TYPE]: 2
1795
+ /* STATIC */
1796
+ };
1797
+ }
1798
+ });
1799
+ }
1800
+ }
1801
+ return addressMap;
1802
+ }
1803
+ function getOrderedAccountsFromAddressMap(addressMap) {
1804
+ let addressComparator;
1805
+ const orderedAccounts = Object.entries(addressMap).sort(([leftAddress, leftEntry], [rightAddress, rightEntry]) => {
1806
+ if (leftEntry[TYPE] !== rightEntry[TYPE]) {
1807
+ if (leftEntry[TYPE] === 0) {
1808
+ return -1;
1809
+ } else if (rightEntry[TYPE] === 0) {
1810
+ return 1;
1811
+ } else if (leftEntry[TYPE] === 2) {
1812
+ return -1;
1813
+ } else if (rightEntry[TYPE] === 2) {
1814
+ return 1;
1815
+ }
1816
+ }
1817
+ const leftIsSigner = isSignerRole2(leftEntry.role);
1818
+ if (leftIsSigner !== isSignerRole2(rightEntry.role)) {
1819
+ return leftIsSigner ? -1 : 1;
1820
+ }
1821
+ const leftIsWritable = isWritableRole2(leftEntry.role);
1822
+ if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
1823
+ return leftIsWritable ? -1 : 1;
1824
+ }
1825
+ addressComparator || (addressComparator = getAddressComparator());
1826
+ if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
1827
+ return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
1828
+ } else {
1829
+ return addressComparator(leftAddress, rightAddress);
1830
+ }
1831
+ }).map(([address2, addressMeta]) => ({
1832
+ address: address2,
1833
+ ...addressMeta
1834
+ }));
1835
+ return orderedAccounts;
1836
+ }
1837
+ function getCompiledAddressTableLookups(orderedAccounts) {
1838
+ var _a;
1839
+ const index = {};
1840
+ for (const account of orderedAccounts) {
1841
+ if (!("lookupTableAddress" in account)) {
1842
+ continue;
1843
+ }
1844
+ const entry = index[_a = account.lookupTableAddress] || (index[_a] = {
1845
+ readableIndices: [],
1846
+ writableIndices: []
1847
+ });
1848
+ if (account.role === AccountRole2.WRITABLE) {
1849
+ entry.writableIndices.push(account.addressIndex);
1850
+ } else {
1851
+ entry.readableIndices.push(account.addressIndex);
1852
+ }
1853
+ }
1854
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
1855
+ lookupTableAddress,
1856
+ ...index[lookupTableAddress]
1857
+ }));
1858
+ }
1859
+ function getCompiledMessageHeader(orderedAccounts) {
1860
+ let numReadonlyNonSignerAccounts = 0;
1861
+ let numReadonlySignerAccounts = 0;
1862
+ let numSignerAccounts = 0;
1863
+ for (const account of orderedAccounts) {
1864
+ if ("lookupTableAddress" in account) {
1865
+ break;
1866
+ }
1867
+ const accountIsWritable = isWritableRole2(account.role);
1868
+ if (isSignerRole2(account.role)) {
1869
+ numSignerAccounts++;
1870
+ if (!accountIsWritable) {
1871
+ numReadonlySignerAccounts++;
1872
+ }
1873
+ } else if (!accountIsWritable) {
1874
+ numReadonlyNonSignerAccounts++;
1875
+ }
1876
+ }
1877
+ return {
1878
+ numReadonlyNonSignerAccounts,
1879
+ numReadonlySignerAccounts,
1880
+ numSignerAccounts
1881
+ };
1882
+ }
1883
+ function getAccountIndex(orderedAccounts) {
1884
+ const out = {};
1885
+ for (const [index, account] of orderedAccounts.entries()) {
1886
+ out[account.address] = index;
1887
+ }
1888
+ return out;
1889
+ }
1890
+ function getCompiledInstructions(instructions, orderedAccounts) {
1891
+ const accountIndex = getAccountIndex(orderedAccounts);
1892
+ return instructions.map(({ accounts, data, programAddress }) => {
1893
+ return {
1894
+ programAddressIndex: accountIndex[programAddress],
1895
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
1896
+ ...data ? { data } : null
1897
+ };
1898
+ });
1899
+ }
1900
+ function getCompiledLifetimeToken(lifetimeConstraint) {
1901
+ if ("nonce" in lifetimeConstraint) {
1902
+ return lifetimeConstraint.nonce;
1903
+ }
1904
+ return lifetimeConstraint.blockhash;
1905
+ }
1906
+ function getCompiledStaticAccounts(orderedAccounts) {
1907
+ const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
1908
+ const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
1909
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
1910
+ }
1911
+ function compileMessage(transaction) {
1912
+ const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
1913
+ const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
1914
+ return {
1915
+ ...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
1916
+ header: getCompiledMessageHeader(orderedAccounts),
1917
+ instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),
1918
+ lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),
1919
+ staticAccounts: getCompiledStaticAccounts(orderedAccounts),
1920
+ version: transaction.version
1921
+ };
1922
+ }
1923
+ function getCompiledTransaction(transaction) {
1924
+ const compiledMessage = compileMessage(transaction);
1925
+ let signatures;
1926
+ if ("signatures" in transaction) {
1927
+ signatures = [];
1928
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1929
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1930
+ }
1931
+ } else {
1932
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1933
+ }
1934
+ return {
1935
+ compiledMessage,
1936
+ signatures
1937
+ };
1938
+ }
1939
+ function addressSerializerCompat(compat) {
1940
+ const codec = getAddressCodec();
1941
+ return {
1942
+ description: compat?.description ?? codec.description,
1943
+ deserialize: codec.decode,
1944
+ fixedSize: codec.fixedSize,
1945
+ maxSize: codec.maxSize,
1946
+ serialize: codec.encode
1947
+ };
1948
+ }
1949
+ function getAddressTableLookupCodec() {
1950
+ return struct(
1951
+ [
1952
+ [
1953
+ "lookupTableAddress",
1954
+ addressSerializerCompat(
1955
+ {
1956
+ description: "The address of the address lookup table account from which instruction addresses should be looked up"
1957
+ }
1958
+ )
1959
+ ],
1960
+ [
1961
+ "writableIndices",
1962
+ array(u8(), {
1963
+ ...{
1964
+ description: "The indices of the accounts in the lookup table that should be loaded as writeable"
1965
+ } ,
1966
+ size: shortU16()
1967
+ })
1968
+ ],
1969
+ [
1970
+ "readableIndices",
1971
+ array(u8(), {
1972
+ ...{
1973
+ description: "The indices of the accounts in the lookup table that should be loaded as read-only"
1974
+ } ,
1975
+ size: shortU16()
1976
+ })
1977
+ ]
1978
+ ],
1979
+ {
1980
+ description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
1981
+ }
1982
+ );
1983
+ }
1984
+ var memoizedU8Codec;
1985
+ function getMemoizedU8Codec() {
1986
+ if (!memoizedU8Codec)
1987
+ memoizedU8Codec = getU8Codec();
1988
+ return memoizedU8Codec;
1989
+ }
1990
+ function getMemoizedU8CodecDescription(description) {
1991
+ const codec = getMemoizedU8Codec();
1992
+ return {
1993
+ ...codec,
1994
+ description: description ?? codec.description
1995
+ };
1996
+ }
1997
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1998
+ var numReadonlySignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable" ;
1999
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
2000
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
2001
+ function getMessageHeaderCodec() {
2002
+ return getStructCodec(
2003
+ [
2004
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
2005
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
2006
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
2007
+ ],
2008
+ {
2009
+ description: messageHeaderDescription
2010
+ }
2011
+ );
2012
+ }
2013
+ function getInstructionCodec() {
2014
+ return mapSerializer(
2015
+ struct([
2016
+ [
2017
+ "programAddressIndex",
2018
+ u8(
2019
+ {
2020
+ description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
2021
+ }
2022
+ )
2023
+ ],
2024
+ [
2025
+ "accountIndices",
2026
+ array(
2027
+ u8({
2028
+ description: "The index of an account, according to the well-ordered accounts list for this transaction"
2029
+ }),
2030
+ {
2031
+ description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
2032
+ size: shortU16()
2033
+ }
2034
+ )
2035
+ ],
2036
+ [
2037
+ "data",
2038
+ bytes({
2039
+ description: "An optional buffer of data passed to the instruction" ,
2040
+ size: shortU16()
2041
+ })
2042
+ ]
2043
+ ]),
2044
+ (value) => {
2045
+ if (value.accountIndices !== void 0 && value.data !== void 0) {
2046
+ return value;
2047
+ }
2048
+ return {
2049
+ ...value,
2050
+ accountIndices: value.accountIndices ?? [],
2051
+ data: value.data ?? new Uint8Array(0)
2052
+ };
2053
+ },
2054
+ (value) => {
2055
+ if (value.accountIndices.length && value.data.byteLength) {
2056
+ return value;
2057
+ }
2058
+ const { accountIndices, data, ...rest } = value;
2059
+ return {
2060
+ ...rest,
2061
+ ...accountIndices.length ? { accountIndices } : null,
2062
+ ...data.byteLength ? { data } : null
2063
+ };
2064
+ }
2065
+ );
2066
+ }
2067
+ var VERSION_FLAG_MASK = 128;
2068
+ var BASE_CONFIG = {
2069
+ description: "A single byte that encodes the version of the transaction" ,
2070
+ fixedSize: null,
2071
+ maxSize: 1
2072
+ };
2073
+ function decode(bytes3, offset = 0) {
2074
+ const firstByte = bytes3[offset];
2075
+ if ((firstByte & VERSION_FLAG_MASK) === 0) {
2076
+ return ["legacy", offset];
2077
+ } else {
2078
+ const version = firstByte ^ VERSION_FLAG_MASK;
2079
+ return [version, offset + 1];
2080
+ }
2081
+ }
2082
+ function encode(value) {
2083
+ if (value === "legacy") {
2084
+ return new Uint8Array();
2085
+ }
2086
+ if (value < 0 || value > 127) {
2087
+ throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
2088
+ }
2089
+ return new Uint8Array([value | VERSION_FLAG_MASK]);
2090
+ }
2091
+ function getTransactionVersionDecoder() {
2092
+ return {
2093
+ ...BASE_CONFIG,
2094
+ decode
2095
+ };
2096
+ }
2097
+ function getTransactionVersionEncoder() {
2098
+ return {
2099
+ ...BASE_CONFIG,
2100
+ encode
2101
+ };
2102
+ }
2103
+ function getTransactionVersionCodec() {
2104
+ return combineCodec(getTransactionVersionEncoder(), getTransactionVersionDecoder());
2105
+ }
2106
+ function getError(type, name) {
2107
+ const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
2108
+ return new Error(
2109
+ `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
2110
+ );
2111
+ }
2112
+ function getUnimplementedDecoder(name) {
2113
+ return () => {
2114
+ throw getError("decoder", name);
2115
+ };
2116
+ }
2117
+ var BASE_CONFIG2 = {
2118
+ description: "The wire format of a Solana transaction message" ,
2119
+ fixedSize: null,
2120
+ maxSize: null
2121
+ };
2122
+ function serialize(compiledMessage) {
2123
+ if (compiledMessage.version === "legacy") {
2124
+ return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
2125
+ } else {
2126
+ return mapSerializer(
2127
+ struct([
2128
+ ...getPreludeStructSerializerTuple(),
2129
+ ["addressTableLookups", getAddressTableLookupsSerializer()]
2130
+ ]),
2131
+ (value) => {
2132
+ if (value.version === "legacy") {
2133
+ return value;
2134
+ }
2135
+ return {
2136
+ ...value,
2137
+ addressTableLookups: value.addressTableLookups ?? []
2138
+ };
2139
+ }
2140
+ ).serialize(compiledMessage);
2141
+ }
2142
+ }
2143
+ function toSerializer(codec) {
2144
+ return {
2145
+ description: codec.description,
2146
+ deserialize: codec.decode,
2147
+ fixedSize: codec.fixedSize,
2148
+ maxSize: codec.maxSize,
2149
+ serialize: codec.encode
2150
+ };
2151
+ }
2152
+ function getPreludeStructSerializerTuple() {
2153
+ return [
2154
+ ["version", toSerializer(getTransactionVersionCodec())],
2155
+ ["header", toSerializer(getMessageHeaderCodec())],
2156
+ [
2157
+ "staticAccounts",
2158
+ array(toSerializer(getAddressCodec()), {
2159
+ description: "A compact-array of static account addresses belonging to this transaction" ,
2160
+ size: shortU16()
2161
+ })
2162
+ ],
2163
+ [
2164
+ "lifetimeToken",
2165
+ string({
2166
+ description: "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ,
2167
+ encoding: base58,
2168
+ size: 32
2169
+ })
2170
+ ],
2171
+ [
2172
+ "instructions",
2173
+ array(getInstructionCodec(), {
2174
+ description: "A compact-array of instructions belonging to this transaction" ,
2175
+ size: shortU16()
2176
+ })
2177
+ ]
2178
+ ];
2179
+ }
2180
+ function getAddressTableLookupsSerializer() {
2181
+ return array(getAddressTableLookupCodec(), {
2182
+ ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
2183
+ size: shortU16()
2184
+ });
2185
+ }
2186
+ function getCompiledMessageEncoder() {
2187
+ return {
2188
+ ...BASE_CONFIG2,
2189
+ deserialize: getUnimplementedDecoder("CompiledMessage"),
2190
+ serialize
2191
+ };
2192
+ }
2193
+ var BASE_CONFIG3 = {
2194
+ description: "The wire format of a Solana transaction" ,
2195
+ fixedSize: null,
2196
+ maxSize: null
2197
+ };
2198
+ function serialize2(transaction) {
2199
+ const compiledTransaction = getCompiledTransaction(transaction);
2200
+ return struct([
2201
+ [
2202
+ "signatures",
2203
+ array(bytes({ size: 64 }), {
2204
+ ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
2205
+ size: shortU16()
2206
+ })
2207
+ ],
2208
+ ["compiledMessage", getCompiledMessageEncoder()]
2209
+ ]).serialize(compiledTransaction);
2210
+ }
2211
+ function getTransactionEncoder() {
2212
+ return {
2213
+ ...BASE_CONFIG3,
2214
+ deserialize: getUnimplementedDecoder("CompiledMessage"),
2215
+ serialize: serialize2
2216
+ };
2217
+ }
2218
+ function assertIsTransactionSignature(putativeTransactionSignature) {
2219
+ try {
2220
+ if (
2221
+ // Lowest value (64 bytes of zeroes)
2222
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2223
+ putativeTransactionSignature.length > 88
2224
+ ) {
2225
+ throw new Error("Expected input string to decode to a byte array of length 64.");
2226
+ }
2227
+ const bytes3 = base58.serialize(putativeTransactionSignature);
2228
+ const numBytes = bytes3.byteLength;
2229
+ if (numBytes !== 64) {
2230
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
2231
+ }
2232
+ } catch (e3) {
2233
+ throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
2234
+ cause: e3
2235
+ });
2236
+ }
2237
+ }
2238
+ function isTransactionSignature(putativeTransactionSignature) {
2239
+ if (
2240
+ // Lowest value (64 bytes of zeroes)
2241
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2242
+ putativeTransactionSignature.length > 88
2243
+ ) {
2244
+ return false;
2245
+ }
2246
+ const bytes3 = base58.serialize(putativeTransactionSignature);
2247
+ const numBytes = bytes3.byteLength;
2248
+ if (numBytes !== 64) {
2249
+ return false;
2250
+ }
2251
+ return true;
2252
+ }
2253
+ async function getCompiledMessageSignature(message, secretKey) {
2254
+ const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
2255
+ const signature = await signBytes(secretKey, wireMessageBytes);
2256
+ return signature;
2257
+ }
2258
+ function getSignatureFromTransaction(transaction) {
2259
+ const signature = transaction.signatures[transaction.feePayer];
2260
+ if (!signature) {
2261
+ throw new Error(
2262
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
2263
+ );
2264
+ }
2265
+ return signature;
2266
+ }
2267
+ async function signTransaction(keyPairs, transaction) {
2268
+ const compiledMessage = compileMessage(transaction);
2269
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
2270
+ const publicKeySignaturePairs = await Promise.all(
2271
+ keyPairs.map(
2272
+ (keyPair) => Promise.all([
2273
+ getAddressFromPublicKey(keyPair.publicKey),
2274
+ getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
2275
+ ])
2276
+ )
2277
+ );
2278
+ for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
2279
+ nextSignatures[signerPublicKey] = signature;
2280
+ }
2281
+ const out = {
2282
+ ...transaction,
2283
+ signatures: nextSignatures
2284
+ };
2285
+ Object.freeze(out);
2286
+ return out;
2287
+ }
2288
+ function transactionSignature(putativeTransactionSignature) {
2289
+ assertIsTransactionSignature(putativeTransactionSignature);
2290
+ return putativeTransactionSignature;
2291
+ }
2292
+ function getBase64EncodedWireTransaction(transaction) {
2293
+ const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
2294
+ {
2295
+ return btoa(String.fromCharCode(...wireTransactionBytes));
2296
+ }
2297
+ }
2298
+
2299
+ // src/rpc.ts
2300
+ init_env_shim();
2301
+
2302
+ // ../functional/dist/index.browser.js
2303
+ init_env_shim();
2304
+ function pipe(init, ...fns) {
2305
+ return fns.reduce((acc, fn) => fn(acc), init);
2306
+ }
2307
+
2308
+ // ../rpc-core/dist/index.browser.js
2309
+ init_env_shim();
2310
+ function getCommitmentScore(commitment) {
2311
+ switch (commitment) {
2312
+ case "finalized":
2313
+ return 2;
2314
+ case "confirmed":
2315
+ return 1;
2316
+ case "processed":
2317
+ return 0;
2318
+ default:
2319
+ return ((_) => {
2320
+ throw new Error(`Unrecognized commitment \`${commitment}\`.`);
2321
+ })();
2322
+ }
2323
+ }
2324
+ function commitmentComparator(a, b) {
2325
+ if (a === b) {
2326
+ return 0;
2327
+ }
2328
+ return getCommitmentScore(a) < getCommitmentScore(b) ? -1 : 1;
2329
+ }
277
2330
  function visitNode(value, keyPath, onIntegerOverflow) {
278
2331
  if (Array.isArray(value)) {
279
2332
  return value.map(
@@ -300,36 +2353,393 @@ this.globalThis.solanaWeb3 = (function (exports) {
300
2353
  return visitNode(params, [], onIntegerOverflow);
301
2354
  }
302
2355
  var KEYPATH_WILDCARD = {};
303
- var ALLOWED_NUMERIC_KEYPATHS = {
304
- getBlockTime: [[]],
305
- getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
306
- getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
307
- getTokenLargestAccounts: [
308
- ["value", KEYPATH_WILDCARD, "decimals"],
309
- ["value", KEYPATH_WILDCARD, "uiAmount"]
310
- ],
311
- getTransaction: [
312
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
313
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
314
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
315
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
316
- ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
317
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
318
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
319
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
320
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
321
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
322
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
323
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
324
- ["transaction", "message", "header", "numReadonlySignedAccounts"],
325
- ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
326
- ["transaction", "message", "header", "numRequiredSignatures"]
327
- ],
328
- getVoteAccounts: [
329
- ["current", KEYPATH_WILDCARD, "commission"],
330
- ["delinquent", KEYPATH_WILDCARD, "commission"]
331
- ]
332
- };
2356
+ var jsonParsedTokenAccountsConfigs = [
2357
+ // parsed Token/Token22 token account
2358
+ ["data", "parsed", "info", "tokenAmount", "decimals"],
2359
+ ["data", "parsed", "info", "tokenAmount", "uiAmount"],
2360
+ ["data", "parsed", "info", "rentExemptReserve", "decimals"],
2361
+ ["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
2362
+ ["data", "parsed", "info", "delegatedAmount", "decimals"],
2363
+ ["data", "parsed", "info", "delegatedAmount", "uiAmount"],
2364
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
2365
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
2366
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
2367
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
2368
+ ];
2369
+ var jsonParsedAccountsConfigs = [
2370
+ ...jsonParsedTokenAccountsConfigs,
2371
+ // parsed AddressTableLookup account
2372
+ ["data", "parsed", "info", "lastExtendedSlotStartIndex"],
2373
+ // parsed Config account
2374
+ ["data", "parsed", "info", "slashPenalty"],
2375
+ ["data", "parsed", "info", "warmupCooldownRate"],
2376
+ // parsed Token/Token22 mint account
2377
+ ["data", "parsed", "info", "decimals"],
2378
+ // parsed Token/Token22 multisig account
2379
+ ["data", "parsed", "info", "numRequiredSigners"],
2380
+ ["data", "parsed", "info", "numValidSigners"],
2381
+ // parsed Stake account
2382
+ ["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
2383
+ // parsed Sysvar rent account
2384
+ ["data", "parsed", "info", "exemptionThreshold"],
2385
+ ["data", "parsed", "info", "burnPercent"],
2386
+ // parsed Vote account
2387
+ ["data", "parsed", "info", "commission"],
2388
+ ["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
2389
+ ];
2390
+ var memoizedNotificationKeypaths;
2391
+ var memoizedResponseKeypaths;
2392
+ function getAllowedNumericKeypathsForNotification() {
2393
+ if (!memoizedNotificationKeypaths) {
2394
+ memoizedNotificationKeypaths = {
2395
+ accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
2396
+ blockNotifications: [
2397
+ ["value", "block", "blockTime"],
2398
+ [
2399
+ "value",
2400
+ "block",
2401
+ "transactions",
2402
+ KEYPATH_WILDCARD,
2403
+ "meta",
2404
+ "preTokenBalances",
2405
+ KEYPATH_WILDCARD,
2406
+ "accountIndex"
2407
+ ],
2408
+ [
2409
+ "value",
2410
+ "block",
2411
+ "transactions",
2412
+ KEYPATH_WILDCARD,
2413
+ "meta",
2414
+ "preTokenBalances",
2415
+ KEYPATH_WILDCARD,
2416
+ "uiTokenAmount",
2417
+ "decimals"
2418
+ ],
2419
+ [
2420
+ "value",
2421
+ "block",
2422
+ "transactions",
2423
+ KEYPATH_WILDCARD,
2424
+ "meta",
2425
+ "postTokenBalances",
2426
+ KEYPATH_WILDCARD,
2427
+ "accountIndex"
2428
+ ],
2429
+ [
2430
+ "value",
2431
+ "block",
2432
+ "transactions",
2433
+ KEYPATH_WILDCARD,
2434
+ "meta",
2435
+ "postTokenBalances",
2436
+ KEYPATH_WILDCARD,
2437
+ "uiTokenAmount",
2438
+ "decimals"
2439
+ ],
2440
+ ["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
2441
+ [
2442
+ "value",
2443
+ "block",
2444
+ "transactions",
2445
+ KEYPATH_WILDCARD,
2446
+ "meta",
2447
+ "innerInstructions",
2448
+ KEYPATH_WILDCARD,
2449
+ "index"
2450
+ ],
2451
+ [
2452
+ "value",
2453
+ "block",
2454
+ "transactions",
2455
+ KEYPATH_WILDCARD,
2456
+ "meta",
2457
+ "innerInstructions",
2458
+ KEYPATH_WILDCARD,
2459
+ "instructions",
2460
+ KEYPATH_WILDCARD,
2461
+ "programIdIndex"
2462
+ ],
2463
+ [
2464
+ "value",
2465
+ "block",
2466
+ "transactions",
2467
+ KEYPATH_WILDCARD,
2468
+ "meta",
2469
+ "innerInstructions",
2470
+ KEYPATH_WILDCARD,
2471
+ "instructions",
2472
+ KEYPATH_WILDCARD,
2473
+ "accounts",
2474
+ KEYPATH_WILDCARD
2475
+ ],
2476
+ [
2477
+ "value",
2478
+ "block",
2479
+ "transactions",
2480
+ KEYPATH_WILDCARD,
2481
+ "transaction",
2482
+ "message",
2483
+ "addressTableLookups",
2484
+ KEYPATH_WILDCARD,
2485
+ "writableIndexes",
2486
+ KEYPATH_WILDCARD
2487
+ ],
2488
+ [
2489
+ "value",
2490
+ "block",
2491
+ "transactions",
2492
+ KEYPATH_WILDCARD,
2493
+ "transaction",
2494
+ "message",
2495
+ "addressTableLookups",
2496
+ KEYPATH_WILDCARD,
2497
+ "readonlyIndexes",
2498
+ KEYPATH_WILDCARD
2499
+ ],
2500
+ [
2501
+ "value",
2502
+ "block",
2503
+ "transactions",
2504
+ KEYPATH_WILDCARD,
2505
+ "transaction",
2506
+ "message",
2507
+ "instructions",
2508
+ KEYPATH_WILDCARD,
2509
+ "programIdIndex"
2510
+ ],
2511
+ [
2512
+ "value",
2513
+ "block",
2514
+ "transactions",
2515
+ KEYPATH_WILDCARD,
2516
+ "transaction",
2517
+ "message",
2518
+ "instructions",
2519
+ KEYPATH_WILDCARD,
2520
+ "accounts",
2521
+ KEYPATH_WILDCARD
2522
+ ],
2523
+ [
2524
+ "value",
2525
+ "block",
2526
+ "transactions",
2527
+ KEYPATH_WILDCARD,
2528
+ "transaction",
2529
+ "message",
2530
+ "header",
2531
+ "numReadonlySignedAccounts"
2532
+ ],
2533
+ [
2534
+ "value",
2535
+ "block",
2536
+ "transactions",
2537
+ KEYPATH_WILDCARD,
2538
+ "transaction",
2539
+ "message",
2540
+ "header",
2541
+ "numReadonlyUnsignedAccounts"
2542
+ ],
2543
+ [
2544
+ "value",
2545
+ "block",
2546
+ "transactions",
2547
+ KEYPATH_WILDCARD,
2548
+ "transaction",
2549
+ "message",
2550
+ "header",
2551
+ "numRequiredSignatures"
2552
+ ],
2553
+ ["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
2554
+ ],
2555
+ programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
2556
+ ["value", KEYPATH_WILDCARD, "account", ...c],
2557
+ [KEYPATH_WILDCARD, "account", ...c]
2558
+ ])
2559
+ };
2560
+ }
2561
+ return memoizedNotificationKeypaths;
2562
+ }
2563
+ function getAllowedNumericKeypathsForResponse() {
2564
+ if (!memoizedResponseKeypaths) {
2565
+ memoizedResponseKeypaths = {
2566
+ getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
2567
+ getBlock: [
2568
+ ["blockTime"],
2569
+ ["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2570
+ [
2571
+ "transactions",
2572
+ KEYPATH_WILDCARD,
2573
+ "meta",
2574
+ "preTokenBalances",
2575
+ KEYPATH_WILDCARD,
2576
+ "uiTokenAmount",
2577
+ "decimals"
2578
+ ],
2579
+ ["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2580
+ [
2581
+ "transactions",
2582
+ KEYPATH_WILDCARD,
2583
+ "meta",
2584
+ "postTokenBalances",
2585
+ KEYPATH_WILDCARD,
2586
+ "uiTokenAmount",
2587
+ "decimals"
2588
+ ],
2589
+ ["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
2590
+ ["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
2591
+ [
2592
+ "transactions",
2593
+ KEYPATH_WILDCARD,
2594
+ "meta",
2595
+ "innerInstructions",
2596
+ KEYPATH_WILDCARD,
2597
+ "instructions",
2598
+ KEYPATH_WILDCARD,
2599
+ "programIdIndex"
2600
+ ],
2601
+ [
2602
+ "transactions",
2603
+ KEYPATH_WILDCARD,
2604
+ "meta",
2605
+ "innerInstructions",
2606
+ KEYPATH_WILDCARD,
2607
+ "instructions",
2608
+ KEYPATH_WILDCARD,
2609
+ "accounts",
2610
+ KEYPATH_WILDCARD
2611
+ ],
2612
+ [
2613
+ "transactions",
2614
+ KEYPATH_WILDCARD,
2615
+ "transaction",
2616
+ "message",
2617
+ "addressTableLookups",
2618
+ KEYPATH_WILDCARD,
2619
+ "writableIndexes",
2620
+ KEYPATH_WILDCARD
2621
+ ],
2622
+ [
2623
+ "transactions",
2624
+ KEYPATH_WILDCARD,
2625
+ "transaction",
2626
+ "message",
2627
+ "addressTableLookups",
2628
+ KEYPATH_WILDCARD,
2629
+ "readonlyIndexes",
2630
+ KEYPATH_WILDCARD
2631
+ ],
2632
+ [
2633
+ "transactions",
2634
+ KEYPATH_WILDCARD,
2635
+ "transaction",
2636
+ "message",
2637
+ "instructions",
2638
+ KEYPATH_WILDCARD,
2639
+ "programIdIndex"
2640
+ ],
2641
+ [
2642
+ "transactions",
2643
+ KEYPATH_WILDCARD,
2644
+ "transaction",
2645
+ "message",
2646
+ "instructions",
2647
+ KEYPATH_WILDCARD,
2648
+ "accounts",
2649
+ KEYPATH_WILDCARD
2650
+ ],
2651
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
2652
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
2653
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
2654
+ ["rewards", KEYPATH_WILDCARD, "commission"]
2655
+ ],
2656
+ getBlockTime: [[]],
2657
+ getClusterNodes: [
2658
+ [KEYPATH_WILDCARD, "featureSet"],
2659
+ [KEYPATH_WILDCARD, "shredVersion"]
2660
+ ],
2661
+ getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
2662
+ getInflationRate: [["foundation"], ["total"], ["validator"]],
2663
+ getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
2664
+ getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
2665
+ getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
2666
+ ["value", KEYPATH_WILDCARD, "account", ...c],
2667
+ [KEYPATH_WILDCARD, "account", ...c]
2668
+ ]),
2669
+ getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
2670
+ getTokenAccountBalance: [
2671
+ ["value", "decimals"],
2672
+ ["value", "uiAmount"]
2673
+ ],
2674
+ getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
2675
+ "value",
2676
+ KEYPATH_WILDCARD,
2677
+ "account",
2678
+ ...c
2679
+ ]),
2680
+ getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
2681
+ "value",
2682
+ KEYPATH_WILDCARD,
2683
+ "account",
2684
+ ...c
2685
+ ]),
2686
+ getTokenLargestAccounts: [
2687
+ ["value", KEYPATH_WILDCARD, "decimals"],
2688
+ ["value", KEYPATH_WILDCARD, "uiAmount"]
2689
+ ],
2690
+ getTokenSupply: [
2691
+ ["value", "decimals"],
2692
+ ["value", "uiAmount"]
2693
+ ],
2694
+ getTransaction: [
2695
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2696
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
2697
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2698
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
2699
+ ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
2700
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
2701
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
2702
+ [
2703
+ "meta",
2704
+ "innerInstructions",
2705
+ KEYPATH_WILDCARD,
2706
+ "instructions",
2707
+ KEYPATH_WILDCARD,
2708
+ "accounts",
2709
+ KEYPATH_WILDCARD
2710
+ ],
2711
+ [
2712
+ "transaction",
2713
+ "message",
2714
+ "addressTableLookups",
2715
+ KEYPATH_WILDCARD,
2716
+ "writableIndexes",
2717
+ KEYPATH_WILDCARD
2718
+ ],
2719
+ [
2720
+ "transaction",
2721
+ "message",
2722
+ "addressTableLookups",
2723
+ KEYPATH_WILDCARD,
2724
+ "readonlyIndexes",
2725
+ KEYPATH_WILDCARD
2726
+ ],
2727
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
2728
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
2729
+ ["transaction", "message", "header", "numReadonlySignedAccounts"],
2730
+ ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
2731
+ ["transaction", "message", "header", "numRequiredSignatures"]
2732
+ ],
2733
+ getVersion: [["feature-set"]],
2734
+ getVoteAccounts: [
2735
+ ["current", KEYPATH_WILDCARD, "commission"],
2736
+ ["delinquent", KEYPATH_WILDCARD, "commission"]
2737
+ ],
2738
+ simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
2739
+ };
2740
+ }
2741
+ return memoizedResponseKeypaths;
2742
+ }
333
2743
  function getNextAllowedKeypaths(keyPaths, property) {
334
2744
  return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
335
2745
  }
@@ -348,14 +2758,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
348
2758
  return out;
349
2759
  } else if (typeof value === "number" && // The presence of an allowed keypath on the route to this value implies it's allowlisted;
350
2760
  // Upcast the value to `bigint` unless an allowed keypath is present.
351
- allowedKeypaths.length === 0) {
2761
+ allowedKeypaths.length === 0 && // Only try to upcast an Integer to `bigint`
2762
+ Number.isInteger(value)) {
352
2763
  return BigInt(value);
353
2764
  } else {
354
2765
  return value;
355
2766
  }
356
2767
  }
357
2768
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
358
- const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
2769
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
2770
+ return visitNode2(rawResponse, allowedKeypaths ?? []);
2771
+ }
2772
+ function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
2773
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
359
2774
  return visitNode2(rawResponse, allowedKeypaths ?? []);
360
2775
  }
361
2776
  function createSolanaRpcApi(config) {
@@ -384,6 +2799,36 @@ this.globalThis.solanaWeb3 = (function (exports) {
384
2799
  }
385
2800
  });
386
2801
  }
2802
+ function createSolanaRpcSubscriptionsApi(config) {
2803
+ return new Proxy({}, {
2804
+ defineProperty() {
2805
+ return false;
2806
+ },
2807
+ deleteProperty() {
2808
+ return false;
2809
+ },
2810
+ get(...args) {
2811
+ const [_, p] = args;
2812
+ const notificationName = p.toString();
2813
+ return function(...rawParams) {
2814
+ const handleIntegerOverflow = config?.onIntegerOverflow;
2815
+ const params = patchParamsForSolanaLabsRpc(
2816
+ rawParams,
2817
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
2818
+ );
2819
+ return {
2820
+ params,
2821
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
2822
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
2823
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
2824
+ };
2825
+ };
2826
+ }
2827
+ });
2828
+ }
2829
+ function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
2830
+ return createSolanaRpcSubscriptionsApi(config);
2831
+ }
387
2832
 
388
2833
  // ../rpc-transport/dist/index.browser.js
389
2834
  init_env_shim();
@@ -450,7 +2895,101 @@ this.globalThis.solanaWeb3 = (function (exports) {
450
2895
  function createJsonRpc(rpcConfig) {
451
2896
  return makeProxy(rpcConfig);
452
2897
  }
453
- var e = globalThis.fetch;
2898
+ function registerIterableCleanup(iterable, cleanupFn) {
2899
+ (async () => {
2900
+ try {
2901
+ for await (const _ of iterable)
2902
+ ;
2903
+ } catch {
2904
+ } finally {
2905
+ cleanupFn();
2906
+ }
2907
+ })();
2908
+ }
2909
+ function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
2910
+ return {
2911
+ async subscribe({ abortSignal }) {
2912
+ abortSignal.throwIfAborted();
2913
+ let subscriptionId;
2914
+ function handleCleanup() {
2915
+ if (subscriptionId !== void 0) {
2916
+ const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
2917
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
2918
+ connectionAbortController.abort();
2919
+ });
2920
+ } else {
2921
+ connectionAbortController.abort();
2922
+ }
2923
+ }
2924
+ abortSignal.addEventListener("abort", handleCleanup);
2925
+ const connectionAbortController = new AbortController();
2926
+ const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
2927
+ const connection = await rpcConfig.transport({
2928
+ payload: subscribeMessage,
2929
+ signal: connectionAbortController.signal
2930
+ });
2931
+ function handleConnectionCleanup() {
2932
+ abortSignal.removeEventListener("abort", handleCleanup);
2933
+ }
2934
+ registerIterableCleanup(connection, handleConnectionCleanup);
2935
+ for await (const message of connection) {
2936
+ if ("id" in message && message.id === subscribeMessage.id) {
2937
+ if ("error" in message) {
2938
+ throw new SolanaJsonRpcError(message.error);
2939
+ } else {
2940
+ subscriptionId = message.result;
2941
+ break;
2942
+ }
2943
+ }
2944
+ }
2945
+ if (subscriptionId == null) {
2946
+ throw new Error("Failed to obtain a subscription id from the server");
2947
+ }
2948
+ return {
2949
+ async *[Symbol.asyncIterator]() {
2950
+ for await (const message of connection) {
2951
+ if (!("params" in message) || message.params.subscription !== subscriptionId) {
2952
+ continue;
2953
+ }
2954
+ const notification = message.params.result;
2955
+ yield responseProcessor ? responseProcessor(notification) : notification;
2956
+ }
2957
+ }
2958
+ };
2959
+ }
2960
+ };
2961
+ }
2962
+ function makeProxy2(rpcConfig) {
2963
+ return new Proxy(rpcConfig.api, {
2964
+ defineProperty() {
2965
+ return false;
2966
+ },
2967
+ deleteProperty() {
2968
+ return false;
2969
+ },
2970
+ get(target, p, receiver) {
2971
+ return function(...rawParams) {
2972
+ const methodName = p.toString();
2973
+ const createRpcSubscription = Reflect.get(target, methodName, receiver);
2974
+ if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
2975
+ throw new Error(
2976
+ "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."
2977
+ );
2978
+ }
2979
+ const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
2980
+ params: rawParams,
2981
+ subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
2982
+ unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
2983
+ };
2984
+ return createPendingRpcSubscription(rpcConfig, newRequest);
2985
+ };
2986
+ }
2987
+ });
2988
+ }
2989
+ function createJsonSubscriptionRpc(rpcConfig) {
2990
+ return makeProxy2(rpcConfig);
2991
+ }
2992
+ var e2 = globalThis.fetch;
454
2993
  var SolanaHttpError = class extends Error {
455
2994
  constructor(details) {
456
2995
  super(`HTTP error (${details.statusCode}): ${details.message}`);
@@ -538,7 +3077,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
538
3077
  method: "POST",
539
3078
  signal
540
3079
  };
541
- const response = await e(url, requestInfo);
3080
+ const response = await e2(url, requestInfo);
542
3081
  if (!response.ok) {
543
3082
  throw new SolanaHttpError({
544
3083
  message: response.statusText,
@@ -548,6 +3087,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
548
3087
  return await response.json();
549
3088
  };
550
3089
  }
3090
+ var e22 = globalThis.WebSocket;
3091
+ var EXPLICIT_ABORT_TOKEN = Symbol(
3092
+ "This symbol is thrown from a socket's iterator when the connection is explicity aborted by the user"
3093
+ );
3094
+ async function createWebSocketConnection({
3095
+ sendBufferHighWatermark,
3096
+ signal,
3097
+ url
3098
+ }) {
3099
+ return new Promise((resolve, reject) => {
3100
+ signal.addEventListener("abort", handleAbort, { once: true });
3101
+ const iteratorState = /* @__PURE__ */ new Map();
3102
+ function errorAndClearAllIteratorStates(reason) {
3103
+ const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
3104
+ iteratorState.clear();
3105
+ errorCallbacks.forEach((cb) => {
3106
+ try {
3107
+ cb(reason);
3108
+ } catch {
3109
+ }
3110
+ });
3111
+ }
3112
+ function handleAbort() {
3113
+ errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
3114
+ if (webSocket.readyState !== e22.CLOSED && webSocket.readyState !== e22.CLOSING) {
3115
+ webSocket.close(1e3);
3116
+ }
3117
+ }
3118
+ function handleClose(ev) {
3119
+ bufferDrainWatcher?.onCancel();
3120
+ signal.removeEventListener("abort", handleAbort);
3121
+ webSocket.removeEventListener("close", handleClose);
3122
+ webSocket.removeEventListener("error", handleError);
3123
+ webSocket.removeEventListener("open", handleOpen);
3124
+ webSocket.removeEventListener("message", handleMessage);
3125
+ errorAndClearAllIteratorStates(ev);
3126
+ }
3127
+ function handleError(ev) {
3128
+ if (!hasConnected) {
3129
+ reject(
3130
+ // TODO: Coded error
3131
+ new Error("WebSocket failed to connect", { cause: ev })
3132
+ );
3133
+ }
3134
+ }
3135
+ let hasConnected = false;
3136
+ let bufferDrainWatcher;
3137
+ function handleOpen() {
3138
+ hasConnected = true;
3139
+ resolve({
3140
+ async send(payload) {
3141
+ const message = JSON.stringify(payload);
3142
+ if (!bufferDrainWatcher && webSocket.readyState === e22.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
3143
+ let onCancel;
3144
+ const promise = new Promise((resolve2, reject2) => {
3145
+ const intervalId = setInterval(() => {
3146
+ if (webSocket.readyState !== e22.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
3147
+ clearInterval(intervalId);
3148
+ bufferDrainWatcher = void 0;
3149
+ resolve2();
3150
+ }
3151
+ }, 16);
3152
+ onCancel = () => {
3153
+ bufferDrainWatcher = void 0;
3154
+ clearInterval(intervalId);
3155
+ reject2(
3156
+ // TODO: Coded error
3157
+ new Error("WebSocket was closed before payload could be sent")
3158
+ );
3159
+ };
3160
+ });
3161
+ bufferDrainWatcher = {
3162
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3163
+ // @ts-ignore
3164
+ onCancel,
3165
+ promise
3166
+ };
3167
+ }
3168
+ if (bufferDrainWatcher) {
3169
+ await bufferDrainWatcher.promise;
3170
+ }
3171
+ webSocket.send(message);
3172
+ },
3173
+ async *[Symbol.asyncIterator]() {
3174
+ const iteratorKey = Symbol();
3175
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
3176
+ try {
3177
+ while (true) {
3178
+ const state = iteratorState.get(iteratorKey);
3179
+ if (!state) {
3180
+ throw new Error("Invariant: WebSocket message iterator is missing state storage");
3181
+ }
3182
+ if (state.__hasPolled) {
3183
+ throw new Error(
3184
+ "Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
3185
+ );
3186
+ }
3187
+ const queuedMessages = state.queuedMessages;
3188
+ if (queuedMessages.length) {
3189
+ state.queuedMessages = [];
3190
+ yield* queuedMessages;
3191
+ } else {
3192
+ try {
3193
+ yield await new Promise((resolve2, reject2) => {
3194
+ iteratorState.set(iteratorKey, {
3195
+ __hasPolled: true,
3196
+ onError: reject2,
3197
+ onMessage: resolve2
3198
+ });
3199
+ });
3200
+ } catch (e3) {
3201
+ if (e3 === EXPLICIT_ABORT_TOKEN) {
3202
+ return;
3203
+ } else {
3204
+ throw new Error("WebSocket connection closed", { cause: e3 });
3205
+ }
3206
+ }
3207
+ }
3208
+ }
3209
+ } finally {
3210
+ iteratorState.delete(iteratorKey);
3211
+ }
3212
+ }
3213
+ });
3214
+ }
3215
+ function handleMessage({ data }) {
3216
+ const message = JSON.parse(data);
3217
+ iteratorState.forEach((state, iteratorKey) => {
3218
+ if (state.__hasPolled) {
3219
+ const { onMessage } = state;
3220
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
3221
+ onMessage(message);
3222
+ } else {
3223
+ state.queuedMessages.push(message);
3224
+ }
3225
+ });
3226
+ }
3227
+ const webSocket = new e22(url);
3228
+ webSocket.addEventListener("close", handleClose);
3229
+ webSocket.addEventListener("error", handleError);
3230
+ webSocket.addEventListener("open", handleOpen);
3231
+ webSocket.addEventListener("message", handleMessage);
3232
+ });
3233
+ }
3234
+ function createWebSocketTransport({ sendBufferHighWatermark, url }) {
3235
+ if (/^wss?:/i.test(url) === false) {
3236
+ const protocolMatch = url.match(/^([^:]+):/);
3237
+ throw new DOMException(
3238
+ 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.`
3239
+ );
3240
+ }
3241
+ return async function sendWebSocketMessage({ payload, signal }) {
3242
+ signal?.throwIfAborted();
3243
+ const connection = await createWebSocketConnection({
3244
+ sendBufferHighWatermark,
3245
+ signal,
3246
+ url
3247
+ });
3248
+ signal?.throwIfAborted();
3249
+ await connection.send(payload);
3250
+ return {
3251
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
3252
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
3253
+ };
3254
+ };
3255
+ }
3256
+
3257
+ // src/rpc.ts
3258
+ var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
551
3259
 
552
3260
  // src/rpc-default-config.ts
553
3261
  init_env_shim();
@@ -589,6 +3297,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
589
3297
  }
590
3298
  };
591
3299
 
3300
+ // src/rpc-subscription-coalescer.ts
3301
+ init_env_shim();
3302
+
3303
+ // src/cached-abortable-iterable.ts
3304
+ init_env_shim();
3305
+ function registerIterableCleanup2(iterable, cleanupFn) {
3306
+ (async () => {
3307
+ try {
3308
+ for await (const _ of iterable)
3309
+ ;
3310
+ } catch {
3311
+ } finally {
3312
+ cleanupFn();
3313
+ }
3314
+ })();
3315
+ }
3316
+ function getCachedAbortableIterableFactory({
3317
+ getAbortSignalFromInputArgs,
3318
+ getCacheEntryMissingError,
3319
+ getCacheKeyFromInputArgs,
3320
+ onCacheHit,
3321
+ onCreateIterable
3322
+ }) {
3323
+ const cache = /* @__PURE__ */ new Map();
3324
+ function getCacheEntryOrThrow(cacheKey) {
3325
+ const currentCacheEntry = cache.get(cacheKey);
3326
+ if (!currentCacheEntry) {
3327
+ throw getCacheEntryMissingError(cacheKey);
3328
+ }
3329
+ return currentCacheEntry;
3330
+ }
3331
+ return async (...args) => {
3332
+ const cacheKey = getCacheKeyFromInputArgs(...args);
3333
+ const signal = getAbortSignalFromInputArgs(...args);
3334
+ if (cacheKey === void 0) {
3335
+ return await onCreateIterable(signal, ...args);
3336
+ }
3337
+ const cleanup = () => {
3338
+ cache.delete(cacheKey);
3339
+ signal.removeEventListener("abort", handleAbort);
3340
+ };
3341
+ const handleAbort = () => {
3342
+ const cacheEntry = getCacheEntryOrThrow(cacheKey);
3343
+ if (cacheEntry.purgeScheduled !== true) {
3344
+ cacheEntry.purgeScheduled = true;
3345
+ globalThis.queueMicrotask(() => {
3346
+ cacheEntry.purgeScheduled = false;
3347
+ if (cacheEntry.referenceCount === 0) {
3348
+ cacheEntry.abortController.abort();
3349
+ cleanup();
3350
+ }
3351
+ });
3352
+ }
3353
+ cacheEntry.referenceCount--;
3354
+ };
3355
+ signal.addEventListener("abort", handleAbort);
3356
+ try {
3357
+ const cacheEntry = cache.get(cacheKey);
3358
+ if (!cacheEntry) {
3359
+ const singletonAbortController = new AbortController();
3360
+ const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
3361
+ const newCacheEntry = {
3362
+ abortController: singletonAbortController,
3363
+ iterable: newIterablePromise,
3364
+ purgeScheduled: false,
3365
+ referenceCount: 1
3366
+ };
3367
+ cache.set(cacheKey, newCacheEntry);
3368
+ const newIterable = await newIterablePromise;
3369
+ registerIterableCleanup2(newIterable, cleanup);
3370
+ newCacheEntry.iterable = newIterable;
3371
+ return newIterable;
3372
+ } else {
3373
+ cacheEntry.referenceCount++;
3374
+ const iterableOrIterablePromise = cacheEntry.iterable;
3375
+ const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
3376
+ await onCacheHit(cachedIterable, ...args);
3377
+ return cachedIterable;
3378
+ }
3379
+ } catch (e3) {
3380
+ cleanup();
3381
+ throw e3;
3382
+ }
3383
+ };
3384
+ }
3385
+
3386
+ // src/rpc-subscription-coalescer.ts
3387
+ var EXPLICIT_ABORT_TOKEN2 = Symbol(
3388
+ "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
3389
+ );
3390
+ function registerIterableCleanup3(iterable, cleanupFn) {
3391
+ (async () => {
3392
+ try {
3393
+ for await (const _ of iterable)
3394
+ ;
3395
+ } catch {
3396
+ } finally {
3397
+ cleanupFn();
3398
+ }
3399
+ })();
3400
+ }
3401
+ function getRpcSubscriptionsWithSubscriptionCoalescing({
3402
+ getDeduplicationKey,
3403
+ rpcSubscriptions
3404
+ }) {
3405
+ const cache = /* @__PURE__ */ new Map();
3406
+ return new Proxy(rpcSubscriptions, {
3407
+ defineProperty() {
3408
+ return false;
3409
+ },
3410
+ deleteProperty() {
3411
+ return false;
3412
+ },
3413
+ get(target, p, receiver) {
3414
+ const subscriptionMethod = Reflect.get(target, p, receiver);
3415
+ if (typeof subscriptionMethod !== "function") {
3416
+ return subscriptionMethod;
3417
+ }
3418
+ return function(...rawParams) {
3419
+ const deduplicationKey = getDeduplicationKey(p, rawParams);
3420
+ if (deduplicationKey === void 0) {
3421
+ return subscriptionMethod(...rawParams);
3422
+ }
3423
+ if (cache.has(deduplicationKey)) {
3424
+ return cache.get(deduplicationKey);
3425
+ }
3426
+ const iterableFactory = getCachedAbortableIterableFactory({
3427
+ getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
3428
+ getCacheEntryMissingError(deduplicationKey2) {
3429
+ return new Error(
3430
+ `Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
3431
+ );
3432
+ },
3433
+ getCacheKeyFromInputArgs: () => deduplicationKey,
3434
+ async onCacheHit(_iterable, _config) {
3435
+ },
3436
+ async onCreateIterable(abortSignal, config) {
3437
+ const pendingSubscription2 = subscriptionMethod(
3438
+ ...rawParams
3439
+ );
3440
+ const iterable = await pendingSubscription2.subscribe({
3441
+ ...config,
3442
+ abortSignal
3443
+ });
3444
+ registerIterableCleanup3(iterable, () => {
3445
+ cache.delete(deduplicationKey);
3446
+ });
3447
+ return iterable;
3448
+ }
3449
+ });
3450
+ const pendingSubscription = {
3451
+ async subscribe(...args) {
3452
+ const iterable = await iterableFactory(...args);
3453
+ const { abortSignal } = args[0];
3454
+ let abortPromise;
3455
+ return {
3456
+ ...iterable,
3457
+ async *[Symbol.asyncIterator]() {
3458
+ abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
3459
+ abortSignal.addEventListener("abort", () => {
3460
+ reject(EXPLICIT_ABORT_TOKEN2);
3461
+ });
3462
+ }));
3463
+ try {
3464
+ const iterator = iterable[Symbol.asyncIterator]();
3465
+ while (true) {
3466
+ const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
3467
+ if (iteratorResult.done) {
3468
+ return;
3469
+ } else {
3470
+ yield iteratorResult.value;
3471
+ }
3472
+ }
3473
+ } catch (e3) {
3474
+ if (e3 === EXPLICIT_ABORT_TOKEN2) {
3475
+ return;
3476
+ }
3477
+ cache.delete(deduplicationKey);
3478
+ throw e3;
3479
+ }
3480
+ }
3481
+ };
3482
+ }
3483
+ };
3484
+ cache.set(deduplicationKey, pendingSubscription);
3485
+ return pendingSubscription;
3486
+ };
3487
+ }
3488
+ });
3489
+ }
3490
+
592
3491
  // src/rpc.ts
593
3492
  function createSolanaRpc(config) {
594
3493
  return createJsonRpc({
@@ -596,6 +3495,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
596
3495
  api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
597
3496
  });
598
3497
  }
3498
+ function createSolanaRpcSubscriptions(config) {
3499
+ return pipe(
3500
+ createJsonSubscriptionRpc({
3501
+ ...config,
3502
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
3503
+ }),
3504
+ (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
3505
+ getDeduplicationKey: (...args) => (0, import_fast_stable_stringify.default)(args),
3506
+ rpcSubscriptions
3507
+ })
3508
+ );
3509
+ }
3510
+ function createSolanaRpcSubscriptions_UNSTABLE(config) {
3511
+ return createJsonSubscriptionRpc({
3512
+ ...config,
3513
+ api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
3514
+ });
3515
+ }
599
3516
 
600
3517
  // src/rpc-transport.ts
601
3518
  init_env_shim();
@@ -632,14 +3549,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
632
3549
  if (signal) {
633
3550
  const responsePromise = coalescedRequest.responsePromise;
634
3551
  return await new Promise((resolve, reject) => {
635
- const handleAbort = (e2) => {
3552
+ const handleAbort = (e3) => {
636
3553
  signal.removeEventListener("abort", handleAbort);
637
3554
  coalescedRequest.numConsumers -= 1;
638
3555
  if (coalescedRequest.numConsumers === 0) {
639
3556
  const abortController = coalescedRequest.abortController;
640
3557
  abortController.abort();
641
3558
  }
642
- const abortError = new DOMException(e2.target.reason, "AbortError");
3559
+ const abortError = new DOMException(e3.target.reason, "AbortError");
643
3560
  reject(abortError);
644
3561
  };
645
3562
  signal.addEventListener("abort", handleAbort);
@@ -655,14 +3572,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
655
3572
 
656
3573
  // src/rpc-request-deduplication.ts
657
3574
  init_env_shim();
658
- var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
659
- function getSolanaRpcPayloadDeduplicationKey(payload) {
3575
+ var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
3576
+ function isJsonRpcPayload(payload) {
660
3577
  if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
661
- return;
662
- }
663
- if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
664
- return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
3578
+ return false;
665
3579
  }
3580
+ return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
3581
+ }
3582
+ function getSolanaRpcPayloadDeduplicationKey(payload) {
3583
+ return isJsonRpcPayload(payload) ? (0, import_fast_stable_stringify2.default)([payload.method, payload.params]) : void 0;
666
3584
  }
667
3585
 
668
3586
  // src/rpc-transport.ts
@@ -674,7 +3592,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
674
3592
  return out;
675
3593
  }
676
3594
  function createDefaultRpcTransport(config) {
677
- return getRpcTransportWithRequestCoalescing(
3595
+ return pipe(
678
3596
  createHttpTransport({
679
3597
  ...config,
680
3598
  headers: {
@@ -685,22 +3603,391 @@ this.globalThis.solanaWeb3 = (function (exports) {
685
3603
  }
686
3604
  }
687
3605
  }),
688
- getSolanaRpcPayloadDeduplicationKey
3606
+ (transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
3607
+ );
3608
+ }
3609
+
3610
+ // src/rpc-websocket-transport.ts
3611
+ init_env_shim();
3612
+
3613
+ // src/rpc-websocket-autopinger.ts
3614
+ init_env_shim();
3615
+ var PING_PAYLOAD = {
3616
+ jsonrpc: "2.0",
3617
+ method: "ping"
3618
+ };
3619
+ function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
3620
+ const pingableConnections = /* @__PURE__ */ new Map();
3621
+ return async (...args) => {
3622
+ const connection = await transport(...args);
3623
+ let intervalId;
3624
+ function sendPing() {
3625
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
3626
+ }
3627
+ function restartPingTimer() {
3628
+ clearInterval(intervalId);
3629
+ intervalId = setInterval(sendPing, intervalMs);
3630
+ }
3631
+ if (pingableConnections.has(connection) === false) {
3632
+ pingableConnections.set(connection, {
3633
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
3634
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
3635
+ restartPingTimer();
3636
+ return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
3637
+ }
3638
+ });
3639
+ (async () => {
3640
+ try {
3641
+ for await (const _ of connection) {
3642
+ restartPingTimer();
3643
+ }
3644
+ } catch {
3645
+ } finally {
3646
+ pingableConnections.delete(connection);
3647
+ clearInterval(intervalId);
3648
+ if (handleOffline) {
3649
+ globalThis.window.removeEventListener("offline", handleOffline);
3650
+ }
3651
+ if (handleOnline) {
3652
+ globalThis.window.removeEventListener("online", handleOnline);
3653
+ }
3654
+ }
3655
+ })();
3656
+ if (globalThis.navigator.onLine) {
3657
+ restartPingTimer();
3658
+ }
3659
+ let handleOffline;
3660
+ let handleOnline;
3661
+ {
3662
+ handleOffline = () => {
3663
+ clearInterval(intervalId);
3664
+ };
3665
+ handleOnline = () => {
3666
+ sendPing();
3667
+ restartPingTimer();
3668
+ };
3669
+ globalThis.window.addEventListener("offline", handleOffline);
3670
+ globalThis.window.addEventListener("online", handleOnline);
3671
+ }
3672
+ }
3673
+ return pingableConnections.get(connection);
3674
+ };
3675
+ }
3676
+
3677
+ // src/rpc-websocket-connection-sharding.ts
3678
+ init_env_shim();
3679
+ var NULL_SHARD_CACHE_KEY = Symbol(
3680
+ "Cache key to use when there is no connection sharding strategy"
3681
+ );
3682
+ function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
3683
+ return getCachedAbortableIterableFactory({
3684
+ getAbortSignalFromInputArgs: ({ signal }) => signal,
3685
+ getCacheEntryMissingError(shardKey) {
3686
+ return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
3687
+ },
3688
+ getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
3689
+ onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
3690
+ onCreateIterable: (abortSignal, config) => transport({
3691
+ ...config,
3692
+ signal: abortSignal
3693
+ })
3694
+ });
3695
+ }
3696
+
3697
+ // src/rpc-websocket-transport.ts
3698
+ function createDefaultRpcSubscriptionsTransport(config) {
3699
+ const { getShard, intervalMs, ...rest } = config;
3700
+ return pipe(
3701
+ createWebSocketTransport({
3702
+ ...rest,
3703
+ sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
3704
+ 131072
3705
+ }),
3706
+ (transport) => getWebSocketTransportWithAutoping({
3707
+ intervalMs: intervalMs ?? 5e3,
3708
+ transport
3709
+ }),
3710
+ (transport) => getWebSocketTransportWithConnectionSharding({
3711
+ getShard,
3712
+ transport
3713
+ })
3714
+ );
3715
+ }
3716
+
3717
+ // src/transaction-confirmation.ts
3718
+ init_env_shim();
3719
+
3720
+ // src/transaction-confirmation-strategy-blockheight.ts
3721
+ init_env_shim();
3722
+ function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
3723
+ return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
3724
+ const abortController = new AbortController();
3725
+ function handleAbort() {
3726
+ abortController.abort();
3727
+ }
3728
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3729
+ const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
3730
+ try {
3731
+ for await (const slotNotification of slotNotifications) {
3732
+ if (slotNotification.slot > lastValidBlockHeight) {
3733
+ throw new Error(
3734
+ "The network has progressed past the last block for which this transaction could have committed."
3735
+ );
3736
+ }
3737
+ }
3738
+ } finally {
3739
+ abortController.abort();
3740
+ }
3741
+ };
3742
+ }
3743
+
3744
+ // src/transaction-confirmation-strategy-nonce.ts
3745
+ init_env_shim();
3746
+ var NONCE_VALUE_OFFSET = 4 + // version(u32)
3747
+ 4 + // state(u32)
3748
+ 32;
3749
+ function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
3750
+ return async function getNonceInvalidationPromise({
3751
+ abortSignal: callerAbortSignal,
3752
+ commitment,
3753
+ currentNonceValue,
3754
+ nonceAccountAddress
3755
+ }) {
3756
+ const abortController = new AbortController();
3757
+ function handleAbort() {
3758
+ abortController.abort();
3759
+ }
3760
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3761
+ const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
3762
+ function getNonceFromAccountData([base64EncodedBytes]) {
3763
+ const data = base64.serialize(base64EncodedBytes);
3764
+ const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
3765
+ return base58.deserialize(nonceValueBytes)[0];
3766
+ }
3767
+ const nonceAccountDidAdvancePromise = (async () => {
3768
+ for await (const accountNotification of accountNotifications) {
3769
+ const nonceValue = getNonceFromAccountData(accountNotification.value.data);
3770
+ if (nonceValue !== currentNonceValue) {
3771
+ throw new Error(
3772
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3773
+ );
3774
+ }
3775
+ }
3776
+ })();
3777
+ const nonceIsAlreadyInvalidPromise = (async () => {
3778
+ const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
3779
+ commitment,
3780
+ dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
3781
+ encoding: "base58"
3782
+ }).send({ abortSignal: abortController.signal });
3783
+ if (!nonceAccount) {
3784
+ throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
3785
+ }
3786
+ const nonceValue = (
3787
+ // This works because we asked for the exact slice of data representing the nonce
3788
+ // value, and furthermore asked for it in `base58` encoding.
3789
+ nonceAccount.data[0]
3790
+ );
3791
+ if (nonceValue !== currentNonceValue) {
3792
+ throw new Error(
3793
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3794
+ );
3795
+ } else {
3796
+ await new Promise(() => {
3797
+ });
3798
+ }
3799
+ })();
3800
+ try {
3801
+ return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
3802
+ } finally {
3803
+ abortController.abort();
3804
+ }
3805
+ };
3806
+ }
3807
+
3808
+ // src/transaction-confirmation-strategy-recent-signature.ts
3809
+ init_env_shim();
3810
+ function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
3811
+ return async function getRecentSignatureConfirmationPromise({
3812
+ abortSignal: callerAbortSignal,
3813
+ commitment,
3814
+ signature
3815
+ }) {
3816
+ const abortController = new AbortController();
3817
+ function handleAbort() {
3818
+ abortController.abort();
3819
+ }
3820
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3821
+ const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
3822
+ const signatureDidCommitPromise = (async () => {
3823
+ for await (const signatureStatusNotification of signatureStatusNotifications) {
3824
+ if (signatureStatusNotification.value.err) {
3825
+ throw new Error(`The transaction with signature \`${signature}\` failed.`, {
3826
+ cause: signatureStatusNotification.value.err
3827
+ });
3828
+ } else {
3829
+ return;
3830
+ }
3831
+ }
3832
+ })();
3833
+ const signatureStatusLookupPromise = (async () => {
3834
+ const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
3835
+ const signatureStatus = signatureStatusResults[0];
3836
+ if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
3837
+ return;
3838
+ } else {
3839
+ await new Promise(() => {
3840
+ });
3841
+ }
3842
+ })();
3843
+ try {
3844
+ return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
3845
+ } finally {
3846
+ abortController.abort();
3847
+ }
3848
+ };
3849
+ }
3850
+
3851
+ // src/transaction-confirmation.ts
3852
+ async function raceStrategies(config, getSpecificStrategiesForRace) {
3853
+ const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise, transaction } = config;
3854
+ callerAbortSignal.throwIfAborted();
3855
+ const signature = getSignatureFromTransaction(transaction);
3856
+ const abortController = new AbortController();
3857
+ function handleAbort() {
3858
+ abortController.abort();
3859
+ }
3860
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3861
+ try {
3862
+ const specificStrategies = getSpecificStrategiesForRace({
3863
+ ...config,
3864
+ abortSignal: abortController.signal
3865
+ });
3866
+ return await Promise.race([
3867
+ getRecentSignatureConfirmationPromise({
3868
+ abortSignal: abortController.signal,
3869
+ commitment,
3870
+ signature
3871
+ }),
3872
+ ...specificStrategies
3873
+ ]);
3874
+ } finally {
3875
+ abortController.abort();
3876
+ }
3877
+ }
3878
+ function createDefaultDurableNonceTransactionConfirmer({
3879
+ rpc,
3880
+ rpcSubscriptions
3881
+ }) {
3882
+ const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
3883
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3884
+ rpc,
3885
+ rpcSubscriptions
3886
+ );
3887
+ return async function confirmDurableNonceTransaction(config) {
3888
+ await waitForDurableNonceTransactionConfirmation({
3889
+ ...config,
3890
+ getNonceInvalidationPromise,
3891
+ getRecentSignatureConfirmationPromise
3892
+ });
3893
+ };
3894
+ }
3895
+ function createDefaultRecentTransactionConfirmer({
3896
+ rpc,
3897
+ rpcSubscriptions
3898
+ }) {
3899
+ const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
3900
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3901
+ rpc,
3902
+ rpcSubscriptions
3903
+ );
3904
+ return async function confirmRecentTransaction(config) {
3905
+ await waitForRecentTransactionConfirmation({
3906
+ ...config,
3907
+ getBlockHeightExceedencePromise,
3908
+ getRecentSignatureConfirmationPromise
3909
+ });
3910
+ };
3911
+ }
3912
+ async function waitForDurableNonceTransactionConfirmation(config) {
3913
+ await raceStrategies(
3914
+ config,
3915
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
3916
+ return [
3917
+ getNonceInvalidationPromise({
3918
+ abortSignal,
3919
+ commitment,
3920
+ currentNonceValue: transaction.lifetimeConstraint.nonce,
3921
+ nonceAccountAddress: transaction.instructions[0].accounts[0].address
3922
+ })
3923
+ ];
3924
+ }
3925
+ );
3926
+ }
3927
+ async function waitForRecentTransactionConfirmation(config) {
3928
+ await raceStrategies(
3929
+ config,
3930
+ function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
3931
+ return [
3932
+ getBlockHeightExceedencePromise({
3933
+ abortSignal,
3934
+ lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
3935
+ })
3936
+ ];
3937
+ }
689
3938
  );
690
3939
  }
691
3940
 
692
3941
  exports.AccountRole = AccountRole;
693
- exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
3942
+ exports.address = address;
3943
+ exports.appendTransactionInstruction = appendTransactionInstruction;
3944
+ exports.assertIsAddress = assertIsAddress;
3945
+ exports.assertIsBlockhash = assertIsBlockhash;
3946
+ exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
3947
+ exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
3948
+ exports.assertIsTransactionSignature = assertIsTransactionSignature;
3949
+ exports.createAddressWithSeed = createAddressWithSeed;
3950
+ exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
3951
+ exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
3952
+ exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
3953
+ exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
694
3954
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
3955
+ exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
3956
+ exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
695
3957
  exports.createSolanaRpc = createSolanaRpc;
3958
+ exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
3959
+ exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
3960
+ exports.createTransaction = createTransaction;
696
3961
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
697
3962
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
698
- exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
3963
+ exports.generateKeyPair = generateKeyPair;
3964
+ exports.getAddressCodec = getAddressCodec;
3965
+ exports.getAddressComparator = getAddressComparator;
3966
+ exports.getAddressDecoder = getAddressDecoder;
3967
+ exports.getAddressEncoder = getAddressEncoder;
3968
+ exports.getAddressFromPublicKey = getAddressFromPublicKey;
3969
+ exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
3970
+ exports.getProgramDerivedAddress = getProgramDerivedAddress;
3971
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
3972
+ exports.getTransactionEncoder = getTransactionEncoder;
3973
+ exports.isAddress = isAddress;
3974
+ exports.isProgramDerivedAddress = isProgramDerivedAddress;
699
3975
  exports.isSignerRole = isSignerRole;
3976
+ exports.isTransactionSignature = isTransactionSignature;
700
3977
  exports.isWritableRole = isWritableRole;
701
3978
  exports.mergeRoles = mergeRoles;
3979
+ exports.prependTransactionInstruction = prependTransactionInstruction;
3980
+ exports.setTransactionFeePayer = setTransactionFeePayer;
3981
+ exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
3982
+ exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
3983
+ exports.signBytes = signBytes;
3984
+ exports.signTransaction = signTransaction;
3985
+ exports.transactionSignature = transactionSignature;
702
3986
  exports.upgradeRoleToSigner = upgradeRoleToSigner;
703
3987
  exports.upgradeRoleToWritable = upgradeRoleToWritable;
3988
+ exports.verifySignature = verifySignature;
3989
+ exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
3990
+ exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
704
3991
 
705
3992
  return exports;
706
3993