@solana/web3.js 1.51.0 → 1.54.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.
Files changed (60) hide show
  1. package/lib/index.browser.cjs.js +3600 -3205
  2. package/lib/index.browser.cjs.js.map +1 -1
  3. package/lib/index.browser.esm.js +3595 -3206
  4. package/lib/index.browser.esm.js.map +1 -1
  5. package/lib/index.cjs.js +3602 -3205
  6. package/lib/index.cjs.js.map +1 -1
  7. package/lib/index.d.ts +953 -831
  8. package/lib/index.esm.js +3597 -3206
  9. package/lib/index.esm.js.map +1 -1
  10. package/lib/index.iife.js +2630 -2235
  11. package/lib/index.iife.js.map +1 -1
  12. package/lib/index.iife.min.js +3 -3
  13. package/lib/index.iife.min.js.map +1 -1
  14. package/lib/index.native.js +3600 -3204
  15. package/lib/index.native.js.map +1 -1
  16. package/package.json +1 -2
  17. package/src/account-data.ts +39 -0
  18. package/src/account.ts +1 -1
  19. package/src/connection.ts +49 -16
  20. package/src/fee-calculator.ts +2 -0
  21. package/src/index.ts +3 -14
  22. package/src/layout.ts +7 -0
  23. package/src/loader.ts +4 -5
  24. package/src/message/index.ts +45 -0
  25. package/src/{message.ts → message/legacy.ts} +46 -27
  26. package/src/message/v0.ts +324 -0
  27. package/src/message/versioned.ts +27 -0
  28. package/src/nonce-account.ts +1 -1
  29. package/src/{address-lookup-table-program.ts → programs/address-lookup-table/index.ts} +8 -6
  30. package/src/programs/address-lookup-table/state.ts +84 -0
  31. package/src/{compute-budget.ts → programs/compute-budget.ts} +4 -4
  32. package/src/{ed25519-program.ts → programs/ed25519.ts} +4 -4
  33. package/src/programs/index.ts +7 -0
  34. package/src/{secp256k1-program.ts → programs/secp256k1.ts} +4 -4
  35. package/src/{stake-program.ts → programs/stake.ts} +7 -7
  36. package/src/{system-program.ts → programs/system.ts} +8 -8
  37. package/src/{vote-program.ts → programs/vote.ts} +28 -7
  38. package/src/publickey.ts +9 -4
  39. package/src/{transaction-constants.ts → transaction/constants.ts} +2 -0
  40. package/src/{util/tx-expiry-custom-errors.ts → transaction/expiry-custom-errors.ts} +0 -0
  41. package/src/transaction/index.ts +4 -0
  42. package/src/{transaction.ts → transaction/legacy.ts} +10 -13
  43. package/src/transaction/versioned.ts +108 -0
  44. package/src/{util → utils}/assert.ts +0 -0
  45. package/src/{util → utils}/bigint.ts +0 -0
  46. package/src/{util → utils}/borsh-schema.ts +0 -0
  47. package/src/{util → utils}/cluster.ts +0 -0
  48. package/src/utils/index.ts +4 -0
  49. package/src/utils/makeWebsocketUrl.ts +26 -0
  50. package/src/{util → utils}/promise-timeout.ts +0 -0
  51. package/src/{util → utils}/send-and-confirm-raw-transaction.ts +0 -0
  52. package/src/{util → utils}/send-and-confirm-transaction.ts +0 -0
  53. package/src/{util → utils}/shortvec-encoding.ts +0 -0
  54. package/src/{util → utils}/sleep.ts +0 -0
  55. package/src/{util → utils}/to-buffer.ts +0 -0
  56. package/src/validator-info.ts +4 -6
  57. package/src/vote-account.ts +1 -1
  58. package/src/util/__forks__/react-native/url-impl.ts +0 -2
  59. package/src/util/makeWebsocketUrl.ts +0 -20
  60. package/src/util/url-impl.ts +0 -2
