@solana/web3.js 2.0.0-experimental.7e66ec4 → 2.0.0-experimental.819a6f7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -4
  3. package/dist/index.browser.cjs +546 -8
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.js +540 -11
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.development.js +2484 -698
  8. package/dist/index.development.js.map +1 -1
  9. package/dist/index.native.js +529 -11
  10. package/dist/index.native.js.map +1 -1
  11. package/dist/index.node.cjs +535 -8
  12. package/dist/index.node.cjs.map +1 -1
  13. package/dist/index.node.js +529 -13
  14. package/dist/index.node.js.map +1 -1
  15. package/dist/index.production.min.js +52 -30
  16. package/dist/types/cached-abortable-iterable.d.ts +11 -0
  17. package/dist/types/cached-abortable-iterable.d.ts.map +1 -0
  18. package/dist/types/index.d.ts +5 -0
  19. package/dist/types/index.d.ts.map +1 -1
  20. package/dist/types/rpc-request-deduplication.d.ts.map +1 -1
  21. package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
  22. package/dist/types/rpc-subscription-coalescer.d.ts.map +1 -0
  23. package/dist/types/rpc-transport.d.ts.map +1 -1
  24. package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
  25. package/dist/types/rpc-websocket-autopinger.d.ts.map +1 -0
  26. package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
  27. package/dist/types/rpc-websocket-connection-sharding.d.ts.map +1 -0
  28. package/dist/types/rpc-websocket-transport.d.ts +13 -0
  29. package/dist/types/rpc-websocket-transport.d.ts.map +1 -0
  30. package/dist/types/rpc.d.ts +5 -3
  31. package/dist/types/rpc.d.ts.map +1 -1
  32. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +10 -0
  33. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -0
  34. package/dist/types/transaction-confirmation-strategy-nonce.d.ts +15 -0
  35. package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +1 -0
  36. package/dist/types/transaction-confirmation-strategy-racer.d.ts +10 -0
  37. package/dist/types/transaction-confirmation-strategy-racer.d.ts.map +1 -0
  38. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +13 -0
  39. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +1 -0
  40. package/dist/types/transaction-confirmation.d.ts +37 -0
  41. package/dist/types/transaction-confirmation.d.ts.map +1 -0
  42. package/package.json +20 -17
@@ -125,19 +125,31 @@ this.globalThis.solanaWeb3 = (function (exports) {
125
125
  // ../addresses/dist/index.browser.js
126
126
  init_env_shim();
127
127
 
128
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
128
+ // ../codecs-core/dist/index.browser.js
129
129
  init_env_shim();
130
-
131
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
132
- init_env_shim();
133
-
134
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
135
- init_env_shim();
136
- var mergeBytes = (bytesArr) => {
137
- const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
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
+ }
134
+ }
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
+ }
140
+ }
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);
138
150
  const result = new Uint8Array(totalLength);
139
151
  let offset = 0;
140
- bytesArr.forEach((arr) => {
152
+ nonEmptyByteArrays.forEach((arr) => {
141
153
  result.set(arr, offset);
142
154
  offset += arr.length;
143
155
  });
@@ -150,100 +162,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
150
162
  paddedBytes.set(bytes2);
151
163
  return paddedBytes;
152
164
  };
153
- var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
154
-
155
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
156
- init_env_shim();
157
- var DeserializingEmptyBufferError = class extends Error {
158
- constructor(serializer) {
159
- super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
160
- __publicField(this, "name", "DeserializingEmptyBufferError");
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
+ );
161
171
  }
162
- };
163
- var NotEnoughBytesError = class extends Error {
164
- constructor(serializer, expected, actual) {
165
- super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
166
- __publicField(this, "name", "NotEnoughBytesError");
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
+ );
167
176
  }
168
- };
169
- var ExpectedFixedSizeSerializerError = class extends Error {
170
- constructor(message) {
171
- message ?? (message = "Expected a fixed-size serializer, got a variable-size one.");
172
- super(message);
173
- __publicField(this, "name", "ExpectedFixedSizeSerializerError");
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
+ );
174
181
  }
175
- };
176
-
177
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
178
- init_env_shim();
179
- function fixSerializer(serializer, fixedBytes, description) {
180
182
  return {
181
- description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
183
+ decode: decoder.decode,
184
+ description: description ?? encoder.description,
185
+ encode: encoder.encode,
186
+ fixedSize: encoder.fixedSize,
187
+ maxSize: encoder.maxSize
188
+ };
189
+ }
190
+ function fixCodecHelper(data, fixedBytes, description) {
191
+ return {
192
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
182
193
  fixedSize: fixedBytes,
183
- maxSize: fixedBytes,
184
- serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
185
- deserialize: (buffer, offset = 0) => {
186
- buffer = buffer.slice(offset, offset + fixedBytes);
187
- if (buffer.length < fixedBytes) {
188
- throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
194
+ maxSize: fixedBytes
195
+ };
196
+ }
197
+ function fixEncoder(encoder, fixedBytes, description) {
198
+ return {
199
+ ...fixCodecHelper(encoder, fixedBytes, description),
200
+ encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
201
+ };
202
+ }
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);
189
210
  }
190
- if (serializer.fixedSize !== null) {
191
- buffer = fixBytes(buffer, serializer.fixedSize);
211
+ if (decoder.fixedSize !== null) {
212
+ bytes2 = fixBytes(bytes2, decoder.fixedSize);
192
213
  }
193
- const [value] = serializer.deserialize(buffer, 0);
214
+ const [value] = decoder.decode(bytes2, 0);
194
215
  return [value, offset + fixedBytes];
195
216
  }
196
217
  };
197
218
  }
198
-
199
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
200
- init_env_shim();
201
- function mapSerializer(serializer, unmap, map) {
219
+ function mapEncoder(encoder, unmap) {
202
220
  return {
203
- description: serializer.description,
204
- fixedSize: serializer.fixedSize,
205
- maxSize: serializer.maxSize,
206
- serialize: (value) => serializer.serialize(unmap(value)),
207
- deserialize: (buffer, offset = 0) => {
208
- const [value, length] = serializer.deserialize(buffer, offset);
209
- return map ? [map(value, buffer, offset), length] : [value, length];
210
- }
221
+ description: encoder.description,
222
+ encode: (value) => encoder.encode(unmap(value)),
223
+ fixedSize: encoder.fixedSize,
224
+ maxSize: encoder.maxSize
211
225
  };
212
226
  }
213
227
 
214
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
215
- init_env_shim();
216
-
217
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
228
+ // ../codecs-strings/dist/index.browser.js
218
229
  init_env_shim();
219
230
 
220
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
231
+ // ../codecs-numbers/dist/index.browser.js
221
232
  init_env_shim();
222
- var InvalidBaseStringError = class extends Error {
223
- constructor(value, base, cause) {
224
- const message = `Expected a string of base ${base}, got [${value}].`;
225
- super(message);
226
- __publicField(this, "name", "InvalidBaseStringError");
227
- 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
+ );
228
238
  }
229
- };
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));
230
316
 
