@secondlayer/sdk 6.46.1 → 6.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -61,9 +61,9 @@ interface SubgraphRowsEnvelope<T = unknown> {
61
61
  rows: T[];
62
62
  next_cursor: string | null;
63
63
  tip: {
64
- block_height: number
65
- subgraph_height: number
66
- blocks_behind: number
64
+ block_height: number;
65
+ subgraph_height: number;
66
+ blocks_behind: number;
67
67
  };
68
68
  }
69
69
  interface BundleSubgraphResponse {
@@ -79,34 +79,34 @@ interface BundleSubgraphResponse {
79
79
  }
80
80
  declare class Subgraphs extends BaseClient {
81
81
  list(): Promise<{
82
- data: SubgraphSummary[]
82
+ data: SubgraphSummary[];
83
83
  }>;
84
84
  get(name: string): Promise<SubgraphDetail>;
85
85
  openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
86
86
  schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
87
87
  markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
88
88
  reindex(name: string, options?: {
89
- fromBlock?: number
90
- toBlock?: number
89
+ fromBlock?: number;
90
+ toBlock?: number;
91
91
  }): Promise<ReindexResponse>;
92
92
  stop(name: string): Promise<{
93
- message: string
94
- operationId?: string
95
- status?: string
93
+ message: string;
94
+ operationId?: string;
95
+ status?: string;
96
96
  }>;
97
97
  backfill(name: string, options: {
98
- fromBlock: number
99
- toBlock: number
98
+ fromBlock: number;
99
+ toBlock: number;
100
100
  }): Promise<ReindexResponse>;
101
101
  gaps(name: string, opts?: {
102
- limit?: number
103
- offset?: number
104
- resolved?: boolean
102
+ limit?: number;
103
+ offset?: number;
104
+ resolved?: boolean;
105
105
  }): Promise<SubgraphGapsResponse>;
106
106
  delete(name: string, options?: {
107
- force?: boolean
107
+ force?: boolean;
108
108
  }): Promise<{
109
- message: string
109
+ message: string;
110
110
  }>;
111
111
  /**
112
112
  * Publish: claim the name in the global public namespace and open anon
@@ -114,14 +114,14 @@ declare class Subgraphs extends BaseClient {
114
114
  * holds the public name.
115
115
  */
116
116
  publish(name: string): Promise<{
117
- name: string
118
- visibility: "public"
119
- url: string
117
+ name: string;
118
+ visibility: "public";
119
+ url: string;
120
120
  }>;
121
121
  /** Make reads private again (owning account's bearer key required). */
122
122
  unpublish(name: string): Promise<{
123
- name: string
124
- visibility: "private"
123
+ name: string;
124
+ visibility: "private";
125
125
  }>;
126
126
  /**
127
127
  * Open /v1 read: cursor-paginated rows. Anon works for public subgraphs;
@@ -129,11 +129,11 @@ declare class Subgraphs extends BaseClient {
129
129
  * `next_cursor`.
130
130
  */
131
131
  rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset" | "sort"> & {
132
- cursor?: string
132
+ cursor?: string;
133
133
  }): Promise<SubgraphRowsEnvelope<T>>;
134
134
  /** Recent reindex/backfill operations for a subgraph, newest first. */
135
135
  operations(name: string): Promise<{
136
- operations: SubgraphOperationStatus[]
136
+ operations: SubgraphOperationStatus[];
137
137
  }>;
138
138
  /** Status of a single operation (poll the `operationId` returned by
139
139
  * reindex/backfill/stop until `status` is terminal). */
@@ -145,11 +145,11 @@ declare class Subgraphs extends BaseClient {
145
145
  * authoring loop so Vercel's serverless runtime doesn't have to run esbuild.
146
146
  */
147
147
  bundle(data: {
148
- code: string
148
+ code: string;
149
149
  }): Promise<BundleSubgraphResponse>;
150
150
  queryTable(name: string, table: string, params?: SubgraphQueryParams): Promise<unknown[]>;
151
151
  queryTableCount(name: string, table: string, params?: SubgraphQueryParams): Promise<{
152
- count: number
152
+ count: number;
153
153
  }>;
154
154
  queryTableAggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
155
155
  /**
@@ -165,8 +165,8 @@ declare class Subgraphs extends BaseClient {
165
165
  * ```
166
166
  */
167
167
  typed<T extends {
168
- name: string
169
- schema: Record<string, unknown>
168
+ name: string;
169
+ schema: Record<string, unknown>;
170
170
  }>(def: T): InferSubgraphClient<T>;
171
171
  private createTableClient;
172
172
  }
@@ -221,12 +221,12 @@ declare class ApiKeys extends BaseClient {
221
221
  * account-level (owner) key or a dashboard session.
222
222
  */
223
223
  list(): Promise<{
224
- keys: ApiKeySummary[]
224
+ keys: ApiKeySummary[];
225
225
  }>;
226
226
  /** Revoke a key by id. Existing requests with that key stop working. */
227
227
  revoke(id: string): Promise<{
228
- revoked: true
229
- id: string
228
+ revoked: true;
229
+ id: string;
230
230
  }>;
231
231
  }
232
232
  /**
@@ -274,7 +274,7 @@ declare class Contracts extends BaseClient {
274
274
  * Pass `{ includeAbi: true }` for the full ABI blob. Resolves null on 404.
275
275
  */
276
276
  get(contractId: string, opts?: {
277
- includeAbi?: boolean
277
+ includeAbi?: boolean;
278
278
  }): Promise<ContractSummary | null>;
279
279
  }
280
280
  import { Pox5EventTopic } from "@secondlayer/stacks/pox5";
@@ -312,8 +312,8 @@ interface TransactionProof {
312
312
  /** Present when consensus-level verification is available: the reward cycle and
313
313
  * its signer set, against which the header's signer signatures are checked. */
314
314
  consensus?: {
315
- reward_cycle: number
316
- reward_set: RewardSet
315
+ reward_cycle: number;
316
+ reward_set: RewardSet;
317
317
  };
318
318
  }
319
319
  /**
@@ -331,12 +331,83 @@ interface TransactionProof {
331
331
  * The interface is dependency-free on purpose: implementations with real
332
332
  * database drivers live behind subpath exports (`@secondlayer/sdk/sinks/*`)
333
333
  * so the root entry ships no DB dependency.
334
+ *
335
+ * ## The contract
336
+ *
337
+ * Binding on every implementation; the conformance kit
338
+ * (`@secondlayer/sdk/sinks/testing`) probes each one. Violations are SILENT
339
+ * in production — they surface as gaps or duplicates weeks later, never as
340
+ * errors at the violation site — which is why they are spelled out here and
341
+ * mechanically tested.
342
+ *
343
+ * What the loop guarantees the sink:
344
+ *
345
+ * 1. **Init-before-first-page.** `loadCursor` is called exactly once, before
346
+ * the first fetch — even when the caller passed an explicit `fromCursor`.
347
+ * It is the sink's init hook: create checkpoint storage, validate
348
+ * rollback preconditions.
349
+ * 2. **Deterministic replay.** Re-reading from the same cursor yields the
350
+ * same rows in the same order. `cursor` is therefore a valid idempotency
351
+ * key: an append-only sink can dedup on it with no contract change.
352
+ * 3. **At-least-once delivery.** A batch whose commit outcome was lost (crash
353
+ * after commit, before the loop observed it) is re-committed on restart
354
+ * with the SAME cursor and the same rows.
355
+ *
356
+ * What the sink must guarantee — `commitBatch`:
357
+ *
358
+ * 4. **Rows+cursor atomicity.** The handler's writes and `cursor` commit in
359
+ * ONE transaction. Committing them separately is the classic torn-batch
360
+ * bug: a crash between the two either re-delivers (duplicates) or skips
361
+ * (gap) depending on the order.
362
+ * 5. **Abort on throw.** A throw from `write` aborts the WHOLE transaction —
363
+ * neither rows nor cursor land — so a crashed batch is simply re-read.
364
+ * 6. **The lent transaction is the real one.** `write(tx)` receives the same
365
+ * live transaction the cursor commits in; every handler write must go
366
+ * through it. Writes outside `tx` escape atomicity AND rollback.
367
+ * 7. **Replay safety.** Committing the same cursor twice must not corrupt
368
+ * state (per #3 the rows are identical; upsert/dedup make it exact).
369
+ *
370
+ * What the sink must guarantee — `rollback`:
371
+ *
372
+ * 8. **Delete+rewind atomicity.** Undoing rows at/above the fork and
373
+ * committing `rewindCursor` happen in ONE transaction. A crash between
374
+ * them resumes above the fork and the deleted range is never re-read —
375
+ * the silent-gap bug.
376
+ * 9. **Inclusive fork point.** Undo AT OR ABOVE `forkPointHeight` (`>=`) —
377
+ * the new canonical chain re-supplies the fork block itself.
378
+ * 10. **Idempotent.** The loop may re-apply the same rollback after a crash
379
+ * (reorgs are deduped in memory only); a second application must be a
380
+ * harmless no-op.
381
+ * 11. **Scope by height, not cursor.** On a page reporting several forks the
382
+ * loop calls `rollback` once per fork: each call carries its own
383
+ * `forkPointHeight` but ALL carry the same `rewindCursor` (the lowest
384
+ * fork point). Derive the undo range from `forkPointHeight` only; a
385
+ * sink that derives it from `rewindCursor` under-deletes silently.
386
+ *
387
+ * Error semantics and concurrency:
388
+ *
389
+ * 12. **Throw, don't swallow; no internal retry.** The loop owns retry
390
+ * policy. A swallowed commit error advances the loop past unwritten
391
+ * data; an internal retry can double-apply around a partial failure.
392
+ * 13. **Single writer per checkpoint id.** The loop assumes one live
393
+ * consumer per checkpoint identity. A sink that can detect a second
394
+ * writer (e.g. a lock) must fail loudly — never block or interleave.
334
395
  */
335
396
  interface ConsumerSink<Tx = unknown> {
336
397
  /** Phantom marker carrying `Tx` in a directly-inferable position, so the
337
398
  * consume loops' `TTx` type parameter resolves from the `sink` option
338
399
  * (never set at runtime). */
339
400
  readonly _tx?: Tx;
401
+ /** Static capabilities, read by the loop before the first fetch to fail
402
+ * fast on impossible pairings. */
403
+ readonly capabilities?: {
404
+ /** This sink cannot undo committed rows (append-only store, ClickHouse,
405
+ * parquet, …), so `rollback` is unimplementable and following the
406
+ * unfinalized tip would corrupt it on the first fork. The loop throws
407
+ * loudly unless consuming with `finalizedOnly: true` — in that mode
408
+ * reorgs never reach the sink and `rollback` may simply throw. */
409
+ finalizedOnly?: boolean;
410
+ };
340
411
  /** The committed checkpoint, or `null` on first run. Called once, before
341
412
  * the first page. Implementations may create their checkpoint storage
342
413
  * here and SHOULD validate their rollback preconditions (e.g. that every
@@ -356,6 +427,11 @@ interface ConsumerSink<Tx = unknown> {
356
427
  * without the rewound cursor is the classic silent-gap bug: a crash
357
428
  * between the two writes resumes above the fork and the deleted range is
358
429
  * never re-read.
430
+ *
431
+ * On a multi-fork page this is called once PER fork, every call with the
432
+ * same `rewindCursor` (the lowest fork point) but its own
433
+ * `forkPointHeight` — scope the undo by `forkPointHeight` only (contract
434
+ * invariant #11), and expect re-application after a crash (#10).
359
435
  */
360
436
  rollback(forkPointHeight: number, rewindCursor: string): Promise<void>;
361
437
  }
@@ -363,75 +439,75 @@ interface ConsumerSink<Tx = unknown> {
363
439
  * is unchanged (an intersection with `unknown` is an identity, so
364
440
  * contextual typing of `onBatch` callbacks never degrades to a union). */
365
441
  type WithSinkTx<TTx> = [TTx] extends [never] ? unknown : {
366
- tx: TTx
442
+ tx: TTx;
367
443
  };
368
444
  import { StreamsEventType } from "@secondlayer/shared";
369
445
  /** A Clarity value as Streams serves it: the canonical hex string, a typed
370
446
  * object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
371
447
  * Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
372
448
  type StreamsClarityValue = string | {
373
- hex: string
449
+ hex: string;
374
450
  } | Record<string, unknown>;
375
451
  type StxTransferPayload = {
376
- sender: string
377
- recipient: string
378
- amount: string
379
- memo?: string
452
+ sender: string;
453
+ recipient: string;
454
+ amount: string;
455
+ memo?: string;
380
456
  };
381
457
  type StxMintPayload = {
382
- recipient: string
383
- amount: string
458
+ recipient: string;
459
+ amount: string;
384
460
  };
385
461
  type StxBurnPayload = {
386
- sender: string
387
- amount: string
462
+ sender: string;
463
+ amount: string;
388
464
  };
389
465
  type StxLockPayload = {
390
- locked_address: string
391
- locked_amount: string
392
- unlock_height: string
466
+ locked_address: string;
467
+ locked_amount: string;
468
+ unlock_height: string;
393
469
  };
394
470
  type FtTransferPayload = {
395
- asset_identifier: string
396
- sender: string
397
- recipient: string
398
- amount: string
471
+ asset_identifier: string;
472
+ sender: string;
473
+ recipient: string;
474
+ amount: string;
399
475
  };
400
476
  type FtMintPayload = {
401
- asset_identifier: string
402
- recipient: string
403
- amount: string
477
+ asset_identifier: string;
478
+ recipient: string;
479
+ amount: string;
404
480
  };
405
481
  type FtBurnPayload = {
406
- asset_identifier: string
407
- sender: string
408
- amount: string
482
+ asset_identifier: string;
483
+ sender: string;
484
+ amount: string;
409
485
  };
410
486
  type NftTransferPayload = {
411
- asset_identifier: string
412
- sender: string
413
- recipient: string
414
- value: StreamsClarityValue
487
+ asset_identifier: string;
488
+ sender: string;
489
+ recipient: string;
490
+ value: StreamsClarityValue;
415
491
  /** Canonical serialized hex of `value`, when the stream carries it. */
416
- raw_value?: string
492
+ raw_value?: string;
417
493
  };
418
494
  type NftMintPayload = {
419
- asset_identifier: string
420
- recipient: string
421
- value: StreamsClarityValue
422
- raw_value?: string
495
+ asset_identifier: string;
496
+ recipient: string;
497
+ value: StreamsClarityValue;
498
+ raw_value?: string;
423
499
  };
424
500
  type NftBurnPayload = {
425
- asset_identifier: string
426
- sender: string
427
- value: StreamsClarityValue
428
- raw_value?: string
501
+ asset_identifier: string;
502
+ sender: string;
503
+ value: StreamsClarityValue;
504
+ raw_value?: string;
429
505
  };
430
506
  type PrintPayload = {
431
- contract_id?: string | null
432
- topic?: string
433
- value?: unknown
434
- raw_value?: string
507
+ contract_id?: string | null;
508
+ topic?: string;
509
+ value?: unknown;
510
+ raw_value?: string;
435
511
  };
