@usearete/sdk 0.1.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +331 -56
- package/dist/index.cjs +6664 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1521 -260
- package/dist/index.esm.js +4603 -1085
- package/dist/index.esm.js.map +1 -1
- package/dist/ssr/handlers.cjs +794 -0
- package/dist/ssr/handlers.cjs.map +1 -0
- package/dist/ssr/handlers.esm.js +523 -4
- package/dist/ssr/handlers.esm.js.map +1 -1
- package/dist/ssr/index.cjs +795 -0
- package/dist/ssr/index.cjs.map +1 -0
- package/dist/ssr/index.esm.js +523 -4
- package/dist/ssr/index.esm.js.map +1 -1
- package/dist/ssr/nextjs-app.cjs +859 -0
- package/dist/ssr/nextjs-app.cjs.map +1 -0
- package/dist/ssr/nextjs-app.esm.js +523 -4
- package/dist/ssr/nextjs-app.esm.js.map +1 -1
- package/dist/ssr/tanstack-start.cjs +881 -0
- package/dist/ssr/tanstack-start.cjs.map +1 -0
- package/dist/ssr/tanstack-start.esm.js +523 -4
- package/dist/ssr/tanstack-start.esm.js.map +1 -1
- package/dist/ssr/vite.cjs +887 -0
- package/dist/ssr/vite.cjs.map +1 -0
- package/dist/ssr/vite.esm.js +523 -4
- package/dist/ssr/vite.esm.js.map +1 -1
- package/package.json +10 -8
- package/dist/index.js +0 -3074
- package/dist/index.js.map +0 -1
- package/dist/ssr/handlers.js +0 -294
- package/dist/ssr/handlers.js.map +0 -1
- package/dist/ssr/index.js +0 -295
- package/dist/ssr/index.js.map +0 -1
- package/dist/ssr/nextjs-app.js +0 -359
- package/dist/ssr/nextjs-app.js.map +0 -1
- package/dist/ssr/tanstack-start.js +0 -381
- package/dist/ssr/tanstack-start.js.map +0 -1
- package/dist/ssr/vite.js +0 -387
- package/dist/ssr/vite.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,211 @@
|
|
|
1
|
+
import { Buffer } from 'buffer';
|
|
2
|
+
|
|
3
|
+
type TransactionCommitment = 'processed' | 'confirmed' | 'finalized';
|
|
4
|
+
type TransactionAuthScope = 'transaction:inspect' | 'transaction:send';
|
|
5
|
+
interface TransactionRequestContext {
|
|
6
|
+
commitment?: TransactionCommitment;
|
|
7
|
+
minContextSlot?: bigint;
|
|
8
|
+
}
|
|
9
|
+
interface LatestBlockhashResult {
|
|
10
|
+
blockhash: string;
|
|
11
|
+
contextSlot: bigint;
|
|
12
|
+
lastValidBlockHeight: bigint;
|
|
13
|
+
}
|
|
14
|
+
interface TransactionFeeResult {
|
|
15
|
+
feeLamports: bigint | null;
|
|
16
|
+
contextSlot: bigint;
|
|
17
|
+
}
|
|
18
|
+
interface TransactionSimulationOptions extends TransactionRequestContext {
|
|
19
|
+
accounts?: readonly string[];
|
|
20
|
+
innerInstructions?: boolean;
|
|
21
|
+
replaceRecentBlockhash?: boolean;
|
|
22
|
+
}
|
|
23
|
+
interface TransactionSimulationResult {
|
|
24
|
+
contextSlot: bigint;
|
|
25
|
+
err: unknown | null;
|
|
26
|
+
logs: readonly string[] | null;
|
|
27
|
+
unitsConsumed?: bigint;
|
|
28
|
+
accounts?: readonly unknown[] | null;
|
|
29
|
+
}
|
|
30
|
+
interface TransactionSendOptions {
|
|
31
|
+
skipPreflight?: boolean;
|
|
32
|
+
preflightCommitment?: TransactionCommitment;
|
|
33
|
+
minContextSlot?: bigint;
|
|
34
|
+
}
|
|
35
|
+
interface TransactionSendResult {
|
|
36
|
+
signature: string;
|
|
37
|
+
}
|
|
38
|
+
interface TransactionSignatureStatus {
|
|
39
|
+
signature: string;
|
|
40
|
+
slot: bigint | null;
|
|
41
|
+
confirmationStatus: TransactionCommitment | null;
|
|
42
|
+
err: unknown | null;
|
|
43
|
+
}
|
|
44
|
+
interface TransactionTransportErrorBody {
|
|
45
|
+
code: string;
|
|
46
|
+
message: string;
|
|
47
|
+
retryable: boolean;
|
|
48
|
+
request_id?: string;
|
|
49
|
+
submission_state?: 'not_submitted' | 'unknown';
|
|
50
|
+
signature?: string;
|
|
51
|
+
details?: unknown;
|
|
52
|
+
}
|
|
53
|
+
declare class TransactionTransportError extends Error {
|
|
54
|
+
readonly code: string;
|
|
55
|
+
readonly retryable: boolean;
|
|
56
|
+
readonly requestId?: string;
|
|
57
|
+
readonly submissionState?: 'not_submitted' | 'unknown';
|
|
58
|
+
readonly signature?: string;
|
|
59
|
+
readonly details?: unknown;
|
|
60
|
+
readonly status: number;
|
|
61
|
+
constructor(status: number, body: TransactionTransportErrorBody);
|
|
62
|
+
}
|
|
63
|
+
interface TransactionTransport {
|
|
64
|
+
getLatestBlockhash(options?: TransactionRequestContext): Promise<LatestBlockhashResult>;
|
|
65
|
+
getFeeForMessage(message: string, options?: TransactionRequestContext): Promise<TransactionFeeResult>;
|
|
66
|
+
simulateTransaction(transaction: string, options?: TransactionSimulationOptions): Promise<TransactionSimulationResult>;
|
|
67
|
+
sendTransaction(transaction: string, options?: TransactionSendOptions): Promise<TransactionSendResult>;
|
|
68
|
+
getSignatureStatus(signature: string, options?: TransactionRequestContext & {
|
|
69
|
+
searchTransactionHistory?: boolean;
|
|
70
|
+
}): Promise<TransactionSignatureStatus | null>;
|
|
71
|
+
getBlockHeight(options?: TransactionRequestContext): Promise<bigint>;
|
|
72
|
+
}
|
|
73
|
+
type AuthenticatedTransactionFetch = (input: string, init: RequestInit, scope: TransactionAuthScope, allowAuthReplay: boolean) => Promise<Response>;
|
|
74
|
+
declare function createTransactionTransport(baseUrl: string, authenticatedFetch: AuthenticatedTransactionFetch): TransactionTransport;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Wallet adapter boundary for the Arete SDK.
|
|
78
|
+
*
|
|
79
|
+
* The core SDK is intentionally RPC-free: it only constructs `BuiltInstruction`
|
|
80
|
+
* objects. Everything network-related (recent blockhash, message compilation,
|
|
81
|
+
* signing, sending, and confirmation) lives behind the `WalletAdapter`
|
|
82
|
+
* boundary, implemented by adapters that wrap the Solana library of your choice
|
|
83
|
+
* (@solana/web3.js, @solana/kit, a raw Keypair signer for scripts, etc.).
|
|
84
|
+
*/
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* A single account reference within a built instruction.
|
|
88
|
+
*/
|
|
89
|
+
interface BuiltAccountMeta {
|
|
90
|
+
/** Account address as a base58-encoded string */
|
|
91
|
+
pubkey: string;
|
|
92
|
+
/** Whether this account must sign the transaction */
|
|
93
|
+
isSigner: boolean;
|
|
94
|
+
/** Whether this account is writable */
|
|
95
|
+
isWritable: boolean;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A framework-agnostic representation of a Solana instruction.
|
|
99
|
+
*
|
|
100
|
+
* This is the boundary type between the core SDK (which builds instructions)
|
|
101
|
+
* and wallet adapters (which broadcast them). It maps 1:1 onto a
|
|
102
|
+
* @solana/web3.js `TransactionInstruction` or a @solana/kit `Instruction`.
|
|
103
|
+
*/
|
|
104
|
+
interface BuiltInstruction {
|
|
105
|
+
/** Program ID (base58) */
|
|
106
|
+
programId: string;
|
|
107
|
+
/** Account keys, in the exact order required by the program */
|
|
108
|
+
keys: BuiltAccountMeta[];
|
|
109
|
+
/** Serialized instruction data (discriminator + Borsh-encoded args) */
|
|
110
|
+
data: Uint8Array;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Confirmation level for transaction processing.
|
|
114
|
+
* - `processed`: Transaction processed but not confirmed
|
|
115
|
+
* - `confirmed`: Transaction confirmed by cluster
|
|
116
|
+
* - `finalized`: Transaction finalized (recommended for production)
|
|
117
|
+
*/
|
|
118
|
+
type ConfirmationLevel = 'processed' | 'confirmed' | 'finalized';
|
|
119
|
+
/**
|
|
120
|
+
* Options forwarded to the wallet adapter when sending a transaction.
|
|
121
|
+
*
|
|
122
|
+
* The core SDK does not interpret these; it passes them straight through to
|
|
123
|
+
* the adapter, which owns all RPC semantics.
|
|
124
|
+
*/
|
|
125
|
+
interface SendOptions {
|
|
126
|
+
/** Confirmation level the adapter should wait for */
|
|
127
|
+
confirmationLevel?: ConfirmationLevel;
|
|
128
|
+
/** Skip the RPC preflight simulation */
|
|
129
|
+
skipPreflight?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Optional extra local signers for this send.
|
|
132
|
+
*
|
|
133
|
+
* The concrete signer type depends on the wallet adapter implementation
|
|
134
|
+
* (for example `@solana/web3.js` Signers or `@solana/kit` TransactionSigners).
|
|
135
|
+
*/
|
|
136
|
+
signers?: readonly unknown[];
|
|
137
|
+
/** Adapter-specific passthrough options (priority fees, lookup tables, etc.) */
|
|
138
|
+
[key: string]: unknown;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Result returned by a wallet adapter after broadcasting a transaction.
|
|
142
|
+
*/
|
|
143
|
+
interface SendResult {
|
|
144
|
+
/** Transaction signature (base58) */
|
|
145
|
+
signature: string;
|
|
146
|
+
/** Slot in which the transaction landed, if the adapter reports it */
|
|
147
|
+
slot?: number;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Adapter-specific options for unsigned transaction inspection.
|
|
151
|
+
*
|
|
152
|
+
* Inspection must not sign or submit the transaction. Concrete adapters may
|
|
153
|
+
* accept additional simulation options through this passthrough object.
|
|
154
|
+
*/
|
|
155
|
+
interface TransactionInspectionOptions {
|
|
156
|
+
[key: string]: unknown;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Unsigned transaction inspection returned by a capable wallet adapter.
|
|
160
|
+
*/
|
|
161
|
+
interface TransactionInspectionResult {
|
|
162
|
+
/** Estimated transaction fee in lamports, when available. */
|
|
163
|
+
feeLamports?: number;
|
|
164
|
+
/** Program logs produced by simulation, when available. */
|
|
165
|
+
logs?: readonly string[];
|
|
166
|
+
/** Compute units consumed by simulation, when available. */
|
|
167
|
+
computeUnitsConsumed?: number;
|
|
168
|
+
/** RPC context slot for the inspection, when available. */
|
|
169
|
+
contextSlot?: number;
|
|
170
|
+
/** Raw simulation failure, if the inspected transaction would fail. */
|
|
171
|
+
error?: unknown;
|
|
172
|
+
/** Adapter-specific inspection fields. */
|
|
173
|
+
[key: string]: unknown;
|
|
174
|
+
}
|
|
175
|
+
interface WalletExecutionContext {
|
|
176
|
+
transactionTransport?: TransactionTransport;
|
|
177
|
+
}
|
|
1
178
|
/**
|
|
2
179
|
* Wallet adapter interface for signing and sending transactions.
|
|
3
|
-
*
|
|
180
|
+
*
|
|
181
|
+
* Implementations own blockhash fetching, message compilation (legacy or v0),
|
|
182
|
+
* signing, sending, and confirmation. The core SDK only needs `publicKey` for
|
|
183
|
+
* signer-account resolution and `signAndSend` to broadcast built instructions.
|
|
4
184
|
*/
|
|
5
185
|
interface WalletAdapter {
|
|
6
186
|
/** The wallet's public key as a base58-encoded string */
|
|
7
187
|
publicKey: string;
|
|
188
|
+
/** Signer addresses the adapter can satisfy without per-send signers. */
|
|
189
|
+
readonly signerAddresses?: readonly string[];
|
|
8
190
|
/**
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
191
|
+
* Compile, sign, and broadcast one or more built instructions as a single
|
|
192
|
+
* transaction.
|
|
193
|
+
*
|
|
194
|
+
* Accepting an array (rather than a single instruction) makes batching and
|
|
195
|
+
* composition fall out for free.
|
|
196
|
+
*
|
|
197
|
+
* @param instructions - Instructions to include in the transaction, in order
|
|
198
|
+
* @param options - Adapter-specific send/confirmation options
|
|
199
|
+
* @returns The transaction signature (and slot, if known)
|
|
200
|
+
*/
|
|
201
|
+
signAndSend(instructions: readonly BuiltInstruction[], options?: SendOptions, context?: WalletExecutionContext): Promise<SendResult>;
|
|
202
|
+
/**
|
|
203
|
+
* Inspect a transaction without signing, submitting, or prompting a wallet.
|
|
204
|
+
*
|
|
205
|
+
* This capability is optional because not every adapter has an RPC-backed
|
|
206
|
+
* unsigned simulation implementation.
|
|
12
207
|
*/
|
|
13
|
-
|
|
208
|
+
inspectTransaction?(instructions: readonly BuiltInstruction[], options?: TransactionInspectionOptions, context?: WalletExecutionContext): Promise<TransactionInspectionResult>;
|
|
14
209
|
}
|
|
15
210
|
/**
|
|
16
211
|
* Wallet connection state
|
|
@@ -68,9 +263,13 @@ interface PdaConfig {
|
|
|
68
263
|
type PdaSeed = {
|
|
69
264
|
type: 'literal';
|
|
70
265
|
value: string;
|
|
266
|
+
} | {
|
|
267
|
+
type: 'bytes';
|
|
268
|
+
value: number[];
|
|
71
269
|
} | {
|
|
72
270
|
type: 'argRef';
|
|
73
271
|
argName: string;
|
|
272
|
+
argType?: string;
|
|
74
273
|
} | {
|
|
75
274
|
type: 'accountRef';
|
|
76
275
|
accountName: string;
|
|
@@ -101,8 +300,10 @@ interface AccountResolutionResult {
|
|
|
101
300
|
* Options for account resolution.
|
|
102
301
|
*/
|
|
103
302
|
interface AccountResolutionOptions {
|
|
104
|
-
/**
|
|
303
|
+
/** Explicit account-address overrides, including signer slots when needed */
|
|
105
304
|
accounts?: Record<string, string>;
|
|
305
|
+
/** Helper-only PDA seed inputs */
|
|
306
|
+
resolve?: Record<string, unknown>;
|
|
106
307
|
/** Wallet adapter for signer accounts */
|
|
107
308
|
wallet?: WalletAdapter;
|
|
108
309
|
/** Program ID for PDA derivation (required if any PDAs exist) */
|
|
@@ -183,6 +384,7 @@ declare function createPublicKeySeed(address: string): Uint8Array;
|
|
|
183
384
|
* This module handles serializing instruction arguments into the binary format
|
|
184
385
|
* expected by Solana programs using Borsh serialization.
|
|
185
386
|
*/
|
|
387
|
+
|
|
186
388
|
/**
|
|
187
389
|
* Instruction argument schema for serialization.
|
|
188
390
|
*/
|
|
@@ -194,13 +396,42 @@ interface ArgSchema {
|
|
|
194
396
|
}
|
|
195
397
|
/**
|
|
196
398
|
* Supported argument types for Borsh serialization.
|
|
399
|
+
*
|
|
400
|
+
* Struct and enum schemas are fully inlined (field names and types travel
|
|
401
|
+
* with the schema), so the serializer needs no runtime type registry.
|
|
197
402
|
*/
|
|
198
|
-
type ArgType = 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'i8' | 'i16' | 'i32' | 'i64' | 'i128' | 'bool' | 'string' | 'pubkey' | {
|
|
403
|
+
type ArgType = 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'i8' | 'i16' | 'i32' | 'i64' | 'i128' | 'f32' | 'f64' | 'bool' | 'string' | 'pubkey' | 'bytes' | {
|
|
199
404
|
vec: ArgType;
|
|
200
405
|
} | {
|
|
201
406
|
option: ArgType;
|
|
202
407
|
} | {
|
|
203
|
-
array: [ArgType, number];
|
|
408
|
+
array: readonly [ArgType, number];
|
|
409
|
+
} | {
|
|
410
|
+
hashMap: readonly [ArgType, ArgType];
|
|
411
|
+
} | {
|
|
412
|
+
struct: readonly ArgStructField[];
|
|
413
|
+
} | {
|
|
414
|
+
enum: readonly EnumVariant[];
|
|
415
|
+
};
|
|
416
|
+
/** One field of a struct schema, in declaration (serialization) order. */
|
|
417
|
+
interface ArgStructField {
|
|
418
|
+
readonly name: string;
|
|
419
|
+
readonly type: ArgType;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* One enum variant: a bare string for fieldless variants, or a named variant
|
|
423
|
+
* carrying struct fields / tuple elements.
|
|
424
|
+
*
|
|
425
|
+
* Values: fieldless variants are passed as the variant name (or its index);
|
|
426
|
+
* data-carrying variants as a single-key object, e.g. `{ transfer: { amount } }`
|
|
427
|
+
* or `{ pair: [1, 2] }`.
|
|
428
|
+
*/
|
|
429
|
+
type EnumVariant = string | {
|
|
430
|
+
readonly name: string;
|
|
431
|
+
readonly fields: readonly ArgStructField[];
|
|
432
|
+
} | {
|
|
433
|
+
readonly name: string;
|
|
434
|
+
readonly tuple: readonly ArgType[];
|
|
204
435
|
};
|
|
205
436
|
/**
|
|
206
437
|
* Serializes instruction arguments into a Buffer using Borsh encoding.
|
|
@@ -212,57 +443,6 @@ type ArgType = 'u8' | 'u16' | 'u32' | 'u64' | 'u128' | 'i8' | 'i16' | 'i32' | 'i
|
|
|
212
443
|
*/
|
|
213
444
|
declare function serializeInstructionData(discriminator: Uint8Array, args: Record<string, unknown>, schema: ArgSchema[]): Buffer;
|
|
214
445
|
|
|
215
|
-
/**
|
|
216
|
-
* Confirmation level for transaction processing.
|
|
217
|
-
* - `processed`: Transaction processed but not confirmed
|
|
218
|
-
* - `confirmed`: Transaction confirmed by cluster
|
|
219
|
-
* - `finalized`: Transaction finalized (recommended for production)
|
|
220
|
-
*/
|
|
221
|
-
type ConfirmationLevel = 'processed' | 'confirmed' | 'finalized';
|
|
222
|
-
/**
|
|
223
|
-
* Options for executing an instruction.
|
|
224
|
-
*/
|
|
225
|
-
interface ExecuteOptions {
|
|
226
|
-
/** Wallet adapter for signing */
|
|
227
|
-
wallet?: WalletAdapter;
|
|
228
|
-
/** User-provided account addresses */
|
|
229
|
-
accounts?: Record<string, string>;
|
|
230
|
-
/** Confirmation level to wait for */
|
|
231
|
-
confirmationLevel?: ConfirmationLevel;
|
|
232
|
-
/** Maximum time to wait for confirmation (ms) */
|
|
233
|
-
timeout?: number;
|
|
234
|
-
/** Refresh view after transaction completes */
|
|
235
|
-
refresh?: {
|
|
236
|
-
view: string;
|
|
237
|
-
key?: string;
|
|
238
|
-
}[];
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Result of a successful instruction execution.
|
|
242
|
-
*/
|
|
243
|
-
interface ExecutionResult {
|
|
244
|
-
/** Transaction signature */
|
|
245
|
-
signature: string;
|
|
246
|
-
/** Confirmation level achieved */
|
|
247
|
-
confirmationLevel: ConfirmationLevel;
|
|
248
|
-
/** Slot when transaction was processed */
|
|
249
|
-
slot: number;
|
|
250
|
-
/** Error code if transaction failed */
|
|
251
|
-
error?: string;
|
|
252
|
-
}
|
|
253
|
-
/**
|
|
254
|
-
* Waits for transaction confirmation.
|
|
255
|
-
*
|
|
256
|
-
* @param signature - Transaction signature
|
|
257
|
-
* @param level - Desired confirmation level
|
|
258
|
-
* @param timeout - Maximum wait time in milliseconds
|
|
259
|
-
* @returns Confirmation result
|
|
260
|
-
*/
|
|
261
|
-
declare function waitForConfirmation(signature: string, level?: ConfirmationLevel, timeout?: number): Promise<{
|
|
262
|
-
level: ConfirmationLevel;
|
|
263
|
-
slot: number;
|
|
264
|
-
}>;
|
|
265
|
-
|
|
266
446
|
/**
|
|
267
447
|
* Parses and handles instruction errors.
|
|
268
448
|
*/
|
|
@@ -285,6 +465,46 @@ interface ErrorMetadata {
|
|
|
285
465
|
name: string;
|
|
286
466
|
msg: string;
|
|
287
467
|
}
|
|
468
|
+
type TransactionFailureStatus = 'not-submitted' | 'submitted-unknown' | 'chain-failed';
|
|
469
|
+
type TransactionFailurePhase = 'build' | 'wallet' | 'send' | 'confirmation' | 'chain';
|
|
470
|
+
interface ConfirmedTransactionOutcome {
|
|
471
|
+
readonly status: 'confirmed';
|
|
472
|
+
readonly phase: 'confirmation';
|
|
473
|
+
readonly signature: string;
|
|
474
|
+
readonly slot?: number;
|
|
475
|
+
}
|
|
476
|
+
interface NotSubmittedTransactionOutcome {
|
|
477
|
+
readonly status: 'not-submitted';
|
|
478
|
+
readonly phase: 'build' | 'wallet' | 'send';
|
|
479
|
+
readonly cause: unknown;
|
|
480
|
+
}
|
|
481
|
+
interface SubmittedUnknownTransactionOutcome {
|
|
482
|
+
readonly status: 'submitted-unknown';
|
|
483
|
+
readonly phase: 'send' | 'confirmation';
|
|
484
|
+
readonly signature: string;
|
|
485
|
+
readonly slot?: number;
|
|
486
|
+
readonly cause: unknown;
|
|
487
|
+
}
|
|
488
|
+
interface ChainFailedTransactionOutcome {
|
|
489
|
+
readonly status: 'chain-failed';
|
|
490
|
+
readonly phase: 'confirmation' | 'chain';
|
|
491
|
+
readonly signature?: string;
|
|
492
|
+
readonly slot?: number;
|
|
493
|
+
readonly programError?: ProgramError;
|
|
494
|
+
readonly cause: unknown;
|
|
495
|
+
}
|
|
496
|
+
type TransactionFailureOutcome = NotSubmittedTransactionOutcome | SubmittedUnknownTransactionOutcome | ChainFailedTransactionOutcome;
|
|
497
|
+
type TransactionOutcome = ConfirmedTransactionOutcome | TransactionFailureOutcome;
|
|
498
|
+
/**
|
|
499
|
+
* Structured transaction failure thrown by adapters and the core executor.
|
|
500
|
+
*/
|
|
501
|
+
declare class TransactionExecutionError extends Error {
|
|
502
|
+
readonly outcome: TransactionFailureOutcome;
|
|
503
|
+
readonly cause: unknown;
|
|
504
|
+
readonly signature?: string;
|
|
505
|
+
readonly slot?: number;
|
|
506
|
+
constructor(outcome: TransactionFailureOutcome, message?: string);
|
|
507
|
+
}
|
|
288
508
|
/**
|
|
289
509
|
* Parses an error returned from a Solana transaction.
|
|
290
510
|
*
|
|
@@ -292,7 +512,7 @@ interface ErrorMetadata {
|
|
|
292
512
|
* @param errorMetadata - Error definitions from the IDL
|
|
293
513
|
* @returns Parsed program error or null if not a program error
|
|
294
514
|
*/
|
|
295
|
-
declare function parseInstructionError(error: unknown, errorMetadata: ErrorMetadata[]): ProgramError | null;
|
|
515
|
+
declare function parseInstructionError(error: unknown, errorMetadata: readonly ErrorMetadata[]): ProgramError | null;
|
|
296
516
|
/**
|
|
297
517
|
* Formats an error for display.
|
|
298
518
|
*
|
|
@@ -300,87 +520,149 @@ declare function parseInstructionError(error: unknown, errorMetadata: ErrorMetad
|
|
|
300
520
|
* @returns Human-readable error message
|
|
301
521
|
*/
|
|
302
522
|
declare function formatProgramError(error: ProgramError): string;
|
|
523
|
+
/**
|
|
524
|
+
* Error thrown when an instruction fails to send and the underlying failure
|
|
525
|
+
* could be parsed against the handler's IDL error definitions.
|
|
526
|
+
*/
|
|
527
|
+
declare class InstructionError extends Error {
|
|
528
|
+
/** Parsed program error, if the failure matched a known error code. */
|
|
529
|
+
readonly programError: ProgramError | null;
|
|
530
|
+
/** The original underlying error from the wallet adapter / RPC. */
|
|
531
|
+
readonly cause: unknown;
|
|
532
|
+
/** Structured chain-failure outcome, including signature and slot when known. */
|
|
533
|
+
readonly outcome: ChainFailedTransactionOutcome;
|
|
534
|
+
readonly signature?: string;
|
|
535
|
+
readonly slot?: number;
|
|
536
|
+
constructor(message: string, programError: ProgramError | null, cause: unknown, outcome?: ChainFailedTransactionOutcome);
|
|
537
|
+
}
|
|
538
|
+
/** Find a structured transaction failure through nested error causes. */
|
|
539
|
+
declare function getTransactionFailureOutcome(error: unknown): TransactionFailureOutcome | null;
|
|
540
|
+
/**
|
|
541
|
+
* Normalize an adapter/host exception without retrying or resubmitting.
|
|
542
|
+
*/
|
|
543
|
+
declare function normalizeTransactionError(cause: unknown, errorMetadata?: readonly ErrorMetadata[], fallbackPhase?: 'wallet' | 'send'): InstructionError | TransactionExecutionError;
|
|
303
544
|
|
|
304
545
|
/**
|
|
305
|
-
* Resolved accounts map passed to
|
|
546
|
+
* Resolved accounts map passed to a handler's build function.
|
|
306
547
|
* Keys are account names, values are base58 addresses.
|
|
307
548
|
*/
|
|
308
549
|
type ResolvedAccounts = Record<string, string>;
|
|
550
|
+
|
|
309
551
|
/**
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
552
|
+
* Instruction handler consumed by the core executor.
|
|
553
|
+
*
|
|
554
|
+
* Handlers are normally produced by {@link createInstructionHandler} (either
|
|
555
|
+
* hand-written or code-generated), so `build` is implemented generically and
|
|
556
|
+
* callers never deal with serialization directly.
|
|
557
|
+
*
|
|
558
|
+
* The phantom `_params` / `_error` fields carry compile-time type information
|
|
559
|
+
* for the typed client surface; they are never populated at runtime.
|
|
313
560
|
*/
|
|
314
|
-
interface
|
|
315
|
-
/** Program ID (base58) */
|
|
561
|
+
interface InstructionHandler<TParams = Record<string, unknown>, TError = unknown> {
|
|
562
|
+
/** Program ID for this instruction (base58). Used for PDA derivation. */
|
|
563
|
+
programId?: string;
|
|
564
|
+
/** Ordered account metadata used by the core SDK for resolution. */
|
|
565
|
+
accounts: AccountMeta[];
|
|
566
|
+
/** Error definitions used for error parsing. */
|
|
567
|
+
errors: ErrorMetadata[];
|
|
568
|
+
/**
|
|
569
|
+
* Names of the instruction's serialized arguments. Everything in the merged
|
|
570
|
+
* params object that is NOT in this list is treated as a user-provided
|
|
571
|
+
* account address override.
|
|
572
|
+
*/
|
|
573
|
+
argNames: string[];
|
|
574
|
+
/**
|
|
575
|
+
* Build the instruction from already-resolved, ordered accounts.
|
|
576
|
+
* Implemented by {@link createInstructionHandler}.
|
|
577
|
+
*/
|
|
578
|
+
build(args: Record<string, unknown>, resolved: ResolvedAccount[]): BuiltInstruction;
|
|
579
|
+
/** Phantom: merged params type (args + user-provided accounts). */
|
|
580
|
+
readonly _params?: TParams;
|
|
581
|
+
/** Phantom: typed error union. */
|
|
582
|
+
readonly _error?: TError;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Configuration accepted by {@link createInstructionHandler}.
|
|
586
|
+
*/
|
|
587
|
+
interface InstructionHandlerConfig {
|
|
588
|
+
/** Program ID (base58). */
|
|
316
589
|
programId: string;
|
|
317
|
-
/**
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
|
|
590
|
+
/** Instruction discriminator bytes (8 for Anchor, 1 for Steel, etc.). */
|
|
591
|
+
discriminator: Uint8Array | number[];
|
|
592
|
+
/** Ordered account metadata. */
|
|
593
|
+
accounts: AccountMeta[];
|
|
594
|
+
/** Ordered argument schema for Borsh serialization. */
|
|
595
|
+
args: ArgSchema[];
|
|
596
|
+
/** Error definitions from the IDL. */
|
|
597
|
+
errors?: ErrorMetadata[];
|
|
325
598
|
}
|
|
326
599
|
/**
|
|
327
|
-
*
|
|
328
|
-
*
|
|
600
|
+
* Creates a data-driven instruction handler.
|
|
601
|
+
*
|
|
602
|
+
* The returned handler implements `build()` generically: it serializes args
|
|
603
|
+
* via the schema-driven serializer and constructs the account key list from
|
|
604
|
+
* the resolved, ordered accounts. No imperative per-instruction code is
|
|
605
|
+
* required, which keeps generated SDKs tiny and puts all serialization logic
|
|
606
|
+
* in one tested place.
|
|
607
|
+
*/
|
|
608
|
+
declare function createInstructionHandler<TParams = Record<string, unknown>, TError = unknown>(config: InstructionHandlerConfig): InstructionHandler<TParams, TError>;
|
|
609
|
+
/**
|
|
610
|
+
* Options for building an instruction (no network access).
|
|
329
611
|
*/
|
|
330
|
-
interface
|
|
612
|
+
interface BuildOptions {
|
|
613
|
+
/** Wallet, used only for `publicKey` to resolve signer accounts. */
|
|
614
|
+
wallet?: WalletAdapter;
|
|
615
|
+
/** Explicit account-address overrides, including signer slots when needed. */
|
|
616
|
+
accounts?: Record<string, string>;
|
|
331
617
|
/**
|
|
332
|
-
*
|
|
333
|
-
*
|
|
618
|
+
* Extra account metas appended after the instruction's declared accounts
|
|
619
|
+
* (Anchor's `remainingAccounts`) — for routers, transfer hooks, and other
|
|
620
|
+
* composition patterns the IDL cannot express.
|
|
334
621
|
*/
|
|
335
|
-
|
|
336
|
-
/** Account metadata - used by core SDK for resolution */
|
|
337
|
-
accounts: AccountMeta[];
|
|
338
|
-
/** Error definitions - used by core SDK for error parsing */
|
|
339
|
-
errors: ErrorMetadata[];
|
|
340
|
-
/** Program ID for this instruction (used for PDA derivation) */
|
|
341
|
-
programId?: string;
|
|
622
|
+
remainingAccounts?: BuiltAccountMeta[];
|
|
342
623
|
}
|
|
343
624
|
/**
|
|
344
|
-
*
|
|
345
|
-
* Legacy instruction definition for backwards compatibility.
|
|
625
|
+
* Options for executing (building + sending) an instruction.
|
|
346
626
|
*/
|
|
347
|
-
interface
|
|
348
|
-
/**
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
627
|
+
interface ExecuteOptions extends BuildOptions {
|
|
628
|
+
/** Wallet adapter that signs and broadcasts the transaction. */
|
|
629
|
+
wallet?: WalletAdapter;
|
|
630
|
+
/** Confirmation level forwarded to the adapter. */
|
|
631
|
+
confirmationLevel?: ConfirmationLevel;
|
|
632
|
+
/** Additional options forwarded verbatim to the wallet adapter. */
|
|
633
|
+
send?: SendOptions;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Result of a successful instruction execution.
|
|
637
|
+
*/
|
|
638
|
+
interface ExecutionResult {
|
|
639
|
+
/** Transaction signature. */
|
|
640
|
+
signature: string;
|
|
641
|
+
/** Slot in which the transaction landed, if the adapter reports it. */
|
|
642
|
+
slot?: number;
|
|
360
643
|
}
|
|
361
644
|
/**
|
|
362
|
-
*
|
|
645
|
+
* Builds a {@link BuiltInstruction} from a handler and a merged params object.
|
|
363
646
|
*
|
|
364
|
-
* This is
|
|
365
|
-
*
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
647
|
+
* This is a pure function: it performs no network access. It is the unit of
|
|
648
|
+
* composition for batching (`wallet.signAndSend([a, b, c])`).
|
|
649
|
+
*/
|
|
650
|
+
declare function buildInstruction(handler: InstructionHandler<any, any>, params: Record<string, unknown>, options?: BuildOptions): BuiltInstruction;
|
|
651
|
+
/**
|
|
652
|
+
* Builds, signs, and sends an instruction via the wallet adapter.
|
|
369
653
|
*
|
|
370
|
-
*
|
|
371
|
-
*
|
|
372
|
-
*
|
|
373
|
-
* @
|
|
654
|
+
* The core SDK does not touch RPC: the adapter owns blockhash, compilation,
|
|
655
|
+
* signing, sending, and confirmation. On failure, program errors are parsed
|
|
656
|
+
* against the handler's IDL error definitions and surfaced as an
|
|
657
|
+
* {@link InstructionError}.
|
|
374
658
|
*/
|
|
375
|
-
declare function executeInstruction(handler: InstructionHandler,
|
|
659
|
+
declare function executeInstruction(handler: InstructionHandler<any, any>, params: Record<string, unknown>, options?: ExecuteOptions): Promise<ExecutionResult>;
|
|
376
660
|
/**
|
|
377
661
|
* Creates an instruction executor bound to a specific wallet.
|
|
378
|
-
*
|
|
379
|
-
* @param wallet - Wallet adapter
|
|
380
|
-
* @returns Bound executor function
|
|
381
662
|
*/
|
|
382
663
|
declare function createInstructionExecutor(wallet: WalletAdapter): {
|
|
383
|
-
execute: (handler: InstructionHandler,
|
|
664
|
+
execute: (handler: InstructionHandler, params: Record<string, unknown>, options?: Omit<ExecuteOptions, "wallet">) => Promise<ExecutionResult>;
|
|
665
|
+
build: (handler: InstructionHandler, params: Record<string, unknown>, options?: Omit<BuildOptions, "wallet">) => BuiltInstruction;
|
|
384
666
|
};
|
|
385
667
|
|
|
386
668
|
type SeedDef = {
|
|
@@ -400,6 +682,7 @@ type SeedDef = {
|
|
|
400
682
|
interface PdaDeriveContext {
|
|
401
683
|
accounts?: Record<string, string>;
|
|
402
684
|
args?: Record<string, unknown>;
|
|
685
|
+
resolve?: Record<string, unknown>;
|
|
403
686
|
programId?: string;
|
|
404
687
|
}
|
|
405
688
|
interface PdaFactory {
|
|
@@ -426,6 +709,9 @@ type Update<T> = {
|
|
|
426
709
|
type: 'patch';
|
|
427
710
|
key: string;
|
|
428
711
|
data: Partial<T>;
|
|
712
|
+
} | {
|
|
713
|
+
type: 'remove';
|
|
714
|
+
key: string;
|
|
429
715
|
} | {
|
|
430
716
|
type: 'delete';
|
|
431
717
|
key: string;
|
|
@@ -440,41 +726,126 @@ type RichUpdate<T> = {
|
|
|
440
726
|
before: T;
|
|
441
727
|
after: T;
|
|
442
728
|
patch?: unknown;
|
|
729
|
+
} | {
|
|
730
|
+
type: 'removed';
|
|
731
|
+
key: string;
|
|
732
|
+
lastKnown?: T;
|
|
443
733
|
} | {
|
|
444
734
|
type: 'deleted';
|
|
445
735
|
key: string;
|
|
446
736
|
lastKnown?: T;
|
|
447
737
|
};
|
|
448
|
-
|
|
738
|
+
type ViewKeyValue = string | number | bigint;
|
|
739
|
+
type ViewKeyFields<TKey> = unknown extends TKey ? readonly string[] : TKey extends object ? readonly Extract<keyof TKey, string>[] : readonly string[];
|
|
740
|
+
interface ViewDef<T, TMode extends 'state' | 'list', TKey = unknown> {
|
|
449
741
|
readonly mode: TMode;
|
|
450
742
|
readonly view: string;
|
|
743
|
+
readonly keyFields?: ViewKeyFields<TKey>;
|
|
451
744
|
readonly _entity?: T;
|
|
745
|
+
readonly _key?: TKey;
|
|
746
|
+
}
|
|
747
|
+
interface StackEndpoints {
|
|
748
|
+
readonly ws: string;
|
|
749
|
+
readonly http?: string;
|
|
750
|
+
}
|
|
751
|
+
type ReadTransportMethod = 'GET' | 'POST';
|
|
752
|
+
interface ProgramAccountReadDefinition<T> {
|
|
753
|
+
readonly account: string;
|
|
754
|
+
readonly path: string;
|
|
755
|
+
readonly schema?: Schema<T>;
|
|
756
|
+
readonly _result?: T;
|
|
757
|
+
}
|
|
758
|
+
interface ProgramQueryDefinition<TParams = unknown, TResult = unknown> {
|
|
759
|
+
readonly name: string;
|
|
760
|
+
readonly path: string;
|
|
761
|
+
readonly method?: ReadTransportMethod;
|
|
762
|
+
readonly schema?: Schema<TResult>;
|
|
763
|
+
readonly _params?: TParams;
|
|
764
|
+
readonly _result?: TResult;
|
|
765
|
+
}
|
|
766
|
+
interface StackQueryDefinition<TParams = unknown, TResult = unknown> {
|
|
767
|
+
readonly name: string;
|
|
768
|
+
readonly path: string;
|
|
769
|
+
readonly method?: ReadTransportMethod;
|
|
770
|
+
readonly schema?: Schema<TResult>;
|
|
771
|
+
readonly _params?: TParams;
|
|
772
|
+
readonly _result?: TResult;
|
|
773
|
+
}
|
|
774
|
+
interface ProgramSdkDefinition {
|
|
775
|
+
readonly name: string;
|
|
776
|
+
readonly programId?: string;
|
|
777
|
+
/** Stable fingerprint of the generated program behavior used for client caching. */
|
|
778
|
+
readonly definitionHash?: string;
|
|
779
|
+
readonly schemas?: Record<string, Schema<unknown>>;
|
|
780
|
+
readonly pdas?: Record<string, unknown>;
|
|
781
|
+
readonly accounts?: Record<string, ProgramAccountReadDefinition<unknown>>;
|
|
782
|
+
readonly queries?: Record<string, ProgramQueryDefinition<unknown, unknown>>;
|
|
783
|
+
readonly rawInstructions?: Record<string, InstructionHandler<any, any>>;
|
|
784
|
+
readonly addresses?: Record<string, unknown>;
|
|
785
|
+
readonly constants?: unknown;
|
|
786
|
+
readonly defaults?: unknown;
|
|
787
|
+
readonly math?: unknown;
|
|
452
788
|
}
|
|
453
789
|
interface StackDefinition {
|
|
454
790
|
readonly name: string;
|
|
455
|
-
readonly
|
|
791
|
+
readonly endpoints: StackEndpoints;
|
|
456
792
|
readonly views: Record<string, ViewGroup>;
|
|
457
793
|
readonly schemas?: Record<string, Schema<unknown>>;
|
|
458
|
-
|
|
794
|
+
readonly patchSchemas?: Record<string, Schema<unknown>>;
|
|
795
|
+
readonly queries?: Record<string, StackQueryDefinition<unknown, unknown>>;
|
|
796
|
+
readonly programs?: Record<string, ProgramSdkDefinition>;
|
|
459
797
|
}
|
|
460
798
|
interface ViewGroup {
|
|
461
|
-
state?: ViewDef<
|
|
462
|
-
list?: ViewDef<
|
|
799
|
+
state?: ViewDef<any, 'state', any>;
|
|
800
|
+
list?: ViewDef<any, 'list'>;
|
|
463
801
|
}
|
|
464
|
-
interface
|
|
802
|
+
interface SubscriptionQuery {
|
|
465
803
|
view: string;
|
|
466
804
|
key?: string;
|
|
467
805
|
partition?: string;
|
|
468
|
-
filters?: Record<string,
|
|
806
|
+
filters?: Record<string, unknown>;
|
|
469
807
|
take?: number;
|
|
470
808
|
skip?: number;
|
|
471
|
-
/** Whether to include initial snapshot (defaults to true for backward compatibility) */
|
|
472
|
-
withSnapshot?: boolean;
|
|
473
|
-
/** Cursor for resuming from a specific point (_seq value) */
|
|
474
809
|
after?: string;
|
|
475
|
-
/** Maximum number of entities to include in snapshot (pagination hint) */
|
|
476
810
|
snapshotLimit?: number;
|
|
477
811
|
}
|
|
812
|
+
interface SubscriptionSnapshotOptions {
|
|
813
|
+
enabled: boolean;
|
|
814
|
+
}
|
|
815
|
+
/** Protocol v2 wire subscription. The client-selected ID remains stable across reconnects. */
|
|
816
|
+
interface Subscription {
|
|
817
|
+
type: 'subscribe';
|
|
818
|
+
protocolVersion: 2;
|
|
819
|
+
subscriptionId: string;
|
|
820
|
+
query: SubscriptionQuery;
|
|
821
|
+
snapshot: SubscriptionSnapshotOptions;
|
|
822
|
+
}
|
|
823
|
+
interface SubscriptionRequest {
|
|
824
|
+
query: SubscriptionQuery;
|
|
825
|
+
snapshot?: Partial<SubscriptionSnapshotOptions>;
|
|
826
|
+
}
|
|
827
|
+
/** Canonical query identity includes every server query field and snapshot behavior. */
|
|
828
|
+
type SubscriptionIdentity = SubscriptionRequest;
|
|
829
|
+
type SubscriptionOptions = SubscriptionSnapshotOptions;
|
|
830
|
+
interface QuerySnapshot<T = unknown> {
|
|
831
|
+
readonly subscriptionId: string;
|
|
832
|
+
readonly query: SubscriptionQuery;
|
|
833
|
+
readonly keys: readonly string[];
|
|
834
|
+
readonly data: readonly T[];
|
|
835
|
+
readonly isLoading: boolean;
|
|
836
|
+
readonly isRefreshing: boolean;
|
|
837
|
+
readonly error?: AreteError;
|
|
838
|
+
}
|
|
839
|
+
interface QueryLease {
|
|
840
|
+
readonly subscription: Subscription;
|
|
841
|
+
readonly queryKey: string;
|
|
842
|
+
getSnapshot<T = unknown>(): QuerySnapshot<T>;
|
|
843
|
+
onChange(callback: () => void): UnsubscribeFn;
|
|
844
|
+
onUpdate<T = unknown>(callback: (update: Update<T>) => void): UnsubscribeFn;
|
|
845
|
+
onRichUpdate<T = unknown>(callback: (update: RichUpdate<T>) => void): UnsubscribeFn;
|
|
846
|
+
refresh(): Promise<void>;
|
|
847
|
+
release(): void;
|
|
848
|
+
}
|
|
478
849
|
type SchemaResult<T> = {
|
|
479
850
|
success: true;
|
|
480
851
|
data: T;
|
|
@@ -486,9 +857,10 @@ interface Schema<T> {
|
|
|
486
857
|
safeParse: (input: unknown) => SchemaResult<T>;
|
|
487
858
|
}
|
|
488
859
|
interface WatchOptions<TSchema = unknown> {
|
|
860
|
+
partition?: string;
|
|
489
861
|
take?: number;
|
|
490
862
|
skip?: number;
|
|
491
|
-
filters?: Record<string,
|
|
863
|
+
filters?: Record<string, unknown>;
|
|
492
864
|
schema?: Schema<TSchema>;
|
|
493
865
|
/** Whether to include initial snapshot (defaults to true) */
|
|
494
866
|
withSnapshot?: boolean;
|
|
@@ -499,6 +871,9 @@ interface WatchOptions<TSchema = unknown> {
|
|
|
499
871
|
}
|
|
500
872
|
interface AreteOptions<TStack extends StackDefinition> {
|
|
501
873
|
stack: TStack;
|
|
874
|
+
/** Connect immediately when the client is created (defaults to true). */
|
|
875
|
+
autoConnect?: boolean;
|
|
876
|
+
/** Reconnect automatically after an established connection is lost (defaults to true). */
|
|
502
877
|
autoReconnect?: boolean;
|
|
503
878
|
reconnectIntervals?: number[];
|
|
504
879
|
maxReconnectAttempts?: number;
|
|
@@ -509,6 +884,10 @@ interface AuthTokenResult {
|
|
|
509
884
|
token: string;
|
|
510
885
|
expiresAt?: number;
|
|
511
886
|
expires_at?: number;
|
|
887
|
+
scopes?: readonly string[];
|
|
888
|
+
}
|
|
889
|
+
interface AuthTokenRequest {
|
|
890
|
+
scopes: readonly string[];
|
|
512
891
|
}
|
|
513
892
|
interface WebSocketFactoryInit {
|
|
514
893
|
headers?: Record<string, string>;
|
|
@@ -518,7 +897,7 @@ interface WebSocketFactoryInit {
|
|
|
518
897
|
*/
|
|
519
898
|
interface AuthConfig {
|
|
520
899
|
/** Custom token provider function - called before each connection and during refresh */
|
|
521
|
-
getToken?: () => Promise<string | AuthTokenResult>;
|
|
900
|
+
getToken?: (request?: AuthTokenRequest) => Promise<string | AuthTokenResult>;
|
|
522
901
|
/** Arete Cloud token endpoint URL */
|
|
523
902
|
tokenEndpoint?: string;
|
|
524
903
|
/** Publishable key for Arete Cloud */
|
|
@@ -535,7 +914,10 @@ interface AuthConfig {
|
|
|
535
914
|
tokenEndpointCredentials?: RequestCredentials;
|
|
536
915
|
}
|
|
537
916
|
interface AreteConfig {
|
|
538
|
-
|
|
917
|
+
/** WebSocket endpoint. `null`/omitted disables the WebSocket transport (HTTP-only mode). */
|
|
918
|
+
websocketUrl?: string | null;
|
|
919
|
+
/** Reconnect automatically after an established connection is lost (defaults to true). */
|
|
920
|
+
autoReconnect?: boolean;
|
|
539
921
|
reconnectIntervals?: number[];
|
|
540
922
|
maxReconnectAttempts?: number;
|
|
541
923
|
initialSubscriptions?: Subscription[];
|
|
@@ -546,14 +928,15 @@ interface AreteConfig {
|
|
|
546
928
|
interface SocketIssue {
|
|
547
929
|
error: string;
|
|
548
930
|
message: string;
|
|
549
|
-
code: AuthErrorCode;
|
|
931
|
+
code: string | AuthErrorCode;
|
|
550
932
|
retryable: boolean;
|
|
551
933
|
retryAfter?: number;
|
|
552
934
|
suggestedAction?: string;
|
|
553
935
|
docsUrl?: string;
|
|
554
936
|
fatal: boolean;
|
|
937
|
+
subscriptionId?: string | null;
|
|
555
938
|
}
|
|
556
|
-
declare const DEFAULT_CONFIG: Required<Pick<AreteConfig, 'reconnectIntervals' | 'maxReconnectAttempts' | 'maxEntriesPerView'>>;
|
|
939
|
+
declare const DEFAULT_CONFIG: Required<Pick<AreteConfig, 'autoReconnect' | 'reconnectIntervals' | 'maxReconnectAttempts' | 'maxEntriesPerView'>>;
|
|
557
940
|
/**
|
|
558
941
|
* Machine-readable error codes for authentication and rate limiting failures
|
|
559
942
|
*
|
|
@@ -569,21 +952,22 @@ type TypedViews<TViews extends StackDefinition['views']> = {
|
|
|
569
952
|
[K in keyof TViews]: TypedViewGroup<TViews[K]>;
|
|
570
953
|
};
|
|
571
954
|
type TypedViewGroup<TGroup> = {
|
|
572
|
-
[K in keyof TGroup]: TGroup[K] extends ViewDef<infer T, 'state'> ? TypedStateView<T
|
|
955
|
+
[K in keyof TGroup]: TGroup[K] extends ViewDef<infer T, 'state', infer TKey> ? TypedStateView<T, DefaultViewKey<TKey>> : TGroup[K] extends ViewDef<infer T, 'list'> ? TypedListView<T> : never;
|
|
573
956
|
};
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
957
|
+
type DefaultViewKey<TKey> = unknown extends TKey ? string : TKey;
|
|
958
|
+
interface TypedStateView<T, TKey = string> {
|
|
959
|
+
use<TSchema = T>(key: TKey, options?: WatchOptions<TSchema>): AsyncIterable<TSchema>;
|
|
960
|
+
watch(key: TKey, options?: WatchOptions): AsyncIterable<Update<T>>;
|
|
961
|
+
watchRich(key: TKey, options?: WatchOptions): AsyncIterable<RichUpdate<T>>;
|
|
962
|
+
get(key: TKey, options?: WatchOptions): Promise<T | null>;
|
|
963
|
+
getSync(key: TKey, options?: WatchOptions): T | null | undefined;
|
|
580
964
|
}
|
|
581
965
|
interface TypedListView<T> {
|
|
582
966
|
use<TSchema = T>(options?: WatchOptions<TSchema>): AsyncIterable<TSchema>;
|
|
583
967
|
watch(options?: WatchOptions): AsyncIterable<Update<T>>;
|
|
584
968
|
watchRich(options?: WatchOptions): AsyncIterable<RichUpdate<T>>;
|
|
585
|
-
get(): Promise<T[]>;
|
|
586
|
-
getSync(): T[] | undefined;
|
|
969
|
+
get(options?: WatchOptions): Promise<T[]>;
|
|
970
|
+
getSync(options?: WatchOptions): T[] | undefined;
|
|
587
971
|
}
|
|
588
972
|
type SubscribeCallback<T> = (update: Update<T>) => void;
|
|
589
973
|
type UnsubscribeFn = () => void;
|
|
@@ -591,52 +975,77 @@ type ConnectionStateCallback = (state: ConnectionState, error?: string) => void;
|
|
|
591
975
|
type SocketIssueCallback = (issue: SocketIssue) => void;
|
|
592
976
|
|
|
593
977
|
type FrameMode = 'state' | 'append' | 'list';
|
|
594
|
-
type FrameOp = '
|
|
978
|
+
type FrameOp = 'subscribed' | 'unsubscribed' | 'snapshot' | 'upsert' | 'patch' | 'remove' | 'delete';
|
|
595
979
|
type SortOrder = 'asc' | 'desc';
|
|
596
980
|
interface SortConfig {
|
|
597
981
|
field: string[];
|
|
598
982
|
order: SortOrder;
|
|
599
983
|
}
|
|
600
|
-
interface
|
|
984
|
+
interface IdentifiedFrame {
|
|
985
|
+
protocolVersion: 2;
|
|
986
|
+
subscriptionId: string;
|
|
987
|
+
}
|
|
988
|
+
interface SubscribedFrame extends IdentifiedFrame {
|
|
601
989
|
op: 'subscribed';
|
|
602
|
-
|
|
990
|
+
query: SubscriptionQuery;
|
|
603
991
|
mode: FrameMode;
|
|
604
992
|
sort?: SortConfig;
|
|
605
993
|
}
|
|
606
|
-
interface
|
|
994
|
+
interface UnsubscribedFrame extends IdentifiedFrame {
|
|
995
|
+
op: 'unsubscribed';
|
|
996
|
+
}
|
|
997
|
+
interface EntityFrame<T = unknown> extends IdentifiedFrame {
|
|
607
998
|
mode: FrameMode;
|
|
608
999
|
entity: string;
|
|
609
|
-
op:
|
|
1000
|
+
op: 'upsert' | 'patch' | 'remove' | 'delete';
|
|
610
1001
|
key: string;
|
|
611
|
-
data: T;
|
|
1002
|
+
data: T | null;
|
|
612
1003
|
append?: string[];
|
|
613
|
-
/** Sequence cursor for ordering and resume capability */
|
|
614
1004
|
seq?: string;
|
|
615
1005
|
}
|
|
616
1006
|
interface SnapshotEntity<T = unknown> {
|
|
617
1007
|
key: string;
|
|
618
1008
|
data: T;
|
|
619
1009
|
}
|
|
620
|
-
interface SnapshotFrame<T = unknown> {
|
|
1010
|
+
interface SnapshotFrame<T = unknown> extends IdentifiedFrame {
|
|
1011
|
+
snapshotId: string;
|
|
1012
|
+
authoritative: boolean;
|
|
621
1013
|
mode: FrameMode;
|
|
622
1014
|
entity: string;
|
|
623
1015
|
op: 'snapshot';
|
|
1016
|
+
key?: string;
|
|
624
1017
|
data: SnapshotEntity<T>[];
|
|
625
|
-
|
|
626
|
-
complete?: boolean;
|
|
1018
|
+
complete: boolean;
|
|
627
1019
|
}
|
|
628
|
-
|
|
1020
|
+
interface ErrorFrame {
|
|
1021
|
+
type: 'error';
|
|
1022
|
+
protocolVersion: 2;
|
|
1023
|
+
subscriptionId: string | null;
|
|
1024
|
+
error?: string;
|
|
1025
|
+
message?: string;
|
|
1026
|
+
code: string;
|
|
1027
|
+
retryable?: boolean;
|
|
1028
|
+
fatal: boolean;
|
|
1029
|
+
retry_after?: number;
|
|
1030
|
+
suggested_action?: string;
|
|
1031
|
+
docs_url?: string;
|
|
1032
|
+
}
|
|
1033
|
+
type Frame<T = unknown> = EntityFrame<T> | SnapshotFrame<T> | SubscribedFrame | UnsubscribedFrame | ErrorFrame;
|
|
629
1034
|
declare function isSnapshotFrame<T>(frame: Frame<T>): frame is SnapshotFrame<T>;
|
|
630
1035
|
declare function isSubscribedFrame(frame: Frame): frame is SubscribedFrame;
|
|
1036
|
+
declare function isUnsubscribedFrame(frame: Frame): frame is UnsubscribedFrame;
|
|
1037
|
+
declare function isErrorFrame(frame: Frame): frame is ErrorFrame;
|
|
631
1038
|
declare function isEntityFrame<T>(frame: Frame<T>): frame is EntityFrame<T>;
|
|
632
1039
|
declare function parseFrame(data: ArrayBuffer | string): Frame;
|
|
633
1040
|
declare function parseFrameFromBlob(blob: Blob): Promise<Frame>;
|
|
634
1041
|
declare function isValidFrame(frame: unknown): frame is Frame;
|
|
635
1042
|
|
|
636
1043
|
type FrameHandler = <T>(frame: Frame<T>) => void;
|
|
1044
|
+
declare function isHostedAreteEndpoint(url: string): boolean;
|
|
637
1045
|
declare class ConnectionManager {
|
|
638
1046
|
private ws;
|
|
639
1047
|
private websocketUrl;
|
|
1048
|
+
private readonly autoReconnect;
|
|
640
1049
|
private reconnectIntervals;
|
|
641
1050
|
private maxReconnectAttempts;
|
|
642
1051
|
private reconnectAttempts;
|
|
@@ -644,15 +1053,20 @@ declare class ConnectionManager {
|
|
|
644
1053
|
private pingInterval;
|
|
645
1054
|
private tokenRefreshTimeout;
|
|
646
1055
|
private tokenRefreshInFlight;
|
|
1056
|
+
private tokenRequestInFlight;
|
|
647
1057
|
private currentState;
|
|
648
1058
|
private subscriptionQueue;
|
|
649
1059
|
private activeSubscriptions;
|
|
1060
|
+
private socketGeneration;
|
|
1061
|
+
private pendingConnect;
|
|
650
1062
|
private frameHandlers;
|
|
651
1063
|
private stateHandlers;
|
|
652
1064
|
private socketIssueHandlers;
|
|
653
1065
|
private authConfig?;
|
|
654
1066
|
private currentToken?;
|
|
655
1067
|
private tokenExpiry?;
|
|
1068
|
+
private tokenScopes;
|
|
1069
|
+
private requestedScopes;
|
|
656
1070
|
private readonly hostedAreteUrl;
|
|
657
1071
|
private reconnectForTokenRefresh;
|
|
658
1072
|
constructor(config: AreteConfig);
|
|
@@ -661,7 +1075,9 @@ declare class ConnectionManager {
|
|
|
661
1075
|
private hasRefreshableAuth;
|
|
662
1076
|
private updateTokenState;
|
|
663
1077
|
private clearTokenState;
|
|
1078
|
+
private tokenCovers;
|
|
664
1079
|
private getOrRefreshToken;
|
|
1080
|
+
private fetchAuthToken;
|
|
665
1081
|
private createTokenEndpointRequestBody;
|
|
666
1082
|
private fetchTokenFromEndpoint;
|
|
667
1083
|
private isTokenExpired;
|
|
@@ -673,20 +1089,25 @@ declare class ConnectionManager {
|
|
|
673
1089
|
private handleSocketIssueMessage;
|
|
674
1090
|
private rotateConnectionForTokenRefresh;
|
|
675
1091
|
private buildAuthUrl;
|
|
1092
|
+
private requireWebsocketUrl;
|
|
676
1093
|
private createWebSocket;
|
|
677
1094
|
getState(): ConnectionState;
|
|
1095
|
+
getHttpAuthToken(forceRefresh?: boolean): Promise<string | undefined>;
|
|
1096
|
+
getHttpAuthToken(requiredScopes?: readonly string[], forceRefresh?: boolean): Promise<string | undefined>;
|
|
1097
|
+
clearHttpAuthToken(): void;
|
|
678
1098
|
onFrame(handler: FrameHandler): () => void;
|
|
679
1099
|
onStateChange(handler: ConnectionStateCallback): () => void;
|
|
680
1100
|
onSocketIssue(handler: SocketIssueCallback): () => void;
|
|
681
1101
|
private notifySocketIssue;
|
|
682
|
-
connect(): Promise<void>;
|
|
1102
|
+
connect(recovering?: boolean): Promise<void>;
|
|
683
1103
|
disconnect(): void;
|
|
684
1104
|
subscribe(subscription: Subscription): void;
|
|
685
|
-
unsubscribe(
|
|
1105
|
+
unsubscribe(subscriptionId: string): void;
|
|
1106
|
+
refresh(subscription: Subscription): void;
|
|
686
1107
|
isConnected(): boolean;
|
|
687
|
-
private makeSubKey;
|
|
688
1108
|
private flushSubscriptionQueue;
|
|
689
1109
|
private resubscribeActive;
|
|
1110
|
+
private addQueuedSubscription;
|
|
690
1111
|
private updateState;
|
|
691
1112
|
private notifyFrameHandlers;
|
|
692
1113
|
private handleReconnect;
|
|
@@ -696,7 +1117,7 @@ declare class ConnectionManager {
|
|
|
696
1117
|
}
|
|
697
1118
|
|
|
698
1119
|
type UpdateCallback<T = unknown> = (viewPath: string, key: string, update: Update<T>) => void;
|
|
699
|
-
type RichUpdateCallback
|
|
1120
|
+
type RichUpdateCallback<T = unknown> = (viewPath: string, key: string, update: RichUpdate<T>) => void;
|
|
700
1121
|
interface StorageAdapterConfig {
|
|
701
1122
|
maxEntriesPerView?: number | null;
|
|
702
1123
|
}
|
|
@@ -722,77 +1143,57 @@ interface StorageAdapter {
|
|
|
722
1143
|
setViewConfig?(viewPath: string, config: ViewSortConfig): void;
|
|
723
1144
|
getViewConfig?(viewPath: string): ViewSortConfig | undefined;
|
|
724
1145
|
onUpdate(callback: UpdateCallback): () => void;
|
|
725
|
-
onRichUpdate(callback: RichUpdateCallback
|
|
1146
|
+
onRichUpdate(callback: RichUpdateCallback): () => void;
|
|
726
1147
|
notifyUpdate<T>(viewPath: string, key: string, update: Update<T>): void;
|
|
727
1148
|
notifyRichUpdate<T>(viewPath: string, key: string, update: RichUpdate<T>): void;
|
|
728
1149
|
}
|
|
729
1150
|
|
|
730
|
-
declare class
|
|
731
|
-
private
|
|
732
|
-
private
|
|
733
|
-
constructor(
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
1151
|
+
declare class QueryStore {
|
|
1152
|
+
private readonly storage;
|
|
1153
|
+
private readonly records;
|
|
1154
|
+
constructor(storage: StorageAdapter);
|
|
1155
|
+
register(subscription: Subscription, queryKey: string): void;
|
|
1156
|
+
unregister(subscriptionId: string): void;
|
|
1157
|
+
getSubscription(subscriptionId: string): Subscription | undefined;
|
|
1158
|
+
getQueryKey(subscriptionId: string): string | undefined;
|
|
1159
|
+
getSnapshot<T>(subscriptionId: string): QuerySnapshot<T> | undefined;
|
|
1160
|
+
onChange(subscriptionId: string, callback: () => void): UnsubscribeFn;
|
|
1161
|
+
onUpdate<T>(subscriptionId: string, callback: (update: Update<T>) => void): UnsubscribeFn;
|
|
1162
|
+
onRichUpdate<T>(subscriptionId: string, callback: (update: RichUpdate<T>) => void): UnsubscribeFn;
|
|
1163
|
+
acknowledge(subscriptionId: string, effectiveQuery: SubscriptionQuery, mode: FrameMode, sort?: SortConfig): void;
|
|
1164
|
+
stageSnapshot(frame: SnapshotFrame, keys: readonly string[]): void;
|
|
1165
|
+
applyLive(subscriptionId: string, key: string, update: Update<unknown>, richUpdate?: RichUpdate<unknown>, sequence?: string): void;
|
|
1166
|
+
deleteGlobal(view: string, key: string, lastKnown?: unknown): void;
|
|
1167
|
+
evict(view: string, key: string): void;
|
|
1168
|
+
failFrame(frame: ErrorFrame): void;
|
|
1169
|
+
beginRefresh(subscriptionId: string, waitForSnapshot?: boolean): Promise<void>;
|
|
1170
|
+
failRefresh(subscriptionId: string, error: AreteError): void;
|
|
1171
|
+
beginReconnect(): void;
|
|
1172
|
+
failRefreshing(error: AreteError): void;
|
|
738
1173
|
clear(): void;
|
|
739
|
-
private
|
|
1174
|
+
private mergeIncremental;
|
|
1175
|
+
private sortKeys;
|
|
1176
|
+
private entitySequence;
|
|
1177
|
+
private fail;
|
|
1178
|
+
private resolveRefresh;
|
|
1179
|
+
private rejectRefresh;
|
|
1180
|
+
private requireRecord;
|
|
1181
|
+
private touch;
|
|
1182
|
+
private emitUpdate;
|
|
1183
|
+
private emitRichUpdate;
|
|
740
1184
|
}
|
|
741
1185
|
|
|
742
|
-
interface
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
reconnectIntervals?: number[];
|
|
748
|
-
maxReconnectAttempts?: number;
|
|
749
|
-
flushIntervalMs?: number;
|
|
750
|
-
validateFrames?: boolean;
|
|
751
|
-
/** Authentication configuration */
|
|
752
|
-
auth?: AuthConfig;
|
|
753
|
-
}
|
|
754
|
-
/** @deprecated Use ConnectOptions instead */
|
|
755
|
-
interface AreteOptionsWithStorage<TStack extends StackDefinition> extends AreteOptions<TStack> {
|
|
756
|
-
storage?: StorageAdapter;
|
|
757
|
-
maxEntriesPerView?: number | null;
|
|
758
|
-
flushIntervalMs?: number;
|
|
759
|
-
auth?: AuthConfig;
|
|
1186
|
+
interface WaitForProcessedSlotOptions {
|
|
1187
|
+
/** Reject if the requested slot has not been processed within this duration. */
|
|
1188
|
+
timeoutMs?: number;
|
|
1189
|
+
/** Abort this wait without affecting frame processing or the connection. */
|
|
1190
|
+
signal?: AbortSignal;
|
|
760
1191
|
}
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
type InstructionsInterface<TInstructions extends Record<string, InstructionHandler> | undefined> = TInstructions extends Record<string, InstructionHandler> ? {
|
|
766
|
-
[K in keyof TInstructions]: InstructionExecutor;
|
|
767
|
-
} : {};
|
|
768
|
-
declare class Arete<TStack extends StackDefinition> {
|
|
769
|
-
private readonly connection;
|
|
770
|
-
private readonly storage;
|
|
771
|
-
private readonly processor;
|
|
772
|
-
private readonly subscriptionRegistry;
|
|
773
|
-
private readonly _views;
|
|
774
|
-
private readonly stack;
|
|
775
|
-
private readonly _instructions;
|
|
776
|
-
private constructor();
|
|
777
|
-
private buildInstructions;
|
|
778
|
-
static connect<T extends StackDefinition>(stack: T, options?: ConnectOptions): Promise<Arete<T>>;
|
|
779
|
-
get views(): TypedViews<TStack['views']>;
|
|
780
|
-
get instructions(): InstructionsInterface<TStack['instructions']>;
|
|
781
|
-
get connectionState(): ConnectionState;
|
|
782
|
-
get stackName(): string;
|
|
783
|
-
get store(): StorageAdapter;
|
|
784
|
-
onConnectionStateChange(callback: ConnectionStateCallback): UnsubscribeFn;
|
|
785
|
-
onFrame(callback: (frame: Frame) => void): UnsubscribeFn;
|
|
786
|
-
onSocketIssue(callback: SocketIssueCallback): UnsubscribeFn;
|
|
787
|
-
connect(): Promise<void>;
|
|
788
|
-
disconnect(): void;
|
|
789
|
-
isConnected(): boolean;
|
|
790
|
-
clearStore(): void;
|
|
791
|
-
getStore(): StorageAdapter;
|
|
792
|
-
getConnection(): ConnectionManager;
|
|
793
|
-
getSubscriptionRegistry(): SubscriptionRegistry;
|
|
1192
|
+
declare class ProcessedSlotTimeoutError extends Error {
|
|
1193
|
+
readonly targetSlot: bigint;
|
|
1194
|
+
readonly processedSlot: bigint | null;
|
|
1195
|
+
constructor(targetSlot: bigint, processedSlot: bigint | null);
|
|
794
1196
|
}
|
|
795
|
-
|
|
796
1197
|
interface FrameProcessorConfig {
|
|
797
1198
|
maxEntriesPerView?: number | null;
|
|
798
1199
|
/**
|
|
@@ -805,24 +1206,54 @@ interface FrameProcessorConfig {
|
|
|
805
1206
|
*/
|
|
806
1207
|
flushIntervalMs?: number;
|
|
807
1208
|
schemas?: Record<string, Schema<unknown>>;
|
|
1209
|
+
patchSchemas?: Record<string, Schema<unknown>>;
|
|
1210
|
+
queryStore?: QueryStore;
|
|
1211
|
+
/** Whether rejected frames should also be written to `console.warn`. */
|
|
1212
|
+
warnOnValidationError?: boolean;
|
|
1213
|
+
/** Receives structured details whenever a generated schema rejects a frame. */
|
|
1214
|
+
onValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
|
|
1215
|
+
}
|
|
1216
|
+
interface FrameValidationDiagnostic {
|
|
1217
|
+
readonly view: string;
|
|
1218
|
+
readonly key?: string;
|
|
1219
|
+
readonly seq?: string;
|
|
1220
|
+
readonly operation: 'snapshot' | 'upsert' | 'patch';
|
|
1221
|
+
readonly error: unknown;
|
|
808
1222
|
}
|
|
809
1223
|
declare class FrameProcessor {
|
|
810
1224
|
private storage;
|
|
811
1225
|
private maxEntriesPerView;
|
|
812
1226
|
private flushIntervalMs;
|
|
813
1227
|
private schemas?;
|
|
1228
|
+
private patchSchemas?;
|
|
1229
|
+
private queryStore?;
|
|
1230
|
+
private warnOnValidationError;
|
|
1231
|
+
private onValidationError?;
|
|
814
1232
|
private pendingUpdates;
|
|
815
1233
|
private flushTimer;
|
|
816
1234
|
private isProcessing;
|
|
1235
|
+
private latestProcessedSlot;
|
|
1236
|
+
private processedSlotWaiters;
|
|
817
1237
|
constructor(storage: StorageAdapter, config?: FrameProcessorConfig);
|
|
818
1238
|
private getSchema;
|
|
819
|
-
private
|
|
1239
|
+
private normalizeEntity;
|
|
1240
|
+
private hasSchema;
|
|
1241
|
+
private normalizePathSegment;
|
|
1242
|
+
private normalizePath;
|
|
1243
|
+
private normalizeSortConfig;
|
|
1244
|
+
private normalizeAppendPaths;
|
|
1245
|
+
private extractSeq;
|
|
1246
|
+
private getInternalSeq;
|
|
1247
|
+
private compareSeq;
|
|
1248
|
+
private attachInternalSeq;
|
|
820
1249
|
handleFrame<T>(frame: Frame<T>): void;
|
|
821
1250
|
/**
|
|
822
1251
|
* Immediately flush all pending updates.
|
|
823
1252
|
* Useful for ensuring all updates are processed before reading state.
|
|
824
1253
|
*/
|
|
825
1254
|
flush(): void;
|
|
1255
|
+
getProcessedSlot(): bigint | null;
|
|
1256
|
+
waitForProcessedSlot(slot: number | bigint, options?: WaitForProcessedSlotOptions): Promise<bigint>;
|
|
826
1257
|
/**
|
|
827
1258
|
* Clean up any pending timers. Call when disposing the processor.
|
|
828
1259
|
*/
|
|
@@ -830,6 +1261,12 @@ declare class FrameProcessor {
|
|
|
830
1261
|
private scheduleFlush;
|
|
831
1262
|
private flushPendingUpdates;
|
|
832
1263
|
private processFrame;
|
|
1264
|
+
private normalizeSlot;
|
|
1265
|
+
private slotFromSeq;
|
|
1266
|
+
private frameSlot;
|
|
1267
|
+
private markFrameProcessed;
|
|
1268
|
+
private removeProcessedSlotWaiter;
|
|
1269
|
+
private createAbortError;
|
|
833
1270
|
private processFrameWithoutEnforce;
|
|
834
1271
|
private handleSubscribedFrame;
|
|
835
1272
|
private handleSnapshotFrame;
|
|
@@ -837,48 +1274,867 @@ declare class FrameProcessor {
|
|
|
837
1274
|
private handleEntityFrame;
|
|
838
1275
|
private handleEntityFrameWithoutEnforce;
|
|
839
1276
|
private emitRichUpdate;
|
|
1277
|
+
private createRichUpdate;
|
|
840
1278
|
private enforceMaxEntries;
|
|
841
1279
|
}
|
|
842
1280
|
|
|
843
|
-
interface
|
|
844
|
-
|
|
1281
|
+
interface NormalizedSubscriptionRequest {
|
|
1282
|
+
query: SubscriptionQuery;
|
|
1283
|
+
snapshot: SubscriptionSnapshotOptions;
|
|
845
1284
|
}
|
|
846
|
-
|
|
847
|
-
|
|
1285
|
+
declare function validateSubscriptionId(subscriptionId: string): void;
|
|
1286
|
+
declare function createSubscriptionId(): string;
|
|
1287
|
+
declare function normalizeSubscriptionQuery(query: SubscriptionQuery): SubscriptionQuery;
|
|
1288
|
+
declare function normalizeSubscriptionRequest(request: SubscriptionRequest): NormalizedSubscriptionRequest;
|
|
1289
|
+
declare function canonicalQueryKey(request: SubscriptionRequest): string;
|
|
1290
|
+
declare function normalizeSubscription(subscription: Subscription): Subscription;
|
|
1291
|
+
declare class SubscriptionRegistry {
|
|
1292
|
+
private readonly connection;
|
|
1293
|
+
private readonly queryStore;
|
|
1294
|
+
private readonly subscriptions;
|
|
1295
|
+
private readonly subscriptionsById;
|
|
1296
|
+
constructor(connection: ConnectionManager, queryStore: QueryStore);
|
|
1297
|
+
subscribe(query: SubscriptionQuery, snapshotEnabled?: boolean): QueryLease;
|
|
1298
|
+
refresh(query: SubscriptionQuery, snapshotEnabled?: boolean): Promise<void>;
|
|
1299
|
+
/**
|
|
1300
|
+
* Refresh every active subscription for a view, optionally narrowed to one
|
|
1301
|
+
* serialized key. Resolves immediately when nothing matches — refreshing a
|
|
1302
|
+
* view with no active subscriptions is a no-op, not an error.
|
|
1303
|
+
*/
|
|
1304
|
+
refreshView(view: string, key?: string): Promise<void>;
|
|
1305
|
+
getRefCount(query: SubscriptionQuery, snapshotEnabled?: boolean): number;
|
|
1306
|
+
getActiveSubscriptions(): Subscription[];
|
|
1307
|
+
getSnapshot<T>(query: SubscriptionQuery, snapshotEnabled?: boolean): QuerySnapshot<T> | undefined;
|
|
1308
|
+
handleConnectionState(state: ConnectionState): void;
|
|
1309
|
+
clear(): void;
|
|
1310
|
+
private createLease;
|
|
1311
|
+
private getTracker;
|
|
1312
|
+
private refreshTracker;
|
|
1313
|
+
private releaseTracker;
|
|
848
1314
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1315
|
+
|
|
1316
|
+
interface ChainClock {
|
|
1317
|
+
slot: number;
|
|
1318
|
+
epoch?: number;
|
|
1319
|
+
leaderScheduleEpoch?: number;
|
|
1320
|
+
unixTimestamp: number;
|
|
1321
|
+
}
|
|
1322
|
+
interface MintAccountInfo {
|
|
1323
|
+
address: string;
|
|
1324
|
+
ownerProgram: string;
|
|
1325
|
+
decimals: number | null;
|
|
1326
|
+
supply: string | null;
|
|
1327
|
+
mintAuthority: string | null;
|
|
1328
|
+
freezeAuthority: string | null;
|
|
1329
|
+
}
|
|
1330
|
+
interface TokenAccountInfo {
|
|
1331
|
+
address: string;
|
|
1332
|
+
ownerProgram: string;
|
|
1333
|
+
mint: string | null;
|
|
1334
|
+
owner: string | null;
|
|
1335
|
+
amount: string | null;
|
|
1336
|
+
uiAmountString: string | null;
|
|
1337
|
+
}
|
|
1338
|
+
interface TokenBalanceInfo {
|
|
1339
|
+
exists: boolean;
|
|
1340
|
+
address: string | null;
|
|
1341
|
+
owner: string;
|
|
1342
|
+
mint: string;
|
|
1343
|
+
tokenProgram?: string;
|
|
1344
|
+
amount: string;
|
|
1345
|
+
decimals?: number | null;
|
|
1346
|
+
uiAmountString?: string | null;
|
|
1347
|
+
contextSlot: bigint;
|
|
1348
|
+
}
|
|
1349
|
+
interface NativeBalanceInfo {
|
|
1350
|
+
lamports: bigint;
|
|
1351
|
+
contextSlot: bigint;
|
|
1352
|
+
}
|
|
1353
|
+
interface ContextSlotOptions {
|
|
1354
|
+
minContextSlot?: number | bigint;
|
|
1355
|
+
}
|
|
1356
|
+
interface TokenBalanceInput {
|
|
1357
|
+
owner: string;
|
|
1358
|
+
mint: string;
|
|
1359
|
+
tokenProgram?: string;
|
|
1360
|
+
}
|
|
1361
|
+
interface RawAccountInfo {
|
|
1362
|
+
address: string;
|
|
1363
|
+
ownerProgram: string;
|
|
1364
|
+
lamports: number;
|
|
1365
|
+
executable: boolean;
|
|
1366
|
+
data: Uint8Array;
|
|
1367
|
+
}
|
|
1368
|
+
interface ChainClient {
|
|
1369
|
+
exists(address: string): Promise<boolean>;
|
|
1370
|
+
lamports(address: string): Promise<number>;
|
|
1371
|
+
nativeBalance(address: string, options?: ContextSlotOptions): Promise<NativeBalanceInfo>;
|
|
1372
|
+
minimumBalanceForRentExemption(space: number): Promise<number>;
|
|
1373
|
+
clock(): Promise<ChainClock>;
|
|
1374
|
+
account(address: string): Promise<RawAccountInfo | null>;
|
|
1375
|
+
mint(address: string): Promise<MintAccountInfo | null>;
|
|
1376
|
+
tokenAccount(address: string): Promise<TokenAccountInfo | null>;
|
|
1377
|
+
balance(input: TokenBalanceInput, options?: ContextSlotOptions): Promise<TokenBalanceInfo>;
|
|
1378
|
+
}
|
|
1379
|
+
type FetchLike = typeof fetch;
|
|
1380
|
+
declare function deriveHttpEndpoint(wsUrl: string): string;
|
|
1381
|
+
declare function createChainClient(httpBaseUrl: string, fetchImpl: FetchLike): ChainClient;
|
|
1382
|
+
|
|
1383
|
+
interface SignerRegistry<TSigner = unknown> {
|
|
1384
|
+
register(address: string, signer: TSigner): void;
|
|
1385
|
+
unregister(address: string): boolean;
|
|
1386
|
+
get(address: string): TSigner | undefined;
|
|
1387
|
+
has(address: string): boolean;
|
|
1388
|
+
addresses(): readonly string[];
|
|
1389
|
+
values(): readonly TSigner[];
|
|
1390
|
+
entries(): readonly (readonly [string, TSigner])[];
|
|
869
1391
|
clear(): void;
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
1392
|
+
}
|
|
1393
|
+
declare function createSignerRegistry<TSigner = unknown>(entries?: Iterable<readonly [string, TSigner]>): SignerRegistry<TSigner>;
|
|
1394
|
+
|
|
1395
|
+
type OperationKind = 'instruction' | 'transaction' | 'flow';
|
|
1396
|
+
type NonEmptyReadonlyArray<T> = readonly [T, ...T[]];
|
|
1397
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
1398
|
+
type JsonValue = JsonPrimitive | JsonObject | readonly JsonValue[];
|
|
1399
|
+
interface JsonObject {
|
|
1400
|
+
readonly [key: string]: JsonValue;
|
|
1401
|
+
}
|
|
1402
|
+
interface PreparedOperationDescription {
|
|
1403
|
+
readonly kind: OperationKind;
|
|
1404
|
+
readonly name: string;
|
|
1405
|
+
readonly artifacts: JsonValue;
|
|
1406
|
+
readonly transactions: readonly {
|
|
1407
|
+
readonly name: string;
|
|
1408
|
+
readonly requiredSignerAddresses: readonly string[];
|
|
1409
|
+
readonly errors: readonly ErrorMetadata[];
|
|
1410
|
+
readonly instructions: readonly {
|
|
1411
|
+
readonly programId: string;
|
|
1412
|
+
readonly keys: readonly {
|
|
1413
|
+
readonly pubkey: string;
|
|
1414
|
+
readonly isSigner: boolean;
|
|
1415
|
+
readonly isWritable: boolean;
|
|
1416
|
+
}[];
|
|
1417
|
+
readonly data: readonly number[];
|
|
1418
|
+
}[];
|
|
1419
|
+
}[];
|
|
1420
|
+
}
|
|
1421
|
+
interface OperationInspection {
|
|
1422
|
+
/** JSON-safe description produced by {@link describePreparedOperation}. */
|
|
1423
|
+
readonly description: PreparedOperationDescription;
|
|
1424
|
+
/** Raw unsigned inspection returned by the adapter. */
|
|
1425
|
+
readonly transaction: TransactionInspectionResult;
|
|
1426
|
+
/** IDL-aware program error parsed from the inspection failure, if any. */
|
|
1427
|
+
readonly programError: ProgramError | null;
|
|
1428
|
+
}
|
|
1429
|
+
interface OperationInspectionOptions {
|
|
1430
|
+
wallet?: WalletAdapter;
|
|
1431
|
+
inspect?: TransactionInspectionOptions;
|
|
1432
|
+
transactionTransport?: TransactionTransport;
|
|
1433
|
+
}
|
|
1434
|
+
interface PreparedTransactionBody {
|
|
1435
|
+
readonly name: string;
|
|
1436
|
+
readonly instructions: NonEmptyReadonlyArray<BuiltInstruction>;
|
|
1437
|
+
readonly requiredSignerAddresses: readonly string[];
|
|
1438
|
+
readonly errors: readonly ErrorMetadata[];
|
|
1439
|
+
}
|
|
1440
|
+
interface OperationPlan<TArtifacts = void> {
|
|
1441
|
+
readonly name: string;
|
|
1442
|
+
readonly artifacts: TArtifacts;
|
|
1443
|
+
readonly transactions: NonEmptyReadonlyArray<PreparedTransactionBody>;
|
|
1444
|
+
}
|
|
1445
|
+
interface PreparedOperationBase<TKind extends OperationKind, TArtifacts> {
|
|
1446
|
+
readonly kind: TKind;
|
|
1447
|
+
readonly name: string;
|
|
1448
|
+
readonly plan: OperationPlan<TArtifacts>;
|
|
1449
|
+
readonly artifacts: TArtifacts;
|
|
1450
|
+
}
|
|
1451
|
+
interface PreparedInstruction<TArtifacts = void> extends PreparedOperationBase<'instruction', TArtifacts> {
|
|
1452
|
+
readonly instruction: BuiltInstruction;
|
|
1453
|
+
readonly transaction: PreparedTransactionBody;
|
|
1454
|
+
}
|
|
1455
|
+
interface PreparedTransaction<TArtifacts = void> extends PreparedOperationBase<'transaction', TArtifacts> {
|
|
1456
|
+
readonly transaction: PreparedTransactionBody;
|
|
1457
|
+
}
|
|
1458
|
+
interface PreparedFlow<TArtifacts = void> extends PreparedOperationBase<'flow', TArtifacts> {
|
|
1459
|
+
}
|
|
1460
|
+
type PreparedOperation<TArtifacts = unknown> = PreparedInstruction<TArtifacts> | PreparedTransaction<TArtifacts> | PreparedFlow<TArtifacts>;
|
|
1461
|
+
interface CreatePreparedInstructionInput<TArtifacts> {
|
|
1462
|
+
name: string;
|
|
1463
|
+
instruction: BuiltInstruction;
|
|
1464
|
+
artifacts: TArtifacts;
|
|
1465
|
+
requiredSignerAddresses?: readonly string[];
|
|
1466
|
+
errors?: readonly ErrorMetadata[];
|
|
1467
|
+
}
|
|
1468
|
+
type PreparedTransactionInstruction = BuiltInstruction | PreparedInstruction<unknown>;
|
|
1469
|
+
type PreparedTransactionOperation = PreparedInstruction<unknown> | PreparedTransaction<unknown>;
|
|
1470
|
+
interface CreatePreparedTransactionBaseInput<TArtifacts> {
|
|
1471
|
+
name: string;
|
|
1472
|
+
artifacts: TArtifacts;
|
|
1473
|
+
requiredSignerAddresses?: readonly string[];
|
|
1474
|
+
errors?: readonly ErrorMetadata[];
|
|
1475
|
+
}
|
|
1476
|
+
type CreatePreparedTransactionInput<TArtifacts> = CreatePreparedTransactionBaseInput<TArtifacts> & ({
|
|
1477
|
+
instructions: readonly PreparedTransactionInstruction[];
|
|
1478
|
+
operations?: never;
|
|
1479
|
+
} | {
|
|
1480
|
+
operations: readonly PreparedTransactionOperation[];
|
|
1481
|
+
instructions?: never;
|
|
1482
|
+
});
|
|
1483
|
+
interface CreatePreparedFlowInput<TArtifacts> {
|
|
1484
|
+
name: string;
|
|
1485
|
+
transactions: readonly PreparedTransactionBody[];
|
|
1486
|
+
artifacts: TArtifacts;
|
|
1487
|
+
}
|
|
1488
|
+
declare function createPreparedTransactionBody(input: {
|
|
1489
|
+
name: string;
|
|
1490
|
+
instructions: readonly BuiltInstruction[];
|
|
1491
|
+
requiredSignerAddresses?: readonly string[];
|
|
1492
|
+
errors?: readonly ErrorMetadata[];
|
|
1493
|
+
}): PreparedTransactionBody;
|
|
1494
|
+
declare function createPreparedInstruction<TArtifacts>(input: CreatePreparedInstructionInput<TArtifacts>): PreparedInstruction<TArtifacts>;
|
|
1495
|
+
declare function createPreparedTransaction<TArtifacts>(input: CreatePreparedTransactionInput<TArtifacts>): PreparedTransaction<TArtifacts>;
|
|
1496
|
+
declare function createPreparedFlow<TArtifacts>(input: CreatePreparedFlowInput<TArtifacts>): PreparedFlow<TArtifacts>;
|
|
1497
|
+
declare function prependTransactionInstructions(transaction: PreparedTransactionBody, instructions: readonly BuiltInstruction[]): PreparedTransactionBody;
|
|
1498
|
+
declare function appendTransactionInstructions(transaction: PreparedTransactionBody, instructions: readonly BuiltInstruction[]): PreparedTransactionBody;
|
|
1499
|
+
declare function appendFlowTransactions<TArtifacts>(flow: PreparedFlow<TArtifacts>, transactions: readonly PreparedTransactionBody[]): PreparedFlow<TArtifacts>;
|
|
1500
|
+
declare function prependFlowTransactionInstructions<TArtifacts>(flow: PreparedFlow<TArtifacts>, transactionIndex: number, instructions: readonly BuiltInstruction[]): PreparedFlow<TArtifacts>;
|
|
1501
|
+
interface OperationTransactionReceipt {
|
|
1502
|
+
readonly transactionIndex: number;
|
|
1503
|
+
readonly transactionName: string;
|
|
1504
|
+
readonly signature: string;
|
|
1505
|
+
readonly slot?: number;
|
|
1506
|
+
}
|
|
1507
|
+
interface SingleTransactionOperationReceipt<TArtifacts> {
|
|
1508
|
+
readonly kind: 'instruction' | 'transaction';
|
|
1509
|
+
readonly operationName: string;
|
|
1510
|
+
readonly artifacts: TArtifacts;
|
|
1511
|
+
readonly signatures: NonEmptyReadonlyArray<string>;
|
|
1512
|
+
readonly transaction: OperationTransactionReceipt;
|
|
1513
|
+
readonly callbackErrors?: readonly OperationCallbackError[];
|
|
1514
|
+
}
|
|
1515
|
+
interface FlowOperationReceipt<TArtifacts> {
|
|
1516
|
+
readonly kind: 'flow';
|
|
1517
|
+
readonly operationName: string;
|
|
1518
|
+
readonly artifacts: TArtifacts;
|
|
1519
|
+
readonly signatures: NonEmptyReadonlyArray<string>;
|
|
1520
|
+
readonly transactions: NonEmptyReadonlyArray<OperationTransactionReceipt>;
|
|
1521
|
+
readonly callbackErrors?: readonly OperationCallbackError[];
|
|
1522
|
+
}
|
|
1523
|
+
type OperationReceiptFor<TPrepared extends PreparedOperation> = TPrepared extends PreparedFlow<infer TArtifacts> ? FlowOperationReceipt<TArtifacts> : TPrepared extends PreparedInstruction<infer TArtifacts> ? SingleTransactionOperationReceipt<TArtifacts> : TPrepared extends PreparedTransaction<infer TArtifacts> ? SingleTransactionOperationReceipt<TArtifacts> : never;
|
|
1524
|
+
interface OperationExecutionEvent<TPrepared extends PreparedOperation = PreparedOperation> {
|
|
1525
|
+
readonly operation: TPrepared;
|
|
1526
|
+
readonly transaction: PreparedTransactionBody;
|
|
1527
|
+
readonly transactionIndex: number;
|
|
1528
|
+
}
|
|
1529
|
+
interface OperationExecutionSuccessEvent<TPrepared extends PreparedOperation = PreparedOperation> extends OperationExecutionEvent<TPrepared> {
|
|
1530
|
+
readonly receipt: OperationTransactionReceipt;
|
|
1531
|
+
}
|
|
1532
|
+
type OperationCallbackPhase = 'transaction-start' | 'transaction-success';
|
|
1533
|
+
interface OperationExecutionOptions<TSigner = unknown, TPrepared extends PreparedOperation = PreparedOperation> {
|
|
1534
|
+
wallet?: WalletAdapter;
|
|
1535
|
+
transactionTransport?: TransactionTransport;
|
|
1536
|
+
send?: SendOptions;
|
|
1537
|
+
signers?: readonly TSigner[];
|
|
1538
|
+
signerRegistry?: SignerRegistry<TSigner>;
|
|
1539
|
+
availableSignerAddresses?: readonly string[];
|
|
1540
|
+
onTransactionStart?: (event: OperationExecutionEvent<TPrepared>) => void | Promise<void>;
|
|
1541
|
+
onTransactionSuccess?: (event: OperationExecutionSuccessEvent<TPrepared>) => void | Promise<void>;
|
|
1542
|
+
/** Receives observer failures without changing the transaction outcome. */
|
|
1543
|
+
onCallbackError?: (error: OperationCallbackError<TPrepared>) => void | Promise<void>;
|
|
1544
|
+
}
|
|
1545
|
+
interface OperationExecutionHost<TSigner = unknown> {
|
|
1546
|
+
readonly wallet?: WalletAdapter;
|
|
1547
|
+
readonly publicKey?: string;
|
|
1548
|
+
transaction(instructions: readonly BuiltInstruction[], options?: {
|
|
1549
|
+
wallet?: WalletAdapter;
|
|
1550
|
+
send?: SendOptions;
|
|
1551
|
+
errors?: ErrorMetadata[];
|
|
1552
|
+
signers?: readonly TSigner[];
|
|
1553
|
+
transactionTransport?: TransactionTransport;
|
|
1554
|
+
}): Promise<{
|
|
1555
|
+
signature: string;
|
|
1556
|
+
slot?: number;
|
|
1557
|
+
}>;
|
|
1558
|
+
}
|
|
1559
|
+
declare class OperationCallbackError<TPrepared extends PreparedOperation = PreparedOperation> extends Error {
|
|
1560
|
+
readonly phase: OperationCallbackPhase;
|
|
1561
|
+
readonly operation: TPrepared;
|
|
1562
|
+
readonly transaction: PreparedTransactionBody;
|
|
1563
|
+
readonly transactionIndex: number;
|
|
1564
|
+
readonly receipt?: OperationTransactionReceipt;
|
|
1565
|
+
readonly cause: unknown;
|
|
1566
|
+
constructor(input: {
|
|
1567
|
+
phase: OperationCallbackPhase;
|
|
1568
|
+
operation: TPrepared;
|
|
1569
|
+
transaction: PreparedTransactionBody;
|
|
1570
|
+
transactionIndex: number;
|
|
1571
|
+
receipt?: OperationTransactionReceipt;
|
|
1572
|
+
cause: unknown;
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
declare class OperationExecutionError<TPrepared extends PreparedOperation = PreparedOperation> extends Error {
|
|
1576
|
+
readonly operation: TPrepared;
|
|
1577
|
+
readonly failedTransaction: PreparedTransactionBody;
|
|
1578
|
+
readonly failedTransactionIndex: number;
|
|
1579
|
+
readonly completedReceipts: readonly OperationTransactionReceipt[];
|
|
1580
|
+
readonly callbackErrors: readonly OperationCallbackError<TPrepared>[];
|
|
1581
|
+
readonly outcome: TransactionFailureOutcome;
|
|
1582
|
+
readonly signature?: string;
|
|
1583
|
+
readonly slot?: number;
|
|
1584
|
+
readonly cause: unknown;
|
|
1585
|
+
constructor(input: {
|
|
1586
|
+
operation: TPrepared;
|
|
1587
|
+
failedTransaction: PreparedTransactionBody;
|
|
1588
|
+
failedTransactionIndex: number;
|
|
1589
|
+
completedReceipts: readonly OperationTransactionReceipt[];
|
|
1590
|
+
callbackErrors?: readonly OperationCallbackError<TPrepared>[];
|
|
1591
|
+
outcome?: TransactionFailureOutcome;
|
|
1592
|
+
cause: unknown;
|
|
1593
|
+
});
|
|
1594
|
+
}
|
|
1595
|
+
declare function executePreparedOperation<TPrepared extends PreparedOperation, TSigner = unknown>(host: OperationExecutionHost<TSigner>, operation: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
|
|
1596
|
+
/**
|
|
1597
|
+
* Recursively unwrap operation context while retaining structured transaction outcomes.
|
|
1598
|
+
*/
|
|
1599
|
+
declare function unwrapOperationExecutionError(error: unknown): InstructionError | TransactionFailureOutcome | unknown;
|
|
1600
|
+
declare function toJsonValue(value: unknown): JsonValue;
|
|
1601
|
+
declare function describePreparedOperation(operation: PreparedOperation): PreparedOperationDescription;
|
|
1602
|
+
/**
|
|
1603
|
+
* Inspect one prepared instruction/transaction without signing or submission.
|
|
1604
|
+
* Multi-transaction flows are intentionally unsupported.
|
|
1605
|
+
*/
|
|
1606
|
+
declare function inspectPreparedOperation(wallet: WalletAdapter | undefined, operation: PreparedOperation, options?: TransactionInspectionOptions, context?: WalletExecutionContext): Promise<OperationInspection>;
|
|
1607
|
+
declare function formatPreparedOperation(operation: PreparedOperation): string;
|
|
1608
|
+
|
|
1609
|
+
interface InstructionOperation<TInput = unknown, TArtifacts = void> {
|
|
1610
|
+
readonly kind: 'instruction';
|
|
1611
|
+
prepare(input: TInput): Promise<PreparedInstruction<TArtifacts>>;
|
|
1612
|
+
}
|
|
1613
|
+
interface TransactionOperation<TInput = unknown, TArtifacts = void> {
|
|
1614
|
+
readonly kind: 'transaction';
|
|
1615
|
+
prepare(input: TInput): Promise<PreparedTransaction<TArtifacts>>;
|
|
1616
|
+
}
|
|
1617
|
+
interface FlowOperation<TInput = unknown, TArtifacts = void> {
|
|
1618
|
+
readonly kind: 'flow';
|
|
1619
|
+
prepare(input: TInput): Promise<PreparedFlow<TArtifacts>>;
|
|
1620
|
+
}
|
|
1621
|
+
type AnyOperation = InstructionOperation<any, any> | TransactionOperation<any, any> | FlowOperation<any, any>;
|
|
1622
|
+
type OperationNamespace<TOperation extends AnyOperation = AnyOperation> = {
|
|
1623
|
+
readonly [key: string]: TOperation | OperationNamespace<TOperation>;
|
|
1624
|
+
};
|
|
1625
|
+
type InstructionOperationNamespace = OperationNamespace<InstructionOperation<any, any>>;
|
|
1626
|
+
type TransactionOperationNamespace = OperationNamespace<TransactionOperation<any, any>>;
|
|
1627
|
+
type FlowOperationNamespace = OperationNamespace<FlowOperation<any, any>>;
|
|
1628
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
1629
|
+
declare function instructionOperation<TInput, TArtifacts>(prepare: (input: TInput) => MaybePromise<PreparedInstruction<TArtifacts>>): InstructionOperation<TInput, TArtifacts>;
|
|
1630
|
+
declare function transactionOperation<TInput, TArtifacts>(prepare: (input: TInput) => MaybePromise<PreparedTransaction<TArtifacts>>): TransactionOperation<TInput, TArtifacts>;
|
|
1631
|
+
declare function flowOperation<TInput, TArtifacts>(prepare: (input: TInput) => MaybePromise<PreparedFlow<TArtifacts>>): FlowOperation<TInput, TArtifacts>;
|
|
1632
|
+
|
|
1633
|
+
declare const STACK_RUNTIME_EXTENSIONS: "__areteStackRuntimeExtensions";
|
|
1634
|
+
declare const PROGRAM_OPERATION_EXTENSIONS: "__areteProgramOperationExtensions";
|
|
1635
|
+
type EmptyRecord = Record<string, never>;
|
|
1636
|
+
/** Fixed arity, or `[required, total]` when a read has optional arguments. */
|
|
1637
|
+
type ReadArgumentCount = number | readonly [required: number, total: number];
|
|
1638
|
+
type RequiredArgumentCount<TArgs extends readonly unknown[], TCount extends readonly unknown[] = []> = TArgs extends readonly [infer THead, ...infer TTail] ? undefined extends THead ? TCount['length'] : RequiredArgumentCount<TTail, readonly [...TCount, unknown]> : TCount['length'];
|
|
1639
|
+
type ReadArgumentCountFor<TRead> = TRead extends (...args: infer TArgs) => unknown ? number extends Required<TArgs>['length'] ? ReadArgumentCount : RequiredArgumentCount<TArgs> extends Required<TArgs>['length'] ? Required<TArgs>['length'] : readonly [
|
|
1640
|
+
required: RequiredArgumentCount<TArgs>,
|
|
1641
|
+
total: Required<TArgs>['length']
|
|
1642
|
+
] : never;
|
|
1643
|
+
type ReadArgumentCounts<TRead = Record<string, unknown>> = {
|
|
1644
|
+
readonly [K in keyof TRead]: ReadArgumentCountFor<TRead[K]>;
|
|
1645
|
+
};
|
|
1646
|
+
type MaybeField<TKey extends string, TValue> = [TValue] extends [never] ? {} : {
|
|
1647
|
+
readonly [K in TKey]: TValue;
|
|
1648
|
+
};
|
|
1649
|
+
type Field<TValue, TKey extends PropertyKey> = TKey extends keyof TValue ? TValue[TKey] : never;
|
|
1650
|
+
type DeepMerge<TBase, TExtension> = TBase extends Record<string, unknown> ? TExtension extends Record<string, unknown> ? Omit<TBase, keyof TExtension> & {
|
|
1651
|
+
readonly [K in keyof TExtension]: K extends keyof TBase ? DeepMerge<TBase[K], TExtension[K]> : TExtension[K];
|
|
1652
|
+
} : TExtension : TExtension;
|
|
1653
|
+
type MergeField<TBase, TExtension> = [TBase] extends [never] ? TExtension : [TExtension] extends [never] ? TBase : DeepMerge<TBase, TExtension>;
|
|
1654
|
+
type FactoryReturn<TValue, TKey extends PropertyKey> = TKey extends keyof TValue ? NonNullable<TValue[TKey]> extends (...args: any[]) => infer TResult ? TResult : never : never;
|
|
1655
|
+
interface ProgramOperations<TInstructions extends InstructionOperationNamespace | EmptyRecord = EmptyRecord, TTransactions extends TransactionOperationNamespace | EmptyRecord = EmptyRecord, TFlows extends FlowOperationNamespace | EmptyRecord = EmptyRecord> {
|
|
1656
|
+
readonly instructions?: TInstructions;
|
|
1657
|
+
readonly transactions?: TTransactions;
|
|
1658
|
+
readonly flows?: TFlows;
|
|
1659
|
+
}
|
|
1660
|
+
type AnyProgramOperations = ProgramOperations<InstructionOperationNamespace, TransactionOperationNamespace, FlowOperationNamespace>;
|
|
1661
|
+
type InstructionOperationsOf<TOperations> = TOperations extends ProgramOperations<infer TInstructions, any, any> ? TInstructions : EmptyRecord;
|
|
1662
|
+
type TransactionOperationsOf<TOperations> = TOperations extends ProgramOperations<any, infer TTransactions, any> ? TTransactions : EmptyRecord;
|
|
1663
|
+
type FlowOperationsOf<TOperations> = TOperations extends ProgramOperations<any, any, infer TFlows> ? TFlows : EmptyRecord;
|
|
1664
|
+
interface ProgramOperationContext<TProgram extends ProgramSdkDefinition = ProgramSdkDefinition> {
|
|
1665
|
+
readonly chain: ChainClient;
|
|
1666
|
+
readonly wallet: WalletAdapter | undefined;
|
|
1667
|
+
readonly program: ProgramInterface<TProgram>;
|
|
1668
|
+
}
|
|
1669
|
+
interface ProgramRuntimeExtensions<TOperations extends AnyProgramOperations = ProgramOperations, TProgram extends ProgramSdkDefinition = ProgramSdkDefinition> {
|
|
1670
|
+
readonly createOperations: (context: ProgramOperationContext<TProgram>) => TOperations;
|
|
1671
|
+
}
|
|
1672
|
+
interface ProgramRuntimeExtensionCarrier<TOperations extends AnyProgramOperations = ProgramOperations> {
|
|
1673
|
+
readonly [PROGRAM_OPERATION_EXTENSIONS]?: ProgramRuntimeExtensions<TOperations, any>;
|
|
1674
|
+
}
|
|
1675
|
+
type ProgramOperationsOf<TProgram> = TProgram extends ProgramRuntimeExtensionCarrier<infer TOperations> ? TOperations : ProgramOperations;
|
|
1676
|
+
type MergeProgramOperations<TBase extends AnyProgramOperations, TExtension extends AnyProgramOperations> = ProgramOperations<Extract<MergeField<InstructionOperationsOf<TBase>, InstructionOperationsOf<TExtension>>, InstructionOperationNamespace | EmptyRecord>, Extract<MergeField<TransactionOperationsOf<TBase>, TransactionOperationsOf<TExtension>>, TransactionOperationNamespace | EmptyRecord>, Extract<MergeField<FlowOperationsOf<TBase>, FlowOperationsOf<TExtension>>, FlowOperationNamespace | EmptyRecord>>;
|
|
1677
|
+
type ExtendedProgramDefinition<TBase extends ProgramSdkDefinition, TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TMath = never> = Omit<TBase, 'definitionHash'> & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath> & ProgramRuntimeExtensionCarrier<MergeProgramOperations<ProgramOperationsOf<TBase>, TOperations>>;
|
|
1678
|
+
interface ProgramExtensionInput<TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TProgram extends ProgramSdkDefinition = ProgramSdkDefinition, TMath = never> {
|
|
1679
|
+
readonly pdas?: Record<string, unknown>;
|
|
1680
|
+
readonly accounts?: Record<string, unknown>;
|
|
1681
|
+
readonly queries?: Record<string, unknown>;
|
|
1682
|
+
readonly raw?: Record<string, unknown>;
|
|
1683
|
+
readonly addresses?: TAddresses;
|
|
1684
|
+
readonly constants?: TConstants;
|
|
1685
|
+
readonly defaults?: TDefaults;
|
|
1686
|
+
readonly math?: TMath;
|
|
1687
|
+
readonly createOperations?: (context: ProgramOperationContext<TProgram>) => TOperations;
|
|
1688
|
+
}
|
|
1689
|
+
declare function defineProgramExtensions<TBase extends ProgramSdkDefinition>(): <TAddresses = never, TConstants = never, TDefaults = never, TOperations extends AnyProgramOperations = ProgramOperations, TMath = never>(extensions: Omit<ProgramExtensionInput<any, any, any, any, any, any>, "addresses" | "constants" | "defaults" | "math" | "createOperations"> & {
|
|
1690
|
+
readonly addresses?: TAddresses;
|
|
1691
|
+
readonly constants?: TConstants;
|
|
1692
|
+
readonly defaults?: TDefaults;
|
|
1693
|
+
readonly math?: TMath;
|
|
1694
|
+
readonly createOperations?: (context: ProgramOperationContext<ExtendedProgramDefinition<TBase, TAddresses, TConstants, TDefaults, ProgramOperations, TMath>>) => TOperations;
|
|
1695
|
+
}) => ProgramExtensionInput<TAddresses, TConstants, TDefaults, TOperations, ExtendedProgramDefinition<TBase, TAddresses, TConstants, TDefaults, ProgramOperations, TMath>, TMath>;
|
|
1696
|
+
declare function extendProgram<TBase extends ProgramSdkDefinition, TExtension extends ProgramExtensionInput<any, any, any, any, any, any>>(program: TBase, extensions: TExtension): ExtendedProgramDefinition<TBase, MergeField<Field<TBase, 'addresses'>, Field<TExtension, 'addresses'>>, MergeField<Field<TBase, 'constants'>, Field<TExtension, 'constants'>>, MergeField<Field<TBase, 'defaults'>, Field<TExtension, 'defaults'>>, Extract<FactoryReturn<TExtension, 'createOperations'>, AnyProgramOperations>, MergeField<Field<TBase, 'math'>, Field<TExtension, 'math'>>>;
|
|
1697
|
+
declare function extendPrograms<TPrograms extends Record<string, ProgramSdkDefinition>, TExtensions extends Partial<{
|
|
1698
|
+
[K in keyof TPrograms]: ProgramExtensionInput<any, any, any, any, any, any>;
|
|
1699
|
+
}>>(programs: TPrograms, extensions: TExtensions): {
|
|
1700
|
+
readonly [K in keyof TPrograms]: K extends keyof TExtensions ? NonNullable<TExtensions[K]> extends ProgramExtensionInput<infer TAddresses, infer THelpers, infer TTypes, infer TOperations, any, infer TMath> ? ExtendedProgramDefinition<TPrograms[K], TAddresses, THelpers, TTypes, TOperations, TMath> : TPrograms[K] : TPrograms[K];
|
|
1701
|
+
};
|
|
1702
|
+
declare function getProgramRuntimeExtensions<TProgram extends ProgramSdkDefinition>(program: TProgram): ProgramRuntimeExtensions<ProgramOperationsOf<TProgram>, TProgram> | undefined;
|
|
1703
|
+
interface StackRuntimeExtensions<TRead = EmptyRecord, TFlows extends FlowOperationNamespace | EmptyRecord = EmptyRecord, TClient = unknown> {
|
|
1704
|
+
readonly readArgCounts?: ReadArgumentCounts<TRead>;
|
|
1705
|
+
readonly createRead?: (client: TClient) => TRead;
|
|
1706
|
+
readonly createFlows?: (client: TClient) => TFlows;
|
|
1707
|
+
}
|
|
1708
|
+
interface StackRuntimeExtensionCarrier<TRead = EmptyRecord, TFlows extends FlowOperationNamespace | EmptyRecord = EmptyRecord> {
|
|
1709
|
+
readonly [STACK_RUNTIME_EXTENSIONS]?: StackRuntimeExtensions<TRead, TFlows>;
|
|
1710
|
+
}
|
|
1711
|
+
type ExtendedStackDefinition<TBase extends StackDefinition, TAddresses = never, TConstants = never, TDefaults = never, TMath = never, TRead = never, TFlows extends FlowOperationNamespace | EmptyRecord = never> = TBase & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath> & StackRuntimeExtensionCarrier<TRead, TFlows>;
|
|
1712
|
+
type StackConnectedExtensions<TStack> = MaybeField<'addresses', Field<TStack, 'addresses'>> & MaybeField<'constants', Field<TStack, 'constants'>> & MaybeField<'defaults', Field<TStack, 'defaults'>> & MaybeField<'math', Field<TStack, 'math'>> & (TStack extends StackRuntimeExtensionCarrier<infer TRead, infer TFlows> ? MaybeField<'read', TRead> & MaybeField<'flows', TFlows> : {});
|
|
1713
|
+
type ConnectedStackClient<TClient extends object, TStack> = TClient & StackConnectedExtensions<TStack>;
|
|
1714
|
+
type StackReadOf<TStack> = TStack extends StackRuntimeExtensionCarrier<infer TRead, any> ? TRead : never;
|
|
1715
|
+
type StackFlowsOf<TStack> = TStack extends StackRuntimeExtensionCarrier<any, infer TFlows> ? TFlows : never;
|
|
1716
|
+
interface StackExtensionInput<TAddresses = never, TConstants = never, TDefaults = never, TMath = never, TRead = never, TFlows extends FlowOperationNamespace | EmptyRecord = never, TClient = unknown> {
|
|
1717
|
+
readonly addresses?: TAddresses;
|
|
1718
|
+
readonly constants?: TConstants;
|
|
1719
|
+
readonly defaults?: TDefaults;
|
|
1720
|
+
readonly math?: TMath;
|
|
1721
|
+
readonly readArgCounts?: ReadArgumentCounts<TRead>;
|
|
1722
|
+
readonly createRead?: (client: TClient) => TRead;
|
|
1723
|
+
readonly createFlows?: (client: TClient) => TFlows;
|
|
1724
|
+
}
|
|
1725
|
+
type ReadArgumentCountRequirement<TExtension> = TExtension extends {
|
|
1726
|
+
readonly createRead: (...args: any[]) => infer TRead;
|
|
1727
|
+
} ? {
|
|
1728
|
+
readonly readArgCounts: ReadArgumentCounts<TRead>;
|
|
1729
|
+
} : {};
|
|
1730
|
+
type StackExtensionClient<TBase extends StackDefinition, TAddresses = never, TConstants = never, TDefaults = never, TMath = never> = Arete$1<TBase> & MaybeField<'addresses', TAddresses> & MaybeField<'constants', TConstants> & MaybeField<'defaults', TDefaults> & MaybeField<'math', TMath>;
|
|
1731
|
+
declare function defineStackExtensions<TBase extends StackDefinition>(): <const TExtension extends StackExtensionInput<any, any, any, any, any, FlowOperationNamespace | EmptyRecord, any>>(extensions: TExtension & ReadArgumentCountRequirement<TExtension> & {
|
|
1732
|
+
readonly createRead?: (client: StackExtensionClient<TBase, any, any, any, any>) => unknown;
|
|
1733
|
+
readonly createFlows?: (client: StackExtensionClient<TBase, any, any, any, any>) => FlowOperationNamespace | EmptyRecord;
|
|
1734
|
+
}) => TExtension;
|
|
1735
|
+
declare function extendStack<TBase extends StackDefinition, TExtension extends StackExtensionInput<any, any, any, any, any, any, any>>(stack: TBase, extensions: TExtension & ReadArgumentCountRequirement<TExtension>): ExtendedStackDefinition<TBase, MergeField<Field<TBase, 'addresses'>, Field<TExtension, 'addresses'>>, MergeField<Field<TBase, 'constants'>, Field<TExtension, 'constants'>>, MergeField<Field<TBase, 'defaults'>, Field<TExtension, 'defaults'>>, MergeField<Field<TBase, 'math'>, Field<TExtension, 'math'>>, MergeField<StackReadOf<TBase>, FactoryReturn<TExtension, 'createRead'>>, Extract<MergeField<StackFlowsOf<TBase>, FactoryReturn<TExtension, 'createFlows'>>, FlowOperationNamespace | EmptyRecord>>;
|
|
1736
|
+
declare function getStackRuntimeExtensions<TStack extends StackDefinition>(stack: TStack): StackRuntimeExtensions<StackReadOf<TStack>> | undefined;
|
|
1737
|
+
declare function applyConnectedStackExtensions<TClient extends object, TStack extends StackDefinition>(client: TClient, stack: TStack): ConnectedStackClient<TClient, TStack>;
|
|
1738
|
+
|
|
1739
|
+
type ProgramMap = Record<string, ProgramSdkDefinition>;
|
|
1740
|
+
type NormalizeProgramMap<TPrograms> = TPrograms extends ProgramMap ? TPrograms : Record<string, never>;
|
|
1741
|
+
type MergeProgramMaps<TStackPrograms, TAttachedPrograms> = Omit<NormalizeProgramMap<TAttachedPrograms>, keyof NormalizeProgramMap<TStackPrograms>> & NormalizeProgramMap<TStackPrograms>;
|
|
1742
|
+
type StackWithAttachedPrograms<TStack extends StackDefinition, TAttachedPrograms extends ProgramMap | undefined> = Omit<TStack, 'programs'> & {
|
|
1743
|
+
programs: MergeProgramMaps<TStack['programs'], TAttachedPrograms>;
|
|
1744
|
+
};
|
|
1745
|
+
declare function withPrograms<TStack extends StackDefinition, TAttachedPrograms extends ProgramMap | undefined>(stack: TStack, attachedPrograms: TAttachedPrograms): StackWithAttachedPrograms<TStack, TAttachedPrograms>;
|
|
1746
|
+
interface ConnectOptions<TPrograms extends ProgramMap | undefined = undefined> {
|
|
1747
|
+
url?: string;
|
|
1748
|
+
httpUrl?: string;
|
|
1749
|
+
/**
|
|
1750
|
+
* Transport mode. `'ws'` (default) opens the streaming WebSocket; `'http'`
|
|
1751
|
+
* skips the socket entirely — point reads, chain reads, and instruction
|
|
1752
|
+
* execution work, while views/subscriptions throw `WEBSOCKET_DISABLED`.
|
|
1753
|
+
*/
|
|
1754
|
+
transport?: 'ws' | 'http';
|
|
1755
|
+
storage?: StorageAdapter;
|
|
1756
|
+
maxEntriesPerView?: number | null;
|
|
1757
|
+
/** Connect immediately when the client is created (defaults to true). */
|
|
1758
|
+
autoConnect?: boolean;
|
|
1759
|
+
/** Reconnect automatically after an established connection is lost (defaults to true). */
|
|
1760
|
+
autoReconnect?: boolean;
|
|
1761
|
+
reconnectIntervals?: number[];
|
|
1762
|
+
maxReconnectAttempts?: number;
|
|
1763
|
+
flushIntervalMs?: number;
|
|
1764
|
+
/**
|
|
1765
|
+
* Generated schemas are always applied to normalize typed entities. Set this
|
|
1766
|
+
* to `false` to suppress console warnings for rejected frames while keeping
|
|
1767
|
+
* schema normalization and `onFrameValidationError` active.
|
|
1768
|
+
*/
|
|
1769
|
+
validateFrames?: boolean;
|
|
1770
|
+
/** Observe generated-schema rejections without scraping console warnings. */
|
|
1771
|
+
onFrameValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
|
|
1772
|
+
/** Authentication configuration */
|
|
1773
|
+
auth?: AuthConfig;
|
|
1774
|
+
/** Default wallet adapter used for instruction execution (overridable per call). */
|
|
1775
|
+
wallet?: WalletAdapter;
|
|
1776
|
+
/** Optional fetch implementation for HTTP point reads. */
|
|
1777
|
+
fetch?: typeof fetch;
|
|
1778
|
+
/** Additional program SDKs exposed under client.programs.<key>. */
|
|
1779
|
+
programs?: TPrograms;
|
|
1780
|
+
/** Default semantic-operation execution settings. */
|
|
1781
|
+
execution?: OperationExecutionOptions<any>;
|
|
1782
|
+
}
|
|
1783
|
+
/** @deprecated Use ConnectOptions instead */
|
|
1784
|
+
interface AreteOptionsWithStorage<TStack extends StackDefinition> extends AreteOptions<TStack> {
|
|
1785
|
+
httpUrl?: string;
|
|
1786
|
+
storage?: StorageAdapter;
|
|
1787
|
+
maxEntriesPerView?: number | null;
|
|
1788
|
+
flushIntervalMs?: number;
|
|
1789
|
+
auth?: AuthConfig;
|
|
1790
|
+
wallet?: WalletAdapter;
|
|
1791
|
+
fetch?: typeof fetch;
|
|
1792
|
+
execution?: OperationExecutionOptions<any>;
|
|
1793
|
+
onFrameValidationError?: (diagnostic: FrameValidationDiagnostic) => void;
|
|
1794
|
+
}
|
|
1795
|
+
interface TransactionOptions<TSigner = unknown> {
|
|
1796
|
+
wallet?: WalletAdapter;
|
|
1797
|
+
transactionTransport?: TransactionTransport;
|
|
1798
|
+
send?: SendOptions;
|
|
1799
|
+
errors?: ErrorMetadata[];
|
|
1800
|
+
signers?: readonly TSigner[];
|
|
1801
|
+
}
|
|
1802
|
+
/**
|
|
1803
|
+
* A typed, callable instruction.
|
|
1804
|
+
*
|
|
1805
|
+
* Calling it builds + signs + sends the transaction. The attached `build`
|
|
1806
|
+
* method is a pure prepare step that returns a {@link BuiltInstruction} for
|
|
1807
|
+
* batching/composition.
|
|
1808
|
+
*/
|
|
1809
|
+
interface TypedInstruction<TParams, TError> {
|
|
1810
|
+
build(params: TParams, options?: BuildOptions): BuiltInstruction;
|
|
1811
|
+
/** Phantom error type for downstream inference. */
|
|
1812
|
+
readonly _error?: TError;
|
|
1813
|
+
}
|
|
1814
|
+
interface TypedAccountReader<T> {
|
|
1815
|
+
fetch(address: string): Promise<T | null>;
|
|
1816
|
+
fetchMany(addresses: readonly string[]): Promise<Array<T | null>>;
|
|
1817
|
+
exists(address: string): Promise<boolean>;
|
|
1818
|
+
}
|
|
1819
|
+
type TypedQueryExecutor<TParams, TResult> = (params: TParams) => Promise<TResult>;
|
|
1820
|
+
type TypedAccountReaderFor<TEntry> = TEntry extends ProgramAccountReadDefinition<infer T> ? TypedAccountReader<T> : TypedAccountReader<unknown>;
|
|
1821
|
+
type TypedQueryFor<TEntry> = TEntry extends ProgramQueryDefinition<infer P, infer R> ? TypedQueryExecutor<P, R> : TEntry extends StackQueryDefinition<infer P, infer R> ? TypedQueryExecutor<P, R> : TypedQueryExecutor<Record<string, unknown>, unknown>;
|
|
1822
|
+
type RawInstructionsInterface<TInstructions extends Record<string, InstructionHandler<any, any>> | undefined> = TInstructions extends Record<string, InstructionHandler<any, any>> ? {
|
|
1823
|
+
[K in keyof TInstructions]: TInstructions[K] extends InstructionHandler<infer P, infer E> ? TypedInstruction<P, E> : TypedInstruction<Record<string, unknown>, unknown>;
|
|
1824
|
+
} : Record<string, never>;
|
|
1825
|
+
type ProgramAccountsInterface<TAccounts extends Record<string, ProgramAccountReadDefinition<unknown>> | undefined> = TAccounts extends Record<string, ProgramAccountReadDefinition<unknown>> ? {
|
|
1826
|
+
[K in keyof TAccounts]: TypedAccountReaderFor<TAccounts[K]>;
|
|
1827
|
+
} : Record<string, never>;
|
|
1828
|
+
type ProgramQueriesInterface<TQueries extends Record<string, ProgramQueryDefinition<unknown, unknown>> | undefined> = TQueries extends Record<string, ProgramQueryDefinition<unknown, unknown>> ? {
|
|
1829
|
+
[K in keyof TQueries]: TypedQueryFor<TQueries[K]>;
|
|
1830
|
+
} : Record<string, never>;
|
|
1831
|
+
type ProgramNamespace<TNamespace> = TNamespace extends Record<string, unknown> ? TNamespace : Record<string, never>;
|
|
1832
|
+
type OperationField<TOperations, TKey extends PropertyKey> = TKey extends keyof TOperations ? ProgramNamespace<TOperations[TKey]> : Record<string, never>;
|
|
1833
|
+
type ProgramInterface<TProgram extends ProgramSdkDefinition> = {
|
|
1834
|
+
name: TProgram['name'];
|
|
1835
|
+
programId: TProgram['programId'];
|
|
1836
|
+
schemas: TProgram['schemas'];
|
|
1837
|
+
pdas: TProgram['pdas'] extends Record<string, unknown> ? TProgram['pdas'] : Record<string, never>;
|
|
1838
|
+
accounts: ProgramAccountsInterface<TProgram['accounts']>;
|
|
1839
|
+
queries: ProgramQueriesInterface<TProgram['queries']>;
|
|
1840
|
+
raw: RawInstructionsInterface<TProgram['rawInstructions']>;
|
|
1841
|
+
addresses: ProgramNamespace<TProgram['addresses']>;
|
|
1842
|
+
constants: ProgramNamespace<TProgram['constants']>;
|
|
1843
|
+
defaults: ProgramNamespace<TProgram['defaults']>;
|
|
1844
|
+
math: ProgramNamespace<TProgram['math']>;
|
|
1845
|
+
instructions: OperationField<ProgramOperationsOf<TProgram>, 'instructions'>;
|
|
1846
|
+
transactions: OperationField<ProgramOperationsOf<TProgram>, 'transactions'>;
|
|
1847
|
+
flows: OperationField<ProgramOperationsOf<TProgram>, 'flows'>;
|
|
1848
|
+
};
|
|
1849
|
+
type ProgramsInterface<TPrograms extends Record<string, ProgramSdkDefinition> | undefined> = TPrograms extends Record<string, ProgramSdkDefinition> ? {
|
|
1850
|
+
[K in keyof TPrograms]: ProgramInterface<TPrograms[K]>;
|
|
1851
|
+
} : Record<string, never>;
|
|
1852
|
+
type QueriesInterface<TQueries extends Record<string, StackQueryDefinition<unknown, unknown>> | undefined> = TQueries extends Record<string, StackQueryDefinition<unknown, unknown>> ? {
|
|
1853
|
+
[K in keyof TQueries]: TypedQueryFor<TQueries[K]>;
|
|
1854
|
+
} : Record<string, never>;
|
|
1855
|
+
type RawProgramsInterface<TPrograms extends Record<string, ProgramSdkDefinition> | undefined> = TPrograms extends Record<string, ProgramSdkDefinition> ? {
|
|
1856
|
+
[K in keyof TPrograms]: RawInstructionsInterface<TPrograms[K]['rawInstructions']>;
|
|
1857
|
+
} : Record<string, never>;
|
|
1858
|
+
/** @deprecated Retained for backward compatibility; prefer {@link TypedInstruction}. */
|
|
1859
|
+
type InstructionExecutor = TypedInstruction<Record<string, unknown>, unknown>;
|
|
1860
|
+
type ConnectedArete<TStack extends StackDefinition, TExtensions = TStack> = Arete$1<TStack> & StackConnectedExtensions<TExtensions>;
|
|
1861
|
+
declare class Arete$1<TStack extends StackDefinition> {
|
|
1862
|
+
private readonly connection;
|
|
1863
|
+
private readonly storage;
|
|
1864
|
+
private readonly processor;
|
|
1865
|
+
private readonly subscriptionRegistry;
|
|
1866
|
+
private readonly queryStore;
|
|
1867
|
+
private readonly _views;
|
|
1868
|
+
private readonly _queries;
|
|
1869
|
+
private readonly _programs;
|
|
1870
|
+
private readonly _chain;
|
|
1871
|
+
private readonly _transactions;
|
|
1872
|
+
private readonly stack;
|
|
1873
|
+
private readonly httpBaseUrl;
|
|
1874
|
+
private readonly fetchImpl;
|
|
1875
|
+
private readonly executionDefaults?;
|
|
1876
|
+
private _wallet?;
|
|
1877
|
+
private _aggregatedErrors?;
|
|
1878
|
+
private constructor();
|
|
1879
|
+
private resolveFetchImpl;
|
|
1880
|
+
private buildQueries;
|
|
1881
|
+
private buildPrograms;
|
|
1882
|
+
private createTypedInstruction;
|
|
1883
|
+
private createAccountReader;
|
|
1884
|
+
private createQueryExecutor;
|
|
1885
|
+
private readJson;
|
|
1886
|
+
private authenticatedFetch;
|
|
1887
|
+
private resolveReadUrl;
|
|
1888
|
+
/** Merge the client's default wallet into call options (call options win). */
|
|
1889
|
+
private withWallet;
|
|
1890
|
+
static connect<T extends StackDefinition, TPrograms extends ProgramMap | undefined = undefined>(stack: T, options?: ConnectOptions<TPrograms>): Promise<ConnectedArete<StackWithAttachedPrograms<T, TPrograms>, T>>;
|
|
1891
|
+
get views(): TypedViews<TStack['views']>;
|
|
1892
|
+
get queries(): QueriesInterface<TStack['queries']>;
|
|
1893
|
+
get programs(): ProgramsInterface<TStack['programs']>;
|
|
1894
|
+
get chain(): ChainClient;
|
|
1895
|
+
get transactions(): TransactionTransport;
|
|
1896
|
+
/** The default wallet adapter, if one was configured. */
|
|
1897
|
+
get wallet(): WalletAdapter | undefined;
|
|
1898
|
+
/** The connected wallet address, if a default wallet was configured. */
|
|
1899
|
+
get publicKey(): string | undefined;
|
|
1900
|
+
/**
|
|
1901
|
+
* Set (or clear) the default wallet adapter used for instruction execution.
|
|
1902
|
+
* Useful for connecting/disconnecting a wallet after the client is created.
|
|
1903
|
+
*/
|
|
1904
|
+
setWallet(wallet: WalletAdapter | undefined): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Sign and send a batch of pre-built instructions as a single transaction.
|
|
1907
|
+
*
|
|
1908
|
+
* Build instructions with `client.programs.<program>.raw.<name>.build(params)`
|
|
1909
|
+
* and compose them here. RPC/compilation/confirmation are owned by the adapter.
|
|
1910
|
+
*
|
|
1911
|
+
* On failure, the error is parsed against `options.errors` when given,
|
|
1912
|
+
* otherwise against error metadata aggregated from all the stack's handlers
|
|
1913
|
+
* (deduped by code, first-wins — if the stack bundles programs with
|
|
1914
|
+
* overlapping error codes, pass `options.errors` or use the per-instruction
|
|
1915
|
+
* call path for precise attribution).
|
|
1916
|
+
*/
|
|
1917
|
+
transaction(instructions: readonly BuiltInstruction[], options?: TransactionOptions): Promise<ExecutionResult>;
|
|
1918
|
+
execute<TPrepared extends PreparedOperation, TSigner = unknown>(prepared: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
|
|
1919
|
+
/** Inspect one prepared instruction/transaction without signing or submitting it. */
|
|
1920
|
+
inspectOperation(prepared: PreparedOperation, options?: OperationInspectionOptions): Promise<OperationInspection>;
|
|
1921
|
+
/** Error metadata from every handler in the stack, deduped by code. */
|
|
1922
|
+
private aggregateErrors;
|
|
1923
|
+
get connectionState(): ConnectionState;
|
|
1924
|
+
get stackName(): string;
|
|
1925
|
+
get store(): StorageAdapter;
|
|
1926
|
+
/** Highest Solana slot whose streamed frame has been stored locally. */
|
|
1927
|
+
get processedSlot(): bigint | null;
|
|
1928
|
+
/**
|
|
1929
|
+
* Wait until a frame at or beyond `slot` has been applied to local storage.
|
|
1930
|
+
* Buffered frames satisfy the wait only after their storage batch is flushed.
|
|
1931
|
+
*/
|
|
1932
|
+
waitForProcessedSlot(slot: number | bigint, options?: WaitForProcessedSlotOptions): Promise<bigint>;
|
|
1933
|
+
onConnectionStateChange(callback: ConnectionStateCallback): UnsubscribeFn;
|
|
1934
|
+
onFrame(callback: (frame: Frame) => void): UnsubscribeFn;
|
|
1935
|
+
onSocketIssue(callback: SocketIssueCallback): UnsubscribeFn;
|
|
1936
|
+
connect(): Promise<void>;
|
|
1937
|
+
disconnect(): void;
|
|
1938
|
+
isConnected(): boolean;
|
|
1939
|
+
clearStore(): void;
|
|
1940
|
+
getStore(): StorageAdapter;
|
|
1941
|
+
getConnection(): ConnectionManager;
|
|
1942
|
+
getSubscriptionRegistry(): SubscriptionRegistry;
|
|
1943
|
+
getQueryStore(): QueryStore;
|
|
880
1944
|
}
|
|
881
1945
|
|
|
1946
|
+
/**
|
|
1947
|
+
* A session composes multiple stack and standalone-program SDK clients
|
|
1948
|
+
* behind one wallet and one shared endpoint configuration.
|
|
1949
|
+
*
|
|
1950
|
+
* Each member gets its own client (connection + store); a stack is itself a
|
|
1951
|
+
* composition of programs + views, and a standalone program member reuses the
|
|
1952
|
+
* exact same machinery as a stack with no views, connected HTTP-only.
|
|
1953
|
+
*/
|
|
1954
|
+
interface SessionDefinition {
|
|
1955
|
+
readonly stacks?: Record<string, StackDefinition>;
|
|
1956
|
+
readonly programs?: Record<string, ProgramSdkDefinition>;
|
|
1957
|
+
}
|
|
1958
|
+
type SessionStackPrograms<TDef extends SessionDefinition> = Partial<{
|
|
1959
|
+
[K in keyof NonNullable<TDef['stacks']>]: Record<string, ProgramSdkDefinition> | undefined;
|
|
1960
|
+
}>;
|
|
1961
|
+
type EffectiveStackPrograms<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef>, K extends keyof NonNullable<TDef['stacks']>> = NonNullable<TDef['stacks']>[K] extends StackDefinition ? K extends keyof TStackPrograms ? StackWithAttachedPrograms<NonNullable<TDef['stacks']>[K], TStackPrograms[K]>['programs'] : NonNullable<NonNullable<TDef['stacks']>[K]['programs']> : never;
|
|
1962
|
+
type StackProgramKeys<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef>> = {
|
|
1963
|
+
[K in keyof NonNullable<TDef['stacks']>]: keyof EffectiveStackPrograms<TDef, TStackPrograms, K>;
|
|
1964
|
+
}[keyof NonNullable<TDef['stacks']>];
|
|
1965
|
+
/** Per-member connection overrides (a subset of {@link ConnectOptions}). */
|
|
1966
|
+
interface SessionMemberOptions<TPrograms extends Record<string, ProgramSdkDefinition> | undefined = undefined> {
|
|
1967
|
+
url?: string;
|
|
1968
|
+
httpUrl?: string;
|
|
1969
|
+
transport?: 'ws' | 'http';
|
|
1970
|
+
auth?: AuthConfig;
|
|
1971
|
+
storage?: StorageAdapter;
|
|
1972
|
+
autoConnect?: boolean;
|
|
1973
|
+
autoReconnect?: boolean;
|
|
1974
|
+
programs?: TPrograms;
|
|
1975
|
+
}
|
|
1976
|
+
interface SessionOptions<TDef extends SessionDefinition = SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> {
|
|
1977
|
+
/** One wallet governs execution across every member. */
|
|
1978
|
+
wallet?: WalletAdapter;
|
|
1979
|
+
/** Canonical chain reader shared by the session when explicitly provided. */
|
|
1980
|
+
chain?: ChainClient;
|
|
1981
|
+
/** Transaction transport override; defaults to the execution host's authenticated client. */
|
|
1982
|
+
transactions?: TransactionTransport;
|
|
1983
|
+
auth?: AuthConfig;
|
|
1984
|
+
fetch?: typeof fetch;
|
|
1985
|
+
/** Default transport for all members ('ws' unless overridden). */
|
|
1986
|
+
transport?: 'ws' | 'http';
|
|
1987
|
+
/** Shared fallback endpoints used when a member defines none of its own. */
|
|
1988
|
+
endpoints?: {
|
|
1989
|
+
http?: string;
|
|
1990
|
+
ws?: string;
|
|
1991
|
+
};
|
|
1992
|
+
/** Default execution settings shared by transaction/plan helpers on the session. */
|
|
1993
|
+
execution?: OperationExecutionOptions<any>;
|
|
1994
|
+
/** Signers available to every transaction executed through this session. */
|
|
1995
|
+
signerRegistry?: SignerRegistry<any>;
|
|
1996
|
+
/** Per-member overrides, keyed by the member's key in the definition. */
|
|
1997
|
+
stacks?: {
|
|
1998
|
+
[K in keyof NonNullable<TDef['stacks']>]?: SessionMemberOptions<K extends keyof TStackPrograms ? TStackPrograms[K] : undefined>;
|
|
1999
|
+
};
|
|
2000
|
+
programs?: Record<string, SessionMemberOptions>;
|
|
2001
|
+
}
|
|
2002
|
+
type SessionStacks<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = {
|
|
2003
|
+
readonly [K in keyof NonNullable<TDef['stacks']>]: NonNullable<TDef['stacks']>[K] extends StackDefinition ? K extends keyof TStackPrograms ? ConnectedArete<StackWithAttachedPrograms<NonNullable<TDef['stacks']>[K], TStackPrograms[K]>, NonNullable<TDef['stacks']>[K]> : ConnectedArete<NonNullable<TDef['stacks']>[K], NonNullable<TDef['stacks']>[K]> : never;
|
|
2004
|
+
};
|
|
2005
|
+
type StackProgramInterfaceForKey<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef>, P extends PropertyKey> = {
|
|
2006
|
+
[K in keyof NonNullable<TDef['stacks']>]: P extends keyof SessionStacks<TDef, TStackPrograms>[K]['programs'] ? SessionStacks<TDef, TStackPrograms>[K]['programs'][P] : never;
|
|
2007
|
+
}[keyof NonNullable<TDef['stacks']>];
|
|
2008
|
+
type PromotedSessionPrograms<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef>> = {
|
|
2009
|
+
readonly [P in StackProgramKeys<TDef, TStackPrograms>]: StackProgramInterfaceForKey<TDef, TStackPrograms, P>;
|
|
2010
|
+
};
|
|
2011
|
+
type ExplicitSessionPrograms<TDef extends SessionDefinition> = {
|
|
2012
|
+
readonly [K in keyof NonNullable<TDef['programs']>]: NonNullable<TDef['programs']>[K] extends ProgramSdkDefinition ? ProgramInterface<NonNullable<TDef['programs']>[K]> : never;
|
|
2013
|
+
};
|
|
2014
|
+
type SessionPrograms<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> = Omit<PromotedSessionPrograms<TDef, TStackPrograms>, keyof NonNullable<TDef['programs']>> & ExplicitSessionPrograms<TDef>;
|
|
2015
|
+
interface Session<TDef extends SessionDefinition = SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}> {
|
|
2016
|
+
readonly stacks: SessionStacks<TDef, TStackPrograms>;
|
|
2017
|
+
readonly programs: SessionPrograms<TDef, TStackPrograms>;
|
|
2018
|
+
readonly wallet: WalletAdapter | undefined;
|
|
2019
|
+
readonly signerRegistry: SignerRegistry<any>;
|
|
2020
|
+
readonly chain: ChainClient;
|
|
2021
|
+
readonly transactions: TransactionTransport;
|
|
2022
|
+
transaction(instructions: readonly BuiltInstruction[], options?: TransactionOptions): Promise<ExecutionResult>;
|
|
2023
|
+
execute<TPrepared extends PreparedOperation, TSigner = unknown>(prepared: TPrepared, options?: OperationExecutionOptions<TSigner, TPrepared>): Promise<OperationReceiptFor<TPrepared>>;
|
|
2024
|
+
setWallet(wallet: WalletAdapter | undefined): void;
|
|
2025
|
+
close(): void;
|
|
2026
|
+
}
|
|
2027
|
+
declare function createSession<TDef extends SessionDefinition, TStackPrograms extends SessionStackPrograms<TDef> = {}>(definition: TDef, options?: SessionOptions<TDef, TStackPrograms>): Promise<Session<TDef, TStackPrograms>>;
|
|
2028
|
+
|
|
2029
|
+
interface AccountLoader {
|
|
2030
|
+
getAccount(address: string): Promise<{
|
|
2031
|
+
data: Uint8Array;
|
|
2032
|
+
} | null>;
|
|
2033
|
+
}
|
|
2034
|
+
declare function chainAccountLoader(chain: ChainClient): AccountLoader;
|
|
2035
|
+
|
|
2036
|
+
declare const SPL_TOKEN_PROGRAM_ADDRESS = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";
|
|
2037
|
+
declare const TOKEN_2022_PROGRAM_ADDRESS = "TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb";
|
|
2038
|
+
declare const ASSOCIATED_TOKEN_PROGRAM_ADDRESS = "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL";
|
|
2039
|
+
declare const SYSTEM_PROGRAM_ADDRESS = "11111111111111111111111111111111";
|
|
2040
|
+
declare function resolveTokenProgramAddress(chain: ChainClient, mint: string, override?: string): Promise<string>;
|
|
2041
|
+
declare function deriveAssociatedTokenAccount(input: {
|
|
2042
|
+
owner: string;
|
|
2043
|
+
mint: string;
|
|
2044
|
+
tokenProgram?: string;
|
|
2045
|
+
}): string;
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* A token amount expressed either in UI units (human decimal string/number)
|
|
2049
|
+
* or raw base units. A bare bigint is treated as raw.
|
|
2050
|
+
*/
|
|
2051
|
+
type AmountInput = bigint | {
|
|
2052
|
+
ui: string | number;
|
|
2053
|
+
} | {
|
|
2054
|
+
raw: bigint | string | number;
|
|
2055
|
+
};
|
|
2056
|
+
interface AmountResolutionInput {
|
|
2057
|
+
mint: string;
|
|
2058
|
+
amount: AmountInput;
|
|
2059
|
+
decimals?: number;
|
|
2060
|
+
}
|
|
2061
|
+
/** Convert a UI amount ("1.5") to raw base units using string math (no float precision loss). */
|
|
2062
|
+
declare function parseUiAmountToRaw(value: string | number, decimals: number): bigint;
|
|
2063
|
+
/** Format raw base units as a UI decimal string (inverse of {@link parseUiAmountToRaw}). */
|
|
2064
|
+
declare function formatRawToUi(raw: bigint | string | number, decimals: number): string;
|
|
2065
|
+
/** Resolve an {@link AmountInput} to raw base units with known decimals. */
|
|
2066
|
+
declare function toRawAmount(amount: AmountInput, decimals: number): bigint;
|
|
2067
|
+
/** Convert an amount to raw units without throwing on invalid user input. */
|
|
2068
|
+
declare function safeToRawAmount(amount: AmountInput, decimals: number): SchemaResult<bigint>;
|
|
2069
|
+
/** Fetch a mint's decimals via the chain read endpoint, throwing when unavailable. */
|
|
2070
|
+
declare function getMintDecimals(chain: ChainClient, mint: string): Promise<number>;
|
|
2071
|
+
/**
|
|
2072
|
+
* Resolve an {@link AmountInput} to raw base units, fetching the mint's
|
|
2073
|
+
* decimals only when they are unknown and actually needed (a bare bigint or
|
|
2074
|
+
* `{raw}` input with explicit `decimals` never touches the network).
|
|
2075
|
+
*/
|
|
2076
|
+
declare function resolveAmount(chain: ChainClient, input: AmountResolutionInput): Promise<{
|
|
2077
|
+
raw: bigint;
|
|
2078
|
+
decimals: number;
|
|
2079
|
+
}>;
|
|
2080
|
+
/**
|
|
2081
|
+
* Resolve an {@link AmountInput} to raw base units without forcing a decimals
|
|
2082
|
+
* fetch when the input is already expressed in raw units.
|
|
2083
|
+
*/
|
|
2084
|
+
declare function resolveAmountToRaw(chain: ChainClient, input: AmountResolutionInput): Promise<bigint>;
|
|
2085
|
+
/** Resolve a named set of {@link AmountInput} values to raw base units. */
|
|
2086
|
+
declare function resolveAmountsToRaw<TInputs extends Record<string, AmountResolutionInput>>(chain: ChainClient, inputs: TInputs): Promise<{
|
|
2087
|
+
[K in keyof TInputs]: bigint;
|
|
2088
|
+
}>;
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Recursively convert bigints to their decimal string form.
|
|
2092
|
+
*
|
|
2093
|
+
* Streamed entities contain bigints, which makes them unsafe to pass through
|
|
2094
|
+
* anything that JSON-stringifies (React's dev-mode performance tooling, log
|
|
2095
|
+
* pipelines, `JSON.stringify` persistence). Prefer stack-provided UI fields
|
|
2096
|
+
* (e.g. `deployedPerSquareUi`) when they exist; use this for the remaining
|
|
2097
|
+
* raw values such as account snapshots.
|
|
2098
|
+
*
|
|
2099
|
+
* Arrays and plain objects are converted structurally and the return type
|
|
2100
|
+
* maps every `bigint` to `string`; class instances (PublicKey, Date, …) are
|
|
2101
|
+
* returned untouched.
|
|
2102
|
+
*/
|
|
2103
|
+
type StringifiedBigints<T> = T extends bigint ? string : T extends readonly (infer U)[] ? readonly StringifiedBigints<U>[] : T extends object ? {
|
|
2104
|
+
[K in keyof T]: StringifiedBigints<T[K]>;
|
|
2105
|
+
} : T;
|
|
2106
|
+
declare function stringifyBigints<T>(value: T): StringifiedBigints<T>;
|
|
2107
|
+
|
|
2108
|
+
declare class ReadRequestError extends Error {
|
|
2109
|
+
readonly status: number;
|
|
2110
|
+
readonly path: string;
|
|
2111
|
+
readonly body: string;
|
|
2112
|
+
readonly serverErrorCode: string | undefined;
|
|
2113
|
+
constructor(input: {
|
|
2114
|
+
status: number;
|
|
2115
|
+
path: string;
|
|
2116
|
+
body: string;
|
|
2117
|
+
serverErrorCode?: string;
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
declare function programAccountRead<T>(input: {
|
|
2121
|
+
account: string;
|
|
2122
|
+
path: string;
|
|
2123
|
+
schema?: Schema<T>;
|
|
2124
|
+
}): ProgramAccountReadDefinition<T>;
|
|
2125
|
+
declare function programQuery<TParams = unknown, TResult = unknown>(input: {
|
|
2126
|
+
name: string;
|
|
2127
|
+
path: string;
|
|
2128
|
+
method?: ReadTransportMethod;
|
|
2129
|
+
schema?: Schema<TResult>;
|
|
2130
|
+
}): ProgramQueryDefinition<TParams, TResult>;
|
|
2131
|
+
declare function stackQuery<TParams = unknown, TResult = unknown>(input: {
|
|
2132
|
+
name: string;
|
|
2133
|
+
path: string;
|
|
2134
|
+
method?: ReadTransportMethod;
|
|
2135
|
+
schema?: Schema<TResult>;
|
|
2136
|
+
}): StackQueryDefinition<TParams, TResult>;
|
|
2137
|
+
|
|
882
2138
|
declare class MemoryAdapter implements StorageAdapter {
|
|
883
2139
|
private views;
|
|
884
2140
|
private updateCallbacks;
|
|
@@ -896,18 +2152,23 @@ declare class MemoryAdapter implements StorageAdapter {
|
|
|
896
2152
|
clear(viewPath?: string): void;
|
|
897
2153
|
evictOldest(viewPath: string): string | undefined;
|
|
898
2154
|
onUpdate(callback: UpdateCallback): () => void;
|
|
899
|
-
onRichUpdate(callback: RichUpdateCallback
|
|
2155
|
+
onRichUpdate(callback: RichUpdateCallback): () => void;
|
|
900
2156
|
notifyUpdate<T>(viewPath: string, key: string, update: Update<T>): void;
|
|
901
2157
|
notifyRichUpdate<T>(viewPath: string, key: string, update: RichUpdate<T>): void;
|
|
902
2158
|
}
|
|
903
2159
|
|
|
904
|
-
declare function createUpdateStream<T>(
|
|
905
|
-
declare function createEntityStream<T>(
|
|
906
|
-
declare function createRichUpdateStream<T>(
|
|
2160
|
+
declare function createUpdateStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, keyFilter?: string, snapshotEnabled?: boolean): AsyncIterable<Update<T>>;
|
|
2161
|
+
declare function createEntityStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, options?: WatchOptions<any>, keyFilter?: string): AsyncIterable<T>;
|
|
2162
|
+
declare function createRichUpdateStream<T>(_storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry, query: SubscriptionQuery, keyFilter?: string, snapshotEnabled?: boolean): AsyncIterable<RichUpdate<T>>;
|
|
907
2163
|
|
|
908
|
-
declare function
|
|
2164
|
+
declare function serializeViewKey<TKey>(viewDef: ViewDef<unknown, 'state', TKey>, key: TKey): string;
|
|
2165
|
+
declare function createTypedStateView<T, TKey = unknown>(viewDef: ViewDef<T, 'state', TKey>, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedStateView<T, DefaultViewKey<TKey>>;
|
|
909
2166
|
declare function createTypedListView<T>(viewDef: ViewDef<T, 'list'>, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedListView<T>;
|
|
910
2167
|
declare function createTypedViews<TStack extends StackDefinition>(stack: TStack, storage: StorageAdapter, subscriptionRegistry: SubscriptionRegistry): TypedViews<TStack['views']>;
|
|
911
2168
|
|
|
912
|
-
|
|
913
|
-
|
|
2169
|
+
declare const Arete: typeof Arete$1 & {
|
|
2170
|
+
session: typeof createSession;
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
export { ASSOCIATED_TOKEN_PROGRAM_ADDRESS, Arete, AreteError, ConnectionManager, DEFAULT_CONFIG, DEFAULT_MAX_ENTRIES_PER_VIEW, FrameProcessor, InstructionError, MemoryAdapter, OperationCallbackError, OperationExecutionError, PROGRAM_OPERATION_EXTENSIONS, ProcessedSlotTimeoutError, QueryStore, ReadRequestError, SPL_TOKEN_PROGRAM_ADDRESS, STACK_RUNTIME_EXTENSIONS, SYSTEM_PROGRAM_ADDRESS, SubscriptionRegistry, TOKEN_2022_PROGRAM_ADDRESS, TransactionExecutionError, TransactionTransportError, account, appendFlowTransactions, appendTransactionInstructions, applyConnectedStackExtensions, arg, buildInstruction, bytes, canonicalQueryKey, chainAccountLoader, createChainClient, createEntityStream, createInstructionExecutor, createInstructionHandler, createPreparedFlow, createPreparedInstruction, createPreparedTransaction, createPreparedTransactionBody, createProgramPdas, createPublicKeySeed, createRichUpdateStream, createSeed, createSession, createSignerRegistry, createSubscriptionId, createTransactionTransport, createTypedListView, createTypedStateView, createTypedViews, createUpdateStream, decodeBase58, defineProgramExtensions, defineStackExtensions, deriveAssociatedTokenAccount, deriveHttpEndpoint, findProgramAddress as derivePda, describePreparedOperation, encodeBase58, executeInstruction, executePreparedOperation, extendProgram, extendPrograms, extendStack, findProgramAddress, findProgramAddressSync, flowOperation, formatPreparedOperation, formatProgramError, formatRawToUi, getMintDecimals, getProgramRuntimeExtensions, getStackRuntimeExtensions, getTransactionFailureOutcome, inspectPreparedOperation, instructionOperation, isEntityFrame, isErrorFrame, isHostedAreteEndpoint, isSnapshotFrame, isSubscribedFrame, isUnsubscribedFrame, isValidFrame, literal, normalizeSubscription, normalizeSubscriptionQuery, normalizeSubscriptionRequest, normalizeTransactionError, parseFrame, parseFrameFromBlob, parseInstructionError, parseUiAmountToRaw, pda, prependFlowTransactionInstructions, prependTransactionInstructions, programAccountRead, programQuery, resolveAccounts, resolveAmount, resolveAmountToRaw, resolveAmountsToRaw, resolveTokenProgramAddress, safeToRawAmount, serializeInstructionData, serializeViewKey, stackQuery, stringifyBigints, toJsonValue, toRawAmount, transactionOperation, unwrapOperationExecutionError, validateAccountResolution, validateSubscriptionId, withPrograms };
|
|
2174
|
+
export type { AccountCategory, AccountLoader, AccountMeta, AccountResolutionOptions, AccountResolutionResult, AmountInput, AnyOperation, AreteConfig, AreteOptions, AreteOptionsWithStorage, ArgSchema, ArgType, AuthConfig, AuthTokenRequest, AuthTokenResult, BuildOptions, BuiltAccountMeta, BuiltInstruction, ChainClient, ChainClock, ChainFailedTransactionOutcome, ConfirmationLevel, ConfirmedTransactionOutcome, ConnectOptions, ConnectedArete, ConnectedStackClient, ConnectionState, ConnectionStateCallback, ContextSlotOptions, CreatePreparedFlowInput, CreatePreparedInstructionInput, CreatePreparedTransactionInput, DefaultViewKey, EntityFrame, ErrorFrame, ErrorMetadata, ExecuteOptions, ExecutionResult, ExtendedProgramDefinition, ExtendedStackDefinition, FlowOperation, FlowOperationNamespace, FlowOperationReceipt, Frame, FrameMode, FrameOp, FrameProcessorConfig, FrameValidationDiagnostic, InstructionExecutor, InstructionHandler, InstructionHandlerConfig, InstructionOperation, InstructionOperationNamespace, JsonObject, JsonPrimitive, JsonValue, LatestBlockhashResult, MergeProgramMaps, MintAccountInfo, NativeBalanceInfo, NonEmptyReadonlyArray, NotSubmittedTransactionOutcome, OperationCallbackPhase, OperationExecutionEvent, OperationExecutionHost, OperationExecutionOptions, OperationExecutionSuccessEvent, OperationInspection, OperationInspectionOptions, OperationKind, OperationNamespace, OperationPlan, OperationReceiptFor, OperationTransactionReceipt, PdaConfig, PdaDeriveContext, PdaFactory, PdaSeed, PreparedFlow, PreparedInstruction, PreparedOperation, PreparedOperationDescription, PreparedTransaction, PreparedTransactionBody, PreparedTransactionInstruction, PreparedTransactionOperation, ProgramAccountReadDefinition, ProgramError, ProgramExtensionInput, ProgramInterface, ProgramOperationContext, ProgramOperations, ProgramOperationsOf, ProgramPdas, ProgramQueryDefinition, ProgramRuntimeExtensionCarrier, ProgramRuntimeExtensions, ProgramSdkDefinition, ProgramsInterface, QueriesInterface, QueryLease, QuerySnapshot, RawAccountInfo, RawInstructionsInterface, RawProgramsInterface, ReadArgumentCount, ReadArgumentCounts, ReadTransportMethod, ResolvedAccount, ResolvedAccounts, RichUpdate, RichUpdateCallback, Schema, SchemaResult, SeedDef, SendOptions, SendResult, Session, SessionDefinition, SessionMemberOptions, SessionOptions, SignerRegistry, SingleTransactionOperationReceipt, SnapshotEntity, SnapshotFrame, SocketIssue, SocketIssueCallback, SortConfig, SortOrder, StackConnectedExtensions, StackDefinition, StackEndpoints, StackExtensionClient, StackExtensionInput, StackQueryDefinition, StackRuntimeExtensionCarrier, StackRuntimeExtensions, StackWithAttachedPrograms, StorageAdapter, StorageAdapterConfig, StringifiedBigints, SubmittedUnknownTransactionOutcome, SubscribeCallback, SubscribedFrame, Subscription, SubscriptionIdentity, SubscriptionOptions, SubscriptionQuery, SubscriptionRequest, SubscriptionSnapshotOptions, TokenAccountInfo, TokenBalanceInfo, TokenBalanceInput, TransactionCommitment, TransactionFailureOutcome, TransactionFailurePhase, TransactionFailureStatus, TransactionFeeResult, TransactionInspectionOptions, TransactionInspectionResult, TransactionOperation, TransactionOperationNamespace, TransactionOptions, TransactionOutcome, TransactionRequestContext, TransactionSendOptions, TransactionSendResult, TransactionSignatureStatus, TransactionSimulationOptions, TransactionSimulationResult, TransactionTransport, TransactionTransportErrorBody, TypedAccountReader, TypedInstruction, TypedListView, TypedQueryExecutor, TypedStateView, TypedViewGroup, TypedViews, UnsubscribeFn, UnsubscribedFrame, Update, UpdateCallback, ViewDef, ViewGroup, ViewKeyFields, ViewKeyValue, ViewSortConfig, WaitForProcessedSlotOptions, WalletAdapter, WalletConnectOptions, WalletExecutionContext, WalletState, WatchOptions, WebSocketFactoryInit };
|