@solana/web3.js 2.0.0-rc.0 → 2.0.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -60,6 +60,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
60
60
  var SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED = 3610004;
61
61
  var SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED = 3610005;
62
62
  var SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED = 3610006;
63
+ var SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = 3610007;
63
64
  var SOLANA_ERROR__CRYPTO__RANDOM_VALUES_FUNCTION_UNIMPLEMENTED = 3611e3;
64
65
  var SOLANA_ERROR__KEYS__INVALID_KEY_PAIR_BYTE_LENGTH = 3704e3;
65
66
  var SOLANA_ERROR__KEYS__INVALID_PRIVATE_KEY_BYTE_LENGTH = 3704001;
@@ -155,6 +156,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
155
156
  var SOLANA_ERROR__TRANSACTION__CANNOT_ENCODE_WITH_EMPTY_SIGNATURES = 5663016;
156
157
  var SOLANA_ERROR__TRANSACTION__MESSAGE_SIGNATURES_MISMATCH = 5663017;
157
158
  var SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = 5663018;
159
+ var SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = 5663019;
158
160
  var SOLANA_ERROR__TRANSACTION_ERROR__UNKNOWN = 705e4;
159
161
  var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE = 7050001;
160
162
  var SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE = 7050002;
@@ -218,15 +220,17 @@ this.globalThis.solanaWeb3 = (function (exports) {
218
220
  var SOLANA_ERROR__RPC__INTEGER_OVERFLOW = 81e5;
219
221
  var SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = 8100001;
220
222
  var SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = 8100002;
221
- var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST = 819e4;
223
+ var SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = 8100003;
224
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = 819e4;
222
225
  var SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = 8190001;
223
- var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
224
- var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED = 8190003;
225
- var SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT = 8190004;
226
- var SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING = 99e5;
227
- var SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
226
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = 8190002;
227
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = 8190003;
228
+ var SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = 8190004;
229
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = 99e5;
230
+ var SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = 9900001;
228
231
  var SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = 9900002;
229
232
  var SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = 9900003;
233
+ var SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = 9900004;
230
234
  var SolanaErrorMessages = {
231
235
  [SOLANA_ERROR__ACCOUNTS__ACCOUNT_NOT_FOUND]: "Account not found at address: $address",
232
236
  [SOLANA_ERROR__ACCOUNTS__EXPECTED_ALL_ACCOUNTS_TO_BE_DECODED]: "Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",
@@ -331,9 +335,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
331
335
  [SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH]: "Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",
332
336
  [SOLANA_ERROR__INVALID_NONCE]: "The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",
333
337
  [SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING]: "Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
338
+ [SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED]: "Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",
339
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
340
+ [SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
334
341
  [SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE]: "Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
335
- [SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE]: "Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
336
- [SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING]: "Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",
337
342
  [SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR]: "JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",
338
343
  [SOLANA_ERROR__JSON_RPC__INVALID_PARAMS]: "JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",
339
344
  [SOLANA_ERROR__JSON_RPC__INVALID_REQUEST]: "JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",
@@ -364,11 +369,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
364
369
  [SOLANA_ERROR__MALFORMED_BIGINT_STRING]: "`$value` cannot be parsed as a `BigInt`",
365
370
  [SOLANA_ERROR__MALFORMED_NUMBER_STRING]: "`$value` cannot be parsed as a `Number`",
366
371
  [SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND]: "No nonce account could be found at address `$nonceAccountAddress`",
367
- [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST]: "Either the notification name must end in 'Notifications' or the API must supply a subscription creator function for the notification '$notificationName' to map between the notification name and the subscribe/unsubscribe method names.",
372
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN]: "The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",
373
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
374
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED]: "WebSocket connection closed",
375
+ [SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT]: "WebSocket failed to connect",
368
376
  [SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID]: "Failed to obtain a subscription id from the server",
369
- [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED]: "WebSocket was closed before payload could be added to the send buffer",
370
- [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED]: "WebSocket connection closed",
371
- [SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT]: "WebSocket failed to connect",
377
+ [SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD]: "Could not find an API plan for RPC method: `$method`",
372
378
  [SOLANA_ERROR__RPC__INTEGER_OVERFLOW]: "The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",
373
379
  [SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR]: "HTTP error ($statusCode): $message",
374
380
  [SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN]: "HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",
@@ -384,6 +390,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
384
390
  [SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS]: "More than one `TransactionSendingSigner` was identified.",
385
391
  [SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING]: "No `TransactionSendingSigner` was identified. Please provide a valid `ITransactionWithSingleSendingSigner` transaction.",
386
392
  [SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED]: "Wallet account signers do not support signing multiple messages/transactions in a single operation",
393
+ [SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY]: "Cannot export a non-extractable key.",
387
394
  [SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED]: "No digest implementation could be found.",
388
395
  [SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT]: "Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",
389
396
  [SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED]: "This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",
@@ -391,7 +398,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
391
398
  [SOLANA_ERROR__SUBTLE_CRYPTO__GENERATE_FUNCTION_UNIMPLEMENTED]: "No key generation implementation could be found.",
392
399
  [SOLANA_ERROR__SUBTLE_CRYPTO__SIGN_FUNCTION_UNIMPLEMENTED]: "No signing implementation could be found.",
393
400
  [SOLANA_ERROR__SUBTLE_CRYPTO__VERIFY_FUNCTION_UNIMPLEMENTED]: "No key export implementation could be found.",
394
- [SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-8.64e15, 8.64e15]. `$value` given",
401
+ [SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE]: "Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",
395
402
  [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_BORROW_OUTSTANDING]: "Transaction processing left an account with an outstanding borrowed reference",
396
403
  [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_IN_USE]: "Account in use",
397
404
  [SOLANA_ERROR__TRANSACTION_ERROR__ACCOUNT_LOADED_TWICE]: "Account loaded twice",
@@ -439,6 +446,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
439
446
  [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING]: "No fee payer set in CompiledTransaction",
440
447
  [SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND]: "Could not find program address at index $index",
441
448
  [SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT]: "Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",
449
+ [SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT]: "Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",
442
450
  [SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING]: "Transaction is missing a fee payer.",
443
451
  [SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING]: "Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",
444
452
  [SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE]: "Transaction first instruction is not advance nonce account instruction.",
@@ -1415,7 +1423,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1415
1423
  getSizeFromValue: (value) => {
1416
1424
  try {
1417
1425
  return atob(value).length;
1418
- } catch (e22) {
1426
+ } catch {
1419
1427
  throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
1420
1428
  alphabet: alphabet3,
1421
1429
  base: 64,
@@ -1428,7 +1436,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1428
1436
  const bytesToAdd = atob(value).split("").map((c) => c.charCodeAt(0));
1429
1437
  bytes.set(bytesToAdd, offset);
1430
1438
  return bytesToAdd.length + offset;
1431
- } catch (e22) {
1439
+ } catch {
1432
1440
  throw new SolanaError(SOLANA_ERROR__CODECS__INVALID_STRING_FOR_BASE, {
1433
1441
  alphabet: alphabet3,
1434
1442
  base: 64,
@@ -1488,7 +1496,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
1488
1496
  return encodedAccount;
1489
1497
  }
1490
1498
  return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) });
1491
- } catch (e3) {
1499
+ } catch {
1492
1500
  throw new SolanaError(SOLANA_ERROR__ACCOUNTS__FAILED_TO_DECODE_ACCOUNT, {
1493
1501
  address: encodedAccount.address
1494
1502
  });
@@ -1585,10 +1593,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
1585
1593
  /* extractable */
1586
1594
  false,
1587
1595
  ["sign", "verify"]
1588
- ).catch(() => {
1589
- resolve(cachedEd25519Decision = false);
1590
- }).then(() => {
1596
+ ).then(() => {
1591
1597
  resolve(cachedEd25519Decision = true);
1598
+ }).catch(() => {
1599
+ resolve(cachedEd25519Decision = false);
1592
1600
  });
1593
1601
  });
1594
1602
  }