436
512
  type StreamsEventBase = {
437
513
  /**
@@ -439,92 +515,97 @@ type StreamsEventBase = {
439
515
  * it as the primary key of your projection rows — replaying a batch then
440
516
  * upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
441
517
  */
442
- cursor: string
443
- block_height: number
444
- block_hash: string
445
- burn_block_height: number
446
- tx_id: string
447
- tx_index: number
448
- event_index: number
449
- contract_id: string | null
450
- ts: string
518
+ cursor: string;
519
+ block_height: number;
520
+ block_hash: string;
521
+ burn_block_height: number;
522
+ tx_id: string;
523
+ tx_index: number;
524
+ event_index: number;
525
+ contract_id: string | null;
526
+ ts: string;
451
527
  /**
452
528
  * True when this event's block is past the finality boundary (immutable).
453
529
  * Optional for back-compat; the API always sets it on Streams responses.
454
530
  */
455
- finalized?: boolean
531
+ finalized?: boolean;
456
532
  /**
457
533
  * Labels whose filter group this event satisfied, present only when the
458
534
  * request used a labelled `filters` map. The SDK dispatches on it for you
459
535
  * (`on.<label>`), so handlers rarely read it directly.
460
536
  */
461
- matched?: string[]
537
+ matched?: string[];
462
538
  };
463
539
  type StreamsEventOf<
464
540
  T extends StreamsEventType,
465
541
  P
466
542
  > = StreamsEventBase & {
467
- event_type: T
468
- payload: P
543
+ event_type: T;
544
+ payload: P;
469
545
  };
470
546
  /** A raw Streams event. Discriminated on `event_type`, so `event.payload`
471
547
  * narrows to the matching payload shape once the type is checked. */
472
548
  type StreamsEvent = StreamsEventOf<"stx_transfer", StxTransferPayload> | StreamsEventOf<"stx_mint", StxMintPayload> | StreamsEventOf<"stx_burn", StxBurnPayload> | StreamsEventOf<"stx_lock", StxLockPayload> | StreamsEventOf<"ft_transfer", FtTransferPayload> | StreamsEventOf<"ft_mint", FtMintPayload> | StreamsEventOf<"ft_burn", FtBurnPayload> | StreamsEventOf<"nft_transfer", NftTransferPayload> | StreamsEventOf<"nft_mint", NftMintPayload> | StreamsEventOf<"nft_burn", NftBurnPayload> | StreamsEventOf<"print", PrintPayload>;
473
549
  type StreamsTip = {
474
- block_height: number
475
- block_hash: string
476
- burn_block_height: number
550
+ block_height: number;
551
+ block_hash: string;
552
+ burn_block_height: number;
477
553
  /**
478
554
  * Highest Stacks block past the burn-confirmation finality boundary.
479
555
  * Optional for back-compat; the API always sets it.
480
556
  */
481
- finalized_height?: number
482
- lag_seconds: number
557
+ finalized_height?: number;
558
+ lag_seconds: number;
483
559
  /**
484
560
  * Oldest height still seekable on the live API for the caller's tier
485
561
  * (`tip - retention`). `null` = unlimited retention. Older reads must use the
486
562
  * cold dumps lane. Optional for back-compat.
487
563
  */
488
- oldest_seekable_height?: number | null
564
+ oldest_seekable_height?: number | null;
489
565
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
490
- oldest_cursor?: string | null
566
+ oldest_cursor?: string | null;
491
567
  };
492
568
  type StreamsCanonicalBlock = {
493
- block_height: number
494
- block_hash: string
495
- burn_block_height: number
496
- burn_block_hash: string | null
497
- is_canonical: true
569
+ block_height: number;
570
+ block_hash: string;
571
+ burn_block_height: number;
572
+ burn_block_hash: string | null;
573
+ is_canonical: true;
498
574
  };
499
575
  type StreamsReorg = {
500
- detected_at: string
501
- fork_point_height: number
576
+ detected_at: string;
577
+ fork_point_height: number;
502
578
  orphaned_range: {
503
- from: string
504
- to: string
505
- }
579
+ from: string;
580
+ to: string;
581
+ };
506
582
  /**
507
583
  * First position of the new canonical chain at the fork, `fork:0`
508
584
  * (INCLUSIVE). Not an exclusive resume token — resuming directly from it
509
585
  * skips `fork:0`. The consumer rewinds to the foot of `fork_point_height`
510
586
  * (`Cursor.atHeight`) to re-read the new run from `fork:0` inclusive.
511
587
  */
512
- new_canonical_tip: string
588
+ new_canonical_tip: string;
513
589
  };
514
- type StreamsEventsEnvelope = {
515
- events: StreamsEvent[]
516
- next_cursor: string | null
517
- tip: StreamsTip
518
- reorgs: StreamsReorg[]
590
+ type StreamsEventsEnvelope<TEvent = StreamsEvent> = {
591
+ events: TEvent[];
592
+ next_cursor: string | null;
593
+ tip: StreamsTip;
594
+ reorgs: StreamsReorg[];
519
595
  };
520
596
  type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
597
+ /** The StreamsEvent union narrowed to a `types` selection — what a
598
+ * const-generic `types: ["ft_transfer"]` buys at the type level. */
599
+ type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
600
+ event_type: T[number];
601
+ }>;
521
602
  type StreamsReorgsListParams = {
522
- since: string
523
- limit?: number
603
+ since: string;
604
+ limit?: number;
524
605
  };
525
606
  type StreamsReorgsListEnvelope = {
526
- reorgs: StreamsReorg[]
527
- next_since: string | null
607
+ reorgs: StreamsReorg[];
608
+ next_since: string | null;
528
609
  };
529
610
  /** A filter that matches a single value or any value in a list. */
530
611
  type StreamsFilterValue = string | readonly string[];
@@ -533,11 +614,11 @@ type StreamsFilterValue = string | readonly string[];
533
614
  * map OR together server-side.
534
615
  */
535
616
  type StreamsLabelledFilter = {
536
- types?: readonly StreamsEventType[]
537
- contractId?: StreamsFilterValue
538
- sender?: StreamsFilterValue
539
- recipient?: StreamsFilterValue
540
- assetIdentifier?: string
617
+ types?: readonly StreamsEventType[];
618
+ contractId?: StreamsFilterValue;
619
+ sender?: StreamsFilterValue;
620
+ recipient?: StreamsFilterValue;
621
+ assetIdentifier?: string;
541
622
  };
542
623
  /** A map of label → filter group. Labels are yours; the server echoes them. */
543
624
  type StreamsFilterMap = Record<string, StreamsLabelledFilter>;
@@ -550,65 +631,65 @@ type StreamsEventForFilter<
550
631
  F,
551
632
  D extends boolean = false
552
633
  > = F extends {
553
- types: readonly (infer T extends StreamsEventType)[]
634
+ types: readonly (infer T extends StreamsEventType)[];
554
635
  } ? D extends true ? Extract<IndexEvent, {
555
- event_type: T
636
+ event_type: T;
556
637
  }> : Extract<StreamsEvent, {
557
- event_type: T
638
+ event_type: T;
558
639
  }> : D extends true ? IndexEvent : StreamsEvent;
559
640
  type StreamsEventsListParams = {
560
- cursor?: string | null
561
- fromHeight?: number
562
- toHeight?: number
563
- types?: readonly StreamsEventType[]
641
+ cursor?: string | null;
642
+ fromHeight?: number;
643
+ toHeight?: number;
644
+ types?: readonly StreamsEventType[];
564
645
  /** Event types to exclude (applied after `types`). */
565
- notTypes?: readonly StreamsEventType[]
566
- contractId?: StreamsFilterValue
567
- sender?: StreamsFilterValue
568
- recipient?: StreamsFilterValue
569
- assetIdentifier?: string
646
+ notTypes?: readonly StreamsEventType[];
647
+ contractId?: StreamsFilterValue;
648
+ sender?: StreamsFilterValue;
649
+ recipient?: StreamsFilterValue;
650
+ assetIdentifier?: string;
570
651
  /**
571
652
  * Labelled filter groups. The groups OR together in one scan and each
572
653
  * returned event carries the labels it matched (`event.matched`) — two
573
654
  * unrelated concerns share one page, one cursor, one checkpoint.
574
655
  */
575
- filters?: StreamsFilterMap
576
- limit?: number
656
+ filters?: StreamsFilterMap;
657
+ limit?: number;
577
658
  };
578
659
  type StreamsEventsStreamParams = {
579
- fromCursor?: string | null
580
- types?: readonly StreamsEventType[]
581
- notTypes?: readonly StreamsEventType[]
582
- contractId?: StreamsFilterValue
583
- sender?: StreamsFilterValue
584
- recipient?: StreamsFilterValue
585
- assetIdentifier?: string
660
+ fromCursor?: string | null;
661
+ types?: readonly StreamsEventType[];
662
+ notTypes?: readonly StreamsEventType[];
663
+ contractId?: StreamsFilterValue;
664
+ sender?: StreamsFilterValue;
665
+ recipient?: StreamsFilterValue;
666
+ assetIdentifier?: string;
586
667
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
587
- filters?: StreamsFilterMap
588
- batchSize?: number
589
- emptyBackoffMs?: number
590
- maxPages?: number
591
- maxEmptyPolls?: number
592
- signal?: AbortSignal
668
+ filters?: StreamsFilterMap;
669
+ batchSize?: number;
670
+ emptyBackoffMs?: number;
671
+ maxPages?: number;
672
+ maxEmptyPolls?: number;
673
+ signal?: AbortSignal;
593
674
  };
594
675
  type StreamsEventsSubscribeParams = {
595
676
  /** Resume strictly after this cursor; omit to live-tail from the tip. */
596
- fromCursor?: string | null
597
- types?: readonly StreamsEventType[]
598
- notTypes?: readonly StreamsEventType[]
599
- contractId?: StreamsFilterValue
600
- sender?: StreamsFilterValue
601
- recipient?: StreamsFilterValue
602
- assetIdentifier?: string
677
+ fromCursor?: string | null;
678
+ types?: readonly StreamsEventType[];
679
+ notTypes?: readonly StreamsEventType[];
680
+ contractId?: StreamsFilterValue;
681
+ sender?: StreamsFilterValue;
682
+ recipient?: StreamsFilterValue;
683
+ assetIdentifier?: string;
603
684
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
604
- filters?: StreamsFilterMap
685
+ filters?: StreamsFilterMap;
605
686
  /** Abort to unsubscribe (the returned function does the same). */
606
- signal?: AbortSignal
687
+ signal?: AbortSignal;
607
688
  /** Called for each pushed event, in order. */
608
- onEvent: (event: StreamsEvent) => void | Promise<void>
689
+ onEvent: (event: StreamsEvent) => void | Promise<void>;
609
690
  /** Called on a connection error; the subscription auto-reconnects from the
610
691
  * last delivered cursor unless the signal has aborted. */
611
- onError?: (err: unknown) => void
692
+ onError?: (err: unknown) => void;
612
693
  };
613
694
  /**
614
695
  * The checkpoint the SDK computes for a batch. Persist `cursor` inside the same
@@ -635,14 +716,14 @@ type ConsumerBatchContext<
635
716
  TReorg = unknown
636
717
  > = {
637
718
  /** Checkpoint to commit alongside your rows. */
638
- cursor: string | null
719
+ cursor: string | null;
639
720
  /** Highest canonical block the sweep has reached. `null` before the first
640
721
  * row of a fresh consume. */
641
- height: number | null
722
+ height: number | null;
642
723
  /** Chain tip as of this page's read. */
643
- tipHeight: number
724
+ tipHeight: number;
644
725
  /** `tipHeight - height`, floored at 0. `null` until `height` is known. */
645
- blocksBehind: number | null
726
+ blocksBehind: number | null;
646
727
  /**
647
728
  * The full tip for this page — `StreamsTip` or `IndexTip` depending on the
648
729
  * surface. Exposed here so a handler never needs the `envelope` parameter,
@@ -650,12 +731,12 @@ type ConsumerBatchContext<
650
731
  * `finalizedOnly` mistake becomes reachable (`return envelope.next_cursor`
651
732
  * jumps the cursor past events that were filtered out and never delivered).
652
733
  */
653
- tip: TTip
734
+ tip: TTip;
654
735
  /**
655
736
  * Reorgs reported alongside this page; empty when none. Rollback still
656
737
  * belongs in `onReorg` — this is for observability inside a batch.
657
738
  */
658
- reorgs: readonly TReorg[]
739
+ reorgs: readonly TReorg[];
659
740
  };
660
741
  /** @deprecated Use {@link ConsumerBatchContext} — the Index and Streams loops
661
742
  * share one shape now. Kept as an alias so existing annotations compile. */
@@ -665,20 +746,20 @@ type StreamsBatchContext = ConsumerBatchContext;
665
746
  * inside the same transaction as your rollback so the two commit atomically.
666
747
  */
667
748
  type StreamsReorgContext = {
668
- cursor: string
749
+ cursor: string;
669
750
  };
670
751
  type StreamsEventsConsumeParams<
671
752
  TTx = never,
672
753
  D extends boolean = false,
673
754
  F extends StreamsFilterMap = Record<never, never>
674
755
  > = {
675
- fromCursor?: string | null
756
+ fromCursor?: string | null;
676
757
  /**
677
758
  * Deliver events pre-decoded as the flat, `event_type`-discriminated rows
678
759
  * Index serves (`IndexEvent`), so Streams consumption reads identically
679
760
  * to Index consumption — no guard+decode pairs in your handler.
680
761
  */
681
- decoded?: D
762
+ decoded?: D;
682
763
  /**
683
764
  * Destination adapter that owns the checkpoint + rollback transaction
684
765
  * (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
@@ -687,29 +768,29 @@ type StreamsEventsConsumeParams<
687
768
  * transaction), reorg rollback is automatic, and `onBatch`'s return value
688
769
  * is ignored.
689
770
  */
690
- sink?: ConsumerSink<TTx>
771
+ sink?: ConsumerSink<TTx>;
691
772
  /** Fires once per page, before `onBatch` and before any early return. */
692
- onProgress?: (ctx: ConsumerBatchContext) => void
693
- mode?: "tail" | "bounded"
773
+ onProgress?: (ctx: ConsumerBatchContext) => void;
774
+ mode?: "tail" | "bounded";
694
775
  /**
695
776
  * Emit only finalized (immutable) events and never surface reorgs. The SDK
696
777
  * checkpoints at the last finalized event and re-reads the unfinalized tail
697
778
  * until it settles. Trades finality lag for zero reorg handling; `onReorg` is
698
779
  * ignored.
699
780
  */
700
- finalizedOnly?: boolean
701
- types?: readonly StreamsEventType[]
702
- notTypes?: readonly StreamsEventType[]
703
- contractId?: StreamsFilterValue
704
- sender?: StreamsFilterValue
705
- recipient?: StreamsFilterValue
706
- assetIdentifier?: string
781
+ finalizedOnly?: boolean;
782
+ types?: readonly StreamsEventType[];
783
+ notTypes?: readonly StreamsEventType[];
784
+ contractId?: StreamsFilterValue;
785
+ sender?: StreamsFilterValue;
786
+ recipient?: StreamsFilterValue;
787
+ assetIdentifier?: string;
707
788
  /**
708
789
  * Labelled filter groups. The groups OR together in ONE server-side scan,
709
790
  * so two unrelated concerns share one page, one cursor, and one checkpoint
710
791
  * instead of two consume loops. Pair with `on` to handle each label.
711
792
  */
712
- filters?: F
793
+ filters?: F;
713
794
  /**
714
795
  * One handler per label in `filters`. Every label must be handled, so
715
796
  * adding a label is a compile error until its handler exists.
@@ -720,8 +801,8 @@ type StreamsEventsConsumeParams<
720
801
  * labels do not interleave within a page — add `onBatch` when you need
721
802
  * strict global order across labels.
722
803
  */
723
- on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> }
724
- batchSize?: number
804
+ on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> };
805
+ batchSize?: number;
725
806
  /**
726
807
  * Apply a page of canonical events. Persist `ctx.cursor` in the same
727
808
  * transaction as your writes. Returning a cursor overrides `ctx.cursor` as
@@ -730,7 +811,7 @@ type StreamsEventsConsumeParams<
730
811
  * Optional only when `on` handles the page instead; a consume call with
731
812
  * neither throws.
732
813
  */
