@solana/web3.js 2.0.0-experimental.8936f2f → 2.0.0-experimental.8c5ac55

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 (32) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -4
  3. package/dist/index.browser.cjs +773 -11
  4. package/dist/index.browser.cjs.map +1 -1
  5. package/dist/index.browser.js +747 -11
  6. package/dist/index.browser.js.map +1 -1
  7. package/dist/index.development.js +3004 -861
  8. package/dist/index.development.js.map +1 -1
  9. package/dist/index.native.js +736 -11
  10. package/dist/index.native.js.map +1 -1
  11. package/dist/index.node.cjs +762 -11
  12. package/dist/index.node.cjs.map +1 -1
  13. package/dist/index.node.js +736 -11
  14. package/dist/index.node.js.map +1 -1
  15. package/dist/index.production.min.js +75 -29
  16. package/dist/types/airdrop-confirmer.d.ts +20 -0
  17. package/dist/types/airdrop.d.ts +23 -0
  18. package/dist/types/cached-abortable-iterable.d.ts +11 -0
  19. package/dist/types/index.d.ts +9 -0
  20. package/dist/types/rpc-subscription-coalescer.d.ts +10 -0
  21. package/dist/types/rpc-websocket-autopinger.d.ts +8 -0
  22. package/dist/types/rpc-websocket-connection-sharding.d.ts +13 -0
  23. package/dist/types/rpc-websocket-transport.d.ts +13 -0
  24. package/dist/types/rpc.d.ts +5 -3
  25. package/dist/types/send-transaction.d.ts +37 -0
  26. package/dist/types/transaction-confirmation-strategy-blockheight.d.ts +10 -0
  27. package/dist/types/transaction-confirmation-strategy-nonce.d.ts +15 -0
  28. package/dist/types/transaction-confirmation-strategy-racer.d.ts +14 -0
  29. package/dist/types/transaction-confirmation-strategy-recent-signature.d.ts +13 -0
  30. package/dist/types/transaction-confirmation-strategy-timeout.d.ts +8 -0
  31. package/dist/types/transaction-confirmation.d.ts +37 -0
  32. package/package.json +24 -23
@@ -8,12 +8,11 @@ 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;
12
11
  var __esm = (fn, res) => function __init() {
13
12
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
14
13
  };
15
- var __commonJS = (cb, mod) => function __require() {
16
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
+ var __commonJS = (cb, mod2) => function __require() {
15
+ return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
17
16
  };
18
17
  var __copyProps = (to, from, except, desc) => {
19
18
  if (from && typeof from === "object" || typeof from === "function") {
@@ -23,18 +22,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
23
22
  }
24
23
  return to;
25
24
  };
26
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
27
26
  // If the importer is in node compatibility mode or this is not an ESM
28
27
  // file that has been converted to a CommonJS file using a Babel-
29
28
  // compatible transform (i.e. "__esModule" has not been set), then set
30
29
  // "default" to the CommonJS "module.exports" for node compatibility.
31
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
- mod
30
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
31
+ mod2
33
32
  ));
34
- var __publicField = (obj, key, value) => {
35
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
36
- return value;
37
- };
38
33
 
39
34
  // ../build-scripts/env-shim.ts
40
35
  var init_env_shim = __esm({
@@ -122,344 +117,209 @@ this.globalThis.solanaWeb3 = (function (exports) {
122
117
  // src/index.ts
123
118
  init_env_shim();
124
119
 
125
- // ../instructions/dist/index.browser.js
126
- init_env_shim();
127
- var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
128
- AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
129
- 3] = "WRITABLE_SIGNER";
130
- AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
131
- 2] = "READONLY_SIGNER";
132
- AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
133
- 1] = "WRITABLE";
134
- AccountRole22[AccountRole22["READONLY"] = /* 0 */
135
- 0] = "READONLY";
136
- return AccountRole22;
137
- })(AccountRole || {});
138
- var IS_SIGNER_BITMASK = 2;
139
- var IS_WRITABLE_BITMASK = 1;
140
- function downgradeRoleToNonSigner(role) {
141
- return role & ~IS_SIGNER_BITMASK;
142
- }
143
- function downgradeRoleToReadonly(role) {
144
- return role & ~IS_WRITABLE_BITMASK;
145
- }
146
- function isSignerRole(role) {
147
- return role >= 2;
148
- }
149
- function isWritableRole(role) {
150
- return (role & IS_WRITABLE_BITMASK) !== 0;
151
- }
152
- function mergeRoles(roleA, roleB) {
153
- return roleA | roleB;
154
- }
155
- function upgradeRoleToSigner(role) {
156
- return role | IS_SIGNER_BITMASK;
157
- }
158
- function upgradeRoleToWritable(role) {
159
- return role | IS_WRITABLE_BITMASK;
160
- }
161
-
162
- // ../keys/dist/index.browser.js
163
- init_env_shim();
164
-
165
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/index.mjs
166
- init_env_shim();
167
-
168
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/index.mjs
120
+ // ../addresses/dist/index.browser.js
169
121
  init_env_shim();
170
122
 
171
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/bytes.mjs
123
+ // ../codecs-core/dist/index.browser.js
172
124
  init_env_shim();
173
- var mergeBytes = (bytesArr) => {
174
- const totalLength = bytesArr.reduce((total, arr) => total + arr.length, 0);
125
+ function assertByteArrayIsNotEmptyForCodec(codecDescription, bytes, offset = 0) {
126
+ if (bytes.length - offset <= 0) {
127
+ throw new Error(`Codec [${codecDescription}] cannot decode empty byte arrays.`);
128
+ }
129
+ }
130
+ function assertByteArrayHasEnoughBytesForCodec(codecDescription, expected, bytes, offset = 0) {
131
+ const bytesLength = bytes.length - offset;
132
+ if (bytesLength < expected) {
133
+ throw new Error(`Codec [${codecDescription}] expected ${expected} bytes, got ${bytesLength}.`);
134
+ }
135
+ }
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);
175
145
  const result = new Uint8Array(totalLength);
176
146
  let offset = 0;
