@solana/web3.js 1.68.2 → 1.69.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs.js CHANGED
@@ -2270,6 +2270,7 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2270
2270
 
2271
2271
  if (transaction.recentBlockhash != null && transaction.lastValidBlockHeight != null) {
2272
2272
  status = (await connection.confirmTransaction({
2273
+ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
2273
2274
  signature: signature,
2274
2275
  blockhash: transaction.recentBlockhash,
2275
2276
  lastValidBlockHeight: transaction.lastValidBlockHeight
@@ -2280,12 +2281,17 @@ async function sendAndConfirmTransaction(connection, transaction, signers, optio
2280
2281
  } = transaction.nonceInfo;
2281
2282
  const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
2282
2283
  status = (await connection.confirmTransaction({
2284
+ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal,
2283
2285
  minContextSlot: transaction.minNonceContextSlot,
2284
2286
  nonceAccountPubkey,
2285
2287
  nonceValue: transaction.nonceInfo.nonce,
2286
2288
  signature
2287
2289
  }, options && options.commitment)).value;
2288
2290
  } else {
2291
+ if ((options === null || options === void 0 ? void 0 : options.abortSignal) != null) {
2292
+ console.warn('sendAndConfirmTransaction(): A transaction with a deprecated confirmation strategy was ' + 'supplied along with an `abortSignal`. Only transactions having `lastValidBlockHeight` ' + 'or a combination of `nonceInfo` and `minNonceContextSlot` are abortable.');
2293
+ }
2294
+
2289
2295
  status = (await connection.confirmTransaction(signature, options && options.commitment)).value;
2290
2296
  }
2291
2297
 
@@ -3498,7 +3504,7 @@ function nextPowerOfTwo(n) {
3498
3504
  /**
3499
3505
  * Epoch schedule
3500
3506
  * (see https://docs.solana.com/terminology#epoch)
3501
- * Can be retrieved with the {@link connection.getEpochSchedule} method
3507
+ * Can be retrieved with the {@link Connection.getEpochSchedule} method
3502
3508
  */
3503
3509
 
3504
3510
 
@@ -3773,13 +3779,10 @@ function extractCommitmentFromConfig(commitmentOrConfig) {
3773
3779
  };
3774
3780
  }
3775
3781
  /**
3776
- * A strategy for confirming durable nonce transactions.
3782
+ * @internal
3777
3783
  */
3778
3784
 
3779
3785
 
3780
- /**
3781
- * @internal
3782
- */
3783
3786
  function createRpcResult(result) {
3784
3787
  return superstruct.union([superstruct.type({
3785
3788
  jsonrpc: superstruct.literal('2.0'),
@@ -4778,7 +4781,7 @@ const LogsNotificationResult = superstruct.type({
4778
4781
 
4779
4782
  /** @internal */
4780
4783
  const COMMON_HTTP_HEADERS = {
4781
- 'solana-client': `js/${(_process$env$npm_pack = "1.68.2") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4784
+ 'solana-client': `js/${(_process$env$npm_pack = "1.69.1") !== null && _process$env$npm_pack !== void 0 ? _process$env$npm_pack : 'UNKNOWN'}`
4782
4785
  };
4783
4786
  /**
4784
4787
  * A connection to a fullnode JSON RPC endpoint
@@ -5394,7 +5397,14 @@ class Connection {
5394
5397
  if (typeof strategy == 'string') {
5395
5398
  rawSignature = strategy;
5396
5399
  } else {
5400
+ var _config$abortSignal;
5401
+
5397
5402
  const config = strategy;
5403
+
5404
+ if ((_config$abortSignal = config.abortSignal) !== null && _config$abortSignal !== void 0 && _config$abortSignal.aborted) {
5405
+ return Promise.reject(config.abortSignal.reason);
5406
+ }
5407
+
5398
5408
  rawSignature = config.signature;
5399
5409
  }
5400
5410
 
@@ -5426,6 +5436,22 @@ class Connection {
5426
5436
  }
5427
5437
  }
5428
5438
 
5439
+ getCancellationPromise(signal) {
5440
+ return new Promise((_, reject) => {
5441
+ if (signal == null) {
5442
+ return;
5443
+ }
5444
+
5445
+ if (signal.aborted) {
5446
+ reject(signal.reason);
5447
+ } else {
5448
+ signal.addEventListener('abort', () => {
5449
+ reject(signal.reason);
5450
+ });
5451
+ }
5452
+ });
5453
+ }
5454
+
5429
5455
  getTransactionConfirmationPromise({
5430
5456
  commitment,
5431
5457
  signature
@@ -5544,6 +5570,7 @@ class Connection {
5544
5570
  async confirmTransactionUsingBlockHeightExceedanceStrategy({
5545
5571
  commitment,
5546
5572
  strategy: {
5573
+ abortSignal,
5547
5574
  lastValidBlockHeight,
5548
5575
  signature
5549
5576
  }
@@ -5582,10 +5609,11 @@ class Connection {
5582
5609
  commitment,
5583
5610
  signature
5584
5611
  });
5612
+ const cancellationPromise = this.getCancellationPromise(abortSignal);
5585
5613
  let result;
5586
5614
 
5587
5615
  try {
5588
- const outcome = await Promise.race([confirmationPromise, expiryPromise]);
5616
+ const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
5589
5617
 
5590
5618
  if (outcome.__type === exports.TransactionStatus.PROCESSED) {
5591
5619
  result = outcome.response;
@@ -5603,6 +5631,7 @@ class Connection {
5603
5631
  async confirmTransactionUsingDurableNonceStrategy({
5604
5632
  commitment,
5605
5633
  strategy: {
5634
+ abortSignal,
5606
5635
  minContextSlot,
5607
5636
  nonceAccountPubkey,
5608
5637
  nonceValue,
@@ -5660,10 +5689,11 @@ class Connection {
5660
5689
  commitment,
5661
5690
  signature
5662
5691
  });
5692
+ const cancellationPromise = this.getCancellationPromise(abortSignal);
5663
5693
  let result;
5664
5694
 
5665
5695
  try {
5666
- const outcome = await Promise.race([confirmationPromise, expiryPromise]);
5696
+ const outcome = await Promise.race([cancellationPromise, confirmationPromise, expiryPromise]);
5667
5697
 
5668
5698
  if (outcome.__type === exports.TransactionStatus.PROCESSED) {
5669
5699
  result = outcome.response;