@thru/thru-sdk 0.1.34 → 0.1.36

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.
@@ -0,0 +1,930 @@
1
+ import { Pubkey as Pubkey$1, TaPubkey, Signature as Signature$1, TsSignature, TransactionVmError, Transaction as Transaction$1, TransactionExecutionResult, ConsensusStatus, TransactionStatus, AccountFlags as AccountFlags$1, AccountMeta as AccountMeta$1, AccountData as AccountData$1, Account as Account$1, FilterParamValue as FilterParamValue$1, Filter as Filter$1, PageRequest as PageRequest$1, PageResponse as PageResponse$1, AccountView, VersionContext, DataSlice, RawAccount, ExecutionStatus, BlockFooter as BlockFooter$1, BlockHeader as BlockHeader$1, Block as Block$1, BlockView, RawBlock, Event, StreamEventsResponse, StateProof as StateProof$1, StateProofType, TransactionView, RawTransaction, BatchSendTransactionsResponse, GetVersionResponse } from '@thru/proto';
2
+ import { Timestamp } from '@bufbuild/protobuf/wkt';
3
+ import { Transport, createClient, CallOptions, Interceptor } from '@connectrpc/connect';
4
+ import { GrpcWebTransportOptions } from '@connectrpc/connect-web';
5
+
6
+ type PubkeyInput = Uint8Array | string | Pubkey;
7
+ declare class Pubkey {
8
+ private readonly bytes;
9
+ private constructor();
10
+ static from(value: PubkeyInput): Pubkey;
11
+ static isThruFmt(value: string): boolean;
12
+ toBytes(): Uint8Array;
13
+ toBytesUnsafe(): Uint8Array;
14
+ toThruFmt(): string;
15
+ toHex(): string;
16
+ equals(other: PubkeyInput): boolean;
17
+ toProtoPubkey(): Pubkey$1;
18
+ toProtoTaPubkey(): TaPubkey;
19
+ static fromProtoPubkey(proto?: Pubkey$1): Pubkey;
20
+ static fromProtoTaPubkey(proto?: TaPubkey): Pubkey;
21
+ private static bytesFromString;
22
+ }
23
+
24
+ type SignatureInput = Uint8Array | string | Signature;
25
+ declare class Signature {
26
+ private readonly bytes;
27
+ private constructor();
28
+ static from(value: SignatureInput): Signature;
29
+ static fromProto(proto?: Signature$1): Signature;
30
+ static isThruFmt(value: string): boolean;
31
+ toBytes(): Uint8Array;
32
+ toBytesUnsafe(): Uint8Array;
33
+ toThruFmt(): string;
34
+ toHex(): string;
35
+ equals(other: SignatureInput): boolean;
36
+ toProtoSignature(): Signature$1;
37
+ toProtoTsSignature(): TsSignature;
38
+ static fromProtoTsSignature(proto?: TsSignature): Signature;
39
+ static fromProtoSignature(proto?: Signature$1): Signature;
40
+ private static bytesFromString;
41
+ }
42
+
43
+ interface ResourceLimits {
44
+ computeUnits?: number;
45
+ stateUnits?: number;
46
+ memoryUnits?: number;
47
+ }
48
+ interface OptionalProofs {
49
+ feePayerStateProof?: Uint8Array;
50
+ feePayerAccountMetaRaw?: Uint8Array;
51
+ }
52
+ interface TransactionHeaderInput extends ResourceLimits {
53
+ fee: bigint;
54
+ nonce: bigint;
55
+ startSlot: bigint;
56
+ expiryAfter?: number;
57
+ flags?: number;
58
+ }
59
+ interface TransactionAccountsInput {
60
+ readWriteAccounts?: PubkeyInput[];
61
+ readOnlyAccounts?: PubkeyInput[];
62
+ }
63
+ /**
64
+ * Context provided to instruction data functions.
65
+ * Contains all transaction accounts in their final sorted order and helper functions
66
+ * for looking up account indexes.
67
+ */
68
+ interface InstructionContext {
69
+ /** All accounts in final transaction order: [feePayer, program, ...readWrite, ...readOnly] */
70
+ accounts: Pubkey[];
71
+ /** Get the index of an account by its public key. Throws if account is not found in transaction. */
72
+ getAccountIndex: (pubkey: PubkeyInput) => number;
73
+ }
74
+ interface FeePayerInput {
75
+ publicKey: PubkeyInput;
76
+ privateKey?: Uint8Array;
77
+ }
78
+ interface BuildTransactionParams {
79
+ feePayer: FeePayerInput;
80
+ program: PubkeyInput;
81
+ header: TransactionHeaderInput;
82
+ accounts?: TransactionAccountsInput;
83
+ instructionData?: Uint8Array | string;
84
+ proofs?: OptionalProofs;
85
+ }
86
+ interface BuiltTransactionResult {
87
+ transaction: TransactionLike;
88
+ }
89
+ interface SignedTransactionResult extends BuiltTransactionResult {
90
+ signature: Signature;
91
+ rawTransaction: Uint8Array;
92
+ }
93
+ interface TransactionLike {
94
+ toWire(): Uint8Array;
95
+ }
96
+
97
+ interface TransactionExecutionEvent {
98
+ eventId: string;
99
+ callIdx: number;
100
+ programIdx: number;
101
+ program?: Pubkey;
102
+ payload: Uint8Array;
103
+ }
104
+ interface TransactionExecutionResultData {
105
+ consumedComputeUnits: number;
106
+ consumedMemoryUnits: number;
107
+ consumedStateUnits: number;
108
+ userErrorCode: bigint;
109
+ vmError: TransactionVmError;
110
+ executionResult: bigint;
111
+ pagesUsed: number;
112
+ eventsCount: number;
113
+ eventsSize: number;
114
+ readwriteAccounts: Pubkey[];
115
+ readonlyAccounts: Pubkey[];
116
+ events?: TransactionExecutionEvent[];
117
+ }
118
+ declare class Transaction {
119
+ readonly version: number;
120
+ readonly feePayer: Pubkey;
121
+ readonly program: Pubkey;
122
+ readonly fee: bigint;
123
+ readonly nonce: bigint;
124
+ readonly startSlot: bigint;
125
+ readonly expiryAfter: number;
126
+ readonly requestedComputeUnits: number;
127
+ readonly requestedStateUnits: number;
128
+ readonly requestedMemoryUnits: number;
129
+ readonly flags: number;
130
+ readonly readWriteAccounts: Pubkey[];
131
+ readonly readOnlyAccounts: Pubkey[];
132
+ readonly instructionData?: Uint8Array;
133
+ readonly instructionDataSize?: number;
134
+ readonly feePayerStateProof?: Uint8Array;
135
+ readonly feePayerAccountMetaRaw?: Uint8Array;
136
+ executionResult?: TransactionExecutionResultData;
137
+ slot?: bigint;
138
+ blockOffset?: number;
139
+ private signature?;
140
+ constructor(params: {
141
+ version?: number;
142
+ feePayer: PubkeyInput;
143
+ program: PubkeyInput;
144
+ header: TransactionHeaderInput;
145
+ accounts?: TransactionAccountsInput;
146
+ instructionData?: Uint8Array;
147
+ instructionDataSize?: number;
148
+ proofs?: OptionalProofs;
149
+ });
150
+ static fromWire(data: Uint8Array): Transaction;
151
+ static parseWire(data: Uint8Array, options?: {
152
+ strict?: boolean;
153
+ }): {
154
+ transaction: Transaction;
155
+ size: number;
156
+ };
157
+ static fromProto(proto: Transaction$1): Transaction;
158
+ getSignature(): Signature | undefined;
159
+ setSignature(signature: Signature): void;
160
+ sign(privateKey: Uint8Array): Promise<Signature>;
161
+ toWireForSigning(): Uint8Array;
162
+ toWire(): Uint8Array;
163
+ private createHeader;
164
+ private buildWirePayload;
165
+ private static parseBodySections;
166
+ private static ensureAvailable;
167
+ private static parseStateProof;
168
+ static executionResultFromProto(proto: TransactionExecutionResult): TransactionExecutionResultData;
169
+ }
170
+
171
+ type StreamTransactionUpdate = {
172
+ kind: "partial";
173
+ signature: Uint8Array;
174
+ slot?: bigint;
175
+ executionResult?: ReturnType<typeof Transaction.executionResultFromProto>;
176
+ } | {
177
+ kind: "full";
178
+ transaction: Transaction;
179
+ };
180
+ interface TrackTransactionUpdate {
181
+ signature?: Uint8Array;
182
+ status: string;
183
+ statusCode: ConsensusStatus;
184
+ executionResult?: ReturnType<typeof Transaction.executionResultFromProto>;
185
+ transaction?: Transaction;
186
+ }
187
+
188
+ interface TransactionStatusParams {
189
+ signature: Uint8Array;
190
+ consensusStatus?: ConsensusStatus;
191
+ executionResult?: ReturnType<typeof Transaction.executionResultFromProto>;
192
+ }
193
+ declare class TransactionStatusSnapshot {
194
+ readonly signature: Uint8Array;
195
+ readonly statusCode?: ConsensusStatus;
196
+ readonly status?: string;
197
+ readonly executionResult?: ReturnType<typeof Transaction.executionResultFromProto>;
198
+ constructor(params: TransactionStatusParams);
199
+ static fromProto(proto: TransactionStatus): TransactionStatusSnapshot;
200
+ }
201
+
202
+ type PartialTransportOptions = Partial<GrpcWebTransportOptions>;
203
+ interface ThruClientConfig {
204
+ baseUrl?: string;
205
+ transport?: Transport;
206
+ transportOptions?: PartialTransportOptions;
207
+ interceptors?: Interceptor[];
208
+ callOptions?: CallOptions;
209
+ }
210
+ type QueryClient = ReturnType<typeof createClient<typeof QueryService>>;
211
+ type CommandClient = ReturnType<typeof createClient<typeof CommandService>>;
212
+ type StreamingClient = ReturnType<typeof createClient<typeof StreamingService>>;
213
+ interface ThruClientContext {
214
+ baseUrl: string;
215
+ transport: Transport;
216
+ query: QueryClient;
217
+ command: CommandClient;
218
+ streaming: StreamingClient;
219
+ callOptions?: CallOptions;
220
+ }
221
+
222
+ interface AccountFlagsData {
223
+ isProgram: boolean;
224
+ isPrivileged: boolean;
225
+ isUncompressable: boolean;
226
+ isEphemeral: boolean;
227
+ isDeleted: boolean;
228
+ isNew: boolean;
229
+ isCompressed: boolean;
230
+ }
231
+ declare class AccountFlags implements AccountFlagsData {
232
+ readonly isProgram: boolean;
233
+ readonly isPrivileged: boolean;
234
+ readonly isUncompressable: boolean;
235
+ readonly isEphemeral: boolean;
236
+ readonly isDeleted: boolean;
237
+ readonly isNew: boolean;
238
+ readonly isCompressed: boolean;
239
+ constructor(flags?: Partial<AccountFlagsData>);
240
+ static fromProto(flags?: AccountFlags$1): AccountFlags;
241
+ }
242
+ declare class AccountMeta {
243
+ readonly version: number;
244
+ readonly flags: AccountFlags;
245
+ readonly dataSize: number;
246
+ readonly seq: bigint;
247
+ readonly owner?: Pubkey;
248
+ readonly balance: bigint;
249
+ readonly nonce?: bigint;
250
+ constructor(params: {
251
+ version: number;
252
+ flags?: AccountFlags;
253
+ dataSize: number;
254
+ seq: bigint;
255
+ owner?: Pubkey;
256
+ balance: bigint;
257
+ nonce?: bigint;
258
+ });
259
+ static fromProto(meta?: AccountMeta$1): AccountMeta | undefined;
260
+ }
261
+ declare class AccountData {
262
+ readonly data?: Uint8Array;
263
+ readonly compressed: boolean;
264
+ readonly compressionAlgorithm?: string;
265
+ constructor(params: {
266
+ data?: Uint8Array;
267
+ compressed?: boolean;
268
+ compressionAlgorithm?: string;
269
+ });
270
+ static fromProto(data?: AccountData$1): AccountData | undefined;
271
+ }
272
+ interface AccountVersionContext {
273
+ slot?: bigint;
274
+ blockTimestampNs?: bigint;
275
+ }
276
+ declare class Account {
277
+ readonly address: Pubkey;
278
+ readonly meta?: AccountMeta;
279
+ readonly data?: AccountData;
280
+ readonly versionContext?: AccountVersionContext;
281
+ readonly consensusStatus?: ConsensusStatus;
282
+ constructor(params: {
283
+ address: Pubkey;
284
+ meta?: AccountMeta;
285
+ data?: AccountData;
286
+ versionContext?: AccountVersionContext;
287
+ consensusStatus?: ConsensusStatus;
288
+ });
289
+ static fromProto(proto: Account$1): Account;
290
+ }
291
+
292
+ interface AccountPageChunk {
293
+ pageIndex: number;
294
+ pageSize: number;
295
+ data: Uint8Array;
296
+ compressed?: boolean;
297
+ compressionAlgorithm?: string;
298
+ }
299
+ interface AccountSnapshot {
300
+ account: Account;
301
+ }
302
+ interface AccountUpdateDelta {
303
+ slot: bigint;
304
+ meta?: AccountMeta;
305
+ page?: AccountPageChunk;
306
+ deleted?: boolean;
307
+ }
308
+ type StreamAccountUpdate = {
309
+ kind: "snapshot";
310
+ snapshot: AccountSnapshot;
311
+ } | {
312
+ kind: "update";
313
+ update: AccountUpdateDelta;
314
+ };
315
+
316
+ type FilterParamValueCase = "stringValue" | "bytesValue" | "boolValue" | "intValue" | "doubleValue" | "uintValue" | "pubkeyValue" | "signatureValue" | "taPubkeyValue" | "tsSignatureValue";
317
+ declare class FilterParamValue {
318
+ private readonly case?;
319
+ private readonly value?;
320
+ private constructor();
321
+ static none(): FilterParamValue;
322
+ static string(value: string): FilterParamValue;
323
+ static bytes(value: Uint8Array): FilterParamValue;
324
+ static bool(value: boolean): FilterParamValue;
325
+ static int(value: bigint): FilterParamValue;
326
+ static double(value: number): FilterParamValue;
327
+ static uint(value: number | bigint): FilterParamValue;
328
+ static pubkey(value: PubkeyInput): FilterParamValue;
329
+ static signature(value: SignatureInput): FilterParamValue;
330
+ static taPubkey(value: PubkeyInput | string): FilterParamValue;
331
+ static tsSignature(value: SignatureInput): FilterParamValue;
332
+ static fromProto(proto: FilterParamValue$1): FilterParamValue;
333
+ toProto(): FilterParamValue$1;
334
+ getCase(): FilterParamValueCase | undefined;
335
+ getString(): string | undefined;
336
+ getBytes(): Uint8Array | undefined;
337
+ getBool(): boolean | undefined;
338
+ getInt(): bigint | undefined;
339
+ getUint(): bigint | undefined;
340
+ getDouble(): number | undefined;
341
+ getPubkey(): Uint8Array | undefined;
342
+ getSignature(): Uint8Array | undefined;
343
+ getTaPubkey(): string | undefined;
344
+ getTsSignature(): string | undefined;
345
+ }
346
+ interface FilterParamsInit {
347
+ [key: string]: FilterParamValue;
348
+ }
349
+ declare class Filter {
350
+ readonly expression?: string;
351
+ private readonly params;
352
+ constructor(init?: {
353
+ expression?: string;
354
+ params?: FilterParamsInit | Map<string, FilterParamValue> | Iterable<[string, FilterParamValue]>;
355
+ });
356
+ static fromProto(proto: Filter$1): Filter;
357
+ toProto(): Filter$1;
358
+ hasParam(name: string): boolean;
359
+ getParam(name: string): FilterParamValue | undefined;
360
+ listParams(): string[];
361
+ entries(): [string, FilterParamValue][];
362
+ withExpression(expression?: string): Filter;
363
+ withParam(name: string, value: FilterParamValue): Filter;
364
+ withoutParam(name: string): Filter;
365
+ private setParamInternal;
366
+ }
367
+
368
+ interface PageRequestParams {
369
+ pageSize?: number;
370
+ pageToken?: string;
371
+ orderBy?: string;
372
+ }
373
+ declare class PageRequest {
374
+ readonly pageSize?: number;
375
+ readonly pageToken?: string;
376
+ readonly orderBy?: string;
377
+ constructor(params?: PageRequestParams);
378
+ static fromProto(proto?: PageRequest$1): PageRequest | undefined;
379
+ toProto(): PageRequest$1;
380
+ withParams(params: PageRequestParams): PageRequest;
381
+ }
382
+ interface PageResponseParams {
383
+ nextPageToken?: string;
384
+ totalSize?: bigint;
385
+ }
386
+ declare class PageResponse {
387
+ readonly nextPageToken?: string;
388
+ readonly totalSize?: bigint;
389
+ constructor(params?: PageResponseParams);
390
+ static fromProto(proto?: PageResponse$1): PageResponse | undefined;
391
+ toProto(): PageResponse$1;
392
+ hasNextPage(): boolean;
393
+ }
394
+
395
+ interface CreateAccountOptions {
396
+ /** The new account's public key (fee payer). */
397
+ publicKey: PubkeyInput;
398
+ /** Optional overrides for the transaction header. */
399
+ header?: Partial<TransactionHeaderInput>;
400
+ }
401
+ interface AccountQueryOptions {
402
+ view?: AccountView;
403
+ versionContext?: VersionContext;
404
+ minConsensus?: ConsensusStatus;
405
+ dataSlice?: DataSlice;
406
+ }
407
+ interface RawAccountQueryOptions {
408
+ view?: AccountView;
409
+ versionContext?: VersionContext;
410
+ minConsensus?: ConsensusStatus;
411
+ }
412
+ interface ListAccountsOptions {
413
+ view?: AccountView;
414
+ versionContext?: VersionContext;
415
+ filter?: Filter;
416
+ page?: PageRequest;
417
+ minConsensus?: ConsensusStatus;
418
+ }
419
+ interface AccountList {
420
+ accounts: Account[];
421
+ page?: PageResponse;
422
+ }
423
+ declare function getAccount(ctx: ThruClientContext, address: PubkeyInput, options?: AccountQueryOptions): Promise<Account>;
424
+ declare function getRawAccount(ctx: ThruClientContext, address: PubkeyInput, options?: RawAccountQueryOptions): Promise<RawAccount>;
425
+ declare function listAccounts(ctx: ThruClientContext, options: ListAccountsOptions): Promise<AccountList>;
426
+ declare function createAccount(ctx: ThruClientContext, options: CreateAccountOptions): Promise<Transaction>;
427
+
428
+ type accounts_AccountList = AccountList;
429
+ type accounts_AccountQueryOptions = AccountQueryOptions;
430
+ type accounts_CreateAccountOptions = CreateAccountOptions;
431
+ type accounts_ListAccountsOptions = ListAccountsOptions;
432
+ type accounts_RawAccountQueryOptions = RawAccountQueryOptions;
433
+ declare const accounts_createAccount: typeof createAccount;
434
+ declare const accounts_getAccount: typeof getAccount;
435
+ declare const accounts_getRawAccount: typeof getRawAccount;
436
+ declare const accounts_listAccounts: typeof listAccounts;
437
+ declare namespace accounts {
438
+ export { type accounts_AccountList as AccountList, type accounts_AccountQueryOptions as AccountQueryOptions, type accounts_CreateAccountOptions as CreateAccountOptions, type accounts_ListAccountsOptions as ListAccountsOptions, type accounts_RawAccountQueryOptions as RawAccountQueryOptions, accounts_createAccount as createAccount, accounts_getAccount as getAccount, accounts_getRawAccount as getRawAccount, accounts_listAccounts as listAccounts };
439
+ }
440
+
441
+ interface BlockFooterParams {
442
+ signature?: Uint8Array;
443
+ status: ExecutionStatus;
444
+ consumedComputeUnits: bigint;
445
+ consumedStateUnits: number;
446
+ attestorPayment: bigint;
447
+ }
448
+ declare class BlockFooter {
449
+ readonly signature?: Uint8Array;
450
+ readonly status: ExecutionStatus;
451
+ readonly consumedComputeUnits: bigint;
452
+ readonly consumedStateUnits: number;
453
+ readonly attestorPayment: bigint;
454
+ constructor(params: BlockFooterParams);
455
+ static fromProto(proto: BlockFooter$1): BlockFooter;
456
+ }
457
+
458
+ interface BlockHeaderParams {
459
+ slot: bigint;
460
+ version: number;
461
+ headerSignature?: Uint8Array;
462
+ producer?: Uint8Array;
463
+ expiryTimestamp?: Timestamp;
464
+ startSlot: bigint;
465
+ expiryAfter?: number;
466
+ maxBlockSize?: number;
467
+ maxComputeUnits?: bigint;
468
+ maxStateUnits?: number;
469
+ bondAmountLockUp?: bigint;
470
+ weightSlot?: bigint;
471
+ blockHash?: Uint8Array;
472
+ }
473
+ declare class BlockHeader {
474
+ readonly slot: bigint;
475
+ readonly version: number;
476
+ readonly headerSignature?: Uint8Array;
477
+ readonly producer?: Uint8Array;
478
+ readonly expiryTimestamp?: Timestamp;
479
+ readonly startSlot: bigint;
480
+ readonly expiryAfter?: number;
481
+ readonly maxBlockSize?: number;
482
+ readonly maxComputeUnits?: bigint;
483
+ readonly maxStateUnits?: number;
484
+ readonly bondAmountLockUp?: bigint;
485
+ readonly weightSlot?: bigint;
486
+ readonly blockHash?: Uint8Array;
487
+ constructor(params: BlockHeaderParams);
488
+ static fromProto(proto: BlockHeader$1): BlockHeader;
489
+ withBlockHash(blockHash: Uint8Array): BlockHeader;
490
+ }
491
+
492
+ declare class Block {
493
+ readonly header: BlockHeader;
494
+ readonly footer?: BlockFooter;
495
+ readonly body?: Uint8Array;
496
+ readonly consensusStatus?: ConsensusStatus;
497
+ blockTimeNs?: bigint;
498
+ attestorPayment?: bigint;
499
+ constructor(params: {
500
+ header: BlockHeader;
501
+ footer?: BlockFooter;
502
+ body?: Uint8Array;
503
+ consensusStatus?: ConsensusStatus;
504
+ });
505
+ static fromProto(proto: Block$1): Block;
506
+ static fromWire(data: Uint8Array): Block;
507
+ toWire(): Uint8Array;
508
+ getTransactions(): Transaction[];
509
+ private static extractTransactionBody;
510
+ private serializeHeader;
511
+ private serializeFooter;
512
+ private static parseHeader;
513
+ private static parseFooter;
514
+ private static parseTransactionsFromBody;
515
+ }
516
+
517
+ type BlockSelector = {
518
+ slot: number | bigint;
519
+ } | {
520
+ blockHash: Uint8Array | string;
521
+ };
522
+ interface DeriveProgramAddressOptions {
523
+ programAddress: PubkeyInput;
524
+ seed: Uint8Array | string;
525
+ ephemeral?: boolean;
526
+ }
527
+ interface DeriveProgramAddressResult {
528
+ bytes: Uint8Array;
529
+ address: string;
530
+ }
531
+ declare function deriveProgramAddress(options: DeriveProgramAddressOptions): DeriveProgramAddressResult;
532
+ type DeriveAddressInput = PubkeyInput | Uint8Array;
533
+ interface DeriveAddressResult {
534
+ bytes: Uint8Array;
535
+ address: string;
536
+ }
537
+ /**
538
+ * Derive an address by hashing an array of inputs.
539
+ * Inputs can be pubkeys (as string, Uint8Array, or Pubkey) or raw Uint8Array data.
540
+ *
541
+ * @example
542
+ * // Token account: SHA256(owner || mint || seed)
543
+ * deriveAddress([ownerPubkey, mintPubkey, seed])
544
+ *
545
+ * // Mint account: SHA256(creator || seed)
546
+ * deriveAddress([creatorPubkey, seed])
547
+ */
548
+ declare function deriveAddress(inputs: DeriveAddressInput[]): DeriveAddressResult;
549
+
550
+ interface BlockQueryOptions {
551
+ view?: BlockView;
552
+ minConsensus?: ConsensusStatus;
553
+ }
554
+ interface RawBlockQueryOptions {
555
+ minConsensus?: ConsensusStatus;
556
+ }
557
+ interface ListBlocksOptions {
558
+ filter?: Filter;
559
+ page?: PageRequest;
560
+ view?: BlockView;
561
+ minConsensus?: ConsensusStatus;
562
+ }
563
+ interface BlockList {
564
+ blocks: Block[];
565
+ page?: PageResponse;
566
+ }
567
+ declare function getBlock(ctx: ThruClientContext, selector: BlockSelector, options?: BlockQueryOptions): Promise<Block>;
568
+ declare function getRawBlock(ctx: ThruClientContext, selector: BlockSelector, options?: RawBlockQueryOptions): Promise<RawBlock>;
569
+ declare function listBlocks(ctx: ThruClientContext, options?: ListBlocksOptions): Promise<BlockList>;
570
+
571
+ type blocks_BlockList = BlockList;
572
+ type blocks_BlockQueryOptions = BlockQueryOptions;
573
+ type blocks_ListBlocksOptions = ListBlocksOptions;
574
+ type blocks_RawBlockQueryOptions = RawBlockQueryOptions;
575
+ declare const blocks_getBlock: typeof getBlock;
576
+ declare const blocks_getRawBlock: typeof getRawBlock;
577
+ declare const blocks_listBlocks: typeof listBlocks;
578
+ declare namespace blocks {
579
+ export { type blocks_BlockList as BlockList, type blocks_BlockQueryOptions as BlockQueryOptions, type blocks_ListBlocksOptions as ListBlocksOptions, type blocks_RawBlockQueryOptions as RawBlockQueryOptions, blocks_getBlock as getBlock, blocks_getRawBlock as getRawBlock, blocks_listBlocks as listBlocks };
580
+ }
581
+
582
+ declare function consensusStatusToString(status: ConsensusStatus): string;
583
+
584
+ type VersionContextInput = VersionContext | {
585
+ current: true;
586
+ } | {
587
+ currentOrHistorical: true;
588
+ } | {
589
+ slot: number | bigint;
590
+ } | {
591
+ timestamp: Date | number | Timestamp;
592
+ } | {
593
+ seq: number | bigint;
594
+ };
595
+
596
+ declare function currentVersionContext(): VersionContext;
597
+ declare function currentOrHistoricalVersionContext(): VersionContext;
598
+ declare function slotVersionContext(slot: number | bigint): VersionContext;
599
+ declare function timestampVersionContext(value: Date | number | Timestamp): VersionContext;
600
+ declare function seqVersionContext(seq: number | bigint): VersionContext;
601
+ declare function versionContext(input?: VersionContextInput): VersionContext;
602
+
603
+ type consensus_VersionContextInput = VersionContextInput;
604
+ declare const consensus_consensusStatusToString: typeof consensusStatusToString;
605
+ declare const consensus_currentOrHistoricalVersionContext: typeof currentOrHistoricalVersionContext;
606
+ declare const consensus_currentVersionContext: typeof currentVersionContext;
607
+ declare const consensus_seqVersionContext: typeof seqVersionContext;
608
+ declare const consensus_slotVersionContext: typeof slotVersionContext;
609
+ declare const consensus_timestampVersionContext: typeof timestampVersionContext;
610
+ declare const consensus_versionContext: typeof versionContext;
611
+ declare namespace consensus {
612
+ export { type consensus_VersionContextInput as VersionContextInput, consensus_consensusStatusToString as consensusStatusToString, consensus_currentOrHistoricalVersionContext as currentOrHistoricalVersionContext, consensus_currentVersionContext as currentVersionContext, consensus_seqVersionContext as seqVersionContext, consensus_slotVersionContext as slotVersionContext, consensus_timestampVersionContext as timestampVersionContext, consensus_versionContext as versionContext };
613
+ }
614
+
615
+ interface ChainEventParams {
616
+ id: string;
617
+ transactionSignature?: Uint8Array;
618
+ program?: Uint8Array;
619
+ payload?: Uint8Array;
620
+ slot?: bigint;
621
+ callIndex?: number;
622
+ programIndex?: number;
623
+ payloadSize?: number;
624
+ timestampNs?: bigint;
625
+ }
626
+ declare class ChainEvent {
627
+ readonly id: string;
628
+ readonly transactionSignature?: Uint8Array;
629
+ readonly program?: Uint8Array;
630
+ readonly payload?: Uint8Array;
631
+ readonly slot?: bigint;
632
+ readonly callIndex?: number;
633
+ readonly programIndex?: number;
634
+ readonly payloadSize?: number;
635
+ readonly timestampNs?: bigint;
636
+ constructor(params: ChainEventParams);
637
+ static fromQuery(proto: Event): ChainEvent;
638
+ static fromStream(proto: StreamEventsResponse): ChainEvent;
639
+ }
640
+
641
+ interface GetEventOptions {
642
+ versionContext?: VersionContext;
643
+ }
644
+ interface ListEventsOptions {
645
+ filter?: Filter;
646
+ page?: PageRequest;
647
+ versionContext?: VersionContext;
648
+ minConsensus?: ConsensusStatus;
649
+ }
650
+ interface EventList {
651
+ events: ChainEvent[];
652
+ page?: PageResponse;
653
+ }
654
+ declare function getEvent(ctx: ThruClientContext, eventId: string, options?: GetEventOptions): Promise<ChainEvent>;
655
+ declare function listEvents(ctx: ThruClientContext, options?: ListEventsOptions): Promise<EventList>;
656
+
657
+ type events_EventList = EventList;
658
+ type events_GetEventOptions = GetEventOptions;
659
+ type events_ListEventsOptions = ListEventsOptions;
660
+ declare const events_getEvent: typeof getEvent;
661
+ declare const events_listEvents: typeof listEvents;
662
+ declare namespace events {
663
+ export { type events_EventList as EventList, type events_GetEventOptions as GetEventOptions, type events_ListEventsOptions as ListEventsOptions, events_getEvent as getEvent, events_listEvents as listEvents };
664
+ }
665
+
666
+ interface HeightSnapshotParams {
667
+ finalized: bigint;
668
+ locallyExecuted: bigint;
669
+ clusterExecuted: bigint;
670
+ }
671
+ declare class HeightSnapshot {
672
+ readonly finalized: bigint;
673
+ readonly locallyExecuted: bigint;
674
+ readonly clusterExecuted: bigint;
675
+ constructor(params: HeightSnapshotParams);
676
+ static fromProto(proto: {
677
+ finalized: bigint;
678
+ locallyExecuted: bigint;
679
+ clusterExecuted: bigint;
680
+ }): HeightSnapshot;
681
+ delta(other: HeightSnapshot): {
682
+ finalized: bigint;
683
+ locallyExecuted: bigint;
684
+ clusterExecuted: bigint;
685
+ };
686
+ }
687
+
688
+ declare function getBlockHeight(ctx: ThruClientContext): Promise<HeightSnapshot>;
689
+
690
+ declare const height_getBlockHeight: typeof getBlockHeight;
691
+ declare namespace height {
692
+ export { height_getBlockHeight as getBlockHeight };
693
+ }
694
+
695
+ interface GeneratedKeyPair {
696
+ address: string;
697
+ publicKey: Uint8Array;
698
+ privateKey: Uint8Array;
699
+ }
700
+ /**
701
+ * Generates a new Ed25519 keypair using the same HD wallet pipeline as the Thru wallet.
702
+ */
703
+ declare function generateKeyPair(): Promise<GeneratedKeyPair>;
704
+ declare function fromPrivateKey(privateKey: Uint8Array): Promise<Uint8Array>;
705
+
706
+ type keys_GeneratedKeyPair = GeneratedKeyPair;
707
+ declare const keys_fromPrivateKey: typeof fromPrivateKey;
708
+ declare const keys_generateKeyPair: typeof generateKeyPair;
709
+ declare namespace keys {
710
+ export { type keys_GeneratedKeyPair as GeneratedKeyPair, keys_fromPrivateKey as fromPrivateKey, keys_generateKeyPair as generateKeyPair };
711
+ }
712
+
713
+ declare class StateProof {
714
+ readonly proof: Uint8Array;
715
+ readonly slot: bigint;
716
+ constructor(params: {
717
+ proof: Uint8Array;
718
+ slot: bigint;
719
+ });
720
+ static fromProto(proto: StateProof$1): StateProof;
721
+ }
722
+
723
+ type GenerateStateProofOptions = {
724
+ address?: PubkeyInput;
725
+ proofType: StateProofType;
726
+ targetSlot?: bigint;
727
+ };
728
+
729
+ declare function generateStateProof(ctx: ThruClientContext, options: GenerateStateProofOptions): Promise<StateProof>;
730
+
731
+ declare const proofs_generateStateProof: typeof generateStateProof;
732
+ declare namespace proofs {
733
+ export { proofs_generateStateProof as generateStateProof };
734
+ }
735
+
736
+ interface TrackTransactionOptions {
737
+ timeoutMs?: number;
738
+ signal?: AbortSignal;
739
+ }
740
+ interface StreamBlocksOptions {
741
+ startSlot?: bigint;
742
+ filter?: Filter;
743
+ view?: BlockView;
744
+ minConsensus?: ConsensusStatus;
745
+ signal?: AbortSignal;
746
+ }
747
+ interface StreamBlocksResult {
748
+ block: Block;
749
+ }
750
+ declare function streamBlocks(ctx: ThruClientContext, options?: StreamBlocksOptions): AsyncIterable<StreamBlocksResult>;
751
+ interface StreamAccountUpdatesOptions {
752
+ view?: AccountView;
753
+ filter?: Filter;
754
+ signal?: AbortSignal;
755
+ }
756
+ interface StreamAccountUpdatesResult {
757
+ update: StreamAccountUpdate;
758
+ }
759
+ declare function streamAccountUpdates(ctx: ThruClientContext, address: PubkeyInput, options?: StreamAccountUpdatesOptions): AsyncIterable<StreamAccountUpdatesResult>;
760
+ interface StreamTransactionsOptions {
761
+ filter?: Filter;
762
+ minConsensus?: ConsensusStatus;
763
+ signal?: AbortSignal;
764
+ }
765
+ type StreamTransactionsResult = StreamTransactionUpdate;
766
+ declare function streamTransactions(ctx: ThruClientContext, options?: StreamTransactionsOptions): AsyncIterable<StreamTransactionsResult>;
767
+ interface StreamEventsOptions {
768
+ filter?: Filter;
769
+ signal?: AbortSignal;
770
+ }
771
+ interface StreamEventsResult {
772
+ event: ChainEvent;
773
+ }
774
+ declare function streamEvents(ctx: ThruClientContext, options?: StreamEventsOptions): AsyncIterable<StreamEventsResult>;
775
+ declare function trackTransaction(ctx: ThruClientContext, signature: SignatureInput, options?: TrackTransactionOptions): AsyncIterable<TrackTransactionUpdate>;
776
+ interface StreamHeightOptions {
777
+ signal?: AbortSignal;
778
+ }
779
+ interface StreamHeightResult {
780
+ height: HeightSnapshot;
781
+ }
782
+ declare function streamHeight(ctx: ThruClientContext, options?: StreamHeightOptions): AsyncIterable<StreamHeightResult>;
783
+ interface CollectStreamOptions {
784
+ limit?: number;
785
+ signal?: AbortSignal;
786
+ }
787
+ declare function collectStream<T>(iterable: AsyncIterable<T>, options?: CollectStreamOptions): Promise<T[]>;
788
+ declare function firstStreamValue<T>(iterable: AsyncIterable<T>, options?: {
789
+ signal?: AbortSignal;
790
+ }): Promise<T | undefined>;
791
+ declare function forEachStreamValue<T>(iterable: AsyncIterable<T>, handler: (value: T, index: number) => void | Promise<void>, options?: {
792
+ signal?: AbortSignal;
793
+ }): Promise<void>;
794
+
795
+ type streaming_CollectStreamOptions = CollectStreamOptions;
796
+ type streaming_StreamAccountUpdatesOptions = StreamAccountUpdatesOptions;
797
+ type streaming_StreamAccountUpdatesResult = StreamAccountUpdatesResult;
798
+ type streaming_StreamBlocksOptions = StreamBlocksOptions;
799
+ type streaming_StreamBlocksResult = StreamBlocksResult;
800
+ type streaming_StreamEventsOptions = StreamEventsOptions;
801
+ type streaming_StreamEventsResult = StreamEventsResult;
802
+ type streaming_StreamHeightOptions = StreamHeightOptions;
803
+ type streaming_StreamHeightResult = StreamHeightResult;
804
+ type streaming_StreamTransactionUpdate = StreamTransactionUpdate;
805
+ type streaming_StreamTransactionsOptions = StreamTransactionsOptions;
806
+ type streaming_StreamTransactionsResult = StreamTransactionsResult;
807
+ type streaming_TrackTransactionOptions = TrackTransactionOptions;
808
+ type streaming_TrackTransactionUpdate = TrackTransactionUpdate;
809
+ declare const streaming_collectStream: typeof collectStream;
810
+ declare const streaming_firstStreamValue: typeof firstStreamValue;
811
+ declare const streaming_forEachStreamValue: typeof forEachStreamValue;
812
+ declare const streaming_streamAccountUpdates: typeof streamAccountUpdates;
813
+ declare const streaming_streamBlocks: typeof streamBlocks;
814
+ declare const streaming_streamEvents: typeof streamEvents;
815
+ declare const streaming_streamHeight: typeof streamHeight;
816
+ declare const streaming_streamTransactions: typeof streamTransactions;
817
+ declare const streaming_trackTransaction: typeof trackTransaction;
818
+ declare namespace streaming {
819
+ export { type streaming_CollectStreamOptions as CollectStreamOptions, type streaming_StreamAccountUpdatesOptions as StreamAccountUpdatesOptions, type streaming_StreamAccountUpdatesResult as StreamAccountUpdatesResult, type streaming_StreamBlocksOptions as StreamBlocksOptions, type streaming_StreamBlocksResult as StreamBlocksResult, type streaming_StreamEventsOptions as StreamEventsOptions, type streaming_StreamEventsResult as StreamEventsResult, type streaming_StreamHeightOptions as StreamHeightOptions, type streaming_StreamHeightResult as StreamHeightResult, type streaming_StreamTransactionUpdate as StreamTransactionUpdate, type streaming_StreamTransactionsOptions as StreamTransactionsOptions, type streaming_StreamTransactionsResult as StreamTransactionsResult, type streaming_TrackTransactionOptions as TrackTransactionOptions, type streaming_TrackTransactionUpdate as TrackTransactionUpdate, streaming_collectStream as collectStream, streaming_firstStreamValue as firstStreamValue, streaming_forEachStreamValue as forEachStreamValue, streaming_streamAccountUpdates as streamAccountUpdates, streaming_streamBlocks as streamBlocks, streaming_streamEvents as streamEvents, streaming_streamHeight as streamHeight, streaming_streamTransactions as streamTransactions, streaming_trackTransaction as trackTransaction };
820
+ }
821
+
822
+ interface TransactionFeePayerConfig {
823
+ publicKey: PubkeyInput;
824
+ privateKey?: Uint8Array;
825
+ }
826
+ interface TransactionAccountsConfig {
827
+ readWrite?: PubkeyInput[];
828
+ readOnly?: PubkeyInput[];
829
+ }
830
+ interface TransactionHeaderConfig {
831
+ fee?: bigint;
832
+ nonce?: bigint;
833
+ startSlot?: bigint;
834
+ expiryAfter?: number;
835
+ computeUnits?: number;
836
+ stateUnits?: number;
837
+ memoryUnits?: number;
838
+ flags?: number;
839
+ }
840
+ /**
841
+ * Instruction data can be either:
842
+ * - A Uint8Array directly
843
+ * - A function that takes an InstructionContext and returns a Uint8Array
844
+ */
845
+ type InstructionData = Uint8Array | string | ((context: InstructionContext) => Promise<Uint8Array>);
846
+ interface BuildTransactionOptions {
847
+ feePayer: TransactionFeePayerConfig;
848
+ program: PubkeyInput;
849
+ header?: TransactionHeaderConfig;
850
+ accounts?: TransactionAccountsConfig;
851
+ instructionData?: InstructionData;
852
+ feePayerStateProof?: Uint8Array;
853
+ feePayerAccountMetaRaw?: Uint8Array;
854
+ }
855
+ interface BuildAndSignTransactionOptions extends BuildTransactionOptions {
856
+ feePayer: TransactionFeePayerConfig & {
857
+ privateKey: Uint8Array;
858
+ };
859
+ }
860
+ interface TransactionQueryOptions {
861
+ view?: TransactionView;
862
+ versionContext?: VersionContext;
863
+ minConsensus?: ConsensusStatus;
864
+ }
865
+ interface RawTransactionQueryOptions {
866
+ versionContext?: VersionContext;
867
+ minConsensus?: ConsensusStatus;
868
+ }
869
+ interface ListTransactionsForAccountOptions {
870
+ filter?: Filter;
871
+ page?: PageRequest;
872
+ transactionOptions?: TransactionQueryOptions;
873
+ }
874
+ interface TransactionList {
875
+ transactions: Transaction[];
876
+ page?: PageResponse;
877
+ }
878
+ interface ListTransactionsOptions {
879
+ filter?: Filter;
880
+ page?: PageRequest;
881
+ returnEvents?: boolean;
882
+ versionContext?: VersionContext;
883
+ minConsensus?: ConsensusStatus;
884
+ }
885
+ declare function getTransaction(ctx: ThruClientContext, signature: SignatureInput, options?: TransactionQueryOptions): Promise<Transaction>;
886
+ declare function getRawTransaction(ctx: ThruClientContext, signature: SignatureInput, options?: RawTransactionQueryOptions): Promise<RawTransaction>;
887
+ declare function getTransactionStatus(ctx: ThruClientContext, signature: SignatureInput): Promise<TransactionStatusSnapshot>;
888
+ declare function listTransactionsForAccount(ctx: ThruClientContext, account: PubkeyInput, options?: ListTransactionsForAccountOptions): Promise<TransactionList>;
889
+ declare function listTransactions(ctx: ThruClientContext, options?: ListTransactionsOptions): Promise<TransactionList>;
890
+ declare function buildTransaction(ctx: ThruClientContext, options: BuildTransactionOptions): Promise<Transaction>;
891
+ declare function buildAndSignTransaction(ctx: ThruClientContext, options: BuildAndSignTransactionOptions): Promise<SignedTransactionResult>;
892
+ declare function sendTransaction(ctx: ThruClientContext, transaction: Transaction | Uint8Array): Promise<string>;
893
+ interface BatchSendTransactionsOptions {
894
+ numRetries?: number;
895
+ }
896
+ declare function batchSendTransactions(ctx: ThruClientContext, transactions: (Transaction | Uint8Array)[], options?: BatchSendTransactionsOptions): Promise<BatchSendTransactionsResponse>;
897
+
898
+ type transactions_BatchSendTransactionsOptions = BatchSendTransactionsOptions;
899
+ type transactions_BuildAndSignTransactionOptions = BuildAndSignTransactionOptions;
900
+ type transactions_BuildTransactionOptions = BuildTransactionOptions;
901
+ type transactions_InstructionData = InstructionData;
902
+ type transactions_ListTransactionsForAccountOptions = ListTransactionsForAccountOptions;
903
+ type transactions_ListTransactionsOptions = ListTransactionsOptions;
904
+ type transactions_RawTransactionQueryOptions = RawTransactionQueryOptions;
905
+ type transactions_TransactionAccountsConfig = TransactionAccountsConfig;
906
+ type transactions_TransactionFeePayerConfig = TransactionFeePayerConfig;
907
+ type transactions_TransactionHeaderConfig = TransactionHeaderConfig;
908
+ type transactions_TransactionList = TransactionList;
909
+ type transactions_TransactionQueryOptions = TransactionQueryOptions;
910
+ declare const transactions_batchSendTransactions: typeof batchSendTransactions;
911
+ declare const transactions_buildAndSignTransaction: typeof buildAndSignTransaction;
912
+ declare const transactions_buildTransaction: typeof buildTransaction;
913
+ declare const transactions_getRawTransaction: typeof getRawTransaction;
914
+ declare const transactions_getTransaction: typeof getTransaction;
915
+ declare const transactions_getTransactionStatus: typeof getTransactionStatus;
916
+ declare const transactions_listTransactions: typeof listTransactions;
917
+ declare const transactions_listTransactionsForAccount: typeof listTransactionsForAccount;
918
+ declare const transactions_sendTransaction: typeof sendTransaction;
919
+ declare namespace transactions {
920
+ export { type transactions_BatchSendTransactionsOptions as BatchSendTransactionsOptions, type transactions_BuildAndSignTransactionOptions as BuildAndSignTransactionOptions, type transactions_BuildTransactionOptions as BuildTransactionOptions, type transactions_InstructionData as InstructionData, type transactions_ListTransactionsForAccountOptions as ListTransactionsForAccountOptions, type transactions_ListTransactionsOptions as ListTransactionsOptions, type transactions_RawTransactionQueryOptions as RawTransactionQueryOptions, type transactions_TransactionAccountsConfig as TransactionAccountsConfig, type transactions_TransactionFeePayerConfig as TransactionFeePayerConfig, type transactions_TransactionHeaderConfig as TransactionHeaderConfig, type transactions_TransactionList as TransactionList, type transactions_TransactionQueryOptions as TransactionQueryOptions, transactions_batchSendTransactions as batchSendTransactions, transactions_buildAndSignTransaction as buildAndSignTransaction, transactions_buildTransaction as buildTransaction, transactions_getRawTransaction as getRawTransaction, transactions_getTransaction as getTransaction, transactions_getTransactionStatus as getTransactionStatus, transactions_listTransactions as listTransactions, transactions_listTransactionsForAccount as listTransactionsForAccount, transactions_sendTransaction as sendTransaction };
921
+ }
922
+
923
+ declare class VersionInfo {
924
+ readonly components: Record<string, string>;
925
+ constructor(components: Record<string, string>);
926
+ static fromProto(proto: GetVersionResponse): VersionInfo;
927
+ get(component: string): string | undefined;
928
+ }
929
+
930
+ export { type StreamAccountUpdatesResult as $, Account as A, type BuildTransactionParams as B, ChainEvent as C, type AccountQueryOptions as D, type CreateAccountOptions as E, Filter as F, type BlockList as G, HeightSnapshot as H, type BlockQueryOptions as I, type ListBlocksOptions as J, type RawBlockQueryOptions as K, type ListAccountsOptions as L, type GetEventOptions as M, type BlockSelector as N, type DeriveAddressInput as O, PageRequest as P, type DeriveAddressResult as Q, type RawAccountQueryOptions as R, type SignedTransactionResult as S, Transaction as T, type DeriveProgramAddressOptions as U, VersionInfo as V, type DeriveProgramAddressResult as W, type GeneratedKeyPair as X, type StreamAccountUpdate as Y, type HeightSnapshotParams as Z, type StreamAccountUpdatesOptions as _, accounts as a, type StreamBlocksOptions as a0, type StreamBlocksResult as a1, type StreamEventsOptions as a2, type StreamEventsResult as a3, type StreamTransactionsOptions as a4, type StreamTransactionsResult as a5, type StreamTransactionUpdate as a6, type TrackTransactionOptions as a7, type TrackTransactionUpdate as a8, type TransactionExecutionEvent as a9, getTransaction as aA, getRawTransaction as aB, getTransactionStatus as aC, listTransactions as aD, listTransactionsForAccount as aE, streamTransactions as aF, buildTransaction as aG, buildAndSignTransaction as aH, sendTransaction as aI, batchSendTransactions as aJ, trackTransaction as aK, getEvent as aL, listEvents as aM, streamEvents as aN, generateStateProof as aO, generateKeyPair as aP, fromPrivateKey as aQ, consensusStatusToString as aR, versionContext as aS, currentVersionContext as aT, currentOrHistoricalVersionContext as aU, slotVersionContext as aV, timestampVersionContext as aW, seqVersionContext as aX, type ThruClientConfig as aY, type TransactionExecutionResultData as aa, type InstructionContext as ab, type BatchSendTransactionsOptions as ac, type BuildAndSignTransactionOptions as ad, type BuildTransactionOptions as ae, type InstructionData as af, type ListTransactionsForAccountOptions as ag, type RawTransactionQueryOptions as ah, type TransactionAccountsConfig as ai, type TransactionFeePayerConfig as aj, type TransactionHeaderConfig as ak, type TransactionList as al, type TransactionQueryOptions as am, type GenerateStateProofOptions as an, type ThruClientContext as ao, getBlock as ap, getRawBlock as aq, listBlocks as ar, streamBlocks as as, getBlockHeight as at, streamHeight as au, getAccount as av, getRawAccount as aw, listAccounts as ax, streamAccountUpdates as ay, createAccount as az, blocks as b, consensus as c, Block as d, events as e, FilterParamValue as f, PageResponse as g, height as h, Pubkey as i, Signature as j, keys as k, StateProof as l, TransactionStatusSnapshot as m, deriveAddress as n, deriveProgramAddress as o, proofs as p, collectStream as q, firstStreamValue as r, streaming as s, transactions as t, forEachStreamValue as u, type PageRequestParams as v, type PageResponseParams as w, type PubkeyInput as x, type SignatureInput as y, type VersionContextInput as z };