@solana/web3.js 1.77.3 → 2.0.0-development

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 (99) hide show
  1. package/README.md +56 -112
  2. package/dist/index.browser.cjs +158 -0
  3. package/dist/index.browser.cjs.map +1 -0
  4. package/dist/index.browser.js +137 -0
  5. package/dist/index.browser.js.map +1 -0
  6. package/dist/index.development.js +1044 -0
  7. package/dist/index.development.js.map +1 -0
  8. package/dist/index.native.js +139 -0
  9. package/dist/index.native.js.map +1 -0
  10. package/dist/index.node.cjs +158 -0
  11. package/dist/index.node.cjs.map +1 -0
  12. package/dist/index.node.js +139 -0
  13. package/dist/index.node.js.map +1 -0
  14. package/dist/index.production.min.js +25 -0
  15. package/dist/types/index.d.ts +5 -0
  16. package/dist/types/rpc-default-config.d.ts +3 -0
  17. package/dist/types/rpc-integer-overflow-error.d.ts +8 -0
  18. package/dist/types/rpc-request-coalescer.d.ts +5 -0
  19. package/dist/types/rpc-request-deduplication.d.ts +2 -0
  20. package/dist/types/rpc-transport.d.ts +4 -0
  21. package/dist/types/rpc.d.ts +5 -0
  22. package/package.json +86 -110
  23. package/lib/index.browser.cjs.js +0 -9534
  24. package/lib/index.browser.cjs.js.map +0 -1
  25. package/lib/index.browser.esm.js +0 -9432
  26. package/lib/index.browser.esm.js.map +0 -1
  27. package/lib/index.cjs.js +0 -12058
  28. package/lib/index.cjs.js.map +0 -1
  29. package/lib/index.d.ts +0 -3891
  30. package/lib/index.esm.js +0 -11949
  31. package/lib/index.esm.js.map +0 -1
  32. package/lib/index.iife.js +0 -25985
  33. package/lib/index.iife.js.map +0 -1
  34. package/lib/index.iife.min.js +0 -20
  35. package/lib/index.iife.min.js.map +0 -1
  36. package/lib/index.native.js +0 -9534
  37. package/lib/index.native.js.map +0 -1
  38. package/src/__forks__/browser/fetch-impl.ts +0 -4
  39. package/src/__forks__/browser/rpc-websocket-factory.ts +0 -1
  40. package/src/__forks__/react-native/fetch-impl.ts +0 -4
  41. package/src/__forks__/react-native/rpc-websocket-factory.ts +0 -1
  42. package/src/account-data.ts +0 -39
  43. package/src/account.ts +0 -55
  44. package/src/blockhash.ts +0 -4
  45. package/src/bpf-loader-deprecated.ts +0 -5
  46. package/src/bpf-loader.ts +0 -45
  47. package/src/connection.ts +0 -6756
  48. package/src/epoch-schedule.ts +0 -102
  49. package/src/errors.ts +0 -50
  50. package/src/fee-calculator.ts +0 -18
  51. package/src/fetch-impl.ts +0 -13
  52. package/src/index.ts +0 -24
  53. package/src/instruction.ts +0 -58
  54. package/src/keypair.ts +0 -93
  55. package/src/layout.ts +0 -188
  56. package/src/loader.ts +0 -267
  57. package/src/message/account-keys.ts +0 -79
  58. package/src/message/compiled-keys.ts +0 -165
  59. package/src/message/index.ts +0 -47
  60. package/src/message/legacy.ts +0 -326
  61. package/src/message/v0.ts +0 -496
  62. package/src/message/versioned.ts +0 -36
  63. package/src/nonce-account.ts +0 -82
  64. package/src/programs/address-lookup-table/index.ts +0 -435
  65. package/src/programs/address-lookup-table/state.ts +0 -84
  66. package/src/programs/compute-budget.ts +0 -281
  67. package/src/programs/ed25519.ts +0 -157
  68. package/src/programs/index.ts +0 -7
  69. package/src/programs/secp256k1.ts +0 -228
  70. package/src/programs/stake.ts +0 -935
  71. package/src/programs/system.ts +0 -1048
  72. package/src/programs/vote.ts +0 -543
  73. package/src/publickey.ts +0 -259
  74. package/src/rpc-websocket-factory.ts +0 -4
  75. package/src/rpc-websocket.ts +0 -79
  76. package/src/sysvar.ts +0 -37
  77. package/src/timing.ts +0 -23
  78. package/src/transaction/constants.ts +0 -12
  79. package/src/transaction/expiry-custom-errors.ts +0 -48
  80. package/src/transaction/index.ts +0 -5
  81. package/src/transaction/legacy.ts +0 -918
  82. package/src/transaction/message.ts +0 -140
  83. package/src/transaction/versioned.ts +0 -126
  84. package/src/utils/assert.ts +0 -8
  85. package/src/utils/bigint.ts +0 -43
  86. package/src/utils/borsh-schema.ts +0 -38
  87. package/src/utils/cluster.ts +0 -31
  88. package/src/utils/ed25519.ts +0 -43
  89. package/src/utils/index.ts +0 -5
  90. package/src/utils/makeWebsocketUrl.ts +0 -26
  91. package/src/utils/promise-timeout.ts +0 -14
  92. package/src/utils/secp256k1.ts +0 -11
  93. package/src/utils/send-and-confirm-raw-transaction.ts +0 -102
  94. package/src/utils/send-and-confirm-transaction.ts +0 -98
  95. package/src/utils/shortvec-encoding.ts +0 -28
  96. package/src/utils/sleep.ts +0 -4
  97. package/src/utils/to-buffer.ts +0 -11
  98. package/src/validator-info.ts +0 -104
  99. package/src/vote-account.ts +0 -236