733
- onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
814
+ onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
734
815
  /**
735
816
  * Roll your projection back to `reorg.fork_point_height`, persisting
736
817
  * `ctx.cursor` in the same transaction. Called once per *new* reorg
@@ -738,126 +819,136 @@ type StreamsEventsConsumeParams<
738
819
  * now-canonical events. Omit it to ignore reorgs (events stay canonical, but
739
820
  * stale rows from an orphaned fork are left in place).
740
821
  */
741
- onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
822
+ onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
742
823
  /** Page-fetch retries after the first failure (429/5xx/network only —
743
824
  * 4xx and handler throws always propagate). Default 3; `0` disables. */
744
- retryCount?: number
825
+ retryCount?: number;
745
826
  /** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
746
827
  * `Retry-After` overrides it. Default 1000. */
747
- retryDelay?: number
828
+ retryDelay?: number;
748
829
  /** Void observer, called before each retry sleep (metrics/logging). */
749
830
  onError?: (err: unknown, ctx: {
750
- attempt: number
751
- retriesLeft: number
752
- delayMs: number
753
- }) => void
754
- emptyBackoffMs?: number
755
- maxPages?: number
756
- maxEmptyPolls?: number
757
- signal?: AbortSignal
831
+ attempt: number;
832
+ retriesLeft: number;
833
+ delayMs: number;
834
+ }) => void;
835
+ emptyBackoffMs?: number;
836
+ maxPages?: number;
837
+ maxEmptyPolls?: number;
838
+ signal?: AbortSignal;
758
839
  };
759
840
  /**
760
841
  * One yielded page from {@link StreamsClient.consume} — the
761
842
  * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
762
843
  * `cursor` (the checkpoint to persist and resume from).
763
844
  */
764
- type StreamsBatch = {
845
+ type StreamsBatch<TEvent = StreamsEvent> = {
765
846
  /** Canonical events of this page, in cursor order. */
766
- events: StreamsEvent[]
847
+ events: TEvent[];
767
848
  /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
768
- cursor: string | null
769
- tip: StreamsTip
849
+ cursor: string | null;
850
+ tip: StreamsTip;
770
851
  /** Chain reorgs reported alongside this page; empty when none. */
771
- reorgs: StreamsReorg[]
852
+ reorgs: StreamsReorg[];
772
853
  };
773
854
  type StreamsConsumeParams = {
774
855
  /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
775
- cursor?: string | null
776
- types?: readonly StreamsEventType[]
777
- notTypes?: readonly StreamsEventType[]
778
- contractId?: StreamsFilterValue
779
- sender?: StreamsFilterValue
780
- recipient?: StreamsFilterValue
781
- assetIdentifier?: string
856
+ cursor?: string | null;
857
+ types?: readonly StreamsEventType[];
858
+ notTypes?: readonly StreamsEventType[];
859
+ contractId?: StreamsFilterValue;
860
+ sender?: StreamsFilterValue;
861
+ recipient?: StreamsFilterValue;
862
+ assetIdentifier?: string;
863
+ /** Labelled OR-groups — same semantics as `events.consume`; each returned
864
+ * event echoes the labels it matched. */
865
+ filters?: StreamsFilterMap;
782
866
  /** Events per page (the `limit` query param). Default 100. */
783
- batchSize?: number
867
+ batchSize?: number;
784
868
  /** Poll interval while caught up at the tip, in ms. Default 2000. */
785
- intervalMs?: number
869
+ intervalMs?: number;
786
870
  /** Abort to end the iteration. */
787
- signal?: AbortSignal
871
+ signal?: AbortSignal;
788
872
  };
789
873
  type StreamsEventsConsumeResult = {
790
- cursor: string | null
791
- pages: number
792
- emptyPolls: number
874
+ cursor: string | null;
875
+ pages: number;
876
+ emptyPolls: number;
793
877
  };
794
878
  type StreamsEventsReplayParams = {
795
879
  /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
796
- from?: "genesis" | string
880
+ from?: "genesis" | string;
797
881
  /**
798
882
  * Called once per finalized dump file, in block order, before live tailing.
799
883
  * Process the parquet with your own tooling (e.g. DuckDB) — the SDK does not
800
884
  * decode parquet. Use `client.dumps.download(file)` to fetch + verify bytes.
801
885
  */
802
- onDumpFile: (file: StreamsDumpFile) => Promise<void> | void
886
+ onDumpFile: (file: StreamsDumpFile) => Promise<void> | void;
803
887
  /** Called per live page after the dump phase, like `consume`. */
804
- onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined
888
+ onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined;
805
889
  /**
806
890
  * Called when the live-tail phase (after the dump backfill) crosses a reorg,
807
891
  * before the cursor rewinds and re-reads the now-canonical events — same
808
892
  * contract as `consume`. The dump-backfill phase is finalized and never
809
893
  * reorgs; omit this to leave stale rows from an orphaned fork in place.
810
894
  */
811
- onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
812
- mode?: "tail" | "bounded"
813
- batchSize?: number
814
- emptyBackoffMs?: number
815
- maxPages?: number
816
- maxEmptyPolls?: number
817
- signal?: AbortSignal
895
+ onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
896
+ mode?: "tail" | "bounded";
897
+ batchSize?: number;
898
+ emptyBackoffMs?: number;
899
+ maxPages?: number;
900
+ maxEmptyPolls?: number;
901
+ signal?: AbortSignal;
902
+ /** Narrow the LIVE TAIL after the dump phase. The dump files themselves are
903
+ * always all-type (block-partitioned parquet) — filter those in your own
904
+ * tooling while processing each file. */
905
+ types?: readonly StreamsEventType[];
906
+ notTypes?: readonly StreamsEventType[];
907
+ /** Labelled OR-groups for the live tail, like `consume`. */
908
+ filters?: StreamsFilterMap;
818
909
  };
819
910
  /** One bulk parquet file in the dumps manifest. `path` is the object key under
820
911
  * the dumps base URL. */
821
912
  type StreamsDumpFile = {
822
- path: string
823
- from_block: number
824
- to_block: number
825
- min_cursor: string | null
826
- max_cursor: string | null
827
- row_count: number
828
- byte_size: number
829
- sha256: string
830
- schema_version: number
831
- created_at: string
913
+ path: string;
914
+ from_block: number;
915
+ to_block: number;
916
+ min_cursor: string | null;
917
+ max_cursor: string | null;
918
+ row_count: number;
919
+ byte_size: number;
920
+ sha256: string;
921
+ schema_version: number;
922
+ created_at: string;
832
923
  };
833
924
  type StreamsDumpsManifest = {
834
- dataset: string
835
- network: string
836
- version: string
837
- schema_version: number
838
- generated_at: string
839
- producer_version: string
840
- finality_lag_blocks: number
925
+ dataset: string;
926
+ network: string;
927
+ version: string;
928
+ schema_version: number;
929
+ generated_at: string;
930
+ producer_version: string;
931
+ finality_lag_blocks: number;
841
932
  /** Cursor at the end of the finalized bulk coverage — hand to live tailing. */
842
- latest_finalized_cursor: string | null
933
+ latest_finalized_cursor: string | null;
843
934
  coverage: {
844
- from_block: number
845
- to_block: number
846
- }
847
- files: StreamsDumpFile[]
935
+ from_block: number;
936
+ to_block: number;
937
+ };
938
+ files: StreamsDumpFile[];
848
939
  /** ed25519 signature over the manifest's canonical bytes. Absent on legacy
849
940
  * unsigned manifests. Verified by `list()` when `verifyDumpsManifest` is on. */
850
- signature?: string
941
+ signature?: string;
851
942
  /** Short id of the signing public key. */
852
- key_id?: string
943
+ key_id?: string;
853
944
  };
854
945
  type StreamsDumps = {
855
946
  /** Fetch and parse the latest dumps manifest. */
856
- list(): Promise<StreamsDumpsManifest>
947
+ list(): Promise<StreamsDumpsManifest>;
857
948
  /** Absolute URL for a manifest file. */
858
- fileUrl(file: StreamsDumpFile): string
949
+ fileUrl(file: StreamsDumpFile): string;
859
950
  /** Download a parquet file and verify its sha256 against the manifest. */
860
- download(file: StreamsDumpFile): Promise<Uint8Array>
951
+ download(file: StreamsDumpFile): Promise<Uint8Array>;
861
952
  };
862
953
  type StreamsClient = {
863
954
  /**
@@ -874,10 +965,19 @@ type StreamsClient = {
874
965
  * rewound automatically — use `events.consume` with `onReorg` for managed
875
966
  * rollback semantics.
876
967
  */
877
- consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
968
+ /** Narrowing overload: a literal `types` array narrows every batch's
969
+ * event union to exactly those members. */
970
+ consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeParams & {
971
+ types: T;
972
+ }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
973
+ consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
878
974
  events: {
879
- list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
880
- byTxId(txId: string): Promise<StreamsEventsListEnvelope>
975
+ /** Narrowing overload, matching `consume`. */
976
+ list<const T extends readonly StreamsEventType[]>(params: StreamsEventsListParams & {
977
+ types: T;
978
+ }): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T>>>;
979
+ list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>;
980
+ byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
881
981
  /**
882
982
  * Pull pages from Streams and call `onBatch` after each page.
883
983
  *
@@ -892,8 +992,8 @@ type StreamsClient = {
892
992
  TTx = never,
893
993
  D extends boolean = false
894
994
  >(params: StreamsEventsConsumeParams<TTx, D, F> & {
895
- sink?: ConsumerSink<TTx>
896
- }): Promise<StreamsEventsConsumeResult>
995
+ sink?: ConsumerSink<TTx>;
996
+ }): Promise<StreamsEventsConsumeResult>;
897
997
  /**
898
998
  * Backfill from bulk dumps, then continue live from the dump→live seam in
899
999
  * one call. Iterates finalized dump files (via `onDumpFile`) in block
@@ -901,7 +1001,7 @@ type StreamsClient = {
901
1001
  * (exclusive input → no gap or duplicate at the seam). Requires
902
1002
  * `dumpsBaseUrl`.
903
1003
  */
904
- replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>
1004
+ replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
905
1005
  /**
906
1006
  * Follow Streams as an async iterator.
907
1007
  *
@@ -909,39 +1009,43 @@ type StreamsClient = {
909
1009
  * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
910
1010
  * `maxEmptyPolls` stops it.
911
1011
  */
912
- stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
1012
+ /** Narrowing overload, matching `consume`. */
1013
+ stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamParams & {
1014
+ types: T;
1015
+ }): AsyncIterable<StreamsEventOfTypes<T>>;
1016
+ stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
913
1017
  /**
914
1018
  * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
915
1019
  * canonical event as the server pushes it (chain cadence, not poll-bounded),
916
1020
  * and verifies each frame's inline ed25519 signature when the client was
917
1021
  * created with `verify`. Returns an unsubscribe function.
918
1022
  */
919
- subscribe(params: StreamsEventsSubscribeParams): () => void
920
- }
1023
+ subscribe(params: StreamsEventsSubscribeParams): () => void;
1024
+ };
921
1025
  blocks: {
922
- events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>
923
- }
1026
+ events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
1027
+ };
924
1028
  reorgs: {
925
- list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>
926
- }
1029
+ list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>;
1030
+ };
927
1031
  /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
928
- dumps: StreamsDumps
929
- canonical(height: number): Promise<StreamsCanonicalBlock>
930
- tip(): Promise<StreamsTip>
1032
+ dumps: StreamsDumps;
1033
+ canonical(height: number): Promise<StreamsCanonicalBlock>;
1034
+ tip(): Promise<StreamsTip>;
931
1035
  /** Your own Streams consumption (events today + this month) and tier limits. */
932
- usage(): Promise<StreamsUsage>
1036
+ usage(): Promise<StreamsUsage>;
933
1037
  };
934
1038
  type StreamsUsage = {
935
- product: "streams"
936
- tier: string
1039
+ product: "streams";
1040
+ tier: string;
937
1041
  limits: {
938
- rate_limit_per_second: number | null
939
- retention_days: number | null
940
- }
1042
+ rate_limit_per_second: number | null;
1043
+ retention_days: number | null;
1044
+ };
941
1045
  usage: {
942
- events_today: number
943
- events_this_month: number
944
- }
1046
+ events_today: number;
1047
+ events_this_month: number;
1048
+ };
945
1049
  };
946
1050
  type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
947
1051
  /** Options shared by both consume loops' page-fetch retry. Vocabulary matches
@@ -949,28 +1053,28 @@ type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
949
1053
  * language across the family, not a third. */
950
1054
  type PageRetryOptions = {
951
1055
  /** Retries after the first failure. Default 3; `0` disables. */
952
- retryCount?: number
1056
+ retryCount?: number;
953
1057
  /** Base delay in ms; the n-th retry waits `retryDelay * n` (matches the
954
1058
  * stacks transport). A server `Retry-After` overrides it. Default 1000. */
955
- retryDelay?: number
1059
+ retryDelay?: number;
956
1060
  /** Void observer, called before each retry sleep (metrics/logging). The
957
1061
  * retry policy owns the decision; this cannot change it. */
958
1062
  onError?: (err: unknown, ctx: {
959
- attempt: number
960
- retriesLeft: number
961
- delayMs: number
962
- }) => void
1063
+ attempt: number;
1064
+ retriesLeft: number;
1065
+ delayMs: number;
1066
+ }) => void;
963
1067
  };
964
1068
  /** Minimum shape a consumed Index row must expose. */
965
1069
  type IndexFeedItem = {
966
- cursor: string
967
- block_height: number
1070
+ cursor: string;
1071
+ block_height: number;
968
1072
  };
969
1073
  /** Minimum envelope shape of a consumable Index feed page. */
970
1074
  type IndexFeedEnvelope = {
971
- next_cursor: string | null
972
- tip: IndexTip
973
- reorgs: IndexReorg[]
1075
+ next_cursor: string | null;
1076
+ tip: IndexTip;
1077
+ reorgs: IndexReorg[];
974
1078
  };
