@solana/web3.js 1.66.4 → 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.
package/lib/index.d.ts CHANGED
@@ -205,12 +205,16 @@ declare module '@solana/web3.js' {
205
205
  }
206
206
 
207
207
  export const NONCE_ACCOUNT_LENGTH: number;
208
+ /**
209
+ * A durable nonce is a 32 byte value encoded as a base58 string.
210
+ */
211
+ export type DurableNonce = string;
208
212
  /**
209
213
  * NonceAccount class
210
214
  */
211
215
  export class NonceAccount {
212
216
  authorizedPubkey: PublicKey;
213
- nonce: Blockhash;
217
+ nonce: DurableNonce;
214
218
  feeCalculator: FeeCalculator;
215
219
  /**
216
220
  * Deserialize NonceAccount from the account data.
@@ -313,6 +317,10 @@ declare module '@solana/web3.js' {
313
317
  signature: string;
314
318
  constructor(signature: string, timeoutSeconds: number);
315
319
  }
320
+ export class TransactionExpiredNonceInvalidError extends Error {
321
+ signature: string;
322
+ constructor(signature: string);
323
+ }
316
324
 
317
325
  export type AccountKeysFromLookups = LoadedAddresses;
318
326
  export class MessageAccountKeys {
@@ -1642,6 +1650,7 @@ declare module '@solana/web3.js' {
1642
1650
  BLOCKHEIGHT_EXCEEDED = 0,
1643
1651
  PROCESSED = 1,
1644
1652
  TIMED_OUT = 2,
1653
+ NONCE_INVALID = 3,
1645
1654
  }
1646
1655
  /**
1647
1656
  * Account metadata used to define instructions
@@ -1712,7 +1721,9 @@ declare module '@solana/web3.js' {
1712
1721
  };
1713
1722
  export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
1714
1723
  /**
1715
- * List of Transaction object fields that may be initialized at construction
1724
+ * Blockhash-based transactions have a lifetime that are defined by
1725
+ * the blockhash they include. Any transaction whose blockhash is
1726
+ * too old will be rejected.
1716
1727
  */
1717
1728
  export type TransactionBlockhashCtor = {
1718
1729
  /** The transaction fee payer */
@@ -1724,6 +1735,17 @@ declare module '@solana/web3.js' {
1724
1735
  /** the last block chain can advance to before tx is exportd expired */
1725
1736
  lastValidBlockHeight: number;
1726
1737
  };
1738
+ /**
1739
+ * Use these options to construct a durable nonce transaction.
1740
+ */
1741
+ export type TransactionNonceCtor = {
1742
+ /** The transaction fee payer */
1743
+ feePayer?: PublicKey | null;
1744
+ minContextSlot: number;
1745
+ nonceInfo: NonceInformation;
1746
+ /** One or more signatures */
1747
+ signatures?: Array<SignaturePubkeyPair>;
1748
+ };
1727
1749
  /**
1728
1750
  * Nonce information to be used to build an offline Transaction.
1729
1751
  */
@@ -1767,7 +1789,16 @@ declare module '@solana/web3.js' {
1767
1789
  * Nonce hash instead of a recentBlockhash. Must be populated by the caller
1768
1790
  */
1769
1791
  nonceInfo?: NonceInformation;
1792
+ /**
1793
+ * If this is a nonce transaction this represents the minimum slot from which
1794
+ * to evaluate if the nonce has advanced when attempting to confirm the
1795
+ * transaction. This protects against a case where the transaction confirmation
1796
+ * logic loads the nonce account from an old slot and assumes the mismatch in
1797
+ * nonce value implies that the nonce has been advanced.
1798
+ */
1799
+ minNonceContextSlot?: number;
1770
1800
  constructor(opts?: TransactionBlockhashCtor);
1801
+ constructor(opts?: TransactionNonceCtor);
1771
1802
  /**
1772
1803
  * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
1773
1804
  * Please supply a `TransactionBlockhashCtor` instead.
@@ -1985,6 +2016,27 @@ declare module '@solana/web3.js' {
1985
2016
  export type BlockheightBasedTransactionConfirmationStrategy = {
1986
2017
  signature: TransactionSignature;
1987
2018
  } & BlockhashWithExpiryBlockHeight;
2019
+ /**
2020
+ * A strategy for confirming durable nonce transactions.
2021
+ */
2022
+ export type DurableNonceTransactionConfirmationStrategy = {
2023
+ /**
2024
+ * The lowest slot at which to fetch the nonce value from the
2025
+ * nonce account. This should be no lower than the slot at
2026
+ * which the last-known value of the nonce was fetched.
2027
+ */
2028
+ minContextSlot: number;
2029
+ /**
2030
+ * The account where the current value of the nonce is stored.
2031
+ */
2032
+ nonceAccountPubkey: PublicKey;
2033
+ /**
2034
+ * The nonce value that was used to sign the transaction
2035
+ * for which confirmation is being sought.
2036
+ */
2037
+ nonceValue: DurableNonce;
2038
+ signature: TransactionSignature;
2039
+ };
1988
2040
  /**
1989
2041
  * The level of commitment desired when querying state
1990
2042
  * <pre>
@@ -2941,6 +2993,24 @@ declare module '@solana/web3.js' {
2941
2993
  /** The minimum slot that the request can be evaluated at */
2942
2994
  minContextSlot?: number;
2943
2995
  };
2996
+ /**
2997
+ * Configuration object for `getNonce`
2998
+ */
2999
+ export type GetNonceConfig = {
3000
+ /** Optional commitment level */
3001
+ commitment?: Commitment;
3002
+ /** The minimum slot that the request can be evaluated at */
3003
+ minContextSlot?: number;
3004
+ };
3005
+ /**
3006
+ * Configuration object for `getNonceAndContext`
3007
+ */
3008
+ export type GetNonceAndContextConfig = {
3009
+ /** Optional commitment level */
3010
+ commitment?: Commitment;
3011
+ /** The minimum slot that the request can be evaluated at */
3012
+ minContextSlot?: number;
3013
+ };
2944
3014
  /**
2945
3015
  * Information describing an account
2946
3016
  */
@@ -3330,7 +3400,9 @@ declare module '@solana/web3.js' {
3330
3400
  }>
3331
3401
  >;
3332
3402
  confirmTransaction(
3333
- strategy: BlockheightBasedTransactionConfirmationStrategy,
3403
+ strategy:
3404
+ | BlockheightBasedTransactionConfirmationStrategy
3405
+ | DurableNonceTransactionConfirmationStrategy,
3334
3406
  commitment?: Commitment,
3335
3407
  ): Promise<RpcResponseAndContext<SignatureResult>>;
3336
3408
  /** @deprecated Instead, call `confirmTransaction` using a `TransactionConfirmationConfig` */
@@ -3338,6 +3410,10 @@ declare module '@solana/web3.js' {
3338
3410
  strategy: TransactionSignature,
3339
3411
  commitment?: Commitment,
3340
3412
  ): Promise<RpcResponseAndContext<SignatureResult>>;
3413
+ private getTransactionConfirmationPromise;
3414
+ private confirmTransactionUsingBlockHeightExceedanceStrategy;
3415
+ private confirmTransactionUsingDurableNonceStrategy;
3416
+ private confirmTransactionUsingLegacyTimeoutStrategy;
3341
3417
  /**
3342
3418
  * Return the list of nodes that are currently participating in the cluster
3343
3419
  */
@@ -3683,14 +3759,14 @@ declare module '@solana/web3.js' {
3683
3759
  */
3684
3760
  getNonceAndContext(
3685
3761
  nonceAccount: PublicKey,
3686
- commitment?: Commitment,
3762
+ commitmentOrConfig?: Commitment | GetNonceAndContextConfig,
3687
3763
  ): Promise<RpcResponseAndContext<NonceAccount | null>>;
3688
3764
  /**
3689
3765
  * Fetch the contents of a Nonce account from the cluster
3690
3766
  */
3691
3767
  getNonce(
3692
3768
  nonceAccount: PublicKey,
3693
- commitment?: Commitment,
3769
+ commitmentOrConfig?: Commitment | GetNonceConfig,
3694
3770
  ): Promise<NonceAccount | null>;
3695
3771
  /**
3696
3772
  * Request an allocation of lamports to the specified address