@secondlayer/sdk 15.0.0 → 15.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +755 -181
- package/dist/index.js.map +11 -11
- package/dist/streams/index.d.ts +190 -88
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +754 -180
- package/dist/subgraphs/index.js.map +9 -9
- package/dist/webhooks/doctor.d.ts +1 -1
- package/dist/webhooks/doctor.js.map +1 -1
- package/package.json +5 -5
|
@@ -90,6 +90,7 @@ declare abstract class BaseClient {
|
|
|
90
90
|
* subclasses that stream a body call this directly and read it themselves. */
|
|
91
91
|
protected fetchResponse(method: string, path: string, body?: unknown, signal?: AbortSignal, extraHeaders?: Record<string, string>): Promise<Response>;
|
|
92
92
|
}
|
|
93
|
+
/** A deployed subgraph's source code, handler bundle, and pin. */
|
|
93
94
|
interface SubgraphSource {
|
|
94
95
|
name: string;
|
|
95
96
|
version: string;
|
|
@@ -133,6 +134,7 @@ interface SubgraphRowsEnvelope<T = unknown> {
|
|
|
133
134
|
blocks_behind: number;
|
|
134
135
|
};
|
|
135
136
|
}
|
|
137
|
+
/** A deployed subgraph's bundled sources, schema, and handler code. */
|
|
136
138
|
interface BundleSubgraphResponse {
|
|
137
139
|
ok: true;
|
|
138
140
|
name: string;
|
|
@@ -144,26 +146,54 @@ interface BundleSubgraphResponse {
|
|
|
144
146
|
bundleSize: number;
|
|
145
147
|
}
|
|
146
148
|
declare class Subgraphs extends BaseClient {
|
|
149
|
+
/**
|
|
150
|
+
* List the subgraphs deployed to this instance.
|
|
151
|
+
*
|
|
152
|
+
* Each summary has the status, the last processed block against the chain tip, progress, `gapCount`, and an `integrity` flag.
|
|
153
|
+
*/
|
|
147
154
|
list(): Promise<{
|
|
148
155
|
data: SubgraphSummary[];
|
|
149
156
|
}>;
|
|
150
157
|
/**
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
158
|
+
* Get a subgraph's health, sync position, and tables.
|
|
159
|
+
*
|
|
160
|
+
* The verify step after a deploy, reindex, or backfill: poll it until
|
|
161
|
+
* `sync` catches the tip.
|
|
154
162
|
*/
|
|
155
163
|
status(name: string): Promise<SubgraphDetail>;
|
|
164
|
+
/**
|
|
165
|
+
* Get a subgraph's OpenAPI spec.
|
|
166
|
+
*
|
|
167
|
+
* Describes the REST routes generated for each table. Pass `serverUrl` to set the server the spec advertises.
|
|
168
|
+
*/
|
|
156
169
|
openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
|
|
170
|
+
/**
|
|
171
|
+
* Get a subgraph's schema as JSON, shaped for agents.
|
|
172
|
+
*
|
|
173
|
+
* Per table: the endpoints, columns, indexes, which fields are sortable, selectable, searchable, or filterable, and a ready example query. Pass `serverUrl` to set the server the endpoints use.
|
|
174
|
+
*/
|
|
157
175
|
schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
|
|
176
|
+
/**
|
|
177
|
+
* Get a subgraph's generated API docs as Markdown text.
|
|
178
|
+
*
|
|
179
|
+
* Pass `serverUrl` to set the server the examples use.
|
|
180
|
+
*/
|
|
158
181
|
markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
|
|
159
182
|
/**
|
|
160
|
-
*
|
|
183
|
+
* Rebuild a subgraph from scratch.
|
|
184
|
+
*
|
|
185
|
+
* A reindex always drops and rebuilds the whole subgraph, so it takes no
|
|
161
186
|
* block range; the API rejects one with `REINDEX_RANGE_NOT_SUPPORTED`.
|
|
162
187
|
* Use {@link backfill} to process a specific range. While a reindex or
|
|
163
188
|
* backfill is already running the API answers 409 with code
|
|
164
189
|
* `OPERATION_IN_PROGRESS`; poll {@link operations} until it finishes.
|
|
165
190
|
*/
|
|
166
191
|
reindex(name: string): Promise<ReindexResponse>;
|
|
192
|
+
/**
|
|
193
|
+
* Stop a running reindex or backfill.
|
|
194
|
+
*
|
|
195
|
+
* Requests the cancel and resolves with the `operationId` and a `cancel_requested` status. Poll {@link getOperation} until `status` is terminal. Throws a 404 with code `NO_OPERATION` when nothing is running.
|
|
196
|
+
*/
|
|
167
197
|
stop(name: string): Promise<{
|
|
168
198
|
message: string;
|
|
169
199
|
operationId?: string;
|
|
@@ -175,19 +205,31 @@ declare class Subgraphs extends BaseClient {
|
|
|
175
205
|
fromBlock: number;
|
|
176
206
|
toBlock: number;
|
|
177
207
|
}): Promise<ReindexResponse>;
|
|
208
|
+
/**
|
|
209
|
+
* List the block ranges a subgraph is missing.
|
|
210
|
+
*
|
|
211
|
+
* Each gap has its `start`, `end`, `size`, `reason`, and when it was detected and resolved. `resolved` filters to resolved or open gaps; page with `limit` and `offset`. `meta` reports the total gap count and total missing blocks.
|
|
212
|
+
*/
|
|
178
213
|
gaps(name: string, opts?: {
|
|
179
214
|
limit?: number;
|
|
180
215
|
offset?: number;
|
|
181
216
|
resolved?: boolean;
|
|
182
217
|
}): Promise<SubgraphGapsResponse>;
|
|
218
|
+
/**
|
|
219
|
+
* Delete a subgraph and its tables.
|
|
220
|
+
*
|
|
221
|
+
* Permanent. The API cancels any running reindex or backfill first, waits up to 5 seconds for it to stop, then drops the subgraph's tables and registry entry. `force: true` is sent as `?force=true`.
|
|
222
|
+
*/
|
|
183
223
|
delete(name: string, options?: {
|
|
184
224
|
force?: boolean;
|
|
185
225
|
}): Promise<{
|
|
186
226
|
message: string;
|
|
187
227
|
}>;
|
|
188
228
|
/**
|
|
189
|
-
*
|
|
190
|
-
*
|
|
229
|
+
* Read a table's rows, one cursor page at a time.
|
|
230
|
+
*
|
|
231
|
+
* Anon works on an open instance; pass an apiKey on the client where reads
|
|
232
|
+
* are closed. `next_cursor` is set
|
|
191
233
|
* on every page that returned rows and is `null` only on an empty page, so a
|
|
192
234
|
* poller tails with `cursor = page.next_cursor ?? cursor`. A paging loop
|
|
193
235
|
* ends on an empty page (or one shorter than `limit`).
|
|
@@ -199,13 +241,20 @@ declare class Subgraphs extends BaseClient {
|
|
|
199
241
|
operations(name: string): Promise<{
|
|
200
242
|
operations: SubgraphOperationStatus[];
|
|
201
243
|
}>;
|
|
202
|
-
/**
|
|
203
|
-
*
|
|
244
|
+
/** Get the status of one reindex, backfill, or stop operation.
|
|
245
|
+
*
|
|
246
|
+
* Poll the `operationId` returned by `reindex`, `backfill`, or `stop`
|
|
247
|
+
* until `status` is terminal. */
|
|
204
248
|
getOperation(name: string, operationId: string): Promise<SubgraphOperationStatus>;
|
|
205
249
|
/** Create or update a subgraph. A deploy that needs a rebuild queues one;
|
|
206
250
|
* if a reindex or backfill is already running the API answers 409 with
|
|
207
251
|
* code `OPERATION_IN_PROGRESS` (an `ApiError`, not a dedicated class). */
|
|
208
252
|
deploy(data: DeploySubgraphRequest): Promise<DeploySubgraphResponse>;
|
|
253
|
+
/**
|
|
254
|
+
* Get a deployed subgraph's source.
|
|
255
|
+
*
|
|
256
|
+
* Returns `sourceCode`, the bundled `handlerCode` the runtime executes, and the `pin` hash of what you deployed. `handlerCode` and `pin` are `null` for local deploys. A subgraph deployed before source was captured returns `sourceCode: null` and `readOnly: true` with a `reason`; redeploy it to capture the source.
|
|
257
|
+
*/
|
|
209
258
|
getSource(name: string): Promise<SubgraphSource>;
|
|
210
259
|
/**
|
|
211
260
|
* Bundle a TypeScript subgraph source on the server. Used by the web chat
|
|
@@ -214,13 +263,15 @@ declare class Subgraphs extends BaseClient {
|
|
|
214
263
|
bundle(data: {
|
|
215
264
|
code: string;
|
|
216
265
|
}): Promise<BundleSubgraphResponse>;
|
|
217
|
-
/**
|
|
218
|
-
*
|
|
266
|
+
/** Count the rows in a table that match a filter.
|
|
267
|
+
*
|
|
268
|
+
* The count is exact. Same auth posture as {@link rows}. */
|
|
219
269
|
count(name: string, table: string, params?: Pick<SubgraphQueryParams, "filters">): Promise<{
|
|
220
270
|
count: number;
|
|
221
271
|
}>;
|
|
222
|
-
/**
|
|
223
|
-
*
|
|
272
|
+
/** Compute scalar aggregates over a table's matching rows.
|
|
273
|
+
*
|
|
274
|
+
* Same auth posture as {@link rows}. */
|
|
224
275
|
aggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
|
|
225
276
|
/**
|
|
226
277
|
* Returns a typed client for a subgraph defined with `defineSubgraph()`.
|
|
@@ -256,9 +307,20 @@ import { InstanceDiagnosis, PublicStatus } from "@secondlayer/shared/archive/ins
|
|
|
256
307
|
/** Structural `/public/status` payload. Extra fields are ignored by diagnosis. */
|
|
257
308
|
type InstanceStatus = PublicStatus;
|
|
258
309
|
type InstanceClient = {
|
|
310
|
+
/**
|
|
311
|
+
* Get the instance's public status report.
|
|
312
|
+
*
|
|
313
|
+
* Reads `GET /public/status`: the overall status, chain tip, chain integrity, and the state of each service and decoder.
|
|
314
|
+
*/
|
|
259
315
|
status(): Promise<InstanceStatus>;
|
|
316
|
+
/**
|
|
317
|
+
* Turn the status report into a verdict with next steps.
|
|
318
|
+
*
|
|
319
|
+
* Resolves to a `state` (`healthy`, `empty-index`, or `degraded`), the API's own `overall` status, and a list of issues, each with the commands that resolve it. A fresh instance with no blocks indexed reads as `empty-index`, not broken.
|
|
320
|
+
*/
|
|
260
321
|
diagnose(): Promise<InstanceDiagnosis>;
|
|
261
322
|
};
|
|
323
|
+
/** What to verify against, and the optional block range. */
|
|
262
324
|
type ArchiveVerifyInput = {
|
|
263
325
|
against: string;
|
|
264
326
|
target?: string;
|
|
@@ -268,6 +330,7 @@ type ArchiveVerifyInput = {
|
|
|
268
330
|
publicKeyPem?: string;
|
|
269
331
|
};
|
|
270
332
|
type ArchiveVerifyRangeStatus = "match" | "digest-mismatch" | "count-mismatch" | "missing";
|
|
333
|
+
/** Whether the archive is clean, diverged, or unanchored, by range. */
|
|
271
334
|
type ArchiveVerifyResult = {
|
|
272
335
|
status: "clean" | "diverged" | "unanchored";
|
|
273
336
|
target: string;
|
|
@@ -292,8 +355,11 @@ type ArchiveVerifyResult = {
|
|
|
292
355
|
};
|
|
293
356
|
import { RangeDigest } from "@secondlayer/shared/archive/range-digest";
|
|
294
357
|
import { ArchiveStatus } from "@secondlayer/shared/archive/status";
|
|
358
|
+
/** The three archive datasets: blocks, transactions, and events. */
|
|
295
359
|
type ArchiveDataset = "blocks" | "transactions" | "events";
|
|
360
|
+
/** Whether an archive purchase is a bootstrap or a repair. */
|
|
296
361
|
type ArchiveFlow = "bootstrap" | "repair";
|
|
362
|
+
/** One archive file: dataset, block range, path, rows, bytes. */
|
|
297
363
|
type ArchivePartition = {
|
|
298
364
|
dataset: string;
|
|
299
365
|
from_block: number;
|
|
@@ -316,6 +382,7 @@ type ArchiveManifest = {
|
|
|
316
382
|
key_id?: string;
|
|
317
383
|
[key: string]: unknown;
|
|
318
384
|
};
|
|
385
|
+
/** A loaded archive manifest with its origin and signature check. */
|
|
319
386
|
type LoadedArchive = {
|
|
320
387
|
manifest: ArchiveManifest;
|
|
321
388
|
origin: string;
|
|
@@ -326,6 +393,7 @@ type LoadedArchive = {
|
|
|
326
393
|
reason?: string;
|
|
327
394
|
};
|
|
328
395
|
};
|
|
396
|
+
/** The price of an archive request, after any free allowance. */
|
|
329
397
|
type ArchiveQuote = {
|
|
330
398
|
partitions: number;
|
|
331
399
|
bundles: number;
|
|
@@ -342,11 +410,13 @@ type ArchiveFetchItem = {
|
|
|
342
410
|
expiresAt: string;
|
|
343
411
|
chargedUsdMicros: number;
|
|
344
412
|
};
|
|
413
|
+
/** Download links for archive partitions and what they cost. */
|
|
345
414
|
type ArchiveFetchResult = {
|
|
346
415
|
urls: ArchiveFetchItem[];
|
|
347
416
|
chargedTotalUsdMicros: number;
|
|
348
417
|
balanceAfterUsdMicros: number;
|
|
349
418
|
};
|
|
419
|
+
/** Your archive credit balance and its refill settings. */
|
|
350
420
|
type ArchiveCreditsBalance = {
|
|
351
421
|
creditsUsdMicros: string;
|
|
352
422
|
refill: {
|
|
@@ -355,37 +425,88 @@ type ArchiveCreditsBalance = {
|
|
|
355
425
|
lastAt: string | null;
|
|
356
426
|
};
|
|
357
427
|
};
|
|
428
|
+
/** Options for loading an archive manifest. */
|
|
358
429
|
type ArchiveLoadOptions = {
|
|
359
430
|
insecure?: boolean;
|
|
360
431
|
};
|
|
361
432
|
type ArchiveClient = {
|
|
433
|
+
/**
|
|
434
|
+
* Load the latest signed archive manifest.
|
|
435
|
+
*
|
|
436
|
+
* Reads `<archive>/latest.json` unless `against` names another manifest URL. The manifest's ed25519 signature is checked against the archive signing key, and a missing or invalid one throws `ArchiveSignatureError`. `insecure: true` skips the check; `signature.verified` on the result says whether it held.
|
|
437
|
+
*/
|
|
362
438
|
latest(against?: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
|
|
439
|
+
/**
|
|
440
|
+
* Load an archive manifest from a URL.
|
|
441
|
+
*
|
|
442
|
+
* Takes http(s) URLs only; a local path throws a `ValidationError` and stays on the CLI. The signature check is the same as {@link latest}.
|
|
443
|
+
*/
|
|
363
444
|
load(against: string, opts?: ArchiveLoadOptions): Promise<LoadedArchive>;
|
|
445
|
+
/**
|
|
446
|
+
* Get the archive's current operational state.
|
|
447
|
+
*
|
|
448
|
+
* Reads the public `status.json`: `fresh`, `lagging`, `stale`, `gap`, `failed-audit`, or `source-unavailable`, plus how far the last signed publish reaches.
|
|
449
|
+
*/
|
|
364
450
|
status(): Promise<ArchiveStatus>;
|
|
451
|
+
/**
|
|
452
|
+
* List a loaded archive's partitions, optionally filtered.
|
|
453
|
+
*
|
|
454
|
+
* Runs locally on the manifest you already loaded and makes no request. Filter by `dataset` (`blocks`, `transactions`, or `events`) and a block range.
|
|
455
|
+
*/
|
|
365
456
|
partitions(ref: LoadedArchive, filter?: {
|
|
366
457
|
dataset?: ArchiveDataset;
|
|
367
458
|
fromBlock?: number;
|
|
368
459
|
toBlock?: number;
|
|
369
460
|
}): ArchivePartition[];
|
|
461
|
+
/**
|
|
462
|
+
* Price a fetch against your balance before you pay for it.
|
|
463
|
+
*
|
|
464
|
+
* Nothing is charged. `flow` is `bootstrap` or `repair`. The quote has the bundle count, the price in USD, the free repair allowance applied, your balance, and `sufficient`. Needs an account key (`sk-sl_*`), not an instance token.
|
|
465
|
+
*/
|
|
370
466
|
quote(input: {
|
|
371
467
|
paths: string[];
|
|
372
468
|
flow: ArchiveFlow;
|
|
373
469
|
}): Promise<ArchiveQuote>;
|
|
470
|
+
/**
|
|
471
|
+
* Get presigned download URLs for archive partitions.
|
|
472
|
+
*
|
|
473
|
+
* Draws credits per partition bundle; your first six repair bundles each month are free. Lists longer than 64 paths go out in batches of 64. Each URL is short-lived (`expiresAt`); pass it to {@link download}. An empty balance throws `InsufficientArchiveCreditsError` with the shortfall. Needs an account key (`sk-sl_*`).
|
|
474
|
+
*/
|
|
374
475
|
fetch(input: {
|
|
375
476
|
paths: string[];
|
|
376
477
|
flow: ArchiveFlow;
|
|
377
478
|
}): Promise<ArchiveFetchResult>;
|
|
479
|
+
/**
|
|
480
|
+
* Download a partition's bytes and verify them.
|
|
481
|
+
*
|
|
482
|
+
* The sha256 is checked against the manifest, and a mismatch throws `ArchiveSignatureError`. On the official archive host you must pass the presigned `url` from {@link fetch}, or it throws a `ValidationError`; any other host downloads straight from its archive tree.
|
|
483
|
+
*/
|
|
378
484
|
download(partition: ArchivePartition, opts?: {
|
|
379
485
|
url?: string;
|
|
380
486
|
}): Promise<Uint8Array>;
|
|
381
487
|
credits: {
|
|
488
|
+
/**
|
|
489
|
+
* Get your archive credit balance.
|
|
490
|
+
*
|
|
491
|
+
* Returns `creditsUsdMicros` (millionths of a dollar, as a string) and your auto-refill setting. Needs an account key (`sk-sl_*`).
|
|
492
|
+
*/
|
|
382
493
|
balance(): Promise<ArchiveCreditsBalance>;
|
|
494
|
+
/**
|
|
495
|
+
* Start a card checkout for a credit pack.
|
|
496
|
+
*
|
|
497
|
+
* `pack` is the dollar amount: 10, 25, 50, or 100. Resolves to the checkout `url`. Needs no account key.
|
|
498
|
+
*/
|
|
383
499
|
checkout(input: {
|
|
384
500
|
email: string;
|
|
385
501
|
pack: 10 | 25 | 50 | 100;
|
|
386
502
|
}): Promise<{
|
|
387
503
|
url: string;
|
|
388
504
|
}>;
|
|
505
|
+
/**
|
|
506
|
+
* Set or turn off automatic credit refill.
|
|
507
|
+
*
|
|
508
|
+
* Pass `belowUsd` and `packUsd` to buy a pack whenever the balance drops below the threshold, or `{ off: true }` to stop. Needs an account key (`sk-sl_*`).
|
|
509
|
+
*/
|
|
389
510
|
refill(input: {
|
|
390
511
|
belowUsd: number;
|
|
391
512
|
packUsd: 10 | 25 | 50 | 100;
|
|
@@ -399,6 +520,11 @@ type ArchiveClient = {
|
|
|
399
520
|
};
|
|
400
521
|
/** Hosted archive client plus instance `verify`. `status()` is still the public archive tree. */
|
|
401
522
|
type SecondLayerArchive = ArchiveClient & {
|
|
523
|
+
/**
|
|
524
|
+
* Check your instance's data against a signed archive.
|
|
525
|
+
*
|
|
526
|
+
* Runs `POST /v1/archive/verify` on your instance: read-only, and it compares raw identity digests only (the deep semantic check is CLI-only). Resolves to `clean`, `diverged`, or `unanchored`; a failed signature is `unanchored`, never `clean`. Narrow the check with `fromBlock` and `toBlock`. Verification is free.
|
|
527
|
+
*/
|
|
402
528
|
verify(input: ArchiveVerifyInput): Promise<ArchiveVerifyResult>;
|
|
403
529
|
};
|
|
404
530
|
/**
|
|
@@ -411,6 +537,7 @@ type SecondLayerArchive = ArchiveClient & {
|
|
|
411
537
|
*/
|
|
412
538
|
/** Whether a trait match must be declared in source, inferred from ABI, or either. */
|
|
413
539
|
type ContractConformance = "declared" | "inferred" | "any";
|
|
540
|
+
/** Trait, conformance, and paging for listing contracts. */
|
|
414
541
|
interface ContractsListParams {
|
|
415
542
|
/** Required. Trait identifier to match (e.g. "sip-010", or a fully-qualified trait). */
|
|
416
543
|
trait: string;
|
|
@@ -423,6 +550,7 @@ interface ContractsListParams {
|
|
|
423
550
|
/** Opaque cursor from a prior response's `next_cursor`. */
|
|
424
551
|
cursor?: string;
|
|
425
552
|
}
|
|
553
|
+
/** A deployed contract with its traits, standards, and ABI status. */
|
|
426
554
|
interface ContractSummary {
|
|
427
555
|
contract_id: string;
|
|
428
556
|
deployer: string;
|
|
@@ -433,6 +561,7 @@ interface ContractSummary {
|
|
|
433
561
|
/** Present only when `include: "abi"` was requested. */
|
|
434
562
|
abi?: unknown;
|
|
435
563
|
}
|
|
564
|
+
/** One page of contracts and the cursor for the next page. */
|
|
436
565
|
interface ContractsEnvelope {
|
|
437
566
|
contracts: ContractSummary[];
|
|
438
567
|
next_cursor: string | null;
|
|
@@ -442,8 +571,10 @@ declare class Contracts extends BaseClient {
|
|
|
442
571
|
/** Find contracts conforming to `trait`. `trait` is required (server 400s without it). */
|
|
443
572
|
list(params: ContractsListParams): Promise<ContractsEnvelope>;
|
|
444
573
|
/**
|
|
445
|
-
*
|
|
446
|
-
*
|
|
574
|
+
* Get one contract from the registry by id, or `null`.
|
|
575
|
+
*
|
|
576
|
+
* The prod-safe ABI source. Pass `{ includeAbi: true }` for the full ABI
|
|
577
|
+
* blob. Resolves to `null` on 404.
|
|
447
578
|
*/
|
|
448
579
|
get(contractId: string, opts?: {
|
|
449
580
|
includeAbi?: boolean;
|
|
@@ -618,6 +749,7 @@ type WithSinkTx<TTx> = [TTx] extends [never] ? unknown : {
|
|
|
618
749
|
};
|
|
619
750
|
import { VmEventType } from "@secondlayer/shared";
|
|
620
751
|
import { RuneEventType, RuneStreamsEvent, StreamsEvent, StreamsEventType, StreamsWireEvent, VmStreamsEvent } from "@secondlayer/shared/streams-rows";
|
|
752
|
+
/** The chain tip: latest block, Bitcoin anchor, and finality boundary. */
|
|
621
753
|
type StreamsTip = {
|
|
622
754
|
block_height: number;
|
|
623
755
|
block_hash: string;
|
|
@@ -637,15 +769,19 @@ type StreamsTip = {
|
|
|
637
769
|
/** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
|
|
638
770
|
oldest_cursor?: string | null;
|
|
639
771
|
};
|
|
640
|
-
/**
|
|
641
|
-
*
|
|
642
|
-
*
|
|
772
|
+
/**
|
|
773
|
+
* The Bitcoin tip, without burn-chain or retention fields.
|
|
774
|
+
*
|
|
775
|
+
* Bitcoin has no burn chain of its own, and Runes reads have no retention
|
|
776
|
+
* ladder. Returned by `tip({ chain: "bitcoin" })`.
|
|
777
|
+
*/
|
|
643
778
|
type StreamsBitcoinTip = {
|
|
644
779
|
block_height: number;
|
|
645
780
|
block_hash: string;
|
|
646
781
|
finalized_height: number;
|
|
647
782
|
lag_seconds: number;
|
|
648
783
|
};
|
|
784
|
+
/** A canonical Stacks block with its Bitcoin anchor. */
|
|
649
785
|
type StreamsCanonicalBlock = {
|
|
650
786
|
block_height: number;
|
|
651
787
|
block_hash: string;
|
|
@@ -653,7 +789,7 @@ type StreamsCanonicalBlock = {
|
|
|
653
789
|
burn_block_hash: string | null;
|
|
654
790
|
is_canonical: true;
|
|
655
791
|
};
|
|
656
|
-
/**
|
|
792
|
+
/** A Bitcoin canonical block, without burn-chain fields. */
|
|
657
793
|
type StreamsBitcoinCanonicalBlock = {
|
|
658
794
|
block_height: number;
|
|
659
795
|
block_hash: string;
|
|
@@ -674,6 +810,7 @@ type StreamsReorg = {
|
|
|
674
810
|
*/
|
|
675
811
|
new_canonical_tip: string;
|
|
676
812
|
};
|
|
813
|
+
/** One page of events with the next cursor, tip, and reorgs. */
|
|
677
814
|
type StreamsEventsEnvelope<
|
|
678
815
|
TEvent = StreamsEvent,
|
|
679
816
|
TTip = StreamsTip
|
|
@@ -683,24 +820,30 @@ type StreamsEventsEnvelope<
|
|
|
683
820
|
tip: TTip;
|
|
684
821
|
reorgs: StreamsReorg[];
|
|
685
822
|
};
|
|
823
|
+
/** One page of events with the tip and reorgs, no cursor. */
|
|
686
824
|
type StreamsEventsListEnvelope<
|
|
687
825
|
TEvent = StreamsEvent,
|
|
688
826
|
TTip = StreamsTip
|
|
689
827
|
> = Omit<StreamsEventsEnvelope<TEvent, TTip>, "next_cursor">;
|
|
690
|
-
/**
|
|
691
|
-
*
|
|
828
|
+
/**
|
|
829
|
+
* The event union narrowed to a `types` selection.
|
|
830
|
+
*
|
|
831
|
+
* A const-generic `types: ["ft_transfer"]` narrows the event type.
|
|
832
|
+
*/
|
|
692
833
|
type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
|
|
693
834
|
event_type: T[number];
|
|
694
835
|
}>;
|
|
836
|
+
/** A starting point and limit for listing reorgs. */
|
|
695
837
|
type StreamsReorgsListParams = {
|
|
696
838
|
since: string;
|
|
697
839
|
limit?: number;
|
|
698
840
|
};
|
|
841
|
+
/** A list of reorgs and the cursor to resume from. */
|
|
699
842
|
type StreamsReorgsListEnvelope = {
|
|
700
843
|
reorgs: StreamsReorg[];
|
|
701
844
|
next_since: string | null;
|
|
702
845
|
};
|
|
703
|
-
/** A
|
|
846
|
+
/** A single value or a list of values to match. */
|
|
704
847
|
type StreamsFilterValue = string | readonly string[];
|
|
705
848
|
/**
|
|
706
849
|
* One labelled filter group. Fields inside a group AND together; groups in a
|
|
@@ -730,14 +873,15 @@ type StreamsEventForFilter<
|
|
|
730
873
|
}> : Extract<StreamsEvent, {
|
|
731
874
|
event_type: T;
|
|
732
875
|
}> : D extends true ? IndexEvent : StreamsEvent;
|
|
876
|
+
/** Cursor, height range, and limit shared by every list call. */
|
|
733
877
|
type StreamsEventsListParamsCommon = {
|
|
734
878
|
cursor?: string | null;
|
|
735
879
|
fromHeight?: number;
|
|
736
880
|
toHeight?: number;
|
|
737
881
|
limit?: number;
|
|
738
882
|
};
|
|
739
|
-
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
|
|
740
|
-
*
|
|
883
|
+
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
|
|
884
|
+
* were added. */
|
|
741
885
|
type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
742
886
|
chain?: "stacks";
|
|
743
887
|
/** `vm` reads ordinal. Omit for Streams 1.0. */
|
|
@@ -757,12 +901,13 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
|
757
901
|
filters?: StreamsFilterMap;
|
|
758
902
|
};
|
|
759
903
|
/**
|
|
760
|
-
*
|
|
761
|
-
*
|
|
762
|
-
* `
|
|
763
|
-
*
|
|
764
|
-
*
|
|
765
|
-
*
|
|
904
|
+
* List options for Runes events, with their own cursor space.
|
|
905
|
+
*
|
|
906
|
+
* `types` is restricted to `RuneEventType` at the type level, so e.g. `{ chain:
|
|
907
|
+
* "bitcoin", types: ["ft_transfer"] }` is a compile error rather than a silent
|
|
908
|
+
* 400 at request time. `contractId`, `sender`, `recipient`, `assetIdentifier`,
|
|
909
|
+
* `filters`, and `clock` don't exist on this branch; they're Stacks-only (the
|
|
910
|
+
* server 400s on them too).
|
|
766
911
|
*/
|
|
767
912
|
type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
|
|
768
913
|
chain: "bitcoin";
|
|
@@ -773,7 +918,9 @@ type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
|
|
|
773
918
|
/** A mainnet address. */
|
|
774
919
|
address?: string;
|
|
775
920
|
};
|
|
921
|
+
/** Chain, cursor, height range, and filters for listing Streams events. */
|
|
776
922
|
type StreamsEventsListParams = StreamsEventsStacksListParams | StreamsEventsBitcoinListParams;
|
|
923
|
+
/** Cursor, batching, and stop options shared by every event stream. */
|
|
777
924
|
type StreamsEventsStreamCommon = {
|
|
778
925
|
fromCursor?: string | null;
|
|
779
926
|
batchSize?: number;
|
|
@@ -782,8 +929,12 @@ type StreamsEventsStreamCommon = {
|
|
|
782
929
|
maxEmptyPolls?: number;
|
|
783
930
|
signal?: AbortSignal;
|
|
784
931
|
};
|
|
785
|
-
/**
|
|
786
|
-
*
|
|
932
|
+
/**
|
|
933
|
+
* Stream options for Stacks events, the default chain.
|
|
934
|
+
*
|
|
935
|
+
* `chain: "stacks"` is the default, so omit `chain` entirely. Matches
|
|
936
|
+
* `StreamsEventsStacksListParams`.
|
|
937
|
+
*/
|
|
787
938
|
type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
|
|
788
939
|
chain?: "stacks";
|
|
789
940
|
types?: readonly StreamsEventType[];
|
|
@@ -795,11 +946,14 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
|
|
|
795
946
|
/** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
|
|
796
947
|
filters?: StreamsFilterMap;
|
|
797
948
|
};
|
|
798
|
-
/**
|
|
799
|
-
*
|
|
800
|
-
*
|
|
801
|
-
*
|
|
802
|
-
*
|
|
949
|
+
/**
|
|
950
|
+
* Stream options for Runes events, tailed like the Stacks default.
|
|
951
|
+
*
|
|
952
|
+
* `types` is restricted to `RuneEventType` at the type level, matching
|
|
953
|
+
* `StreamsEventsBitcoinListParams`. `contractId`, `sender`, `recipient`,
|
|
954
|
+
* `assetIdentifier`, and `filters` don't exist on this branch; they're
|
|
955
|
+
* Stacks-only.
|
|
956
|
+
*/
|
|
803
957
|
type StreamsEventsStreamBitcoinParams = StreamsEventsStreamCommon & {
|
|
804
958
|
chain: "bitcoin";
|
|
805
959
|
types?: readonly RuneEventType[];
|
|
@@ -853,9 +1007,12 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
|
|
|
853
1007
|
*/
|
|
854
1008
|
onEvent: (event: StreamsEvent) => void | Promise<void>;
|
|
855
1009
|
};
|
|
856
|
-
/**
|
|
857
|
-
*
|
|
858
|
-
*
|
|
1010
|
+
/**
|
|
1011
|
+
* Options for pushing Runes events live, on their own cursor space.
|
|
1012
|
+
*
|
|
1013
|
+
* `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
|
|
1014
|
+
* exist on this branch; they're Stacks-only.
|
|
1015
|
+
*/
|
|
859
1016
|
type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
|
|
860
1017
|
chain: "bitcoin";
|
|
861
1018
|
types?: readonly RuneEventType[];
|
|
@@ -945,6 +1102,7 @@ type StreamsBatchContext = ConsumerBatchContext;
|
|
|
945
1102
|
type StreamsReorgContext = {
|
|
946
1103
|
cursor: string | null;
|
|
947
1104
|
};
|
|
1105
|
+
/** Options for consuming Streams events: cursor, batching, filters, handler. */
|
|
948
1106
|
type StreamsEventsConsumeParams<
|
|
949
1107
|
TTx = never,
|
|
950
1108
|
D extends boolean = false,
|
|
@@ -1062,13 +1220,14 @@ type StreamsEventsConsumeParams<
|
|
|
1062
1220
|
wake?: () => Promise<void>;
|
|
1063
1221
|
};
|
|
1064
1222
|
/**
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
*
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1223
|
+
* Options for the checkpointed sweep over Runes events.
|
|
1224
|
+
*
|
|
1225
|
+
* A separate, simpler type from `StreamsEventsConsumeParams` rather than a
|
|
1226
|
+
* widened union member: `filters`, `on`, and `decoded` are Stacks-only concepts
|
|
1227
|
+
* (labelled OR-groups and Index-shaped projection have no Runes equivalent
|
|
1228
|
+
* yet), so `onBatch` is the only way in and is required. Reorg rewind still
|
|
1229
|
+
* works the same way (bitcoin reorgs carry the same `fork_point_height` and
|
|
1230
|
+
* `new_canonical_tip` shape as Stacks ones).
|
|
1072
1231
|
*/
|
|
1073
1232
|
type StreamsEventsConsumeBitcoinParams<TTx = never> = {
|
|
1074
1233
|
chain: "bitcoin";
|
|
@@ -1101,9 +1260,10 @@ type StreamsEventsConsumeBitcoinParams<TTx = never> = {
|
|
|
1101
1260
|
wake?: () => Promise<void>;
|
|
1102
1261
|
};
|
|
1103
1262
|
/**
|
|
1104
|
-
* One
|
|
1105
|
-
*
|
|
1106
|
-
*
|
|
1263
|
+
* One page yielded by `consume`, with `cursor` to persist and resume.
|
|
1264
|
+
*
|
|
1265
|
+
* It is the `GET /v1/streams/events` envelope verbatim, with `next_cursor`
|
|
1266
|
+
* renamed to `cursor`.
|
|
1107
1267
|
*/
|
|
1108
1268
|
type StreamsBatch<
|
|
1109
1269
|
TEvent = StreamsEvent,
|
|
@@ -1117,6 +1277,7 @@ type StreamsBatch<
|
|
|
1117
1277
|
/** Chain reorgs reported alongside this page; empty when none. */
|
|
1118
1278
|
reorgs: StreamsReorg[];
|
|
1119
1279
|
};
|
|
1280
|
+
/** Cursor, batch size, and polling options shared by every consume loop. */
|
|
1120
1281
|
type StreamsConsumeCommon = {
|
|
1121
1282
|
/** Resume strictly after this cursor; omit to start from the oldest seekable page. */
|
|
1122
1283
|
cursor?: string | null;
|
|
@@ -1140,9 +1301,12 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
|
|
|
1140
1301
|
* event echoes the labels it matched. */
|
|
1141
1302
|
filters?: StreamsFilterMap;
|
|
1142
1303
|
};
|
|
1143
|
-
/**
|
|
1144
|
-
*
|
|
1145
|
-
*
|
|
1304
|
+
/**
|
|
1305
|
+
* Consume options for Runes batches, with their own cursor space.
|
|
1306
|
+
*
|
|
1307
|
+
* `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
|
|
1308
|
+
* exist on this branch; they're Stacks-only.
|
|
1309
|
+
*/
|
|
1146
1310
|
type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
|
|
1147
1311
|
chain: "bitcoin";
|
|
1148
1312
|
types?: readonly RuneEventType[];
|
|
@@ -1153,11 +1317,13 @@ type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
|
|
|
1153
1317
|
address?: string;
|
|
1154
1318
|
};
|
|
1155
1319
|
type StreamsConsumeParams = StreamsConsumeStacksParams | StreamsConsumeBitcoinParams;
|
|
1320
|
+
/** Where a consume loop stopped: cursor, pages read, empty polls. */
|
|
1156
1321
|
type StreamsEventsConsumeResult = {
|
|
1157
1322
|
cursor: string | null;
|
|
1158
1323
|
pages: number;
|
|
1159
1324
|
emptyPolls: number;
|
|
1160
1325
|
};
|
|
1326
|
+
/** Options for replaying history from dump files, then tailing live. */
|
|
1161
1327
|
type StreamsEventsReplayParams = {
|
|
1162
1328
|
/** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
|
|
1163
1329
|
from?: "genesis" | string;
|
|
@@ -1212,6 +1378,7 @@ type StreamsDumpFile = {
|
|
|
1212
1378
|
schema_version: number;
|
|
1213
1379
|
created_at: string;
|
|
1214
1380
|
};
|
|
1381
|
+
/** The index of finalized Parquet dump files for one dataset. */
|
|
1215
1382
|
type StreamsDumpsManifest = {
|
|
1216
1383
|
dataset: string;
|
|
1217
1384
|
network: string;
|
|
@@ -1243,38 +1410,43 @@ type StreamsDumps = {
|
|
|
1243
1410
|
};
|
|
1244
1411
|
type StreamsClient = {
|
|
1245
1412
|
/**
|
|
1246
|
-
*
|
|
1413
|
+
* Read Streams page by page as an async iterator.
|
|
1247
1414
|
*
|
|
1248
|
-
* Yields one {@link StreamsBatch} per
|
|
1249
|
-
*
|
|
1250
|
-
*
|
|
1251
|
-
* because the envelope is page-keyed, so every yield is exactly one fetch.
|
|
1252
|
-
* Empty pages are skipped; at the tip the iterator re-polls every
|
|
1253
|
-
* `intervalMs` (default 2000) until aborted via `signal`.
|
|
1415
|
+
* Yields one {@link StreamsBatch} per events page, so each yield is exactly
|
|
1416
|
+
* one API call. Empty pages are skipped; at the tip the iterator polls again
|
|
1417
|
+
* every `intervalMs` (default 2000) until `signal` aborts.
|
|
1254
1418
|
*
|
|
1255
|
-
* Reorgs
|
|
1256
|
-
*
|
|
1257
|
-
*
|
|
1419
|
+
* Reorgs appear on `batch.reorgs`, but the cursor is not rewound for you.
|
|
1420
|
+
* Use `events.consume` with `onReorg` when you need rollback.
|
|
1421
|
+
*
|
|
1422
|
+
* A literal `types` array narrows every batch's event union to those types.
|
|
1423
|
+
* `chain: "bitcoin"` batches carry Runes rows only, on the bitcoin tip shape.
|
|
1258
1424
|
*/
|
|
1259
|
-
/** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
|
|
1260
|
-
* shape (plan 059/061). */
|
|
1261
1425
|
consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1262
|
-
/** Narrowing overload: a literal `types` array narrows every batch's
|
|
1263
|
-
* event union to exactly those members. */
|
|
1264
1426
|
consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
|
|
1265
1427
|
types: T;
|
|
1266
1428
|
}): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
|
|
1267
1429
|
consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
|
|
1268
1430
|
events: {
|
|
1269
|
-
/**
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1431
|
+
/**
|
|
1432
|
+
* Read one page of chain events and the next cursor.
|
|
1433
|
+
*
|
|
1434
|
+
* Narrow with `types`, `notTypes`, `contractId`, `sender`, `recipient`,
|
|
1435
|
+
* `assetIdentifier`, `fromHeight`/`toHeight`, or labelled `filters`.
|
|
1436
|
+
* Filters match exactly, and an event type without a given field never
|
|
1437
|
+
* matches it. Pass `next_cursor` back as `cursor` to continue. The
|
|
1438
|
+
* envelope also carries the `tip` and any `reorgs`. To write the events
|
|
1439
|
+
* somewhere with a checkpoint, use `events.consume` instead.
|
|
1440
|
+
*
|
|
1441
|
+
* A literal `types` array narrows every row to those event types.
|
|
1442
|
+
* `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
|
|
1443
|
+
* `event_index` = `ordinal`), never `StreamsEvent`; it is Stacks only.
|
|
1444
|
+
* `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip shape,
|
|
1445
|
+
* and filter by `rune` or `address`.
|
|
1446
|
+
*/
|
|
1272
1447
|
list(params: StreamsEventsStacksListParams & {
|
|
1273
1448
|
clock: "vm";
|
|
1274
1449
|
}): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
|
|
1275
|
-
/** Narrowing overload, matching `consume`. Classic clock only —
|
|
1276
|
-
* `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
|
|
1277
|
-
* variable (clock unresolved) is the wire-union fallback. */
|
|
1278
1450
|
list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
|
|
1279
1451
|
types: T;
|
|
1280
1452
|
notTypes?: readonly StreamsEventType[];
|
|
@@ -1285,27 +1457,35 @@ type StreamsClient = {
|
|
|
1285
1457
|
notTypes?: readonly StreamsEventType[];
|
|
1286
1458
|
clock?: "classic";
|
|
1287
1459
|
}): Promise<StreamsEventsEnvelope>;
|
|
1288
|
-
/** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
|
|
1289
|
-
* shape (plan 059). */
|
|
1290
1460
|
list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1291
|
-
/** Unresolved `chain`/`clock` on a general params variable: the wire union. */
|
|
1292
1461
|
list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
|
|
1293
|
-
/**
|
|
1462
|
+
/**
|
|
1463
|
+
* Read every event a transaction emitted.
|
|
1464
|
+
*
|
|
1465
|
+
* Returns the events and the `tip`, with no `next_cursor`: one transaction
|
|
1466
|
+
* is one response.
|
|
1467
|
+
*
|
|
1468
|
+
* `chain: "bitcoin"` returns the Runes events for one Bitcoin transaction.
|
|
1469
|
+
*/
|
|
1294
1470
|
byTxId(txId: string, opts: {
|
|
1295
1471
|
chain: "bitcoin";
|
|
1296
1472
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1297
1473
|
byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
|
|
1298
1474
|
/**
|
|
1299
|
-
*
|
|
1475
|
+
* Run a checkpointed indexer that rewinds on reorgs.
|
|
1476
|
+
*
|
|
1477
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same
|
|
1478
|
+
* transaction; resume with `fromCursor`. Reorgs at or below your checkpoint
|
|
1479
|
+
* call `onReorg`, then the loop re-reads from the fork point. Delivery is
|
|
1480
|
+
* at-least-once, so keep writes idempotent. With a `sink`, the checkpoint
|
|
1481
|
+
* and rollback are handled for you. `mode: "tail"` (default) keeps polling
|
|
1482
|
+
* at the tip; `mode: "bounded"` returns on the first empty page. It also
|
|
1483
|
+
* stops on `maxPages`, `maxEmptyPolls`, or `signal`. Pass `finalizedOnly`
|
|
1484
|
+
* to skip reorg handling entirely.
|
|
1300
1485
|
*
|
|
1301
|
-
*
|
|
1302
|
-
*
|
|
1303
|
-
* polling when caught up; `mode: "bounded"` exits on the first empty page.
|
|
1304
|
-
* The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
|
|
1305
|
-
* stops it.
|
|
1486
|
+
* `chain: "bitcoin"` sweeps Runes events; see
|
|
1487
|
+
* {@link StreamsEventsConsumeBitcoinParams}.
|
|
1306
1488
|
*/
|
|
1307
|
-
/** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
|
|
1308
|
-
* {@link StreamsEventsConsumeBitcoinParams}. */
|
|
1309
1489
|
consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
|
|
1310
1490
|
sink?: ConsumerSink<TTx>;
|
|
1311
1491
|
}): Promise<StreamsEventsConsumeResult>;
|
|
@@ -1317,46 +1497,66 @@ type StreamsClient = {
|
|
|
1317
1497
|
sink?: ConsumerSink<TTx>;
|
|
1318
1498
|
}): Promise<StreamsEventsConsumeResult>;
|
|
1319
1499
|
/**
|
|
1320
|
-
* Backfill from bulk dumps, then continue live
|
|
1321
|
-
*
|
|
1322
|
-
*
|
|
1323
|
-
*
|
|
1324
|
-
* `
|
|
1500
|
+
* Backfill from bulk dumps, then continue live in one call.
|
|
1501
|
+
*
|
|
1502
|
+
* Hands each finalized dump file to `onDumpFile` in block order, then tails
|
|
1503
|
+
* live from the manifest's `latest_finalized_cursor`, with no gap or
|
|
1504
|
+
* duplicate at the seam. A file that straddles `from` is delivered whole,
|
|
1505
|
+
* so skip the rows at or below it. Requires `dumpsBaseUrl`.
|
|
1325
1506
|
*/
|
|
1326
1507
|
replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
|
|
1327
1508
|
/**
|
|
1328
|
-
*
|
|
1509
|
+
* Read events one at a time as an async iterator.
|
|
1510
|
+
*
|
|
1511
|
+
* For live processors and watch-style apps that keep their own state. It
|
|
1512
|
+
* tails indefinitely and stops when `signal`, `maxPages`, or
|
|
1513
|
+
* `maxEmptyPolls` ends it. There is no checkpoint or reorg handling; use
|
|
1514
|
+
* `events.consume` for that.
|
|
1329
1515
|
*
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
* `maxEmptyPolls` stops it.
|
|
1516
|
+
* A literal `types` array narrows every event to those types.
|
|
1517
|
+
* `chain: "bitcoin"` yields Runes events only.
|
|
1333
1518
|
*/
|
|
1334
|
-
/** `chain: "bitcoin"` — Runes events only (plan 059/061). */
|
|
1335
1519
|
stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
|
|
1336
|
-
/** Narrowing overload, matching `consume`. */
|
|
1337
1520
|
stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
|
|
1338
1521
|
types: T;
|
|
1339
1522
|
}): AsyncIterable<StreamsEventOfTypes<T>>;
|
|
1340
1523
|
stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
|
|
1341
1524
|
/**
|
|
1342
|
-
*
|
|
1343
|
-
*
|
|
1344
|
-
*
|
|
1345
|
-
*
|
|
1346
|
-
*
|
|
1347
|
-
*
|
|
1525
|
+
* Get each new event pushed to `onEvent` as it lands.
|
|
1526
|
+
*
|
|
1527
|
+
* Reconnects from the last handled cursor after a transport error, and
|
|
1528
|
+
* verifies each frame's ed25519 signature when the client has `verify` on.
|
|
1529
|
+
* Returns an unsubscribe function whose `done` promise settles when the
|
|
1530
|
+
* loop ends. Not reorg-aware: an event delivered and then orphaned is never
|
|
1531
|
+
* retracted. Durable writers use `events.consume`.
|
|
1532
|
+
*
|
|
1533
|
+
* `chain: "bitcoin"` delivers Runes rows to `onEvent`.
|
|
1348
1534
|
*/
|
|
1349
|
-
/** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
|
|
1350
1535
|
subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
|
|
1351
1536
|
subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
|
|
1352
1537
|
};
|
|
1353
1538
|
blocks: {
|
|
1539
|
+
/**
|
|
1540
|
+
* Read every event in one block, by height or hash.
|
|
1541
|
+
*
|
|
1542
|
+
* Returns the events and the `tip`, with no `next_cursor`.
|
|
1543
|
+
*
|
|
1544
|
+
* `chain: "bitcoin"` returns the Runes events in one Bitcoin block.
|
|
1545
|
+
*/
|
|
1354
1546
|
events(heightOrHash: number | string, opts: {
|
|
1355
1547
|
chain: "bitcoin";
|
|
1356
1548
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
1357
1549
|
events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
|
|
1358
1550
|
};
|
|
1359
1551
|
reorgs: {
|
|
1552
|
+
/**
|
|
1553
|
+
* List chain reorgs since a cursor.
|
|
1554
|
+
*
|
|
1555
|
+
* `since` is required. Each reorg gives its `fork_point_height` and the
|
|
1556
|
+
* orphaned range. Page with `next_since`.
|
|
1557
|
+
*
|
|
1558
|
+
* `chain: "bitcoin"` lists Bitcoin reorgs, on their own cursor space.
|
|
1559
|
+
*/
|
|
1360
1560
|
list(params: StreamsReorgsListParams & {
|
|
1361
1561
|
chain: "bitcoin";
|
|
1362
1562
|
}): Promise<StreamsReorgsListEnvelope>;
|
|
@@ -1364,10 +1564,27 @@ type StreamsClient = {
|
|
|
1364
1564
|
};
|
|
1365
1565
|
/** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
|
|
1366
1566
|
dumps: StreamsDumps;
|
|
1567
|
+
/**
|
|
1568
|
+
* Get the canonical block at a height.
|
|
1569
|
+
*
|
|
1570
|
+
* Returns the block hash and, on Stacks, the burn block it anchors to.
|
|
1571
|
+
*
|
|
1572
|
+
* `chain: "bitcoin"` returns the Bitcoin block, without burn-chain fields.
|
|
1573
|
+
*/
|
|
1367
1574
|
canonical(height: number, opts: {
|
|
1368
1575
|
chain: "bitcoin";
|
|
1369
1576
|
}): Promise<StreamsBitcoinCanonicalBlock>;
|
|
1370
1577
|
canonical(height: number): Promise<StreamsCanonicalBlock>;
|
|
1578
|
+
/**
|
|
1579
|
+
* Get the current chain tip.
|
|
1580
|
+
*
|
|
1581
|
+
* Returns the tip height and hash, `finalized_height`, and `lag_seconds`. On
|
|
1582
|
+
* Stacks it also reports the oldest height your tier can seek; older reads
|
|
1583
|
+
* come from the bulk dumps.
|
|
1584
|
+
*
|
|
1585
|
+
* `chain: "bitcoin"` returns the Bitcoin tip, without burn-chain or retention
|
|
1586
|
+
* fields.
|
|
1587
|
+
*/
|
|
1371
1588
|
tip(opts: {
|
|
1372
1589
|
chain: "bitcoin";
|
|
1373
1590
|
}): Promise<StreamsBitcoinTip>;
|
|
@@ -1504,6 +1721,7 @@ type IndexReorg = {
|
|
|
1504
1721
|
*/
|
|
1505
1722
|
new_canonical_tip: string;
|
|
1506
1723
|
};
|
|
1724
|
+
/** A decoded fungible-token transfer: sender, recipient, asset, amount. */
|
|
1507
1725
|
type FtTransfer = {
|
|
1508
1726
|
cursor: string;
|
|
1509
1727
|
block_height: number;
|
|
@@ -1518,6 +1736,7 @@ type FtTransfer = {
|
|
|
1518
1736
|
recipient: string;
|
|
1519
1737
|
amount: string;
|
|
1520
1738
|
};
|
|
1739
|
+
/** One page of fungible-token transfers, with the cursor, tip, and reorgs. */
|
|
1521
1740
|
type FtTransfersEnvelope<TRow = FtTransfer> = {
|
|
1522
1741
|
events: TRow[];
|
|
1523
1742
|
next_cursor: string | null;
|
|
@@ -1529,6 +1748,7 @@ type FtTransfersEnvelope<TRow = FtTransfer> = {
|
|
|
1529
1748
|
type FtTransferAlwaysFields = "cursor" | "block_height" | "event_type";
|
|
1530
1749
|
/** An ft-transfer row narrowed to the requested columns plus the always-present ones. */
|
|
1531
1750
|
type FtTransferFields<F extends keyof FtTransfer & string> = Pick<FtTransfer, (F | FtTransferAlwaysFields) & keyof FtTransfer>;
|
|
1751
|
+
/** Column selection, paging, and filters for listing token transfers. */
|
|
1532
1752
|
type FtTransfersListParams = {
|
|
1533
1753
|
/**
|
|
1534
1754
|
* Columns to return. The server projects the row, so an unrequested column
|
|
@@ -1560,7 +1780,9 @@ type WalkOptions = PageRetryOptions & {
|
|
|
1560
1780
|
* walk from a stopped one. */
|
|
1561
1781
|
signal?: AbortSignal;
|
|
1562
1782
|
};
|
|
1783
|
+
/** `FtTransfersListParams` without `limit`, plus walk options. */
|
|
1563
1784
|
type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & WalkOptions;
|
|
1785
|
+
/** A decoded non-fungible-token transfer: sender, recipient, asset, value. */
|
|
1564
1786
|
type NftTransfer = {
|
|
1565
1787
|
cursor: string;
|
|
1566
1788
|
block_height: number;
|
|
@@ -1575,6 +1797,7 @@ type NftTransfer = {
|
|
|
1575
1797
|
recipient: string;
|
|
1576
1798
|
value: string;
|
|
1577
1799
|
};
|
|
1800
|
+
/** One page of non-fungible-token transfers, with the cursor, tip, and reorgs. */
|
|
1578
1801
|
type NftTransfersEnvelope<TRow = NftTransfer> = {
|
|
1579
1802
|
events: TRow[];
|
|
1580
1803
|
next_cursor: string | null;
|
|
@@ -1585,6 +1808,7 @@ type NftTransfersEnvelope<TRow = NftTransfer> = {
|
|
|
1585
1808
|
type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
|
|
1586
1809
|
/** An nft-transfer row narrowed to the requested columns plus the always-present ones. */
|
|
1587
1810
|
type NftTransferFields<F extends keyof NftTransfer & string> = Pick<NftTransfer, (F | NftTransferAlwaysFields) & keyof NftTransfer>;
|
|
1811
|
+
/** Column selection, paging, and filters for listing NFT transfers. */
|
|
1588
1812
|
type NftTransfersListParams = {
|
|
1589
1813
|
/** Columns to return (see {@link FtTransfersListParams.fields}). */
|
|
1590
1814
|
fields?: readonly (keyof NftTransfer & string)[];
|
|
@@ -1598,6 +1822,7 @@ type NftTransfersListParams = {
|
|
|
1598
1822
|
fromHeight?: number;
|
|
1599
1823
|
toHeight?: number;
|
|
1600
1824
|
};
|
|
1825
|
+
/** `NftTransfersListParams` without `limit`, plus walk options. */
|
|
1601
1826
|
type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & WalkOptions;
|
|
1602
1827
|
type IndexEventBase = {
|
|
1603
1828
|
cursor: string;
|
|
@@ -1618,6 +1843,7 @@ type IndexEventBase = {
|
|
|
1618
1843
|
tx_contract_id?: string | null;
|
|
1619
1844
|
tx_function_name?: string | null;
|
|
1620
1845
|
};
|
|
1846
|
+
/** A fungible-token transfer event. */
|
|
1621
1847
|
type IndexFtTransfer = IndexEventBase & {
|
|
1622
1848
|
event_type: "ft_transfer";
|
|
1623
1849
|
asset_identifier: string;
|
|
@@ -1625,6 +1851,7 @@ type IndexFtTransfer = IndexEventBase & {
|
|
|
1625
1851
|
recipient: string;
|
|
1626
1852
|
amount: string;
|
|
1627
1853
|
};
|
|
1854
|
+
/** A non-fungible-token transfer event. */
|
|
1628
1855
|
type IndexNftTransfer = IndexEventBase & {
|
|
1629
1856
|
event_type: "nft_transfer";
|
|
1630
1857
|
asset_identifier: string;
|
|
@@ -1632,6 +1859,7 @@ type IndexNftTransfer = IndexEventBase & {
|
|
|
1632
1859
|
recipient: string;
|
|
1633
1860
|
value: string;
|
|
1634
1861
|
};
|
|
1862
|
+
/** An STX transfer event. */
|
|
1635
1863
|
type IndexStxTransfer = IndexEventBase & {
|
|
1636
1864
|
event_type: "stx_transfer";
|
|
1637
1865
|
sender: string;
|
|
@@ -1639,16 +1867,19 @@ type IndexStxTransfer = IndexEventBase & {
|
|
|
1639
1867
|
amount: string;
|
|
1640
1868
|
memo: string | null;
|
|
1641
1869
|
};
|
|
1870
|
+
/** An STX mint event. */
|
|
1642
1871
|
type IndexStxMint = IndexEventBase & {
|
|
1643
1872
|
event_type: "stx_mint";
|
|
1644
1873
|
recipient: string;
|
|
1645
1874
|
amount: string;
|
|
1646
1875
|
};
|
|
1876
|
+
/** An STX burn event. */
|
|
1647
1877
|
type IndexStxBurn = IndexEventBase & {
|
|
1648
1878
|
event_type: "stx_burn";
|
|
1649
1879
|
sender: string;
|
|
1650
1880
|
amount: string;
|
|
1651
1881
|
};
|
|
1882
|
+
/** An STX lock event with its unlock height. */
|
|
1652
1883
|
type IndexStxLock = IndexEventBase & {
|
|
1653
1884
|
event_type: "stx_lock";
|
|
1654
1885
|
sender: string;
|
|
@@ -1657,30 +1888,35 @@ type IndexStxLock = IndexEventBase & {
|
|
|
1657
1888
|
unlock_height: string | null;
|
|
1658
1889
|
};
|
|
1659
1890
|
};
|
|
1891
|
+
/** A fungible-token mint event. */
|
|
1660
1892
|
type IndexFtMint = IndexEventBase & {
|
|
1661
1893
|
event_type: "ft_mint";
|
|
1662
1894
|
asset_identifier: string;
|
|
1663
1895
|
recipient: string;
|
|
1664
1896
|
amount: string;
|
|
1665
1897
|
};
|
|
1898
|
+
/** A fungible-token burn event. */
|
|
1666
1899
|
type IndexFtBurn = IndexEventBase & {
|
|
1667
1900
|
event_type: "ft_burn";
|
|
1668
1901
|
asset_identifier: string;
|
|
1669
1902
|
sender: string;
|
|
1670
1903
|
amount: string;
|
|
1671
1904
|
};
|
|
1905
|
+
/** A non-fungible-token mint event. */
|
|
1672
1906
|
type IndexNftMint = IndexEventBase & {
|
|
1673
1907
|
event_type: "nft_mint";
|
|
1674
1908
|
asset_identifier: string;
|
|
1675
1909
|
recipient: string;
|
|
1676
1910
|
value: string;
|
|
1677
1911
|
};
|
|
1912
|
+
/** A non-fungible-token burn event. */
|
|
1678
1913
|
type IndexNftBurn = IndexEventBase & {
|
|
1679
1914
|
event_type: "nft_burn";
|
|
1680
1915
|
asset_identifier: string;
|
|
1681
1916
|
sender: string;
|
|
1682
1917
|
value: string;
|
|
1683
1918
|
};
|
|
1919
|
+
/** A contract `print` event with its topic and value. */
|
|
1684
1920
|
type IndexPrint = IndexEventBase & {
|
|
1685
1921
|
event_type: "print";
|
|
1686
1922
|
payload: {
|
|
@@ -1689,6 +1925,7 @@ type IndexPrint = IndexEventBase & {
|
|
|
1689
1925
|
raw_value: string | null;
|
|
1690
1926
|
};
|
|
1691
1927
|
};
|
|
1928
|
+
/** A contract call made from inside another contract call. */
|
|
1692
1929
|
type IndexNestedContractCall = IndexEventBase & {
|
|
1693
1930
|
event_type: "nested_contract_call";
|
|
1694
1931
|
sender: string | null;
|
|
@@ -1697,23 +1934,27 @@ type IndexNestedContractCall = IndexEventBase & {
|
|
|
1697
1934
|
function_args: unknown;
|
|
1698
1935
|
raw_result: string | null;
|
|
1699
1936
|
};
|
|
1937
|
+
/** A contract data variable write. */
|
|
1700
1938
|
type IndexVarSet = IndexEventBase & {
|
|
1701
1939
|
event_type: "var_set";
|
|
1702
1940
|
var_name: string;
|
|
1703
1941
|
raw_value: string;
|
|
1704
1942
|
};
|
|
1943
|
+
/** A contract map entry overwrite. */
|
|
1705
1944
|
type IndexMapSet = IndexEventBase & {
|
|
1706
1945
|
event_type: "map_set";
|
|
1707
1946
|
map: string;
|
|
1708
1947
|
raw_key: string;
|
|
1709
1948
|
raw_value: string;
|
|
1710
1949
|
};
|
|
1950
|
+
/** A new contract map entry. */
|
|
1711
1951
|
type IndexMapInsert = IndexEventBase & {
|
|
1712
1952
|
event_type: "map_insert";
|
|
1713
1953
|
map: string;
|
|
1714
1954
|
raw_key: string;
|
|
1715
1955
|
raw_value: string;
|
|
1716
1956
|
};
|
|
1957
|
+
/** A contract map entry deletion. */
|
|
1717
1958
|
type IndexMapDelete = IndexEventBase & {
|
|
1718
1959
|
event_type: "map_delete";
|
|
1719
1960
|
map: string;
|
|
@@ -1730,6 +1971,7 @@ type IndexEventFields<
|
|
|
1730
1971
|
T extends IndexEventType,
|
|
1731
1972
|
F extends keyof IndexEventOf<T> & string
|
|
1732
1973
|
> = Pick<IndexEventOf<T>, (F | IndexAlwaysFields) & keyof IndexEventOf<T>>;
|
|
1974
|
+
/** One page of decoded events, with the cursor, tip, and reorgs. */
|
|
1733
1975
|
type EventsEnvelope<
|
|
1734
1976
|
T extends IndexEventType = IndexEventType,
|
|
1735
1977
|
TRow = IndexEventOf<T>
|
|
@@ -1744,6 +1986,7 @@ type EventsEnvelope<
|
|
|
1744
1986
|
type IndexEventOf<T extends IndexEventType> = Extract<IndexEvent, {
|
|
1745
1987
|
event_type: T;
|
|
1746
1988
|
}>;
|
|
1989
|
+
/** Event type, paging, and filters for listing decoded events. */
|
|
1747
1990
|
type EventsListParams<T extends IndexEventType = IndexEventType> = {
|
|
1748
1991
|
/** Decoded types or VM types (`nested_contract_call`, `map_set`, …). */
|
|
1749
1992
|
eventType: T;
|
|
@@ -1788,11 +2031,13 @@ type EventsListParams<T extends IndexEventType = IndexEventType> = {
|
|
|
1788
2031
|
*/
|
|
1789
2032
|
fields?: readonly (keyof IndexEventOf<T> & string)[];
|
|
1790
2033
|
};
|
|
2034
|
+
/** `EventsListParams` without `limit`, plus walk options. */
|
|
1791
2035
|
type EventsWalkParams<T extends IndexEventType = IndexEventType> = Omit<EventsListParams<T>, "limit"> & WalkOptions;
|
|
1792
2036
|
type EventsConsumeParams<
|
|
1793
2037
|
T extends IndexEventType = IndexEventType,
|
|
1794
2038
|
TTx = never
|
|
1795
2039
|
> = Omit<EventsListParams<T>, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexEventOf<T>, EventsEnvelope<T>, TTx>;
|
|
2040
|
+
/** A decoded contract call: contract, function, sender, arguments, result. */
|
|
1796
2041
|
type IndexContractCall = {
|
|
1797
2042
|
cursor: string;
|
|
1798
2043
|
block_height: number;
|
|
@@ -1807,12 +2052,14 @@ type IndexContractCall = {
|
|
|
1807
2052
|
result: unknown;
|
|
1808
2053
|
result_hex: string | null;
|
|
1809
2054
|
};
|
|
2055
|
+
/** One page of contract calls, with the cursor, tip, and reorgs. */
|
|
1810
2056
|
type ContractCallsEnvelope = {
|
|
1811
2057
|
contract_calls: IndexContractCall[];
|
|
1812
2058
|
next_cursor: string | null;
|
|
1813
2059
|
tip: IndexTip;
|
|
1814
2060
|
reorgs: IndexReorg[];
|
|
1815
2061
|
};
|
|
2062
|
+
/** Paging and contract filters for listing contract calls. */
|
|
1816
2063
|
type ContractCallsListParams = {
|
|
1817
2064
|
cursor?: string | null;
|
|
1818
2065
|
fromCursor?: string | null;
|
|
@@ -1828,6 +2075,7 @@ type ContractCallsListParams = {
|
|
|
1828
2075
|
* Mutually exclusive with contractId. */
|
|
1829
2076
|
trait?: string;
|
|
1830
2077
|
};
|
|
2078
|
+
/** `ContractCallsListParams` without `limit`, plus walk options. */
|
|
1831
2079
|
type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & WalkOptions;
|
|
1832
2080
|
type ContractCallsConsumeParams<TTx = never> = Omit<ContractCallsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexContractCall, ContractCallsEnvelope, TTx>;
|
|
1833
2081
|
/** One canonical block in the sync map. Lean by design — block + parent hash
|
|
@@ -1841,11 +2089,13 @@ type IndexCanonicalBlock = {
|
|
|
1841
2089
|
burn_block_height: number;
|
|
1842
2090
|
burn_block_hash: string | null;
|
|
1843
2091
|
};
|
|
2092
|
+
/** One page of canonical blocks, with the next cursor and chain tip. */
|
|
1844
2093
|
type CanonicalEnvelope = {
|
|
1845
2094
|
canonical: IndexCanonicalBlock[];
|
|
1846
2095
|
next_cursor: string | null;
|
|
1847
2096
|
tip: IndexTip;
|
|
1848
2097
|
};
|
|
2098
|
+
/** Paging and height filters for listing canonical blocks. */
|
|
1849
2099
|
type CanonicalListParams = {
|
|
1850
2100
|
cursor?: string | null;
|
|
1851
2101
|
fromCursor?: string | null;
|
|
@@ -1853,6 +2103,7 @@ type CanonicalListParams = {
|
|
|
1853
2103
|
fromHeight?: number;
|
|
1854
2104
|
toHeight?: number;
|
|
1855
2105
|
};
|
|
2106
|
+
/** `CanonicalListParams` without `limit`, plus walk options. */
|
|
1856
2107
|
type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & WalkOptions;
|
|
1857
2108
|
/** One MARF write a block committed, in the node's write order. Present only
|
|
1858
2109
|
* from the height the instance's node subscribed to `state_writes`. */
|
|
@@ -1877,12 +2128,14 @@ type IndexStateWrite = {
|
|
|
1877
2128
|
tx_contract_id?: string | null;
|
|
1878
2129
|
tx_function_name?: string | null;
|
|
1879
2130
|
};
|
|
2131
|
+
/** One page of contract state writes, with the cursor, tip, and reorgs. */
|
|
1880
2132
|
type StateWritesEnvelope = {
|
|
1881
2133
|
state_writes: IndexStateWrite[];
|
|
1882
2134
|
next_cursor: string | null;
|
|
1883
2135
|
tip: IndexTip;
|
|
1884
2136
|
reorgs: IndexReorg[];
|
|
1885
2137
|
};
|
|
2138
|
+
/** Paging and filters for listing contract state writes. */
|
|
1886
2139
|
type StateWritesListParams = {
|
|
1887
2140
|
cursor?: string | null;
|
|
1888
2141
|
fromCursor?: string | null;
|
|
@@ -1896,6 +2149,7 @@ type StateWritesListParams = {
|
|
|
1896
2149
|
/** Join the writing transaction's `tx_*` fields onto each row. */
|
|
1897
2150
|
txContext?: boolean;
|
|
1898
2151
|
};
|
|
2152
|
+
/** `StateWritesListParams` without `limit`, plus walk options. */
|
|
1899
2153
|
type StateWritesWalkParams = Omit<StateWritesListParams, "limit"> & WalkOptions;
|
|
1900
2154
|
/** A block resource. Metadata is intentionally thin — only chain-linkage and
|
|
1901
2155
|
* burn-anchor fields are persisted (no miner / tx_count / signer). */
|
|
@@ -1909,15 +2163,18 @@ type IndexBlock = {
|
|
|
1909
2163
|
block_time: string | null;
|
|
1910
2164
|
canonical: boolean;
|
|
1911
2165
|
};
|
|
2166
|
+
/** One page of blocks, with the next cursor and chain tip. */
|
|
1912
2167
|
type BlocksEnvelope = {
|
|
1913
2168
|
blocks: IndexBlock[];
|
|
1914
2169
|
next_cursor: string | null;
|
|
1915
2170
|
tip: IndexTip;
|
|
1916
2171
|
};
|
|
2172
|
+
/** One block and the chain tip. */
|
|
1917
2173
|
type BlockEnvelope = {
|
|
1918
2174
|
block: IndexBlock;
|
|
1919
2175
|
tip: IndexTip;
|
|
1920
2176
|
};
|
|
2177
|
+
/** Paging and height filters for listing blocks. */
|
|
1921
2178
|
type BlocksListParams = {
|
|
1922
2179
|
cursor?: string | null;
|
|
1923
2180
|
fromCursor?: string | null;
|
|
@@ -1925,6 +2182,7 @@ type BlocksListParams = {
|
|
|
1925
2182
|
fromHeight?: number;
|
|
1926
2183
|
toHeight?: number;
|
|
1927
2184
|
};
|
|
2185
|
+
/** `BlocksListParams` without `limit`, plus walk options. */
|
|
1928
2186
|
type BlocksWalkParams = Omit<BlocksListParams, "limit"> & WalkOptions;
|
|
1929
2187
|
type IndexPostCondition = {
|
|
1930
2188
|
type: "stx";
|
|
@@ -2001,12 +2259,14 @@ type IndexTransaction = {
|
|
|
2001
2259
|
cause: number;
|
|
2002
2260
|
};
|
|
2003
2261
|
};
|
|
2262
|
+
/** One page of transactions, with the cursor, tip, and reorgs. */
|
|
2004
2263
|
type TransactionsEnvelope<TRow = IndexTransaction> = {
|
|
2005
2264
|
transactions: TRow[];
|
|
2006
2265
|
next_cursor: string | null;
|
|
2007
2266
|
tip: IndexTip;
|
|
2008
2267
|
reorgs: IndexReorg[];
|
|
2009
2268
|
};
|
|
2269
|
+
/** One transaction and the chain tip. */
|
|
2010
2270
|
type TransactionEnvelope = {
|
|
2011
2271
|
transaction: IndexTransaction;
|
|
2012
2272
|
tip: IndexTip;
|
|
@@ -2015,6 +2275,7 @@ type TransactionEnvelope = {
|
|
|
2015
2275
|
type TransactionAlwaysFields = "cursor" | "block_height" | "tx_id";
|
|
2016
2276
|
/** A Transaction row narrowed to the requested columns plus the always-present ones. */
|
|
2017
2277
|
type TransactionFields<F extends keyof IndexTransaction & string> = Pick<IndexTransaction, (F | TransactionAlwaysFields) & keyof IndexTransaction>;
|
|
2278
|
+
/** Column selection, paging, and filters for listing transactions. */
|
|
2018
2279
|
type TransactionsListParams = {
|
|
2019
2280
|
/**
|
|
2020
2281
|
* Columns to return. The server projects the row, so an unrequested column
|
|
@@ -2031,6 +2292,7 @@ type TransactionsListParams = {
|
|
|
2031
2292
|
fromHeight?: number;
|
|
2032
2293
|
toHeight?: number;
|
|
2033
2294
|
};
|
|
2295
|
+
/** `TransactionsListParams` without `limit`, plus walk options. */
|
|
2034
2296
|
type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & WalkOptions;
|
|
2035
2297
|
/** A decoded PoX-4 stacking action (one per stacking contract call). */
|
|
2036
2298
|
type IndexStackingAction = {
|
|
@@ -2057,6 +2319,7 @@ type IndexStackingAction = {
|
|
|
2057
2319
|
signer_key: string | null;
|
|
2058
2320
|
result_ok: boolean;
|
|
2059
2321
|
};
|
|
2322
|
+
/** One page of stacking actions, with the cursor, tip, and reorgs. */
|
|
2060
2323
|
type StackingEnvelope = {
|
|
2061
2324
|
stacking: IndexStackingAction[];
|
|
2062
2325
|
next_cursor: string | null;
|
|
@@ -2065,6 +2328,7 @@ type StackingEnvelope = {
|
|
|
2065
2328
|
/** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
|
|
2066
2329
|
notes?: string;
|
|
2067
2330
|
};
|
|
2331
|
+
/** Paging and filters for listing stacking actions. */
|
|
2068
2332
|
type StackingListParams = {
|
|
2069
2333
|
cursor?: string | null;
|
|
2070
2334
|
fromCursor?: string | null;
|
|
@@ -2075,6 +2339,7 @@ type StackingListParams = {
|
|
|
2075
2339
|
fromHeight?: number;
|
|
2076
2340
|
toHeight?: number;
|
|
2077
2341
|
};
|
|
2342
|
+
/** `StackingListParams` without `limit`, plus walk options. */
|
|
2078
2343
|
type StackingWalkParams = Omit<StackingListParams, "limit"> & WalkOptions;
|
|
2079
2344
|
/** A pending (unconfirmed) transaction. Like a transaction document but
|
|
2080
2345
|
* pre-chain — no block_height/tx_index/result/events — with `received_at` and
|
|
@@ -2111,15 +2376,18 @@ type IndexMempoolTransaction = {
|
|
|
2111
2376
|
cause: number;
|
|
2112
2377
|
};
|
|
2113
2378
|
};
|
|
2379
|
+
/** One page of pending transactions, with the next cursor and chain tip. */
|
|
2114
2380
|
type MempoolEnvelope = {
|
|
2115
2381
|
mempool: IndexMempoolTransaction[];
|
|
2116
2382
|
next_cursor: string | null;
|
|
2117
2383
|
tip: IndexTip;
|
|
2118
2384
|
};
|
|
2385
|
+
/** One pending transaction and the chain tip. */
|
|
2119
2386
|
type MempoolTransactionEnvelope = {
|
|
2120
2387
|
transaction: IndexMempoolTransaction;
|
|
2121
2388
|
tip: IndexTip;
|
|
2122
2389
|
};
|
|
2390
|
+
/** Paging and sender filters for listing pending transactions. */
|
|
2123
2391
|
type MempoolListParams = {
|
|
2124
2392
|
cursor?: string | null;
|
|
2125
2393
|
fromCursor?: string | null;
|
|
@@ -2131,11 +2399,13 @@ type MempoolListParams = {
|
|
|
2131
2399
|
/** Filter to pending calls to a single function (composes with `contractId`). */
|
|
2132
2400
|
functionName?: string;
|
|
2133
2401
|
};
|
|
2402
|
+
/** `MempoolListParams` without `limit`, plus walk options. */
|
|
2134
2403
|
type MempoolWalkParams = Omit<MempoolListParams, "limit"> & WalkOptions;
|
|
2135
2404
|
/**
|
|
2136
|
-
*
|
|
2137
|
-
*
|
|
2138
|
-
*
|
|
2405
|
+
* Per-topic print payload schema for a contract, inferred from sampled events.
|
|
2406
|
+
*
|
|
2407
|
+
* `topics` is sorted by count desc; `sampled` is true when the contract has
|
|
2408
|
+
* more print events than the windows examined.
|
|
2139
2409
|
*/
|
|
2140
2410
|
type PrintSchemaResponse = {
|
|
2141
2411
|
contract_id: string;
|
|
@@ -2172,8 +2442,12 @@ type IndexSbtcDeposit = {
|
|
|
2172
2442
|
type IndexSbtcDepositDetail = IndexSbtcDeposit & {
|
|
2173
2443
|
status: "COMPLETED";
|
|
2174
2444
|
};
|
|
2175
|
-
/**
|
|
2176
|
-
*
|
|
2445
|
+
/**
|
|
2446
|
+
* A peg-out as one row per request, with its latest status.
|
|
2447
|
+
*
|
|
2448
|
+
* Collapsed to one row per `request_id`, with lifecycle `status` derived from
|
|
2449
|
+
* the latest accept/reject.
|
|
2450
|
+
*/
|
|
2177
2451
|
type IndexSbtcWithdrawal = {
|
|
2178
2452
|
cursor: string;
|
|
2179
2453
|
request_id: number;
|
|
@@ -2227,8 +2501,11 @@ type IndexSbtcWithdrawalDetail = {
|
|
|
2227
2501
|
};
|
|
2228
2502
|
finalized: boolean;
|
|
2229
2503
|
};
|
|
2230
|
-
/**
|
|
2231
|
-
*
|
|
2504
|
+
/**
|
|
2505
|
+
* A raw decoded sBTC protocol-state event, one per event.
|
|
2506
|
+
*
|
|
2507
|
+
* It is the full `sbtc_events` row, one per event across all topics.
|
|
2508
|
+
*/
|
|
2232
2509
|
type IndexSbtcEvent = {
|
|
2233
2510
|
cursor: string;
|
|
2234
2511
|
block_height: number;
|
|
@@ -2267,6 +2544,7 @@ type IndexSbtcSummary = {
|
|
|
2267
2544
|
total_locked_sats: string;
|
|
2268
2545
|
sbtc_supply_sats: string | null;
|
|
2269
2546
|
};
|
|
2547
|
+
/** One page of sBTC deposits, with the cursor, tip, and reorgs. */
|
|
2270
2548
|
type SbtcDepositsEnvelope<TRow = IndexSbtcDeposit> = {
|
|
2271
2549
|
deposits: TRow[];
|
|
2272
2550
|
next_cursor: string | null;
|
|
@@ -2275,10 +2553,12 @@ type SbtcDepositsEnvelope<TRow = IndexSbtcDeposit> = {
|
|
|
2275
2553
|
/** Present only when the sBTC decoder is disabled, explaining an empty feed. */
|
|
2276
2554
|
notes?: string;
|
|
2277
2555
|
};
|
|
2556
|
+
/** One sBTC deposit and the chain tip. */
|
|
2278
2557
|
type SbtcDepositEnvelope = {
|
|
2279
2558
|
deposit: IndexSbtcDepositDetail;
|
|
2280
2559
|
tip: IndexTip;
|
|
2281
2560
|
};
|
|
2561
|
+
/** One page of sBTC withdrawals, with the cursor, tip, and reorgs. */
|
|
2282
2562
|
type SbtcWithdrawalsEnvelope<TRow = IndexSbtcWithdrawal> = {
|
|
2283
2563
|
withdrawals: TRow[];
|
|
2284
2564
|
next_cursor: string | null;
|
|
@@ -2286,10 +2566,12 @@ type SbtcWithdrawalsEnvelope<TRow = IndexSbtcWithdrawal> = {
|
|
|
2286
2566
|
reorgs: IndexReorg[];
|
|
2287
2567
|
notes?: string;
|
|
2288
2568
|
};
|
|
2569
|
+
/** One sBTC withdrawal and the chain tip. */
|
|
2289
2570
|
type SbtcWithdrawalEnvelope = {
|
|
2290
2571
|
withdrawal: IndexSbtcWithdrawalDetail;
|
|
2291
2572
|
tip: IndexTip;
|
|
2292
2573
|
};
|
|
2574
|
+
/** One page of sBTC events, with the cursor, tip, and reorgs. */
|
|
2293
2575
|
type SbtcEventsEnvelope = {
|
|
2294
2576
|
events: IndexSbtcEvent[];
|
|
2295
2577
|
next_cursor: string | null;
|
|
@@ -2297,11 +2579,13 @@ type SbtcEventsEnvelope = {
|
|
|
2297
2579
|
reorgs: IndexReorg[];
|
|
2298
2580
|
notes?: string;
|
|
2299
2581
|
};
|
|
2582
|
+
/** The sBTC totals and the chain tip. */
|
|
2300
2583
|
type SbtcSummaryEnvelope = {
|
|
2301
2584
|
summary: IndexSbtcSummary;
|
|
2302
2585
|
tip: IndexTip;
|
|
2303
2586
|
notes?: string;
|
|
2304
2587
|
};
|
|
2588
|
+
/** Column selection, paging, and filters for listing sBTC deposits. */
|
|
2305
2589
|
type SbtcDepositsListParams = {
|
|
2306
2590
|
cursor?: string | null;
|
|
2307
2591
|
fromCursor?: string | null;
|
|
@@ -2323,11 +2607,13 @@ type SbtcDepositsListParams = {
|
|
|
2323
2607
|
type SbtcDepositAlwaysFields = "cursor" | "block_height";
|
|
2324
2608
|
/** A deposit row narrowed to the requested columns plus the always-present ones. */
|
|
2325
2609
|
type SbtcDepositFields<F extends keyof IndexSbtcDeposit & string> = Pick<IndexSbtcDeposit, (F | SbtcDepositAlwaysFields) & keyof IndexSbtcDeposit>;
|
|
2610
|
+
/** `SbtcDepositsListParams` without `limit`, plus walk options. */
|
|
2326
2611
|
type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & WalkOptions;
|
|
2327
2612
|
/** SbtcWithdrawal columns that survive any projection. */
|
|
2328
2613
|
type SbtcWithdrawalAlwaysFields = "cursor" | "request_id";
|
|
2329
2614
|
/** A SbtcWithdrawal row narrowed to the requested columns plus the always-present ones. */
|
|
2330
2615
|
type SbtcWithdrawalFields<F extends keyof IndexSbtcWithdrawal & string> = Pick<IndexSbtcWithdrawal, (F | SbtcWithdrawalAlwaysFields) & keyof IndexSbtcWithdrawal>;
|
|
2616
|
+
/** Column selection, paging, and filters for listing sBTC withdrawals. */
|
|
2331
2617
|
type SbtcWithdrawalsListParams = {
|
|
2332
2618
|
/**
|
|
2333
2619
|
* Columns to return. The server projects the row, so an unrequested column
|
|
@@ -2348,7 +2634,9 @@ type SbtcWithdrawalsListParams = {
|
|
|
2348
2634
|
fromHeight?: number;
|
|
2349
2635
|
toHeight?: number;
|
|
2350
2636
|
};
|
|
2637
|
+
/** `SbtcWithdrawalsListParams` without `limit`, plus walk options. */
|
|
2351
2638
|
type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & WalkOptions;
|
|
2639
|
+
/** Paging and filters for listing sBTC events. */
|
|
2352
2640
|
type SbtcEventsListParams = {
|
|
2353
2641
|
cursor?: string | null;
|
|
2354
2642
|
fromCursor?: string | null;
|
|
@@ -2361,6 +2649,7 @@ type SbtcEventsListParams = {
|
|
|
2361
2649
|
fromHeight?: number;
|
|
2362
2650
|
toHeight?: number;
|
|
2363
2651
|
};
|
|
2652
|
+
/** `SbtcEventsListParams` without `limit`, plus walk options. */
|
|
2364
2653
|
type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & WalkOptions;
|
|
2365
2654
|
type SbtcEventsConsumeParams<TTx = never> = Omit<SbtcEventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcEvent, SbtcEventsEnvelope, TTx>;
|
|
2366
2655
|
type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
|
|
@@ -2368,15 +2657,27 @@ type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "curs
|
|
|
2368
2657
|
* events, scoreboard). The only productized decoded sBTC peg feed on Stacks. */
|
|
2369
2658
|
interface SbtcResource {
|
|
2370
2659
|
deposits: {
|
|
2371
|
-
/**
|
|
2372
|
-
*
|
|
2660
|
+
/**
|
|
2661
|
+
* Read one page of completed sBTC deposits.
|
|
2662
|
+
*
|
|
2663
|
+
* Filter by `sender`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only deposits past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor` and `block_height` always come back.
|
|
2664
|
+
*/
|
|
2373
2665
|
list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
|
|
2374
2666
|
fields: readonly F[];
|
|
2375
2667
|
}): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
|
|
2376
2668
|
list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
|
|
2669
|
+
/**
|
|
2670
|
+
* Iterate every completed sBTC deposit, paging for you.
|
|
2671
|
+
*
|
|
2672
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2673
|
+
*/
|
|
2377
2674
|
walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
|
|
2378
|
-
/**
|
|
2379
|
-
*
|
|
2675
|
+
/**
|
|
2676
|
+
* Run a checkpointed, reorg-aware indexer over completed deposits.
|
|
2677
|
+
*
|
|
2678
|
+
* Deposits are append-only, so they are safe to mirror. See
|
|
2679
|
+
* {@link IndexConsumeOptions}.
|
|
2680
|
+
*/
|
|
2380
2681
|
consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
|
|
2381
2682
|
sink?: ConsumerSink<TTx>;
|
|
2382
2683
|
}): Promise<{
|
|
@@ -2388,21 +2689,43 @@ interface SbtcResource {
|
|
|
2388
2689
|
get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
|
|
2389
2690
|
};
|
|
2390
2691
|
withdrawals: {
|
|
2391
|
-
/**
|
|
2392
|
-
*
|
|
2692
|
+
/**
|
|
2693
|
+
* Read one page of sBTC withdrawals, each with its current status.
|
|
2694
|
+
*
|
|
2695
|
+
* Filter by `status` (`REQUESTED`, `ACCEPTED`, `REJECTED`), `sender`, `requestId`, `settlementConfirmed`, and a height range. A row changes as the peg-out moves along, which is why withdrawals have no `consume`. `fields` returns only those columns and narrows the row type; `cursor` and `request_id` always come back.
|
|
2696
|
+
*/
|
|
2393
2697
|
list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
|
|
2394
2698
|
fields: readonly F[];
|
|
2395
2699
|
}): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
|
|
2396
2700
|
list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
|
|
2701
|
+
/**
|
|
2702
|
+
* Iterate every sBTC withdrawal, paging for you.
|
|
2703
|
+
*
|
|
2704
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2705
|
+
*/
|
|
2397
2706
|
walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
|
|
2398
2707
|
/** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
|
|
2399
2708
|
get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
|
|
2400
2709
|
};
|
|
2401
2710
|
events: {
|
|
2711
|
+
/**
|
|
2712
|
+
* Read one page of the raw sBTC peg event log.
|
|
2713
|
+
*
|
|
2714
|
+
* Filter by `topic`, `sender`, `requestId`, `bitcoinTxid`, and a height range. `confirmed: true` keeps only events past the finality boundary.
|
|
2715
|
+
*/
|
|
2402
2716
|
list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
|
|
2717
|
+
/**
|
|
2718
|
+
* Iterate every sBTC peg event, paging for you.
|
|
2719
|
+
*
|
|
2720
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2721
|
+
*/
|
|
2403
2722
|
walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
|
|
2404
|
-
/**
|
|
2405
|
-
*
|
|
2723
|
+
/**
|
|
2724
|
+
* Run a checkpointed, reorg-aware indexer over the raw peg event log.
|
|
2725
|
+
*
|
|
2726
|
+
* The log is append-only across all six topics. See
|
|
2727
|
+
* {@link IndexConsumeOptions}.
|
|
2728
|
+
*/
|
|
2406
2729
|
consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
|
|
2407
2730
|
sink?: ConsumerSink<TTx>;
|
|
2408
2731
|
}): Promise<{
|
|
@@ -2411,7 +2734,11 @@ interface SbtcResource {
|
|
|
2411
2734
|
emptyPolls: number;
|
|
2412
2735
|
}>;
|
|
2413
2736
|
};
|
|
2414
|
-
/**
|
|
2737
|
+
/**
|
|
2738
|
+
* Get the all-time sBTC peg scoreboard.
|
|
2739
|
+
*
|
|
2740
|
+
* A single aggregate, with no pagination.
|
|
2741
|
+
*/
|
|
2415
2742
|
summary(): Promise<SbtcSummaryEnvelope>;
|
|
2416
2743
|
}
|
|
2417
2744
|
/** One pox-5 reward cycle, exact to the node. */
|
|
@@ -2468,6 +2795,7 @@ type IndexPoxCycleSigner = {
|
|
|
2468
2795
|
in_set: boolean;
|
|
2469
2796
|
rewards_claimed: string;
|
|
2470
2797
|
};
|
|
2798
|
+
/** One page of reward cycles, newest first, with the next cursor. */
|
|
2471
2799
|
type PoxCyclesEnvelope = {
|
|
2472
2800
|
/** The PoX version this response reports. Currently 5. */
|
|
2473
2801
|
pox_version: 5;
|
|
@@ -2476,6 +2804,7 @@ type PoxCyclesEnvelope = {
|
|
|
2476
2804
|
next_cursor: number | null;
|
|
2477
2805
|
tip: IndexTip;
|
|
2478
2806
|
};
|
|
2807
|
+
/** One reward cycle with its signers and the chain tip. */
|
|
2479
2808
|
type PoxCycleEnvelope = {
|
|
2480
2809
|
pox_version: 5;
|
|
2481
2810
|
cycle: IndexPoxCycle & {
|
|
@@ -2483,19 +2812,35 @@ type PoxCycleEnvelope = {
|
|
|
2483
2812
|
};
|
|
2484
2813
|
tip: IndexTip;
|
|
2485
2814
|
};
|
|
2815
|
+
/** Paging for listing reward cycles. */
|
|
2486
2816
|
type PoxCyclesListParams = {
|
|
2487
2817
|
/** A `reward_cycle` to page from; the page returns cycles below it (descending). */
|
|
2488
2818
|
cursor?: number | null;
|
|
2489
2819
|
limit?: number;
|
|
2490
2820
|
};
|
|
2821
|
+
/** `PoxCyclesListParams` without `limit`, plus walk options. */
|
|
2491
2822
|
type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & WalkOptions;
|
|
2492
2823
|
/** `index.pox` — reward cycles of the current PoX (PoX-5). */
|
|
2493
2824
|
interface PoxResource {
|
|
2494
2825
|
cycles: {
|
|
2826
|
+
/**
|
|
2827
|
+
* Read one page of PoX reward cycles, newest first.
|
|
2828
|
+
*
|
|
2829
|
+
* `cursor` is a `reward_cycle` number, and the page returns the cycles below it. `next_cursor` is the next cycle number to page from, or `null` at the end. This reports the current PoX (PoX-5); PoX-4 history is not served here, so read `stacking` for it.
|
|
2830
|
+
*/
|
|
2495
2831
|
list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
|
|
2832
|
+
/**
|
|
2833
|
+
* Iterate every reward cycle, paging for you.
|
|
2834
|
+
*
|
|
2835
|
+
* Takes the same filters as `list` (it pages by reward cycle number). Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2836
|
+
*/
|
|
2496
2837
|
walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
|
|
2497
|
-
/**
|
|
2498
|
-
*
|
|
2838
|
+
/**
|
|
2839
|
+
* Get one reward cycle by number, or `null`.
|
|
2840
|
+
*
|
|
2841
|
+
* Resolves to `null` on 404: an unknown cycle, or one below pox-5's first
|
|
2842
|
+
* reward cycle (141), whose PoX-4 history is final and not served here.
|
|
2843
|
+
*/
|
|
2499
2844
|
get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
|
|
2500
2845
|
};
|
|
2501
2846
|
}
|
|
@@ -2531,6 +2876,7 @@ type IndexPox5Event = {
|
|
|
2531
2876
|
/** The full decoded print tuple as JSON. */
|
|
2532
2877
|
data: unknown;
|
|
2533
2878
|
};
|
|
2879
|
+
/** One page of PoX-5 events, with the cursor, tip, and reorgs. */
|
|
2534
2880
|
type Pox5EventsEnvelope<TRow = IndexPox5Event> = {
|
|
2535
2881
|
events: TRow[];
|
|
2536
2882
|
next_cursor: string | null;
|
|
@@ -2543,6 +2889,7 @@ type Pox5EventsEnvelope<TRow = IndexPox5Event> = {
|
|
|
2543
2889
|
type Pox5EventAlwaysFields = "cursor" | "block_height" | "topic";
|
|
2544
2890
|
/** A Pox5Event row narrowed to the requested columns plus the always-present ones. */
|
|
2545
2891
|
type Pox5EventFields<F extends keyof IndexPox5Event & string> = Pick<IndexPox5Event, (F | Pox5EventAlwaysFields) & keyof IndexPox5Event>;
|
|
2892
|
+
/** Column selection, paging, and filters for listing PoX-5 events. */
|
|
2546
2893
|
type Pox5EventsListParams = {
|
|
2547
2894
|
/**
|
|
2548
2895
|
* Columns to return. The server projects the row, so an unrequested column
|
|
@@ -2564,21 +2911,34 @@ type Pox5EventsListParams = {
|
|
|
2564
2911
|
fromHeight?: number;
|
|
2565
2912
|
toHeight?: number;
|
|
2566
2913
|
};
|
|
2914
|
+
/** `Pox5EventsListParams` without `limit`, plus walk options. */
|
|
2567
2915
|
type Pox5EventsWalkParams = Omit<Pox5EventsListParams, "limit"> & WalkOptions;
|
|
2568
2916
|
type Pox5EventsConsumeParams<TTx = never> = Omit<Pox5EventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexPox5Event, Pox5EventsEnvelope, TTx>;
|
|
2569
2917
|
/** `index.pox5` — decoded PoX-5 print events, the staking primitive from the
|
|
2570
2918
|
* epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
|
|
2571
2919
|
interface Pox5Resource {
|
|
2572
2920
|
events: {
|
|
2573
|
-
/**
|
|
2574
|
-
*
|
|
2921
|
+
/**
|
|
2922
|
+
* Read one page of decoded PoX-5 staking events.
|
|
2923
|
+
*
|
|
2924
|
+
* Filter by `topic`, `staker`, `signer`, `signerManager`, `bondIndex`, `rewardCycle`, and a height range. `confirmed: true` keeps only rows past the finality boundary. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `topic` always come back.
|
|
2925
|
+
*/
|
|
2575
2926
|
list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
|
|
2576
2927
|
fields: readonly F[];
|
|
2577
2928
|
}): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
|
|
2578
2929
|
list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
|
|
2930
|
+
/**
|
|
2931
|
+
* Iterate every PoX-5 event, paging for you.
|
|
2932
|
+
*
|
|
2933
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
2934
|
+
*/
|
|
2579
2935
|
walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
|
|
2580
|
-
/**
|
|
2581
|
-
*
|
|
2936
|
+
/**
|
|
2937
|
+
* Run a checkpointed, reorg-aware indexer over PoX-5 events.
|
|
2938
|
+
*
|
|
2939
|
+
* The pox-5 print log is append-only across all 19 topics. See
|
|
2940
|
+
* {@link IndexConsumeOptions}.
|
|
2941
|
+
*/
|
|
2582
2942
|
consume<TTx = never>(params: Pox5EventsConsumeParams<TTx> & {
|
|
2583
2943
|
sink?: ConsumerSink<TTx>;
|
|
2584
2944
|
}): Promise<{
|
|
@@ -2591,11 +2951,13 @@ interface Pox5Resource {
|
|
|
2591
2951
|
/** A rune's `<block>:<tx>` id — the etch transaction's position, e.g. `840000:3`. */
|
|
2592
2952
|
type RuneId = `${number}:${number}`;
|
|
2593
2953
|
/**
|
|
2594
|
-
* A rune
|
|
2595
|
-
*
|
|
2596
|
-
* `dog.go.to.the.moon` and `doggotothemoon` all resolve
|
|
2597
|
-
*
|
|
2598
|
-
*
|
|
2954
|
+
* A rune id or name, in any case, with or without spacers.
|
|
2955
|
+
*
|
|
2956
|
+
* `DOG•GO•TO•THE•MOON`, `dog.go.to.the.moon` and `doggotothemoon` all resolve
|
|
2957
|
+
* to the same rune.
|
|
2958
|
+
*
|
|
2959
|
+
* Typing every rune name is a no: 178k runes and growing, so a generated union
|
|
2960
|
+
* would be huge and stale on day one. `list({ search })` covers discovery.
|
|
2599
2961
|
*/
|
|
2600
2962
|
type RuneRef = RuneId | (string & {});
|
|
2601
2963
|
/** The Bitcoin chain tip a Runes read was served against — a separate clock
|
|
@@ -2640,8 +3002,11 @@ type IndexRuneTerms = {
|
|
|
2640
3002
|
offset_start: string | null;
|
|
2641
3003
|
offset_end: string | null;
|
|
2642
3004
|
};
|
|
2643
|
-
/**
|
|
2644
|
-
*
|
|
3005
|
+
/**
|
|
3006
|
+
* One etched rune: identity, counters, supply, and mint terms.
|
|
3007
|
+
*
|
|
3008
|
+
* Counters cover premine, mint, and burn; supply is computed.
|
|
3009
|
+
*/
|
|
2645
3010
|
type IndexRuneEntry = IndexRuneRefSummary & {
|
|
2646
3011
|
/** Etch sequence number (u128 decimal string) — 0 is genesis. */
|
|
2647
3012
|
number: string;
|
|
@@ -2658,6 +3023,7 @@ type IndexRuneEntry = IndexRuneRefSummary & {
|
|
|
2658
3023
|
etched_tx_index: number;
|
|
2659
3024
|
terms: IndexRuneTerms | null;
|
|
2660
3025
|
};
|
|
3026
|
+
/** One page of runes, with the cursor and Bitcoin tip. */
|
|
2661
3027
|
type RunesEnvelope<TRow = IndexRuneEntry> = {
|
|
2662
3028
|
runes: TRow[];
|
|
2663
3029
|
next_cursor: string | null;
|
|
@@ -2668,6 +3034,7 @@ type RunesEnvelope<TRow = IndexRuneEntry> = {
|
|
|
2668
3034
|
/** Present only when Runes data is not configured on this instance. */
|
|
2669
3035
|
notes?: string;
|
|
2670
3036
|
};
|
|
3037
|
+
/** Name search, sort order, and paging for listing runes. */
|
|
2671
3038
|
type RunesListParams = {
|
|
2672
3039
|
/** Name prefix, spacers and case ignored (`dog` matches `DOG•GO•TO•THE•MOON`). */
|
|
2673
3040
|
search?: string;
|
|
@@ -2676,13 +3043,17 @@ type RunesListParams = {
|
|
|
2676
3043
|
cursor?: string | null;
|
|
2677
3044
|
limit?: number;
|
|
2678
3045
|
};
|
|
3046
|
+
/** One rune and the Bitcoin tip. */
|
|
2679
3047
|
type RuneEnvelope = {
|
|
2680
3048
|
rune: IndexRuneEntry;
|
|
2681
3049
|
tip: IndexBitcoinTip;
|
|
2682
3050
|
};
|
|
2683
3051
|
type IndexRuneEventKind = "rune_etch" | "rune_mint" | "rune_transfer" | "rune_burn";
|
|
2684
|
-
/**
|
|
2685
|
-
*
|
|
3052
|
+
/**
|
|
3053
|
+
* One rune etch, mint, transfer, or burn, with the rune's identity.
|
|
3054
|
+
*
|
|
3055
|
+
* The identity is embedded so an activity feed needs no second lookup to show a name.
|
|
3056
|
+
*/
|
|
2686
3057
|
type IndexRuneEvent = {
|
|
2687
3058
|
cursor: string;
|
|
2688
3059
|
block_height: number;
|
|
@@ -2697,6 +3068,7 @@ type IndexRuneEvent = {
|
|
|
2697
3068
|
address: string | null;
|
|
2698
3069
|
rune: IndexRuneRefSummary;
|
|
2699
3070
|
};
|
|
3071
|
+
/** One page of rune events, with the cursor, Bitcoin tip, and reorgs. */
|
|
2700
3072
|
type RuneActivityEnvelope<TRow = IndexRuneEvent> = {
|
|
2701
3073
|
events: TRow[];
|
|
2702
3074
|
next_cursor: string | null;
|
|
@@ -2704,6 +3076,7 @@ type RuneActivityEnvelope<TRow = IndexRuneEvent> = {
|
|
|
2704
3076
|
reorgs: IndexBtcReorg[];
|
|
2705
3077
|
notes?: string;
|
|
2706
3078
|
};
|
|
3079
|
+
/** Paging and height filters for listing rune events. */
|
|
2707
3080
|
type RuneActivityListParams = {
|
|
2708
3081
|
cursor?: string | null;
|
|
2709
3082
|
fromCursor?: string | null;
|
|
@@ -2715,6 +3088,7 @@ type RuneActivityListParams = {
|
|
|
2715
3088
|
kind?: readonly IndexRuneEventKind[];
|
|
2716
3089
|
txid?: string;
|
|
2717
3090
|
};
|
|
3091
|
+
/** `RuneActivityListParams` without `limit`, plus walk options. */
|
|
2718
3092
|
type RuneActivityWalkParams = Omit<RuneActivityListParams, "limit"> & WalkOptions;
|
|
2719
3093
|
/** A rune's balance on one unspent output, with the rune's identity embedded. */
|
|
2720
3094
|
type IndexRuneBalance = {
|
|
@@ -2726,6 +3100,7 @@ type IndexRuneBalance = {
|
|
|
2726
3100
|
/** u128 decimal string. Never `Number()`. */
|
|
2727
3101
|
amount: string;
|
|
2728
3102
|
};
|
|
3103
|
+
/** One page of rune balances, with the cursor and Bitcoin tip. */
|
|
2729
3104
|
type RuneBalancesEnvelope<TRow = IndexRuneBalance> = {
|
|
2730
3105
|
balances: TRow[];
|
|
2731
3106
|
next_cursor: string | null;
|
|
@@ -2734,8 +3109,11 @@ type RuneBalancesEnvelope<TRow = IndexRuneBalance> = {
|
|
|
2734
3109
|
reorgs: IndexBtcReorg[];
|
|
2735
3110
|
notes?: string;
|
|
2736
3111
|
};
|
|
2737
|
-
/**
|
|
2738
|
-
*
|
|
3112
|
+
/**
|
|
3113
|
+
* Rune balance filters; exactly one of `address` or `outpoint`.
|
|
3114
|
+
*
|
|
3115
|
+
* Enforced at the type level, not just at runtime.
|
|
3116
|
+
*/
|
|
2739
3117
|
type RuneBalancesListParams = ({
|
|
2740
3118
|
address: string;
|
|
2741
3119
|
outpoint?: never;
|
|
@@ -2756,14 +3134,28 @@ interface RunesResource {
|
|
|
2756
3134
|
/** The rune catalog. `search` prefix-matches the name; `sort` is etch
|
|
2757
3135
|
* order (default) or busiest-first. */
|
|
2758
3136
|
list(params?: RunesListParams): Promise<RunesEnvelope>;
|
|
2759
|
-
/**
|
|
2760
|
-
*
|
|
3137
|
+
/**
|
|
3138
|
+
* Get one rune by id or name, or `null`.
|
|
3139
|
+
*
|
|
3140
|
+
* Resolves to `null` on 404: no such rune, or Runes isn't configured on
|
|
3141
|
+
* this instance.
|
|
3142
|
+
*/
|
|
2761
3143
|
get(rune: RuneRef): Promise<RuneEnvelope | null>;
|
|
2762
3144
|
/** Current per-outpoint rune balances by address or outpoint. */
|
|
2763
3145
|
balances(params: RuneBalancesListParams): Promise<RuneBalancesEnvelope>;
|
|
2764
3146
|
/** Etch/mint/transfer/burn events, cursor `<block_height>:<event_index>`. */
|
|
2765
3147
|
activity: {
|
|
3148
|
+
/**
|
|
3149
|
+
* Read one page of Rune etch, mint, transfer, and burn events.
|
|
3150
|
+
*
|
|
3151
|
+
* Filter by `rune` (an id or a name), `address`, `kind`, `txid`, and a height range. The cursor is `<block_height>:<event_index>`, and the envelope's tip is a Bitcoin tip. `notes` says so when Runes is not configured on the instance.
|
|
3152
|
+
*/
|
|
2766
3153
|
list(params?: RuneActivityListParams): Promise<RuneActivityEnvelope>;
|
|
3154
|
+
/**
|
|
3155
|
+
* Iterate every Rune event, paging for you.
|
|
3156
|
+
*
|
|
3157
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3158
|
+
*/
|
|
2767
3159
|
walk(params?: RuneActivityWalkParams): AsyncIterable<IndexRuneEvent>;
|
|
2768
3160
|
};
|
|
2769
3161
|
}
|
|
@@ -2781,15 +3173,20 @@ interface FtTransfersResource {
|
|
|
2781
3173
|
fields: readonly F[];
|
|
2782
3174
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2783
3175
|
(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2784
|
-
/**
|
|
2785
|
-
*
|
|
3176
|
+
/**
|
|
3177
|
+
* Read one page of fungible-token transfers, plus the cursor for the next.
|
|
3178
|
+
*
|
|
3179
|
+
* Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Filters are equality only: there is no amount filter. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back. `reorgs` on the envelope lists forks that overlap the page.
|
|
3180
|
+
*/
|
|
2786
3181
|
list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
|
|
2787
3182
|
fields: readonly F[];
|
|
2788
3183
|
}): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
|
|
2789
3184
|
list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
|
|
2790
|
-
/**
|
|
2791
|
-
*
|
|
2792
|
-
*
|
|
3185
|
+
/**
|
|
3186
|
+
* Iterate every fungible-token transfer, paging for you.
|
|
3187
|
+
*
|
|
3188
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3189
|
+
*/
|
|
2793
3190
|
walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
|
|
2794
3191
|
fields: readonly F[];
|
|
2795
3192
|
}): AsyncIterable<FtTransferFields<F>>;
|
|
@@ -2803,13 +3200,20 @@ interface NftTransfersResource {
|
|
|
2803
3200
|
fields: readonly F[];
|
|
2804
3201
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2805
3202
|
(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2806
|
-
/**
|
|
2807
|
-
*
|
|
3203
|
+
/**
|
|
3204
|
+
* Read one page of NFT transfers, plus the cursor for the next.
|
|
3205
|
+
*
|
|
3206
|
+
* Filter by `contractId`, `assetIdentifier`, `sender`, `recipient`, and a height range. Pass `next_cursor` back as `cursor` to continue. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `event_type` always come back.
|
|
3207
|
+
*/
|
|
2808
3208
|
list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
|
|
2809
3209
|
fields: readonly F[];
|
|
2810
3210
|
}): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
|
|
2811
3211
|
list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
|
|
2812
|
-
/**
|
|
3212
|
+
/**
|
|
3213
|
+
* Iterate every NFT transfer, paging for you.
|
|
3214
|
+
*
|
|
3215
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3216
|
+
*/
|
|
2813
3217
|
walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
|
|
2814
3218
|
fields: readonly F[];
|
|
2815
3219
|
}): AsyncIterable<NftTransferFields<F>>;
|
|
@@ -2826,9 +3230,11 @@ interface IndexEventsResource {
|
|
|
2826
3230
|
fields: readonly F[];
|
|
2827
3231
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2828
3232
|
<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2829
|
-
/**
|
|
2830
|
-
*
|
|
2831
|
-
*
|
|
3233
|
+
/**
|
|
3234
|
+
* Read one page of decoded events of one type.
|
|
3235
|
+
*
|
|
3236
|
+
* `eventType` is required: a decoded type (`ft_transfer`, `print`, ...) or a VM type (`nested_contract_call`, `map_set`, ...), and a literal narrows the row type. Scope with `contractId` (one id or up to 20) or `trait`, never both, plus `assetIdentifier`, `sender`, `recipient`, `functionName`, `caller`, `map`, `varName`, `txId`, and a height range. `txContext: true` joins the submitting transaction onto each event. `fields` returns only those columns and narrows the row type; it saves wire bytes but does not change what you are billed, since rows are metered, not columns.
|
|
3237
|
+
*/
|
|
2832
3238
|
list<
|
|
2833
3239
|
T extends IndexEventType,
|
|
2834
3240
|
const F extends keyof IndexEventOf<T> & string
|
|
@@ -2836,9 +3242,11 @@ interface IndexEventsResource {
|
|
|
2836
3242
|
fields: readonly F[];
|
|
2837
3243
|
}): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
|
|
2838
3244
|
list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
|
|
2839
|
-
/**
|
|
2840
|
-
*
|
|
2841
|
-
*
|
|
3245
|
+
/**
|
|
3246
|
+
* Iterate every decoded event of one type, paging for you.
|
|
3247
|
+
*
|
|
3248
|
+
* Takes the same filters as `list`, including `eventType`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3249
|
+
*/
|
|
2842
3250
|
walk<
|
|
2843
3251
|
T extends IndexEventType,
|
|
2844
3252
|
const F extends keyof IndexEventOf<T> & string
|
|
@@ -2846,6 +3254,11 @@ interface IndexEventsResource {
|
|
|
2846
3254
|
fields: readonly F[];
|
|
2847
3255
|
}): AsyncIterable<IndexEventFields<T, F>>;
|
|
2848
3256
|
walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
|
|
3257
|
+
/**
|
|
3258
|
+
* Run a checkpointed, reorg-aware indexer over decoded events.
|
|
3259
|
+
*
|
|
3260
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`.
|
|
3261
|
+
*/
|
|
2849
3262
|
consume<
|
|
2850
3263
|
T extends IndexEventType,
|
|
2851
3264
|
TTx = never
|
|
@@ -2864,9 +3277,12 @@ type IndexEventTypeFilters = {
|
|
|
2864
3277
|
equality_filters?: string[];
|
|
2865
3278
|
required_non_null?: string[];
|
|
2866
3279
|
};
|
|
2867
|
-
/**
|
|
2868
|
-
*
|
|
2869
|
-
*
|
|
3280
|
+
/**
|
|
3281
|
+
* The `GET /v1/index` discovery doc: live endpoints and filter vocabulary.
|
|
3282
|
+
*
|
|
3283
|
+
* Shape is intentionally open (the server may add fields); the agent-relevant
|
|
3284
|
+
* parts are the per-type filter rules.
|
|
3285
|
+
*/
|
|
2870
3286
|
type IndexDiscovery = {
|
|
2871
3287
|
event_type_filters?: Record<string, IndexEventTypeFilters>;
|
|
2872
3288
|
[key: string]: unknown;
|
|
@@ -2874,15 +3290,19 @@ type IndexDiscovery = {
|
|
|
2874
3290
|
declare class Index extends BaseClient {
|
|
2875
3291
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
2876
3292
|
/**
|
|
2877
|
-
*
|
|
2878
|
-
*
|
|
2879
|
-
*
|
|
3293
|
+
* Get the live vocabulary of what Index can query.
|
|
3294
|
+
*
|
|
3295
|
+
* The discovery doc lists every endpoint and each event type's columns,
|
|
3296
|
+
* allowed and equality filters, and required-non-null fields. Read it to
|
|
3297
|
+
* learn what's queryable (and which types accept `trait`) instead of
|
|
3298
|
+
* hardcoding.
|
|
2880
3299
|
*/
|
|
2881
3300
|
discover(): Promise<IndexDiscovery>;
|
|
2882
3301
|
/**
|
|
2883
|
-
*
|
|
2884
|
-
*
|
|
2885
|
-
*
|
|
3302
|
+
* Get the print payload schema a contract actually emits.
|
|
3303
|
+
*
|
|
3304
|
+
* Lists the topics it emits and each field's observed Clarity, TS, and
|
|
3305
|
+
* column types. Anonymous read; resolves to `null` on 404.
|
|
2886
3306
|
*/
|
|
2887
3307
|
printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
|
|
2888
3308
|
/** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
|
|
@@ -2893,8 +3313,23 @@ declare class Index extends BaseClient {
|
|
|
2893
3313
|
* Callable: `index.events(params)` ≡ `index.events.list(params)`. */
|
|
2894
3314
|
readonly events: IndexEventsResource;
|
|
2895
3315
|
readonly contractCalls: {
|
|
3316
|
+
/**
|
|
3317
|
+
* Read one page of decoded contract calls.
|
|
3318
|
+
*
|
|
3319
|
+
* Filter by `contractId` (one id or up to 20) or `trait`, never both, plus `functionName`, `sender`, and a height range. Each row has the function name, arguments, result, and status. Pass `next_cursor` back as `cursor` to continue.
|
|
3320
|
+
*/
|
|
2896
3321
|
list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
|
|
3322
|
+
/**
|
|
3323
|
+
* Iterate every decoded contract call, paging for you.
|
|
3324
|
+
*
|
|
3325
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3326
|
+
*/
|
|
2897
3327
|
walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
|
|
3328
|
+
/**
|
|
3329
|
+
* Run a checkpointed, reorg-aware indexer over contract calls.
|
|
3330
|
+
*
|
|
3331
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same transaction; resume with `fromCursor`. Without `fromCursor` or `fromHeight` the API serves only its recent default window, so pass `fromHeight: 0` for a full backfill. A reorg at or below your checkpoint calls `onReorg`, then the loop re-reads from the fork point. Delivery is at-least-once, so keep writes idempotent. With a `sink`, the checkpoint and rollback are handled for you. `finalizedOnly` holds delivery to finalized rows, so no reorg handling is needed. `mode: "tail"` (default) keeps polling at the tip; `mode: "bounded"` returns on the first empty page. Resolves to `{ cursor, pages, emptyPolls }`. Calls already carry `sender` and `function_name`, so there is no `txContext`.
|
|
3332
|
+
*/
|
|
2898
3333
|
consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
|
|
2899
3334
|
sink?: ConsumerSink<TTx>;
|
|
2900
3335
|
}) => Promise<{
|
|
@@ -2905,49 +3340,125 @@ declare class Index extends BaseClient {
|
|
|
2905
3340
|
};
|
|
2906
3341
|
/** Canonical block-hash map — sync only the current canonical chain. */
|
|
2907
3342
|
readonly canonical: {
|
|
3343
|
+
/**
|
|
3344
|
+
* Read one page of the canonical block-hash map.
|
|
3345
|
+
*
|
|
3346
|
+
* Each row is a block's hash, its parent hash, and its burn-chain anchor. Compare it with your own tables to confirm you follow the current chain.
|
|
3347
|
+
*/
|
|
2908
3348
|
list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
|
|
3349
|
+
/**
|
|
3350
|
+
* Iterate every canonical block hash, paging for you.
|
|
3351
|
+
*
|
|
3352
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3353
|
+
*/
|
|
2909
3354
|
walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
|
|
2910
3355
|
};
|
|
2911
3356
|
/** Exact MARF writes per canonical block (`/v1/index/state-writes`). */
|
|
2912
3357
|
readonly stateWrites: {
|
|
3358
|
+
/**
|
|
3359
|
+
* Read one page of the contract-state writes each block committed.
|
|
3360
|
+
*
|
|
3361
|
+
* Rows are the exact key and value writes, in the node's write order (`ordinal`), so you can see which key a transaction changed when events alone do not show it. Filter by `blockHeight` (excludes `fromHeight` and `toHeight`) or `contractId`. `txContext: true` joins the writing transaction. Rows exist only from the height your node first subscribed to state writes.
|
|
3362
|
+
*/
|
|
2913
3363
|
list: (params?: StateWritesListParams) => Promise<StateWritesEnvelope>;
|
|
3364
|
+
/**
|
|
3365
|
+
* Iterate every state write, paging for you.
|
|
3366
|
+
*
|
|
3367
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3368
|
+
*/
|
|
2914
3369
|
walk: (params?: StateWritesWalkParams) => AsyncIterable<IndexStateWrite>;
|
|
2915
3370
|
};
|
|
2916
3371
|
/** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
|
|
2917
3372
|
* (resolves to null on 404). */
|
|
2918
3373
|
readonly blocks: {
|
|
3374
|
+
/**
|
|
3375
|
+
* Read one page of canonical blocks.
|
|
3376
|
+
*
|
|
3377
|
+
* Each block has its hash, parent hash, burn-chain anchor, and `block_time`. Filter by a height range.
|
|
3378
|
+
*/
|
|
2919
3379
|
list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
|
|
3380
|
+
/**
|
|
3381
|
+
* Iterate every canonical block, paging for you.
|
|
3382
|
+
*
|
|
3383
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3384
|
+
*/
|
|
2920
3385
|
walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
|
|
3386
|
+
/**
|
|
3387
|
+
* Get one block by height or hash, or `null`.
|
|
3388
|
+
*
|
|
3389
|
+
* Resolves to `null` when no such block exists (404).
|
|
3390
|
+
*/
|
|
2921
3391
|
get: (ref: string | number) => Promise<BlockEnvelope | null>;
|
|
2922
3392
|
};
|
|
2923
3393
|
/** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
|
|
2924
3394
|
* (resolves to null on 404). */
|
|
2925
3395
|
readonly transactions: {
|
|
2926
|
-
/**
|
|
2927
|
-
*
|
|
2928
|
-
*
|
|
2929
|
-
*
|
|
3396
|
+
/**
|
|
3397
|
+
* Read one page of full transaction documents.
|
|
3398
|
+
*
|
|
3399
|
+
* Filter by `type`, `sender`, `contractId`, and a height range. Each document has the decoded post conditions and the payload for its `tx_type`; enrichment fields are null when the raw transaction cannot be decoded. `fields` returns only those columns and narrows the row type; `cursor`, `block_height`, and `tx_id` always come back.
|
|
3400
|
+
*/
|
|
2930
3401
|
list: {
|
|
2931
3402
|
<const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
|
|
2932
3403
|
fields: readonly F[];
|
|
2933
3404
|
}): Promise<TransactionsEnvelope<TransactionFields<F>>>;
|
|
2934
3405
|
(params?: TransactionsListParams): Promise<TransactionsEnvelope>;
|
|
2935
3406
|
};
|
|
3407
|
+
/**
|
|
3408
|
+
* Iterate every transaction document, paging for you.
|
|
3409
|
+
*
|
|
3410
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3411
|
+
*/
|
|
2936
3412
|
walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
|
|
3413
|
+
/**
|
|
3414
|
+
* Get one transaction by id, or `null`.
|
|
3415
|
+
*
|
|
3416
|
+
* Resolves to `null` when the transaction is not found (404).
|
|
3417
|
+
*/
|
|
2937
3418
|
get: (txId: string) => Promise<TransactionEnvelope | null>;
|
|
3419
|
+
/**
|
|
3420
|
+
* Get a transaction's inclusion proof, or `null`.
|
|
3421
|
+
*
|
|
3422
|
+
* The proof is the raw transaction, the Nakamoto block header, and the merkle path. Check it yourself with `verifyTransactionProof`; nothing in it needs to be trusted. Resolves to `null` on 404. A 503 (`PROOF_TX_SET_INCOMPLETE` or `PROOF_NODE_UNAVAILABLE`) throws an `ApiError`: the proof cannot be assembled on this deployment right now.
|
|
3423
|
+
*/
|
|
2938
3424
|
getProof: (txId: string) => Promise<TransactionProof | null>;
|
|
2939
3425
|
};
|
|
2940
3426
|
/** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
|
|
2941
3427
|
* platform's PoX-4 decoder is disabled. */
|
|
2942
3428
|
readonly stacking: {
|
|
3429
|
+
/**
|
|
3430
|
+
* Read one page of decoded PoX-4 stacking actions.
|
|
3431
|
+
*
|
|
3432
|
+
* One row per stacking contract call. Filter by `functionName`, `stacker`, `caller`, and a height range. The feed is empty, with a `notes` hint, when the instance's PoX-4 decoder is disabled. For the current PoX, use `pox5.events` and `pox.cycles`.
|
|
3433
|
+
*/
|
|
2943
3434
|
list: (params?: StackingListParams) => Promise<StackingEnvelope>;
|
|
3435
|
+
/**
|
|
3436
|
+
* Iterate every PoX-4 stacking action, paging for you.
|
|
3437
|
+
*
|
|
3438
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3439
|
+
*/
|
|
2944
3440
|
walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
|
|
2945
3441
|
};
|
|
2946
3442
|
/** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
|
|
2947
3443
|
* tx_id (resolves to null when the tx has confirmed or dropped). */
|
|
2948
3444
|
readonly mempool: {
|
|
3445
|
+
/**
|
|
3446
|
+
* Read one page of pending, unconfirmed transactions.
|
|
3447
|
+
*
|
|
3448
|
+
* Filter by `sender`, `type`, `contractId`, and `functionName`. There is no height filter: rows carry `received_at` and a sequence cursor instead of a block position.
|
|
3449
|
+
*/
|
|
2949
3450
|
list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
|
|
3451
|
+
/**
|
|
3452
|
+
* Iterate every pending transaction, paging for you.
|
|
3453
|
+
*
|
|
3454
|
+
* Takes the same filters as `list`. Not a live index: it does not checkpoint, ignores reorgs, and ends when it catches the tip. `batchSize` defaults to 200 (max 1000); page fetches retry on 429 and 5xx; aborting `signal` rejects the iterator.
|
|
3455
|
+
*/
|
|
2950
3456
|
walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
|
|
3457
|
+
/**
|
|
3458
|
+
* Get one pending transaction, or `null`.
|
|
3459
|
+
*
|
|
3460
|
+
* Resolves to `null` once the transaction has confirmed or dropped.
|
|
3461
|
+
*/
|
|
2951
3462
|
get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
|
|
2952
3463
|
};
|
|
2953
3464
|
/** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
|
|
@@ -3022,37 +3533,93 @@ declare class Index extends BaseClient {
|
|
|
3022
3533
|
}
|
|
3023
3534
|
import { CreateWebhookRequest, CreateWebhookResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, UpdateWebhookRequest, WebhookActivity, WebhookDeliveryDetail, WebhookDetail, WebhookSummary, WebhookTestResult } from "@secondlayer/shared/schemas/webhooks";
|
|
3024
3535
|
declare class Webhooks extends BaseClient {
|
|
3536
|
+
/**
|
|
3537
|
+
* List your webhooks.
|
|
3538
|
+
*
|
|
3539
|
+
* Each summary has the status, format, URL, last delivery and last success, and the circuit breaker state (`circuitFailures`, `circuitOpenedAt`).
|
|
3540
|
+
*/
|
|
3025
3541
|
list(): Promise<{
|
|
3026
3542
|
data: WebhookSummary[];
|
|
3027
3543
|
}>;
|
|
3544
|
+
/**
|
|
3545
|
+
* Get one webhook's full configuration.
|
|
3546
|
+
*
|
|
3547
|
+
* Adds the triggers, the receiver's auth (redacted to header names and whether a secret is set), the retry and timeout limits, `lastError`, and a `warning` when this instance's trigger evaluator is not running.
|
|
3548
|
+
*/
|
|
3028
3549
|
get(id: string): Promise<WebhookDetail>;
|
|
3550
|
+
/**
|
|
3551
|
+
* Create a webhook that POSTs chain events to your URL.
|
|
3552
|
+
*
|
|
3553
|
+
* Takes a `name`, a `url`, and `triggers` built with `trigger.*`; each trigger is validated before anything is provisioned, and an invalid one is a 400. The signing secret comes back once in `signingSecret`, so store it. A webhook starts at the chain tip and never backfills: use {@link replay} for history. Hosted accounts cap `maxRetries` at 7 and `timeoutMs` at 30000.
|
|
3554
|
+
*/
|
|
3029
3555
|
create(input: CreateWebhookRequest): Promise<CreateWebhookResponse>;
|
|
3556
|
+
/**
|
|
3557
|
+
* Change a webhook's name, URL, format, auth, or delivery limits.
|
|
3558
|
+
*
|
|
3559
|
+
* Send only the fields to change: `name`, `url`, `format`, `authConfig`, `maxRetries`, `timeoutMs`, `concurrency`. Triggers are not part of an update. Resolves to the updated webhook.
|
|
3560
|
+
*/
|
|
3030
3561
|
update(id: string, patch: UpdateWebhookRequest): Promise<WebhookDetail>;
|
|
3562
|
+
/**
|
|
3563
|
+
* Stop deliveries without deleting the webhook.
|
|
3564
|
+
*
|
|
3565
|
+
* Resolves to the updated webhook. {@link resume} turns it back on.
|
|
3566
|
+
*/
|
|
3031
3567
|
pause(id: string): Promise<WebhookDetail>;
|
|
3568
|
+
/**
|
|
3569
|
+
* Start delivering again after a pause.
|
|
3570
|
+
*
|
|
3571
|
+
* Also clears a circuit-breaker pause, which happens after 20 straight failed deliveries. Resolves to the updated webhook.
|
|
3572
|
+
*/
|
|
3032
3573
|
resume(id: string): Promise<WebhookDetail>;
|
|
3574
|
+
/**
|
|
3575
|
+
* Delete a webhook.
|
|
3576
|
+
*
|
|
3577
|
+
* Resolves to `{ ok: true }`. Throws a 404 when the webhook does not exist.
|
|
3578
|
+
*/
|
|
3033
3579
|
delete(id: string): Promise<{
|
|
3034
3580
|
ok: true;
|
|
3035
3581
|
}>;
|
|
3582
|
+
/**
|
|
3583
|
+
* Issue a new signing secret.
|
|
3584
|
+
*
|
|
3585
|
+
* The new secret comes back once in `signingSecret`. Update the receiver that calls `verifyWebhookSignature` with it: deliveries are signed with the new secret from now on.
|
|
3586
|
+
*/
|
|
3036
3587
|
rotateSecret(id: string): Promise<RotateSecretResponse>;
|
|
3037
|
-
/** Send a one-off test
|
|
3038
|
-
*
|
|
3588
|
+
/** Send a one-off test delivery to a webhook's URL.
|
|
3589
|
+
*
|
|
3590
|
+
* Built for the webhook's format and SSRF-guarded. Logged as a delivery
|
|
3591
|
+
* row, visible via `deliveries`. */
|
|
3039
3592
|
test(id: string): Promise<WebhookTestResult>;
|
|
3040
3593
|
/** The last 100 delivery attempts, newest first. The server caps the window;
|
|
3041
3594
|
* there is nothing to page. */
|
|
3042
3595
|
deliveries(id: string): Promise<{
|
|
3043
3596
|
data: DeliveryRow[];
|
|
3044
3597
|
}>;
|
|
3045
|
-
/**
|
|
3046
|
-
*
|
|
3598
|
+
/** Get a webhook's hourly delivery counts for the last 7 days.
|
|
3599
|
+
*
|
|
3600
|
+
* Each hour has delivered, waiting, and gave-up counts, plus the current
|
|
3601
|
+
* queue depth. This is the events chart on the detail page. */
|
|
3047
3602
|
activity(id: string): Promise<WebhookActivity>;
|
|
3048
|
-
/**
|
|
3049
|
-
*
|
|
3603
|
+
/** Get one delivery attempt with its payload and response.
|
|
3604
|
+
*
|
|
3605
|
+
* Includes the outbox context (payload, response headers). This is the
|
|
3606
|
+
* delivery card on the detail page. */
|
|
3050
3607
|
delivery(id: string, deliveryId: string): Promise<WebhookDeliveryDetail>;
|
|
3608
|
+
/**
|
|
3609
|
+
* Re-deliver historical events over an existing webhook.
|
|
3610
|
+
*
|
|
3611
|
+
* Pass `fromBlock` and `toBlock`; the range is capped at 100,000 blocks. A replay is historical only and never moves the live cursor. It is idempotent: the same range twice is a no-op, so pass any string as `force` to re-deliver it. Replays carry `is_replay` and use the standard `chain.{type}.apply` envelope. Resolves to `replayId`, `enqueuedCount`, and `scannedCount`. A second replay while one is running is a 409. `sbtc_withdrawal_swept_confirmed` is forward-only and never replayed. Hosted accounts get 5 replays an hour.
|
|
3612
|
+
*/
|
|
3051
3613
|
replay(id: string, range: {
|
|
3052
3614
|
fromBlock: number;
|
|
3053
3615
|
toBlock: number;
|
|
3054
3616
|
force?: string;
|
|
3055
3617
|
}): Promise<ReplayResult>;
|
|
3618
|
+
/**
|
|
3619
|
+
* List the events a webhook gave up delivering.
|
|
3620
|
+
*
|
|
3621
|
+
* Returns up to 100 dead-lettered events, newest failure first. Each row's `id` is what {@link requeue} takes.
|
|
3622
|
+
*/
|
|
3056
3623
|
dead(id: string): Promise<{
|
|
3057
3624
|
data: DeadRow[];
|
|
3058
3625
|
}>;
|
|
@@ -3091,10 +3658,11 @@ interface ContextField<T> {
|
|
|
3091
3658
|
error?: ContextFieldError;
|
|
3092
3659
|
}
|
|
3093
3660
|
/**
|
|
3094
|
-
* A point-in-time orientation snapshot
|
|
3095
|
-
*
|
|
3096
|
-
*
|
|
3097
|
-
* catching up) instead of a bare
|
|
3661
|
+
* A point-in-time orientation snapshot: live tips and what this instance holds.
|
|
3662
|
+
*
|
|
3663
|
+
* Every field is a `ContextField`, so a missing value says why it is missing
|
|
3664
|
+
* (API unreachable, token rejected, index still catching up) instead of a bare
|
|
3665
|
+
* `null`. `context()` itself never throws.
|
|
3098
3666
|
*/
|
|
3099
3667
|
interface ContextSnapshot {
|
|
3100
3668
|
/** Token identity from `/api/accounts/me`. A self-hosted instance has no
|
|
@@ -3122,8 +3690,12 @@ declare class SecondLayer extends BaseClient {
|
|
|
3122
3690
|
readonly instance: InstanceClient;
|
|
3123
3691
|
constructor(options?: Partial<SecondLayerOptions>);
|
|
3124
3692
|
/**
|
|
3125
|
-
*
|
|
3126
|
-
*
|
|
3693
|
+
* Run up to 10 public reads in one round trip (`POST /v1/batch`).
|
|
3694
|
+
*
|
|
3695
|
+
* Each item is authorized on its own; the client's bearer token applies to
|
|
3696
|
+
* every item. Results come back in order as `{ path, status, body }`. Only
|
|
3697
|
+
* paths under `/v1/index/`, `/v1/subgraphs`, `/v1/streams/`, and
|
|
3698
|
+
* `/v1/contracts` are allowed; anything else is a per-item 400.
|
|
3127
3699
|
*/
|
|
3128
3700
|
batch(requests: Array<{
|
|
3129
3701
|
path: string;
|
|
@@ -3136,10 +3708,12 @@ declare class SecondLayer extends BaseClient {
|
|
|
3136
3708
|
}>;
|
|
3137
3709
|
}>;
|
|
3138
3710
|
/**
|
|
3139
|
-
*
|
|
3140
|
-
*
|
|
3141
|
-
*
|
|
3142
|
-
*
|
|
3711
|
+
* Get a one-call snapshot of your account and instance.
|
|
3712
|
+
*
|
|
3713
|
+
* Returns a {@link ContextSnapshot}: the same orientation an MCP agent reads
|
|
3714
|
+
* from `secondlayer://context`, available to any SDK or CLI consumer. Reads
|
|
3715
|
+
* run concurrently; a failed read lands as `{ value: null, error }` on its
|
|
3716
|
+
* field rather than rejecting the whole snapshot.
|
|
3143
3717
|
*/
|
|
3144
3718
|
context(): Promise<ContextSnapshot>;
|
|
3145
3719
|
}
|