@solana/web3.js 2.0.0-experimental.490159e → 2.0.0-experimental.4c1874d

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 (40) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1155 -43
  3. package/dist/index.browser.cjs +687 -13
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.js +671 -17
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.development.js +2288 -819
  8. package/dist/index.development.js.map +1 -1
  9. package/dist/index.native.js +671 -17
  10. package/dist/index.native.js.map +1 -1
  11. package/dist/index.node.cjs +687 -13
  12. package/dist/index.node.cjs.map +1 -1
  13. package/dist/index.node.js +671 -17
  14. package/dist/index.node.js.map +1 -1
  15. package/dist/index.production.min.js +80 -33
  16. package/dist/types/airdrop-confirmer.d.ts +20 -0
  17. package/dist/types/airdrop.d.ts +23 -0
  18. package/dist/types/cached-abortable-iterable.d.ts +11 -0
  19. package/dist/types/index.d.ts +7 -0
  20. package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
  21. package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
  22. package/dist/types/rpc-websocket-transport.d.ts +6 -0
  23. package/dist/types/rpc.d.ts +2 -1
  24. package/dist/types/send-transaction.d.ts +38 -0
  25. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +10 -0
  26. package/dist/types/transaction-confirmation-strategy-nonce.d.ts +15 -0
  27. package/dist/types/transaction-confirmation-strategy-racer.d.ts +14 -0
  28. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +13 -0
  29. package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
  30. package/dist/types/transaction-confirmation.d.ts +37 -0
  31. package/package.json +19 -16
  32. package/dist/types/index.d.ts.map +0 -1
  33. package/dist/types/rpc-default-config.d.ts.map +0 -1
  34. package/dist/types/rpc-integer-overflow-error.d.ts.map +0 -1
  35. package/dist/types/rpc-request-coalescer.d.ts.map +0 -1
  36. package/dist/types/rpc-request-deduplication.d.ts.map +0 -1
  37. package/dist/types/rpc-transport.d.ts.map +0 -1
  38. package/dist/types/rpc-websocket-autopinger.d.ts.map +0 -1
  39. package/dist/types/rpc-websocket-transport.d.ts.map +0 -1
  40. package/dist/types/rpc.d.ts.map +0 -1
@@ -125,125 +125,269 @@ 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.9/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.9/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.9/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, bytes, offset = 0) {
131
+ if (bytes.length - offset <= 0) {
132
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
133
+ }
134
+ }
135
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
136
+ const bytesLength = bytes.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
  });
144
156
  return result;
145
157
  };
146
- var padBytes = (bytes2, length) => {
147
- if (bytes2.length >= length)
148
- return bytes2;
158
+ var padBytes = (bytes, length) => {
159
+ if (bytes.length >= length)
160
+ return bytes;
149
161
  const paddedBytes = new Uint8Array(length).fill(0);
150
- paddedBytes.set(bytes2);
162
+ paddedBytes.set(bytes);
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.9/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 = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.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.9/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 != null ? 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 != null ? 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: (bytes, offset = 0) => {
207
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
208
+ if (offset > 0 || bytes.length > fixedBytes) {
209
+ bytes = bytes.slice(offset, offset + fixedBytes);
189
210
  }
190
- if (serializer.fixedSize !== null) {
191
- buffer = fixBytes(buffer, serializer.fixedSize);
211
+ if (decoder.fixedSize !== null) {
212
+ bytes = fixBytes(bytes, decoder.fixedSize);
192
213
  }
193
- const [value] = serializer.deserialize(buffer, 0);
214
+ const [value] = decoder.decode(bytes, 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.9/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
225
+ };
226
+ }
227
+ function mapDecoder(decoder, map) {
228
+ return {
229
+ decode: (bytes, offset = 0) => {
230
+ const [value, length] = decoder.decode(bytes, offset);
231
+ return [map(value, bytes, offset), length];
232
+ },
233
+ description: decoder.description,
234
+ fixedSize: decoder.fixedSize,
235
+ maxSize: decoder.maxSize
211
236
  };
212
237
  }
213
238
 
214
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/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.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
239
+ // ../codecs-strings/dist/index.browser.js
218
240
  init_env_shim();
219
241
 
220
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
242
+ // ../codecs-numbers/dist/index.browser.js
221
243
  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;
244
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
245
+ if (value < min || value > max) {
246
+ throw new Error(
247
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
248
+ );
228
249
  }
250
+ }
251
+ function sharedNumberFactory(input) {
252
+ var _a;
253
+ let littleEndian;
254
+ let defaultDescription = input.name;
255
+ if (input.size > 1) {
256
+ littleEndian = !("endian" in input.config) || input.config.endian === 0;
257
+ defaultDescription += littleEndian ? "(le)" : "(be)";
258
+ }
259
+ return {
260
+ description: (_a = input.config.description) != null ? _a : defaultDescription,
261
+ fixedSize: input.size,
262
+ littleEndian,
263
+ maxSize: input.size
264
+ };
265
+ }
266
+ function numberEncoderFactory(input) {
267
+ const codecData = sharedNumberFactory(input);
268
+ return {
269
+ description: codecData.description,
270
+ encode(value) {
271
+ if (input.range) {
272
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
273
+ }
274
+ const arrayBuffer = new ArrayBuffer(input.size);
275
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
276
+ return new Uint8Array(arrayBuffer);
277
+ },
278
+ fixedSize: codecData.fixedSize,
279
+ maxSize: codecData.maxSize
280
+ };
281
+ }
282
+ function numberDecoderFactory(input) {
283
+ const codecData = sharedNumberFactory(input);
284
+ return {
285
+ decode(bytes, offset = 0) {
286
+ assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
287
+ assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
288
+ const view = new DataView(toArrayBuffer(bytes, offset, input.size));
289
+ return [input.get(view, codecData.littleEndian), offset + input.size];
290
+ },
291
+ description: codecData.description,
292
+ fixedSize: codecData.fixedSize,
293
+ maxSize: codecData.maxSize
294
+ };
295
+ }
296
+ function toArrayBuffer(bytes, offset, length) {
297
+ const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
298
+ const bytesLength = length != null ? length : bytes.byteLength;
299
+ return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
300
+ }
301
+ var getShortU16Encoder = (config = {}) => {
302
+ var _a;
303
+ return {
304
+ description: (_a = config.description) != null ? _a : "shortU16",
305
+ encode: (value) => {
306
+ assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
307
+ const bytes = [0];
308
+ for (let ii = 0; ; ii += 1) {
309
+ const alignedValue = value >> ii * 7;
310
+ if (alignedValue === 0) {
311
+ break;
312
+ }
313
+ const nextSevenBits = 127 & alignedValue;
314
+ bytes[ii] = nextSevenBits;
315
+ if (ii > 0) {
316
+ bytes[ii - 1] |= 128;
317
+ }
318
+ }
319
+ return new Uint8Array(bytes);
320
+ },
321
+ fixedSize: null,
322
+ maxSize: 3
323
+ };
324
+ };
325
+ var getShortU16Decoder = (config = {}) => {
326
+ var _a;
327
+ return {
328
+ decode: (bytes, offset = 0) => {
329
+ let value = 0;
330
+ let byteCount = 0;
331
+ while (++byteCount) {
332
+ const byteIndex = byteCount - 1;
333
+ const currentByte = bytes[offset + byteIndex];
334
+ const nextSevenBits = 127 & currentByte;
335
+ value |= nextSevenBits << byteIndex * 7;
336
+ if ((currentByte & 128) === 0) {
337
+ break;
338
+ }
339
+ }
340
+ return [value, offset + byteCount];
341
+ },
342
+ description: (_a = config.description) != null ? _a : "shortU16",
343
+ fixedSize: null,
344
+ maxSize: 3
345
+ };
229
346
  };
347
+ var getU32Encoder = (config = {}) => numberEncoderFactory({
348
+ config,
349
+ name: "u32",
350
+ range: [0, Number("0xffffffff")],
351
+ set: (view, value, le) => view.setUint32(0, value, le),
352
+ size: 4
353
+ });
354
+ var getU32Decoder = (config = {}) => numberDecoderFactory({
355
+ config,
356
+ get: (view, le) => view.getUint32(0, le),
357
+ name: "u32",
358
+ size: 4
359
+ });
360
+ var getU8Encoder = (config = {}) => numberEncoderFactory({
361
+ config,
362
+ name: "u8",
363
+ range: [0, Number("0xff")],
364
+ set: (view, value) => view.setUint8(0, value),
365
+ size: 1
366
+ });
367
+ var getU8Decoder = (config = {}) => numberDecoderFactory({
368
+ config,
369
+ get: (view) => view.getUint8(0),
370
+ name: "u8",
371
+ size: 1
372
+ });
230
373
 
231
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
232
- var baseX = (alphabet) => {
233
- const base = alphabet.length;
374
+ // ../codecs-strings/dist/index.browser.js
375
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
376
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
377
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
378
+ }
379
+ }
380
+ var getBaseXEncoder = (alphabet4) => {
381
+ const base = alphabet4.length;
234
382
  const baseBigInt = BigInt(base);
235
383
  return {
236
384
  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
- }
385
+ encode(value) {
386
+ assertValidBaseString(alphabet4, value);
243
387
  if (value === "")
244
388
  return new Uint8Array();
245
389
  const chars = [...value];
246
- let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
390
+ let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
247
391
  trailIndex = trailIndex === -1 ? chars.length : trailIndex;
248
392
  const leadingZeroes = Array(trailIndex).fill(0);
249
393
  if (trailIndex === chars.length)
@@ -252,7 +396,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
252
396
  let base10Number = 0n;
253
397
  let baseXPower = 1n;
254
398
  for (let i = tailChars.length - 1; i >= 0; i -= 1) {
255
- base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
399
+ base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
256
400
  baseXPower *= baseBigInt;
257
401
  }
258
402
  const tailBytes = [];
@@ -262,391 +406,149 @@ this.globalThis.solanaWeb3 = (function (exports) {
262
406
  }
263
407
  return Uint8Array.from(leadingZeroes.concat(tailBytes));
264
408
  },
265
- deserialize(buffer, offset = 0) {
266
- if (buffer.length === 0)
409
+ fixedSize: null,
410
+ maxSize: null
411
+ };
412
+ };
413
+ var getBaseXDecoder = (alphabet4) => {
414
+ const base = alphabet4.length;
415
+ const baseBigInt = BigInt(base);
416
+ return {
417
+ decode(rawBytes, offset = 0) {
418
+ const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
419
+ if (bytes.length === 0)
267
420
  return ["", 0];
268
- const bytes2 = buffer.slice(offset);
269
- let trailIndex = bytes2.findIndex((n) => n !== 0);
270
- trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
271
- const leadingZeroes = alphabet[0].repeat(trailIndex);
272
- if (trailIndex === bytes2.length)
273
- return [leadingZeroes, buffer.length];
274
- let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
421
+ let trailIndex = bytes.findIndex((n) => n !== 0);
422
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
423
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
424
+ if (trailIndex === bytes.length)
425
+ return [leadingZeroes, rawBytes.length];
426
+ let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
275
427
  const tailChars = [];
276
428
  while (base10Number > 0n) {
277
- tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
429
+ tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
278
430
  base10Number /= baseBigInt;
279
431
  }
280
- return [leadingZeroes + tailChars.join(""), buffer.length];
281
- }
432
+ return [leadingZeroes + tailChars.join(""), rawBytes.length];
433
+ },
434
+ description: `base${base}`,
435
+ fixedSize: null,
436
+ maxSize: null
282
437
  };
283
438
  };
284
-
285
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/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.9/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
290
- init_env_shim();
291
- var removeNullCharacters = (value) => (
292
- // eslint-disable-next-line no-control-regex
293
- value.replace(/\u0000/g, "")
294
- );
295
-
296
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.9/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];
439
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
440
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
441
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
442
+ var getBase64Encoder = () => {
443
+ {
444
+ return {
445
+ description: `base64`,
446
+ encode(value) {
447
+ try {
448
+ const bytes = atob(value).split("").map((c) => c.charCodeAt(0));
449
+ return new Uint8Array(bytes);
450
+ } catch (e23) {
451
+ throw new Error(`Expected a string of base 64, got [${value}].`);
452
+ }
453
+ },
454
+ fixedSize: null,
455
+ maxSize: null
456
+ };
308
457
  }
309
458
  };
310
-
311
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/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.9/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.9/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");
459
+ var getBase64Decoder = () => {
460
+ {
461
+ return {
462
+ decode(bytes, offset = 0) {
463
+ const slice = bytes.slice(offset);
464
+ const value = btoa(String.fromCharCode(...slice));
465
+ return [value, bytes.length];
466
+ },
467
+ description: `base64`,
468
+ fixedSize: null,
469
+ maxSize: null
470
+ };
328
471
  }
329
472
  };
330
-
331
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/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)";
339
- }
473
+ var removeNullCharacters = (value) => (
474
+ // eslint-disable-next-line no-control-regex
475
+ value.replace(/\u0000/g, "")
476
+ );
477
+ var e = globalThis.TextDecoder;
478
+ var o = globalThis.TextEncoder;
479
+ var getUtf8Encoder = () => {
480
+ let textEncoder;
340
481
  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);
351
- },
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
- }
482
+ description: "utf8",
483
+ encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
484
+ fixedSize: null,
485
+ maxSize: null
358
486
  };
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
- };
367
- var assertEnoughBytes = (serializer, bytes2, expected) => {
368
- if (bytes2.length === 0) {
369
- throw new DeserializingEmptyBufferError(serializer);
370
- }
371
- if (bytes2.length < expected) {
372
- throw new NotEnoughBytesError(serializer, expected, bytes2.length);
373
- }
374
- };
375
-
376
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.9/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.9/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.9/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.9/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.9/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
487
  };
459
-
460
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/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.9/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.9/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.9/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
- }
488
+ var getUtf8Decoder = () => {
489
+ let textDecoder;
511
490
  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))]);
491
+ decode(bytes, offset = 0) {
492
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
493
+ return [removeNullCharacters(value), bytes.length];
520
494
  },
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.9/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,
495
+ description: "utf8",
545
496
  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
- }
497
+ maxSize: null
552
498
  };
