@solana/web3.js 2.0.0-experimental.63683a4 → 2.0.0-experimental.63c7492

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 (46) hide show
  1. package/README.md +57 -17
  2. package/dist/index.browser.cjs +6 -3
  3. package/dist/index.browser.cjs.map +1 -1
  4. package/dist/index.browser.js +8 -3
  5. package/dist/index.browser.js.map +1 -1
  6. package/dist/index.development.js +808 -832
  7. package/dist/index.development.js.map +1 -1
  8. package/dist/index.native.js +6 -3
  9. package/dist/index.native.js.map +1 -1
  10. package/dist/index.node.cjs +6 -3
  11. package/dist/index.node.cjs.map +1 -1
  12. package/dist/index.node.js +6 -3
  13. package/dist/index.node.js.map +1 -1
  14. package/dist/index.production.min.js +82 -75
  15. package/dist/types/airdrop-confirmer.d.ts +6 -7
  16. package/dist/types/airdrop-confirmer.d.ts.map +1 -1
  17. package/dist/types/airdrop.d.ts +6 -8
  18. package/dist/types/airdrop.d.ts.map +1 -1
  19. package/dist/types/index.d.ts +9 -9
  20. package/dist/types/rpc-request-coalescer.d.ts +1 -1
  21. package/dist/types/rpc-request-coalescer.d.ts.map +1 -1
  22. package/dist/types/rpc-subscription-coalescer.d.ts +1 -1
  23. package/dist/types/rpc-subscription-coalescer.d.ts.map +1 -1
  24. package/dist/types/rpc-transport.d.ts +1 -2
  25. package/dist/types/rpc-transport.d.ts.map +1 -1
  26. package/dist/types/rpc-websocket-autopinger.d.ts +1 -1
  27. package/dist/types/rpc-websocket-autopinger.d.ts.map +1 -1
  28. package/dist/types/rpc-websocket-connection-sharding.d.ts +1 -1
  29. package/dist/types/rpc-websocket-connection-sharding.d.ts.map +1 -1
  30. package/dist/types/rpc-websocket-transport.d.ts +1 -2
  31. package/dist/types/rpc-websocket-transport.d.ts.map +1 -1
  32. package/dist/types/rpc.d.ts +1 -2
  33. package/dist/types/rpc.d.ts.map +1 -1
  34. package/dist/types/send-transaction.d.ts +7 -6
  35. package/dist/types/send-transaction.d.ts.map +1 -1
  36. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +2 -3
  37. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts.map +1 -1
  38. package/dist/types/transaction-confirmation-strategy-nonce.d.ts +2 -3
  39. package/dist/types/transaction-confirmation-strategy-nonce.d.ts.map +1 -1
  40. package/dist/types/transaction-confirmation-strategy-racer.d.ts +3 -3
  41. package/dist/types/transaction-confirmation-strategy-racer.d.ts.map +1 -1
  42. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +4 -5
  43. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts.map +1 -1
  44. package/dist/types/transaction-confirmation.d.ts +5 -10
  45. package/dist/types/transaction-confirmation.d.ts.map +1 -1
  46. package/package.json +15 -15
@@ -8,6 +8,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
8
8
  var __getOwnPropNames = Object.getOwnPropertyNames;
9
9
  var __getProtoOf = Object.getPrototypeOf;
10
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
11
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
12
  var __esm = (fn, res) => function __init() {
12
13
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
14
  };
@@ -30,6 +31,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
30
31
  isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
31
32
  mod2
32
33
  ));
34
+ var __publicField = (obj, key, value) => {
35
+ __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
+ return value;
37
+ };
33
38
 
34
39
  // ../build-scripts/env-shim.ts
35
40
  var init_env_shim = __esm({
@@ -133,23 +138,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
133
138
  throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
134
139
  }
135
140
  }