975
1079
  /** Consumer options shared by `index.events.consume` and
976
1080
  * `index.contractCalls.consume`. Same contract as the Streams consumer:
@@ -983,18 +1087,18 @@ type IndexConsumeOptions<
983
1087
  > = {
984
1088
  /** Resume from a committed checkpoint. Without it (and without
985
1089
  * `fromHeight`) the API serves only the recent default window. */
986
- fromCursor?: string | null
1090
+ fromCursor?: string | null;
987
1091
  /** Start a fresh sweep at this height (e.g. `0` for genesis backfill).
988
1092
  * Ignored once a cursor exists (including a sink's committed cursor). */
989
- fromHeight?: number
1093
+ fromHeight?: number;
990
1094
  /** `tail` (default) keeps polling at the tip; `bounded` returns on the
991
1095
  * first empty page. */
992
- mode?: "tail" | "bounded"
1096
+ mode?: "tail" | "bounded";
993
1097
  /** Emit only rows at or below the tip's `finalized_height`; the
994
1098
  * unfinalized tail is re-read each poll until it settles. Finalized data
995
1099
  * never reorgs, so `onReorg` is skipped entirely. */
996
- finalizedOnly?: boolean
997
- batchSize?: number
1100
+ finalizedOnly?: boolean;
1101
+ batchSize?: number;
998
1102
  /**
999
1103
  * Destination adapter that owns the checkpoint + rollback transaction
1000
1104
  * (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
@@ -1003,37 +1107,37 @@ type IndexConsumeOptions<
1003
1107
  * transaction — a throw aborts both), reorg rollback is automatic (no
1004
1108
  * `onReorg` needed), and `onBatch`'s return value is ignored.
1005
1109
  */
1006
- sink?: ConsumerSink<TTx>
1110
+ sink?: ConsumerSink<TTx>;
1007
1111
  /** Fires once per page, before `onBatch` and before any early return —
1008
1112
  * an empty page still proves the loop is alive. Feed it to
1009
1113
  * `consumerHealth().record`. */
1010
- onProgress?: (ctx: ConsumerBatchContext) => void
1011
- onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
1114
+ onProgress?: (ctx: ConsumerBatchContext) => void;
1115
+ onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
1012
1116
  onReorg?: (reorg: IndexReorg, ctx: {
1013
- cursor: string
1014
- }) => Promise<void> | void
1015
- sleep?: Sleep
1016
- emptyBackoffMs?: number
1017
- maxPages?: number
1018
- maxEmptyPolls?: number
1019
- signal?: AbortSignal
1117
+ cursor: string;
1118
+ }) => Promise<void> | void;
1119
+ sleep?: Sleep;
1120
+ emptyBackoffMs?: number;
1121
+ maxPages?: number;
1122
+ maxEmptyPolls?: number;
1123
+ signal?: AbortSignal;
1020
1124
  /** Page-fetch retries after the first failure (429/5xx/network only —
1021
1125
  * 4xx and handler throws always propagate). Default 3; `0` disables. */
1022
- retryCount?: number
1126
+ retryCount?: number;
1023
1127
  /** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
1024
1128
  * `Retry-After` overrides it. Default 1000. */
1025
- retryDelay?: number
1129
+ retryDelay?: number;
1026
1130
  /** Void observer, called before each retry sleep. Cannot change the retry
1027
1131
  * decision — the policy owns it. */
1028
- onError?: PageRetryOptions["onError"]
1132
+ onError?: PageRetryOptions["onError"];
1029
1133
  };
1030
1134
  type IndexTip = {
1031
- block_height: number
1135
+ block_height: number;
1032
1136
  /** Highest height treated as immutable (past the burn-confirmation
1033
1137
  * finality boundary). Rows at or below it never reorg — `finalizedOnly`
1034
1138
  * consumers gate on this, since Index rows carry no per-event flag. */
1035
- finalized_height: number
1036
- lag_seconds: number
1139
+ finalized_height: number;
1140
+ lag_seconds: number;
1037
1141
  };
1038
1142
  /**
1039
1143
  * A chain reorg overlapping a returned page's height range. Height-keyed feeds
@@ -1046,54 +1150,54 @@ type IndexTip = {
1046
1150
  * inclusive. Empty when the page spans no reorg.
1047
1151
  */
1048
1152
  type IndexReorg = {
1049
- id: string
1050
- detected_at: string
1051
- fork_point_height: number
1052
- old_index_block_hash: string | null
1053
- new_index_block_hash: string | null
1153
+ id: string;
1154
+ detected_at: string;
1155
+ fork_point_height: number;
1156
+ old_index_block_hash: string | null;
1157
+ new_index_block_hash: string | null;
1054
1158
  /** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */
1055
1159
  orphaned_range: {
1056
- from: string
1057
- to: string
1058
- }
1160
+ from: string;
1161
+ to: string;
1162
+ };
1059
1163
  /**
1060
1164
  * First position of the new canonical chain at the fork, `fork:0`
1061
1165
  * (INCLUSIVE). Not an exclusive resume token — resuming a `(bh,ei) > cursor`
1062
1166
  * read directly from it would skip `fork:0`. To re-read the new run, rewind
1063
1167
  * to the foot of `fork_point_height` (`Cursor.atHeight`), not to this value.
1064
1168
  */
1065
- new_canonical_tip: string
1169
+ new_canonical_tip: string;
1066
1170
  };
1067
1171
  type IndexUsage = {
1068
- product: "index"
1069
- tier: string
1172
+ product: "index";
1173
+ tier: string;
1070
1174
  limits: {
1071
- rate_limit_per_second: number | null
1072
- }
1175
+ rate_limit_per_second: number | null;
1176
+ };
1073
1177
  usage: {
1074
- decoded_events_today: number
1075
- decoded_events_this_month: number
1076
- }
1178
+ decoded_events_today: number;
1179
+ decoded_events_this_month: number;
1180
+ };
1077
1181
  };
1078
1182
  type FtTransfer = {
1079
- cursor: string
1080
- block_height: number
1081
- block_time?: string | null
1082
- tx_id: string
1083
- tx_index: number
1084
- event_index: number
1085
- event_type: "ft_transfer"
1086
- contract_id: string
1087
- asset_identifier: string
1088
- sender: string
1089
- recipient: string
1090
- amount: string
1183
+ cursor: string;
1184
+ block_height: number;
1185
+ block_time?: string | null;
1186
+ tx_id: string;
1187
+ tx_index: number;
1188
+ event_index: number;
1189
+ event_type: "ft_transfer";
1190
+ contract_id: string;
1191
+ asset_identifier: string;
1192
+ sender: string;
1193
+ recipient: string;
1194
+ amount: string;
1091
1195
  };
1092
1196
  type FtTransfersEnvelope<TRow = FtTransfer> = {
1093
- events: TRow[]
1094
- next_cursor: string | null
1095
- tip: IndexTip
1096
- reorgs: IndexReorg[]
1197
+ events: TRow[];
1198
+ next_cursor: string | null;
1199
+ tip: IndexTip;
1200
+ reorgs: IndexReorg[];
1097
1201
  };
1098
1202
  /** Transfer columns that survive any projection — the consume contract
1099
1203
  * (`cursor`, `block_height`) plus the `event_type` discriminant. */
@@ -1107,40 +1211,40 @@ type FtTransfersListParams = {
1107
1211
  * one a compile error rather than `undefined` at runtime. Omitting
1108
1212
  * `block_time` also lets the server skip the blocks join.
1109
1213
  */
1110
- fields?: readonly (keyof FtTransfer & string)[]
1111
- cursor?: string | null
1112
- fromCursor?: string | null
1113
- limit?: number
1114
- contractId?: string
1115
- assetIdentifier?: string
1116
- sender?: string
1117
- recipient?: string
1118
- fromHeight?: number
1119
- toHeight?: number
1214
+ fields?: readonly (keyof FtTransfer & string)[];
1215
+ cursor?: string | null;
1216
+ fromCursor?: string | null;
1217
+ limit?: number;
1218
+ contractId?: string;
1219
+ assetIdentifier?: string;
1220
+ sender?: string;
1221
+ recipient?: string;
1222
+ fromHeight?: number;
1223
+ toHeight?: number;
1120
1224
  };
1121
1225
  type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & {
1122
- batchSize?: number
1123
- signal?: AbortSignal
1226
+ batchSize?: number;
1227
+ signal?: AbortSignal;
1124
1228
  };
1125
1229
  type NftTransfer = {
1126
- cursor: string
1127
- block_height: number
1128
- block_time?: string | null
1129
- tx_id: string
1130
- tx_index: number
1131
- event_index: number
1132
- event_type: "nft_transfer"
1133
- contract_id: string
1134
- asset_identifier: string
1135
- sender: string
1136
- recipient: string
1137
- value: string
1230
+ cursor: string;
1231
+ block_height: number;
1232
+ block_time?: string | null;
1233
+ tx_id: string;
1234
+ tx_index: number;
1235
+ event_index: number;
1236
+ event_type: "nft_transfer";
1237
+ contract_id: string;
1238
+ asset_identifier: string;
1239
+ sender: string;
1240
+ recipient: string;
1241
+ value: string;
1138
1242
  };
1139
1243
  type NftTransfersEnvelope<TRow = NftTransfer> = {
1140
- events: TRow[]
1141
- next_cursor: string | null
1142
- tip: IndexTip
1143
- reorgs: IndexReorg[]
1244
+ events: TRow[];
1245
+ next_cursor: string | null;
1246
+ tip: IndexTip;
1247
+ reorgs: IndexReorg[];
1144
1248
  };
1145
1249
  /** See {@link FtTransferAlwaysFields}. */
1146
1250
  type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
@@ -1148,110 +1252,110 @@ type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
1148
1252
  type NftTransferFields<F extends keyof NftTransfer & string> = Pick<NftTransfer, (F | NftTransferAlwaysFields) & keyof NftTransfer>;
1149
1253
  type NftTransfersListParams = {
1150
1254
  /** Columns to return (see {@link FtTransfersListParams.fields}). */
1151
- fields?: readonly (keyof NftTransfer & string)[]
1152
- cursor?: string | null
1153
- fromCursor?: string | null
1154
- limit?: number
1155
- contractId?: string
1156
- assetIdentifier?: string
1157
- sender?: string
1158
- recipient?: string
1159
- fromHeight?: number
1160
- toHeight?: number
1255
+ fields?: readonly (keyof NftTransfer & string)[];
1256
+ cursor?: string | null;
1257
+ fromCursor?: string | null;
1258
+ limit?: number;
1259
+ contractId?: string;
1260
+ assetIdentifier?: string;
1261
+ sender?: string;
1262
+ recipient?: string;
1263
+ fromHeight?: number;
1264
+ toHeight?: number;
1161
1265
  };
1162
1266
  type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
1163
- batchSize?: number
1164
- signal?: AbortSignal
1267
+ batchSize?: number;
1268
+ signal?: AbortSignal;
1165
1269
  };
1166
1270
  type IndexEventBase = {
1167
- cursor: string
1168
- block_height: number
1169
- block_time?: string | null
1170
- tx_id: string
1171
- tx_index: number
1172
- event_index: number
1173
- contract_id: string | null
1271
+ cursor: string;
1272
+ block_height: number;
1273
+ block_time?: string | null;
1274
+ tx_id: string;
1275
+ tx_index: number;
1276
+ event_index: number;
1277
+ contract_id: string | null;
1174
1278
  /** Submitting-transaction context, present only when `txContext: true` was
1175
1279
  * requested. `tx_sender` is the real tx sender — distinct from a transfer's
1176
1280
  * asset `sender`, and the only place a `print` event's sender is available.
1177
1281
  * Lets a consumer build per-event tx context without a `/v1/index/transactions`
1178
1282
  * call per event. */
1179
- tx_sender?: string | null
1180
- tx_type?: string | null
1181
- tx_status?: string | null
1182
- tx_contract_id?: string | null
1183
- tx_function_name?: string | null
1283
+ tx_sender?: string | null;
1284
+ tx_type?: string | null;
1285
+ tx_status?: string | null;
1286
+ tx_contract_id?: string | null;
1287
+ tx_function_name?: string | null;
1184
1288
  };
1185
1289
  type IndexFtTransfer = IndexEventBase & {
1186
- event_type: "ft_transfer"
1187
- asset_identifier: string
1188
- sender: string
1189
- recipient: string
1190
- amount: string
1290
+ event_type: "ft_transfer";
1291
+ asset_identifier: string;
1292
+ sender: string;
1293
+ recipient: string;
1294
+ amount: string;
1191
1295
  };
1192
1296
  type IndexNftTransfer = IndexEventBase & {
1193
- event_type: "nft_transfer"
1194
- asset_identifier: string
1195
- sender: string
1196
- recipient: string
1197
- value: string
1297
+ event_type: "nft_transfer";
1298
+ asset_identifier: string;
1299
+ sender: string;
1300
+ recipient: string;
1301
+ value: string;
1198
1302
  };
1199
1303
  type IndexStxTransfer = IndexEventBase & {
1200
- event_type: "stx_transfer"
1201
- sender: string
1202
- recipient: string
1203
- amount: string
1204
- memo: string | null
1304
+ event_type: "stx_transfer";
1305
+ sender: string;
1306
+ recipient: string;
1307
+ amount: string;
1308
+ memo: string | null;
1205
1309
  };
1206
1310
  type IndexStxMint = IndexEventBase & {
1207
- event_type: "stx_mint"
1208
- recipient: string
1209
- amount: string
1311
+ event_type: "stx_mint";
1312
+ recipient: string;
1313
+ amount: string;
1210
1314
  };
1211
1315
  type IndexStxBurn = IndexEventBase & {
1212
- event_type: "stx_burn"
1213
- sender: string
1214
- amount: string
1316
+ event_type: "stx_burn";
1317
+ sender: string;
1318
+ amount: string;
1215
1319
  };
1216
1320
  type IndexStxLock = IndexEventBase & {
1217
- event_type: "stx_lock"
1218
- sender: string
1219
- amount: string
1321
+ event_type: "stx_lock";
1322
+ sender: string;
1323
+ amount: string;
1220
1324
  payload: {
1221
- unlock_height: string | null
1222
- }
1325
+ unlock_height: string | null;
1326
+ };
1223
1327
  };
1224
1328
  type IndexFtMint = IndexEventBase & {
1225
- event_type: "ft_mint"
1226
- asset_identifier: string
1227
- recipient: string
1228
- amount: string
1329
+ event_type: "ft_mint";
1330
+ asset_identifier: string;
1331
+ recipient: string;
1332
+ amount: string;
1229
1333
  };
1230
1334
  type IndexFtBurn = IndexEventBase & {
1231
- event_type: "ft_burn"
1232
- asset_identifier: string
1233
- sender: string
1234
- amount: string
1335
+ event_type: "ft_burn";
1336
+ asset_identifier: string;
1337
+ sender: string;
1338
+ amount: string;
1235
1339
  };
1236
1340
  type IndexNftMint = IndexEventBase & {
1237
- event_type: "nft_mint"
1238
- asset_identifier: string
1239
- recipient: string
1240
- value: string
1341
+ event_type: "nft_mint";
1342
+ asset_identifier: string;
1343
+ recipient: string;
1344
+ value: string;
1241
1345
  };