499
+ };
500
+ var getStringEncoder = (config = {}) => {
501
+ var _a, _b, _c;
502
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
503
+ const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
504
+ const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
553
505
  if (size === "variable") {
554
- return byteSerializer;
506
+ return { ...encoding, description };
555
507
  }
556
508
  if (typeof size === "number") {
557
- return fixSerializer(byteSerializer, size, description);
509
+ return fixEncoder(encoding, size, description);
558
510
  }
559
511
  return {
560
512
  description,
561
- fixedSize: null,
562
- maxSize: null,
563
- serialize: (value) => {
564
- const contentBytes = byteSerializer.serialize(value);
565
- const lengthBytes = size.serialize(contentBytes.length);
513
+ encode: (value) => {
514
+ const contentBytes = encoding.encode(value);
515
+ const lengthBytes = size.encode(contentBytes.length);
566
516
  return mergeBytes([lengthBytes, contentBytes]);
567
517
  },
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
- }
518
+ fixedSize: null,
519
+ maxSize: null
583
520
  };
584
- }
585
-
586
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/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)})`;
521
+ };
522
+ var getStringDecoder = (config = {}) => {
523
+ var _a, _b, _c;
524
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
525
+ const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
526
+ const description = (_c = config.description) != null ? _c : `string(${encoding.description}; ${getSizeDescription(size)})`;
592
527
  if (size === "variable") {
593
- return {
594
- ...encoding,
595
- description
596
- };
528
+ return { ...encoding, description };
597
529
  }
598
530
  if (typeof size === "number") {
599
- return fixSerializer(encoding, size, description);
531
+ return fixDecoder(encoding, size, description);
600
532
  }
601
533
  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);
534
+ decode: (bytes, offset = 0) => {
535
+ assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
536
+ const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
615
537
  const length = Number(lengthBigInt);
616
538
  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);
539
+ const contentBytes = bytes.slice(offset, offset + length);
540
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
541
+ const [value, contentOffset] = encoding.decode(contentBytes);
622
542
  offset += contentOffset;
623
543
  return [value, offset];
624
- }
625
- };
626
- }
627
-
628
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.9/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
544
  },
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
- }
545
+ description,
546
+ fixedSize: null,
547
+ maxSize: null
649
548
  };
549
+ };
550
+ function getSizeDescription(size) {
551
+ return typeof size === "object" ? size.description : `${size}`;
650
552
  }
651
553
 
652
554
  // ../assertions/dist/index.browser.js
@@ -681,14 +583,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
681
583
  }
682
584
  }
683
585
  async function assertDigestCapabilityIsAvailable() {
586
+ var _a;
684
587
  assertIsSecureContext();
685
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
588
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
686
589
  throw new Error("No digest implementation could be found");
687
590
  }
688
591
  }
689
592
  async function assertKeyGenerationIsAvailable() {
593
+ var _a;
690
594
  assertIsSecureContext();
691
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
595
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") {
692
596
  throw new Error("No key generation implementation could be found");
693
597
  }
694
598
  if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
@@ -698,51 +602,104 @@ this.globalThis.solanaWeb3 = (function (exports) {
698
602
  }
699
603
  }
700
604
  async function assertKeyExporterIsAvailable() {
605
+ var _a;
701
606
  assertIsSecureContext();
702
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") {
607
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
703
608
  throw new Error("No key export implementation could be found");
704
609
  }
705
610
  }
706
611
  async function assertSigningCapabilityIsAvailable() {
612
+ var _a;
707
613
  assertIsSecureContext();
708
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.sign !== "function") {
614
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
709
615
  throw new Error("No signing implementation could be found");
710
616
  }
711
617
  }
712
618
  async function assertVerificationCapabilityIsAvailable() {
619
+ var _a;
713
620
  assertIsSecureContext();
714
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.verify !== "function") {
621
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.verify) !== "function") {
715
622
  throw new Error("No signature verification implementation could be found");
716
623
  }
717
624
  }
718
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
625
+
626
+ // ../addresses/dist/index.browser.js
627
+ var memoizedBase58Encoder;
628
+ var memoizedBase58Decoder;
629
+ function getMemoizedBase58Encoder() {
630
+ if (!memoizedBase58Encoder)
631
+ memoizedBase58Encoder = getBase58Encoder();
632
+ return memoizedBase58Encoder;
633
+ }
634
+ function getMemoizedBase58Decoder() {
635
+ if (!memoizedBase58Decoder)
636
+ memoizedBase58Decoder = getBase58Decoder();
637
+ return memoizedBase58Decoder;
638
+ }
639
+ function isAddress(putativeAddress) {
640
+ if (
641
+ // Lowest address (32 bytes of zeroes)
642
+ putativeAddress.length < 32 || // Highest address (32 bytes of 255)
643
+ putativeAddress.length > 44
644
+ ) {
645
+ return false;
646
+ }
647
+ const base58Encoder3 = getMemoizedBase58Encoder();
648
+ const bytes = base58Encoder3.encode(putativeAddress);
649
+ const numBytes = bytes.byteLength;
650
+ if (numBytes !== 32) {
651
+ return false;
652
+ }
653
+ return true;
654
+ }
655
+ function assertIsAddress(putativeAddress) {
719
656
  try {
720
657
  if (
721
658
  // Lowest address (32 bytes of zeroes)
722
- putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
723
- putativeBase58EncodedAddress.length > 44
659
+ putativeAddress.length < 32 || // Highest address (32 bytes of 255)
660
+ putativeAddress.length > 44
724
661
  ) {
725
662
  throw new Error("Expected input string to decode to a byte array of length 32.");
726
663
  }
727
- const bytes2 = base58.serialize(putativeBase58EncodedAddress);
728
- const numBytes = bytes2.byteLength;
664
+ const base58Encoder3 = getMemoizedBase58Encoder();
665
+ const bytes = base58Encoder3.encode(putativeAddress);
666
+ const numBytes = bytes.byteLength;
729
667
  if (numBytes !== 32) {
730
668
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
731
669
  }
732
670
  } catch (e3) {
733
- throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
671
+ throw new Error(`\`${putativeAddress}\` is not a base-58 encoded address`, {
734
672
  cause: e3
735
673
  });
736
674
  }
737
675
  }