136
- var mergeBytes = (byteArrays) => {
137
- const nonEmptyByteArrays = byteArrays.filter((arr) => arr.length);
138
- if (nonEmptyByteArrays.length === 0) {
139
- return byteArrays.length ? byteArrays[0] : new Uint8Array();
140
- }
141
- if (nonEmptyByteArrays.length === 1) {
142
- return nonEmptyByteArrays[0];
143
- }
144
- const totalLength = nonEmptyByteArrays.reduce((total, arr) => total + arr.length, 0);
145
- const result = new Uint8Array(totalLength);
146
- let offset = 0;
147
- nonEmptyByteArrays.forEach((arr) => {
148
- result.set(arr, offset);
149
- offset += arr.length;
150
- });
151
- return result;
152
- };
153
141
  var padBytes = (bytes, length) => {
154
142
  if (bytes.length >= length)
155
143
  return bytes;
@@ -158,77 +146,100 @@ this.globalThis.solanaWeb3 = (function (exports) {
158
146
  return paddedBytes;
159
147
  };
160
148
  var fixBytes = (bytes, length) => padBytes(bytes.length <= length ? bytes : bytes.slice(0, length), length);
161
- function combineCodec(encoder, decoder, description) {
162
- if (encoder.fixedSize !== decoder.fixedSize) {
149
+ function getEncodedSize(value, encoder) {
150
+ return "fixedSize" in encoder ? encoder.fixedSize : encoder.getSizeFromValue(value);
151
+ }
152
+ function createEncoder(encoder) {
153
+ return Object.freeze({
154
+ ...encoder,
155
+ encode: (value) => {
156
+ const bytes = new Uint8Array(getEncodedSize(value, encoder));
157
+ encoder.write(value, bytes, 0);
158
+ return bytes;
159
+ }
160
+ });
161
+ }
162
+ function createDecoder(decoder) {
163
+ return Object.freeze({
164
+ ...decoder,
165
+ decode: (bytes, offset = 0) => decoder.read(bytes, offset)[0]
166
+ });
167
+ }
168
+ function isFixedSize(codec) {
169
+ return "fixedSize" in codec && typeof codec.fixedSize === "number";
170
+ }
171
+ function assertIsFixedSize(codec, message) {
172
+ if (!isFixedSize(codec)) {
173
+ throw new Error(message != null ? message : "Expected a fixed-size codec, got a variable-size one.");
174
+ }
175
+ }
176
+ function isVariableSize(codec) {
177
+ return !isFixedSize(codec);
178
+ }
179
+ function combineCodec(encoder, decoder) {
180
+ if (isFixedSize(encoder) !== isFixedSize(decoder)) {
181
+ throw new Error(`Encoder and decoder must either both be fixed-size or variable-size.`);
182
+ }
183
+ if (isFixedSize(encoder) && isFixedSize(decoder) && encoder.fixedSize !== decoder.fixedSize) {
163
184
  throw new Error(
164
185
  `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
165
186
  );
166
187
  }
167
- if (encoder.maxSize !== decoder.maxSize) {
188
+ if (!isFixedSize(encoder) && !isFixedSize(decoder) && encoder.maxSize !== decoder.maxSize) {
168
189
  throw new Error(
169
190
  `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
170
191
  );
171
192
  }
172
- if (description === void 0 && encoder.description !== decoder.description) {
173
- throw new Error(
174
- `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.`
175
- );
176
- }
177
193
  return {
194
+ ...decoder,
195
+ ...encoder,
178
196
  decode: decoder.decode,
179
- description: description ?? encoder.description,
180
197
  encode: encoder.encode,
181
- fixedSize: encoder.fixedSize,
182
- maxSize: encoder.maxSize
198
+ read: decoder.read,
199
+ write: encoder.write
183
200
  };
184
201
  }
185
- function fixCodecHelper(data, fixedBytes, description) {
186
- return {
187
- description: description ?? `fixed(${fixedBytes}, ${data.description})`,
202
+ function fixEncoder(encoder, fixedBytes) {
203
+ return createEncoder({
188
204
  fixedSize: fixedBytes,
189
- maxSize: fixedBytes
190
- };
191
- }
192
- function fixEncoder(encoder, fixedBytes, description) {
193
- return {
194
- ...fixCodecHelper(encoder, fixedBytes, description),
195
- encode: (value) => fixBytes(encoder.encode(value), fixedBytes)
196
- };
205
+ write: (value, bytes, offset) => {
206
+ const variableByteArray = encoder.encode(value);
207
+ const fixedByteArray = variableByteArray.length > fixedBytes ? variableByteArray.slice(0, fixedBytes) : variableByteArray;
208
+ bytes.set(fixedByteArray, offset);
209
+ return offset + fixedBytes;
210
+ }
211
+ });
197
212
  }
198
- function fixDecoder(decoder, fixedBytes, description) {
199
- return {
200
- ...fixCodecHelper(decoder, fixedBytes, description),
201
- decode: (bytes, offset = 0) => {
213
+ function fixDecoder(decoder, fixedBytes) {
214
+ return createDecoder({
215
+ fixedSize: fixedBytes,
216
+ read: (bytes, offset) => {
202
217
  assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
203
218
  if (offset > 0 || bytes.length > fixedBytes) {
204
219
  bytes = bytes.slice(offset, offset + fixedBytes);
205
220
  }
206
- if (decoder.fixedSize !== null) {
221
+ if (isFixedSize(decoder)) {
207
222
  bytes = fixBytes(bytes, decoder.fixedSize);
208
223
  }
209
- const [value] = decoder.decode(bytes, 0);
224
+ const [value] = decoder.read(bytes, 0);
210
225
  return [value, offset + fixedBytes];
211
226
  }
212
- };
227
+ });
213
228
  }
214
229
  function mapEncoder(encoder, unmap) {
215
- return {
216
- description: encoder.description,
217
- encode: (value) => encoder.encode(unmap(value)),
218
- fixedSize: encoder.fixedSize,
219
- maxSize: encoder.maxSize
220
- };
230
+ return createEncoder({
231
+ ...isVariableSize(encoder) ? { ...encoder, getSizeFromValue: (value) => encoder.getSizeFromValue(unmap(value)) } : encoder,
232
+ write: (value, bytes, offset) => encoder.write(unmap(value), bytes, offset)
233
+ });
221
234
  }
222
235
  function mapDecoder(decoder, map) {
223
- return {
224
- decode: (bytes, offset = 0) => {
225
- const [value, length] = decoder.decode(bytes, offset);
226
- return [map(value, bytes, offset), length];
227
- },
228
- description: decoder.description,
229
- fixedSize: decoder.fixedSize,
230
- maxSize: decoder.maxSize
231
- };
236
+ return createDecoder({
237
+ ...decoder,
238
+ read: (bytes, offset) => {
239
+ const [value, newOffset] = decoder.read(bytes, offset);
240
+ return [map(value, bytes, offset), newOffset];
241
+ }
242
+ });
232
243
  }
233
244
 
234
245
  // ../codecs-strings/dist/index.browser.js
@@ -243,78 +254,69 @@ this.globalThis.solanaWeb3 = (function (exports) {
243
254
  );
244
255
  }
245
256
  }
246
- function sharedNumberFactory(input) {
247
- let littleEndian;
248
- let defaultDescription = input.name;
249
- if (input.size > 1) {
250
- littleEndian = !("endian" in input.options) || input.options.endian === 0;
251
- defaultDescription += littleEndian ? "(le)" : "(be)";
252
- }
253
- return {
254
- description: input.options.description ?? defaultDescription,
255
- fixedSize: input.size,
256
- littleEndian,
257
- maxSize: input.size
258
- };
257
+ function isLittleEndian(config) {
258
+ return (config == null ? void 0 : config.endian) === 1 ? false : true;
259
259
  }
260
260
  function numberEncoderFactory(input) {
261
- const codecData = sharedNumberFactory(input);
262
- return {
263
- description: codecData.description,
264
- encode(value) {
261
+ return createEncoder({
262
+ fixedSize: input.size,
263
+ write(value, bytes, offset) {
265
264
  if (input.range) {
266
265
  assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
267
266
  }
268
267
  const arrayBuffer = new ArrayBuffer(input.size);
269
- input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
270
- return new Uint8Array(arrayBuffer);
271
- },
272
- fixedSize: codecData.fixedSize,
273
- maxSize: codecData.maxSize
274
- };
268
+ input.set(new DataView(arrayBuffer), value, isLittleEndian(input.config));
269
+ bytes.set(new Uint8Array(arrayBuffer), offset);
270
+ return offset + input.size;
271
+ }
272
+ });
275
273
  }
276
274
  function numberDecoderFactory(input) {
277
- const codecData = sharedNumberFactory(input);
278
- return {
279
- decode(bytes, offset = 0) {
280
- assertByteArrayIsNotEmptyForCodec(codecData.description, bytes, offset);
281
- assertByteArrayHasEnoughBytesForCodec(codecData.description, input.size, bytes, offset);
275
+ return createDecoder({
276
+ fixedSize: input.size,
277
+ read(bytes, offset = 0) {
278
+ assertByteArrayIsNotEmptyForCodec(input.name, bytes, offset);
279
+ assertByteArrayHasEnoughBytesForCodec(input.name, input.size, bytes, offset);
282
280
  const view = new DataView(toArrayBuffer(bytes, offset, input.size));
283
- return [input.get(view, codecData.littleEndian), offset + input.size];
284
- },
285
- description: codecData.description,
286
- fixedSize: codecData.fixedSize,
287
- maxSize: codecData.maxSize
288
- };
281
+ return [input.get(view, isLittleEndian(input.config)), offset + input.size];
282
+ }
283
+ });
289
284
  }
290
285
  function toArrayBuffer(bytes, offset, length) {
291
- const bytesOffset = bytes.byteOffset + (offset ?? 0);
292
- const bytesLength = length ?? bytes.byteLength;
286
+ const bytesOffset = bytes.byteOffset + (offset != null ? offset : 0);
287
+ const bytesLength = length != null ? length : bytes.byteLength;
293
288
  return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
294
289
  }
295
- var getShortU16Encoder = (options = {}) => ({
296
- description: options.description ?? "shortU16",
297
- encode: (value) => {
290
+ var getShortU16Encoder = () => createEncoder({
291
+ getSizeFromValue: (value) => {
292
+ if (value <= 127)
293
+ return 1;
294
+ if (value <= 16383)
295
+ return 2;
296
+ return 3;
297
+ },
298
+ maxSize: 3,
299
+ write: (value, bytes, offset) => {
298
300
  assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
299
- const bytes = [0];
301
+ const shortU16Bytes = [0];
300
302
  for (let ii = 0; ; ii += 1) {
301
303
  const alignedValue = value >> ii * 7;
302
304
  if (alignedValue === 0) {
303
305
  break;
304
306
  }
305
307
  const nextSevenBits = 127 & alignedValue;
306
- bytes[ii] = nextSevenBits;
308
+ shortU16Bytes[ii] = nextSevenBits;
307
309
  if (ii > 0) {
308
- bytes[ii - 1] |= 128;
310
+ shortU16Bytes[ii - 1] |= 128;
309
311
  }
310
312
  }
311
- return new Uint8Array(bytes);
312
- },
313
- fixedSize: null,
314
- maxSize: 3
313
+ bytes.set(shortU16Bytes, offset);
314
+ return offset + shortU16Bytes.length;
315
+ }
315
316
  });
316
- var getShortU16Decoder = (options = {}) => ({
317
- decode: (bytes, offset = 0) => {
317
+ var getShortU16Decoder = () => createDecoder({
318
+ maxSize: 3,
319
+ read: (bytes, offset) => {
318
320
  let value = 0;
319
321
  let byteCount = 0;
320
322
  while (++byteCount) {
@@ -327,35 +329,30 @@ this.globalThis.solanaWeb3 = (function (exports) {
327
329
  }
328
330
  }
329
331
  return [value, offset + byteCount];
330
- },
331
- description: options.description ?? "shortU16",
332
- fixedSize: null,
333
- maxSize: 3
332
+ }
334
333
  });
335
- var getU32Encoder = (options = {}) => numberEncoderFactory({
334
+ var getU32Encoder = (config = {}) => numberEncoderFactory({
335
+ config,
336
336
  name: "u32",
337
- options,
338
337
  range: [0, Number("0xffffffff")],
339
338
  set: (view, value, le) => view.setUint32(0, value, le),
340
339
  size: 4
341
340
  });
342
- var getU32Decoder = (options = {}) => numberDecoderFactory({
341
+ var getU32Decoder = (config = {}) => numberDecoderFactory({
342
+ config,
343
343
  get: (view, le) => view.getUint32(0, le),
344
344
  name: "u32",
345
- options,
346
345
  size: 4
347
346
  });
348
- var getU8Encoder = (options = {}) => numberEncoderFactory({
347
+ var getU8Encoder = () => numberEncoderFactory({
349
348
  name: "u8",
350
- options,
351
349
  range: [0, Number("0xff")],
352
350
  set: (view, value) => view.setUint8(0, value),
353
351
  size: 1
354
352
  });
355
- var getU8Decoder = (options = {}) => numberDecoderFactory({
353
+ var getU8Decoder = () => numberDecoderFactory({
356
354
  get: (view) => view.getUint8(0),
357
355
  name: "u8",
358
- options,
359
356
  size: 1
360
357
  });
361
358
 
@@ -366,43 +363,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
366
363
  }
367
364
  }
368
365
  var getBaseXEncoder = (alphabet4) => {
369
- const base = alphabet4.length;
370
- const baseBigInt = BigInt(base);
371
- return {
372
- description: `base${base}`,
373
- encode(value) {
366
+ return createEncoder({
367
+ getSizeFromValue: (value) => {
368
+ const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
369
+ if (tailChars === "")
370
+ return value.length;
371
+ const base10Number = getBigIntFromBaseX(tailChars, alphabet4);
372
+ return leadingZeroes.length + Math.ceil(base10Number.toString(16).length / 2);
373
+ },
374
+ write(value, bytes, offset) {
374
375
  assertValidBaseString(alphabet4, value);
375
376
  if (value === "")
376
- return new Uint8Array();
377
- const chars = [...value];
378
- let trailIndex = chars.findIndex((c) => c !== alphabet4[0]);
379
- trailIndex = trailIndex === -1 ? chars.length : trailIndex;
380
- const leadingZeroes = Array(trailIndex).fill(0);
381
- if (trailIndex === chars.length)
382
- return Uint8Array.from(leadingZeroes);
383
- const tailChars = chars.slice(trailIndex);
384
- let base10Number = 0n;
385
- let baseXPower = 1n;
386
- for (let i = tailChars.length - 1; i >= 0; i -= 1) {
387
- base10Number += baseXPower * BigInt(alphabet4.indexOf(tailChars[i]));
388
- baseXPower *= baseBigInt;
377
+ return offset;
378
+ const [leadingZeroes, tailChars] = partitionLeadingZeroes(value, alphabet4[0]);
379
+ if (tailChars === "") {
380
+ bytes.set(new Uint8Array(leadingZeroes.length).fill(0), offset);
381
+ return offset + leadingZeroes.length;
389
382
  }
383
+ let base10Number = getBigIntFromBaseX(tailChars, alphabet4);
390
384
  const tailBytes = [];
391
385
  while (base10Number > 0n) {
392
386
  tailBytes.unshift(Number(base10Number % 256n));
393
387
  base10Number /= 256n;
394
388
  }
395
- return Uint8Array.from(leadingZeroes.concat(tailBytes));
396
- },
397
- fixedSize: null,
398
- maxSize: null
399
- };
389
+ const bytesToAdd = [...Array(leadingZeroes.length).fill(0), ...tailBytes];
390
+ bytes.set(bytesToAdd, offset);
391
+ return offset + bytesToAdd.length;
392
+ }
393
+ });
400
394
  };
401
395
  var getBaseXDecoder = (alphabet4) => {
402
- const base = alphabet4.length;
403
- const baseBigInt = BigInt(base);
404
- return {
405
- decode(rawBytes, offset = 0) {
396
+ return createDecoder({
397
+ read(rawBytes, offset) {
406
398
  const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
407
399
  if (bytes.length === 0)
408
400
  return ["", 0];
@@ -411,37 +403,63 @@ this.globalThis.solanaWeb3 = (function (exports) {
411
403
  const leadingZeroes = alphabet4[0].repeat(trailIndex);
412
404
  if (trailIndex === bytes.length)
413
405
  return [leadingZeroes, rawBytes.length];
414
- let base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
415
- const tailChars = [];
416
- while (base10Number > 0n) {
417
- tailChars.unshift(alphabet4[Number(base10Number % baseBigInt)]);
418
- base10Number /= baseBigInt;
419
- }
420
- return [leadingZeroes + tailChars.join(""), rawBytes.length];
421
- },
422
- description: `base${base}`,
423
- fixedSize: null,
424
- maxSize: null
425
- };
406
+ const base10Number = bytes.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
407
+ const tailChars = getBaseXFromBigInt(base10Number, alphabet4);
408
+ return [leadingZeroes + tailChars, rawBytes.length];
409
+ }
410
+ });
426
411
  };
412
+ function partitionLeadingZeroes(value, zeroCharacter) {
413
+ const leadingZeroIndex = [...value].findIndex((c) => c !== zeroCharacter);
414
+ return leadingZeroIndex === -1 ? [value, ""] : [value.slice(0, leadingZeroIndex), value.slice(leadingZeroIndex)];
415
+ }
416
+ function getBigIntFromBaseX(value, alphabet4) {
417
+ const base = BigInt(alphabet4.length);
418
+ return [...value].reduce((sum, char) => sum * base + BigInt(alphabet4.indexOf(char)), 0n);
419
+ }
420
+ function getBaseXFromBigInt(value, alphabet4) {
421
+ const base = BigInt(alphabet4.length);
422
+ const tailChars = [];
423
+ while (value > 0n) {
424
+ tailChars.unshift(alphabet4[Number(value % base)]);
425
+ value /= base;
426
+ }
427
+ return tailChars.join("");
428
+ }
427
429
  var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
428
430
  var getBase58Encoder = () => getBaseXEncoder(alphabet2);
429
431
  var getBase58Decoder = () => getBaseXDecoder(alphabet2);
430
432
  var getBase64Encoder = () => {
431
433
  {
432
- return {
433
- description: `base64`,
434
- encode(value) {
434
+ return createEncoder({
435
+ getSizeFromValue: (value) => {
435
436
  try {
436
- const bytes = atob(value).split("").map((c) => c.charCodeAt(0));
437
- return new Uint8Array(bytes);
437
+ return atob(value).length;
438
438
  } catch (e23) {
439
439
  throw new Error(`Expected a string of base 64, got [${value}].`);
440
440
  }
441
441
  },
442
- fixedSize: null,
443
- maxSize: null
444
- };
442
+ write(value, bytes, offset) {
443
+ try {
444
+ const bytesToAdd = atob(value).split("").map((c) => c.charCodeAt(0));
445
+ bytes.set(bytesToAdd, offset);
446
+ return bytesToAdd.length + offset;
447
+ } catch (e23) {
448
+ throw new Error(`Expected a string of base 64, got [${value}].`);
449
+ }
450
+ }
451
+ });
452
+ }
453
+ };
454
+ var getBase64Decoder = () => {
455
+ {
456
+ return createDecoder({
457
+ read(bytes, offset = 0) {
458
+ const slice = bytes.slice(offset);
459
+ const value = btoa(String.fromCharCode(...slice));
460
+ return [value, bytes.length];
461
+ }
462
+ });
445
463
  }
446
464
  };
447
465
  var removeNullCharacters = (value) => (
@@ -452,75 +470,69 @@ this.globalThis.solanaWeb3 = (function (exports) {
452
470
  var o = globalThis.TextEncoder;
453
471
  var getUtf8Encoder = () => {
454
472
  let textEncoder;
455
- return {
456
- description: "utf8",
457
- encode: (value) => new Uint8Array((textEncoder || (textEncoder = new o())).encode(value)),
458
- fixedSize: null,
459
- maxSize: null
460
- };
473
+ return createEncoder({
474
+ getSizeFromValue: (value) => (textEncoder || (textEncoder = new o())).encode(value).length,
475
+ write: (value, bytes, offset) => {
476
+ const bytesToAdd = (textEncoder || (textEncoder = new o())).encode(value);
477
+ bytes.set(bytesToAdd, offset);
478
+ return offset + bytesToAdd.length;
479
+ }
480
+ });
461
481
  };
462
482
  var getUtf8Decoder = () => {
463
483
  let textDecoder;
464
- return {
465
- decode(bytes, offset = 0) {
484
+ return createDecoder({
485
+ read(bytes, offset) {
466
486
  const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
467
487
  return [removeNullCharacters(value), bytes.length];
468
- },
469
- description: "utf8",
470
- fixedSize: null,
471
- maxSize: null
472
- };
488
+ }
489
+ });
473
490
  };
474
- var getStringEncoder = (options = {}) => {
475
- const size = options.size ?? getU32Encoder();
476
- const encoding = options.encoding ?? getUtf8Encoder();
477
- const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
491
+ function getStringEncoder(config = {}) {
492
+ var _a, _b;
493
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
494
+ const encoding = (_b = config.encoding) != null ? _b : getUtf8Encoder();
478
495
  if (size === "variable") {
479
- return { ...encoding, description };
496
+ return encoding;
480
497
  }
481
498
  if (typeof size === "number") {
482
- return fixEncoder(encoding, size, description);
499
+ return fixEncoder(encoding, size);
483
500
  }
484
- return {
485
- description,
486
- encode: (value) => {
487
- const contentBytes = encoding.encode(value);
488
- const lengthBytes = size.encode(contentBytes.length);
489
- return mergeBytes([lengthBytes, contentBytes]);
501
+ return createEncoder({
502
+ getSizeFromValue: (value) => {
503
+ const contentSize = getEncodedSize(value, encoding);
504
+ return getEncodedSize(contentSize, size) + contentSize;
490
505
  },
491
- fixedSize: null,
492
- maxSize: null
493
- };
494
- };
495
- var getStringDecoder = (options = {}) => {
496
- const size = options.size ?? getU32Decoder();
497
- const encoding = options.encoding ?? getUtf8Decoder();
498
- const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
506
+ write: (value, bytes, offset) => {
507
+ const contentSize = getEncodedSize(value, encoding);
508
+ offset = size.write(contentSize, bytes, offset);
509
+ return encoding.write(value, bytes, offset);
510
+ }
511
+ });
512
+ }
513
+ function getStringDecoder(config = {}) {
514
+ var _a, _b;
515
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
516
+ const encoding = (_b = config.encoding) != null ? _b : getUtf8Decoder();
499
517
  if (size === "variable") {
500
- return { ...encoding, description };
518
+ return encoding;
501
519
  }
502
520
  if (typeof size === "number") {
503
- return fixDecoder(encoding, size, description);
521
+ return fixDecoder(encoding, size);
504
522
  }
505
- return {
506
- decode: (bytes, offset = 0) => {
523
+ return createDecoder({
524
+ read: (bytes, offset = 0) => {
507
525
  assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
508
- const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
526
+ const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
509
527
  const length = Number(lengthBigInt);
510
528
  offset = lengthOffset;
511
529
  const contentBytes = bytes.slice(offset, offset + length);
512
530
  assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
513
- const [value, contentOffset] = encoding.decode(contentBytes);
531
+ const [value, contentOffset] = encoding.read(contentBytes, 0);
514
532
  offset += contentOffset;
515
533
  return [value, offset];
516
- },
517
- description,
518
- fixedSize: null,
519
- maxSize: null
520
- };
521
- };
522
- function getSizeDescription(size) {
523
- return typeof size === "object" ? size.description : `${size}`;
534
+ }
535
+ });
524
536
  }
525
537
 
526
538
  // ../assertions/dist/index.browser.js
@@ -555,14 +567,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
555
567
  }
556
568
  }
557
569
  async function assertDigestCapabilityIsAvailable() {
570
+ var _a;
558
571
  assertIsSecureContext();
559
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
572
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.digest) !== "function") {
560
573
  throw new Error("No digest implementation could be found");
561
574
  }
562
575
  }
563
576
  async function assertKeyGenerationIsAvailable() {
577
+ var _a;
564
578
  assertIsSecureContext();
565
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
579
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.generateKey) !== "function") {
566
580
  throw new Error("No key generation implementation could be found");
567
581
  }
568
582
  if (!await isEd25519CurveSupported(globalThis.crypto.subtle)) {
@@ -572,20 +586,23 @@ this.globalThis.solanaWeb3 = (function (exports) {
572
586
  }
573
587
  }
574
588
  async function assertKeyExporterIsAvailable() {
589
+ var _a;
575
590
  assertIsSecureContext();
576
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.exportKey !== "function") {
591
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.exportKey) !== "function") {
577
592
  throw new Error("No key export implementation could be found");
578
593
  }
579
594
  }
580
595
  async function assertSigningCapabilityIsAvailable() {
596
+ var _a;
581
597
  assertIsSecureContext();
582
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.sign !== "function") {
598
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.sign) !== "function") {
583
599
  throw new Error("No signing implementation could be found");
584
600
  }
585
601
  }
586
602
  async function assertVerificationCapabilityIsAvailable() {
603
+ var _a;
587
604
  assertIsSecureContext();
588
- if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.verify !== "function") {
605
+ if (typeof globalThis.crypto === "undefined" || typeof ((_a = globalThis.crypto.subtle) == null ? void 0 : _a.verify) !== "function") {
589
606
  throw new Error("No signature verification implementation could be found");
590
607
  }
591
608
  }
@@ -644,25 +661,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
644
661
  assertIsAddress(putativeAddress);
645
662
  return putativeAddress;
646
663
  }
647
- function getAddressEncoder(config) {
664
+ function getAddressEncoder() {
648
665
  return mapEncoder(
649
- getStringEncoder({
650
- description: config?.description ?? "Address",
651
- encoding: getMemoizedBase58Encoder(),
652
- size: 32
653
- }),
666
+ getStringEncoder({ encoding: getMemoizedBase58Encoder(), size: 32 }),
654
667
  (putativeAddress) => address(putativeAddress)
655
668
  );
656
669
  }
657
- function getAddressDecoder(config) {
658
- return getStringDecoder({
659
- description: config?.description ?? "Address",
660
- encoding: getMemoizedBase58Decoder(),
661
- size: 32
662
- });
670
+ function getAddressDecoder() {
671
+ return getStringDecoder({ encoding: getMemoizedBase58Decoder(), size: 32 });
663
672
  }
664
- function getAddressCodec(config) {
665
- return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
673
+ function getAddressCodec() {
674
+ return combineCodec(getAddressEncoder(), getAddressDecoder());
666
675
  }
667
676
  function getAddressComparator() {
668
677
  return new Intl.Collator("en", {
@@ -827,7 +836,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
827
836
  if (await compressedPointBytesAreOnCurve(addressBytes)) {
828
837
  throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
829
838
  }
830
- return base58EncodedAddressCodec.decode(addressBytes)[0];
839
+ return base58EncodedAddressCodec.decode(addressBytes);
831
840
  }
832
841
  async function getProgramDerivedAddress({
833
842
  programAddress,
@@ -852,21 +861,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
852
861
  throw new Error("Unable to find a viable program address bump seed");
853
862
  }
854
863
  async function createAddressWithSeed({ baseAddress, programAddress, seed }) {
855
- const { encode: encode2, decode: decode2 } = getAddressCodec();
864
+ const { encode, decode } = getAddressCodec();
856
865
  const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
857
866
  if (seedBytes.byteLength > MAX_SEED_LENGTH) {
858
867
  throw new Error(`The seed exceeds the maximum length of 32 bytes`);
859
868
  }
860
- const programAddressBytes = encode2(programAddress);
869
+ const programAddressBytes = encode(programAddress);
861
870
  if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
862
871
  throw new Error(`programAddress cannot end with the PDA marker`);
863
872
  }
864
873
  const addressBytesBuffer = await crypto.subtle.digest(
865
874
  "SHA-256",
866
- new Uint8Array([...encode2(baseAddress), ...seedBytes, ...programAddressBytes])
875
+ new Uint8Array([...encode(baseAddress), ...seedBytes, ...programAddressBytes])
867
876
  );
868
877
  const addressBytes = new Uint8Array(addressBytesBuffer);
869
- return decode2(addressBytes)[0];
878
+ return decode(addressBytes);
870
879
  }
871
880
  async function getAddressFromPublicKey(publicKey) {
872
881
  await assertKeyExporterIsAvailable();
@@ -874,8 +883,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
874
883
  throw new Error("The `CryptoKey` must be an `Ed25519` public key");
875
884
  }
876
885
  const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
877
- const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
878
- return base58EncodedAddress;
886
+ return getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
879
887
  }
880
888
 
881
889
  // ../instructions/dist/index.browser.js
@@ -931,14 +939,111 @@ this.globalThis.solanaWeb3 = (function (exports) {
931
939
  );
932
940
  return keyPair;
933
941
  }
942
+ function addPkcs8Header(bytes) {
943
+ return new Uint8Array([
944
+ /**
945
+ * PKCS#8 header
946
+ */
947
+ 48,
948
+ // ASN.1 sequence tag
949
+ 46,
950
+ // Length of sequence (46 more bytes)
951
+ 2,
952
+ // ASN.1 integer tag
953
+ 1,
954
+ // Length of integer
955
+ 0,
956
+ // Version number
957
+ 48,
958
+ // ASN.1 sequence tag
959
+ 5,
960
+ // Length of sequence
961
+ 6,
962
+ // ASN.1 object identifier tag
963
+ 3,
964
+ // Length of object identifier
965
+ // Edwards curve algorithms identifier https://oid-rep.orange-labs.fr/get/1.3.101.112
966
+ 43,
967
+ // iso(1) / identified-organization(3) (The first node is multiplied by the decimal 40 and the result is added to the value of the second node)
968
+ 101,
969
+ // thawte(101)
970
+ // Ed25519 identifier
971
+ 112,
972
+ // id-Ed25519(112)
973
+ /**
974
+ * Private key payload
975
+ */
976
+ 4,
977
+ // ASN.1 octet string tag
978
+ 34,
979
+ // String length (34 more bytes)
980
+ // Private key bytes as octet string
981
+ 4,
982
+ // ASN.1 octet string tag
983
+ 32,
984
+ // String length (32 bytes)
985
+ ...bytes
986
+ ]);
987
+ }
988
+ async function createPrivateKeyFromBytes(bytes, extractable) {
989
+ if (bytes.byteLength !== 32) {
990
+ throw new Error("Private key bytes must be of length 32");
991
+ }
992
+ const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
993
+ return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
994
+ }
995
+ var base58Encoder;
996
+ function assertIsSignature(putativeSignature) {
997
+ if (!base58Encoder)
998
+ base58Encoder = getBase58Encoder();
999
+ try {
1000
+ if (
1001
+ // Lowest value (64 bytes of zeroes)
1002
+ putativeSignature.length < 64 || // Highest value (64 bytes of 255)
1003
+ putativeSignature.length > 88
1004
+ ) {
1005
+ throw new Error("Expected input string to decode to a byte array of length 64.");
1006
+ }
1007
+ const bytes = base58Encoder.encode(putativeSignature);
1008
+ const numBytes = bytes.byteLength;
1009
+ if (numBytes !== 64) {
1010
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
1011
+ }
1012
+ } catch (e3) {
1013
+ throw new Error(`\`${putativeSignature}\` is not a signature`, {
1014
+ cause: e3
1015
+ });
1016
+ }
1017
+ }
1018
+ function isSignature(putativeSignature) {
1019
+ if (!base58Encoder)
1020
+ base58Encoder = getBase58Encoder();
1021
+ if (
1022
+ // Lowest value (64 bytes of zeroes)
1023
+ putativeSignature.length < 64 || // Highest value (64 bytes of 255)
1024
+ putativeSignature.length > 88
1025
+ ) {
1026
+ return false;
1027
+ }
1028
+ const bytes = base58Encoder.encode(putativeSignature);
1029
+ const numBytes = bytes.byteLength;
1030
+ if (numBytes !== 64) {
1031
+ return false;
1032
+ }
1033
+ return true;
1034
+ }
934
1035
  async function signBytes(key, data) {
935
1036
  await assertSigningCapabilityIsAvailable();
936
1037
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
937
1038
  return new Uint8Array(signedData);
938
1039
  }
939
- async function verifySignature(key, signature, data) {
1040
+ function signature(putativeSignature) {
1041
+ assertIsSignature(putativeSignature);
1042
+ return putativeSignature;
1043
+ }
1044
+ async function verifySignature(key, signature2, data) {
940
1045
  await assertVerificationCapabilityIsAvailable();
941
- return await crypto.subtle.verify("Ed25519", key, signature, data);
1046
+ return await crypto.subtle.verify("Ed25519", key, signature2, data);
942
1047
  }
943
1048
 
944
1049
  // ../rpc-types/dist/index.browser.js
@@ -1039,181 +1144,194 @@ this.globalThis.solanaWeb3 = (function (exports) {
1039
1144
 
1040
1145
  // ../codecs-data-structures/dist/index.browser.js
1041
1146
  init_env_shim();
1147
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1148
+ if (expected !== actual) {
1149
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1150
+ }
1151
+ }
1042
1152
  function sumCodecSizes(sizes) {
1043
1153
  return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1044
1154
  }
1045
- function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
1155
+ function getFixedSize(codec) {
1156
+ return isFixedSize(codec) ? codec.fixedSize : null;
1157
+ }
1158
+ function getMaxSize(codec) {
1159
+ var _a;
1160
+ return isFixedSize(codec) ? codec.fixedSize : (_a = codec.maxSize) != null ? _a : null;
1161
+ }
1162
+ function getArrayEncoder(item, config = {}) {
1163
+ var _a, _b;
1164
+ const size = (_a = config.size) != null ? _a : getU32Encoder();
1165
+ if (size === "remainder") {
1166
+ assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
1167
+ }
1168
+ const fixedSize = computeArrayLikeCodecSize(size, getFixedSize(item));
1169
+ const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
1170
+ return createEncoder({
1171
+ ...fixedSize !== null ? { fixedSize } : {
1172
+ getSizeFromValue: (array) => {
1173
+ const prefixSize = typeof size === "object" ? getEncodedSize(array.length, size) : 0;
1174
+ return prefixSize + [...array].reduce((all, value) => all + getEncodedSize(value, item), 0);
1175
+ },
1176
+ maxSize
1177
+ },
1178
+ write: (array, bytes, offset) => {
1179
+ if (typeof size === "number") {
1180
+ assertValidNumberOfItemsForCodec("array", size, array.length);
1181
+ }
1182
+ if (typeof size === "object") {
1183
+ offset = size.write(array.length, bytes, offset);
1184
+ }
1185
+ array.forEach((value) => {
1186
+ offset = item.write(value, bytes, offset);
1187
+ });
1188
+ return offset;
1189
+ }
1190
+ });
1191
+ }
1192
+ function getArrayDecoder(item, config = {}) {
1193
+ var _a, _b;
1194
+ const size = (_a = config.size) != null ? _a : getU32Decoder();
1195
+ if (size === "remainder") {
1196
+ assertIsFixedSize(item, 'Codecs of "remainder" size must have fixed-size items.');
1197
+ }
1198
+ const itemSize = getFixedSize(item);
1199
+ const fixedSize = computeArrayLikeCodecSize(size, itemSize);
1200
+ const maxSize = (_b = computeArrayLikeCodecSize(size, getMaxSize(item))) != null ? _b : void 0;
1201
+ return createDecoder({
1202
+ ...fixedSize !== null ? { fixedSize } : { maxSize },
1203
+ read: (bytes, offset) => {
1204
+ const array = [];
1205
+ if (typeof size === "object" && bytes.slice(offset).length === 0) {
1206
+ return [array, offset];
1207
+ }
1208
+ const [resolvedSize, newOffset] = readArrayLikeCodecSize(size, itemSize, bytes, offset);
1209
+ offset = newOffset;
1210
+ for (let i = 0; i < resolvedSize; i += 1) {
1211
+ const [value, newOffset2] = item.read(bytes, offset);
1212
+ offset = newOffset2;
1213
+ array.push(value);
1214
+ }
1215
+ return [array, offset];
1216
+ }
1217
+ });
1218
+ }
1219
+ function readArrayLikeCodecSize(size, itemSize, bytes, offset) {
1046
1220
  if (typeof size === "number") {
1047
1221
  return [size, offset];
1048
1222
  }
1049
1223
  if (typeof size === "object") {
1050
- return size.decode(bytes, offset);
1224
+ return size.read(bytes, offset);
1051
1225
  }
1052
1226
  if (size === "remainder") {
1053
- const childrenSize = sumCodecSizes(childrenSizes);
1054
- if (childrenSize === null) {
1227
+ if (itemSize === null) {
1055
1228
  throw new Error('Codecs of "remainder" size must have fixed-size items.');
1056
1229
  }
1057
- const remainder = bytes.slice(offset).length;
1058
- if (remainder % childrenSize !== 0) {
1230
+ const remainder = Math.max(0, bytes.length - offset);
1231
+ if (remainder % itemSize !== 0) {
1059
1232
  throw new Error(
1060
- `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.`
1233
+ `The remainder of the byte array (${remainder} bytes) cannot be split into chunks of ${itemSize} bytes. Codecs of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainder} modulo ${itemSize} should be equal to zero.`
1061
1234
  );
1062
1235
  }
1063
- return [remainder / childrenSize, offset];
1236
+ return [remainder / itemSize, offset];
1064
1237
  }
1065
1238
  throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
1066
1239
  }
1067
- function getArrayLikeCodecSizeDescription(size) {
1068
- return typeof size === "object" ? size.description : `${size}`;
1069
- }
1070
- function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
1240
+ function computeArrayLikeCodecSize(size, itemSize) {
1071
1241
  if (typeof size !== "number")
1072
1242
  return null;
1073
1243
  if (size === 0)
1074
1244
  return 0;
1075
- const childrenSize = sumCodecSizes(childrenSizes);
1076
- return childrenSize === null ? null : childrenSize * size;
1077
- }
1078
- function getArrayLikeCodecSizePrefix(size, realSize) {
1079
- return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
1245
+ return itemSize === null ? null : itemSize * size;
1080
1246
  }
1081
- function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1082
- if (expected !== actual) {
1083
- throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1084
- }
1085
- }
1086
- function arrayCodecHelper(item, size, description) {
1087
- if (size === "remainder" && item.fixedSize === null) {
1088
- throw new Error('Codecs of "remainder" size must have fixed-size items.');
1089
- }
1090
- return {
1091
- description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
1092
- fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
1093
- maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
1094
- };
1095
- }
1096
- function getArrayEncoder(item, options = {}) {
1097
- const size = options.size ?? getU32Encoder();
1098
- return {
1099
- ...arrayCodecHelper(item, size, options.description),
1100
- encode: (value) => {
1101
- if (typeof size === "number") {
1102
- assertValidNumberOfItemsForCodec("array", size, value.length);
1103
- }
1104
- return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
1105
- }
1106
- };
1107
- }
1108
- function getArrayDecoder(item, options = {}) {
1109
- const size = options.size ?? getU32Decoder();
1110
- return {
1111
- ...arrayCodecHelper(item, size, options.description),
1112
- decode: (bytes, offset = 0) => {
1113
- if (typeof size === "object" && bytes.slice(offset).length === 0) {
1114
- return [[], offset];
1115
- }
1116
- const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
1117
- offset = newOffset;
1118
- const values = [];
1119
- for (let i = 0; i < resolvedSize; i += 1) {
1120
- const [value, newOffset2] = item.decode(bytes, offset);
1121
- values.push(value);
1122
- offset = newOffset2;
1123
- }
1124
- return [values, offset];
1247
+ function getBytesEncoder(config = {}) {
1248
+ var _a;
1249
+ const size = (_a = config.size) != null ? _a : "variable";
1250
+ const byteEncoder = createEncoder({
1251
+ getSizeFromValue: (value) => value.length,
1252
+ write: (value, bytes, offset) => {
1253
+ bytes.set(value, offset);
1254
+ return offset + value.length;
1125
1255
  }
1126
- };
1127
- }
1128
- function getBytesEncoder(options = {}) {
1129
- const size = options.size ?? "variable";
1130
- const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1131
- const description = options.description ?? `bytes(${sizeDescription})`;
1132
- const byteEncoder = {
1133
- description,
1134
- encode: (value) => value,
1135
- fixedSize: null,
1136
- maxSize: null
1137
- };
1256
+ });
1138
1257
  if (size === "variable") {
1139
1258
  return byteEncoder;
1140
1259
  }
1141
1260
  if (typeof size === "number") {
1142
- return fixEncoder(byteEncoder, size, description);
1261
+ return fixEncoder(byteEncoder, size);
1143
1262
  }
1144
- return {
1145
- ...byteEncoder,
1146
- encode: (value) => {
1147
- const contentBytes = byteEncoder.encode(value);
1148
- const lengthBytes = size.encode(contentBytes.length);
1149
- return mergeBytes([lengthBytes, contentBytes]);
1263
+ return createEncoder({
1264
+ getSizeFromValue: (value) => getEncodedSize(value.length, size) + value.length,
1265
+ write: (value, bytes, offset) => {
1266
+ offset = size.write(value.length, bytes, offset);
1267
+ return byteEncoder.write(value, bytes, offset);
1150
1268
  }
1151
- };
1269
+ });
1152
1270
  }
1153
- function getBytesDecoder(options = {}) {
1154
- const size = options.size ?? "variable";
1155
- const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1156
- const description = options.description ?? `bytes(${sizeDescription})`;
1157
- const byteDecoder = {
1158
- decode: (bytes, offset = 0) => {
1271
+ function getBytesDecoder(config = {}) {
1272
+ var _a;
1273
+ const size = (_a = config.size) != null ? _a : "variable";
1274
+ const byteDecoder = createDecoder({
1275
+ read: (bytes, offset) => {
1159
1276
  const slice = bytes.slice(offset);
1160
1277
  return [slice, offset + slice.length];
1161
- },
1162
- description,
1163
- fixedSize: null,
1164
- maxSize: null
1165
- };
1278
+ }
1279
+ });
1166
1280
  if (size === "variable") {
1167
1281
  return byteDecoder;
1168
1282
  }
1169
1283
  if (typeof size === "number") {
1170
- return fixDecoder(byteDecoder, size, description);
1284
+ return fixDecoder(byteDecoder, size);
1171
1285
  }
1172
- return {
1173
- ...byteDecoder,
1174
- decode: (bytes, offset = 0) => {
1286
+ return createDecoder({
1287
+ read: (bytes, offset) => {
1175
1288
  assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
1176
- const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
1289
+ const [lengthBigInt, lengthOffset] = size.read(bytes, offset);
1177
1290
  const length = Number(lengthBigInt);
1178
1291
  offset = lengthOffset;
1179
1292
  const contentBytes = bytes.slice(offset, offset + length);
1180
1293
  assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
1181
- const [value, contentOffset] = byteDecoder.decode(contentBytes);
1294
+ const [value, contentOffset] = byteDecoder.read(contentBytes, 0);
1182
1295
  offset += contentOffset;
1183
1296
  return [value, offset];
1184
1297
  }
1185
- };
1186
- }
1187
- function structCodecHelper(fields, description) {
1188
- const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1189
- return {
1190
- description: description ?? `struct(${fieldDescriptions})`,
1191
- fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1192
- maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1193
- };
1298
+ });
1194
1299
  }
1195
- function getStructEncoder(fields, options = {}) {
1196
- return {
1197
- ...structCodecHelper(fields, options.description),
1198
- encode: (struct) => {
1199
- const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
1200
- return mergeBytes(fieldBytes);
1300
+ function getStructEncoder(fields) {
1301
+ var _a;
1302
+ const fieldCodecs = fields.map(([, codec]) => codec);
1303
+ const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
1304
+ const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
1305
+ return createEncoder({
1306
+ ...fixedSize === null ? {
1307
+ getSizeFromValue: (value) => fields.map(([key, codec]) => getEncodedSize(value[key], codec)).reduce((all, one) => all + one, 0),
1308
+ maxSize
1309
+ } : { fixedSize },
1310
+ write: (struct, bytes, offset) => {
1311
+ fields.forEach(([key, codec]) => {
1312
+ offset = codec.write(struct[key], bytes, offset);
1313
+ });
1314
+ return offset;
1201
1315
  }
1202
- };
1316
+ });
1203
1317
  }
1204
- function getStructDecoder(fields, options = {}) {
1205
- return {
1206
- ...structCodecHelper(fields, options.description),
1207
- decode: (bytes, offset = 0) => {
1318
+ function getStructDecoder(fields) {
1319
+ var _a;
1320
+ const fieldCodecs = fields.map(([, codec]) => codec);
1321
+ const fixedSize = sumCodecSizes(fieldCodecs.map(getFixedSize));
1322
+ const maxSize = (_a = sumCodecSizes(fieldCodecs.map(getMaxSize))) != null ? _a : void 0;
1323
+ return createDecoder({
1324
+ ...fixedSize === null ? { maxSize } : { fixedSize },
1325
+ read: (bytes, offset) => {
1208
1326
  const struct = {};
1209
1327
  fields.forEach(([key, codec]) => {
1210
- const [value, newOffset] = codec.decode(bytes, offset);
1328
+ const [value, newOffset] = codec.read(bytes, offset);
1211
1329
  offset = newOffset;
1212
1330
  struct[key] = value;
1213
1331
  });
1214
1332
  return [struct, offset];
1215
1333
  }
1216
- };
1334
+ });
1217
1335
  }
1218
1336
 
1219
1337
  // ../functional/dist/index.browser.js
@@ -1221,6 +1339,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1221
1339
  function pipe(init, ...fns) {
1222
1340
  return fns.reduce((acc, fn) => fn(acc), init);
1223
1341
  }
1342
+
1343
+ // ../transactions/dist/index.browser.js
1224
1344
  function getUnsignedTransaction(transaction) {
1225
1345
  if ("signatures" in transaction) {
1226
1346
  const {
@@ -1233,10 +1353,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1233
1353
  return transaction;
1234
1354
  }
1235
1355
  }
1236
- var base58Encoder;
1356
+ var base58Encoder2;
1237
1357
  function assertIsBlockhash(putativeBlockhash) {
1238
- if (!base58Encoder)
1239
- base58Encoder = getBase58Encoder();
1358
+ if (!base58Encoder2)
1359
+ base58Encoder2 = getBase58Encoder();
1240
1360
  try {
1241
1361
  if (
1242
1362
  // Lowest value (32 bytes of zeroes)
@@ -1245,7 +1365,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1245
1365
  ) {
1246
1366
  throw new Error("Expected input string to decode to a byte array of length 32.");
1247
1367
  }
1248
- const bytes = base58Encoder.encode(putativeBlockhash);
1368
+ const bytes = base58Encoder2.encode(putativeBlockhash);
1249
1369
  const numBytes = bytes.byteLength;
1250
1370
  if (numBytes !== 32) {
1251
1371
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
@@ -1256,6 +1376,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1256
1376
  });
1257
1377
  }
1258
1378
  }
1379
+ function isTransactionWithBlockhashLifetime(transaction) {
1380
+ const lifetimeConstraintShapeMatches = "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.blockhash === "string" && typeof transaction.lifetimeConstraint.lastValidBlockHeight === "bigint";
1381
+ if (!lifetimeConstraintShapeMatches)
1382
+ return false;
1383
+ try {
1384
+ assertIsBlockhash(transaction.lifetimeConstraint.blockhash);
1385
+ return true;
1386
+ } catch {
1387
+ return false;
1388
+ }
1389
+ }
1390
+ function assertIsTransactionWithBlockhashLifetime(transaction) {
1391
+ if (!isTransactionWithBlockhashLifetime(transaction)) {
1392
+ throw new Error("Transaction does not have a blockhash lifetime");
1393
+ }
1394
+ }
1259
1395
  function setTransactionLifetimeUsingBlockhash(blockhashLifetimeConstraint, transaction) {
1260
1396
  if ("lifetimeConstraint" in transaction && transaction.lifetimeConstraint.blockhash === blockhashLifetimeConstraint.blockhash && transaction.lifetimeConstraint.lastValidBlockHeight === blockhashLifetimeConstraint.lastValidBlockHeight) {
1261
1397
  return transaction;
@@ -1320,9 +1456,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1320
1456
  };
1321
1457
  }
1322
1458
  function isAdvanceNonceAccountInstruction(instruction) {
1459
+ var _a;
1323
1460
  return instruction.programAddress === SYSTEM_PROGRAM_ADDRESS && // Test for `AdvanceNonceAccount` instruction data
1324
1461
  instruction.data != null && isAdvanceNonceAccountInstructionData(instruction.data) && // Test for exactly 3 accounts
1325
- instruction.accounts?.length === 3 && // First account is nonce account address
1462
+ ((_a = instruction.accounts) == null ? void 0 : _a.length) === 3 && // First account is nonce account address
1326
1463
  instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
1327
1464
  instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
1328
1465
  instruction.accounts[2].address != null && isSignerRole2(instruction.accounts[2].role);
@@ -1400,7 +1537,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1400
1537
  return out;
1401
1538
  }
1402
1539
  function upsert(addressMap, address2, update) {
1403
- addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
1540
+ var _a;
1541
+ addressMap[address2] = update((_a = addressMap[address2]) != null ? _a : { role: AccountRole2.READONLY });
1404
1542
  }
1405
1543
  var TYPE = Symbol("AddressMapTypeProperty");
1406
1544
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -1645,25 +1783,236 @@ this.globalThis.solanaWeb3 = (function (exports) {
1645
1783
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
1646
1784
  return orderedStaticAccounts.map(({ address: address2 }) => address2);
1647
1785
  }
1648
- function compileMessage(transaction) {
1649
- const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
1650
- const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
1651
- return {
1652
- ...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
1653
- header: getCompiledMessageHeader(orderedAccounts),
1654
- instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),
1655
- lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),
1656
- staticAccounts: getCompiledStaticAccounts(orderedAccounts),
1657
- version: transaction.version
1658
- };
1786
+ function compileMessage(transaction) {
1787
+ const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
1788
+ const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
1789
+ return {
1790
+ ...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
1791
+ header: getCompiledMessageHeader(orderedAccounts),
1792
+ instructions: getCompiledInstructions(transaction.instructions, orderedAccounts),
1793
+ lifetimeToken: getCompiledLifetimeToken(transaction.lifetimeConstraint),
1794
+ staticAccounts: getCompiledStaticAccounts(orderedAccounts),
1795
+ version: transaction.version
1796
+ };
1797
+ }
1798
+ var memoizedAddressTableLookupEncoder;
1799
+ function getAddressTableLookupEncoder() {
1800
+ if (!memoizedAddressTableLookupEncoder) {
1801
+ memoizedAddressTableLookupEncoder = getStructEncoder([
1802
+ ["lookupTableAddress", getAddressEncoder()],
1803
+ [
1804
+ "writableIndices",
1805
+ getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
1806
+ ],
1807
+ [
1808
+ "readableIndices",
1809
+ getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })
1810
+ ]
1811
+ ]);
1812
+ }
1813
+ return memoizedAddressTableLookupEncoder;
1814
+ }
1815
+ var memoizedAddressTableLookupDecoder;
1816
+ function getAddressTableLookupDecoder() {
1817
+ if (!memoizedAddressTableLookupDecoder) {
1818
+ memoizedAddressTableLookupDecoder = getStructDecoder([
1819
+ ["lookupTableAddress", getAddressDecoder()],
1820
+ ["writableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
1821
+ ["readableIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })]
1822
+ ]);
1823
+ }
1824
+ return memoizedAddressTableLookupDecoder;
1825
+ }
1826
+ var memoizedU8Encoder;
1827
+ function getMemoizedU8Encoder() {
1828
+ if (!memoizedU8Encoder)
1829
+ memoizedU8Encoder = getU8Encoder();
1830
+ return memoizedU8Encoder;
1831
+ }
1832
+ var memoizedU8Decoder;
1833
+ function getMemoizedU8Decoder() {
1834
+ if (!memoizedU8Decoder)
1835
+ memoizedU8Decoder = getU8Decoder();
1836
+ return memoizedU8Decoder;
1837
+ }
1838
+ function getMessageHeaderEncoder() {
1839
+ return getStructEncoder([
1840
+ ["numSignerAccounts", getMemoizedU8Encoder()],
1841
+ ["numReadonlySignerAccounts", getMemoizedU8Encoder()],
1842
+ ["numReadonlyNonSignerAccounts", getMemoizedU8Encoder()]
1843
+ ]);
1844
+ }
1845
+ function getMessageHeaderDecoder() {
1846
+ return getStructDecoder([
1847
+ ["numSignerAccounts", getMemoizedU8Decoder()],
1848
+ ["numReadonlySignerAccounts", getMemoizedU8Decoder()],
1849
+ ["numReadonlyNonSignerAccounts", getMemoizedU8Decoder()]
1850
+ ]);
1851
+ }
1852
+ var memoizedGetInstructionEncoder;
1853
+ function getInstructionEncoder() {
1854
+ if (!memoizedGetInstructionEncoder) {
1855
+ memoizedGetInstructionEncoder = mapEncoder(
1856
+ getStructEncoder([
1857
+ ["programAddressIndex", getU8Encoder()],
1858
+ ["accountIndices", getArrayEncoder(getU8Encoder(), { size: getShortU16Encoder() })],
1859
+ ["data", getBytesEncoder({ size: getShortU16Encoder() })]
1860
+ ]),
1861
+ // Convert an instruction to have all fields defined
1862
+ (instruction) => {
1863
+ var _a, _b;
1864
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1865
+ return instruction;
1866
+ }
1867
+ return {
1868
+ ...instruction,
1869
+ accountIndices: (_a = instruction.accountIndices) != null ? _a : [],
1870
+ data: (_b = instruction.data) != null ? _b : new Uint8Array(0)
1871
+ };
1872
+ }
1873
+ );
1874
+ }
1875
+ return memoizedGetInstructionEncoder;
1876
+ }
1877
+ var memoizedGetInstructionDecoder;
1878
+ function getInstructionDecoder() {
1879
+ if (!memoizedGetInstructionDecoder) {
1880
+ memoizedGetInstructionDecoder = mapDecoder(
1881
+ getStructDecoder([
1882
+ ["programAddressIndex", getU8Decoder()],
1883
+ ["accountIndices", getArrayDecoder(getU8Decoder(), { size: getShortU16Decoder() })],
1884
+ ["data", getBytesDecoder({ size: getShortU16Decoder() })]
1885
+ ]),
1886
+ // Convert an instruction to exclude optional fields if they are empty
1887
+ (instruction) => {
1888
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
1889
+ return instruction;
1890
+ }
1891
+ const { accountIndices, data, ...rest } = instruction;
1892
+ return {
1893
+ ...rest,
1894
+ ...accountIndices.length ? { accountIndices } : null,
1895
+ ...data.byteLength ? { data } : null
1896
+ };
1897
+ }
1898
+ );
1899
+ }
1900
+ return memoizedGetInstructionDecoder;
1901
+ }
1902
+ var VERSION_FLAG_MASK = 128;
1903
+ function getTransactionVersionEncoder() {
1904
+ return createEncoder({
1905
+ getSizeFromValue: (value) => value === "legacy" ? 0 : 1,
1906
+ maxSize: 1,
1907
+ write: (value, bytes, offset) => {
1908
+ if (value === "legacy") {
1909
+ return offset;
1910
+ }
1911
+ if (value < 0 || value > 127) {
1912
+ throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
1913
+ }
1914
+ bytes.set([value | VERSION_FLAG_MASK], offset);
1915
+ return offset + 1;
1916
+ }
1917
+ });
1918
+ }
1919
+ function getTransactionVersionDecoder() {
1920
+ return createDecoder({
1921
+ maxSize: 1,
1922
+ read: (bytes, offset) => {
1923
+ const firstByte = bytes[offset];
1924
+ if ((firstByte & VERSION_FLAG_MASK) === 0) {
1925
+ return ["legacy", offset];
1926
+ } else {
1927
+ const version = firstByte ^ VERSION_FLAG_MASK;
1928
+ return [version, offset + 1];
1929
+ }
1930
+ }
1931
+ });
1932
+ }
1933
+ function getCompiledMessageLegacyEncoder() {
1934
+ return getStructEncoder(getPreludeStructEncoderTuple());
1935
+ }
1936
+ function getCompiledMessageVersionedEncoder() {
1937
+ return mapEncoder(
1938
+ getStructEncoder([
1939
+ ...getPreludeStructEncoderTuple(),
1940
+ ["addressTableLookups", getAddressTableLookupArrayEncoder()]
1941
+ ]),
1942
+ (value) => {
1943
+ var _a;
1944
+ if (value.version === "legacy") {
1945
+ return value;
1946
+ }
1947
+ return {
1948
+ ...value,
1949
+ addressTableLookups: (_a = value.addressTableLookups) != null ? _a : []
1950
+ };
1951
+ }
1952
+ );
1953
+ }
1954
+ function getPreludeStructEncoderTuple() {
1955
+ return [
1956
+ ["version", getTransactionVersionEncoder()],
1957
+ ["header", getMessageHeaderEncoder()],
1958
+ ["staticAccounts", getArrayEncoder(getAddressEncoder(), { size: getShortU16Encoder() })],
1959
+ ["lifetimeToken", getStringEncoder({ encoding: getBase58Encoder(), size: 32 })],
1960
+ ["instructions", getArrayEncoder(getInstructionEncoder(), { size: getShortU16Encoder() })]
1961
+ ];
1962
+ }
1963
+ function getPreludeStructDecoderTuple() {
1964
+ return [
1965
+ ["version", getTransactionVersionDecoder()],
1966
+ ["header", getMessageHeaderDecoder()],
1967
+ ["staticAccounts", getArrayDecoder(getAddressDecoder(), { size: getShortU16Decoder() })],
1968
+ ["lifetimeToken", getStringDecoder({ encoding: getBase58Decoder(), size: 32 })],
1969
+ ["instructions", getArrayDecoder(getInstructionDecoder(), { size: getShortU16Decoder() })],
1970
+ ["addressTableLookups", getAddressTableLookupArrayDecoder()]
1971
+ ];
1972
+ }
1973
+ function getAddressTableLookupArrayEncoder() {
1974
+ return getArrayEncoder(getAddressTableLookupEncoder(), { size: getShortU16Encoder() });
1975
+ }
1976
+ function getAddressTableLookupArrayDecoder() {
1977
+ return getArrayDecoder(getAddressTableLookupDecoder(), { size: getShortU16Decoder() });
1978
+ }
1979
+ function getCompiledMessageEncoder() {
1980
+ return createEncoder({
1981
+ getSizeFromValue: (compiledMessage) => {
1982
+ if (compiledMessage.version === "legacy") {
1983
+ return getCompiledMessageLegacyEncoder().getSizeFromValue(compiledMessage);
1984
+ } else {
1985
+ return getCompiledMessageVersionedEncoder().getSizeFromValue(compiledMessage);
1986
+ }
1987
+ },
1988
+ write: (compiledMessage, bytes, offset) => {
1989
+ if (compiledMessage.version === "legacy") {
1990
+ return getCompiledMessageLegacyEncoder().write(compiledMessage, bytes, offset);
1991
+ } else {
1992
+ return getCompiledMessageVersionedEncoder().write(compiledMessage, bytes, offset);
1993
+ }
1994
+ }
1995
+ });
1996
+ }
1997
+ function getCompiledMessageDecoder() {
1998
+ return mapDecoder(getStructDecoder(getPreludeStructDecoderTuple()), ({ addressTableLookups, ...restOfMessage }) => {
1999
+ if (restOfMessage.version === "legacy" || !(addressTableLookups == null ? void 0 : addressTableLookups.length)) {
2000
+ return restOfMessage;
2001
+ }
2002
+ return { ...restOfMessage, addressTableLookups };
2003
+ });
2004
+ }
2005
+ function getCompiledMessageCodec() {
2006
+ return combineCodec(getCompiledMessageEncoder(), getCompiledMessageDecoder());
1659
2007
  }
1660
2008
  function getCompiledTransaction(transaction) {
2009
+ var _a;
1661
2010
  const compiledMessage = compileMessage(transaction);
1662
2011
  let signatures;
1663
2012
  if ("signatures" in transaction) {
1664
2013
  signatures = [];
1665
2014
  for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1666
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
2015
+ signatures[ii] = (_a = transaction.signatures[compiledMessage.staticAccounts[ii]]) != null ? _a : new Uint8Array(Array(64).fill(0));
1667
2016
  }
1668
2017
  } else {
1669
2018
  signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
@@ -1710,11 +2059,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
1710
2059
  return accountMetas;
1711
2060
  }
1712
2061
  function convertInstruction(instruction, accountMetas) {
1713
- const programAddress = accountMetas[instruction.programAddressIndex]?.address;
2062
+ var _a, _b;
2063
+ const programAddress = (_a = accountMetas[instruction.programAddressIndex]) == null ? void 0 : _a.address;
1714
2064
  if (!programAddress) {
1715
2065
  throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
1716
2066
  }
1717
- const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
2067
+ const accounts = (_b = instruction.accountIndices) == null ? void 0 : _b.map((accountIndex) => accountMetas[accountIndex]);
1718
2068
  const { data } = instruction;
1719
2069
  return {
1720
2070
  programAddress,
@@ -1726,7 +2076,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1726
2076
  if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
1727
2077
  return {
1728
2078
  blockhash: messageLifetimeToken,
1729
- lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
2079
+ lastValidBlockHeight: lastValidBlockHeight != null ? lastValidBlockHeight : 2n ** 64n - 1n
1730
2080
  // U64 MAX
1731
2081
  };
1732
2082
  } else {
@@ -1783,376 +2133,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
1783
2133
  (tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
1784
2134
  );
1785
2135
  }
1786
- var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1787
- var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1788
- var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1789
- 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" ;
1790
- var memoizedAddressTableLookupEncoder;
1791
- function getAddressTableLookupEncoder() {
1792
- if (!memoizedAddressTableLookupEncoder) {
1793
- memoizedAddressTableLookupEncoder = getStructEncoder(
1794
- [
1795
- ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1796
- [
1797
- "writableIndices",
1798
- getArrayEncoder(getU8Encoder(), {
1799
- description: writableIndicesDescription,
1800
- size: getShortU16Encoder()
1801
- })
1802
- ],
1803
- [
1804
- "readableIndices",
1805
- getArrayEncoder(getU8Encoder(), {
1806
- description: readableIndicesDescription,
1807
- size: getShortU16Encoder()
1808
- })
1809
- ]
1810
- ],
1811
- { description: addressTableLookupDescription }
1812
- );
1813
- }
1814
- return memoizedAddressTableLookupEncoder;
1815
- }
1816
- var memoizedAddressTableLookupDecoder;
1817
- function getAddressTableLookupDecoder() {
1818
- if (!memoizedAddressTableLookupDecoder) {
1819
- memoizedAddressTableLookupDecoder = getStructDecoder(
1820
- [
1821
- ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
1822
- [
1823
- "writableIndices",
1824
- getArrayDecoder(getU8Decoder(), {
1825
- description: writableIndicesDescription,
1826
- size: getShortU16Decoder()
1827
- })
1828
- ],
1829
- [
1830
- "readableIndices",
1831
- getArrayDecoder(getU8Decoder(), {
1832
- description: readableIndicesDescription,
1833
- size: getShortU16Decoder()
1834
- })
1835
- ]
1836
- ],
1837
- { description: addressTableLookupDescription }
1838
- );
1839
- }
1840
- return memoizedAddressTableLookupDecoder;
1841
- }
1842
- var memoizedU8Encoder;
1843
- function getMemoizedU8Encoder() {
1844
- if (!memoizedU8Encoder)
1845
- memoizedU8Encoder = getU8Encoder();
1846
- return memoizedU8Encoder;
1847
- }
1848
- function getMemoizedU8EncoderDescription(description) {
1849
- const encoder = getMemoizedU8Encoder();
1850
- return {
1851
- ...encoder,
1852
- description: description ?? encoder.description
1853
- };
1854
- }
1855
- var memoizedU8Decoder;
1856
- function getMemoizedU8Decoder() {
1857
- if (!memoizedU8Decoder)
1858
- memoizedU8Decoder = getU8Decoder();
1859
- return memoizedU8Decoder;
1860
- }
1861
- function getMemoizedU8DecoderDescription(description) {
1862
- const decoder = getMemoizedU8Decoder();
1863
- return {
1864
- ...decoder,
1865
- description: description ?? decoder.description
1866
- };
1867
- }
1868
- var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1869
- 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" ;
1870
- var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1871
- var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1872
- function getMessageHeaderEncoder() {
1873
- return getStructEncoder(
1874
- [
1875
- ["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
1876
- ["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
1877
- ["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
1878
- ],
1879
- {
1880
- description: messageHeaderDescription
1881
- }
1882
- );
1883
- }
1884
- function getMessageHeaderDecoder() {
1885
- return getStructDecoder(
1886
- [
1887
- ["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
1888
- ["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
1889
- ["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
1890
- ],
1891
- {
1892
- description: messageHeaderDescription
1893
- }
1894
- );
1895
- }
1896
- var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1897
- var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1898
- 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" ;
1899
- var dataDescription = "An optional buffer of data passed to the instruction" ;
1900
- var memoizedGetInstructionEncoder;
1901
- function getInstructionEncoder() {
1902
- if (!memoizedGetInstructionEncoder) {
1903
- memoizedGetInstructionEncoder = mapEncoder(
1904
- getStructEncoder([
1905
- ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1906
- [
1907
- "accountIndices",
1908
- getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1909
- description: accountIndicesDescription,
1910
- size: getShortU16Encoder()
1911
- })
1912
- ],
1913
- ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1914
- ]),
1915
- // Convert an instruction to have all fields defined
1916
- (instruction) => {
1917
- if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1918
- return instruction;
1919
- }
1920
- return {
1921
- ...instruction,
1922
- accountIndices: instruction.accountIndices ?? [],
1923
- data: instruction.data ?? new Uint8Array(0)
1924
- };
1925
- }
1926
- );
1927
- }
1928
- return memoizedGetInstructionEncoder;
1929
- }
1930
- var memoizedGetInstructionDecoder;
1931
- function getInstructionDecoder() {
1932
- if (!memoizedGetInstructionDecoder) {
1933
- memoizedGetInstructionDecoder = mapDecoder(
1934
- getStructDecoder([
1935
- ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
1936
- [
1937
- "accountIndices",
1938
- getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
1939
- description: accountIndicesDescription,
1940
- size: getShortU16Decoder()
1941
- })
1942
- ],
1943
- ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
1944
- ]),
1945
- // Convert an instruction to exclude optional fields if they are empty
1946
- (instruction) => {
1947
- if (instruction.accountIndices.length && instruction.data.byteLength) {
1948
- return instruction;
1949
- }
1950
- const { accountIndices, data, ...rest } = instruction;
1951
- return {
1952
- ...rest,
1953
- ...accountIndices.length ? { accountIndices } : null,
1954
- ...data.byteLength ? { data } : null
1955
- };
1956
- }
1957
- );
1958
- }
1959
- return memoizedGetInstructionDecoder;
1960
- }
1961
- var VERSION_FLAG_MASK = 128;
1962
- var BASE_CONFIG = {
1963
- description: "A single byte that encodes the version of the transaction" ,
1964
- fixedSize: null,
1965
- maxSize: 1
1966
- };
1967
- function decode(bytes, offset = 0) {
1968
- const firstByte = bytes[offset];
1969
- if ((firstByte & VERSION_FLAG_MASK) === 0) {
1970
- return ["legacy", offset];
1971
- } else {
1972
- const version = firstByte ^ VERSION_FLAG_MASK;
1973
- return [version, offset + 1];
1974
- }
1975
- }
1976
- function encode(value) {
1977
- if (value === "legacy") {
1978
- return new Uint8Array();
1979
- }
1980
- if (value < 0 || value > 127) {
1981
- throw new Error(`Transaction version must be in the range [0, 127]. \`${value}\` given.`);
1982
- }
1983
- return new Uint8Array([value | VERSION_FLAG_MASK]);
1984
- }
1985
- function getTransactionVersionDecoder() {
1986
- return {
1987
- ...BASE_CONFIG,
1988
- decode
1989
- };
1990
- }
1991
- function getTransactionVersionEncoder() {
1992
- return {
1993
- ...BASE_CONFIG,
1994
- encode
1995
- };
1996
- }
1997
- var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
1998
- var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
1999
- var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
2000
- var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
2001
- function getCompiledMessageLegacyEncoder() {
2002
- return getStructEncoder(getPreludeStructEncoderTuple());
2003
- }
2004
- function getCompiledMessageVersionedEncoder() {
2005
- return mapEncoder(
2006
- getStructEncoder([
2007
- ...getPreludeStructEncoderTuple(),
2008
- ["addressTableLookups", getAddressTableLookupArrayEncoder()]
2009
- ]),
2010
- (value) => {
2011
- if (value.version === "legacy") {
2012
- return value;
2013
- }
2014
- return {
2015
- ...value,
2016
- addressTableLookups: value.addressTableLookups ?? []
2017
- };
2018
- }
2019
- );
2020
- }
2021
- function getPreludeStructEncoderTuple() {
2022
- return [
2023
- ["version", getTransactionVersionEncoder()],
2024
- ["header", getMessageHeaderEncoder()],
2025
- [
2026
- "staticAccounts",
2027
- getArrayEncoder(getAddressEncoder(), {
2028
- description: staticAccountsDescription,
2029
- size: getShortU16Encoder()
2030
- })
2031
- ],
2032
- [
2033
- "lifetimeToken",
2034
- getStringEncoder({
2035
- description: lifetimeTokenDescription,
2036
- encoding: getBase58Encoder(),
2037
- size: 32
2038
- })
2039
- ],
2040
- [
2041
- "instructions",
2042
- getArrayEncoder(getInstructionEncoder(), {
2043
- description: instructionsDescription,
2044
- size: getShortU16Encoder()
2045
- })
2046
- ]
2047
- ];
2048
- }
2049
- function getPreludeStructDecoderTuple() {
2050
- return [
2051
- ["version", getTransactionVersionDecoder()],
2052
- ["header", getMessageHeaderDecoder()],
2053
- [
2054
- "staticAccounts",
2055
- getArrayDecoder(getAddressDecoder(), {
2056
- description: staticAccountsDescription,
2057
- size: getShortU16Decoder()
2058
- })
2059
- ],
2060
- [
2061
- "lifetimeToken",
2062
- getStringDecoder({
2063
- description: lifetimeTokenDescription,
2064
- encoding: getBase58Decoder(),
2065
- size: 32
2066
- })
2067
- ],
2068
- [
2069
- "instructions",
2070
- getArrayDecoder(getInstructionDecoder(), {
2071
- description: instructionsDescription,
2072
- size: getShortU16Decoder()
2073
- })
2074
- ],
2075
- ["addressTableLookups", getAddressTableLookupArrayDecoder()]
2076
- ];
2077
- }
2078
- function getAddressTableLookupArrayEncoder() {
2079
- return getArrayEncoder(getAddressTableLookupEncoder(), {
2080
- description: addressTableLookupsDescription,
2081
- size: getShortU16Encoder()
2082
- });
2083
- }
2084
- function getAddressTableLookupArrayDecoder() {
2085
- return getArrayDecoder(getAddressTableLookupDecoder(), {
2086
- description: addressTableLookupsDescription,
2087
- size: getShortU16Decoder()
2088
- });
2089
- }
2090
- var messageDescription = "The wire format of a Solana transaction message" ;
2091
- function getCompiledMessageEncoder() {
2092
- return {
2093
- description: messageDescription,
2094
- encode: (compiledMessage) => {
2095
- if (compiledMessage.version === "legacy") {
2096
- return getCompiledMessageLegacyEncoder().encode(compiledMessage);
2097
- } else {
2098
- return getCompiledMessageVersionedEncoder().encode(compiledMessage);
2099
- }
2100
- },
2101
- fixedSize: null,
2102
- maxSize: null
2103
- };
2104
- }
2105
- function getCompiledMessageDecoder() {
2106
- return mapDecoder(
2107
- getStructDecoder(getPreludeStructDecoderTuple(), {
2108
- description: messageDescription
2109
- }),
2110
- ({ addressTableLookups, ...restOfMessage }) => {
2111
- if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
2112
- return restOfMessage;
2113
- }
2114
- return { ...restOfMessage, addressTableLookups };
2115
- }
2116
- );
2117
- }
2118
- var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
2119
- var transactionDescription = "The wire format of a Solana transaction" ;
2120
2136
  function getCompiledTransactionEncoder() {
2121
- return getStructEncoder(
2122
- [
2123
- [
2124
- "signatures",
2125
- getArrayEncoder(getBytesEncoder({ size: 64 }), {
2126
- description: signaturesDescription,
2127
- size: getShortU16Encoder()
2128
- })
2129
- ],
2130
- ["compiledMessage", getCompiledMessageEncoder()]
2131
- ],
2132
- {
2133
- description: transactionDescription
2134
- }
2135
- );
2136
- }
2137
- function getSignatureDecoder() {
2138
- return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
2137
+ return getStructEncoder([
2138
+ ["signatures", getArrayEncoder(getBytesEncoder({ size: 64 }), { size: getShortU16Encoder() })],
2139
+ ["compiledMessage", getCompiledMessageEncoder()]
2140
+ ]);
2139
2141
  }
2140
2142
  function getCompiledTransactionDecoder() {
2141
- return getStructDecoder(
2143
+ return getStructDecoder([
2142
2144
  [
2143
- [
2144
- "signatures",
2145
- getArrayDecoder(getSignatureDecoder(), {
2146
- description: signaturesDescription,
2147
- size: getShortU16Decoder()
2148
- })
2149
- ],
2150
- ["compiledMessage", getCompiledMessageDecoder()]
2145
+ "signatures",
2146
+ getArrayDecoder(getBytesDecoder({ size: 64 }), {
2147
+ size: getShortU16Decoder()
2148
+ })
2151
2149
  ],
2152
- {
2153
- description: transactionDescription
2154
- }
2155
- );
2150
+ ["compiledMessage", getCompiledMessageDecoder()]
2151
+ ]);
2156
2152
  }
2157
2153
  function getTransactionEncoder() {
2158
2154
  return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
@@ -2166,47 +2162,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2166
2162
  function getTransactionCodec(lastValidBlockHeight) {
2167
2163
  return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
2168
2164
  }
2169
- var base58Encoder2;
2170
2165
  var base58Decoder;
2171
- function assertIsTransactionSignature(putativeTransactionSignature) {
2172
- if (!base58Encoder2)
2173
- base58Encoder2 = getBase58Encoder();
2174
- try {
2175
- if (
2176
- // Lowest value (64 bytes of zeroes)
2177
- putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2178
- putativeTransactionSignature.length > 88
2179
- ) {
2180
- throw new Error("Expected input string to decode to a byte array of length 64.");
2181
- }
2182
- const bytes = base58Encoder2.encode(putativeTransactionSignature);
2183
- const numBytes = bytes.byteLength;
2184
- if (numBytes !== 64) {
2185
- throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
2186
- }
2187
- } catch (e3) {
2188
- throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
2189
- cause: e3
2190
- });
2191
- }
2192
- }
2193
- function isTransactionSignature(putativeTransactionSignature) {
2194
- if (!base58Encoder2)
2195
- base58Encoder2 = getBase58Encoder();
2196
- if (
2197
- // Lowest value (64 bytes of zeroes)
2198
- putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2199
- putativeTransactionSignature.length > 88
2200
- ) {
2201
- return false;
2202
- }
2203
- const bytes = base58Encoder2.encode(putativeTransactionSignature);
2204
- const numBytes = bytes.byteLength;
2205
- if (numBytes !== 64) {
2206
- return false;
2207
- }
2208
- return true;
2209
- }
2210
2166
  function getSignatureFromTransaction(transaction) {
2211
2167
  if (!base58Decoder)
2212
2168
  base58Decoder = getBase58Decoder();
@@ -2216,10 +2172,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
2216
2172
  "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
2217
2173
  );
2218
2174
  }
2219
- const transactionSignature2 = base58Decoder.decode(signatureBytes)[0];
2220
- return transactionSignature2;
2175
+ const transactionSignature = base58Decoder.decode(signatureBytes);
2176
+ return transactionSignature;
2221
2177
  }
2222
- async function signTransaction(keyPairs, transaction) {
2178
+ async function partiallySignTransaction(keyPairs, transaction) {
2223
2179
  const compiledMessage = compileMessage(transaction);
2224
2180
  const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
2225
2181
  const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
@@ -2228,8 +2184,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2228
2184
  (keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
2229
2185
  )
2230
2186
  );
2231
- for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
2232
- nextSignatures[signerPublicKey] = signature;
2187
+ for (const [signerPublicKey, signature2] of publicKeySignaturePairs) {
2188
+ nextSignatures[signerPublicKey] = signature2;
2233
2189
  }
2234
2190
  const out = {
2235
2191
  ...transaction,
@@ -2238,12 +2194,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
2238
2194
  Object.freeze(out);
2239
2195
  return out;
2240
2196
  }
2241
- function transactionSignature(putativeTransactionSignature) {
2242
- assertIsTransactionSignature(putativeTransactionSignature);
2243
- return putativeTransactionSignature;
2197
+ async function signTransaction(keyPairs, transaction) {
2198
+ const out = await partiallySignTransaction(keyPairs, transaction);
2199
+ assertTransactionIsFullySigned(out);
2200
+ Object.freeze(out);
2201
+ return out;
2244
2202
  }
2245
2203
  function assertTransactionIsFullySigned(transaction) {
2246
- const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole2(a.role)) ?? []).map((a) => a.address);
2204
+ const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => {
2205
+ var _a, _b;
2206
+ return (_b = (_a = i.accounts) == null ? void 0 : _a.filter((a) => isSignerRole2(a.role))) != null ? _b : [];
2207
+ }).map((a) => a.address);
2247
2208
  const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
2248
2209
  requiredSigners.forEach((address2) => {
2249
2210
  if (!transaction.signatures[address2]) {
@@ -2253,9 +2214,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2253
2214
  }
2254
2215
  function getBase64EncodedWireTransaction(transaction) {
2255
2216
  const wireTransactionBytes = getTransactionEncoder().encode(transaction);
2256
- {
2257
- return btoa(String.fromCharCode(...wireTransactionBytes));
2258
- }
2217
+ return getBase64Decoder().decode(wireTransactionBytes);
2259
2218
  }
2260
2219
 
2261
2220
  // src/airdrop.ts
@@ -2266,9 +2225,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
2266
2225
 
2267
2226
  // src/transaction-confirmation-strategy-racer.ts
2268
2227
  init_env_shim();
2269
- async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
2228
+ async function raceStrategies(signature2, config, getSpecificStrategiesForRace) {
2270
2229
  const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
2271
- callerAbortSignal?.throwIfAborted();
2230
+ callerAbortSignal == null ? void 0 : callerAbortSignal.throwIfAborted();
2272
2231
  const abortController = new AbortController();
2273
2232
  if (callerAbortSignal) {
2274
2233
  const handleAbort = () => {
@@ -2285,7 +2244,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2285
2244
  getRecentSignatureConfirmationPromise({
2286
2245
  abortSignal: abortController.signal,
2287
2246
  commitment,
2288
- signature
2247
+ signature: signature2
2289
2248
  }),
2290
2249
  ...specificStrategies
2291
2250
  ]);
@@ -2300,18 +2259,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
2300
2259
  return async function getRecentSignatureConfirmationPromise({
2301
2260
  abortSignal: callerAbortSignal,
2302
2261
  commitment,
2303
- signature
2262
+ signature: signature2
2304
2263
  }) {
2305
2264
  const abortController = new AbortController();
2306
2265
  function handleAbort() {
2307
2266
  abortController.abort();
2308
2267
  }
2309
2268
  callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
2310
- const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
2269
+ const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature2, { commitment }).subscribe({ abortSignal: abortController.signal });
2311
2270
  const signatureDidCommitPromise = (async () => {
2312
2271
  for await (const signatureStatusNotification of signatureStatusNotifications) {
2313
2272
  if (signatureStatusNotification.value.err) {
2314
- throw new Error(`The transaction with signature \`${signature}\` failed.`, {
2273
+ throw new Error(`The transaction with signature \`${signature2}\` failed.`, {
2315
2274
  cause: signatureStatusNotification.value.err
2316
2275
  });
2317
2276
  } else {
@@ -2320,7 +2279,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2320
2279
  }
2321
2280
  })();
2322
2281
  const signatureStatusLookupPromise = (async () => {
2323
- const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
2282
+ const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature2]).send({ abortSignal: abortController.signal });
2324
2283
  const signatureStatus = signatureStatusResults[0];
2325
2284
  if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
2326
2285
  return;
@@ -2869,11 +2828,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
2869
2828
  }
2870
2829
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
2871
2830
  const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
2872
- return visitNode2(rawResponse, allowedKeypaths ?? []);
2831
+ return visitNode2(rawResponse, allowedKeypaths != null ? allowedKeypaths : []);
2873
2832
  }
2874
2833
  function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
2875
2834
  const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
2876
- return visitNode2(rawResponse, allowedKeypaths ?? []);
2835
+ return visitNode2(rawResponse, allowedKeypaths != null ? allowedKeypaths : []);
2877
2836
  }
2878
2837
  function createSolanaRpcApi(config) {
2879
2838
  return new Proxy({}, {
@@ -2887,7 +2846,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2887
2846
  const [_, p] = args;
2888
2847
  const methodName = p.toString();
2889
2848
  return function(...rawParams) {
2890
- const handleIntegerOverflow = config?.onIntegerOverflow;
2849
+ const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
2891
2850
  const params = patchParamsForSolanaLabsRpc(
2892
2851
  rawParams,
2893
2852
  handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
@@ -2913,7 +2872,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2913
2872
  const [_, p] = args;
2914
2873
  const notificationName = p.toString();
2915
2874
  return function(...rawParams) {
2916
- const handleIntegerOverflow = config?.onIntegerOverflow;
2875
+ const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
2917
2876
  const params = patchParamsForSolanaLabsRpc(
2918
2877
  rawParams,
2919
2878
  handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
@@ -2937,6 +2896,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
2937
2896
  var SolanaJsonRpcError = class extends Error {
2938
2897
  constructor(details) {
2939
2898
  super(`JSON-RPC 2.0 error (${details.code}): ${details.message}`);
2899
+ __publicField(this, "code");
2900
+ __publicField(this, "data");
2940
2901
  Error.captureStackTrace(this, this.constructor);
2941
2902
  this.code = details.code;
2942
2903
  this.data = details.data;
@@ -2966,7 +2927,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2966
2927
  const payload = createJsonRpcMessage(methodName, params);
2967
2928
  const response = await rpcConfig.transport({
2968
2929
  payload,
2969
- signal: options?.abortSignal
2930
+ signal: options == null ? void 0 : options.abortSignal
2970
2931
  });
2971
2932
  if ("error" in response) {
2972
2933
  throw new SolanaJsonRpcError(response.error);
@@ -3095,6 +3056,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3095
3056
  var SolanaHttpError = class extends Error {
3096
3057
  constructor(details) {
3097
3058
  super(`HTTP error (${details.statusCode}): ${details.message}`);
3059
+ __publicField(this, "statusCode");
3098
3060
  Error.captureStackTrace(this, this.constructor);
3099
3061
  this.statusCode = details.statusCode;
3100
3062
  }
@@ -3184,7 +3146,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3184
3146
  }
3185
3147
  var e22 = globalThis.WebSocket;
3186
3148
  var EXPLICIT_ABORT_TOKEN = Symbol(
3187
- "This symbol is thrown from a socket's iterator when the connection is explicity aborted by the user"
3149
+ "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
3188
3150
  );
3189
3151
  async function createWebSocketConnection({
3190
3152
  sendBufferHighWatermark,
@@ -3211,7 +3173,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3211
3173
  }
3212
3174
  }
3213
3175
  function handleClose(ev) {
3214
- bufferDrainWatcher?.onCancel();
3176
+ bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
3215
3177
  signal.removeEventListener("abort", handleAbort);
3216
3178
  webSocket.removeEventListener("close", handleClose);
3217
3179
  webSocket.removeEventListener("error", handleError);
@@ -3334,13 +3296,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
3334
3296
  );
3335
3297
  }
3336
3298
  return async function sendWebSocketMessage({ payload, signal }) {
3337
- signal?.throwIfAborted();
3299
+ signal == null ? void 0 : signal.throwIfAborted();
3338
3300
  const connection = await createWebSocketConnection({
3339
3301
  sendBufferHighWatermark,
3340
3302
  signal,
3341
3303
  url
3342
3304
  });
3343
- signal?.throwIfAborted();
3305
+ signal == null ? void 0 : signal.throwIfAborted();
3344
3306
  await connection.send(payload);
3345
3307
  return {
3346
3308
  [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
@@ -3376,6 +3338,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3376
3338
  super(
3377
3339
  `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\`.`
3378
3340
  );
3341
+ __publicField(this, "methodName");
3342
+ __publicField(this, "keyPath");
3343
+ __publicField(this, "value");
3379
3344
  this.keyPath = keyPath;
3380
3345
  this.methodName = methodName;
3381
3346
  this.value = value;
@@ -3522,7 +3487,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3522
3487
  getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
3523
3488
  getCacheEntryMissingError(deduplicationKey2) {
3524
3489
  return new Error(
3525
- `Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
3490
+ `Found no cache entry for subscription with deduplication key \`${deduplicationKey2 == null ? void 0 : deduplicationKey2.toString()}\``
3526
3491
  );
3527
3492
  },
3528
3493
  getCacheKeyFromInputArgs: () => deduplicationKey,
@@ -3687,6 +3652,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3687
3652
  return out;
3688
3653
  }
3689
3654
  function createDefaultRpcTransport(config) {
3655
+ var _a;
3690
3656
  return pipe(
3691
3657
  createHttpTransport({
3692
3658
  ...config,
@@ -3694,7 +3660,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3694
3660
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
3695
3661
  ...{
3696
3662
  // Keep these headers lowercase so they will override any user-supplied headers above.
3697
- "solana-client": `js/${"2.0.0-development"}` ?? "UNKNOWN"
3663
+ "solana-client": (_a = `js/${"2.0.0-development"}`) != null ? _a : "UNKNOWN"
3698
3664
  }
3699
3665
  }
3700
3666
  }),
@@ -3778,7 +3744,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3778
3744
  return getCachedAbortableIterableFactory({
3779
3745
  getAbortSignalFromInputArgs: ({ signal }) => signal,
3780
3746
  getCacheEntryMissingError(shardKey) {
3781
- return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
3747
+ return new Error(`Found no cache entry for connection with shard key \`${shardKey == null ? void 0 : shardKey.toString()}\``);
3782
3748
  },
3783
3749
  getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
3784
3750
  onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
@@ -3791,15 +3757,18 @@ this.globalThis.solanaWeb3 = (function (exports) {
3791
3757
 
3792
3758
  // src/rpc-websocket-transport.ts
3793
3759
  function createDefaultRpcSubscriptionsTransport(config) {
3760
+ var _a;
3794
3761
  const { getShard, intervalMs, ...rest } = config;
3795
3762
  return pipe(
3796
3763
  createWebSocketTransport({
3797
3764
  ...rest,
3798
- sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
3799
- 131072
3765
+ sendBufferHighWatermark: (_a = config.sendBufferHighWatermark) != null ? _a : (
3766
+ // Let 128KB of data into the WebSocket buffer before buffering it in the app.
3767
+ 131072
3768
+ )
3800
3769
  }),
3801
3770
  (transport) => getWebSocketTransportWithAutoping({
3802
- intervalMs: intervalMs ?? 5e3,
3771
+ intervalMs: intervalMs != null ? intervalMs : 5e3,
3803
3772
  transport
3804
3773
  }),
3805
3774
  (transport) => getWebSocketTransportWithConnectionSharding({
@@ -3862,7 +3831,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3862
3831
  function getNonceFromAccountData([base64EncodedBytes]) {
3863
3832
  const data = base64Encoder.encode(base64EncodedBytes);
3864
3833
  const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
3865
- return base58Decoder2.decode(nonceValueBytes)[0];
3834
+ return base58Decoder2.decode(nonceValueBytes);
3866
3835
  }
3867
3836
  const nonceAccountDidAdvancePromise = (async () => {
3868
3837
  for await (const accountNotification of accountNotifications) {
@@ -3975,7 +3944,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3975
3944
  function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
3976
3945
  if (
3977
3946
  // The developer has supplied no value for `preflightCommitment`.
3978
- !config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
3947
+ !(config == null ? void 0 : config.preflightCommitment) && // The value of `commitment` is lower than the server default of `preflightCommitment`.
3979
3948
  commitmentComparator(
3980
3949
  commitment,
3981
3950
  "finalized"
@@ -4048,7 +4017,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4048
4017
  transaction,
4049
4018
  ...sendTransactionConfig
4050
4019
  }) {
4051
- const transactionSignature2 = await sendTransaction_INTERNAL({
4020
+ const transactionSignature = await sendTransaction_INTERNAL({
4052
4021
  ...sendTransactionConfig,
4053
4022
  abortSignal,
4054
4023
  commitment,
@@ -4060,7 +4029,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4060
4029
  commitment,
4061
4030
  transaction
4062
4031
  });
4063
- return transactionSignature2;
4032
+ return transactionSignature;
4064
4033
  }
4065
4034
  async function sendAndConfirmTransaction({
4066
4035
  abortSignal,
@@ -4070,7 +4039,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4070
4039
  transaction,
4071
4040
  ...sendTransactionConfig
4072
4041
  }) {
4073
- const transactionSignature2 = await sendTransaction_INTERNAL({
4042
+ const transactionSignature = await sendTransaction_INTERNAL({
4074
4043
  ...sendTransactionConfig,
4075
4044
  abortSignal,
4076
4045
  commitment,
@@ -4082,7 +4051,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4082
4051
  commitment,
4083
4052
  transaction
4084
4053
  });
4085
- return transactionSignature2;
4054
+ return transactionSignature;
4086
4055
  }
4087
4056
 
4088
4057
  exports.AccountRole = AccountRole;
@@ -4093,12 +4062,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
4093
4062
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
4094
4063
  exports.assertIsLamports = assertIsLamports;
4095
4064
  exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
4065
+ exports.assertIsSignature = assertIsSignature;
4096
4066
  exports.assertIsStringifiedBigInt = assertIsStringifiedBigInt;
4097
4067
  exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
4098
- exports.assertIsTransactionSignature = assertIsTransactionSignature;
4068
+ exports.assertIsTransactionWithBlockhashLifetime = assertIsTransactionWithBlockhashLifetime;
4099
4069
  exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
4100
4070
  exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
4101
4071
  exports.commitmentComparator = commitmentComparator;
4072
+ exports.compileMessage = compileMessage;
4102
4073
  exports.createAddressWithSeed = createAddressWithSeed;
4103
4074
  exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
4104
4075
  exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
@@ -4109,6 +4080,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4109
4080
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
4110
4081
  exports.createDefaultTransactionSender = createDefaultTransactionSender;
4111
4082
  exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
4083
+ exports.createPrivateKeyFromBytes = createPrivateKeyFromBytes;
4112
4084
  exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
4113
4085
  exports.createSolanaRpc = createSolanaRpc;
4114
4086
  exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
@@ -4123,6 +4095,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4123
4095
  exports.getAddressEncoder = getAddressEncoder;
4124
4096
  exports.getAddressFromPublicKey = getAddressFromPublicKey;
4125
4097
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
4098
+ exports.getCompiledMessageCodec = getCompiledMessageCodec;
4099
+ exports.getCompiledMessageDecoder = getCompiledMessageDecoder;
4100
+ exports.getCompiledMessageEncoder = getCompiledMessageEncoder;
4126
4101
  exports.getProgramDerivedAddress = getProgramDerivedAddress;
4127
4102
  exports.getSignatureFromTransaction = getSignatureFromTransaction;
4128
4103
  exports.getTransactionCodec = getTransactionCodec;
@@ -4132,14 +4107,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
4132
4107
  exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
4133
4108
  exports.isLamports = isLamports;
4134
4109
  exports.isProgramDerivedAddress = isProgramDerivedAddress;
4110
+ exports.isSignature = isSignature;
4135
4111
  exports.isSignerRole = isSignerRole;
4136
4112
  exports.isStringifiedBigInt = isStringifiedBigInt;
4137
4113
  exports.isStringifiedNumber = isStringifiedNumber;
4138
- exports.isTransactionSignature = isTransactionSignature;
4139
4114
  exports.isUnixTimestamp = isUnixTimestamp;
4140
4115
  exports.isWritableRole = isWritableRole;
4141
4116
  exports.lamports = lamports;
4142
4117
  exports.mergeRoles = mergeRoles;
4118
+ exports.partiallySignTransaction = partiallySignTransaction;
4143
4119
  exports.prependTransactionInstruction = prependTransactionInstruction;
4144
4120
  exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
4145
4121
  exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
@@ -4149,9 +4125,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
4149
4125
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
4150
4126
  exports.signBytes = signBytes;
4151
4127
  exports.signTransaction = signTransaction;
4128
+ exports.signature = signature;
4152
4129
  exports.stringifiedBigInt = stringifiedBigInt;
4153
4130
  exports.stringifiedNumber = stringifiedNumber;
4154
- exports.transactionSignature = transactionSignature;
4155
4131
  exports.unixTimestamp = unixTimestamp;
4156
4132
  exports.upgradeRoleToSigner = upgradeRoleToSigner;
4157
4133
  exports.upgradeRoleToWritable = upgradeRoleToWritable;