@@ -1662,12 +1670,11 @@ this.globalThis.solanaWeb3 = (function (exports) {
1662
1670
  return false;
1663
1671
  }
1664
1672
  const base58Encoder2 = getMemoizedBase58Encoder();
1665
- const bytes = base58Encoder2.encode(putativeAddress);
1666
- const numBytes = bytes.byteLength;
1667
- if (numBytes !== 32) {
1673
+ try {
1674
+ return base58Encoder2.encode(putativeAddress).byteLength === 32;
1675
+ } catch {
1668
1676
  return false;
1669
1677
  }
1670
- return true;
1671
1678
  }
1672
1679
  function assertIsAddress(putativeAddress) {
1673
1680
  if (
@@ -2562,9 +2569,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
2562
2569
  var getDataEnumDecoder = getDiscriminatedUnionDecoder;
2563
2570
  var getDataEnumCodec = getDiscriminatedUnionCodec;
2564
2571
  function getEnumStats(constructor) {
2565
- const numericalValues = [
2566
- ...new Set(Object.values(constructor).filter((v) => typeof v === "number"))
2567
- ].sort();
2572
+ const numericalValues = [...new Set(Object.values(constructor).filter((v) => typeof v === "number"))].sort();
2568
2573
  const enumRecord = Object.fromEntries(Object.entries(constructor).slice(numericalValues.length));
2569
2574
  const enumKeys = Object.keys(enumRecord);
2570
2575
  const enumValues = Object.values(enumRecord);
@@ -3093,6 +3098,26 @@ this.globalThis.solanaWeb3 = (function (exports) {
3093
3098
  const privateKeyBytesPkcs8 = addPkcs8Header(bytes);
3094
3099
  return await crypto.subtle.importKey("pkcs8", privateKeyBytesPkcs8, "Ed25519", extractable != null ? extractable : false, ["sign"]);
3095
3100
  }
3101
+ async function getPublicKeyFromPrivateKey(privateKey, extractable = false) {
3102
+ assertKeyExporterIsAvailable();
3103
+ if (privateKey.extractable === false) {
3104
+ throw new SolanaError(SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY, { key: privateKey });
3105
+ }
3106
+ const jwk = await crypto.subtle.exportKey("jwk", privateKey);
3107
+ return await crypto.subtle.importKey(
3108
+ "jwk",
3109
+ {
3110
+ crv: "Ed25519",
3111
+ ext: extractable,
3112
+ key_ops: ["verify"],
3113
+ kty: "OKP",
3114
+ x: jwk.x
3115
+ },
3116
+ "Ed25519",
3117
+ extractable,
3118
+ ["verify"]
3119
+ );
3120
+ }
3096
3121
  var base58Encoder;
3097
3122
  function assertIsSignature(putativeSignature) {
3098
3123
  if (!base58Encoder) base58Encoder = getBase58Encoder();
@@ -3181,6 +3206,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
3181
3206
  }
3182
3207
  return { privateKey, publicKey };
3183
3208
  }
3209
+ async function createKeyPairFromPrivateKeyBytes(bytes, extractable = false) {
3210
+ const privateKeyPromise = createPrivateKeyFromBytes(bytes, extractable);
3211
+ const [publicKey, privateKey] = await Promise.all([
3212
+ // This nested promise makes things efficient by
3213
+ // creating the public key in parallel with the
3214
+ // second private key creation, if it is needed.
3215
+ (extractable ? privateKeyPromise : createPrivateKeyFromBytes(
3216
+ bytes,
3217
+ true
3218
+ /* extractable */
3219
+ )).then(
3220
+ async (privateKey2) => await getPublicKeyFromPrivateKey(
3221
+ privateKey2,
3222
+ true
3223
+ /* extractable */
3224
+ )
3225
+ ),
3226
+ privateKeyPromise
3227
+ ]);
3228
+ return { privateKey, publicKey };
3229
+ }
3184
3230
 
3185
3231
  // ../programs/dist/index.browser.mjs
3186
3232
  function isProgramError(error, transactionMessage, programAddress, code) {
@@ -3196,20 +3242,90 @@ this.globalThis.solanaWeb3 = (function (exports) {
3196
3242
  }
3197
3243
 
3198
3244
  // ../rpc-spec-types/dist/index.browser.mjs
3245
+ function parseJsonWithBigInts(json) {
3246
+ return JSON.parse(wrapIntegersInBigIntValueObject(json), (_, value) => {
3247
+ return isBigIntValueObject(value) ? unwrapBigIntValueObject(value) : value;
3248
+ });
3249
+ }
3250
+ function wrapIntegersInBigIntValueObject(json) {
3251
+ const out = [];
3252
+ let inQuote = false;
3253
+ for (let ii = 0; ii < json.length; ii++) {
3254
+ let isEscaped = false;
3255
+ if (json[ii] === "\\") {
3256
+ out.push(json[ii++]);
3257
+ isEscaped = !isEscaped;
3258
+ }
3259
+ if (json[ii] === '"') {
3260
+ out.push(json[ii]);
3261
+ if (!isEscaped) {
3262
+ inQuote = !inQuote;
3263
+ }
3264
+ continue;
3265
+ }
3266
+ if (!inQuote) {
3267
+ const consumedNumber = consumeNumber(json, ii);
3268
+ if (consumedNumber == null ? void 0 : consumedNumber.length) {
3269
+ ii += consumedNumber.length - 1;
3270
+ if (consumedNumber.match(/\.|[eE]-/)) {
3271
+ out.push(consumedNumber);
3272
+ } else {
3273
+ out.push(wrapBigIntValueObject(consumedNumber));
3274
+ }
3275
+ continue;
3276
+ }
3277
+ }
3278
+ out.push(json[ii]);
3279
+ }
3280
+ return out.join("");
3281
+ }
3282
+ function consumeNumber(json, ii) {
3283
+ var _a;
3284
+ const JSON_NUMBER_REGEX = /^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/;
3285
+ if (!((_a = json[ii]) == null ? void 0 : _a.match(/[-\d]/))) {
3286
+ return null;
3287
+ }
3288
+ const numberMatch = json.slice(ii).match(JSON_NUMBER_REGEX);
3289
+ return numberMatch ? numberMatch[0] : null;
3290
+ }
3291
+ function wrapBigIntValueObject(value) {
3292
+ return `{"$n":"${value}"}`;
3293
+ }
3294
+ function unwrapBigIntValueObject({ $n }) {
3295
+ if ($n.match(/[eE]/)) {
3296
+ const [units, exponent] = $n.split(/[eE]/);
3297
+ return BigInt(units) * BigInt(10) ** BigInt(exponent);
3298
+ }
3299
+ return BigInt($n);
3300
+ }
3301
+ function isBigIntValueObject(value) {
3302
+ return !!value && typeof value === "object" && "$n" in value && typeof value.$n === "string";
3303
+ }
3199
3304
  var _nextMessageId = 0;
3200
3305
  function getNextMessageId() {
3201
3306
  const id = _nextMessageId;
3202
3307
  _nextMessageId = (_nextMessageId + 1) % Number.MAX_SAFE_INTEGER;
3203
3308
  return id;
3204
3309
  }
3205
- function createRpcMessage(method, params) {
3310
+ function createRpcMessage(request) {
3206
3311
  return {
3207
3312
  id: getNextMessageId(),
3208
3313
  jsonrpc: "2.0",
3209
- method,
3210
- params
3314
+ method: request.methodName,
3315
+ params: request.params
3211
3316
  };
3212
3317
  }
3318
+ function stringifyJsonWithBigints(value, space) {
3319
+ return unwrapBigIntValueObject2(
3320
+ JSON.stringify(value, (_, v) => typeof v === "bigint" ? wrapBigIntValueObject2(v) : v, space)
3321
+ );
3322
+ }
3323
+ function wrapBigIntValueObject2(value) {
3324
+ return { $n: `${value}` };
3325
+ }
3326
+ function unwrapBigIntValueObject2(value) {
3327
+ return value.replace(/\{\s*"\$n"\s*:\s*"(-?\d+)"\s*\}/g, "$1");
3328
+ }
3213
3329
 
3214
3330
  // ../rpc-spec/dist/index.browser.mjs
3215
3331
  function createRpc(rpcConfig) {
@@ -3226,27 +3342,27 @@ this.globalThis.solanaWeb3 = (function (exports) {
3226
3342
  get(target, p, receiver) {
3227
3343
  return function(...rawParams) {
3228
3344
  const methodName = p.toString();
3229
- const createRpcRequest = Reflect.get(target, methodName, receiver);
3230
- const newRequest = createRpcRequest ? createRpcRequest(...rawParams) : { methodName, params: rawParams };
3231
- return createPendingRpcRequest(rpcConfig, newRequest);
3345
+ const getApiPlan = Reflect.get(target, methodName, receiver);
3346
+ if (!getApiPlan) {
3347
+ throw new SolanaError(SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD, {
3348
+ method: methodName,
3349
+ params: rawParams
3350
+ });
3351
+ }
3352
+ const apiPlan = getApiPlan(...rawParams);
3353
+ return createPendingRpcRequest(rpcConfig, apiPlan);
3232
3354
  };
3233
3355
  }
3234
3356
  });
3235
3357
  }
3236
- function createPendingRpcRequest(rpcConfig, pendingRequest) {
3358
+ function createPendingRpcRequest({ transport }, plan) {
3237
3359
  return {
3238
3360
  async send(options) {
3239
- const { methodName, params, responseTransformer } = pendingRequest;
3240
- const payload = createRpcMessage(methodName, params);
3241
- const response = await rpcConfig.transport({
3242
- payload,
3243
- signal: options == null ? void 0 : options.abortSignal
3244
- });
3245
- return responseTransformer ? responseTransformer(response, methodName) : response;
3361
+ return await plan.execute({ signal: options == null ? void 0 : options.abortSignal, transport });
3246
3362
  }
3247
3363
  };
3248
3364
  }
3249
- function createRpcApi(config) {
3365
+ function createJsonRpcApi(config) {
3250
3366
  return new Proxy({}, {
3251
3367
  defineProperty() {
3252
3368
  return false;
@@ -3258,19 +3374,106 @@ this.globalThis.solanaWeb3 = (function (exports) {
3258
3374
  const [_, p] = args;
3259
3375
  const methodName = p.toString();
3260
3376
  return function(...rawParams) {
3261
- const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, methodName) : rawParams;
3262
- const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
3263
- return {
3264
- methodName,
3265
- params,
3266
- responseTransformer
3267
- };
3377
+ const rawRequest = Object.freeze({ methodName, params: rawParams });
3378
+ const request = (config == null ? void 0 : config.requestTransformer) ? config == null ? void 0 : config.requestTransformer(rawRequest) : rawRequest;
3379
+ return Object.freeze({
3380
+ execute: async ({ signal, transport }) => {
3381
+ const payload = createRpcMessage(request);
3382
+ const response = await transport({ payload, signal });
3383
+ if (!(config == null ? void 0 : config.responseTransformer)) {
3384
+ return response;
3385
+ }
3386
+ return config.responseTransformer(response, request);
3387
+ }
3388
+ });
3268
3389
  };
3269
3390
  }
3270
3391
  });
3271
3392
  }
3393
+ function isJsonRpcPayload(payload) {
3394
+ if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
3395
+ return false;
3396
+ }
3397
+ return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
3398
+ }
3272
3399
 
3273
3400
  // ../rpc-transformers/dist/index.browser.mjs
3401
+ var KEYPATH_WILDCARD = {};
3402
+ function getTreeWalker(visitors) {
3403
+ return function traverse(node, state) {
3404
+ if (Array.isArray(node)) {
3405
+ return node.map((element, ii) => {
3406
+ const nextState = {
3407
+ ...state,
3408
+ keyPath: [...state.keyPath, ii]
3409
+ };
3410
+ return traverse(element, nextState);
3411
+ });
3412
+ } else if (typeof node === "object" && node !== null) {
3413
+ const out = {};
3414
+ for (const propName in node) {
3415
+ if (!Object.prototype.hasOwnProperty.call(node, propName)) {
3416
+ continue;
3417
+ }
3418
+ const nextState = {
3419
+ ...state,
3420
+ keyPath: [...state.keyPath, propName]
3421
+ };
3422
+ out[propName] = traverse(node[propName], nextState);
3423
+ }
3424
+ return out;
3425
+ } else {
3426
+ return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
3427
+ }
3428
+ };
3429
+ }
3430
+ function getTreeWalkerRequestTransformer(visitors, initialState) {
3431
+ return (request) => {
3432
+ const traverse = getTreeWalker(visitors);
3433
+ return Object.freeze({
3434
+ ...request,
3435
+ params: traverse(request.params, initialState)
3436
+ });
3437
+ };
3438
+ }
3439
+ function getTreeWalkerResponseTransformer(visitors, initialState) {
3440
+ return (json) => getTreeWalker(visitors)(json, initialState);
3441
+ }
3442
+ function getBigIntDowncastRequestTransformer() {
3443
+ return getTreeWalkerRequestTransformer([downcastNodeToNumberIfBigint], { keyPath: [] });
3444
+ }
3445
+ function downcastNodeToNumberIfBigint(value) {
3446
+ return typeof value === "bigint" ? (
3447
+ // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
3448
+ // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
3449
+ // downcasting `bigints` to `numbers`.
3450
+ Number(value)
3451
+ ) : value;
3452
+ }
3453
+ function getDefaultCommitmentRequestTransformer({
3454
+ defaultCommitment,
3455
+ optionsObjectPositionByMethod
3456
+ }) {
3457
+ return (request) => {
3458
+ const { params, methodName } = request;
3459
+ if (!Array.isArray(params)) {
3460
+ return request;
3461
+ }
3462
+ const optionsObjectPositionInParams = optionsObjectPositionByMethod[methodName];
3463
+ if (optionsObjectPositionInParams == null) {
3464
+ return request;
3465
+ }
3466
+ return Object.freeze({
3467
+ methodName,
3468
+ params: applyDefaultCommitment({
3469
+ commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment",
3470
+ optionsObjectPositionInParams,
3471
+ overrideCommitment: defaultCommitment,
3472
+ params
3473
+ })
3474
+ });
3475
+ };
3476
+ }
3274
3477
  function applyDefaultCommitment({
3275
3478
  commitmentPropertyName,
3276
3479
  params,
@@ -3316,13 +3519,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
3316
3519
  }
3317
3520
  return params;
3318
3521
  }
3319
- function downcastNodeToNumberIfBigint(value) {
3320
- return typeof value === "bigint" ? (
3321
- // FIXME(solana-labs/solana/issues/30341) Create a data type to represent u64 in the Solana
3322
- // JSON RPC implementation so that we can throw away this entire patcher instead of unsafely
3323
- // downcasting `bigints` to `numbers`.
3324
- Number(value)
3325
- ) : value;
3522
+ function getIntegerOverflowRequestTransformer(onIntegerOverflow) {
3523
+ return (request) => {
3524
+ const transformer = getTreeWalkerRequestTransformer(
3525
+ [getIntegerOverflowNodeVisitor((...args) => onIntegerOverflow(request, ...args))],
3526
+ { keyPath: [] }
3527
+ );
3528
+ return transformer(request);
3529
+ };
3326
3530
  }
3327
3531
  function getIntegerOverflowNodeVisitor(onIntegerOverflow) {
3328
3532
  return (value, { keyPath }) => {
@@ -3344,15 +3548,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3344
3548
  getBlockProduction: 0,
3345
3549
  getBlocks: 2,
3346
3550
  getBlocksWithLimit: 2,
3347
- getConfirmedBlock: 1,
3348
- getConfirmedBlocks: 1,
3349
- getConfirmedBlocksWithLimit: 2,
3350
- getConfirmedSignaturesForAddress2: 1,
3351
- getConfirmedTransaction: 1,
3352
3551
  getEpochInfo: 0,
3353
- getFeeCalculatorForBlockhash: 1,
3354
3552
  getFeeForMessage: 1,
3355
- getFees: 1,
3356
3553
  getInflationGovernor: 0,
3357
3554
  getInflationReward: 1,
3358
3555
  getLargestAccounts: 0,
@@ -3361,11 +3558,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
3361
3558
  getMinimumBalanceForRentExemption: 1,
3362
3559
  getMultipleAccounts: 1,
3363
3560
  getProgramAccounts: 1,
3364
- getRecentBlockhash: 1,
3365
3561
  getSignaturesForAddress: 1,
3366
3562
  getSlot: 0,
3367
3563
  getSlotLeader: 0,
3368
- getStakeActivation: 1,
3369
3564
  getStakeMinimumDelegation: 0,
3370
3565
  getSupply: 0,
3371
3566
  getTokenAccountBalance: 1,
@@ -3384,73 +3579,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
3384
3579
  signatureNotifications: 1,
3385
3580
  simulateTransaction: 1
3386
3581
  };
3387
- var KEYPATH_WILDCARD = {};
3388
- function getTreeWalker(visitors) {
3389
- return function traverse(node, state) {
3390
- if (Array.isArray(node)) {
3391
- return node.map((element, ii) => {
3392
- const nextState = {
3393
- ...state,
3394
- keyPath: [...state.keyPath, ii]
3395
- };
3396
- return traverse(element, nextState);
3397
- });
3398
- } else if (typeof node === "object" && node !== null) {
3399
- const out = {};
3400
- for (const propName in node) {
3401
- if (!Object.prototype.hasOwnProperty.call(node, propName)) {
3402
- continue;
3403
- }
3404
- const nextState = {
3405
- ...state,
3406
- keyPath: [...state.keyPath, propName]
3407
- };
3408
- out[propName] = traverse(node[propName], nextState);
3409
- }
3410
- return out;
3411
- } else {
3412
- return visitors.reduce((acc, visitNode) => visitNode(acc, state), node);
3413
- }
3414
- };
3415
- }
3416
- function getDefaultParamsTransformerForSolanaRpc(config) {
3417
- const defaultCommitment = config == null ? void 0 : config.defaultCommitment;
3582
+ function getDefaultRequestTransformerForSolanaRpc(config) {
3418
3583
  const handleIntegerOverflow = config == null ? void 0 : config.onIntegerOverflow;
3419
- return (rawParams, methodName) => {
3420
- const traverse = getTreeWalker([
3421
- ...handleIntegerOverflow ? [getIntegerOverflowNodeVisitor((...args) => handleIntegerOverflow(methodName, ...args))] : [],
3422
- downcastNodeToNumberIfBigint
3423
- ]);
3424
- const initialState = {
3425
- keyPath: []
3426
- };
3427
- const patchedParams = traverse(rawParams, initialState);
3428
- if (!Array.isArray(patchedParams)) {
3429
- return patchedParams;
3430
- }
3431
- const optionsObjectPositionInParams = OPTIONS_OBJECT_POSITION_BY_METHOD[methodName];
3432
- if (optionsObjectPositionInParams == null) {
3433
- return patchedParams;
3434
- }
3584
+ return (request) => {
3435
3585
  return pipe(
3436
- patchedParams,
3437
- (params) => applyDefaultCommitment({
3438
- commitmentPropertyName: methodName === "sendTransaction" ? "preflightCommitment" : "commitment",
3439
- optionsObjectPositionInParams,
3440
- overrideCommitment: defaultCommitment,
3441
- params
3442
- }),
3443
- // FIXME Remove when https://github.com/anza-xyz/agave/pull/483 is deployed.
3444
- (params) => methodName === "sendTransaction" ? applyFixForIssue479(params) : params
3586
+ request,
3587
+ handleIntegerOverflow ? getIntegerOverflowRequestTransformer(handleIntegerOverflow) : (r) => r,
3588
+ getBigIntDowncastRequestTransformer(),
3589
+ getDefaultCommitmentRequestTransformer({
3590
+ defaultCommitment: config == null ? void 0 : config.defaultCommitment,
3591
+ optionsObjectPositionByMethod: OPTIONS_OBJECT_POSITION_BY_METHOD
3592
+ })
3445
3593
  );
3446
3594
  };
3447
3595
  }
3448
- function applyFixForIssue479(params) {
3449
- var _a;
3450
- if (((_a = params[1]) == null ? void 0 : _a.skipPreflight) !== true) {
3451
- return params;
3452
- }
3453
- return [params[0], { ...params[1], preflightCommitment: "processed" }, ...params.slice(2)];
3596
+ function getBigIntUpcastResponseTransformer(allowedNumericKeyPaths) {
3597
+ return getTreeWalkerResponseTransformer([getBigIntUpcastVisitor(allowedNumericKeyPaths)], { keyPath: [] });
3598
+ }
3599
+ function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
3600
+ return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
3601
+ const isInteger = typeof value === "number" && Number.isInteger(value) || typeof value === "bigint";
3602
+ if (!isInteger) return value;
3603
+ if (keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
3604
+ return Number(value);
3605
+ } else {
3606
+ return BigInt(value);
3607
+ }
3608
+ };
3454
3609
  }
3455
3610
  function keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths) {
3456
3611
  return allowedNumericKeyPaths.some((prohibitedKeyPath) => {
@@ -3467,26 +3622,35 @@ this.globalThis.solanaWeb3 = (function (exports) {
3467
3622
  return true;
3468
3623
  });
3469
3624
  }
3470
- function getBigIntUpcastVisitor(allowedNumericKeyPaths) {
3471
- return function upcastNodeToBigIntIfNumber(value, { keyPath }) {
3472
- if (typeof value === "number" && Number.isInteger(value) && !keyPathIsAllowedToBeNumeric(keyPath, allowedNumericKeyPaths)) {
3473
- return BigInt(value);
3474
- } else {
3475
- return value;
3625
+ function getResultResponseTransformer() {
3626
+ return (json) => json.result;
3627
+ }
3628
+ function getThrowSolanaErrorResponseTransformer() {
3629
+ return (json) => {
3630
+ const jsonRpcResponse = json;
3631
+ if ("error" in jsonRpcResponse) {
3632
+ throw getSolanaErrorFromJsonRpcError(jsonRpcResponse.error);
3476
3633
  }
3634
+ return jsonRpcResponse;
3477
3635
  };
3478
3636
  }
3479
3637
  function getDefaultResponseTransformerForSolanaRpc(config) {
3480
- return (rawResponse, methodName) => {
3481
- if ("error" in rawResponse) {
3482
- throw getSolanaErrorFromJsonRpcError(rawResponse.error);
3483
- }
3638
+ return (response, request) => {
3639
+ const methodName = request.methodName;
3484
3640
  const keyPaths = (config == null ? void 0 : config.allowedNumericKeyPaths) && methodName ? config.allowedNumericKeyPaths[methodName] : void 0;
3485
- const traverse = getTreeWalker([getBigIntUpcastVisitor(keyPaths != null ? keyPaths : [])]);
3486
- const initialState = {
3487
- keyPath: []
3488
- };
3489
- return traverse(rawResponse.result, initialState);
3641
+ return pipe(
3642
+ response,
3643
+ (r) => getThrowSolanaErrorResponseTransformer()(r, request),
3644
+ (r) => getResultResponseTransformer()(r, request),
3645
+ (r) => getBigIntUpcastResponseTransformer(keyPaths != null ? keyPaths : [])(r, request)
3646
+ );
3647
+ };
3648
+ }
3649
+ function getDefaultResponseTransformerForSolanaRpcSubscriptions(config) {
3650
+ return (response, request) => {
3651
+ const methodName = request.methodName;
3652
+ const keyPaths = (config == null ? void 0 : config.allowedNumericKeyPaths) && methodName ? config.allowedNumericKeyPaths[methodName] : void 0;
3653
+ return pipe(response, (r) => getBigIntUpcastResponseTransformer(keyPaths != null ? keyPaths : [])(r, request));
3490
3654
  };
3491
3655
  }
3492
3656
  var jsonParsedTokenAccountsConfigs = [
@@ -3542,8 +3706,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3542
3706
 
3543
3707
  // ../rpc-api/dist/index.browser.mjs
3544
3708
  function createSolanaRpcApi(config) {
3545
- return createRpcApi({
3546
- parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config),
3709
+ return createJsonRpcApi({
3710
+ requestTransformer: getDefaultRequestTransformerForSolanaRpc(config),
3547
3711
  responseTransformer: getDefaultResponseTransformerForSolanaRpc({
3548
3712
  allowedNumericKeyPaths: getAllowedNumericKeypaths()
3549
3713
  })
@@ -3555,7 +3719,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3555
3719
  memoizedKeypaths = {
3556
3720
  getAccountInfo: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
3557
3721
  getBlock: [
3558
- ["blockTime"],
3559
3722
  ["transactions", KEYPATH_WILDCARD, "meta", "preTokenBalances", KEYPATH_WILDCARD, "accountIndex"],
3560
3723
  [
3561
3724
  "transactions",
@@ -3588,7 +3751,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3588
3751
  ...messageConfig.map((c) => ["transactions", KEYPATH_WILDCARD, "transaction", "message", ...c]),
3589
3752
  ["rewards", KEYPATH_WILDCARD, "commission"]
3590
3753
  ],
3591
- getBlockTime: [[]],
3592
3754
  getClusterNodes: [
3593
3755
  [KEYPATH_WILDCARD, "featureSet"],
3594
3756
  [KEYPATH_WILDCARD, "shredVersion"]
@@ -3655,31 +3817,33 @@ this.globalThis.solanaWeb3 = (function (exports) {
3655
3817
  "content-length": true,
3656
3818
  "content-type": true
3657
3819
  };
3658
- var FORBIDDEN_HEADERS = {
3659
- "accept-charset": true,
3660
- "accept-encoding": true,
3661
- "access-control-request-headers": true,
3662
- "access-control-request-method": true,
3663
- connection: true,
3664
- "content-length": true,
3665
- cookie: true,
3666
- date: true,
3667
- dnt: true,
3668
- expect: true,
3669
- host: true,
3670
- "keep-alive": true,
3671
- origin: true,
3672
- "permissions-policy": true,
3673
- // Prefix matching is implemented in code, below.
3674
- // 'proxy-': true,
3675
- // 'sec-': true,
3676
- referer: true,
3677
- te: true,
3678
- trailer: true,
3679
- "transfer-encoding": true,
3680
- upgrade: true,
3681
- via: true
3682
- };
3820
+ var FORBIDDEN_HEADERS = /* @__PURE__ */ Object.assign(
3821
+ {
3822
+ "accept-charset": true,
3823
+ "access-control-request-headers": true,
3824
+ "access-control-request-method": true,
3825
+ connection: true,
3826
+ "content-length": true,
3827
+ cookie: true,
3828
+ date: true,
3829
+ dnt: true,
3830
+ expect: true,
3831
+ host: true,
3832
+ "keep-alive": true,
3833
+ origin: true,
3834
+ "permissions-policy": true,
3835
+ // Prefix matching is implemented in code, below.
3836
+ // 'proxy-': true,
3837
+ // 'sec-': true,
3838
+ referer: true,
3839
+ te: true,
3840
+ trailer: true,
3841
+ "transfer-encoding": true,
3842
+ upgrade: true,
3843
+ via: true
3844
+ },
3845
+ { "accept-encoding": true }
3846
+ );
3683
3847
  function assertIsAllowedHttpRequestHeaders(headers) {
3684
3848
  const badHeaders = Object.keys(headers).filter((headerName) => {
3685
3849
  const lowercaseHeaderName = headerName.toLowerCase();
@@ -3712,7 +3876,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3712
3876
  if ("dispatcher_NODE_ONLY" in config) {
3713
3877
  warnDispatcherWasSuppliedInNonNodeEnvironment();
3714
3878
  }
3715
- const { headers, url } = config;
3879
+ const { fromJson, headers, toJson, url } = config;
3716
3880
  if (headers) {
3717
3881
  assertIsAllowedHttpRequestHeaders(headers);
3718
3882
  }
@@ -3722,7 +3886,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3722
3886
  payload,
3723
3887
  signal
3724
3888
  }) {
3725
- const body = JSON.stringify(payload);
3889
+ const body = toJson ? toJson(payload) : JSON.stringify(payload);
3726
3890
  const requestInfo = {
3727
3891
  ...dispatcherConfig,
3728
3892
  body,
@@ -3743,9 +3907,87 @@ this.globalThis.solanaWeb3 = (function (exports) {
3743
3907
  statusCode: response.status
3744
3908
  });
3745
3909
  }
3910
+ if (fromJson) {
3911
+ return fromJson(await response.text(), payload);
3912
+ }
3746
3913
  return await response.json();
3747
3914
  };
3748
3915
  }
3916
+ var SOLANA_RPC_METHODS = [
3917
+ "getAccountInfo",
3918
+ "getBalance",
3919
+ "getBlock",
3920
+ "getBlockCommitment",
3921
+ "getBlockHeight",
3922
+ "getBlockProduction",
3923
+ "getBlocks",
3924
+ "getBlocksWithLimit",
3925
+ "getBlockTime",
3926
+ "getClusterNodes",
3927
+ "getEpochInfo",
3928
+ "getEpochSchedule",
3929
+ "getFeeForMessage",
3930
+ "getFirstAvailableBlock",
3931
+ "getGenesisHash",
3932
+ "getHealth",
3933
+ "getHighestSnapshotSlot",
3934
+ "getIdentity",
3935
+ "getInflationGovernor",
3936
+ "getInflationRate",
3937
+ "getInflationReward",
3938
+ "getLargestAccounts",
3939
+ "getLatestBlockhash",
3940
+ "getLeaderSchedule",
3941
+ "getMaxRetransmitSlot",
3942
+ "getMaxShredInsertSlot",
3943
+ "getMinimumBalanceForRentExemption",
3944
+ "getMultipleAccounts",
3945
+ "getProgramAccounts",
3946
+ "getRecentPerformanceSamples",
3947
+ "getRecentPrioritizationFees",
3948
+ "getSignaturesForAddress",
3949
+ "getSignatureStatuses",
3950
+ "getSlot",
3951
+ "getSlotLeader",
3952
+ "getSlotLeaders",
3953
+ "getStakeMinimumDelegation",
3954
+ "getSupply",
3955
+ "getTokenAccountBalance",
3956
+ "getTokenAccountsByDelegate",
3957
+ "getTokenAccountsByOwner",
3958
+ "getTokenLargestAccounts",
3959
+ "getTokenSupply",
3960
+ "getTransaction",
3961
+ "getTransactionCount",
3962
+ "getVersion",
3963
+ "getVoteAccounts",
3964
+ "index",
3965
+ "isBlockhashValid",
3966
+ "minimumLedgerSlot",
3967
+ "requestAirdrop",
3968
+ "sendTransaction",
3969
+ "simulateTransaction"
3970
+ ];
3971
+ function isSolanaRequest(payload) {
3972
+ return isJsonRpcPayload(payload) && SOLANA_RPC_METHODS.includes(payload.method);
3973
+ }
3974
+ function createHttpTransportForSolanaRpc(config) {
3975
+ return createHttpTransport({
3976
+ ...config,
3977
+ fromJson: (rawResponse, payload) => {
3978
+ if (!isSolanaRequest(payload)) return JSON.parse(rawResponse);
3979
+ const response = parseJsonWithBigInts(rawResponse);
3980
+ if (isErrorResponse(response)) {
3981
+ return { ...response, error: { ...response.error, code: Number(response.error.code) } };
3982
+ }
3983
+ return response;
3984
+ },
3985
+ toJson: (payload) => isSolanaRequest(payload) ? stringifyJsonWithBigints(payload) : JSON.stringify(payload)
3986
+ });
3987
+ }
3988
+ function isErrorResponse(value) {
3989
+ return !!value && typeof value === "object" && "error" in value && !!value.error && typeof value.error === "object" && "code" in value.error;
3990
+ }
3749
3991
 
3750
3992
  // ../fast-stable-stringify/dist/index.browser.mjs
3751
3993
  var objToString = Object.prototype.toString;
@@ -3854,8 +4096,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
3854
4096
  }
3855
4097
  var DEFAULT_RPC_CONFIG = {
3856
4098
  defaultCommitment: "confirmed",
3857
- onIntegerOverflow(methodName, keyPath, value) {
3858
- throw createSolanaJsonRpcIntegerOverflowError(methodName, keyPath, value);
4099
+ onIntegerOverflow(request, keyPath, value) {
4100
+ throw createSolanaJsonRpcIntegerOverflowError(request.methodName, keyPath, value);
3859
4101
  }
3860
4102
  };
3861
4103
  var EXPLICIT_ABORT_TOKEN;
@@ -3866,14 +4108,14 @@ this.globalThis.solanaWeb3 = (function (exports) {
3866
4108
  }
3867
4109
  function getRpcTransportWithRequestCoalescing(transport, getDeduplicationKey) {
3868
4110
  let coalescedRequestsByDeduplicationKey;
3869
- return async function makeCoalescedHttpRequest(config) {
3870
- const { payload, signal } = config;
4111
+ return async function makeCoalescedHttpRequest(request) {
4112
+ const { payload, signal } = request;
3871
4113
  const deduplicationKey = getDeduplicationKey(payload);
3872
4114
  if (deduplicationKey === void 0) {
3873
- return await transport(config);
4115
+ return await transport(request);
3874
4116
  }
3875
4117
  if (!coalescedRequestsByDeduplicationKey) {
3876
- Promise.resolve().then(() => {
4118
+ queueMicrotask(() => {
3877
4119
  coalescedRequestsByDeduplicationKey = void 0;
3878
4120
  });
3879
4121
  coalescedRequestsByDeduplicationKey = {};
@@ -3883,7 +4125,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3883
4125
  const responsePromise = (async () => {
3884
4126
  try {
3885
4127
  return await transport({
3886
- ...config,
4128
+ ...request,
3887
4129
  signal: abortController.signal
3888
4130
  });
3889
4131
  } catch (e3) {
@@ -3907,7 +4149,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
3907
4149
  const handleAbort = (e3) => {
3908
4150
  signal.removeEventListener("abort", handleAbort);
3909
4151
  coalescedRequest.numConsumers -= 1;
3910
- Promise.resolve().then(() => {
4152
+ queueMicrotask(() => {
3911
4153
  if (coalescedRequest.numConsumers === 0) {
3912
4154
  const abortController = coalescedRequest.abortController;
3913
4155
  abortController.abort(EXPLICIT_ABORT_TOKEN || (EXPLICIT_ABORT_TOKEN = createExplicitAbortToken()));
@@ -3925,12 +4167,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
3925
4167
  }
3926
4168
  };
3927
4169
  }
3928
- function isJsonRpcPayload(payload) {
3929
- if (payload == null || typeof payload !== "object" || Array.isArray(payload)) {
3930
- return false;
3931
- }
3932
- return "jsonrpc" in payload && payload.jsonrpc === "2.0" && "method" in payload && typeof payload.method === "string" && "params" in payload;
3933
- }
3934
4170
  function getSolanaRpcPayloadDeduplicationKey(payload) {
3935
4171
  return isJsonRpcPayload(payload) ? src_default([payload.method, payload.params]) : void 0;
3936
4172
  }
@@ -3942,15 +4178,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
3942
4178
  return out;
3943
4179
  }
3944
4180
  function createDefaultRpcTransport(config) {
3945
- var _a;
3946
4181
  return pipe(
3947
- createHttpTransport({
4182
+ createHttpTransportForSolanaRpc({
3948
4183
  ...config,
3949
4184
  headers: {
4185
+ ...false,
3950
4186
  ...config.headers ? normalizeHeaders2(config.headers) : void 0,
3951
4187
  ...{
3952
4188
  // Keep these headers lowercase so they will override any user-supplied headers above.
3953
- "solana-client": (_a = `js/${"2.0.0-rc.0"}`) != null ? _a : "UNKNOWN"
4189
+ "solana-client": `js/${"2.0.0-rc.2"}`
3954
4190
  }
3955
4191
  }
3956
4192
  }),
@@ -3967,98 +4203,285 @@ this.globalThis.solanaWeb3 = (function (exports) {
3967
4203
  });
3968
4204
  }
3969
4205
 
3970
- // ../rpc-subscriptions-spec/dist/index.browser.mjs
3971
- function createSubscriptionRpc(rpcConfig) {
3972
- return makeProxy2(rpcConfig);
4206
+ // ../subscribable/dist/index.browser.mjs
4207
+ var EXPLICIT_ABORT_TOKEN2;
4208
+ function createExplicitAbortToken2() {
4209
+ return Symbol(
4210
+ "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
4211
+ );
3973
4212
  }
3974
- function makeProxy2(rpcConfig) {
3975
- return new Proxy(rpcConfig.api, {
3976
- defineProperty() {
3977
- return false;
3978
- },
3979
- deleteProperty() {
3980
- return false;
3981
- },
3982
- get(target, p, receiver) {
3983
- return function(...rawParams) {
3984
- const notificationName = p.toString();
3985
- const createRpcSubscription = Reflect.get(target, notificationName, receiver);
3986
- if (p.toString().endsWith("Notifications") === false && !createRpcSubscription) {
3987
- throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST, {
3988
- notificationName
3989
- });
3990
- }
3991
- const newRequest = createRpcSubscription ? createRpcSubscription(...rawParams) : {
3992
- params: rawParams,
3993
- subscribeMethodName: notificationName.replace(/Notifications$/, "Subscribe"),
3994
- unsubscribeMethodName: notificationName.replace(/Notifications$/, "Unsubscribe")
3995
- };
3996
- return createPendingRpcSubscription(rpcConfig, newRequest);
3997
- };
4213
+ var UNINITIALIZED = Symbol();
4214
+ function createAsyncIterableFromDataPublisher({
4215
+ abortSignal,
4216
+ dataChannelName,
4217
+ dataPublisher,
4218
+ errorChannelName
4219
+ }) {
4220
+ const iteratorState = /* @__PURE__ */ new Map();
4221
+ function publishErrorToAllIterators(reason) {
4222
+ for (const [iteratorKey, state] of iteratorState.entries()) {
4223
+ if (state.__hasPolled) {
4224
+ iteratorState.delete(iteratorKey);
4225
+ state.onError(reason);
4226
+ } else {
4227
+ state.publishQueue.push({
4228
+ __type: 1,
4229
+ err: reason
4230
+ });
4231
+ }
3998
4232
  }
4233
+ }
4234
+ const abortController = new AbortController();
4235
+ abortSignal.addEventListener("abort", () => {
4236
+ abortController.abort();
4237
+ publishErrorToAllIterators(EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()));
3999
4238
  });
4000
- }
4001
- function registerIterableCleanup(iterable, cleanupFn) {
4002
- (async () => {
4003
- try {
4004
- for await (const _ of iterable) ;
4005
- } catch {
4006
- } finally {
4007
- cleanupFn();
4008
- }
4009
- })();
4010
- }
4011
- function createPendingRpcSubscription(rpcConfig, { params, subscribeMethodName, unsubscribeMethodName, responseTransformer }) {
4012
- return {
4013
- async subscribe({ abortSignal }) {
4014
- abortSignal.throwIfAborted();
4015
- let subscriptionId;
4016
- function handleCleanup() {
4017
- if (subscriptionId !== void 0) {
4018
- const payload = createRpcMessage(unsubscribeMethodName, [subscriptionId]);
4019
- connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload).finally(() => {
4020
- connectionAbortController.abort();
4021
- });
4239
+ const options = { signal: abortController.signal };
4240
+ let firstError = UNINITIALIZED;
4241
+ dataPublisher.on(
4242
+ errorChannelName,
4243
+ (err) => {
4244
+ if (firstError === UNINITIALIZED) {
4245
+ firstError = err;
4246
+ abortController.abort();
4247
+ publishErrorToAllIterators(err);
4248
+ }
4249
+ },
4250
+ options
4251
+ );
4252
+ dataPublisher.on(
4253
+ dataChannelName,
4254
+ (data) => {
4255
+ iteratorState.forEach((state, iteratorKey) => {
4256
+ if (state.__hasPolled) {
4257
+ const { onData } = state;
4258
+ iteratorState.set(iteratorKey, { __hasPolled: false, publishQueue: [] });
4259
+ onData(data);
4022
4260
  } else {
4023
- connectionAbortController.abort();
4261
+ state.publishQueue.push({
4262
+ __type: 0,
4263
+ data
4264
+ });
4024
4265
  }
4025
- }
4026
- abortSignal.addEventListener("abort", handleCleanup);
4027
- const connectionAbortController = new AbortController();
4028
- const subscribeMessage = createRpcMessage(subscribeMethodName, params);
4029
- const connection = await rpcConfig.transport({
4030
- payload: subscribeMessage,
4031
- signal: connectionAbortController.signal
4032
4266
  });
4033
- function handleConnectionCleanup() {
4034
- abortSignal.removeEventListener("abort", handleCleanup);
4035
- }
4036
- registerIterableCleanup(connection, handleConnectionCleanup);
4037
- for await (const message of connection) {
4038
- if ("id" in message && message.id === subscribeMessage.id) {
4039
- if ("error" in message) {
4040
- throw getSolanaErrorFromJsonRpcError(message.error);
4041
- } else {
4042
- subscriptionId = message.result;
4043
- break;
4267
+ },
4268
+ options
4269
+ );
4270
+ return {
4271
+ async *[Symbol.asyncIterator]() {
4272
+ if (abortSignal.aborted) {
4273
+ return;
4274
+ }
4275
+ if (firstError !== UNINITIALIZED) {
4276
+ throw firstError;
4277
+ }
4278
+ const iteratorKey = Symbol();
4279
+ iteratorState.set(iteratorKey, { __hasPolled: false, publishQueue: [] });
4280
+ try {
4281
+ while (true) {
4282
+ const state = iteratorState.get(iteratorKey);
4283
+ if (!state) {
4284
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING);
4285
+ }
4286
+ if (state.__hasPolled) {
4287
+ throw new SolanaError(
4288
+ SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
4289
+ );
4290
+ }
4291
+ const publishQueue = state.publishQueue;
4292
+ try {
4293
+ if (publishQueue.length) {
4294
+ state.publishQueue = [];
4295
+ for (const item of publishQueue) {
4296
+ if (item.__type === 0) {
4297
+ yield item.data;
4298
+ } else {
4299
+ throw item.err;
4300
+ }
4301
+ }
4302
+ } else {
4303
+ yield await new Promise((resolve, reject) => {
4304
+ iteratorState.set(iteratorKey, {
4305
+ __hasPolled: true,
4306
+ onData: resolve,
4307
+ onError: reject
4308
+ });
4309
+ });
4310
+ }
4311
+ } catch (e3) {
4312
+ if (e3 === (EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()))) {
4313
+ return;
4314
+ } else {
4315
+ throw e3;
4316
+ }
4044
4317
  }
4045
4318
  }
4319
+ } finally {
4320
+ iteratorState.delete(iteratorKey);
4046
4321
  }
4047
- if (subscriptionId == null) {
4048
- throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID);
4322
+ }
4323
+ };
4324
+ }
4325
+ function getDataPublisherFromEventEmitter(eventEmitter) {
4326
+ return {
4327
+ on(channelName, subscriber, options) {
4328
+ function innerListener(ev) {
4329
+ if (ev instanceof CustomEvent) {
4330
+ const data = ev.detail;
4331
+ subscriber(data);
4332
+ } else {
4333
+ subscriber();
4334
+ }
4049
4335
  }
4050
- return {
4051
- async *[Symbol.asyncIterator]() {
4052
- for await (const message of connection) {
4053
- if (!("params" in message) || message.params.subscription !== subscriptionId) {
4054
- continue;
4055
- }
4056
- const notification = message.params;
4057
- yield responseTransformer ? responseTransformer(notification, subscribeMethodName) : notification;
4336
+ eventEmitter.addEventListener(channelName, innerListener, options);
4337
+ return () => {
4338
+ eventEmitter.removeEventListener(channelName, innerListener);
4339
+ };
4340
+ }
4341
+ };
4342
+ }
4343
+ function demultiplexDataPublisher(publisher, sourceChannelName, messageTransformer) {
4344
+ let innerPublisherState;
4345
+ const eventTarget = new EventTarget();
4346
+ const demultiplexedDataPublisher = getDataPublisherFromEventEmitter(eventTarget);
4347
+ return {
4348
+ ...demultiplexedDataPublisher,
4349
+ on(channelName, subscriber, options) {
4350
+ if (!innerPublisherState) {
4351
+ const innerPublisherUnsubscribe = publisher.on(sourceChannelName, (sourceMessage) => {
4352
+ const transformResult = messageTransformer(sourceMessage);
4353
+ if (!transformResult) {
4354
+ return;
4058
4355
  }
4356
+ const [destinationChannelName, message] = transformResult;
4357
+ eventTarget.dispatchEvent(
4358
+ new CustomEvent(destinationChannelName, {
4359
+ detail: message
4360
+ })
4361
+ );
4362
+ });
4363
+ innerPublisherState = {
4364
+ dispose: innerPublisherUnsubscribe,
4365
+ numSubscribers: 0
4366
+ };
4367
+ }
4368
+ innerPublisherState.numSubscribers++;
4369
+ const unsubscribe = demultiplexedDataPublisher.on(channelName, subscriber, options);
4370
+ let isActive = true;
4371
+ function handleUnsubscribe() {
4372
+ if (!isActive) {
4373
+ return;
4374
+ }
4375
+ isActive = false;
4376
+ options == null ? void 0 : options.signal.removeEventListener("abort", handleUnsubscribe);
4377
+ innerPublisherState.numSubscribers--;
4378
+ if (innerPublisherState.numSubscribers === 0) {
4379
+ innerPublisherState.dispose();
4380
+ innerPublisherState = void 0;
4381
+ }
4382
+ unsubscribe();
4383
+ }
4384
+ options == null ? void 0 : options.signal.addEventListener("abort", handleUnsubscribe);
4385
+ return handleUnsubscribe;
4386
+ }
4387
+ };
4388
+ }
4389
+
4390
+ // ../promises/dist/index.browser.mjs
4391
+ function isObject(value) {
4392
+ return value !== null && (typeof value === "object" || typeof value === "function");
4393
+ }
4394
+ function addRaceContender(contender) {
4395
+ const deferreds = /* @__PURE__ */ new Set();
4396
+ const record = { deferreds, settled: false };
4397
+ Promise.resolve(contender).then(
4398
+ (value) => {
4399
+ for (const { resolve } of deferreds) {
4400
+ resolve(value);
4401
+ }
4402
+ deferreds.clear();
4403
+ record.settled = true;
4404
+ },
4405
+ (err) => {
4406
+ for (const { reject } of deferreds) {
4407
+ reject(err);
4408
+ }
4409
+ deferreds.clear();
4410
+ record.settled = true;
4411
+ }
4412
+ );
4413
+ return record;
4414
+ }
4415
+ var wm = /* @__PURE__ */ new WeakMap();
4416
+ async function safeRace(contenders) {
4417
+ let deferred;
4418
+ const result = new Promise((resolve, reject) => {
4419
+ deferred = { reject, resolve };
4420
+ for (const contender of contenders) {
4421
+ if (!isObject(contender)) {
4422
+ Promise.resolve(contender).then(resolve, reject);
4423
+ continue;
4424
+ }
4425
+ let record = wm.get(contender);
4426
+ if (record === void 0) {
4427
+ record = addRaceContender(contender);
4428
+ record.deferreds.add(deferred);
4429
+ wm.set(contender, record);
4430
+ } else if (record.settled) {
4431
+ Promise.resolve(contender).then(resolve, reject);
4432
+ } else {
4433
+ record.deferreds.add(deferred);
4434
+ }
4435
+ }
4436
+ });
4437
+ return await result.finally(() => {
4438
+ for (const contender of contenders) {
4439
+ if (isObject(contender)) {
4440
+ const record = wm.get(contender);
4441
+ record.deferreds.delete(deferred);
4442
+ }
4443
+ }
4444
+ });
4445
+ }
4446
+
4447
+ // ../rpc-subscriptions-spec/dist/index.browser.mjs
4448
+ function createSubscriptionRpc(rpcConfig) {
4449
+ return new Proxy(rpcConfig.api, {
4450
+ defineProperty() {
4451
+ return false;
4452
+ },
4453
+ deleteProperty() {
4454
+ return false;
4455
+ },
4456
+ get(target, p, receiver) {
4457
+ return function(...rawParams) {
4458
+ const notificationName = p.toString();
4459
+ const createRpcSubscriptionPlan = Reflect.get(target, notificationName, receiver);
4460
+ if (!createRpcSubscriptionPlan) {
4461
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN, {
4462
+ notificationName
4463
+ });
4059
4464
  }
4465
+ const subscriptionPlan = createRpcSubscriptionPlan(...rawParams);
4466
+ return createPendingRpcSubscription(rpcConfig.transport, subscriptionPlan);
4060
4467
  };
4061
4468
  }
4469
+ });
4470
+ }
4471
+ function createPendingRpcSubscription(transport, subscriptionsPlan) {
4472
+ return {
4473
+ async subscribe({ abortSignal }) {
4474
+ const notificationsDataPublisher = await transport({
4475
+ signal: abortSignal,
4476
+ ...subscriptionsPlan
4477
+ });
4478
+ return createAsyncIterableFromDataPublisher({
4479
+ abortSignal,
4480
+ dataChannelName: "notification",
4481
+ dataPublisher: notificationsDataPublisher,
4482
+ errorChannelName: "error"
4483
+ });
4484
+ }
4062
4485
  };
4063
4486
  }
4064
4487
  function createRpcSubscriptionsApi(config) {
@@ -4071,32 +4494,206 @@ this.globalThis.solanaWeb3 = (function (exports) {
4071
4494
  },
4072
4495
  get(...args) {
4073
4496
  const [_, p] = args;
4074
- const notificationName = p.toString();
4075
- return function(...rawParams) {
4076
- const params = (config == null ? void 0 : config.parametersTransformer) ? config == null ? void 0 : config.parametersTransformer(rawParams, notificationName) : rawParams;
4077
- const responseTransformer = (config == null ? void 0 : config.responseTransformer) ? config == null ? void 0 : config.responseTransformer : (rawResponse) => rawResponse;
4078
- const subscribeMethodName = (config == null ? void 0 : config.subscribeNotificationNameTransformer) ? config == null ? void 0 : config.subscribeNotificationNameTransformer(notificationName) : notificationName;
4079
- const unsubscribeMethodName = (config == null ? void 0 : config.unsubscribeNotificationNameTransformer) ? config == null ? void 0 : config.unsubscribeNotificationNameTransformer(notificationName) : notificationName;
4497
+ const methodName = p.toString();
4498
+ return function(...params) {
4499
+ const rawRequest = { methodName, params };
4500
+ const request = config.requestTransformer ? config.requestTransformer(rawRequest) : rawRequest;
4080
4501
  return {
4081
- params,
4082
- responseTransformer,
4083
- subscribeMethodName,
4084
- unsubscribeMethodName
4502
+ execute(planConfig) {
4503
+ return config.planExecutor({ ...planConfig, request });
4504
+ },
4505
+ request
4085
4506
  };
4086
4507
  };
4087
4508
  }
4088
4509
  });
4089
4510
  }
4511
+ function transformChannelInboundMessages(channel, transform) {
4512
+ return Object.freeze({
4513
+ ...channel,
4514
+ on(type, subscriber, options) {
4515
+ if (type !== "message") {
4516
+ return channel.on(
4517
+ type,
4518
+ subscriber,
4519
+ options
4520
+ );
4521
+ }
4522
+ return channel.on(
4523
+ "message",
4524
+ (message) => subscriber(transform(message)),
4525
+ options
4526
+ );
4527
+ }
4528
+ });
4529
+ }
4530
+ function transformChannelOutboundMessages(channel, transform) {
4531
+ return Object.freeze({
4532
+ ...channel,
4533
+ send: (message) => channel.send(transform(message))
4534
+ });
4535
+ }
4536
+ var subscriberCountBySubscriptionIdByChannel = /* @__PURE__ */ new WeakMap();
4537
+ function decrementSubscriberCountAndReturnNewCount(channel, subscriptionId) {
4538
+ return augmentSubscriberCountAndReturnNewCount(-1, channel, subscriptionId);
4539
+ }
4540
+ function incrementSubscriberCount(channel, subscriptionId) {
4541
+ augmentSubscriberCountAndReturnNewCount(1, channel, subscriptionId);
4542
+ }
4543
+ function augmentSubscriberCountAndReturnNewCount(amount, channel, subscriptionId) {
4544
+ if (subscriptionId === void 0) {
4545
+ return;
4546
+ }
4547
+ let subscriberCountBySubscriptionId = subscriberCountBySubscriptionIdByChannel.get(channel);
4548
+ if (!subscriberCountBySubscriptionId && amount > 0) {
4549
+ subscriberCountBySubscriptionIdByChannel.set(
4550
+ channel,
4551
+ subscriberCountBySubscriptionId = { [subscriptionId]: 0 }
4552
+ );
4553
+ }
4554
+ if ((subscriberCountBySubscriptionId == null ? void 0 : subscriberCountBySubscriptionId[subscriptionId]) !== void 0) {
4555
+ return subscriberCountBySubscriptionId[subscriptionId] = amount + subscriberCountBySubscriptionId[subscriptionId];
4556
+ }
4557
+ }
4558
+ var cache = /* @__PURE__ */ new WeakMap();
4559
+ function getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer(channel, subscribeRequest, responseTransformer) {
4560
+ let publisherByResponseTransformer = cache.get(channel);
4561
+ if (!publisherByResponseTransformer) {
4562
+ cache.set(channel, publisherByResponseTransformer = /* @__PURE__ */ new WeakMap());
4563
+ }
4564
+ const responseTransformerKey = responseTransformer != null ? responseTransformer : channel;
4565
+ let publisher = publisherByResponseTransformer.get(responseTransformerKey);
4566
+ if (!publisher) {
4567
+ publisherByResponseTransformer.set(
4568
+ responseTransformerKey,
4569
+ publisher = demultiplexDataPublisher(channel, "message", (rawMessage) => {
4570
+ const message = rawMessage;
4571
+ if (!("method" in message)) {
4572
+ return;
4573
+ }
4574
+ const transformedNotification = responseTransformer ? responseTransformer(message.params.result, subscribeRequest) : message.params.result;
4575
+ return [`notification:${message.params.subscription}`, transformedNotification];
4576
+ })
4577
+ );
4578
+ }
4579
+ return publisher;
4580
+ }
4581
+ async function executeRpcPubSubSubscriptionPlan({
4582
+ channel,
4583
+ responseTransformer,
4584
+ signal,
4585
+ subscribeRequest,
4586
+ unsubscribeMethodName
4587
+ }) {
4588
+ let subscriptionId;
4589
+ channel.on(
4590
+ "error",
4591
+ () => {
4592
+ subscriptionId = void 0;
4593
+ subscriberCountBySubscriptionIdByChannel.delete(channel);
4594
+ },
4595
+ { signal }
4596
+ );
4597
+ const abortPromise = new Promise((_, reject) => {
4598
+ function handleAbort() {
4599
+ if (decrementSubscriberCountAndReturnNewCount(channel, subscriptionId) === 0) {
4600
+ const unsubscribePayload = createRpcMessage({
4601
+ methodName: unsubscribeMethodName,
4602
+ params: [subscriptionId]
4603
+ });
4604
+ subscriptionId = void 0;
4605
+ channel.send(unsubscribePayload).catch(() => {
4606
+ });
4607
+ }
4608
+ reject(this.reason);
4609
+ }
4610
+ if (signal.aborted) {
4611
+ handleAbort.call(signal);
4612
+ } else {
4613
+ signal.addEventListener("abort", handleAbort);
4614
+ }
4615
+ });
4616
+ const subscribePayload = createRpcMessage(subscribeRequest);
4617
+ await channel.send(subscribePayload);
4618
+ const subscriptionIdPromise = new Promise((resolve, reject) => {
4619
+ const abortController = new AbortController();
4620
+ signal.addEventListener("abort", abortController.abort.bind(abortController));
4621
+ const options = { signal: abortController.signal };
4622
+ channel.on(
4623
+ "error",
4624
+ (err) => {
4625
+ abortController.abort();
4626
+ reject(err);
4627
+ },
4628
+ options
4629
+ );
4630
+ channel.on(
4631
+ "message",
4632
+ (message) => {
4633
+ if (message && typeof message === "object" && "id" in message && message.id === subscribePayload.id) {
4634
+ abortController.abort();
4635
+ if ("error" in message) {
4636
+ reject(getSolanaErrorFromJsonRpcError(message.error));
4637
+ } else {
4638
+ resolve(message.result);
4639
+ }
4640
+ }
4641
+ },
4642
+ options
4643
+ );
4644
+ });
4645
+ subscriptionId = await safeRace([abortPromise, subscriptionIdPromise]);
4646
+ if (subscriptionId == null) {
4647
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID);
4648
+ }
4649
+ incrementSubscriberCount(channel, subscriptionId);
4650
+ const notificationPublisher = getMemoizedDemultiplexedNotificationPublisherFromChannelAndResponseTransformer(
4651
+ channel,
4652
+ subscribeRequest,
4653
+ responseTransformer
4654
+ );
4655
+ const notificationKey = `notification:${subscriptionId}`;
4656
+ return {
4657
+ on(type, listener, options) {
4658
+ switch (type) {
4659
+ case "notification":
4660
+ return notificationPublisher.on(
4661
+ notificationKey,
4662
+ listener,
4663
+ options
4664
+ );
4665
+ case "error":
4666
+ return channel.on(
4667
+ "error",
4668
+ listener,
4669
+ options
4670
+ );
4671
+ default:
4672
+ throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED, {
4673
+ channelName: type,
4674
+ supportedChannelNames: ["notification", "error"]
4675
+ });
4676
+ }
4677
+ }
4678
+ };
4679
+ }
4090
4680
 
4091
4681
  // ../rpc-subscriptions-api/dist/index.browser.mjs
4092
4682
  function createSolanaRpcSubscriptionsApi_INTERNAL(config) {
4683
+ const requestTransformer = getDefaultRequestTransformerForSolanaRpc(config);
4684
+ const responseTransformer = getDefaultResponseTransformerForSolanaRpcSubscriptions({
4685
+ allowedNumericKeyPaths: getAllowedNumericKeypaths2()
4686
+ });
4093
4687
  return createRpcSubscriptionsApi({
4094
- parametersTransformer: getDefaultParamsTransformerForSolanaRpc(config),
4095
- responseTransformer: getDefaultResponseTransformerForSolanaRpc({
4096
- allowedNumericKeyPaths: getAllowedNumericKeypaths2()
4097
- }),
4098
- subscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Subscribe"),
4099
- unsubscribeNotificationNameTransformer: (notificationName) => notificationName.replace(/Notifications$/, "Unsubscribe")
4688
+ planExecutor({ request, ...rest }) {
4689
+ return executeRpcPubSubSubscriptionPlan({
4690
+ ...rest,
4691
+ responseTransformer,
4692
+ subscribeRequest: { ...request, methodName: request.methodName.replace(/Notifications$/, "Subscribe") },
4693
+ unsubscribeMethodName: request.methodName.replace(/Notifications$/, "Unsubscribe")
4694
+ });
4695
+ },
4696
+ requestTransformer
4100
4697
  });
4101
4698
  }
4102
4699
  function createSolanaRpcSubscriptionsApi(config) {
@@ -4113,7 +4710,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
4113
4710
  memoizedKeypaths2 = {
4114
4711
  accountNotifications: jsonParsedAccountsConfigs.map((c) => ["value", ...c]),
4115
4712
  blockNotifications: [
4116
- ["value", "block", "blockTime"],
4117
4713
  [
4118
4714
  "value",
4119
4715
  "block",
@@ -4280,184 +4876,133 @@ this.globalThis.solanaWeb3 = (function (exports) {
4280
4876
  return memoizedKeypaths2;
4281
4877
  }
4282
4878
 
4283
- // ../rpc-subscriptions-transport-websocket/dist/index.browser.mjs
4879
+ // ../rpc-subscriptions-channel-websocket/dist/index.browser.mjs
4284
4880
  var e2 = globalThis.WebSocket;
4285
- var EXPLICIT_ABORT_TOKEN2;
4286
- function createExplicitAbortToken2() {
4287
- return Symbol(
4288
- "This symbol is thrown from a socket's iterator when the connection is explicitly aborted by the user"
4289
- );
4290
- }
4291
- async function createWebSocketConnection({
4881
+ var NORMAL_CLOSURE_CODE = 1e3;
4882
+ function createWebSocketChannel({
4292
4883
  sendBufferHighWatermark,
4293
4884
  signal,
4294
4885
  url
4295
4886
  }) {
4296
- return await new Promise((resolve, reject) => {
4297
- signal.addEventListener("abort", handleAbort, { once: true });
4298
- const iteratorState = /* @__PURE__ */ new Map();
4299
- function errorAndClearAllIteratorStates(reason) {
4300
- const errorCallbacks = [...iteratorState.values()].filter((state) => state.__hasPolled).map(({ onError }) => onError);
4301
- iteratorState.clear();
4302
- errorCallbacks.forEach((cb) => {
4303
- try {
4304
- cb(reason);
4305
- } catch {
4306
- }
4307
- });
4887
+ if (signal.aborted) {
4888
+ return Promise.reject(signal.reason);
4889
+ }
4890
+ let bufferDrainWatcher;
4891
+ let hasConnected = false;
4892
+ const listenerRemovers = /* @__PURE__ */ new Set();
4893
+ function cleanupListeners() {
4894
+ listenerRemovers.forEach((r) => {
4895
+ r();
4896
+ });
4897
+ listenerRemovers.clear();
4898
+ }
4899
+ function handleAbort() {
4900
+ cleanupListeners();
4901
+ if (!hasConnected) {
4902
+ rejectOpen(signal.reason);
4903
+ }
4904
+ if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
4905
+ webSocket.close(NORMAL_CLOSURE_CODE);
4906
+ }
4907
+ }
4908
+ function handleClose(ev) {
4909
+ cleanupListeners();
4910
+ bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
4911
+ signal.removeEventListener("abort", handleAbort);
4912
+ webSocket.removeEventListener("close", handleClose);
4913
+ webSocket.removeEventListener("error", handleError);
4914
+ webSocket.removeEventListener("message", handleMessage);
4915
+ webSocket.removeEventListener("open", handleOpen);
4916
+ if (!signal.aborted && !(ev.wasClean && ev.code === NORMAL_CLOSURE_CODE)) {
4917
+ eventTarget.dispatchEvent(
4918
+ new CustomEvent("error", {
4919
+ detail: new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED, {
4920
+ cause: ev
4921
+ })
4922
+ })
4923
+ );
4308
4924
  }
4309
- function handleAbort() {
4310
- errorAndClearAllIteratorStates(EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()));
4311
- if (webSocket.readyState !== e2.CLOSED && webSocket.readyState !== e2.CLOSING) {
4312
- webSocket.close(1e3);
4313
- }
4925
+ }
4926
+ function handleError(ev) {
4927
+ if (signal.aborted) {
4928
+ return;
4314
4929
  }
4315
- function handleClose(ev) {
4316
- bufferDrainWatcher == null ? void 0 : bufferDrainWatcher.onCancel();
4317
- signal.removeEventListener("abort", handleAbort);
4318
- webSocket.removeEventListener("close", handleClose);
4319
- webSocket.removeEventListener("error", handleError);
4320
- webSocket.removeEventListener("open", handleOpen);
4321
- webSocket.removeEventListener("message", handleMessage);
4322
- errorAndClearAllIteratorStates(ev);
4323
- }
4324
- function handleError(ev) {
4325
- if (!hasConnected) {
4326
- reject(
4327
- new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT, {
4328
- errorEvent: ev
4329
- })
4330
- );
4331
- }
4930
+ if (!hasConnected) {
4931
+ const failedToConnectError = new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT, {
4932
+ errorEvent: ev
4933
+ });
4934
+ rejectOpen(failedToConnectError);
4935
+ eventTarget.dispatchEvent(
4936
+ new CustomEvent("error", {
4937
+ detail: failedToConnectError
4938
+ })
4939
+ );
4332
4940
  }
4333
- let hasConnected = false;
4334
- let bufferDrainWatcher;
4335
- function handleOpen() {
4336
- hasConnected = true;
4337
- resolve({
4338
- async send(payload) {
4339
- const message = JSON.stringify(payload);
4340
- if (!bufferDrainWatcher && webSocket.readyState === e2.OPEN && webSocket.bufferedAmount > sendBufferHighWatermark) {
4341
- let onCancel;
4342
- const promise = new Promise((resolve2, reject2) => {
4343
- const intervalId = setInterval(() => {
4344
- if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
4345
- clearInterval(intervalId);
4346
- bufferDrainWatcher = void 0;
4347
- resolve2();
4348
- }
4349
- }, 16);
4350
- onCancel = () => {
4351
- bufferDrainWatcher = void 0;
4941
+ }
4942
+ function handleMessage(ev) {
4943
+ if (signal.aborted) {
4944
+ return;
4945
+ }
4946
+ eventTarget.dispatchEvent(new CustomEvent("message", { detail: ev.data }));
4947
+ }
4948
+ const eventTarget = new EventTarget();
4949
+ const dataPublisher = getDataPublisherFromEventEmitter(eventTarget);
4950
+ function handleOpen() {
4951
+ hasConnected = true;
4952
+ resolveOpen({
4953
+ ...dataPublisher,
4954
+ async send(message) {
4955
+ if (webSocket.readyState !== e2.OPEN) {
4956
+ throw new SolanaError(SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED);
4957
+ }
4958
+ if (!bufferDrainWatcher && webSocket.bufferedAmount > sendBufferHighWatermark) {
4959
+ let onCancel;
4960
+ const promise = new Promise((resolve, reject) => {
4961
+ const intervalId = setInterval(() => {
4962
+ if (webSocket.readyState !== e2.OPEN || !(webSocket.bufferedAmount > sendBufferHighWatermark)) {
4352
4963
  clearInterval(intervalId);
4353
- reject2(
4354
- new SolanaError(
4355
- SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED
4356
- )
4357
- );
4358
- };
4359
- });
4360
- bufferDrainWatcher = {
4361
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
4362
- // @ts-ignore
4363
- onCancel,
4364
- promise
4365
- };
4366
- }
4367
- if (bufferDrainWatcher) {
4368
- await bufferDrainWatcher.promise;
4369
- }
4370
- webSocket.send(message);
4371
- },
4372
- async *[Symbol.asyncIterator]() {
4373
- const iteratorKey = Symbol();
4374
- iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
4375
- try {
4376
- while (true) {
4377
- const state = iteratorState.get(iteratorKey);
4378
- if (!state) {
4379
- throw new SolanaError(
4380
- SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING
4381
- );
4382
- }
4383
- if (state.__hasPolled) {
4384
- throw new SolanaError(
4385
- SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE
4386
- );
4387
- }
4388
- const queuedMessages = state.queuedMessages;
4389
- if (queuedMessages.length) {
4390
- state.queuedMessages = [];
4391
- yield* queuedMessages;
4392
- } else {
4393
- try {
4394
- yield await new Promise((resolve2, reject2) => {
4395
- iteratorState.set(iteratorKey, {
4396
- __hasPolled: true,
4397
- onError: reject2,
4398
- onMessage: resolve2
4399
- });
4400
- });
4401
- } catch (e22) {
4402
- if (e22 === (EXPLICIT_ABORT_TOKEN2 || (EXPLICIT_ABORT_TOKEN2 = createExplicitAbortToken2()))) {
4403
- return;
4404
- } else {
4405
- throw new SolanaError(
4406
- SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED,
4407
- {
4408
- cause: e22
4409
- }
4410
- );
4411
- }
4412
- }
4964
+ bufferDrainWatcher = void 0;
4965
+ resolve();
4413
4966
  }
4414
- }
4415
- } finally {
4416
- iteratorState.delete(iteratorKey);
4417
- }
4967
+ }, 16);
4968
+ onCancel = () => {
4969
+ bufferDrainWatcher = void 0;
4970
+ clearInterval(intervalId);
4971
+ reject(
4972
+ new SolanaError(
4973
+ SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED
4974
+ )
4975
+ );
4976
+ };
4977
+ });
4978
+ bufferDrainWatcher = {
4979
+ onCancel,
4980
+ promise
4981
+ };
4418
4982
  }
4419
- });
4420
- }
4421
- function handleMessage({ data }) {
4422
- const message = JSON.parse(data);
4423
- iteratorState.forEach((state, iteratorKey) => {
4424
- if (state.__hasPolled) {
4425
- const { onMessage } = state;
4426
- iteratorState.set(iteratorKey, { __hasPolled: false, queuedMessages: [] });
4427
- onMessage(message);
4428
- } else {
4429
- state.queuedMessages.push(message);
4983
+ if (bufferDrainWatcher) {
4984
+ if (ArrayBuffer.isView(message) && !(message instanceof DataView)) {
4985
+ const TypedArrayConstructor = message.constructor;
4986
+ message = new TypedArrayConstructor(message);
4987
+ }
4988
+ await bufferDrainWatcher.promise;
4430
4989
  }
4431
- });
4432
- }
4433
- const webSocket = new e2(url);
4434
- webSocket.addEventListener("close", handleClose);
4435
- webSocket.addEventListener("error", handleError);
4436
- webSocket.addEventListener("open", handleOpen);
4437
- webSocket.addEventListener("message", handleMessage);
4438
- });
4439
- }
4440
- function createWebSocketTransport({ sendBufferHighWatermark, url }) {
4441
- if (/^wss?:/i.test(url) === false) {
4442
- const protocolMatch = url.match(/^([^:]+):/);
4443
- throw new DOMException(
4444
- 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.`
4445
- );
4446
- }
4447
- return async function sendWebSocketMessage({ payload, signal }) {
4448
- signal == null ? void 0 : signal.throwIfAborted();
4449
- const connection = await createWebSocketConnection({
4450
- sendBufferHighWatermark,
4451
- signal,
4452
- url
4990
+ webSocket.send(message);
4991
+ }
4453
4992
  });
4454
- signal == null ? void 0 : signal.throwIfAborted();
4455
- await connection.send(payload);
4456
- return {
4457
- [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
4458
- send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: connection.send.bind(connection)
4459
- };
4460
- };
4993
+ }
4994
+ const webSocket = new e2(url);
4995
+ signal.addEventListener("abort", handleAbort);
4996
+ webSocket.addEventListener("close", handleClose);
4997
+ webSocket.addEventListener("error", handleError);
4998
+ webSocket.addEventListener("message", handleMessage);
4999
+ webSocket.addEventListener("open", handleOpen);
5000
+ let rejectOpen;
5001
+ let resolveOpen;
5002
+ return new Promise((resolve, reject) => {
5003
+ rejectOpen = reject;
5004
+ resolveOpen = resolve;
5005
+ });
4461
5006
  }
4462
5007
 
4463
5008
  // ../rpc-subscriptions/dist/index.browser.mjs
@@ -4493,317 +5038,302 @@ this.globalThis.solanaWeb3 = (function (exports) {
4493
5038
  }
4494
5039
  var DEFAULT_RPC_SUBSCRIPTIONS_CONFIG = {
4495
5040
  defaultCommitment: "confirmed",
4496
- onIntegerOverflow(methodName, keyPath, value) {
4497
- throw createSolanaJsonRpcIntegerOverflowError2(methodName, keyPath, value);
5041
+ onIntegerOverflow(request, keyPath, value) {
5042
+ throw createSolanaJsonRpcIntegerOverflowError2(request.methodName, keyPath, value);
4498
5043
  }
4499
5044
  };
4500
- function registerIterableCleanup2(iterable, cleanupFn) {
4501
- (async () => {
4502
- try {
4503
- for await (const _ of iterable) ;
4504
- } catch {
4505
- } finally {
4506
- cleanupFn();
4507
- }
4508
- })();
4509
- }
4510
- function getCachedAbortableIterableFactory({
4511
- getAbortSignalFromInputArgs,
4512
- getCacheKeyFromInputArgs,
4513
- onCacheHit,
4514
- onCreateIterable
5045
+ var PING_PAYLOAD = {
5046
+ jsonrpc: "2.0",
5047
+ method: "ping"
5048
+ };
5049
+ function getRpcSubscriptionsChannelWithAutoping({
5050
+ abortSignal: callerAbortSignal,
5051
+ channel,
5052
+ intervalMs
4515
5053
  }) {
4516
- const cache = /* @__PURE__ */ new Map();
4517
- function getCacheEntryOrThrow(cacheKey) {
4518
- const currentCacheEntry = cache.get(cacheKey);
4519
- if (!currentCacheEntry) {
4520
- throw new SolanaError(SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING, {
4521
- cacheKey: cacheKey.toString()
4522
- });
4523
- }
4524
- return currentCacheEntry;
5054
+ let intervalId;
5055
+ function sendPing() {
5056
+ channel.send(PING_PAYLOAD).catch((e3) => {
5057
+ if (isSolanaError(e3, SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED)) {
5058
+ pingerAbortController.abort();
5059
+ }
5060
+ });
4525
5061
  }
4526
- return async (...args) => {
4527
- const cacheKey = getCacheKeyFromInputArgs(...args);
4528
- const signal = getAbortSignalFromInputArgs(...args);
4529
- if (cacheKey === void 0) {
4530
- return await onCreateIterable(signal, ...args);
4531
- }
4532
- const cleanup = () => {
4533
- cache.delete(cacheKey);
4534
- signal.removeEventListener("abort", handleAbort);
4535
- };
4536
- const handleAbort = () => {
4537
- const cacheEntry = getCacheEntryOrThrow(cacheKey);
4538
- if (cacheEntry.purgeScheduled !== true) {
4539
- cacheEntry.purgeScheduled = true;
4540
- globalThis.queueMicrotask(() => {
4541
- cacheEntry.purgeScheduled = false;
4542
- if (cacheEntry.referenceCount === 0) {
4543
- cacheEntry.abortController.abort();
4544
- cleanup();
4545
- }
4546
- });
5062
+ function restartPingTimer() {
5063
+ clearInterval(intervalId);
5064
+ intervalId = setInterval(sendPing, intervalMs);
5065
+ }
5066
+ const pingerAbortController = new AbortController();
5067
+ pingerAbortController.signal.addEventListener("abort", () => {
5068
+ clearInterval(intervalId);
5069
+ });
5070
+ callerAbortSignal.addEventListener("abort", () => {
5071
+ pingerAbortController.abort();
5072
+ });
5073
+ channel.on(
5074
+ "error",
5075
+ () => {
5076
+ pingerAbortController.abort();
5077
+ },
5078
+ { signal: pingerAbortController.signal }
5079
+ );
5080
+ channel.on("message", restartPingTimer, { signal: pingerAbortController.signal });
5081
+ if (globalThis.navigator.onLine) {
5082
+ restartPingTimer();
5083
+ }
5084
+ {
5085
+ globalThis.window.addEventListener(
5086
+ "offline",
5087
+ function handleOffline() {
5088
+ clearInterval(intervalId);
5089
+ },
5090
+ { signal: pingerAbortController.signal }
5091
+ );
5092
+ globalThis.window.addEventListener(
5093
+ "online",
5094
+ function handleOnline() {
5095
+ sendPing();
5096
+ restartPingTimer();
5097
+ },
5098
+ { signal: pingerAbortController.signal }
5099
+ );
5100
+ }
5101
+ return {
5102
+ ...channel,
5103
+ send(...args) {
5104
+ if (!pingerAbortController.signal.aborted) {
5105
+ restartPingTimer();
4547
5106
  }
4548
- cacheEntry.referenceCount--;
4549
- };
4550
- signal.addEventListener("abort", handleAbort);
4551
- try {
4552
- const cacheEntry = cache.get(cacheKey);
4553
- if (!cacheEntry) {
4554
- const singletonAbortController = new AbortController();
4555
- const newIterablePromise = onCreateIterable(singletonAbortController.signal, ...args);
4556
- const newCacheEntry = {
4557
- abortController: singletonAbortController,
4558
- iterable: newIterablePromise,
4559
- purgeScheduled: false,
4560
- referenceCount: 1
5107
+ return channel.send(...args);
5108
+ }
5109
+ };
5110
+ }
5111
+ function createChannelPool() {
5112
+ return {
5113
+ entries: [],
5114
+ freeChannelIndex: -1
5115
+ };
5116
+ }
5117
+ function getChannelPoolingChannelCreator(createChannel, { maxSubscriptionsPerChannel, minChannels }) {
5118
+ const pool = createChannelPool();
5119
+ function recomputeFreeChannelIndex() {
5120
+ var _a;
5121
+ if (pool.entries.length < minChannels) {
5122
+ pool.freeChannelIndex = -1;
5123
+ return;
5124
+ }
5125
+ let mostFreeChannel;
5126
+ for (let ii = 0; ii < pool.entries.length; ii++) {
5127
+ const nextPoolIndex = (pool.freeChannelIndex + ii + 2) % pool.entries.length;
5128
+ const nextPoolEntry = (
5129
+ // Start from the item two positions after the current item. This way, the
5130
+ // search will finish on the item after the current one. This ensures that, if
5131
+ // any channels tie for having the most capacity, the one that will be chosen is
5132
+ // the one immediately to the current one's right (wrapping around).
5133
+ pool.entries[nextPoolIndex]
5134
+ );
5135
+ if (nextPoolEntry.subscriptionCount < maxSubscriptionsPerChannel && (!mostFreeChannel || mostFreeChannel.subscriptionCount >= nextPoolEntry.subscriptionCount)) {
5136
+ mostFreeChannel = {
5137
+ poolIndex: nextPoolIndex,
5138
+ subscriptionCount: nextPoolEntry.subscriptionCount
4561
5139
  };
4562
- cache.set(cacheKey, newCacheEntry);
4563
- const newIterable = await newIterablePromise;
4564
- registerIterableCleanup2(newIterable, cleanup);
4565
- newCacheEntry.iterable = newIterable;
4566
- return newIterable;
4567
- } else {
4568
- cacheEntry.referenceCount++;
4569
- const iterableOrIterablePromise = cacheEntry.iterable;
4570
- const cachedIterable = "then" in iterableOrIterablePromise ? await iterableOrIterablePromise : iterableOrIterablePromise;
4571
- await onCacheHit(cachedIterable, ...args);
4572
- return cachedIterable;
4573
5140
  }
4574
- } catch (e3) {
4575
- cleanup();
4576
- throw e3;
4577
5141
  }
5142
+ pool.freeChannelIndex = (_a = mostFreeChannel == null ? void 0 : mostFreeChannel.poolIndex) != null ? _a : -1;
5143
+ }
5144
+ return function getExistingChannelWithMostCapacityOrCreateChannel({ abortSignal }) {
5145
+ let poolEntry;
5146
+ function destroyPoolEntry() {
5147
+ const index = pool.entries.findIndex((entry) => entry === poolEntry);
5148
+ pool.entries.splice(index, 1);
5149
+ poolEntry.dispose();
5150
+ recomputeFreeChannelIndex();
5151
+ }
5152
+ if (pool.freeChannelIndex === -1) {
5153
+ const abortController = new AbortController();
5154
+ const newChannelPromise = createChannel({ abortSignal: abortController.signal });
5155
+ newChannelPromise.then((newChannel) => {
5156
+ newChannel.on("error", destroyPoolEntry, { signal: abortController.signal });
5157
+ }).catch(destroyPoolEntry);
5158
+ poolEntry = {
5159
+ channel: newChannelPromise,
5160
+ dispose() {
5161
+ abortController.abort();
5162
+ },
5163
+ subscriptionCount: 0
5164
+ };
5165
+ pool.entries.push(poolEntry);
5166
+ } else {
5167
+ poolEntry = pool.entries[pool.freeChannelIndex];
5168
+ }
5169
+ poolEntry.subscriptionCount++;
5170
+ abortSignal.addEventListener("abort", function destroyConsumer() {
5171
+ poolEntry.subscriptionCount--;
5172
+ if (poolEntry.subscriptionCount === 0) {
5173
+ destroyPoolEntry();
5174
+ } else if (pool.freeChannelIndex !== -1) {
5175
+ pool.freeChannelIndex--;
5176
+ recomputeFreeChannelIndex();
5177
+ }
5178
+ });
5179
+ recomputeFreeChannelIndex();
5180
+ return poolEntry.channel;
4578
5181
  };
4579
5182
  }
4580
- var EXPLICIT_ABORT_TOKEN3;
4581
- function createExplicitAbortToken3() {
4582
- return Symbol(
4583
- "This symbol is thrown from a subscription's iterator when the subscription is explicitly aborted by the user"
5183
+ function getRpcSubscriptionsChannelWithJSONSerialization(channel) {
5184
+ return pipe(
5185
+ channel,
5186
+ (c) => transformChannelInboundMessages(c, JSON.parse),
5187
+ (c) => transformChannelOutboundMessages(c, JSON.stringify)
4584
5188
  );
4585
5189
  }
4586
- function registerIterableCleanup22(iterable, cleanupFn) {
4587
- (async () => {
4588
- try {
4589
- for await (const _ of iterable) ;
4590
- } catch {
4591
- } finally {
4592
- cleanupFn();
4593
- }
4594
- })();
5190
+ function getRpcSubscriptionsChannelWithBigIntJSONSerialization(channel) {
5191
+ return pipe(
5192
+ channel,
5193
+ (c) => transformChannelInboundMessages(c, parseJsonWithBigInts),
5194
+ (c) => transformChannelOutboundMessages(c, stringifyJsonWithBigints)
5195
+ );
4595
5196
  }
4596
- function getRpcSubscriptionsWithSubscriptionCoalescing({
4597
- getDeduplicationKey,
4598
- rpcSubscriptions
4599
- }) {
4600
- const cache = /* @__PURE__ */ new Map();
4601
- return new Proxy(rpcSubscriptions, {
4602
- defineProperty() {
4603
- return false;
4604
- },
4605
- deleteProperty() {
4606
- return false;
4607
- },
4608
- get(target, p, receiver) {
4609
- const subscriptionMethod = Reflect.get(target, p, receiver);
4610
- if (typeof subscriptionMethod !== "function") {
4611
- return subscriptionMethod;
4612
- }
4613
- return function(...rawParams) {
4614
- const deduplicationKey = getDeduplicationKey(p, rawParams);
4615
- if (deduplicationKey === void 0) {
4616
- return subscriptionMethod(...rawParams);
4617
- }
4618
- if (cache.has(deduplicationKey)) {
4619
- return cache.get(deduplicationKey);
4620
- }
4621
- const iterableFactory = getCachedAbortableIterableFactory({
4622
- getAbortSignalFromInputArgs: ({ abortSignal }) => abortSignal,
4623
- getCacheKeyFromInputArgs: () => deduplicationKey,
4624
- async onCacheHit(_iterable, _config) {
4625
- },
4626
- async onCreateIterable(abortSignal, config) {
4627
- const pendingSubscription2 = subscriptionMethod(
4628
- ...rawParams
4629
- );
4630
- const iterable = await pendingSubscription2.subscribe({
4631
- ...config,
4632
- abortSignal
4633
- });
4634
- registerIterableCleanup22(iterable, () => {
4635
- cache.delete(deduplicationKey);
4636
- });
4637
- return iterable;
4638
- }
4639
- });
4640
- const pendingSubscription = {
4641
- async subscribe(...args) {
4642
- const iterable = await iterableFactory(...args);
4643
- const { abortSignal } = args[0];
4644
- let abortPromise;
4645
- return {
4646
- ...iterable,
4647
- async *[Symbol.asyncIterator]() {
4648
- abortPromise || (abortPromise = abortSignal.aborted ? Promise.reject(EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3())) : new Promise((_, reject) => {
4649
- abortSignal.addEventListener("abort", () => {
4650
- reject(EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3()));
4651
- });
4652
- }));
4653
- try {
4654
- const iterator = iterable[Symbol.asyncIterator]();
4655
- while (true) {
4656
- const iteratorResult = await Promise.race([iterator.next(), abortPromise]);
4657
- if (iteratorResult.done) {
4658
- return;
4659
- } else {
4660
- yield iteratorResult.value;
4661
- }
4662
- }
4663
- } catch (e3) {
4664
- if (e3 === (EXPLICIT_ABORT_TOKEN3 || (EXPLICIT_ABORT_TOKEN3 = createExplicitAbortToken3()))) {
4665
- return;
4666
- }
4667
- cache.delete(deduplicationKey);
4668
- throw e3;
4669
- }
4670
- }
4671
- };
4672
- }
4673
- };
4674
- cache.set(deduplicationKey, pendingSubscription);
4675
- return pendingSubscription;
4676
- };
4677
- }
5197
+ function createDefaultSolanaRpcSubscriptionsChannelCreator(config) {
5198
+ return createDefaultRpcSubscriptionsChannelCreatorImpl({
5199
+ ...config,
5200
+ jsonSerializer: getRpcSubscriptionsChannelWithBigIntJSONSerialization
4678
5201
  });
4679
5202
  }
4680
- var PING_PAYLOAD = {
4681
- jsonrpc: "2.0",
4682
- method: "ping"
4683
- };
4684
- function getWebSocketTransportWithAutoping({
4685
- intervalMs,
4686
- transport
4687
- }) {
4688
- const pingableConnections = /* @__PURE__ */ new Map();
4689
- return async (...args) => {
4690
- const connection = await transport(...args);
4691
- let intervalId;
4692
- function sendPing() {
4693
- connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(PING_PAYLOAD);
4694
- }
4695
- function restartPingTimer() {
4696
- clearInterval(intervalId);
4697
- intervalId = setInterval(sendPing, intervalMs);
4698
- }
4699
- if (pingableConnections.has(connection) === false) {
4700
- pingableConnections.set(connection, {
4701
- [Symbol.asyncIterator]: connection[Symbol.asyncIterator].bind(connection),
4702
- send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: (...args2) => {
4703
- restartPingTimer();
4704
- return connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(...args2);
4705
- }
5203
+ function createDefaultRpcSubscriptionsChannelCreator(config) {
5204
+ return createDefaultRpcSubscriptionsChannelCreatorImpl({
5205
+ ...config,
5206
+ jsonSerializer: getRpcSubscriptionsChannelWithJSONSerialization
5207
+ });
5208
+ }
5209
+ function createDefaultRpcSubscriptionsChannelCreatorImpl(config) {
5210
+ var _a, _b;
5211
+ if (/^wss?:/i.test(config.url) === false) {
5212
+ const protocolMatch = config.url.match(/^([^:]+):/);
5213
+ throw new DOMException(
5214
+ 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 '${config.url}' is invalid.`
5215
+ );
5216
+ }
5217
+ const { intervalMs, ...rest } = config;
5218
+ const createDefaultRpcSubscriptionsChannel = ({ abortSignal }) => {
5219
+ var _a2;
5220
+ return createWebSocketChannel({
5221
+ ...rest,
5222
+ sendBufferHighWatermark: (_a2 = config.sendBufferHighWatermark) != null ? _a2 : (
5223
+ // Let 128KB of data into the WebSocket buffer before buffering it in the app.
5224
+ 131072
5225
+ ),
5226
+ signal: abortSignal
5227
+ }).then(config.jsonSerializer).then(
5228
+ (channel) => getRpcSubscriptionsChannelWithAutoping({
5229
+ abortSignal,
5230
+ channel,
5231
+ intervalMs: intervalMs != null ? intervalMs : 5e3
5232
+ })
5233
+ );
5234
+ };
5235
+ return getChannelPoolingChannelCreator(createDefaultRpcSubscriptionsChannel, {
5236
+ maxSubscriptionsPerChannel: (_a = config.maxSubscriptionsPerChannel) != null ? _a : (
5237
+ /**
5238
+ * A note about this default. The idea here is that, because some RPC providers impose
5239
+ * an upper limit on the number of subscriptions you can make per channel, we must
5240
+ * choose a number low enough to avoid hitting that limit. Without knowing what provider
5241
+ * a given person is using, or what their limit is, we have to choose the lowest of all
5242
+ * known limits. As of this writing (October 2024) that is the public mainnet RPC node
5243
+ * (api.mainnet-beta.solana.com) at 100 subscriptions.
5244
+ */
5245
+ 100
5246
+ ),
5247
+ minChannels: (_b = config.minChannels) != null ? _b : 1
5248
+ });
5249
+ }
5250
+ function getRpcSubscriptionsTransportWithSubscriptionCoalescing(transport) {
5251
+ const cache2 = /* @__PURE__ */ new Map();
5252
+ return function rpcSubscriptionsTransportWithSubscriptionCoalescing(config) {
5253
+ const { request, signal } = config;
5254
+ const subscriptionConfigurationHash = src_default([request.methodName, request.params]);
5255
+ let cachedDataPublisherPromise = cache2.get(subscriptionConfigurationHash);
5256
+ if (!cachedDataPublisherPromise) {
5257
+ const abortController = new AbortController();
5258
+ const dataPublisherPromise = transport({
5259
+ ...config,
5260
+ signal: abortController.signal
4706
5261
  });
4707
- (async () => {
4708
- try {
4709
- for await (const _ of connection) {
4710
- restartPingTimer();
4711
- }
4712
- } catch {
4713
- } finally {
4714
- pingableConnections.delete(connection);
4715
- clearInterval(intervalId);
4716
- if (handleOffline) {
4717
- globalThis.window.removeEventListener("offline", handleOffline);
4718
- }
4719
- if (handleOnline) {
4720
- globalThis.window.removeEventListener("online", handleOnline);
4721
- }
5262
+ dataPublisherPromise.then((dataPublisher) => {
5263
+ dataPublisher.on(
5264
+ "error",
5265
+ () => {
5266
+ cache2.delete(subscriptionConfigurationHash);
5267
+ abortController.abort();
5268
+ },
5269
+ { signal: abortController.signal }
5270
+ );
5271
+ }).catch(() => {
5272
+ });
5273
+ cache2.set(
5274
+ subscriptionConfigurationHash,
5275
+ cachedDataPublisherPromise = {
5276
+ abortController,
5277
+ dataPublisherPromise,
5278
+ numSubscribers: 0
4722
5279
  }
4723
- })();
4724
- if (globalThis.navigator.onLine) {
4725
- restartPingTimer();
4726
- }
4727
- let handleOffline;
4728
- let handleOnline;
4729
- {
4730
- handleOffline = () => {
4731
- clearInterval(intervalId);
4732
- };
4733
- handleOnline = () => {
4734
- sendPing();
4735
- restartPingTimer();
4736
- };
4737
- globalThis.window.addEventListener("offline", handleOffline);
4738
- globalThis.window.addEventListener("online", handleOnline);
4739
- }
5280
+ );
4740
5281
  }
4741
- return pingableConnections.get(connection);
5282
+ cachedDataPublisherPromise.numSubscribers++;
5283
+ signal.addEventListener(
5284
+ "abort",
5285
+ () => {
5286
+ cachedDataPublisherPromise.numSubscribers--;
5287
+ if (cachedDataPublisherPromise.numSubscribers === 0) {
5288
+ queueMicrotask(() => {
5289
+ if (cachedDataPublisherPromise.numSubscribers === 0) {
5290
+ cache2.delete(subscriptionConfigurationHash);
5291
+ cachedDataPublisherPromise.abortController.abort();
5292
+ }
5293
+ });
5294
+ }
5295
+ },
5296
+ { signal: cachedDataPublisherPromise.abortController.signal }
5297
+ );
5298
+ return cachedDataPublisherPromise.dataPublisherPromise;
4742
5299
  };
4743
5300
  }
4744
- var NULL_SHARD_CACHE_KEY;
4745
- function createNullShardCacheKey() {
4746
- return Symbol("Cache key to use when there is no connection sharding strategy" );
4747
- }
4748
- function getWebSocketTransportWithConnectionSharding({
4749
- getShard,
4750
- transport
5301
+ function createDefaultRpcSubscriptionsTransport({
5302
+ createChannel
4751
5303
  }) {
4752
- return getCachedAbortableIterableFactory({
4753
- getAbortSignalFromInputArgs: ({ signal }) => signal,
4754
- getCacheKeyFromInputArgs: ({ payload }) => getShard ? getShard(payload) : NULL_SHARD_CACHE_KEY || (NULL_SHARD_CACHE_KEY = createNullShardCacheKey()),
4755
- onCacheHit: (connection, { payload }) => connection.send_DO_NOT_USE_OR_YOU_WILL_BE_FIRED(payload),
4756
- onCreateIterable: (abortSignal, config) => transport({
4757
- ...config,
4758
- signal: abortSignal
4759
- })
4760
- });
4761
- }
4762
- function createDefaultRpcSubscriptionsTransport(config) {
4763
- var _a;
4764
- const { getShard, intervalMs, ...rest } = config;
4765
5304
  return pipe(
4766
- createWebSocketTransport({
4767
- ...rest,
4768
- sendBufferHighWatermark: (_a = config.sendBufferHighWatermark) != null ? _a : (
4769
- // Let 128KB of data into the WebSocket buffer before buffering it in the app.
4770
- 131072
4771
- )
4772
- }),
4773
- (transport) => getWebSocketTransportWithAutoping({
4774
- intervalMs: intervalMs != null ? intervalMs : 5e3,
4775
- transport
4776
- }),
4777
- (transport) => getWebSocketTransportWithConnectionSharding({
4778
- getShard,
4779
- transport
4780
- })
5305
+ createRpcSubscriptionsTransportFromChannelCreator(
5306
+ createChannel
5307
+ ),
5308
+ (transport) => getRpcSubscriptionsTransportWithSubscriptionCoalescing(transport)
4781
5309
  );
4782
5310
  }
4783
- function createSolanaRpcSubscriptions(clusterUrl, config) {
4784
- const transport = createDefaultRpcSubscriptionsTransport({ url: clusterUrl, ...config });
5311
+ function createRpcSubscriptionsTransportFromChannelCreator(createChannel) {
5312
+ return async ({ execute, signal }) => {
5313
+ const channel = await createChannel({ abortSignal: signal });
5314
+ return await execute({ channel, signal });
5315
+ };
5316
+ }
5317
+ function createSolanaRpcSubscriptionsImpl(clusterUrl, config) {
5318
+ const transport = createDefaultRpcSubscriptionsTransport({
5319
+ createChannel: createDefaultSolanaRpcSubscriptionsChannelCreator({ ...config, url: clusterUrl })
5320
+ });
4785
5321
  return createSolanaRpcSubscriptionsFromTransport(transport);
4786
5322
  }
5323
+ function createSolanaRpcSubscriptions(clusterUrl, config) {
5324
+ return createSolanaRpcSubscriptionsImpl(clusterUrl, config);
5325
+ }
4787
5326
  function createSolanaRpcSubscriptions_UNSTABLE(clusterUrl, config) {
4788
- return createSolanaRpcSubscriptions(
5327
+ return createSolanaRpcSubscriptionsImpl(
4789
5328
  clusterUrl,
4790
5329
  config
4791
5330
  );
4792
5331
  }
4793
5332
  function createSolanaRpcSubscriptionsFromTransport(transport) {
4794
- return pipe(
4795
- createSubscriptionRpc({
4796
- api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
4797
- transport
4798
- }),
4799
- (rpcSubscriptions) => getRpcSubscriptionsWithSubscriptionCoalescing({
4800
- getDeduplicationKey: (...args) => src_default(args),
4801
- rpcSubscriptions
4802
- })
4803
- );
4804
- }
4805
- function createSolanaRpcSubscriptionsFromTransport_UNSTABLE(transport) {
4806
- return createSolanaRpcSubscriptionsFromTransport(transport);
5333
+ return createSubscriptionRpc({
5334
+ api: createSolanaRpcSubscriptionsApi(DEFAULT_RPC_SUBSCRIPTIONS_CONFIG),
5335
+ transport
5336
+ });
4807
5337
  }
4808
5338
 
4809
5339
  // ../rpc-types/dist/index.browser.mjs
@@ -4955,7 +5485,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
4955
5485
  try {
4956
5486
  BigInt(putativeBigInt);
4957
5487
  return true;
4958
- } catch (_) {
5488
+ } catch {
4959
5489
  return false;
4960
5490
  }
4961
5491
  }
@@ -4986,14 +5516,13 @@ this.globalThis.solanaWeb3 = (function (exports) {
4986
5516
  assertIsStringifiedNumber(putativeNumber);
4987
5517
  return putativeNumber;
4988
5518
  }
5519
+ var maxI64Value = 9223372036854775807n;
5520
+ var minI64Value = -9223372036854775808n;
4989
5521
  function isUnixTimestamp(putativeTimestamp) {
4990
- if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
4991
- return false;
4992
- }
4993
- return true;
5522
+ return putativeTimestamp >= minI64Value && putativeTimestamp <= maxI64Value;
4994
5523
  }
4995
5524
  function assertIsUnixTimestamp(putativeTimestamp) {
4996
- if (putativeTimestamp > 864e13 || putativeTimestamp < -864e13) {
5525
+ if (putativeTimestamp < minI64Value || putativeTimestamp > maxI64Value) {
4997
5526
  throw new SolanaError(SOLANA_ERROR__TIMESTAMP_OUT_OF_RANGE, {
4998
5527
  value: putativeTimestamp
4999
5528
  });
@@ -5578,7 +6107,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5578
6107
  return orderedStaticAccounts.map(({ address: address2 }) => address2);
5579
6108
  }
5580
6109
  function compileTransactionMessage(transaction) {
5581
- const addressMap = getAddressMapFromInstructions(transaction.feePayer, transaction.instructions);
6110
+ const addressMap = getAddressMapFromInstructions(transaction.feePayer.address, transaction.instructions);
5582
6111
  const orderedAccounts = getOrderedAccountsFromAddressMap(addressMap);
5583
6112
  return {
5584
6113
  ...transaction.version !== "legacy" ? { addressTableLookups: getCompiledAddressTableLookups(orderedAccounts) } : null,
@@ -5717,17 +6246,21 @@ this.globalThis.solanaWeb3 = (function (exports) {
5717
6246
  })
5718
6247
  });
5719
6248
  }
5720
- function setTransactionMessageFeePayer(feePayer, transaction) {
5721
- if ("feePayer" in transaction && feePayer === transaction.feePayer) {
5722
- return transaction;
6249
+ function setTransactionMessageFeePayer(feePayer, transactionMessage) {
6250
+ var _a;
6251
+ if ("feePayer" in transactionMessage && feePayer === ((_a = transactionMessage.feePayer) == null ? void 0 : _a.address) && isAddressOnlyFeePayer(transactionMessage.feePayer)) {
6252
+ return transactionMessage;
5723
6253
  }
5724
6254
  const out = {
5725
- ...transaction,
5726
- feePayer
6255
+ ...transactionMessage,
6256
+ feePayer: Object.freeze({ address: feePayer })
5727
6257
  };
5728
6258
  Object.freeze(out);
5729
6259
  return out;
5730
6260
  }
6261
+ function isAddressOnlyFeePayer(feePayer) {
6262
+ return !!feePayer && "address" in feePayer && typeof feePayer.address === "string" && Object.keys(feePayer).length === 1;
6263
+ }
5731
6264
  function appendTransactionMessageInstruction(instruction, transaction) {
5732
6265
  return appendTransactionMessageInstructions([instruction], transaction);
5733
6266
  }
@@ -5961,9 +6494,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
5961
6494
  }
5962
6495
  function compileTransaction(transactionMessage) {
5963
6496
  const compiledMessage = compileTransactionMessage(transactionMessage);
5964
- const messageBytes = getCompiledTransactionMessageEncoder().encode(
5965
- compiledMessage
5966
- );
6497
+ const messageBytes = getCompiledTransactionMessageEncoder().encode(compiledMessage);
5967
6498
  const transactionSigners = compiledMessage.staticAccounts.slice(0, compiledMessage.header.numSignerAccounts);
5968
6499
  const signatures = {};
5969
6500
  for (const signerAddress of transactionSigners) {
@@ -6080,6 +6611,46 @@ this.globalThis.solanaWeb3 = (function (exports) {
6080
6611
  });
6081
6612
  return Object.values(deduplicated);
6082
6613
  }
6614
+ function isTransactionModifyingSigner(value) {
6615
+ return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";
6616
+ }
6617
+ function assertIsTransactionModifyingSigner(value) {
6618
+ if (!isTransactionModifyingSigner(value)) {
6619
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
6620
+ address: value.address
6621
+ });
6622
+ }
6623
+ }
6624
+ function isTransactionPartialSigner(value) {
6625
+ return "signTransactions" in value && typeof value.signTransactions === "function";
6626
+ }
6627
+ function assertIsTransactionPartialSigner(value) {
6628
+ if (!isTransactionPartialSigner(value)) {
6629
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
6630
+ address: value.address
6631
+ });
6632
+ }
6633
+ }
6634
+ function isTransactionSendingSigner(value) {
6635
+ return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";
6636
+ }
6637
+ function assertIsTransactionSendingSigner(value) {
6638
+ if (!isTransactionSendingSigner(value)) {
6639
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
6640
+ address: value.address
6641
+ });
6642
+ }
6643
+ }
6644
+ function isTransactionSigner(value) {
6645
+ return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);
6646
+ }
6647
+ function assertIsTransactionSigner(value) {
6648
+ if (!isTransactionSigner(value)) {
6649
+ throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
6650
+ address: value.address
6651
+ });
6652
+ }
6653
+ }
6083
6654
  function getSignersFromInstruction(instruction) {
6084
6655
  var _a;
6085
6656
  return deduplicateSigners(
@@ -6088,7 +6659,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6088
6659
  }
6089
6660
  function getSignersFromTransactionMessage(transaction) {
6090
6661
  return deduplicateSigners([
6091
- ...transaction.feePayerSigner ? [transaction.feePayerSigner] : [],
6662
+ ...transaction.feePayer && isTransactionSigner(transaction.feePayer) ? [transaction.feePayer] : [],
6092
6663
  ...transaction.instructions.flatMap(getSignersFromInstruction)
6093
6664
  ]);
6094
6665
  }
@@ -6117,19 +6688,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
6117
6688
  instructions: transactionMessage.instructions.map((instruction) => addSignersToInstruction(signers, instruction))
6118
6689
  });
6119
6690
  }
6120
- function setTransactionMessageFeePayerSigner(feePayerSigner, transactionMessage) {
6121
- if ("feePayer" in transactionMessage && feePayerSigner.address === transactionMessage.feePayer) {
6122
- if ("feePayerSigner" in transactionMessage)
6123
- return transactionMessage;
6124
- const out2 = { ...transactionMessage, feePayerSigner };
6125
- Object.freeze(out2);
6126
- return out2;
6127
- }
6128
- const out = {
6129
- ...transactionMessage,
6130
- feePayer: feePayerSigner.address,
6131
- feePayerSigner
6132
- };
6691
+ function setTransactionMessageFeePayerSigner(feePayer, transactionMessage) {
6692
+ Object.freeze(feePayer);
6693
+ const out = { ...transactionMessage, feePayer };
6133
6694
  Object.freeze(out);
6134
6695
  return out;
6135
6696
  }
@@ -6143,16 +6704,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
6143
6704
  });
6144
6705
  }
6145
6706
  }
6146
- function isTransactionPartialSigner(value) {
6147
- return "signTransactions" in value && typeof value.signTransactions === "function";
6148
- }
6149
- function assertIsTransactionPartialSigner(value) {
6150
- if (!isTransactionPartialSigner(value)) {
6151
- throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_PARTIAL_SIGNER, {
6152
- address: value.address
6153
- });
6154
- }
6155
- }
6156
6707
  function isKeyPairSigner(value) {
6157
6708
  return "keyPair" in value && typeof value.keyPair === "object" && isMessagePartialSigner(value) && isTransactionPartialSigner(value);
6158
6709
  }
@@ -6188,6 +6739,9 @@ this.globalThis.solanaWeb3 = (function (exports) {
6188
6739
  async function createKeyPairSignerFromBytes(bytes, extractable) {
6189
6740
  return await createSignerFromKeyPair(await createKeyPairFromBytes(bytes, extractable));
6190
6741
  }
6742
+ async function createKeyPairSignerFromPrivateKeyBytes(bytes, extractable) {
6743
+ return await createSignerFromKeyPair(await createKeyPairFromPrivateKeyBytes(bytes, extractable));
6744
+ }
6191
6745
  function isMessageModifyingSigner(value) {
6192
6746
  return isAddress(value.address) && "modifyAndSignMessages" in value && typeof value.modifyAndSignMessages === "function";
6193
6747
  }
@@ -6216,36 +6770,6 @@ this.globalThis.solanaWeb3 = (function (exports) {
6216
6770
  };
6217
6771
  return Object.freeze(out);
6218
6772
  }
6219
- function isTransactionModifyingSigner(value) {
6220
- return "modifyAndSignTransactions" in value && typeof value.modifyAndSignTransactions === "function";
6221
- }
6222
- function assertIsTransactionModifyingSigner(value) {
6223
- if (!isTransactionModifyingSigner(value)) {
6224
- throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_MODIFYING_SIGNER, {
6225
- address: value.address
6226
- });
6227
- }
6228
- }
6229
- function isTransactionSendingSigner(value) {
6230
- return "signAndSendTransactions" in value && typeof value.signAndSendTransactions === "function";
6231
- }
6232
- function assertIsTransactionSendingSigner(value) {
6233
- if (!isTransactionSendingSigner(value)) {
6234
- throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SENDING_SIGNER, {
6235
- address: value.address
6236
- });
6237
- }
6238
- }
6239
- function isTransactionSigner(value) {
6240
- return isTransactionPartialSigner(value) || isTransactionModifyingSigner(value) || isTransactionSendingSigner(value);
6241
- }
6242
- function assertIsTransactionSigner(value) {
6243
- if (!isTransactionSigner(value)) {
6244
- throw new SolanaError(SOLANA_ERROR__SIGNER__EXPECTED_TRANSACTION_SIGNER, {
6245
- address: value.address
6246
- });
6247
- }
6248
- }
6249
6773
  function isTransactionMessageWithSingleSendingSigner(transaction) {
6250
6774
  try {
6251
6775
  assertIsTransactionMessageWithSingleSendingSigner(transaction);
@@ -6381,6 +6905,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6381
6905
  commitment,
6382
6906
  lastValidBlockHeight
6383
6907
  }) {
6908
+ callerAbortSignal.throwIfAborted();
6384
6909
  const abortController = new AbortController();
6385
6910
  const handleAbort = () => {
6386
6911
  abortController.abort();
@@ -6398,6 +6923,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6398
6923
  rpcSubscriptions.slotNotifications().subscribe({ abortSignal: abortController.signal }),
6399
6924
  getBlockHeightAndDifferenceBetweenSlotHeightAndBlockHeight()
6400
6925
  ]);
6926
+ callerAbortSignal.throwIfAborted();
6401
6927
  let currentBlockHeight = initialBlockHeight;
6402
6928
  if (currentBlockHeight <= lastValidBlockHeight) {
6403
6929
  let lastKnownDifferenceBetweenSlotHeightAndBlockHeight = differenceBetweenSlotHeightAndBlockHeight;
@@ -6417,6 +6943,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6417
6943
  }
6418
6944
  }
6419
6945
  }
6946
+ callerAbortSignal.throwIfAborted();
6420
6947
  throw new SolanaError(SOLANA_ERROR__BLOCK_HEIGHT_EXCEEDED, {
6421
6948
  currentBlockHeight,
6422
6949
  lastValidBlockHeight
@@ -6490,7 +7017,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6490
7017
  }
6491
7018
  })();
6492
7019
  try {
6493
- return await Promise.race([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
7020
+ return await safeRace([nonceAccountDidAdvancePromise, nonceIsAlreadyInvalidPromise]);
6494
7021
  } finally {
6495
7022
  abortController.abort();
6496
7023
  }
@@ -6531,7 +7058,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6531
7058
  }
6532
7059
  })();
6533
7060
  try {
6534
- return await Promise.race([signatureDidCommitPromise, signatureStatusLookupPromise]);
7061
+ return await safeRace([signatureDidCommitPromise, signatureStatusLookupPromise]);
6535
7062
  } finally {
6536
7063
  abortController.abort();
6537
7064
  }
@@ -6573,7 +7100,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6573
7100
  ...config,
6574
7101
  abortSignal: abortController.signal
6575
7102
  });
6576
- return await Promise.race([
7103
+ return await safeRace([
6577
7104
  getRecentSignatureConfirmationPromise({
6578
7105
  abortSignal: abortController.signal,
6579
7106
  commitment,
@@ -6742,7 +7269,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6742
7269
  const wireTransactionBytes = getBase64EncodedWireTransaction(compiledTransaction);
6743
7270
  try {
6744
7271
  const {
6745
- value: { unitsConsumed }
7272
+ value: { err: transactionError, unitsConsumed }
6746
7273
  } = await rpc.simulateTransaction(wireTransactionBytes, {
6747
7274
  ...simulateConfig,
6748
7275
  encoding: "base64",
@@ -6753,8 +7280,15 @@ this.globalThis.solanaWeb3 = (function (exports) {
6753
7280
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT);
6754
7281
  }
6755
7282
  const downcastUnitsConsumed = unitsConsumed > 4294967295n ? 4294967295 : Number(unitsConsumed);
7283
+ if (transactionError) {
7284
+ throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT, {
7285
+ cause: transactionError,
7286
+ unitsConsumed: downcastUnitsConsumed
7287
+ });
7288
+ }
6756
7289
  return downcastUnitsConsumed;
6757
7290
  } catch (e3) {
7291
+ if (isSolanaError(e3, SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT)) throw e3;
6758
7292
  throw new SolanaError(SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT, {
6759
7293
  cause: e3
6760
7294
  });
@@ -6774,7 +7308,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6774
7308
  };
6775
7309
  }
6776
7310
 
6777
- // src/decode-transaction-message.ts
7311
+ // src/decompile-transaction-message-fetching-lookup-tables.ts
6778
7312
  async function fetchLookupTables(lookupTableAddresses, rpc, config) {
6779
7313
  const fetchedLookupTables = await fetchJsonParsedAccounts(
6780
7314
  rpc,
@@ -6790,7 +7324,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
6790
7324
  };
6791
7325
  }, {});
6792
7326
  }
6793
- async function decodeTransactionMessage(compiledTransactionMessage, rpc, config) {
7327
+ async function decompileTransactionMessageFetchingLookupTables(compiledTransactionMessage, rpc, config) {
6794
7328
  const lookupTables = "addressTableLookups" in compiledTransactionMessage && compiledTransactionMessage.addressTableLookups !== void 0 && compiledTransactionMessage.addressTableLookups.length > 0 ? compiledTransactionMessage.addressTableLookups : [];
6795
7329
  const lookupTableAddresses = lookupTables.map((l) => l.lookupTableAddress);
6796
7330
  const { lastValidBlockHeight, ...fetchAccountsConfig } = config != null ? config : {};
@@ -7059,9 +7593,10 @@ this.globalThis.solanaWeb3 = (function (exports) {
7059
7593
  exports.SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH = SOLANA_ERROR__INVALID_BLOCKHASH_BYTE_LENGTH;
7060
7594
  exports.SOLANA_ERROR__INVALID_NONCE = SOLANA_ERROR__INVALID_NONCE;
7061
7595
  exports.SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__CACHED_ABORTABLE_ITERABLE_CACHE_ENTRY_MISSING;
7596
+ exports.SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED = SOLANA_ERROR__INVARIANT_VIOLATION__DATA_PUBLISHER_CHANNEL_UNIMPLEMENTED;
7597
+ exports.SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE;
7598
+ exports.SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__SUBSCRIPTION_ITERATOR_STATE_MISSING;
7062
7599
  exports.SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE = SOLANA_ERROR__INVARIANT_VIOLATION__SWITCH_MUST_BE_EXHAUSTIVE;
7063
- exports.SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE = SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_MUST_NOT_POLL_BEFORE_RESOLVING_EXISTING_MESSAGE_PROMISE;
7064
- exports.SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING = SOLANA_ERROR__INVARIANT_VIOLATION__WEBSOCKET_MESSAGE_ITERATOR_STATE_MISSING;
7065
7600
  exports.SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR = SOLANA_ERROR__JSON_RPC__INTERNAL_ERROR;
7066
7601
  exports.SOLANA_ERROR__JSON_RPC__INVALID_PARAMS = SOLANA_ERROR__JSON_RPC__INVALID_PARAMS;
7067
7602
  exports.SOLANA_ERROR__JSON_RPC__INVALID_REQUEST = SOLANA_ERROR__JSON_RPC__INVALID_REQUEST;
@@ -7092,11 +7627,12 @@ this.globalThis.solanaWeb3 = (function (exports) {
7092
7627
  exports.SOLANA_ERROR__MALFORMED_BIGINT_STRING = SOLANA_ERROR__MALFORMED_BIGINT_STRING;
7093
7628
  exports.SOLANA_ERROR__MALFORMED_NUMBER_STRING = SOLANA_ERROR__MALFORMED_NUMBER_STRING;
7094
7629
  exports.SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND = SOLANA_ERROR__NONCE_ACCOUNT_NOT_FOUND;
7095
- exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_REQUEST;
7630
+ exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CANNOT_CREATE_SUBSCRIPTION_PLAN;
7631
+ exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CLOSED_BEFORE_MESSAGE_BUFFERED;
7632
+ exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_CONNECTION_CLOSED;
7633
+ exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT = SOLANA_ERROR__RPC_SUBSCRIPTIONS__CHANNEL_FAILED_TO_CONNECT;
7096
7634
  exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID = SOLANA_ERROR__RPC_SUBSCRIPTIONS__EXPECTED_SERVER_SUBSCRIPTION_ID;
7097
- exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CLOSED_BEFORE_MESSAGE_BUFFERED;
7098
- exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED = SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_CONNECTION_CLOSED;
7099
- exports.SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT = SOLANA_ERROR__RPC_SUBSCRIPTIONS__TRANSPORT_FAILED_TO_CONNECT;
7635
+ exports.SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD = SOLANA_ERROR__RPC__API_PLAN_MISSING_FOR_RPC_METHOD;
7100
7636
  exports.SOLANA_ERROR__RPC__INTEGER_OVERFLOW = SOLANA_ERROR__RPC__INTEGER_OVERFLOW;
7101
7637
  exports.SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR = SOLANA_ERROR__RPC__TRANSPORT_HTTP_ERROR;
7102
7638
  exports.SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN = SOLANA_ERROR__RPC__TRANSPORT_HTTP_HEADER_FORBIDDEN;
@@ -7112,6 +7648,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
7112
7648
  exports.SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS = SOLANA_ERROR__SIGNER__TRANSACTION_CANNOT_HAVE_MULTIPLE_SENDING_SIGNERS;
7113
7649
  exports.SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING = SOLANA_ERROR__SIGNER__TRANSACTION_SENDING_SIGNER_MISSING;
7114
7650
  exports.SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED = SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED;
7651
+ exports.SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY = SOLANA_ERROR__SUBTLE_CRYPTO__CANNOT_EXPORT_NON_EXTRACTABLE_KEY;
7115
7652
  exports.SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED = SOLANA_ERROR__SUBTLE_CRYPTO__DIGEST_UNIMPLEMENTED;
7116
7653
  exports.SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT = SOLANA_ERROR__SUBTLE_CRYPTO__DISALLOWED_IN_INSECURE_CONTEXT;
7117
7654
  exports.SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED = SOLANA_ERROR__SUBTLE_CRYPTO__ED25519_ALGORITHM_UNIMPLEMENTED;
@@ -7167,6 +7704,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
7167
7704
  exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING = SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_FEE_PAYER_MISSING;
7168
7705
  exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND = SOLANA_ERROR__TRANSACTION__FAILED_TO_DECOMPILE_INSTRUCTION_PROGRAM_ADDRESS_NOT_FOUND;
7169
7706
  exports.SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT = SOLANA_ERROR__TRANSACTION__FAILED_TO_ESTIMATE_COMPUTE_LIMIT;
7707
+ exports.SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT = SOLANA_ERROR__TRANSACTION__FAILED_WHEN_SIMULATING_TO_ESTIMATE_COMPUTE_LIMIT;
7170
7708
  exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_MISSING;
7171
7709
  exports.SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING = SOLANA_ERROR__TRANSACTION__FEE_PAYER_SIGNATURE_MISSING;
7172
7710
  exports.SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE = SOLANA_ERROR__TRANSACTION__INVALID_NONCE_TRANSACTION_FIRST_INSTRUCTION_MUST_BE_ADVANCE_NONCE;
@@ -7234,16 +7772,22 @@ this.globalThis.solanaWeb3 = (function (exports) {
7234
7772
  exports.createAddressWithSeed = createAddressWithSeed;
7235
7773
  exports.createCodec = createCodec;
7236
7774
  exports.createDecoder = createDecoder;
7775
+ exports.createDefaultRpcSubscriptionsChannelCreator = createDefaultRpcSubscriptionsChannelCreator;
7237
7776
  exports.createDefaultRpcSubscriptionsTransport = createDefaultRpcSubscriptionsTransport;
7238
7777
  exports.createDefaultRpcTransport = createDefaultRpcTransport;
7778
+ exports.createDefaultSolanaRpcSubscriptionsChannelCreator = createDefaultSolanaRpcSubscriptionsChannelCreator;
7239
7779
  exports.createEncoder = createEncoder;
7780
+ exports.createJsonRpcApi = createJsonRpcApi;
7240
7781
  exports.createKeyPairFromBytes = createKeyPairFromBytes;
7782
+ exports.createKeyPairFromPrivateKeyBytes = createKeyPairFromPrivateKeyBytes;
7241
7783
  exports.createKeyPairSignerFromBytes = createKeyPairSignerFromBytes;
7784
+ exports.createKeyPairSignerFromPrivateKeyBytes = createKeyPairSignerFromPrivateKeyBytes;
7242
7785
  exports.createNoopSigner = createNoopSigner;
7243
7786
  exports.createPrivateKeyFromBytes = createPrivateKeyFromBytes;
7244
7787
  exports.createRpc = createRpc;
7245
- exports.createRpcApi = createRpcApi;
7788
+ exports.createRpcMessage = createRpcMessage;
7246
7789
  exports.createRpcSubscriptionsApi = createRpcSubscriptionsApi;
7790
+ exports.createRpcSubscriptionsTransportFromChannelCreator = createRpcSubscriptionsTransportFromChannelCreator;
7247
7791
  exports.createSignableMessage = createSignableMessage;
7248
7792
  exports.createSignerFromKeyPair = createSignerFromKeyPair;
7249
7793
  exports.createSolanaRpc = createSolanaRpc;
@@ -7253,16 +7797,16 @@ this.globalThis.solanaWeb3 = (function (exports) {
7253
7797
  exports.createSolanaRpcSubscriptionsApi = createSolanaRpcSubscriptionsApi;
7254
7798
  exports.createSolanaRpcSubscriptionsApi_UNSTABLE = createSolanaRpcSubscriptionsApi_UNSTABLE;
7255
7799
  exports.createSolanaRpcSubscriptionsFromTransport = createSolanaRpcSubscriptionsFromTransport;
7256
- exports.createSolanaRpcSubscriptionsFromTransport_UNSTABLE = createSolanaRpcSubscriptionsFromTransport_UNSTABLE;
7257
7800
  exports.createSolanaRpcSubscriptions_UNSTABLE = createSolanaRpcSubscriptions_UNSTABLE;
7258
7801
  exports.createSubscriptionRpc = createSubscriptionRpc;
7259
7802
  exports.createTransactionMessage = createTransactionMessage;
7260
7803
  exports.decodeAccount = decodeAccount;
7261
- exports.decodeTransactionMessage = decodeTransactionMessage;
7262
7804
  exports.decompileTransactionMessage = decompileTransactionMessage;
7805
+ exports.decompileTransactionMessageFetchingLookupTables = decompileTransactionMessageFetchingLookupTables;
7263
7806
  exports.devnet = devnet;
7264
7807
  exports.downgradeRoleToNonSigner = downgradeRoleToNonSigner;
7265
7808
  exports.downgradeRoleToReadonly = downgradeRoleToReadonly;
7809
+ exports.executeRpcPubSubSubscriptionPlan = executeRpcPubSubSubscriptionPlan;
7266
7810
  exports.fetchEncodedAccount = fetchEncodedAccount;
7267
7811
  exports.fetchEncodedAccounts = fetchEncodedAccounts;
7268
7812
  exports.fetchJsonParsedAccount = fetchJsonParsedAccount;
@@ -7373,6 +7917,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
7373
7917
  exports.getOptionDecoder = getOptionDecoder;
7374
7918
  exports.getOptionEncoder = getOptionEncoder;
7375
7919
  exports.getProgramDerivedAddress = getProgramDerivedAddress;
7920
+ exports.getPublicKeyFromPrivateKey = getPublicKeyFromPrivateKey;
7921
+ exports.getRpcSubscriptionsChannelWithJSONSerialization = getRpcSubscriptionsChannelWithJSONSerialization;
7376
7922
  exports.getScalarEnumCodec = getScalarEnumCodec;
7377
7923
  exports.getScalarEnumDecoder = getScalarEnumDecoder;
7378
7924
  exports.getScalarEnumEncoder = getScalarEnumEncoder;
@@ -7432,6 +7978,7 @@ this.globalThis.solanaWeb3 = (function (exports) {
7432
7978
  exports.isInstructionForProgram = isInstructionForProgram;
7433
7979
  exports.isInstructionWithAccounts = isInstructionWithAccounts;
7434
7980
  exports.isInstructionWithData = isInstructionWithData;
7981
+ exports.isJsonRpcPayload = isJsonRpcPayload;
7435
7982
  exports.isKeyPairSigner = isKeyPairSigner;
7436
7983
  exports.isLamports = isLamports;
7437
7984
  exports.isMessageModifyingSigner = isMessageModifyingSigner;
@@ -7504,6 +8051,8 @@ this.globalThis.solanaWeb3 = (function (exports) {
7504
8051
  exports.stringifiedBigInt = stringifiedBigInt;
7505
8052
  exports.stringifiedNumber = stringifiedNumber;
7506
8053
  exports.testnet = testnet;
8054
+ exports.transformChannelInboundMessages = transformChannelInboundMessages;
8055
+ exports.transformChannelOutboundMessages = transformChannelOutboundMessages;
7507
8056
  exports.transformCodec = transformCodec;
7508
8057
  exports.transformDecoder = transformDecoder;
7509
8058
  exports.transformEncoder = transformEncoder;