738
- function getBase58EncodedAddressCodec(config) {
739
- return string({
740
- description: config?.description ?? ("A 32-byte account address" ),
741
- encoding: base58,
676
+ function address(putativeAddress) {
677
+ assertIsAddress(putativeAddress);
678
+ return putativeAddress;
679
+ }
680
+ function getAddressEncoder(config) {
681
+ var _a;
682
+ return mapEncoder(
683
+ getStringEncoder({
684
+ description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
685
+ encoding: getMemoizedBase58Encoder(),
686
+ size: 32
687
+ }),
688
+ (putativeAddress) => address(putativeAddress)
689
+ );
690
+ }
691
+ function getAddressDecoder(config) {
692
+ var _a;
693
+ return getStringDecoder({
694
+ description: (_a = config == null ? void 0 : config.description) != null ? _a : "Address",
695
+ encoding: getMemoizedBase58Decoder(),
742
696
  size: 32
743
697
  });
744
698
  }
745
- function getBase58EncodedAddressComparator() {
699
+ function getAddressCodec(config) {
700
+ return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
701
+ }
702
+ function getAddressComparator() {
746
703
  return new Intl.Collator("en", {
747
704
  caseFirst: "lower",
748
705
  ignorePunctuation: false,
@@ -826,17 +783,32 @@ this.globalThis.solanaWeb3 = (function (exports) {
826
783
  return hexString;
827
784
  }
828
785
  }
829
- function decompressPointBytes(bytes2) {
830
- const hexString = bytes2.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
786
+ function decompressPointBytes(bytes) {
787
+ const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
831
788
  const integerLiteralString = `0x${hexString}`;
832
789
  return BigInt(integerLiteralString);
833
790
  }
834
- async function compressedPointBytesAreOnCurve(bytes2) {
835
- if (bytes2.byteLength !== 32) {
836
- return false;
791
+ async function compressedPointBytesAreOnCurve(bytes) {
792
+ if (bytes.byteLength !== 32) {
793
+ return false;
794
+ }
795
+ const y = decompressPointBytes(bytes);
796
+ return pointIsOnCurve(y, bytes[31]);
797
+ }
798
+ function isProgramDerivedAddress(value) {
799
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);
800
+ }
801
+ function assertIsProgramDerivedAddress(value) {
802
+ const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
803
+ if (!validFormat) {
804
+ throw new Error(
805
+ `Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].`
806
+ );
807
+ }
808
+ if (value[1] < 0 || value[1] > 255) {
809
+ throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
837
810
  }
838
- const y = decompressPointBytes(bytes2);
839
- return pointIsOnCurve(y, bytes2[31]);
811
+ assertIsAddress(value[0]);
840
812
  }
841
813
  var MAX_SEED_LENGTH = 32;
842
814
  var MAX_SEEDS = 16;
@@ -873,15 +845,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
873
845
  }
874
846
  let textEncoder;
875
847
  const seedBytes = seeds.reduce((acc, seed, ii) => {
876
- const bytes2 = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
877
- if (bytes2.byteLength > MAX_SEED_LENGTH) {
848
+ const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
849
+ if (bytes.byteLength > MAX_SEED_LENGTH) {
878
850
  throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
879
851
  }
880
- acc.push(...bytes2);
852
+ acc.push(...bytes);
881
853
  return acc;
882
854
  }, []);
883
- const base58EncodedAddressCodec = getBase58EncodedAddressCodec();
884
- const programAddressBytes = base58EncodedAddressCodec.serialize(programAddress);
855
+ const base58EncodedAddressCodec = getAddressCodec();
856
+ const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
885
857
  const addressBytesBuffer = await crypto.subtle.digest(
886
858
  "SHA-256",
887
859
  new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
@@ -890,19 +862,20 @@ this.globalThis.solanaWeb3 = (function (exports) {
890
862
  if (await compressedPointBytesAreOnCurve(addressBytes)) {
891
863
  throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
892
864
  }
893
- return base58EncodedAddressCodec.deserialize(addressBytes)[0];
865
+ return base58EncodedAddressCodec.decode(addressBytes)[0];
894
866
  }
895
- async function getProgramDerivedAddress({ programAddress, seeds }) {
867
+ async function getProgramDerivedAddress({
868
+ programAddress,
869
+ seeds
870
+ }) {
896
871
  let bumpSeed = 255;
897
872
  while (bumpSeed > 0) {
898
873
  try {
899
- return {
900
- bumpSeed,
901
- pda: await createProgramDerivedAddress({
902
- programAddress,
903
- seeds: [...seeds, new Uint8Array([bumpSeed])]
904
- })
905
- };
874
+ const address2 = await createProgramDerivedAddress({
875
+ programAddress,
876
+ seeds: [...seeds, new Uint8Array([bumpSeed])]
877
+ });
878
+ return [address2, bumpSeed];
906
879
  } catch (e3) {
907
880
  if (e3 instanceof PointOnCurveError) {
908
881
  bumpSeed--;
@@ -913,26 +886,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
913
886
  }
914
887
  throw new Error("Unable to find a viable program address bump seed");
915
888
  }
916
- async function createAddressWithSeed({
917
- baseAddress,
918
- programAddress,
919
- seed
920
- }) {
921
- const { serialize: serialize4, deserialize: deserialize2 } = getBase58EncodedAddressCodec();
889
+ async function createAddressWithSeed({ baseAddress, programAddress, seed }) {
890
+ const { encode: encode2, decode: decode2 } = getAddressCodec();
922
891
  const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
923
892
  if (seedBytes.byteLength > MAX_SEED_LENGTH) {
924
893
  throw new Error(`The seed exceeds the maximum length of 32 bytes`);
925
894
  }
926
- const programAddressBytes = serialize4(programAddress);
895
+ const programAddressBytes = encode2(programAddress);
927
896
  if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
928
897
  throw new Error(`programAddress cannot end with the PDA marker`);
929
898
  }
930
899
  const addressBytesBuffer = await crypto.subtle.digest(
931
900
  "SHA-256",
932
- new Uint8Array([...serialize4(baseAddress), ...seedBytes, ...programAddressBytes])
901
+ new Uint8Array([...encode2(baseAddress), ...seedBytes, ...programAddressBytes])
933
902
  );
934
903
  const addressBytes = new Uint8Array(addressBytesBuffer);
935
- return deserialize2(addressBytes)[0];
904
+ return decode2(addressBytes)[0];
936
905
  }
937
906
  async function getAddressFromPublicKey(publicKey) {
938
907
  await assertKeyExporterIsAvailable();
@@ -940,7 +909,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
940
909
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
941
910
  }
942
911
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
943
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
912
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
944
913
  return base58EncodedAddress;
945
914
  }
946
915
 
@@ -997,18 +966,344 @@ this.globalThis.solanaWeb3 = (function (exports) {
997
966
  );
998
967
  return keyPair;
999
968
  }
969
+ var base58Encoder;
970
+ function assertIsSignature(putativeSignature) {
971
+ if (!base58Encoder)
972
+ base58Encoder = getBase58Encoder();
973
+ try {
974
+ if (
975
+ // Lowest value (64 bytes of zeroes)
976
+ putativeSignature.length < 64 || // Highest value (64 bytes of 255)
977
+ putativeSignature.length > 88
978
+ ) {
979
+ throw new Error("Expected input string to decode to a byte array of length 64.");
980
+ }
981
+ const bytes = base58Encoder.encode(putativeSignature);
982
+ const numBytes = bytes.byteLength;
983
+ if (numBytes !== 64) {
984
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
985
+ }
986
+ } catch (e3) {
987
+ throw new Error(`\`${putativeSignature}\` is not a signature`, {
988
+ cause: e3
989
+ });
990
+ }
991
+ }
992
+ function isSignature(putativeSignature) {
993
+ if (!base58Encoder)
994
+ base58Encoder = getBase58Encoder();
995
+ if (
996
+ // Lowest value (64 bytes of zeroes)
997
+ putativeSignature.length < 64 || // Highest value (64 bytes of 255)
998
+ putativeSignature.length > 88
999
+ ) {
1000
+ return false;
1001
+ }
1002
+ const bytes = base58Encoder.encode(putativeSignature);
1003
+ const numBytes = bytes.byteLength;
1004
+ if (numBytes !== 64) {
1005
+ return false;
1006
+ }
1007
+ return true;
1008
+ }
1000
1009
  async function signBytes(key, data) {
1001
1010
  await assertSigningCapabilityIsAvailable();
1002
1011
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
1003
1012
  return new Uint8Array(signedData);
1004
1013
  }
1005
- async function verifySignature(key, signature, data) {
1014
+ function signature(putativeSignature) {
1015
+ assertIsSignature(putativeSignature);
1016
+ return putativeSignature;
1017
+ }
1018
+ async function verifySignature(key, signature2, data) {
1006
1019
  await assertVerificationCapabilityIsAvailable();
1007
- return await crypto.subtle.verify("Ed25519", key, signature, data);
1020
+ return await crypto.subtle.verify("Ed25519", key, signature2, data);
1021
+ }
1022
+
1023
+ // ../rpc-types/dist/index.browser.js
1024
+ init_env_shim();
1025
+ function getCommitmentScore(commitment) {
1026
+ switch (commitment) {
1027
+ case "finalized":
1028
+ return 2;
1029
+ case "confirmed":
1030
+ return 1;
1031
+ case "processed":
1032
+ return 0;
1033
+ default:
1034
+ return ((_) => {
1035
+ throw new Error(`Unrecognized commitment \`${commitment}\`.`);
1036
+ })();
1037
+ }
1038
+ }
1039
+ function commitmentComparator(a, b) {
1040
+ if (a === b) {
1041
+ return 0;
1042
+ }
1043
+ return getCommitmentScore(a) < getCommitmentScore(b) ? -1 : 1;
1044
+ }
1045
+ var maxU64Value = 18446744073709551615n;
1046
+ function isLamports(putativeLamports) {
1047
+ return putativeLamports >= 0 && putativeLamports <= maxU64Value;
1048
+ }
1049
+ function assertIsLamports(putativeLamports) {
1050
+ if (putativeLamports < 0) {
1051
+ throw new Error("Input for 64-bit unsigned integer cannot be negative");
1052
+ }
1053
+ if (putativeLamports > maxU64Value) {
1054
+ throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
1055
+ }
1056
+ }
1057
+ function lamports(putativeLamports) {
1058
+ assertIsLamports(putativeLamports);
1059
+ return putativeLamports;
1060
+ }
1061
+ function isStringifiedBigInt(putativeBigInt) {
1062
+ try {
1063
+ BigInt(putativeBigInt);
1064
+ return true;
1065
+ } catch (_) {
1066
+ return false;
1067
+ }
1068
+ }
1069
+ function assertIsStringifiedBigInt(putativeBigInt) {
1070
+ try {
1071
+ BigInt(putativeBigInt);
1072
+ } catch (e3) {
1073
+ throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
1074
+ cause: e3
1075
+ });
1076
+ }
1077
+ }
1078
+ function stringifiedBigInt(putativeBigInt) {
1079
+ assertIsStringifiedBigInt(putativeBigInt);
1080
+ return putativeBigInt;
1081
+ }
1082
+ function isStringifiedNumber(putativeNumber) {
1083
+ return !Number.isNaN(Number(putativeNumber));
1084
+ }
1085
+ function assertIsStringifiedNumber(putativeNumber) {
1086
+ if (Number.isNaN(Number(putativeNumber))) {
1087
+ throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
1088
+ }
1089
+ }
1090
+ function stringifiedNumber(putativeNumber) {
1091
+ assertIsStringifiedNumber(putativeNumber);
1092
+ return putativeNumber;
1093
+ }
1094
+ function isUnixTimestamp(putativeTimestamp) {
1095
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
1096
+ return false;
1097
+ }
1098
+ return true;
1099
+ }
1100
+ function assertIsUnixTimestamp(putativeTimestamp) {
1101
+ try {
1102
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
1103
+ throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
1104
+ }
1105
+ } catch (e3) {
1106
+ throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
1107
+ cause: e3
1108
+ });
1109
+ }
1110
+ }
1111
+ function unixTimestamp(putativeTimestamp) {
1112
+ assertIsUnixTimestamp(putativeTimestamp);
1113
+ return putativeTimestamp;
1008
1114
  }
1009
1115
 
1010
1116
  // ../transactions/dist/index.browser.js
1011
1117
  init_env_shim();
1118
+
1119
+ // ../codecs-data-structures/dist/index.browser.js
1120
+ init_env_shim();
1121
+ function sumCodecSizes(sizes) {
1122
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1123
+ }
1124
+ function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
1125
+ if (typeof size === "number") {
1126
+ return [size, offset];
1127
+ }
1128
+ if (typeof size === "object") {
1129
+ return size.decode(bytes, offset);
1130
+ }
1131
+ if (size === "remainder") {
1132
+ const childrenSize = sumCodecSizes(childrenSizes);
1133
+ if (childrenSize === null) {
1134
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1135
+ }
1136
+ const remainder = bytes.slice(offset).length;
1137
+ if (remainder % childrenSize !== 0) {
1138
+ throw new Error(
1139
+ `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${childrenSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${childrenSize} should be equal to zero.`
1140
+ );
1141
+ }
1142
+ return [remainder / childrenSize, offset];
1143
+ }
1144
+ throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
1145
+ }
1146
+ function getArrayLikeCodecSizeDescription(size) {
1147
+ return typeof size === "object" ? size.description : `${size}`;
1148
+ }
1149
+ function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
1150
+ if (typeof size !== "number")
1151
+ return null;
1152
+ if (size === 0)
1153
+ return 0;
1154
+ const childrenSize = sumCodecSizes(childrenSizes);
1155
+ return childrenSize === null ? null : childrenSize * size;
1156
+ }
1157
+ function getArrayLikeCodecSizePrefix(size, realSize) {
1158
+ return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
1159
+ }
1160
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1161
+ if (expected !== actual) {
1162
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1163
+ }
1164
+ }
1165
+ function arrayCodecHelper(item, size, description) {
1166
+ if (size === "remainder" && item.fixedSize === null) {
1167
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1168
+ }
1169
+ return {
1170
+ description: description != null ? description : `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
1171
+ fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
1172
+ maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
1173
+ };
1174
+ }
1175
+ function getArrayEncoder(item, config = {}) {
1176
+ var _a;
1177
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
1178
+ return {
1179
+ ...arrayCodecHelper(item, size, config.description),
1180
+ encode: (value) => {
1181
+ if (typeof size === "number") {
1182
+ assertValidNumberOfItemsForCodec("array", size, value.length);
1183
+ }
1184
+ return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
1185
+ }
1186
+ };
1187
+ }
1188
+ function getArrayDecoder(item, config = {}) {
1189
+ var _a;
1190
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
1191
+ return {
1192
+ ...arrayCodecHelper(item, size, config.description),
1193
+ decode: (bytes, offset = 0) => {
1194
+ if (typeof size === "object" && bytes.slice(offset).length === 0) {
1195
+ return [[], offset];
1196
+ }
1197
+ const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
1198
+ offset = newOffset;
1199
+ const values = [];
1200
+ for (let i = 0; i < resolvedSize; i += 1) {
1201
+ const [value, newOffset2] = item.decode(bytes, offset);
1202
+ values.push(value);
1203
+ offset = newOffset2;
1204
+ }
1205
+ return [values, offset];
1206
+ }
1207
+ };
1208
+ }
1209
+ function getBytesEncoder(config = {}) {
1210
+ var _a, _b;
1211
+ const size = (_a = config.size) != null ? _a : "variable";
1212
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1213
+ const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
1214
+ const byteEncoder = {
1215
+ description,
1216
+ encode: (value) => value,
1217
+ fixedSize: null,
1218
+ maxSize: null
1219
+ };
1220
+ if (size === "variable") {
1221
+ return byteEncoder;
1222
+ }
1223
+ if (typeof size === "number") {
1224
+ return fixEncoder(byteEncoder, size, description);
1225
+ }
1226
+ return {
1227
+ ...byteEncoder,
1228
+ encode: (value) => {
1229
+ const contentBytes = byteEncoder.encode(value);
1230
+ const lengthBytes = size.encode(contentBytes.length);
1231
+ return mergeBytes([lengthBytes, contentBytes]);
1232
+ }
1233
+ };
1234
+ }
1235
+ function getBytesDecoder(config = {}) {
1236
+ var _a, _b;
1237
+ const size = (_a = config.size) != null ? _a : "variable";
1238
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1239
+ const description = (_b = config.description) != null ? _b : `bytes(${sizeDescription})`;
1240
+ const byteDecoder = {
1241
+ decode: (bytes, offset = 0) => {
1242
+ const slice = bytes.slice(offset);
1243
+ return [slice, offset + slice.length];
1244
+ },
1245
+ description,
1246
+ fixedSize: null,
1247
+ maxSize: null
1248
+ };
1249
+ if (size === "variable") {
1250
+ return byteDecoder;
1251
+ }
1252
+ if (typeof size === "number") {
1253
+ return fixDecoder(byteDecoder, size, description);
1254
+ }
1255
+ return {
1256
+ ...byteDecoder,
1257
+ decode: (bytes, offset = 0) => {
1258
+ assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
1259
+ const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
1260
+ const length = Number(lengthBigInt);
1261
+ offset = lengthOffset;
1262
+ const contentBytes = bytes.slice(offset, offset + length);
1263
+ assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
1264
+ const [value, contentOffset] = byteDecoder.decode(contentBytes);
1265
+ offset += contentOffset;
1266
+ return [value, offset];
1267
+ }
1268
+ };
1269
+ }
1270
+ function structCodecHelper(fields, description) {
1271
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1272
+ return {
1273
+ description: description != null ? description : `struct(${fieldDescriptions})`,
1274
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1275
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1276
+ };
1277
+ }
1278
+ function getStructEncoder(fields, config = {}) {
1279
+ return {
1280
+ ...structCodecHelper(fields, config.description),
1281
+ encode: (struct) => {
1282
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
1283
+ return mergeBytes(fieldBytes);
1284
+ }
1285
+ };
1286
+ }
1287
+ function getStructDecoder(fields, config = {}) {
1288
+ return {
1289
+ ...structCodecHelper(fields, config.description),
1290
+ decode: (bytes, offset = 0) => {
1291
+ const struct = {};
1292
+ fields.forEach(([key, codec]) => {
1293
+ const [value, newOffset] = codec.decode(bytes, offset);
1294
+ offset = newOffset;
1295
+ struct[key] = value;
1296
+ });
1297
+ return [struct, offset];
1298
+ }
1299
+ };
1300
+ }
1301
+
1302
+ // ../functional/dist/index.browser.js
1303
+ init_env_shim();
1304
+ function pipe(init, ...fns) {
1305
+ return fns.reduce((acc, fn) => fn(acc), init);
1306
+ }
1012
1307
  function getUnsignedTransaction(transaction) {
1013
1308
  if ("signatures" in transaction) {
1014
1309
  const {
@@ -1021,7 +1316,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1021
1316
  return transaction;
1022
1317
  }
1023
1318
  }
1319
+ var base58Encoder2;
1024
1320
  function assertIsBlockhash(putativeBlockhash) {
1321
+ if (!base58Encoder2)
1322
+ base58Encoder2 = getBase58Encoder();
1025
1323
  try {
1026
1324
  if (
1027
1325
  // Lowest value (32 bytes of zeroes)
@@ -1030,8 +1328,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1030
1328
  ) {
1031
1329
  throw new Error("Expected input string to decode to a byte array of length 32.");
1032
1330
  }
1033
- const bytes3 = base58.serialize(putativeBlockhash);
1034
- const numBytes = bytes3.byteLength;
1331
+ const bytes = base58Encoder2.encode(putativeBlockhash);
1332
+ const numBytes = bytes.byteLength;
1035
1333
  if (numBytes !== 32) {
1036
1334
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
1037
1335
  }
@@ -1105,12 +1403,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
1105
1403
  };
1106
1404
  }
1107
1405
  function isAdvanceNonceAccountInstruction(instruction) {
1406
+ var _a;
1108
1407
  return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
1109
1408
  instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
1110
- instruction.accounts?.length === 3 && // First account is nonce account address
1409
+ ((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
1111
1410
  instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
1112
1411
  instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
1113
- instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole2.READONLY_SIGNER;
1412
+ instruction.accounts[2].address != null && isSignerRole2(instruction.accounts[2].role);
1114
1413
  }
1115
1414
  function isAdvanceNonceAccountInstructionData(data) {
1116
1415
  return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
@@ -1118,21 +1417,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
1118
1417
  function isDurableNonceTransaction(transaction) {
1119
1418
  return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
1120
1419
  }
1420
+ function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
1421
+ return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
1422
+ }
1121
1423
  function setTransactionLifetimeUsingDurableNonce({
1122
1424
  nonce,
1123
1425
  nonceAccountAddress,
1124
1426
  nonceAuthorityAddress
1125
1427
  }, transaction) {
1126
- const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
1127
- if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
1128
- return transaction;
1428
+ let newInstructions;
1429
+ const firstInstruction = transaction.instructions[0];
1430
+ if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
1431
+ if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
1432
+ if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
1433
+ return transaction;
1434
+ } else {
1435
+ newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
1436
+ }
1437
+ } else {
1438
+ newInstructions = [
1439
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1440
+ ...transaction.instructions.slice(1)
1441
+ ];
1442
+ }
1443
+ } else {
1444
+ newInstructions = [
1445
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1446
+ ...transaction.instructions
1447
+ ];
1129
1448
  }
1130
1449
  const out = {
1131
1450
  ...getUnsignedTransaction(transaction),
1132
- instructions: [
1133
- createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1134
- ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
1135
- ],
1451
+ instructions: newInstructions,
1136
1452
  lifetimeConstraint: {
1137
1453
  nonce
1138
1454
  }
@@ -1167,8 +1483,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
1167
1483
  Object.freeze(out);
1168
1484
  return out;
1169
1485
  }
1170
- function upsert(addressMap, address, update) {
1171
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole2.READONLY });
1486
+ function upsert(addressMap, address2, update) {
1487
+ var _a;
1488
+ addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole2.READONLY });
1172
1489
  }
1173
1490
  var TYPE = Symbol("AddressMapTypeProperty");
1174
1491
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -1219,7 +1536,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1219
1536
  const shouldReplaceEntry = (
1220
1537
  // Consider using the new LOOKUP_TABLE if its address is different...
1221
1538
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
1222
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
1539
+ (addressComparator || (addressComparator = getAddressComparator()))(
1223
1540
  accountMeta.lookupTableAddress,
1224
1541
  entry.lookupTableAddress
1225
1542
  ) < 0
@@ -1327,14 +1644,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1327
1644
  if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
1328
1645
  return leftIsWritable ? -1 : 1;
1329
1646
  }
1330
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
1647
+ addressComparator || (addressComparator = getAddressComparator());
1331
1648
  if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
1332
1649
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
1333
1650
  } else {
1334
1651
  return addressComparator(leftAddress, rightAddress);
1335
1652
  }
1336
- }).map(([address, addressMeta]) => ({
1337
- address,
1653
+ }).map(([address2, addressMeta]) => ({
1654
+ address: address2,
1338
1655
  ...addressMeta
1339
1656
  }));
1340
1657
  return orderedAccounts;
@@ -1356,7 +1673,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1356
1673
  entry.readableIndices.push(account.addressIndex);
1357
1674
  }
1358
1675
  }
1359
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
1676
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
1360
1677
  lookupTableAddress,
1361
1678
  ...index[lookupTableAddress]
1362
1679
  }));
@@ -1397,7 +1714,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1397
1714
  return instructions.map(({ accounts, data, programAddress }) => {
1398
1715
  return {
1399
1716
  programAddressIndex: accountIndex[programAddress],
1400
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
1717
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
1401
1718
  ...data ? { data } : null
1402
1719
  };
1403
1720
  });
@@ -1411,7 +1728,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1411
1728
  function getCompiledStaticAccounts(orderedAccounts) {
1412
1729
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
1413
1730
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
1414
- return orderedStaticAccounts.map(({ address }) => address);
1731
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
1415
1732
  }
1416
1733
  function compileMessage(transaction) {
1417
1734
  const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
@@ -1425,138 +1742,181 @@ this.globalThis.solanaWeb3 = (function (exports) {
1425
1742
  version: transaction.version
1426
1743
  };
1427
1744
  }
1428
- function getAddressTableLookupCodec() {
1429
- return struct(
1430
- [
1745
+ var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1746
+ var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1747
+ var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1748
+ var addressTableLookupDescription = "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it" ;
1749
+ var memoizedAddressTableLookupEncoder;
1750
+ function getAddressTableLookupEncoder() {
1751
+ if (!memoizedAddressTableLookupEncoder) {
1752
+ memoizedAddressTableLookupEncoder = getStructEncoder(
1431
1753
  [
1432
- "lookupTableAddress",
1433
- getBase58EncodedAddressCodec(
1434
- {
1435
- description: "The address of the address lookup table account from which instruction addresses should be looked up"
1436
- }
1437
- )
1754
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1755
+ [
1756
+ "writableIndices",
1757
+ getArrayEncoder(getU8Encoder(), {
1758
+ description: writableIndicesDescription,
1759
+ size: getShortU16Encoder()
1760
+ })
1761
+ ],
1762
+ [
1763
+ "readableIndices",
1764
+ getArrayEncoder(getU8Encoder(), {
1765
+ description: readableIndicesDescription,
1766
+ size: getShortU16Encoder()
1767
+ })
1768
+ ]
1438
1769
  ],
1770
+ { description: addressTableLookupDescription }
1771
+ );
1772
+ }
1773
+ return memoizedAddressTableLookupEncoder;
1774
+ }
1775
+ var memoizedAddressTableLookupDecoder;
1776
+ function getAddressTableLookupDecoder() {
1777
+ if (!memoizedAddressTableLookupDecoder) {
1778
+ memoizedAddressTableLookupDecoder = getStructDecoder(
1439
1779
  [
1440
- "writableIndices",
1441
- array(u8(), {
1442
- ...{
1443
- description: "The indices of the accounts in the lookup table that should be loaded as writeable"
1444
- } ,
1445
- size: shortU16()
1446
- })
1780
+ ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
1781
+ [
1782
+ "writableIndices",
1783
+ getArrayDecoder(getU8Decoder(), {
1784
+ description: writableIndicesDescription,
1785
+ size: getShortU16Decoder()
1786
+ })
1787
+ ],
1788
+ [
1789
+ "readableIndices",
1790
+ getArrayDecoder(getU8Decoder(), {
1791
+ description: readableIndicesDescription,
1792
+ size: getShortU16Decoder()
1793
+ })
1794
+ ]
1447
1795
  ],
1448
- [
1449
- "readableIndices",
1450
- array(u8(), {
1451
- ...{
1452
- description: "The indices of the accounts in the lookup table that should be loaded as read-only"
1453
- } ,
1454
- size: shortU16()
1455
- })
1456
- ]
1796
+ { description: addressTableLookupDescription }
1797
+ );
1798
+ }
1799
+ return memoizedAddressTableLookupDecoder;
1800
+ }
1801
+ var memoizedU8Encoder;
1802
+ function getMemoizedU8Encoder() {
1803
+ if (!memoizedU8Encoder)
1804
+ memoizedU8Encoder = getU8Encoder();
1805
+ return memoizedU8Encoder;
1806
+ }
1807
+ function getMemoizedU8EncoderDescription(description) {
1808
+ const encoder = getMemoizedU8Encoder();
1809
+ return {
1810
+ ...encoder,
1811
+ description: description != null ? description : encoder.description
1812
+ };
1813
+ }
1814
+ var memoizedU8Decoder;
1815
+ function getMemoizedU8Decoder() {
1816
+ if (!memoizedU8Decoder)
1817
+ memoizedU8Decoder = getU8Decoder();
1818
+ return memoizedU8Decoder;
1819
+ }
1820
+ function getMemoizedU8DecoderDescription(description) {
1821
+ const decoder = getMemoizedU8Decoder();
1822
+ return {
1823
+ ...decoder,
1824
+ description: description != null ? description : decoder.description
1825
+ };
1826
+ }
1827
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1828
+ 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" ;
1829
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1830
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1831
+ function getMessageHeaderEncoder() {
1832
+ return getStructEncoder(
1833
+ [
1834
+ ["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
1835
+ ["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
1836
+ ["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
1457
1837
  ],
1458
1838
  {
1459
- description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
1460
- }
1839
+ description: messageHeaderDescription
1840
+ }
1461
1841
  );
1462
1842
  }
1463
- function getMessageHeaderCodec() {
1464
- return struct(
1843
+ function getMessageHeaderDecoder() {
1844
+ return getStructDecoder(
1465
1845
  [
1466
- [
1467
- "numSignerAccounts",
1468
- u8(
1469
- {
1470
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1471
- }
1472
- )
1473
- ],
1474
- [
1475
- "numReadonlySignerAccounts",
1476
- u8(
1477
- {
1478
- 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"
1479
- }
1480
- )
1481
- ],
1482
- [
1483
- "numReadonlyNonSignerAccounts",
1484
- u8(
1485
- {
1486
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1487
- }
1488
- )
1489
- ]
1846
+ ["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
1847
+ ["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
1848
+ ["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
1490
1849
  ],
1491
1850
  {
1492
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1493
- }
1494
- );
1495
- }
1496
- function getInstructionCodec() {
1497
- return mapSerializer(
1498
- struct([
1499
- [
1500
- "programAddressIndex",
1501
- u8(
1502
- {
1503
- description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
1504
- }
1505
- )
1506
- ],
1507
- [
1508
- "accountIndices",
1509
- array(
1510
- u8({
1511
- description: "The index of an account, according to the well-ordered accounts list for this transaction"
1512
- }),
1513
- {
1514
- description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
1515
- size: shortU16()
1516
- }
1517
- )
1518
- ],
1519
- [
1520
- "data",
1521
- bytes({
1522
- description: "An optional buffer of data passed to the instruction" ,
1523
- size: shortU16()
1524
- })
1525
- ]
1526
- ]),
1527
- (value) => {
1528
- if (value.accountIndices !== void 0 && value.data !== void 0) {
1529
- return value;
1530
- }
1531
- return {
1532
- ...value,
1533
- accountIndices: value.accountIndices ?? [],
1534
- data: value.data ?? new Uint8Array(0)
1535
- };
1536
- },
1537
- (value) => {
1538
- if (value.accountIndices.length && value.data.byteLength) {
1539
- return value;
1540
- }
1541
- const { accountIndices, data, ...rest } = value;
1542
- return {
1543
- ...rest,
1544
- ...accountIndices.length ? { accountIndices } : null,
1545
- ...data.byteLength ? { data } : null
1546
- };
1851
+ description: messageHeaderDescription
1547
1852
  }
1548
1853
  );
1549
1854
  }
1550
- function getError(type, name) {
1551
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1552
- return new Error(
1553
- `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}`
1554
- );
1855
+ var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1856
+ var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1857
+ var accountIndicesDescription = "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ;
1858
+ var dataDescription = "An optional buffer of data passed to the instruction" ;
1859
+ var memoizedGetInstructionEncoder;
1860
+ function getInstructionEncoder() {
1861
+ if (!memoizedGetInstructionEncoder) {
1862
+ memoizedGetInstructionEncoder = mapEncoder(
1863
+ getStructEncoder([
1864
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1865
+ [
1866
+ "accountIndices",
1867
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1868
+ description: accountIndicesDescription,
1869
+ size: getShortU16Encoder()
1870
+ })
1871
+ ],
1872
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1873
+ ]),
1874
+ // Convert an instruction to have all fields defined
1875
+ (instruction) => {
1876
+ var _a, _b;
1877
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1878
+ return instruction;
1879
+ }
1880
+ return {
1881
+ ...instruction,
1882
+ accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
1883
+ data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
1884
+ };
1885
+ }
1886
+ );
1887
+ }
1888
+ return memoizedGetInstructionEncoder;
1555
1889
  }
1556
- function getUnimplementedDecoder(name) {
1557
- return () => {
1558
- throw getError("decoder", name);
1559
- };
1890
+ var memoizedGetInstructionDecoder;
1891
+ function getInstructionDecoder() {
1892
+ if (!memoizedGetInstructionDecoder) {
1893
+ memoizedGetInstructionDecoder = mapDecoder(
1894
+ getStructDecoder([
1895
+ ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
1896
+ [
1897
+ "accountIndices",
1898
+ getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
1899
+ description: accountIndicesDescription,
1900
+ size: getShortU16Decoder()
1901
+ })
1902
+ ],
1903
+ ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
1904
+ ]),
1905
+ // Convert an instruction to exclude optional fields if they are empty
1906
+ (instruction) => {
1907
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
1908
+ return instruction;
1909
+ }
1910
+ const { accountIndices, data, ...rest } = instruction;
1911
+ return {
1912
+ ...rest,
1913
+ ...accountIndices.length ? { accountIndices } : null,
1914
+ ...data.byteLength ? { data } : null
1915
+ };
1916
+ }
1917
+ );
1918
+ }
1919
+ return memoizedGetInstructionDecoder;
1560
1920
  }
1561
1921
  var VERSION_FLAG_MASK = 128;
1562
1922
  var BASE_CONFIG = {
@@ -1564,8 +1924,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1564
1924
  fixedSize: null,
1565
1925
  maxSize: 1
1566
1926
  };
1567
- function deserialize(bytes3, offset = 0) {
1568
- const firstByte = bytes3[offset];
1927
+ function decode(bytes, offset = 0) {
1928
+ const firstByte = bytes[offset];
1569
1929
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
1570
1930
  return ["legacy", offset];
1571
1931
  } else {
@@ -1573,7 +1933,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1573
1933
  return [version, offset + 1];
1574
1934
  }
1575
1935
  }
1576
- function serialize(value) {
1936
+ function encode(value) {
1577
1937
  if (value === "legacy") {
1578
1938
  return new Uint8Array();
1579
1939
  }
@@ -1582,109 +1942,151 @@ this.globalThis.solanaWeb3 = (function (exports) {
1582
1942
  }
1583
1943
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1584
1944
  }
1585
- function getTransactionVersionCodec() {
1945
+ function getTransactionVersionDecoder() {
1946
+ return {
1947
+ ...BASE_CONFIG,
1948
+ decode
1949
+ };
1950
+ }
1951
+ function getTransactionVersionEncoder() {
1586
1952
  return {
1587
1953
  ...BASE_CONFIG,
1588
- deserialize,
1589
- serialize
1954
+ encode
1590
1955
  };
1591
1956
  }
1592
- var BASE_CONFIG2 = {
1593
- description: "The wire format of a Solana transaction message" ,
1594
- fixedSize: null,
1595
- maxSize: null
1596
- };
1597
- function serialize2(compiledMessage) {
1598
- if (compiledMessage.version === "legacy") {
1599
- return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1600
- } else {
1601
- return mapSerializer(
1602
- struct([
1603
- ...getPreludeStructSerializerTuple(),
1604
- ["addressTableLookups", getAddressTableLookupsSerializer()]
1605
- ]),
1606
- (value) => {
1607
- if (value.version === "legacy") {
1608
- return value;
1609
- }
1610
- return {
1611
- ...value,
1612
- addressTableLookups: value.addressTableLookups ?? []
1613
- };
1957
+ var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
1958
+ var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
1959
+ var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
1960
+ var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
1961
+ function getCompiledMessageLegacyEncoder() {
1962
+ return getStructEncoder(getPreludeStructEncoderTuple());
1963
+ }
1964
+ function getCompiledMessageVersionedEncoder() {
1965
+ return mapEncoder(
1966
+ getStructEncoder([
1967
+ ...getPreludeStructEncoderTuple(),
1968
+ ["addressTableLookups", getAddressTableLookupArrayEncoder()]
1969
+ ]),
1970
+ (value) => {
1971
+ var _a;
1972
+ if (value.version === "legacy") {
1973
+ return value;
1614
1974
  }
1615
- ).serialize(compiledMessage);
1616
- }
1975
+ return {
1976
+ ...value,
1977
+ addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
1978
+ };
1979
+ }
1980
+ );
1617
1981
  }
1618
- function getPreludeStructSerializerTuple() {
1982
+ function getPreludeStructEncoderTuple() {
1619
1983
  return [
1620
- ["version", getTransactionVersionCodec()],
1621
- ["header", getMessageHeaderCodec()],
1984
+ ["version", getTransactionVersionEncoder()],
1985
+ ["header", getMessageHeaderEncoder()],
1622
1986
  [
1623
1987
  "staticAccounts",
1624
- array(getBase58EncodedAddressCodec(), {
1625
- description: "A compact-array of static account addresses belonging to this transaction" ,
1626
- size: shortU16()
1988
+ getArrayEncoder(getAddressEncoder(), {
1989
+ description: staticAccountsDescription,
1990
+ size: getShortU16Encoder()
1627
1991
  })
1628
1992
  ],
1629
1993
  [
1630
1994
  "lifetimeToken",
1631
- string({
1632
- description: "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ,
1633
- encoding: base58,
1995
+ getStringEncoder({
1996
+ description: lifetimeTokenDescription,
1997
+ encoding: getBase58Encoder(),
1634
1998
  size: 32
1635
1999
  })
1636
2000
  ],
1637
2001
  [
1638
2002
  "instructions",
1639
- array(getInstructionCodec(), {
1640
- description: "A compact-array of instructions belonging to this transaction" ,
1641
- size: shortU16()
2003
+ getArrayEncoder(getInstructionEncoder(), {
2004
+ description: instructionsDescription,
2005
+ size: getShortU16Encoder()
1642
2006
  })
1643
2007
  ]
1644
2008
  ];
1645
2009
  }
1646
- function getAddressTableLookupsSerializer() {
1647
- return array(getAddressTableLookupCodec(), {
1648
- ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
1649
- size: shortU16()
2010
+ function getPreludeStructDecoderTuple() {
2011
+ return [
2012
+ ["version", getTransactionVersionDecoder()],
2013
+ ["header", getMessageHeaderDecoder()],
2014
+ [
2015
+ "staticAccounts",
2016
+ getArrayDecoder(getAddressDecoder(), {
2017
+ description: staticAccountsDescription,
2018
+ size: getShortU16Decoder()
2019
+ })
2020
+ ],
2021
+ [
2022
+ "lifetimeToken",
2023
+ getStringDecoder({
2024
+ description: lifetimeTokenDescription,
2025
+ encoding: getBase58Decoder(),
2026
+ size: 32
2027
+ })
2028
+ ],
2029
+ [
2030
+ "instructions",
2031
+ getArrayDecoder(getInstructionDecoder(), {
2032
+ description: instructionsDescription,
2033
+ size: getShortU16Decoder()
2034
+ })
2035
+ ],
2036
+ ["addressTableLookups", getAddressTableLookupArrayDecoder()]
2037
+ ];
2038
+ }
2039
+ function getAddressTableLookupArrayEncoder() {
2040
+ return getArrayEncoder(getAddressTableLookupEncoder(), {
2041
+ description: addressTableLookupsDescription,
2042
+ size: getShortU16Encoder()
2043
+ });
2044
+ }
2045
+ function getAddressTableLookupArrayDecoder() {
2046
+ return getArrayDecoder(getAddressTableLookupDecoder(), {
2047
+ description: addressTableLookupsDescription,
2048
+ size: getShortU16Decoder()
1650
2049
  });
1651
2050
  }
2051
+ var messageDescription = "The wire format of a Solana transaction message" ;
1652
2052
  function getCompiledMessageEncoder() {
1653
2053
  return {
1654
- ...BASE_CONFIG2,
1655
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1656
- serialize: serialize2
2054
+ description: messageDescription,
2055
+ encode: (compiledMessage) => {
2056
+ if (compiledMessage.version === "legacy") {
2057
+ return getCompiledMessageLegacyEncoder().encode(compiledMessage);
2058
+ } else {
2059
+ return getCompiledMessageVersionedEncoder().encode(compiledMessage);
2060
+ }
2061
+ },
2062
+ fixedSize: null,
2063
+ maxSize: null
1657
2064
  };
1658
2065
  }
1659
- async function getCompiledMessageSignature(message, secretKey) {
1660
- const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1661
- const signature = await signBytes(secretKey, wireMessageBytes);
1662
- return signature;
2066
+ function getCompiledMessageDecoder() {
2067
+ return mapDecoder(
2068
+ getStructDecoder(getPreludeStructDecoderTuple(), {
2069
+ description: messageDescription
2070
+ }),
2071
+ ({ addressTableLookups, ...restOfMessage }) => {
2072
+ if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
2073
+ return restOfMessage;
2074
+ }
2075
+ return { ...restOfMessage, addressTableLookups };
2076
+ }
2077
+ );
1663
2078
  }
1664
- async function signTransaction(keyPair, transaction) {
1665
- const compiledMessage = compileMessage(transaction);
1666
- const [signerPublicKey, signature] = await Promise.all([
1667
- getAddressFromPublicKey(keyPair.publicKey),
1668
- getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1669
- ]);
1670
- const nextSignatures = {
1671
- ..."signatures" in transaction ? transaction.signatures : null,
1672
- ...{ [signerPublicKey]: signature }
1673
- };
1674
- const out = {
1675
- ...transaction,
1676
- signatures: nextSignatures
1677
- };
1678
- Object.freeze(out);
1679
- return out;
2079
+ function getCompiledMessageCodec() {
2080
+ return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
1680
2081
  }
1681
2082
  function getCompiledTransaction(transaction) {
2083
+ var _a;
1682
2084
  const compiledMessage = compileMessage(transaction);
1683
2085
  let signatures;
1684
2086
  if ("signatures" in transaction) {
1685
2087
  signatures = [];
1686
2088
  for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1687
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
2089
+ signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
1688
2090
  }
1689
2091
  } else {
1690
2092
  signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
@@ -1694,38 +2096,389 @@ this.globalThis.solanaWeb3 = (function (exports) {
1694
2096
  signatures
1695
2097
  };
1696
2098
  }
1697
- var BASE_CONFIG3 = {
1698
- description: "The wire format of a Solana transaction" ,
1699
- fixedSize: null,
1700
- maxSize: null
1701
- };
1702
- function serialize3(transaction) {
1703
- const compiledTransaction = getCompiledTransaction(transaction);
1704
- return struct([
2099
+ function getAccountMetas(message) {
2100
+ const { header } = message;
2101
+ const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
2102
+ const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
2103
+ const accountMetas = [];
2104
+ let accountIndex = 0;
2105
+ for (let i = 0; i < numWritableSignerAccounts; i++) {
2106
+ accountMetas.push({
2107
+ address: message.staticAccounts[accountIndex],
2108
+ role: AccountRole2.WRITABLE_SIGNER
2109
+ });
2110
+ accountIndex++;
2111
+ }
2112
+ for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
2113
+ accountMetas.push({
2114
+ address: message.staticAccounts[accountIndex],
2115
+ role: AccountRole2.READONLY_SIGNER
2116
+ });
2117
+ accountIndex++;
2118
+ }
2119
+ for (let i = 0; i < numWritableNonSignerAccounts; i++) {
2120
+ accountMetas.push({
2121
+ address: message.staticAccounts[accountIndex],
2122
+ role: AccountRole2.WRITABLE
2123
+ });
2124
+ accountIndex++;
2125
+ }
2126
+ for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
2127
+ accountMetas.push({
2128
+ address: message.staticAccounts[accountIndex],
2129
+ role: AccountRole2.READONLY
2130
+ });
2131
+ accountIndex++;
2132
+ }
2133
+ return accountMetas;
2134
+ }
2135
+ function convertInstruction(instruction, accountMetas) {
2136
+ var _a, _b;
2137
+ const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
2138
+ if (!programAddress) {
2139
+ throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
2140
+ }
2141
+ const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
2142
+ const { data } = instruction;
2143
+ return {
2144
+ programAddress,
2145
+ ...accounts && accounts.length ? { accounts } : {},
2146
+ ...data && data.length ? { data } : {}
2147
+ };
2148
+ }
2149
+ function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
2150
+ if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
2151
+ return {
2152
+ blockhash: messageLifetimeToken,
2153
+ lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
2154
+ // U64 MAX
2155
+ };
2156
+ } else {
2157
+ const nonceAccountAddress = firstInstruction.accounts[0].address;
2158
+ assertIsAddress(nonceAccountAddress);
2159
+ const nonceAuthorityAddress = firstInstruction.accounts[2].address;
2160
+ assertIsAddress(nonceAuthorityAddress);
2161
+ return {
2162
+ nonce: messageLifetimeToken,
2163
+ nonceAccountAddress,
2164
+ nonceAuthorityAddress
2165
+ };
2166
+ }
2167
+ }
2168
+ function convertSignatures(compiledTransaction) {
2169
+ const {
2170
+ compiledMessage: { staticAccounts },
2171
+ signatures
2172
+ } = compiledTransaction;
2173
+ return signatures.reduce((acc, sig, index) => {
2174
+ const allZeros = sig.every((byte) => byte === 0);
2175
+ if (allZeros)
2176
+ return acc;
2177
+ const address2 = staticAccounts[index];
2178
+ return { ...acc, [address2]: sig };
2179
+ }, {});
2180
+ }
2181
+ function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
2182
+ const { compiledMessage } = compiledTransaction;
2183
+ if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
2184
+ throw new Error("Cannot convert transaction with addressTableLookups");
2185
+ }
2186
+ const feePayer = compiledMessage.staticAccounts[0];
2187
+ if (!feePayer)
2188
+ throw new Error("No fee payer set in CompiledTransaction");
2189
+ const accountMetas = getAccountMetas(compiledMessage);
2190
+ const instructions = compiledMessage.instructions.map(
2191
+ (compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
2192
+ );
2193
+ const firstInstruction = instructions[0];
2194
+ const lifetimeConstraint = getLifetimeConstraint(
2195
+ compiledMessage.lifetimeToken,
2196
+ firstInstruction,
2197
+ lastValidBlockHeight
2198
+ );
2199
+ const signatures = convertSignatures(compiledTransaction);
2200
+ return pipe(
2201
+ createTransaction({ version: compiledMessage.version }),
2202
+ (tx) => setTransactionFeePayer(feePayer, tx),
2203
+ (tx) => instructions.reduce((acc, instruction) => {
2204
+ return appendTransactionInstruction(instruction, acc);
2205
+ }, tx),
2206
+ (tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
2207
+ (tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
2208
+ );
2209
+ }
2210
+ var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
2211
+ var transactionDescription = "The wire format of a Solana transaction" ;
2212
+ function getCompiledTransactionEncoder() {
2213
+ return getStructEncoder(
1705
2214
  [
1706
- "signatures",
1707
- array(bytes({ size: 64 }), {
1708
- ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1709
- size: shortU16()
1710
- })
2215
+ [
2216
+ "signatures",
2217
+ getArrayEncoder(getBytesEncoder({ size: 64 }), {
2218
+ description: signaturesDescription,
2219
+ size: getShortU16Encoder()
2220
+ })
2221
+ ],
2222
+ ["compiledMessage", getCompiledMessageEncoder()]
2223
+ ],
2224
+ {
2225
+ description: transactionDescription
2226
+ }
2227
+ );
2228
+ }
2229
+ function getSignatureDecoder() {
2230
+ return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
2231
+ }
2232
+ function getCompiledTransactionDecoder() {
2233
+ return getStructDecoder(
2234
+ [
2235
+ [
2236
+ "signatures",
2237
+ getArrayDecoder(getSignatureDecoder(), {
2238
+ description: signaturesDescription,
2239
+ size: getShortU16Decoder()
2240
+ })
2241
+ ],
2242
+ ["compiledMessage", getCompiledMessageDecoder()]
1711
2243
  ],
1712
- ["compiledMessage", getCompiledMessageEncoder()]
1713
- ]).serialize(compiledTransaction);
2244
+ {
2245
+ description: transactionDescription
2246
+ }
2247
+ );
1714
2248
  }
1715
2249
  function getTransactionEncoder() {
1716
- return {
1717
- ...BASE_CONFIG3,
1718
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1719
- serialize: serialize3
2250
+ return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
2251
+ }
2252
+ function getTransactionDecoder(lastValidBlockHeight) {
2253
+ return mapDecoder(
2254
+ getCompiledTransactionDecoder(),
2255
+ (compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
2256
+ );
2257
+ }
2258
+ function getTransactionCodec(lastValidBlockHeight) {
2259
+ return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
2260
+ }
2261
+ var base58Decoder;
2262
+ function getSignatureFromTransaction(transaction) {
2263
+ if (!base58Decoder)
2264
+ base58Decoder = getBase58Decoder();
2265
+ const signatureBytes = transaction.signatures[transaction.feePayer];
2266
+ if (!signatureBytes) {
2267
+ throw new Error(
2268
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
2269
+ );
2270
+ }
2271
+ const transactionSignature = base58Decoder.decode(signatureBytes)[0];
2272
+ return transactionSignature;
2273
+ }
2274
+ async function partiallySignTransaction(keyPairs, transaction) {
2275
+ const compiledMessage = compileMessage(transaction);
2276
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
2277
+ const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
2278
+ const publicKeySignaturePairs = await Promise.all(
2279
+ keyPairs.map(
2280
+ (keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
2281
+ )
2282
+ );
2283
+ for (const [signerPublicKey, signature2] of publicKeySignaturePairs) {
2284
+ nextSignatures[signerPublicKey] = signature2;
2285
+ }
2286
+ const out = {
2287
+ ...transaction,
2288
+ signatures: nextSignatures
1720
2289
  };
2290
+ Object.freeze(out);
2291
+ return out;
2292
+ }
2293
+ async function signTransaction(keyPairs, transaction) {
2294
+ const out = await partiallySignTransaction(keyPairs, transaction);
2295
+ assertTransactionIsFullySigned(out);
2296
+ Object.freeze(out);
2297
+ return out;
2298
+ }
2299
+ function assertTransactionIsFullySigned(transaction) {
2300
+ const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
2301
+ var _a, _b;
2302
+ return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
2303
+ }).map((a) => a.address);
2304
+ const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
2305
+ requiredSigners.forEach((address2) => {
2306
+ if (!transaction.signatures[address2]) {
2307
+ throw new Error(`Transaction is missing signature for address \`${address2}\``);
2308
+ }
2309
+ });
1721
2310
  }
1722
2311
  function getBase64EncodedWireTransaction(transaction) {
1723
- const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
1724
- {
1725
- return btoa(String.fromCharCode(...wireTransactionBytes));
2312
+ const wireTransactionBytes = getTransactionEncoder().encode(transaction);
2313
+ return getBase64Decoder().decode(wireTransactionBytes)[0];
2314
+ }
2315
+
2316
+ // src/airdrop.ts
2317
+ init_env_shim();
2318
+
2319
+ // src/airdrop-confirmer.ts
2320
+ init_env_shim();
2321
+
2322
+ // src/transaction-confirmation-strategy-racer.ts
2323
+ init_env_shim();
2324
+ async function raceStrategies(signature2, config, getSpecificStrategiesForRace) {
2325
+ const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
2326
+ callerAbortSignal == null ? void 0 : callerAbortSignal.throwIfAborted();
2327
+ const abortController = new AbortController();
2328
+ if (callerAbortSignal) {
2329
+ const handleAbort = () => {
2330
+ abortController.abort();
2331
+ };
2332
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
2333
+ }
2334
+ try {
2335
+ const specificStrategies = getSpecificStrategiesForRace({
2336
+ ...config,
2337
+ abortSignal: abortController.signal
2338
+ });
2339
+ return await Promise.race([
2340
+ getRecentSignatureConfirmationPromise({
2341
+ abortSignal: abortController.signal,
2342
+ commitment,
2343
+ signature: signature2
2344
+ }),
2345
+ ...specificStrategies
2346
+ ]);
2347
+ } finally {
2348
+ abortController.abort();
1726
2349
  }
1727
2350
  }
1728
2351
 
2352
+ // src/transaction-confirmation-strategy-recent-signature.ts
2353
+ init_env_shim();
2354
+ function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
2355
+ return async function getRecentSignatureConfirmationPromise({
2356
+ abortSignal: callerAbortSignal,
2357
+ commitment,
2358
+ signature: signature2
2359
+ }) {
2360
+ const abortController = new AbortController();
2361
+ function handleAbort() {
2362
+ abortController.abort();
2363
+ }
2364
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
2365
+ const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature2, { commitment }).subscribe({ abortSignal: abortController.signal });
2366
+ const signatureDidCommitPromise = (async () => {
2367
+ for await (const signatureStatusNotification of signatureStatusNotifications) {
2368
+ if (signatureStatusNotification.value.err) {
2369
+ throw new Error(`The transaction with signature \`${signature2}\` failed.`, {
2370
+ cause: signatureStatusNotification.value.err
2371
+ });
2372
+ } else {
2373
+ return;
2374
+ }
2375
+ }
2376
+ })();
2377
+ const signatureStatusLookupPromise = (async () => {
2378
+ const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature2]).send({ abortSignal: abortController.signal });
2379
+ const signatureStatus = signatureStatusResults[0];
2380
+ if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
2381
+ return;
2382
+ } else {
2383
+ await new Promise(() => {
2384
+ });
2385
+ }
2386
+ })();
2387
+ try {
2388
+ return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
2389
+ } finally {
2390
+ abortController.abort();
2391
+ }
2392
+ };
2393
+ }
2394
+
2395
+ // src/transaction-confirmation-strategy-timeout.ts
2396
+ init_env_shim();
2397
+ async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
2398
+ return await new Promise((_, reject) => {
2399
+ const handleAbort = (e3) => {
2400
+ clearTimeout(timeoutId);
2401
+ const abortError = new DOMException(e3.target.reason, "AbortError");
2402
+ reject(abortError);
2403
+ };
2404
+ callerAbortSignal.addEventListener("abort", handleAbort);
2405
+ const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
2406
+ const startMs = performance.now();
2407
+ const timeoutId = (
2408
+ // We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
2409
+ // elapsed time instead of active time.
2410
+ // See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
2411
+ setTimeout(() => {
2412
+ const elapsedMs = performance.now() - startMs;
2413
+ reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
2414
+ }, timeoutMs)
2415
+ );
2416
+ });
2417
+ }
2418
+
2419
+ // src/airdrop-confirmer.ts
2420
+ function createDefaultSignatureOnlyRecentTransactionConfirmer({
2421
+ rpc,
2422
+ rpcSubscriptions
2423
+ }) {
2424
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
2425
+ rpc,
2426
+ rpcSubscriptions
2427
+ );
2428
+ return async function confirmSignatureOnlyRecentTransaction(config) {
2429
+ await waitForRecentTransactionConfirmationUntilTimeout({
2430
+ ...config,
2431
+ getRecentSignatureConfirmationPromise,
2432
+ getTimeoutPromise
2433
+ });
2434
+ };
2435
+ }
2436
+ async function waitForRecentTransactionConfirmationUntilTimeout(config) {
2437
+ await raceStrategies(
2438
+ config.signature,
2439
+ config,
2440
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
2441
+ return [
2442
+ getTimeoutPromise2({
2443
+ abortSignal,
2444
+ commitment
2445
+ })
2446
+ ];
2447
+ }
2448
+ );
2449
+ }
2450
+
2451
+ // src/airdrop.ts
2452
+ function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
2453
+ const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
2454
+ rpc,
2455
+ rpcSubscriptions
2456
+ });
2457
+ return async function requestAirdrop(config) {
2458
+ return await requestAndConfirmAirdrop({
2459
+ ...config,
2460
+ confirmSignatureOnlyTransaction,
2461
+ rpc
2462
+ });
2463
+ };
2464
+ }
2465
+ async function requestAndConfirmAirdrop({
2466
+ abortSignal,
2467
+ commitment,
2468
+ confirmSignatureOnlyTransaction,
2469
+ lamports: lamports2,
2470
+ recipientAddress,
2471
+ rpc
2472
+ }) {
2473
+ const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports2, { commitment }).send({ abortSignal });
2474
+ await confirmSignatureOnlyTransaction({
2475
+ abortSignal,
2476
+ commitment,
2477
+ signature: airdropTransactionSignature
2478
+ });
2479
+ return airdropTransactionSignature;
2480
+ }
2481
+
1729
2482
  // src/rpc.ts
