@solana/web3.js 1.41.9 → 1.43.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.browser.cjs.js +238 -66
- package/lib/index.browser.cjs.js.map +1 -1
- package/lib/index.browser.esm.js +239 -67
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +238 -66
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +101 -24
- package/lib/index.esm.js +239 -67
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +238 -66
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/package.json +1 -1
- package/src/compute-budget.ts +92 -3
- package/src/connection.ts +157 -65
- package/src/transaction.ts +54 -7
- package/src/util/send-and-confirm-raw-transaction.ts +52 -7
- package/src/util/send-and-confirm-transaction.ts +19 -6
- package/src/util/tx-expiry-custom-errors.ts +35 -0
package/lib/index.d.ts
CHANGED
|
@@ -338,6 +338,11 @@ declare module '@solana/web3.js' {
|
|
|
338
338
|
* Transaction signature as base-58 encoded string
|
|
339
339
|
*/
|
|
340
340
|
export type TransactionSignature = string;
|
|
341
|
+
export const enum TransactionStatus {
|
|
342
|
+
BLOCKHEIGHT_EXCEEDED = 0,
|
|
343
|
+
PROCESSED = 1,
|
|
344
|
+
TIMED_OUT = 2,
|
|
345
|
+
}
|
|
341
346
|
/**
|
|
342
347
|
* Account metadata used to define instructions
|
|
343
348
|
*/
|
|
@@ -394,17 +399,29 @@ declare module '@solana/web3.js' {
|
|
|
394
399
|
};
|
|
395
400
|
/**
|
|
396
401
|
* List of Transaction object fields that may be initialized at construction
|
|
397
|
-
*
|
|
398
402
|
*/
|
|
399
|
-
export type
|
|
400
|
-
/** A recent blockhash */
|
|
401
|
-
recentBlockhash?: Blockhash | null;
|
|
403
|
+
export type TransactionCtorFields_DEPRECATED = {
|
|
402
404
|
/** Optional nonce information used for offline nonce'd transactions */
|
|
403
405
|
nonceInfo?: NonceInformation | null;
|
|
404
406
|
/** The transaction fee payer */
|
|
405
407
|
feePayer?: PublicKey | null;
|
|
406
408
|
/** One or more signatures */
|
|
407
409
|
signatures?: Array<SignaturePubkeyPair>;
|
|
410
|
+
/** A recent blockhash */
|
|
411
|
+
recentBlockhash?: Blockhash;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* List of Transaction object fields that may be initialized at construction
|
|
415
|
+
*/
|
|
416
|
+
export type TransactionBlockhashCtor = {
|
|
417
|
+
/** The transaction fee payer */
|
|
418
|
+
feePayer?: PublicKey | null;
|
|
419
|
+
/** One or more signatures */
|
|
420
|
+
signatures?: Array<SignaturePubkeyPair>;
|
|
421
|
+
/** A recent blockhash */
|
|
422
|
+
blockhash: Blockhash;
|
|
423
|
+
/** the last block chain can advance to before tx is exportd expired */
|
|
424
|
+
lastValidBlockHeight: number;
|
|
408
425
|
};
|
|
409
426
|
/**
|
|
410
427
|
* Nonce information to be used to build an offline Transaction.
|
|
@@ -440,15 +457,21 @@ declare module '@solana/web3.js' {
|
|
|
440
457
|
* A recent transaction id. Must be populated by the caller
|
|
441
458
|
*/
|
|
442
459
|
recentBlockhash?: Blockhash;
|
|
460
|
+
/**
|
|
461
|
+
* the last block chain can advance to before tx is exportd expired
|
|
462
|
+
* */
|
|
463
|
+
lastValidBlockHeight?: number;
|
|
443
464
|
/**
|
|
444
465
|
* Optional Nonce information. If populated, transaction will use a durable
|
|
445
466
|
* Nonce hash instead of a recentBlockhash. Must be populated by the caller
|
|
446
467
|
*/
|
|
447
468
|
nonceInfo?: NonceInformation;
|
|
469
|
+
constructor(opts?: TransactionBlockhashCtor);
|
|
448
470
|
/**
|
|
449
|
-
*
|
|
471
|
+
* @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
|
|
472
|
+
* Please supply a `TransactionBlockhashCtor` instead.
|
|
450
473
|
*/
|
|
451
|
-
constructor(opts?:
|
|
474
|
+
constructor(opts?: TransactionCtorFields_DEPRECATED);
|
|
452
475
|
/**
|
|
453
476
|
* Add one or more instructions to this Transaction
|
|
454
477
|
*/
|
|
@@ -602,6 +625,17 @@ declare module '@solana/web3.js' {
|
|
|
602
625
|
/** response value */
|
|
603
626
|
value: T;
|
|
604
627
|
};
|
|
628
|
+
export type BlockhashWithExpiryBlockHeight = Readonly<{
|
|
629
|
+
blockhash: Blockhash;
|
|
630
|
+
lastValidBlockHeight: number;
|
|
631
|
+
}>;
|
|
632
|
+
/**
|
|
633
|
+
* A strategy for confirming transactions that uses the last valid
|
|
634
|
+
* block height for a given blockhash to check for transaction expiration.
|
|
635
|
+
*/
|
|
636
|
+
export type BlockheightBasedTransactionConfirmationStrategy = {
|
|
637
|
+
signature: TransactionSignature;
|
|
638
|
+
} & BlockhashWithExpiryBlockHeight;
|
|
605
639
|
/**
|
|
606
640
|
* The level of commitment desired when querying state
|
|
607
641
|
* <pre>
|
|
@@ -1624,11 +1658,13 @@ declare module '@solana/web3.js' {
|
|
|
1624
1658
|
account: AccountInfo<Buffer | ParsedAccountData>;
|
|
1625
1659
|
}>
|
|
1626
1660
|
>;
|
|
1627
|
-
/**
|
|
1628
|
-
* Confirm the transaction identified by the specified signature.
|
|
1629
|
-
*/
|
|
1630
1661
|
confirmTransaction(
|
|
1631
|
-
|
|
1662
|
+
strategy: BlockheightBasedTransactionConfirmationStrategy,
|
|
1663
|
+
commitment?: Commitment,
|
|
1664
|
+
): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
1665
|
+
/** @deprecated Instead, call `confirmTransaction` using a `TransactionConfirmationConfig` */
|
|
1666
|
+
confirmTransaction(
|
|
1667
|
+
strategy: TransactionSignature,
|
|
1632
1668
|
commitment?: Commitment,
|
|
1633
1669
|
): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
1634
1670
|
/**
|
|
@@ -1756,22 +1792,18 @@ declare module '@solana/web3.js' {
|
|
|
1756
1792
|
}>;
|
|
1757
1793
|
/**
|
|
1758
1794
|
* Fetch the latest blockhash from the cluster
|
|
1759
|
-
* @return {Promise<
|
|
1795
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1760
1796
|
*/
|
|
1761
|
-
getLatestBlockhash(
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
}>;
|
|
1797
|
+
getLatestBlockhash(
|
|
1798
|
+
commitment?: Commitment,
|
|
1799
|
+
): Promise<BlockhashWithExpiryBlockHeight>;
|
|
1765
1800
|
/**
|
|
1766
1801
|
* Fetch the latest blockhash from the cluster
|
|
1767
|
-
* @return {Promise<
|
|
1802
|
+
* @return {Promise<BlockhashWithExpiryBlockHeight>}
|
|
1768
1803
|
*/
|
|
1769
|
-
getLatestBlockhashAndContext(
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
lastValidBlockHeight: number;
|
|
1773
|
-
}>
|
|
1774
|
-
>;
|
|
1804
|
+
getLatestBlockhashAndContext(
|
|
1805
|
+
commitment?: Commitment,
|
|
1806
|
+
): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
|
|
1775
1807
|
/**
|
|
1776
1808
|
* Fetch the node version
|
|
1777
1809
|
*/
|
|
@@ -2194,20 +2226,34 @@ declare module '@solana/web3.js' {
|
|
|
2194
2226
|
static decodeRequestHeapFrame(
|
|
2195
2227
|
instruction: TransactionInstruction,
|
|
2196
2228
|
): RequestHeapFrameParams;
|
|
2229
|
+
/**
|
|
2230
|
+
* Decode set compute unit limit compute budget instruction and retrieve the instruction params.
|
|
2231
|
+
*/
|
|
2232
|
+
static decodeSetComputeUnitLimit(
|
|
2233
|
+
instruction: TransactionInstruction,
|
|
2234
|
+
): SetComputeUnitLimitParams;
|
|
2235
|
+
/**
|
|
2236
|
+
* Decode set compute unit price compute budget instruction and retrieve the instruction params.
|
|
2237
|
+
*/
|
|
2238
|
+
static decodeSetComputeUnitPrice(
|
|
2239
|
+
instruction: TransactionInstruction,
|
|
2240
|
+
): SetComputeUnitPriceParams;
|
|
2197
2241
|
}
|
|
2198
2242
|
/**
|
|
2199
2243
|
* An enumeration of valid ComputeBudgetInstructionType's
|
|
2200
2244
|
*/
|
|
2201
2245
|
export type ComputeBudgetInstructionType =
|
|
2202
2246
|
| 'RequestUnits'
|
|
2203
|
-
| 'RequestHeapFrame'
|
|
2247
|
+
| 'RequestHeapFrame'
|
|
2248
|
+
| 'SetComputeUnitLimit'
|
|
2249
|
+
| 'SetComputeUnitPrice';
|
|
2204
2250
|
/**
|
|
2205
2251
|
* Request units instruction params
|
|
2206
2252
|
*/
|
|
2207
2253
|
interface RequestUnitsParams {
|
|
2208
2254
|
/** Units to request for transaction-wide compute */
|
|
2209
2255
|
units: number;
|
|
2210
|
-
/**
|
|
2256
|
+
/** Prioritization fee lamports */
|
|
2211
2257
|
additionalFee: number;
|
|
2212
2258
|
}
|
|
2213
2259
|
/**
|
|
@@ -2217,6 +2263,20 @@ declare module '@solana/web3.js' {
|
|
|
2217
2263
|
/** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */
|
|
2218
2264
|
bytes: number;
|
|
2219
2265
|
};
|
|
2266
|
+
/**
|
|
2267
|
+
* Set compute unit limit instruction params
|
|
2268
|
+
*/
|
|
2269
|
+
interface SetComputeUnitLimitParams {
|
|
2270
|
+
/** Transaction-wide compute unit limit */
|
|
2271
|
+
units: number;
|
|
2272
|
+
}
|
|
2273
|
+
/**
|
|
2274
|
+
* Set compute unit price instruction params
|
|
2275
|
+
*/
|
|
2276
|
+
interface SetComputeUnitPriceParams {
|
|
2277
|
+
/** Transaction compute unit price used for prioritization fees */
|
|
2278
|
+
microLamports: number | bigint;
|
|
2279
|
+
}
|
|
2220
2280
|
/**
|
|
2221
2281
|
* Factory class for transaction instructions to interact with the Compute Budget program
|
|
2222
2282
|
*/
|
|
@@ -2229,6 +2289,12 @@ declare module '@solana/web3.js' {
|
|
|
2229
2289
|
static requestHeapFrame(
|
|
2230
2290
|
params: RequestHeapFrameParams,
|
|
2231
2291
|
): TransactionInstruction;
|
|
2292
|
+
static setComputeUnitLimit(
|
|
2293
|
+
params: SetComputeUnitLimitParams,
|
|
2294
|
+
): TransactionInstruction;
|
|
2295
|
+
static setComputeUnitPrice(
|
|
2296
|
+
params: SetComputeUnitPriceParams,
|
|
2297
|
+
): TransactionInstruction;
|
|
2232
2298
|
}
|
|
2233
2299
|
|
|
2234
2300
|
/**
|
|
@@ -3320,9 +3386,20 @@ declare module '@solana/web3.js' {
|
|
|
3320
3386
|
*
|
|
3321
3387
|
* @param {Connection} connection
|
|
3322
3388
|
* @param {Buffer} rawTransaction
|
|
3389
|
+
* @param {BlockheightBasedTransactionConfirmationStrategy} confirmationStrategy
|
|
3323
3390
|
* @param {ConfirmOptions} [options]
|
|
3324
3391
|
* @returns {Promise<TransactionSignature>}
|
|
3325
3392
|
*/
|
|
3393
|
+
export function sendAndConfirmRawTransaction(
|
|
3394
|
+
connection: Connection,
|
|
3395
|
+
rawTransaction: Buffer,
|
|
3396
|
+
confirmationStrategy: BlockheightBasedTransactionConfirmationStrategy,
|
|
3397
|
+
options?: ConfirmOptions,
|
|
3398
|
+
): Promise<TransactionSignature>;
|
|
3399
|
+
/**
|
|
3400
|
+
* @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
|
|
3401
|
+
* is no longer supported and will be removed in a future version.
|
|
3402
|
+
*/
|
|
3326
3403
|
export function sendAndConfirmRawTransaction(
|
|
3327
3404
|
connection: Connection,
|
|
3328
3405
|
rawTransaction: Buffer,
|