1242
1346
  type IndexNftBurn = IndexEventBase & {
1243
- event_type: "nft_burn"
1244
- asset_identifier: string
1245
- sender: string
1246
- value: string
1347
+ event_type: "nft_burn";
1348
+ asset_identifier: string;
1349
+ sender: string;
1350
+ value: string;
1247
1351
  };
1248
1352
  type IndexPrint = IndexEventBase & {
1249
- event_type: "print"
1353
+ event_type: "print";
1250
1354
  payload: {
1251
- topic: string | null
1252
- value: unknown
1253
- raw_value: string | null
1254
- }
1355
+ topic: string | null;
1356
+ value: unknown;
1357
+ raw_value: string | null;
1358
+ };
1255
1359
  };
1256
1360
  /** Decoded chain event, discriminated by `event_type`. */
1257
1361
  type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
@@ -1268,39 +1372,39 @@ type EventsEnvelope<
1268
1372
  T extends IndexEventType = IndexEventType,
1269
1373
  TRow = IndexEventOf<T>
1270
1374
  > = {
1271
- events: TRow[]
1272
- next_cursor: string | null
1273
- tip: IndexTip
1274
- reorgs: IndexReorg[]
1375
+ events: TRow[];
1376
+ next_cursor: string | null;
1377
+ tip: IndexTip;
1378
+ reorgs: IndexReorg[];
1275
1379
  };
1276
1380
  /** The single decoded-event member matching one `event_type` literal.
1277
1381
  * `IndexEventOf<"ft_transfer">` is `IndexFtTransfer`. */
1278
1382
  type IndexEventOf<T extends IndexEventType> = Extract<IndexEvent, {
1279
- event_type: T
1383
+ event_type: T;
1280
1384
  }>;
1281
1385
  type EventsListParams<T extends IndexEventType = IndexEventType> = {
1282
1386
  /** Required. One of the decoded event types. Passing a literal narrows the
1283
1387
  * rows every surface hands back to that event's own shape. */
1284
- eventType: T
1285
- cursor?: string | null
1286
- fromCursor?: string | null
1287
- limit?: number
1388
+ eventType: T;
1389
+ cursor?: string | null;
1390
+ fromCursor?: string | null;
1391
+ limit?: number;
1288
1392
  /** One id, or several to scope the sweep to a set of contracts (max 20).
1289
1393
  * Mutually exclusive with `trait`. */
1290
- contractId?: string | readonly string[]
1291
- assetIdentifier?: string
1292
- sender?: string
1293
- recipient?: string
1294
- fromHeight?: number
1295
- toHeight?: number
1394
+ contractId?: string | readonly string[];
1395
+ assetIdentifier?: string;
1396
+ sender?: string;
1397
+ recipient?: string;
1398
+ fromHeight?: number;
1399
+ toHeight?: number;
1296
1400
  /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1297
1401
  * Mutually exclusive with contractId; contract-keyed event types only. */
1298
- trait?: string
1402
+ trait?: string;
1299
1403
  /** Join the submitting transaction into each event — populates `tx_sender`,
1300
1404
  * `tx_type`, `tx_status`, `tx_contract_id`, `tx_function_name`. Off by default.
1301
1405
  * Avoids a `/v1/index/transactions` call per event; for `print` events it's
1302
1406
  * the only source of the submitting sender. */
1303
- txContext?: boolean
1407
+ txContext?: boolean;
1304
1408
  /**
1305
1409
  * Return only these columns. The server projects the SELECT, so an
1306
1410
  * unrequested field is physically absent — and the returned row type
@@ -1315,188 +1419,188 @@ type EventsListParams<T extends IndexEventType = IndexEventType> = {
1315
1419
  * not per field. What it buys is wire bytes, plus skipping the `blocks`
1316
1420
  * join when `block_time` is omitted.
1317
1421
  */
1318
- fields?: readonly (keyof IndexEventOf<T> & string)[]
1422
+ fields?: readonly (keyof IndexEventOf<T> & string)[];
1319
1423
  };
1320
1424
  type EventsWalkParams<T extends IndexEventType = IndexEventType> = Omit<EventsListParams<T>, "limit"> & {
1321
- batchSize?: number
1322
- signal?: AbortSignal
1425
+ batchSize?: number;
1426
+ signal?: AbortSignal;
1323
1427
  };
1324
1428
  type EventsConsumeParams<
1325
1429
  T extends IndexEventType = IndexEventType,
1326
1430
  TTx = never
1327
1431
  > = Omit<EventsListParams<T>, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexEventOf<T>, EventsEnvelope<T>, TTx>;
1328
1432
  type IndexContractCall = {
1329
- cursor: string
1330
- block_height: number
1331
- block_time?: string | null
1332
- tx_id: string
1333
- tx_index: number
1334
- contract_id: string
1335
- function_name: string
1336
- sender: string
1337
- status: string
1338
- args: unknown[]
1339
- result: unknown
1340
- result_hex: string | null
1433
+ cursor: string;
1434
+ block_height: number;
1435
+ block_time?: string | null;
1436
+ tx_id: string;
1437
+ tx_index: number;
1438
+ contract_id: string;
1439
+ function_name: string;
1440
+ sender: string;
1441
+ status: string;
1442
+ args: unknown[];
1443
+ result: unknown;
1444
+ result_hex: string | null;
1341
1445
  };
1342
1446
  type ContractCallsEnvelope = {
1343
- contract_calls: IndexContractCall[]
1344
- next_cursor: string | null
1345
- tip: IndexTip
1346
- reorgs: IndexReorg[]
1447
+ contract_calls: IndexContractCall[];
1448
+ next_cursor: string | null;
1449
+ tip: IndexTip;
1450
+ reorgs: IndexReorg[];
1347
1451
  };
1348
1452
  type ContractCallsListParams = {
1349
- cursor?: string | null
1350
- fromCursor?: string | null
1351
- limit?: number
1453
+ cursor?: string | null;
1454
+ fromCursor?: string | null;
1455
+ limit?: number;
1352
1456
  /** One id, or several to scope the sweep to a set of contracts (max 20).
1353
1457
  * Mutually exclusive with `trait`. */
1354
- contractId?: string | readonly string[]
1355
- functionName?: string
1356
- sender?: string
1357
- fromHeight?: number
1358
- toHeight?: number
1458
+ contractId?: string | readonly string[];
1459
+ functionName?: string;
1460
+ sender?: string;
1461
+ fromHeight?: number;
1462
+ toHeight?: number;
1359
1463
  /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1360
1464
  * Mutually exclusive with contractId. */
1361
- trait?: string
1465
+ trait?: string;
1362
1466
  };
1363
1467
  type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
1364
- batchSize?: number
1365
- signal?: AbortSignal
1468
+ batchSize?: number;
1469
+ signal?: AbortSignal;
1366
1470
  };
1367
1471
  type ContractCallsConsumeParams<TTx = never> = Omit<ContractCallsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexContractCall, ContractCallsEnvelope, TTx>;
1368
1472
  /** One canonical block in the sync map. Lean by design — block + parent hash
1369
1473
  * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for
1370
1474
  * the full block resource. */
1371
1475
  type IndexCanonicalBlock = {
1372
- cursor: string
1373
- block_height: number
1374
- block_hash: string
1375
- parent_hash: string
1376
- burn_block_height: number
1377
- burn_block_hash: string | null
1476
+ cursor: string;
1477
+ block_height: number;
1478
+ block_hash: string;
1479
+ parent_hash: string;
1480
+ burn_block_height: number;
1481
+ burn_block_hash: string | null;
1378
1482
  };
1379
1483
  type CanonicalEnvelope = {
1380
- canonical: IndexCanonicalBlock[]
1381
- next_cursor: string | null
1382
- tip: IndexTip
1484
+ canonical: IndexCanonicalBlock[];
1485
+ next_cursor: string | null;
1486
+ tip: IndexTip;
1383
1487
  };
1384
1488
  type CanonicalListParams = {
1385
- cursor?: string | null
1386
- fromCursor?: string | null
1387
- limit?: number
1388
- fromHeight?: number
1389
- toHeight?: number
1489
+ cursor?: string | null;
1490
+ fromCursor?: string | null;
1491
+ limit?: number;
1492
+ fromHeight?: number;
1493
+ toHeight?: number;
1390
1494
  };
1391
1495
  type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & {
1392
- batchSize?: number
1393
- signal?: AbortSignal
1496
+ batchSize?: number;
1497
+ signal?: AbortSignal;
1394
1498
  };
1395
1499
  /** A block resource. Metadata is intentionally thin — only chain-linkage and
1396
1500
  * burn-anchor fields are persisted (no miner / tx_count / signer). */
1397
1501
  type IndexBlock = {
1398
- cursor: string
1399
- block_height: number
1400
- block_hash: string
1401
- parent_hash: string
1402
- burn_block_height: number
1403
- burn_block_hash: string | null
1404
- block_time: string | null
1405
- canonical: boolean
1502
+ cursor: string;
1503
+ block_height: number;
1504
+ block_hash: string;
1505
+ parent_hash: string;
1506
+ burn_block_height: number;
1507
+ burn_block_hash: string | null;
1508
+ block_time: string | null;
1509
+ canonical: boolean;
1406
1510
  };
1407
1511
  type BlocksEnvelope = {
1408
- blocks: IndexBlock[]
1409
- next_cursor: string | null
1410
- tip: IndexTip
1512
+ blocks: IndexBlock[];
1513
+ next_cursor: string | null;
1514
+ tip: IndexTip;
1411
1515
  };
1412
1516
  type BlockEnvelope = {
1413
- block: IndexBlock
1414
- tip: IndexTip
1517
+ block: IndexBlock;
1518
+ tip: IndexTip;
1415
1519
  };
1416
1520
  type BlocksListParams = {
1417
- cursor?: string | null
1418
- fromCursor?: string | null
1419
- limit?: number
1420
- fromHeight?: number
1421
- toHeight?: number
1521
+ cursor?: string | null;
1522
+ fromCursor?: string | null;
1523
+ limit?: number;
1524
+ fromHeight?: number;
1525
+ toHeight?: number;
1422
1526
  };
1423
1527
  type BlocksWalkParams = Omit<BlocksListParams, "limit"> & {
1424
- batchSize?: number
1425
- signal?: AbortSignal
1528
+ batchSize?: number;
1529
+ signal?: AbortSignal;
1426
1530
  };
1427
1531
  type IndexPostCondition = {
1428
- type: "stx"
1429
- principal: string
1430
- condition_code: number
1431
- condition_code_name: string | null
1432
- amount: string
1532
+ type: "stx";
1533
+ principal: string;
1534
+ condition_code: number;
1535
+ condition_code_name: string | null;
1536
+ amount: string;
1433
1537
  } | {
1434
- type: "ft"
1435
- principal: string
1436
- asset_identifier: string
1437
- condition_code: number
1438
- condition_code_name: string | null
1439
- amount: string
1538
+ type: "ft";
1539
+ principal: string;
1540
+ asset_identifier: string;
1541
+ condition_code: number;
1542
+ condition_code_name: string | null;
1543
+ amount: string;
1440
1544
  } | {
1441
- type: "nft"
1442
- principal: string
1443
- asset_identifier: string
1444
- asset_value: unknown
1445
- condition_code: number
1446
- condition_code_name: string | null
1545
+ type: "nft";
1546
+ principal: string;
1547
+ asset_identifier: string;
1548
+ asset_value: unknown;
1549
+ condition_code: number;
1550
+ condition_code_name: string | null;
1447
1551
  };
1448
1552
  /** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.
1449
1553
  * Payload sub-objects are present only for the matching `tx_type`; enrichment
1450
1554
  * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */
1451
1555
  type IndexTransaction = {
1452
- cursor: string
1453
- tx_id: string
1454
- block_height: number
1455
- block_time?: string | null
1456
- tx_index: number
1457
- tx_type: string
1458
- sender: string
1459
- status: string
1460
- fee: string | null
1461
- nonce: string | null
1462
- sponsored: boolean | null
1463
- anchor_mode: string | null
1464
- post_condition_mode: string | null
1465
- post_conditions: IndexPostCondition[]
1556
+ cursor: string;
1557
+ tx_id: string;
1558
+ block_height: number;
1559
+ block_time?: string | null;
1560
+ tx_index: number;
1561
+ tx_type: string;
1562
+ sender: string;
1563
+ status: string;
1564
+ fee: string | null;
1565
+ nonce: string | null;
1566
+ sponsored: boolean | null;
1567
+ anchor_mode: string | null;
1568
+ post_condition_mode: string | null;
1569
+ post_conditions: IndexPostCondition[];
1466
1570
  contract_call?: {
1467
- contract_id: string
1468
- function_name: string
1469
- function_args: unknown[]
1571
+ contract_id: string;
1572
+ function_name: string;
1573
+ function_args: unknown[];
1470
1574
  /** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */
1471
- function_args_hex: string[]
1472
- result: unknown
1473
- result_hex: string | null
1474
- }
1575
+ function_args_hex: string[];
1576
+ result: unknown;
1577
+ result_hex: string | null;
1578
+ };
1475
1579
  token_transfer?: {
1476
- recipient: string
1477
- amount: string
1478
- memo: string
1479
- }
1580
+ recipient: string;
1581
+ amount: string;
1582
+ memo: string;
1583
+ };
1480
1584
  smart_contract?: {
1481
- contract_id: string | null
1482
- clarity_version: number | null
1483
- }
1585
+ contract_id: string | null;
1586
+ clarity_version: number | null;
1587
+ };
1484
1588
  coinbase?: {
1485
- alt_recipient: string | null
1486
- }
1589
+ alt_recipient: string | null;
1590
+ };
1487
1591
  tenure_change?: {
1488
- cause: number
1489
- }
1592
+ cause: number;
1593
+ };
1490
1594
  };
1491
1595
  type TransactionsEnvelope<TRow = IndexTransaction> = {
1492
- transactions: TRow[]
1493
- next_cursor: string | null
1494
- tip: IndexTip
1495
- reorgs: IndexReorg[]
1596
+ transactions: TRow[];
1597
+ next_cursor: string | null;
1598
+ tip: IndexTip;
1599
+ reorgs: IndexReorg[];
1496
1600
  };
1497
1601
  type TransactionEnvelope = {
1498
- transaction: IndexTransaction
1499
- tip: IndexTip
1602
+ transaction: IndexTransaction;
1603
+ tip: IndexTip;
1500
1604
  };
1501
1605
  /** Transaction columns that survive any projection. */
1502
1606
  type TransactionAlwaysFields = "cursor" | "block_height" | "tx_id";
@@ -1508,123 +1612,123 @@ type TransactionsListParams = {
1508
1612
  * is physically absent — and the narrowing overload on `list` makes reading
1509
1613
  * one a compile error rather than `undefined` at runtime.
1510
1614
  */
1511
- fields?: readonly (keyof IndexTransaction & string)[]
1512
- cursor?: string | null
1513
- fromCursor?: string | null
1514
- limit?: number
1515
- type?: string
1516
- sender?: string
1517
- contractId?: string
1518
- fromHeight?: number
1519
- toHeight?: number
1615
+ fields?: readonly (keyof IndexTransaction & string)[];
1616
+ cursor?: string | null;
1617
+ fromCursor?: string | null;
1618
+ limit?: number;
1619
+ type?: string;
1620
+ sender?: string;
1621
+ contractId?: string;
1622
+ fromHeight?: number;
1623
+ toHeight?: number;
1520
1624
  };
