@solana/web3.js 1.47.3 → 1.49.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
@@ -142,13 +142,6 @@ declare module '@solana/web3.js' {
142
142
  get secretKey(): Buffer;
143
143
  }
144
144
 
145
- /**
146
- * Blockhash as Base58 string.
147
- */
148
- export type Blockhash = string;
149
-
150
- export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
151
-
152
145
  /**
153
146
  * Epoch schedule
154
147
  * (see https://docs.solana.com/terminology#epoch)
@@ -184,6 +177,11 @@ declare module '@solana/web3.js' {
184
177
  init?: nodeFetch.RequestInit,
185
178
  ): Promise<nodeFetch.Response>;
186
179
 
180
+ /**
181
+ * Blockhash as Base58 string.
182
+ */
183
+ export type Blockhash = string;
184
+
187
185
  /**
188
186
  * Calculator for transaction fees.
189
187
  */
@@ -339,223 +337,6 @@ declare module '@solana/web3.js' {
339
337
  static from(buffer: Buffer | Uint8Array | Array<number>): Message;
340
338
  }
341
339
 
342
- /**
343
- * Transaction signature as base-58 encoded string
344
- */
345
- export type TransactionSignature = string;
346
- export const enum TransactionStatus {
347
- BLOCKHEIGHT_EXCEEDED = 0,
348
- PROCESSED = 1,
349
- TIMED_OUT = 2,
350
- }
351
- /**
352
- * Account metadata used to define instructions
353
- */
354
- export type AccountMeta = {
355
- /** An account's public key */
356
- pubkey: PublicKey;
357
- /** True if an instruction requires a transaction signature matching `pubkey` */
358
- isSigner: boolean;
359
- /** True if the `pubkey` can be loaded as a read-write account. */
360
- isWritable: boolean;
361
- };
362
- /**
363
- * List of TransactionInstruction object fields that may be initialized at construction
364
- */
365
- export type TransactionInstructionCtorFields = {
366
- keys: Array<AccountMeta>;
367
- programId: PublicKey;
368
- data?: Buffer;
369
- };
370
- /**
371
- * Configuration object for Transaction.serialize()
372
- */
373
- export type SerializeConfig = {
374
- /** Require all transaction signatures be present (default: true) */
375
- requireAllSignatures?: boolean;
376
- /** Verify provided signatures (default: true) */
377
- verifySignatures?: boolean;
378
- };
379
- /**
380
- * Transaction Instruction class
381
- */
382
- export class TransactionInstruction {
383
- /**
384
- * Public keys to include in this transaction
385
- * Boolean represents whether this pubkey needs to sign the transaction
386
- */
387
- keys: Array<AccountMeta>;
388
- /**
389
- * Program Id to execute
390
- */
391
- programId: PublicKey;
392
- /**
393
- * Program input
394
- */
395
- data: Buffer;
396
- constructor(opts: TransactionInstructionCtorFields);
397
- }
398
- /**
399
- * Pair of signature and corresponding public key
400
- */
401
- export type SignaturePubkeyPair = {
402
- signature: Buffer | null;
403
- publicKey: PublicKey;
404
- };
405
- /**
406
- * List of Transaction object fields that may be initialized at construction
407
- */
408
- export type TransactionCtorFields_DEPRECATED = {
409
- /** Optional nonce information used for offline nonce'd transactions */
410
- nonceInfo?: NonceInformation | null;
411
- /** The transaction fee payer */
412
- feePayer?: PublicKey | null;
413
- /** One or more signatures */
414
- signatures?: Array<SignaturePubkeyPair>;
415
- /** A recent blockhash */
416
- recentBlockhash?: Blockhash;
417
- };
418
- export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
419
- /**
420
- * List of Transaction object fields that may be initialized at construction
421
- */
422
- export type TransactionBlockhashCtor = {
423
- /** The transaction fee payer */
424
- feePayer?: PublicKey | null;
425
- /** One or more signatures */
426
- signatures?: Array<SignaturePubkeyPair>;
427
- /** A recent blockhash */
428
- blockhash: Blockhash;
429
- /** the last block chain can advance to before tx is exportd expired */
430
- lastValidBlockHeight: number;
431
- };
432
- /**
433
- * Nonce information to be used to build an offline Transaction.
434
- */
435
- export type NonceInformation = {
436
- /** The current blockhash stored in the nonce */
437
- nonce: Blockhash;
438
- /** AdvanceNonceAccount Instruction */
439
- nonceInstruction: TransactionInstruction;
440
- };
441
- /**
442
- * Transaction class
443
- */
444
- export class Transaction {
445
- /**
446
- * Signatures for the transaction. Typically created by invoking the
447
- * `sign()` method
448
- */
449
- signatures: Array<SignaturePubkeyPair>;
450
- /**
451
- * The first (payer) Transaction signature
452
- */
453
- get signature(): Buffer | null;
454
- /**
455
- * The transaction fee payer
456
- */
457
- feePayer?: PublicKey;
458
- /**
459
- * The instructions to atomically execute
460
- */
461
- instructions: Array<TransactionInstruction>;
462
- /**
463
- * A recent transaction id. Must be populated by the caller
464
- */
465
- recentBlockhash?: Blockhash;
466
- /**
467
- * the last block chain can advance to before tx is exportd expired
468
- * */
469
- lastValidBlockHeight?: number;
470
- /**
471
- * Optional Nonce information. If populated, transaction will use a durable
472
- * Nonce hash instead of a recentBlockhash. Must be populated by the caller
473
- */
474
- nonceInfo?: NonceInformation;
475
- constructor(opts?: TransactionBlockhashCtor);
476
- /**
477
- * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
478
- * Please supply a `TransactionBlockhashCtor` instead.
479
- */
480
- constructor(opts?: TransactionCtorFields_DEPRECATED);
481
- /**
482
- * Add one or more instructions to this Transaction
483
- */
484
- add(
485
- ...items: Array<
486
- Transaction | TransactionInstruction | TransactionInstructionCtorFields
487
- >
488
- ): Transaction;
489
- /**
490
- * Compile transaction data
491
- */
492
- compileMessage(): Message;
493
- /**
494
- * Get a buffer of the Transaction data that need to be covered by signatures
495
- */
496
- serializeMessage(): Buffer;
497
- /**
498
- * Get the estimated fee associated with a transaction
499
- */
500
- getEstimatedFee(connection: Connection): Promise<number>;
501
- /**
502
- * Specify the public keys which will be used to sign the Transaction.
503
- * The first signer will be used as the transaction fee payer account.
504
- *
505
- * Signatures can be added with either `partialSign` or `addSignature`
506
- *
507
- * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
508
- * specified and it can be set in the Transaction constructor or with the
509
- * `feePayer` property.
510
- */
511
- setSigners(...signers: Array<PublicKey>): void;
512
- /**
513
- * Sign the Transaction with the specified signers. Multiple signatures may
514
- * be applied to a Transaction. The first signature is considered "primary"
515
- * and is used identify and confirm transactions.
516
- *
517
- * If the Transaction `feePayer` is not set, the first signer will be used
518
- * as the transaction fee payer account.
519
- *
520
- * Transaction fields should not be modified after the first call to `sign`,
521
- * as doing so may invalidate the signature and cause the Transaction to be
522
- * rejected.
523
- *
524
- * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
525
- */
526
- sign(...signers: Array<Signer>): void;
527
- /**
528
- * Partially sign a transaction with the specified accounts. All accounts must
529
- * correspond to either the fee payer or a signer account in the transaction
530
- * instructions.
531
- *
532
- * All the caveats from the `sign` method apply to `partialSign`
533
- */
534
- partialSign(...signers: Array<Signer>): void;
535
- /**
536
- * Add an externally created signature to a transaction. The public key
537
- * must correspond to either the fee payer or a signer account in the transaction
538
- * instructions.
539
- */
540
- addSignature(pubkey: PublicKey, signature: Buffer): void;
541
- /**
542
- * Verify signatures of a complete, signed Transaction
543
- */
544
- verifySignatures(): boolean;
545
- /**
546
- * Serialize the Transaction in the wire format.
547
- */
548
- serialize(config?: SerializeConfig): Buffer;
549
- /**
550
- * Parse a wire transaction into a Transaction object.
551
- */
552
- static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
553
- /**
554
- * Populate Transaction object from message and signatures
555
- */
556
- static populate(message: Message, signatures?: Array<string>): Transaction;
557
- }
558
-
559
340
  export type ClientSubscriptionId = number;