177
- bytesArr.forEach((arr) => {
147
+ nonEmptyByteArrays.forEach((arr) => {
178
148
  result.set(arr, offset);
179
149
  offset += arr.length;
180
150
  });
181
151
  return result;
182
152
  };
183
- var padBytes = (bytes2, length) => {
184
- if (bytes2.length >= length)
185
- return bytes2;
153
+ var padBytes = (bytes, length) => {
154
+ if (bytes.length >= length)
155
+ return bytes;
186
156
  const paddedBytes = new Uint8Array(length).fill(0);
187
- paddedBytes.set(bytes2);
157
+ paddedBytes.set(bytes);
188
158
  return paddedBytes;
189
159
  };
190
- var fixBytes = (bytes2, length) => padBytes(bytes2.slice(0, length), length);
191
-
192
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/errors.mjs
193
- init_env_shim();
194
- var DeserializingEmptyBufferError = class extends Error {
195
- constructor(serializer) {
196
- super(`Serializer [${serializer}] cannot deserialize empty buffers.`);
197
- __publicField(this, "name", "DeserializingEmptyBufferError");
160
+ 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) {
163
+ throw new Error(
164
+ `Encoder and decoder must have the same fixed size, got [${encoder.fixedSize}] and [${decoder.fixedSize}].`
165
+ );
198
166
  }
199
- };
200
- var NotEnoughBytesError = class extends Error {
201
- constructor(serializer, expected, actual) {
202
- super(`Serializer [${serializer}] expected ${expected} bytes, got ${actual}.`);
203
- __publicField(this, "name", "NotEnoughBytesError");
167
+ if (encoder.maxSize !== decoder.maxSize) {
168
+ throw new Error(
169
+ `Encoder and decoder must have the same max size, got [${encoder.maxSize}] and [${decoder.maxSize}].`
170
+ );
204
171
  }
205
- };
206
- var ExpectedFixedSizeSerializerError = class extends Error {
207
- constructor(message) {
208
- message ?? (message = "Expected a fixed-size serializer, got a variable-size one.");
209
- super(message);
210
- __publicField(this, "name", "ExpectedFixedSizeSerializerError");
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
+ );
211
176
  }
212
- };
213
-
214
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/fixSerializer.mjs
215
- init_env_shim();
216
- function fixSerializer(serializer, fixedBytes, description) {
217
177
  return {
218
- description: description ?? `fixed(${fixedBytes}, ${serializer.description})`,
178
+ decode: decoder.decode,
179
+ description: description ?? encoder.description,
180
+ encode: encoder.encode,
181
+ fixedSize: encoder.fixedSize,
182
+ maxSize: encoder.maxSize
183
+ };
184
+ }
185
+ function fixCodecHelper(data, fixedBytes, description) {
186
+ return {
187
+ description: description ?? `fixed(${fixedBytes}, ${data.description})`,
219
188
  fixedSize: fixedBytes,
220
- maxSize: fixedBytes,
221
- serialize: (value) => fixBytes(serializer.serialize(value), fixedBytes),
222
- deserialize: (buffer, offset = 0) => {
223
- buffer = buffer.slice(offset, offset + fixedBytes);
224
- if (buffer.length < fixedBytes) {
225
- throw new NotEnoughBytesError("fixSerializer", fixedBytes, buffer.length);
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
+ };
197
+ }
198
+ function fixDecoder(decoder, fixedBytes, description) {
199
+ return {
200
+ ...fixCodecHelper(decoder, fixedBytes, description),
201
+ decode: (bytes, offset = 0) => {
202
+ assertByteArrayHasEnoughBytesForCodec("fixCodec", fixedBytes, bytes, offset);
203
+ if (offset > 0 || bytes.length > fixedBytes) {
204
+ bytes = bytes.slice(offset, offset + fixedBytes);
226
205
  }
227
- if (serializer.fixedSize !== null) {
228
- buffer = fixBytes(buffer, serializer.fixedSize);
206
+ if (decoder.fixedSize !== null) {
207
+ bytes = fixBytes(bytes, decoder.fixedSize);
229
208
  }
230
- const [value] = serializer.deserialize(buffer, 0);
209
+ const [value] = decoder.decode(bytes, 0);
231
210
  return [value, offset + fixedBytes];
232
211
  }
233
212
  };
234
213
  }
235
-
236
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-core@0.8.2/node_modules/@metaplex-foundation/umi-serializers-core/dist/esm/mapSerializer.mjs
237
- init_env_shim();
238
- function mapSerializer(serializer, unmap, map) {
214
+ function mapEncoder(encoder, unmap) {
239
215
  return {
240
- description: serializer.description,
241
- fixedSize: serializer.fixedSize,
242
- maxSize: serializer.maxSize,
243
- serialize: (value) => serializer.serialize(unmap(value)),
244
- deserialize: (buffer, offset = 0) => {
245
- const [value, length] = serializer.deserialize(buffer, offset);
246
- return map ? [map(value, buffer, offset), length] : [value, length];
247
- }
216
+ description: encoder.description,
217
+ encode: (value) => encoder.encode(unmap(value)),
218
+ fixedSize: encoder.fixedSize,
219
+ maxSize: encoder.maxSize
248
220
  };
249
221
  }
250
-
251
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/index.mjs
252
- init_env_shim();
253
-
254
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
255
- init_env_shim();
256
-
257
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/errors.mjs
258
- init_env_shim();
259
- var InvalidBaseStringError = class extends Error {
260
- constructor(value, base, cause) {
261
- const message = `Expected a string of base ${base}, got [${value}].`;
262
- super(message);
263
- __publicField(this, "name", "InvalidBaseStringError");
264
- this.cause = cause;
265
- }
266
- };
267
-
268
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/baseX.mjs
269
- var baseX = (alphabet) => {
270
- const base = alphabet.length;
271
- const baseBigInt = BigInt(base);
222
+ function mapDecoder(decoder, map) {
272
223
  return {
273
- description: `base${base}`,
274
- fixedSize: null,
275
- maxSize: null,
276
- serialize(value) {
277
- if (!value.match(new RegExp(`^[${alphabet}]*$`))) {
278
- throw new InvalidBaseStringError(value, base);
279
- }
280
- if (value === "")
281
- return new Uint8Array();
282
- const chars = [...value];
283
- let trailIndex = chars.findIndex((c) => c !== alphabet[0]);
284
- trailIndex = trailIndex === -1 ? chars.length : trailIndex;
285
- const leadingZeroes = Array(trailIndex).fill(0);
286
- if (trailIndex === chars.length)
287
- return Uint8Array.from(leadingZeroes);
288
- const tailChars = chars.slice(trailIndex);
289
- let base10Number = 0n;
290
- let baseXPower = 1n;
291
- for (let i = tailChars.length - 1; i >= 0; i -= 1) {
292
- base10Number += baseXPower * BigInt(alphabet.indexOf(tailChars[i]));
293
- baseXPower *= baseBigInt;
294
- }
295
- const tailBytes = [];
296
- while (base10Number > 0n) {
297
- tailBytes.unshift(Number(base10Number % 256n));
298
- base10Number /= 256n;
299
- }
300
- return Uint8Array.from(leadingZeroes.concat(tailBytes));
224
+ decode: (bytes, offset = 0) => {
225
+ const [value, length] = decoder.decode(bytes, offset);
226
+ return [map(value, bytes, offset), length];
301
227
  },
302
- deserialize(buffer, offset = 0) {
303
- if (buffer.length === 0)
304
- return ["", 0];
305
- const bytes2 = buffer.slice(offset);
306
- let trailIndex = bytes2.findIndex((n) => n !== 0);
307
- trailIndex = trailIndex === -1 ? bytes2.length : trailIndex;
308
- const leadingZeroes = alphabet[0].repeat(trailIndex);
309
- if (trailIndex === bytes2.length)
310
- return [leadingZeroes, buffer.length];
311
- let base10Number = bytes2.slice(trailIndex).reduce((sum, byte) => sum * 256n + BigInt(byte), 0n);
312
- const tailChars = [];
313
- while (base10Number > 0n) {
314
- tailChars.unshift(alphabet[Number(base10Number % baseBigInt)]);
315
- base10Number /= baseBigInt;
316
- }
317
- return [leadingZeroes + tailChars.join(""), buffer.length];
318
- }
228
+ description: decoder.description,
229
+ fixedSize: decoder.fixedSize,
230
+ maxSize: decoder.maxSize
319
231
  };
320
- };
321
-
322
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/base58.mjs
323
- init_env_shim();
324
- var base58 = baseX("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
325
-
326
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/nullCharacters.mjs
327
- init_env_shim();
328
- var removeNullCharacters = (value) => (
329
- // eslint-disable-next-line no-control-regex
330
- value.replace(/\u0000/g, "")
331
- );
332
-
333
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-encodings@0.8.2/node_modules/@metaplex-foundation/umi-serializers-encodings/dist/esm/utf8.mjs
334
- init_env_shim();
335
- var utf8 = {
336
- description: "utf8",
337
- fixedSize: null,
338
- maxSize: null,
339
- serialize(value) {
340
- return new TextEncoder().encode(value);
341
- },
342
- deserialize(buffer, offset = 0) {
343
- const value = new TextDecoder().decode(buffer.slice(offset));
344
- return [removeNullCharacters(value), buffer.length];
345
- }
346
- };
347
-
348
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/index.mjs
349
- init_env_shim();
232
+ }
350
233
 
351
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/common.mjs
234
+ // ../codecs-strings/dist/index.browser.js
352
235
  init_env_shim();
353
- var Endian;
354
- (function(Endian2) {
355
- Endian2["Little"] = "le";
356
- Endian2["Big"] = "be";
357
- })(Endian || (Endian = {}));
358
236
 
359
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/errors.mjs
237
+ // ../codecs-numbers/dist/index.browser.js
360
238
  init_env_shim();
361
- var NumberOutOfRangeError = class extends RangeError {
362
- constructor(serializer, min, max, actual) {
363
- super(`Serializer [${serializer}] expected number to be between ${min} and ${max}, got ${actual}.`);
364
- __publicField(this, "name", "NumberOutOfRangeError");
239
+ function assertNumberIsBetweenForCodec(codecDescription, min, max, value) {
240
+ if (value < min || value > max) {
241
+ throw new Error(
242
+ `Codec [${codecDescription}] expected number to be in the range [${min}, ${max}], got ${value}.`
243
+ );
365
244
  }
366
- };
367
-
368
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/utils.mjs
369
- init_env_shim();
370
- function numberFactory(input) {
245
+ }
246
+ function sharedNumberFactory(input) {
371
247
  let littleEndian;
372
248
  let defaultDescription = input.name;
373
249
  if (input.size > 1) {
374
- littleEndian = !("endian" in input.options) || input.options.endian === Endian.Little;
250
+ littleEndian = !("endian" in input.options) || input.options.endian === 0;
375
251
  defaultDescription += littleEndian ? "(le)" : "(be)";
376
252
  }
377
253
  return {
378
254
  description: input.options.description ?? defaultDescription,
379
255
  fixedSize: input.size,
380
- maxSize: input.size,
381
- serialize(value) {
256
+ littleEndian,
257
+ maxSize: input.size
258
+ };
259
+ }
260
+ function numberEncoderFactory(input) {
261
+ const codecData = sharedNumberFactory(input);
262
+ return {
263
+ description: codecData.description,
264
+ encode(value) {
382
265
  if (input.range) {
383
- assertRange(input.name, input.range[0], input.range[1], value);
266
+ assertNumberIsBetweenForCodec(input.name, input.range[0], input.range[1], value);
384
267
  }
385
- const buffer = new ArrayBuffer(input.size);
386
- input.set(new DataView(buffer), value, littleEndian);
387
- return new Uint8Array(buffer);
268
+ const arrayBuffer = new ArrayBuffer(input.size);
269
+ input.set(new DataView(arrayBuffer), value, codecData.littleEndian);
270
+ return new Uint8Array(arrayBuffer);
388
271
  },
389
- deserialize(bytes2, offset = 0) {
390
- const slice = bytes2.slice(offset, offset + input.size);
391
- assertEnoughBytes("i8", slice, input.size);
392
- const view = toDataView(slice);
393
- return [input.get(view, littleEndian), offset + input.size];
394
- }
272
+ fixedSize: codecData.fixedSize,
273
+ maxSize: codecData.maxSize
395
274
  };
396
275
  }
397
- var toArrayBuffer = (array2) => array2.buffer.slice(array2.byteOffset, array2.byteLength + array2.byteOffset);
398
- var toDataView = (array2) => new DataView(toArrayBuffer(array2));
399
- var assertRange = (serializer, min, max, value) => {
400
- if (value < min || value > max) {
401
- throw new NumberOutOfRangeError(serializer, min, max, value);
402
- }
403
- };
404
- var assertEnoughBytes = (serializer, bytes2, expected) => {
405
- if (bytes2.length === 0) {
406
- throw new DeserializingEmptyBufferError(serializer);
407
- }
408
- if (bytes2.length < expected) {
409
- throw new NotEnoughBytesError(serializer, expected, bytes2.length);
410
- }
411
- };
412
-
413
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u8.mjs
414
- init_env_shim();
415
- var u8 = (options = {}) => numberFactory({
416
- name: "u8",
417
- size: 1,
418
- range: [0, Number("0xff")],
419
- set: (view, value) => view.setUint8(0, Number(value)),
420
- get: (view) => view.getUint8(0),
421
- options
422
- });
423
-
424
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/u32.mjs
425
- init_env_shim();
426
- var u32 = (options = {}) => numberFactory({
427
- name: "u32",
428
- size: 4,
429
- range: [0, Number("0xffffffff")],
430
- set: (view, value, le) => view.setUint32(0, Number(value), le),
431
- get: (view, le) => view.getUint32(0, le),
432
- options
433
- });
434
-
435
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers-numbers@0.8.2/node_modules/@metaplex-foundation/umi-serializers-numbers/dist/esm/shortU16.mjs
436
- init_env_shim();
437
- var shortU16 = (options = {}) => ({
276
+ 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);
282
+ 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
+ };
289
+ }
290
+ function toArrayBuffer(bytes, offset, length) {
291
+ const bytesOffset = bytes.byteOffset + (offset ?? 0);
292
+ const bytesLength = length ?? bytes.byteLength;
293
+ return bytes.buffer.slice(bytesOffset, bytesOffset + bytesLength);
294
+ }
295
+ var getShortU16Encoder = (options = {}) => ({
438
296
  description: options.description ?? "shortU16",
439
- fixedSize: null,
440
- maxSize: 3,
441
- serialize: (value) => {
442
- assertRange("shortU16", 0, 65535, value);
443
- const bytes2 = [0];
297
+ encode: (value) => {
298
+ assertNumberIsBetweenForCodec("shortU16", 0, 65535, value);
299
+ const bytes = [0];
444
300
  for (let ii = 0; ; ii += 1) {
445
301
  const alignedValue = value >> ii * 7;
446
302
  if (alignedValue === 0) {
447
303
  break;
448
304
  }
449
305
  const nextSevenBits = 127 & alignedValue;
450
- bytes2[ii] = nextSevenBits;
306
+ bytes[ii] = nextSevenBits;
451
307
  if (ii > 0) {
452
- bytes2[ii - 1] |= 128;
308
+ bytes[ii - 1] |= 128;
453
309
  }
454
310
  }
455
- return new Uint8Array(bytes2);
311
+ return new Uint8Array(bytes);
456
312
  },
457
- deserialize: (bytes2, offset = 0) => {
313
+ fixedSize: null,
314
+ maxSize: 3
315
+ });
316
+ var getShortU16Decoder = (options = {}) => ({
317
+ decode: (bytes, offset = 0) => {
458
318
  let value = 0;
459
319
  let byteCount = 0;
460
320
  while (++byteCount) {
461
321
  const byteIndex = byteCount - 1;
462
- const currentByte = bytes2[offset + byteIndex];
322
+ const currentByte = bytes[offset + byteIndex];
463
323
  const nextSevenBits = 127 & currentByte;
464
324
  value |= nextSevenBits << byteIndex * 7;
465
325
  if ((currentByte & 128) === 0) {
@@ -467,261 +327,204 @@ this.globalThis.solanaWeb3 = (function (exports) {
467
327
  }
468
328
  }
469
329
  return [value, offset + byteCount];
470
- }
330
+ },
331
+ description: options.description ?? "shortU16",
332
+ fixedSize: null,
333
+ maxSize: 3
334
+ });
335
+ var getU32Encoder = (options = {}) => numberEncoderFactory({
336
+ name: "u32",
337
+ options,
338
+ range: [0, Number("0xffffffff")],
339
+ set: (view, value, le) => view.setUint32(0, value, le),
340
+ size: 4
341
+ });
342
+ var getU32Decoder = (options = {}) => numberDecoderFactory({
343
+ get: (view, le) => view.getUint32(0, le),
344
+ name: "u32",
345
+ options,
346
+ size: 4
347
+ });
348
+ var getU8Encoder = (options = {}) => numberEncoderFactory({
349
+ name: "u8",
350
+ options,
351
+ range: [0, Number("0xff")],
352
+ set: (view, value) => view.setUint8(0, value),
353
+ size: 1
354
+ });
355
+ var getU8Decoder = (options = {}) => numberDecoderFactory({
356
+ get: (view) => view.getUint8(0),
357
+ name: "u8",
358
+ options,
359
+ size: 1
471
360
  });
472
361
 
473
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
474
- init_env_shim();
475
-
476
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/errors.mjs
477
- init_env_shim();
478
- var InvalidNumberOfItemsError = class extends Error {
479
- constructor(serializer, expected, actual) {
480
- super(`Expected [${serializer}] to have ${expected} items, got ${actual}.`);
481
- __publicField(this, "name", "InvalidNumberOfItemsError");
362
+ // ../codecs-strings/dist/index.browser.js
363
+ function assertValidBaseString(alphabet4, testValue, givenValue = testValue) {
364
+ if (!testValue.match(new RegExp(`^[${alphabet4}]*$`))) {
365
+ throw new Error(`Expected a string of base ${alphabet4.length}, got [${givenValue}].`);
482
366
  }
367
+ }
368
+ var getBaseXEncoder = (alphabet4) => {
369
+ const base = alphabet4.length;
370
+ const baseBigInt = BigInt(base);
371
+ return {
372
+ description: `base${base}`,
373
+ encode(value) {
374
+ assertValidBaseString(alphabet4, value);
375
+ 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;
389
+ }
390
+ const tailBytes = [];
391
+ while (base10Number > 0n) {
392
+ tailBytes.unshift(Number(base10Number % 256n));
393
+ base10Number /= 256n;
394
+ }
395
+ return Uint8Array.from(leadingZeroes.concat(tailBytes));
396
+ },
397
+ fixedSize: null,
398
+ maxSize: null
399
+ };
483
400
  };
484
- var InvalidArrayLikeRemainderSizeError = class extends Error {
485
- constructor(remainderSize, itemSize) {
486
- super(`The remainder of the buffer (${remainderSize} bytes) cannot be split into chunks of ${itemSize} bytes. Serializers of "remainder" size must have a remainder that is a multiple of its item size. In other words, ${remainderSize} modulo ${itemSize} should be equal to zero.`);
487
- __publicField(this, "name", "InvalidArrayLikeRemainderSizeError");
488
- }
401
+ var getBaseXDecoder = (alphabet4) => {
402
+ const base = alphabet4.length;
403
+ const baseBigInt = BigInt(base);
404
+ return {
405
+ decode(rawBytes, offset = 0) {
406
+ const bytes = offset === 0 ? rawBytes : rawBytes.slice(offset);
407
+ if (bytes.length === 0)
408
+ return ["", 0];
409
+ let trailIndex = bytes.findIndex((n) => n !== 0);
410
+ trailIndex = trailIndex === -1 ? bytes.length : trailIndex;
411
+ const leadingZeroes = alphabet4[0].repeat(trailIndex);
412
+ if (trailIndex === bytes.length)
413
+ 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
+ };
489
426
  };
490
- var UnrecognizedArrayLikeSerializerSizeError = class extends Error {
491
- constructor(size) {
492
- super(`Unrecognized array-like serializer size: ${JSON.stringify(size)}`);
493
- __publicField(this, "name", "UnrecognizedArrayLikeSerializerSizeError");
427
+ var alphabet2 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
428
+ var getBase58Encoder = () => getBaseXEncoder(alphabet2);
429
+ var getBase58Decoder = () => getBaseXDecoder(alphabet2);
430
+ var getBase64Encoder = () => {
431
+ {
432
+ return {
433
+ description: `base64`,
434
+ encode(value) {
435
+ try {
436
+ const bytes = atob(value).split("").map((c) => c.charCodeAt(0));
437
+ return new Uint8Array(bytes);
438
+ } catch (e23) {
439
+ throw new Error(`Expected a string of base 64, got [${value}].`);
440
+ }
441
+ },
442
+ fixedSize: null,
443
+ maxSize: null
444
+ };
494
445
  }
495
446
  };
496
-
497
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
498
- init_env_shim();
499
-
500
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/sumSerializerSizes.mjs
501
- init_env_shim();
502
- function sumSerializerSizes(sizes) {
503
- return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
504
- }
505
-
506
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/utils.mjs
507
- function getResolvedSize(size, childrenSizes, bytes2, offset) {
447
+ var removeNullCharacters = (value) => (
448
+ // eslint-disable-next-line no-control-regex
449
+ value.replace(/\u0000/g, "")
450
+ );
451
+ var e = globalThis.TextDecoder;
452
+ var o = globalThis.TextEncoder;
453
+ var getUtf8Encoder = () => {
454
+ 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
+ };
461
+ };
462
+ var getUtf8Decoder = () => {
463
+ let textDecoder;
464
+ return {
465
+ decode(bytes, offset = 0) {
466
+ const value = (textDecoder || (textDecoder = new e())).decode(bytes.slice(offset));
467
+ return [removeNullCharacters(value), bytes.length];
468
+ },
469
+ description: "utf8",
470
+ fixedSize: null,
471
+ maxSize: null
472
+ };
473
+ };
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)})`;
478
+ if (size === "variable") {
479
+ return { ...encoding, description };
480
+ }
508
481
  if (typeof size === "number") {
509
- return [size, offset];
510
- }
511
- if (typeof size === "object") {
512
- return size.deserialize(bytes2, offset);
513
- }
514
- if (size === "remainder") {
515
- const childrenSize = sumSerializerSizes(childrenSizes);
516
- if (childrenSize === null) {
517
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
518
- }
519
- const remainder = bytes2.slice(offset).length;
520
- if (remainder % childrenSize !== 0) {
521
- throw new InvalidArrayLikeRemainderSizeError(remainder, childrenSize);
522
- }
523
- return [remainder / childrenSize, offset];
524
- }
525
- throw new UnrecognizedArrayLikeSerializerSizeError(size);
526
- }
527
- function getSizeDescription(size) {
528
- return typeof size === "object" ? size.description : `${size}`;
529
- }
530
- function getSizeFromChildren(size, childrenSizes) {
531
- if (typeof size !== "number")
532
- return null;
533
- if (size === 0)
534
- return 0;
535
- const childrenSize = sumSerializerSizes(childrenSizes);
536
- return childrenSize === null ? null : childrenSize * size;
537
- }
538
- function getSizePrefix(size, realSize) {
539
- return typeof size === "object" ? size.serialize(realSize) : new Uint8Array();
540
- }
541
-
542
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/array.mjs
543
- function array(item, options = {}) {
544
- const size = options.size ?? u32();
545
- if (size === "remainder" && item.fixedSize === null) {
546
- throw new ExpectedFixedSizeSerializerError('Serializers of "remainder" size must have fixed-size items.');
547
- }
548
- return {
549
- description: options.description ?? `array(${item.description}; ${getSizeDescription(size)})`,
550
- fixedSize: getSizeFromChildren(size, [item.fixedSize]),
551
- maxSize: getSizeFromChildren(size, [item.maxSize]),
552
- serialize: (value) => {
553
- if (typeof size === "number" && value.length !== size) {
554
- throw new InvalidNumberOfItemsError("array", size, value.length);
555
- }
556
- return mergeBytes([getSizePrefix(size, value.length), ...value.map((v) => item.serialize(v))]);
557
- },
558
- deserialize: (bytes2, offset = 0) => {
559
- if (typeof size === "object" && bytes2.slice(offset).length === 0) {
560
- return [[], offset];
561
- }
562
- const [resolvedSize, newOffset] = getResolvedSize(size, [item.fixedSize], bytes2, offset);
563
- offset = newOffset;
564
- const values = [];
565
- for (let i = 0; i < resolvedSize; i += 1) {
566
- const [value, newOffset2] = item.deserialize(bytes2, offset);
567
- values.push(value);
568
- offset = newOffset2;
569
- }
570
- return [values, offset];
571
- }
572
- };
573
- }
574
-
575
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/bytes.mjs
576
- init_env_shim();
577
- function bytes(options = {}) {
578
- const size = options.size ?? "variable";
579
- const description = options.description ?? `bytes(${getSizeDescription(size)})`;
580
- const byteSerializer = {
581
- description,
582
- fixedSize: null,
583
- maxSize: null,
584
- serialize: (value) => new Uint8Array(value),
585
- deserialize: (bytes2, offset = 0) => {
586
- const slice = bytes2.slice(offset);
587
- return [slice, offset + slice.length];
588
- }
589
- };
590
- if (size === "variable") {
591
- return byteSerializer;
592
- }
593
- if (typeof size === "number") {
594
- return fixSerializer(byteSerializer, size, description);
482
+ return fixEncoder(encoding, size, description);
595
483
  }
596
484
  return {
597
485
  description,
598
- fixedSize: null,
599
- maxSize: null,
600
- serialize: (value) => {
601
- const contentBytes = byteSerializer.serialize(value);
602
- const lengthBytes = size.serialize(contentBytes.length);
486
+ encode: (value) => {
487
+ const contentBytes = encoding.encode(value);
488
+ const lengthBytes = size.encode(contentBytes.length);
603
489
  return mergeBytes([lengthBytes, contentBytes]);
604
490
  },
605
- deserialize: (buffer, offset = 0) => {
606
- if (buffer.slice(offset).length === 0) {
607
- throw new DeserializingEmptyBufferError("bytes");
608
- }
609
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
610
- const length = Number(lengthBigInt);
611
- offset = lengthOffset;
612
- const contentBuffer = buffer.slice(offset, offset + length);
613
- if (contentBuffer.length < length) {
614
- throw new NotEnoughBytesError("bytes", length, contentBuffer.length);
615
- }
616
- const [value, contentOffset] = byteSerializer.deserialize(contentBuffer);
617
- offset += contentOffset;
618
- return [value, offset];
619
- }
491
+ fixedSize: null,
492
+ maxSize: null
620
493
  };
621
- }
622
-
623
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/string.mjs
624
- init_env_shim();
625
- function string(options = {}) {
626
- const size = options.size ?? u32();
627
- const encoding = options.encoding ?? utf8;
494
+ };
495
+ var getStringDecoder = (options = {}) => {
496
+ const size = options.size ?? getU32Decoder();
497
+ const encoding = options.encoding ?? getUtf8Decoder();
628
498
  const description = options.description ?? `string(${encoding.description}; ${getSizeDescription(size)})`;
629
499
  if (size === "variable") {
630
- return {
631
- ...encoding,
632
- description
633
- };
500
+ return { ...encoding, description };
634
501
  }
635
502
  if (typeof size === "number") {
636
- return fixSerializer(encoding, size, description);
503
+ return fixDecoder(encoding, size, description);
637
504
  }
638
505
  return {
639
- description,
640
- fixedSize: null,
641
- maxSize: null,
642
- serialize: (value) => {
643
- const contentBytes = encoding.serialize(value);
644
- const lengthBytes = size.serialize(contentBytes.length);
645
- return mergeBytes([lengthBytes, contentBytes]);
646
- },
647
- deserialize: (buffer, offset = 0) => {
648
- if (buffer.slice(offset).length === 0) {
649
- throw new DeserializingEmptyBufferError("string");
650
- }
651
- const [lengthBigInt, lengthOffset] = size.deserialize(buffer, offset);
506
+ decode: (bytes, offset = 0) => {
507
+ assertByteArrayIsNotEmptyForCodec("string", bytes, offset);
508
+ const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
652
509
  const length = Number(lengthBigInt);
653
510
  offset = lengthOffset;
654
- const contentBuffer = buffer.slice(offset, offset + length);
655
- if (contentBuffer.length < length) {
656
- throw new NotEnoughBytesError("string", length, contentBuffer.length);
657
- }
658
- const [value, contentOffset] = encoding.deserialize(contentBuffer);
511
+ const contentBytes = bytes.slice(offset, offset + length);
512
+ assertByteArrayHasEnoughBytesForCodec("string", length, contentBytes);
513
+ const [value, contentOffset] = encoding.decode(contentBytes);
659
514
  offset += contentOffset;
660
515
  return [value, offset];
661
- }
516
+ },
517
+ description,
518
+ fixedSize: null,
519
+ maxSize: null
662
520
  };
521
+ };
522
+ function getSizeDescription(size) {
523
+ return typeof size === "object" ? size.description : `${size}`;
663
524
  }
664
525
 
665
- // ../../node_modules/.pnpm/@metaplex-foundation+umi-serializers@0.8.5/node_modules/@metaplex-foundation/umi-serializers/dist/esm/struct.mjs
526
+ // ../assertions/dist/index.browser.js
666
527
  init_env_shim();
667
- function struct(fields, options = {}) {
668
- const fieldDescriptions = fields.map(([name, serializer]) => `${String(name)}: ${serializer.description}`).join(", ");
669
- return {
670
- description: options.description ?? `struct(${fieldDescriptions})`,
671
- fixedSize: sumSerializerSizes(fields.map(([, field]) => field.fixedSize)),
672
- maxSize: sumSerializerSizes(fields.map(([, field]) => field.maxSize)),
673
- serialize: (struct2) => {
674
- const fieldBytes = fields.map(([key, serializer]) => serializer.serialize(struct2[key]));
675
- return mergeBytes(fieldBytes);
676
- },
677
- deserialize: (bytes2, offset = 0) => {
678
- const struct2 = {};
679
- fields.forEach(([key, serializer]) => {
680
- const [value, newOffset] = serializer.deserialize(bytes2, offset);
681
- offset = newOffset;
682
- struct2[key] = value;
683
- });
684
- return [struct2, offset];
685
- }
686
- };
687
- }
688
- function assertIsBase58EncodedAddress(putativeBase58EncodedAddress) {
689
- try {
690
- if (
691
- // Lowest address (32 bytes of zeroes)
692
- putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
693
- putativeBase58EncodedAddress.length > 44
694
- ) {
695
- throw new Error("Expected input string to decode to a byte array of length 32.");
696
- }
697
- const bytes2 = base58.serialize(putativeBase58EncodedAddress);
698
- const numBytes = bytes2.byteLength;
699
- if (numBytes !== 32) {
700
- throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
701
- }
702
- } catch (e2) {
703
- throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
704
- cause: e2
705
- });
706
- }
707
- }
708
- function getBase58EncodedAddressCodec(config) {
709
- return string({
710
- description: config?.description ?? ("A 32-byte account address" ),
711
- encoding: base58,
712
- size: 32
713
- });
714
- }
715
- function getBase58EncodedAddressComparator() {
716
- return new Intl.Collator("en", {
717
- caseFirst: "lower",
718
- ignorePunctuation: false,
719
- localeMatcher: "best fit",
720
- numeric: false,
721
- sensitivity: "variant",
722
- usage: "sort"
723
- }).compare;
724
- }
725
528
  function assertIsSecureContext() {
726
529
  if (!globalThis.isSecureContext) {
727
530
  throw new Error(
@@ -751,6 +554,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
751
554
  return await cachedEd25519Decision;
752
555
  }
753
556
  }
557
+ async function assertDigestCapabilityIsAvailable() {
558
+ assertIsSecureContext();
559
+ if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.digest !== "function") {
560
+ throw new Error("No digest implementation could be found");
561
+ }
562
+ }
754
563
  async function assertKeyGenerationIsAvailable() {
755
564
  assertIsSecureContext();
756
565
  if (typeof globalThis.crypto === "undefined" || typeof globalThis.crypto.subtle?.generateKey !== "function") {
@@ -780,6 +589,341 @@ this.globalThis.solanaWeb3 = (function (exports) {
780
589
  throw new Error("No signature verification implementation could be found");
781
590
  }
782
591
  }
592
+
593
+ // ../addresses/dist/index.browser.js
594
+ var memoizedBase58Encoder;
595
+ var memoizedBase58Decoder;
596
+ function getMemoizedBase58Encoder() {
597
+ if (!memoizedBase58Encoder)
598
+ memoizedBase58Encoder = getBase58Encoder();
599
+ return memoizedBase58Encoder;
600
+ }
601
+ function getMemoizedBase58Decoder() {
602
+ if (!memoizedBase58Decoder)
603
+ memoizedBase58Decoder = getBase58Decoder();
604
+ return memoizedBase58Decoder;
605
+ }
606
+ function isAddress(putativeBase58EncodedAddress) {
607
+ if (
608
+ // Lowest address (32 bytes of zeroes)
609
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
610
+ putativeBase58EncodedAddress.length > 44
611
+ ) {
612
+ return false;
613
+ }
614
+ const base58Encoder3 = getMemoizedBase58Encoder();
615
+ const bytes = base58Encoder3.encode(putativeBase58EncodedAddress);
616
+ const numBytes = bytes.byteLength;
617
+ if (numBytes !== 32) {
618
+ return false;
619
+ }
620
+ return true;
621
+ }
622
+ function assertIsAddress(putativeBase58EncodedAddress) {
623
+ try {
624
+ if (
625
+ // Lowest address (32 bytes of zeroes)
626
+ putativeBase58EncodedAddress.length < 32 || // Highest address (32 bytes of 255)
627
+ putativeBase58EncodedAddress.length > 44
628
+ ) {
629
+ throw new Error("Expected input string to decode to a byte array of length 32.");
630
+ }
631
+ const base58Encoder3 = getMemoizedBase58Encoder();
632
+ const bytes = base58Encoder3.encode(putativeBase58EncodedAddress);
633
+ const numBytes = bytes.byteLength;
634
+ if (numBytes !== 32) {
635
+ throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
636
+ }
637
+ } catch (e3) {
638
+ throw new Error(`\`${putativeBase58EncodedAddress}\` is not a base-58 encoded address`, {
639
+ cause: e3
640
+ });
641
+ }
642
+ }
643
+ function address(putativeBase58EncodedAddress) {
644
+ assertIsAddress(putativeBase58EncodedAddress);
645
+ return putativeBase58EncodedAddress;
646
+ }
647
+ function getAddressEncoder(config) {
648
+ return mapEncoder(
649
+ getStringEncoder({
650
+ description: config?.description ?? "Base58EncodedAddress",
651
+ encoding: getMemoizedBase58Encoder(),
652
+ size: 32
653
+ }),
654
+ (putativeAddress) => address(putativeAddress)
655
+ );
656
+ }
657
+ function getAddressDecoder(config) {
658
+ return getStringDecoder({
659
+ description: config?.description ?? "Base58EncodedAddress",
660
+ encoding: getMemoizedBase58Decoder(),
661
+ size: 32
662
+ });
663
+ }
664
+ function getAddressCodec(config) {
665
+ return combineCodec(getAddressEncoder(config), getAddressDecoder(config));
666
+ }
667
+ function getAddressComparator() {
668
+ return new Intl.Collator("en", {
669
+ caseFirst: "lower",
670
+ ignorePunctuation: false,
671
+ localeMatcher: "best fit",
672
+ numeric: false,
673
+ sensitivity: "variant",
674
+ usage: "sort"
675
+ }).compare;
676
+ }
677
+ var D = 37095705934669439343138083508754565189542113879843219016388785533085940283555n;
678
+ var P = 57896044618658097711785492504343953926634992332820282019728792003956564819949n;
679
+ var RM1 = 19681161376707505956807079304988542015446066515923890162744021073123829784752n;
680
+ function mod(a) {
681
+ const r = a % P;
682
+ return r >= 0n ? r : P + r;
683
+ }
684
+ function pow2(x, power) {
685
+ let r = x;
686
+ while (power-- > 0n) {
687
+ r *= r;
688
+ r %= P;
689
+ }
690
+ return r;
691
+ }
692
+ function pow_2_252_3(x) {
693
+ const x2 = x * x % P;
694
+ const b2 = x2 * x % P;
695
+ const b4 = pow2(b2, 2n) * b2 % P;
696
+ const b5 = pow2(b4, 1n) * x % P;
697
+ const b10 = pow2(b5, 5n) * b5 % P;
698
+ const b20 = pow2(b10, 10n) * b10 % P;
699
+ const b40 = pow2(b20, 20n) * b20 % P;
700
+ const b80 = pow2(b40, 40n) * b40 % P;
701
+ const b160 = pow2(b80, 80n) * b80 % P;
702
+ const b240 = pow2(b160, 80n) * b80 % P;
703
+ const b250 = pow2(b240, 10n) * b10 % P;
704
+ const pow_p_5_8 = pow2(b250, 2n) * x % P;
705
+ return pow_p_5_8;
706
+ }
707
+ function uvRatio(u, v) {
708
+ const v3 = mod(v * v * v);
709
+ const v7 = mod(v3 * v3 * v);
710
+ const pow = pow_2_252_3(u * v7);
711
+ let x = mod(u * v3 * pow);
712
+ const vx2 = mod(v * x * x);
713
+ const root1 = x;
714
+ const root2 = mod(x * RM1);
715
+ const useRoot1 = vx2 === u;
716
+ const useRoot2 = vx2 === mod(-u);
717
+ const noRoot = vx2 === mod(-u * RM1);
718
+ if (useRoot1)
719
+ x = root1;
720
+ if (useRoot2 || noRoot)
721
+ x = root2;
722
+ if ((mod(x) & 1n) === 1n)
723
+ x = mod(-x);
724
+ if (!useRoot1 && !useRoot2) {
725
+ return null;
726
+ }
727
+ return x;
728
+ }
729
+ function pointIsOnCurve(y, lastByte) {
730
+ const y2 = mod(y * y);
731
+ const u = mod(y2 - 1n);
732
+ const v = mod(D * y2 + 1n);
733
+ const x = uvRatio(u, v);
734
+ if (x === null) {
735
+ return false;
736
+ }
737
+ const isLastByteOdd = (lastByte & 128) !== 0;
738
+ if (x === 0n && isLastByteOdd) {
739
+ return false;
740
+ }
741
+ return true;
742
+ }
743
+ function byteToHex(byte) {
744
+ const hexString = byte.toString(16);
745
+ if (hexString.length === 1) {
746
+ return `0${hexString}`;
747
+ } else {
748
+ return hexString;
749
+ }
750
+ }
751
+ function decompressPointBytes(bytes) {
752
+ const hexString = bytes.reduce((acc, byte, ii) => `${byteToHex(ii === 31 ? byte & ~128 : byte)}${acc}`, "");
753
+ const integerLiteralString = `0x${hexString}`;
754
+ return BigInt(integerLiteralString);
755
+ }
756
+ async function compressedPointBytesAreOnCurve(bytes) {
757
+ if (bytes.byteLength !== 32) {
758
+ return false;
759
+ }
760
+ const y = decompressPointBytes(bytes);
761
+ return pointIsOnCurve(y, bytes[31]);
762
+ }
763
+ function isProgramDerivedAddress(value) {
764
+ return Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number" && value[1] >= 0 && value[1] <= 255 && isAddress(value[0]);
765
+ }
766
+ function assertIsProgramDerivedAddress(value) {
767
+ const validFormat = Array.isArray(value) && value.length === 2 && typeof value[0] === "string" && typeof value[1] === "number";
768
+ if (!validFormat) {
769
+ throw new Error(
770
+ `Expected given program derived address to have the following format: [Base58EncodedAddress, ProgramDerivedAddressBump].`
771
+ );
772
+ }
773
+ if (value[1] < 0 || value[1] > 255) {
774
+ throw new Error(`Expected program derived address bump to be in the range [0, 255], got: ${value[1]}.`);
775
+ }
776
+ assertIsAddress(value[0]);
777
+ }
778
+ var MAX_SEED_LENGTH = 32;
779
+ var MAX_SEEDS = 16;
780
+ var PDA_MARKER_BYTES = [
781
+ // The string 'ProgramDerivedAddress'
782
+ 80,
783
+ 114,
784
+ 111,
785
+ 103,
786
+ 114,
787
+ 97,
788
+ 109,
789
+ 68,
790
+ 101,
791
+ 114,
792
+ 105,
793
+ 118,
794
+ 101,
795
+ 100,
796
+ 65,
797
+ 100,
798
+ 100,
799
+ 114,
800
+ 101,
801
+ 115,
802
+ 115
803
+ ];
804
+ var PointOnCurveError = class extends Error {
805
+ };
806
+ async function createProgramDerivedAddress({
807
+ programAddress,
808
+ seeds
809
+ }) {
810
+ await assertDigestCapabilityIsAvailable();
811
+ if (seeds.length > MAX_SEEDS) {
812
+ throw new Error(`A maximum of ${MAX_SEEDS} seeds may be supplied when creating an address`);
813
+ }
814
+ let textEncoder;
815
+ const seedBytes = seeds.reduce((acc, seed, ii) => {
816
+ const bytes = typeof seed === "string" ? (textEncoder || (textEncoder = new TextEncoder())).encode(seed) : seed;
817
+ if (bytes.byteLength > MAX_SEED_LENGTH) {
818
+ throw new Error(`The seed at index ${ii} exceeds the maximum length of 32 bytes`);
819
+ }
820
+ acc.push(...bytes);
821
+ return acc;
822
+ }, []);
823
+ const base58EncodedAddressCodec = getAddressCodec();
824
+ const programAddressBytes = base58EncodedAddressCodec.encode(programAddress);
825
+ const addressBytesBuffer = await crypto.subtle.digest(
826
+ "SHA-256",
827
+ new Uint8Array([...seedBytes, ...programAddressBytes, ...PDA_MARKER_BYTES])
828
+ );
829
+ const addressBytes = new Uint8Array(addressBytesBuffer);
830
+ if (await compressedPointBytesAreOnCurve(addressBytes)) {
831
+ throw new PointOnCurveError("Invalid seeds; point must fall off the Ed25519 curve");
832
+ }
833
+ return base58EncodedAddressCodec.decode(addressBytes)[0];
834
+ }
835
+ async function getProgramDerivedAddress({
836
+ programAddress,
837
+ seeds
838
+ }) {
839
+ let bumpSeed = 255;
840
+ while (bumpSeed > 0) {
841
+ try {
842
+ const address2 = await createProgramDerivedAddress({
843
+ programAddress,
844
+ seeds: [...seeds, new Uint8Array([bumpSeed])]
845
+ });
846
+ return [address2, bumpSeed];
847
+ } catch (e3) {
848
+ if (e3 instanceof PointOnCurveError) {
849
+ bumpSeed--;
850
+ } else {
851
+ throw e3;
852
+ }
853
+ }
854
+ }
855
+ throw new Error("Unable to find a viable program address bump seed");
856
+ }
857
+ async function createAddressWithSeed({
858
+ baseAddress,
859
+ programAddress,
860
+ seed
861
+ }) {
862
+ const { encode: encode2, decode: decode2 } = getAddressCodec();
863
+ const seedBytes = typeof seed === "string" ? new TextEncoder().encode(seed) : seed;
864
+ if (seedBytes.byteLength > MAX_SEED_LENGTH) {
865
+ throw new Error(`The seed exceeds the maximum length of 32 bytes`);
866
+ }
867
+ const programAddressBytes = encode2(programAddress);
868
+ if (programAddressBytes.length >= PDA_MARKER_BYTES.length && programAddressBytes.slice(-PDA_MARKER_BYTES.length).every((byte, index) => byte === PDA_MARKER_BYTES[index])) {
869
+ throw new Error(`programAddress cannot end with the PDA marker`);
870
+ }
871
+ const addressBytesBuffer = await crypto.subtle.digest(
872
+ "SHA-256",
873
+ new Uint8Array([...encode2(baseAddress), ...seedBytes, ...programAddressBytes])
874
+ );
875
+ const addressBytes = new Uint8Array(addressBytesBuffer);
876
+ return decode2(addressBytes)[0];
877
+ }
878
+ async function getAddressFromPublicKey(publicKey) {
879
+ await assertKeyExporterIsAvailable();
880
+ if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
881
+ throw new Error("The `CryptoKey` must be an `Ed25519` public key");
882
+ }
883
+ const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
884
+ const [base58EncodedAddress] = getAddressDecoder().decode(new Uint8Array(publicKeyBytes));
885
+ return base58EncodedAddress;
886
+ }
887
+
888
+ // ../instructions/dist/index.browser.js
889
+ init_env_shim();
890
+ var AccountRole = /* @__PURE__ */ ((AccountRole22) => {
891
+ AccountRole22[AccountRole22["WRITABLE_SIGNER"] = /* 3 */
892
+ 3] = "WRITABLE_SIGNER";
893
+ AccountRole22[AccountRole22["READONLY_SIGNER"] = /* 2 */
894
+ 2] = "READONLY_SIGNER";
895
+ AccountRole22[AccountRole22["WRITABLE"] = /* 1 */
896
+ 1] = "WRITABLE";
897
+ AccountRole22[AccountRole22["READONLY"] = /* 0 */
898
+ 0] = "READONLY";
899
+ return AccountRole22;
900
+ })(AccountRole || {});
901
+ var IS_SIGNER_BITMASK = 2;
902
+ var IS_WRITABLE_BITMASK = 1;
903
+ function downgradeRoleToNonSigner(role) {
904
+ return role & ~IS_SIGNER_BITMASK;
905
+ }
906
+ function downgradeRoleToReadonly(role) {
907
+ return role & ~IS_WRITABLE_BITMASK;
908
+ }
909
+ function isSignerRole(role) {
910
+ return role >= 2;
911
+ }
912
+ function isWritableRole(role) {
913
+ return (role & IS_WRITABLE_BITMASK) !== 0;
914
+ }
915
+ function mergeRoles(roleA, roleB) {
916
+ return roleA | roleB;
917
+ }
918
+ function upgradeRoleToSigner(role) {
919
+ return role | IS_SIGNER_BITMASK;
920
+ }
921
+ function upgradeRoleToWritable(role) {
922
+ return role | IS_WRITABLE_BITMASK;
923
+ }
924
+
925
+ // ../keys/dist/index.browser.js
926
+ init_env_shim();
783
927
  async function generateKeyPair() {
784
928
  await assertKeyGenerationIsAvailable();
785
929
  const keyPair = await crypto.subtle.generateKey(
@@ -794,15 +938,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
794
938
  );
795
939
  return keyPair;
796
940
  }
797
- async function getBase58EncodedAddressFromPublicKey(publicKey) {
798
- await assertKeyExporterIsAvailable();
799
- if (publicKey.type !== "public" || publicKey.algorithm.name !== "Ed25519") {
800
- throw new Error("The `CryptoKey` must be an `Ed25519` public key");
801
- }
802
- const publicKeyBytes = await crypto.subtle.exportKey("raw", publicKey);
803
- const [base58EncodedAddress] = getBase58EncodedAddressCodec().deserialize(new Uint8Array(publicKeyBytes));
804
- return base58EncodedAddress;
805
- }
806
941
  async function signBytes(key, data) {
807
942
  await assertSigningCapabilityIsAvailable();
808
943
  const signedData = await crypto.subtle.sign("Ed25519", key, data);
@@ -813,8 +948,286 @@ this.globalThis.solanaWeb3 = (function (exports) {
813
948
  return await crypto.subtle.verify("Ed25519", key, signature, data);
814
949
  }
815
950
 
951
+ // ../rpc-types/dist/index.browser.js
952
+ init_env_shim();
953
+ function getCommitmentScore(commitment) {
954
+ switch (commitment) {
955
+ case "finalized":
956
+ return 2;
957
+ case "confirmed":
958
+ return 1;
959
+ case "processed":
960
+ return 0;
961
+ default:
962
+ return ((_) => {
963
+ throw new Error(`Unrecognized commitment \`${commitment}\`.`);
964
+ })();
965
+ }
966
+ }
967
+ function commitmentComparator(a, b) {
968
+ if (a === b) {
969
+ return 0;
970
+ }
971
+ return getCommitmentScore(a) < getCommitmentScore(b) ? -1 : 1;
972
+ }
973
+ var maxU64Value = 18446744073709551615n;
974
+ function isLamports(putativeLamports) {
975
+ return putativeLamports >= 0 && putativeLamports <= maxU64Value;
976
+ }
977
+ function assertIsLamports(putativeLamports) {
978
+ if (putativeLamports < 0) {
979
+ throw new Error("Input for 64-bit unsigned integer cannot be negative");
980
+ }
981
+ if (putativeLamports > maxU64Value) {
982
+ throw new Error("Input number is too large to be represented as a 64-bit unsigned integer");
983
+ }
984
+ }
985
+ function lamports(putativeLamports) {
986
+ assertIsLamports(putativeLamports);
987
+ return putativeLamports;
988
+ }
989
+ function isStringifiedBigInt(putativeBigInt) {
990
+ try {
991
+ BigInt(putativeBigInt);
992
+ return true;
993
+ } catch (_) {
994
+ return false;
995
+ }
996
+ }
997
+ function assertIsStringifiedBigInt(putativeBigInt) {
998
+ try {
999
+ BigInt(putativeBigInt);
1000
+ } catch (e3) {
1001
+ throw new Error(`\`${putativeBigInt}\` cannot be parsed as a BigInt`, {
1002
+ cause: e3
1003
+ });
1004
+ }
1005
+ }
1006
+ function stringifiedBigInt(putativeBigInt) {
1007
+ assertIsStringifiedBigInt(putativeBigInt);
1008
+ return putativeBigInt;
1009
+ }
1010
+ function isStringifiedNumber(putativeNumber) {
1011
+ return !Number.isNaN(Number(putativeNumber));
1012
+ }
1013
+ function assertIsStringifiedNumber(putativeNumber) {
1014
+ if (Number.isNaN(Number(putativeNumber))) {
1015
+ throw new Error(`\`${putativeNumber}\` cannot be parsed as a Number`);
1016
+ }
1017
+ }
1018
+ function stringifiedNumber(putativeNumber) {
1019
+ assertIsStringifiedNumber(putativeNumber);
1020
+ return putativeNumber;
1021
+ }
1022
+ function isUnixTimestamp(putativeTimestamp) {
1023
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
1024
+ return false;
1025
+ }
1026
+ return true;
1027
+ }
1028
+ function assertIsUnixTimestamp(putativeTimestamp) {
1029
+ try {
1030
+ if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
1031
+ throw new Error("Expected input number to be in the range [-8.64e15, 8.64e15]");
1032
+ }
1033
+ } catch (e3) {
1034
+ throw new Error(`\`${putativeTimestamp}\` is not a timestamp`, {
1035
+ cause: e3
1036
+ });
1037
+ }
1038
+ }
1039
+ function unixTimestamp(putativeTimestamp) {
1040
+ assertIsUnixTimestamp(putativeTimestamp);
1041
+ return putativeTimestamp;
1042
+ }
1043
+
816
1044
  // ../transactions/dist/index.browser.js
817
1045
  init_env_shim();
1046
+
1047
+ // ../codecs-data-structures/dist/index.browser.js
1048
+ init_env_shim();
1049
+ function sumCodecSizes(sizes) {
1050
+ return sizes.reduce((all, size) => all === null || size === null ? null : all + size, 0);
1051
+ }
1052
+ function decodeArrayLikeCodecSize(size, childrenSizes, bytes, offset) {
1053
+ if (typeof size === "number") {
1054
+ return [size, offset];
1055
+ }
1056
+ if (typeof size === "object") {
1057
+ return size.decode(bytes, offset);
1058
+ }
1059
+ if (size === "remainder") {
1060
+ const childrenSize = sumCodecSizes(childrenSizes);
1061
+ if (childrenSize === null) {
1062
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1063
+ }
1064
+ const remainder = bytes.slice(offset).length;
1065
+ if (remainder % childrenSize !== 0) {
1066
+ throw new Error(
1067
+ `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.`
1068
+ );
1069
+ }
1070
+ return [remainder / childrenSize, offset];
1071
+ }
1072
+ throw new Error(`Unrecognized array-like codec size: ${JSON.stringify(size)}`);
1073
+ }
1074
+ function getArrayLikeCodecSizeDescription(size) {
1075
+ return typeof size === "object" ? size.description : `${size}`;
1076
+ }
1077
+ function getArrayLikeCodecSizeFromChildren(size, childrenSizes) {
1078
+ if (typeof size !== "number")
1079
+ return null;
1080
+ if (size === 0)
1081
+ return 0;
1082
+ const childrenSize = sumCodecSizes(childrenSizes);
1083
+ return childrenSize === null ? null : childrenSize * size;
1084
+ }
1085
+ function getArrayLikeCodecSizePrefix(size, realSize) {
1086
+ return typeof size === "object" ? size.encode(realSize) : new Uint8Array();
1087
+ }
1088
+ function assertValidNumberOfItemsForCodec(codecDescription, expected, actual) {
1089
+ if (expected !== actual) {
1090
+ throw new Error(`Expected [${codecDescription}] to have ${expected} items, got ${actual}.`);
1091
+ }
1092
+ }
1093
+ function arrayCodecHelper(item, size, description) {
1094
+ if (size === "remainder" && item.fixedSize === null) {
1095
+ throw new Error('Codecs of "remainder" size must have fixed-size items.');
1096
+ }
1097
+ return {
1098
+ description: description ?? `array(${item.description}; ${getArrayLikeCodecSizeDescription(size)})`,
1099
+ fixedSize: getArrayLikeCodecSizeFromChildren(size, [item.fixedSize]),
1100
+ maxSize: getArrayLikeCodecSizeFromChildren(size, [item.maxSize])
1101
+ };
1102
+ }
1103
+ function getArrayEncoder(item, options = {}) {
1104
+ const size = options.size ?? getU32Encoder();
1105
+ return {
1106
+ ...arrayCodecHelper(item, size, options.description),
1107
+ encode: (value) => {
1108
+ if (typeof size === "number") {
1109
+ assertValidNumberOfItemsForCodec("array", size, value.length);
1110
+ }
1111
+ return mergeBytes([getArrayLikeCodecSizePrefix(size, value.length), ...value.map((v) => item.encode(v))]);
1112
+ }
1113
+ };
1114
+ }
1115
+ function getArrayDecoder(item, options = {}) {
1116
+ const size = options.size ?? getU32Decoder();
1117
+ return {
1118
+ ...arrayCodecHelper(item, size, options.description),
1119
+ decode: (bytes, offset = 0) => {
1120
+ if (typeof size === "object" && bytes.slice(offset).length === 0) {
1121
+ return [[], offset];
1122
+ }
1123
+ const [resolvedSize, newOffset] = decodeArrayLikeCodecSize(size, [item.fixedSize], bytes, offset);
1124
+ offset = newOffset;
1125
+ const values = [];
1126
+ for (let i = 0; i < resolvedSize; i += 1) {
1127
+ const [value, newOffset2] = item.decode(bytes, offset);
1128
+ values.push(value);
1129
+ offset = newOffset2;
1130
+ }
1131
+ return [values, offset];
1132
+ }
1133
+ };
1134
+ }
1135
+ function getBytesEncoder(options = {}) {
1136
+ const size = options.size ?? "variable";
1137
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1138
+ const description = options.description ?? `bytes(${sizeDescription})`;
1139
+ const byteEncoder = {
1140
+ description,
1141
+ encode: (value) => value,
1142
+ fixedSize: null,
1143
+ maxSize: null
1144
+ };
1145
+ if (size === "variable") {
1146
+ return byteEncoder;
1147
+ }
1148
+ if (typeof size === "number") {
1149
+ return fixEncoder(byteEncoder, size, description);
1150
+ }
1151
+ return {
1152
+ ...byteEncoder,
1153
+ encode: (value) => {
1154
+ const contentBytes = byteEncoder.encode(value);
1155
+ const lengthBytes = size.encode(contentBytes.length);
1156
+ return mergeBytes([lengthBytes, contentBytes]);
1157
+ }
1158
+ };
1159
+ }
1160
+ function getBytesDecoder(options = {}) {
1161
+ const size = options.size ?? "variable";
1162
+ const sizeDescription = typeof size === "object" ? size.description : `${size}`;
1163
+ const description = options.description ?? `bytes(${sizeDescription})`;
1164
+ const byteDecoder = {
1165
+ decode: (bytes, offset = 0) => {
1166
+ const slice = bytes.slice(offset);
1167
+ return [slice, offset + slice.length];
1168
+ },
1169
+ description,
1170
+ fixedSize: null,
1171
+ maxSize: null
1172
+ };
1173
+ if (size === "variable") {
1174
+ return byteDecoder;
1175
+ }
1176
+ if (typeof size === "number") {
1177
+ return fixDecoder(byteDecoder, size, description);
1178
+ }
1179
+ return {
1180
+ ...byteDecoder,
1181
+ decode: (bytes, offset = 0) => {
1182
+ assertByteArrayIsNotEmptyForCodec("bytes", bytes, offset);
1183
+ const [lengthBigInt, lengthOffset] = size.decode(bytes, offset);
1184
+ const length = Number(lengthBigInt);
1185
+ offset = lengthOffset;
1186
+ const contentBytes = bytes.slice(offset, offset + length);
1187
+ assertByteArrayHasEnoughBytesForCodec("bytes", length, contentBytes);
1188
+ const [value, contentOffset] = byteDecoder.decode(contentBytes);
1189
+ offset += contentOffset;
1190
+ return [value, offset];
1191
+ }
1192
+ };
1193
+ }
1194
+ function structCodecHelper(fields, description) {
1195
+ const fieldDescriptions = fields.map(([name, codec]) => `${String(name)}: ${codec.description}`).join(", ");
1196
+ return {
1197
+ description: description ?? `struct(${fieldDescriptions})`,
1198
+ fixedSize: sumCodecSizes(fields.map(([, field]) => field.fixedSize)),
1199
+ maxSize: sumCodecSizes(fields.map(([, field]) => field.maxSize))
1200
+ };
1201
+ }
1202
+ function getStructEncoder(fields, options = {}) {
1203
+ return {
1204
+ ...structCodecHelper(fields, options.description),
1205
+ encode: (struct) => {
1206
+ const fieldBytes = fields.map(([key, codec]) => codec.encode(struct[key]));
1207
+ return mergeBytes(fieldBytes);
1208
+ }
1209
+ };
1210
+ }
1211
+ function getStructDecoder(fields, options = {}) {
1212
+ return {
1213
+ ...structCodecHelper(fields, options.description),
1214
+ decode: (bytes, offset = 0) => {
1215
+ const struct = {};
1216
+ fields.forEach(([key, codec]) => {
1217
+ const [value, newOffset] = codec.decode(bytes, offset);
1218
+ offset = newOffset;
1219
+ struct[key] = value;
1220
+ });
1221
+ return [struct, offset];
1222
+ }
1223
+ };
1224
+ }
1225
+
1226
+ // ../functional/dist/index.browser.js
1227
+ init_env_shim();
1228
+ function pipe(init, ...fns) {
1229
+ return fns.reduce((acc, fn) => fn(acc), init);
1230
+ }
818
1231
  function getUnsignedTransaction(transaction) {
819
1232
  if ("signatures" in transaction) {
820
1233
  const {
@@ -827,7 +1240,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
827
1240
  return transaction;
828
1241
  }
829
1242
  }
1243
+ var base58Encoder;
830
1244
  function assertIsBlockhash(putativeBlockhash) {
1245
+ if (!base58Encoder)
1246
+ base58Encoder = getBase58Encoder();
831
1247
  try {
832
1248
  if (
833
1249
  // Lowest value (32 bytes of zeroes)
@@ -836,14 +1252,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
836
1252
  ) {
837
1253
  throw new Error("Expected input string to decode to a byte array of length 32.");
838
1254
  }
839
- const bytes3 = base58.serialize(putativeBlockhash);
840
- const numBytes = bytes3.byteLength;
1255
+ const bytes = base58Encoder.encode(putativeBlockhash);
1256
+ const numBytes = bytes.byteLength;
841
1257
  if (numBytes !== 32) {
842
1258
  throw new Error(`Expected input string to decode to a byte array of length 32. Actual length: ${numBytes}`);
843
1259
  }
844
- } catch (e2) {
1260
+ } catch (e3) {
845
1261
  throw new Error(`\`${putativeBlockhash}\` is not a blockhash`, {
846
- cause: e2
1262
+ cause: e3
847
1263
  });
848
1264
  }
849
1265
  }
@@ -916,7 +1332,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
916
1332
  instruction.accounts?.length === 3 && // First account is nonce account address
917
1333
  instruction.accounts[0].address != null && instruction.accounts[0].role === AccountRole2.WRITABLE && // Second account is recent blockhashes sysvar
918
1334
  instruction.accounts[1].address === RECENT_BLOCKHASHES_SYSVAR_ADDRESS && instruction.accounts[1].role === AccountRole2.READONLY && // Third account is nonce authority account
919
- instruction.accounts[2].address != null && instruction.accounts[2].role === AccountRole2.READONLY_SIGNER;
1335
+ instruction.accounts[2].address != null && isSignerRole2(instruction.accounts[2].role);
920
1336
  }
921
1337
  function isAdvanceNonceAccountInstructionData(data) {
922
1338
  return data.byteLength === 4 && data[0] === 4 && data[1] === 0 && data[2] === 0 && data[3] === 0;
@@ -924,21 +1340,38 @@ this.globalThis.solanaWeb3 = (function (exports) {
924
1340
  function isDurableNonceTransaction(transaction) {
925
1341
  return "lifetimeConstraint" in transaction && typeof transaction.lifetimeConstraint.nonce === "string" && transaction.instructions[0] != null && isAdvanceNonceAccountInstruction(transaction.instructions[0]);
926
1342
  }
1343
+ function isAdvanceNonceAccountInstructionForNonce(instruction, nonceAccountAddress, nonceAuthorityAddress) {
1344
+ return instruction.accounts[0].address === nonceAccountAddress && instruction.accounts[2].address === nonceAuthorityAddress;
1345
+ }
927
1346
  function setTransactionLifetimeUsingDurableNonce({
928
1347
  nonce,
929
1348
  nonceAccountAddress,
930
1349
  nonceAuthorityAddress
931
1350
  }, transaction) {
932
- const isAlreadyDurableNonceTransaction = isDurableNonceTransaction(transaction);
933
- if (isAlreadyDurableNonceTransaction && transaction.lifetimeConstraint.nonce === nonce && transaction.instructions[0].accounts[0].address === nonceAccountAddress && transaction.instructions[0].accounts[2].address === nonceAuthorityAddress) {
934
- return transaction;
1351
+ let newInstructions;
1352
+ const firstInstruction = transaction.instructions[0];
1353
+ if (firstInstruction && isAdvanceNonceAccountInstruction(firstInstruction)) {
1354
+ if (isAdvanceNonceAccountInstructionForNonce(firstInstruction, nonceAccountAddress, nonceAuthorityAddress)) {
1355
+ if (isDurableNonceTransaction(transaction) && transaction.lifetimeConstraint.nonce === nonce) {
1356
+ return transaction;
1357
+ } else {
1358
+ newInstructions = [firstInstruction, ...transaction.instructions.slice(1)];
1359
+ }
1360
+ } else {
1361
+ newInstructions = [
1362
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1363
+ ...transaction.instructions.slice(1)
1364
+ ];
1365
+ }
1366
+ } else {
1367
+ newInstructions = [
1368
+ createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
1369
+ ...transaction.instructions
1370
+ ];
935
1371
  }
936
1372
  const out = {
937
1373
  ...getUnsignedTransaction(transaction),
938
- instructions: [
939
- createAdvanceNonceAccountInstruction(nonceAccountAddress, nonceAuthorityAddress),
940
- ...isAlreadyDurableNonceTransaction ? transaction.instructions.slice(1) : transaction.instructions
941
- ],
1374
+ instructions: newInstructions,
942
1375
  lifetimeConstraint: {
943
1376
  nonce
944
1377
  }
@@ -973,8 +1406,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
973
1406
  Object.freeze(out);
974
1407
  return out;
975
1408
  }
976
- function upsert(addressMap, address, update) {
977
- addressMap[address] = update(addressMap[address] ?? { role: AccountRole2.READONLY });
1409
+ function upsert(addressMap, address2, update) {
1410
+ addressMap[address2] = update(addressMap[address2] ?? { role: AccountRole2.READONLY });
978
1411
  }
979
1412
  var TYPE = Symbol("AddressMapTypeProperty");
980
1413
  function getAddressMapFromInstructions(feePayer, instructions) {
@@ -1025,7 +1458,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1025
1458
  const shouldReplaceEntry = (
1026
1459
  // Consider using the new LOOKUP_TABLE if its address is different...
1027
1460
  entry.lookupTableAddress !== accountMeta.lookupTableAddress && // ...and sorts before the existing one.
1028
- (addressComparator || (addressComparator = getBase58EncodedAddressComparator()))(
1461
+ (addressComparator || (addressComparator = getAddressComparator()))(
1029
1462
  accountMeta.lookupTableAddress,
1030
1463
  entry.lookupTableAddress
1031
1464
  ) < 0
@@ -1133,14 +1566,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1133
1566
  if (leftIsWritable !== isWritableRole2(rightEntry.role)) {
1134
1567
  return leftIsWritable ? -1 : 1;
1135
1568
  }
1136
- addressComparator || (addressComparator = getBase58EncodedAddressComparator());
1569
+ addressComparator || (addressComparator = getAddressComparator());
1137
1570
  if (leftEntry[TYPE] === 1 && rightEntry[TYPE] === 1 && leftEntry.lookupTableAddress !== rightEntry.lookupTableAddress) {
1138
1571
  return addressComparator(leftEntry.lookupTableAddress, rightEntry.lookupTableAddress);
1139
1572
  } else {
1140
1573
  return addressComparator(leftAddress, rightAddress);
1141
1574
  }
1142
- }).map(([address, addressMeta]) => ({
1143
- address,
1575
+ }).map(([address2, addressMeta]) => ({
1576
+ address: address2,
1144
1577
  ...addressMeta
1145
1578
  }));
1146
1579
  return orderedAccounts;
@@ -1162,7 +1595,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1162
1595
  entry.readableIndices.push(account.addressIndex);
1163
1596
  }
1164
1597
  }
1165
- return Object.keys(index).sort(getBase58EncodedAddressComparator()).map((lookupTableAddress) => ({
1598
+ return Object.keys(index).sort(getAddressComparator()).map((lookupTableAddress) => ({
1166
1599
  lookupTableAddress,
1167
1600
  ...index[lookupTableAddress]
1168
1601
  }));
@@ -1203,7 +1636,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1203
1636
  return instructions.map(({ accounts, data, programAddress }) => {
1204
1637
  return {
1205
1638
  programAddressIndex: accountIndex[programAddress],
1206
- ...accounts ? { accountIndices: accounts.map(({ address }) => accountIndex[address]) } : null,
1639
+ ...accounts ? { accountIndices: accounts.map(({ address: address2 }) => accountIndex[address2]) } : null,
1207
1640
  ...data ? { data } : null
1208
1641
  };
1209
1642
  });
@@ -1217,7 +1650,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1217
1650
  function getCompiledStaticAccounts(orderedAccounts) {
1218
1651
  const firstLookupTableAccountIndex = orderedAccounts.findIndex((account) => "lookupTableAddress" in account);
1219
1652
  const orderedStaticAccounts = firstLookupTableAccountIndex === -1 ? orderedAccounts : orderedAccounts.slice(0, firstLookupTableAccountIndex);
1220
- return orderedStaticAccounts.map(({ address }) => address);
1653
+ return orderedStaticAccounts.map(({ address: address2 }) => address2);
1221
1654
  }
1222
1655
  function compileMessage(transaction) {
1223
1656
  const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
@@ -1231,138 +1664,306 @@ this.globalThis.solanaWeb3 = (function (exports) {
1231
1664
  version: transaction.version
1232
1665
  };
1233
1666
  }
1234
- function getAddressTableLookupCodec() {
1235
- return struct(
1236
- [
1237
- [
1238
- "lookupTableAddress",
1239
- getBase58EncodedAddressCodec(
1240
- {
1241
- description: "The address of the address lookup table account from which instruction addresses should be looked up"
1242
- }
1243
- )
1244
- ],
1245
- [
1246
- "writableIndices",
1247
- array(u8(), {
1248
- ...{
1249
- description: "The indices of the accounts in the lookup table that should be loaded as writeable"
1250
- } ,
1251
- size: shortU16()
1252
- })
1253
- ],
1254
- [
1255
- "readableIndices",
1256
- array(u8(), {
1257
- ...{
1258
- description: "The indices of the accounts in the lookup table that should be loaded as read-only"
1259
- } ,
1260
- size: shortU16()
1261
- })
1262
- ]
1263
- ],
1264
- {
1265
- description: "A pointer to the address of an address lookup table, along with the readonly/writeable indices of the addresses that should be loaded from it"
1266
- }
1667
+ function getCompiledTransaction(transaction) {
1668
+ const compiledMessage = compileMessage(transaction);
1669
+ let signatures;
1670
+ if ("signatures" in transaction) {
1671
+ signatures = [];
1672
+ for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1673
+ signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
1674
+ }
1675
+ } else {
1676
+ signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
1677
+ }
1678
+ return {
1679
+ compiledMessage,
1680
+ signatures
1681
+ };
1682
+ }
1683
+ function getAccountMetas(message) {
1684
+ const { header } = message;
1685
+ const numWritableSignerAccounts = header.numSignerAccounts - header.numReadonlySignerAccounts;
1686
+ const numWritableNonSignerAccounts = message.staticAccounts.length - header.numSignerAccounts - header.numReadonlyNonSignerAccounts;
1687
+ const accountMetas = [];
1688
+ let accountIndex = 0;
1689
+ for (let i = 0; i < numWritableSignerAccounts; i++) {
1690
+ accountMetas.push({
1691
+ address: message.staticAccounts[accountIndex],
1692
+ role: AccountRole2.WRITABLE_SIGNER
1693
+ });
1694
+ accountIndex++;
1695
+ }
1696
+ for (let i = 0; i < header.numReadonlySignerAccounts; i++) {
1697
+ accountMetas.push({
1698
+ address: message.staticAccounts[accountIndex],
1699
+ role: AccountRole2.READONLY_SIGNER
1700
+ });
1701
+ accountIndex++;
1702
+ }
1703
+ for (let i = 0; i < numWritableNonSignerAccounts; i++) {
1704
+ accountMetas.push({
1705
+ address: message.staticAccounts[accountIndex],
1706
+ role: AccountRole2.WRITABLE
1707
+ });
1708
+ accountIndex++;
1709
+ }
1710
+ for (let i = 0; i < header.numReadonlyNonSignerAccounts; i++) {
1711
+ accountMetas.push({
1712
+ address: message.staticAccounts[accountIndex],
1713
+ role: AccountRole2.READONLY
1714
+ });
1715
+ accountIndex++;
1716
+ }
1717
+ return accountMetas;
1718
+ }
1719
+ function convertInstruction(instruction, accountMetas) {
1720
+ const programAddress = accountMetas[instruction.programAddressIndex]?.address;
1721
+ if (!programAddress) {
1722
+ throw new Error(`Could not find program address at index ${instruction.programAddressIndex}`);
1723
+ }
1724
+ const accounts = instruction.accountIndices?.map((accountIndex) => accountMetas[accountIndex]);
1725
+ const { data } = instruction;
1726
+ return {
1727
+ programAddress,
1728
+ ...accounts && accounts.length ? { accounts } : {},
1729
+ ...data && data.length ? { data } : {}
1730
+ };
1731
+ }
1732
+ function getLifetimeConstraint(messageLifetimeToken, firstInstruction, lastValidBlockHeight) {
1733
+ if (!firstInstruction || !isAdvanceNonceAccountInstruction(firstInstruction)) {
1734
+ return {
1735
+ blockhash: messageLifetimeToken,
1736
+ lastValidBlockHeight: lastValidBlockHeight ?? 2n ** 64n - 1n
1737
+ // U64 MAX
1738
+ };
1739
+ } else {
1740
+ const nonceAccountAddress = firstInstruction.accounts[0].address;
1741
+ assertIsAddress(nonceAccountAddress);
1742
+ const nonceAuthorityAddress = firstInstruction.accounts[2].address;
1743
+ assertIsAddress(nonceAuthorityAddress);
1744
+ return {
1745
+ nonce: messageLifetimeToken,
1746
+ nonceAccountAddress,
1747
+ nonceAuthorityAddress
1748
+ };
1749
+ }
1750
+ }
1751
+ function convertSignatures(compiledTransaction) {
1752
+ const {
1753
+ compiledMessage: { staticAccounts },
1754
+ signatures
1755
+ } = compiledTransaction;
1756
+ return signatures.reduce((acc, sig, index) => {
1757
+ const allZeros = sig.every((byte) => byte === 0);
1758
+ if (allZeros)
1759
+ return acc;
1760
+ const address2 = staticAccounts[index];
1761
+ return { ...acc, [address2]: sig };
1762
+ }, {});
1763
+ }
1764
+ function decompileTransaction(compiledTransaction, lastValidBlockHeight) {
1765
+ const { compiledMessage } = compiledTransaction;
1766
+ if ("addressTableLookups" in compiledMessage && compiledMessage.addressTableLookups.length > 0) {
1767
+ throw new Error("Cannot convert transaction with addressTableLookups");
1768
+ }
1769
+ const feePayer = compiledMessage.staticAccounts[0];
1770
+ if (!feePayer)
1771
+ throw new Error("No fee payer set in CompiledTransaction");
1772
+ const accountMetas = getAccountMetas(compiledMessage);
1773
+ const instructions = compiledMessage.instructions.map(
1774
+ (compiledInstruction) => convertInstruction(compiledInstruction, accountMetas)
1775
+ );
1776
+ const firstInstruction = instructions[0];
1777
+ const lifetimeConstraint = getLifetimeConstraint(
1778
+ compiledMessage.lifetimeToken,
1779
+ firstInstruction,
1780
+ lastValidBlockHeight
1781
+ );
1782
+ const signatures = convertSignatures(compiledTransaction);
1783
+ return pipe(
1784
+ createTransaction({ version: compiledMessage.version }),
1785
+ (tx) => setTransactionFeePayer(feePayer, tx),
1786
+ (tx) => instructions.reduce((acc, instruction) => {
1787
+ return appendTransactionInstruction(instruction, acc);
1788
+ }, tx),
1789
+ (tx) => "blockhash" in lifetimeConstraint ? setTransactionLifetimeUsingBlockhash(lifetimeConstraint, tx) : setTransactionLifetimeUsingDurableNonce(lifetimeConstraint, tx),
1790
+ (tx) => compiledTransaction.signatures.length ? { ...tx, signatures } : tx
1267
1791
  );
1268
1792
  }
1269
- function getMessageHeaderCodec() {
1270
- return struct(
1271
- [
1793
+ var lookupTableAddressDescription = "The address of the address lookup table account from which instruction addresses should be looked up" ;
1794
+ var writableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as writeable" ;
1795
+ var readableIndicesDescription = "The indices of the accounts in the lookup table that should be loaded as read-only" ;
1796
+ 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" ;
1797
+ var memoizedAddressTableLookupEncoder;
1798
+ function getAddressTableLookupEncoder() {
1799
+ if (!memoizedAddressTableLookupEncoder) {
1800
+ memoizedAddressTableLookupEncoder = getStructEncoder(
1272
1801
  [
1273
- "numSignerAccounts",
1274
- u8(
1275
- {
1276
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction"
1277
- }
1278
- )
1802
+ ["lookupTableAddress", getAddressEncoder({ description: lookupTableAddressDescription })],
1803
+ [
1804
+ "writableIndices",
1805
+ getArrayEncoder(getU8Encoder(), {
1806
+ description: writableIndicesDescription,
1807
+ size: getShortU16Encoder()
1808
+ })
1809
+ ],
1810
+ [
1811
+ "readableIndices",
1812
+ getArrayEncoder(getU8Encoder(), {
1813
+ description: readableIndicesDescription,
1814
+ size: getShortU16Encoder()
1815
+ })
1816
+ ]
1279
1817
  ],
1818
+ { description: addressTableLookupDescription }
1819
+ );
1820
+ }
1821
+ return memoizedAddressTableLookupEncoder;
1822
+ }
1823
+ var memoizedAddressTableLookupDecoder;
1824
+ function getAddressTableLookupDecoder() {
1825
+ if (!memoizedAddressTableLookupDecoder) {
1826
+ memoizedAddressTableLookupDecoder = getStructDecoder(
1280
1827
  [
1281
- "numReadonlySignerAccounts",
1282
- u8(
1283
- {
1284
- description: "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction, but may not be writable"
1285
- }
1286
- )
1828
+ ["lookupTableAddress", getAddressDecoder({ description: lookupTableAddressDescription })],
1829
+ [
1830
+ "writableIndices",
1831
+ getArrayDecoder(getU8Decoder(), {
1832
+ description: writableIndicesDescription,
1833
+ size: getShortU16Decoder()
1834
+ })
1835
+ ],
1836
+ [
1837
+ "readableIndices",
1838
+ getArrayDecoder(getU8Decoder(), {
1839
+ description: readableIndicesDescription,
1840
+ size: getShortU16Decoder()
1841
+ })
1842
+ ]
1287
1843
  ],
1288
- [
1289
- "numReadonlyNonSignerAccounts",
1290
- u8(
1291
- {
1292
- description: "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable"
1293
- }
1294
- )
1295
- ]
1844
+ { description: addressTableLookupDescription }
1845
+ );
1846
+ }
1847
+ return memoizedAddressTableLookupDecoder;
1848
+ }
1849
+ var memoizedU8Encoder;
1850
+ function getMemoizedU8Encoder() {
1851
+ if (!memoizedU8Encoder)
1852
+ memoizedU8Encoder = getU8Encoder();
1853
+ return memoizedU8Encoder;
1854
+ }
1855
+ function getMemoizedU8EncoderDescription(description) {
1856
+ const encoder = getMemoizedU8Encoder();
1857
+ return {
1858
+ ...encoder,
1859
+ description: description ?? encoder.description
1860
+ };
1861
+ }
1862
+ var memoizedU8Decoder;
1863
+ function getMemoizedU8Decoder() {
1864
+ if (!memoizedU8Decoder)
1865
+ memoizedU8Decoder = getU8Decoder();
1866
+ return memoizedU8Decoder;
1867
+ }
1868
+ function getMemoizedU8DecoderDescription(description) {
1869
+ const decoder = getMemoizedU8Decoder();
1870
+ return {
1871
+ ...decoder,
1872
+ description: description ?? decoder.description
1873
+ };
1874
+ }
1875
+ var numSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are required to sign this transaction" ;
1876
+ 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" ;
1877
+ var numReadonlyNonSignerAccountsDescription = "The expected number of addresses in the static address list belonging to accounts that are neither signers, nor writable" ;
1878
+ var messageHeaderDescription = "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses" ;
1879
+ function getMessageHeaderEncoder() {
1880
+ return getStructEncoder(
1881
+ [
1882
+ ["numSignerAccounts", getMemoizedU8EncoderDescription(numSignerAccountsDescription)],
1883
+ ["numReadonlySignerAccounts", getMemoizedU8EncoderDescription(numReadonlySignerAccountsDescription)],
1884
+ ["numReadonlyNonSignerAccounts", getMemoizedU8EncoderDescription(numReadonlyNonSignerAccountsDescription)]
1296
1885
  ],
1297
1886
  {
1298
- description: "The transaction message header containing counts of the signer, readonly-signer, and readonly-nonsigner account addresses"
1299
- }
1887
+ description: messageHeaderDescription
1888
+ }
1300
1889
  );
1301
1890
  }
1302
- function getInstructionCodec() {
1303
- return mapSerializer(
1304
- struct([
1305
- [
1306
- "programAddressIndex",
1307
- u8(
1308
- {
1309
- description: "The index of the program being called, according to the well-ordered accounts list for this transaction"
1310
- }
1311
- )
1312
- ],
1313
- [
1314
- "addressIndices",
1315
- array(
1316
- u8({
1317
- description: "The index of an account, according to the well-ordered accounts list for this transaction"
1318
- }),
1319
- {
1320
- description: "An optional list of account indices, according to the well-ordered accounts list for this transaction, in the order in which the program being called expects them" ,
1321
- size: shortU16()
1322
- }
1323
- )
1324
- ],
1325
- [
1326
- "data",
1327
- bytes({
1328
- description: "An optional buffer of data passed to the instruction" ,
1329
- size: shortU16()
1330
- })
1331
- ]
1332
- ]),
1333
- (value) => {
1334
- if (value.addressIndices !== void 0 && value.data !== void 0) {
1335
- return value;
1336
- }
1337
- return {
1338
- ...value,
1339
- addressIndices: value.addressIndices ?? [],
1340
- data: value.data ?? new Uint8Array(0)
1341
- };
1342
- },
1343
- (value) => {
1344
- if (value.addressIndices.length && value.data.byteLength) {
1345
- return value;
1346
- }
1347
- const { addressIndices, data, ...rest } = value;
1348
- return {
1349
- ...rest,
1350
- ...addressIndices.length ? { addressIndices } : null,
1351
- ...data.byteLength ? { data } : null
1352
- };
1891
+ function getMessageHeaderDecoder() {
1892
+ return getStructDecoder(
1893
+ [
1894
+ ["numSignerAccounts", getMemoizedU8DecoderDescription(numSignerAccountsDescription)],
1895
+ ["numReadonlySignerAccounts", getMemoizedU8DecoderDescription(numReadonlySignerAccountsDescription)],
1896
+ ["numReadonlyNonSignerAccounts", getMemoizedU8DecoderDescription(numReadonlyNonSignerAccountsDescription)]
1897
+ ],
1898
+ {
1899
+ description: messageHeaderDescription
1353
1900
  }
1354
1901
  );
1355
1902
  }
1356
- function getError(type, name) {
1357
- const functionSuffix = name + type[0].toUpperCase() + type.slice(1);
1358
- return new Error(
1359
- `No ${type} exists for ${name}. Use \`get${functionSuffix}()\` if you need a ${type}, and \`get${name}Codec()\` if you need to both encode and decode ${name}`
1360
- );
1903
+ var programAddressIndexDescription = "The index of the program being called, according to the well-ordered accounts list for this transaction" ;
1904
+ var accountIndexDescription = "The index of an account, according to the well-ordered accounts list for this transaction" ;
1905
+ 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" ;
1906
+ var dataDescription = "An optional buffer of data passed to the instruction" ;
1907
+ var memoizedGetInstructionEncoder;
1908
+ function getInstructionEncoder() {
1909
+ if (!memoizedGetInstructionEncoder) {
1910
+ memoizedGetInstructionEncoder = mapEncoder(
1911
+ getStructEncoder([
1912
+ ["programAddressIndex", getU8Encoder({ description: programAddressIndexDescription })],
1913
+ [
1914
+ "accountIndices",
1915
+ getArrayEncoder(getU8Encoder({ description: accountIndexDescription }), {
1916
+ description: accountIndicesDescription,
1917
+ size: getShortU16Encoder()
1918
+ })
1919
+ ],
1920
+ ["data", getBytesEncoder({ description: dataDescription, size: getShortU16Encoder() })]
1921
+ ]),
1922
+ // Convert an instruction to have all fields defined
1923
+ (instruction) => {
1924
+ if (instruction.accountIndices !== void 0 && instruction.data !== void 0) {
1925
+ return instruction;
1926
+ }
1927
+ return {
1928
+ ...instruction,
1929
+ accountIndices: instruction.accountIndices ?? [],
1930
+ data: instruction.data ?? new Uint8Array(0)
1931
+ };
1932
+ }
1933
+ );
1934
+ }
1935
+ return memoizedGetInstructionEncoder;
1361
1936
  }
1362
- function getUnimplementedDecoder(name) {
1363
- return () => {
1364
- throw getError("decoder", name);
1365
- };
1937
+ var memoizedGetInstructionDecoder;
1938
+ function getInstructionDecoder() {
1939
+ if (!memoizedGetInstructionDecoder) {
1940
+ memoizedGetInstructionDecoder = mapDecoder(
1941
+ getStructDecoder([
1942
+ ["programAddressIndex", getU8Decoder({ description: programAddressIndexDescription })],
1943
+ [
1944
+ "accountIndices",
1945
+ getArrayDecoder(getU8Decoder({ description: accountIndexDescription }), {
1946
+ description: accountIndicesDescription,
1947
+ size: getShortU16Decoder()
1948
+ })
1949
+ ],
1950
+ ["data", getBytesDecoder({ description: dataDescription, size: getShortU16Decoder() })]
1951
+ ]),
1952
+ // Convert an instruction to exclude optional fields if they are empty
1953
+ (instruction) => {
1954
+ if (instruction.accountIndices.length && instruction.data.byteLength) {
1955
+ return instruction;
1956
+ }
1957
+ const { accountIndices, data, ...rest } = instruction;
1958
+ return {
1959
+ ...rest,
1960
+ ...accountIndices.length ? { accountIndices } : null,
1961
+ ...data.byteLength ? { data } : null
1962
+ };
1963
+ }
1964
+ );
1965
+ }
1966
+ return memoizedGetInstructionDecoder;
1366
1967
  }
1367
1968
  var VERSION_FLAG_MASK = 128;
1368
1969
  var BASE_CONFIG = {
@@ -1370,8 +1971,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
1370
1971
  fixedSize: null,
1371
1972
  maxSize: 1
1372
1973
  };
1373
- function deserialize(bytes3, offset = 0) {
1374
- const firstByte = bytes3[offset];
1974
+ function decode(bytes, offset = 0) {
1975
+ const firstByte = bytes[offset];
1375
1976
  if ((firstByte & VERSION_FLAG_MASK) === 0) {
1376
1977
  return ["legacy", offset];
1377
1978
  } else {
@@ -1379,7 +1980,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1379
1980
  return [version, offset + 1];
1380
1981
  }
1381
1982
  }
1382
- function serialize(value) {
1983
+ function encode(value) {
1383
1984
  if (value === "legacy") {
1384
1985
  return new Uint8Array();
1385
1986
  }
@@ -1388,95 +1989,255 @@ this.globalThis.solanaWeb3 = (function (exports) {
1388
1989
  }
1389
1990
  return new Uint8Array([value | VERSION_FLAG_MASK]);
1390
1991
  }
1391
- function getTransactionVersionCodec() {
1992
+ function getTransactionVersionDecoder() {
1392
1993
  return {
1393
1994
  ...BASE_CONFIG,
1394
- deserialize,
1395
- serialize
1995
+ decode
1396
1996
  };
1397
1997
  }
1398
- var BASE_CONFIG2 = {
1399
- description: "The wire format of a Solana transaction message" ,
1400
- fixedSize: null,
1401
- maxSize: null
1402
- };
1403
- function serialize2(compiledMessage) {
1404
- if (compiledMessage.version === "legacy") {
1405
- return struct(getPreludeStructSerializerTuple()).serialize(compiledMessage);
1406
- } else {
1407
- return mapSerializer(
1408
- struct([
1409
- ...getPreludeStructSerializerTuple(),
1410
- ["addressTableLookups", getAddressTableLookupsSerializer()]
1411
- ]),
1412
- (value) => {
1413
- if (value.version === "legacy") {
1414
- return value;
1415
- }
1416
- return {
1417
- ...value,
1418
- addressTableLookups: value.addressTableLookups ?? []
1419
- };
1998
+ function getTransactionVersionEncoder() {
1999
+ return {
2000
+ ...BASE_CONFIG,
2001
+ encode
2002
+ };
2003
+ }
2004
+ var staticAccountsDescription = "A compact-array of static account addresses belonging to this transaction" ;
2005
+ var lifetimeTokenDescription = "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ;
2006
+ var instructionsDescription = "A compact-array of instructions belonging to this transaction" ;
2007
+ var addressTableLookupsDescription = "A compact array of address table lookups belonging to this transaction" ;
2008
+ function getCompiledMessageLegacyEncoder() {
2009
+ return getStructEncoder(getPreludeStructEncoderTuple());
2010
+ }
2011
+ function getCompiledMessageVersionedEncoder() {
2012
+ return mapEncoder(
2013
+ getStructEncoder([
2014
+ ...getPreludeStructEncoderTuple(),
2015
+ ["addressTableLookups", getAddressTableLookupArrayEncoder()]
2016
+ ]),
2017
+ (value) => {
2018
+ if (value.version === "legacy") {
2019
+ return value;
1420
2020
  }
1421
- ).serialize(compiledMessage);
1422
- }
2021
+ return {
2022
+ ...value,
2023
+ addressTableLookups: value.addressTableLookups ?? []
2024
+ };
2025
+ }
2026
+ );
1423
2027
  }
1424
- function getPreludeStructSerializerTuple() {
2028
+ function getPreludeStructEncoderTuple() {
1425
2029
  return [
1426
- ["version", getTransactionVersionCodec()],
1427
- ["header", getMessageHeaderCodec()],
2030
+ ["version", getTransactionVersionEncoder()],
2031
+ ["header", getMessageHeaderEncoder()],
1428
2032
  [
1429
2033
  "staticAccounts",
1430
- array(getBase58EncodedAddressCodec(), {
1431
- description: "A compact-array of static account addresses belonging to this transaction" ,
1432
- size: shortU16()
2034
+ getArrayEncoder(getAddressEncoder(), {
2035
+ description: staticAccountsDescription,
2036
+ size: getShortU16Encoder()
1433
2037
  })
1434
2038
  ],
1435
2039
  [
1436
2040
  "lifetimeToken",
1437
- string({
1438
- description: "A 32-byte token that specifies the lifetime of this transaction (eg. a recent blockhash, or a durable nonce)" ,
1439
- encoding: base58,
2041
+ getStringEncoder({
2042
+ description: lifetimeTokenDescription,
2043
+ encoding: getBase58Encoder(),
1440
2044
  size: 32
1441
2045
  })
1442
2046
  ],
1443
2047
  [
1444
2048
  "instructions",
1445
- array(getInstructionCodec(), {
1446
- description: "A compact-array of instructions belonging to this transaction" ,
1447
- size: shortU16()
2049
+ getArrayEncoder(getInstructionEncoder(), {
2050
+ description: instructionsDescription,
2051
+ size: getShortU16Encoder()
1448
2052
  })
1449
2053
  ]
1450
2054
  ];
1451
2055
  }
1452
- function getAddressTableLookupsSerializer() {
1453
- return array(getAddressTableLookupCodec(), {
1454
- ...{ description: "A compact array of address table lookups belonging to this transaction" } ,
1455
- size: shortU16()
2056
+ function getPreludeStructDecoderTuple() {
2057
+ return [
2058
+ ["version", getTransactionVersionDecoder()],
2059
+ ["header", getMessageHeaderDecoder()],
2060
+ [
2061
+ "staticAccounts",
2062
+ getArrayDecoder(getAddressDecoder(), {
2063
+ description: staticAccountsDescription,
2064
+ size: getShortU16Decoder()
2065
+ })
2066
+ ],
2067
+ [
2068
+ "lifetimeToken",
2069
+ getStringDecoder({
2070
+ description: lifetimeTokenDescription,
2071
+ encoding: getBase58Decoder(),
2072
+ size: 32
2073
+ })
2074
+ ],
2075
+ [
2076
+ "instructions",
2077
+ getArrayDecoder(getInstructionDecoder(), {
2078
+ description: instructionsDescription,
2079
+ size: getShortU16Decoder()
2080
+ })
2081
+ ],
2082
+ ["addressTableLookups", getAddressTableLookupArrayDecoder()]
2083
+ ];
2084
+ }
2085
+ function getAddressTableLookupArrayEncoder() {
2086
+ return getArrayEncoder(getAddressTableLookupEncoder(), {
2087
+ description: addressTableLookupsDescription,
2088
+ size: getShortU16Encoder()
2089
+ });
2090
+ }
2091
+ function getAddressTableLookupArrayDecoder() {
2092
+ return getArrayDecoder(getAddressTableLookupDecoder(), {
2093
+ description: addressTableLookupsDescription,
2094
+ size: getShortU16Decoder()
1456
2095
  });
1457
2096
  }
2097
+ var messageDescription = "The wire format of a Solana transaction message" ;
1458
2098
  function getCompiledMessageEncoder() {
1459
2099
  return {
1460
- ...BASE_CONFIG2,
1461
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1462
- serialize: serialize2
2100
+ description: messageDescription,
2101
+ encode: (compiledMessage) => {
2102
+ if (compiledMessage.version === "legacy") {
2103
+ return getCompiledMessageLegacyEncoder().encode(compiledMessage);
2104
+ } else {
2105
+ return getCompiledMessageVersionedEncoder().encode(compiledMessage);
2106
+ }
2107
+ },
2108
+ fixedSize: null,
2109
+ maxSize: null
1463
2110
  };
1464
2111
  }
1465
- async function getCompiledMessageSignature(message, secretKey) {
1466
- const wireMessageBytes = getCompiledMessageEncoder().serialize(message);
1467
- const signature = await signBytes(secretKey, wireMessageBytes);
1468
- return signature;
2112
+ function getCompiledMessageDecoder() {
2113
+ return mapDecoder(
2114
+ getStructDecoder(getPreludeStructDecoderTuple(), {
2115
+ description: messageDescription
2116
+ }),
2117
+ ({ addressTableLookups, ...restOfMessage }) => {
2118
+ if (restOfMessage.version === "legacy" || !addressTableLookups?.length) {
2119
+ return restOfMessage;
2120
+ }
2121
+ return { ...restOfMessage, addressTableLookups };
2122
+ }
2123
+ );
2124
+ }
2125
+ var signaturesDescription = "A compact array of 64-byte, base-64 encoded Ed25519 signatures" ;
2126
+ var transactionDescription = "The wire format of a Solana transaction" ;
2127
+ function getCompiledTransactionEncoder() {
2128
+ return getStructEncoder(
2129
+ [
2130
+ [
2131
+ "signatures",
2132
+ getArrayEncoder(getBytesEncoder({ size: 64 }), {
2133
+ description: signaturesDescription,
2134
+ size: getShortU16Encoder()
2135
+ })
2136
+ ],
2137
+ ["compiledMessage", getCompiledMessageEncoder()]
2138
+ ],
2139
+ {
2140
+ description: transactionDescription
2141
+ }
2142
+ );
2143
+ }
2144
+ function getSignatureDecoder() {
2145
+ return mapDecoder(getBytesDecoder({ size: 64 }), (bytes) => bytes);
2146
+ }
2147
+ function getCompiledTransactionDecoder() {
2148
+ return getStructDecoder(
2149
+ [
2150
+ [
2151
+ "signatures",
2152
+ getArrayDecoder(getSignatureDecoder(), {
2153
+ description: signaturesDescription,
2154
+ size: getShortU16Decoder()
2155
+ })
2156
+ ],
2157
+ ["compiledMessage", getCompiledMessageDecoder()]
2158
+ ],
2159
+ {
2160
+ description: transactionDescription
2161
+ }
2162
+ );
2163
+ }
2164
+ function getTransactionEncoder() {
2165
+ return mapEncoder(getCompiledTransactionEncoder(), getCompiledTransaction);
2166
+ }
2167
+ function getTransactionDecoder(lastValidBlockHeight) {
2168
+ return mapDecoder(
2169
+ getCompiledTransactionDecoder(),
2170
+ (compiledTransaction) => decompileTransaction(compiledTransaction, lastValidBlockHeight)
2171
+ );
2172
+ }
2173
+ function getTransactionCodec(lastValidBlockHeight) {
2174
+ return combineCodec(getTransactionEncoder(), getTransactionDecoder(lastValidBlockHeight));
2175
+ }
2176
+ var base58Encoder2;
2177
+ var base58Decoder;
2178
+ function assertIsTransactionSignature(putativeTransactionSignature) {
2179
+ if (!base58Encoder2)
2180
+ base58Encoder2 = getBase58Encoder();
2181
+ try {
2182
+ if (
2183
+ // Lowest value (64 bytes of zeroes)
2184
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2185
+ putativeTransactionSignature.length > 88
2186
+ ) {
2187
+ throw new Error("Expected input string to decode to a byte array of length 64.");
2188
+ }
2189
+ const bytes = base58Encoder2.encode(putativeTransactionSignature);
2190
+ const numBytes = bytes.byteLength;
2191
+ if (numBytes !== 64) {
2192
+ throw new Error(`Expected input string to decode to a byte array of length 64. Actual length: ${numBytes}`);
2193
+ }
2194
+ } catch (e3) {
2195
+ throw new Error(`\`${putativeTransactionSignature}\` is not a transaction signature`, {
2196
+ cause: e3
2197
+ });
2198
+ }
2199
+ }
2200
+ function isTransactionSignature(putativeTransactionSignature) {
2201
+ if (!base58Encoder2)
2202
+ base58Encoder2 = getBase58Encoder();
2203
+ if (
2204
+ // Lowest value (64 bytes of zeroes)
2205
+ putativeTransactionSignature.length < 64 || // Highest value (64 bytes of 255)
2206
+ putativeTransactionSignature.length > 88
2207
+ ) {
2208
+ return false;
2209
+ }
2210
+ const bytes = base58Encoder2.encode(putativeTransactionSignature);
2211
+ const numBytes = bytes.byteLength;
2212
+ if (numBytes !== 64) {
2213
+ return false;
2214
+ }
2215
+ return true;
2216
+ }
2217
+ function getSignatureFromTransaction(transaction) {
2218
+ if (!base58Decoder)
2219
+ base58Decoder = getBase58Decoder();
2220
+ const signatureBytes = transaction.signatures[transaction.feePayer];
2221
+ if (!signatureBytes) {
2222
+ throw new Error(
2223
+ "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer."
2224
+ );
2225
+ }
2226
+ const transactionSignature2 = base58Decoder.decode(signatureBytes)[0];
2227
+ return transactionSignature2;
1469
2228
  }
1470
- async function signTransaction(keyPair, transaction) {
2229
+ async function signTransaction(keyPairs, transaction) {
1471
2230
  const compiledMessage = compileMessage(transaction);
1472
- const [signerPublicKey, signature] = await Promise.all([
1473
- getBase58EncodedAddressFromPublicKey(keyPair.publicKey),
1474
- getCompiledMessageSignature(compiledMessage, keyPair.privateKey)
1475
- ]);
1476
- const nextSignatures = {
1477
- ..."signatures" in transaction ? transaction.signatures : null,
1478
- ...{ [signerPublicKey]: signature }
1479
- };
2231
+ const nextSignatures = "signatures" in transaction ? { ...transaction.signatures } : {};
2232
+ const wireMessageBytes = getCompiledMessageEncoder().encode(compiledMessage);
2233
+ const publicKeySignaturePairs = await Promise.all(
2234
+ keyPairs.map(
2235
+ (keyPair) => Promise.all([getAddressFromPublicKey(keyPair.publicKey), signBytes(keyPair.privateKey, wireMessageBytes)])
2236
+ )
2237
+ );
2238
+ for (const [signerPublicKey, signature] of publicKeySignaturePairs) {
2239
+ nextSignatures[signerPublicKey] = signature;
2240
+ }
1480
2241
  const out = {
1481
2242
  ...transaction,
1482
2243
  signatures: nextSignatures
@@ -1484,52 +2245,190 @@ this.globalThis.solanaWeb3 = (function (exports) {
1484
2245
  Object.freeze(out);
1485
2246
  return out;
1486
2247
  }
1487
- function getCompiledTransaction(transaction) {
1488
- const compiledMessage = compileMessage(transaction);
1489
- let signatures;
1490
- if ("signatures" in transaction) {
1491
- signatures = [];
1492
- for (let ii = 0; ii < compiledMessage.header.numSignerAccounts; ii++) {
1493
- signatures[ii] = transaction.signatures[compiledMessage.staticAccounts[ii]] ?? new Uint8Array(Array(64).fill(0));
2248
+ function transactionSignature(putativeTransactionSignature) {
2249
+ assertIsTransactionSignature(putativeTransactionSignature);
2250
+ return putativeTransactionSignature;
2251
+ }
2252
+ function assertTransactionIsFullySigned(transaction) {
2253
+ const signerAddressesFromInstructions = transaction.instructions.flatMap((i) => i.accounts?.filter((a) => isSignerRole2(a.role)) ?? []).map((a) => a.address);
2254
+ const requiredSigners = /* @__PURE__ */ new Set([transaction.feePayer, ...signerAddressesFromInstructions]);
2255
+ requiredSigners.forEach((address2) => {
2256
+ if (!transaction.signatures[address2]) {
2257
+ throw new Error(`Transaction is missing signature for address \`${address2}\``);
1494
2258
  }
1495
- } else {
1496
- signatures = Array(compiledMessage.header.numSignerAccounts).fill(new Uint8Array(Array(64).fill(0)));
2259
+ });
2260
+ }
2261
+ function getBase64EncodedWireTransaction(transaction) {
2262
+ const wireTransactionBytes = getTransactionEncoder().encode(transaction);
2263
+ {
2264
+ return btoa(String.fromCharCode(...wireTransactionBytes));
1497
2265
  }
1498
- return {
1499
- compiledMessage,
1500
- signatures
2266
+ }
2267
+
2268
+ // src/airdrop.ts
2269
+ init_env_shim();
2270
+
2271
+ // src/airdrop-confirmer.ts
2272
+ init_env_shim();
2273
+
2274
+ // src/transaction-confirmation-strategy-racer.ts
2275
+ init_env_shim();
2276
+ async function raceStrategies(signature, config, getSpecificStrategiesForRace) {
2277
+ const { abortSignal: callerAbortSignal, commitment, getRecentSignatureConfirmationPromise } = config;
2278
+ callerAbortSignal?.throwIfAborted();
2279
+ const abortController = new AbortController();
2280
+ if (callerAbortSignal) {
2281
+ const handleAbort = () => {
2282
+ abortController.abort();
2283
+ };
2284
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
2285
+ }
2286
+ try {
2287
+ const specificStrategies = getSpecificStrategiesForRace({
2288
+ ...config,
2289
+ abortSignal: abortController.signal
2290
+ });
2291
+ return await Promise.race([
2292
+ getRecentSignatureConfirmationPromise({
2293
+ abortSignal: abortController.signal,
2294
+ commitment,
2295
+ signature
2296
+ }),
2297
+ ...specificStrategies
2298
+ ]);
2299
+ } finally {
2300
+ abortController.abort();
2301
+ }
2302
+ }
2303
+
2304
+ // src/transaction-confirmation-strategy-recent-signature.ts
2305
+ init_env_shim();
2306
+ function createRecentSignatureConfirmationPromiseFactory(rpc, rpcSubscriptions) {
2307
+ return async function getRecentSignatureConfirmationPromise({
2308
+ abortSignal: callerAbortSignal,
2309
+ commitment,
2310
+ signature
2311
+ }) {
2312
+ const abortController = new AbortController();
2313
+ function handleAbort() {
2314
+ abortController.abort();
2315
+ }
2316
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
2317
+ const signatureStatusNotifications = await rpcSubscriptions.signatureNotifications(signature, { commitment }).subscribe({ abortSignal: abortController.signal });
2318
+ const signatureDidCommitPromise = (async () => {
2319
+ for await (const signatureStatusNotification of signatureStatusNotifications) {
2320
+ if (signatureStatusNotification.value.err) {
2321
+ throw new Error(`The transaction with signature \`${signature}\` failed.`, {
2322
+ cause: signatureStatusNotification.value.err
2323
+ });
2324
+ } else {
2325
+ return;
2326
+ }
2327
+ }
2328
+ })();
2329
+ const signatureStatusLookupPromise = (async () => {
2330
+ const { value: signatureStatusResults } = await rpc.getSignatureStatuses([signature]).send({ abortSignal: abortController.signal });
2331
+ const signatureStatus = signatureStatusResults[0];
2332
+ if (signatureStatus && signatureStatus.confirmationStatus && commitmentComparator(signatureStatus.confirmationStatus, commitment) >= 0) {
2333
+ return;
2334
+ } else {
2335
+ await new Promise(() => {
2336
+ });
2337
+ }
2338
+ })();
2339
+ try {
2340
+ return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
2341
+ } finally {
2342
+ abortController.abort();
2343
+ }
1501
2344
  };
1502
2345
  }
1503
- var BASE_CONFIG3 = {
1504
- description: "The wire format of a Solana transaction" ,
1505
- fixedSize: null,
1506
- maxSize: null
1507
- };
1508
- function serialize3(transaction) {
1509
- const compiledTransaction = getCompiledTransaction(transaction);
1510
- return struct([
1511
- [
1512
- "signatures",
1513
- array(bytes({ size: 64 }), {
1514
- ...{ description: "A compact array of 64-byte, base-64 encoded Ed25519 signatures" } ,
1515
- size: shortU16()
1516
- })
1517
- ],
1518
- ["compiledMessage", getCompiledMessageEncoder()]
1519
- ]).serialize(compiledTransaction);
2346
+
2347
+ // src/transaction-confirmation-strategy-timeout.ts
2348
+ init_env_shim();
2349
+ async function getTimeoutPromise({ abortSignal: callerAbortSignal, commitment }) {
2350
+ return await new Promise((_, reject) => {
2351
+ const handleAbort = (e3) => {
2352
+ clearTimeout(timeoutId);
2353
+ const abortError = new DOMException(e3.target.reason, "AbortError");
2354
+ reject(abortError);
2355
+ };
2356
+ callerAbortSignal.addEventListener("abort", handleAbort);
2357
+ const timeoutMs = commitment === "processed" ? 3e4 : 6e4;
2358
+ const startMs = performance.now();
2359
+ const timeoutId = (
2360
+ // We use `setTimeout` instead of `AbortSignal.timeout()` because we want to measure
2361
+ // elapsed time instead of active time.
2362
+ // See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
2363
+ setTimeout(() => {
2364
+ const elapsedMs = performance.now() - startMs;
2365
+ reject(new DOMException(`Timeout elapsed after ${elapsedMs} ms`, "TimeoutError"));
2366
+ }, timeoutMs)
2367
+ );
2368
+ });
1520
2369
  }
1521
- function getTransactionEncoder() {
1522
- return {
1523
- ...BASE_CONFIG3,
1524
- deserialize: getUnimplementedDecoder("CompiledMessage"),
1525
- serialize: serialize3
2370
+
2371
+ // src/airdrop-confirmer.ts
2372
+ function createDefaultSignatureOnlyRecentTransactionConfirmer({
2373
+ rpc,
2374
+ rpcSubscriptions
2375
+ }) {
2376
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
2377
+ rpc,
2378
+ rpcSubscriptions
2379
+ );
2380
+ return async function confirmSignatureOnlyRecentTransaction(config) {
2381
+ await waitForRecentTransactionConfirmationUntilTimeout({
2382
+ ...config,
2383
+ getRecentSignatureConfirmationPromise,
2384
+ getTimeoutPromise
2385
+ });
1526
2386
  };
1527
2387
  }
1528
- function getBase64EncodedWireTransaction(transaction) {
1529
- const wireTransactionBytes = getTransactionEncoder().serialize(transaction);
1530
- {
1531
- return btoa(String.fromCharCode(...wireTransactionBytes));
1532
- }
2388
+ async function waitForRecentTransactionConfirmationUntilTimeout(config) {
2389
+ await raceStrategies(
2390
+ config.signature,
2391
+ config,
2392
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getTimeoutPromise: getTimeoutPromise2 }) {
2393
+ return [
2394
+ getTimeoutPromise2({
2395
+ abortSignal,
2396
+ commitment
2397
+ })
2398
+ ];
2399
+ }
2400
+ );
2401
+ }
2402
+
2403
+ // src/airdrop.ts
2404
+ function createDefaultAirdropRequester({ rpc, rpcSubscriptions }) {
2405
+ const confirmSignatureOnlyTransaction = createDefaultSignatureOnlyRecentTransactionConfirmer({
2406
+ rpc,
2407
+ rpcSubscriptions
2408
+ });
2409
+ return async function requestAirdrop(config) {
2410
+ return await requestAndConfirmAirdrop({
2411
+ ...config,
2412
+ confirmSignatureOnlyTransaction,
2413
+ rpc
2414
+ });
2415
+ };
2416
+ }
2417
+ async function requestAndConfirmAirdrop({
2418
+ abortSignal,
2419
+ commitment,
2420
+ confirmSignatureOnlyTransaction,
2421
+ lamports: lamports2,
2422
+ recipientAddress,
2423
+ rpc
2424
+ }) {
2425
+ const airdropTransactionSignature = await rpc.requestAirdrop(recipientAddress, lamports2, { commitment }).send({ abortSignal });
2426
+ await confirmSignatureOnlyTransaction({
2427
+ abortSignal,
2428
+ commitment,
2429
+ signature: airdropTransactionSignature
2430
+ });
2431
+ return airdropTransactionSignature;
1533
2432
  }
1534
2433
 
1535
2434
  // src/rpc.ts
@@ -1563,85 +2462,393 @@ this.globalThis.solanaWeb3 = (function (exports) {
1563
2462
  return visitNode(params, [], onIntegerOverflow);
1564
2463
  }
1565
2464
  var KEYPATH_WILDCARD = {};
1566
- var ALLOWED_NUMERIC_KEYPATHS = {
1567
- getAccountInfo: [
1568
- // parsed AddressTableLookup account
1569
- ["value", "data", "parsed", "info", "lastExtendedSlotStartIndex"],
1570
- // parsed Config account
1571
- ["value", "data", "parsed", "info", "slashPenalty"],
1572
- ["value", "data", "parsed", "info", "warmupCooldownRate"],
1573
- // parsed Token/Token22 token account
1574
- ["value", "data", "parsed", "info", "tokenAmount", "decimals"],
1575
- ["value", "data", "parsed", "info", "tokenAmount", "uiAmount"],
1576
- ["value", "data", "parsed", "info", "rentExemptReserve", "decimals"],
1577
- ["value", "data", "parsed", "info", "delegatedAmount", "decimals"],
1578
- [
1579
- "value",
1580
- "data",
1581
- "parsed",
1582
- "info",
1583
- "extensions",
1584
- KEYPATH_WILDCARD,
1585
- "state",
1586
- "olderTransferFee",
1587
- "transferFeeBasisPoints"
1588
- ],
1589
- [
1590
- "value",
1591
- "data",
1592
- "parsed",
1593
- "info",
1594
- "extensions",
1595
- KEYPATH_WILDCARD,
1596
- "state",
1597
- "newerTransferFee",
1598
- "transferFeeBasisPoints"
1599
- ],
1600
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
1601
- ["value", "data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"],
1602
- // parsed Token/Token22 mint account
1603
- ["value", "data", "parsed", "info", "decimals"],
1604
- // parsed Token/Token22 multisig account
1605
- ["value", "data", "parsed", "info", "numRequiredSigners"],
1606
- ["value", "data", "parsed", "info", "numValidSigners"],
1607
- // parsed Stake account
1608
- ["value", "data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
1609
- // parsed Sysvar rent account
1610
- ["value", "data", "parsed", "info", "exemptionThreshold"],
1611
- ["value", "data", "parsed", "info", "burnPercent"],
1612
- // parsed Vote account
1613
- ["value", "data", "parsed", "info", "commission"],
1614
- ["value", "data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
1615
- ],
1616
- getBlockTime: [[]],
1617
- getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
1618
- getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
1619
- getTokenLargestAccounts: [
1620
- ["value", KEYPATH_WILDCARD, "decimals"],
1621
- ["value", KEYPATH_WILDCARD, "uiAmount"]
1622
- ],
1623
- getTransaction: [
1624
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1625
- ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1626
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
1627
- ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
1628
- ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
1629
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
1630
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1631
- ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1632
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "writableIndexes", KEYPATH_WILDCARD],
1633
- ["transaction", "message", "addressTableLookups", KEYPATH_WILDCARD, "readonlyIndexes", KEYPATH_WILDCARD],
1634
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
1635
- ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
1636
- ["transaction", "message", "header", "numReadonlySignedAccounts"],
1637
- ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
1638
- ["transaction", "message", "header", "numRequiredSignatures"]
1639
- ],
1640
- getVoteAccounts: [
1641
- ["current", KEYPATH_WILDCARD, "commission"],
1642
- ["delinquent", KEYPATH_WILDCARD, "commission"]
1643
- ]
1644
- };
2465
+ var jsonParsedTokenAccountsConfigs = [
2466
+ // parsed Token/Token22 token account
2467
+ ["data", "parsed", "info", "tokenAmount", "decimals"],
2468
+ ["data", "parsed", "info", "tokenAmount", "uiAmount"],
2469
+ ["data", "parsed", "info", "rentExemptReserve", "decimals"],
2470
+ ["data", "parsed", "info", "rentExemptReserve", "uiAmount"],
2471
+ ["data", "parsed", "info", "delegatedAmount", "decimals"],
2472
+ ["data", "parsed", "info", "delegatedAmount", "uiAmount"],
2473
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "olderTransferFee", "transferFeeBasisPoints"],
2474
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "newerTransferFee", "transferFeeBasisPoints"],
2475
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "preUpdateAverageRate"],
2476
+ ["data", "parsed", "info", "extensions", KEYPATH_WILDCARD, "state", "currentRate"]
2477
+ ];
2478
+ var jsonParsedAccountsConfigs = [
2479
+ ...jsonParsedTokenAccountsConfigs,
2480
+ // parsed AddressTableLookup account
2481
+ ["data", "parsed", "info", "lastExtendedSlotStartIndex"],
2482
+ // parsed Config account
2483
+ ["data", "parsed", "info", "slashPenalty"],
2484
+ ["data", "parsed", "info", "warmupCooldownRate"],
2485
+ // parsed Token/Token22 mint account
2486
+ ["data", "parsed", "info", "decimals"],
2487
+ // parsed Token/Token22 multisig account
2488
+ ["data", "parsed", "info", "numRequiredSigners"],
2489
+ ["data", "parsed", "info", "numValidSigners"],
2490
+ // parsed Stake account
2491
+ ["data", "parsed", "info", "stake", "delegation", "warmupCooldownRate"],
2492
+ // parsed Sysvar rent account
2493
+ ["data", "parsed", "info", "exemptionThreshold"],
2494
+ ["data", "parsed", "info", "burnPercent"],
2495
+ // parsed Vote account
2496
+ ["data", "parsed", "info", "commission"],
2497
+ ["data", "parsed", "info", "votes", KEYPATH_WILDCARD, "confirmationCount"]
2498
+ ];
2499
+ var memoizedNotificationKeypaths;
2500
+ var memoizedResponseKeypaths;
2501
+ function getAllowedNumericKeypathsForNotification() {
2502
+ if (!memoizedNotificationKeypaths) {
2503
+ memoizedNotificationKeypaths = {
2504
+ accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
2505
+ blockNotifications: [
2506
+ ["value", "block", "blockTime"],
2507
+ [
2508
+ "value",
2509
+ "block",
2510
+ "transactions",
2511
+ KEYPATH_WILDCARD,
2512
+ "meta",
2513
+ "preTokenBalances",
2514
+ KEYPATH_WILDCARD,
2515
+ "accountIndex"
2516
+ ],
2517
+ [
2518
+ "value",
2519
+ "block",
2520
+ "transactions",
2521
+ KEYPATH_WILDCARD,
2522
+ "meta",
2523
+ "preTokenBalances",
2524
+ KEYPATH_WILDCARD,
2525
+ "uiTokenAmount",
2526
+ "decimals"
2527
+ ],
2528
+ [
2529
+ "value",
2530
+ "block",
2531
+ "transactions",
2532
+ KEYPATH_WILDCARD,
2533
+ "meta",
2534
+ "postTokenBalances",
2535
+ KEYPATH_WILDCARD,
2536
+ "accountIndex"
2537
+ ],
2538
+ [
2539
+ "value",
2540
+ "block",
2541
+ "transactions",
2542
+ KEYPATH_WILDCARD,
2543
+ "meta",
2544
+ "postTokenBalances",
2545
+ KEYPATH_WILDCARD,
2546
+ "uiTokenAmount",
2547
+ "decimals"
2548
+ ],
2549
+ ["value", "block", "transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
2550
+ [
2551
+ "value",
2552
+ "block",
2553
+ "transactions",
2554
+ KEYPATH_WILDCARD,
2555
+ "meta",
2556
+ "innerInstructions",
2557
+ KEYPATH_WILDCARD,
2558
+ "index"
2559
+ ],
2560
+ [
2561
+ "value",
2562
+ "block",
2563
+ "transactions",
2564
+ KEYPATH_WILDCARD,
2565
+ "meta",
2566
+ "innerInstructions",
2567
+ KEYPATH_WILDCARD,
2568
+ "instructions",
2569
+ KEYPATH_WILDCARD,
2570
+ "programIdIndex"
2571
+ ],
2572
+ [
2573
+ "value",
2574
+ "block",
2575
+ "transactions",
2576
+ KEYPATH_WILDCARD,
2577
+ "meta",
2578
+ "innerInstructions",
2579
+ KEYPATH_WILDCARD,
2580
+ "instructions",
2581
+ KEYPATH_WILDCARD,
2582
+ "accounts",
2583
+ KEYPATH_WILDCARD
2584
+ ],
2585
+ [
2586
+ "value",
2587
+ "block",
2588
+ "transactions",
2589
+ KEYPATH_WILDCARD,
2590
+ "transaction",
2591
+ "message",
2592
+ "addressTableLookups",
2593
+ KEYPATH_WILDCARD,
2594
+ "writableIndexes",
2595
+ KEYPATH_WILDCARD
2596
+ ],
2597
+ [
2598
+ "value",
2599
+ "block",
2600
+ "transactions",
2601
+ KEYPATH_WILDCARD,
2602
+ "transaction",
2603
+ "message",
2604
+ "addressTableLookups",
2605
+ KEYPATH_WILDCARD,
2606
+ "readonlyIndexes",
2607
+ KEYPATH_WILDCARD
2608
+ ],
2609
+ [
2610
+ "value",
2611
+ "block",
2612
+ "transactions",
2613
+ KEYPATH_WILDCARD,
2614
+ "transaction",
2615
+ "message",
2616
+ "instructions",
2617
+ KEYPATH_WILDCARD,
2618
+ "programIdIndex"
2619
+ ],
2620
+ [
2621
+ "value",
2622
+ "block",
2623
+ "transactions",
2624
+ KEYPATH_WILDCARD,
2625
+ "transaction",
2626
+ "message",
2627
+ "instructions",
2628
+ KEYPATH_WILDCARD,
2629
+ "accounts",
2630
+ KEYPATH_WILDCARD
2631
+ ],
2632
+ [
2633
+ "value",
2634
+ "block",
2635
+ "transactions",
2636
+ KEYPATH_WILDCARD,
2637
+ "transaction",
2638
+ "message",
2639
+ "header",
2640
+ "numReadonlySignedAccounts"
2641
+ ],
2642
+ [
2643
+ "value",
2644
+ "block",
2645
+ "transactions",
2646
+ KEYPATH_WILDCARD,
2647
+ "transaction",
2648
+ "message",
2649
+ "header",
2650
+ "numReadonlyUnsignedAccounts"
2651
+ ],
2652
+ [
2653
+ "value",
2654
+ "block",
2655
+ "transactions",
2656
+ KEYPATH_WILDCARD,
2657
+ "transaction",
2658
+ "message",
2659
+ "header",
2660
+ "numRequiredSignatures"
2661
+ ],
2662
+ ["value", "block", "rewards", KEYPATH_WILDCARD, "commission"]
2663
+ ],
2664
+ programNotifications: jsonParsedAccountsConfigs.flatMap((c) => [
2665
+ ["value", KEYPATH_WILDCARD, "account", ...c],
2666
+ [KEYPATH_WILDCARD, "account", ...c]
2667
+ ])
2668
+ };
2669
+ }
2670
+ return memoizedNotificationKeypaths;
2671
+ }
2672
+ function getAllowedNumericKeypathsForResponse() {
2673
+ if (!memoizedResponseKeypaths) {
2674
+ memoizedResponseKeypaths = {
2675
+ getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
2676
+ getBlock: [
2677
+ ["blockTime"],
2678
+ ["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2679
+ [
2680
+ "transactions",
2681
+ KEYPATH_WILDCARD,
2682
+ "meta",
2683
+ "preTokenBalances",
2684
+ KEYPATH_WILDCARD,
2685
+ "uiTokenAmount",
2686
+ "decimals"
2687
+ ],
2688
+ ["transactions", KEYPATH_WILDCARD, "meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2689
+ [
2690
+ "transactions",
2691
+ KEYPATH_WILDCARD,
2692
+ "meta",
2693
+ "postTokenBalances",
2694
+ KEYPATH_WILDCARD,
2695
+ "uiTokenAmount",
2696
+ "decimals"
2697
+ ],
2698
+ ["transactions", KEYPATH_WILDCARD, "meta", "rewards", KEYPATH_WILDCARD, "commission"],
2699
+ ["transactions", KEYPATH_WILDCARD, "meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
2700
+ [
2701
+ "transactions",
2702
+ KEYPATH_WILDCARD,
2703
+ "meta",
2704
+ "innerInstructions",
2705
+ KEYPATH_WILDCARD,
2706
+ "instructions",
2707
+ KEYPATH_WILDCARD,
2708
+ "programIdIndex"
2709
+ ],
2710
+ [
2711
+ "transactions",
2712
+ KEYPATH_WILDCARD,
2713
+ "meta",
2714
+ "innerInstructions",
2715
+ KEYPATH_WILDCARD,
2716
+ "instructions",
2717
+ KEYPATH_WILDCARD,
2718
+ "accounts",
2719
+ KEYPATH_WILDCARD
2720
+ ],
2721
+ [
2722
+ "transactions",
2723
+ KEYPATH_WILDCARD,
2724
+ "transaction",
2725
+ "message",
2726
+ "addressTableLookups",
2727
+ KEYPATH_WILDCARD,
2728
+ "writableIndexes",
2729
+ KEYPATH_WILDCARD
2730
+ ],
2731
+ [
2732
+ "transactions",
2733
+ KEYPATH_WILDCARD,
2734
+ "transaction",
2735
+ "message",
2736
+ "addressTableLookups",
2737
+ KEYPATH_WILDCARD,
2738
+ "readonlyIndexes",
2739
+ KEYPATH_WILDCARD
2740
+ ],
2741
+ [
2742
+ "transactions",
2743
+ KEYPATH_WILDCARD,
2744
+ "transaction",
2745
+ "message",
2746
+ "instructions",
2747
+ KEYPATH_WILDCARD,
2748
+ "programIdIndex"
2749
+ ],
2750
+ [
2751
+ "transactions",
2752
+ KEYPATH_WILDCARD,
2753
+ "transaction",
2754
+ "message",
2755
+ "instructions",
2756
+ KEYPATH_WILDCARD,
2757
+ "accounts",
2758
+ KEYPATH_WILDCARD
2759
+ ],
2760
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlySignedAccounts"],
2761
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numReadonlyUnsignedAccounts"],
2762
+ ["transactions", KEYPATH_WILDCARD, "transaction", "message", "header", "numRequiredSignatures"],
2763
+ ["rewards", KEYPATH_WILDCARD, "commission"]
2764
+ ],
2765
+ getBlockTime: [[]],
2766
+ getClusterNodes: [
2767
+ [KEYPATH_WILDCARD, "featureSet"],
2768
+ [KEYPATH_WILDCARD, "shredVersion"]
2769
+ ],
2770
+ getInflationGovernor: [["initial"], ["foundation"], ["foundationTerm"], ["taper"], ["terminal"]],
2771
+ getInflationRate: [["foundation"], ["total"], ["validator"]],
2772
+ getInflationReward: [[KEYPATH_WILDCARD, "commission"]],
2773
+ getMultipleAccounts: jsonParsedAccountsConfigs.map((c) => ["value", KEYPATH_WILDCARD, ...c]),
2774
+ getProgramAccounts: jsonParsedAccountsConfigs.flatMap((c) => [
2775
+ ["value", KEYPATH_WILDCARD, "account", ...c],
2776
+ [KEYPATH_WILDCARD, "account", ...c]
2777
+ ]),
2778
+ getRecentPerformanceSamples: [[KEYPATH_WILDCARD, "samplePeriodSecs"]],
2779
+ getTokenAccountBalance: [
2780
+ ["value", "decimals"],
2781
+ ["value", "uiAmount"]
2782
+ ],
2783
+ getTokenAccountsByDelegate: jsonParsedTokenAccountsConfigs.map((c) => [
2784
+ "value",
2785
+ KEYPATH_WILDCARD,
2786
+ "account",
2787
+ ...c
2788
+ ]),
2789
+ getTokenAccountsByOwner: jsonParsedTokenAccountsConfigs.map((c) => [
2790
+ "value",
2791
+ KEYPATH_WILDCARD,
2792
+ "account",
2793
+ ...c
2794
+ ]),
2795
+ getTokenLargestAccounts: [
2796
+ ["value", KEYPATH_WILDCARD, "decimals"],
2797
+ ["value", KEYPATH_WILDCARD, "uiAmount"]
2798
+ ],
2799
+ getTokenSupply: [
2800
+ ["value", "decimals"],
2801
+ ["value", "uiAmount"]
2802
+ ],
2803
+ getTransaction: [
2804
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2805
+ ["meta", "preTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
2806
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
2807
+ ["meta", "postTokenBalances", KEYPATH_WILDCARD, "uiTokenAmount", "decimals"],
2808
+ ["meta", "rewards", KEYPATH_WILDCARD, "commission"],
2809
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "index"],
2810
+ ["meta", "innerInstructions", KEYPATH_WILDCARD, "instructions", KEYPATH_WILDCARD, "programIdIndex"],
2811
+ [
2812
+ "meta",
2813
+ "innerInstructions",
2814
+ KEYPATH_WILDCARD,
2815
+ "instructions",
2816
+ KEYPATH_WILDCARD,
2817
+ "accounts",
2818
+ KEYPATH_WILDCARD
2819
+ ],
2820
+ [
2821
+ "transaction",
2822
+ "message",
2823
+ "addressTableLookups",
2824
+ KEYPATH_WILDCARD,
2825
+ "writableIndexes",
2826
+ KEYPATH_WILDCARD
2827
+ ],
2828
+ [
2829
+ "transaction",
2830
+ "message",
2831
+ "addressTableLookups",
2832
+ KEYPATH_WILDCARD,
2833
+ "readonlyIndexes",
2834
+ KEYPATH_WILDCARD
2835
+ ],
2836
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "programIdIndex"],
2837
+ ["transaction", "message", "instructions", KEYPATH_WILDCARD, "accounts", KEYPATH_WILDCARD],
2838
+ ["transaction", "message", "header", "numReadonlySignedAccounts"],
2839
+ ["transaction", "message", "header", "numReadonlyUnsignedAccounts"],
2840
+ ["transaction", "message", "header", "numRequiredSignatures"]
2841
+ ],
2842
+ getVersion: [["feature-set"]],
2843
+ getVoteAccounts: [
2844
+ ["current", KEYPATH_WILDCARD, "commission"],
2845
+ ["delinquent", KEYPATH_WILDCARD, "commission"]
2846
+ ],
2847
+ simulateTransaction: jsonParsedAccountsConfigs.map((c) => ["value", "accounts", KEYPATH_WILDCARD, ...c])
2848
+ };
2849
+ }
2850
+ return memoizedResponseKeypaths;
2851
+ }
1645
2852
  function getNextAllowedKeypaths(keyPaths, property) {
1646
2853
  return keyPaths.filter((keyPath) => keyPath[0] === KEYPATH_WILDCARD && typeof property === "number" || keyPath[0] === property).map((keyPath) => keyPath.slice(1));
1647
2854
  }
@@ -1668,7 +2875,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1668
2875
  }
1669
2876
  }
1670
2877
  function patchResponseForSolanaLabsRpc(rawResponse, methodName) {
1671
- const allowedKeypaths = methodName ? ALLOWED_NUMERIC_KEYPATHS[methodName] : void 0;
2878
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForResponse()[methodName] : void 0;
2879
+ return visitNode2(rawResponse, allowedKeypaths ?? []);
2880
+ }
2881
+ function patchResponseForSolanaLabsRpcSubscriptions(rawResponse, methodName) {
2882
+ const allowedKeypaths = methodName ? getAllowedNumericKeypathsForNotification()[methodName] : void 0;
1672
2883
  return visitNode2(rawResponse, allowedKeypaths ?? []);
1673
2884
  }
1674
2885
  function createSolanaRpcApi(config) {
@@ -1681,22 +2892,52 @@ this.globalThis.solanaWeb3 = (function (exports) {
1681
2892
  },
1682
2893
  get(...args) {
1683
2894
  const [_, p] = args;
1684
- const methodName = p.toString();
2895
+ const methodName = p.toString();
2896
+ return function(...rawParams) {
2897
+ const handleIntegerOverflow = config?.onIntegerOverflow;
2898
+ const params = patchParamsForSolanaLabsRpc(
2899
+ rawParams,
2900
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
2901
+ );
2902
+ return {
2903
+ methodName,
2904
+ params,
2905
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
2906
+ };
2907
+ };
2908
+ }
2909
+ });
2910
+ }
2911
+ function createSolanaRpcSubscriptionsApi(config) {
2912
+ return new Proxy({}, {
2913
+ defineProperty() {
2914
+ return false;
2915
+ },
2916
+ deleteProperty() {
2917
+ return false;
2918
+ },
2919
+ get(...args) {
2920
+ const [_, p] = args;
2921
+ const notificationName = p.toString();
1685
2922
  return function(...rawParams) {
1686
2923
  const handleIntegerOverflow = config?.onIntegerOverflow;
1687
2924
  const params = patchParamsForSolanaLabsRpc(
1688
2925
  rawParams,
1689
- handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(methodName, keyPath, value) : void 0
2926
+ handleIntegerOverflow ? (keyPath, value) => handleIntegerOverflow(notificationName, keyPath, value) : void 0
1690
2927
  );
1691
2928
  return {
1692
- methodName,
1693
2929
  params,
1694
- responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpc(rawResponse, methodName)
2930
+ responseProcessor: (rawResponse) => patchResponseForSolanaLabsRpcSubscriptions(rawResponse, notificationName),
2931
+ subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
2932
+ unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
1695
2933
  };
1696
2934
  };
1697
2935
  }
1698
2936
  });
1699
2937
  }
2938
+ function createSolanaRpcSubscriptionsApi_UNSTABLE(config) {
2939
+ return createSolanaRpcSubscriptionsApi(config);
2940
+ }
1700
2941
 
1701
2942
  // ../rpc-transport/dist/index.browser.js
1702
2943
  init_env_shim();
@@ -1763,7 +3004,101 @@ this.globalThis.solanaWeb3 = (function (exports) {
1763
3004
  function createJsonRpc(rpcConfig) {
1764
3005
  return makeProxy(rpcConfig);
1765
3006
  }
1766
- var e = globalThis.fetch;
3007
+ function registerIterableCleanup(iterable, cleanupFn) {
3008
+ (async () => {
3009
+ try {
3010
+ for await (const _ of iterable)
3011
+ ;
3012
+ } catch {
3013
+ } finally {
3014
+ cleanupFn();
3015
+ }
3016
+ })();
3017
+ }
3018
+ function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseProcessor }) {
3019
+ return {
3020
+ async subscribe({ abortSignal }) {
3021
+ abortSignal.throwIfAborted();
3022
+ let subscriptionId;
3023
+ function handleCleanup() {
3024
+ if (subscriptionId !== void 0) {
3025
+ const payload = createJsonRpcMessage(unsubscribeMethodName, [subscriptionId]);
3026
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
3027
+ connectionAbortController.abort();
3028
+ });
3029
+ } else {
3030
+ connectionAbortController.abort();
3031
+ }
3032
+ }
3033
+ abortSignal.addEventListener("abort", handleCleanup);
3034
+ const connectionAbortController = new AbortController();
3035
+ const subscribeMessage = createJsonRpcMessage(subscribeMethodName, params);
3036
+ const connection = await rpcConfig.transport({
3037
+ payload: subscribeMessage,
3038
+ signal: connectionAbortController.signal
3039
+ });
3040
+ function handleConnectionCleanup() {
3041
+ abortSignal.removeEventListener("abort", handleCleanup);
3042
+ }
3043
+ registerIterableCleanup(connection, handleConnectionCleanup);
3044
+ for await (const message of connection) {
3045
+ if ("id" in message && message.id === subscribeMessage.id) {
3046
+ if ("error" in message) {
3047
+ throw new SolanaJsonRpcError(message.error);
3048
+ } else {
3049
+ subscriptionId = message.result;
3050
+ break;
3051
+ }
3052
+ }
3053
+ }
3054
+ if (subscriptionId == null) {
3055
+ throw new Error("Failed to obtain a subscription id from the server");
3056
+ }
3057
+ return {
3058
+ async *[Symbol.asyncIterator]() {
3059
+ for await (const message of connection) {
3060
+ if (!("params" in message) || message.params.subscription !== subscriptionId) {
3061
+ continue;
3062
+ }
3063
+ const notification = message.params.result;
3064
+ yield responseProcessor ? responseProcessor(notification) : notification;
3065
+ }
3066
+ }
3067
+ };
3068
+ }
3069
+ };
3070
+ }
3071
+ function makeProxy2(rpcConfig) {
3072
+ return new Proxy(rpcConfig.api, {
3073
+ defineProperty() {
3074
+ return false;
3075
+ },
3076
+ deleteProperty() {
3077
+ return false;
3078
+ },
3079
+ get(target, p, receiver) {
3080
+ return function(...rawParams) {
3081
+ const methodName = p.toString();
3082
+ const createRpcSubscription = Reflect.get(target, methodName, receiver);
3083
+ if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
3084
+ throw new Error(
3085
+ "Either the notification name must end in 'Notifications' or the API must supply a subscription creator function to map between the notification name and the subscribe/unsubscribe method names."
3086
+ );
3087
+ }
3088
+ const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
3089
+ params: rawParams,
3090
+ subscribeMethodName: methodName.replace(/Notifications$/, "Subscribe"),
3091
+ unsubscribeMethodName: methodName.replace(/Notifications$/, "Unsubscribe")
3092
+ };
3093
+ return createPendingRpcSubscription(rpcConfig, newRequest);
3094
+ };
3095
+ }
3096
+ });
3097
+ }
3098
+ function createJsonSubscriptionRpc(rpcConfig) {
3099
+ return makeProxy2(rpcConfig);
3100
+ }
3101
+ var e2 = globalThis.fetch;
1767
3102
  var SolanaHttpError = class extends Error {
1768
3103
  constructor(details) {
1769
3104
  super(`HTTP error (${details.statusCode}): ${details.message}`);
@@ -1851,7 +3186,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1851
3186
  method: "POST",
1852
3187
  signal
1853
3188
  };
1854
- const response = await e(url, requestInfo);
3189
+ const response = await e2(url, requestInfo);
1855
3190
  if (!response.ok) {
1856
3191
  throw new SolanaHttpError({
1857
3192
  message: response.statusText,
@@ -1861,6 +3196,175 @@ this.globalThis.solanaWeb3 = (function (exports) {
1861
3196
  return await response.json();
1862
3197
  };
1863
3198
  }
3199
+ var e22 = globalThis.WebSocket;
3200
+ var EXPLICIT_ABORT_TOKEN = Symbol(
3201
+ "This symbol is thrown from a socket's iterator when the connection is explicity aborted by the user"
3202
+ );
3203
+ async function createWebSocketConnection({
3204
+ sendBufferHighWatermark,
3205
+ signal,
3206
+ url
3207
+ }) {
3208
+ return new Promise((resolve, reject) => {
3209
+ signal.addEventListener("abort", handleAbort, { once: true });
3210
+ const iteratorState = /* @__PURE__ */ new Map();
3211
+ function errorAndClearAllIteratorStates(reason) {
3212
+ const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
3213
+ iteratorState.clear();
3214
+ errorCallbacks.forEach((cb) => {
3215
+ try {
3216
+ cb(reason);
3217
+ } catch {
3218
+ }
3219
+ });
3220
+ }
3221
+ function handleAbort() {
3222
+ errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN);
3223
+ if (webSocket.readyState !== e22.CLOSED && webSocket.readyState !== e22.CLOSING) {
3224
+ webSocket.close(1e3);
3225
+ }
3226
+ }
3227
+ function handleClose(ev) {
3228
+ bufferDrainWatcher?.onCancel();
3229
+ signal.removeEventListener("abort", handleAbort);
3230
+ webSocket.removeEventListener("close", handleClose);
3231
+ webSocket.removeEventListener("error", handleError);
3232
+ webSocket.removeEventListener("open", handleOpen);
3233
+ webSocket.removeEventListener("message", handleMessage);
3234
+ errorAndClearAllIteratorStates(ev);
3235
+ }
3236
+ function handleError(ev) {
3237
+ if (!hasConnected) {
3238
+ reject(
3239
+ // TODO: Coded error
3240
+ new Error("WebSocket failed to connect", { cause: ev })
3241
+ );
3242
+ }
3243
+ }
3244
+ let hasConnected = false;
3245
+ let bufferDrainWatcher;
3246
+ function handleOpen() {
3247
+ hasConnected = true;
3248
+ resolve({
3249
+ async send(payload) {
3250
+ const message = JSON.stringify(payload);
3251
+ if (!bufferDrainWatcher && webSocket.readyState === e22.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
3252
+ let onCancel;
3253
+ const promise = new Promise((resolve2, reject2) => {
3254
+ const intervalId = setInterval(() => {
3255
+ if (webSocket.readyState !== e22.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
3256
+ clearInterval(intervalId);
3257
+ bufferDrainWatcher = void 0;
3258
+ resolve2();
3259
+ }
3260
+ }, 16);
3261
+ onCancel = () => {
3262
+ bufferDrainWatcher = void 0;
3263
+ clearInterval(intervalId);
3264
+ reject2(
3265
+ // TODO: Coded error
3266
+ new Error("WebSocket was closed before payload could be sent")
3267
+ );
3268
+ };
3269
+ });
3270
+ bufferDrainWatcher = {
3271
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3272
+ // @ts-ignore
3273
+ onCancel,
3274
+ promise
3275
+ };
3276
+ }
3277
+ if (bufferDrainWatcher) {
3278
+ await bufferDrainWatcher.promise;
3279
+ }
3280
+ webSocket.send(message);
3281
+ },
3282
+ async *[Symbol.asyncIterator]() {
3283
+ const iteratorKey = Symbol();
3284
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
3285
+ try {
3286
+ while (true) {
3287
+ const state = iteratorState.get(iteratorKey);
3288
+ if (!state) {
3289
+ throw new Error("Invariant: WebSocket message iterator is missing state storage");
3290
+ }
3291
+ if (state.__hasPolled) {
3292
+ throw new Error(
3293
+ "Invariant: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise"
3294
+ );
3295
+ }
3296
+ const queuedMessages = state.queuedMessages;
3297
+ if (queuedMessages.length) {
3298
+ state.queuedMessages = [];
3299
+ yield* queuedMessages;
3300
+ } else {
3301
+ try {
3302
+ yield await new Promise((resolve2, reject2) => {
3303
+ iteratorState.set(iteratorKey, {
3304
+ __hasPolled: true,
3305
+ onError: reject2,
3306
+ onMessage: resolve2
3307
+ });
3308
+ });
3309
+ } catch (e3) {
3310
+ if (e3 === EXPLICIT_ABORT_TOKEN) {
3311
+ return;
3312
+ } else {
3313
+ throw new Error("WebSocket connection closed", { cause: e3 });
3314
+ }
3315
+ }
3316
+ }
3317
+ }
3318
+ } finally {
3319
+ iteratorState.delete(iteratorKey);
3320
+ }
3321
+ }
3322
+ });
3323
+ }
3324
+ function handleMessage({ data }) {
3325
+ const message = JSON.parse(data);
3326
+ iteratorState.forEach((state, iteratorKey) => {
3327
+ if (state.__hasPolled) {
3328
+ const { onMessage } = state;
3329
+ iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
3330
+ onMessage(message);
3331
+ } else {
3332
+ state.queuedMessages.push(message);
3333
+ }
3334
+ });
3335
+ }
3336
+ const webSocket = new e22(url);
3337
+ webSocket.addEventListener("close", handleClose);
3338
+ webSocket.addEventListener("error", handleError);
3339
+ webSocket.addEventListener("open", handleOpen);
3340
+ webSocket.addEventListener("message", handleMessage);
3341
+ });
3342
+ }
3343
+ function createWebSocketTransport({ sendBufferHighWatermark, url }) {
3344
+ if (/^wss?:/i.test(url) === false) {
3345
+ const protocolMatch = url.match(/^([^:]+):/);
3346
+ throw new DOMException(
3347
+ protocolMatch ? `Failed to construct 'WebSocket': The URL's scheme must be either 'ws' or 'wss'. '${protocolMatch[1]}:' is not allowed.` : `Failed to construct 'WebSocket': The URL '${url}' is invalid.`
3348
+ );
3349
+ }
3350
+ return async function sendWebSocketMessage({ payload, signal }) {
3351
+ signal?.throwIfAborted();
3352
+ const connection = await createWebSocketConnection({
3353
+ sendBufferHighWatermark,
3354
+ signal,
3355
+ url
3356
+ });
3357
+ signal?.throwIfAborted();
3358
+ await connection.send(payload);
3359
+ return {
3360
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
3361
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
3362
+ };
3363
+ };
3364
+ }
3365
+
3366
+ // src/rpc.ts
3367
+ var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
1864
3368
 
1865
3369
  // src/rpc-default-config.ts
1866
3370
  init_env_shim();
@@ -1902,6 +3406,197 @@ this.globalThis.solanaWeb3 = (function (exports) {
1902
3406
  }
1903
3407
  };
1904
3408
 
3409
+ // src/rpc-subscription-coalescer.ts
3410
+ init_env_shim();
3411
+
3412
+ // src/cached-abortable-iterable.ts
3413
+ init_env_shim();
3414
+ function registerIterableCleanup2(iterable, cleanupFn) {
3415
+ (async () => {
3416
+ try {
3417
+ for await (const _ of iterable)
3418
+ ;
3419
+ } catch {
3420
+ } finally {
3421
+ cleanupFn();
3422
+ }
3423
+ })();
3424
+ }
3425
+ function getCachedAbortableIterableFactory({
3426
+ getAbortSignalFromInputArgs,
3427
+ getCacheEntryMissingError,
3428
+ getCacheKeyFromInputArgs,
3429
+ onCacheHit,
3430
+ onCreateIterable
3431
+ }) {
3432
+ const cache = /* @__PURE__ */ new Map();
3433
+ function getCacheEntryOrThrow(cacheKey) {
3434
+ const currentCacheEntry = cache.get(cacheKey);
3435
+ if (!currentCacheEntry) {
3436
+ throw getCacheEntryMissingError(cacheKey);
3437
+ }
3438
+ return currentCacheEntry;
3439
+ }
3440
+ return async (...args) => {
3441
+ const cacheKey = getCacheKeyFromInputArgs(...args);
3442
+ const signal = getAbortSignalFromInputArgs(...args);
3443
+ if (cacheKey === void 0) {
3444
+ return await onCreateIterable(signal, ...args);
3445
+ }
3446
+ const cleanup = () => {
3447
+ cache.delete(cacheKey);
3448
+ signal.removeEventListener("abort", handleAbort);
3449
+ };
3450
+ const handleAbort = () => {
3451
+ const cacheEntry = getCacheEntryOrThrow(cacheKey);
3452
+ if (cacheEntry.purgeScheduled !== true) {
3453
+ cacheEntry.purgeScheduled = true;
3454
+ globalThis.queueMicrotask(() => {
3455
+ cacheEntry.purgeScheduled = false;
3456
+ if (cacheEntry.referenceCount === 0) {
3457
+ cacheEntry.abortController.abort();
3458
+ cleanup();
3459
+ }
3460
+ });
3461
+ }
3462
+ cacheEntry.referenceCount--;
3463
+ };
3464
+ signal.addEventListener("abort", handleAbort);
3465
+ try {
3466
+ const cacheEntry = cache.get(cacheKey);
3467
+ if (!cacheEntry) {
3468
+ const singletonAbortController = new AbortController();
3469
+ const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
3470
+ const newCacheEntry = {
3471
+ abortController: singletonAbortController,
3472
+ iterable: newIterablePromise,
3473
+ purgeScheduled: false,
3474
+ referenceCount: 1
3475
+ };
3476
+ cache.set(cacheKey, newCacheEntry);
3477
+ const newIterable = await newIterablePromise;
3478
+ registerIterableCleanup2(newIterable, cleanup);
3479
+ newCacheEntry.iterable = newIterable;
3480
+ return newIterable;
3481
+ } else {
3482
+ cacheEntry.referenceCount++;
3483
+ const iterableOrIterablePromise = cacheEntry.iterable;
3484
+ const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
3485
+ await onCacheHit(cachedIterable, ...args);
3486
+ return cachedIterable;
3487
+ }
3488
+ } catch (e3) {
3489
+ cleanup();
3490
+ throw e3;
3491
+ }
3492
+ };
3493
+ }
3494
+
3495
+ // src/rpc-subscription-coalescer.ts
3496
+ var EXPLICIT_ABORT_TOKEN2 = Symbol(
3497
+ "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
3498
+ );
3499
+ function registerIterableCleanup3(iterable, cleanupFn) {
3500
+ (async () => {
3501
+ try {
3502
+ for await (const _ of iterable)
3503
+ ;
3504
+ } catch {
3505
+ } finally {
3506
+ cleanupFn();
3507
+ }
3508
+ })();
3509
+ }
3510
+ function getRpcSubscriptionsWithSubscriptionCoalescing({
3511
+ getDeduplicationKey,
3512
+ rpcSubscriptions
3513
+ }) {
3514
+ const cache = /* @__PURE__ */ new Map();
3515
+ return new Proxy(rpcSubscriptions, {
3516
+ defineProperty() {
3517
+ return false;
3518
+ },
3519
+ deleteProperty() {
3520
+ return false;
3521
+ },
3522
+ get(target, p, receiver) {
3523
+ const subscriptionMethod = Reflect.get(target, p, receiver);
3524
+ if (typeof subscriptionMethod !== "function") {
3525
+ return subscriptionMethod;
3526
+ }
3527
+ return function(...rawParams) {
3528
+ const deduplicationKey = getDeduplicationKey(p, rawParams);
3529
+ if (deduplicationKey === void 0) {
3530
+ return subscriptionMethod(...rawParams);
3531
+ }
3532
+ if (cache.has(deduplicationKey)) {
3533
+ return cache.get(deduplicationKey);
3534
+ }
3535
+ const iterableFactory = getCachedAbortableIterableFactory({
3536
+ getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
3537
+ getCacheEntryMissingError(deduplicationKey2) {
3538
+ return new Error(
3539
+ `Found no cache entry for subscription with deduplication key \`${deduplicationKey2?.toString()}\``
3540
+ );
3541
+ },
3542
+ getCacheKeyFromInputArgs: () => deduplicationKey,
3543
+ async onCacheHit(_iterable, _config) {
3544
+ },
3545
+ async onCreateIterable(abortSignal, config) {
3546
+ const pendingSubscription2 = subscriptionMethod(
3547
+ ...rawParams
3548
+ );
3549
+ const iterable = await pendingSubscription2.subscribe({
3550
+ ...config,
3551
+ abortSignal
3552
+ });
3553
+ registerIterableCleanup3(iterable, () => {
3554
+ cache.delete(deduplicationKey);
3555
+ });
3556
+ return iterable;
3557
+ }
3558
+ });
3559
+ const pendingSubscription = {
3560
+ async subscribe(...args) {
3561
+ const iterable = await iterableFactory(...args);
3562
+ const { abortSignal } = args[0];
3563
+ let abortPromise;
3564
+ return {
3565
+ ...iterable,
3566
+ async *[Symbol.asyncIterator]() {
3567
+ abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN2) : new Promise((_, reject) => {
3568
+ abortSignal.addEventListener("abort", () => {
3569
+ reject(EXPLICIT_ABORT_TOKEN2);
3570
+ });
3571
+ }));
3572
+ try {
3573
+ const iterator = iterable[Symbol.asyncIterator]();
3574
+ while (true) {
3575
+ const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
3576
+ if (iteratorResult.done) {
3577
+ return;
3578
+ } else {
3579
+ yield iteratorResult.value;
3580
+ }
3581
+ }
3582
+ } catch (e3) {
3583
+ if (e3 === EXPLICIT_ABORT_TOKEN2) {
3584
+ return;
3585
+ }
3586
+ cache.delete(deduplicationKey);
3587
+ throw e3;
3588
+ }
3589
+ }
3590
+ };
3591
+ }
3592
+ };
3593
+ cache.set(deduplicationKey, pendingSubscription);
3594
+ return pendingSubscription;
3595
+ };
3596
+ }
3597
+ });
3598
+ }
3599
+
1905
3600
  // src/rpc.ts
1906
3601
  function createSolanaRpc(config) {
1907
3602
  return createJsonRpc({
@@ -1909,6 +3604,24 @@ this.globalThis.solanaWeb3 = (function (exports) {
1909
3604
  api: createSolanaRpcApi(DEFAULT_RPC_CONFIG)
1910
3605
  });
1911
3606
  }
3607
+ function createSolanaRpcSubscriptions(config) {
3608
+ return pipe(
3609
+ createJsonSubscriptionRpc({
3610
+ ...config,
3611
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_CONFIG)
3612
+ }),
3613
+ (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
3614
+ getDeduplicationKey: (...args) => (0, import_fast_stable_stringify.default)(args),
3615
+ rpcSubscriptions
3616
+ })
3617
+ );
3618
+ }
3619
+ function createSolanaRpcSubscriptions_UNSTABLE(config) {
3620
+ return createJsonSubscriptionRpc({
3621
+ ...config,
3622
+ api: createSolanaRpcSubscriptionsApi_UNSTABLE(DEFAULT_RPC_CONFIG)
3623
+ });
3624
+ }
1912
3625
 
1913
3626
  // src/rpc-transport.ts
1914
3627
  init_env_shim();
@@ -1945,14 +3658,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
1945
3658
  if (signal) {
1946
3659
  const responsePromise = coalescedRequest.responsePromise;
1947
3660
  return await new Promise((resolve, reject) => {
1948
- const handleAbort = (e2) => {
3661
+ const handleAbort = (e3) => {
1949
3662
  signal.removeEventListener("abort", handleAbort);
1950
3663
  coalescedRequest.numConsumers -= 1;
1951
3664
  if (coalescedRequest.numConsumers === 0) {
1952
3665
  const abortController = coalescedRequest.abortController;
1953
3666
  abortController.abort();
1954
3667
  }
1955
- const abortError = new DOMException(e2.target.reason, "AbortError");
3668
+ const abortError = new DOMException(e3.target.reason, "AbortError");
1956
3669
  reject(abortError);
1957
3670
  };
1958
3671
  signal.addEventListener("abort", handleAbort);
@@ -1968,14 +3681,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
1968
3681
 
1969
3682
  // src/rpc-request-deduplication.ts
1970
3683
  init_env_shim();
1971
- var import_fast_stable_stringify = __toESM(require_fast_stable_stringify(), 1);
1972
- function getSolanaRpcPayloadDeduplicationKey(payload) {
3684
+ var import_fast_stable_stringify2 = __toESM(require_fast_stable_stringify(), 1);
3685
+ function isJsonRpcPayload(payload) {
1973
3686
  if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
1974
- return;
1975
- }
1976
- if ("jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && "params" in payload) {
1977
- return (0, import_fast_stable_stringify.default)([payload.method, payload.params]);
3687
+ return false;
1978
3688
  }
3689
+ return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
3690
+ }
3691
+ function getSolanaRpcPayloadDeduplicationKey(payload) {
3692
+ return isJsonRpcPayload(payload) ? (0, import_fast_stable_stringify2.default)([payload.method, payload.params]) : void 0;
1979
3693
  }
1980
3694
 
1981
3695
  // src/rpc-transport.ts
@@ -1987,7 +3701,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1987
3701
  return out;
1988
3702
  }
1989
3703
  function createDefaultRpcTransport(config) {
1990
- return getRpcTransportWithRequestCoalescing(
3704
+ return pipe(
1991
3705
  createHttpTransport({
1992
3706
  ...config,
1993
3707
  headers: {
@@ -1998,37 +3712,466 @@ this.globalThis.solanaWeb3 = (function (exports) {
1998
3712
  }
1999
3713
  }
2000
3714
  }),
2001
- getSolanaRpcPayloadDeduplicationKey
3715
+ (transport) => getRpcTransportWithRequestCoalescing(transport, getSolanaRpcPayloadDeduplicationKey)
3716
+ );
3717
+ }
3718
+
3719
+ // src/rpc-websocket-transport.ts
3720
+ init_env_shim();
3721
+
3722
+ // src/rpc-websocket-autopinger.ts
3723
+ init_env_shim();
3724
+ var PING_PAYLOAD = {
3725
+ jsonrpc: "2.0",
3726
+ method: "ping"
3727
+ };
3728
+ function getWebSocketTransportWithAutoping({ intervalMs, transport }) {
3729
+ const pingableConnections = /* @__PURE__ */ new Map();
3730
+ return async (...args) => {
3731
+ const connection = await transport(...args);
3732
+ let intervalId;
3733
+ function sendPing() {
3734
+ connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
3735
+ }
3736
+ function restartPingTimer() {
3737
+ clearInterval(intervalId);
3738
+ intervalId = setInterval(sendPing, intervalMs);
3739
+ }
3740
+ if (pingableConnections.has(connection) === false) {
3741
+ pingableConnections.set(connection, {
3742
+ [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
3743
+ send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
3744
+ restartPingTimer();
3745
+ return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
3746
+ }
3747
+ });
3748
+ (async () => {
3749
+ try {
3750
+ for await (const _ of connection) {
3751
+ restartPingTimer();
3752
+ }
3753
+ } catch {
3754
+ } finally {
3755
+ pingableConnections.delete(connection);
3756
+ clearInterval(intervalId);
3757
+ if (handleOffline) {
3758
+ globalThis.window.removeEventListener("offline", handleOffline);
3759
+ }
3760
+ if (handleOnline) {
3761
+ globalThis.window.removeEventListener("online", handleOnline);
3762
+ }
3763
+ }
3764
+ })();
3765
+ if (globalThis.navigator.onLine) {
3766
+ restartPingTimer();
3767
+ }
3768
+ let handleOffline;
3769
+ let handleOnline;
3770
+ {
3771
+ handleOffline = () => {
3772
+ clearInterval(intervalId);
3773
+ };
3774
+ handleOnline = () => {
3775
+ sendPing();
3776
+ restartPingTimer();
3777
+ };
3778
+ globalThis.window.addEventListener("offline", handleOffline);
3779
+ globalThis.window.addEventListener("online", handleOnline);
3780
+ }
3781
+ }
3782
+ return pingableConnections.get(connection);
3783
+ };
3784
+ }
3785
+
3786
+ // src/rpc-websocket-connection-sharding.ts
3787
+ init_env_shim();
3788
+ var NULL_SHARD_CACHE_KEY = Symbol(
3789
+ "Cache key to use when there is no connection sharding strategy"
3790
+ );
3791
+ function getWebSocketTransportWithConnectionSharding({ getShard, transport }) {
3792
+ return getCachedAbortableIterableFactory({
3793
+ getAbortSignalFromInputArgs: ({ signal }) => signal,
3794
+ getCacheEntryMissingError(shardKey) {
3795
+ return new Error(`Found no cache entry for connection with shard key \`${shardKey?.toString()}\``);
3796
+ },
3797
+ getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY,
3798
+ onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
3799
+ onCreateIterable: (abortSignal, config) => transport({
3800
+ ...config,
3801
+ signal: abortSignal
3802
+ })
3803
+ });
3804
+ }
3805
+
3806
+ // src/rpc-websocket-transport.ts
3807
+ function createDefaultRpcSubscriptionsTransport(config) {
3808
+ const { getShard, intervalMs, ...rest } = config;
3809
+ return pipe(
3810
+ createWebSocketTransport({
3811
+ ...rest,
3812
+ sendBufferHighWatermark: config.sendBufferHighWatermark ?? // Let 128KB of data into the WebSocket buffer before buffering it in the app.
3813
+ 131072
3814
+ }),
3815
+ (transport) => getWebSocketTransportWithAutoping({
3816
+ intervalMs: intervalMs ?? 5e3,
3817
+ transport
3818
+ }),
3819
+ (transport) => getWebSocketTransportWithConnectionSharding({
3820
+ getShard,
3821
+ transport
3822
+ })
3823
+ );
3824
+ }
3825
+
3826
+ // src/send-transaction.ts
3827
+ init_env_shim();
3828
+
3829
+ // src/transaction-confirmation.ts
3830
+ init_env_shim();
3831
+
3832
+ // src/transaction-confirmation-strategy-blockheight.ts
3833
+ init_env_shim();
3834
+ function createBlockHeightExceedencePromiseFactory(rpcSubscriptions) {
3835
+ return async function getBlockHeightExceedencePromise({ abortSignal: callerAbortSignal, lastValidBlockHeight }) {
3836
+ const abortController = new AbortController();
3837
+ function handleAbort() {
3838
+ abortController.abort();
3839
+ }
3840
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3841
+ const slotNotifications = await rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal });
3842
+ try {
3843
+ for await (const slotNotification of slotNotifications) {
3844
+ if (slotNotification.slot > lastValidBlockHeight) {
3845
+ throw new Error(
3846
+ "The network has progressed past the last block for which this transaction could have committed."
3847
+ );
3848
+ }
3849
+ }
3850
+ } finally {
3851
+ abortController.abort();
3852
+ }
3853
+ };
3854
+ }
3855
+
3856
+ // src/transaction-confirmation-strategy-nonce.ts
3857
+ init_env_shim();
3858
+ var NONCE_VALUE_OFFSET = 4 + // version(u32)
3859
+ 4 + // state(u32)
3860
+ 32;
3861
+ function createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions) {
3862
+ return async function getNonceInvalidationPromise({
3863
+ abortSignal: callerAbortSignal,
3864
+ commitment,
3865
+ currentNonceValue,
3866
+ nonceAccountAddress
3867
+ }) {
3868
+ const abortController = new AbortController();
3869
+ function handleAbort() {
3870
+ abortController.abort();
3871
+ }
3872
+ callerAbortSignal.addEventListener("abort", handleAbort, { signal: abortController.signal });
3873
+ const accountNotifications = await rpcSubscriptions.accountNotifications(nonceAccountAddress, { commitment, encoding: "base64" }).subscribe({ abortSignal: abortController.signal });
3874
+ const base58Decoder2 = getBase58Decoder();
3875
+ const base64Encoder = getBase64Encoder();
3876
+ function getNonceFromAccountData([base64EncodedBytes]) {
3877
+ const data = base64Encoder.encode(base64EncodedBytes);
3878
+ const nonceValueBytes = data.slice(NONCE_VALUE_OFFSET, NONCE_VALUE_OFFSET + 32);
3879
+ return base58Decoder2.decode(nonceValueBytes)[0];
3880
+ }
3881
+ const nonceAccountDidAdvancePromise = (async () => {
3882
+ for await (const accountNotification of accountNotifications) {
3883
+ const nonceValue = getNonceFromAccountData(accountNotification.value.data);
3884
+ if (nonceValue !== currentNonceValue) {
3885
+ throw new Error(
3886
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3887
+ );
3888
+ }
3889
+ }
3890
+ })();
3891
+ const nonceIsAlreadyInvalidPromise = (async () => {
3892
+ const { value: nonceAccount } = await rpc.getAccountInfo(nonceAccountAddress, {
3893
+ commitment,
3894
+ dataSlice: { length: 32, offset: NONCE_VALUE_OFFSET },
3895
+ encoding: "base58"
3896
+ }).send({ abortSignal: abortController.signal });
3897
+ if (!nonceAccount) {
3898
+ throw new Error(`No nonce account could be found at address \`${nonceAccountAddress}\`.`);
3899
+ }
3900
+ const nonceValue = (
3901
+ // This works because we asked for the exact slice of data representing the nonce
3902
+ // value, and furthermore asked for it in `base58` encoding.
3903
+ nonceAccount.data[0]
3904
+ );
3905
+ if (nonceValue !== currentNonceValue) {
3906
+ throw new Error(
3907
+ `The nonce \`${currentNonceValue}\` is no longer valid. It has advanced to \`${nonceValue}\`.`
3908
+ );
3909
+ } else {
3910
+ await new Promise(() => {
3911
+ });
3912
+ }
3913
+ })();
3914
+ try {
3915
+ return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
3916
+ } finally {
3917
+ abortController.abort();
3918
+ }
3919
+ };
3920
+ }
3921
+
3922
+ // src/transaction-confirmation.ts
3923
+ function createDefaultDurableNonceTransactionConfirmer({
3924
+ rpc,
3925
+ rpcSubscriptions
3926
+ }) {
3927
+ const getNonceInvalidationPromise = createNonceInvalidationPromiseFactory(rpc, rpcSubscriptions);
3928
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3929
+ rpc,
3930
+ rpcSubscriptions
3931
+ );
3932
+ return async function confirmDurableNonceTransaction(config) {
3933
+ await waitForDurableNonceTransactionConfirmation({
3934
+ ...config,
3935
+ getNonceInvalidationPromise,
3936
+ getRecentSignatureConfirmationPromise
3937
+ });
3938
+ };
3939
+ }
3940
+ function createDefaultRecentTransactionConfirmer({
3941
+ rpc,
3942
+ rpcSubscriptions
3943
+ }) {
3944
+ const getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory(rpcSubscriptions);
3945
+ const getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory(
3946
+ rpc,
3947
+ rpcSubscriptions
3948
+ );
3949
+ return async function confirmRecentTransaction(config) {
3950
+ await waitForRecentTransactionConfirmation({
3951
+ ...config,
3952
+ getBlockHeightExceedencePromise,
3953
+ getRecentSignatureConfirmationPromise
3954
+ });
3955
+ };
3956
+ }
3957
+ async function waitForDurableNonceTransactionConfirmation(config) {
3958
+ await raceStrategies(
3959
+ getSignatureFromTransaction(config.transaction),
3960
+ config,
3961
+ function getSpecificStrategiesForRace({ abortSignal, commitment, getNonceInvalidationPromise, transaction }) {
3962
+ return [
3963
+ getNonceInvalidationPromise({
3964
+ abortSignal,
3965
+ commitment,
3966
+ currentNonceValue: transaction.lifetimeConstraint.nonce,
3967
+ nonceAccountAddress: transaction.instructions[0].accounts[0].address
3968
+ })
3969
+ ];
3970
+ }
2002
3971
  );
2003
3972
  }
3973
+ async function waitForRecentTransactionConfirmation(config) {
3974
+ await raceStrategies(
3975
+ getSignatureFromTransaction(config.transaction),
3976
+ config,
3977
+ function getSpecificStrategiesForRace({ abortSignal, getBlockHeightExceedencePromise, transaction }) {
3978
+ return [
3979
+ getBlockHeightExceedencePromise({
3980
+ abortSignal,
3981
+ lastValidBlockHeight: transaction.lifetimeConstraint.lastValidBlockHeight
3982
+ })
3983
+ ];
3984
+ }
3985
+ );
3986
+ }
3987
+
3988
+ // src/send-transaction.ts
3989
+ function getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, config) {
3990
+ if (
3991
+ // The developer has supplied no value for `preflightCommitment`.
3992
+ !config?.preflightCommitment && // The value of `commitment` is lower than the server default of `preflightCommitment`.
3993
+ commitmentComparator(
3994
+ commitment,
3995
+ "finalized"
3996
+ /* default value of `preflightCommitment` */
3997
+ ) < 0
3998
+ ) {
3999
+ return {
4000
+ ...config,
4001
+ // In the common case, it is unlikely that you want to simulate a transaction at
4002
+ // `finalized` commitment when your standard of commitment for confirming the
4003
+ // transaction is lower. Cap the simulation commitment level to the level of the
4004
+ // confirmation commitment.
4005
+ preflightCommitment: commitment
4006
+ };
4007
+ }
4008
+ return config;
4009
+ }
4010
+ async function sendTransaction_INTERNAL({
4011
+ abortSignal,
4012
+ commitment,
4013
+ rpc,
4014
+ transaction,
4015
+ ...sendTransactionConfig
4016
+ }) {
4017
+ const base64EncodedWireTransaction = getBase64EncodedWireTransaction(transaction);
4018
+ return await rpc.sendTransaction(base64EncodedWireTransaction, {
4019
+ ...getSendTransactionConfigWithAdjustedPreflightCommitment(commitment, sendTransactionConfig),
4020
+ encoding: "base64"
4021
+ }).send({ abortSignal });
4022
+ }
4023
+ function createDefaultDurableNonceTransactionSender({
4024
+ rpc,
4025
+ rpcSubscriptions
4026
+ }) {
4027
+ const confirmDurableNonceTransaction = createDefaultDurableNonceTransactionConfirmer({
4028
+ rpc,
4029
+ rpcSubscriptions
4030
+ });
4031
+ return async function sendDurableNonceTransaction(transaction, config) {
4032
+ await sendAndConfirmDurableNonceTransaction({
4033
+ ...config,
4034
+ confirmDurableNonceTransaction,
4035
+ rpc,
4036
+ transaction
4037
+ });
4038
+ };
4039
+ }
4040
+ function createDefaultTransactionSender({
4041
+ rpc,
4042
+ rpcSubscriptions
4043
+ }) {
4044
+ const confirmRecentTransaction = createDefaultRecentTransactionConfirmer({
4045
+ rpc,
4046
+ rpcSubscriptions
4047
+ });
4048
+ return async function sendTransaction(transaction, config) {
4049
+ await sendAndConfirmTransaction({
4050
+ ...config,
4051
+ confirmRecentTransaction,
4052
+ rpc,
4053
+ transaction
4054
+ });
4055
+ };
4056
+ }
4057
+ async function sendAndConfirmDurableNonceTransaction({
4058
+ abortSignal,
4059
+ commitment,
4060
+ confirmDurableNonceTransaction,
4061
+ rpc,
4062
+ transaction,
4063
+ ...sendTransactionConfig
4064
+ }) {
4065
+ const transactionSignature2 = await sendTransaction_INTERNAL({
4066
+ ...sendTransactionConfig,
4067
+ abortSignal,
4068
+ commitment,
4069
+ rpc,
4070
+ transaction
4071
+ });
4072
+ await confirmDurableNonceTransaction({
4073
+ abortSignal,
4074
+ commitment,
4075
+ transaction
4076
+ });
4077
+ return transactionSignature2;
4078
+ }
4079
+ async function sendAndConfirmTransaction({
4080
+ abortSignal,
4081
+ commitment,
4082
+ confirmRecentTransaction,
4083
+ rpc,
4084
+ transaction,
4085
+ ...sendTransactionConfig
4086
+ }) {
4087
+ const transactionSignature2 = await sendTransaction_INTERNAL({
4088
+ ...sendTransactionConfig,
4089
+ abortSignal,
4090
+ commitment,
4091
+ rpc,
4092
+ transaction
4093
+ });
4094
+ await confirmRecentTransaction({
4095
+ abortSignal,
4096
+ commitment,
4097
+ transaction
4098
+ });
4099
+ return transactionSignature2;
4100
+ }
2004
4101
 
2005
4102
  exports.AccountRole = AccountRole;
4103
+ exports.address = address;
2006
4104
  exports.appendTransactionInstruction = appendTransactionInstruction;
2007
- exports.assertIsBase58EncodedAddress = assertIsBase58EncodedAddress;
4105
+ exports.assertIsAddress = assertIsAddress;
2008
4106
  exports.assertIsBlockhash = assertIsBlockhash;
2009
4107
  exports.assertIsDurableNonceTransaction = assertIsDurableNonceTransaction;
4108
+ exports.assertIsLamports = assertIsLamports;
4109
+ exports.assertIsProgramDerivedAddress = assertIsProgramDerivedAddress;
4110
+ exports.assertIsStringifiedBigInt = assertIsStringifiedBigInt;
4111
+ exports.assertIsStringifiedNumber = assertIsStringifiedNumber;
4112
+ exports.assertIsTransactionSignature = assertIsTransactionSignature;
4113
+ exports.assertIsUnixTimestamp = assertIsUnixTimestamp;
4114
+ exports.assertTransactionIsFullySigned = assertTransactionIsFullySigned;
4115
+ exports.commitmentComparator = commitmentComparator;
4116
+ exports.createAddressWithSeed = createAddressWithSeed;
4117
+ exports.createBlockHeightExceedencePromiseFactory = createBlockHeightExceedencePromiseFactory;
4118
+ exports.createDefaultAirdropRequester = createDefaultAirdropRequester;
4119
+ exports.createDefaultDurableNonceTransactionConfirmer = createDefaultDurableNonceTransactionConfirmer;
4120
+ exports.createDefaultDurableNonceTransactionSender = createDefaultDurableNonceTransactionSender;
4121
+ exports.createDefaultRecentTransactionConfirmer = createDefaultRecentTransactionConfirmer;
4122
+ exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
2010
4123
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
4124
+ exports.createDefaultTransactionSender = createDefaultTransactionSender;
4125
+ exports.createNonceInvalidationPromiseFactory = createNonceInvalidationPromiseFactory;
4126
+ exports.createRecentSignatureConfirmationPromiseFactory = createRecentSignatureConfirmationPromiseFactory;
2011
4127
  exports.createSolanaRpc = createSolanaRpc;
4128
+ exports.createSolanaRpcSubscriptions = createSolanaRpcSubscriptions;
4129
+ exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
2012
4130
  exports.createTransaction = createTransaction;
2013
4131
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
2014
4132
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
2015
4133
  exports.generateKeyPair = generateKeyPair;
2016
- exports.getBase58EncodedAddressCodec = getBase58EncodedAddressCodec;
2017
- exports.getBase58EncodedAddressComparator = getBase58EncodedAddressComparator;
2018
- exports.getBase58EncodedAddressFromPublicKey = getBase58EncodedAddressFromPublicKey;
4134
+ exports.getAddressCodec = getAddressCodec;
4135
+ exports.getAddressComparator = getAddressComparator;
4136
+ exports.getAddressDecoder = getAddressDecoder;
4137
+ exports.getAddressEncoder = getAddressEncoder;
4138
+ exports.getAddressFromPublicKey = getAddressFromPublicKey;
2019
4139
  exports.getBase64EncodedWireTransaction = getBase64EncodedWireTransaction;
4140
+ exports.getProgramDerivedAddress = getProgramDerivedAddress;
4141
+ exports.getSignatureFromTransaction = getSignatureFromTransaction;
4142
+ exports.getTransactionCodec = getTransactionCodec;
4143
+ exports.getTransactionDecoder = getTransactionDecoder;
4144
+ exports.getTransactionEncoder = getTransactionEncoder;
4145
+ exports.isAddress = isAddress;
4146
+ exports.isAdvanceNonceAccountInstruction = isAdvanceNonceAccountInstruction;
4147
+ exports.isLamports = isLamports;
4148
+ exports.isProgramDerivedAddress = isProgramDerivedAddress;
2020
4149
  exports.isSignerRole = isSignerRole;
4150
+ exports.isStringifiedBigInt = isStringifiedBigInt;
4151
+ exports.isStringifiedNumber = isStringifiedNumber;
4152
+ exports.isTransactionSignature = isTransactionSignature;
4153
+ exports.isUnixTimestamp = isUnixTimestamp;
2021
4154
  exports.isWritableRole = isWritableRole;
4155
+ exports.lamports = lamports;
2022
4156
  exports.mergeRoles = mergeRoles;
2023
4157
  exports.prependTransactionInstruction = prependTransactionInstruction;
4158
+ exports.requestAndConfirmAirdrop = requestAndConfirmAirdrop;
4159
+ exports.sendAndConfirmDurableNonceTransaction = sendAndConfirmDurableNonceTransaction;
4160
+ exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
2024
4161
  exports.setTransactionFeePayer = setTransactionFeePayer;
2025
4162
  exports.setTransactionLifetimeUsingBlockhash = setTransactionLifetimeUsingBlockhash;
2026
4163
  exports.setTransactionLifetimeUsingDurableNonce = setTransactionLifetimeUsingDurableNonce;
2027
4164
  exports.signBytes = signBytes;
2028
4165
  exports.signTransaction = signTransaction;
4166
+ exports.stringifiedBigInt = stringifiedBigInt;
4167
+ exports.stringifiedNumber = stringifiedNumber;
4168
+ exports.transactionSignature = transactionSignature;
4169
+ exports.unixTimestamp = unixTimestamp;
2029
4170
  exports.upgradeRoleToSigner = upgradeRoleToSigner;
2030
4171
  exports.upgradeRoleToWritable = upgradeRoleToWritable;
2031
4172
  exports.verifySignature = verifySignature;
4173
+ exports.waitForDurableNonceTransactionConfirmation = waitForDurableNonceTransactionConfirmation;
4174
+ exports.waitForRecentTransactionConfirmation = waitForRecentTransactionConfirmation;
2032
4175
 
2033
4176
  return exports;
2034
4177