1521
1625
  type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & {
1522
- batchSize?: number
1523
- signal?: AbortSignal
1626
+ batchSize?: number;
1627
+ signal?: AbortSignal;
1524
1628
  };
1525
1629
  /** A decoded PoX-4 stacking action (one per stacking contract call). */
1526
1630
  type IndexStackingAction = {
1527
- cursor: string
1528
- block_height: number
1529
- block_time?: string | null
1530
- burn_block_height: number
1531
- tx_id: string
1532
- tx_index: number
1533
- function_name: string
1534
- caller: string
1535
- stacker: string | null
1536
- delegate_to: string | null
1537
- amount_ustx: string | null
1538
- lock_period: number | null
1631
+ cursor: string;
1632
+ block_height: number;
1633
+ block_time?: string | null;
1634
+ burn_block_height: number;
1635
+ tx_id: string;
1636
+ tx_index: number;
1637
+ function_name: string;
1638
+ caller: string;
1639
+ stacker: string | null;
1640
+ delegate_to: string | null;
1641
+ amount_ustx: string | null;
1642
+ lock_period: number | null;
1539
1643
  pox_addr: {
1540
- version: number | null
1541
- hashbytes: string | null
1542
- btc: string | null
1543
- }
1544
- start_cycle: number | null
1545
- end_cycle: number | null
1546
- reward_cycle: number | null
1547
- signer_key: string | null
1548
- result_ok: boolean
1644
+ version: number | null;
1645
+ hashbytes: string | null;
1646
+ btc: string | null;
1647
+ };
1648
+ start_cycle: number | null;
1649
+ end_cycle: number | null;
1650
+ reward_cycle: number | null;
1651
+ signer_key: string | null;
1652
+ result_ok: boolean;
1549
1653
  };
1550
1654
  type StackingEnvelope = {
1551
- stacking: IndexStackingAction[]
1552
- next_cursor: string | null
1553
- tip: IndexTip
1554
- reorgs: IndexReorg[]
1655
+ stacking: IndexStackingAction[];
1656
+ next_cursor: string | null;
1657
+ tip: IndexTip;
1658
+ reorgs: IndexReorg[];
1555
1659
  /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
1556
- notes?: string
1660
+ notes?: string;
1557
1661
  };
1558
1662
  type StackingListParams = {
1559
- cursor?: string | null
1560
- fromCursor?: string | null
1561
- limit?: number
1562
- functionName?: string
1563
- stacker?: string
1564
- caller?: string
1565
- fromHeight?: number
1566
- toHeight?: number
1663
+ cursor?: string | null;
1664
+ fromCursor?: string | null;
1665
+ limit?: number;
1666
+ functionName?: string;
1667
+ stacker?: string;
1668
+ caller?: string;
1669
+ fromHeight?: number;
1670
+ toHeight?: number;
1567
1671
  };
1568
1672
  type StackingWalkParams = Omit<StackingListParams, "limit"> & {
1569
- batchSize?: number
1570
- signal?: AbortSignal
1673
+ batchSize?: number;
1674
+ signal?: AbortSignal;
1571
1675
  };
1572
1676
  /** A pending (unconfirmed) transaction. Like a transaction document but
1573
1677
  * pre-chain — no block_height/tx_index/result/events — with `received_at` and
1574
1678
  * a sequence cursor instead of a block position. */
1575
1679
  type IndexMempoolTransaction = {
1576
- cursor: string
1577
- tx_id: string
1578
- tx_type: string
1579
- sender: string
1580
- received_at?: string | null
1581
- fee: string | null
1582
- nonce: string | null
1583
- sponsored: boolean | null
1584
- anchor_mode: string | null
1585
- post_condition_mode: string | null
1586
- post_conditions: IndexPostCondition[]
1680
+ cursor: string;
1681
+ tx_id: string;
1682
+ tx_type: string;
1683
+ sender: string;
1684
+ received_at?: string | null;
1685
+ fee: string | null;
1686
+ nonce: string | null;
1687
+ sponsored: boolean | null;
1688
+ anchor_mode: string | null;
1689
+ post_condition_mode: string | null;
1690
+ post_conditions: IndexPostCondition[];
1587
1691
  contract_call?: {
1588
- contract_id: string
1589
- function_name: string
1590
- function_args: unknown[]
1591
- }
1692
+ contract_id: string;
1693
+ function_name: string;
1694
+ function_args: unknown[];
1695
+ };
1592
1696
  token_transfer?: {
1593
- recipient: string
1594
- amount: string
1595
- memo: string
1596
- }
1697
+ recipient: string;
1698
+ amount: string;
1699
+ memo: string;
1700
+ };
1597
1701
  smart_contract?: {
1598
- clarity_version: number | null
1599
- }
1702
+ clarity_version: number | null;
1703
+ };
1600
1704
  coinbase?: {
1601
- alt_recipient: string | null
1602
- }
1705
+ alt_recipient: string | null;
1706
+ };
1603
1707
  tenure_change?: {
1604
- cause: number
1605
- }
1708
+ cause: number;
1709
+ };
1606
1710
  };
1607
1711
  type MempoolEnvelope = {
1608
- mempool: IndexMempoolTransaction[]
1609
- next_cursor: string | null
1610
- tip: IndexTip
1712
+ mempool: IndexMempoolTransaction[];
1713
+ next_cursor: string | null;
1714
+ tip: IndexTip;
1611
1715
  };
1612
1716
  type MempoolTransactionEnvelope = {
1613
- transaction: IndexMempoolTransaction
1614
- tip: IndexTip
1717
+ transaction: IndexMempoolTransaction;
1718
+ tip: IndexTip;
1615
1719
  };
1616
1720
  type MempoolListParams = {
1617
- cursor?: string | null
1618
- fromCursor?: string | null
1619
- limit?: number
1620
- sender?: string
1621
- type?: string
1721
+ cursor?: string | null;
1722
+ fromCursor?: string | null;
1723
+ limit?: number;
1724
+ sender?: string;
1725
+ type?: string;
1622
1726
  /** Filter to pending calls to a single contract (e.g. `SP….contract`). */
1623
- contractId?: string
1727
+ contractId?: string;
1624
1728
  };
1625
1729
  type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
1626
- batchSize?: number
1627
- signal?: AbortSignal
1730
+ batchSize?: number;
1731
+ signal?: AbortSignal;
1628
1732
  };
1629
1733
  /**
1630
1734
  * Empirical per-topic print payload schema for a contract, inferred from
@@ -1632,194 +1736,194 @@ type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
1632
1736
  * when the contract has more print events than the windows examined.
1633
1737
  */
1634
1738
  type PrintSchemaResponse = {
1635
- contract_id: string
1636
- topics: InferredTopicSchema[]
1637
- sampled: boolean
1638
- total_events: number
1739
+ contract_id: string;
1740
+ topics: InferredTopicSchema[];
1741
+ sampled: boolean;
1742
+ total_events: number;
1639
1743
  /** True when the count hit the server-side cap (total_events is the cap). */
1640
- total_events_capped: boolean
1744
+ total_events_capped: boolean;
1641
1745
  sample: {
1642
- size: number
1643
- newest_height: number | null
1644
- oldest_height: number | null
1645
- }
1646
- tip: IndexTip
1746
+ size: number;
1747
+ newest_height: number | null;
1748
+ oldest_height: number | null;
1749
+ };
1750
+ tip: IndexTip;
1647
1751
  };
1648
1752
  type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
1649
1753
  /** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
1650
1754
  * `request_id`). One terminal `completed-deposit` event per deposit. */
1651
1755
  type IndexSbtcDeposit = {
1652
- cursor: string
1653
- block_height: number
1654
- block_time?: string | null
1655
- tx_id: string
1656
- tx_index: number
1657
- event_index: number
1658
- amount: string | null
1659
- sender: string | null
1660
- bitcoin_txid: string | null
1661
- output_index: number | null
1662
- recipient_btc_version: number | null
1663
- recipient_btc_hashbytes: string | null
1756
+ cursor: string;
1757
+ block_height: number;
1758
+ block_time?: string | null;
1759
+ tx_id: string;
1760
+ tx_index: number;
1761
+ event_index: number;
1762
+ amount: string | null;
1763
+ sender: string | null;
1764
+ bitcoin_txid: string | null;
1765
+ output_index: number | null;
1766
+ recipient_btc_version: number | null;
1767
+ recipient_btc_hashbytes: string | null;
1664
1768
  };
1665
1769
  /** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
1666
1770
  type IndexSbtcDepositDetail = IndexSbtcDeposit & {
1667
- status: "COMPLETED"
1771
+ status: "COMPLETED";
1668
1772
  };
1669
1773
  /** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
1670
1774
  * derived from the latest accept/reject. */
1671
1775
  type IndexSbtcWithdrawal = {
1672
- cursor: string
1673
- request_id: number
1674
- status: SbtcWithdrawalStatus
1675
- amount: string | null
1676
- sender: string | null
1677
- recipient_btc_version: number | null
1678
- recipient_btc_hashbytes: string | null
1679
- sweep_txid: string | null
1776
+ cursor: string;
1777
+ request_id: number;
1778
+ status: SbtcWithdrawalStatus;
1779
+ amount: string | null;
1780
+ sender: string | null;
1781
+ recipient_btc_version: number | null;
1782
+ recipient_btc_hashbytes: string | null;
1783
+ sweep_txid: string | null;
1680
1784
  /** BTC L1 settlement of the committed sweep: true once confirmed, false while
1681
1785
  * pending, null when there is no sweep yet (REQUESTED). */
1682
- settlement_confirmed: boolean | null
1786
+ settlement_confirmed: boolean | null;
1683
1787
  /** BTC confirmations on the sweep tx, null when no settlement row yet. */
1684
- btc_confirmations: number | null
1788
+ btc_confirmations: number | null;
1685
1789
  /** Confirming BTC block height, null while unconfirmed / no sweep. */
1686
- btc_block_height: number | null
1790
+ btc_block_height: number | null;
1687
1791
  /** When the sweep crossed the confirmation threshold (ISO), null otherwise. */
1688
- confirmed_at: string | null
1689
- requested_at?: string | null
1690
- resolved_at?: string | null
1792
+ confirmed_at: string | null;
1793
+ requested_at?: string | null;
1794
+ resolved_at?: string | null;
1691
1795
  };
1692
1796
  /** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
1693
1797
  type IndexSbtcWithdrawalPhase = {
1694
- block_height: number
1695
- block_time: string | null
1696
- tx_id: string
1798
+ block_height: number;
1799
+ block_time: string | null;
1800
+ tx_id: string;
1697
1801
  };
1698
1802
  /** A single peg-out's full assembled lifecycle, fetched by `request_id`.
1699
1803
  * `finalized` is true once terminal and past the reorg margin. */
1700
1804
  type IndexSbtcWithdrawalDetail = {
1701
- request_id: number
1702
- status: SbtcWithdrawalStatus
1703
- amount: string | null
1704
- sender: string | null
1705
- recipient_btc_version: number | null
1706
- recipient_btc_hashbytes: string | null
1707
- requested: IndexSbtcWithdrawalPhase
1805
+ request_id: number;
1806
+ status: SbtcWithdrawalStatus;
1807
+ amount: string | null;
1808
+ sender: string | null;
1809
+ recipient_btc_version: number | null;
1810
+ recipient_btc_hashbytes: string | null;
1811
+ requested: IndexSbtcWithdrawalPhase;
1708
1812
  accepted: (IndexSbtcWithdrawalPhase & {
1709
- sweep_txid: string | null
1710
- signer_bitmap: string | null
1711
- }) | null
1712
- rejected: IndexSbtcWithdrawalPhase | null
1813
+ sweep_txid: string | null;
1814
+ signer_bitmap: string | null;
1815
+ }) | null;
1816
+ rejected: IndexSbtcWithdrawalPhase | null;
1713
1817
  settlement: {
1714
- sweep_txid: string | null
1715
- btc_confirmations: number | null
1716
- settlement_confirmed: boolean | null
1818
+ sweep_txid: string | null;
1819
+ btc_confirmations: number | null;
1820
+ settlement_confirmed: boolean | null;
1717
1821
  /** Confirming Bitcoin block height; null until the sweep confirms. */
1718
- btc_block_height: number | null
1822
+ btc_block_height: number | null;
1719
1823
  /** ISO timestamp the sweep first crossed the confirmation threshold. */
1720
- confirmed_at: string | null
1721
- }
1722
- finalized: boolean
1824
+ confirmed_at: string | null;
1825
+ };
1826
+ finalized: boolean;
1723
1827
  };
1724
1828
  /** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
1725
1829
  * per event across all topics. */
1726
1830
  type IndexSbtcEvent = {
1727
- cursor: string
1728
- block_height: number
1729
- block_time?: string | null
1730
- tx_id: string
1731
- tx_index: number
1732
- event_index: number
1733
- topic: SbtcEventTopic
1734
- request_id: number | null
1735
- amount: string | null
1736
- sender: string | null
1737
- recipient_btc_version: number | null
1738
- recipient_btc_hashbytes: string | null
1739
- bitcoin_txid: string | null
1740
- output_index: number | null
1741
- sweep_txid: string | null
1742
- burn_hash: string | null
1743
- burn_height: number | null
1744
- signer_bitmap: string | null
1745
- max_fee: string | null
1746
- fee: string | null
1747
- governance_contract_type: number | null
1748
- governance_new_contract: string | null
1749
- signer_aggregate_pubkey: string | null
1750
- signer_threshold: number | null
1751
- signer_address: string | null
1752
- signer_keys_count: number | null
1831
+ cursor: string;
1832
+ block_height: number;
1833
+ block_time?: string | null;
1834
+ tx_id: string;
1835
+ tx_index: number;
1836
+ event_index: number;
1837
+ topic: SbtcEventTopic;
1838
+ request_id: number | null;
1839
+ amount: string | null;
1840
+ sender: string | null;
1841
+ recipient_btc_version: number | null;
1842
+ recipient_btc_hashbytes: string | null;
1843
+ bitcoin_txid: string | null;
1844
+ output_index: number | null;
1845
+ sweep_txid: string | null;
1846
+ burn_hash: string | null;
1847
+ burn_height: number | null;
1848
+ signer_bitmap: string | null;
1849
+ max_fee: string | null;
1850
+ fee: string | null;
1851
+ governance_contract_type: number | null;
1852
+ governance_new_contract: string | null;
1853
+ signer_aggregate_pubkey: string | null;
1854
+ signer_threshold: number | null;
1855
+ signer_address: string | null;
1856
+ signer_keys_count: number | null;
1753
1857
  };
1754
1858
  /** The peg "scoreboard" — a single all-time canonical aggregate. */