560
341
  export type TokenAccountsFilter =
561
342
  | {
@@ -699,6 +480,15 @@ declare module '@solana/web3.js' {
699
480
  /** The minimum slot that the request can be evaluated at */
700
481
  minContextSlot?: number;
701
482
  };
483
+ /**
484
+ * Configuration object for changing `getBlock` query behavior
485
+ */
486
+ export type GetBlockConfig = {
487
+ /** The level of finality desired */
488
+ commitment?: Finality;
489
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
490
+ maxSupportedTransactionVersion?: number;
491
+ };
702
492
  /**
703
493
  * Configuration object for changing `getBlockHeight` query behavior
704
494
  */
@@ -755,6 +545,15 @@ declare module '@solana/web3.js' {
755
545
  /** The minimum slot that the request can be evaluated at */
756
546
  minContextSlot?: number;
757
547
  };
548
+ /**
549
+ * Configuration object for changing `getTransaction` query behavior
550
+ */
551
+ export type GetTransactionConfig = {
552
+ /** The level of finality desired */
553
+ commitment?: Finality;
554
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
555
+ maxSupportedTransactionVersion?: number;
556
+ };
758
557
  /**
759
558
  * Configuration object for changing `getLargestAccounts` query behavior
760
559
  */
@@ -885,11 +684,17 @@ declare module '@solana/web3.js' {
885
684
  /** Optional rent epoch info for account */
886
685
  rentEpoch?: number;
887
686
  };
687
+ export type TransactionReturnDataEncoding = 'base64';
688
+ export type TransactionReturnData = {
689
+ programId: string;
690
+ data: [string, TransactionReturnDataEncoding];
691
+ };
888
692
  export type SimulatedTransactionResponse = {
889
693
  err: TransactionError | string | null;
890
694
  logs: Array<string> | null;
891
695
  accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
892
696
  unitsConsumed?: number;
697
+ returnData?: TransactionReturnData | null;
893
698
  };
894
699
  export type ParsedInnerInstruction = {
895
700
  index: number;
@@ -1951,9 +1756,7 @@ declare module '@solana/web3.js' {
1951
1756
  */
1952
1757
  getBlock(
1953
1758
  slot: number,
1954
- opts?: {
1955
- commitment?: Finality;
1956
- },
1759
+ rawConfig?: GetBlockConfig,
1957
1760
  ): Promise<BlockResponse | null>;
1958
1761
  getBlockHeight(
1959
1762
  commitmentOrConfig?: Commitment | GetBlockHeightConfig,
@@ -1966,9 +1769,7 @@ declare module '@solana/web3.js' {
1966
1769
  */
1967
1770
  getTransaction(
1968
1771
  signature: string,
1969
- opts?: {
1970
- commitment?: Finality;
1971
- },
1772
+ rawConfig?: GetTransactionConfig,
1972
1773
  ): Promise<TransactionResponse | null>;
1973
1774
  /**
1974
1775
  * Fetch parsed transaction details for a confirmed or finalized transaction
@@ -2309,6 +2110,312 @@ declare module '@solana/web3.js' {
2309
2110
  ): Promise<void>;
2310
2111
  }
2311
2112
 
2113
+ /**
2114
+ * Transaction signature as base-58 encoded string
2115
+ */
2116
+ export type TransactionSignature = string;
2117
+ export const enum TransactionStatus {
2118
+ BLOCKHEIGHT_EXCEEDED = 0,
2119
+ PROCESSED = 1,
2120
+ TIMED_OUT = 2,
2121
+ }
2122
+ /**
2123
+ * Account metadata used to define instructions
2124
+ */
2125
+ export type AccountMeta = {
2126
+ /** An account's public key */
2127
+ pubkey: PublicKey;
2128
+ /** True if an instruction requires a transaction signature matching `pubkey` */
2129
+ isSigner: boolean;
2130
+ /** True if the `pubkey` can be loaded as a read-write account. */
2131
+ isWritable: boolean;
2132
+ };
2133
+ /**
2134
+ * List of TransactionInstruction object fields that may be initialized at construction
2135
+ */
2136
+ export type TransactionInstructionCtorFields = {
2137
+ keys: Array<AccountMeta>;
2138
+ programId: PublicKey;
2139
+ data?: Buffer;
2140
+ };
2141
+ /**
2142
+ * Configuration object for Transaction.serialize()
2143
+ */
2144
+ export type SerializeConfig = {
2145
+ /** Require all transaction signatures be present (default: true) */
2146
+ requireAllSignatures?: boolean;
2147
+ /** Verify provided signatures (default: true) */
2148
+ verifySignatures?: boolean;
2149
+ };
2150
+ /**
2151
+ * Transaction Instruction class
2152
+ */
2153
+ export class TransactionInstruction {
2154
+ /**
2155
+ * Public keys to include in this transaction
2156
+ * Boolean represents whether this pubkey needs to sign the transaction
2157
+ */
2158
+ keys: Array<AccountMeta>;
2159
+ /**
2160
+ * Program Id to execute
2161
+ */
2162
+ programId: PublicKey;
2163
+ /**
2164
+ * Program input
2165
+ */
2166
+ data: Buffer;
2167
+ constructor(opts: TransactionInstructionCtorFields);
2168
+ }
2169
+ /**
2170
+ * Pair of signature and corresponding public key
2171
+ */
2172
+ export type SignaturePubkeyPair = {
2173
+ signature: Buffer | null;
2174
+ publicKey: PublicKey;
2175
+ };
2176
+ /**
2177
+ * List of Transaction object fields that may be initialized at construction
2178
+ */
2179
+ export type TransactionCtorFields_DEPRECATED = {
2180
+ /** Optional nonce information used for offline nonce'd transactions */
2181
+ nonceInfo?: NonceInformation | null;
2182
+ /** The transaction fee payer */
2183
+ feePayer?: PublicKey | null;
2184
+ /** One or more signatures */
2185
+ signatures?: Array<SignaturePubkeyPair>;
2186
+ /** A recent blockhash */
2187
+ recentBlockhash?: Blockhash;
2188
+ };
2189
+ export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
2190
+ /**
2191
+ * List of Transaction object fields that may be initialized at construction
2192
+ */
2193
+ export type TransactionBlockhashCtor = {
2194
+ /** The transaction fee payer */
2195
+ feePayer?: PublicKey | null;
2196
+ /** One or more signatures */
2197
+ signatures?: Array<SignaturePubkeyPair>;
2198
+ /** A recent blockhash */
2199
+ blockhash: Blockhash;
2200
+ /** the last block chain can advance to before tx is exportd expired */
2201
+ lastValidBlockHeight: number;
2202
+ };
2203
+ /**
2204
+ * Nonce information to be used to build an offline Transaction.
2205
+ */
2206
+ export type NonceInformation = {
2207
+ /** The current blockhash stored in the nonce */
2208
+ nonce: Blockhash;
2209
+ /** AdvanceNonceAccount Instruction */
2210
+ nonceInstruction: TransactionInstruction;
2211
+ };
2212
+ /**
2213
+ * Transaction class
2214
+ */
2215
+ export class Transaction {
2216
+ /**
2217
+ * Signatures for the transaction. Typically created by invoking the
2218
+ * `sign()` method
2219
+ */
2220
+ signatures: Array<SignaturePubkeyPair>;
2221
+ /**
2222
+ * The first (payer) Transaction signature
2223
+ */
2224
+ get signature(): Buffer | null;
2225
+ /**
2226
+ * The transaction fee payer
2227
+ */
2228
+ feePayer?: PublicKey;
2229
+ /**
2230
+ * The instructions to atomically execute
2231
+ */
2232
+ instructions: Array<TransactionInstruction>;
2233
+ /**
2234
+ * A recent transaction id. Must be populated by the caller
2235
+ */
2236
+ recentBlockhash?: Blockhash;
2237
+ /**
2238
+ * the last block chain can advance to before tx is exportd expired
2239
+ * */
2240
+ lastValidBlockHeight?: number;
2241
+ /**
2242
+ * Optional Nonce information. If populated, transaction will use a durable
2243
+ * Nonce hash instead of a recentBlockhash. Must be populated by the caller
2244
+ */
2245
+ nonceInfo?: NonceInformation;
2246
+ constructor(opts?: TransactionBlockhashCtor);
2247
+ /**
2248
+ * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
2249
+ * Please supply a `TransactionBlockhashCtor` instead.
2250
+ */
2251
+ constructor(opts?: TransactionCtorFields_DEPRECATED);
2252
+ /**
2253
+ * Add one or more instructions to this Transaction
2254
+ */
2255
+ add(
2256
+ ...items: Array<
2257
+ Transaction | TransactionInstruction | TransactionInstructionCtorFields
2258
+ >
2259
+ ): Transaction;
2260
+ /**
2261
+ * Compile transaction data
2262
+ */
2263
+ compileMessage(): Message;
2264
+ /**
2265
+ * Get a buffer of the Transaction data that need to be covered by signatures
2266
+ */
2267
+ serializeMessage(): Buffer;
2268
+ /**
2269
+ * Get the estimated fee associated with a transaction
2270
+ */
2271
+ getEstimatedFee(connection: Connection): Promise<number>;
2272
+ /**
2273
+ * Specify the public keys which will be used to sign the Transaction.
2274
+ * The first signer will be used as the transaction fee payer account.
2275
+ *
2276
+ * Signatures can be added with either `partialSign` or `addSignature`
2277
+ *
2278
+ * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
2279
+ * specified and it can be set in the Transaction constructor or with the
2280
+ * `feePayer` property.
2281
+ */
2282
+ setSigners(...signers: Array<PublicKey>): void;
2283
+ /**
2284
+ * Sign the Transaction with the specified signers. Multiple signatures may
2285
+ * be applied to a Transaction. The first signature is considered "primary"
2286
+ * and is used identify and confirm transactions.
2287
+ *
2288
+ * If the Transaction `feePayer` is not set, the first signer will be used
2289
+ * as the transaction fee payer account.
2290
+ *
2291
+ * Transaction fields should not be modified after the first call to `sign`,
2292
+ * as doing so may invalidate the signature and cause the Transaction to be
2293
+ * rejected.
2294
+ *
2295
+ * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
2296
+ */
2297
+ sign(...signers: Array<Signer>): void;
2298
+ /**
2299
+ * Partially sign a transaction with the specified accounts. All accounts must
2300
+ * correspond to either the fee payer or a signer account in the transaction
2301
+ * instructions.
2302
+ *
2303
+ * All the caveats from the `sign` method apply to `partialSign`
2304
+ */
2305
+ partialSign(...signers: Array<Signer>): void;
2306
+ /**
2307
+ * Add an externally created signature to a transaction. The public key
2308
+ * must correspond to either the fee payer or a signer account in the transaction
2309
+ * instructions.
2310
+ */
2311
+ addSignature(pubkey: PublicKey, signature: Buffer): void;
2312
+ /**
2313
+ * Verify signatures of a complete, signed Transaction
2314
+ */
2315
+ verifySignatures(): boolean;
2316
+ /**
2317
+ * Serialize the Transaction in the wire format.
2318
+ */
2319
+ serialize(config?: SerializeConfig): Buffer;
2320
+ /**
2321
+ * Parse a wire transaction into a Transaction object.
2322
+ */
2323
+ static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
2324
+ /**
2325
+ * Populate Transaction object from message and signatures
2326
+ */
2327
+ static populate(message: Message, signatures?: Array<string>): Transaction;
2328
+ }
2329
+
2330
+ export type CreateLookupTableParams = {
2331
+ /** Account used to derive and control the new address lookup table. */
2332
+ authority: PublicKey;
2333
+ /** Account that will fund the new address lookup table. */
2334
+ payer: PublicKey;
2335
+ /** A recent slot must be used in the derivation path for each initialized table. */
2336
+ recentSlot: bigint | number;
2337
+ };
2338
+ export type FreezeLookupTableParams = {
2339
+ /** Address lookup table account to freeze. */
2340
+ lookupTable: PublicKey;
2341
+ /** Account which is the current authority. */
2342
+ authority: PublicKey;
2343
+ };
2344
+ export type ExtendLookupTableParams = {
2345
+ /** Address lookup table account to extend. */
2346
+ lookupTable: PublicKey;
2347
+ /** Account which is the current authority. */
2348
+ authority: PublicKey;
2349
+ /** Account that will fund the table reallocation.
2350
+ * Not required if the reallocation has already been funded. */
2351
+ payer?: PublicKey;
2352
+ /** List of Public Keys to be added to the lookup table. */
2353
+ addresses: Array<PublicKey>;
2354
+ };
2355
+ export type DeactivateLookupTableParams = {
2356
+ /** Address lookup table account to deactivate. */
2357
+ lookupTable: PublicKey;
2358
+ /** Account which is the current authority. */
2359
+ authority: PublicKey;
2360
+ };
2361
+ export type CloseLookupTableParams = {
2362
+ /** Address lookup table account to close. */
2363
+ lookupTable: PublicKey;
2364
+ /** Account which is the current authority. */
2365
+ authority: PublicKey;
2366
+ /** Recipient of closed account lamports. */
2367
+ recipient: PublicKey;
2368
+ };
2369
+ /**
2370
+ * An enumeration of valid LookupTableInstructionType's
2371
+ */
2372
+ export type LookupTableInstructionType =
2373
+ | 'CreateLookupTable'
2374
+ | 'ExtendLookupTable'
2375
+ | 'CloseLookupTable'
2376
+ | 'FreezeLookupTable'
2377
+ | 'DeactivateLookupTable';
2378
+ export class AddressLookupTableInstruction {
2379
+ static decodeInstructionType(
2380
+ instruction: TransactionInstruction,
2381
+ ): LookupTableInstructionType;
2382
+ static decodeCreateLookupTable(
2383
+ instruction: TransactionInstruction,
2384
+ ): CreateLookupTableParams;
2385
+ static decodeExtendLookupTable(
2386
+ instruction: TransactionInstruction,
2387
+ ): ExtendLookupTableParams;
2388
+ static decodeCloseLookupTable(
2389
+ instruction: TransactionInstruction,
2390
+ ): CloseLookupTableParams;
2391
+ static decodeFreezeLookupTable(
2392
+ instruction: TransactionInstruction,
2393
+ ): FreezeLookupTableParams;
2394
+ static decodeDeactivateLookupTable(
2395
+ instruction: TransactionInstruction,
2396
+ ): DeactivateLookupTableParams;
2397
+ }
2398
+ export class AddressLookupTableProgram {
2399
+ static programId: PublicKey;
2400
+ static createLookupTable(
2401
+ params: CreateLookupTableParams,
2402
+ ): [TransactionInstruction, PublicKey];
2403
+ static freezeLookupTable(
2404
+ params: FreezeLookupTableParams,
2405
+ ): TransactionInstruction;
2406
+ static extendLookupTable(
2407
+ params: ExtendLookupTableParams,
2408
+ ): TransactionInstruction;
2409
+ static deactivateLookupTable(
2410
+ params: DeactivateLookupTableParams,
2411
+ ): TransactionInstruction;
2412
+ static closeLookupTable(
2413
+ params: CloseLookupTableParams,
2414
+ ): TransactionInstruction;
2415
+ }
2416
+
2417
+ export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
2418
+
2312
2419
  export const BPF_LOADER_PROGRAM_ID: PublicKey;
2313
2420
  /**
2314
2421
  * Factory class for transactions to interact with a program loader