package/lib/index.d.ts DELETED
@@ -1,3891 +0,0 @@
1
- /// <reference types="node" />
2
- declare module "@solana/web3.js" {
3
- import { Buffer } from 'buffer';
4
- import { Agent } from 'http';
5
- import { Agent as Agent$1 } from 'https';
6
- import * as nodeFetch from 'node-fetch';
7
-
8
- export class Struct {
9
- constructor(properties: any);
10
- encode(): Buffer;
11
- static decode(data: Buffer): any;
12
- static decodeUnchecked(data: Buffer): any;
13
- }
14
- export class Enum extends Struct {
15
- enum: string;
16
- constructor(properties: any);
17
- }
18
- export const SOLANA_SCHEMA: Map<Function, any>;
19
-
20
- /**
21
- * Maximum length of derived pubkey seed
22
- */
23
- export const MAX_SEED_LENGTH = 32;
24
- /**
25
- * Size of public key in bytes
26
- */
27
- export const PUBLIC_KEY_LENGTH = 32;
28
- /**
29
- * Value to be converted into public key
30
- */
31
- type PublicKeyInitData = number | string | Uint8Array | Array<number> | PublicKeyData;
32
- /**
33
- * JSON object representation of PublicKey class
34
- */
35
- type PublicKeyData = {};
36
- /**
37
- * A public key
38
- */
39
- export class PublicKey extends Struct {
40
- /**
41
- * Create a new PublicKey object
42
- * @param value ed25519 public key as buffer or base-58 encoded string
43
- */
44
- constructor(value: PublicKeyInitData);
45
- /**
46
- * Returns a unique PublicKey for tests and benchmarks using a counter
47
- */
48
- static unique(): PublicKey;
49
- /**
50
- * Default public key value. The base58-encoded string representation is all ones (as seen below)
51
- * The underlying BN number is 32 bytes that are all zeros
52
- */
53
- static default: PublicKey;
54
- /**
55
- * Checks if two publicKeys are equal
56
- */
57
- equals(publicKey: PublicKey): boolean;
58
- /**
59
- * Return the base-58 representation of the public key
60
- */
61
- toBase58(): string;
62
- toJSON(): string;
63
- /**
64
- * Return the byte array representation of the public key in big endian
65
- */
66
- toBytes(): Uint8Array;
67
- /**
68
- * Return the Buffer representation of the public key in big endian
69
- */
70
- toBuffer(): Buffer;
71
- get [Symbol.toStringTag](): string;
72
- /**
73
- * Return the base-58 representation of the public key
74
- */
75
- toString(): string;
76
- /**
77
- * Derive a public key from another key, a seed, and a program ID.
78
- * The program ID will also serve as the owner of the public key, giving
79
- * it permission to write data to the account.
80
- */
81
- static createWithSeed(fromPublicKey: PublicKey, seed: string, programId: PublicKey): Promise<PublicKey>;
82
- /**
83
- * Derive a program address from seeds and a program ID.
84
- */
85
- static createProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): PublicKey;
86
- /**
87
- * Async version of createProgramAddressSync
88
- * For backwards compatibility
89
- *
90
- * @deprecated Use {@link createProgramAddressSync} instead
91
- */
92
- static createProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<PublicKey>;
93
- /**
94
- * Find a valid program address
95
- *
96
- * Valid program addresses must fall off the ed25519 curve. This function
97
- * iterates a nonce until it finds one that when combined with the seeds
98
- * results in a valid program address.
99
- */
100
- static findProgramAddressSync(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): [PublicKey, number];
101
- /**
102
- * Async version of findProgramAddressSync
103
- * For backwards compatibility
104
- *
105
- * @deprecated Use {@link findProgramAddressSync} instead
106
- */
107
- static findProgramAddress(seeds: Array<Buffer | Uint8Array>, programId: PublicKey): Promise<[PublicKey, number]>;
108
- /**
109
- * Check that a pubkey is on the ed25519 curve.
110
- */
111
- static isOnCurve(pubkeyData: PublicKeyInitData): boolean;
112
- }
113
-
114
- /**
115
- * An account key pair (public and secret keys).
116
- *
117
- * @deprecated since v1.10.0, please use {@link Keypair} instead.
118
- */
119
- export class Account {
120
- /**
121
- * Create a new Account object
122
- *
123
- * If the secretKey parameter is not provided a new key pair is randomly
124
- * created for the account
125
- *
126
- * @param secretKey Secret key for the account
127
- */
128
- constructor(secretKey?: Uint8Array | Array<number>);
129
- /**
130
- * The public key for this account
131
- */
132
- get publicKey(): PublicKey;
133
- /**
134
- * The **unencrypted** secret key for this account. The first 32 bytes
135
- * is the private scalar and the last 32 bytes is the public key.
136
- * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
137
- */
138
- get secretKey(): Buffer;
139
- }
140
-
141
- /**
142
- * Blockhash as Base58 string.
143
- */
144
- type Blockhash = string;
145
-
146
- export const BPF_LOADER_DEPRECATED_PROGRAM_ID: PublicKey;
147
-
148
- /**
149
- * Epoch schedule
150
- * (see https://docs.solana.com/terminology#epoch)
151
- * Can be retrieved with the {@link Connection.getEpochSchedule} method
152
- */
153
- export class EpochSchedule {
154
- /** The maximum number of slots in each epoch */
155
- slotsPerEpoch: number;
156
- /** The number of slots before beginning of an epoch to calculate a leader schedule for that epoch */
157
- leaderScheduleSlotOffset: number;
158
- /** Indicates whether epochs start short and grow */
159
- warmup: boolean;
160
- /** The first epoch with `slotsPerEpoch` slots */
161
- firstNormalEpoch: number;
162
- /** The first slot of `firstNormalEpoch` */
163
- firstNormalSlot: number;
164
- constructor(slotsPerEpoch: number, leaderScheduleSlotOffset: number, warmup: boolean, firstNormalEpoch: number, firstNormalSlot: number);
165
- getEpoch(slot: number): number;
166
- getEpochAndSlotIndex(slot: number): [number, number];
167
- getFirstSlotInEpoch(epoch: number): number;
168
- getLastSlotInEpoch(epoch: number): number;
169
- getSlotsInEpoch(epoch: number): number;
170
- }
171
-
172
- export function export_default(input: nodeFetch.RequestInfo, init?: nodeFetch.RequestInit): Promise<nodeFetch.Response>;
173
-
174
- /**
175
- * Calculator for transaction fees.
176
- *
177
- * @deprecated Deprecated since Solana v1.8.0.
178
- */
179
- interface FeeCalculator {
180
- /** Cost in lamports to validate a signature. */
181
- lamportsPerSignature: number;
182
- }
183
-
184
- export const NONCE_ACCOUNT_LENGTH: number;
185
- /**
186
- * A durable nonce is a 32 byte value encoded as a base58 string.
187
- */
188
- type DurableNonce = string;
189
- /**
190
- * NonceAccount class
191
- */
192
- export class NonceAccount {
193
- authorizedPubkey: PublicKey;
194
- nonce: DurableNonce;
195
- feeCalculator: FeeCalculator;
196
- /**
197
- * Deserialize NonceAccount from the account data.
198
- *
199
- * @param buffer account data
200
- * @return NonceAccount
201
- */
202
- static fromAccountData(buffer: Buffer | Uint8Array | Array<number>): NonceAccount;
203
- }
204
-
205
- /**
206
- * A 64 byte secret key, the first 32 bytes of which is the
207
- * private scalar and the last 32 bytes is the public key.
208
- * Read more: https://blog.mozilla.org/warner/2011/11/29/ed25519-keys/
209
- */
210
- type Ed25519SecretKey = Uint8Array;
211
- /**
212
- * Ed25519 Keypair
213
- */
214
- interface Ed25519Keypair {
215
- publicKey: Uint8Array;
216
- secretKey: Ed25519SecretKey;
217
- }
218
-
219
- /**
220
- * Keypair signer interface
221
- */
222
- interface Signer {
223
- publicKey: PublicKey;
224
- secretKey: Uint8Array;
225
- }
226
- /**
227
- * An account keypair used for signing transactions.
228
- */
229
- export class Keypair {
230
- private _keypair;
231
- /**
232
- * Create a new keypair instance.
233
- * Generate random keypair if no {@link Ed25519Keypair} is provided.
234
- *
235
- * @param keypair ed25519 keypair
236
- */
237
- constructor(keypair?: Ed25519Keypair);
238
- /**
239
- * Generate a new random keypair
240
- */
241
- static generate(): Keypair;
242
- /**
243
- * Create a keypair from a raw secret key byte array.
244
- *
245
- * This method should only be used to recreate a keypair from a previously
246
- * generated secret key. Generating keypairs from a random seed should be done
247
- * with the {@link Keypair.fromSeed} method.
248
- *
249
- * @throws error if the provided secret key is invalid and validation is not skipped.
250
- *
251
- * @param secretKey secret key byte array
252
- * @param options: skip secret key validation
253
- */
254
- static fromSecretKey(secretKey: Uint8Array, options?: {
255
- skipValidation?: boolean;
256
- }): Keypair;
257
- /**
258
- * Generate a keypair from a 32 byte seed.
259
- *
260
- * @param seed seed byte array
261
- */
262
- static fromSeed(seed: Uint8Array): Keypair;
263
- /**
264
- * The public key for this keypair
265
- */
266
- get publicKey(): PublicKey;
267
- /**
268
- * The raw secret key for this keypair
269
- */
270
- get secretKey(): Uint8Array;
271
- }
272
-
273
- /**
274
- * Maximum over-the-wire size of a Transaction
275
- *
276
- * 1280 is IPv6 minimum MTU
277
- * 40 bytes is the size of the IPv6 header
278
- * 8 bytes is the size of the fragment header
279
- */
280
- export const PACKET_DATA_SIZE: number;
281
- export const VERSION_PREFIX_MASK = 127;
282
- export const SIGNATURE_LENGTH_IN_BYTES = 64;
283
-
284
- export class TransactionExpiredBlockheightExceededError extends Error {
285
- signature: string;
286
- constructor(signature: string);
287
- }
288
- export class TransactionExpiredTimeoutError extends Error {
289
- signature: string;
290
- constructor(signature: string, timeoutSeconds: number);
291
- }
292
- export class TransactionExpiredNonceInvalidError extends Error {
293
- signature: string;
294
- constructor(signature: string);
295
- }
296
-
297
- type AccountKeysFromLookups = LoadedAddresses;
298
- export class MessageAccountKeys {
299
- staticAccountKeys: Array<PublicKey>;
300
- accountKeysFromLookups?: AccountKeysFromLookups;
301
- constructor(staticAccountKeys: Array<PublicKey>, accountKeysFromLookups?: AccountKeysFromLookups);
302
- keySegments(): Array<Array<PublicKey>>;
303
- get(index: number): PublicKey | undefined;
304
- get length(): number;
305
- compileInstructions(instructions: Array<TransactionInstruction>): Array<MessageCompiledInstruction>;
306
- }
307
-
308
- /**
309
- * An instruction to execute by a program
310
- *
311
- * @property {number} programIdIndex
312
- * @property {number[]} accounts
313
- * @property {string} data
314
- */
315
- type CompiledInstruction = {
316
- /** Index into the transaction keys array indicating the program account that executes this instruction */
317
- programIdIndex: number;
318
- /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
319
- accounts: number[];
320
- /** The program input data encoded as base 58 */
321
- data: string;
322
- };
323
- /**
324
- * Message constructor arguments
325
- */
326
- type MessageArgs = {
327
- /** The message header, identifying signed and read-only `accountKeys` */
328
- header: MessageHeader;
329
- /** All the account keys used by this transaction */
330
- accountKeys: string[] | PublicKey[];
331
- /** The hash of a recent ledger block */
332
- recentBlockhash: Blockhash;
333
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
334
- instructions: CompiledInstruction[];
335
- };
336
- type CompileLegacyArgs = {
337
- payerKey: PublicKey;
338
- instructions: Array<TransactionInstruction>;
339
- recentBlockhash: Blockhash;
340
- };
341
- /**
342
- * List of instructions to be processed atomically
343
- */
344
- export class Message {
345
- header: MessageHeader;
346
- accountKeys: PublicKey[];
347
- recentBlockhash: Blockhash;
348
- instructions: CompiledInstruction[];
349
- private indexToProgramIds;
350
- constructor(args: MessageArgs);
351
- get version(): 'legacy';
352
- get staticAccountKeys(): Array<PublicKey>;
353
- get compiledInstructions(): Array<MessageCompiledInstruction>;
354
- get addressTableLookups(): Array<MessageAddressTableLookup>;
355
- getAccountKeys(): MessageAccountKeys;
356
- static compile(args: CompileLegacyArgs): Message;
357
- isAccountSigner(index: number): boolean;
358
- isAccountWritable(index: number): boolean;
359
- isProgramId(index: number): boolean;
360
- programIds(): PublicKey[];
361
- nonProgramIds(): PublicKey[];
362
- serialize(): Buffer;
363
- /**
364
- * Decode a compiled message into a Message object.
365
- */
366
- static from(buffer: Buffer | Uint8Array | Array<number>): Message;
367
- }
368
-
369
- type AddressLookupTableState = {
370
- deactivationSlot: bigint;
371
- lastExtendedSlot: number;
372
- lastExtendedSlotStartIndex: number;
373
- authority?: PublicKey;
374
- addresses: Array<PublicKey>;
375
- };
376
- type AddressLookupTableAccountArgs = {
377
- key: PublicKey;
378
- state: AddressLookupTableState;
379
- };
380
- export class AddressLookupTableAccount {
381
- key: PublicKey;
382
- state: AddressLookupTableState;
383
- constructor(args: AddressLookupTableAccountArgs);
384
- isActive(): boolean;
385
- static deserialize(accountData: Uint8Array): AddressLookupTableState;
386
- }
387
-
388
- type CreateLookupTableParams = {
389
- /** Account used to derive and control the new address lookup table. */
390
- authority: PublicKey;
391
- /** Account that will fund the new address lookup table. */
392
- payer: PublicKey;
393
- /** A recent slot must be used in the derivation path for each initialized table. */
394
- recentSlot: bigint | number;
395
- };
396
- type FreezeLookupTableParams = {
397
- /** Address lookup table account to freeze. */
398
- lookupTable: PublicKey;
399
- /** Account which is the current authority. */
400
- authority: PublicKey;
401
- };
402
- type ExtendLookupTableParams = {
403
- /** Address lookup table account to extend. */
404
- lookupTable: PublicKey;
405
- /** Account which is the current authority. */
406
- authority: PublicKey;
407
- /** Account that will fund the table reallocation.
408
- * Not required if the reallocation has already been funded. */
409
- payer?: PublicKey;
410
- /** List of Public Keys to be added to the lookup table. */
411
- addresses: Array<PublicKey>;
412
- };
413
- type DeactivateLookupTableParams = {
414
- /** Address lookup table account to deactivate. */
415
- lookupTable: PublicKey;
416
- /** Account which is the current authority. */
417
- authority: PublicKey;
418
- };
419
- type CloseLookupTableParams = {
420
- /** Address lookup table account to close. */
421
- lookupTable: PublicKey;
422
- /** Account which is the current authority. */
423
- authority: PublicKey;
424
- /** Recipient of closed account lamports. */
425
- recipient: PublicKey;
426
- };
427
- /**
428
- * An enumeration of valid LookupTableInstructionType's
429
- */
430
- type LookupTableInstructionType = 'CreateLookupTable' | 'ExtendLookupTable' | 'CloseLookupTable' | 'FreezeLookupTable' | 'DeactivateLookupTable';
431
- export class AddressLookupTableInstruction {
432
- static decodeInstructionType(instruction: TransactionInstruction): LookupTableInstructionType;
433
- static decodeCreateLookupTable(instruction: TransactionInstruction): CreateLookupTableParams;
434
- static decodeExtendLookupTable(instruction: TransactionInstruction): ExtendLookupTableParams;
435
- static decodeCloseLookupTable(instruction: TransactionInstruction): CloseLookupTableParams;
436
- static decodeFreezeLookupTable(instruction: TransactionInstruction): FreezeLookupTableParams;
437
- static decodeDeactivateLookupTable(instruction: TransactionInstruction): DeactivateLookupTableParams;
438
- }
439
- export class AddressLookupTableProgram {
440
- static programId: PublicKey;
441
- static createLookupTable(params: CreateLookupTableParams): [TransactionInstruction, PublicKey];
442
- static freezeLookupTable(params: FreezeLookupTableParams): TransactionInstruction;
443
- static extendLookupTable(params: ExtendLookupTableParams): TransactionInstruction;
444
- static deactivateLookupTable(params: DeactivateLookupTableParams): TransactionInstruction;
445
- static closeLookupTable(params: CloseLookupTableParams): TransactionInstruction;
446
- }
447
-
448
- /**
449
- * Compute Budget Instruction class
450
- */
451
- export class ComputeBudgetInstruction {
452
- /**
453
- * Decode a compute budget instruction and retrieve the instruction type.
454
- */
455
- static decodeInstructionType(instruction: TransactionInstruction): ComputeBudgetInstructionType;
456
- /**
457
- * Decode request units compute budget instruction and retrieve the instruction params.
458
- */
459
- static decodeRequestUnits(instruction: TransactionInstruction): RequestUnitsParams;
460
- /**
461
- * Decode request heap frame compute budget instruction and retrieve the instruction params.
462
- */
463
- static decodeRequestHeapFrame(instruction: TransactionInstruction): RequestHeapFrameParams;
464
- /**
465
- * Decode set compute unit limit compute budget instruction and retrieve the instruction params.
466
- */
467
- static decodeSetComputeUnitLimit(instruction: TransactionInstruction): SetComputeUnitLimitParams;
468
- /**
469
- * Decode set compute unit price compute budget instruction and retrieve the instruction params.
470
- */
471
- static decodeSetComputeUnitPrice(instruction: TransactionInstruction): SetComputeUnitPriceParams;
472
- }
473
- /**
474
- * An enumeration of valid ComputeBudgetInstructionType's
475
- */
476
- type ComputeBudgetInstructionType = 'RequestUnits' | 'RequestHeapFrame' | 'SetComputeUnitLimit' | 'SetComputeUnitPrice';
477
- /**
478
- * Request units instruction params
479
- */
480
- interface RequestUnitsParams {
481
- /** Units to request for transaction-wide compute */
482
- units: number;
483
- /** Prioritization fee lamports */
484
- additionalFee: number;
485
- }
486
- /**
487
- * Request heap frame instruction params
488
- */
489
- type RequestHeapFrameParams = {
490
- /** Requested transaction-wide program heap size in bytes. Must be multiple of 1024. Applies to each program, including CPIs. */
491
- bytes: number;
492
- };
493
- /**
494
- * Set compute unit limit instruction params
495
- */
496
- interface SetComputeUnitLimitParams {
497
- /** Transaction-wide compute unit limit */
498
- units: number;
499
- }
500
- /**
501
- * Set compute unit price instruction params
502
- */
503
- interface SetComputeUnitPriceParams {
504
- /** Transaction compute unit price used for prioritization fees */
505
- microLamports: number | bigint;
506
- }
507
- /**
508
- * Factory class for transaction instructions to interact with the Compute Budget program
509
- */
510
- export class ComputeBudgetProgram {
511
- /**
512
- * Public key that identifies the Compute Budget program
513
- */
514
- static programId: PublicKey;
515
- /**
516
- * @deprecated Instead, call {@link setComputeUnitLimit} and/or {@link setComputeUnitPrice}
517
- */
518
- static requestUnits(params: RequestUnitsParams): TransactionInstruction;
519
- static requestHeapFrame(params: RequestHeapFrameParams): TransactionInstruction;
520
- static setComputeUnitLimit(params: SetComputeUnitLimitParams): TransactionInstruction;
521
- static setComputeUnitPrice(params: SetComputeUnitPriceParams): TransactionInstruction;
522
- }
523
-
524
- /**
525
- * Params for creating an ed25519 instruction using a public key
526
- */
527
- type CreateEd25519InstructionWithPublicKeyParams = {
528
- publicKey: Uint8Array;
529
- message: Uint8Array;
530
- signature: Uint8Array;
531
- instructionIndex?: number;
532
- };
533
- /**
534
- * Params for creating an ed25519 instruction using a private key
535
- */
536
- type CreateEd25519InstructionWithPrivateKeyParams = {
537
- privateKey: Uint8Array;
538
- message: Uint8Array;
539
- instructionIndex?: number;
540
- };
541
- export class Ed25519Program {
542
- /**
543
- * Public key that identifies the ed25519 program
544
- */
545
- static programId: PublicKey;
546
- /**
547
- * Create an ed25519 instruction with a public key and signature. The
548
- * public key must be a buffer that is 32 bytes long, and the signature
549
- * must be a buffer of 64 bytes.
550
- */
551
- static createInstructionWithPublicKey(params: CreateEd25519InstructionWithPublicKeyParams): TransactionInstruction;
552
- /**
553
- * Create an ed25519 instruction with a private key. The private key
554
- * must be a buffer that is 64 bytes long.
555
- */
556
- static createInstructionWithPrivateKey(params: CreateEd25519InstructionWithPrivateKeyParams): TransactionInstruction;
557
- }
558
-
559
- /**
560
- * Params for creating an secp256k1 instruction using a public key
561
- */
562
- type CreateSecp256k1InstructionWithPublicKeyParams = {
563
- publicKey: Buffer | Uint8Array | Array<number>;
564
- message: Buffer | Uint8Array | Array<number>;
565
- signature: Buffer | Uint8Array | Array<number>;
566
- recoveryId: number;
567
- instructionIndex?: number;
568
- };
569
- /**
570
- * Params for creating an secp256k1 instruction using an Ethereum address
571
- */
572
- type CreateSecp256k1InstructionWithEthAddressParams = {
573
- ethAddress: Buffer | Uint8Array | Array<number> | string;
574
- message: Buffer | Uint8Array | Array<number>;
575
- signature: Buffer | Uint8Array | Array<number>;
576
- recoveryId: number;
577
- instructionIndex?: number;
578
- };
579
- /**
580
- * Params for creating an secp256k1 instruction using a private key
581
- */
582
- type CreateSecp256k1InstructionWithPrivateKeyParams = {
583
- privateKey: Buffer | Uint8Array | Array<number>;
584
- message: Buffer | Uint8Array | Array<number>;
585
- instructionIndex?: number;
586
- };
587
- export class Secp256k1Program {
588
- /**
589
- * Public key that identifies the secp256k1 program
590
- */
591
- static programId: PublicKey;
592
- /**
593
- * Construct an Ethereum address from a secp256k1 public key buffer.
594
- * @param {Buffer} publicKey a 64 byte secp256k1 public key buffer
595
- */
596
- static publicKeyToEthAddress(publicKey: Buffer | Uint8Array | Array<number>): Buffer;
597
- /**
598
- * Create an secp256k1 instruction with a public key. The public key
599
- * must be a buffer that is 64 bytes long.
600
- */
601
- static createInstructionWithPublicKey(params: CreateSecp256k1InstructionWithPublicKeyParams): TransactionInstruction;
602
- /**
603
- * Create an secp256k1 instruction with an Ethereum address. The address
604
- * must be a hex string or a buffer that is 20 bytes long.
605
- */
606
- static createInstructionWithEthAddress(params: CreateSecp256k1InstructionWithEthAddressParams): TransactionInstruction;
607
- /**
608
- * Create an secp256k1 instruction with a private key. The private key
609
- * must be a buffer that is 32 bytes long.
610
- */
611
- static createInstructionWithPrivateKey(params: CreateSecp256k1InstructionWithPrivateKeyParams): TransactionInstruction;
612
- }
613
-
614
- /**
615
- * Address of the stake config account which configures the rate
616
- * of stake warmup and cooldown as well as the slashing penalty.
617
- */
618
- export const STAKE_CONFIG_ID: PublicKey;
619
- /**
620
- * Stake account authority info
621
- */
622
- export class Authorized {
623
- /** stake authority */
624
- staker: PublicKey;
625
- /** withdraw authority */
626
- withdrawer: PublicKey;
627
- /**
628
- * Create a new Authorized object
629
- * @param staker the stake authority
630
- * @param withdrawer the withdraw authority
631
- */
632
- constructor(staker: PublicKey, withdrawer: PublicKey);
633
- }
634
- /**
635
- * Stake account lockup info
636
- */
637
- export class Lockup {
638
- /** Unix timestamp of lockup expiration */
639
- unixTimestamp: number;
640
- /** Epoch of lockup expiration */
641
- epoch: number;
642
- /** Lockup custodian authority */
643
- custodian: PublicKey;
644
- /**
645
- * Create a new Lockup object
646
- */
647
- constructor(unixTimestamp: number, epoch: number, custodian: PublicKey);
648
- /**
649
- * Default, inactive Lockup value
650
- */
651
- static default: Lockup;
652
- }
653
- /**
654
- * Create stake account transaction params
655
- */
656
- type CreateStakeAccountParams = {
657
- /** Address of the account which will fund creation */
658
- fromPubkey: PublicKey;
659
- /** Address of the new stake account */
660
- stakePubkey: PublicKey;
661
- /** Authorities of the new stake account */
662
- authorized: Authorized;
663
- /** Lockup of the new stake account */
664
- lockup?: Lockup;
665
- /** Funding amount */
666
- lamports: number;
667
- };
668
- /**
669
- * Create stake account with seed transaction params
670
- */
671
- type CreateStakeAccountWithSeedParams = {
672
- fromPubkey: PublicKey;
673
- stakePubkey: PublicKey;
674
- basePubkey: PublicKey;
675
- seed: string;
676
- authorized: Authorized;
677
- lockup?: Lockup;
678
- lamports: number;
679
- };
680
- /**
681
- * Initialize stake instruction params
682
- */
683
- type InitializeStakeParams = {
684
- stakePubkey: PublicKey;
685
- authorized: Authorized;
686
- lockup?: Lockup;
687
- };
688
- /**
689
- * Delegate stake instruction params
690
- */
691
- type DelegateStakeParams = {
692
- stakePubkey: PublicKey;
693
- authorizedPubkey: PublicKey;
694
- votePubkey: PublicKey;
695
- };
696
- /**
697
- * Authorize stake instruction params
698
- */
699
- type AuthorizeStakeParams = {
700
- stakePubkey: PublicKey;
701
- authorizedPubkey: PublicKey;
702
- newAuthorizedPubkey: PublicKey;
703
- stakeAuthorizationType: StakeAuthorizationType;
704
- custodianPubkey?: PublicKey;
705
- };
706
- /**
707
- * Authorize stake instruction params using a derived key
708
- */
709
- type AuthorizeWithSeedStakeParams = {
710
- stakePubkey: PublicKey;
711
- authorityBase: PublicKey;
712
- authoritySeed: string;
713
- authorityOwner: PublicKey;
714
- newAuthorizedPubkey: PublicKey;
715
- stakeAuthorizationType: StakeAuthorizationType;
716
- custodianPubkey?: PublicKey;
717
- };
718
- /**
719
- * Split stake instruction params
720
- */
721
- type SplitStakeParams = {
722
- stakePubkey: PublicKey;
723
- authorizedPubkey: PublicKey;
724
- splitStakePubkey: PublicKey;
725
- lamports: number;
726
- };
727
- /**
728
- * Split with seed transaction params
729
- */
730
- type SplitStakeWithSeedParams = {
731
- stakePubkey: PublicKey;
732
- authorizedPubkey: PublicKey;
733
- splitStakePubkey: PublicKey;
734
- basePubkey: PublicKey;
735
- seed: string;
736
- lamports: number;
737
- };
738
- /**
739
- * Withdraw stake instruction params
740
- */
741
- type WithdrawStakeParams = {
742
- stakePubkey: PublicKey;
743
- authorizedPubkey: PublicKey;
744
- toPubkey: PublicKey;
745
- lamports: number;
746
- custodianPubkey?: PublicKey;
747
- };
748
- /**
749
- * Deactivate stake instruction params
750
- */
751
- type DeactivateStakeParams = {
752
- stakePubkey: PublicKey;
753
- authorizedPubkey: PublicKey;
754
- };
755
- /**
756
- * Merge stake instruction params
757
- */
758
- type MergeStakeParams = {
759
- stakePubkey: PublicKey;
760
- sourceStakePubKey: PublicKey;
761
- authorizedPubkey: PublicKey;
762
- };
763
- /**
764
- * Stake Instruction class
765
- */
766
- export class StakeInstruction {
767
- /**
768
- * Decode a stake instruction and retrieve the instruction type.
769
- */
770
- static decodeInstructionType(instruction: TransactionInstruction): StakeInstructionType;
771
- /**
772
- * Decode a initialize stake instruction and retrieve the instruction params.
773
- */
774
- static decodeInitialize(instruction: TransactionInstruction): InitializeStakeParams;
775
- /**
776
- * Decode a delegate stake instruction and retrieve the instruction params.
777
- */
778
- static decodeDelegate(instruction: TransactionInstruction): DelegateStakeParams;
779
- /**
780
- * Decode an authorize stake instruction and retrieve the instruction params.
781
- */
782
- static decodeAuthorize(instruction: TransactionInstruction): AuthorizeStakeParams;
783
- /**
784
- * Decode an authorize-with-seed stake instruction and retrieve the instruction params.
785
- */
786
- static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeWithSeedStakeParams;
787
- /**
788
- * Decode a split stake instruction and retrieve the instruction params.
789
- */
790
- static decodeSplit(instruction: TransactionInstruction): SplitStakeParams;
791
- /**
792
- * Decode a merge stake instruction and retrieve the instruction params.
793
- */
794
- static decodeMerge(instruction: TransactionInstruction): MergeStakeParams;
795
- /**
796
- * Decode a withdraw stake instruction and retrieve the instruction params.
797
- */
798
- static decodeWithdraw(instruction: TransactionInstruction): WithdrawStakeParams;
799
- /**
800
- * Decode a deactivate stake instruction and retrieve the instruction params.
801
- */
802
- static decodeDeactivate(instruction: TransactionInstruction): DeactivateStakeParams;
803
- }
804
- /**
805
- * An enumeration of valid StakeInstructionType's
806
- */
807
- type StakeInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'Deactivate' | 'Delegate' | 'Initialize' | 'Merge' | 'Split' | 'Withdraw';
808
- /**
809
- * Stake authorization type
810
- */
811
- type StakeAuthorizationType = {
812
- /** The Stake Authorization index (from solana-stake-program) */
813
- index: number;
814
- };
815
- /**
816
- * An enumeration of valid StakeAuthorizationLayout's
817
- */
818
- export const StakeAuthorizationLayout: Readonly<{
819
- Staker: {
820
- index: number;
821
- };
822
- Withdrawer: {
823
- index: number;
824
- };
825
- }>;
826
- /**
827
- * Factory class for transactions to interact with the Stake program
828
- */
829
- export class StakeProgram {
830
- /**
831
- * Public key that identifies the Stake program
832
- */
833
- static programId: PublicKey;
834
- /**
835
- * Max space of a Stake account
836
- *
837
- * This is generated from the solana-stake-program StakeState struct as
838
- * `StakeState::size_of()`:
839
- * https://docs.rs/solana-stake-program/latest/solana_stake_program/stake_state/enum.StakeState.html
840
- */
841
- static space: number;
842
- /**
843
- * Generate an Initialize instruction to add to a Stake Create transaction
844
- */
845
- static initialize(params: InitializeStakeParams): TransactionInstruction;
846
- /**
847
- * Generate a Transaction that creates a new Stake account at
848
- * an address generated with `from`, a seed, and the Stake programId
849
- */
850
- static createAccountWithSeed(params: CreateStakeAccountWithSeedParams): Transaction;
851
- /**
852
- * Generate a Transaction that creates a new Stake account
853
- */
854
- static createAccount(params: CreateStakeAccountParams): Transaction;
855
- /**
856
- * Generate a Transaction that delegates Stake tokens to a validator
857
- * Vote PublicKey. This transaction can also be used to redelegate Stake
858
- * to a new validator Vote PublicKey.
859
- */
860
- static delegate(params: DelegateStakeParams): Transaction;
861
- /**
862
- * Generate a Transaction that authorizes a new PublicKey as Staker
863
- * or Withdrawer on the Stake account.
864
- */
865
- static authorize(params: AuthorizeStakeParams): Transaction;
866
- /**
867
- * Generate a Transaction that authorizes a new PublicKey as Staker
868
- * or Withdrawer on the Stake account.
869
- */
870
- static authorizeWithSeed(params: AuthorizeWithSeedStakeParams): Transaction;
871
- /**
872
- * Generate a Transaction that splits Stake tokens into another stake account
873
- */
874
- static split(params: SplitStakeParams): Transaction;
875
- /**
876
- * Generate a Transaction that splits Stake tokens into another account
877
- * derived from a base public key and seed
878
- */
879
- static splitWithSeed(params: SplitStakeWithSeedParams): Transaction;
880
- /**
881
- * Generate a Transaction that merges Stake accounts.
882
- */
883
- static merge(params: MergeStakeParams): Transaction;
884
- /**
885
- * Generate a Transaction that withdraws deactivated Stake tokens.
886
- */
887
- static withdraw(params: WithdrawStakeParams): Transaction;
888
- /**
889
- * Generate a Transaction that deactivates Stake tokens.
890
- */
891
- static deactivate(params: DeactivateStakeParams): Transaction;
892
- }
893
-
894
- /**
895
- * Create account system transaction params
896
- */
897
- type CreateAccountParams = {
898
- /** The account that will transfer lamports to the created account */
899
- fromPubkey: PublicKey;
900
- /** Public key of the created account */
901
- newAccountPubkey: PublicKey;
902
- /** Amount of lamports to transfer to the created account */
903
- lamports: number;
904
- /** Amount of space in bytes to allocate to the created account */
905
- space: number;
906
- /** Public key of the program to assign as the owner of the created account */
907
- programId: PublicKey;
908
- };
909
- /**
910
- * Transfer system transaction params
911
- */
912
- type TransferParams = {
913
- /** Account that will transfer lamports */
914
- fromPubkey: PublicKey;
915
- /** Account that will receive transferred lamports */
916
- toPubkey: PublicKey;
917
- /** Amount of lamports to transfer */
918
- lamports: number | bigint;
919
- };
920
- /**
921
- * Assign system transaction params
922
- */
923
- type AssignParams = {
924
- /** Public key of the account which will be assigned a new owner */
925
- accountPubkey: PublicKey;
926
- /** Public key of the program to assign as the owner */
927
- programId: PublicKey;
928
- };
929
- /**
930
- * Create account with seed system transaction params
931
- */
932
- type CreateAccountWithSeedParams = {
933
- /** The account that will transfer lamports to the created account */
934
- fromPubkey: PublicKey;
935
- /** Public key of the created account. Must be pre-calculated with PublicKey.createWithSeed() */
936
- newAccountPubkey: PublicKey;
937
- /** Base public key to use to derive the address of the created account. Must be the same as the base key used to create `newAccountPubkey` */
938
- basePubkey: PublicKey;
939
- /** Seed to use to derive the address of the created account. Must be the same as the seed used to create `newAccountPubkey` */
940
- seed: string;
941
- /** Amount of lamports to transfer to the created account */
942
- lamports: number;
943
- /** Amount of space in bytes to allocate to the created account */
944
- space: number;
945
- /** Public key of the program to assign as the owner of the created account */
946
- programId: PublicKey;
947
- };
948
- /**
949
- * Create nonce account system transaction params
950
- */
951
- type CreateNonceAccountParams = {
952
- /** The account that will transfer lamports to the created nonce account */
953
- fromPubkey: PublicKey;
954
- /** Public key of the created nonce account */
955
- noncePubkey: PublicKey;
956
- /** Public key to set as authority of the created nonce account */
957
- authorizedPubkey: PublicKey;
958
- /** Amount of lamports to transfer to the created nonce account */
959
- lamports: number;
960
- };
961
- /**
962
- * Create nonce account with seed system transaction params
963
- */
964
- type CreateNonceAccountWithSeedParams = {
965
- /** The account that will transfer lamports to the created nonce account */
966
- fromPubkey: PublicKey;
967
- /** Public key of the created nonce account */
968
- noncePubkey: PublicKey;
969
- /** Public key to set as authority of the created nonce account */
970
- authorizedPubkey: PublicKey;
971
- /** Amount of lamports to transfer to the created nonce account */
972
- lamports: number;
973
- /** Base public key to use to derive the address of the nonce account */
974
- basePubkey: PublicKey;
975
- /** Seed to use to derive the address of the nonce account */
976
- seed: string;
977
- };
978
- /**
979
- * Initialize nonce account system instruction params
980
- */
981
- type InitializeNonceParams = {
982
- /** Nonce account which will be initialized */
983
- noncePubkey: PublicKey;
984
- /** Public key to set as authority of the initialized nonce account */
985
- authorizedPubkey: PublicKey;
986
- };
987
- /**
988
- * Advance nonce account system instruction params
989
- */
990
- type AdvanceNonceParams = {
991
- /** Nonce account */
992
- noncePubkey: PublicKey;
993
- /** Public key of the nonce authority */
994
- authorizedPubkey: PublicKey;
995
- };
996
- /**
997
- * Withdraw nonce account system transaction params
998
- */
999
- type WithdrawNonceParams = {
1000
- /** Nonce account */
1001
- noncePubkey: PublicKey;
1002
- /** Public key of the nonce authority */
1003
- authorizedPubkey: PublicKey;
1004
- /** Public key of the account which will receive the withdrawn nonce account balance */
1005
- toPubkey: PublicKey;
1006
- /** Amount of lamports to withdraw from the nonce account */
1007
- lamports: number;
1008
- };
1009
- /**
1010
- * Authorize nonce account system transaction params
1011
- */
1012
- type AuthorizeNonceParams = {
1013
- /** Nonce account */
1014
- noncePubkey: PublicKey;
1015
- /** Public key of the current nonce authority */
1016
- authorizedPubkey: PublicKey;
1017
- /** Public key to set as the new nonce authority */
1018
- newAuthorizedPubkey: PublicKey;
1019
- };
1020
- /**
1021
- * Allocate account system transaction params
1022
- */
1023
- type AllocateParams = {
1024
- /** Account to allocate */
1025
- accountPubkey: PublicKey;
1026
- /** Amount of space in bytes to allocate */
1027
- space: number;
1028
- };
1029
- /**
1030
- * Allocate account with seed system transaction params
1031
- */
1032
- type AllocateWithSeedParams = {
1033
- /** Account to allocate */
1034
- accountPubkey: PublicKey;
1035
- /** Base public key to use to derive the address of the allocated account */
1036
- basePubkey: PublicKey;
1037
- /** Seed to use to derive the address of the allocated account */
1038
- seed: string;
1039
- /** Amount of space in bytes to allocate */
1040
- space: number;
1041
- /** Public key of the program to assign as the owner of the allocated account */
1042
- programId: PublicKey;
1043
- };
1044
- /**
1045
- * Assign account with seed system transaction params
1046
- */
1047
- type AssignWithSeedParams = {
1048
- /** Public key of the account which will be assigned a new owner */
1049
- accountPubkey: PublicKey;
1050
- /** Base public key to use to derive the address of the assigned account */
1051
- basePubkey: PublicKey;
1052
- /** Seed to use to derive the address of the assigned account */
1053
- seed: string;
1054
- /** Public key of the program to assign as the owner */
1055
- programId: PublicKey;
1056
- };
1057
- /**
1058
- * Transfer with seed system transaction params
1059
- */
1060
- type TransferWithSeedParams = {
1061
- /** Account that will transfer lamports */
1062
- fromPubkey: PublicKey;
1063
- /** Base public key to use to derive the funding account address */
1064
- basePubkey: PublicKey;
1065
- /** Account that will receive transferred lamports */
1066
- toPubkey: PublicKey;
1067
- /** Amount of lamports to transfer */
1068
- lamports: number | bigint;
1069
- /** Seed to use to derive the funding account address */
1070
- seed: string;
1071
- /** Program id to use to derive the funding account address */
1072
- programId: PublicKey;
1073
- };
1074
- /** Decoded transfer system transaction instruction */
1075
- type DecodedTransferInstruction = {
1076
- /** Account that will transfer lamports */
1077
- fromPubkey: PublicKey;
1078
- /** Account that will receive transferred lamports */
1079
- toPubkey: PublicKey;
1080
- /** Amount of lamports to transfer */
1081
- lamports: bigint;
1082
- };
1083
- /** Decoded transferWithSeed system transaction instruction */
1084
- type DecodedTransferWithSeedInstruction = {
1085
- /** Account that will transfer lamports */
1086
- fromPubkey: PublicKey;
1087
- /** Base public key to use to derive the funding account address */
1088
- basePubkey: PublicKey;
1089
- /** Account that will receive transferred lamports */
1090
- toPubkey: PublicKey;
1091
- /** Amount of lamports to transfer */
1092
- lamports: bigint;
1093
- /** Seed to use to derive the funding account address */
1094
- seed: string;
1095
- /** Program id to use to derive the funding account address */
1096
- programId: PublicKey;
1097
- };
1098
- /**
1099
- * System Instruction class
1100
- */
1101
- export class SystemInstruction {
1102
- /**
1103
- * Decode a system instruction and retrieve the instruction type.
1104
- */
1105
- static decodeInstructionType(instruction: TransactionInstruction): SystemInstructionType;
1106
- /**
1107
- * Decode a create account system instruction and retrieve the instruction params.
1108
- */
1109
- static decodeCreateAccount(instruction: TransactionInstruction): CreateAccountParams;
1110
- /**
1111
- * Decode a transfer system instruction and retrieve the instruction params.
1112
- */
1113
- static decodeTransfer(instruction: TransactionInstruction): DecodedTransferInstruction;
1114
- /**
1115
- * Decode a transfer with seed system instruction and retrieve the instruction params.
1116
- */
1117
- static decodeTransferWithSeed(instruction: TransactionInstruction): DecodedTransferWithSeedInstruction;
1118
- /**
1119
- * Decode an allocate system instruction and retrieve the instruction params.
1120
- */
1121
- static decodeAllocate(instruction: TransactionInstruction): AllocateParams;
1122
- /**
1123
- * Decode an allocate with seed system instruction and retrieve the instruction params.
1124
- */
1125
- static decodeAllocateWithSeed(instruction: TransactionInstruction): AllocateWithSeedParams;
1126
- /**
1127
- * Decode an assign system instruction and retrieve the instruction params.
1128
- */
1129
- static decodeAssign(instruction: TransactionInstruction): AssignParams;
1130
- /**
1131
- * Decode an assign with seed system instruction and retrieve the instruction params.
1132
- */
1133
- static decodeAssignWithSeed(instruction: TransactionInstruction): AssignWithSeedParams;
1134
- /**
1135
- * Decode a create account with seed system instruction and retrieve the instruction params.
1136
- */
1137
- static decodeCreateWithSeed(instruction: TransactionInstruction): CreateAccountWithSeedParams;
1138
- /**
1139
- * Decode a nonce initialize system instruction and retrieve the instruction params.
1140
- */
1141
- static decodeNonceInitialize(instruction: TransactionInstruction): InitializeNonceParams;
1142
- /**
1143
- * Decode a nonce advance system instruction and retrieve the instruction params.
1144
- */
1145
- static decodeNonceAdvance(instruction: TransactionInstruction): AdvanceNonceParams;
1146
- /**
1147
- * Decode a nonce withdraw system instruction and retrieve the instruction params.
1148
- */
1149
- static decodeNonceWithdraw(instruction: TransactionInstruction): WithdrawNonceParams;
1150
- /**
1151
- * Decode a nonce authorize system instruction and retrieve the instruction params.
1152
- */
1153
- static decodeNonceAuthorize(instruction: TransactionInstruction): AuthorizeNonceParams;
1154
- }
1155
- /**
1156
- * An enumeration of valid SystemInstructionType's
1157
- */
1158
- type SystemInstructionType = 'AdvanceNonceAccount' | 'Allocate' | 'AllocateWithSeed' | 'Assign' | 'AssignWithSeed' | 'AuthorizeNonceAccount' | 'Create' | 'CreateWithSeed' | 'InitializeNonceAccount' | 'Transfer' | 'TransferWithSeed' | 'WithdrawNonceAccount' | 'UpgradeNonceAccount';
1159
- /**
1160
- * Factory class for transactions to interact with the System program
1161
- */
1162
- export class SystemProgram {
1163
- /**
1164
- * Public key that identifies the System program
1165
- */
1166
- static programId: PublicKey;
1167
- /**
1168
- * Generate a transaction instruction that creates a new account
1169
- */
1170
- static createAccount(params: CreateAccountParams): TransactionInstruction;
1171
- /**
1172
- * Generate a transaction instruction that transfers lamports from one account to another
1173
- */
1174
- static transfer(params: TransferParams | TransferWithSeedParams): TransactionInstruction;
1175
- /**
1176
- * Generate a transaction instruction that assigns an account to a program
1177
- */
1178
- static assign(params: AssignParams | AssignWithSeedParams): TransactionInstruction;
1179
- /**
1180
- * Generate a transaction instruction that creates a new account at
1181
- * an address generated with `from`, a seed, and programId
1182
- */
1183
- static createAccountWithSeed(params: CreateAccountWithSeedParams): TransactionInstruction;
1184
- /**
1185
- * Generate a transaction that creates a new Nonce account
1186
- */
1187
- static createNonceAccount(params: CreateNonceAccountParams | CreateNonceAccountWithSeedParams): Transaction;
1188
- /**
1189
- * Generate an instruction to initialize a Nonce account
1190
- */
1191
- static nonceInitialize(params: InitializeNonceParams): TransactionInstruction;
1192
- /**
1193
- * Generate an instruction to advance the nonce in a Nonce account
1194
- */
1195
- static nonceAdvance(params: AdvanceNonceParams): TransactionInstruction;
1196
- /**
1197
- * Generate a transaction instruction that withdraws lamports from a Nonce account
1198
- */
1199
- static nonceWithdraw(params: WithdrawNonceParams): TransactionInstruction;
1200
- /**
1201
- * Generate a transaction instruction that authorizes a new PublicKey as the authority
1202
- * on a Nonce account.
1203
- */
1204
- static nonceAuthorize(params: AuthorizeNonceParams): TransactionInstruction;
1205
- /**
1206
- * Generate a transaction instruction that allocates space in an account without funding
1207
- */
1208
- static allocate(params: AllocateParams | AllocateWithSeedParams): TransactionInstruction;
1209
- }
1210
-
1211
- /**
1212
- * Vote account info
1213
- */
1214
- export class VoteInit {
1215
- nodePubkey: PublicKey;
1216
- authorizedVoter: PublicKey;
1217
- authorizedWithdrawer: PublicKey;
1218
- commission: number; /** [0, 100] */
1219
- constructor(nodePubkey: PublicKey, authorizedVoter: PublicKey, authorizedWithdrawer: PublicKey, commission: number);
1220
- }
1221
- /**
1222
- * Create vote account transaction params
1223
- */
1224
- type CreateVoteAccountParams = {
1225
- fromPubkey: PublicKey;
1226
- votePubkey: PublicKey;
1227
- voteInit: VoteInit;
1228
- lamports: number;
1229
- };
1230
- /**
1231
- * InitializeAccount instruction params
1232
- */
1233
- type InitializeAccountParams = {
1234
- votePubkey: PublicKey;
1235
- nodePubkey: PublicKey;
1236
- voteInit: VoteInit;
1237
- };
1238
- /**
1239
- * Authorize instruction params
1240
- */
1241
- type AuthorizeVoteParams = {
1242
- votePubkey: PublicKey;
1243
- /** Current vote or withdraw authority, depending on `voteAuthorizationType` */
1244
- authorizedPubkey: PublicKey;
1245
- newAuthorizedPubkey: PublicKey;
1246
- voteAuthorizationType: VoteAuthorizationType;
1247
- };
1248
- /**
1249
- * AuthorizeWithSeed instruction params
1250
- */
1251
- type AuthorizeVoteWithSeedParams = {
1252
- currentAuthorityDerivedKeyBasePubkey: PublicKey;
1253
- currentAuthorityDerivedKeyOwnerPubkey: PublicKey;
1254
- currentAuthorityDerivedKeySeed: string;
1255
- newAuthorizedPubkey: PublicKey;
1256
- voteAuthorizationType: VoteAuthorizationType;
1257
- votePubkey: PublicKey;
1258
- };
1259
- /**
1260
- * Withdraw from vote account transaction params
1261
- */
1262
- type WithdrawFromVoteAccountParams = {
1263
- votePubkey: PublicKey;
1264
- authorizedWithdrawerPubkey: PublicKey;
1265
- lamports: number;
1266
- toPubkey: PublicKey;
1267
- };
1268
- /**
1269
- * Vote Instruction class
1270
- */
1271
- export class VoteInstruction {
1272
- /**
1273
- * Decode a vote instruction and retrieve the instruction type.
1274
- */
1275
- static decodeInstructionType(instruction: TransactionInstruction): VoteInstructionType;
1276
- /**
1277
- * Decode an initialize vote instruction and retrieve the instruction params.
1278
- */
1279
- static decodeInitializeAccount(instruction: TransactionInstruction): InitializeAccountParams;
1280
- /**
1281
- * Decode an authorize instruction and retrieve the instruction params.
1282
- */
1283
- static decodeAuthorize(instruction: TransactionInstruction): AuthorizeVoteParams;
1284
- /**
1285
- * Decode an authorize instruction and retrieve the instruction params.
1286
- */
1287
- static decodeAuthorizeWithSeed(instruction: TransactionInstruction): AuthorizeVoteWithSeedParams;
1288
- /**
1289
- * Decode a withdraw instruction and retrieve the instruction params.
1290
- */
1291
- static decodeWithdraw(instruction: TransactionInstruction): WithdrawFromVoteAccountParams;
1292
- }
1293
- /**
1294
- * An enumeration of valid VoteInstructionType's
1295
- */
1296
- type VoteInstructionType = 'Authorize' | 'AuthorizeWithSeed' | 'InitializeAccount' | 'Withdraw';
1297
- /**
1298
- * VoteAuthorize type
1299
- */
1300
- type VoteAuthorizationType = {
1301
- /** The VoteAuthorize index (from solana-vote-program) */
1302
- index: number;
1303
- };
1304
- /**
1305
- * An enumeration of valid VoteAuthorization layouts.
1306
- */
1307
- export const VoteAuthorizationLayout: Readonly<{
1308
- Voter: {
1309
- index: number;
1310
- };
1311
- Withdrawer: {
1312
- index: number;
1313
- };
1314
- }>;
1315
- /**
1316
- * Factory class for transactions to interact with the Vote program
1317
- */
1318
- export class VoteProgram {
1319
- /**
1320
- * Public key that identifies the Vote program
1321
- */
1322
- static programId: PublicKey;
1323
- /**
1324
- * Max space of a Vote account
1325
- *
1326
- * This is generated from the solana-vote-program VoteState struct as
1327
- * `VoteState::size_of()`:
1328
- * https://docs.rs/solana-vote-program/1.9.5/solana_vote_program/vote_state/struct.VoteState.html#method.size_of
1329
- *
1330
- * KEEP IN SYNC WITH `VoteState::size_of()` in https://github.com/solana-labs/solana/blob/a474cb24b9238f5edcc982f65c0b37d4a1046f7e/sdk/program/src/vote/state/mod.rs#L340-L342
1331
- */
1332
- static space: number;
1333
- /**
1334
- * Generate an Initialize instruction.
1335
- */
1336
- static initializeAccount(params: InitializeAccountParams): TransactionInstruction;
1337
- /**
1338
- * Generate a transaction that creates a new Vote account.
1339
- */
1340
- static createAccount(params: CreateVoteAccountParams): Transaction;
1341
- /**
1342
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account.
1343
- */
1344
- static authorize(params: AuthorizeVoteParams): Transaction;
1345
- /**
1346
- * Generate a transaction that authorizes a new Voter or Withdrawer on the Vote account
1347
- * where the current Voter or Withdrawer authority is a derived key.
1348
- */
1349
- static authorizeWithSeed(params: AuthorizeVoteWithSeedParams): Transaction;
1350
- /**
1351
- * Generate a transaction to withdraw from a Vote account.
1352
- */
1353
- static withdraw(params: WithdrawFromVoteAccountParams): Transaction;
1354
- /**
1355
- * Generate a transaction to withdraw safely from a Vote account.
1356
- *
1357
- * This function was created as a safeguard for vote accounts running validators, `safeWithdraw`
1358
- * checks that the withdraw amount will not exceed the specified balance while leaving enough left
1359
- * to cover rent. If you wish to close the vote account by withdrawing the full amount, call the
1360
- * `withdraw` method directly.
1361
- */
1362
- static safeWithdraw(params: WithdrawFromVoteAccountParams, currentVoteAccountBalance: number, rentExemptMinimum: number): Transaction;
1363
- }
1364
-
1365
- /**
1366
- * Message constructor arguments
1367
- */
1368
- type MessageV0Args = {
1369
- /** The message header, identifying signed and read-only `accountKeys` */
1370
- header: MessageHeader;
1371
- /** The static account keys used by this transaction */
1372
- staticAccountKeys: PublicKey[];
1373
- /** The hash of a recent ledger block */
1374
- recentBlockhash: Blockhash;
1375
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
1376
- compiledInstructions: MessageCompiledInstruction[];
1377
- /** Instructions that will be executed in sequence and committed in one atomic transaction if all succeed. */
1378
- addressTableLookups: MessageAddressTableLookup[];
1379
- };
1380
- type CompileV0Args = {
1381
- payerKey: PublicKey;
1382
- instructions: Array<TransactionInstruction>;
1383
- recentBlockhash: Blockhash;
1384
- addressLookupTableAccounts?: Array<AddressLookupTableAccount>;
1385
- };
1386
- type GetAccountKeysArgs = {
1387
- accountKeysFromLookups?: AccountKeysFromLookups | null;
1388
- } | {
1389
- addressLookupTableAccounts?: AddressLookupTableAccount[] | null;
1390
- };
1391
- export class MessageV0 {
1392
- header: MessageHeader;
1393
- staticAccountKeys: Array<PublicKey>;
1394
- recentBlockhash: Blockhash;
1395
- compiledInstructions: Array<MessageCompiledInstruction>;
1396
- addressTableLookups: Array<MessageAddressTableLookup>;
1397
- constructor(args: MessageV0Args);
1398
- get version(): 0;
1399
- get numAccountKeysFromLookups(): number;
1400
- getAccountKeys(args?: GetAccountKeysArgs): MessageAccountKeys;
1401
- isAccountSigner(index: number): boolean;
1402
- isAccountWritable(index: number): boolean;
1403
- resolveAddressTableLookups(addressLookupTableAccounts: AddressLookupTableAccount[]): AccountKeysFromLookups;
1404
- static compile(args: CompileV0Args): MessageV0;
1405
- serialize(): Uint8Array;
1406
- private serializeInstructions;
1407
- private serializeAddressTableLookups;
1408
- static deserialize(serializedMessage: Uint8Array): MessageV0;
1409
- }
1410
-
1411
- type VersionedMessage = Message | MessageV0;
1412
- export const VersionedMessage: {
1413
- deserializeMessageVersion(serializedMessage: Uint8Array): 'legacy' | number;
1414
- deserialize: (serializedMessage: Uint8Array) => VersionedMessage;
1415
- };
1416
-
1417
- /**
1418
- * The message header, identifying signed and read-only account
1419
- */
1420
- type MessageHeader = {
1421
- /**
1422
- * The number of signatures required for this message to be considered valid. The
1423
- * signatures must match the first `numRequiredSignatures` of `accountKeys`.
1424
- */
1425
- numRequiredSignatures: number;
1426
- /** The last `numReadonlySignedAccounts` of the signed keys are read-only accounts */
1427
- numReadonlySignedAccounts: number;
1428
- /** The last `numReadonlySignedAccounts` of the unsigned keys are read-only accounts */
1429
- numReadonlyUnsignedAccounts: number;
1430
- };
1431
- /**
1432
- * An address table lookup used to load additional accounts
1433
- */
1434
- type MessageAddressTableLookup = {
1435
- accountKey: PublicKey;
1436
- writableIndexes: Array<number>;
1437
- readonlyIndexes: Array<number>;
1438
- };
1439
- /**
1440
- * An instruction to execute by a program
1441
- *
1442
- * @property {number} programIdIndex
1443
- * @property {number[]} accountKeyIndexes
1444
- * @property {Uint8Array} data
1445
- */
1446
- type MessageCompiledInstruction = {
1447
- /** Index into the transaction keys array indicating the program account that executes this instruction */
1448
- programIdIndex: number;
1449
- /** Ordered indices into the transaction keys array indicating which accounts to pass to the program */
1450
- accountKeyIndexes: number[];
1451
- /** The program input data */
1452
- data: Uint8Array;
1453
- };
1454
-
1455
- /**
1456
- * Transaction signature as base-58 encoded string
1457
- */
1458
- type TransactionSignature = string;
1459
- export const enum TransactionStatus {
1460
- BLOCKHEIGHT_EXCEEDED = 0,
1461
- PROCESSED = 1,
1462
- TIMED_OUT = 2,
1463
- NONCE_INVALID = 3
1464
- }
1465
- /**
1466
- * Account metadata used to define instructions
1467
- */
1468
- type AccountMeta = {
1469
- /** An account's public key */
1470
- pubkey: PublicKey;
1471
- /** True if an instruction requires a transaction signature matching `pubkey` */
1472
- isSigner: boolean;
1473
- /** True if the `pubkey` can be loaded as a read-write account. */
1474
- isWritable: boolean;
1475
- };
1476
- /**
1477
- * List of TransactionInstruction object fields that may be initialized at construction
1478
- */
1479
- type TransactionInstructionCtorFields = {
1480
- keys: Array<AccountMeta>;
1481
- programId: PublicKey;
1482
- data?: Buffer;
1483
- };
1484
- /**
1485
- * Configuration object for Transaction.serialize()
1486
- */
1487
- type SerializeConfig = {
1488
- /** Require all transaction signatures be present (default: true) */
1489
- requireAllSignatures?: boolean;
1490
- /** Verify provided signatures (default: true) */
1491
- verifySignatures?: boolean;
1492
- };
1493
- /**
1494
- * Transaction Instruction class
1495
- */
1496
- export class TransactionInstruction {
1497
- /**
1498
- * Public keys to include in this transaction
1499
- * Boolean represents whether this pubkey needs to sign the transaction
1500
- */
1501
- keys: Array<AccountMeta>;
1502
- /**
1503
- * Program Id to execute
1504
- */
1505
- programId: PublicKey;
1506
- /**
1507
- * Program input
1508
- */
1509
- data: Buffer;
1510
- constructor(opts: TransactionInstructionCtorFields);
1511
- }
1512
- /**
1513
- * Pair of signature and corresponding public key
1514
- */
1515
- type SignaturePubkeyPair = {
1516
- signature: Buffer | null;
1517
- publicKey: PublicKey;
1518
- };
1519
- /**
1520
- * List of Transaction object fields that may be initialized at construction
1521
- */
1522
- type TransactionCtorFields_DEPRECATED = {
1523
- /** Optional nonce information used for offline nonce'd transactions */
1524
- nonceInfo?: NonceInformation | null;
1525
- /** The transaction fee payer */
1526
- feePayer?: PublicKey | null;
1527
- /** One or more signatures */
1528
- signatures?: Array<SignaturePubkeyPair>;
1529
- /** A recent blockhash */
1530
- recentBlockhash?: Blockhash;
1531
- };
1532
- type TransactionCtorFields = TransactionCtorFields_DEPRECATED;
1533
- /**
1534
- * Blockhash-based transactions have a lifetime that are defined by
1535
- * the blockhash they include. Any transaction whose blockhash is
1536
- * too old will be rejected.
1537
- */
1538
- type TransactionBlockhashCtor = {
1539
- /** The transaction fee payer */
1540
- feePayer?: PublicKey | null;
1541
- /** One or more signatures */
1542
- signatures?: Array<SignaturePubkeyPair>;
1543
- /** A recent blockhash */
1544
- blockhash: Blockhash;
1545
- /** the last block chain can advance to before tx is exportd expired */
1546
- lastValidBlockHeight: number;
1547
- };
1548
- /**
1549
- * Use these options to construct a durable nonce transaction.
1550
- */
1551
- type TransactionNonceCtor = {
1552
- /** The transaction fee payer */
1553
- feePayer?: PublicKey | null;
1554
- minContextSlot: number;
1555
- nonceInfo: NonceInformation;
1556
- /** One or more signatures */
1557
- signatures?: Array<SignaturePubkeyPair>;
1558
- };
1559
- /**
1560
- * Nonce information to be used to build an offline Transaction.
1561
- */
1562
- type NonceInformation = {
1563
- /** The current blockhash stored in the nonce */
1564
- nonce: Blockhash;
1565
- /** AdvanceNonceAccount Instruction */
1566
- nonceInstruction: TransactionInstruction;
1567
- };
1568
- /**
1569
- * Transaction class
1570
- */
1571
- export class Transaction {
1572
- /**
1573
- * Signatures for the transaction. Typically created by invoking the
1574
- * `sign()` method
1575
- */
1576
- signatures: Array<SignaturePubkeyPair>;
1577
- /**
1578
- * The first (payer) Transaction signature
1579
- */
1580
- get signature(): Buffer | null;
1581
- /**
1582
- * The transaction fee payer
1583
- */
1584
- feePayer?: PublicKey;
1585
- /**
1586
- * The instructions to atomically execute
1587
- */
1588
- instructions: Array<TransactionInstruction>;
1589
- /**
1590
- * A recent transaction id. Must be populated by the caller
1591
- */
1592
- recentBlockhash?: Blockhash;
1593
- /**
1594
- * the last block chain can advance to before tx is exportd expired
1595
- * */
1596
- lastValidBlockHeight?: number;
1597
- /**
1598
- * Optional Nonce information. If populated, transaction will use a durable
1599
- * Nonce hash instead of a recentBlockhash. Must be populated by the caller
1600
- */
1601
- nonceInfo?: NonceInformation;
1602
- /**
1603
- * If this is a nonce transaction this represents the minimum slot from which
1604
- * to evaluate if the nonce has advanced when attempting to confirm the
1605
- * transaction. This protects against a case where the transaction confirmation
1606
- * logic loads the nonce account from an old slot and assumes the mismatch in
1607
- * nonce value implies that the nonce has been advanced.
1608
- */
1609
- minNonceContextSlot?: number;
1610
- constructor(opts?: TransactionBlockhashCtor);
1611
- constructor(opts?: TransactionNonceCtor);
1612
- /**
1613
- * @deprecated `TransactionCtorFields` has been deprecated and will be removed in a future version.
1614
- * Please supply a `TransactionBlockhashCtor` instead.
1615
- */
1616
- constructor(opts?: TransactionCtorFields_DEPRECATED);
1617
- /**
1618
- * Add one or more instructions to this Transaction
1619
- */
1620
- add(...items: Array<Transaction | TransactionInstruction | TransactionInstructionCtorFields>): Transaction;
1621
- /**
1622
- * Compile transaction data
1623
- */
1624
- compileMessage(): Message;
1625
- /**
1626
- * Get a buffer of the Transaction data that need to be covered by signatures
1627
- */
1628
- serializeMessage(): Buffer;
1629
- /**
1630
- * Get the estimated fee associated with a transaction
1631
- */
1632
- getEstimatedFee(connection: Connection): Promise<number | null>;
1633
- /**
1634
- * Specify the public keys which will be used to sign the Transaction.
1635
- * The first signer will be used as the transaction fee payer account.
1636
- *
1637
- * Signatures can be added with either `partialSign` or `addSignature`
1638
- *
1639
- * @deprecated Deprecated since v0.84.0. Only the fee payer needs to be
1640
- * specified and it can be set in the Transaction constructor or with the
1641
- * `feePayer` property.
1642
- */
1643
- setSigners(...signers: Array<PublicKey>): void;
1644
- /**
1645
- * Sign the Transaction with the specified signers. Multiple signatures may
1646
- * be applied to a Transaction. The first signature is considered "primary"
1647
- * and is used identify and confirm transactions.
1648
- *
1649
- * If the Transaction `feePayer` is not set, the first signer will be used
1650
- * as the transaction fee payer account.
1651
- *
1652
- * Transaction fields should not be modified after the first call to `sign`,
1653
- * as doing so may invalidate the signature and cause the Transaction to be
1654
- * rejected.
1655
- *
1656
- * The Transaction must be assigned a valid `recentBlockhash` before invoking this method
1657
- */
1658
- sign(...signers: Array<Signer>): void;
1659
- /**
1660
- * Partially sign a transaction with the specified accounts. All accounts must
1661
- * correspond to either the fee payer or a signer account in the transaction
1662
- * instructions.
1663
- *
1664
- * All the caveats from the `sign` method apply to `partialSign`
1665
- */
1666
- partialSign(...signers: Array<Signer>): void;
1667
- /**
1668
- * Add an externally created signature to a transaction. The public key
1669
- * must correspond to either the fee payer or a signer account in the transaction
1670
- * instructions.
1671
- */
1672
- addSignature(pubkey: PublicKey, signature: Buffer): void;
1673
- /**
1674
- * Verify signatures of a Transaction
1675
- * Optional parameter specifies if we're expecting a fully signed Transaction or a partially signed one.
1676
- * If no boolean is provided, we expect a fully signed Transaction by default.
1677
- */
1678
- verifySignatures(requireAllSignatures?: boolean): boolean;
1679
- /**
1680
- * Serialize the Transaction in the wire format.
1681
- */
1682
- serialize(config?: SerializeConfig): Buffer;
1683
- /**
1684
- * Parse a wire transaction into a Transaction object.
1685
- */
1686
- static from(buffer: Buffer | Uint8Array | Array<number>): Transaction;
1687
- /**
1688
- * Populate Transaction object from message and signatures
1689
- */
1690
- static populate(message: Message, signatures?: Array<string>): Transaction;
1691
- }
1692
-
1693
- type TransactionMessageArgs = {
1694
- payerKey: PublicKey;
1695
- instructions: Array<TransactionInstruction>;
1696
- recentBlockhash: Blockhash;
1697
- };
1698
- type DecompileArgs = {
1699
- accountKeysFromLookups: AccountKeysFromLookups;
1700
- } | {
1701
- addressLookupTableAccounts: AddressLookupTableAccount[];
1702
- };
1703
- export class TransactionMessage {
1704
- payerKey: PublicKey;
1705
- instructions: Array<TransactionInstruction>;
1706
- recentBlockhash: Blockhash;
1707
- constructor(args: TransactionMessageArgs);
1708
- static decompile(message: VersionedMessage, args?: DecompileArgs): TransactionMessage;
1709
- compileToLegacyMessage(): Message;
1710
- compileToV0Message(addressLookupTableAccounts?: AddressLookupTableAccount[]): MessageV0;
1711
- }
1712
-
1713
- type TransactionVersion = 'legacy' | 0;
1714
- /**
1715
- * Versioned transaction class
1716
- */
1717
- export class VersionedTransaction {
1718
- signatures: Array<Uint8Array>;
1719
- message: VersionedMessage;
1720
- get version(): TransactionVersion;
1721
- constructor(message: VersionedMessage, signatures?: Array<Uint8Array>);
1722
- serialize(): Uint8Array;
1723
- static deserialize(serializedTransaction: Uint8Array): VersionedTransaction;
1724
- sign(signers: Array<Signer>): void;
1725
- addSignature(publicKey: PublicKey, signature: Uint8Array): void;
1726
- }
1727
-
1728
- type ClientSubscriptionId = number;
1729
- type TokenAccountsFilter = {
1730
- mint: PublicKey;
1731
- } | {
1732
- programId: PublicKey;
1733
- };
1734
- /**
1735
- * Extra contextual information for RPC responses
1736
- */
1737
- type Context = {
1738
- slot: number;
1739
- };
1740
- /**
1741
- * Options for sending transactions
1742
- */
1743
- type SendOptions = {
1744
- /** disable transaction verification step */
1745
- skipPreflight?: boolean;
1746
- /** preflight commitment level */
1747
- preflightCommitment?: Commitment;
1748
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
1749
- maxRetries?: number;
1750
- /** The minimum slot that the request can be evaluated at */
1751
- minContextSlot?: number;
1752
- };
1753
- /**
1754
- * Options for confirming transactions
1755
- */
1756
- type ConfirmOptions = {
1757
- /** disable transaction verification step */
1758
- skipPreflight?: boolean;
1759
- /** desired commitment level */
1760
- commitment?: Commitment;
1761
- /** preflight commitment level */
1762
- preflightCommitment?: Commitment;
1763
- /** Maximum number of times for the RPC node to retry sending the transaction to the leader. */
1764
- maxRetries?: number;
1765
- /** The minimum slot that the request can be evaluated at */
1766
- minContextSlot?: number;
1767
- };
1768
- /**
1769
- * Options for getConfirmedSignaturesForAddress2
1770
- */
1771
- type ConfirmedSignaturesForAddress2Options = {
1772
- /**
1773
- * Start searching backwards from this transaction signature.
1774
- * @remark If not provided the search starts from the highest max confirmed block.
1775
- */
1776
- before?: TransactionSignature;
1777
- /** Search until this transaction signature is reached, if found before `limit`. */
1778
- until?: TransactionSignature;
1779
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
1780
- limit?: number;
1781
- };
1782
- /**
1783
- * Options for getSignaturesForAddress
1784
- */
1785
- type SignaturesForAddressOptions = {
1786
- /**
1787
- * Start searching backwards from this transaction signature.
1788
- * @remark If not provided the search starts from the highest max confirmed block.
1789
- */
1790
- before?: TransactionSignature;
1791
- /** Search until this transaction signature is reached, if found before `limit`. */
1792
- until?: TransactionSignature;
1793
- /** Maximum transaction signatures to return (between 1 and 1,000, default: 1,000). */
1794
- limit?: number;
1795
- /** The minimum slot that the request can be evaluated at */
1796
- minContextSlot?: number;
1797
- };
1798
- /**
1799
- * RPC Response with extra contextual information
1800
- */
1801
- type RpcResponseAndContext<T> = {
1802
- /** response context */
1803
- context: Context;
1804
- /** response value */
1805
- value: T;
1806
- };
1807
- type BlockhashWithExpiryBlockHeight = Readonly<{
1808
- blockhash: Blockhash;
1809
- lastValidBlockHeight: number;
1810
- }>;
1811
- /**
1812
- * A strategy for confirming transactions that uses the last valid
1813
- * block height for a given blockhash to check for transaction expiration.
1814
- */
1815
- type BlockheightBasedTransactionConfirmationStrategy = BaseTransactionConfirmationStrategy & BlockhashWithExpiryBlockHeight;
1816
- /**
1817
- * A strategy for confirming durable nonce transactions.
1818
- */
1819
- type DurableNonceTransactionConfirmationStrategy = BaseTransactionConfirmationStrategy & {
1820
- /**
1821
- * The lowest slot at which to fetch the nonce value from the
1822
- * nonce account. This should be no lower than the slot at
1823
- * which the last-known value of the nonce was fetched.
1824
- */
1825
- minContextSlot: number;
1826
- /**
1827
- * The account where the current value of the nonce is stored.
1828
- */
1829
- nonceAccountPubkey: PublicKey;
1830
- /**
1831
- * The nonce value that was used to sign the transaction
1832
- * for which confirmation is being sought.
1833
- */
1834
- nonceValue: DurableNonce;
1835
- };
1836
- /**
1837
- * Properties shared by all transaction confirmation strategies
1838
- */
1839
- type BaseTransactionConfirmationStrategy = Readonly<{
1840
- /** A signal that, when aborted, cancels any outstanding transaction confirmation operations */
1841
- abortSignal?: AbortSignal;
1842
- signature: TransactionSignature;
1843
- }>;
1844
- /**
1845
- * This type represents all transaction confirmation strategies
1846
- */
1847
- type TransactionConfirmationStrategy = BlockheightBasedTransactionConfirmationStrategy | DurableNonceTransactionConfirmationStrategy;
1848
- /**
1849
- * The level of commitment desired when querying state
1850
- * <pre>
1851
- * 'processed': Query the most recent block which has reached 1 confirmation by the connected node
1852
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
1853
- * 'finalized': Query the most recent block which has been finalized by the cluster
1854
- * </pre>
1855
- */
1856
- type Commitment = 'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max';
1857
- /**
1858
- * A subset of Commitment levels, which are at least optimistically confirmed
1859
- * <pre>
1860
- * 'confirmed': Query the most recent block which has reached 1 confirmation by the cluster
1861
- * 'finalized': Query the most recent block which has been finalized by the cluster
1862
- * </pre>
1863
- */
1864
- type Finality = 'confirmed' | 'finalized';
1865
- /**
1866
- * Filter for largest accounts query
1867
- * <pre>
1868
- * 'circulating': Return the largest accounts that are part of the circulating supply
1869
- * 'nonCirculating': Return the largest accounts that are not part of the circulating supply
1870
- * </pre>
1871
- */
1872
- type LargestAccountsFilter = 'circulating' | 'nonCirculating';
1873
- /**
1874
- * Configuration object for changing `getAccountInfo` query behavior
1875
- */
1876
- type GetAccountInfoConfig = {
1877
- /** The level of commitment desired */
1878
- commitment?: Commitment;
1879
- /** The minimum slot that the request can be evaluated at */
1880
- minContextSlot?: number;
1881
- /** Optional data slice to limit the returned account data */
1882
- dataSlice?: DataSlice;
1883
- };
1884
- /**
1885
- * Configuration object for changing `getBalance` query behavior
1886
- */
1887
- type GetBalanceConfig = {
1888
- /** The level of commitment desired */
1889
- commitment?: Commitment;
1890
- /** The minimum slot that the request can be evaluated at */
1891
- minContextSlot?: number;
1892
- };
1893
- /**
1894
- * Configuration object for changing `getBlock` query behavior
1895
- */
1896
- type GetBlockConfig = {
1897
- /** The level of finality desired */
1898
- commitment?: Finality;
1899
- /**
1900
- * Whether to populate the rewards array. If parameter not provided, the default includes rewards.
1901
- */
1902
- rewards?: boolean;
1903
- /**
1904
- * Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
1905
- * parameter not provided, the default detail level is "full". If "accounts" are requested,
1906
- * transaction details only include signatures and an annotated list of accounts in each
1907
- * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
1908
- * pre_token_balances, and post_token_balances.
1909
- */
1910
- transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
1911
- };
1912
- /**
1913
- * Configuration object for changing `getBlock` query behavior
1914
- */
1915
- type GetVersionedBlockConfig = {
1916
- /** The level of finality desired */
1917
- commitment?: Finality;
1918
- /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
1919
- maxSupportedTransactionVersion?: number;
1920
- /**
1921
- * Whether to populate the rewards array. If parameter not provided, the default includes rewards.
1922
- */
1923
- rewards?: boolean;
1924
- /**
1925
- * Level of transaction detail to return, either "full", "accounts", "signatures", or "none". If
1926
- * parameter not provided, the default detail level is "full". If "accounts" are requested,
1927
- * transaction details only include signatures and an annotated list of accounts in each
1928
- * transaction. Transaction metadata is limited to only: fee, err, pre_balances, post_balances,
1929
- * pre_token_balances, and post_token_balances.
1930
- */
1931
- transactionDetails?: 'accounts' | 'full' | 'none' | 'signatures';
1932
- };
1933
- /**
1934
- * Configuration object for changing `getStakeMinimumDelegation` query behavior
1935
- */
1936
- type GetStakeMinimumDelegationConfig = {
1937
- /** The level of commitment desired */
1938
- commitment?: Commitment;
1939
- };
1940
- /**
1941
- * Configuration object for changing `getBlockHeight` query behavior
1942
- */
1943
- type GetBlockHeightConfig = {
1944
- /** The level of commitment desired */
1945
- commitment?: Commitment;
1946
- /** The minimum slot that the request can be evaluated at */
1947
- minContextSlot?: number;
1948
- };
1949
- /**
1950
- * Configuration object for changing `getEpochInfo` query behavior
1951
- */
1952
- type GetEpochInfoConfig = {
1953
- /** The level of commitment desired */
1954
- commitment?: Commitment;
1955
- /** The minimum slot that the request can be evaluated at */
1956
- minContextSlot?: number;
1957
- };
1958
- /**
1959
- * Configuration object for changing `getInflationReward` query behavior
1960
- */
1961
- type GetInflationRewardConfig = {
1962
- /** The level of commitment desired */
1963
- commitment?: Commitment;
1964
- /** An epoch for which the reward occurs. If omitted, the previous epoch will be used */
1965
- epoch?: number;
1966
- /** The minimum slot that the request can be evaluated at */
1967
- minContextSlot?: number;
1968
- };
1969
- /**
1970
- * Configuration object for changing `getLatestBlockhash` query behavior
1971
- */
1972
- type GetLatestBlockhashConfig = {
1973
- /** The level of commitment desired */
1974
- commitment?: Commitment;
1975
- /** The minimum slot that the request can be evaluated at */
1976
- minContextSlot?: number;
1977
- };
1978
- /**
1979
- * Configuration object for changing `getSlot` query behavior
1980
- */
1981
- type GetSlotConfig = {
1982
- /** The level of commitment desired */
1983
- commitment?: Commitment;
1984
- /** The minimum slot that the request can be evaluated at */
1985
- minContextSlot?: number;
1986
- };
1987
- /**
1988
- * Configuration object for changing `getSlotLeader` query behavior
1989
- */
1990
- type GetSlotLeaderConfig = {
1991
- /** The level of commitment desired */
1992
- commitment?: Commitment;
1993
- /** The minimum slot that the request can be evaluated at */
1994
- minContextSlot?: number;
1995
- };
1996
- /**
1997
- * Configuration object for changing `getTransaction` query behavior
1998
- */
1999
- type GetTransactionConfig = {
2000
- /** The level of finality desired */
2001
- commitment?: Finality;
2002
- };
2003
- /**
2004
- * Configuration object for changing `getTransaction` query behavior
2005
- */
2006
- type GetVersionedTransactionConfig = {
2007
- /** The level of finality desired */
2008
- commitment?: Finality;
2009
- /** The max transaction version to return in responses. If the requested transaction is a higher version, an error will be returned */
2010
- maxSupportedTransactionVersion?: number;
2011
- };
2012
- /**
2013
- * Configuration object for changing `getLargestAccounts` query behavior
2014
- */
2015
- type GetLargestAccountsConfig = {
2016
- /** The level of commitment desired */
2017
- commitment?: Commitment;
2018
- /** Filter largest accounts by whether they are part of the circulating supply */
2019
- filter?: LargestAccountsFilter;
2020
- };
2021
- /**
2022
- * Configuration object for changing `getSupply` request behavior
2023
- */
2024
- type GetSupplyConfig = {
2025
- /** The level of commitment desired */
2026
- commitment?: Commitment;
2027
- /** Exclude non circulating accounts list from response */
2028
- excludeNonCirculatingAccountsList?: boolean;
2029
- };
2030
- /**
2031
- * Configuration object for changing query behavior
2032
- */
2033
- type SignatureStatusConfig = {
2034
- /** enable searching status history, not needed for recent transactions */
2035
- searchTransactionHistory: boolean;
2036
- };
2037
- /**
2038
- * Information describing a cluster node
2039
- */
2040
- type ContactInfo = {
2041
- /** Identity public key of the node */
2042
- pubkey: string;
2043
- /** Gossip network address for the node */
2044
- gossip: string | null;
2045
- /** TPU network address for the node (null if not available) */
2046
- tpu: string | null;
2047
- /** JSON RPC network address for the node (null if not available) */
2048
- rpc: string | null;
2049
- /** Software version of the node (null if not available) */
2050
- version: string | null;
2051
- };
2052
- /**
2053
- * Information describing a vote account
2054
- */
2055
- type VoteAccountInfo = {
2056
- /** Public key of the vote account */
2057
- votePubkey: string;
2058
- /** Identity public key of the node voting with this account */
2059
- nodePubkey: string;
2060
- /** The stake, in lamports, delegated to this vote account and activated */
2061
- activatedStake: number;
2062
- /** Whether the vote account is staked for this epoch */
2063
- epochVoteAccount: boolean;
2064
- /** Recent epoch voting credit history for this voter */
2065
- epochCredits: Array<[number, number, number]>;
2066
- /** A percentage (0-100) of rewards payout owed to the voter */
2067
- commission: number;
2068
- /** Most recent slot voted on by this vote account */
2069
- lastVote: number;
2070
- };
2071
- /**
2072
- * A collection of cluster vote accounts
2073
- */
2074
- type VoteAccountStatus = {
2075
- /** Active vote accounts */
2076
- current: Array<VoteAccountInfo>;
2077
- /** Inactive vote accounts */
2078
- delinquent: Array<VoteAccountInfo>;
2079
- };
2080
- /**
2081
- * Network Inflation
2082
- * (see https://docs.solana.com/implemented-proposals/ed_overview)
2083
- */
2084
- type InflationGovernor = {
2085
- foundation: number;
2086
- foundationTerm: number;
2087
- initial: number;
2088
- taper: number;
2089
- terminal: number;
2090
- };
2091
- /**
2092
- * The inflation reward for an epoch
2093
- */
2094
- type InflationReward = {
2095
- /** epoch for which the reward occurs */
2096
- epoch: number;
2097
- /** the slot in which the rewards are effective */
2098
- effectiveSlot: number;
2099
- /** reward amount in lamports */
2100
- amount: number;
2101
- /** post balance of the account in lamports */
2102
- postBalance: number;
2103
- /** vote account commission when the reward was credited */
2104
- commission?: number | null;
2105
- };
2106
- type RecentPrioritizationFees = {
2107
- /** slot in which the fee was observed */
2108
- slot: number;
2109
- /** the per-compute-unit fee paid by at least one successfully landed transaction, specified in increments of 0.000001 lamports*/
2110
- prioritizationFee: number;
2111
- };
2112
- /**
2113
- * Configuration object for changing `getRecentPrioritizationFees` query behavior
2114
- */
2115
- type GetRecentPrioritizationFeesConfig = {
2116
- /**
2117
- * If this parameter is provided, the response will reflect a fee to land a transaction locking
2118
- * all of the provided accounts as writable.
2119
- */
2120
- lockedWritableAccounts?: PublicKey[];
2121
- };
2122
- type InflationRate = {
2123
- /** total inflation */
2124
- total: number;
2125
- /** inflation allocated to validators */
2126
- validator: number;
2127
- /** inflation allocated to the foundation */
2128
- foundation: number;
2129
- /** epoch for which these values are valid */
2130
- epoch: number;
2131
- };
2132
- /**
2133
- * Information about the current epoch
2134
- */
2135
- type EpochInfo = {
2136
- epoch: number;
2137
- slotIndex: number;
2138
- slotsInEpoch: number;
2139
- absoluteSlot: number;
2140
- blockHeight?: number;
2141
- transactionCount?: number;
2142
- };
2143
- /**
2144
- * Leader schedule
2145
- * (see https://docs.solana.com/terminology#leader-schedule)
2146
- */
2147
- type LeaderSchedule = {
2148
- [address: string]: number[];
2149
- };
2150
- /**
2151
- * Version info for a node
2152
- */
2153
- type Version = {
2154
- /** Version of solana-core */
2155
- 'solana-core': string;
2156
- 'feature-set'?: number;
2157
- };
2158
- type SimulatedTransactionAccountInfo = {
2159
- /** `true` if this account's data contains a loaded program */
2160
- executable: boolean;
2161
- /** Identifier of the program that owns the account */
2162
- owner: string;
2163
- /** Number of lamports assigned to the account */
2164
- lamports: number;
2165
- /** Optional data assigned to the account */
2166
- data: string[];
2167
- /** Optional rent epoch info for account */
2168
- rentEpoch?: number;
2169
- };
2170
- type TransactionReturnDataEncoding = 'base64';
2171
- type TransactionReturnData = {
2172
- programId: string;
2173
- data: [string, TransactionReturnDataEncoding];
2174
- };
2175
- type SimulateTransactionConfig = {
2176
- /** Optional parameter used to enable signature verification before simulation */
2177
- sigVerify?: boolean;
2178
- /** Optional parameter used to replace the simulated transaction's recent blockhash with the latest blockhash */
2179
- replaceRecentBlockhash?: boolean;
2180
- /** Optional parameter used to set the commitment level when selecting the latest block */
2181
- commitment?: Commitment;
2182
- /** Optional parameter used to specify a list of account addresses to return post simulation state for */
2183
- accounts?: {
2184
- encoding: 'base64';
2185
- addresses: string[];
2186
- };
2187
- /** Optional parameter used to specify the minimum block slot that can be used for simulation */
2188
- minContextSlot?: number;
2189
- };
2190
- type SimulatedTransactionResponse = {
2191
- err: TransactionError | string | null;
2192
- logs: Array<string> | null;
2193
- accounts?: (SimulatedTransactionAccountInfo | null)[] | null;
2194
- unitsConsumed?: number;
2195
- returnData?: TransactionReturnData | null;
2196
- };
2197
- type ParsedInnerInstruction = {
2198
- index: number;
2199
- instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
2200
- };
2201
- type TokenBalance = {
2202
- accountIndex: number;
2203
- mint: string;
2204
- owner?: string;
2205
- uiTokenAmount: TokenAmount;
2206
- };
2207
- /**
2208
- * Metadata for a parsed confirmed transaction on the ledger
2209
- *
2210
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link ParsedTransactionMeta} instead.
2211
- */
2212
- type ParsedConfirmedTransactionMeta = ParsedTransactionMeta;
2213
- /**
2214
- * Collection of addresses loaded by a transaction using address table lookups
2215
- */
2216
- type LoadedAddresses = {
2217
- writable: Array<PublicKey>;
2218
- readonly: Array<PublicKey>;
2219
- };
2220
- /**
2221
- * Metadata for a parsed transaction on the ledger
2222
- */
2223
- type ParsedTransactionMeta = {
2224
- /** The fee charged for processing the transaction */
2225
- fee: number;
2226
- /** An array of cross program invoked parsed instructions */
2227
- innerInstructions?: ParsedInnerInstruction[] | null;
2228
- /** The balances of the transaction accounts before processing */
2229
- preBalances: Array<number>;
2230
- /** The balances of the transaction accounts after processing */
2231
- postBalances: Array<number>;
2232
- /** An array of program log messages emitted during a transaction */
2233
- logMessages?: Array<string> | null;
2234
- /** The token balances of the transaction accounts before processing */
2235
- preTokenBalances?: Array<TokenBalance> | null;
2236
- /** The token balances of the transaction accounts after processing */
2237
- postTokenBalances?: Array<TokenBalance> | null;
2238
- /** The error result of transaction processing */
2239
- err: TransactionError | null;
2240
- /** The collection of addresses loaded using address lookup tables */
2241
- loadedAddresses?: LoadedAddresses;
2242
- /** The compute units consumed after processing the transaction */
2243
- computeUnitsConsumed?: number;
2244
- };
2245
- type CompiledInnerInstruction = {
2246
- index: number;
2247
- instructions: CompiledInstruction[];
2248
- };
2249
- /**
2250
- * Metadata for a confirmed transaction on the ledger
2251
- */
2252
- type ConfirmedTransactionMeta = {
2253
- /** The fee charged for processing the transaction */
2254
- fee: number;
2255
- /** An array of cross program invoked instructions */
2256
- innerInstructions?: CompiledInnerInstruction[] | null;
2257
- /** The balances of the transaction accounts before processing */
2258
- preBalances: Array<number>;
2259
- /** The balances of the transaction accounts after processing */
2260
- postBalances: Array<number>;
2261
- /** An array of program log messages emitted during a transaction */
2262
- logMessages?: Array<string> | null;
2263
- /** The token balances of the transaction accounts before processing */
2264
- preTokenBalances?: Array<TokenBalance> | null;
2265
- /** The token balances of the transaction accounts after processing */
2266
- postTokenBalances?: Array<TokenBalance> | null;
2267
- /** The error result of transaction processing */
2268
- err: TransactionError | null;
2269
- /** The collection of addresses loaded using address lookup tables */
2270
- loadedAddresses?: LoadedAddresses;
2271
- /** The compute units consumed after processing the transaction */
2272
- computeUnitsConsumed?: number;
2273
- };
2274
- /**
2275
- * A processed transaction from the RPC API
2276
- */
2277
- type TransactionResponse = {
2278
- /** The slot during which the transaction was processed */
2279
- slot: number;
2280
- /** The transaction */
2281
- transaction: {
2282
- /** The transaction message */
2283
- message: Message;
2284
- /** The transaction signatures */
2285
- signatures: string[];
2286
- };
2287
- /** Metadata produced from the transaction */
2288
- meta: ConfirmedTransactionMeta | null;
2289
- /** The unix timestamp of when the transaction was processed */
2290
- blockTime?: number | null;
2291
- };
2292
- /**
2293
- * A processed transaction from the RPC API
2294
- */
2295
- type VersionedTransactionResponse = {
2296
- /** The slot during which the transaction was processed */
2297
- slot: number;
2298
- /** The transaction */
2299
- transaction: {
2300
- /** The transaction message */
2301
- message: VersionedMessage;
2302
- /** The transaction signatures */
2303
- signatures: string[];
2304
- };
2305
- /** Metadata produced from the transaction */
2306
- meta: ConfirmedTransactionMeta | null;
2307
- /** The unix timestamp of when the transaction was processed */
2308
- blockTime?: number | null;
2309
- /** The transaction version */
2310
- version?: TransactionVersion;
2311
- };
2312
- /**
2313
- * A confirmed transaction on the ledger
2314
- *
2315
- * @deprecated Deprecated since Solana v1.8.0.
2316
- */
2317
- type ConfirmedTransaction = {
2318
- /** The slot during which the transaction was processed */
2319
- slot: number;
2320
- /** The details of the transaction */
2321
- transaction: Transaction;
2322
- /** Metadata produced from the transaction */
2323
- meta: ConfirmedTransactionMeta | null;
2324
- /** The unix timestamp of when the transaction was processed */
2325
- blockTime?: number | null;
2326
- };
2327
- /**
2328
- * A partially decoded transaction instruction
2329
- */
2330
- type PartiallyDecodedInstruction = {
2331
- /** Program id called by this instruction */
2332
- programId: PublicKey;
2333
- /** Public keys of accounts passed to this instruction */
2334
- accounts: Array<PublicKey>;
2335
- /** Raw base-58 instruction data */
2336
- data: string;
2337
- };
2338
- /**
2339
- * A parsed transaction message account
2340
- */
2341
- type ParsedMessageAccount = {
2342
- /** Public key of the account */
2343
- pubkey: PublicKey;
2344
- /** Indicates if the account signed the transaction */
2345
- signer: boolean;
2346
- /** Indicates if the account is writable for this transaction */
2347
- writable: boolean;
2348
- /** Indicates if the account key came from the transaction or a lookup table */
2349
- source?: 'transaction' | 'lookupTable';
2350
- };
2351
- /**
2352
- * A parsed transaction instruction
2353
- */
2354
- type ParsedInstruction = {
2355
- /** Name of the program for this instruction */
2356
- program: string;
2357
- /** ID of the program for this instruction */
2358
- programId: PublicKey;
2359
- /** Parsed instruction info */
2360
- parsed: any;
2361
- };
2362
- /**
2363
- * A parsed address table lookup
2364
- */
2365
- type ParsedAddressTableLookup = {
2366
- /** Address lookup table account key */
2367
- accountKey: PublicKey;
2368
- /** Parsed instruction info */
2369
- writableIndexes: number[];
2370
- /** Parsed instruction info */
2371
- readonlyIndexes: number[];
2372
- };
2373
- /**
2374
- * A parsed transaction message
2375
- */
2376
- type ParsedMessage = {
2377
- /** Accounts used in the instructions */
2378
- accountKeys: ParsedMessageAccount[];
2379
- /** The atomically executed instructions for the transaction */
2380
- instructions: (ParsedInstruction | PartiallyDecodedInstruction)[];
2381
- /** Recent blockhash */
2382
- recentBlockhash: string;
2383
- /** Address table lookups used to load additional accounts */
2384
- addressTableLookups?: ParsedAddressTableLookup[] | null;
2385
- };
2386
- /**
2387
- * A parsed transaction
2388
- */
2389
- type ParsedTransaction = {
2390
- /** Signatures for the transaction */
2391
- signatures: Array<string>;
2392
- /** Message of the transaction */
2393
- message: ParsedMessage;
2394
- };
2395
- /**
2396
- * A parsed and confirmed transaction on the ledger
2397
- *
2398
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link ParsedTransactionWithMeta} instead.
2399
- */
2400
- type ParsedConfirmedTransaction = ParsedTransactionWithMeta;
2401
- /**
2402
- * A parsed transaction on the ledger with meta
2403
- */
2404
- type ParsedTransactionWithMeta = {
2405
- /** The slot during which the transaction was processed */
2406
- slot: number;
2407
- /** The details of the transaction */
2408
- transaction: ParsedTransaction;
2409
- /** Metadata produced from the transaction */
2410
- meta: ParsedTransactionMeta | null;
2411
- /** The unix timestamp of when the transaction was processed */
2412
- blockTime?: number | null;
2413
- /** The version of the transaction message */
2414
- version?: TransactionVersion;
2415
- };
2416
- /**
2417
- * A processed block fetched from the RPC API
2418
- */
2419
- type BlockResponse = {
2420
- /** Blockhash of this block */
2421
- blockhash: Blockhash;
2422
- /** Blockhash of this block's parent */
2423
- previousBlockhash: Blockhash;
2424
- /** Slot index of this block's parent */
2425
- parentSlot: number;
2426
- /** Vector of transactions with status meta and original message */
2427
- transactions: Array<{
2428
- /** The transaction */
2429
- transaction: {
2430
- /** The transaction message */
2431
- message: Message;
2432
- /** The transaction signatures */
2433
- signatures: string[];
2434
- };
2435
- /** Metadata produced from the transaction */
2436
- meta: ConfirmedTransactionMeta | null;
2437
- /** The transaction version */
2438
- version?: TransactionVersion;
2439
- }>;
2440
- /** Vector of block rewards */
2441
- rewards?: Array<{
2442
- /** Public key of reward recipient */
2443
- pubkey: string;
2444
- /** Reward value in lamports */
2445
- lamports: number;
2446
- /** Account balance after reward is applied */
2447
- postBalance: number | null;
2448
- /** Type of reward received */
2449
- rewardType: string | null;
2450
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2451
- commission?: number | null;
2452
- }>;
2453
- /** The unix timestamp of when the block was processed */
2454
- blockTime: number | null;
2455
- };
2456
- /**
2457
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
2458
- */
2459
- type AccountsModeBlockResponse = VersionedAccountsModeBlockResponse;
2460
- /**
2461
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
2462
- */
2463
- type NoneModeBlockResponse = VersionedNoneModeBlockResponse;
2464
- /**
2465
- * A block with parsed transactions
2466
- */
2467
- type ParsedBlockResponse = {
2468
- /** Blockhash of this block */
2469
- blockhash: Blockhash;
2470
- /** Blockhash of this block's parent */
2471
- previousBlockhash: Blockhash;
2472
- /** Slot index of this block's parent */
2473
- parentSlot: number;
2474
- /** Vector of transactions with status meta and original message */
2475
- transactions: Array<{
2476
- /** The details of the transaction */
2477
- transaction: ParsedTransaction;
2478
- /** Metadata produced from the transaction */
2479
- meta: ParsedTransactionMeta | null;
2480
- /** The transaction version */
2481
- version?: TransactionVersion;
2482
- }>;
2483
- /** Vector of block rewards */
2484
- rewards?: Array<{
2485
- /** Public key of reward recipient */
2486
- pubkey: string;
2487
- /** Reward value in lamports */
2488
- lamports: number;
2489
- /** Account balance after reward is applied */
2490
- postBalance: number | null;
2491
- /** Type of reward received */
2492
- rewardType: string | null;
2493
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2494
- commission?: number | null;
2495
- }>;
2496
- /** The unix timestamp of when the block was processed */
2497
- blockTime: number | null;
2498
- /** The number of blocks beneath this block */
2499
- blockHeight: number | null;
2500
- };
2501
- /**
2502
- * A block with parsed transactions where the `transactionDetails` mode is `accounts`
2503
- */
2504
- type ParsedAccountsModeBlockResponse = Omit<ParsedBlockResponse, 'transactions'> & {
2505
- transactions: Array<Omit<ParsedBlockResponse['transactions'][number], 'transaction'> & {
2506
- transaction: Pick<ParsedBlockResponse['transactions'][number]['transaction'], 'signatures'> & {
2507
- accountKeys: ParsedMessageAccount[];
2508
- };
2509
- }>;
2510
- };
2511
- /**
2512
- * A block with parsed transactions where the `transactionDetails` mode is `none`
2513
- */
2514
- type ParsedNoneModeBlockResponse = Omit<ParsedBlockResponse, 'transactions'>;
2515
- /**
2516
- * A processed block fetched from the RPC API
2517
- */
2518
- type VersionedBlockResponse = {
2519
- /** Blockhash of this block */
2520
- blockhash: Blockhash;
2521
- /** Blockhash of this block's parent */
2522
- previousBlockhash: Blockhash;
2523
- /** Slot index of this block's parent */
2524
- parentSlot: number;
2525
- /** Vector of transactions with status meta and original message */
2526
- transactions: Array<{
2527
- /** The transaction */
2528
- transaction: {
2529
- /** The transaction message */
2530
- message: VersionedMessage;
2531
- /** The transaction signatures */
2532
- signatures: string[];
2533
- };
2534
- /** Metadata produced from the transaction */
2535
- meta: ConfirmedTransactionMeta | null;
2536
- /** The transaction version */
2537
- version?: TransactionVersion;
2538
- }>;
2539
- /** Vector of block rewards */
2540
- rewards?: Array<{
2541
- /** Public key of reward recipient */
2542
- pubkey: string;
2543
- /** Reward value in lamports */
2544
- lamports: number;
2545
- /** Account balance after reward is applied */
2546
- postBalance: number | null;
2547
- /** Type of reward received */
2548
- rewardType: string | null;
2549
- /** Vote account commission when the reward was credited, only present for voting and staking rewards */
2550
- commission?: number | null;
2551
- }>;
2552
- /** The unix timestamp of when the block was processed */
2553
- blockTime: number | null;
2554
- };
2555
- /**
2556
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `accounts`
2557
- */
2558
- type VersionedAccountsModeBlockResponse = Omit<VersionedBlockResponse, 'transactions'> & {
2559
- transactions: Array<Omit<VersionedBlockResponse['transactions'][number], 'transaction'> & {
2560
- transaction: Pick<VersionedBlockResponse['transactions'][number]['transaction'], 'signatures'> & {
2561
- accountKeys: ParsedMessageAccount[];
2562
- };
2563
- }>;
2564
- };
2565
- /**
2566
- * A processed block fetched from the RPC API where the `transactionDetails` mode is `none`
2567
- */
2568
- type VersionedNoneModeBlockResponse = Omit<VersionedBlockResponse, 'transactions'>;
2569
- /**
2570
- * A confirmed block on the ledger
2571
- *
2572
- * @deprecated Deprecated since Solana v1.8.0.
2573
- */
2574
- type ConfirmedBlock = {
2575
- /** Blockhash of this block */
2576
- blockhash: Blockhash;
2577
- /** Blockhash of this block's parent */
2578
- previousBlockhash: Blockhash;
2579
- /** Slot index of this block's parent */
2580
- parentSlot: number;
2581
- /** Vector of transactions and status metas */
2582
- transactions: Array<{
2583
- transaction: Transaction;
2584
- meta: ConfirmedTransactionMeta | null;
2585
- }>;
2586
- /** Vector of block rewards */
2587
- rewards?: Array<{
2588
- pubkey: string;
2589
- lamports: number;
2590
- postBalance: number | null;
2591
- rewardType: string | null;
2592
- commission?: number | null;
2593
- }>;
2594
- /** The unix timestamp of when the block was processed */
2595
- blockTime: number | null;
2596
- };
2597
- /**
2598
- * A Block on the ledger with signatures only
2599
- */
2600
- type BlockSignatures = {
2601
- /** Blockhash of this block */
2602
- blockhash: Blockhash;
2603
- /** Blockhash of this block's parent */
2604
- previousBlockhash: Blockhash;
2605
- /** Slot index of this block's parent */
2606
- parentSlot: number;
2607
- /** Vector of signatures */
2608
- signatures: Array<string>;
2609
- /** The unix timestamp of when the block was processed */
2610
- blockTime: number | null;
2611
- };
2612
- /**
2613
- * recent block production information
2614
- */
2615
- type BlockProduction = Readonly<{
2616
- /** a dictionary of validator identities, as base-58 encoded strings. Value is a two element array containing the number of leader slots and the number of blocks produced */
2617
- byIdentity: Readonly<Record<string, ReadonlyArray<number>>>;
2618
- /** Block production slot range */
2619
- range: Readonly<{
2620
- /** first slot of the block production information (inclusive) */
2621
- firstSlot: number;
2622
- /** last slot of block production information (inclusive) */
2623
- lastSlot: number;
2624
- }>;
2625
- }>;
2626
- type GetBlockProductionConfig = {
2627
- /** Optional commitment level */
2628
- commitment?: Commitment;
2629
- /** Slot range to return block production for. If parameter not provided, defaults to current epoch. */
2630
- range?: {
2631
- /** first slot to return block production information for (inclusive) */
2632
- firstSlot: number;
2633
- /** last slot to return block production information for (inclusive). If parameter not provided, defaults to the highest slot */
2634
- lastSlot?: number;
2635
- };
2636
- /** Only return results for this validator identity (base-58 encoded) */
2637
- identity?: string;
2638
- };
2639
- /**
2640
- * A performance sample
2641
- */
2642
- type PerfSample = {
2643
- /** Slot number of sample */
2644
- slot: number;
2645
- /** Number of transactions in a sample window */
2646
- numTransactions: number;
2647
- /** Number of slots in a sample window */
2648
- numSlots: number;
2649
- /** Sample window in seconds */
2650
- samplePeriodSecs: number;
2651
- };
2652
- /**
2653
- * Supply
2654
- */
2655
- type Supply = {
2656
- /** Total supply in lamports */
2657
- total: number;
2658
- /** Circulating supply in lamports */
2659
- circulating: number;
2660
- /** Non-circulating supply in lamports */
2661
- nonCirculating: number;
2662
- /** List of non-circulating account addresses */
2663
- nonCirculatingAccounts: Array<PublicKey>;
2664
- };
2665
- /**
2666
- * Token amount object which returns a token amount in different formats
2667
- * for various client use cases.
2668
- */
2669
- type TokenAmount = {
2670
- /** Raw amount of tokens as string ignoring decimals */
2671
- amount: string;
2672
- /** Number of decimals configured for token's mint */
2673
- decimals: number;
2674
- /** Token amount as float, accounts for decimals */
2675
- uiAmount: number | null;
2676
- /** Token amount as string, accounts for decimals */
2677
- uiAmountString?: string;
2678
- };
2679
- /**
2680
- * Token address and balance.
2681
- */
2682
- type TokenAccountBalancePair = {
2683
- /** Address of the token account */
2684
- address: PublicKey;
2685
- /** Raw amount of tokens as string ignoring decimals */
2686
- amount: string;
2687
- /** Number of decimals configured for token's mint */
2688
- decimals: number;
2689
- /** Token amount as float, accounts for decimals */
2690
- uiAmount: number | null;
2691
- /** Token amount as string, accounts for decimals */
2692
- uiAmountString?: string;
2693
- };
2694
- /**
2695
- * Pair of an account address and its balance
2696
- */
2697
- type AccountBalancePair = {
2698
- address: PublicKey;
2699
- lamports: number;
2700
- };
2701
- /**
2702
- * Slot updates which can be used for tracking the live progress of a cluster.
2703
- * - `"firstShredReceived"`: connected node received the first shred of a block.
2704
- * Indicates that a new block that is being produced.
2705
- * - `"completed"`: connected node has received all shreds of a block. Indicates
2706
- * a block was recently produced.
2707
- * - `"optimisticConfirmation"`: block was optimistically confirmed by the
2708
- * cluster. It is not guaranteed that an optimistic confirmation notification
2709
- * will be sent for every finalized blocks.
2710
- * - `"root"`: the connected node rooted this block.
2711
- * - `"createdBank"`: the connected node has started validating this block.
2712
- * - `"frozen"`: the connected node has validated this block.
2713
- * - `"dead"`: the connected node failed to validate this block.
2714
- */
2715
- type SlotUpdate = {
2716
- type: 'firstShredReceived';
2717
- slot: number;
2718
- timestamp: number;
2719
- } | {
2720
- type: 'completed';
2721
- slot: number;
2722
- timestamp: number;
2723
- } | {
2724
- type: 'createdBank';
2725
- slot: number;
2726
- timestamp: number;
2727
- parent: number;
2728
- } | {
2729
- type: 'frozen';
2730
- slot: number;
2731
- timestamp: number;
2732
- stats: {
2733
- numTransactionEntries: number;
2734
- numSuccessfulTransactions: number;
2735
- numFailedTransactions: number;
2736
- maxTransactionsPerEntry: number;
2737
- };
2738
- } | {
2739
- type: 'dead';
2740
- slot: number;
2741
- timestamp: number;
2742
- err: string;
2743
- } | {
2744
- type: 'optimisticConfirmation';
2745
- slot: number;
2746
- timestamp: number;
2747
- } | {
2748
- type: 'root';
2749
- slot: number;
2750
- timestamp: number;
2751
- };
2752
- /**
2753
- * Information about the latest slot being processed by a node
2754
- */
2755
- type SlotInfo = {
2756
- /** Currently processing slot */
2757
- slot: number;
2758
- /** Parent of the current slot */
2759
- parent: number;
2760
- /** The root block of the current slot's fork */
2761
- root: number;
2762
- };
2763
- /**
2764
- * Parsed account data
2765
- */
2766
- type ParsedAccountData = {
2767
- /** Name of the program that owns this account */
2768
- program: string;
2769
- /** Parsed account data */
2770
- parsed: any;
2771
- /** Space used by account data */
2772
- space: number;
2773
- };
2774
- /**
2775
- * Stake Activation data
2776
- */
2777
- type StakeActivationData = {
2778
- /** the stake account's activation state */
2779
- state: 'active' | 'inactive' | 'activating' | 'deactivating';
2780
- /** stake active during the epoch */
2781
- active: number;
2782
- /** stake inactive during the epoch */
2783
- inactive: number;
2784
- };
2785
- /**
2786
- * Data slice argument for getProgramAccounts
2787
- */
2788
- type DataSlice = {
2789
- /** offset of data slice */
2790
- offset: number;
2791
- /** length of data slice */
2792
- length: number;
2793
- };
2794
- /**
2795
- * Memory comparison filter for getProgramAccounts
2796
- */
2797
- type MemcmpFilter = {
2798
- memcmp: {
2799
- /** offset into program account data to start comparison */
2800
- offset: number;
2801
- /** data to match, as base-58 encoded string and limited to less than 129 bytes */
2802
- bytes: string;
2803
- };
2804
- };
2805
- /**
2806
- * Data size comparison filter for getProgramAccounts
2807
- */
2808
- type DataSizeFilter = {
2809
- /** Size of data for program account data length comparison */
2810
- dataSize: number;
2811
- };
2812
- /**
2813
- * A filter object for getProgramAccounts
2814
- */
2815
- type GetProgramAccountsFilter = MemcmpFilter | DataSizeFilter;
2816
- /**
2817
- * Configuration object for getProgramAccounts requests
2818
- */
2819
- type GetProgramAccountsConfig = {
2820
- /** Optional commitment level */
2821
- commitment?: Commitment;
2822
- /** Optional encoding for account data (default base64)
2823
- * To use "jsonParsed" encoding, please refer to `getParsedProgramAccounts` in connection.ts
2824
- * */
2825
- encoding?: 'base64';
2826
- /** Optional data slice to limit the returned account data */
2827
- dataSlice?: DataSlice;
2828
- /** Optional array of filters to apply to accounts */
2829
- filters?: GetProgramAccountsFilter[];
2830
- /** The minimum slot that the request can be evaluated at */
2831
- minContextSlot?: number;
2832
- /** wrap the result in an RpcResponse JSON object */
2833
- withContext?: boolean;
2834
- };
2835
- type GetProgramAccountsResponse = readonly Readonly<{
2836
- account: AccountInfo<Buffer>;
2837
- /** the account Pubkey as base-58 encoded string */
2838
- pubkey: PublicKey;
2839
- }>[];
2840
- /**
2841
- * Configuration object for getParsedProgramAccounts
2842
- */
2843
- type GetParsedProgramAccountsConfig = {
2844
- /** Optional commitment level */
2845
- commitment?: Commitment;
2846
- /** Optional array of filters to apply to accounts */
2847
- filters?: GetProgramAccountsFilter[];
2848
- /** The minimum slot that the request can be evaluated at */
2849
- minContextSlot?: number;
2850
- };
2851
- /**
2852
- * Configuration object for getMultipleAccounts
2853
- */
2854
- type GetMultipleAccountsConfig = {
2855
- /** Optional commitment level */
2856
- commitment?: Commitment;
2857
- /** The minimum slot that the request can be evaluated at */
2858
- minContextSlot?: number;
2859
- /** Optional data slice to limit the returned account data */
2860
- dataSlice?: DataSlice;
2861
- };
2862
- /**
2863
- * Configuration object for `getStakeActivation`
2864
- */
2865
- type GetStakeActivationConfig = {
2866
- /** Optional commitment level */
2867
- commitment?: Commitment;
2868
- /** Epoch for which to calculate activation details. If parameter not provided, defaults to current epoch */
2869
- epoch?: number;
2870
- /** The minimum slot that the request can be evaluated at */
2871
- minContextSlot?: number;
2872
- };
2873
- /**
2874
- * Configuration object for `getStakeActivation`
2875
- */
2876
- type GetTokenAccountsByOwnerConfig = {
2877
- /** Optional commitment level */
2878
- commitment?: Commitment;
2879
- /** The minimum slot that the request can be evaluated at */
2880
- minContextSlot?: number;
2881
- };
2882
- /**
2883
- * Configuration object for `getStakeActivation`
2884
- */
2885
- type GetTransactionCountConfig = {
2886
- /** Optional commitment level */
2887
- commitment?: Commitment;
2888
- /** The minimum slot that the request can be evaluated at */
2889
- minContextSlot?: number;
2890
- };
2891
- /**
2892
- * Configuration object for `getNonce`
2893
- */
2894
- type GetNonceConfig = {
2895
- /** Optional commitment level */
2896
- commitment?: Commitment;
2897
- /** The minimum slot that the request can be evaluated at */
2898
- minContextSlot?: number;
2899
- };
2900
- /**
2901
- * Configuration object for `getNonceAndContext`
2902
- */
2903
- type GetNonceAndContextConfig = {
2904
- /** Optional commitment level */
2905
- commitment?: Commitment;
2906
- /** The minimum slot that the request can be evaluated at */
2907
- minContextSlot?: number;
2908
- };
2909
- /**
2910
- * Information describing an account
2911
- */
2912
- type AccountInfo<T> = {
2913
- /** `true` if this account's data contains a loaded program */
2914
- executable: boolean;
2915
- /** Identifier of the program that owns the account */
2916
- owner: PublicKey;
2917
- /** Number of lamports assigned to the account */
2918
- lamports: number;
2919
- /** Optional data assigned to the account */
2920
- data: T;
2921
- /** Optional rent epoch info for account */
2922
- rentEpoch?: number;
2923
- };
2924
- /**
2925
- * Account information identified by pubkey
2926
- */
2927
- type KeyedAccountInfo = {
2928
- accountId: PublicKey;
2929
- accountInfo: AccountInfo<Buffer>;
2930
- };
2931
- /**
2932
- * Callback function for account change notifications
2933
- */
2934
- type AccountChangeCallback = (accountInfo: AccountInfo<Buffer>, context: Context) => void;
2935
- /**
2936
- * Callback function for program account change notifications
2937
- */
2938
- type ProgramAccountChangeCallback = (keyedAccountInfo: KeyedAccountInfo, context: Context) => void;
2939
- /**
2940
- * Callback function for slot change notifications
2941
- */
2942
- type SlotChangeCallback = (slotInfo: SlotInfo) => void;
2943
- /**
2944
- * Callback function for slot update notifications
2945
- */
2946
- type SlotUpdateCallback = (slotUpdate: SlotUpdate) => void;
2947
- /**
2948
- * Callback function for signature status notifications
2949
- */
2950
- type SignatureResultCallback = (signatureResult: SignatureResult, context: Context) => void;
2951
- /**
2952
- * Signature status notification with transaction result
2953
- */
2954
- type SignatureStatusNotification = {
2955
- type: 'status';
2956
- result: SignatureResult;
2957
- };
2958
- /**
2959
- * Signature received notification
2960
- */
2961
- type SignatureReceivedNotification = {
2962
- type: 'received';
2963
- };
2964
- /**
2965
- * Callback function for signature notifications
2966
- */
2967
- type SignatureSubscriptionCallback = (notification: SignatureStatusNotification | SignatureReceivedNotification, context: Context) => void;
2968
- /**
2969
- * Signature subscription options
2970
- */
2971
- type SignatureSubscriptionOptions = {
2972
- commitment?: Commitment;
2973
- enableReceivedNotification?: boolean;
2974
- };
2975
- /**
2976
- * Callback function for root change notifications
2977
- */
2978
- type RootChangeCallback = (root: number) => void;
2979
- /**
2980
- * Logs result.
2981
- */
2982
- type Logs = {
2983
- err: TransactionError | null;
2984
- logs: string[];
2985
- signature: string;
2986
- };
2987
- /**
2988
- * Filter for log subscriptions.
2989
- */
2990
- type LogsFilter = PublicKey | 'all' | 'allWithVotes';
2991
- /**
2992
- * Callback function for log notifications.
2993
- */
2994
- type LogsCallback = (logs: Logs, ctx: Context) => void;
2995
- /**
2996
- * Signature result
2997
- */
2998
- type SignatureResult = {
2999
- err: TransactionError | null;
3000
- };
3001
- /**
3002
- * Transaction error
3003
- */
3004
- type TransactionError = {} | string;
3005
- /**
3006
- * Transaction confirmation status
3007
- * <pre>
3008
- * 'processed': Transaction landed in a block which has reached 1 confirmation by the connected node
3009
- * 'confirmed': Transaction landed in a block which has reached 1 confirmation by the cluster
3010
- * 'finalized': Transaction landed in a block which has been finalized by the cluster
3011
- * </pre>
3012
- */
3013
- type TransactionConfirmationStatus = 'processed' | 'confirmed' | 'finalized';
3014
- /**
3015
- * Signature status
3016
- */
3017
- type SignatureStatus = {
3018
- /** when the transaction was processed */
3019
- slot: number;
3020
- /** the number of blocks that have been confirmed and voted on in the fork containing `slot` */
3021
- confirmations: number | null;
3022
- /** transaction error, if any */
3023
- err: TransactionError | null;
3024
- /** cluster confirmation status, if data available. Possible responses: `processed`, `confirmed`, `finalized` */
3025
- confirmationStatus?: TransactionConfirmationStatus;
3026
- };
3027
- /**
3028
- * A confirmed signature with its status
3029
- */
3030
- type ConfirmedSignatureInfo = {
3031
- /** the transaction signature */
3032
- signature: string;
3033
- /** when the transaction was processed */
3034
- slot: number;
3035
- /** error, if any */
3036
- err: TransactionError | null;
3037
- /** memo associated with the transaction, if any */
3038
- memo: string | null;
3039
- /** The unix timestamp of when the transaction was processed */
3040
- blockTime?: number | null;
3041
- /** Cluster confirmation status, if available. Possible values: `processed`, `confirmed`, `finalized` */
3042
- confirmationStatus?: TransactionConfirmationStatus;
3043
- };
3044
- /**
3045
- * An object defining headers to be passed to the RPC server
3046
- */
3047
- type HttpHeaders = {
3048
- [header: string]: string;
3049
- } & {
3050
- 'solana-client'?: never;
3051
- };
3052
- /**
3053
- * The type of the JavaScript `fetch()` API
3054
- */
3055
- type FetchFn = typeof export_default;
3056
- /**
3057
- * A callback used to augment the outgoing HTTP request
3058
- */
3059
- type FetchMiddleware = (info: Parameters<FetchFn>[0], init: Parameters<FetchFn>[1], fetch: (...a: Parameters<FetchFn>) => void) => void;
3060
- /**
3061
- * Configuration for instantiating a Connection
3062
- */
3063
- type ConnectionConfig = {
3064
- /**
3065
- * An `http.Agent` that will be used to manage socket connections (eg. to implement connection
3066
- * persistence). Set this to `false` to create a connection that uses no agent. This applies to
3067
- * Node environments only.
3068
- */
3069
- httpAgent?: Agent | Agent$1 | false;
3070
- /** Optional commitment level */
3071
- commitment?: Commitment;
3072
- /** Optional endpoint URL to the fullnode JSON RPC PubSub WebSocket Endpoint */
3073
- wsEndpoint?: string;
3074
- /** Optional HTTP headers object */
3075
- httpHeaders?: HttpHeaders;
3076
- /** Optional custom fetch function */
3077
- fetch?: FetchFn;
3078
- /** Optional fetch middleware callback */
3079
- fetchMiddleware?: FetchMiddleware;
3080
- /** Optional Disable retrying calls when server responds with HTTP 429 (Too Many Requests) */
3081
- disableRetryOnRateLimit?: boolean;
3082
- /** time to allow for the server to initially process a transaction (in milliseconds) */
3083
- confirmTransactionInitialTimeout?: number;
3084
- };
3085
- /**
3086
- * A connection to a fullnode JSON RPC endpoint
3087
- */
3088
- export class Connection {
3089
- /**
3090
- * Establish a JSON RPC connection
3091
- *
3092
- * @param endpoint URL to the fullnode JSON RPC endpoint
3093
- * @param commitmentOrConfig optional default commitment level or optional ConnectionConfig configuration object
3094
- */
3095
- constructor(endpoint: string, commitmentOrConfig?: Commitment | ConnectionConfig);
3096
- /**
3097
- * The default commitment used for requests
3098
- */
3099
- get commitment(): Commitment | undefined;
3100
- /**
3101
- * The RPC endpoint
3102
- */
3103
- get rpcEndpoint(): string;
3104
- /**
3105
- * Fetch the balance for the specified public key, return with context
3106
- */
3107
- getBalanceAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<RpcResponseAndContext<number>>;
3108
- /**
3109
- * Fetch the balance for the specified public key
3110
- */
3111
- getBalance(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<number>;
3112
- /**
3113
- * Fetch the estimated production time of a block
3114
- */
3115
- getBlockTime(slot: number): Promise<number | null>;
3116
- /**
3117
- * Fetch the lowest slot that the node has information about in its ledger.
3118
- * This value may increase over time if the node is configured to purge older ledger data
3119
- */
3120
- getMinimumLedgerSlot(): Promise<number>;
3121
- /**
3122
- * Fetch the slot of the lowest confirmed block that has not been purged from the ledger
3123
- */
3124
- getFirstAvailableBlock(): Promise<number>;
3125
- /**
3126
- * Fetch information about the current supply
3127
- */
3128
- getSupply(config?: GetSupplyConfig | Commitment): Promise<RpcResponseAndContext<Supply>>;
3129
- /**
3130
- * Fetch the current supply of a token mint
3131
- */
3132
- getTokenSupply(tokenMintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
3133
- /**
3134
- * Fetch the current balance of a token account
3135
- */
3136
- getTokenAccountBalance(tokenAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
3137
- /**
3138
- * Fetch all the token accounts owned by the specified account
3139
- *
3140
- * @return {Promise<RpcResponseAndContext<GetProgramAccountsResponse>}
3141
- */
3142
- getTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig): Promise<RpcResponseAndContext<GetProgramAccountsResponse>>;
3143
- /**
3144
- * Fetch parsed token accounts owned by the specified account
3145
- *
3146
- * @return {Promise<RpcResponseAndContext<Array<{pubkey: PublicKey, account: AccountInfo<ParsedAccountData>}>>>}
3147
- */
3148
- getParsedTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitment?: Commitment): Promise<RpcResponseAndContext<Array<{
3149
- pubkey: PublicKey;
3150
- account: AccountInfo<ParsedAccountData>;
3151
- }>>>;
3152
- /**
3153
- * Fetch the 20 largest accounts with their current balances
3154
- */
3155
- getLargestAccounts(config?: GetLargestAccountsConfig): Promise<RpcResponseAndContext<Array<AccountBalancePair>>>;
3156
- /**
3157
- * Fetch the 20 largest token accounts with their current balances
3158
- * for a given mint.
3159
- */
3160
- getTokenLargestAccounts(mintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<Array<TokenAccountBalancePair>>>;
3161
- /**
3162
- * Fetch all the account info for the specified public key, return with context
3163
- */
3164
- getAccountInfoAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
3165
- /**
3166
- * Fetch parsed account info for the specified public key
3167
- */
3168
- getParsedAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>>;
3169
- /**
3170
- * Fetch all the account info for the specified public key
3171
- */
3172
- getAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<AccountInfo<Buffer> | null>;
3173
- /**
3174
- * Fetch all the account info for multiple accounts specified by an array of public keys, return with context
3175
- */
3176
- getMultipleParsedAccounts(publicKeys: PublicKey[], rawConfig?: GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer | ParsedAccountData> | null)[]>>;
3177
- /**
3178
- * Fetch all the account info for multiple accounts specified by an array of public keys, return with context
3179
- */
3180
- getMultipleAccountsInfoAndContext(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
3181
- /**
3182
- * Fetch all the account info for multiple accounts specified by an array of public keys
3183
- */
3184
- getMultipleAccountsInfo(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<(AccountInfo<Buffer> | null)[]>;
3185
- /**
3186
- * Returns epoch activation information for a stake account that has been delegated
3187
- */
3188
- getStakeActivation(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetStakeActivationConfig, epoch?: number): Promise<StakeActivationData>;
3189
- /**
3190
- * Fetch all the accounts owned by the specified program id
3191
- *
3192
- * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer>}>>}
3193
- */
3194
- getProgramAccounts(programId: PublicKey, configOrCommitment: GetProgramAccountsConfig & Readonly<{
3195
- withContext: true;
3196
- }>): Promise<RpcResponseAndContext<GetProgramAccountsResponse>>;
3197
- getProgramAccounts(programId: PublicKey, configOrCommitment?: GetProgramAccountsConfig | Commitment): Promise<GetProgramAccountsResponse>;
3198
- /**
3199
- * Fetch and parse all the accounts owned by the specified program id
3200
- *
3201
- * @return {Promise<Array<{pubkey: PublicKey, account: AccountInfo<Buffer | ParsedAccountData>}>>}
3202
- */
3203
- getParsedProgramAccounts(programId: PublicKey, configOrCommitment?: GetParsedProgramAccountsConfig | Commitment): Promise<Array<{
3204
- pubkey: PublicKey;
3205
- account: AccountInfo<Buffer | ParsedAccountData>;
3206
- }>>;
3207
- confirmTransaction(strategy: TransactionConfirmationStrategy, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
3208
- /** @deprecated Instead, call `confirmTransaction` and pass in {@link TransactionConfirmationStrategy} */
3209
- confirmTransaction(strategy: TransactionSignature, commitment?: Commitment): Promise<RpcResponseAndContext<SignatureResult>>;
3210
- private getCancellationPromise;
3211
- private getTransactionConfirmationPromise;
3212
- private confirmTransactionUsingBlockHeightExceedanceStrategy;
3213
- private confirmTransactionUsingDurableNonceStrategy;
3214
- private confirmTransactionUsingLegacyTimeoutStrategy;
3215
- /**
3216
- * Return the list of nodes that are currently participating in the cluster
3217
- */
3218
- getClusterNodes(): Promise<Array<ContactInfo>>;
3219
- /**
3220
- * Return the list of nodes that are currently participating in the cluster
3221
- */
3222
- getVoteAccounts(commitment?: Commitment): Promise<VoteAccountStatus>;
3223
- /**
3224
- * Fetch the current slot that the node is processing
3225
- */
3226
- getSlot(commitmentOrConfig?: Commitment | GetSlotConfig): Promise<number>;
3227
- /**
3228
- * Fetch the current slot leader of the cluster
3229
- */
3230
- getSlotLeader(commitmentOrConfig?: Commitment | GetSlotLeaderConfig): Promise<string>;
3231
- /**
3232
- * Fetch `limit` number of slot leaders starting from `startSlot`
3233
- *
3234
- * @param startSlot fetch slot leaders starting from this slot
3235
- * @param limit number of slot leaders to return
3236
- */
3237
- getSlotLeaders(startSlot: number, limit: number): Promise<Array<PublicKey>>;
3238
- /**
3239
- * Fetch the current status of a signature
3240
- */
3241
- getSignatureStatus(signature: TransactionSignature, config?: SignatureStatusConfig): Promise<RpcResponseAndContext<SignatureStatus | null>>;
3242
- /**
3243
- * Fetch the current statuses of a batch of signatures
3244
- */
3245
- getSignatureStatuses(signatures: Array<TransactionSignature>, config?: SignatureStatusConfig): Promise<RpcResponseAndContext<Array<SignatureStatus | null>>>;
3246
- /**
3247
- * Fetch the current transaction count of the cluster
3248
- */
3249
- getTransactionCount(commitmentOrConfig?: Commitment | GetTransactionCountConfig): Promise<number>;
3250
- /**
3251
- * Fetch the current total currency supply of the cluster in lamports
3252
- *
3253
- * @deprecated Deprecated since v1.2.8. Please use {@link getSupply} instead.
3254
- */
3255
- getTotalSupply(commitment?: Commitment): Promise<number>;
3256
- /**
3257
- * Fetch the cluster InflationGovernor parameters
3258
- */
3259
- getInflationGovernor(commitment?: Commitment): Promise<InflationGovernor>;
3260
- /**
3261
- * Fetch the inflation reward for a list of addresses for an epoch
3262
- */
3263
- getInflationReward(addresses: PublicKey[], epoch?: number, commitmentOrConfig?: Commitment | GetInflationRewardConfig): Promise<(InflationReward | null)[]>;
3264
- /**
3265
- * Fetch the specific inflation values for the current epoch
3266
- */
3267
- getInflationRate(): Promise<InflationRate>;
3268
- /**
3269
- * Fetch the Epoch Info parameters
3270
- */
3271
- getEpochInfo(commitmentOrConfig?: Commitment | GetEpochInfoConfig): Promise<EpochInfo>;
3272
- /**
3273
- * Fetch the Epoch Schedule parameters
3274
- */
3275
- getEpochSchedule(): Promise<EpochSchedule>;
3276
- /**
3277
- * Fetch the leader schedule for the current epoch
3278
- * @return {Promise<RpcResponseAndContext<LeaderSchedule>>}
3279
- */
3280
- getLeaderSchedule(): Promise<LeaderSchedule>;
3281
- /**
3282
- * Fetch the minimum balance needed to exempt an account of `dataLength`
3283
- * size from rent
3284
- */
3285
- getMinimumBalanceForRentExemption(dataLength: number, commitment?: Commitment): Promise<number>;
3286
- /**
3287
- * Fetch a recent blockhash from the cluster, return with context
3288
- * @return {Promise<RpcResponseAndContext<{blockhash: Blockhash, feeCalculator: FeeCalculator}>>}
3289
- *
3290
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
3291
- */
3292
- getRecentBlockhashAndContext(commitment?: Commitment): Promise<RpcResponseAndContext<{
3293
- blockhash: Blockhash;
3294
- feeCalculator: FeeCalculator;
3295
- }>>;
3296
- /**
3297
- * Fetch recent performance samples
3298
- * @return {Promise<Array<PerfSample>>}
3299
- */
3300
- getRecentPerformanceSamples(limit?: number): Promise<Array<PerfSample>>;
3301
- /**
3302
- * Fetch the fee calculator for a recent blockhash from the cluster, return with context
3303
- *
3304
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getFeeForMessage} instead.
3305
- */
3306
- getFeeCalculatorForBlockhash(blockhash: Blockhash, commitment?: Commitment): Promise<RpcResponseAndContext<FeeCalculator | null>>;
3307
- /**
3308
- * Fetch the fee for a message from the cluster, return with context
3309
- */
3310
- getFeeForMessage(message: VersionedMessage, commitment?: Commitment): Promise<RpcResponseAndContext<number | null>>;
3311
- /**
3312
- * Fetch a list of prioritization fees from recent blocks.
3313
- */
3314
- getRecentPrioritizationFees(config?: GetRecentPrioritizationFeesConfig): Promise<RecentPrioritizationFees[]>;
3315
- /**
3316
- * Fetch a recent blockhash from the cluster
3317
- * @return {Promise<{blockhash: Blockhash, feeCalculator: FeeCalculator}>}
3318
- *
3319
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getLatestBlockhash} instead.
3320
- */
3321
- getRecentBlockhash(commitment?: Commitment): Promise<{
3322
- blockhash: Blockhash;
3323
- feeCalculator: FeeCalculator;
3324
- }>;
3325
- /**
3326
- * Fetch the latest blockhash from the cluster
3327
- * @return {Promise<BlockhashWithExpiryBlockHeight>}
3328
- */
3329
- getLatestBlockhash(commitmentOrConfig?: Commitment | GetLatestBlockhashConfig): Promise<BlockhashWithExpiryBlockHeight>;
3330
- /**
3331
- * Fetch the latest blockhash from the cluster
3332
- * @return {Promise<BlockhashWithExpiryBlockHeight>}
3333
- */
3334
- getLatestBlockhashAndContext(commitmentOrConfig?: Commitment | GetLatestBlockhashConfig): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
3335
- /**
3336
- * Fetch the node version
3337
- */
3338
- getVersion(): Promise<Version>;
3339
- /**
3340
- * Fetch the genesis hash
3341
- */
3342
- getGenesisHash(): Promise<string>;
3343
- /**
3344
- * Fetch a processed block from the cluster.
3345
- *
3346
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3347
- * setting the `maxSupportedTransactionVersion` property.
3348
- */
3349
- getBlock(slot: number, rawConfig?: GetBlockConfig): Promise<BlockResponse | null>;
3350
- /**
3351
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3352
- * setting the `maxSupportedTransactionVersion` property.
3353
- */
3354
- getBlock(slot: number, rawConfig: GetBlockConfig & {
3355
- transactionDetails: 'accounts';
3356
- }): Promise<AccountsModeBlockResponse | null>;
3357
- /**
3358
- * @deprecated Instead, call `getBlock` using a `GetVersionedBlockConfig` by
3359
- * setting the `maxSupportedTransactionVersion` property.
3360
- */
3361
- getBlock(slot: number, rawConfig: GetBlockConfig & {
3362
- transactionDetails: 'none';
3363
- }): Promise<NoneModeBlockResponse | null>;
3364
- /**
3365
- * Fetch a processed block from the cluster.
3366
- */
3367
- getBlock(slot: number, rawConfig?: GetVersionedBlockConfig): Promise<VersionedBlockResponse | null>;
3368
- getBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3369
- transactionDetails: 'accounts';
3370
- }): Promise<VersionedAccountsModeBlockResponse | null>;
3371
- getBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3372
- transactionDetails: 'none';
3373
- }): Promise<VersionedNoneModeBlockResponse | null>;
3374
- /**
3375
- * Fetch parsed transaction details for a confirmed or finalized block
3376
- */
3377
- getParsedBlock(slot: number, rawConfig?: GetVersionedBlockConfig): Promise<ParsedAccountsModeBlockResponse>;
3378
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3379
- transactionDetails: 'accounts';
3380
- }): Promise<ParsedAccountsModeBlockResponse>;
3381
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
3382
- transactionDetails: 'none';
3383
- }): Promise<ParsedNoneModeBlockResponse>;
3384
- getBlockHeight: (commitmentOrConfig?: Commitment | GetBlockHeightConfig) => Promise<number>;
3385
- getBlockProduction(configOrCommitment?: GetBlockProductionConfig | Commitment): Promise<RpcResponseAndContext<BlockProduction>>;
3386
- /**
3387
- * Fetch a confirmed or finalized transaction from the cluster.
3388
- *
3389
- * @deprecated Instead, call `getTransaction` using a
3390
- * `GetVersionedTransactionConfig` by setting the
3391
- * `maxSupportedTransactionVersion` property.
3392
- */
3393
- getTransaction(signature: string, rawConfig?: GetTransactionConfig): Promise<TransactionResponse | null>;
3394
- /**
3395
- * Fetch a confirmed or finalized transaction from the cluster.
3396
- */
3397
- getTransaction(signature: string, rawConfig: GetVersionedTransactionConfig): Promise<VersionedTransactionResponse | null>;
3398
- /**
3399
- * Fetch parsed transaction details for a confirmed or finalized transaction
3400
- */
3401
- getParsedTransaction(signature: TransactionSignature, commitmentOrConfig?: GetVersionedTransactionConfig | Finality): Promise<ParsedTransactionWithMeta | null>;
3402
- /**
3403
- * Fetch parsed transaction details for a batch of confirmed transactions
3404
- */
3405
- getParsedTransactions(signatures: TransactionSignature[], commitmentOrConfig?: GetVersionedTransactionConfig | Finality): Promise<(ParsedTransactionWithMeta | null)[]>;
3406
- /**
3407
- * Fetch transaction details for a batch of confirmed transactions.
3408
- * Similar to {@link getParsedTransactions} but returns a {@link TransactionResponse}.
3409
- *
3410
- * @deprecated Instead, call `getTransactions` using a
3411
- * `GetVersionedTransactionConfig` by setting the
3412
- * `maxSupportedTransactionVersion` property.
3413
- */
3414
- getTransactions(signatures: TransactionSignature[], commitmentOrConfig?: GetTransactionConfig | Finality): Promise<(TransactionResponse | null)[]>;
3415
- /**
3416
- * Fetch transaction details for a batch of confirmed transactions.
3417
- * Similar to {@link getParsedTransactions} but returns a {@link
3418
- * VersionedTransactionResponse}.
3419
- */
3420
- getTransactions(signatures: TransactionSignature[], commitmentOrConfig: GetVersionedTransactionConfig | Finality): Promise<(VersionedTransactionResponse | null)[]>;
3421
- /**
3422
- * Fetch a list of Transactions and transaction statuses from the cluster
3423
- * for a confirmed block.
3424
- *
3425
- * @deprecated Deprecated since v1.13.0. Please use {@link getBlock} instead.
3426
- */
3427
- getConfirmedBlock(slot: number, commitment?: Finality): Promise<ConfirmedBlock>;
3428
- /**
3429
- * Fetch confirmed blocks between two slots
3430
- */
3431
- getBlocks(startSlot: number, endSlot?: number, commitment?: Finality): Promise<Array<number>>;
3432
- /**
3433
- * Fetch a list of Signatures from the cluster for a block, excluding rewards
3434
- */
3435
- getBlockSignatures(slot: number, commitment?: Finality): Promise<BlockSignatures>;
3436
- /**
3437
- * Fetch a list of Signatures from the cluster for a confirmed block, excluding rewards
3438
- *
3439
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getBlockSignatures} instead.
3440
- */
3441
- getConfirmedBlockSignatures(slot: number, commitment?: Finality): Promise<BlockSignatures>;
3442
- /**
3443
- * Fetch a transaction details for a confirmed transaction
3444
- *
3445
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getTransaction} instead.
3446
- */
3447
- getConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ConfirmedTransaction | null>;
3448
- /**
3449
- * Fetch parsed transaction details for a confirmed transaction
3450
- *
3451
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransaction} instead.
3452
- */
3453
- getParsedConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ParsedConfirmedTransaction | null>;
3454
- /**
3455
- * Fetch parsed transaction details for a batch of confirmed transactions
3456
- *
3457
- * @deprecated Deprecated since Solana v1.8.0. Please use {@link getParsedTransactions} instead.
3458
- */
3459
- getParsedConfirmedTransactions(signatures: TransactionSignature[], commitment?: Finality): Promise<(ParsedConfirmedTransaction | null)[]>;
3460
- /**
3461
- * Fetch a list of all the confirmed signatures for transactions involving an address
3462
- * within a specified slot range. Max range allowed is 10,000 slots.
3463
- *
3464
- * @deprecated Deprecated since v1.3. Please use {@link getConfirmedSignaturesForAddress2} instead.
3465
- *
3466
- * @param address queried address
3467
- * @param startSlot start slot, inclusive
3468
- * @param endSlot end slot, inclusive
3469
- */
3470
- getConfirmedSignaturesForAddress(address: PublicKey, startSlot: number, endSlot: number): Promise<Array<TransactionSignature>>;
3471
- /**
3472
- * Returns confirmed signatures for transactions involving an
3473
- * address backwards in time from the provided signature or most recent confirmed block
3474
- *
3475
- *
3476
- * @param address queried address
3477
- * @param options
3478
- */
3479
- getConfirmedSignaturesForAddress2(address: PublicKey, options?: ConfirmedSignaturesForAddress2Options, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
3480
- /**
3481
- * Returns confirmed signatures for transactions involving an
3482
- * address backwards in time from the provided signature or most recent confirmed block
3483
- *
3484
- *
3485
- * @param address queried address
3486
- * @param options
3487
- */
3488
- getSignaturesForAddress(address: PublicKey, options?: SignaturesForAddressOptions, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
3489
- getAddressLookupTable(accountKey: PublicKey, config?: GetAccountInfoConfig): Promise<RpcResponseAndContext<AddressLookupTableAccount | null>>;
3490
- /**
3491
- * Fetch the contents of a Nonce account from the cluster, return with context
3492
- */
3493
- getNonceAndContext(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceAndContextConfig): Promise<RpcResponseAndContext<NonceAccount | null>>;
3494
- /**
3495
- * Fetch the contents of a Nonce account from the cluster
3496
- */
3497
- getNonce(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceConfig): Promise<NonceAccount | null>;
3498
- /**
3499
- * Request an allocation of lamports to the specified address
3500
- *
3501
- * ```typescript
3502
- * import { Connection, PublicKey, LAMPORTS_PER_SOL } from "@solana/web3.js";
3503
- *
3504
- * (async () => {
3505
- * const connection = new Connection("https://api.testnet.solana.com", "confirmed");
3506
- * const myAddress = new PublicKey("2nr1bHFT86W9tGnyvmYW4vcHKsQB3sVQfnddasz4kExM");
3507
- * const signature = await connection.requestAirdrop(myAddress, LAMPORTS_PER_SOL);
3508
- * await connection.confirmTransaction(signature);
3509
- * })();
3510
- * ```
3511
- */
3512
- requestAirdrop(to: PublicKey, lamports: number): Promise<TransactionSignature>;
3513
- /**
3514
- * get the stake minimum delegation
3515
- */
3516
- getStakeMinimumDelegation(config?: GetStakeMinimumDelegationConfig): Promise<RpcResponseAndContext<number>>;
3517
- /**
3518
- * Simulate a transaction
3519
- *
3520
- * @deprecated Instead, call {@link simulateTransaction} with {@link
3521
- * VersionedTransaction} and {@link SimulateTransactionConfig} parameters
3522
- */
3523
- simulateTransaction(transactionOrMessage: Transaction | Message, signers?: Array<Signer>, includeAccounts?: boolean | Array<PublicKey>): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
3524
- /**
3525
- * Simulate a transaction
3526
- */
3527
- simulateTransaction(transaction: VersionedTransaction, config?: SimulateTransactionConfig): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
3528
- /**
3529
- * Sign and send a transaction
3530
- *
3531
- * @deprecated Instead, call {@link sendTransaction} with a {@link
3532
- * VersionedTransaction}
3533
- */
3534
- sendTransaction(transaction: Transaction, signers: Array<Signer>, options?: SendOptions): Promise<TransactionSignature>;
3535
- /**
3536
- * Send a signed transaction
3537
- */
3538
- sendTransaction(transaction: VersionedTransaction, options?: SendOptions): Promise<TransactionSignature>;
3539
- /**
3540
- * Send a transaction that has already been signed and serialized into the
3541
- * wire format
3542
- */
3543
- sendRawTransaction(rawTransaction: Buffer | Uint8Array | Array<number>, options?: SendOptions): Promise<TransactionSignature>;
3544
- /**
3545
- * Send a transaction that has already been signed, serialized into the
3546
- * wire format, and encoded as a base64 string
3547
- */
3548
- sendEncodedTransaction(encodedTransaction: string, options?: SendOptions): Promise<TransactionSignature>;
3549
- /**
3550
- * Register a callback to be invoked whenever the specified account changes
3551
- *
3552
- * @param publicKey Public key of the account to monitor
3553
- * @param callback Function to invoke whenever the account is changed
3554
- * @param commitment Specify the commitment level account changes must reach before notification
3555
- * @return subscription id
3556
- */
3557
- onAccountChange(publicKey: PublicKey, callback: AccountChangeCallback, commitment?: Commitment): ClientSubscriptionId;
3558
- /**
3559
- * Deregister an account notification callback
3560
- *
3561
- * @param id client subscription id to deregister
3562
- */
3563
- removeAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3564
- /**
3565
- * Register a callback to be invoked whenever accounts owned by the
3566
- * specified program change
3567
- *
3568
- * @param programId Public key of the program to monitor
3569
- * @param callback Function to invoke whenever the account is changed
3570
- * @param commitment Specify the commitment level account changes must reach before notification
3571
- * @param filters The program account filters to pass into the RPC method
3572
- * @return subscription id
3573
- */
3574
- onProgramAccountChange(programId: PublicKey, callback: ProgramAccountChangeCallback, commitment?: Commitment, filters?: GetProgramAccountsFilter[]): ClientSubscriptionId;
3575
- /**
3576
- * Deregister an account notification callback
3577
- *
3578
- * @param id client subscription id to deregister
3579
- */
3580
- removeProgramAccountChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3581
- /**
3582
- * Registers a callback to be invoked whenever logs are emitted.
3583
- */
3584
- onLogs(filter: LogsFilter, callback: LogsCallback, commitment?: Commitment): ClientSubscriptionId;
3585
- /**
3586
- * Deregister a logs callback.
3587
- *
3588
- * @param id client subscription id to deregister.
3589
- */
3590
- removeOnLogsListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3591
- /**
3592
- * Register a callback to be invoked upon slot changes
3593
- *
3594
- * @param callback Function to invoke whenever the slot changes
3595
- * @return subscription id
3596
- */
3597
- onSlotChange(callback: SlotChangeCallback): ClientSubscriptionId;
3598
- /**
3599
- * Deregister a slot notification callback
3600
- *
3601
- * @param id client subscription id to deregister
3602
- */
3603
- removeSlotChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3604
- /**
3605
- * Register a callback to be invoked upon slot updates. {@link SlotUpdate}'s
3606
- * may be useful to track live progress of a cluster.
3607
- *
3608
- * @param callback Function to invoke whenever the slot updates
3609
- * @return subscription id
3610
- */
3611
- onSlotUpdate(callback: SlotUpdateCallback): ClientSubscriptionId;
3612
- /**
3613
- * Deregister a slot update notification callback
3614
- *
3615
- * @param id client subscription id to deregister
3616
- */
3617
- removeSlotUpdateListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3618
- _buildArgs(args: Array<any>, override?: Commitment, encoding?: 'jsonParsed' | 'base64', extra?: any): Array<any>;
3619
- /**
3620
- * Register a callback to be invoked upon signature updates
3621
- *
3622
- * @param signature Transaction signature string in base 58
3623
- * @param callback Function to invoke on signature notifications
3624
- * @param commitment Specify the commitment level signature must reach before notification
3625
- * @return subscription id
3626
- */
3627
- onSignature(signature: TransactionSignature, callback: SignatureResultCallback, commitment?: Commitment): ClientSubscriptionId;
3628
- /**
3629
- * Register a callback to be invoked when a transaction is
3630
- * received and/or processed.
3631
- *
3632
- * @param signature Transaction signature string in base 58
3633
- * @param callback Function to invoke on signature notifications
3634
- * @param options Enable received notifications and set the commitment
3635
- * level that signature must reach before notification
3636
- * @return subscription id
3637
- */
3638
- onSignatureWithOptions(signature: TransactionSignature, callback: SignatureSubscriptionCallback, options?: SignatureSubscriptionOptions): ClientSubscriptionId;
3639
- /**
3640
- * Deregister a signature notification callback
3641
- *
3642
- * @param id client subscription id to deregister
3643
- */
3644
- removeSignatureListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3645
- /**
3646
- * Register a callback to be invoked upon root changes
3647
- *
3648
- * @param callback Function to invoke whenever the root changes
3649
- * @return subscription id
3650
- */
3651
- onRootChange(callback: RootChangeCallback): ClientSubscriptionId;
3652
- /**
3653
- * Deregister a root notification callback
3654
- *
3655
- * @param id client subscription id to deregister
3656
- */
3657
- removeRootChangeListener(clientSubscriptionId: ClientSubscriptionId): Promise<void>;
3658
- }
3659
-
3660
- export const BPF_LOADER_PROGRAM_ID: PublicKey;
3661
- /**
3662
- * Factory class for transactions to interact with a program loader
3663
- */
3664
- export class BpfLoader {
3665
- /**
3666
- * Minimum number of signatures required to load a program not including
3667
- * retries
3668
- *
3669
- * Can be used to calculate transaction fees
3670
- */
3671
- static getMinNumSignatures(dataLength: number): number;
3672
- /**
3673
- * Load a SBF program
3674
- *
3675
- * @param connection The connection to use
3676
- * @param payer Account that will pay program loading fees
3677
- * @param program Account to load the program into
3678
- * @param elf The entire ELF containing the SBF program
3679
- * @param loaderProgramId The program id of the BPF loader to use
3680
- * @return true if program was loaded successfully, false if program was already loaded
3681
- */
3682
- static load(connection: Connection, payer: Signer, program: Signer, elf: Buffer | Uint8Array | Array<number>, loaderProgramId: PublicKey): Promise<boolean>;
3683
- }
3684
-
3685
- export class SendTransactionError extends Error {
3686
- logs: string[] | undefined;
3687
- constructor(message: string, logs?: string[]);
3688
- }
3689
- export const SolanaJSONRPCErrorCode: {
3690
- readonly JSON_RPC_SERVER_ERROR_BLOCK_CLEANED_UP: -32001;
3691
- readonly JSON_RPC_SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE: -32002;
3692
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_VERIFICATION_FAILURE: -32003;
3693
- readonly JSON_RPC_SERVER_ERROR_BLOCK_NOT_AVAILABLE: -32004;
3694
- readonly JSON_RPC_SERVER_ERROR_NODE_UNHEALTHY: -32005;
3695
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_PRECOMPILE_VERIFICATION_FAILURE: -32006;
3696
- readonly JSON_RPC_SERVER_ERROR_SLOT_SKIPPED: -32007;
3697
- readonly JSON_RPC_SERVER_ERROR_NO_SNAPSHOT: -32008;
3698
- readonly JSON_RPC_SERVER_ERROR_LONG_TERM_STORAGE_SLOT_SKIPPED: -32009;
3699
- readonly JSON_RPC_SERVER_ERROR_KEY_EXCLUDED_FROM_SECONDARY_INDEX: -32010;
3700
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_HISTORY_NOT_AVAILABLE: -32011;
3701
- readonly JSON_RPC_SCAN_ERROR: -32012;
3702
- readonly JSON_RPC_SERVER_ERROR_TRANSACTION_SIGNATURE_LEN_MISMATCH: -32013;
3703
- readonly JSON_RPC_SERVER_ERROR_BLOCK_STATUS_NOT_AVAILABLE_YET: -32014;
3704
- readonly JSON_RPC_SERVER_ERROR_UNSUPPORTED_TRANSACTION_VERSION: -32015;
3705
- readonly JSON_RPC_SERVER_ERROR_MIN_CONTEXT_SLOT_NOT_REACHED: -32016;
3706
- };
3707
- type SolanaJSONRPCErrorCodeEnum = (typeof SolanaJSONRPCErrorCode)[keyof typeof SolanaJSONRPCErrorCode];
3708
- export class SolanaJSONRPCError extends Error {
3709
- code: SolanaJSONRPCErrorCodeEnum | unknown;
3710
- data?: any;
3711
- constructor({ code, message, data, }: Readonly<{
3712
- code: unknown;
3713
- message: string;
3714
- data?: any;
3715
- }>, customMessage?: string);
3716
- }
3717
-
3718
- /**
3719
- * Program loader interface
3720
- */
3721
- export class Loader {
3722
- /**
3723
- * Amount of program data placed in each load Transaction
3724
- */
3725
- static chunkSize: number;
3726
- /**
3727
- * Minimum number of signatures required to load a program not including
3728
- * retries
3729
- *
3730
- * Can be used to calculate transaction fees
3731
- */
3732
- static getMinNumSignatures(dataLength: number): number;
3733
- /**
3734
- * Loads a generic program
3735
- *
3736
- * @param connection The connection to use
3737
- * @param payer System account that pays to load the program
3738
- * @param program Account to load the program into
3739
- * @param programId Public key that identifies the loader
3740
- * @param data Program octets
3741
- * @return true if program was loaded successfully, false if program was already loaded
3742
- */
3743
- static load(connection: Connection, payer: Signer, program: Signer, programId: PublicKey, data: Buffer | Uint8Array | Array<number>): Promise<boolean>;
3744
- }
3745
-
3746
- export const VALIDATOR_INFO_KEY: PublicKey;
3747
- /**
3748
- * Info used to identity validators.
3749
- */
3750
- type Info = {
3751
- /** validator name */
3752
- name: string;
3753
- /** optional, validator website */
3754
- website?: string;
3755
- /** optional, extra information the validator chose to share */
3756
- details?: string;
3757
- /** optional, used to identify validators on keybase.io */
3758
- keybaseUsername?: string;
3759
- };
3760
- /**
3761
- * ValidatorInfo class
3762
- */
3763
- export class ValidatorInfo {
3764
- /**
3765
- * validator public key
3766
- */
3767
- key: PublicKey;
3768
- /**
3769
- * validator information
3770
- */
3771
- info: Info;
3772
- /**
3773
- * Construct a valid ValidatorInfo
3774
- *
3775
- * @param key validator public key
3776
- * @param info validator information
3777
- */
3778
- constructor(key: PublicKey, info: Info);
3779
- /**
3780
- * Deserialize ValidatorInfo from the config account data. Exactly two config
3781
- * keys are required in the data.
3782
- *
3783
- * @param buffer config account data
3784
- * @return null if info was not found
3785
- */
3786
- static fromConfigData(buffer: Buffer | Uint8Array | Array<number>): ValidatorInfo | null;
3787
- }
3788
-
3789
- export const VOTE_PROGRAM_ID: PublicKey;
3790
- type Lockout = {
3791
- slot: number;
3792
- confirmationCount: number;
3793
- };
3794
- /**
3795
- * History of how many credits earned by the end of each epoch
3796
- */
3797
- type EpochCredits = Readonly<{
3798
- epoch: number;
3799
- credits: number;
3800
- prevCredits: number;
3801
- }>;
3802
- type AuthorizedVoter = Readonly<{
3803
- epoch: number;
3804
- authorizedVoter: PublicKey;
3805
- }>;
3806
- type PriorVoter = Readonly<{
3807
- authorizedPubkey: PublicKey;
3808
- epochOfLastAuthorizedSwitch: number;
3809
- targetEpoch: number;
3810
- }>;
3811
- type BlockTimestamp = Readonly<{
3812
- slot: number;
3813
- timestamp: number;
3814
- }>;
3815
- /**
3816
- * VoteAccount class
3817
- */
3818
- export class VoteAccount {
3819
- nodePubkey: PublicKey;
3820
- authorizedWithdrawer: PublicKey;
3821
- commission: number;
3822
- rootSlot: number | null;
3823
- votes: Lockout[];
3824
- authorizedVoters: AuthorizedVoter[];
3825
- priorVoters: PriorVoter[];
3826
- epochCredits: EpochCredits[];
3827
- lastTimestamp: BlockTimestamp;
3828
- /**
3829
- * Deserialize VoteAccount from the account data.
3830
- *
3831
- * @param buffer account data
3832
- * @return VoteAccount
3833
- */
3834
- static fromAccountData(buffer: Buffer | Uint8Array | Array<number>): VoteAccount;
3835
- }
3836
-
3837
- export const SYSVAR_CLOCK_PUBKEY: PublicKey;
3838
- export const SYSVAR_EPOCH_SCHEDULE_PUBKEY: PublicKey;
3839
- export const SYSVAR_INSTRUCTIONS_PUBKEY: PublicKey;
3840
- export const SYSVAR_RECENT_BLOCKHASHES_PUBKEY: PublicKey;
3841
- export const SYSVAR_RENT_PUBKEY: PublicKey;
3842
- export const SYSVAR_REWARDS_PUBKEY: PublicKey;
3843
- export const SYSVAR_SLOT_HASHES_PUBKEY: PublicKey;
3844
- export const SYSVAR_SLOT_HISTORY_PUBKEY: PublicKey;
3845
- export const SYSVAR_STAKE_HISTORY_PUBKEY: PublicKey;
3846
-
3847
- type Cluster = 'devnet' | 'testnet' | 'mainnet-beta';
3848
- /**
3849
- * Retrieves the RPC API URL for the specified cluster
3850
- */
3851
- export function clusterApiUrl(cluster?: Cluster, tls?: boolean): string;
3852
-
3853
- /**
3854
- * Send and confirm a raw transaction
3855
- *
3856
- * If `commitment` option is not specified, defaults to 'max' commitment.
3857
- *
3858
- * @param {Connection} connection
3859
- * @param {Buffer} rawTransaction
3860
- * @param {TransactionConfirmationStrategy} confirmationStrategy
3861
- * @param {ConfirmOptions} [options]
3862
- * @returns {Promise<TransactionSignature>}
3863
- */
3864
- export function sendAndConfirmRawTransaction(connection: Connection, rawTransaction: Buffer, confirmationStrategy: TransactionConfirmationStrategy, options?: ConfirmOptions): Promise<TransactionSignature>;
3865
- /**
3866
- * @deprecated Calling `sendAndConfirmRawTransaction()` without a `confirmationStrategy`
3867
- * is no longer supported and will be removed in a future version.
3868
- */
3869
- export function sendAndConfirmRawTransaction(connection: Connection, rawTransaction: Buffer, options?: ConfirmOptions): Promise<TransactionSignature>;
3870
-
3871
- /**
3872
- * Sign, send and confirm a transaction.
3873
- *
3874
- * If `commitment` option is not specified, defaults to 'max' commitment.
3875
- *
3876
- * @param {Connection} connection
3877
- * @param {Transaction} transaction
3878
- * @param {Array<Signer>} signers
3879
- * @param {ConfirmOptions} [options]
3880
- * @returns {Promise<TransactionSignature>}
3881
- */
3882
- export function sendAndConfirmTransaction(connection: Connection, transaction: Transaction, signers: Array<Signer>, options?: ConfirmOptions & Readonly<{
3883
- abortSignal?: AbortSignal;
3884
- }>): Promise<TransactionSignature>;
3885
-
3886
- /**
3887
- * There are 1-billion lamports in one SOL
3888
- */
3889
- export const LAMPORTS_PER_SOL = 1000000000;
3890
-
3891
- }