1755
1859
  type IndexSbtcSummary = {
1756
- total_deposits: number
1757
- total_withdrawals_requested: number
1758
- total_withdrawals_accepted: number
1759
- total_withdrawals_rejected: number
1760
- net_peg_flow_sats: string
1761
- total_locked_sats: string
1762
- sbtc_supply_sats: string | null
1860
+ total_deposits: number;
1861
+ total_withdrawals_requested: number;
1862
+ total_withdrawals_accepted: number;
1863
+ total_withdrawals_rejected: number;
1864
+ net_peg_flow_sats: string;
1865
+ total_locked_sats: string;
1866
+ sbtc_supply_sats: string | null;
1763
1867
  };
1764
1868
  type SbtcDepositsEnvelope<TRow = IndexSbtcDeposit> = {
1765
- deposits: TRow[]
1766
- next_cursor: string | null
1767
- tip: IndexTip
1768
- reorgs: IndexReorg[]
1869
+ deposits: TRow[];
1870
+ next_cursor: string | null;
1871
+ tip: IndexTip;
1872
+ reorgs: IndexReorg[];
1769
1873
  /** Present only when the sBTC decoder is disabled, explaining an empty feed. */
1770
- notes?: string
1874
+ notes?: string;
1771
1875
  };
1772
1876
  type SbtcDepositEnvelope = {
1773
- deposit: IndexSbtcDepositDetail
1774
- tip: IndexTip
1877
+ deposit: IndexSbtcDepositDetail;
1878
+ tip: IndexTip;
1775
1879
  };
1776
1880
  type SbtcWithdrawalsEnvelope<TRow = IndexSbtcWithdrawal> = {
1777
- withdrawals: TRow[]
1778
- next_cursor: string | null
1779
- tip: IndexTip
1780
- reorgs: IndexReorg[]
1781
- notes?: string
1881
+ withdrawals: TRow[];
1882
+ next_cursor: string | null;
1883
+ tip: IndexTip;
1884
+ reorgs: IndexReorg[];
1885
+ notes?: string;
1782
1886
  };
1783
1887
  type SbtcWithdrawalEnvelope = {
1784
- withdrawal: IndexSbtcWithdrawalDetail
1785
- tip: IndexTip
1888
+ withdrawal: IndexSbtcWithdrawalDetail;
1889
+ tip: IndexTip;
1786
1890
  };
1787
1891
  type SbtcEventsEnvelope = {
1788
- events: IndexSbtcEvent[]
1789
- next_cursor: string | null
1790
- tip: IndexTip
1791
- reorgs: IndexReorg[]
1792
- notes?: string
1892
+ events: IndexSbtcEvent[];
1893
+ next_cursor: string | null;
1894
+ tip: IndexTip;
1895
+ reorgs: IndexReorg[];
1896
+ notes?: string;
1793
1897
  };
1794
1898
  type SbtcSummaryEnvelope = {
1795
- summary: IndexSbtcSummary
1796
- tip: IndexTip
1797
- notes?: string
1899
+ summary: IndexSbtcSummary;
1900
+ tip: IndexTip;
1901
+ notes?: string;
1798
1902
  };
1799
1903
  type SbtcDepositsListParams = {
1800
- cursor?: string | null
1801
- fromCursor?: string | null
1802
- limit?: number
1904
+ cursor?: string | null;
1905
+ fromCursor?: string | null;
1906
+ limit?: number;
1803
1907
  /** Clamp to the finality boundary — only settled deposits past the reorg margin. */
1804
- confirmed?: boolean
1805
- sender?: string
1806
- bitcoinTxid?: string
1807
- fromHeight?: number
1808
- toHeight?: number
1908
+ confirmed?: boolean;
1909
+ sender?: string;
1910
+ bitcoinTxid?: string;
1911
+ fromHeight?: number;
1912
+ toHeight?: number;
1809
1913
  /**
1810
1914
  * Columns to return. The server projects the row, so an unrequested column
1811
1915
  * is physically absent — and the narrowing overload on `list` makes reading
1812
1916
  * one a compile error rather than `undefined` at runtime.
1813
1917
  */
1814
- fields?: readonly (keyof IndexSbtcDeposit & string)[]
1918
+ fields?: readonly (keyof IndexSbtcDeposit & string)[];
1815
1919
  };
1816
1920
  /** Deposit columns that survive any projection — pagination needs them. */
1817
1921
  type SbtcDepositAlwaysFields = "cursor" | "block_height";
1818
1922
  /** A deposit row narrowed to the requested columns plus the always-present ones. */
1819
1923
  type SbtcDepositFields<F extends keyof IndexSbtcDeposit & string> = Pick<IndexSbtcDeposit, (F | SbtcDepositAlwaysFields) & keyof IndexSbtcDeposit>;
1820
1924
  type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
1821
- batchSize?: number
1822
- signal?: AbortSignal
1925
+ batchSize?: number;
1926
+ signal?: AbortSignal;
1823
1927
  };
1824
1928
  /** SbtcWithdrawal columns that survive any projection. */
1825
1929
  type SbtcWithdrawalAlwaysFields = "cursor" | "request_id";
@@ -1831,39 +1935,39 @@ type SbtcWithdrawalsListParams = {
1831
1935
  * is physically absent — and the narrowing overload on `list` makes reading
1832
1936
  * one a compile error rather than `undefined` at runtime.
1833
1937
  */
1834
- fields?: readonly (keyof IndexSbtcWithdrawal & string)[]
1835
- cursor?: string | null
1836
- fromCursor?: string | null
1837
- limit?: number
1838
- confirmed?: boolean
1839
- status?: SbtcWithdrawalStatus
1840
- sender?: string
1841
- requestId?: number
1938
+ fields?: readonly (keyof IndexSbtcWithdrawal & string)[];
1939
+ cursor?: string | null;
1940
+ fromCursor?: string | null;
1941
+ limit?: number;
1942
+ confirmed?: boolean;
1943
+ status?: SbtcWithdrawalStatus;
1944
+ sender?: string;
1945
+ requestId?: number;
1842
1946
  /** Filter by BTC L1 settlement: true → only confirmed sweeps; false → not
1843
1947
  * yet confirmed (pending or no sweep). */
1844
- settlementConfirmed?: boolean
1845
- fromHeight?: number
1846
- toHeight?: number
1948
+ settlementConfirmed?: boolean;
1949
+ fromHeight?: number;
1950
+ toHeight?: number;
1847
1951
  };
1848
1952
  type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
1849
- batchSize?: number
1850
- signal?: AbortSignal
1953
+ batchSize?: number;
1954
+ signal?: AbortSignal;
1851
1955
  };
1852
1956
  type SbtcEventsListParams = {
1853
- cursor?: string | null
1854
- fromCursor?: string | null
1855
- limit?: number
1856
- confirmed?: boolean
1857
- topic?: SbtcEventTopic
1858
- sender?: string
1859
- requestId?: number
1860
- bitcoinTxid?: string
1861
- fromHeight?: number
1862
- toHeight?: number
1957
+ cursor?: string | null;
1958
+ fromCursor?: string | null;
1959
+ limit?: number;
1960
+ confirmed?: boolean;
1961
+ topic?: SbtcEventTopic;
1962
+ sender?: string;
1963
+ requestId?: number;
1964
+ bitcoinTxid?: string;
1965
+ fromHeight?: number;
1966
+ toHeight?: number;
1863
1967
  };
1864
1968
  type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
1865
- batchSize?: number
1866
- signal?: AbortSignal
1969
+ batchSize?: number;
1970
+ signal?: AbortSignal;
1867
1971
  };
1868
1972
  type SbtcEventsConsumeParams<TTx = never> = Omit<SbtcEventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcEvent, SbtcEventsEnvelope, TTx>;
1869
1973
  type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
@@ -1874,98 +1978,98 @@ interface SbtcResource {
1874
1978
  /** Narrowing overload: `fields` shrinks the row type to exactly the
1875
1979
  * requested columns plus {@link SbtcDepositAlwaysFields}. */
1876
1980
  list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
1877
- fields: readonly F[]
1878
- }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>
1879
- list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>
1880
- walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>
1981
+ fields: readonly F[];
1982
+ }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
1983
+ list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
1984
+ walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
1881
1985
  /** Checkpointed sweep of completed deposits — append-only, so safe to
1882
1986
  * mirror. See {@link IndexConsumeOptions}. */
1883
1987
  consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
1884
- sink?: ConsumerSink<TTx>
1988
+ sink?: ConsumerSink<TTx>;
1885
1989
  }): Promise<{
1886
- cursor: string | null
1887
- pages: number
1888
- emptyPolls: number
1889
- }>
1990
+ cursor: string | null;
1991
+ pages: number;
1992
+ emptyPolls: number;
1993
+ }>;
1890
1994
  /** Fetch a completed deposit by Bitcoin txid; 404 → null. */
1891
- get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>
1995
+ get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
1892
1996
  };
1893
1997
  withdrawals: {
1894
1998
  /** Narrowing overload: `fields` shrinks the row type to exactly the
1895
1999
  * requested columns plus {@link SbtcWithdrawalAlwaysFields}. */
1896
2000
  list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
1897
- fields: readonly F[]
1898
- }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>
1899
- list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>
1900
- walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>
2001
+ fields: readonly F[];
2002
+ }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
2003
+ list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
2004
+ walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
1901
2005
  /** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
1902
- get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>
2006
+ get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
1903
2007
  };
1904
2008
  events: {
1905
- list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>
1906
- walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>
2009
+ list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
2010
+ walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
1907
2011
  /** Checkpointed sweep of the raw peg event log — append-only across all
1908
2012
  * six topics. See {@link IndexConsumeOptions}. */
1909
2013
  consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
1910
- sink?: ConsumerSink<TTx>
2014
+ sink?: ConsumerSink<TTx>;
1911
2015
  }): Promise<{
1912
- cursor: string | null
1913
- pages: number
1914
- emptyPolls: number
1915
- }>
2016
+ cursor: string | null;
2017
+ pages: number;
2018
+ emptyPolls: number;
2019
+ }>;
1916
2020
  };
1917
2021
  /** The peg scoreboard — a single all-time aggregate (no pagination). */
1918
2022
  summary(): Promise<SbtcSummaryEnvelope>;
1919
2023
  }
1920
2024
  /** Per-function action count within a reward cycle. */
1921
2025
  type IndexPoxFunctionCount = {
1922
- function_name: string
1923
- count: number
2026
+ function_name: string;
2027
+ count: number;
1924
2028
  };
1925
2029
  /** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
1926
2030
  * (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
1927
2031
  type IndexPoxCycle = {
1928
- reward_cycle: number
2032
+ reward_cycle: number;
1929
2033
  /** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
1930
- total_stacked_ustx: string
1931
- unique_stackers: number
1932
- unique_delegators: number
1933
- action_count: number
1934
- start_block_height: number
1935
- end_block_height: number
2034
+ total_stacked_ustx: string;
2035
+ unique_stackers: number;
2036
+ unique_delegators: number;
2037
+ action_count: number;
2038
+ start_block_height: number;
2039
+ end_block_height: number;
1936
2040
  /** True when this is the latest reward cycle (still accumulating new actions). */
1937
- is_current: boolean
1938
- function_breakdown: IndexPoxFunctionCount[]
2041
+ is_current: boolean;
2042
+ function_breakdown: IndexPoxFunctionCount[];
1939
2043
  };
1940
2044
  type PoxCyclesEnvelope = {
1941
- cycles: IndexPoxCycle[]
2045
+ cycles: IndexPoxCycle[];
1942
2046
  /** The next `reward_cycle` to page from (cycles descend), or null at the end. */
1943
- next_cursor: number | null
1944
- tip: IndexTip
2047
+ next_cursor: number | null;
2048
+ tip: IndexTip;
1945
2049
  /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
1946
- notes?: string
2050
+ notes?: string;
1947
2051
  };
1948
2052
  type PoxCycleEnvelope = {
1949
- cycle: IndexPoxCycle
1950
- tip: IndexTip
1951
- notes?: string
2053
+ cycle: IndexPoxCycle;
2054
+ tip: IndexTip;
2055
+ notes?: string;
1952
2056
  };
1953
2057
  type PoxCyclesListParams = {
1954
2058
  /** A `reward_cycle` to page from; the page returns cycles below it (descending). */
1955
- cursor?: number | null
1956
- limit?: number
2059
+ cursor?: number | null;
2060
+ limit?: number;
1957
2061
  };
1958
2062
  type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
1959
- batchSize?: number
1960
- signal?: AbortSignal
2063
+ batchSize?: number;
2064
+ signal?: AbortSignal;
1961
2065
  };
1962
2066
  /** `index.pox` — PoX reward-cycle aggregates. */
1963
2067
  interface PoxResource {
1964
2068
  cycles: {
1965
- list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>
1966
- walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>
2069
+ list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
2070
+ walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
1967
2071
  /** Fetch one reward cycle's aggregate by number; 404 → null. */
1968
- get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
2072
+ get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
1969
2073
  };
1970
2074
  }
1971
2075
  /** The decoded `pox-5` boot-contract print topics (SIP-045 Bitcoin Staking) —
@@ -1976,37 +2080,37 @@ type IndexPox5EventTopic = Pox5EventTopic;
1976
2080
  * `data` always carries the full decoded tuple, including nested shapes
1977
2081
  * (`btc-lockup`, `bond-rewards`, `bond-periods`) that have no flat column. */
1978
2082
  type IndexPox5Event = {
1979
- cursor: string
1980
- block_height: number
1981
- block_time: string | null
1982
- tx_id: string
1983
- tx_index: number
1984
- event_index: number
1985
- topic: IndexPox5EventTopic
1986
- staker: string | null
1987
- signer: string | null
1988
- signer_manager: string | null
1989
- bond_index: number | null
2083
+ cursor: string;
2084
+ block_height: number;
2085
+ block_time: string | null;
2086
+ tx_id: string;
2087
+ tx_index: number;
2088
+ event_index: number;
2089
+ topic: IndexPox5EventTopic;
2090
+ staker: string | null;
2091
+ signer: string | null;
2092
+ signer_manager: string | null;
2093
+ bond_index: number | null;
1990
2094
  /** ustx, bigint-safe string. */
1991
- amount_ustx: string | null
2095
+ amount_ustx: string | null;
1992
2096
  /** sats, bigint-safe string. */
1993
- amount_sats: string | null
1994
- reward_cycle: number | null
1995
- first_reward_cycle: number | null
1996
- unlock_cycle: number | null
1997
- unlock_burn_height: number | null
1998
- is_l1_lock: boolean | null
1999
- signer_key: string | null
2097
+ amount_sats: string | null;
2098
+ reward_cycle: number | null;
2099
+ first_reward_cycle: number | null;
2100
+ unlock_cycle: number | null;
2101
+ unlock_burn_height: number | null;
2102
+ is_l1_lock: boolean | null;
2103
+ signer_key: string | null;
2000
2104
  /** The full decoded print tuple as JSON. */
2001
- data: unknown
2105
+ data: unknown;
2002
2106
  };
2003
2107
  type Pox5EventsEnvelope<TRow = IndexPox5Event> = {
2004
- events: TRow[]
2005
- next_cursor: string | null
2006
- tip: IndexTip
2007
- reorgs: IndexReorg[]
2108
+ events: TRow[];
2109
+ next_cursor: string | null;
2110
+ tip: IndexTip;
2111
+ reorgs: IndexReorg[];
2008
2112
  /** Present only when the PoX-5 decoder is disabled, explaining an empty feed. */
2009
- notes?: string
2113
+ notes?: string;
2010
2114
  };
