@solana/web3.js 1.66.5 → 1.67.0

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.
@@ -3,6 +3,7 @@ import type {Buffer} from 'buffer';
3
3
  import {
4
4
  BlockheightBasedTransactionConfirmationStrategy,
5
5
  Connection,
6
+ DurableNonceTransactionConfirmationStrategy,
6
7
  } from '../connection';
7
8
  import type {TransactionSignature} from '../transaction';
8
9
  import type {ConfirmOptions} from '../connection';
@@ -42,12 +43,14 @@ export async function sendAndConfirmRawTransaction(
42
43
  rawTransaction: Buffer,
43
44
  confirmationStrategyOrConfirmOptions:
44
45
  | BlockheightBasedTransactionConfirmationStrategy
46
+ | DurableNonceTransactionConfirmationStrategy
45
47
  | ConfirmOptions
46
48
  | undefined,
47
49
  maybeConfirmOptions?: ConfirmOptions,
48
50
  ): Promise<TransactionSignature> {
49
51
  let confirmationStrategy:
50
52
  | BlockheightBasedTransactionConfirmationStrategy
53
+ | DurableNonceTransactionConfirmationStrategy
51
54
  | undefined;
52
55
  let options: ConfirmOptions | undefined;
53
56
  if (
@@ -60,6 +63,16 @@ export async function sendAndConfirmRawTransaction(
60
63
  confirmationStrategy =
61
64
  confirmationStrategyOrConfirmOptions as BlockheightBasedTransactionConfirmationStrategy;
62
65
  options = maybeConfirmOptions;
66
+ } else if (
67
+ confirmationStrategyOrConfirmOptions &&
68
+ Object.prototype.hasOwnProperty.call(
69
+ confirmationStrategyOrConfirmOptions,
70
+ 'nonceValue',
71
+ )
72
+ ) {
73
+ confirmationStrategy =
74
+ confirmationStrategyOrConfirmOptions as DurableNonceTransactionConfirmationStrategy;
75
+ options = maybeConfirmOptions;
63
76
  } else {
64
77
  options = confirmationStrategyOrConfirmOptions as
65
78
  | ConfirmOptions
@@ -1,4 +1,4 @@
1
- import {Connection} from '../connection';
1
+ import {Connection, SignatureResult} from '../connection';
2
2
  import {Transaction} from '../transaction';
3
3
  import type {ConfirmOptions} from '../connection';
4
4
  import type {Signer} from '../keypair';
@@ -34,25 +34,46 @@ export async function sendAndConfirmTransaction(
34
34
  sendOptions,
35
35
  );
36
36
 
37
- const status =
37
+ let status: SignatureResult;
38
+ if (
38
39
  transaction.recentBlockhash != null &&
39
40
  transaction.lastValidBlockHeight != null
40
- ? (
41
- await connection.confirmTransaction(
42
- {
43
- signature: signature,
44
- blockhash: transaction.recentBlockhash,
45
- lastValidBlockHeight: transaction.lastValidBlockHeight,
46
- },
47
- options && options.commitment,
48
- )
49
- ).value
50
- : (
51
- await connection.confirmTransaction(
52
- signature,
53
- options && options.commitment,
54
- )
55
- ).value;
41
+ ) {
42
+ status = (
43
+ await connection.confirmTransaction(
44
+ {
45
+ signature: signature,
46
+ blockhash: transaction.recentBlockhash,
47
+ lastValidBlockHeight: transaction.lastValidBlockHeight,
48
+ },
49
+ options && options.commitment,
50
+ )
51
+ ).value;
52
+ } else if (
53
+ transaction.minNonceContextSlot != null &&
54
+ transaction.nonceInfo != null
55
+ ) {
56
+ const {nonceInstruction} = transaction.nonceInfo;
57
+ const nonceAccountPubkey = nonceInstruction.keys[0].pubkey;
58
+ status = (
59
+ await connection.confirmTransaction(
60
+ {
61
+ minContextSlot: transaction.minNonceContextSlot,
62
+ nonceAccountPubkey,
63
+ nonceValue: transaction.nonceInfo.nonce,
64
+ signature,
65
+ },
66
+ options && options.commitment,
67
+ )
68
+ ).value;
69
+ } else {
70
+ status = (
71
+ await connection.confirmTransaction(
72
+ signature,
73
+ options && options.commitment,
74
+ )
75
+ ).value;
76
+ }
56
77
 
57
78
  if (status.err) {
58
79
  throw new Error(