@solana/web3.js 1.1.1 → 1.1.2

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 ADDED
@@ -0,0 +1,2320 @@
1
+ /// <reference types="node" />
2
+ declare module '@solana/web3.js' {
3
+ /**
4
+ * Maximum length of derived pubkey seed
5
+ */
6
+ export const MAX_SEED_LENGTH = 32;
7
+ /**
8
+ * A public key
9
+ */
10
+ export class PublicKey {
11
+ /**
12
+ * Create a new PublicKey object
13
+ * @param value ed25519 public key as buffer or base-58 encoded string
14
+ */
15
+ constructor(value: number | string | Buffer | Uint8Array | Array<number>);
16
+ /**
17
+ * Checks if two publicKeys are equal
18
+ */
19
+ equals(publicKey: PublicKey): boolean;
20
+ /**
21
+ * Return the base-58 representation of the public key
22
+ */
23
+ toBase58(): string;
24
+ /**
25
+ * Return the byte array representation of the public key
26
+ */
27
+ toBytes(): Uint8Array;
28
+ /**
29
+ * Return the Buffer representation of the public key
30
+ */
31
+ toBuffer(): Buffer;
32
+ /**
33
+ * Return the base-58 representation of the public key
34
+ */
35
+ toString(): string;
36
+ /**
37
+ * Derive a public key from another key, a seed, and a program ID.
38
+ */
39
+ static createWithSeed(
40
+ fromPublicKey: PublicKey,
41
+ seed: string,
42
+ programId: PublicKey,
43
+ ): Promise<PublicKey>;
44
+ /**
45
+ * Derive a program address from seeds and a program ID.
46
+ */
47
+ static createProgramAddress(
48
+ seeds: Array<Buffer | Uint8Array>,
49
+ programId: PublicKey,
50
+ ): Promise<PublicKey>;
51
+ /**
52
+ * Find a valid program address
53
+ *
54
+ * Valid program addresses must fall off the ed25519 curve. This function
55
+ * iterates a nonce until it finds one that when combined with the seeds
56
+ * results in a valid program address.
57
+ */
58
+ static findProgramAddress(
59
+ seeds: Array<Buffer | Uint8Array>,
60
+ programId: PublicKey,
61
+ ): Promise<[PublicKey, number]>;
62
+ }
63
+
64
+ /**
65
+ * An account key pair (public and secret keys).
66
+ */
67
+ export class Account {
68
+ /**
69
+ * Create a new Account object
70
+ *
71
+ * If the secretKey parameter is not provided a new key pair is randomly
72
+ * created for the account
73
+ *
74
+ * @param secretKey Secret key for the account
75
+ */
76
+ constructor(secretKey?: Buffer | Uint8Array | Array<number>);
77
+ /**
78
+ * The public key for this account
79
+ */
80
+ get publicKey(): PublicKey;
81
+ /**
82
+ * The **unencrypted** secret key for this account
83
+ */
84
+ get secretKey(): Buffer;
85
+ }
86
+
87
+ /**
88
+ * Blockhash as Base58 string.
89
+ */
90
+ export type Blockhash = string;
91
+
92
+ export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
93
+
94
+ /**
95
+ * Calculator for transaction fees.
96
+ */
97
+ interface FeeCalculator {
98
+ /** Cost in lamports to validate a signature. */
99
+ lamportsPerSignature: number;
100
+ }
101
+
102
+ export const NONCE_ACCOUNT_LENGTH: any;
103
+ /**
104
+ * NonceAccount class
105
+ */
106
+ export class NonceAccount {
107
+ authorizedPubkey: PublicKey;
108
+ nonce: Blockhash;
109
+ feeCalculator: FeeCalculator;
110
+ /**
111
+ * Deserialize NonceAccount from the account data.
112
+ *
113
+ * @param buffer account data
114
+ * @return NonceAccount
115
+ */
116
+ static fromAccountData(
117
+ buffer: Buffer | Uint8Array | Array<number>,
118
+ ): NonceAccount;
119
+ }
120
+
121
+ /**
122
+ * The message header, identifying signed and read-only account
123
+ */
124
+ export type MessageHeader = {
125
+ /**
126
+ * The number of signatures required for this message to be considered valid. The
127
+ * signatures must match the first `numRequiredSignatures` of `accountKeys`.
128
+ */
129
+ numRequiredSignatures: number;
130
+ /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
131
+ numReadonlySignedAccounts: number;
132
+ /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
133
+ numReadonlyUnsignedAccounts: number;
134
+ };
135
+ /**
136
+ * An instruction to execute by a program
137
+ *
138
+ * @property {number} programIdIndex
139
+ * @property {number[]} accounts
140
+ * @property {string} data
141
+ */
142
+ export type CompiledInstruction = {
143
+ /** Index into the transaction keys array indicating the program account that executes this instruction */
144
+ programIdIndex: number;
145
+ /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
146
+ accounts: number[];
147
+ /** The program input data encoded as base 58 */
148
+ data: string;
149
+ };
150
+ /**
151
+ * Message constructor arguments
152
+ */
153
+ export type MessageArgs = {
154
+ /** The message header, identifying signed and read-only `accountKeys` */
155
+ header: MessageHeader;
156
+ /** All the account keys used by this transaction */
157
+ accountKeys: string[];
158
+ /** The hash of a recent ledger block */
159
+ recentBlockhash: Blockhash;
160
+ /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
161
+ instructions: CompiledInstruction[];
162
+ };
163
+ /**
164
+ * List of instructions to be processed atomically
165
+ */
166
+ export class Message {
167
+ header: MessageHeader;
168
+ accountKeys: PublicKey[];
169
+ recentBlockhash: Blockhash;
170
+ instructions: CompiledInstruction[];
171
+ constructor(args: MessageArgs);
172
+ isAccountWritable(index: number): boolean;
173
+ serialize(): Buffer;
174
+ /**
175
+ * Decode a compiled message into a Message object.
176
+ */
177
+ static from(buffer: Buffer | Uint8Array | Array<number>): Message;
178
+ }
179
+
180
+ /**
181
+ * Transaction signature as base-58 encoded string
182
+ */
183
+ export type TransactionSignature = string;
184
+ /**
185
+ * Maximum over-the-wire size of a Transaction
186
+ *
187
+ * 1280 is IPv6 minimum MTU
188
+ * 40 bytes is the size of the IPv6 header
189
+ * 8 bytes is the size of the fragment header
190
+ */
191
+ export const PACKET_DATA_SIZE: number;
192
+ /**
193
+ * Account metadata used to define instructions
194
+ */
195
+ export type AccountMeta = {
196
+ /** An account's public key */
197
+ pubkey: PublicKey;
198
+ /** True if an instruction requires a transaction signature matching `pubkey` */
199
+ isSigner: boolean;
200
+ /** True if the `pubkey` can be loaded as a read-write account. */
201
+ isWritable: boolean;
202
+ };
203
+ /**
204
+ * List of TransactionInstruction object fields that may be initialized at construction
205
+ */
206
+ export type TransactionInstructionCtorFields = {
207
+ keys: Array<AccountMeta>;
208
+ programId: PublicKey;
209
+ data?: Buffer;
210
+ };
211
+ /**
212
+ * Configuration object for Transaction.serialize()
213
+ */
214
+ export type SerializeConfig = {
215
+ /** Require all transaction signatures be present (default: true) */
216
+ requireAllSignatures?: boolean;
217
+ /** Verify provided signatures (default: true) */
218
+ verifySignatures?: boolean;
219
+ };
220
+ /**
221
+ * Transaction Instruction class
222
+ */
223
+ export class TransactionInstruction {
224
+ /**
225
+ * Public keys to include in this transaction
226
+ * Boolean represents whether this pubkey needs to sign the transaction
227
+ */
228
+ keys: Array<AccountMeta>;
229
+ /**
230
+ * Program Id to execute
231
+ */
232
+ programId: PublicKey;
233
+ /**
234
+ * Program input
235
+ */
236
+ data: Buffer;
237
+ constructor(opts: TransactionInstructionCtorFields);
238
+ }
239
+ /**
240
+ * Pair of signature and corresponding public key
241
+ */
242
+ export type SignaturePubkeyPair = {
243
+ signature: Buffer | null;
244
+ publicKey: PublicKey;
245
+ };
246
+ /**
247
+ * List of Transaction object fields that may be initialized at construction
248
+ *
249
+ */
250
+ export type TransactionCtorFields = {
251
+ /** A recent blockhash */
252
+ recentBlockhash?: Blockhash | null;
253
+ /** Optional nonce information used for offline nonce'd transactions */
254
+ nonceInfo?: NonceInformation | null;
255
+ /** The transaction fee payer */
256
+ feePayer?: PublicKey | null;
257
+ /** One or more signatures */
258
+ signatures?: Array<SignaturePubkeyPair>;
259
+ };
260
+ /**
261
+ * Nonce information to be used to build an offline Transaction.
262
+ */
263
+ export type NonceInformation = {
264
+ /** The current blockhash stored in the nonce */
265
+ nonce: Blockhash;
266
+ /** AdvanceNonceAccount Instruction */
267
+ nonceInstruction: TransactionInstruction;
268
+ };
269
+ /**
270
+ * Transaction class
271
+ */
272
+ export class Transaction {
273
+ /**
274
+ * Signatures for the transaction. Typically created by invoking the
275
+ * `sign()` method
276
+ */
277
+ signatures: Array<SignaturePubkeyPair>;
278
+ /**
279
+ * The first (payer) Transaction signature
280
+ */
281
+ get signature(): Buffer | null;
282
+ /**
283
+ * The transaction fee payer
284
+ */
285
+ feePayer?: PublicKey;
286
+ /**
287
+ * The instructions to atomically execute
288
+ */
289
+ instructions: Array<TransactionInstruction>;
290
+ /**
291
+ * A recent transaction id. Must be populated by the caller
292
+ */
293
+ recentBlockhash?: Blockhash;
294
+ /**
295
+ * Optional Nonce information. If populated, transaction will use a durable
296
+ * Nonce hash instead of a recentBlockhash. Must be populated by the caller
297
+ */
298
+ nonceInfo?: NonceInformation;
299
+ /**
300
+ * Construct an empty Transaction
301
+ */
302
+ constructor(opts?: TransactionCtorFields);
303
+ /**
304
+ * Add one or more instructions to this Transaction
305
+ */
306
+ add(
307
+ ...items: Array<
308
+ Transaction | TransactionInstruction | TransactionInstructionCtorFields
309
+ >
310
+ ): Transaction;
311
+ /**
312
+ * Compile transaction data
313
+ */
314
+ compileMessage(): Message;
315
+ /**
316
+ * Get a buffer of the Transaction data that need to be covered by signatures
317
+ */
318
+ serializeMessage(): Buffer;
319
+ /**
320
+ * Specify the public keys which will be used to sign the Transaction.
321
+ * The first signer will be used as the transaction fee payer account.
322
+ *
323
+ * Signatures can be added with either `partialSign` or `addSignature`
324
+ *
325
+ * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
326
+ * specified and it can be set in the Transaction constructor or with the
327
+ * `feePayer` property.
328
+ */
329
+ setSigners(...signers: Array<PublicKey>): void;
330
+ /**
331
+ * Sign the Transaction with the specified accounts. Multiple signatures may
332
+ * be applied to a Transaction. The first signature is considered "primary"
333
+ * and is used identify and confirm transactions.
334
+ *
335
+ * If the Transaction `feePayer` is not set, the first signer will be used
336
+ * as the transaction fee payer account.
337
+ *
338
+ * Transaction fields should not be modified after the first call to `sign`,
339
+ * as doing so may invalidate the signature and cause the Transaction to be
340
+ * rejected.
341
+ *
342
+ * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
343
+ */
344
+ sign(...signers: Array<Account>): void;
345
+ /**
346
+ * Partially sign a transaction with the specified accounts. All accounts must
347
+ * correspond to either the fee payer or a signer account in the transaction
348
+ * instructions.
349
+ *
350
+ * All the caveats from the `sign` method apply to `partialSign`
351
+ */
352
+ partialSign(...signers: Array<Account>): void;
353
+ /**
354
+ * Add an externally created signature to a transaction. The public key
355
+ * must correspond to either the fee payer or a signer account in the transaction
356
+ * instructions.
357
+ */
358
+ addSignature(pubkey: PublicKey, signature: Buffer): void;
359
+ /**
360
+ * Verify signatures of a complete, signed Transaction
361
+ */
362
+ verifySignatures(): boolean;
363
+ /**
364
+ * Serialize the Transaction in the wire format.
365
+ */
366
+ serialize(config?: SerializeConfig): Buffer;
367
+ /**
368
+ * Parse a wire transaction into a Transaction object.
369
+ */
370
+ static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
371
+ /**
372
+ * Populate Transaction object from message and signatures
373
+ */
374
+ static populate(message: Message, signatures: Array<string>): Transaction;
375
+ }
376
+
377
+ export type TokenAccountsFilter =
378
+ | {
379
+ mint: PublicKey;
380
+ }
381
+ | {
382
+ programId: PublicKey;
383
+ };
384
+ /**
385
+ * Extra contextual information for RPC responses
386
+ */
387
+ export type Context = {
388
+ slot: number;
389
+ };
390
+ /**
391
+ * Options for sending transactions
392
+ */
393
+ export type SendOptions = {
394
+ /** disable transaction verification step */
395
+ skipPreflight?: boolean;
396
+ /** preflight commitment level */
397
+ preflightCommitment?: Commitment;
398
+ };
399
+ /**
400
+ * Options for confirming transactions
401
+ */
402
+ export type ConfirmOptions = {
403
+ /** disable transaction verification step */
404
+ skipPreflight?: boolean;
405
+ /** desired commitment level */
406
+ commitment?: Commitment;
407
+ /** preflight commitment level */
408
+ preflightCommitment?: Commitment;
409
+ };
410
+ /**
411
+ * Options for getConfirmedSignaturesForAddress2
412
+ */
413
+ export type ConfirmedSignaturesForAddress2Options = {
414
+ /**
415
+ * Start searching backwards from this transaction signature.
416
+ * @remark If not provided the search starts from the highest max confirmed block.
417
+ */
418
+ before?: TransactionSignature;
419
+ /** Search until this transaction signature is reached, if found before `limit`. */
420
+ until?: TransactionSignature;
421
+ /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
422
+ limit?: number;
423
+ };
424
+ /**
425
+ * RPC Response with extra contextual information
426
+ */
427
+ export type RpcResponseAndContext<T> = {
428
+ /** response context */
429
+ context: Context;
430
+ /** response value */
431
+ value: T;
432
+ };
433
+ /**
434
+ * The level of commitment desired when querying state
435
+ * <pre>
436
+ * 'processed': Query the most recent block which has reached 1 confirmation by the connected node
437
+ * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
438
+ * 'finalized': Query the most recent block which has been finalized by the cluster
439
+ * </pre>
440
+ */
441
+ export type Commitment =
442
+ | 'processed'
443
+ | 'confirmed'
444
+ | 'finalized'
445
+ | 'recent'
446
+ | 'single'
447
+ | 'singleGossip'
448
+ | 'root'
449
+ | 'max';
450
+ /**
451
+ * Filter for largest accounts query
452
+ * <pre>
453
+ * 'circulating': Return the largest accounts that are part of the circulating supply
454
+ * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
455
+ * </pre>
456
+ */
457
+ export type LargestAccountsFilter = 'circulating' | 'nonCirculating';
458
+ /**
459
+ * Configuration object for changing `getLargestAccounts` query behavior
460
+ */
461
+ export type GetLargestAccountsConfig = {
462
+ /** The level of commitment desired */
463
+ commitment?: Commitment;
464
+ /** Filter largest accounts by whether they are part of the circulating supply */
465
+ filter?: LargestAccountsFilter;
466
+ };
467
+ /**
468
+ * Configuration object for changing query behavior
469
+ */
470
+ export type SignatureStatusConfig = {
471
+ /** enable searching status history, not needed for recent transactions */
472
+ searchTransactionHistory: boolean;
473
+ };
474
+ /**
475
+ * Information describing a cluster node
476
+ */
477
+ export type ContactInfo = {
478
+ /** Identity public key of the node */
479
+ pubkey: string;
480
+ /** Gossip network address for the node */
481
+ gossip: string | null;
482
+ /** TPU network address for the node (null if not available) */
483
+ tpu: string | null;
484
+ /** JSON RPC network address for the node (null if not available) */
485
+ rpc: string | null;
486
+ /** Software version of the node (null if not available) */
487
+ version: string | null;
488
+ };
489
+ /**
490
+ * Information describing a vote account
491
+ */
492
+ export type VoteAccountInfo = {
493
+ /** Public key of the vote account */
494
+ votePubkey: string;
495
+ /** Identity public key of the node voting with this account */
496
+ nodePubkey: string;
497
+ /** The stake, in lamports, delegated to this vote account and activated */
498
+ activatedStake: number;
499
+ /** Whether the vote account is staked for this epoch */
500
+ epochVoteAccount: boolean;
501
+ /** Recent epoch voting credit history for this voter */
502
+ epochCredits: Array<[number, number, number]>;
503
+ /** A percentage (0-100) of rewards payout owed to the voter */
504
+ commission: number;
505
+ /** Most recent slot voted on by this vote account */
506
+ lastVote: number;
507
+ };
508
+ /**
509
+ * A collection of cluster vote accounts
510
+ */
511
+ export type VoteAccountStatus = {
512
+ /** Active vote accounts */
513
+ current: Array<VoteAccountInfo>;
514
+ /** Inactive vote accounts */
515
+ delinquent: Array<VoteAccountInfo>;
516
+ };
517
+ /**
518
+ * Network Inflation
519
+ * (see https://docs.solana.com/implemented-proposals/ed_overview)
520
+ */
521
+ export type InflationGovernor = {
522
+ foundation: number;
523
+ foundationTerm: number;
524
+ initial: number;
525
+ taper: number;
526
+ terminal: number;
527
+ };
528
+ /**
529
+ * Information about the current epoch
530
+ */
531
+ export type EpochInfo = {
532
+ epoch: number;
533
+ slotIndex: number;
534
+ slotsInEpoch: number;
535
+ absoluteSlot: number;
536
+ blockHeight?: number;
537
+ transactionCount?: number;
538
+ };
539
+ /**
540
+ * Epoch schedule
541
+ * (see https://docs.solana.com/terminology#epoch)
542
+ */
543
+ export type EpochSchedule = {
544
+ /** The maximum number of slots in each epoch */
545
+ slotsPerEpoch: number;
546
+ /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */
547
+ leaderScheduleSlotOffset: number;
548
+ /** Indicates whether epochs start short and grow */
549
+ warmup: boolean;
550
+ /** The first epoch with `slotsPerEpoch` slots */
551
+ firstNormalEpoch: number;
552
+ /** The first slot of `firstNormalEpoch` */
553
+ firstNormalSlot: number;
554
+ };
555
+ /**
556
+ * Leader schedule
557
+ * (see https://docs.solana.com/terminology#leader-schedule)
558
+ */
559
+ export type LeaderSchedule = {
560
+ [address: string]: number[];
561
+ };
562
+ /**
563
+ * Version info for a node
564
+ */
565
+ export type Version = {
566
+ /** Version of solana-core */
567
+ 'solana-core': string;
568
+ 'feature-set'?: number;
569
+ };
570
+ export type SimulatedTransactionResponse = {
571
+ err: TransactionError | string | null;
572
+ logs: Array<string> | null;
573
+ };
574
+ export type ParsedInnerInstruction = {
575
+ index: number;
576
+ instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
577
+ };
578
+ export type TokenBalance = {
579
+ accountIndex: number;
580
+ mint: string;
581
+ uiTokenAmount: TokenAmount;
582
+ };
583
+ /**
584
+ * Metadata for a parsed confirmed transaction on the ledger
585
+ */
586
+ export type ParsedConfirmedTransactionMeta = {
587
+ /** The fee charged for processing the transaction */
588
+ fee: number;
589
+ /** An array of cross program invoked parsed instructions */
590
+ innerInstructions?: ParsedInnerInstruction[] | null;
591
+ /** The balances of the transaction accounts before processing */
592
+ preBalances: Array<number>;
593
+ /** The balances of the transaction accounts after processing */
594
+ postBalances: Array<number>;
595
+ /** An array of program log messages emitted during a transaction */
596
+ logMessages?: Array<string> | null;
597
+ /** The token balances of the transaction accounts before processing */
598
+ preTokenBalances?: Array<TokenBalance> | null;
599
+ /** The token balances of the transaction accounts after processing */
600
+ postTokenBalances?: Array<TokenBalance> | null;
601
+ /** The error result of transaction processing */
602
+ err: TransactionError | null;
603
+ };
604
+ export type CompiledInnerInstruction = {
605
+ index: number;
606
+ instructions: CompiledInstruction[];
607
+ };
608
+ /**
609
+ * Metadata for a confirmed transaction on the ledger
610
+ */
611
+ export type ConfirmedTransactionMeta = {
612
+ /** The fee charged for processing the transaction */
613
+ fee: number;
614
+ /** An array of cross program invoked instructions */
615
+ innerInstructions?: CompiledInnerInstruction[] | null;
616
+ /** The balances of the transaction accounts before processing */
617
+ preBalances: Array<number>;
618
+ /** The balances of the transaction accounts after processing */
619
+ postBalances: Array<number>;
620
+ /** An array of program log messages emitted during a transaction */
621
+ logMessages?: Array<string> | null;
622
+ /** The token balances of the transaction accounts before processing */
623
+ preTokenBalances?: Array<TokenBalance> | null;
624
+ /** The token balances of the transaction accounts after processing */
625
+ postTokenBalances?: Array<TokenBalance> | null;
626
+ /** The error result of transaction processing */
627
+ err: TransactionError | null;
628
+ };
629
+ /**
630
+ * A confirmed transaction on the ledger
631
+ */
632
+ export type ConfirmedTransaction = {
633
+ /** The slot during which the transaction was processed */
634
+ slot: number;
635
+ /** The details of the transaction */
636
+ transaction: Transaction;
637
+ /** Metadata produced from the transaction */
638
+ meta: ConfirmedTransactionMeta | null;
639
+ /** The unix timestamp of when the transaction was processed */
640
+ blockTime?: number | null;
641
+ };
642
+ /**
643
+ * A partially decoded transaction instruction
644
+ */
645
+ export type PartiallyDecodedInstruction = {
646
+ /** Program id called by this instruction */
647
+ programId: PublicKey;
648
+ /** Public keys of accounts passed to this instruction */
649
+ accounts: Array<PublicKey>;
650
+ /** Raw base-58 instruction data */
651
+ data: string;
652
+ };
653
+ /**
654
+ * A parsed transaction message account
655
+ */
656
+ export type ParsedMessageAccount = {
657
+ /** Public key of the account */
658
+ pubkey: PublicKey;
659
+ /** Indicates if the account signed the transaction */
660
+ signer: boolean;
661
+ /** Indicates if the account is writable for this transaction */
662
+ writable: boolean;
663
+ };
664
+ /**
665
+ * A parsed transaction instruction
666
+ */
667
+ export type ParsedInstruction = {
668
+ /** Name of the program for this instruction */
669
+ program: string;
670
+ /** ID of the program for this instruction */
671
+ programId: PublicKey;
672
+ /** Parsed instruction info */
673
+ parsed: any;
674
+ };
675
+ /**
676
+ * A parsed transaction message
677
+ */
678
+ export type ParsedMessage = {
679
+ /** Accounts used in the instructions */
680
+ accountKeys: ParsedMessageAccount[];
681
+ /** The atomically executed instructions for the transaction */
682
+ instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
683
+ /** Recent blockhash */
684
+ recentBlockhash: string;
685
+ };
686
+ /**
687
+ * A parsed transaction
688
+ */
689
+ export type ParsedTransaction = {
690
+ /** Signatures for the transaction */
691
+ signatures: Array<string>;
692
+ /** Message of the transaction */
693
+ message: ParsedMessage;
694
+ };
695
+ /**
696
+ * A parsed and confirmed transaction on the ledger
697
+ */
698
+ export type ParsedConfirmedTransaction = {
699
+ /** The slot during which the transaction was processed */
700
+ slot: number;
701
+ /** The details of the transaction */
702
+ transaction: ParsedTransaction;
703
+ /** Metadata produced from the transaction */
704
+ meta: ParsedConfirmedTransactionMeta | null;
705
+ /** The unix timestamp of when the transaction was processed */
706
+ blockTime?: number | null;
707
+ };
708
+ /**
709
+ * A ConfirmedBlock on the ledger
710
+ */
711
+ export type ConfirmedBlock = {
712
+ /** Blockhash of this block */
713
+ blockhash: Blockhash;
714
+ /** Blockhash of this block's parent */
715
+ previousBlockhash: Blockhash;
716
+ /** Slot index of this block's parent */
717
+ parentSlot: number;
718
+ /** Vector of transactions and status metas */
719
+ transactions: Array<{
720
+ transaction: Transaction;
721
+ meta: ConfirmedTransactionMeta | null;
722
+ }>;
723
+ /** Vector of block rewards */
724
+ rewards?: Array<{
725
+ pubkey: string;
726
+ lamports: number;
727
+ postBalance: number | null;
728
+ rewardType: string | null;
729
+ }>;
730
+ /** The unix timestamp of when the block was processed */
731
+ blockTime: number | null;
732
+ };
733
+ /**
734
+ * A performance sample
735
+ */
736
+ export type PerfSample = {
737
+ /** Slot number of sample */
738
+ slot: number;
739
+ /** Number of transactions in a sample window */
740
+ numTransactions: number;
741
+ /** Number of slots in a sample window */
742
+ numSlots: number;
743
+ /** Sample window in seconds */
744
+ samplePeriodSecs: number;
745
+ };
746
+ /**
747
+ * Supply
748
+ */
749
+ export type Supply = {
750
+ /** Total supply in lamports */
751
+ total: number;
752
+ /** Circulating supply in lamports */
753
+ circulating: number;
754
+ /** Non-circulating supply in lamports */
755
+ nonCirculating: number;
756
+ /** List of non-circulating account addresses */
757
+ nonCirculatingAccounts: Array<PublicKey>;
758
+ };
759
+ /**
760
+ * Token amount object which returns a token amount in different formats
761
+ * for various client use cases.
762
+ */
763
+ export type TokenAmount = {
764
+ /** Raw amount of tokens as string ignoring decimals */
765
+ amount: string;
766
+ /** Number of decimals configured for token's mint */
767
+ decimals: number;
768
+ /** Token amount as float, accounts for decimals */
769
+ uiAmount: number | null;
770
+ /** Token amount as string, accounts for decimals */
771
+ uiAmountString?: string;
772
+ };
773
+ /**
774
+ * Token address and balance.
775
+ */
776
+ export type TokenAccountBalancePair = {
777
+ /** Address of the token account */
778
+ address: PublicKey;
779
+ /** Raw amount of tokens as string ignoring decimals */
780
+ amount: string;
781
+ /** Number of decimals configured for token's mint */
782
+ decimals: number;
783
+ /** Token amount as float, accounts for decimals */
784
+ uiAmount: number | null;
785
+ /** Token amount as string, accounts for decimals */
786
+ uiAmountString?: string;
787
+ };
788
+ /**
789
+ * Pair of an account address and its balance
790
+ */
791
+ export type AccountBalancePair = {
792
+ address: PublicKey;
793
+ lamports: number;
794
+ };
795
+ /**
796
+ * Information about the latest slot being processed by a node
797
+ */
798
+ export type SlotInfo = {
799
+ /** Currently processing slot */
800
+ slot: number;
801
+ /** Parent of the current slot */
802
+ parent: number;
803
+ /** The root block of the current slot's fork */
804
+ root: number;
805
+ };
806
+ /**
807
+ * Parsed account data
808
+ */
809
+ export type ParsedAccountData = {
810
+ /** Name of the program that owns this account */
811
+ program: string;
812
+ /** Parsed account data */
813
+ parsed: any;
814
+ /** Space used by account data */
815
+ space: number;
816
+ };
817
+ /**
818
+ * Stake Activation data
819
+ */
820
+ export type StakeActivationData = {
821
+ /** the stake account's activation state */
822
+ state: 'active' | 'inactive' | 'activating' | 'deactivating';
823
+ /** stake active during the epoch */
824
+ active: number;
825
+ /** stake inactive during the epoch */
826
+ inactive: number;
827
+ };
828
+ /**
829
+ * Information describing an account
830
+ */
831
+ export type AccountInfo<T> = {
832
+ /** `true` if this account's data contains a loaded program */
833
+ executable: boolean;
834
+ /** Identifier of the program that owns the account */
835
+ owner: PublicKey;
836
+ /** Number of lamports assigned to the account */
837
+ lamports: number;
838
+ /** Optional data assigned to the account */
839
+ data: T;
840
+ };
841
+ /**
842
+ * Account information identified by pubkey
843
+ */
844
+ export type KeyedAccountInfo = {
845
+ accountId: PublicKey;
846
+ accountInfo: AccountInfo<Buffer>;
847
+ };
848
+ /**
849
+ * Callback function for account change notifications
850
+ */
851
+ export type AccountChangeCallback = (
852
+ accountInfo: AccountInfo<Buffer>,
853
+ context: Context,
854
+ ) => void;
855
+ /**
856
+ * Callback function for program account change notifications
857
+ */
858
+ export type ProgramAccountChangeCallback = (
859
+ keyedAccountInfo: KeyedAccountInfo,
860
+ context: Context,
861
+ ) => void;
862
+ /**
863
+ * Callback function for slot change notifications
864
+ */
865
+ export type SlotChangeCallback = (slotInfo: SlotInfo) => void;
866
+ /**
867
+ * Callback function for signature status notifications
868
+ */
869
+ export type SignatureResultCallback = (
870
+ signatureResult: SignatureResult,
871
+ context: Context,
872
+ ) => void;
873
+ /**
874
+ * Signature status notification with transaction result
875
+ */
876
+ export type SignatureStatusNotification = {
877
+ type: 'status';
878
+ result: SignatureResult;
879
+ };
880
+ /**
881
+ * Signature received notification
882
+ */
883
+ export type SignatureReceivedNotification = {
884
+ type: 'received';
885
+ };
886
+ /**
887
+ * Callback function for signature notifications
888
+ */
889
+ export type SignatureSubscriptionCallback = (
890
+ notification: SignatureStatusNotification | SignatureReceivedNotification,
891
+ context: Context,
892
+ ) => void;
893
+ /**
894
+ * Signature subscription options
895
+ */
896
+ export type SignatureSubscriptionOptions = {
897
+ commitment?: Commitment;
898
+ enableReceivedNotification?: boolean;
899
+ };
900
+ /**
901
+ * Callback function for root change notifications
902
+ */
903
+ export type RootChangeCallback = (root: number) => void;
904
+ /**
905
+ * Logs result.
906
+ */
907
+ export type Logs = {
908
+ err: TransactionError | null;
909
+ logs: string[];
910
+ signature: string;
911
+ };
912
+ /**
913
+ * Filter for log subscriptions.
914
+ */
915
+ export type LogsFilter = PublicKey | 'all' | 'allWithVotes';
916
+ /**
917
+ * Callback function for log notifications.
918
+ */
919
+ export type LogsCallback = (logs: Logs, ctx: Context) => void;
920
+ /**
921
+ * Signature result
922
+ */
923
+ export type SignatureResult = {
924
+ err: TransactionError | null;
925
+ };
926
+ /**
927
+ * Transaction error
928
+ */
929
+ export type TransactionError = {} | string;
930
+ /**
931
+ * Transaction confirmation status
932
+ * <pre>
933
+ * 'processed': Transaction landed in a block which has reached 1 confirmation by the connected node
934
+ * 'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster
935
+ * 'finalized': Transaction landed in a block which has been finalized by the cluster
936
+ * </pre>
937
+ */
938
+ export type TransactionConfirmationStatus =
939
+ | 'processed'
940
+ | 'confirmed'
941
+ | 'finalized';
942
+ /**
943
+ * Signature status
944
+ */
945
+ export type SignatureStatus = {
946
+ /** when the transaction was processed */
947
+ slot: number;
948
+ /** the number of blocks that have been confirmed and voted on in the fork containing `slot` */
949
+ confirmations: number | null;
950
+ /** transaction error, if any */
951
+ err: TransactionError | null;
952
+ /** cluster confirmation status, if data available. Possible responses: `processed`, `confirmed`, `finalized` */
953
+ confirmationStatus?: TransactionConfirmationStatus;
954
+ };
955
+ /**
956
+ * A confirmed signature with its status
957
+ */
958
+ export type ConfirmedSignatureInfo = {
959
+ /** the transaction signature */
960
+ signature: string;
961
+ /** when the transaction was processed */
962
+ slot: number;
963
+ /** error, if any */
964
+ err: TransactionError | null;
965
+ /** memo associated with the transaction, if any */
966
+ memo: string | null;
967
+ /** The unix timestamp of when the transaction was processed */
968
+ blockTime?: number | null;
969
+ };
970
+ /**
971
+ * A connection to a fullnode JSON RPC endpoint
972
+ */
973
+ export class Connection {
974
+ /**
975
+ * Establish a JSON RPC connection
976
+ *
977
+ * @param endpoint URL to the fullnode JSON RPC endpoint
978
+ * @param commitment optional default commitment level
979
+ */
980
+ constructor(endpoint: string, commitment?: Commitment);
981
+ /**
982
+ * The default commitment used for requests
983
+ */
984
+ get commitment(): Commitment | undefined;
985
+ /**
986
+ * Fetch the balance for the specified public key, return with context
987
+ */
988
+ getBalanceAndContext(
989
+ publicKey: PublicKey,
990
+ commitment?: Commitment,
991
+ ): Promise<RpcResponseAndContext<number>>;
992
+ /**
993
+ * Fetch the balance for the specified public key
994
+ */
995
+ getBalance(publicKey: PublicKey, commitment?: Commitment): Promise<number>;
996
+ /**
997
+ * Fetch the estimated production time of a block
998
+ */
999
+ getBlockTime(slot: number): Promise<number | null>;
1000
+ /**
1001
+ * Fetch the lowest slot that the node has information about in its ledger.
1002
+ * This value may increase over time if the node is configured to purge older ledger data
1003
+ */
1004
+ getMinimumLedgerSlot(): Promise<number>;
1005
+ /**
1006
+ * Fetch the slot of the lowest confirmed block that has not been purged from the ledger
1007
+ */
1008
+ getFirstAvailableBlock(): Promise<number>;
1009
+ /**
1010
+ * Fetch information about the current supply
1011
+ */
1012
+ getSupply(commitment?: Commitment): Promise<RpcResponseAndContext<Supply>>;
1013
+ /**
1014
+ * Fetch the current supply of a token mint
1015
+ */
1016
+ getTokenSupply(
1017
+ tokenMintAddress: PublicKey,
1018
+ commitment?: Commitment,
1019
+ ): Promise<RpcResponseAndContext<TokenAmount>>;
1020
+ /**
1021
+ * Fetch the current balance of a token account
1022
+ */
1023
+ getTokenAccountBalance(
1024
+ tokenAddress: PublicKey,
1025
+ commitment?: Commitment,
1026
+ ): Promise<RpcResponseAndContext<TokenAmount>>;
1027
+ /**
1028
+ * Fetch all the token accounts owned by the specified account
1029
+ *
1030
+ * @return {Promise<RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>>}
1031
+ */
1032
+ getTokenAccountsByOwner(
1033
+ ownerAddress: PublicKey,
1034
+ filter: TokenAccountsFilter,
1035
+ commitment?: Commitment,
1036
+ ): Promise<
1037
+ RpcResponseAndContext<
1038
+ Array<{
1039
+ pubkey: PublicKey;
1040
+ account: AccountInfo<Buffer>;
1041
+ }>
1042
+ >
1043
+ >;
1044
+ /**
1045
+ * Fetch parsed token accounts owned by the specified account
1046
+ *
1047
+ * @return {Promise<RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo<ParsedAccountData>}>>>}
1048
+ */
1049
+ getParsedTokenAccountsByOwner(
1050
+ ownerAddress: PublicKey,
1051
+ filter: TokenAccountsFilter,
1052
+ commitment?: Commitment,
1053
+ ): Promise<
1054
+ RpcResponseAndContext<
1055
+ Array<{
1056
+ pubkey: PublicKey;
1057
+ account: AccountInfo<ParsedAccountData>;
1058
+ }>
1059
+ >
1060
+ >;
1061
+ /**
1062
+ * Fetch the 20 largest accounts with their current balances
1063
+ */
1064
+ getLargestAccounts(
1065
+ config?: GetLargestAccountsConfig,
1066
+ ): Promise<RpcResponseAndContext<Array<AccountBalancePair>>>;
1067
+ /**
1068
+ * Fetch the 20 largest token accounts with their current balances
1069
+ * for a given mint.
1070
+ */
1071
+ getTokenLargestAccounts(
1072
+ mintAddress: PublicKey,
1073
+ commitment?: Commitment,
1074
+ ): Promise<RpcResponseAndContext<Array<TokenAccountBalancePair>>>;
1075
+ /**
1076
+ * Fetch all the account info for the specified public key, return with context
1077
+ */
1078
+ getAccountInfoAndContext(
1079
+ publicKey: PublicKey,
1080
+ commitment?: Commitment,
1081
+ ): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
1082
+ /**
1083
+ * Fetch parsed account info for the specified public key
1084
+ */
1085
+ getParsedAccountInfo(
1086
+ publicKey: PublicKey,
1087
+ commitment?: Commitment,
1088
+ ): Promise<
1089
+ RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>
1090
+ >;
1091
+ /**
1092
+ * Fetch all the account info for the specified public key
1093
+ */
1094
+ getAccountInfo(
1095
+ publicKey: PublicKey,
1096
+ commitment?: Commitment,
1097
+ ): Promise<AccountInfo<Buffer> | null>;
1098
+ /**
1099
+ * Returns epoch activation information for a stake account that has been delegated
1100
+ */
1101
+ getStakeActivation(
1102
+ publicKey: PublicKey,
1103
+ commitment?: Commitment,
1104
+ epoch?: number,
1105
+ ): Promise<StakeActivationData>;
1106
+ /**
1107
+ * Fetch all the accounts owned by the specified program id
1108
+ *
1109
+ * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>}
1110
+ */
1111
+ getProgramAccounts(
1112
+ programId: PublicKey,
1113
+ commitment?: Commitment,
1114
+ ): Promise<
1115
+ Array<{
1116
+ pubkey: PublicKey;
1117
+ account: AccountInfo<Buffer>;
1118
+ }>
1119
+ >;
1120
+ /**
1121
+ * Fetch and parse all the accounts owned by the specified program id
1122
+ *
1123
+ * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer | ParsedAccountData>}>>}
1124
+ */
1125
+ getParsedProgramAccounts(
1126
+ programId: PublicKey,
1127
+ commitment?: Commitment,
1128
+ ): Promise<
1129
+ Array<{
1130
+ pubkey: PublicKey;
1131
+ account: AccountInfo<Buffer | ParsedAccountData>;
1132
+ }>
1133
+ >;
1134
+ /**
1135
+ * Confirm the transaction identified by the specified signature.
1136
+ */
1137
+ confirmTransaction(
1138
+ signature: TransactionSignature,
1139
+ commitment?: Commitment,
1140
+ ): Promise<RpcResponseAndContext<SignatureResult>>;
1141
+ /**
1142
+ * Return the list of nodes that are currently participating in the cluster
1143
+ */
1144
+ getClusterNodes(): Promise<Array<ContactInfo>>;
1145
+ /**
1146
+ * Return the list of nodes that are currently participating in the cluster
1147
+ */
1148
+ getVoteAccounts(commitment?: Commitment): Promise<VoteAccountStatus>;
1149
+ /**
1150
+ * Fetch the current slot that the node is processing
1151
+ */
1152
+ getSlot(commitment?: Commitment): Promise<number>;
1153
+ /**
1154
+ * Fetch the current slot leader of the cluster
1155
+ */
1156
+ getSlotLeader(commitment?: Commitment): Promise<string>;
1157
+ /**
1158
+ * Fetch the current status of a signature
1159
+ */
1160
+ getSignatureStatus(
1161
+ signature: TransactionSignature,
1162
+ config?: SignatureStatusConfig,
1163
+ ): Promise<RpcResponseAndContext<SignatureStatus | null>>;
1164
+ /**
1165
+ * Fetch the current statuses of a batch of signatures
1166
+ */
1167
+ getSignatureStatuses(
1168
+ signatures: Array<TransactionSignature>,
1169
+ config?: SignatureStatusConfig,
1170
+ ): Promise<RpcResponseAndContext<Array<SignatureStatus | null>>>;
1171
+ /**
1172
+ * Fetch the current transaction count of the cluster
1173
+ */
1174
+ getTransactionCount(commitment?: Commitment): Promise<number>;
1175
+ /**
1176
+ * Fetch the current total currency supply of the cluster in lamports
1177
+ */
1178
+ getTotalSupply(commitment?: Commitment): Promise<number>;
1179
+ /**
1180
+ * Fetch the cluster InflationGovernor parameters
1181
+ */
1182
+ getInflationGovernor(commitment?: Commitment): Promise<InflationGovernor>;
1183
+ /**
1184
+ * Fetch the Epoch Info parameters
1185
+ */
1186
+ getEpochInfo(commitment?: Commitment): Promise<EpochInfo>;
1187
+ /**
1188
+ * Fetch the Epoch Schedule parameters
1189
+ */
1190
+ getEpochSchedule(): Promise<EpochSchedule>;
1191
+ /**
1192
+ * Fetch the leader schedule for the current epoch
1193
+ * @return {Promise<RpcResponseAndContext<LeaderSchedule>>}
1194
+ */
1195
+ getLeaderSchedule(): Promise<LeaderSchedule>;
1196
+ /**
1197
+ * Fetch the minimum balance needed to exempt an account of `dataLength`
1198
+ * size from rent
1199
+ */
1200
+ getMinimumBalanceForRentExemption(
1201
+ dataLength: number,
1202
+ commitment?: Commitment,
1203
+ ): Promise<number>;
1204
+ /**
1205
+ * Fetch a recent blockhash from the cluster, return with context
1206
+ * @return {Promise<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
1207
+ */
1208
+ getRecentBlockhashAndContext(
1209
+ commitment?: Commitment,
1210
+ ): Promise<
1211
+ RpcResponseAndContext<{
1212
+ blockhash: Blockhash;
1213
+ feeCalculator: FeeCalculator;
1214
+ }>
1215
+ >;
1216
+ /**
1217
+ * Fetch recent performance samples
1218
+ * @return {Promise<Array<PerfSample>>}
1219
+ */
1220
+ getRecentPerformanceSamples(limit?: number): Promise<Array<PerfSample>>;
1221
+ /**
1222
+ * Fetch the fee calculator for a recent blockhash from the cluster, return with context
1223
+ */
1224
+ getFeeCalculatorForBlockhash(
1225
+ blockhash: Blockhash,
1226
+ commitment?: Commitment,
1227
+ ): Promise<RpcResponseAndContext<FeeCalculator | null>>;
1228
+ /**
1229
+ * Fetch a recent blockhash from the cluster
1230
+ * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
1231
+ */
1232
+ getRecentBlockhash(
1233
+ commitment?: Commitment,
1234
+ ): Promise<{
1235
+ blockhash: Blockhash;
1236
+ feeCalculator: FeeCalculator;
1237
+ }>;
1238
+ /**
1239
+ * Fetch the node version
1240
+ */
1241
+ getVersion(): Promise<Version>;
1242
+ /**
1243
+ * Fetch a list of Transactions and transaction statuses from the cluster
1244
+ * for a confirmed block
1245
+ */
1246
+ getConfirmedBlock(slot: number): Promise<ConfirmedBlock>;
1247
+ /**
1248
+ * Fetch a transaction details for a confirmed transaction
1249
+ */
1250
+ getConfirmedTransaction(
1251
+ signature: TransactionSignature,
1252
+ ): Promise<ConfirmedTransaction | null>;
1253
+ /**
1254
+ * Fetch parsed transaction details for a confirmed transaction
1255
+ */
1256
+ getParsedConfirmedTransaction(
1257
+ signature: TransactionSignature,
1258
+ ): Promise<ParsedConfirmedTransaction | null>;
1259
+ /**
1260
+ * Fetch parsed transaction details for a batch of confirmed transactions
1261
+ */
1262
+ getParsedConfirmedTransactions(
1263
+ signatures: TransactionSignature[],
1264
+ ): Promise<(ParsedConfirmedTransaction | null)[]>;
1265
+ /**
1266
+ * Fetch a list of all the confirmed signatures for transactions involving an address
1267
+ * within a specified slot range. Max range allowed is 10,000 slots.
1268
+ *
1269
+ * @param address queried address
1270
+ * @param startSlot start slot, inclusive
1271
+ * @param endSlot end slot, inclusive
1272
+ */
1273
+ getConfirmedSignaturesForAddress(
1274
+ address: PublicKey,
1275
+ startSlot: number,
1276
+ endSlot: number,
1277
+ ): Promise<Array<TransactionSignature>>;
1278
+ /**
1279
+ * Returns confirmed signatures for transactions involving an
1280
+ * address backwards in time from the provided signature or most recent confirmed block
1281
+ *
1282
+ *
1283
+ * @param address queried address
1284
+ * @param options
1285
+ */
1286
+ getConfirmedSignaturesForAddress2(
1287
+ address: PublicKey,
1288
+ options?: ConfirmedSignaturesForAddress2Options,
1289
+ ): Promise<Array<ConfirmedSignatureInfo>>;
1290
+ /**
1291
+ * Fetch the contents of a Nonce account from the cluster, return with context
1292
+ */
1293
+ getNonceAndContext(
1294
+ nonceAccount: PublicKey,
1295
+ commitment?: Commitment,
1296
+ ): Promise<RpcResponseAndContext<NonceAccount | null>>;
1297
+ /**
1298
+ * Fetch the contents of a Nonce account from the cluster
1299
+ */
1300
+ getNonce(
1301
+ nonceAccount: PublicKey,
1302
+ commitment?: Commitment,
1303
+ ): Promise<NonceAccount | null>;
1304
+ /**
1305
+ * Request an allocation of lamports to the specified account
1306
+ */
1307
+ requestAirdrop(
1308
+ to: PublicKey,
1309
+ amount: number,
1310
+ ): Promise<TransactionSignature>;
1311
+ /**
1312
+ * Simulate a transaction
1313
+ */
1314
+ simulateTransaction(
1315
+ transaction: Transaction,
1316
+ signers?: Array<Account>,
1317
+ ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
1318
+ /**
1319
+ * Sign and send a transaction
1320
+ */
1321
+ sendTransaction(
1322
+ transaction: Transaction,
1323
+ signers: Array<Account>,
1324
+ options?: SendOptions,
1325
+ ): Promise<TransactionSignature>;
1326
+ /**
1327
+ * Send a transaction that has already been signed and serialized into the
1328
+ * wire format
1329
+ */
1330
+ sendRawTransaction(
1331
+ rawTransaction: Buffer | Uint8Array | Array<number>,
1332
+ options?: SendOptions,
1333
+ ): Promise<TransactionSignature>;
1334
+ /**
1335
+ * Send a transaction that has already been signed, serialized into the
1336
+ * wire format, and encoded as a base64 string
1337
+ */
1338
+ sendEncodedTransaction(
1339
+ encodedTransaction: string,
1340
+ options?: SendOptions,
1341
+ ): Promise<TransactionSignature>;
1342
+ /**
1343
+ * Register a callback to be invoked whenever the specified account changes
1344
+ *
1345
+ * @param publicKey Public key of the account to monitor
1346
+ * @param callback Function to invoke whenever the account is changed
1347
+ * @param commitment Specify the commitment level account changes must reach before notification
1348
+ * @return subscription id
1349
+ */
1350
+ onAccountChange(
1351
+ publicKey: PublicKey,
1352
+ callback: AccountChangeCallback,
1353
+ commitment?: Commitment,
1354
+ ): number;
1355
+ /**
1356
+ * Deregister an account notification callback
1357
+ *
1358
+ * @param id subscription id to deregister
1359
+ */
1360
+ removeAccountChangeListener(id: number): Promise<void>;
1361
+ /**
1362
+ * Register a callback to be invoked whenever accounts owned by the
1363
+ * specified program change
1364
+ *
1365
+ * @param programId Public key of the program to monitor
1366
+ * @param callback Function to invoke whenever the account is changed
1367
+ * @param commitment Specify the commitment level account changes must reach before notification
1368
+ * @return subscription id
1369
+ */
1370
+ onProgramAccountChange(
1371
+ programId: PublicKey,
1372
+ callback: ProgramAccountChangeCallback,
1373
+ commitment?: Commitment,
1374
+ ): number;
1375
+ /**
1376
+ * Deregister an account notification callback
1377
+ *
1378
+ * @param id subscription id to deregister
1379
+ */
1380
+ removeProgramAccountChangeListener(id: number): Promise<void>;
1381
+ /**
1382
+ * Registers a callback to be invoked whenever logs are emitted.
1383
+ */
1384
+ onLogs(
1385
+ filter: LogsFilter,
1386
+ callback: LogsCallback,
1387
+ commitment?: Commitment,
1388
+ ): number;
1389
+ /**
1390
+ * Deregister a logs callback.
1391
+ *
1392
+ * @param id subscription id to deregister.
1393
+ */
1394
+ removeOnLogsListener(id: number): Promise<void>;
1395
+ /**
1396
+ * Register a callback to be invoked upon slot changes
1397
+ *
1398
+ * @param callback Function to invoke whenever the slot changes
1399
+ * @return subscription id
1400
+ */
1401
+ onSlotChange(callback: SlotChangeCallback): number;
1402
+ /**
1403
+ * Deregister a slot notification callback
1404
+ *
1405
+ * @param id subscription id to deregister
1406
+ */
1407
+ removeSlotChangeListener(id: number): Promise<void>;
1408
+ /**
1409
+ * Register a callback to be invoked upon signature updates
1410
+ *
1411
+ * @param signature Transaction signature string in base 58
1412
+ * @param callback Function to invoke on signature notifications
1413
+ * @param commitment Specify the commitment level signature must reach before notification
1414
+ * @return subscription id
1415
+ */
1416
+ onSignature(
1417
+ signature: TransactionSignature,
1418
+ callback: SignatureResultCallback,
1419
+ commitment?: Commitment,
1420
+ ): number;
1421
+ /**
1422
+ * Register a callback to be invoked when a transaction is
1423
+ * received and/or processed.
1424
+ *
1425
+ * @param signature Transaction signature string in base 58
1426
+ * @param callback Function to invoke on signature notifications
1427
+ * @param options Enable received notifications and set the commitment
1428
+ * level that signature must reach before notification
1429
+ * @return subscription id
1430
+ */
1431
+ onSignatureWithOptions(
1432
+ signature: TransactionSignature,
1433
+ callback: SignatureSubscriptionCallback,
1434
+ options?: SignatureSubscriptionOptions,
1435
+ ): number;
1436
+ /**
1437
+ * Deregister a signature notification callback
1438
+ *
1439
+ * @param id subscription id to deregister
1440
+ */
1441
+ removeSignatureListener(id: number): Promise<void>;
1442
+ /**
1443
+ * Register a callback to be invoked upon root changes
1444
+ *
1445
+ * @param callback Function to invoke whenever the root changes
1446
+ * @return subscription id
1447
+ */
1448
+ onRootChange(callback: RootChangeCallback): number;
1449
+ /**
1450
+ * Deregister a root notification callback
1451
+ *
1452
+ * @param id subscription id to deregister
1453
+ */
1454
+ removeRootChangeListener(id: number): Promise<void>;
1455
+ }
1456
+
1457
+ export const BPF_LOADER_PROGRAM_ID: PublicKey;
1458
+ /**
1459
+ * Factory class for transactions to interact with a program loader
1460
+ */
1461
+ export class BpfLoader {
1462
+ /**
1463
+ * Minimum number of signatures required to load a program not including
1464
+ * retries
1465
+ *
1466
+ * Can be used to calculate transaction fees
1467
+ */
1468
+ static getMinNumSignatures(dataLength: number): number;
1469
+ /**
1470
+ * Load a BPF program
1471
+ *
1472
+ * @param connection The connection to use
1473
+ * @param payer Account that will pay program loading fees
1474
+ * @param program Account to load the program into
1475
+ * @param elf The entire ELF containing the BPF program
1476
+ * @param loaderProgramId The program id of the BPF loader to use
1477
+ * @return true if program was loaded successfully, false if program was already loaded
1478
+ */
1479
+ static load(
1480
+ connection: Connection,
1481
+ payer: Account,
1482
+ program: Account,
1483
+ elf: Buffer | Uint8Array | Array<number>,
1484
+ loaderProgramId: PublicKey,
1485
+ ): Promise<boolean>;
1486
+ }
1487
+
1488
+ /**
1489
+ * Program loader interface
1490
+ */
1491
+ export class Loader {
1492
+ /**
1493
+ * Amount of program data placed in each load Transaction
1494
+ */
1495
+ static chunkSize: number;
1496
+ /**
1497
+ * Minimum number of signatures required to load a program not including
1498
+ * retries
1499
+ *
1500
+ * Can be used to calculate transaction fees
1501
+ */
1502
+ static getMinNumSignatures(dataLength: number): number;
1503
+ /**
1504
+ * Loads a generic program
1505
+ *
1506
+ * @param connection The connection to use
1507
+ * @param payer System account that pays to load the program
1508
+ * @param program Account to load the program into
1509
+ * @param programId Public key that identifies the loader
1510
+ * @param data Program octets
1511
+ * @return true if program was loaded successfully, false if program was already loaded
1512
+ */
1513
+ static load(
1514
+ connection: Connection,
1515
+ payer: Account,
1516
+ program: Account,
1517
+ programId: PublicKey,
1518
+ data: Buffer | Uint8Array | Array<number>,
1519
+ ): Promise<boolean>;
1520
+ }
1521
+
1522
+ /**
1523
+ * Address of the stake config account which configures the rate
1524
+ * of stake warmup and cooldown as well as the slashing penalty.
1525
+ */
1526
+ export const STAKE_CONFIG_ID: PublicKey;
1527
+ /**
1528
+ * Stake account authority info
1529
+ */
1530
+ export class Authorized {
1531
+ /** stake authority */
1532
+ staker: PublicKey;
1533
+ /** withdraw authority */
1534
+ withdrawer: PublicKey;
1535
+ /**
1536
+ * Create a new Authorized object
1537
+ * @param staker the stake authority
1538
+ * @param withdrawer the withdraw authority
1539
+ */
1540
+ constructor(staker: PublicKey, withdrawer: PublicKey);
1541
+ }
1542
+ /**
1543
+ * Stake account lockup info
1544
+ */
1545
+ export class Lockup {
1546
+ /** Unix timestamp of lockup expiration */
1547
+ unixTimestamp: number;
1548
+ /** Epoch of lockup expiration */
1549
+ epoch: number;
1550
+ /** Lockup custodian authority */
1551
+ custodian: PublicKey;
1552
+ /**
1553
+ * Create a new Lockup object
1554
+ */
1555
+ constructor(unixTimestamp: number, epoch: number, custodian: PublicKey);
1556
+ }
1557
+ /**
1558
+ * Create stake account transaction params
1559
+ */
1560
+ export type CreateStakeAccountParams = {
1561
+ /** Address of the account which will fund creation */
1562
+ fromPubkey: PublicKey;
1563
+ /** Address of the new stake account */
1564
+ stakePubkey: PublicKey;
1565
+ /** Authorities of the new stake account */
1566
+ authorized: Authorized;
1567
+ /** Lockup of the new stake account */
1568
+ lockup: Lockup;
1569
+ /** Funding amount */
1570
+ lamports: number;
1571
+ };
1572
+ /**
1573
+ * Create stake account with seed transaction params
1574
+ */
1575
+ export type CreateStakeAccountWithSeedParams = {
1576
+ fromPubkey: PublicKey;
1577
+ stakePubkey: PublicKey;
1578
+ basePubkey: PublicKey;
1579
+ seed: string;
1580
+ authorized: Authorized;
1581
+ lockup: Lockup;
1582
+ lamports: number;
1583
+ };
1584
+ /**
1585
+ * Initialize stake instruction params
1586
+ */
1587
+ export type InitializeStakeParams = {
1588
+ stakePubkey: PublicKey;
1589
+ authorized: Authorized;
1590
+ lockup: Lockup;
1591
+ };
1592
+ /**
1593
+ * Delegate stake instruction params
1594
+ */
1595
+ export type DelegateStakeParams = {
1596
+ stakePubkey: PublicKey;
1597
+ authorizedPubkey: PublicKey;
1598
+ votePubkey: PublicKey;
1599
+ };
1600
+ /**
1601
+ * Authorize stake instruction params
1602
+ */
1603
+ export type AuthorizeStakeParams = {
1604
+ stakePubkey: PublicKey;
1605
+ authorizedPubkey: PublicKey;
1606
+ newAuthorizedPubkey: PublicKey;
1607
+ stakeAuthorizationType: StakeAuthorizationType;
1608
+ custodianPubkey?: PublicKey;
1609
+ };
1610
+ /**
1611
+ * Authorize stake instruction params using a derived key
1612
+ */
1613
+ export type AuthorizeWithSeedStakeParams = {
1614
+ stakePubkey: PublicKey;
1615
+ authorityBase: PublicKey;
1616
+ authoritySeed: string;
1617
+ authorityOwner: PublicKey;
1618
+ newAuthorizedPubkey: PublicKey;
1619
+ stakeAuthorizationType: StakeAuthorizationType;
1620
+ custodianPubkey?: PublicKey;
1621
+ };
1622
+ /**
1623
+ * Split stake instruction params
1624
+ */
1625
+ export type SplitStakeParams = {
1626
+ stakePubkey: PublicKey;
1627
+ authorizedPubkey: PublicKey;
1628
+ splitStakePubkey: PublicKey;
1629
+ lamports: number;
1630
+ };
1631
+ /**
1632
+ * Withdraw stake instruction params
1633
+ */
1634
+ export type WithdrawStakeParams = {
1635
+ stakePubkey: PublicKey;
1636
+ authorizedPubkey: PublicKey;
1637
+ toPubkey: PublicKey;
1638
+ lamports: number;
1639
+ custodianPubkey?: PublicKey;
1640
+ };
1641
+ /**
1642
+ * Deactivate stake instruction params
1643
+ */
1644
+ export type DeactivateStakeParams = {
1645
+ stakePubkey: PublicKey;
1646
+ authorizedPubkey: PublicKey;
1647
+ };
1648
+ /**
1649
+ * Stake Instruction class
1650
+ */
1651
+ export class StakeInstruction {
1652
+ /**
1653
+ * Decode a stake instruction and retrieve the instruction type.
1654
+ */
1655
+ static decodeInstructionType(
1656
+ instruction: TransactionInstruction,
1657
+ ): StakeInstructionType;
1658
+ /**
1659
+ * Decode a initialize stake instruction and retrieve the instruction params.
1660
+ */
1661
+ static decodeInitialize(
1662
+ instruction: TransactionInstruction,
1663
+ ): InitializeStakeParams;
1664
+ /**
1665
+ * Decode a delegate stake instruction and retrieve the instruction params.
1666
+ */
1667
+ static decodeDelegate(
1668
+ instruction: TransactionInstruction,
1669
+ ): DelegateStakeParams;
1670
+ /**
1671
+ * Decode an authorize stake instruction and retrieve the instruction params.
1672
+ */
1673
+ static decodeAuthorize(
1674
+ instruction: TransactionInstruction,
1675
+ ): AuthorizeStakeParams;
1676
+ /**
1677
+ * Decode an authorize-with-seed stake instruction and retrieve the instruction params.
1678
+ */
1679
+ static decodeAuthorizeWithSeed(
1680
+ instruction: TransactionInstruction,
1681
+ ): AuthorizeWithSeedStakeParams;
1682
+ /**
1683
+ * Decode a split stake instruction and retrieve the instruction params.
1684
+ */
1685
+ static decodeSplit(instruction: TransactionInstruction): SplitStakeParams;
1686
+ /**
1687
+ * Decode a withdraw stake instruction and retrieve the instruction params.
1688
+ */
1689
+ static decodeWithdraw(
1690
+ instruction: TransactionInstruction,
1691
+ ): WithdrawStakeParams;
1692
+ /**
1693
+ * Decode a deactivate stake instruction and retrieve the instruction params.
1694
+ */
1695
+ static decodeDeactivate(
1696
+ instruction: TransactionInstruction,
1697
+ ): DeactivateStakeParams;
1698
+ }
1699
+ /**
1700
+ * An enumeration of valid StakeInstructionType's
1701
+ */
1702
+ export type StakeInstructionType =
1703
+ | 'AuthorizeWithSeed'
1704
+ | 'Authorize'
1705
+ | 'Deactivate'
1706
+ | 'Delegate'
1707
+ | 'Initialize'
1708
+ | 'Split'
1709
+ | 'Withdraw';
1710
+ /**
1711
+ * Stake authorization type
1712
+ */
1713
+ export type StakeAuthorizationType = {
1714
+ /** The Stake Authorization index (from solana-stake-program) */
1715
+ index: number;
1716
+ };
1717
+ /**
1718
+ * An enumeration of valid StakeAuthorizationLayout's
1719
+ */
1720
+ export const StakeAuthorizationLayout: Readonly<{
1721
+ Staker: {
1722
+ index: number;
1723
+ };
1724
+ Withdrawer: {
1725
+ index: number;
1726
+ };
1727
+ }>;
1728
+ /**
1729
+ * Factory class for transactions to interact with the Stake program
1730
+ */
1731
+ export class StakeProgram {
1732
+ /**
1733
+ * Public key that identifies the Stake program
1734
+ */
1735
+ static programId: PublicKey;
1736
+ /**
1737
+ * Max space of a Stake account
1738
+ *
1739
+ * This is generated from the solana-stake-program StakeState struct as
1740
+ * `std::mem::size_of::<StakeState>()`:
1741
+ * https://docs.rs/solana-stake-program/1.4.4/solana_stake_program/stake_state/enum.StakeState.html
1742
+ */
1743
+ static space: number;
1744
+ /**
1745
+ * Generate an Initialize instruction to add to a Stake Create transaction
1746
+ */
1747
+ static initialize(params: InitializeStakeParams): TransactionInstruction;
1748
+ /**
1749
+ * Generate a Transaction that creates a new Stake account at
1750
+ * an address generated with `from`, a seed, and the Stake programId
1751
+ */
1752
+ static createAccountWithSeed(
1753
+ params: CreateStakeAccountWithSeedParams,
1754
+ ): Transaction;
1755
+ /**
1756
+ * Generate a Transaction that creates a new Stake account
1757
+ */
1758
+ static createAccount(params: CreateStakeAccountParams): Transaction;
1759
+ /**
1760
+ * Generate a Transaction that delegates Stake tokens to a validator
1761
+ * Vote PublicKey. This transaction can also be used to redelegate Stake
1762
+ * to a new validator Vote PublicKey.
1763
+ */
1764
+ static delegate(params: DelegateStakeParams): Transaction;
1765
+ /**
1766
+ * Generate a Transaction that authorizes a new PublicKey as Staker
1767
+ * or Withdrawer on the Stake account.
1768
+ */
1769
+ static authorize(params: AuthorizeStakeParams): Transaction;
1770
+ /**
1771
+ * Generate a Transaction that authorizes a new PublicKey as Staker
1772
+ * or Withdrawer on the Stake account.
1773
+ */
1774
+ static authorizeWithSeed(params: AuthorizeWithSeedStakeParams): Transaction;
1775
+ /**
1776
+ * Generate a Transaction that splits Stake tokens into another stake account
1777
+ */
1778
+ static split(params: SplitStakeParams): Transaction;
1779
+ /**
1780
+ * Generate a Transaction that withdraws deactivated Stake tokens.
1781
+ */
1782
+ static withdraw(params: WithdrawStakeParams): Transaction;
1783
+ /**
1784
+ * Generate a Transaction that deactivates Stake tokens.
1785
+ */
1786
+ static deactivate(params: DeactivateStakeParams): Transaction;
1787
+ }
1788
+
1789
+ /**
1790
+ * Create account system transaction params
1791
+ */
1792
+ export type CreateAccountParams = {
1793
+ /** The account that will transfer lamports to the created account */
1794
+ fromPubkey: PublicKey;
1795
+ /** Public key of the created account */
1796
+ newAccountPubkey: PublicKey;
1797
+ /** Amount of lamports to transfer to the created account */
1798
+ lamports: number;
1799
+ /** Amount of space in bytes to allocate to the created account */
1800
+ space: number;
1801
+ /** Public key of the program to assign as the owner of the created account */
1802
+ programId: PublicKey;
1803
+ };
1804
+ /**
1805
+ * Transfer system transaction params
1806
+ */
1807
+ export type TransferParams = {
1808
+ /** Account that will transfer lamports */
1809
+ fromPubkey: PublicKey;
1810
+ /** Account that will receive transferred lamports */
1811
+ toPubkey: PublicKey;
1812
+ /** Amount of lamports to transfer */
1813
+ lamports: number;
1814
+ };
1815
+ /**
1816
+ * Assign system transaction params
1817
+ */
1818
+ export type AssignParams = {
1819
+ /** Public key of the account which will be assigned a new owner */
1820
+ accountPubkey: PublicKey;
1821
+ /** Public key of the program to assign as the owner */
1822
+ programId: PublicKey;
1823
+ };
1824
+ /**
1825
+ * Create account with seed system transaction params
1826
+ */
1827
+ export type CreateAccountWithSeedParams = {
1828
+ /** The account that will transfer lamports to the created account */
1829
+ fromPubkey: PublicKey;
1830
+ /** Public key of the created account */
1831
+ newAccountPubkey: PublicKey;
1832
+ /** Base public key to use to derive the address of the created account */
1833
+ basePubkey: PublicKey;
1834
+ /** Seed to use to derive the address of the created account */
1835
+ seed: string;
1836
+ /** Amount of lamports to transfer to the created account */
1837
+ lamports: number;
1838
+ /** Amount of space in bytes to allocate to the created account */
1839
+ space: number;
1840
+ /** Public key of the program to assign as the owner of the created account */
1841
+ programId: PublicKey;
1842
+ };
1843
+ /**
1844
+ * Create nonce account system transaction params
1845
+ */
1846
+ export type CreateNonceAccountParams = {
1847
+ /** The account that will transfer lamports to the created nonce account */
1848
+ fromPubkey: PublicKey;
1849
+ /** Public key of the created nonce account */
1850
+ noncePubkey: PublicKey;
1851
+ /** Public key to set as authority of the created nonce account */
1852
+ authorizedPubkey: PublicKey;
1853
+ /** Amount of lamports to transfer to the created nonce account */
1854
+ lamports: number;
1855
+ };
1856
+ /**
1857
+ * Create nonce account with seed system transaction params
1858
+ */
1859
+ export type CreateNonceAccountWithSeedParams = {
1860
+ /** The account that will transfer lamports to the created nonce account */
1861
+ fromPubkey: PublicKey;
1862
+ /** Public key of the created nonce account */
1863
+ noncePubkey: PublicKey;
1864
+ /** Public key to set as authority of the created nonce account */
1865
+ authorizedPubkey: PublicKey;
1866
+ /** Amount of lamports to transfer to the created nonce account */
1867
+ lamports: number;
1868
+ /** Base public key to use to derive the address of the nonce account */
1869
+ basePubkey: PublicKey;
1870
+ /** Seed to use to derive the address of the nonce account */
1871
+ seed: string;
1872
+ };
1873
+ /**
1874
+ * Initialize nonce account system instruction params
1875
+ */
1876
+ export type InitializeNonceParams = {
1877
+ /** Nonce account which will be initialized */
1878
+ noncePubkey: PublicKey;
1879
+ /** Public key to set as authority of the initialized nonce account */
1880
+ authorizedPubkey: PublicKey;
1881
+ };
1882
+ /**
1883
+ * Advance nonce account system instruction params
1884
+ */
1885
+ export type AdvanceNonceParams = {
1886
+ /** Nonce account */
1887
+ noncePubkey: PublicKey;
1888
+ /** Public key of the nonce authority */
1889
+ authorizedPubkey: PublicKey;
1890
+ };
1891
+ /**
1892
+ * Withdraw nonce account system transaction params
1893
+ */
1894
+ export type WithdrawNonceParams = {
1895
+ /** Nonce account */
1896
+ noncePubkey: PublicKey;
1897
+ /** Public key of the nonce authority */
1898
+ authorizedPubkey: PublicKey;
1899
+ /** Public key of the account which will receive the withdrawn nonce account balance */
1900
+ toPubkey: PublicKey;
1901
+ /** Amount of lamports to withdraw from the nonce account */
1902
+ lamports: number;
1903
+ };
1904
+ /**
1905
+ * Authorize nonce account system transaction params
1906
+ */
1907
+ export type AuthorizeNonceParams = {
1908
+ /** Nonce account */
1909
+ noncePubkey: PublicKey;
1910
+ /** Public key of the current nonce authority */
1911
+ authorizedPubkey: PublicKey;
1912
+ /** Public key to set as the new nonce authority */
1913
+ newAuthorizedPubkey: PublicKey;
1914
+ };
1915
+ /**
1916
+ * Allocate account system transaction params
1917
+ */
1918
+ export type AllocateParams = {
1919
+ /** Account to allocate */
1920
+ accountPubkey: PublicKey;
1921
+ /** Amount of space in bytes to allocate */
1922
+ space: number;
1923
+ };
1924
+ /**
1925
+ * Allocate account with seed system transaction params
1926
+ */
1927
+ export type AllocateWithSeedParams = {
1928
+ /** Account to allocate */
1929
+ accountPubkey: PublicKey;
1930
+ /** Base public key to use to derive the address of the allocated account */
1931
+ basePubkey: PublicKey;
1932
+ /** Seed to use to derive the address of the allocated account */
1933
+ seed: string;
1934
+ /** Amount of space in bytes to allocate */
1935
+ space: number;
1936
+ /** Public key of the program to assign as the owner of the allocated account */
1937
+ programId: PublicKey;
1938
+ };
1939
+ /**
1940
+ * Assign account with seed system transaction params
1941
+ */
1942
+ export type AssignWithSeedParams = {
1943
+ /** Public key of the account which will be assigned a new owner */
1944
+ accountPubkey: PublicKey;
1945
+ /** Base public key to use to derive the address of the assigned account */
1946
+ basePubkey: PublicKey;
1947
+ /** Seed to use to derive the address of the assigned account */
1948
+ seed: string;
1949
+ /** Public key of the program to assign as the owner */
1950
+ programId: PublicKey;
1951
+ };
1952
+ /**
1953
+ * Transfer with seed system transaction params
1954
+ */
1955
+ export type TransferWithSeedParams = {
1956
+ /** Account that will transfer lamports */
1957
+ fromPubkey: PublicKey;
1958
+ /** Base public key to use to derive the funding account address */
1959
+ basePubkey: PublicKey;
1960
+ /** Account that will receive transferred lamports */
1961
+ toPubkey: PublicKey;
1962
+ /** Amount of lamports to transfer */
1963
+ lamports: number;
1964
+ /** Seed to use to derive the funding account address */
1965
+ seed: string;
1966
+ /** Program id to use to derive the funding account address */
1967
+ programId: PublicKey;
1968
+ };
1969
+ /**
1970
+ * System Instruction class
1971
+ */
1972
+ export class SystemInstruction {
1973
+ /**
1974
+ * Decode a system instruction and retrieve the instruction type.
1975
+ */
1976
+ static decodeInstructionType(
1977
+ instruction: TransactionInstruction,
1978
+ ): SystemInstructionType;
1979
+ /**
1980
+ * Decode a create account system instruction and retrieve the instruction params.
1981
+ */
1982
+ static decodeCreateAccount(
1983
+ instruction: TransactionInstruction,
1984
+ ): CreateAccountParams;
1985
+ /**
1986
+ * Decode a transfer system instruction and retrieve the instruction params.
1987
+ */
1988
+ static decodeTransfer(instruction: TransactionInstruction): TransferParams;
1989
+ /**
1990
+ * Decode a transfer with seed system instruction and retrieve the instruction params.
1991
+ */
1992
+ static decodeTransferWithSeed(
1993
+ instruction: TransactionInstruction,
1994
+ ): TransferWithSeedParams;
1995
+ /**
1996
+ * Decode an allocate system instruction and retrieve the instruction params.
1997
+ */
1998
+ static decodeAllocate(instruction: TransactionInstruction): AllocateParams;
1999
+ /**
2000
+ * Decode an allocate with seed system instruction and retrieve the instruction params.
2001
+ */
2002
+ static decodeAllocateWithSeed(
2003
+ instruction: TransactionInstruction,
2004
+ ): AllocateWithSeedParams;
2005
+ /**
2006
+ * Decode an assign system instruction and retrieve the instruction params.
2007
+ */
2008
+ static decodeAssign(instruction: TransactionInstruction): AssignParams;
2009
+ /**
2010
+ * Decode an assign with seed system instruction and retrieve the instruction params.
2011
+ */
2012
+ static decodeAssignWithSeed(
2013
+ instruction: TransactionInstruction,
2014
+ ): AssignWithSeedParams;
2015
+ /**
2016
+ * Decode a create account with seed system instruction and retrieve the instruction params.
2017
+ */
2018
+ static decodeCreateWithSeed(
2019
+ instruction: TransactionInstruction,
2020
+ ): CreateAccountWithSeedParams;
2021
+ /**
2022
+ * Decode a nonce initialize system instruction and retrieve the instruction params.
2023
+ */
2024
+ static decodeNonceInitialize(
2025
+ instruction: TransactionInstruction,
2026
+ ): InitializeNonceParams;
2027
+ /**
2028
+ * Decode a nonce advance system instruction and retrieve the instruction params.
2029
+ */
2030
+ static decodeNonceAdvance(
2031
+ instruction: TransactionInstruction,
2032
+ ): AdvanceNonceParams;
2033
+ /**
2034
+ * Decode a nonce withdraw system instruction and retrieve the instruction params.
2035
+ */
2036
+ static decodeNonceWithdraw(
2037
+ instruction: TransactionInstruction,
2038
+ ): WithdrawNonceParams;
2039
+ /**
2040
+ * Decode a nonce authorize system instruction and retrieve the instruction params.
2041
+ */
2042
+ static decodeNonceAuthorize(
2043
+ instruction: TransactionInstruction,
2044
+ ): AuthorizeNonceParams;
2045
+ }
2046
+ /**
2047
+ * An enumeration of valid SystemInstructionType's
2048
+ */
2049
+ export type SystemInstructionType =
2050
+ | 'AdvanceNonceAccount'
2051
+ | 'Allocate'
2052
+ | 'AllocateWithSeed'
2053
+ | 'Assign'
2054
+ | 'AssignWithSeed'
2055
+ | 'AuthorizeNonceAccount'
2056
+ | 'Create'
2057
+ | 'CreateWithSeed'
2058
+ | 'InitializeNonceAccount'
2059
+ | 'Transfer'
2060
+ | 'TransferWithSeed'
2061
+ | 'WithdrawNonceAccount';
2062
+ /**
2063
+ * Factory class for transactions to interact with the System program
2064
+ */
2065
+ export class SystemProgram {
2066
+ /**
2067
+ * Public key that identifies the System program
2068
+ */
2069
+ static programId: PublicKey;
2070
+ /**
2071
+ * Generate a transaction instruction that creates a new account
2072
+ */
2073
+ static createAccount(params: CreateAccountParams): TransactionInstruction;
2074
+ /**
2075
+ * Generate a transaction instruction that transfers lamports from one account to another
2076
+ */
2077
+ static transfer(
2078
+ params: TransferParams | TransferWithSeedParams,
2079
+ ): TransactionInstruction;
2080
+ /**
2081
+ * Generate a transaction instruction that assigns an account to a program
2082
+ */
2083
+ static assign(
2084
+ params: AssignParams | AssignWithSeedParams,
2085
+ ): TransactionInstruction;
2086
+ /**
2087
+ * Generate a transaction instruction that creates a new account at
2088
+ * an address generated with `from`, a seed, and programId
2089
+ */
2090
+ static createAccountWithSeed(
2091
+ params: CreateAccountWithSeedParams,
2092
+ ): TransactionInstruction;
2093
+ /**
2094
+ * Generate a transaction that creates a new Nonce account
2095
+ */
2096
+ static createNonceAccount(
2097
+ params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams,
2098
+ ): Transaction;
2099
+ /**
2100
+ * Generate an instruction to initialize a Nonce account
2101
+ */
2102
+ static nonceInitialize(
2103
+ params: InitializeNonceParams,
2104
+ ): TransactionInstruction;
2105
+ /**
2106
+ * Generate an instruction to advance the nonce in a Nonce account
2107
+ */
2108
+ static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
2109
+ /**
2110
+ * Generate a transaction instruction that withdraws lamports from a Nonce account
2111
+ */
2112
+ static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction;
2113
+ /**
2114
+ * Generate a transaction instruction that authorizes a new PublicKey as the authority
2115
+ * on a Nonce account.
2116
+ */
2117
+ static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction;
2118
+ /**
2119
+ * Generate a transaction instruction that allocates space in an account without funding
2120
+ */
2121
+ static allocate(
2122
+ params: AllocateParams | AllocateWithSeedParams,
2123
+ ): TransactionInstruction;
2124
+ }
2125
+
2126
+ /**
2127
+ * Params for creating an secp256k1 instruction using a public key
2128
+ */
2129
+ export type CreateSecp256k1InstructionWithPublicKeyParams = {
2130
+ publicKey: Buffer | Uint8Array | Array<number>;
2131
+ message: Buffer | Uint8Array | Array<number>;
2132
+ signature: Buffer | Uint8Array | Array<number>;
2133
+ recoveryId: number;
2134
+ };
2135
+ /**
2136
+ * Params for creating an secp256k1 instruction using an Ethereum address
2137
+ */
2138
+ export type CreateSecp256k1InstructionWithEthAddressParams = {
2139
+ ethAddress: Buffer | Uint8Array | Array<number> | string;
2140
+ message: Buffer | Uint8Array | Array<number>;
2141
+ signature: Buffer | Uint8Array | Array<number>;
2142
+ recoveryId: number;
2143
+ };
2144
+ /**
2145
+ * Params for creating an secp256k1 instruction using a private key
2146
+ */
2147
+ export type CreateSecp256k1InstructionWithPrivateKeyParams = {
2148
+ privateKey: Buffer | Uint8Array | Array<number>;
2149
+ message: Buffer | Uint8Array | Array<number>;
2150
+ };
2151
+ export class Secp256k1Program {
2152
+ /**
2153
+ * Public key that identifies the secp256k1 program
2154
+ */
2155
+ static programId: PublicKey;
2156
+ /**
2157
+ * Construct an Ethereum address from a secp256k1 public key buffer.
2158
+ * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
2159
+ */
2160
+ static publicKeyToEthAddress(
2161
+ publicKey: Buffer | Uint8Array | Array<number>,
2162
+ ): Buffer;
2163
+ /**
2164
+ * Create an secp256k1 instruction with a public key. The public key
2165
+ * must be a buffer that is 64 bytes long.
2166
+ */
2167
+ static createInstructionWithPublicKey(
2168
+ params: CreateSecp256k1InstructionWithPublicKeyParams,
2169
+ ): TransactionInstruction;
2170
+ /**
2171
+ * Create an secp256k1 instruction with an Ethereum address. The address
2172
+ * must be a hex string or a buffer that is 20 bytes long.
2173
+ */
2174
+ static createInstructionWithEthAddress(
2175
+ params: CreateSecp256k1InstructionWithEthAddressParams,
2176
+ ): TransactionInstruction;
2177
+ /**
2178
+ * Create an secp256k1 instruction with a private key. The private key
2179
+ * must be a buffer that is 32 bytes long.
2180
+ */
2181
+ static createInstructionWithPrivateKey(
2182
+ params: CreateSecp256k1InstructionWithPrivateKeyParams,
2183
+ ): TransactionInstruction;
2184
+ }
2185
+
2186
+ export const VALIDATOR_INFO_KEY: PublicKey;
2187
+ /**
2188
+ * Info used to identity validators.
2189
+ */
2190
+ export type Info = {
2191
+ /** validator name */
2192
+ name: string;
2193
+ /** optional, validator website */
2194
+ website?: string;
2195
+ /** optional, extra information the validator chose to share */
2196
+ details?: string;
2197
+ /** optional, used to identify validators on keybase.io */
2198
+ keybaseUsername?: string;
2199
+ };
2200
+ /**
2201
+ * ValidatorInfo class
2202
+ */
2203
+ export class ValidatorInfo {
2204
+ /**
2205
+ * validator public key
2206
+ */
2207
+ key: PublicKey;
2208
+ /**
2209
+ * validator information
2210
+ */
2211
+ info: Info;
2212
+ /**
2213
+ * Construct a valid ValidatorInfo
2214
+ *
2215
+ * @param key validator public key
2216
+ * @param info validator information
2217
+ */
2218
+ constructor(key: PublicKey, info: Info);
2219
+ /**
2220
+ * Deserialize ValidatorInfo from the config account data. Exactly two config
2221
+ * keys are required in the data.
2222
+ *
2223
+ * @param buffer config account data
2224
+ * @return null if info was not found
2225
+ */
2226
+ static fromConfigData(
2227
+ buffer: Buffer | Uint8Array | Array<number>,
2228
+ ): ValidatorInfo | null;
2229
+ }
2230
+
2231
+ export const VOTE_PROGRAM_ID: PublicKey;
2232
+ export type Lockout = {
2233
+ slot: number;
2234
+ confirmationCount: number;
2235
+ };
2236
+ /**
2237
+ * History of how many credits earned by the end of each epoch
2238
+ */
2239
+ export type EpochCredits = {
2240
+ epoch: number;
2241
+ credits: number;
2242
+ prevCredits: number;
2243
+ };
2244
+ /**
2245
+ * VoteAccount class
2246
+ */
2247
+ export class VoteAccount {
2248
+ nodePubkey: PublicKey;
2249
+ authorizedVoterPubkey: PublicKey;
2250
+ authorizedWithdrawerPubkey: PublicKey;
2251
+ commission: number;
2252
+ votes: Array<Lockout>;
2253
+ rootSlot: number | null;
2254
+ epoch: number;
2255
+ credits: number;
2256
+ lastEpochCredits: number;
2257
+ epochCredits: Array<EpochCredits>;
2258
+ /**
2259
+ * Deserialize VoteAccount from the account data.
2260
+ *
2261
+ * @param buffer account data
2262
+ * @return VoteAccount
2263
+ */
2264
+ static fromAccountData(
2265
+ buffer: Buffer | Uint8Array | Array<number>,
2266
+ ): VoteAccount;
2267
+ }
2268
+
2269
+ export const SYSVAR_CLOCK_PUBKEY: PublicKey;
2270
+ export const SYSVAR_RECENT_BLOCKHASHES_PUBKEY: PublicKey;
2271
+ export const SYSVAR_RENT_PUBKEY: PublicKey;
2272
+ export const SYSVAR_REWARDS_PUBKEY: PublicKey;
2273
+ export const SYSVAR_STAKE_HISTORY_PUBKEY: PublicKey;
2274
+ export const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;
2275
+
2276
+ /**
2277
+ * Sign, send and confirm a transaction.
2278
+ *
2279
+ * If `commitment` option is not specified, defaults to 'max' commitment.
2280
+ *
2281
+ * @param {Connection} connection
2282
+ * @param {Transaction} transaction
2283
+ * @param {Array<Account>} signers
2284
+ * @param {ConfirmOptions} [options]
2285
+ * @returns {Promise<TransactionSignature>}
2286
+ */
2287
+ export function sendAndConfirmTransaction(
2288
+ connection: Connection,
2289
+ transaction: Transaction,
2290
+ signers: Array<Account>,
2291
+ options?: ConfirmOptions,
2292
+ ): Promise<TransactionSignature>;
2293
+
2294
+ /**
2295
+ * Send and confirm a raw transaction
2296
+ *
2297
+ * If `commitment` option is not specified, defaults to 'max' commitment.
2298
+ *
2299
+ * @param {Connection} connection
2300
+ * @param {Buffer} rawTransaction
2301
+ * @param {ConfirmOptions} [options]
2302
+ * @returns {Promise<TransactionSignature>}
2303
+ */
2304
+ export function sendAndConfirmRawTransaction(
2305
+ connection: Connection,
2306
+ rawTransaction: Buffer,
2307
+ options?: ConfirmOptions,
2308
+ ): Promise<TransactionSignature>;
2309
+
2310
+ export type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
2311
+ /**
2312
+ * Retrieves the RPC API URL for the specified cluster
2313
+ */
2314
+ export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string;
2315
+
2316
+ /**
2317
+ * There are 1-billion lamports in one SOL
2318
+ */
2319
+ export const LAMPORTS_PER_SOL = 1000000000;
2320
+ }