231
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
232
- var baseX = (alphabet) => {
233
- 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;
234
325
  const baseBigInt = BigInt(base);
235
326
  return {
236
327
  description: `base${base}`,
237
- fixedSize: null,
238
- maxSize: null,
239
- serialize(value) {
240
- if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
241
- throw new InvalidBaseStringError(value, base);
242
- }
328
+ encode(value) {
329
+ assertValidBaseString(alphabet4, value);
243
330
  if (value === "")
244
331
  return new Uint8Array();
245
332
  const chars = [...value];
246
- let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
333
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
247
334
  trailIndex = trailIndex === -1 ? chars.length : trailIndex;
248
335
  const leadingZeroes = Array(trailIndex).fill(0);
249
336
  if (trailIndex === chars.length)
@@ -252,7 +339,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
252
339
  let base10Number = 0n;
253
340
  let baseXPower = 1n;
254
341
  for (let i = tailChars.length - 1; i >= 0; i -= 1) {
255
- base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
342
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
256
343
  baseXPower *= baseBigInt;
257
344
  }
258
345
  const tailBytes = [];
@@ -262,394 +349,119 @@ this.globalThis.solanaWeb3 = (function (exports) {
262
349
  }
263
350
  return Uint8Array.from(leadingZeroes.concat(tailBytes));
264
351
  },
265
- deserialize(buffer, offset = 0) {
266
- 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)
267
363
  return ["", 0];
268
- const bytes2 = buffer.slice(offset);
269
364
  let trailIndex = bytes2.findIndex((n) => n !== 0);
270
365
  trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
271
- const leadingZeroes = alphabet[0].repeat(trailIndex);
366
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
272
367
  if (trailIndex === bytes2.length)
273
- return [leadingZeroes, buffer.length];
368
+ return [leadingZeroes, rawBytes.length];
274
369
  let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
275
370
  const tailChars = [];
276
371
  while (base10Number > 0n) {
277
- tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
372
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
278
373
  base10Number /= baseBigInt;
279
374
  }
280
- return [leadingZeroes + tailChars.join(""), buffer.length];
281
- }
375
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
376
+ },
377
+ description: `base${base}`,
378
+ fixedSize: null,
379
+ maxSize: null
282
380
  };
283
381
  };
284
-
285
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
286
- init_env_shim();
287
- var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
288
-
289
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
290
- init_env_shim();
382
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
383
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
384
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
291
385
  var removeNullCharacters = (value) => (
292
386
  // eslint-disable-next-line no-control-regex
293
387
  value.replace(/\u0000/g, "")
294
388
  );
295
-
296
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
297
- init_env_shim();
298
- var utf8 = {
299
- description: "utf8",
300
- fixedSize: null,
301
- maxSize: null,
302
- serialize(value) {
303
- return new TextEncoder().encode(value);
304
- },
305
- deserialize(buffer, offset = 0) {
306
- const value = new TextDecoder().decode(buffer.slice(offset));
307
- return [removeNullCharacters(value), buffer.length];
308
- }
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
+ };
309
399
  };
310
-
311
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
312
- init_env_shim();
313
-
314
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
315
- init_env_shim();
316
- var Endian;
317
- (function(Endian2) {
318
- Endian2["Little"] = "le";
319
- Endian2["Big"] = "be";
320
- })(Endian || (Endian = {}));
321
-
322
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
323
- init_env_shim();
324
- var NumberOutOfRangeError = class extends RangeError {
325
- constructor(serializer, min, max, actual) {
326
- super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
327
- __publicField(this, "name", "NumberOutOfRangeError");
328
- }
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
+ };
329
411
  };
330
-
331
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
332
- init_env_shim();
333
- function numberFactory(input) {
334
- let littleEndian;
335
- let defaultDescription = input.name;
336
- if (input.size > 1) {
337
- littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
338
- defaultDescription += littleEndian ? "(le)" : "(be)";
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);
339
421
  }
340
422
  return {
341
- description: input.options.description ?? defaultDescription,
342
- fixedSize: input.size,
343
- maxSize: input.size,
344
- serialize(value) {
345
- if (input.range) {
346
- assertRange(input.name, input.range[0], input.range[1], value);
347
- }
348
- const buffer = new ArrayBuffer(input.size);
349
- input.set(new DataView(buffer), value, littleEndian);
350
- return new Uint8Array(buffer);
423
+ description,
424
+ encode: (value) => {
425
+ const contentBytes = encoding.encode(value);
426
+ const lengthBytes = size.encode(contentBytes.length);
427
+ return mergeBytes([lengthBytes, contentBytes]);
351
428
  },
352
- deserialize(bytes2, offset = 0) {
353
- const slice = bytes2.slice(offset, offset + input.size);
354
- assertEnoughBytes("i8", slice, input.size);
355
- const view = toDataView(slice);
356
- return [input.get(view, littleEndian), offset + input.size];
357
- }
429
+ fixedSize: null,
430
+ maxSize: null
358
431
  };
359
- }
360
- var toArrayBuffer = (array2) => array2.buffer.slice(array2.byteOffset, array2.byteLength + array2.byteOffset);
361
- var toDataView = (array2) => new DataView(toArrayBuffer(array2));
362
- var assertRange = (serializer, min, max, value) => {
363
- if (value < min || value > max) {
364
- throw new NumberOutOfRangeError(serializer, min, max, value);
365
- }
366
432
  };
367
- var assertEnoughBytes = (serializer, bytes2, expected) => {
368
- if (bytes2.length === 0) {
369
- throw new DeserializingEmptyBufferError(serializer);
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 };
370
439
  }
371
- if (bytes2.length < expected) {
372
- throw new NotEnoughBytesError(serializer, expected, bytes2.length);
440
+ if (typeof size === "number") {
441
+ return fixDecoder(encoding, size, description);
373
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
458
+ };
374
459
  };
460
+ function getSizeDescription(size) {
461
+ return typeof size === "object" ? size.description : `${size}`;
462
+ }
375
463
 