package/lib/index.d.ts CHANGED
@@ -19,6 +19,10 @@ declare module '@solana/web3.js' {
19
19
  * Maximum length of derived pubkey seed
20
20
  */
21
21
  export const MAX_SEED_LENGTH = 32;
22
+ /**
23
+ * Size of public key in bytes
24
+ */
25
+ export const PUBLIC_KEY_LENGTH = 32;
22
26
  /**
23
27
  * Value to be converted into public key
24
28
  */
@@ -142,6 +146,13 @@ declare module '@solana/web3.js' {
142
146
  get secretKey(): Buffer;
143
147
  }
144
148
 
149
+ /**
150
+ * Blockhash as Base58 string.
151
+ */
152
+ export type Blockhash = string;
153
+
154
+ export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
155
+
145
156
  /**
146
157
  * Epoch schedule
147
158
  * (see https://docs.solana.com/terminology#epoch)
@@ -177,13 +188,10 @@ declare module '@solana/web3.js' {
177
188
  init?: nodeFetch.RequestInit,
178
189
  ): Promise<nodeFetch.Response>;
179
190
 
180
- /**
181
- * Blockhash as Base58 string.
182
- */
183
- export type Blockhash = string;
184
-
185
191
  /**
186
192
  * Calculator for transaction fees.
193
+ *
194
+ * @deprecated Deprecated since Solana v1.8.0.
187
195
  */
188
196
  interface FeeCalculator {
189
197
  /** Cost in lamports to validate a signature. */
@@ -274,19 +282,25 @@ declare module '@solana/web3.js' {
274
282
  }
275
283
 
276
284
  /**
277
- * The message header, identifying signed and read-only account
285
+ * Maximum over-the-wire size of a Transaction
286
+ *
287
+ * 1280 is IPv6 minimum MTU
288
+ * 40 bytes is the size of the IPv6 header
289
+ * 8 bytes is the size of the fragment header
278
290
  */
279
- export type MessageHeader = {
280
- /**
281
- * The number of signatures required for this message to be considered valid. The
282
- * signatures must match the first `numRequiredSignatures` of `accountKeys`.
283
- */
284
- numRequiredSignatures: number;
285
- /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
286
- numReadonlySignedAccounts: number;
287
- /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
288
- numReadonlyUnsignedAccounts: number;
289
- };
291
+ export const PACKET_DATA_SIZE: number;
292
+ export const VERSION_PREFIX_MASK = 127;
293
+ export const SIGNATURE_LENGTH_IN_BYTES = 64;
294
+
295
+ export class TransactionExpiredBlockheightExceededError extends Error {
296
+ signature: string;
297
+ constructor(signature: string);
298
+ }
299
+ export class TransactionExpiredTimeoutError extends Error {
300
+ signature: string;
301
+ constructor(signature: string, timeoutSeconds: number);
302
+ }
303
+
290
304
  /**
291
305
  * An instruction to execute by a program
292
306
  *
@@ -325,6 +339,10 @@ declare module '@solana/web3.js' {
325
339
  instructions: CompiledInstruction[];
326
340
  private indexToProgramIds;
327
341
  constructor(args: MessageArgs);
342
+ get version(): 'legacy';
343
+ get staticAccountKeys(): Array<PublicKey>;
344
+ get compiledInstructions(): Array<MessageCompiledInstruction>;
345
+ get addressTableLookups(): Array<MessageAddressTableLookup>;
328
346
  isAccountSigner(index: number): boolean;
329
347
  isAccountWritable(index: number): boolean;
330
348
  isProgramId(index: number): boolean;
@@ -337,247 +355,568 @@ declare module '@solana/web3.js' {
337
355
  static from(buffer: Buffer | Uint8Array | Array<number>): Message;
338
356
  }
339
357
 
340
- export type ClientSubscriptionId = number;
341
- export type TokenAccountsFilter =
342
- | {
343
- mint: PublicKey;
344
- }
345
- | {
346
- programId: PublicKey;
347
- };
348
- /**
349
- * Extra contextual information for RPC responses
350
- */
351
- export type Context = {
352
- slot: number;
353
- };
354
358
  /**
355
- * Options for sending transactions
359
+ * Message constructor arguments
356
360
  */
357
- export type SendOptions = {
358
- /** disable transaction verification step */
359
- skipPreflight?: boolean;
360
- /** preflight commitment level */
361
- preflightCommitment?: Commitment;
362
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
363
- maxRetries?: number;
364
- /** The minimum slot that the request can be evaluated at */
365
- minContextSlot?: number;
361
+ export type MessageV0Args = {
362
+ /** The message header, identifying signed and read-only `accountKeys` */
363
+ header: MessageHeader;
364
+ /** The static account keys used by this transaction */
365
+ staticAccountKeys: PublicKey[];
366
+ /** The hash of a recent ledger block */
367
+ recentBlockhash: Blockhash;
368
+ /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
369
+ compiledInstructions: MessageCompiledInstruction[];
370
+ /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
371
+ addressTableLookups: MessageAddressTableLookup[];
366
372
  };
367
- /**
368
- * Options for confirming transactions
369
- */
370
- export type ConfirmOptions = {
371
- /** disable transaction verification step */
372
- skipPreflight?: boolean;
373
- /** desired commitment level */
374
- commitment?: Commitment;
375
- /** preflight commitment level */
376
- preflightCommitment?: Commitment;
377
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
378
- maxRetries?: number;
379
- /** The minimum slot that the request can be evaluated at */
380
- minContextSlot?: number;
373
+ export class MessageV0 {
374
+ header: MessageHeader;
375
+ staticAccountKeys: Array<PublicKey>;
376
+ recentBlockhash: Blockhash;
377
+ compiledInstructions: Array<MessageCompiledInstruction>;
378
+ addressTableLookups: Array<MessageAddressTableLookup>;
379
+ constructor(args: MessageV0Args);
380
+ get version(): 0;
381
+ serialize(): Uint8Array;
382
+ private serializeInstructions;
383
+ private serializeAddressTableLookups;
384
+ static deserialize(serializedMessage: Uint8Array): MessageV0;
385
+ }
386
+
387
+ export type VersionedMessage = Message | MessageV0;
388
+ export const VersionedMessage: {
389
+ deserialize: (serializedMessage: Uint8Array) => VersionedMessage;
381
390
  };
391
+
382
392
  /**
383
- * Options for getConfirmedSignaturesForAddress2
393
+ * The message header, identifying signed and read-only account
384
394
  */
385
- export type ConfirmedSignaturesForAddress2Options = {
395
+ export type MessageHeader = {
386
396
  /**
387
- * Start searching backwards from this transaction signature.
388
- * @remark If not provided the search starts from the highest max confirmed block.
397
+ * The number of signatures required for this message to be considered valid. The
398
+ * signatures must match the first `numRequiredSignatures` of `accountKeys`.
389
399
  */
390
- before?: TransactionSignature;
391
- /** Search until this transaction signature is reached, if found before `limit`. */
392
- until?: TransactionSignature;
393
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
394
- limit?: number;
400
+ numRequiredSignatures: number;
401
+ /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
402
+ numReadonlySignedAccounts: number;
403
+ /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
404
+ numReadonlyUnsignedAccounts: number;
395
405
  };
396
406
  /**
397
- * Options for getSignaturesForAddress
407
+ * An address table lookup used to load additional accounts
398
408
  */
399
- export type SignaturesForAddressOptions = {
400
- /**
401
- * Start searching backwards from this transaction signature.
402
- * @remark If not provided the search starts from the highest max confirmed block.
403
- */
404
- before?: TransactionSignature;
405
- /** Search until this transaction signature is reached, if found before `limit`. */
406
- until?: TransactionSignature;
407
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
408
- limit?: number;
409
- /** The minimum slot that the request can be evaluated at */
410
- minContextSlot?: number;
409
+ export type MessageAddressTableLookup = {
410
+ accountKey: PublicKey;
411
+ writableIndexes: Array<number>;
412
+ readonlyIndexes: Array<number>;
411
413
  };
412
414
  /**
413
- * RPC Response with extra contextual information
415
+ * An instruction to execute by a program
416
+ *
417
+ * @property {number} programIdIndex
418
+ * @property {number[]} accountKeyIndexes
419
+ * @property {Uint8Array} data
414
420
  */
415
- export type RpcResponseAndContext<T> = {
416
- /** response context */
417
- context: Context;
418
- /** response value */
419
- value: T;
421
+ export type MessageCompiledInstruction = {
422
+ /** Index into the transaction keys array indicating the program account that executes this instruction */
423
+ programIdIndex: number;
424
+ /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
425
+ accountKeyIndexes: number[];
426
+ /** The program input data */
427
+ data: Uint8Array;
420
428
  };
421
- export type BlockhashWithExpiryBlockHeight = Readonly<{
422
- blockhash: Blockhash;
423
- lastValidBlockHeight: number;
424
- }>;
429
+
425
430
  /**
426
- * A strategy for confirming transactions that uses the last valid
427
- * block height for a given blockhash to check for transaction expiration.
431
+ * Transaction signature as base-58 encoded string
428
432
  */
429
- export type BlockheightBasedTransactionConfirmationStrategy = {
430
- signature: TransactionSignature;
431
- } & BlockhashWithExpiryBlockHeight;
433
+ export type TransactionSignature = string;
434
+ export const enum TransactionStatus {
435
+ BLOCKHEIGHT_EXCEEDED = 0,
436
+ PROCESSED = 1,
437
+ TIMED_OUT = 2,
438
+ }
432
439
  /**
433
- * The level of commitment desired when querying state
434
- * <pre>
435
- * 'processed': Query the most recent block which has reached 1 confirmation by the connected node
436
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
437
- * 'finalized': Query the most recent block which has been finalized by the cluster
438
- * </pre>
440
+ * Account metadata used to define instructions
439
441
  */
440
- export type Commitment =
441
- | 'processed'
442
- | 'confirmed'
443
- | 'finalized'
444
- | 'recent'
445
- | 'single'
446
- | 'singleGossip'
447
- | 'root'
448
- | 'max';
442
+ export type AccountMeta = {
443
+ /** An account's public key */
444
+ pubkey: PublicKey;
445
+ /** True if an instruction requires a transaction signature matching `pubkey` */
446
+ isSigner: boolean;
447
+ /** True if the `pubkey` can be loaded as a read-write account. */
448
+ isWritable: boolean;
449
+ };
449
450
  /**
450
- * A subset of Commitment levels, which are at least optimistically confirmed
451
- * <pre>
452
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
453
- * 'finalized': Query the most recent block which has been finalized by the cluster
454
- * </pre>
451
+ * List of TransactionInstruction object fields that may be initialized at construction
455
452
  */
456
- export type Finality = 'confirmed' | 'finalized';
453
+ export type TransactionInstructionCtorFields = {
454
+ keys: Array<AccountMeta>;
455
+ programId: PublicKey;
456
+ data?: Buffer;
457
+ };
457
458
  /**
458
- * Filter for largest accounts query
459
- * <pre>
460
- * 'circulating': Return the largest accounts that are part of the circulating supply
461
- * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
462
- * </pre>
459
+ * Configuration object for Transaction.serialize()
463
460
  */
464
- export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
461
+ export type SerializeConfig = {
462
+ /** Require all transaction signatures be present (default: true) */
463
+ requireAllSignatures?: boolean;
464
+ /** Verify provided signatures (default: true) */
465
+ verifySignatures?: boolean;
466
+ };
465
467
  /**
466
- * Configuration object for changing `getAccountInfo` query behavior
468
+ * Transaction Instruction class
467
469
  */
468
- export type GetAccountInfoConfig = {
469
- /** The level of commitment desired */
470
- commitment?: Commitment;
471
- /** The minimum slot that the request can be evaluated at */
472
- minContextSlot?: number;
473
- };
470
+ export class TransactionInstruction {
471
+ /**
472
+ * Public keys to include in this transaction
473
+ * Boolean represents whether this pubkey needs to sign the transaction
474
+ */
475
+ keys: Array<AccountMeta>;
476
+ /**
477
+ * Program Id to execute
478
+ */
479
+ programId: PublicKey;
480
+ /**
481
+ * Program input
482
+ */
483
+ data: Buffer;
484
+ constructor(opts: TransactionInstructionCtorFields);
485
+ }
474
486
  /**
475
- * Configuration object for changing `getBalance` query behavior
487
+ * Pair of signature and corresponding public key
476
488
  */
477
- export type GetBalanceConfig = {
478
- /** The level of commitment desired */
479
- commitment?: Commitment;
480
- /** The minimum slot that the request can be evaluated at */
481
- minContextSlot?: number;
489
+ export type SignaturePubkeyPair = {
490
+ signature: Buffer | null;
491
+ publicKey: PublicKey;
482
492
  };
483
493
  /**
484
- * Configuration object for changing `getBlock` query behavior
494
+ * List of Transaction object fields that may be initialized at construction
485
495
  */
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;
496
+ export type TransactionCtorFields_DEPRECATED = {
497
+ /** Optional nonce information used for offline nonce'd transactions */
498
+ nonceInfo?: NonceInformation | null;
499
+ /** The transaction fee payer */
500
+ feePayer?: PublicKey | null;
501
+ /** One or more signatures */
502
+ signatures?: Array<SignaturePubkeyPair>;
503
+ /** A recent blockhash */
504
+ recentBlockhash?: Blockhash;
491
505
  };
506
+ export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
492
507
  /**
493
- * Configuration object for changing `getStakeMinimumDelegation` query behavior
508
+ * List of Transaction object fields that may be initialized at construction
494
509
  */
495
- export type GetStakeMinimumDelegationConfig = {
496
- /** The level of commitment desired */
497
- commitment?: Commitment;
510
+ export type TransactionBlockhashCtor = {
511
+ /** The transaction fee payer */
512
+ feePayer?: PublicKey | null;
513
+ /** One or more signatures */
514
+ signatures?: Array<SignaturePubkeyPair>;
515
+ /** A recent blockhash */
516
+ blockhash: Blockhash;
517
+ /** the last block chain can advance to before tx is exportd expired */
518
+ lastValidBlockHeight: number;
498
519
  };
499
520
  /**
500
- * Configuration object for changing `getBlockHeight` query behavior
521
+ * Nonce information to be used to build an offline Transaction.
501
522
  */
502
- export type GetBlockHeightConfig = {
503
- /** The level of commitment desired */
504
- commitment?: Commitment;
505
- /** The minimum slot that the request can be evaluated at */
506
- minContextSlot?: number;
523
+ export type NonceInformation = {
524
+ /** The current blockhash stored in the nonce */
525
+ nonce: Blockhash;
526
+ /** AdvanceNonceAccount Instruction */
527
+ nonceInstruction: TransactionInstruction;
507
528
  };
508
529
  /**
509
- * Configuration object for changing `getEpochInfo` query behavior
530
+ * Transaction class
510
531
  */
511
- export type GetEpochInfoConfig = {
512
- /** The level of commitment desired */
513
- commitment?: Commitment;
514
- /** The minimum slot that the request can be evaluated at */
515
- minContextSlot?: number;
516
- };
532
+ export class Transaction {
533
+ /**
534
+ * Signatures for the transaction. Typically created by invoking the
535
+ * `sign()` method
536
+ */
537
+ signatures: Array<SignaturePubkeyPair>;
538
+ /**
539
+ * The first (payer) Transaction signature
540
+ */
541
+ get signature(): Buffer | null;
542
+ /**
543
+ * The transaction fee payer
544
+ */
545
+ feePayer?: PublicKey;
546
+ /**
547
+ * The instructions to atomically execute
548
+ */
549
+ instructions: Array<TransactionInstruction>;
550
+ /**
551
+ * A recent transaction id. Must be populated by the caller
552
+ */
553
+ recentBlockhash?: Blockhash;
554
+ /**
555
+ * the last block chain can advance to before tx is exportd expired
556
+ * */
557
+ lastValidBlockHeight?: number;
558
+ /**
559
+ * Optional Nonce information. If populated, transaction will use a durable
560
+ * Nonce hash instead of a recentBlockhash. Must be populated by the caller
561
+ */
562
+ nonceInfo?: NonceInformation;
563
+ constructor(opts?: TransactionBlockhashCtor);
564
+ /**
565
+ * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
566
+ * Please supply a `TransactionBlockhashCtor` instead.
567
+ */
568
+ constructor(opts?: TransactionCtorFields_DEPRECATED);
569
+ /**
570
+ * Add one or more instructions to this Transaction
571
+ */
572
+ add(
573
+ ...items: Array<
574
+ Transaction | TransactionInstruction | TransactionInstructionCtorFields
575
+ >
576
+ ): Transaction;
577
+ /**
578
+ * Compile transaction data
579
+ */
580
+ compileMessage(): Message;
581
+ /**
582
+ * Get a buffer of the Transaction data that need to be covered by signatures
583
+ */
584
+ serializeMessage(): Buffer;
585
+ /**
586
+ * Get the estimated fee associated with a transaction
587
+ */
588
+ getEstimatedFee(connection: Connection): Promise<number>;
589
+ /**
590
+ * Specify the public keys which will be used to sign the Transaction.
591
+ * The first signer will be used as the transaction fee payer account.
592
+ *
593
+ * Signatures can be added with either `partialSign` or `addSignature`
594
+ *
595
+ * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
596
+ * specified and it can be set in the Transaction constructor or with the
597
+ * `feePayer` property.
598
+ */
599
+ setSigners(...signers: Array<PublicKey>): void;
600
+ /**
601
+ * Sign the Transaction with the specified signers. Multiple signatures may
602
+ * be applied to a Transaction. The first signature is considered "primary"
603
+ * and is used identify and confirm transactions.
604
+ *
605
+ * If the Transaction `feePayer` is not set, the first signer will be used
606
+ * as the transaction fee payer account.
607
+ *
608
+ * Transaction fields should not be modified after the first call to `sign`,
609
+ * as doing so may invalidate the signature and cause the Transaction to be
610
+ * rejected.
611
+ *
612
+ * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
613
+ */
614
+ sign(...signers: Array<Signer>): void;
615
+ /**
616
+ * Partially sign a transaction with the specified accounts. All accounts must
617
+ * correspond to either the fee payer or a signer account in the transaction
618
+ * instructions.
619
+ *
620
+ * All the caveats from the `sign` method apply to `partialSign`
621
+ */
622
+ partialSign(...signers: Array<Signer>): void;
623
+ /**
624
+ * Add an externally created signature to a transaction. The public key
625
+ * must correspond to either the fee payer or a signer account in the transaction
626
+ * instructions.
627
+ */
628
+ addSignature(pubkey: PublicKey, signature: Buffer): void;
629
+ /**
630
+ * Verify signatures of a complete, signed Transaction
631
+ */
632
+ verifySignatures(): boolean;
633
+ /**
634
+ * Serialize the Transaction in the wire format.
635
+ */
636
+ serialize(config?: SerializeConfig): Buffer;
637
+ /**
638
+ * Parse a wire transaction into a Transaction object.
639
+ */
640
+ static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
641
+ /**
642
+ * Populate Transaction object from message and signatures
643
+ */
644
+ static populate(message: Message, signatures?: Array<string>): Transaction;
645
+ }
646
+
647
+ export type TransactionVersion = 'legacy' | 0;
517
648
  /**
518
- * Configuration object for changing `getInflationReward` query behavior
649
+ * Versioned transaction class
519
650
  */
520
- export type GetInflationRewardConfig = {
521
- /** The level of commitment desired */
522
- commitment?: Commitment;
523
- /** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
524
- epoch?: number;
525
- /** The minimum slot that the request can be evaluated at */
526
- minContextSlot?: number;
651
+ export class VersionedTransaction {
652
+ signatures: Array<Uint8Array>;
653
+ message: VersionedMessage;
654
+ constructor(message: VersionedMessage, signatures?: Array<Uint8Array>);
655
+ serialize(): Uint8Array;
656
+ static deserialize(serializedTransaction: Uint8Array): VersionedTransaction;
657
+ sign(signers: Array<Signer>): void;
658
+ }
659
+
660
+ export type AddressLookupTableState = {
661
+ deactivationSlot: bigint;
662
+ lastExtendedSlot: number;
663
+ lastExtendedSlotStartIndex: number;
664
+ authority?: PublicKey;
665
+ addresses: Array<PublicKey>;
666
+ };
667
+ export type AddressLookupTableAccountArgs = {
668
+ key: PublicKey;
669
+ state: AddressLookupTableState;
527
670
  };
671
+ export class AddressLookupTableAccount {
672
+ key: PublicKey;
673
+ state: AddressLookupTableState;
674
+ constructor(args: AddressLookupTableAccountArgs);
675
+ isActive(): boolean;
676
+ static deserialize(accountData: Uint8Array): AddressLookupTableState;
677
+ }
678
+
679
+ export type ClientSubscriptionId = number;
680
+ export type TokenAccountsFilter =
681
+ | {
682
+ mint: PublicKey;
683
+ }
684
+ | {
685
+ programId: PublicKey;
686
+ };
528
687
  /**
529
- * Configuration object for changing `getLatestBlockhash` query behavior
688
+ * Extra contextual information for RPC responses
530
689
  */
531
- export type GetLatestBlockhashConfig = {
532
- /** The level of commitment desired */
533
- commitment?: Commitment;
534
- /** The minimum slot that the request can be evaluated at */
535
- minContextSlot?: number;
690
+ export type Context = {
691
+ slot: number;
536
692
  };
537
693
  /**
538
- * Configuration object for changing `getSlot` query behavior
694
+ * Options for sending transactions
539
695
  */
540
- export type GetSlotConfig = {
541
- /** The level of commitment desired */
542
- commitment?: Commitment;
696
+ export type SendOptions = {
697
+ /** disable transaction verification step */
698
+ skipPreflight?: boolean;
699
+ /** preflight commitment level */
700
+ preflightCommitment?: Commitment;
701
+ /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
702
+ maxRetries?: number;
543
703
  /** The minimum slot that the request can be evaluated at */
544
704
  minContextSlot?: number;
545
705
  };
546
706
  /**
547
- * Configuration object for changing `getSlotLeader` query behavior
707
+ * Options for confirming transactions
548
708
  */
549
- export type GetSlotLeaderConfig = {
550
- /** The level of commitment desired */
709
+ export type ConfirmOptions = {
710
+ /** disable transaction verification step */
711
+ skipPreflight?: boolean;
712
+ /** desired commitment level */
551
713
  commitment?: Commitment;
714
+ /** preflight commitment level */
715
+ preflightCommitment?: Commitment;
716
+ /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
717
+ maxRetries?: number;
552
718
  /** The minimum slot that the request can be evaluated at */
553
719
  minContextSlot?: number;
554
720
  };
555
721
  /**
556
- * Configuration object for changing `getTransaction` query behavior
722
+ * Options for getConfirmedSignaturesForAddress2
557
723
  */
558
- export type GetTransactionConfig = {
559
- /** The level of finality desired */
560
- commitment?: Finality;
561
- /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
562
- maxSupportedTransactionVersion?: number;
724
+ export type ConfirmedSignaturesForAddress2Options = {
725
+ /**
726
+ * Start searching backwards from this transaction signature.
727
+ * @remark If not provided the search starts from the highest max confirmed block.
728
+ */
729
+ before?: TransactionSignature;
730
+ /** Search until this transaction signature is reached, if found before `limit`. */
731
+ until?: TransactionSignature;
732
+ /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
733
+ limit?: number;
563
734
  };
564
735
  /**
565
- * Configuration object for changing `getLargestAccounts` query behavior
736
+ * Options for getSignaturesForAddress
566
737
  */
567
- export type GetLargestAccountsConfig = {
568
- /** The level of commitment desired */
569
- commitment?: Commitment;
570
- /** Filter largest accounts by whether they are part of the circulating supply */
571
- filter?: LargestAccountsFilter;
738
+ export type SignaturesForAddressOptions = {
739
+ /**
740
+ * Start searching backwards from this transaction signature.
741
+ * @remark If not provided the search starts from the highest max confirmed block.
742
+ */
743
+ before?: TransactionSignature;
744
+ /** Search until this transaction signature is reached, if found before `limit`. */
745
+ until?: TransactionSignature;
746
+ /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
747
+ limit?: number;
748
+ /** The minimum slot that the request can be evaluated at */
749
+ minContextSlot?: number;
572
750
  };
573
751
  /**
574
- * Configuration object for changing `getSupply` request behavior
752
+ * RPC Response with extra contextual information
575
753
  */
576
- export type GetSupplyConfig = {
577
- /** The level of commitment desired */
578
- commitment?: Commitment;
579
- /** Exclude non circulating accounts list from response */
580
- excludeNonCirculatingAccountsList?: boolean;
754
+ export type RpcResponseAndContext<T> = {
755
+ /** response context */
756
+ context: Context;
757
+ /** response value */
758
+ value: T;
759
+ };
760
+ export type BlockhashWithExpiryBlockHeight = Readonly<{
761
+ blockhash: Blockhash;
762
+ lastValidBlockHeight: number;
763
+ }>;
764
+ /**
765
+ * A strategy for confirming transactions that uses the last valid
766
+ * block height for a given blockhash to check for transaction expiration.
767
+ */
768
+ export type BlockheightBasedTransactionConfirmationStrategy = {
769
+ signature: TransactionSignature;
770
+ } & BlockhashWithExpiryBlockHeight;
771
+ /**
772
+ * The level of commitment desired when querying state
773
+ * <pre>
774
+ * 'processed': Query the most recent block which has reached 1 confirmation by the connected node
775
+ * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
776
+ * 'finalized': Query the most recent block which has been finalized by the cluster
777
+ * </pre>
778
+ */
779
+ export type Commitment =
780
+ | 'processed'
781
+ | 'confirmed'
782
+ | 'finalized'
783
+ | 'recent'
784
+ | 'single'
785
+ | 'singleGossip'
786
+ | 'root'
787
+ | 'max';
788
+ /**
789
+ * A subset of Commitment levels, which are at least optimistically confirmed
790
+ * <pre>
791
+ * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
792
+ * 'finalized': Query the most recent block which has been finalized by the cluster
793
+ * </pre>
794
+ */
795
+ export type Finality = 'confirmed' | 'finalized';
796
+ /**
797
+ * Filter for largest accounts query
798
+ * <pre>
799
+ * 'circulating': Return the largest accounts that are part of the circulating supply
800
+ * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
801
+ * </pre>
802
+ */
803
+ export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
804
+ /**
805
+ * Configuration object for changing `getAccountInfo` query behavior
806
+ */
807
+ export type GetAccountInfoConfig = {
808
+ /** The level of commitment desired */
809
+ commitment?: Commitment;
810
+ /** The minimum slot that the request can be evaluated at */
811
+ minContextSlot?: number;
812
+ };
813
+ /**
814
+ * Configuration object for changing `getBalance` query behavior
815
+ */
816
+ export type GetBalanceConfig = {
817
+ /** The level of commitment desired */
818
+ commitment?: Commitment;
819
+ /** The minimum slot that the request can be evaluated at */
820
+ minContextSlot?: number;
821
+ };
822
+ /**
823
+ * Configuration object for changing `getBlock` query behavior
824
+ */
825
+ export type GetBlockConfig = {
826
+ /** The level of finality desired */
827
+ commitment?: Finality;
828
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
829
+ maxSupportedTransactionVersion?: number;
830
+ };
831
+ /**
832
+ * Configuration object for changing `getStakeMinimumDelegation` query behavior
833
+ */
834
+ export type GetStakeMinimumDelegationConfig = {
835
+ /** The level of commitment desired */
836
+ commitment?: Commitment;
837
+ };
838
+ /**
839
+ * Configuration object for changing `getBlockHeight` query behavior
840
+ */
841
+ export type GetBlockHeightConfig = {
842
+ /** The level of commitment desired */
843
+ commitment?: Commitment;
844
+ /** The minimum slot that the request can be evaluated at */
845
+ minContextSlot?: number;
846
+ };
847
+ /**
848
+ * Configuration object for changing `getEpochInfo` query behavior
849
+ */
850
+ export type GetEpochInfoConfig = {
851
+ /** The level of commitment desired */
852
+ commitment?: Commitment;
853
+ /** The minimum slot that the request can be evaluated at */
854
+ minContextSlot?: number;
855
+ };
856
+ /**
857
+ * Configuration object for changing `getInflationReward` query behavior
858
+ */
859
+ export type GetInflationRewardConfig = {
860
+ /** The level of commitment desired */
861
+ commitment?: Commitment;
862
+ /** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
863
+ epoch?: number;
864
+ /** The minimum slot that the request can be evaluated at */
865
+ minContextSlot?: number;
866
+ };
867
+ /**
868
+ * Configuration object for changing `getLatestBlockhash` query behavior
869
+ */
870
+ export type GetLatestBlockhashConfig = {
871
+ /** The level of commitment desired */
872
+ commitment?: Commitment;
873
+ /** The minimum slot that the request can be evaluated at */
874
+ minContextSlot?: number;
875
+ };
876
+ /**
877
+ * Configuration object for changing `getSlot` query behavior
878
+ */
879
+ export type GetSlotConfig = {
880
+ /** The level of commitment desired */
881
+ commitment?: Commitment;
882
+ /** The minimum slot that the request can be evaluated at */
883
+ minContextSlot?: number;
884
+ };
885
+ /**
886
+ * Configuration object for changing `getSlotLeader` query behavior
887
+ */
888
+ export type GetSlotLeaderConfig = {
889
+ /** The level of commitment desired */
890
+ commitment?: Commitment;
891
+ /** The minimum slot that the request can be evaluated at */
892
+ minContextSlot?: number;
893
+ };
894
+ /**
895
+ * Configuration object for changing `getTransaction` query behavior
896
+ */
897
+ export type GetTransactionConfig = {
898
+ /** The level of finality desired */
899
+ commitment?: Finality;
900
+ /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
901
+ maxSupportedTransactionVersion?: number;
902
+ };
903
+ /**
904
+ * Configuration object for changing `getLargestAccounts` query behavior
905
+ */
906
+ export type GetLargestAccountsConfig = {
907
+ /** The level of commitment desired */
908
+ commitment?: Commitment;
909
+ /** Filter largest accounts by whether they are part of the circulating supply */
910
+ filter?: LargestAccountsFilter;
911
+ };
912
+ /**
913
+ * Configuration object for changing `getSupply` request behavior
914
+ */
915
+ export type GetSupplyConfig = {
916
+ /** The level of commitment desired */
917
+ commitment?: Commitment;
918
+ /** Exclude non circulating accounts list from response */
919
+ excludeNonCirculatingAccountsList?: boolean;
581
920
  };
582
921
  /**
583
922
  * Configuration object for changing query behavior
@@ -794,6 +1133,8 @@ declare module '@solana/web3.js' {
794
1133
  };
795
1134
  /**
796
1135
  * A confirmed transaction on the ledger
1136
+ *
1137
+ * @deprecated Deprecated since Solana v1.8.0.
797
1138
  */
798
1139
  export type ConfirmedTransaction = {
799
1140
  /** The slot during which the transaction was processed */
@@ -914,7 +1255,9 @@ declare module '@solana/web3.js' {
914
1255
  blockTime: number | null;
915
1256
  };
916
1257
  /**
917
- * A ConfirmedBlock on the ledger
1258
+ * A confirmed block on the ledger
1259
+ *
1260
+ * @deprecated Deprecated since Solana v1.8.0.
918
1261
  */
919
1262
  export type ConfirmedBlock = {
920
1263
  /** Blockhash of this block */
@@ -1546,7 +1889,7 @@ declare module '@solana/web3.js' {
1546
1889
  */
1547
1890
  getParsedAccountInfo(
1548
1891
  publicKey: PublicKey,
1549
- commitment?: Commitment,
1892
+ commitmentOrConfig?: Commitment | GetAccountInfoConfig,
1550
1893
  ): Promise<
1551
1894
  RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>
1552
1895
  >;
@@ -1911,6 +2254,10 @@ declare module '@solana/web3.js' {
1911
2254
  options?: SignaturesForAddressOptions,
1912
2255
  commitment?: Finality,
1913
2256
  ): Promise<Array<ConfirmedSignatureInfo>>;
2257
+ getAddressLookupTable(
2258
+ accountKey: PublicKey,
2259
+ config?: GetAccountInfoConfig,
2260
+ ): Promise<RpcResponseAndContext<AddressLookupTableAccount | null>>;
1914
2261
  /**
1915
2262
  * Fetch the contents of a Nonce account from the cluster, return with context
1916
2263
  */
@@ -1974,379 +2321,268 @@ declare module '@solana/web3.js' {
1974
2321
  options?: SendOptions,
1975
2322
  ): Promise<TransactionSignature>;
1976
2323
  /**
1977
- * Send a transaction that has already been signed, serialized into the
1978
- * wire format, and encoded as a base64 string
1979
- */
1980
- sendEncodedTransaction(
1981
- encodedTransaction: string,
1982
- options?: SendOptions,
1983
- ): Promise<TransactionSignature>;
1984
- /**
1985
- * Register a callback to be invoked whenever the specified account changes
1986
- *
1987
- * @param publicKey Public key of the account to monitor
1988
- * @param callback Function to invoke whenever the account is changed
1989
- * @param commitment Specify the commitment level account changes must reach before notification
1990
- * @return subscription id
1991
- */
1992
- onAccountChange(
1993
- publicKey: PublicKey,
1994
- callback: AccountChangeCallback,
1995
- commitment?: Commitment,
1996
- ): ClientSubscriptionId;
1997
- /**
1998
- * Deregister an account notification callback
1999
- *
2000
- * @param id client subscription id to deregister
2001
- */
2002
- removeAccountChangeListener(
2003
- clientSubscriptionId: ClientSubscriptionId,
2004
- ): Promise<void>;
2005
- /**
2006
- * Register a callback to be invoked whenever accounts owned by the
2007
- * specified program change
2008
- *
2009
- * @param programId Public key of the program to monitor
2010
- * @param callback Function to invoke whenever the account is changed
2011
- * @param commitment Specify the commitment level account changes must reach before notification
2012
- * @param filters The program account filters to pass into the RPC method
2013
- * @return subscription id
2014
- */
2015
- onProgramAccountChange(
2016
- programId: PublicKey,
2017
- callback: ProgramAccountChangeCallback,
2018
- commitment?: Commitment,
2019
- filters?: GetProgramAccountsFilter[],
2020
- ): ClientSubscriptionId;
2021
- /**
2022
- * Deregister an account notification callback
2023
- *
2024
- * @param id client subscription id to deregister
2025
- */
2026
- removeProgramAccountChangeListener(
2027
- clientSubscriptionId: ClientSubscriptionId,
2028
- ): Promise<void>;
2029
- /**
2030
- * Registers a callback to be invoked whenever logs are emitted.
2031
- */
2032
- onLogs(
2033
- filter: LogsFilter,
2034
- callback: LogsCallback,
2035
- commitment?: Commitment,
2036
- ): ClientSubscriptionId;
2037
- /**
2038
- * Deregister a logs callback.
2039
- *
2040
- * @param id client subscription id to deregister.
2041
- */
2042
- removeOnLogsListener(
2043
- clientSubscriptionId: ClientSubscriptionId,
2044
- ): Promise<void>;
2045
- /**
2046
- * Register a callback to be invoked upon slot changes
2047
- *
2048
- * @param callback Function to invoke whenever the slot changes
2049
- * @return subscription id
2050
- */
2051
- onSlotChange(callback: SlotChangeCallback): ClientSubscriptionId;
2052
- /**
2053
- * Deregister a slot notification callback
2054
- *
2055
- * @param id client subscription id to deregister
2056
- */
2057
- removeSlotChangeListener(
2058
- clientSubscriptionId: ClientSubscriptionId,
2059
- ): Promise<void>;
2060
- /**
2061
- * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s
2062
- * may be useful to track live progress of a cluster.
2063
- *
2064
- * @param callback Function to invoke whenever the slot updates
2065
- * @return subscription id
2066
- */
2067
- onSlotUpdate(callback: SlotUpdateCallback): ClientSubscriptionId;
2068
- /**
2069
- * Deregister a slot update notification callback
2070
- *
2071
- * @param id client subscription id to deregister
2072
- */
2073
- removeSlotUpdateListener(
2074
- clientSubscriptionId: ClientSubscriptionId,
2075
- ): Promise<void>;
2076
- _buildArgs(
2077
- args: Array<any>,
2078
- override?: Commitment,
2079
- encoding?: 'jsonParsed' | 'base64',
2080
- extra?: any,
2081
- ): Array<any>;
2082
- /**
2083
- * Register a callback to be invoked upon signature updates
2084
- *
2085
- * @param signature Transaction signature string in base 58
2086
- * @param callback Function to invoke on signature notifications
2087
- * @param commitment Specify the commitment level signature must reach before notification
2088
- * @return subscription id
2089
- */
2090
- onSignature(
2091
- signature: TransactionSignature,
2092
- callback: SignatureResultCallback,
2093
- commitment?: Commitment,
2094
- ): ClientSubscriptionId;
2095
- /**
2096
- * Register a callback to be invoked when a transaction is
2097
- * received and/or processed.
2098
- *
2099
- * @param signature Transaction signature string in base 58
2100
- * @param callback Function to invoke on signature notifications
2101
- * @param options Enable received notifications and set the commitment
2102
- * level that signature must reach before notification
2103
- * @return subscription id
2104
- */
2105
- onSignatureWithOptions(
2106
- signature: TransactionSignature,
2107
- callback: SignatureSubscriptionCallback,
2108
- options?: SignatureSubscriptionOptions,
2109
- ): ClientSubscriptionId;
2110
- /**
2111
- * Deregister a signature notification callback
2112
- *
2113
- * @param id client subscription id to deregister
2114
- */
2115
- removeSignatureListener(
2116
- clientSubscriptionId: ClientSubscriptionId,
2117
- ): Promise<void>;
2118
- /**
2119
- * Register a callback to be invoked upon root changes
2120
- *
2121
- * @param callback Function to invoke whenever the root changes
2122
- * @return subscription id
2123
- */
2124
- onRootChange(callback: RootChangeCallback): ClientSubscriptionId;
2125
- /**
2126
- * Deregister a root notification callback
2127
- *
2128
- * @param id client subscription id to deregister
2129
- */
2130
- removeRootChangeListener(
2131
- clientSubscriptionId: ClientSubscriptionId,
2132
- ): Promise<void>;
2133
- }
2134
-
2135
- /**
2136
- * Transaction signature as base-58 encoded string
2137
- */
2138
- export type TransactionSignature = string;
2139
- export const enum TransactionStatus {
2140
- BLOCKHEIGHT_EXCEEDED = 0,
2141
- PROCESSED = 1,
2142
- TIMED_OUT = 2,
2143
- }
2144
- /**
2145
- * Account metadata used to define instructions
2146
- */
2147
- export type AccountMeta = {
2148
- /** An account's public key */
2149
- pubkey: PublicKey;
2150
- /** True if an instruction requires a transaction signature matching `pubkey` */
2151
- isSigner: boolean;
2152
- /** True if the `pubkey` can be loaded as a read-write account. */
2153
- isWritable: boolean;
2154
- };
2155
- /**
2156
- * List of TransactionInstruction object fields that may be initialized at construction
2157
- */
2158
- export type TransactionInstructionCtorFields = {
2159
- keys: Array<AccountMeta>;
2160
- programId: PublicKey;
2161
- data?: Buffer;
2162
- };
2163
- /**
2164
- * Configuration object for Transaction.serialize()
2165
- */
2166
- export type SerializeConfig = {
2167
- /** Require all transaction signatures be present (default: true) */
2168
- requireAllSignatures?: boolean;
2169
- /** Verify provided signatures (default: true) */
2170
- verifySignatures?: boolean;
2171
- };
2172
- /**
2173
- * Transaction Instruction class
2174
- */
2175
- export class TransactionInstruction {
2176
- /**
2177
- * Public keys to include in this transaction
2178
- * Boolean represents whether this pubkey needs to sign the transaction
2179
- */
2180
- keys: Array<AccountMeta>;
2181
- /**
2182
- * Program Id to execute
2183
- */
2184
- programId: PublicKey;
2185
- /**
2186
- * Program input
2187
- */
2188
- data: Buffer;
2189
- constructor(opts: TransactionInstructionCtorFields);
2190
- }
2191
- /**
2192
- * Pair of signature and corresponding public key
2193
- */
2194
- export type SignaturePubkeyPair = {
2195
- signature: Buffer | null;
2196
- publicKey: PublicKey;
2197
- };
2198
- /**
2199
- * List of Transaction object fields that may be initialized at construction
2200
- */
2201
- export type TransactionCtorFields_DEPRECATED = {
2202
- /** Optional nonce information used for offline nonce'd transactions */
2203
- nonceInfo?: NonceInformation | null;
2204
- /** The transaction fee payer */
2205
- feePayer?: PublicKey | null;
2206
- /** One or more signatures */
2207
- signatures?: Array<SignaturePubkeyPair>;
2208
- /** A recent blockhash */
2209
- recentBlockhash?: Blockhash;
2210
- };
2211
- export type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
2212
- /**
2213
- * List of Transaction object fields that may be initialized at construction
2214
- */
2215
- export type TransactionBlockhashCtor = {
2216
- /** The transaction fee payer */
2217
- feePayer?: PublicKey | null;
2218
- /** One or more signatures */
2219
- signatures?: Array<SignaturePubkeyPair>;
2220
- /** A recent blockhash */
2221
- blockhash: Blockhash;
2222
- /** the last block chain can advance to before tx is exportd expired */
2223
- lastValidBlockHeight: number;
2224
- };
2225
- /**
2226
- * Nonce information to be used to build an offline Transaction.
2227
- */
2228
- export type NonceInformation = {
2229
- /** The current blockhash stored in the nonce */
2230
- nonce: Blockhash;
2231
- /** AdvanceNonceAccount Instruction */
2232
- nonceInstruction: TransactionInstruction;
2233
- };
2234
- /**
2235
- * Transaction class
2236
- */
2237
- export class Transaction {
2238
- /**
2239
- * Signatures for the transaction. Typically created by invoking the
2240
- * `sign()` method
2241
- */
2242
- signatures: Array<SignaturePubkeyPair>;
2243
- /**
2244
- * The first (payer) Transaction signature
2324
+ * Send a transaction that has already been signed, serialized into the
2325
+ * wire format, and encoded as a base64 string
2245
2326
  */
2246
- get signature(): Buffer | null;
2327
+ sendEncodedTransaction(
2328
+ encodedTransaction: string,
2329
+ options?: SendOptions,
2330
+ ): Promise<TransactionSignature>;
2247
2331
  /**
2248
- * The transaction fee payer
2332
+ * Register a callback to be invoked whenever the specified account changes
2333
+ *
2334
+ * @param publicKey Public key of the account to monitor
2335
+ * @param callback Function to invoke whenever the account is changed
2336
+ * @param commitment Specify the commitment level account changes must reach before notification
2337
+ * @return subscription id
2249
2338
  */
2250
- feePayer?: PublicKey;
2339
+ onAccountChange(
2340
+ publicKey: PublicKey,
2341
+ callback: AccountChangeCallback,
2342
+ commitment?: Commitment,
2343
+ ): ClientSubscriptionId;
2251
2344
  /**
2252
- * The instructions to atomically execute
2345
+ * Deregister an account notification callback
2346
+ *
2347
+ * @param id client subscription id to deregister
2253
2348
  */
2254
- instructions: Array<TransactionInstruction>;
2349
+ removeAccountChangeListener(
2350
+ clientSubscriptionId: ClientSubscriptionId,
2351
+ ): Promise<void>;
2255
2352
  /**
2256
- * A recent transaction id. Must be populated by the caller
2353
+ * Register a callback to be invoked whenever accounts owned by the
2354
+ * specified program change
2355
+ *
2356
+ * @param programId Public key of the program to monitor
2357
+ * @param callback Function to invoke whenever the account is changed
2358
+ * @param commitment Specify the commitment level account changes must reach before notification
2359
+ * @param filters The program account filters to pass into the RPC method
2360
+ * @return subscription id
2257
2361
  */
2258
- recentBlockhash?: Blockhash;
2259
- /**
2260
- * the last block chain can advance to before tx is exportd expired
2261
- * */
2262
- lastValidBlockHeight?: number;
2362
+ onProgramAccountChange(
2363
+ programId: PublicKey,
2364
+ callback: ProgramAccountChangeCallback,
2365
+ commitment?: Commitment,
2366
+ filters?: GetProgramAccountsFilter[],
2367
+ ): ClientSubscriptionId;
2263
2368
  /**
2264
- * Optional Nonce information. If populated, transaction will use a durable
2265
- * Nonce hash instead of a recentBlockhash. Must be populated by the caller
2369
+ * Deregister an account notification callback
2370
+ *
2371
+ * @param id client subscription id to deregister
2266
2372
  */
2267
- nonceInfo?: NonceInformation;
2268
- constructor(opts?: TransactionBlockhashCtor);
2373
+ removeProgramAccountChangeListener(
2374
+ clientSubscriptionId: ClientSubscriptionId,
2375
+ ): Promise<void>;
2269
2376
  /**
2270
- * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
2271
- * Please supply a `TransactionBlockhashCtor` instead.
2377
+ * Registers a callback to be invoked whenever logs are emitted.
2272
2378
  */
2273
- constructor(opts?: TransactionCtorFields_DEPRECATED);
2379
+ onLogs(
2380
+ filter: LogsFilter,
2381
+ callback: LogsCallback,
2382
+ commitment?: Commitment,
2383
+ ): ClientSubscriptionId;
2274
2384
  /**
2275
- * Add one or more instructions to this Transaction
2385
+ * Deregister a logs callback.
2386
+ *
2387
+ * @param id client subscription id to deregister.
2276
2388
  */
2277
- add(
2278
- ...items: Array<
2279
- Transaction | TransactionInstruction | TransactionInstructionCtorFields
2280
- >
2281
- ): Transaction;
2389
+ removeOnLogsListener(
2390
+ clientSubscriptionId: ClientSubscriptionId,
2391
+ ): Promise<void>;
2282
2392
  /**
2283
- * Compile transaction data
2393
+ * Register a callback to be invoked upon slot changes
2394
+ *
2395
+ * @param callback Function to invoke whenever the slot changes
2396
+ * @return subscription id
2284
2397
  */
2285
- compileMessage(): Message;
2398
+ onSlotChange(callback: SlotChangeCallback): ClientSubscriptionId;
2286
2399
  /**
2287
- * Get a buffer of the Transaction data that need to be covered by signatures
2400
+ * Deregister a slot notification callback
2401
+ *
2402
+ * @param id client subscription id to deregister
2288
2403
  */
2289
- serializeMessage(): Buffer;
2404
+ removeSlotChangeListener(
2405
+ clientSubscriptionId: ClientSubscriptionId,
2406
+ ): Promise<void>;
2290
2407
  /**
2291
- * Get the estimated fee associated with a transaction
2408
+ * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s
2409
+ * may be useful to track live progress of a cluster.
2410
+ *
2411
+ * @param callback Function to invoke whenever the slot updates
2412
+ * @return subscription id
2292
2413
  */
2293
- getEstimatedFee(connection: Connection): Promise<number>;
2414
+ onSlotUpdate(callback: SlotUpdateCallback): ClientSubscriptionId;
2294
2415
  /**
2295
- * Specify the public keys which will be used to sign the Transaction.
2296
- * The first signer will be used as the transaction fee payer account.
2416
+ * Deregister a slot update notification callback
2297
2417
  *
2298
- * Signatures can be added with either `partialSign` or `addSignature`
2418
+ * @param id client subscription id to deregister
2419
+ */
2420
+ removeSlotUpdateListener(
2421
+ clientSubscriptionId: ClientSubscriptionId,
2422
+ ): Promise<void>;
2423
+ _buildArgs(
2424
+ args: Array<any>,
2425
+ override?: Commitment,
2426
+ encoding?: 'jsonParsed' | 'base64',
2427
+ extra?: any,
2428
+ ): Array<any>;
2429
+ /**
2430
+ * Register a callback to be invoked upon signature updates
2299
2431
  *
2300
- * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
2301
- * specified and it can be set in the Transaction constructor or with the
2302
- * `feePayer` property.
2432
+ * @param signature Transaction signature string in base 58
2433
+ * @param callback Function to invoke on signature notifications
2434
+ * @param commitment Specify the commitment level signature must reach before notification
2435
+ * @return subscription id
2303
2436
  */
2304
- setSigners(...signers: Array<PublicKey>): void;
2437
+ onSignature(
2438
+ signature: TransactionSignature,
2439
+ callback: SignatureResultCallback,
2440
+ commitment?: Commitment,
2441
+ ): ClientSubscriptionId;
2305
2442
  /**
2306
- * Sign the Transaction with the specified signers. Multiple signatures may
2307
- * be applied to a Transaction. The first signature is considered "primary"
2308
- * and is used identify and confirm transactions.
2443
+ * Register a callback to be invoked when a transaction is
2444
+ * received and/or processed.
2309
2445
  *
2310
- * If the Transaction `feePayer` is not set, the first signer will be used
2311
- * as the transaction fee payer account.
2446
+ * @param signature Transaction signature string in base 58
2447
+ * @param callback Function to invoke on signature notifications
2448
+ * @param options Enable received notifications and set the commitment
2449
+ * level that signature must reach before notification
2450
+ * @return subscription id
2451
+ */
2452
+ onSignatureWithOptions(
2453
+ signature: TransactionSignature,
2454
+ callback: SignatureSubscriptionCallback,
2455
+ options?: SignatureSubscriptionOptions,
2456
+ ): ClientSubscriptionId;
2457
+ /**
2458
+ * Deregister a signature notification callback
2312
2459
  *
2313
- * Transaction fields should not be modified after the first call to `sign`,
2314
- * as doing so may invalidate the signature and cause the Transaction to be
2315
- * rejected.
2460
+ * @param id client subscription id to deregister
2461
+ */
2462
+ removeSignatureListener(
2463
+ clientSubscriptionId: ClientSubscriptionId,
2464
+ ): Promise<void>;
2465
+ /**
2466
+ * Register a callback to be invoked upon root changes
2316
2467
  *
2317
- * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
2468
+ * @param callback Function to invoke whenever the root changes
2469
+ * @return subscription id
2318
2470
  */
2319
- sign(...signers: Array<Signer>): void;
2471
+ onRootChange(callback: RootChangeCallback): ClientSubscriptionId;
2320
2472
  /**
2321
- * Partially sign a transaction with the specified accounts. All accounts must
2322
- * correspond to either the fee payer or a signer account in the transaction
2323
- * instructions.
2473
+ * Deregister a root notification callback
2324
2474
  *
2325
- * All the caveats from the `sign` method apply to `partialSign`
2475
+ * @param id client subscription id to deregister
2326
2476
  */
2327
- partialSign(...signers: Array<Signer>): void;
2477
+ removeRootChangeListener(
2478
+ clientSubscriptionId: ClientSubscriptionId,
2479
+ ): Promise<void>;
2480
+ }
2481
+
2482
+ export const BPF_LOADER_PROGRAM_ID: PublicKey;
2483
+ /**
2484
+ * Factory class for transactions to interact with a program loader
2485
+ */
2486
+ export class BpfLoader {
2328
2487
  /**
2329
- * Add an externally created signature to a transaction. The public key
2330
- * must correspond to either the fee payer or a signer account in the transaction
2331
- * instructions.
2488
+ * Minimum number of signatures required to load a program not including
2489
+ * retries
2490
+ *
2491
+ * Can be used to calculate transaction fees
2332
2492
  */
2333
- addSignature(pubkey: PublicKey, signature: Buffer): void;
2493
+ static getMinNumSignatures(dataLength: number): number;
2334
2494
  /**
2335
- * Verify signatures of a complete, signed Transaction
2495
+ * Load a BPF program
2496
+ *
2497
+ * @param connection The connection to use
2498
+ * @param payer Account that will pay program loading fees
2499
+ * @param program Account to load the program into
2500
+ * @param elf The entire ELF containing the BPF program
2501
+ * @param loaderProgramId The program id of the BPF loader to use
2502
+ * @return true if program was loaded successfully, false if program was already loaded
2336
2503
  */
2337
- verifySignatures(): boolean;
2504
+ static load(
2505
+ connection: Connection,
2506
+ payer: Signer,
2507
+ program: Signer,
2508
+ elf: Buffer | Uint8Array | Array<number>,
2509
+ loaderProgramId: PublicKey,
2510
+ ): Promise<boolean>;
2511
+ }
2512
+
2513
+ export class SendTransactionError extends Error {
2514
+ logs: string[] | undefined;
2515
+ constructor(message: string, logs?: string[]);
2516
+ }
2517
+ export const SolanaJSONRPCErrorCode: {
2518
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
2519
+ readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
2520
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
2521
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
2522
+ readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
2523
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
2524
+ readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
2525
+ readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
2526
+ readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
2527
+ readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
2528
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
2529
+ readonly JSON_RPC_SCAN_ERROR: -32012;
2530
+ readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
2531
+ readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
2532
+ readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
2533
+ readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
2534
+ };
2535
+ export type SolanaJSONRPCErrorCodeEnum =
2536
+ typeof SolanaJSONRPCErrorCode[keyof typeof SolanaJSONRPCErrorCode];
2537
+ export class SolanaJSONRPCError extends Error {
2538
+ code: SolanaJSONRPCErrorCodeEnum | unknown;
2539
+ data?: any;
2540
+ constructor(
2541
+ {
2542
+ code,
2543
+ message,
2544
+ data,
2545
+ }: Readonly<{
2546
+ code: unknown;
2547
+ message: string;
2548
+ data?: any;
2549
+ }>,
2550
+ customMessage?: string,
2551
+ );
2552
+ }
2553
+
2554
+ /**
2555
+ * Program loader interface
2556
+ */
2557
+ export class Loader {
2338
2558
  /**
2339
- * Serialize the Transaction in the wire format.
2559
+ * Amount of program data placed in each load Transaction
2340
2560
  */
2341
- serialize(config?: SerializeConfig): Buffer;
2561
+ static chunkSize: number;
2342
2562
  /**
2343
- * Parse a wire transaction into a Transaction object.
2563
+ * Minimum number of signatures required to load a program not including
2564
+ * retries
2565
+ *
2566
+ * Can be used to calculate transaction fees
2344
2567
  */
2345
- static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
2568
+ static getMinNumSignatures(dataLength: number): number;
2346
2569
  /**
2347
- * Populate Transaction object from message and signatures
2570
+ * Loads a generic program
2571
+ *
2572
+ * @param connection The connection to use
2573
+ * @param payer System account that pays to load the program
2574
+ * @param program Account to load the program into
2575
+ * @param programId Public key that identifies the loader
2576
+ * @param data Program octets
2577
+ * @return true if program was loaded successfully, false if program was already loaded
2348
2578
  */
2349
- static populate(message: Message, signatures?: Array<string>): Transaction;
2579
+ static load(
2580
+ connection: Connection,
2581
+ payer: Signer,
2582
+ program: Signer,
2583
+ programId: PublicKey,
2584
+ data: Buffer | Uint8Array | Array<number>,
2585
+ ): Promise<boolean>;
2350
2586
  }
2351
2587
 
2352
2588
  export type CreateLookupTableParams = {
@@ -2436,39 +2672,6 @@ declare module '@solana/web3.js' {
2436
2672
  ): TransactionInstruction;
2437
2673
  }
2438
2674
 
2439
- export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
2440
-
2441
- export const BPF_LOADER_PROGRAM_ID: PublicKey;
2442
- /**
2443
- * Factory class for transactions to interact with a program loader
2444
- */
2445
- export class BpfLoader {
2446
- /**
2447
- * Minimum number of signatures required to load a program not including
2448
- * retries
2449
- *
2450
- * Can be used to calculate transaction fees
2451
- */
2452
- static getMinNumSignatures(dataLength: number): number;
2453
- /**
2454
- * Load a BPF program
2455
- *
2456
- * @param connection The connection to use
2457
- * @param payer Account that will pay program loading fees
2458
- * @param program Account to load the program into
2459
- * @param elf The entire ELF containing the BPF program
2460
- * @param loaderProgramId The program id of the BPF loader to use
2461
- * @return true if program was loaded successfully, false if program was already loaded
2462
- */
2463
- static load(
2464
- connection: Connection,
2465
- payer: Signer,
2466
- program: Signer,
2467
- elf: Buffer | Uint8Array | Array<number>,
2468
- loaderProgramId: PublicKey,
2469
- ): Promise<boolean>;
2470
- }
2471
-
2472
2675
  /**
2473
2676
  * Compute Budget Instruction class
2474
2677
  */
@@ -2602,37 +2805,66 @@ declare module '@solana/web3.js' {
2602
2805
  }
2603
2806
 
2604
2807
  /**
2605
- * Program loader interface
2808
+ * Params for creating an secp256k1 instruction using a public key
2606
2809
  */
2607
- export class Loader {
2810
+ export type CreateSecp256k1InstructionWithPublicKeyParams = {
2811
+ publicKey: Buffer | Uint8Array | Array<number>;
2812
+ message: Buffer | Uint8Array | Array<number>;
2813
+ signature: Buffer | Uint8Array | Array<number>;
2814
+ recoveryId: number;
2815
+ instructionIndex?: number;
2816
+ };
2817
+ /**
2818
+ * Params for creating an secp256k1 instruction using an Ethereum address
2819
+ */
2820
+ export type CreateSecp256k1InstructionWithEthAddressParams = {
2821
+ ethAddress: Buffer | Uint8Array | Array<number> | string;
2822
+ message: Buffer | Uint8Array | Array<number>;
2823
+ signature: Buffer | Uint8Array | Array<number>;
2824
+ recoveryId: number;
2825
+ instructionIndex?: number;
2826
+ };
2827
+ /**
2828
+ * Params for creating an secp256k1 instruction using a private key
2829
+ */
2830
+ export type CreateSecp256k1InstructionWithPrivateKeyParams = {
2831
+ privateKey: Buffer | Uint8Array | Array<number>;
2832
+ message: Buffer | Uint8Array | Array<number>;
2833
+ instructionIndex?: number;
2834
+ };
2835
+ export class Secp256k1Program {
2608
2836
  /**
2609
- * Amount of program data placed in each load Transaction
2837
+ * Public key that identifies the secp256k1 program
2610
2838
  */
2611
- static chunkSize: number;
2839
+ static programId: PublicKey;
2612
2840
  /**
2613
- * Minimum number of signatures required to load a program not including
2614
- * retries
2615
- *
2616
- * Can be used to calculate transaction fees
2841
+ * Construct an Ethereum address from a secp256k1 public key buffer.
2842
+ * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
2617
2843
  */
2618
- static getMinNumSignatures(dataLength: number): number;
2844
+ static publicKeyToEthAddress(
2845
+ publicKey: Buffer | Uint8Array | Array<number>,
2846
+ ): Buffer;
2619
2847
  /**
2620
- * Loads a generic program
2621
- *
2622
- * @param connection The connection to use
2623
- * @param payer System account that pays to load the program
2624
- * @param program Account to load the program into
2625
- * @param programId Public key that identifies the loader
2626
- * @param data Program octets
2627
- * @return true if program was loaded successfully, false if program was already loaded
2848
+ * Create an secp256k1 instruction with a public key. The public key
2849
+ * must be a buffer that is 64 bytes long.
2628
2850
  */
2629
- static load(
2630
- connection: Connection,
2631
- payer: Signer,
2632
- program: Signer,
2633
- programId: PublicKey,
2634
- data: Buffer | Uint8Array | Array<number>,
2635
- ): Promise<boolean>;
2851
+ static createInstructionWithPublicKey(
2852
+ params: CreateSecp256k1InstructionWithPublicKeyParams,
2853
+ ): TransactionInstruction;
2854
+ /**
2855
+ * Create an secp256k1 instruction with an Ethereum address. The address
2856
+ * must be a hex string or a buffer that is 20 bytes long.
2857
+ */
2858
+ static createInstructionWithEthAddress(
2859
+ params: CreateSecp256k1InstructionWithEthAddressParams,
2860
+ ): TransactionInstruction;
2861
+ /**
2862
+ * Create an secp256k1 instruction with a private key. The private key
2863
+ * must be a buffer that is 32 bytes long.
2864
+ */
2865
+ static createInstructionWithPrivateKey(
2866
+ params: CreateSecp256k1InstructionWithPrivateKeyParams,
2867
+ ): TransactionInstruction;
2636
2868
  }
2637
2869
 
2638
2870
  /**
@@ -3285,190 +3517,22 @@ declare module '@solana/web3.js' {
3285
3517
  /**
3286
3518
  * Generate an instruction to advance the nonce in a Nonce account
3287
3519
  */
3288
- static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
3289
- /**
3290
- * Generate a transaction instruction that withdraws lamports from a Nonce account
3291
- */
3292
- static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction;
3293
- /**
3294
- * Generate a transaction instruction that authorizes a new PublicKey as the authority
3295
- * on a Nonce account.
3296
- */
3297
- static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction;
3298
- /**
3299
- * Generate a transaction instruction that allocates space in an account without funding
3300
- */
3301
- static allocate(
3302
- params: AllocateParams | AllocateWithSeedParams,
3303
- ): TransactionInstruction;
3304
- }
3305
-
3306
- /**
3307
- * Params for creating an secp256k1 instruction using a public key
3308
- */
3309
- export type CreateSecp256k1InstructionWithPublicKeyParams = {
3310
- publicKey: Buffer | Uint8Array | Array<number>;
3311
- message: Buffer | Uint8Array | Array<number>;
3312
- signature: Buffer | Uint8Array | Array<number>;
3313
- recoveryId: number;
3314
- instructionIndex?: number;
3315
- };
3316
- /**
3317
- * Params for creating an secp256k1 instruction using an Ethereum address
3318
- */
3319
- export type CreateSecp256k1InstructionWithEthAddressParams = {
3320
- ethAddress: Buffer | Uint8Array | Array<number> | string;
3321
- message: Buffer | Uint8Array | Array<number>;
3322
- signature: Buffer | Uint8Array | Array<number>;
3323
- recoveryId: number;
3324
- instructionIndex?: number;
3325
- };
3326
- /**
3327
- * Params for creating an secp256k1 instruction using a private key
3328
- */
3329
- export type CreateSecp256k1InstructionWithPrivateKeyParams = {
3330
- privateKey: Buffer | Uint8Array | Array<number>;
3331
- message: Buffer | Uint8Array | Array<number>;
3332
- instructionIndex?: number;
3333
- };
3334
- export class Secp256k1Program {
3335
- /**
3336
- * Public key that identifies the secp256k1 program
3337
- */
3338
- static programId: PublicKey;
3339
- /**
3340
- * Construct an Ethereum address from a secp256k1 public key buffer.
3341
- * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
3342
- */
3343
- static publicKeyToEthAddress(
3344
- publicKey: Buffer | Uint8Array | Array<number>,
3345
- ): Buffer;
3346
- /**
3347
- * Create an secp256k1 instruction with a public key. The public key
3348
- * must be a buffer that is 64 bytes long.
3349
- */
3350
- static createInstructionWithPublicKey(
3351
- params: CreateSecp256k1InstructionWithPublicKeyParams,
3352
- ): TransactionInstruction;
3353
- /**
3354
- * Create an secp256k1 instruction with an Ethereum address. The address
3355
- * must be a hex string or a buffer that is 20 bytes long.
3356
- */
3357
- static createInstructionWithEthAddress(
3358
- params: CreateSecp256k1InstructionWithEthAddressParams,
3359
- ): TransactionInstruction;
3360
- /**
3361
- * Create an secp256k1 instruction with a private key. The private key
3362
- * must be a buffer that is 32 bytes long.
3363
- */
3364
- static createInstructionWithPrivateKey(
3365
- params: CreateSecp256k1InstructionWithPrivateKeyParams,
3366
- ): TransactionInstruction;
3367
- }
3368
-
3369
- /**
3370
- * Maximum over-the-wire size of a Transaction
3371
- *
3372
- * 1280 is IPv6 minimum MTU
3373
- * 40 bytes is the size of the IPv6 header
3374
- * 8 bytes is the size of the fragment header
3375
- */
3376
- export const PACKET_DATA_SIZE: number;
3377
- export const SIGNATURE_LENGTH_IN_BYTES = 64;
3378
-
3379
- export const VALIDATOR_INFO_KEY: PublicKey;
3380
- /**
3381
- * Info used to identity validators.
3382
- */
3383
- export type Info = {
3384
- /** validator name */
3385
- name: string;
3386
- /** optional, validator website */
3387
- website?: string;
3388
- /** optional, extra information the validator chose to share */
3389
- details?: string;
3390
- /** optional, used to identify validators on keybase.io */
3391
- keybaseUsername?: string;
3392
- };
3393
- /**
3394
- * ValidatorInfo class
3395
- */
3396
- export class ValidatorInfo {
3397
- /**
3398
- * validator public key
3399
- */
3400
- key: PublicKey;
3401
- /**
3402
- * validator information
3403
- */
3404
- info: Info;
3520
+ static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
3405
3521
  /**
3406
- * Construct a valid ValidatorInfo
3407
- *
3408
- * @param key validator public key
3409
- * @param info validator information
3522
+ * Generate a transaction instruction that withdraws lamports from a Nonce account
3410
3523
  */
3411
- constructor(key: PublicKey, info: Info);
3524
+ static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction;
3412
3525
  /**
3413
- * Deserialize ValidatorInfo from the config account data. Exactly two config
3414
- * keys are required in the data.
3415
- *
3416
- * @param buffer config account data
3417
- * @return null if info was not found
3526
+ * Generate a transaction instruction that authorizes a new PublicKey as the authority
3527
+ * on a Nonce account.
3418
3528
  */
3419
- static fromConfigData(
3420
- buffer: Buffer | Uint8Array | Array<number>,
3421
- ): ValidatorInfo | null;
3422
- }
3423
-
3424
- export const VOTE_PROGRAM_ID: PublicKey;
3425
- export type Lockout = {
3426
- slot: number;
3427
- confirmationCount: number;
3428
- };
3429
- /**
3430
- * History of how many credits earned by the end of each epoch
3431
- */
3432
- export type EpochCredits = Readonly<{
3433
- epoch: number;
3434
- credits: number;
3435
- prevCredits: number;
3436
- }>;
3437
- export type AuthorizedVoter = Readonly<{
3438
- epoch: number;
3439
- authorizedVoter: PublicKey;
3440
- }>;
3441
- export type PriorVoter = Readonly<{
3442
- authorizedPubkey: PublicKey;
3443
- epochOfLastAuthorizedSwitch: number;
3444
- targetEpoch: number;
3445
- }>;
3446
- export type BlockTimestamp = Readonly<{
3447
- slot: number;
3448
- timestamp: number;
3449
- }>;
3450
- /**
3451
- * VoteAccount class
3452
- */
3453
- export class VoteAccount {
3454
- nodePubkey: PublicKey;
3455
- authorizedWithdrawer: PublicKey;
3456
- commission: number;
3457
- rootSlot: number | null;
3458
- votes: Lockout[];
3459
- authorizedVoters: AuthorizedVoter[];
3460
- priorVoters: PriorVoter[];
3461
- epochCredits: EpochCredits[];
3462
- lastTimestamp: BlockTimestamp;
3529
+ static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction;
3463
3530
  /**
3464
- * Deserialize VoteAccount from the account data.
3465
- *
3466
- * @param buffer account data
3467
- * @return VoteAccount
3531
+ * Generate a transaction instruction that allocates space in an account without funding
3468
3532
  */
3469
- static fromAccountData(
3470
- buffer: Buffer | Uint8Array | Array<number>,
3471
- ): VoteAccount;
3533
+ static allocate(
3534
+ params: AllocateParams | AllocateWithSeedParams,
3535
+ ): TransactionInstruction;
3472
3536
  }
3473
3537
 
3474
3538
  /**
@@ -3610,6 +3674,114 @@ declare module '@solana/web3.js' {
3610
3674
  * Generate a transaction to withdraw from a Vote account.
3611
3675
  */
3612
3676
  static withdraw(params: WithdrawFromVoteAccountParams): Transaction;
3677
+ /**
3678
+ * Generate a transaction to withdraw safely from a Vote account.
3679
+ *
3680
+ * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
3681
+ * checks that the withdraw amount will not exceed the specified balance while leaving enough left
3682
+ * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
3683
+ * `withdraw` method directly.
3684
+ */
3685
+ static safeWithdraw(
3686
+ params: WithdrawFromVoteAccountParams,
3687
+ currentVoteAccountBalance: number,
3688
+ rentExemptMinimum: number,
3689
+ ): Transaction;
3690
+ }
3691
+
3692
+ export const VALIDATOR_INFO_KEY: PublicKey;
3693
+ /**
3694
+ * Info used to identity validators.
3695
+ */
3696
+ export type Info = {
3697
+ /** validator name */
3698
+ name: string;
3699
+ /** optional, validator website */
3700
+ website?: string;
3701
+ /** optional, extra information the validator chose to share */
3702
+ details?: string;
3703
+ /** optional, used to identify validators on keybase.io */
3704
+ keybaseUsername?: string;
3705
+ };
3706
+ /**
3707
+ * ValidatorInfo class
3708
+ */
3709
+ export class ValidatorInfo {
3710
+ /**
3711
+ * validator public key
3712
+ */
3713
+ key: PublicKey;
3714
+ /**
3715
+ * validator information
3716
+ */
3717
+ info: Info;
3718
+ /**
3719
+ * Construct a valid ValidatorInfo
3720
+ *
3721
+ * @param key validator public key
3722
+ * @param info validator information
3723
+ */
3724
+ constructor(key: PublicKey, info: Info);
3725
+ /**
3726
+ * Deserialize ValidatorInfo from the config account data. Exactly two config
3727
+ * keys are required in the data.
3728
+ *
3729
+ * @param buffer config account data
3730
+ * @return null if info was not found
3731
+ */
3732
+ static fromConfigData(
3733
+ buffer: Buffer | Uint8Array | Array<number>,
3734
+ ): ValidatorInfo | null;
3735
+ }
3736
+
3737
+ export const VOTE_PROGRAM_ID: PublicKey;
3738
+ export type Lockout = {
3739
+ slot: number;
3740
+ confirmationCount: number;
3741
+ };
3742
+ /**
3743
+ * History of how many credits earned by the end of each epoch
3744
+ */
3745
+ export type EpochCredits = Readonly<{
3746
+ epoch: number;
3747
+ credits: number;
3748
+ prevCredits: number;
3749
+ }>;
3750
+ export type AuthorizedVoter = Readonly<{
3751
+ epoch: number;
3752
+ authorizedVoter: PublicKey;
3753
+ }>;
3754
+ export type PriorVoter = Readonly<{
3755
+ authorizedPubkey: PublicKey;
3756
+ epochOfLastAuthorizedSwitch: number;
3757
+ targetEpoch: number;
3758
+ }>;
3759
+ export type BlockTimestamp = Readonly<{
3760
+ slot: number;
3761
+ timestamp: number;
3762
+ }>;
3763
+ /**
3764
+ * VoteAccount class
3765
+ */
3766
+ export class VoteAccount {
3767
+ nodePubkey: PublicKey;
3768
+ authorizedWithdrawer: PublicKey;
3769
+ commission: number;
3770
+ rootSlot: number | null;
3771
+ votes: Lockout[];
3772
+ authorizedVoters: AuthorizedVoter[];
3773
+ priorVoters: PriorVoter[];
3774
+ epochCredits: EpochCredits[];
3775
+ lastTimestamp: BlockTimestamp;
3776
+ /**
3777
+ * Deserialize VoteAccount from the account data.
3778
+ *
3779
+ * @param buffer account data
3780
+ * @return VoteAccount
3781
+ */
3782
+ static fromAccountData(
3783
+ buffer: Buffer | Uint8Array | Array<number>,
3784
+ ): VoteAccount;
3613
3785
  }
3614
3786
 
3615
3787
  export const SYSVAR_CLOCK_PUBKEY: PublicKey;
@@ -3622,64 +3794,11 @@ declare module '@solana/web3.js' {
3622
3794
  export const SYSVAR_SLOT_HISTORY_PUBKEY: PublicKey;
3623
3795
  export const SYSVAR_STAKE_HISTORY_PUBKEY: PublicKey;
3624
3796
 
3625
- export class SendTransactionError extends Error {
3626
- logs: string[] | undefined;
3627
- constructor(message: string, logs?: string[]);
3628
- }
3629
- export const SolanaJSONRPCErrorCode: {
3630
- readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
3631
- readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
3632
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
3633
- readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
3634
- readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
3635
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
3636
- readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
3637
- readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
3638
- readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
3639
- readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
3640
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
3641
- readonly JSON_RPC_SCAN_ERROR: -32012;
3642
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
3643
- readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
3644
- readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
3645
- readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
3646
- };
3647
- export type SolanaJSONRPCErrorCodeEnum =
3648
- typeof SolanaJSONRPCErrorCode[keyof typeof SolanaJSONRPCErrorCode];
3649
- export class SolanaJSONRPCError extends Error {
3650
- code: SolanaJSONRPCErrorCodeEnum | unknown;
3651
- data?: any;
3652
- constructor(
3653
- {
3654
- code,
3655
- message,
3656
- data,
3657
- }: Readonly<{
3658
- code: unknown;
3659
- message: string;
3660
- data?: any;
3661
- }>,
3662
- customMessage?: string,
3663
- );
3664
- }
3665
-
3797
+ export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
3666
3798
  /**
3667
- * Sign, send and confirm a transaction.
3668
- *
3669
- * If `commitment` option is not specified, defaults to 'max' commitment.
3670
- *
3671
- * @param {Connection} connection
3672
- * @param {Transaction} transaction
3673
- * @param {Array<Signer>} signers
3674
- * @param {ConfirmOptions} [options]
3675
- * @returns {Promise<TransactionSignature>}
3799
+ * Retrieves the RPC API URL for the specified cluster
3676
3800
  */
3677
- export function sendAndConfirmTransaction(
3678
- connection: Connection,
3679
- transaction: Transaction,
3680
- signers: Array<Signer>,
3681
- options?: ConfirmOptions,
3682
- ): Promise<TransactionSignature>;
3801
+ export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string;
3683
3802
 
3684
3803
  /**
3685
3804
  * Send and confirm a raw transaction
@@ -3708,20 +3827,23 @@ declare module '@solana/web3.js' {
3708
3827
  options?: ConfirmOptions,
3709
3828
  ): Promise<TransactionSignature>;
3710
3829
 
3711
- export class TransactionExpiredBlockheightExceededError extends Error {
3712
- signature: string;
3713
- constructor(signature: string);
3714
- }
3715
- export class TransactionExpiredTimeoutError extends Error {
3716
- signature: string;
3717
- constructor(signature: string, timeoutSeconds: number);
3718
- }
3719
-
3720
- export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
3721
3830
  /**
3722
- * Retrieves the RPC API URL for the specified cluster
3831
+ * Sign, send and confirm a transaction.
3832
+ *
3833
+ * If `commitment` option is not specified, defaults to 'max' commitment.
3834
+ *
3835
+ * @param {Connection} connection
3836
+ * @param {Transaction} transaction
3837
+ * @param {Array<Signer>} signers
3838
+ * @param {ConfirmOptions} [options]
3839
+ * @returns {Promise<TransactionSignature>}
3723
3840
  */
3724
- export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string;
3841
+ export function sendAndConfirmTransaction(
3842
+ connection: Connection,
3843
+ transaction: Transaction,
3844
+ signers: Array<Signer>,
3845
+ options?: ConfirmOptions,
3846
+ ): Promise<TransactionSignature>;
3725
3847
 
3726
3848
  /**
3727
3849
  * There are 1-billion lamports in one SOL