2011
2115
  /** Pox5Event columns that survive any projection. */
2012
2116
  type Pox5EventAlwaysFields = "cursor" | "block_height" | "topic";
@@ -2018,24 +2122,24 @@ type Pox5EventsListParams = {
2018
2122
  * is physically absent — and the narrowing overload on `list` makes reading
2019
2123
  * one a compile error rather than `undefined` at runtime.
2020
2124
  */
2021
- fields?: readonly (keyof IndexPox5Event & string)[]
2022
- cursor?: string | null
2023
- fromCursor?: string | null
2024
- limit?: number
2125
+ fields?: readonly (keyof IndexPox5Event & string)[];
2126
+ cursor?: string | null;
2127
+ fromCursor?: string | null;
2128
+ limit?: number;
2025
2129
  /** Clamp to the finality boundary — only rows past the reorg margin. */
2026
- confirmed?: boolean
2027
- topic?: IndexPox5EventTopic
2028
- staker?: string
2029
- signer?: string
2030
- signerManager?: string
2031
- bondIndex?: number
2032
- rewardCycle?: number
2033
- fromHeight?: number
2034
- toHeight?: number
2130
+ confirmed?: boolean;
2131
+ topic?: IndexPox5EventTopic;
2132
+ staker?: string;
2133
+ signer?: string;
2134
+ signerManager?: string;
2135
+ bondIndex?: number;
2136
+ rewardCycle?: number;
2137
+ fromHeight?: number;
2138
+ toHeight?: number;
2035
2139
  };
2036
2140
  type Pox5EventsWalkParams = Omit<Pox5EventsListParams, "limit"> & {
2037
- batchSize?: number
2038
- signal?: AbortSignal
2141
+ batchSize?: number;
2142
+ signal?: AbortSignal;
2039
2143
  };
2040
2144
  /** `index.pox5` — decoded PoX-5 print events, the staking primitive from the
2041
2145
  * epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
@@ -2044,10 +2148,10 @@ interface Pox5Resource {
2044
2148
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2045
2149
  * requested columns plus {@link Pox5EventAlwaysFields}. */
2046
2150
  list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
2047
- fields: readonly F[]
2048
- }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>
2049
- list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>
2050
- walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>
2151
+ fields: readonly F[];
2152
+ }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
2153
+ list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
2154
+ walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
2051
2155
  };
2052
2156
  }
2053
2157
  /**
@@ -2061,20 +2165,20 @@ interface FtTransfersResource {
2061
2165
  /** Narrowing overload for the callable shorthand — same wire path as
2062
2166
  * `list`, so it must narrow identically. */
2063
2167
  <const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2064
- fields: readonly F[]
2168
+ fields: readonly F[];
2065
2169
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2066
2170
  (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2067
2171
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2068
2172
  * requested columns plus {@link FtTransferAlwaysFields}. */
2069
2173
  list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2070
- fields: readonly F[]
2174
+ fields: readonly F[];
2071
2175
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2072
2176
  list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2073
2177
  /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2074
2178
  * wire, so without this the yielded rows are stripped while the type
2075
2179
  * still promises every column. */
2076
2180
  walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
2077
- fields: readonly F[]
2181
+ fields: readonly F[];
2078
2182
  }): AsyncIterable<FtTransferFields<F>>;
2079
2183
  walk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;
2080
2184
  }
@@ -2083,18 +2187,18 @@ interface NftTransfersResource {
2083
2187
  /** Narrowing overload for the callable shorthand — same wire path as
2084
2188
  * `list`, so it must narrow identically. */
2085
2189
  <const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2086
- fields: readonly F[]
2190
+ fields: readonly F[];
2087
2191
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2088
2192
  (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2089
2193
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2090
2194
  * requested columns plus {@link NftTransferAlwaysFields}. */
2091
2195
  list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2092
- fields: readonly F[]
2196
+ fields: readonly F[];
2093
2197
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2094
2198
  list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2095
2199
  /** Narrowing overload, matching `list` (see {@link FtTransfersResource}). */
2096
2200
  walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
2097
- fields: readonly F[]
2201
+ fields: readonly F[];
2098
2202
  }): AsyncIterable<NftTransferFields<F>>;
2099
2203
  walk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;
2100
2204
  }
@@ -2106,7 +2210,7 @@ interface IndexEventsResource {
2106
2210
  T extends IndexEventType,
2107
2211
  const F extends keyof IndexEventOf<T> & string
2108
2212
  >(params: EventsListParams<T> & {
2109
- fields: readonly F[]
2213
+ fields: readonly F[];
2110
2214
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2111
2215
  <T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2112
2216
  /** Narrowing overload: `fields` shrinks the returned row type to exactly
@@ -2116,7 +2220,7 @@ interface IndexEventsResource {
2116
2220
  T extends IndexEventType,
2117
2221
  const F extends keyof IndexEventOf<T> & string
2118
2222
  >(params: EventsListParams<T> & {
2119
- fields: readonly F[]
2223
+ fields: readonly F[];
2120
2224
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2121
2225
  list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2122
2226
  /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
@@ -2126,33 +2230,33 @@ interface IndexEventsResource {
2126
2230
  T extends IndexEventType,
2127
2231
  const F extends keyof IndexEventOf<T> & string
2128
2232
  >(params: EventsWalkParams<T> & {
2129
- fields: readonly F[]
2233
+ fields: readonly F[];
2130
2234
  }): AsyncIterable<IndexEventFields<T, F>>;
2131
2235
  walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
2132
2236
  consume<
2133
2237
  T extends IndexEventType,
2134
2238
  TTx = never
2135
2239
  >(params: EventsConsumeParams<T, TTx> & {
2136
- sink?: ConsumerSink<TTx>
2240
+ sink?: ConsumerSink<TTx>;
2137
2241
  }): Promise<{
2138
- cursor: string | null
2139
- pages: number
2140
- emptyPolls: number
2242
+ cursor: string | null;
2243
+ pages: number;
2244
+ emptyPolls: number;
2141
2245
  }>;
2142
2246
  }
2143
2247
  /** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */
2144
2248
  type IndexEventTypeFilters = {
2145
- columns?: string[]
2146
- allowed_filters?: string[]
2147
- equality_filters?: string[]
2148
- required_non_null?: string[]
2249
+ columns?: string[];
2250
+ allowed_filters?: string[];
2251
+ equality_filters?: string[];
2252
+ required_non_null?: string[];
2149
2253
  };
2150
2254
  /** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.
2151
2255
  * Shape is intentionally open (the server may add fields); the agent-relevant
2152
2256
  * parts are the per-type filter rules. */
2153
2257
  type IndexDiscovery = {
2154
- event_type_filters?: Record<string, IndexEventTypeFilters>
2155
- [key: string]: unknown
2258
+ event_type_filters?: Record<string, IndexEventTypeFilters>;
2259
+ [key: string]: unknown;
2156
2260
  };
2157
2261
  declare class Index extends BaseClient {
2158
2262
  constructor(options?: Partial<SecondLayerOptions>);
@@ -2178,27 +2282,27 @@ declare class Index extends BaseClient {
2178
2282
  * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
2179
2283
  readonly events: IndexEventsResource;
2180
2284
  readonly contractCalls: {
2181
- list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>
2182
- walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>
2285
+ list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
2286
+ walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
2183
2287
  consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
2184
- sink?: ConsumerSink<TTx>
2288
+ sink?: ConsumerSink<TTx>;
2185
2289
  }) => Promise<{
2186
- cursor: string | null
2187
- pages: number
2188
- emptyPolls: number
2189
- }>
2290
+ cursor: string | null;
2291
+ pages: number;
2292
+ emptyPolls: number;
2293
+ }>;
2190
2294
  };
2191
2295
  /** Canonical block-hash map — sync only the current canonical chain. */
2192
2296
  readonly canonical: {
2193
- list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>
2194
- walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>
2297
+ list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
2298
+ walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
2195
2299
  };
2196
2300
  /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
2197
2301
  * (resolves to null on 404). */
2198
2302
  readonly blocks: {
2199
- list: (params?: BlocksListParams) => Promise<BlocksEnvelope>
2200
- walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>
2201
- get: (ref: string | number) => Promise<BlockEnvelope | null>
2303
+ list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
2304
+ walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
2305
+ get: (ref: string | number) => Promise<BlockEnvelope | null>;
2202
2306
  };
2203
2307
  /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
2204
2308
  * (resolves to null on 404). */
@@ -2209,26 +2313,26 @@ declare class Index extends BaseClient {
2209
2313
  * overloads. */
2210
2314
  list: {
2211
2315
  <const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
2212
- fields: readonly F[]
2213
- }): Promise<TransactionsEnvelope<TransactionFields<F>>>
2214
- (params?: TransactionsListParams): Promise<TransactionsEnvelope>
2215
- }
2216
- walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>
2217
- get: (txId: string) => Promise<TransactionEnvelope | null>
2218
- getProof: (txId: string) => Promise<TransactionProof | null>
2316
+ fields: readonly F[];
2317
+ }): Promise<TransactionsEnvelope<TransactionFields<F>>>;
2318
+ (params?: TransactionsListParams): Promise<TransactionsEnvelope>;
2319
+ };
2320
+ walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
2321
+ get: (txId: string) => Promise<TransactionEnvelope | null>;
2322
+ getProof: (txId: string) => Promise<TransactionProof | null>;
2219
2323
  };
2220
2324
  /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
2221
2325
  * platform's PoX-4 decoder is disabled. */
2222
2326
  readonly stacking: {
2223
- list: (params?: StackingListParams) => Promise<StackingEnvelope>
2224
- walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
2327
+ list: (params?: StackingListParams) => Promise<StackingEnvelope>;
2328
+ walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
2225
2329
  };
2226
2330
  /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
2227
2331
  * tx_id (resolves to null when the tx has confirmed or dropped). */
2228
2332
  readonly mempool: {
2229
- list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
2230
- walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
2231
- get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
2333
+ list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
2334
+ walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
2335
+ get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
2232
2336
  };
2233
2337
  /** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
2234
2338
  * Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
@@ -2341,7 +2445,7 @@ declare class Projects extends BaseClient {
2341
2445
  constructor(options?: Partial<SecondLayerOptions>);
2342
2446
  /** All projects owned by the account, newest-relevant first. */
2343
2447
  list(): Promise<{
2344
- projects: Project[]
2448
+ projects: Project[];
2345
2449
  }>;
2346
2450
  /** A single project by slug. */
2347
2451
  get(slug: string): Promise<Project>;
@@ -2351,7 +2455,7 @@ declare class Projects extends BaseClient {
2351
2455
  update(slug: string, patch: UpdateProjectParams): Promise<Project>;
2352
2456
  /** Delete a project. The account's last remaining project cannot be deleted. */
2353
2457
  delete(slug: string): Promise<{
2354
- ok: true
2458
+ ok: true;
2355
2459
  }>;
2356
2460
  /** Team members and pending invitations for a project. */
2357
2461
  team(slug: string): Promise<ProjectTeam>;
@@ -2359,7 +2463,7 @@ declare class Projects extends BaseClient {
2359
2463
  import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, SubscriptionTestResult, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
2360
2464
  declare class Subscriptions extends BaseClient {
2361
2465
  list(): Promise<{
2362
- data: SubscriptionSummary[]
2466
+ data: SubscriptionSummary[];
2363
2467
  }>;
2364
2468
  get(id: string): Promise<SubscriptionDetail>;
2365
2469
  create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
@@ -2367,25 +2471,25 @@ declare class Subscriptions extends BaseClient {
2367
2471
  pause(id: string): Promise<SubscriptionDetail>;
2368
2472
  resume(id: string): Promise<SubscriptionDetail>;
2369
2473
  delete(id: string): Promise<{
2370
- ok: true
2474
+ ok: true;
2371
2475
  }>;
2372
2476
  rotateSecret(id: string): Promise<RotateSecretResponse>;
2373
2477
  /** Send a one-off test webhook to the subscription's URL (built for its
2374
2478
  * format, SSRF-guarded). Logged as a delivery row, visible via recentDeliveries. */
2375
2479
  test(id: string): Promise<SubscriptionTestResult>;
2376
2480
  recentDeliveries(id: string): Promise<{
2377
- data: DeliveryRow[]
2481
+ data: DeliveryRow[];
2378
2482
  }>;
2379
2483
  replay(id: string, range: {
2380
- fromBlock: number
2381
- toBlock: number
2382
- force?: string
2484
+ fromBlock: number;
2485
+ toBlock: number;
2486
+ force?: string;
2383
2487
  }): Promise<ReplayResult>;
2384
2488
  dead(id: string): Promise<{
2385
- data: DeadRow[]
2489
+ data: DeadRow[];
2386
2490
  }>;
2387
2491
  requeueDead(id: string, outboxId: string): Promise<{
2388
- ok: true
2492
+ ok: true;
2389
2493
  }>;
2390
2494
  }
2391
2495
  interface ContextAccount {
@@ -2423,8 +2527,8 @@ interface ContextSnapshot {
2423
2527
  indexTip: IndexTip | null;
2424
2528
  subgraphs: SubgraphSummary2[] | null;
2425
2529
  subscriptions: {
2426
- count: number
2427
- byStatus: Record<string, number>
2530
+ count: number;
2531
+ byStatus: Record<string, number>;
2428
2532
  } | null;
2429
2533
  /** The account's projects (null when unreadable — e.g. a scoped key). */
2430
2534
  projects: ContextProject[] | null;
@@ -2453,14 +2557,14 @@ declare class SecondLayer extends BaseClient {
2453
2557
  * PAYMENT-BALANCE/SESSION) apply to every item.
2454
2558
  */
2455
2559
  batch(requests: Array<{
2456
- path: string
2457
- params?: Record<string, string | number | boolean>
2560
+ path: string;
2561
+ params?: Record<string, string | number | boolean>;
2458
2562
  }>): Promise<{
2459
2563
  results: Array<{
2460
- path: string | null
2461
- status: number
2462
- body: unknown
2463
- }>
2564
+ path: string | null;
2565
+ status: number;
2566
+ body: unknown;
2567
+ }>;
2464
2568
  }>;
2465
2569
  context(): Promise<ContextSnapshot>;
2466
2570
  }
@@ -2479,8 +2583,8 @@ declare class SecondLayer extends BaseClient {
2479
2583
  * ```
2480
2584
  */
2481
2585
  declare function getSubgraph<T extends {
2482
- name: string
2483
- schema: Record<string, unknown>
2586
+ name: string;
2587
+ schema: Record<string, unknown>;
2484
2588
  }>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
2485
2589
  import { SubgraphAgentSchema as SubgraphAgentSchema2, SubgraphSpecFormat, SubgraphSpecOptions as SubgraphSpecOptions2 } from "@secondlayer/shared/subgraphs/spec";
2486
2590
  export { getSubgraph, Subgraphs, SubgraphSpecOptions2 as SubgraphSpecOptions, SubgraphSpecFormat, SubgraphAgentSchema2 as SubgraphAgentSchema, SecondLayerOptions };