376
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
377
- init_env_shim();
378
- var u8 = (options = {}) => numberFactory({
379
- name: "u8",
380
- size: 1,
381
- range: [0, Number("0xff")],
382
- set: (view, value) => view.setUint8(0, Number(value)),
383
- get: (view) => view.getUint8(0),
384
- options
385
- });
386
-
387
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
388
- init_env_shim();
389
- var u32 = (options = {}) => numberFactory({
390
- name: "u32",
391
- size: 4,
392
- range: [0, Number("0xffffffff")],
393
- set: (view, value, le) => view.setUint32(0, Number(value), le),
394
- get: (view, le) => view.getUint32(0, le),
395
- options
396
- });
397
-
398
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
399
- init_env_shim();
400
- var shortU16 = (options = {}) => ({
401
- description: options.description ?? "shortU16",
402
- fixedSize: null,
403
- maxSize: 3,
404
- serialize: (value) => {
405
- assertRange("shortU16", 0, 65535, value);
406
- const bytes2 = [0];
407
- for (let ii = 0; ; ii += 1) {
408
- const alignedValue = value >> ii * 7;
409
- if (alignedValue === 0) {
410
- break;
411
- }
412
- const nextSevenBits = 127 & alignedValue;
413
- bytes2[ii] = nextSevenBits;
414
- if (ii > 0) {
415
- bytes2[ii - 1] |= 128;
416
- }
417
- }
418
- return new Uint8Array(bytes2);
419
- },
420
- deserialize: (bytes2, offset = 0) => {
421
- let value = 0;
422
- let byteCount = 0;
423
- while (++byteCount) {
424
- const byteIndex = byteCount - 1;
425
- const currentByte = bytes2[offset + byteIndex];
426
- const nextSevenBits = 127 & currentByte;
427
- value |= nextSevenBits << byteIndex * 7;
428
- if ((currentByte & 128) === 0) {
429
- break;
430
- }
431
- }
432
- return [value, offset + byteCount];
433
- }
434
- });
435
-
436
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
437
- init_env_shim();
438
-
439
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
440
- init_env_shim();
441
- var InvalidNumberOfItemsError = class extends Error {
442
- constructor(serializer, expected, actual) {
443
- super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
444
- __publicField(this, "name", "InvalidNumberOfItemsError");
445
- }
446
- };
447
- var InvalidArrayLikeRemainderSizeError = class extends Error {
448
- constructor(remainderSize, itemSize) {
449
- 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.`);
450
- __publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
451
- }
452
- };
453
- var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
454
- constructor(size) {
455
- super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
456
- __publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
457
- }
458
- };
459
-
460
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
461
- init_env_shim();
462
-
463
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
464
- init_env_shim();
465
- function sumSerializerSizes(sizes) {
466
- return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
467
- }
468
-
469
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
470
- function getResolvedSize(size, childrenSizes, bytes2, offset) {
471
- if (typeof size === "number") {
472
- return [size, offset];
473
- }
474
- if (typeof size === "object") {
475
- return size.deserialize(bytes2, offset);
476
- }
477
- if (size === "remainder") {
478
- const childrenSize = sumSerializerSizes(childrenSizes);
479
- if (childrenSize === null) {
480
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
481
- }
482
- const remainder = bytes2.slice(offset).length;
483
- if (remainder % childrenSize !== 0) {
484
- throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
485
- }
486
- return [remainder / childrenSize, offset];
487
- }
488
- throw new UnrecognizedArrayLikeSerializerSizeError(size);
489
- }
490
- function getSizeDescription(size) {
491
- return typeof size === "object" ? size.description : `${size}`;
492
- }
493
- function getSizeFromChildren(size, childrenSizes) {
494
- if (typeof size !== "number")
495
- return null;
496
- if (size === 0)
497
- return 0;
498
- const childrenSize = sumSerializerSizes(childrenSizes);
499
- return childrenSize === null ? null : childrenSize * size;
500
- }
501
- function getSizePrefix(size, realSize) {
502
- return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
503
- }
504
-
505
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
506
- function array(item, options = {}) {
507
- const size = options.size ?? u32();
508
- if (size === "remainder" && item.fixedSize === null) {
509
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
510
- }
511
- return {
512
- description: options.description ?? `array(${item.description}; ${getSizeDescription(size)})`,
513
- fixedSize: getSizeFromChildren(size, [item.fixedSize]),
514
- maxSize: getSizeFromChildren(size, [item.maxSize]),
515
- serialize: (value) => {
516
- if (typeof size === "number" && value.length !== size) {
517
- throw new InvalidNumberOfItemsError("array", size, value.length);
518
- }
519
- return mergeBytes([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
520
- },
521
- deserialize: (bytes2, offset = 0) => {
522
- if (typeof size === "object" && bytes2.slice(offset).length === 0) {
523
- return [[], offset];
524
- }
525
- const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
526
- offset = newOffset;
527
- const values = [];
528
- for (let i = 0; i < resolvedSize; i += 1) {
529
- const [value, newOffset2] = item.deserialize(bytes2, offset);
530
- values.push(value);
531
- offset = newOffset2;
532
- }
533
- return [values, offset];
534
- }
535
- };
536
- }
537
-
538
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
539
- init_env_shim();
540
- function bytes(options = {}) {
541
- const size = options.size ?? "variable";
542
- const description = options.description ?? `bytes(${getSizeDescription(size)})`;
543
- const byteSerializer = {
544
- description,
545
- fixedSize: null,
546
- maxSize: null,
547
- serialize: (value) => new Uint8Array(value),
548
- deserialize: (bytes2, offset = 0) => {
549
- const slice = bytes2.slice(offset);
550
- return [slice, offset + slice.length];
551
- }
552
- };
553
- if (size === "variable") {
554
- return byteSerializer;
555
- }
556
- if (typeof size === "number") {
557
- return fixSerializer(byteSerializer, size, description);
558
- }
559
- return {
560
- description,
561
- fixedSize: null,
562
- maxSize: null,
563
- serialize: (value) => {
564
- const contentBytes = byteSerializer.serialize(value);
565
- const lengthBytes = size.serialize(contentBytes.length);
566
- return mergeBytes([lengthBytes, contentBytes]);
567
- },
568
- deserialize: (buffer, offset = 0) => {
569
- if (buffer.slice(offset).length === 0) {
570
- throw new DeserializingEmptyBufferError("bytes");
571
- }
572
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
573
- const length = Number(lengthBigInt);
574
- offset = lengthOffset;
575
- const contentBuffer = buffer.slice(offset, offset + length);
576
- if (contentBuffer.length < length) {
577
- throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
578
- }
579
- const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
580
- offset += contentOffset;
581
- return [value, offset];
582
- }
583
- };
584
- }
585
-
586
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
587
- init_env_shim();
588
- function string(options = {}) {
589
- const size = options.size ?? u32();
590
- const encoding = options.encoding ?? utf8;
591
- const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
592
- if (size === "variable") {
593
- return {
594
- ...encoding,
595
- description
596
- };
597
- }
598
- if (typeof size === "number") {
599
- return fixSerializer(encoding, size, description);
600
- }
601
- return {
602
- description,
603
- fixedSize: null,
604
- maxSize: null,
605
- serialize: (value) => {
606
- const contentBytes = encoding.serialize(value);
607
- const lengthBytes = size.serialize(contentBytes.length);
608
- return mergeBytes([lengthBytes, contentBytes]);
609
- },
610
- deserialize: (buffer, offset = 0) => {
611
- if (buffer.slice(offset).length === 0) {
612
- throw new DeserializingEmptyBufferError("string");
613
- }
614
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
615
- const length = Number(lengthBigInt);
616
- offset = lengthOffset;
617
- const contentBuffer = buffer.slice(offset, offset + length);
618
- if (contentBuffer.length < length) {
619
- throw new NotEnoughBytesError("string", length, contentBuffer.length);
620
- }
621
- const [value, contentOffset] = encoding.deserialize(contentBuffer);
622
- offset += contentOffset;
623
- return [value, offset];
624
- }
625
- };
626
- }
627
-
628
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
629
- init_env_shim();
630
- function struct(fields, options = {}) {
631
- const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
632
- return {
633
- description: options.description ?? `struct(${fieldDescriptions})`,
634
- fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
635
- maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
636
- serialize: (struct2) => {
637
- const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
638
- return mergeBytes(fieldBytes);
639
- },
640
- deserialize: (bytes2, offset = 0) => {
641
- const struct2 = {};
642
- fields.forEach(([key, serializer]) => {
643
- const [value, newOffset] = serializer.deserialize(bytes2, offset);
644
- offset = newOffset;
645
- struct2[key] = value;
646
- });
647
- return [struct2, offset];
648
- }
649
- };
650
- }
651
-
652
- // ../assertions/dist/index.browser.js
464
+ // ../assertions/dist/index.browser.js
653
465
  init_env_shim();
654
466
  function assertIsSecureContext() {
655
467
  if (!globalThis.isSecureContext) {
@@ -715,7 +527,37 @@ this.globalThis.solanaWeb3 = (function (exports) {
715
527
  throw new Error("No signature verification implementation could be found");
716
528
  }
717
529
  }
718
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
530
+
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) {
719
561
  try {
720
562
  if (
721
563
  // Lowest address (32 bytes of zeroes)
@@ -724,26 +566,44 @@ this.globalThis.solanaWeb3 = (function (exports) {
724
566
  ) {
725
567
  throw new Error("Expected input string to decode to a byte array of length 32.");
726
568
  }
727
- const bytes2 = base58.serialize(putativeBase58EncodedAddress);
569
+ const base58Encoder = getMemoizedBase58Encoder();
570
+ const bytes2 = base58Encoder.encode(putativeBase58EncodedAddress);
728
571
  const numBytes = bytes2.byteLength;
729
572
  if (numBytes !== 32) {
730
573
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
731
574
  }
732
- } catch (e2) {
575
+ } catch (e3) {
733
576
  throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
734
- cause: e2
577
+ cause: e3
735
578
  });
736
579
  }
737
580
  }
738
- function getBase58EncodedAddressCodec(config) {
739
- return string({
740
- description: config?.description ?? ("A 32-byte account address" ),
741
- encoding: base58,
742
- size: 32
743
- });
581
+ function address(putativeBase58EncodedAddress) {
582
+ assertIsAddress(putativeBase58EncodedAddress);
583
+ return putativeBase58EncodedAddress;
744
584
  }
745
- function getBase58EncodedAddressComparator() {
746
- return new Intl.Collator("en", {
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() {
606
+ return new Intl.Collator("en", {
747
607
  caseFirst: "lower",
748
608
  ignorePunctuation: false,
749
609
  localeMatcher: "best fit",
@@ -838,6 +698,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
838
698
  const y = decompressPointBytes(bytes2);
839
699
  return pointIsOnCurve(y, bytes2[31]);
840
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
+ }
841
716
  var MAX_SEED_LENGTH = 32;
842
717
  var MAX_SEEDS = 16;
843
718
  var PDA_MARKER_BYTES = [
@@ -866,7 +741,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
866
741
  ];
867
742
  var PointOnCurveError = class extends Error {
868
743
  };
869
- async function createProgramDerivedAddress({ programAddress, seeds }) {
744
+ async function createProgramDerivedAddress({
745
+ programAddress,
746
+ seeds
747
+ }) {
870
748
  await assertDigestCapabilityIsAvailable();
871
749
  if (seeds.length > MAX_SEEDS) {
872
750
  throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
@@ -880,8 +758,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
880
758
  acc.push(...bytes2);
881
759
  return acc;
882
760
  }, []);
883
- const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
884
- const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
761
+ const base58EncodedAddressCodec = getAddressCodec();
762
+ const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
885
763
  const addressBytesBuffer = await crypto.subtle.digest(
886
764
  "SHA-256",
887
765
  new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
@@ -890,36 +768,58 @@ this.globalThis.solanaWeb3 = (function (exports) {
890
768
  if (await compressedPointBytesAreOnCurve(addressBytes)) {
891
769
  throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
892
770
  }
893
- return base58EncodedAddressCodec.deserialize(addressBytes)[0];
771
+ return base58EncodedAddressCodec.decode(addressBytes)[0];
894
772
  }
895
- async function getProgramDerivedAddress({ programAddress, seeds }) {
773
+ async function getProgramDerivedAddress({
774
+ programAddress,
775
+ seeds
776
+ }) {
896
777
  let bumpSeed = 255;
897
778
  while (bumpSeed > 0) {
898
779
  try {
899
- return {
900
- bumpSeed,
901
- pda: await createProgramDerivedAddress({
902
- programAddress,
903
- seeds: [...seeds, new Uint8Array([bumpSeed])]
904
- })
905
- };
906
- } catch (e2) {
907
- if (e2 instanceof PointOnCurveError) {
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) {
908
787
  bumpSeed--;
909
788
  } else {
910
- throw e2;
789
+ throw e3;
911
790
  }
912
791
  }
913
792
  }
914
793
  throw new Error("Unable to find a viable program address bump seed");
915
794
  }
916
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
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) {
917
817
  await assertKeyExporterIsAvailable();
918
818
  if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
919
819
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
920
820
  }
921
821
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
922
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
822
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
923
823
  return base58EncodedAddress;
924
824
  }
925
825
 
@@ -960,34 +860,650 @@ this.globalThis.solanaWeb3 = (function (exports) {
960
860
  return role | IS_WRITABLE_BITMASK;
961
861
  }
962
862
 
963
- // ../keys/dist/index.browser.js
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
890
+ init_env_shim();
891
+
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
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
964
1469
  init_env_shim();
965
- async function generateKeyPair() {
966
- await assertKeyGenerationIsAvailable();
967
- const keyPair = await crypto.subtle.generateKey(
968
- /* algorithm */
969
- "Ed25519",
970
- // Native implementation status: https://github.com/WICG/webcrypto-secure-curves/issues/20
971
- /* extractable */
972
- false,
973
- // Prevents the bytes of the private key from being visible to JS.
974
- /* allowed uses */
975
- ["sign", "verify"]
976
- );
977
- return keyPair;
1470
+ function sumCodecSizes(sizes) {
1471
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
978
1472
  }
979
- async function signBytes(key, data) {
980
- await assertSigningCapabilityIsAvailable();
981
- const signedData = await crypto.subtle.sign("Ed25519", key, data);
982
- return new Uint8Array(signedData);
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
+ };
983
1480
  }
984
- async function verifySignature(key, signature, data) {
985
- await assertVerificationCapabilityIsAvailable();
986
- return await crypto.subtle.verify("Ed25519", key, signature, data);
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));
987
1506
  }
988
-
989
- // ../transactions/dist/index.browser.js
990
- init_env_shim();
991
1507
  function getUnsignedTransaction(transaction) {
992
1508
  if ("signatures" in transaction) {
993
1509
  const {
@@ -1014,9 +1530,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
1014
1530
  if (numBytes !== 32) {
1015
1531
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1016
1532
  }
1017
- } catch (e2) {
1533
+ } catch (e3) {
1018
1534
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
1019
- cause: e2
1535
+ cause: e3
1020
1536
  });
1021
1537
  }
1022
1538
  }
@@ -1146,8 +1662,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1146
1662
  Object.freeze(out);
1147
1663
  return out;
1148
1664
  }
1149
- function upsert(addressMap, address, update) {
1150
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole2.READONLY });
1665
+ function upsert(addressMap, address2, update) {
1666
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
1151
1667
  }
1152
1668
  var TYPE = Symbol("AddressMapTypeProperty");
1153
1669
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -1198,7 +1714,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1198
1714
  const shouldReplaceEntry = (
1199
1715
  // Consider using the new LOOKUP_TABLE if its address is different...
1200
1716
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
1201
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
1717
+ (addressComparator || (addressComparator = getAddressComparator()))(
1202
1718
  accountMeta.lookupTableAddress,
1203
1719
  entry.lookupTableAddress
1204
1720
  ) < 0
@@ -1306,14 +1822,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1306
1822
  if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
1307
1823
  return leftIsWritable ? -1 : 1;
1308
1824
  }
1309
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
1825
+ addressComparator || (addressComparator = getAddressComparator());
1310
1826
  if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
1311
1827
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
1312
1828
  } else {
1313
1829
  return addressComparator(leftAddress, rightAddress);
1314
1830
  }
1315
- }).map(([address, addressMeta]) => ({
1316
- address,
1831
+ }).map(([address2, addressMeta]) => ({
1832
+ address: address2,
1317
1833
  ...addressMeta
1318
1834
  }));
1319
1835
  return orderedAccounts;
@@ -1335,7 +1851,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1335
1851
  entry.readableIndices.push(account.addressIndex);
1336
1852
  }
1337
1853
  }
1338
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
1854
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
1339
1855
  lookupTableAddress,
1340
1856
  ...index[lookupTableAddress]
1341
1857
  }));
@@ -1376,7 +1892,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1376
1892
  return instructions.map(({ accounts, data, programAddress }) => {
1377
1893
  return {
1378
1894
  programAddressIndex: accountIndex[programAddress],
1379
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
1895
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
1380
1896
  ...data ? { data } : null
1381
1897
  };
1382
1898
  });
@@ -1390,7 +1906,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1390
1906
  function getCompiledStaticAccounts(orderedAccounts) {
1391
1907
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
1392
1908
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
1393
- return orderedStaticAccounts.map(({ address }) => address);
1909
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
1394
1910
  }
1395
1911
  function compileMessage(transaction) {
1396
1912
  const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
@@ -1404,12 +1920,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
1404
1920
  version: transaction.version
1405
1921
  };
1406
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
+ }
1407
1949
  function getAddressTableLookupCodec() {
1408
1950
  return struct(
1409
1951
  [
1410
1952
  [
1411
1953
  "lookupTableAddress",
1412
- getBase58EncodedAddressCodec(
1954
+ addressSerializerCompat(
1413
1955
  {
1414
1956
  description: "The address of the address lookup table account from which instruction addresses should be looked up"
1415
1957
  }
@@ -1439,37 +1981,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
1439
1981
  }
1440
1982
  );
1441
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" ;
1442
2001
  function getMessageHeaderCodec() {
1443
- return struct(
2002
+ return getStructCodec(
1444
2003
  [
1445
- [
1446
- "numSignerAccounts",
1447
- u8(
1448
- {
1449
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1450
- }
1451
- )
1452
- ],
1453
- [
1454
- "numReadonlySignerAccounts",
1455
- u8(
1456
- {
1457
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
1458
- }
1459
- )
1460
- ],
1461
- [
1462
- "numReadonlyNonSignerAccounts",
1463
- u8(
1464
- {
1465
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1466
- }
1467
- )
1468
- ]
2004
+ ["numSignerAccounts", getMemoizedU8CodecDescription(numSignerAccountsDescription)],
2005
+ ["numReadonlySignerAccounts", getMemoizedU8CodecDescription(numReadonlySignerAccountsDescription)],
2006
+ ["numReadonlyNonSignerAccounts", getMemoizedU8CodecDescription(numReadonlyNonSignerAccountsDescription)]
1469
2007
  ],
1470
2008
  {
1471
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1472
- }
2009
+ description: messageHeaderDescription
2010
+ }
1473
2011
  );
1474
2012
  }
1475
2013
  function getInstructionCodec() {
@@ -1526,24 +2064,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
1526
2064
  }
1527
2065
  );
1528
2066
  }
1529
- function getError(type, name) {
1530
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1531
- return new Error(
1532
- `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}`
1533
- );
1534
- }
1535
- function getUnimplementedDecoder(name) {
1536
- return () => {
1537
- throw getError("decoder", name);
1538
- };
1539
- }
1540
2067
  var VERSION_FLAG_MASK = 128;
1541
2068
  var BASE_CONFIG = {
1542
2069
  description: "A single byte that encodes the version of the transaction" ,
1543
2070
  fixedSize: null,
1544
2071
  maxSize: 1
1545
2072
  };
1546
- function deserialize(bytes3, offset = 0) {
2073
+ function decode(bytes3, offset = 0) {
1547
2074
  const firstByte = bytes3[offset];
1548
2075
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
1549
2076
  return ["legacy", offset];
@@ -1552,7 +2079,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1552
2079
  return [version, offset + 1];
1553
2080
  }
1554
2081
  }
1555
- function serialize(value) {
2082
+ function encode(value) {
1556
2083
  if (value === "legacy") {
1557
2084
  return new Uint8Array();
1558
2085
  }
@@ -1561,11 +2088,30 @@ this.globalThis.solanaWeb3 = (function (exports) {
1561
2088
  }
1562
2089
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1563
2090
  }
1564
- function getTransactionVersionCodec() {
2091
+ function getTransactionVersionDecoder() {
1565
2092
  return {
1566
2093
  ...BASE_CONFIG,
1567
- deserialize,
1568
- serialize
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);
1569
2115
  };
1570
2116
  }
1571
2117
  var BASE_CONFIG2 = {
@@ -1573,7 +2119,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1573
2119
  fixedSize: null,
1574
2120
  maxSize: null
1575
2121
  };
1576
- function serialize2(compiledMessage) {
2122
+ function serialize(compiledMessage) {
1577
2123
  if (compiledMessage.version === "legacy") {
1578
2124
  return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1579
2125
  } else {
@@ -1594,13 +2140,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1594
2140
  ).serialize(compiledMessage);
1595
2141
  }
1596
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
+ }
1597
2152
  function getPreludeStructSerializerTuple() {
1598
2153
  return [
1599
- ["version", getTransactionVersionCodec()],
1600
- ["header", getMessageHeaderCodec()],
2154
+ ["version", toSerializer(getTransactionVersionCodec())],
2155
+ ["header", toSerializer(getMessageHeaderCodec())],
1601
2156
  [
1602
2157
  "staticAccounts",
1603
- array(getBase58EncodedAddressCodec(), {
2158
+ array(toSerializer(getAddressCodec()), {
1604
2159
  description: "A compact-array of static account addresses belonging to this transaction" ,
1605
2160
  size: shortU16()
1606
2161
  })
@@ -1632,45 +2187,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1632
2187
  return {
1633
2188
  ...BASE_CONFIG2,
1634
2189
  deserialize: getUnimplementedDecoder("CompiledMessage"),
1635
- serialize: serialize2
1636
- };
1637
- }
1638
- async function getCompiledMessageSignature(message, secretKey) {
1639
- const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1640
- const signature = await signBytes(secretKey, wireMessageBytes);
1641
- return signature;
1642
- }
1643
- async function signTransaction(keyPair, transaction) {
1644
- const compiledMessage = compileMessage(transaction);
1645
- const [signerPublicKey, signature] = await Promise.all([
1646
- getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
1647
- getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1648
- ]);
1649
- const nextSignatures = {
1650
- ..."signatures" in transaction ? transaction.signatures : null,
1651
- ...{ [signerPublicKey]: signature }
1652
- };
1653
- const out = {
1654
- ...transaction,
1655
- signatures: nextSignatures
1656
- };
1657
- Object.freeze(out);
1658
- return out;
1659
- }
1660
- function getCompiledTransaction(transaction) {
1661
- const compiledMessage = compileMessage(transaction);
1662
- let signatures;
1663
- if ("signatures" in transaction) {
1664
- signatures = [];
1665
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1666
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1667
- }
1668
- } else {
1669
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1670
- }
1671
- return {
1672
- compiledMessage,
1673
- signatures
2190
+ serialize
1674
2191
  };
1675
2192
  }
1676
2193
  var BASE_CONFIG3 = {
@@ -1678,7 +2195,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1678
2195
  fixedSize: null,
1679
2196
  maxSize: null
1680
2197
  };
1681
- function serialize3(transaction) {
2198
+ function serialize2(transaction) {
1682
2199
  const compiledTransaction = getCompiledTransaction(transaction);
1683
2200
  return struct([
1684
2201
  [
@@ -1695,8 +2212,82 @@ this.globalThis.solanaWeb3 = (function (exports) {
1695
2212
  return {
1696
2213
  ...BASE_CONFIG3,
1697
2214
  deserialize: getUnimplementedDecoder("CompiledMessage"),
1698
- serialize: serialize3
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
1699
2284
  };
2285
+ Object.freeze(out);
2286
+ return out;
2287
+ }
2288
+ function transactionSignature(putativeTransactionSignature) {
2289
+ assertIsTransactionSignature(putativeTransactionSignature);
2290
+ return putativeTransactionSignature;
1700
2291
  }
1701
2292
  function getBase64EncodedWireTransaction(transaction) {
1702
2293
  const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
@@ -1708,8 +2299,34 @@ this.globalThis.solanaWeb3 = (function (exports) {
1708
2299
  // src/rpc.ts
1709
2300
  init_env_shim();
1710
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
+
1711
2308
  // ../rpc-core/dist/index.browser.js
1712
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
+ }
1713
2330
  function visitNode(value, keyPath, onIntegerOverflow) {
1714
2331
  if (Array.isArray(value)) {
1715
2332
  return value.map(
@@ -1736,88 +2353,393 @@ this.globalThis.solanaWeb3 = (function (exports) {
1736
2353
  return visitNode(params, [], onIntegerOverflow);
1737
2354
  }
1738
2355
  var KEYPATH_WILDCARD = {};
1739
- var ALLOWED_NUMERIC_KEYPATHS = {
1740
- getAccountInfo: [
1741
- // parsed AddressTableLookup account
1742
- ["value", "data", "parsed", "info", "lastExtendedSlotStartIndex"],
1743
- // parsed Config account
1744
- ["value", "data", "parsed", "info", "slashPenalty"],
1745
- ["value", "data", "parsed", "info", "warmupCooldownRate"],
1746
- // parsed Token/Token22 token account
1747
- ["value", "data", "parsed", "info", "tokenAmount", "decimals"],
1748
- ["value", "data", "parsed", "info", "tokenAmount", "uiAmount"],
1749
- ["value", "data", "parsed", "info", "rentExemptReserve", "decimals"],
1750
- ["value", "data", "parsed", "info", "delegatedAmount", "decimals"],
1751
- [
1752
- "value",
1753
- "data",
1754
- "parsed",
1755
- "info",
1756
- "extensions",
1757
- KEYPATH_WILDCARD,
1758
- "state",
1759
- "olderTransferFee",
1760
- "transferFeeBasisPoints"
1761
- ],
1762
- [
1763
- "value",
1764
- "data",
1765
- "parsed",
1766
- "info",
1767
- "extensions",
1768
- KEYPATH_WILDCARD,
1769
- "state",
1770
- "newerTransferFee",
1771
- "transferFeeBasisPoints"
1772
- ],
1773
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
1774
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"],
1775
- // parsed Token/Token22 mint account
1776
- ["value", "data", "parsed", "info", "decimals"],
1777
- // parsed Token/Token22 multisig account
1778
- ["value", "data", "parsed", "info", "numRequiredSigners"],
1779
- ["value", "data", "parsed", "info", "numValidSigners"],
1780
- // parsed Stake account
1781
- ["value", "data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
1782
- // parsed Sysvar rent account
1783
- ["value", "data", "parsed", "info", "exemptionThreshold"],
1784
- ["value", "data", "parsed", "info", "burnPercent"],
1785
- // parsed Vote account
1786
- ["value", "data", "parsed", "info", "commission"],
1787
- ["value", "data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
1788
- ],
1789
- getBlockTime: [[]],
1790
- getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
1791
- getInflationRate: [["foundation"], ["total"], ["validator"]],
1792
- getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
1793
- getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
1794
- getTokenLargestAccounts: [
1795
- ["value", KEYPATH_WILDCARD, "decimals"],
1796
- ["value", KEYPATH_WILDCARD, "uiAmount"]
1797
- ],
1798
- getTransaction: [
1799
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1800
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1801
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1802
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1803
- ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
1804
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
1805
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1806
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1807
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
1808
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
1809
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1810
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1811
- ["transaction", "message", "header", "numReadonlySignedAccounts"],
1812
- ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
1813
- ["transaction", "message", "header", "numRequiredSignatures"]
1814
- ],
1815
- getVersion: [["feature-set"]],
1816
- getVoteAccounts: [
1817
- ["current", KEYPATH_WILDCARD, "commission"],
1818
- ["delinquent", KEYPATH_WILDCARD, "commission"]
1819
- ]
1820
- };
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
+ }
1821
2743
  function getNextAllowedKeypaths(keyPaths, property) {
1822
2744
  return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
1823
2745
  }
@@ -1844,10 +2766,40 @@ this.globalThis.solanaWeb3 = (function (exports) {
1844
2766
  }
1845
2767
  }
1846
2768
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
1847
- 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;
1848
2774
  return visitNode2(rawResponse, allowedKeypaths ?? []);
1849
2775
  }
1850
- function createSolanaRpcApi(config) {
2776
+ function createSolanaRpcApi(config) {
2777
+ return new Proxy({}, {
2778
+ defineProperty() {
2779
+ return false;
2780
+ },
2781
+ deleteProperty() {
2782
+ return false;
2783
+ },
2784
+ get(...args) {
2785
+ const [_, p] = args;
2786
+ const methodName = p.toString();
2787
+ return function(...rawParams) {
2788
+ const handleIntegerOverflow = config?.onIntegerOverflow;
2789
+ const params = patchParamsForSolanaLabsRpc(
2790
+ rawParams,
2791
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
2792
+ );
2793
+ return {
2794
+ methodName,
2795
+ params,
2796
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
2797
+ };
2798
+ };
2799
+ }
2800
+ });
2801
+ }
2802
+ function createSolanaRpcSubscriptionsApi(config) {
1851
2803
  return new Proxy({}, {
1852
2804
  defineProperty() {
1853
2805
  return false;
@@ -1857,22 +2809,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
1857
2809
  },
1858
2810
  get(...args) {
1859
2811
  const [_, p] = args;
1860
- const methodName = p.toString();
2812
+ const notificationName = p.toString();
1861
2813
  return function(...rawParams) {
1862
2814
  const handleIntegerOverflow = config?.onIntegerOverflow;
1863
2815
  const params = patchParamsForSolanaLabsRpc(
1864
2816
  rawParams,
1865
- handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
2817
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
1866
2818
  );
1867
2819
  return {
1868
- methodName,
1869
2820
  params,
1870
- responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
2821
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
2822
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
2823
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
1871
2824
  };
1872
2825
  };
1873
2826
  }
1874
2827
  });
1875
2828
  }
2829
+ function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
2830
+ return createSolanaRpcSubscriptionsApi(config);
2831
+ }
1876
2832
 
1877
2833
  // ../rpc-transport/dist/index.browser.js
1878
2834
  init_env_shim();
@@ -1939,7 +2895,101 @@ this.globalThis.solanaWeb3 = (function (exports) {
1939
2895
  function createJsonRpc(rpcConfig) {
1940
2896
  return makeProxy(rpcConfig);
1941
2897
  }
1942
- 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;
1943
2993
  var SolanaHttpError = class extends Error {
1944
2994
  constructor(details) {
1945
2995
  super(`HTTP error (${details.statusCode}): ${details.message}`);
@@ -2027,7 +3077,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2027
3077
  method: "POST",
2028
3078
  signal
2029
3079
  };
2030
- const response = await e(url, requestInfo);
3080
+ const response = await e2(url, requestInfo);
2031
3081
  if (!response.ok) {
2032
3082
  throw new SolanaHttpError({
2033
3083
  message: response.statusText,
@@ -2037,6 +3087,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
2037
3087
  return await response.json();
2038
3088
  };
2039
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);
2040
3259
 
2041
3260
  // src/rpc-default-config.ts
2042
3261
  init_env_shim();
@@ -2078,6 +3297,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
2078
3297
  }
2079
3298
  };
2080
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
+
2081
3491
  // src/rpc.ts
2082
3492
  function createSolanaRpc(config) {
2083
3493
  return createJsonRpc({
@@ -2085,6 +3495,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
2085
3495
  api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
2086
3496
  });
2087
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
+ }
2088
3516
 
2089
3517
  // src/rpc-transport.ts
2090
3518
  init_env_shim();
@@ -2121,14 +3549,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
2121
3549
  if (signal) {
2122
3550
  const responsePromise = coalescedRequest.responsePromise;
2123
3551
  return await new Promise((resolve, reject) => {
2124
- const handleAbort = (e2) => {
3552
+ const handleAbort = (e3) => {
2125
3553
  signal.removeEventListener("abort", handleAbort);
2126
3554
  coalescedRequest.numConsumers -= 1;
2127
3555
  if (coalescedRequest.numConsumers === 0) {
2128
3556
  const abortController = coalescedRequest.abortController;
2129
3557
  abortController.abort();
2130
3558
  }
2131
- const abortError = new DOMException(e2.target.reason, "AbortError");
3559
+ const abortError = new DOMException(e3.target.reason, "AbortError");
2132
3560
  reject(abortError);
2133
3561
  };
2134
3562
  signal.addEventListener("abort", handleAbort);
@@ -2144,14 +3572,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
2144
3572
 
2145
3573
  // src/rpc-request-deduplication.ts
2146
3574
  init_env_shim();
2147
- var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
2148
- function getSolanaRpcPayloadDeduplicationKey(payload) {
3575
+ var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
3576
+ function isJsonRpcPayload(payload) {
2149
3577
  if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
2150
- return;
2151
- }
2152
- if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
2153
- return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
3578
+ return false;
2154
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;
2155
3584
  }
2156
3585
 
2157
3586
  // src/rpc-transport.ts
@@ -2163,7 +3592,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2163
3592
  return out;
2164
3593
  }
2165
3594
  function createDefaultRpcTransport(config) {
2166
- return getRpcTransportWithRequestCoalescing(
3595
+ return pipe(
2167
3596
  createHttpTransport({
2168
3597
  ...config,
2169
3598
  headers: {
@@ -2174,27 +3603,381 @@ this.globalThis.solanaWeb3 = (function (exports) {
2174
3603
  }
2175
3604
  }
2176
3605
  }),
2177
- 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-racer.ts
3809
+ init_env_shim();
3810
+ async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
3811
+ const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
3812
+ callerAbortSignal.throwIfAborted();
3813
+ const abortController = new AbortController();
3814
+ function handleAbort() {
3815
+ abortController.abort();
3816
+ }
3817
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3818
+ try {
3819
+ const specificStrategies = getSpecificStrategiesForRace({
3820
+ ...config,
3821
+ abortSignal: abortController.signal
3822
+ });
3823
+ return await Promise.race([
3824
+ getRecentSignatureConfirmationPromise({
3825
+ abortSignal: abortController.signal,
3826
+ commitment,
3827
+ signature
3828
+ }),
3829
+ ...specificStrategies
3830
+ ]);
3831
+ } finally {
3832
+ abortController.abort();
3833
+ }
3834
+ }
3835
+
3836
+ // src/transaction-confirmation-strategy-recent-signature.ts
3837
+ init_env_shim();
3838
+ function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
3839
+ return async function getRecentSignatureConfirmationPromise({
3840
+ abortSignal: callerAbortSignal,
3841
+ commitment,
3842
+ signature
3843
+ }) {
3844
+ const abortController = new AbortController();
3845
+ function handleAbort() {
3846
+ abortController.abort();
3847
+ }
3848
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3849
+ const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
3850
+ const signatureDidCommitPromise = (async () => {
3851
+ for await (const signatureStatusNotification of signatureStatusNotifications) {
3852
+ if (signatureStatusNotification.value.err) {
3853
+ throw new Error(`The transaction with signature \`${signature}\` failed.`, {
3854
+ cause: signatureStatusNotification.value.err
3855
+ });
3856
+ } else {
3857
+ return;
3858
+ }
3859
+ }
3860
+ })();
3861
+ const signatureStatusLookupPromise = (async () => {
3862
+ const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
3863
+ const signatureStatus = signatureStatusResults[0];
3864
+ if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
3865
+ return;
3866
+ } else {
3867
+ await new Promise(() => {
3868
+ });
3869
+ }
3870
+ })();
3871
+ try {
3872
+ return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
3873
+ } finally {
3874
+ abortController.abort();
3875
+ }
3876
+ };
3877
+ }
3878
+
3879
+ // src/transaction-confirmation.ts
3880
+ function createDefaultDurableNonceTransactionConfirmer({
3881
+ rpc,
3882
+ rpcSubscriptions
3883
+ }) {
3884
+ const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
3885
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3886
+ rpc,
3887
+ rpcSubscriptions
3888
+ );
3889
+ return async function confirmDurableNonceTransaction(config) {
3890
+ await waitForDurableNonceTransactionConfirmation({
3891
+ ...config,
3892
+ getNonceInvalidationPromise,
3893
+ getRecentSignatureConfirmationPromise
3894
+ });
3895
+ };
3896
+ }
3897
+ function createDefaultRecentTransactionConfirmer({
3898
+ rpc,
3899
+ rpcSubscriptions
3900
+ }) {
3901
+ const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
3902
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3903
+ rpc,
3904
+ rpcSubscriptions
3905
+ );
3906
+ return async function confirmRecentTransaction(config) {
3907
+ await waitForRecentTransactionConfirmation({
3908
+ ...config,
3909
+ getBlockHeightExceedencePromise,
3910
+ getRecentSignatureConfirmationPromise
3911
+ });
3912
+ };
3913
+ }
3914
+ async function waitForDurableNonceTransactionConfirmation(config) {
3915
+ await raceStrategies(
3916
+ getSignatureFromTransaction(config.transaction),
3917
+ config,
3918
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
3919
+ return [
3920
+ getNonceInvalidationPromise({
3921
+ abortSignal,
3922
+ commitment,
3923
+ currentNonceValue: transaction.lifetimeConstraint.nonce,
3924
+ nonceAccountAddress: transaction.instructions[0].accounts[0].address
3925
+ })
3926
+ ];
3927
+ }
3928
+ );
3929
+ }
3930
+ async function waitForRecentTransactionConfirmation(config) {
3931
+ await raceStrategies(
3932
+ getSignatureFromTransaction(config.transaction),
3933
+ config,
3934
+ function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
3935
+ return [
3936
+ getBlockHeightExceedencePromise({
3937
+ abortSignal,
3938
+ lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
3939
+ })
3940
+ ];
3941
+ }
2178
3942
  );
