@solana/web3.js 1.47.2 → 1.48.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
  | {
@@ -885,11 +666,17 @@ declare module '@solana/web3.js' {
885
666
  /** Optional rent epoch info for account */
886
667
  rentEpoch?: number;
887
668
  };
669
+ export type TransactionReturnDataEncoding = 'base64';
670
+ export type TransactionReturnData = {
671
+ programId: string;
672
+ data: [string, TransactionReturnDataEncoding];
673
+ };
888
674
  export type SimulatedTransactionResponse = {
889
675
  err: TransactionError | string | null;
890
676
  logs: Array<string> | null;
891
677
  accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
892
678
  unitsConsumed?: number;
679
+ returnData?: TransactionReturnData | null;
893
680
  };
894
681
  export type ParsedInnerInstruction = {
895
682
  index: number;
@@ -2309,6 +2096,312 @@ declare module '@solana/web3.js' {
2309
2096
  ): Promise<void>;
2310
2097
  }
2311
2098
 
2099
+ /**
2100
+ * Transaction signature as base-58 encoded string
2101
+ */
2102
+ export type TransactionSignature = string;
2103
+ export const enum TransactionStatus {
2104
+ BLOCKHEIGHT_EXCEEDED = 0,
2105
+ PROCESSED = 1,
2106
+ TIMED_OUT = 2,
2107
+ }
2108
+ /**
2109
+ * Account metadata used to define instructions
2110
+ */
2111
+ export type AccountMeta = {
2112
+ /** An account's public key */
2113
+ pubkey: PublicKey;
2114
+ /** True if an instruction requires a transaction signature matching `pubkey` */
2115
+ isSigner: boolean;
2116
+ /** True if the `pubkey` can be loaded as a read-write account. */
2117
+ isWritable: boolean;
2118
+ };
2119
+ /**
2120
+ * List of TransactionInstruction object fields that may be initialized at construction
2121
+ */
2122
+ export type TransactionInstructionCtorFields = {
2123
+ keys: Array<AccountMeta>;
2124
+ programId: PublicKey;
2125
+ data?: Buffer;
2126
+ };
2127
+ /**
2128
+ * Configuration object for Transaction.serialize()
2129
+ */
2130
+ export type SerializeConfig = {
2131
+ /** Require all transaction signatures be present (default: true) */
2132
+ requireAllSignatures?: boolean;
2133
+ /** Verify provided signatures (default: true) */
2134
+ verifySignatures?: boolean;
2135
+ };
2136
+ /**
2137
+ * Transaction Instruction class
2138
+ */
2139
+ export class TransactionInstruction {
2140
+ /**
2141
+ * Public keys to include in this transaction
2142
+ * Boolean represents whether this pubkey needs to sign the transaction
2143
+ */
2144
+ keys: Array<AccountMeta>;
2145
+ /**
2146
+ * Program Id to execute
2147
+ */
2148
+ programId: PublicKey;
2149
+ /**
2150
+ * Program input
2151
+ */
2152
+ data: Buffer;
2153
+ constructor(opts: TransactionInstructionCtorFields);
2154
+ }
2155
+ /**
2156
+ * Pair of signature and corresponding public key
2157
+ */
2158
+ export type SignaturePubkeyPair = {
2159
+ signature: Buffer | null;
2160
+ publicKey: PublicKey;
2161
+ };
2162
+ /**
2163
+ * List of Transaction object fields that may be initialized at construction
2164
+ */
2165
+ export type TransactionCtorFields_DEPRECATED = {
2166
+ /** Optional nonce information used for offline nonce'd transactions */
2167
+ nonceInfo?: NonceInformation | null;
2168
+ /** The transaction fee payer */
2169
+ feePayer?: PublicKey | null;
2170
+ /** One or more signatures */
2171
+ signatures?: Array<SignaturePubkeyPair>;
2172
+ /** A recent blockhash */
2173
+ recentBlockhash?: Blockhash;
2174
+ };
2175
+ export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
2176
+ /**
2177
+ * List of Transaction object fields that may be initialized at construction
2178
+ */
2179
+ export type TransactionBlockhashCtor = {
2180
+ /** The transaction fee payer */
2181
+ feePayer?: PublicKey | null;
2182
+ /** One or more signatures */
2183
+ signatures?: Array<SignaturePubkeyPair>;
2184
+ /** A recent blockhash */
2185
+ blockhash: Blockhash;
2186
+ /** the last block chain can advance to before tx is exportd expired */
2187
+ lastValidBlockHeight: number;
2188
+ };
2189
+ /**
2190
+ * Nonce information to be used to build an offline Transaction.
2191
+ */
2192
+ export type NonceInformation = {
2193
+ /** The current blockhash stored in the nonce */
2194
+ nonce: Blockhash;
2195
+ /** AdvanceNonceAccount Instruction */
2196
+ nonceInstruction: TransactionInstruction;
2197
+ };
2198
+ /**
2199
+ * Transaction class
2200
+ */
2201
+ export class Transaction {
2202
+ /**
2203
+ * Signatures for the transaction. Typically created by invoking the
2204
+ * `sign()` method
2205
+ */
2206
+ signatures: Array<SignaturePubkeyPair>;
2207
+ /**
2208
+ * The first (payer) Transaction signature
2209
+ */
2210
+ get signature(): Buffer | null;
2211
+ /**
2212
+ * The transaction fee payer
2213
+ */
2214
+ feePayer?: PublicKey;
2215
+ /**
2216
+ * The instructions to atomically execute
2217
+ */
2218
+ instructions: Array<TransactionInstruction>;
2219
+ /**
2220
+ * A recent transaction id. Must be populated by the caller
2221
+ */
2222
+ recentBlockhash?: Blockhash;
2223
+ /**
2224
+ * the last block chain can advance to before tx is exportd expired
2225
+ * */
2226
+ lastValidBlockHeight?: number;
2227
+ /**
2228
+ * Optional Nonce information. If populated, transaction will use a durable
2229
+ * Nonce hash instead of a recentBlockhash. Must be populated by the caller
2230
+ */
2231
+ nonceInfo?: NonceInformation;
2232
+ constructor(opts?: TransactionBlockhashCtor);
2233
+ /**
2234
+ * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
2235
+ * Please supply a `TransactionBlockhashCtor` instead.
2236
+ */
2237
+ constructor(opts?: TransactionCtorFields_DEPRECATED);
2238
+ /**
2239
+ * Add one or more instructions to this Transaction
2240
+ */
2241
+ add(
2242
+ ...items: Array<
2243
+ Transaction | TransactionInstruction | TransactionInstructionCtorFields
2244
+ >
2245
+ ): Transaction;
2246
+ /**
2247
+ * Compile transaction data
2248
+ */
2249
+ compileMessage(): Message;
2250
+ /**
2251
+ * Get a buffer of the Transaction data that need to be covered by signatures
2252
+ */
2253
+ serializeMessage(): Buffer;
2254
+ /**
2255
+ * Get the estimated fee associated with a transaction
2256
+ */
2257
+ getEstimatedFee(connection: Connection): Promise<number>;
2258
+ /**
2259
+ * Specify the public keys which will be used to sign the Transaction.
2260
+ * The first signer will be used as the transaction fee payer account.
2261
+ *
2262
+ * Signatures can be added with either `partialSign` or `addSignature`
2263
+ *
2264
+ * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
2265
+ * specified and it can be set in the Transaction constructor or with the
2266
+ * `feePayer` property.
2267
+ */
2268
+ setSigners(...signers: Array<PublicKey>): void;
2269
+ /**
2270
+ * Sign the Transaction with the specified signers. Multiple signatures may
2271
+ * be applied to a Transaction. The first signature is considered "primary"
2272
+ * and is used identify and confirm transactions.
2273
+ *
2274
+ * If the Transaction `feePayer` is not set, the first signer will be used
2275
+ * as the transaction fee payer account.
2276
+ *
2277
+ * Transaction fields should not be modified after the first call to `sign`,
2278
+ * as doing so may invalidate the signature and cause the Transaction to be
2279
+ * rejected.
2280
+ *
2281
+ * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
2282
+ */
2283
+ sign(...signers: Array<Signer>): void;
2284
+ /**
2285
+ * Partially sign a transaction with the specified accounts. All accounts must
2286
+ * correspond to either the fee payer or a signer account in the transaction
2287
+ * instructions.
2288
+ *
2289
+ * All the caveats from the `sign` method apply to `partialSign`
2290
+ */
2291
+ partialSign(...signers: Array<Signer>): void;
2292
+ /**
2293
+ * Add an externally created signature to a transaction. The public key
2294
+ * must correspond to either the fee payer or a signer account in the transaction
2295
+ * instructions.
2296
+ */
2297
+ addSignature(pubkey: PublicKey, signature: Buffer): void;
2298
+ /**
2299
+ * Verify signatures of a complete, signed Transaction
2300
+ */
2301
+ verifySignatures(): boolean;
2302
+ /**
2303
+ * Serialize the Transaction in the wire format.
2304
+ */
2305
+ serialize(config?: SerializeConfig): Buffer;
2306
+ /**
2307
+ * Parse a wire transaction into a Transaction object.
2308
+ */
2309
+ static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
2310
+ /**
2311
+ * Populate Transaction object from message and signatures
2312
+ */
2313
+ static populate(message: Message, signatures?: Array<string>): Transaction;
2314
+ }
2315
+
2316
+ export type CreateLookupTableParams = {
2317
+ /** Account used to derive and control the new address lookup table. */
2318
+ authority: PublicKey;
2319
+ /** Account that will fund the new address lookup table. */
2320
+ payer: PublicKey;
2321
+ /** A recent slot must be used in the derivation path for each initialized table. */
2322
+ recentSlot: bigint | number;
2323
+ };
2324
+ export type FreezeLookupTableParams = {
2325
+ /** Address lookup table account to freeze. */
2326
+ lookupTable: PublicKey;
2327
+ /** Account which is the current authority. */
2328
+ authority: PublicKey;
2329
+ };
2330
+ export type ExtendLookupTableParams = {
2331
+ /** Address lookup table account to extend. */
2332
+ lookupTable: PublicKey;
2333
+ /** Account which is the current authority. */
2334
+ authority: PublicKey;
2335
+ /** Account that will fund the table reallocation.
2336
+ * Not required if the reallocation has already been funded. */
2337
+ payer?: PublicKey;
2338
+ /** List of Public Keys to be added to the lookup table. */
2339
+ addresses: Array<PublicKey>;
2340
+ };
2341
+ export type DeactivateLookupTableParams = {
2342
+ /** Address lookup table account to deactivate. */
2343
+ lookupTable: PublicKey;
2344
+ /** Account which is the current authority. */
2345
+ authority: PublicKey;
2346
+ };
2347
+ export type CloseLookupTableParams = {
2348
+ /** Address lookup table account to close. */
2349
+ lookupTable: PublicKey;
2350
+ /** Account which is the current authority. */
2351
+ authority: PublicKey;
2352
+ /** Recipient of closed account lamports. */
2353
+ recipient: PublicKey;
2354
+ };
2355
+ /**
2356
+ * An enumeration of valid LookupTableInstructionType's
2357
+ */
2358
+ export type LookupTableInstructionType =
2359
+ | 'CreateLookupTable'
2360
+ | 'ExtendLookupTable'
2361
+ | 'CloseLookupTable'
2362
+ | 'FreezeLookupTable'
2363
+ | 'DeactivateLookupTable';
2364
+ export class AddressLookupTableInstruction {
2365
+ static decodeInstructionType(
2366
+ instruction: TransactionInstruction,
2367
+ ): LookupTableInstructionType;
2368
+ static decodeCreateLookupTable(
2369
+ instruction: TransactionInstruction,
2370
+ ): CreateLookupTableParams;
2371
+ static decodeExtendLookupTable(
2372
+ instruction: TransactionInstruction,
2373
+ ): ExtendLookupTableParams;
2374
+ static decodeCloseLookupTable(
2375
+ instruction: TransactionInstruction,
2376
+ ): CloseLookupTableParams;
2377
+ static decodeFreezeLookupTable(
2378
+ instruction: TransactionInstruction,
2379
+ ): FreezeLookupTableParams;
2380
+ static decodeDeactivateLookupTable(
2381
+ instruction: TransactionInstruction,
2382
+ ): DeactivateLookupTableParams;
2383
+ }
2384
+ export class AddressLookupTableProgram {
2385
+ static programId: PublicKey;
2386
+ static createLookupTable(
2387
+ params: CreateLookupTableParams,
2388
+ ): [TransactionInstruction, PublicKey];
2389
+ static freezeLookupTable(
2390
+ params: FreezeLookupTableParams,
2391
+ ): TransactionInstruction;
2392
+ static extendLookupTable(
2393
+ params: ExtendLookupTableParams,
2394
+ ): TransactionInstruction;
2395
+ static deactivateLookupTable(
2396
+ params: DeactivateLookupTableParams,
2397
+ ): TransactionInstruction;
2398
+ static closeLookupTable(
2399
+ params: CloseLookupTableParams,
2400
+ ): TransactionInstruction;
2401
+ }
2402
+
2403
+ export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
2404
+
2312
2405
  export const BPF_LOADER_PROGRAM_ID: PublicKey;
2313
2406
  /**
2314
2407
  * Factory class for transactions to interact with a program loader