1730
2483
  init_env_shim();
1731
2484
 
@@ -1757,68 +2510,215 @@ this.globalThis.solanaWeb3 = (function (exports) {
1757
2510
  return visitNode(params, [], onIntegerOverflow);
1758
2511
  }
1759
2512
  var KEYPATH_WILDCARD = {};
2513
+ var jsonParsedTokenAccountsConfigs = [
2514
+ // parsed Token/Token22 token account
2515
+ ["data", "parsed", "info", "tokenAmount", "decimals"],
2516
+ ["data", "parsed", "info", "tokenAmount", "uiAmount"],
2517
+ ["data", "parsed", "info", "rentExemptReserve", "decimals"],
2518
+ ["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
2519
+ ["data", "parsed", "info", "delegatedAmount", "decimals"],
2520
+ ["data", "parsed", "info", "delegatedAmount", "uiAmount"],
2521
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
2522
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
2523
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
2524
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
2525
+ ];
2526
+ var jsonParsedAccountsConfigs = [
2527
+ ...jsonParsedTokenAccountsConfigs,
2528
+ // parsed AddressTableLookup account
2529
+ ["data", "parsed", "info", "lastExtendedSlotStartIndex"],
2530
+ // parsed Config account
2531
+ ["data", "parsed", "info", "slashPenalty"],
2532
+ ["data", "parsed", "info", "warmupCooldownRate"],
2533
+ // parsed Token/Token22 mint account
2534
+ ["data", "parsed", "info", "decimals"],
2535
+ // parsed Token/Token22 multisig account
2536
+ ["data", "parsed", "info", "numRequiredSigners"],
2537
+ ["data", "parsed", "info", "numValidSigners"],
2538
+ // parsed Stake account
2539
+ ["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
2540
+ // parsed Sysvar rent account
2541
+ ["data", "parsed", "info", "exemptionThreshold"],
2542
+ ["data", "parsed", "info", "burnPercent"],
2543
+ // parsed Vote account
2544
+ ["data", "parsed", "info", "commission"],
2545
+ ["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
2546
+ ];
1760
2547
  var memoizedNotificationKeypaths;
1761
2548
  var memoizedResponseKeypaths;
1762
2549
  function getAllowedNumericKeypathsForNotification() {
1763
2550
  if (!memoizedNotificationKeypaths) {
1764
- memoizedNotificationKeypaths = {};
2551
+ memoizedNotificationKeypaths = {
2552
+ accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
2553
+ blockNotifications: [
2554
+ ["value", "block", "blockTime"],
2555
+ [
2556
+ "value",
2557
+ "block",
2558
+ "transactions",
2559
+ KEYPATH_WILDCARD,
2560
+ "meta",
2561
+ "preTokenBalances",
2562
+ KEYPATH_WILDCARD,
2563
+ "accountIndex"
2564
+ ],
2565
+ [
2566
+ "value",
2567
+ "block",
2568
+ "transactions",
2569
+ KEYPATH_WILDCARD,
2570
+ "meta",
2571
+ "preTokenBalances",
2572
+ KEYPATH_WILDCARD,
2573
+ "uiTokenAmount",
2574
+ "decimals"
2575
+ ],
2576
+ [
2577
+ "value",
2578
+ "block",
2579
+ "transactions",
2580
+ KEYPATH_WILDCARD,
2581
+ "meta",
2582
+ "postTokenBalances",
2583
+ KEYPATH_WILDCARD,
2584
+ "accountIndex"
2585
+ ],
2586
+ [
2587
+ "value",
2588
+ "block",
2589
+ "transactions",
2590
+ KEYPATH_WILDCARD,
2591
+ "meta",
2592
+ "postTokenBalances",
2593
+ KEYPATH_WILDCARD,
2594
+ "uiTokenAmount",
2595
+ "decimals"
2596
+ ],
2597
+ ["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
2598
+ [
2599
+ "value",
2600
+ "block",
2601
+ "transactions",
2602
+ KEYPATH_WILDCARD,
2603
+ "meta",
2604
+ "innerInstructions",
2605
+ KEYPATH_WILDCARD,
2606
+ "index"
2607
+ ],
2608
+ [
2609
+ "value",
2610
+ "block",
2611
+ "transactions",
2612
+ KEYPATH_WILDCARD,
2613
+ "meta",
2614
+ "innerInstructions",
2615
+ KEYPATH_WILDCARD,
2616
+ "instructions",
2617
+ KEYPATH_WILDCARD,
2618
+ "programIdIndex"
2619
+ ],
2620
+ [
2621
+ "value",
2622
+ "block",
2623
+ "transactions",
2624
+ KEYPATH_WILDCARD,
2625
+ "meta",
2626
+ "innerInstructions",
2627
+ KEYPATH_WILDCARD,
2628
+ "instructions",
2629
+ KEYPATH_WILDCARD,
2630
+ "accounts",
2631
+ KEYPATH_WILDCARD
2632
+ ],
2633
+ [
2634
+ "value",
2635
+ "block",
2636
+ "transactions",
2637
+ KEYPATH_WILDCARD,
2638
+ "transaction",
2639
+ "message",
2640
+ "addressTableLookups",
2641
+ KEYPATH_WILDCARD,
2642
+ "writableIndexes",
2643
+ KEYPATH_WILDCARD
2644
+ ],
2645
+ [
2646
+ "value",
2647
+ "block",
2648
+ "transactions",
2649
+ KEYPATH_WILDCARD,
2650
+ "transaction",
2651
+ "message",
2652
+ "addressTableLookups",
2653
+ KEYPATH_WILDCARD,
2654
+ "readonlyIndexes",
2655
+ KEYPATH_WILDCARD
2656
+ ],
2657
+ [
2658
+ "value",
2659
+ "block",
2660
+ "transactions",
2661
+ KEYPATH_WILDCARD,
2662
+ "transaction",
2663
+ "message",
2664
+ "instructions",
2665
+ KEYPATH_WILDCARD,
2666
+ "programIdIndex"
2667
+ ],
2668
+ [
2669
+ "value",
2670
+ "block",
2671
+ "transactions",
2672
+ KEYPATH_WILDCARD,
2673
+ "transaction",
2674
+ "message",
2675
+ "instructions",
2676
+ KEYPATH_WILDCARD,
2677
+ "accounts",
2678
+ KEYPATH_WILDCARD
2679
+ ],
2680
+ [
2681
+ "value",
2682
+ "block",
2683
+ "transactions",
2684
+ KEYPATH_WILDCARD,
2685
+ "transaction",
2686
+ "message",
2687
+ "header",
2688
+ "numReadonlySignedAccounts"
2689
+ ],
2690
+ [
2691
+ "value",
2692
+ "block",
2693
+ "transactions",
2694
+ KEYPATH_WILDCARD,
2695
+ "transaction",
2696
+ "message",
2697
+ "header",
2698
+ "numReadonlyUnsignedAccounts"
2699
+ ],
2700
+ [
2701
+ "value",
2702
+ "block",
2703
+ "transactions",
2704
+ KEYPATH_WILDCARD,
2705
+ "transaction",
2706
+ "message",
2707
+ "header",
2708
+ "numRequiredSignatures"
2709
+ ],
2710
+ ["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
2711
+ ],
2712
+ programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
2713
+ ["value", KEYPATH_WILDCARD, "account", ...c],
2714
+ [KEYPATH_WILDCARD, "account", ...c]
2715
+ ])
2716
+ };
1765
2717
  }
1766
2718
  return memoizedNotificationKeypaths;
1767
2719
  }
1768
2720
  function getAllowedNumericKeypathsForResponse() {
1769
2721
  if (!memoizedResponseKeypaths) {
1770
- const jsonParsedTokenAccountsConfigs = [
1771
- // parsed Token/Token22 token account
1772
- ["data", "parsed", "info", "tokenAmount", "decimals"],
1773
- ["data", "parsed", "info", "tokenAmount", "uiAmount"],
1774
- ["data", "parsed", "info", "rentExemptReserve", "decimals"],
1775
- ["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
1776
- ["data", "parsed", "info", "delegatedAmount", "decimals"],
1777
- ["data", "parsed", "info", "delegatedAmount", "uiAmount"],
1778
- [
1779
- "data",
1780
- "parsed",
1781
- "info",
1782
- "extensions",
1783
- KEYPATH_WILDCARD,
1784
- "state",
1785
- "olderTransferFee",
1786
- "transferFeeBasisPoints"
1787
- ],
1788
- [
1789
- "data",
1790
- "parsed",
1791
- "info",
1792
- "extensions",
1793
- KEYPATH_WILDCARD,
1794
- "state",
1795
- "newerTransferFee",
1796
- "transferFeeBasisPoints"
1797
- ],
1798
- ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
1799
- ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
1800
- ];
1801
- const jsonParsedAccountsConfigs = [
1802
- ...jsonParsedTokenAccountsConfigs,
1803
- // parsed AddressTableLookup account
1804
- ["data", "parsed", "info", "lastExtendedSlotStartIndex"],
1805
- // parsed Config account
1806
- ["data", "parsed", "info", "slashPenalty"],
1807
- ["data", "parsed", "info", "warmupCooldownRate"],
1808
- // parsed Token/Token22 mint account
1809
- ["data", "parsed", "info", "decimals"],
1810
- // parsed Token/Token22 multisig account
1811
- ["data", "parsed", "info", "numRequiredSigners"],
1812
- ["data", "parsed", "info", "numValidSigners"],
1813
- // parsed Stake account
1814
- ["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
1815
- // parsed Sysvar rent account
1816
- ["data", "parsed", "info", "exemptionThreshold"],
1817
- ["data", "parsed", "info", "burnPercent"],
1818
- // parsed Vote account
1819
- ["data", "parsed", "info", "commission"],
1820
- ["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
1821
- ];
1822
2722
  memoizedResponseKeypaths = {
1823
2723
  getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
1824
2724
  getBlock: [
@@ -2024,11 +2924,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2024
2924
  }
2025
2925
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
2026
2926
  const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
2027
- return visitNode2(rawResponse, allowedKeypaths ?? []);
2927
+ return visitNode2(rawResponse, allowedKeypaths != null ? allowedKeypaths : []);
2028
2928
  }
2029
2929
  function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
2030
2930
  const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
2031
- return visitNode2(rawResponse, allowedKeypaths ?? []);
2931
+ return visitNode2(rawResponse, allowedKeypaths != null ? allowedKeypaths : []);
2032
2932
  }
2033
2933
  function createSolanaRpcApi(config) {
2034
2934
  return new Proxy({}, {
@@ -2042,7 +2942,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2042
2942
  const [_, p] = args;
2043
2943
  const methodName = p.toString();
2044
2944
  return function(...rawParams) {
2045
- const handleIntegerOverflow = config?.onIntegerOverflow;
2945
+ const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
2046
2946
  const params = patchParamsForSolanaLabsRpc(
2047
2947
  rawParams,
2048
2948
  handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
@@ -2068,7 +2968,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2068
2968
  const [_, p] = args;
2069
2969
  const notificationName = p.toString();
2070
2970
  return function(...rawParams) {
2071
- const handleIntegerOverflow = config?.onIntegerOverflow;
2971
+ const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
2072
2972
  const params = patchParamsForSolanaLabsRpc(
2073
2973
  rawParams,
2074
2974
  handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
@@ -2083,12 +2983,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
2083
2983
  }
2084
2984
  });
2085
2985
  }
2986
+ function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
2987
+ return createSolanaRpcSubscriptionsApi(config);
2988
+ }
2086
2989
 
2087
2990
  // ../rpc-transport/dist/index.browser.js
2088
2991
  init_env_shim();
2089
2992
  var SolanaJsonRpcError = class extends Error {
2090
2993
  constructor(details) {
2091
2994
  super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);
2995
+ __publicField(this, "code");
2996
+ __publicField(this, "data");
2092
2997
  Error.captureStackTrace(this, this.constructor);
2093
2998
  this.code = details.code;
2094
2999
  this.data = details.data;
@@ -2118,7 +3023,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2118
3023
  const payload = createJsonRpcMessage(methodName, params);
2119
3024
  const response = await rpcConfig.transport({
2120
3025
  payload,
2121
- signal: options?.abortSignal
3026
+ signal: options == null ? void 0 : options.abortSignal
2122
3027
  });
2123
3028
  if ("error" in response) {
2124
3029
  throw new SolanaJsonRpcError(response.error);
@@ -2162,8 +3067,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2162
3067
  }
2163
3068
  function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
2164
3069
  return {
2165
- async subscribe(options) {
2166
- options?.abortSignal?.throwIfAborted();
3070
+ async subscribe({ abortSignal }) {
3071
+ abortSignal.throwIfAborted();
2167
3072
  let subscriptionId;
2168
3073
  function handleCleanup() {
2169
3074
  if (subscriptionId !== void 0) {
@@ -2175,7 +3080,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2175
3080
  connectionAbortController.abort();
2176
3081
  }
2177
3082
  }
2178
- options?.abortSignal?.addEventListener("abort", handleCleanup);
3083
+ abortSignal.addEventListener("abort", handleCleanup);
2179
3084
  const connectionAbortController = new AbortController();
2180
3085
  const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
2181
3086
  const connection = await rpcConfig.transport({
@@ -2183,7 +3088,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2183
3088
  signal: connectionAbortController.signal
2184
3089
  });
2185
3090
  function handleConnectionCleanup() {
2186
- options?.abortSignal?.removeEventListener("abort", handleCleanup);
3091
+ abortSignal.removeEventListener("abort", handleCleanup);
2187
3092
  }
2188
3093
  registerIterableCleanup(connection, handleConnectionCleanup);
2189
3094
  for await (const message of connection) {
@@ -2243,10 +3148,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2243
3148
  function createJsonSubscriptionRpc(rpcConfig) {
2244
3149
  return makeProxy2(rpcConfig);
2245
3150
  }
2246
- var e = globalThis.fetch;
3151
+ var e2 = globalThis.fetch;
2247
3152
  var SolanaHttpError = class extends Error {
2248
3153
  constructor(details) {
2249
3154
  super(`HTTP error (${details.statusCode}): ${details.message}`);
3155
+ __publicField(this, "statusCode");
2250
3156
  Error.captureStackTrace(this, this.constructor);
2251
3157
  this.statusCode = details.statusCode;
2252
3158
  }
@@ -2302,16 +3208,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
2302
3208
  }
2303
3209
  return out;
2304
3210
  }
2305
- function createHttpTransport({ httpAgentNodeOnly, headers, url }) {
3211
+ function createHttpTransport({ headers, url }) {
2306
3212
  if (headers) {
2307
3213
  assertIsAllowedHttpRequestHeaders(headers);
2308
3214
  }
2309
- const agent = void 0;
2310
- if (httpAgentNodeOnly != null) {
2311
- console.warn(
2312
- "createHttpTransport(): The `httpAgentNodeOnly` config you supplied has been ignored; HTTP agents are only usable in Node environments."
2313
- );
2314
- }
2315
3215
  const customHeaders = headers && normalizeHeaders(headers);
2316
3216
  return async function makeHttpRequest({
2317
3217
  payload,
@@ -2319,7 +3219,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
2319
3219
  }) {
2320
3220
  const body = JSON.stringify(payload);
2321
3221
  const requestInfo = {
2322
- agent,
2323
3222
  body,
2324
3223
  headers: {
2325
3224
  ...customHeaders,
@@ -2331,7 +3230,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2331
3230
  method: "POST",
2332
3231
  signal
2333
3232
  };
2334
- const response = await e(url, requestInfo);
3233
+ const response = await e2(url, requestInfo);
2335
3234
  if (!response.ok) {
2336
3235
  throw new SolanaHttpError({
2337
3236
  message: response.statusText,
@@ -2341,7 +3240,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
2341
3240
  return await response.json();
2342
3241
  };
2343
3242
  }
2344
- var e2 = globalThis.WebSocket;
3243
+ var e22 = globalThis.WebSocket;
3244
+ var EXPLICIT_ABORT_TOKEN = Symbol(
3245
+ "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
3246
+ );
2345
3247
  async function createWebSocketConnection({
2346
3248
  sendBufferHighWatermark,
2347
3249
  signal,
@@ -2350,27 +3252,30 @@ this.globalThis.solanaWeb3 = (function (exports) {
2350
3252
  return new Promise((resolve, reject) => {
2351
3253
  signal.addEventListener("abort", handleAbort, { once: true });
2352
3254
  const iteratorState = /* @__PURE__ */ new Map();
3255
+ function errorAndClearAllIteratorStates(reason) {
3256
+ const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
3257
+ iteratorState.clear();
3258
+ errorCallbacks.forEach((cb) => {
3259
+ try {
3260
+ cb(reason);
3261
+ } catch {
3262
+ }
3263
+ });
3264
+ }
2353
3265
  function handleAbort() {
2354
- if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
3266
+ errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
3267
+ if (webSocket.readyState !== e22.CLOSED && webSocket.readyState !== e22.CLOSING) {
2355
3268
  webSocket.close(1e3);
2356
3269
  }
2357
3270
  }
2358
3271
  function handleClose(ev) {
2359
- bufferDrainWatcher?.onCancel();
3272
+ bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
2360
3273
  signal.removeEventListener("abort", handleAbort);
2361
3274
  webSocket.removeEventListener("close", handleClose);
2362
3275
  webSocket.removeEventListener("error", handleError);
2363
3276
  webSocket.removeEventListener("open", handleOpen);
2364
3277
  webSocket.removeEventListener("message", handleMessage);
2365
- iteratorState.forEach((state, iteratorKey) => {
2366
- if (state.__hasPolled) {
2367
- const { onError } = state;
2368
- iteratorState.delete(iteratorKey);
2369
- onError(ev);
2370
- } else {
2371
- iteratorState.delete(iteratorKey);
2372
- }
2373
- });
3278
+ errorAndClearAllIteratorStates(ev);
2374
3279
  }
2375
3280
  function handleError(ev) {
2376
3281
  if (!hasConnected) {
@@ -2387,11 +3292,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2387
3292
  resolve({
2388
3293
  async send(payload) {
2389
3294
  const message = JSON.stringify(payload);
2390
- if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
3295
+ if (!bufferDrainWatcher && webSocket.readyState === e22.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
2391
3296
  let onCancel;
2392
3297
  const promise = new Promise((resolve2, reject2) => {
2393
3298
  const intervalId = setInterval(() => {
2394
- if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
3299
+ if (webSocket.readyState !== e22.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
2395
3300
  clearInterval(intervalId);
2396
3301
  bufferDrainWatcher = void 0;
2397
3302
  resolve2();
@@ -2438,15 +3343,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
2438
3343
  yield* queuedMessages;
2439
3344
  } else {
2440
3345
  try {
2441
- yield await new Promise((onMessage, onError) => {
3346
+ yield await new Promise((resolve2, reject2) => {
2442
3347
  iteratorState.set(iteratorKey, {
2443
3348
  __hasPolled: true,
2444
- onError,
2445
- onMessage
3349
+ onError: reject2,
3350
+ onMessage: resolve2
2446
3351
  });
2447
3352
  });
2448
3353
  } catch (e3) {
2449
- if (e3 !== null && typeof e3 === "object" && "type" in e3 && e3.type === "close" && "wasClean" in e3 && e3.wasClean) {
3354
+ if (e3 === EXPLICIT_ABORT_TOKEN) {
2450
3355
  return;
2451
3356
  } else {
2452
3357
  throw new Error("WebSocket connection closed", { cause: e3 });
@@ -2472,7 +3377,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2472
3377
  }
2473
3378
  });
2474
3379
  }
2475
- const webSocket = new e2(url);
3380
+ const webSocket = new e22(url);
2476
3381
  webSocket.addEventListener("close", handleClose);
2477
3382
  webSocket.addEventListener("error", handleError);
2478
3383
  webSocket.addEventListener("open", handleOpen);
@@ -2487,13 +3392,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
2487
3392
  );
2488
3393
  }
2489
3394
  return async function sendWebSocketMessage({ payload, signal }) {
2490
- signal?.throwIfAborted();
3395
+ signal == null ? void 0 : signal.throwIfAborted();
2491
3396
  const connection = await createWebSocketConnection({
2492
3397
  sendBufferHighWatermark,
2493
3398
  signal,
2494
3399
  url
2495
3400
  });
2496
- signal?.throwIfAborted();
3401
+ signal == null ? void 0 : signal.throwIfAborted();
2497
3402
  await connection.send(payload);
2498
3403
  return {
2499
3404
  [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
@@ -2502,6 +3407,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2502
3407
  };
2503
3408
  }
2504
3409
 
3410
+ // src/rpc.ts
3411
+ var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
3412
+
2505
3413
  // src/rpc-default-config.ts
2506
3414
  init_env_shim();
2507
3415
 
@@ -2526,6 +3434,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2526
3434
  super(
2527
3435
  `The ${ordinal} argument to the \`${methodName}\` RPC method${path ? ` at path \`${path}\`` : ""} was \`${value}\`. This number is unsafe for use with the Solana JSON-RPC because it exceeds \`Number.MAX_SAFE_INTEGER\`.`
2528
3436
  );
3437
+ __publicField(this, "methodName");
3438
+ __publicField(this, "keyPath");
3439
+ __publicField(this, "value");
2529
3440
  this.keyPath = keyPath;
2530
3441
  this.methodName = methodName;
2531
3442
  this.value = value;
@@ -2542,6 +3453,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
2542
3453
  }
2543
3454
  };
2544
3455
 
3456
+ // src/rpc-subscription-coalescer.ts
3457
+ init_env_shim();
3458
+
3459
+ // src/cached-abortable-iterable.ts
3460
+ init_env_shim();
3461
+ function registerIterableCleanup2(iterable, cleanupFn) {
3462
+ (async () => {
3463
+ try {
3464
+ for await (const _ of iterable)
3465
+ ;
3466
+ } catch {
3467
+ } finally {
3468
+ cleanupFn();
3469
+ }
3470
+ })();
3471
+ }
3472
+ function getCachedAbortableIterableFactory({
3473
+ getAbortSignalFromInputArgs,
3474
+ getCacheEntryMissingError,
3475
+ getCacheKeyFromInputArgs,
3476
+ onCacheHit,
3477
+ onCreateIterable
3478
+ }) {
3479
+ const cache = /* @__PURE__ */ new Map();
3480
+ function getCacheEntryOrThrow(cacheKey) {
3481
+ const currentCacheEntry = cache.get(cacheKey);
3482
+ if (!currentCacheEntry) {
3483
+ throw getCacheEntryMissingError(cacheKey);
3484
+ }
3485
+ return currentCacheEntry;
3486
+ }
3487
+ return async (...args) => {
3488
+ const cacheKey = getCacheKeyFromInputArgs(...args);
3489
+ const signal = getAbortSignalFromInputArgs(...args);
3490
+ if (cacheKey === void 0) {
3491
+ return await onCreateIterable(signal, ...args);
3492
+ }
3493
+ const cleanup = () => {
3494
+ cache.delete(cacheKey);
3495
+ signal.removeEventListener("abort", handleAbort);
3496
+ };
3497
+ const handleAbort = () => {
3498
+ const cacheEntry = getCacheEntryOrThrow(cacheKey);
3499
+ if (cacheEntry.purgeScheduled !== true) {
3500
+ cacheEntry.purgeScheduled = true;
3501
+ globalThis.queueMicrotask(() => {
3502
+ cacheEntry.purgeScheduled = false;
3503
+ if (cacheEntry.referenceCount === 0) {
3504
+ cacheEntry.abortController.abort();
3505
+ cleanup();
3506
+ }
3507
+ });
3508
+ }
3509
+ cacheEntry.referenceCount--;
3510
+ };
3511
+ signal.addEventListener("abort", handleAbort);
3512
+ try {
3513
+ const cacheEntry = cache.get(cacheKey);
3514
+ if (!cacheEntry) {
3515
+ const singletonAbortController = new AbortController();
3516
+ const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
3517
+ const newCacheEntry = {
3518
+ abortController: singletonAbortController,
3519
+ iterable: newIterablePromise,
3520
+ purgeScheduled: false,
3521
+ referenceCount: 1
3522
+ };
3523
+ cache.set(cacheKey, newCacheEntry);
3524
+ const newIterable = await newIterablePromise;
3525
+ registerIterableCleanup2(newIterable, cleanup);
3526
+ newCacheEntry.iterable = newIterable;
3527
+ return newIterable;
3528
+ } else {
3529
+ cacheEntry.referenceCount++;
3530
+ const iterableOrIterablePromise = cacheEntry.iterable;
3531
+ const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
3532
+ await onCacheHit(cachedIterable, ...args);
3533
+ return cachedIterable;
3534
+ }
3535
+ } catch (e3) {
3536
+ cleanup();
3537
+ throw e3;
3538
+ }
3539
+ };
3540
+ }
3541
+
3542
+ // src/rpc-subscription-coalescer.ts
3543
+ var EXPLICIT_ABORT_TOKEN2 = Symbol(
3544
+ "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
3545
+ );
3546
+ function registerIterableCleanup3(iterable, cleanupFn) {
3547
+ (async () => {
3548
+ try {
3549
+ for await (const _ of iterable)
3550
+ ;
3551
+ } catch {
3552
+ } finally {
3553
+ cleanupFn();
3554
+ }
3555
+ })();
3556
+ }
3557
+ function getRpcSubscriptionsWithSubscriptionCoalescing({
3558
+ getDeduplicationKey,
3559
+ rpcSubscriptions
3560
+ }) {
3561
+ const cache = /* @__PURE__ */ new Map();
3562
+ return new Proxy(rpcSubscriptions, {
3563
+ defineProperty() {
3564
+ return false;
3565
+ },
3566
+ deleteProperty() {
3567
+ return false;
3568
+ },
3569
+ get(target, p, receiver) {
3570
+ const subscriptionMethod = Reflect.get(target, p, receiver);
3571
+ if (typeof subscriptionMethod !== "function") {
3572
+ return subscriptionMethod;
3573
+ }
3574
+ return function(...rawParams) {
3575
+ const deduplicationKey = getDeduplicationKey(p, rawParams);
3576
+ if (deduplicationKey === void 0) {
3577
+ return subscriptionMethod(...rawParams);
3578
+ }
3579
+ if (cache.has(deduplicationKey)) {
3580
+ return cache.get(deduplicationKey);
3581
+ }
3582
+ const iterableFactory = getCachedAbortableIterableFactory({
3583
+ getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
3584
+ getCacheEntryMissingError(deduplicationKey2) {
3585
+ return new Error(
3586
+ `Found no cache entry for subscription with deduplication key \`${deduplicationKey2 == null ? void 0 : deduplicationKey2.toString()}\``
3587
+ );
3588
+ },
3589
+ getCacheKeyFromInputArgs: () => deduplicationKey,
3590
+ async onCacheHit(_iterable, _config) {
3591
+ },
3592
+ async onCreateIterable(abortSignal, config) {
3593
+ const pendingSubscription2 = subscriptionMethod(
3594
+ ...rawParams
3595
+ );
3596
+ const iterable = await pendingSubscription2.subscribe({
3597
+ ...config,
3598
+ abortSignal
3599
+ });
3600
+ registerIterableCleanup3(iterable, () => {
3601
+ cache.delete(deduplicationKey);
3602
+ });
3603
+ return iterable;
3604
+ }
3605
+ });
3606
+ const pendingSubscription = {
3607
+ async subscribe(...args) {
3608
+ const iterable = await iterableFactory(...args);
3609
+ const { abortSignal } = args[0];
3610
+ let abortPromise;
3611
+ return {
3612
+ ...iterable,
3613
+ async *[Symbol.asyncIterator]() {
3614
+ abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
3615
+ abortSignal.addEventListener("abort", () => {
3616
+ reject(EXPLICIT_ABORT_TOKEN2);
3617
+ });
3618
+ }));
3619
+ try {
3620
+ const iterator = iterable[Symbol.asyncIterator]();
3621
+ while (true) {
3622
+ const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
3623
+ if (iteratorResult.done) {
3624
+ return;
3625
+ } else {
3626
+ yield iteratorResult.value;
3627
+ }
3628
+ }
3629
+ } catch (e3) {
3630
+ if (e3 === EXPLICIT_ABORT_TOKEN2) {
3631
+ return;
3632
+ }
3633
+ cache.delete(deduplicationKey);
3634
+ throw e3;
3635
+ }
3636
+ }
3637
+ };
3638
+ }
3639
+ };
3640
+ cache.set(deduplicationKey, pendingSubscription);
3641
+ return pendingSubscription;
3642
+ };
3643
+ }
3644
+ });
3645
+ }
3646
+
2545
3647
  // src/rpc.ts
2546
3648
  function createSolanaRpc(config) {
2547
3649
  return createJsonRpc({
@@ -2550,9 +3652,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
2550
3652
  });
2551
3653
  }
2552
3654
  function createSolanaRpcSubscriptions(config) {
3655
+ return pipe(
3656
+ createJsonSubscriptionRpc({
3657
+ ...config,
3658
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
3659
+ }),
3660
+ (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
3661
+ getDeduplicationKey: (...args) => (0, import_fast_stable_stringify.default)(args),
3662
+ rpcSubscriptions
3663
+ })
3664
+ );
3665
+ }
3666
+ function createSolanaRpcSubscriptions_UNSTABLE(config) {
2553
3667
  return createJsonSubscriptionRpc({
2554
3668
  ...config,
2555
- api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
3669
+ api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
2556
3670
  });
2557
3671
  }
2558
3672
 
@@ -2614,14 +3728,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
2614
3728
 
2615
3729
  // src/rpc-request-deduplication.ts
2616
3730
  init_env_shim();
2617
- var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
2618
- function getSolanaRpcPayloadDeduplicationKey(payload) {
3731
+ var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
3732
+ function isJsonRpcPayload(payload) {
2619
3733
  if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
2620
- return;
2621
- }
2622
- if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
2623
- return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
3734
+ return false;
2624
3735
  }
3736
+ return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
3737
+ }
3738
+ function getSolanaRpcPayloadDeduplicationKey(payload) {
3739
+ return isJsonRpcPayload(payload) ? (0, import_fast_stable_stringify2.default)([payload.method, payload.params]) : void 0;
2625
3740
  }
2626
3741
 
2627
3742
  // src/rpc-transport.ts
@@ -2633,18 +3748,19 @@ this.globalThis.solanaWeb3 = (function (exports) {
2633
3748
  return out;
2634
3749
  }
2635
3750
  function createDefaultRpcTransport(config) {
2636
- return getRpcTransportWithRequestCoalescing(
3751
+ var _a;
3752
+ return pipe(
2637
3753
  createHttpTransport({
2638
3754
  ...config,
2639
3755
  headers: {
2640
3756
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
2641
3757
  ...{
2642
3758
  // Keep these headers lowercase so they will override any user-supplied headers above.
2643
- "solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
3759
+ "solana-client": (_a = `js/${"2.0.0-development"}`) != null ? _a : "UNKNOWN"
2644
3760
  }
2645
3761
  }
2646
3762
  }),
2647
- getSolanaRpcPayloadDeduplicationKey
3763
+ (transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
2648
3764
  );
2649
3765
  }
2650
3766
 
@@ -2715,50 +3831,403 @@ this.globalThis.solanaWeb3 = (function (exports) {
2715
3831
  };
2716
3832
  }
2717
3833
 
3834
+ // src/rpc-websocket-connection-sharding.ts
3835
+ init_env_shim();
3836
+ var NULL_SHARD_CACHE_KEY = Symbol(
3837
+ "Cache key to use when there is no connection sharding strategy"
3838
+ );
3839
+ function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
3840
+ return getCachedAbortableIterableFactory({
3841
+ getAbortSignalFromInputArgs: ({ signal }) => signal,
3842
+ getCacheEntryMissingError(shardKey) {
3843
+ return new Error(`Found no cache entry for connection with shard key \`${shardKey == null ? void 0 : shardKey.toString()}\``);
3844
+ },
3845
+ getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
3846
+ onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
3847
+ onCreateIterable: (abortSignal, config) => transport({
3848
+ ...config,
3849
+ signal: abortSignal
3850
+ })
3851
+ });
3852
+ }
3853
+
2718
3854
  // src/rpc-websocket-transport.ts
2719
3855
  function createDefaultRpcSubscriptionsTransport(config) {
2720
- const { intervalMs, ...rest } = config;
2721
- return getWebSocketTransportWithAutoping({
2722
- intervalMs: intervalMs ?? 5e3,
2723
- transport: createWebSocketTransport({
3856
+ var _a;
3857
+ const { getShard, intervalMs, ...rest } = config;
3858
+ return pipe(
3859
+ createWebSocketTransport({
2724
3860
  ...rest,
2725
- sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
2726
- 131072
3861
+ sendBufferHighWatermark: (_a = config.sendBufferHighWatermark) != null ? _a : (
3862
+ // Let 128KB of data into the WebSocket buffer before buffering it in the app.
3863
+ 131072
3864
+ )
3865
+ }),
3866
+ (transport) => getWebSocketTransportWithAutoping({
3867
+ intervalMs: intervalMs != null ? intervalMs : 5e3,
3868
+ transport
3869
+ }),
3870
+ (transport) => getWebSocketTransportWithConnectionSharding({
3871
+ getShard,
3872
+ transport
2727
3873
  })
3874
+ );
3875
+ }
3876
+
3877
+ // src/send-transaction.ts
3878
+ init_env_shim();
3879
+
3880
+ // src/transaction-confirmation.ts
3881
+ init_env_shim();
3882
+
3883
+ // src/transaction-confirmation-strategy-blockheight.ts
3884
+ init_env_shim();
3885
+ function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
3886
+ return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
3887
+ const abortController = new AbortController();
3888
+ function handleAbort() {
3889
+ abortController.abort();
3890
+ }
3891
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3892
+ const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
3893
+ try {
3894
+ for await (const slotNotification of slotNotifications) {
3895
+ if (slotNotification.slot > lastValidBlockHeight) {
3896
+ throw new Error(
3897
+ "The network has progressed past the last block for which this transaction could have committed."
3898
+ );
3899
+ }
3900
+ }
3901
+ } finally {
3902
+ abortController.abort();
3903
+ }
3904
+ };
3905
+ }
3906
+
3907
+ // src/transaction-confirmation-strategy-nonce.ts
3908
+ init_env_shim();
3909
+ var NONCE_VALUE_OFFSET = 4 + // version(u32)
3910
+ 4 + // state(u32)
3911
+ 32;
3912
+ function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
3913
+ return async function getNonceInvalidationPromise({
3914
+ abortSignal: callerAbortSignal,
3915
+ commitment,
3916
+ currentNonceValue,
3917
+ nonceAccountAddress
3918
+ }) {
3919
+ const abortController = new AbortController();
3920
+ function handleAbort() {
3921
+ abortController.abort();
3922
+ }
3923
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3924
+ const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
3925
+ const base58Decoder2 = getBase58Decoder();
3926
+ const base64Encoder = getBase64Encoder();
3927
+ function getNonceFromAccountData([base64EncodedBytes]) {
3928
+ const data = base64Encoder.encode(base64EncodedBytes);
3929
+ const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
3930
+ return base58Decoder2.decode(nonceValueBytes)[0];
3931
+ }
3932
+ const nonceAccountDidAdvancePromise = (async () => {
3933
+ for await (const accountNotification of accountNotifications) {
3934
+ const nonceValue = getNonceFromAccountData(accountNotification.value.data);
3935
+ if (nonceValue !== currentNonceValue) {
3936
+ throw new Error(
3937
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3938
+ );
3939
+ }
3940
+ }
3941
+ })();
3942
+ const nonceIsAlreadyInvalidPromise = (async () => {
3943
+ const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
3944
+ commitment,
3945
+ dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
3946
+ encoding: "base58"
3947
+ }).send({ abortSignal: abortController.signal });
3948
+ if (!nonceAccount) {
3949
+ throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
3950
+ }
3951
+ const nonceValue = (
3952
+ // This works because we asked for the exact slice of data representing the nonce
3953
+ // value, and furthermore asked for it in `base58` encoding.
3954
+ nonceAccount.data[0]
3955
+ );
3956
+ if (nonceValue !== currentNonceValue) {
3957
+ throw new Error(
3958
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3959
+ );
3960
+ } else {
3961
+ await new Promise(() => {
3962
+ });
3963
+ }
3964
+ })();
3965
+ try {
3966
+ return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
3967
+ } finally {
3968
+ abortController.abort();
3969
+ }
3970
+ };
3971
+ }
3972
+
3973
+ // src/transaction-confirmation.ts
3974
+ function createDefaultDurableNonceTransactionConfirmer({
3975
+ rpc,
3976
+ rpcSubscriptions
3977
+ }) {
3978
+ const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
3979
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3980
+ rpc,
3981
+ rpcSubscriptions
3982
+ );
3983
+ return async function confirmDurableNonceTransaction(config) {
3984
+ await waitForDurableNonceTransactionConfirmation({
3985
+ ...config,
3986
+ getNonceInvalidationPromise,
3987
+ getRecentSignatureConfirmationPromise
3988
+ });
3989
+ };
3990
+ }
3991
+ function createDefaultRecentTransactionConfirmer({
3992
+ rpc,
3993
+ rpcSubscriptions
3994
+ }) {
3995
+ const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
3996
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3997
+ rpc,
3998
+ rpcSubscriptions
3999
+ );
4000
+ return async function confirmRecentTransaction(config) {
4001
+ await waitForRecentTransactionConfirmation({
4002
+ ...config,
4003
+ getBlockHeightExceedencePromise,
4004
+ getRecentSignatureConfirmationPromise
4005
+ });
4006
+ };
4007
+ }
4008
+ async function waitForDurableNonceTransactionConfirmation(config) {
4009
+ await raceStrategies(
4010
+ getSignatureFromTransaction(config.transaction),
4011
+ config,
4012
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
4013
+ return [
4014
+ getNonceInvalidationPromise({
4015
+ abortSignal,
4016
+ commitment,
4017
+ currentNonceValue: transaction.lifetimeConstraint.nonce,
4018
+ nonceAccountAddress: transaction.instructions[0].accounts[0].address
4019
+ })
4020
+ ];
4021
+ }
4022
+ );
4023
+ }
4024
+ async function waitForRecentTransactionConfirmation(config) {
4025
+ await raceStrategies(
4026
+ getSignatureFromTransaction(config.transaction),
4027
+ config,
4028
+ function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
4029
+ return [
4030
+ getBlockHeightExceedencePromise({
4031
+ abortSignal,
4032
+ lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
4033
+ })
4034
+ ];
4035
+ }
4036
+ );
4037
+ }
4038
+
4039
+ // src/send-transaction.ts
4040
+ function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
4041
+ if (
4042
+ // The developer has supplied no value for `preflightCommitment`.
4043
+ !(config == null ? void 0 : config.preflightCommitment) && // The value of `commitment` is lower than the server default of `preflightCommitment`.
4044
+ commitmentComparator(
4045
+ commitment,
4046
+ "finalized"
4047
+ /* default value of `preflightCommitment` */
4048
+ ) < 0
4049
+ ) {
4050
+ return {
4051
+ ...config,
4052
+ // In the common case, it is unlikely that you want to simulate a transaction at
4053
+ // `finalized` commitment when your standard of commitment for confirming the
4054
+ // transaction is lower. Cap the simulation commitment level to the level of the
4055
+ // confirmation commitment.
4056
+ preflightCommitment: commitment
4057
+ };
4058
+ }
4059
+ return config;
4060
+ }
4061
+ async function sendTransaction_INTERNAL({
4062
+ abortSignal,
4063
+ commitment,
4064
+ rpc,
4065
+ transaction,
4066
+ ...sendTransactionConfig
4067
+ }) {
4068
+ const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
4069
+ return await rpc.sendTransaction(base64EncodedWireTransaction, {
4070
+ ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
4071
+ encoding: "base64"
4072
+ }).send({ abortSignal });
4073
+ }
4074
+ function createDefaultDurableNonceTransactionSender({
4075
+ rpc,
4076
+ rpcSubscriptions
4077
+ }) {
4078
+ const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
4079
+ rpc,
4080
+ rpcSubscriptions
4081
+ });
4082
+ return async function sendDurableNonceTransaction(transaction, config) {
4083
+ await sendAndConfirmDurableNonceTransaction({
4084
+ ...config,
4085
+ confirmDurableNonceTransaction,
4086
+ rpc,
4087
+ transaction
4088
+ });
4089
+ };
4090
+ }
4091
+ function createDefaultTransactionSender({
4092
+ rpc,
4093
+ rpcSubscriptions
4094
+ }) {
4095
+ const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
4096
+ rpc,
4097
+ rpcSubscriptions
4098
+ });
4099
+ return async function sendTransaction(transaction, config) {
4100
+ await sendAndConfirmTransaction({
4101
+ ...config,
4102
+ confirmRecentTransaction,
4103
+ rpc,
4104
+ transaction
4105
+ });
4106
+ };
4107
+ }
4108
+ async function sendAndConfirmDurableNonceTransaction({
4109
+ abortSignal,
4110
+ commitment,
4111
+ confirmDurableNonceTransaction,
4112
+ rpc,
4113
+ transaction,
4114
+ ...sendTransactionConfig
4115
+ }) {
4116
+ const transactionSignature = await sendTransaction_INTERNAL({
4117
+ ...sendTransactionConfig,
4118
+ abortSignal,
4119
+ commitment,
4120
+ rpc,
4121
+ transaction
4122
+ });
4123
+ await confirmDurableNonceTransaction({
4124
+ abortSignal,
4125
+ commitment,
4126
+ transaction
4127
+ });
4128
+ return transactionSignature;
4129
+ }
4130
+ async function sendAndConfirmTransaction({
4131
+ abortSignal,
4132
+ commitment,
4133
+ confirmRecentTransaction,
4134
+ rpc,
4135
+ transaction,
4136
+ ...sendTransactionConfig
4137
+ }) {
4138
+ const transactionSignature = await sendTransaction_INTERNAL({
4139
+ ...sendTransactionConfig,
4140
+ abortSignal,
4141
+ commitment,
4142
+ rpc,
4143
+ transaction
4144
+ });
4145
+ await confirmRecentTransaction({
4146
+ abortSignal,
4147
+ commitment,
4148
+ transaction
2728
4149
  });
4150
+ return transactionSignature;
2729
4151
  }
2730
4152
 
2731
4153
  exports.AccountRole = AccountRole;
4154
+ exports.address = address;
2732
4155
  exports.appendTransactionInstruction = appendTransactionInstruction;
2733
- exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
4156
+ exports.assertIsAddress = assertIsAddress;
2734
4157
  exports.assertIsBlockhash = assertIsBlockhash;
2735
4158
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
4159
+ exports.assertIsLamports = assertIsLamports;
4160
+ exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
4161
+ exports.assertIsSignature = assertIsSignature;
4162
+ exports.assertIsStringifiedBigInt = assertIsStringifiedBigInt;
4163
+ exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
4164
+ exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
4165
+ exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
4166
+ exports.commitmentComparator = commitmentComparator;
4167
+ exports.compileMessage = compileMessage;
2736
4168
  exports.createAddressWithSeed = createAddressWithSeed;
4169
+ exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
4170
+ exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
4171
+ exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
4172
+ exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
4173
+ exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
2737
4174
  exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
2738
4175
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
4176
+ exports.createDefaultTransactionSender = createDefaultTransactionSender;
4177
+ exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
4178
+ exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
2739
4179
  exports.createSolanaRpc = createSolanaRpc;
2740
4180
  exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
4181
+ exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
2741
4182
  exports.createTransaction = createTransaction;
2742
4183
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
2743
4184
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
2744
4185
  exports.generateKeyPair = generateKeyPair;
4186
+ exports.getAddressCodec = getAddressCodec;
4187
+ exports.getAddressComparator = getAddressComparator;
4188
+ exports.getAddressDecoder = getAddressDecoder;
4189
+ exports.getAddressEncoder = getAddressEncoder;
2745
4190
  exports.getAddressFromPublicKey = getAddressFromPublicKey;
2746
- exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
2747
- exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
2748
4191
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
4192
+ exports.getCompiledMessageCodec = getCompiledMessageCodec;
4193
+ exports.getCompiledMessageDecoder = getCompiledMessageDecoder;
4194
+ exports.getCompiledMessageEncoder = getCompiledMessageEncoder;
2749
4195
  exports.getProgramDerivedAddress = getProgramDerivedAddress;
4196
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
4197
+ exports.getTransactionCodec = getTransactionCodec;
4198
+ exports.getTransactionDecoder = getTransactionDecoder;
4199
+ exports.getTransactionEncoder = getTransactionEncoder;
4200
+ exports.isAddress = isAddress;
4201
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
4202
+ exports.isLamports = isLamports;
4203
+ exports.isProgramDerivedAddress = isProgramDerivedAddress;
4204
+ exports.isSignature = isSignature;
2750
4205
  exports.isSignerRole = isSignerRole;
4206
+ exports.isStringifiedBigInt = isStringifiedBigInt;
4207
+ exports.isStringifiedNumber = isStringifiedNumber;
4208
+ exports.isUnixTimestamp = isUnixTimestamp;
2751
4209
  exports.isWritableRole = isWritableRole;
4210
+ exports.lamports = lamports;
2752
4211
  exports.mergeRoles = mergeRoles;
4212
+ exports.partiallySignTransaction = partiallySignTransaction;
2753
4213
  exports.prependTransactionInstruction = prependTransactionInstruction;
4214
+ exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
4215
+ exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
4216
+ exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
2754
4217
  exports.setTransactionFeePayer = setTransactionFeePayer;
2755
4218
  exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
2756
4219
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
2757
4220
  exports.signBytes = signBytes;
2758
4221
  exports.signTransaction = signTransaction;
4222
+ exports.signature = signature;
4223
+ exports.stringifiedBigInt = stringifiedBigInt;
4224
+ exports.stringifiedNumber = stringifiedNumber;
4225
+ exports.unixTimestamp = unixTimestamp;
2759
4226
  exports.upgradeRoleToSigner = upgradeRoleToSigner;
2760
4227
  exports.upgradeRoleToWritable = upgradeRoleToWritable;
2761
4228
  exports.verifySignature = verifySignature;
4229
+ exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
4230
+ exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
2762
4231
 
2763
4232
  return exports;
2764
4233