2179
3943
  }
2180
3944
 
2181
3945
  exports.AccountRole = AccountRole;
3946
+ exports.address = address;
2182
3947
  exports.appendTransactionInstruction = appendTransactionInstruction;
2183
- exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
3948
+ exports.assertIsAddress = assertIsAddress;
2184
3949
  exports.assertIsBlockhash = assertIsBlockhash;
2185
3950
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
3951
+ exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
3952
+ exports.assertIsTransactionSignature = assertIsTransactionSignature;
3953
+ exports.createAddressWithSeed = createAddressWithSeed;
3954
+ exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
3955
+ exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
3956
+ exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
3957
+ exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
2186
3958
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
3959
+ exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
3960
+ exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
2187
3961
  exports.createSolanaRpc = createSolanaRpc;
3962
+ exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
3963
+ exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
2188
3964
  exports.createTransaction = createTransaction;
2189
3965
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
2190
3966
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
2191
3967
  exports.generateKeyPair = generateKeyPair;
2192
- exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
2193
- exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
2194
- exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
3968
+ exports.getAddressCodec = getAddressCodec;
3969
+ exports.getAddressComparator = getAddressComparator;
3970
+ exports.getAddressDecoder = getAddressDecoder;
3971
+ exports.getAddressEncoder = getAddressEncoder;
3972
+ exports.getAddressFromPublicKey = getAddressFromPublicKey;
2195
3973
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
2196
3974
  exports.getProgramDerivedAddress = getProgramDerivedAddress;
3975
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
3976
+ exports.getTransactionEncoder = getTransactionEncoder;
3977
+ exports.isAddress = isAddress;
3978
+ exports.isProgramDerivedAddress = isProgramDerivedAddress;
2197
3979
  exports.isSignerRole = isSignerRole;
3980
+ exports.isTransactionSignature = isTransactionSignature;
2198
3981
  exports.isWritableRole = isWritableRole;
2199
3982
  exports.mergeRoles = mergeRoles;
2200
3983
  exports.prependTransactionInstruction = prependTransactionInstruction;
@@ -2203,9 +3986,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
2203
3986
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
2204
3987
  exports.signBytes = signBytes;
2205
3988
  exports.signTransaction = signTransaction;
3989
+ exports.transactionSignature = transactionSignature;
2206
3990
  exports.upgradeRoleToSigner = upgradeRoleToSigner;
2207
3991
  exports.upgradeRoleToWritable = upgradeRoleToWritable;
2208
3992
  exports.verifySignature = verifySignature;
3993
+ exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
3994
+ exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
2209
3995
 
2210
3996
  return exports;
2211
3997