@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.
package/dist/index.d.ts CHANGED
@@ -69,9 +69,9 @@ interface SubgraphRowsEnvelope<T = unknown> {
69
69
  rows: T[];
70
70
  next_cursor: string | null;
71
71
  tip: {
72
- block_height: number
73
- subgraph_height: number
74
- blocks_behind: number
72
+ block_height: number;
73
+ subgraph_height: number;
74
+ blocks_behind: number;
75
75
  };
76
76
  }
77
77
  interface BundleSubgraphResponse {
@@ -87,34 +87,34 @@ interface BundleSubgraphResponse {
87
87
  }
88
88
  declare class Subgraphs extends BaseClient {
89
89
  list(): Promise<{
90
- data: SubgraphSummary[]
90
+ data: SubgraphSummary[];
91
91
  }>;
92
92
  get(name: string): Promise<SubgraphDetail>;
93
93
  openapi(name: string, options?: SubgraphSpecOptions): Promise<Record<string, unknown>>;
94
94
  schema(name: string, options?: SubgraphSpecOptions): Promise<SubgraphAgentSchema>;
95
95
  markdown(name: string, options?: SubgraphSpecOptions): Promise<string>;
96
96
  reindex(name: string, options?: {
97
- fromBlock?: number
98
- toBlock?: number
97
+ fromBlock?: number;
98
+ toBlock?: number;
99
99
  }): Promise<ReindexResponse>;
100
100
  stop(name: string): Promise<{
101
- message: string
102
- operationId?: string
103
- status?: string
101
+ message: string;
102
+ operationId?: string;
103
+ status?: string;
104
104
  }>;
105
105
  backfill(name: string, options: {
106
- fromBlock: number
107
- toBlock: number
106
+ fromBlock: number;
107
+ toBlock: number;
108
108
  }): Promise<ReindexResponse>;
109
109
  gaps(name: string, opts?: {
110
- limit?: number
111
- offset?: number
112
- resolved?: boolean
110
+ limit?: number;
111
+ offset?: number;
112
+ resolved?: boolean;
113
113
  }): Promise<SubgraphGapsResponse>;
114
114
  delete(name: string, options?: {
115
- force?: boolean
115
+ force?: boolean;
116
116
  }): Promise<{
117
- message: string
117
+ message: string;
118
118
  }>;
119
119
  /**
120
120
  * Publish: claim the name in the global public namespace and open anon
@@ -122,14 +122,14 @@ declare class Subgraphs extends BaseClient {
122
122
  * holds the public name.
123
123
  */
124
124
  publish(name: string): Promise<{
125
- name: string
126
- visibility: "public"
127
- url: string
125
+ name: string;
126
+ visibility: "public";
127
+ url: string;
128
128
  }>;
129
129
  /** Make reads private again (owning account's bearer key required). */
130
130
  unpublish(name: string): Promise<{
131
- name: string
132
- visibility: "private"
131
+ name: string;
132
+ visibility: "private";
133
133
  }>;
134
134
  /**
135
135
  * Open /v1 read: cursor-paginated rows. Anon works for public subgraphs;
@@ -137,11 +137,11 @@ declare class Subgraphs extends BaseClient {
137
137
  * `next_cursor`.
138
138
  */
139
139
  rows<T = unknown>(name: string, table: string, params?: Omit<SubgraphQueryParams, "offset" | "sort"> & {
140
- cursor?: string
140
+ cursor?: string;
141
141
  }): Promise<SubgraphRowsEnvelope<T>>;
142
142
  /** Recent reindex/backfill operations for a subgraph, newest first. */
143
143
  operations(name: string): Promise<{
144
- operations: SubgraphOperationStatus[]
144
+ operations: SubgraphOperationStatus[];
145
145
  }>;
146
146
  /** Status of a single operation (poll the `operationId` returned by
147
147
  * reindex/backfill/stop until `status` is terminal). */
@@ -153,11 +153,11 @@ declare class Subgraphs extends BaseClient {
153
153
  * authoring loop so Vercel's serverless runtime doesn't have to run esbuild.
154
154
  */
155
155
  bundle(data: {
156
- code: string
156
+ code: string;
157
157
  }): Promise<BundleSubgraphResponse>;
158
158
  queryTable(name: string, table: string, params?: SubgraphQueryParams): Promise<unknown[]>;
159
159
  queryTableCount(name: string, table: string, params?: SubgraphQueryParams): Promise<{
160
- count: number
160
+ count: number;
161
161
  }>;
162
162
  queryTableAggregate(name: string, table: string, params?: SubgraphAggregateParams): Promise<SubgraphAggregateResponse>;
163
163
  /**
@@ -173,8 +173,8 @@ declare class Subgraphs extends BaseClient {
173
173
  * ```
174
174
  */
175
175
  typed<T extends {
176
- name: string
177
- schema: Record<string, unknown>
176
+ name: string;
177
+ schema: Record<string, unknown>;
178
178
  }>(def: T): InferSubgraphClient<T>;
179
179
  private createTableClient;
180
180
  }
@@ -229,12 +229,12 @@ declare class ApiKeys extends BaseClient {
229
229
  * account-level (owner) key or a dashboard session.
230
230
  */
231
231
  list(): Promise<{
232
- keys: ApiKeySummary[]
232
+ keys: ApiKeySummary[];
233
233
  }>;
234
234
  /** Revoke a key by id. Existing requests with that key stop working. */
235
235
  revoke(id: string): Promise<{
236
- revoked: true
237
- id: string
236
+ revoked: true;
237
+ id: string;
238
238
  }>;
239
239
  }
240
240
  /**
@@ -282,7 +282,7 @@ declare class Contracts extends BaseClient {
282
282
  * Pass `{ includeAbi: true }` for the full ABI blob. Resolves null on 404.
283
283
  */
284
284
  get(contractId: string, opts?: {
285
- includeAbi?: boolean
285
+ includeAbi?: boolean;
286
286
  }): Promise<ContractSummary | null>;
287
287
  }
288
288
  import { Pox5EventTopic } from "@secondlayer/stacks/pox5";
@@ -320,8 +320,8 @@ interface TransactionProof {
320
320
  /** Present when consensus-level verification is available: the reward cycle and
321
321
  * its signer set, against which the header's signer signatures are checked. */
322
322
  consensus?: {
323
- reward_cycle: number
324
- reward_set: RewardSet
323
+ reward_cycle: number;
324
+ reward_set: RewardSet;
325
325
  };
326
326
  }
327
327
  interface TransactionProofVerifyResult {
@@ -353,9 +353,9 @@ interface TransactionProofVerifyResult {
353
353
  * `verifyTransactionProof(proof, { rewardSet })`.
354
354
  */
355
355
  declare function fetchRewardSet(opts: {
356
- nodeUrl: string
357
- cycle: number
358
- fetchImpl?: typeof fetch
356
+ nodeUrl: string;
357
+ cycle: number;
358
+ fetchImpl?: typeof fetch;
359
359
  }): Promise<RewardSet | null>;
360
360
  /**
361
361
  * Verify a transaction-inclusion proof. Every check is recomputed client-side,
@@ -365,7 +365,7 @@ declare function fetchRewardSet(opts: {
365
365
  * embedded in the proof.
366
366
  */
367
367
  declare function verifyTransactionProof(proof: TransactionProof, opts?: {
368
- rewardSet?: RewardSet
368
+ rewardSet?: RewardSet;
369
369
  }): TransactionProofVerifyResult;
370
370
  /**
371
371
  * A consumer sink: the destination adapter a consume loop writes through.
@@ -382,12 +382,83 @@ declare function verifyTransactionProof(proof: TransactionProof, opts?: {
382
382
  * The interface is dependency-free on purpose: implementations with real
383
383
  * database drivers live behind subpath exports (`@secondlayer/sdk/sinks/*`)
384
384
  * so the root entry ships no DB dependency.
385
+ *
386
+ * ## The contract
387
+ *
388
+ * Binding on every implementation; the conformance kit
389
+ * (`@secondlayer/sdk/sinks/testing`) probes each one. Violations are SILENT
390
+ * in production — they surface as gaps or duplicates weeks later, never as
391
+ * errors at the violation site — which is why they are spelled out here and
392
+ * mechanically tested.
393
+ *
394
+ * What the loop guarantees the sink:
395
+ *
396
+ * 1. **Init-before-first-page.** `loadCursor` is called exactly once, before
397
+ * the first fetch — even when the caller passed an explicit `fromCursor`.
398
+ * It is the sink's init hook: create checkpoint storage, validate
399
+ * rollback preconditions.
400
+ * 2. **Deterministic replay.** Re-reading from the same cursor yields the
401
+ * same rows in the same order. `cursor` is therefore a valid idempotency
402
+ * key: an append-only sink can dedup on it with no contract change.
403
+ * 3. **At-least-once delivery.** A batch whose commit outcome was lost (crash
404
+ * after commit, before the loop observed it) is re-committed on restart
405
+ * with the SAME cursor and the same rows.
406
+ *
407
+ * What the sink must guarantee — `commitBatch`:
408
+ *
409
+ * 4. **Rows+cursor atomicity.** The handler's writes and `cursor` commit in
410
+ * ONE transaction. Committing them separately is the classic torn-batch
411
+ * bug: a crash between the two either re-delivers (duplicates) or skips
412
+ * (gap) depending on the order.
413
+ * 5. **Abort on throw.** A throw from `write` aborts the WHOLE transaction —
414
+ * neither rows nor cursor land — so a crashed batch is simply re-read.
415
+ * 6. **The lent transaction is the real one.** `write(tx)` receives the same
416
+ * live transaction the cursor commits in; every handler write must go
417
+ * through it. Writes outside `tx` escape atomicity AND rollback.
418
+ * 7. **Replay safety.** Committing the same cursor twice must not corrupt
419
+ * state (per #3 the rows are identical; upsert/dedup make it exact).
420
+ *
421
+ * What the sink must guarantee — `rollback`:
422
+ *
423
+ * 8. **Delete+rewind atomicity.** Undoing rows at/above the fork and
424
+ * committing `rewindCursor` happen in ONE transaction. A crash between
425
+ * them resumes above the fork and the deleted range is never re-read —
426
+ * the silent-gap bug.
427
+ * 9. **Inclusive fork point.** Undo AT OR ABOVE `forkPointHeight` (`>=`) —
428
+ * the new canonical chain re-supplies the fork block itself.
429
+ * 10. **Idempotent.** The loop may re-apply the same rollback after a crash
430
+ * (reorgs are deduped in memory only); a second application must be a
431
+ * harmless no-op.
432
+ * 11. **Scope by height, not cursor.** On a page reporting several forks the
433
+ * loop calls `rollback` once per fork: each call carries its own
434
+ * `forkPointHeight` but ALL carry the same `rewindCursor` (the lowest
435
+ * fork point). Derive the undo range from `forkPointHeight` only; a
436
+ * sink that derives it from `rewindCursor` under-deletes silently.
437
+ *
438
+ * Error semantics and concurrency:
439
+ *
440
+ * 12. **Throw, don't swallow; no internal retry.** The loop owns retry
441
+ * policy. A swallowed commit error advances the loop past unwritten
442
+ * data; an internal retry can double-apply around a partial failure.
443
+ * 13. **Single writer per checkpoint id.** The loop assumes one live
444
+ * consumer per checkpoint identity. A sink that can detect a second
445
+ * writer (e.g. a lock) must fail loudly — never block or interleave.
385
446
  */
386
447
  interface ConsumerSink<Tx = unknown> {
387
448
  /** Phantom marker carrying `Tx` in a directly-inferable position, so the
388
449
  * consume loops' `TTx` type parameter resolves from the `sink` option
389
450
  * (never set at runtime). */
390
451
  readonly _tx?: Tx;
452
+ /** Static capabilities, read by the loop before the first fetch to fail
453
+ * fast on impossible pairings. */
454
+ readonly capabilities?: {
455
+ /** This sink cannot undo committed rows (append-only store, ClickHouse,
456
+ * parquet, …), so `rollback` is unimplementable and following the
457
+ * unfinalized tip would corrupt it on the first fork. The loop throws
458
+ * loudly unless consuming with `finalizedOnly: true` — in that mode
459
+ * reorgs never reach the sink and `rollback` may simply throw. */
460
+ finalizedOnly?: boolean;
461
+ };
391
462
  /** The committed checkpoint, or `null` on first run. Called once, before
392
463
  * the first page. Implementations may create their checkpoint storage
393
464
  * here and SHOULD validate their rollback preconditions (e.g. that every
@@ -407,6 +478,11 @@ interface ConsumerSink<Tx = unknown> {
407
478
  * without the rewound cursor is the classic silent-gap bug: a crash
408
479
  * between the two writes resumes above the fork and the deleted range is
409
480
  * never re-read.
481
+ *
482
+ * On a multi-fork page this is called once PER fork, every call with the
483
+ * same `rewindCursor` (the lowest fork point) but its own
484
+ * `forkPointHeight` — scope the undo by `forkPointHeight` only (contract
485
+ * invariant #11), and expect re-application after a crash (#10).
410
486
  */
411
487
  rollback(forkPointHeight: number, rewindCursor: string): Promise<void>;
412
488
  }
@@ -416,75 +492,75 @@ type SinkTx<S> = S extends ConsumerSink<infer Tx> ? Tx : never;
416
492
  * is unchanged (an intersection with `unknown` is an identity, so
417
493
  * contextual typing of `onBatch` callbacks never degrades to a union). */
418
494
  type WithSinkTx<TTx> = [TTx] extends [never] ? unknown : {
419
- tx: TTx
495
+ tx: TTx;
420
496
  };
421
497
  import { StreamsEventType } from "@secondlayer/shared";
422
498
  /** A Clarity value as Streams serves it: the canonical hex string, a typed
423
499
  * object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
424
500
  * Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
425
501
  type StreamsClarityValue = string | {
426
- hex: string
502
+ hex: string;
427
503
  } | Record<string, unknown>;
428
504
  type StxTransferPayload = {
429
- sender: string
430
- recipient: string
431
- amount: string
432
- memo?: string
505
+ sender: string;
506
+ recipient: string;
507
+ amount: string;
508
+ memo?: string;
433
509
  };
434
510
  type StxMintPayload = {
435
- recipient: string
436
- amount: string
511
+ recipient: string;
512
+ amount: string;
437
513
  };
438
514
  type StxBurnPayload = {
439
- sender: string
440
- amount: string
515
+ sender: string;
516
+ amount: string;
441
517
  };
442
518
  type StxLockPayload = {
443
- locked_address: string
444
- locked_amount: string
445
- unlock_height: string
519
+ locked_address: string;
520
+ locked_amount: string;
521
+ unlock_height: string;
446
522
  };
447
523
  type FtTransferPayload = {
448
- asset_identifier: string
449
- sender: string
450
- recipient: string
451
- amount: string
524
+ asset_identifier: string;
525
+ sender: string;
526
+ recipient: string;
527
+ amount: string;
452
528
  };
453
529
  type FtMintPayload = {
454
- asset_identifier: string
455
- recipient: string
456
- amount: string
530
+ asset_identifier: string;
531
+ recipient: string;
532
+ amount: string;
457
533
  };
458
534
  type FtBurnPayload = {
459
- asset_identifier: string
460
- sender: string
461
- amount: string
535
+ asset_identifier: string;
536
+ sender: string;
537
+ amount: string;
462
538
  };
463
539
  type NftTransferPayload = {
464
- asset_identifier: string
465
- sender: string
466
- recipient: string
467
- value: StreamsClarityValue
540
+ asset_identifier: string;
541
+ sender: string;
542
+ recipient: string;
543
+ value: StreamsClarityValue;
468
544
  /** Canonical serialized hex of `value`, when the stream carries it. */
469
- raw_value?: string
545
+ raw_value?: string;
470
546
  };
471
547
  type NftMintPayload = {
472
- asset_identifier: string
473
- recipient: string
474
- value: StreamsClarityValue
475
- raw_value?: string
548
+ asset_identifier: string;
549
+ recipient: string;
550
+ value: StreamsClarityValue;
551
+ raw_value?: string;
476
552
  };
477
553
  type NftBurnPayload = {
478
- asset_identifier: string
479
- sender: string
480
- value: StreamsClarityValue
481
- raw_value?: string
554
+ asset_identifier: string;
555
+ sender: string;
556
+ value: StreamsClarityValue;
557
+ raw_value?: string;
482
558
  };
483
559
  type PrintPayload = {
484
- contract_id?: string | null
485
- topic?: string
486
- value?: unknown
487
- raw_value?: string
560
+ contract_id?: string | null;
561
+ topic?: string;
562
+ value?: unknown;
563
+ raw_value?: string;
488
564
  };
489
565
  /** Union of every Streams payload shape, discriminated by `event_type` on the
490
566
  * parent `StreamsEvent`. */
@@ -495,92 +571,97 @@ type StreamsEventBase = {
495
571
  * it as the primary key of your projection rows — replaying a batch then
496
572
  * upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
497
573
  */
498
- cursor: string
499
- block_height: number
500
- block_hash: string
501
- burn_block_height: number
502
- tx_id: string
503
- tx_index: number
504
- event_index: number
505
- contract_id: string | null
506
- ts: string
574
+ cursor: string;
575
+ block_height: number;
576
+ block_hash: string;
577
+ burn_block_height: number;
578
+ tx_id: string;
579
+ tx_index: number;
580
+ event_index: number;
581
+ contract_id: string | null;
582
+ ts: string;
507
583
  /**
508
584
  * True when this event's block is past the finality boundary (immutable).
509
585
  * Optional for back-compat; the API always sets it on Streams responses.
510
586
  */
511
- finalized?: boolean
587
+ finalized?: boolean;
512
588
  /**
513
589
  * Labels whose filter group this event satisfied, present only when the
514
590
  * request used a labelled `filters` map. The SDK dispatches on it for you
515
591
  * (`on.<label>`), so handlers rarely read it directly.
516
592
  */
517
- matched?: string[]
593
+ matched?: string[];
518
594
  };
519
595
  type StreamsEventOf<
520
596
  T extends StreamsEventType,
521
597
  P
522
598
  > = StreamsEventBase & {
523
- event_type: T
524
- payload: P
599
+ event_type: T;
600
+ payload: P;
525
601
  };
526
602
  /** A raw Streams event. Discriminated on `event_type`, so `event.payload`
527
603
  * narrows to the matching payload shape once the type is checked. */
528
604
  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>;
529
605
  type StreamsTip = {
530
- block_height: number
531
- block_hash: string
532
- burn_block_height: number
606
+ block_height: number;
607
+ block_hash: string;
608
+ burn_block_height: number;
533
609
  /**
534
610
  * Highest Stacks block past the burn-confirmation finality boundary.
535
611
  * Optional for back-compat; the API always sets it.
536
612
  */
537
- finalized_height?: number
538
- lag_seconds: number
613
+ finalized_height?: number;
614
+ lag_seconds: number;
539
615
  /**
540
616
  * Oldest height still seekable on the live API for the caller's tier
541
617
  * (`tip - retention`). `null` = unlimited retention. Older reads must use the
542
618
  * cold dumps lane. Optional for back-compat.
543
619
  */
544
- oldest_seekable_height?: number | null
620
+ oldest_seekable_height?: number | null;
545
621
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
546
- oldest_cursor?: string | null
622
+ oldest_cursor?: string | null;
547
623
  };
548
624
  type StreamsCanonicalBlock = {
549
- block_height: number
550
- block_hash: string
551
- burn_block_height: number
552
- burn_block_hash: string | null
553
- is_canonical: true
625
+ block_height: number;
626
+ block_hash: string;
627
+ burn_block_height: number;
628
+ burn_block_hash: string | null;
629
+ is_canonical: true;
554
630
  };
555
631
  type StreamsReorg = {
556
- detected_at: string
557
- fork_point_height: number
632
+ detected_at: string;
633
+ fork_point_height: number;
558
634
  orphaned_range: {
559
- from: string
560
- to: string
561
- }
635
+ from: string;
636
+ to: string;
637
+ };
562
638
  /**
563
639
  * First position of the new canonical chain at the fork, `fork:0`
564
640
  * (INCLUSIVE). Not an exclusive resume token — resuming directly from it
565
641
  * skips `fork:0`. The consumer rewinds to the foot of `fork_point_height`
566
642
  * (`Cursor.atHeight`) to re-read the new run from `fork:0` inclusive.
567
643
  */
568
- new_canonical_tip: string
644
+ new_canonical_tip: string;
569
645
  };
570
- type StreamsEventsEnvelope = {
571
- events: StreamsEvent[]
572
- next_cursor: string | null
573
- tip: StreamsTip
574
- reorgs: StreamsReorg[]
646
+ type StreamsEventsEnvelope<TEvent = StreamsEvent> = {
647
+ events: TEvent[];
648
+ next_cursor: string | null;
649
+ tip: StreamsTip;
650
+ reorgs: StreamsReorg[];
575
651
  };
576
652
  type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
653
+ /** The StreamsEvent union narrowed to a `types` selection — what a
654
+ * const-generic `types: ["ft_transfer"]` buys at the type level. */
655
+ type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
656
+ event_type: T[number];
657
+ }>;
577
658
  type StreamsReorgsListParams = {
578
- since: string
579
- limit?: number
659
+ since: string;
660
+ limit?: number;
580
661
  };
581
662
  type StreamsReorgsListEnvelope = {
582
- reorgs: StreamsReorg[]
583
- next_since: string | null
663
+ reorgs: StreamsReorg[];
664
+ next_since: string | null;
584
665
  };
585
666
  /** A filter that matches a single value or any value in a list. */
586
667
  type StreamsFilterValue = string | readonly string[];
@@ -589,11 +670,11 @@ type StreamsFilterValue = string | readonly string[];
589
670
  * map OR together server-side.
590
671
  */
591
672
  type StreamsLabelledFilter = {
592
- types?: readonly StreamsEventType[]
593
- contractId?: StreamsFilterValue
594
- sender?: StreamsFilterValue
595
- recipient?: StreamsFilterValue
596
- assetIdentifier?: string
673
+ types?: readonly StreamsEventType[];
674
+ contractId?: StreamsFilterValue;
675
+ sender?: StreamsFilterValue;
676
+ recipient?: StreamsFilterValue;
677
+ assetIdentifier?: string;
597
678
  };
598
679
  /** A map of label → filter group. Labels are yours; the server echoes them. */
599
680
  type StreamsFilterMap = Record<string, StreamsLabelledFilter>;
@@ -606,65 +687,65 @@ type StreamsEventForFilter<
606
687
  F,
607
688
  D extends boolean = false
608
689
  > = F extends {
609
- types: readonly (infer T extends StreamsEventType)[]
690
+ types: readonly (infer T extends StreamsEventType)[];
610
691
  } ? D extends true ? Extract<IndexEvent, {
611
- event_type: T
692
+ event_type: T;
612
693
  }> : Extract<StreamsEvent, {
613
- event_type: T
694
+ event_type: T;
614
695
  }> : D extends true ? IndexEvent : StreamsEvent;
615
696
  type StreamsEventsListParams = {
616
- cursor?: string | null
617
- fromHeight?: number
618
- toHeight?: number
619
- types?: readonly StreamsEventType[]
697
+ cursor?: string | null;
698
+ fromHeight?: number;
699
+ toHeight?: number;
700
+ types?: readonly StreamsEventType[];
620
701
  /** Event types to exclude (applied after `types`). */
621
- notTypes?: readonly StreamsEventType[]
622
- contractId?: StreamsFilterValue
623
- sender?: StreamsFilterValue
624
- recipient?: StreamsFilterValue
625
- assetIdentifier?: string
702
+ notTypes?: readonly StreamsEventType[];
703
+ contractId?: StreamsFilterValue;
704
+ sender?: StreamsFilterValue;
705
+ recipient?: StreamsFilterValue;
706
+ assetIdentifier?: string;
626
707
  /**
627
708
  * Labelled filter groups. The groups OR together in one scan and each
628
709
  * returned event carries the labels it matched (`event.matched`) — two
629
710
  * unrelated concerns share one page, one cursor, one checkpoint.
630
711
  */
631
- filters?: StreamsFilterMap
632
- limit?: number
712
+ filters?: StreamsFilterMap;
713
+ limit?: number;
633
714
  };
634
715
  type StreamsEventsStreamParams = {
635
- fromCursor?: string | null
636
- types?: readonly StreamsEventType[]
637
- notTypes?: readonly StreamsEventType[]
638
- contractId?: StreamsFilterValue
639
- sender?: StreamsFilterValue
640
- recipient?: StreamsFilterValue
641
- assetIdentifier?: string
716
+ fromCursor?: string | null;
717
+ types?: readonly StreamsEventType[];
718
+ notTypes?: readonly StreamsEventType[];
719
+ contractId?: StreamsFilterValue;
720
+ sender?: StreamsFilterValue;
721
+ recipient?: StreamsFilterValue;
722
+ assetIdentifier?: string;
642
723
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
643
- filters?: StreamsFilterMap
644
- batchSize?: number
645
- emptyBackoffMs?: number
646
- maxPages?: number
647
- maxEmptyPolls?: number
648
- signal?: AbortSignal
724
+ filters?: StreamsFilterMap;
725
+ batchSize?: number;
726
+ emptyBackoffMs?: number;
727
+ maxPages?: number;
728
+ maxEmptyPolls?: number;
729
+ signal?: AbortSignal;
649
730
  };
650
731
  type StreamsEventsSubscribeParams = {
651
732
  /** Resume strictly after this cursor; omit to live-tail from the tip. */
652
- fromCursor?: string | null
653
- types?: readonly StreamsEventType[]
654
- notTypes?: readonly StreamsEventType[]
655
- contractId?: StreamsFilterValue
656
- sender?: StreamsFilterValue
657
- recipient?: StreamsFilterValue
658
- assetIdentifier?: string
733
+ fromCursor?: string | null;
734
+ types?: readonly StreamsEventType[];
735
+ notTypes?: readonly StreamsEventType[];
736
+ contractId?: StreamsFilterValue;
737
+ sender?: StreamsFilterValue;
738
+ recipient?: StreamsFilterValue;
739
+ assetIdentifier?: string;
659
740
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
660
- filters?: StreamsFilterMap
741
+ filters?: StreamsFilterMap;
661
742
  /** Abort to unsubscribe (the returned function does the same). */
662
- signal?: AbortSignal
743
+ signal?: AbortSignal;
663
744
  /** Called for each pushed event, in order. */
664
- onEvent: (event: StreamsEvent) => void | Promise<void>
745
+ onEvent: (event: StreamsEvent) => void | Promise<void>;
665
746
  /** Called on a connection error; the subscription auto-reconnects from the
666
747
  * last delivered cursor unless the signal has aborted. */
667
- onError?: (err: unknown) => void
748
+ onError?: (err: unknown) => void;
668
749
  };
669
750
  /**
670
751
  * The checkpoint the SDK computes for a batch. Persist `cursor` inside the same
@@ -691,14 +772,14 @@ type ConsumerBatchContext<
691
772
  TReorg = unknown
692
773
  > = {
693
774
  /** Checkpoint to commit alongside your rows. */
694
- cursor: string | null
775
+ cursor: string | null;
695
776
  /** Highest canonical block the sweep has reached. `null` before the first
696
777
  * row of a fresh consume. */
697
- height: number | null
778
+ height: number | null;
698
779
  /** Chain tip as of this page's read. */
699
- tipHeight: number
780
+ tipHeight: number;
700
781
  /** `tipHeight - height`, floored at 0. `null` until `height` is known. */
701
- blocksBehind: number | null
782
+ blocksBehind: number | null;
702
783
  /**
703
784
  * The full tip for this page — `StreamsTip` or `IndexTip` depending on the
704
785
  * surface. Exposed here so a handler never needs the `envelope` parameter,
@@ -706,12 +787,12 @@ type ConsumerBatchContext<
706
787
  * `finalizedOnly` mistake becomes reachable (`return envelope.next_cursor`
707
788
  * jumps the cursor past events that were filtered out and never delivered).
708
789
  */
709
- tip: TTip
790
+ tip: TTip;
710
791
  /**
711
792
  * Reorgs reported alongside this page; empty when none. Rollback still
712
793
  * belongs in `onReorg` — this is for observability inside a batch.
713
794
  */
714
- reorgs: readonly TReorg[]
795
+ reorgs: readonly TReorg[];
715
796
  };
716
797
  /** @deprecated Use {@link ConsumerBatchContext} — the Index and Streams loops
717
798
  * share one shape now. Kept as an alias so existing annotations compile. */
@@ -721,20 +802,20 @@ type StreamsBatchContext = ConsumerBatchContext;
721
802
  * inside the same transaction as your rollback so the two commit atomically.
722
803
  */
723
804
  type StreamsReorgContext = {
724
- cursor: string
805
+ cursor: string;
725
806
  };
726
807
  type StreamsEventsConsumeParams<
727
808
  TTx = never,
728
809
  D extends boolean = false,
729
810
  F extends StreamsFilterMap = Record<never, never>
730
811
  > = {
731
- fromCursor?: string | null
812
+ fromCursor?: string | null;
732
813
  /**
733
814
  * Deliver events pre-decoded as the flat, `event_type`-discriminated rows
734
815
  * Index serves (`IndexEvent`), so Streams consumption reads identically
735
816
  * to Index consumption — no guard+decode pairs in your handler.
736
817
  */
737
- decoded?: D
818
+ decoded?: D;
738
819
  /**
739
820
  * Destination adapter that owns the checkpoint + rollback transaction
740
821
  * (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
@@ -743,29 +824,29 @@ type StreamsEventsConsumeParams<
743
824
  * transaction), reorg rollback is automatic, and `onBatch`'s return value
744
825
  * is ignored.
745
826
  */
746
- sink?: ConsumerSink<TTx>
827
+ sink?: ConsumerSink<TTx>;
747
828
  /** Fires once per page, before `onBatch` and before any early return. */
748
- onProgress?: (ctx: ConsumerBatchContext) => void
749
- mode?: "tail" | "bounded"
829
+ onProgress?: (ctx: ConsumerBatchContext) => void;
830
+ mode?: "tail" | "bounded";
750
831
  /**
751
832
  * Emit only finalized (immutable) events and never surface reorgs. The SDK
752
833
  * checkpoints at the last finalized event and re-reads the unfinalized tail
753
834
  * until it settles. Trades finality lag for zero reorg handling; `onReorg` is
754
835
  * ignored.
755
836
  */
756
- finalizedOnly?: boolean
757
- types?: readonly StreamsEventType[]
758
- notTypes?: readonly StreamsEventType[]
759
- contractId?: StreamsFilterValue
760
- sender?: StreamsFilterValue
761
- recipient?: StreamsFilterValue
762
- assetIdentifier?: string
837
+ finalizedOnly?: boolean;
838
+ types?: readonly StreamsEventType[];
839
+ notTypes?: readonly StreamsEventType[];
840
+ contractId?: StreamsFilterValue;
841
+ sender?: StreamsFilterValue;
842
+ recipient?: StreamsFilterValue;
843
+ assetIdentifier?: string;
763
844
  /**
764
845
  * Labelled filter groups. The groups OR together in ONE server-side scan,
765
846
  * so two unrelated concerns share one page, one cursor, and one checkpoint
766
847
  * instead of two consume loops. Pair with `on` to handle each label.
767
848
  */
768
- filters?: F
849
+ filters?: F;
769
850
  /**
770
851
  * One handler per label in `filters`. Every label must be handled, so
771
852
  * adding a label is a compile error until its handler exists.
@@ -776,8 +857,8 @@ type StreamsEventsConsumeParams<
776
857
  * labels do not interleave within a page — add `onBatch` when you need
777
858
  * strict global order across labels.
778
859
  */
779
- on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> }
780
- batchSize?: number
860
+ on?: { [K in keyof F] : (events: StreamsEventForFilter<F[K], D>[], ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | Promise<void> };
861
+ batchSize?: number;
781
862
  /**
782
863
  * Apply a page of canonical events. Persist `ctx.cursor` in the same
783
864
  * transaction as your writes. Returning a cursor overrides `ctx.cursor` as
@@ -786,7 +867,7 @@ type StreamsEventsConsumeParams<
786
867
  * Optional only when `on` handles the page instead; a consume call with
787
868
  * neither throws.
788
869
  */
789
- onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
870
+ onBatch?: (events: D extends true ? IndexEvent[] : StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
790
871
  /**
791
872
  * Roll your projection back to `reorg.fork_point_height`, persisting
792
873
  * `ctx.cursor` in the same transaction. Called once per *new* reorg
@@ -794,127 +875,137 @@ type StreamsEventsConsumeParams<
794
875
  * now-canonical events. Omit it to ignore reorgs (events stay canonical, but
795
876
  * stale rows from an orphaned fork are left in place).
796
877
  */
797
- onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
878
+ onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
798
879
  /** Page-fetch retries after the first failure (429/5xx/network only —
799
880
  * 4xx and handler throws always propagate). Default 3; `0` disables. */
800
- retryCount?: number
881
+ retryCount?: number;
801
882
  /** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
802
883
  * `Retry-After` overrides it. Default 1000. */
803
- retryDelay?: number
884
+ retryDelay?: number;
804
885
  /** Void observer, called before each retry sleep (metrics/logging). */
805
886
  onError?: (err: unknown, ctx: {
806
- attempt: number
807
- retriesLeft: number
808
- delayMs: number
809
- }) => void
810
- emptyBackoffMs?: number
811
- maxPages?: number
812
- maxEmptyPolls?: number
813
- signal?: AbortSignal
887
+ attempt: number;
888
+ retriesLeft: number;
889
+ delayMs: number;
890
+ }) => void;
891
+ emptyBackoffMs?: number;
892
+ maxPages?: number;
893
+ maxEmptyPolls?: number;
894
+ signal?: AbortSignal;
814
895
  };
815
896
  /**
816
897
  * One yielded page from {@link StreamsClient.consume} — the
817
898
  * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
818
899
  * `cursor` (the checkpoint to persist and resume from).
819
900
  */
820
- type StreamsBatch = {
901
+ type StreamsBatch<TEvent = StreamsEvent> = {
821
902
  /** Canonical events of this page, in cursor order. */
822
- events: StreamsEvent[]
903
+ events: TEvent[];
823
904
  /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
824
- cursor: string | null
825
- tip: StreamsTip
905
+ cursor: string | null;
906
+ tip: StreamsTip;
826
907
  /** Chain reorgs reported alongside this page; empty when none. */
827
- reorgs: StreamsReorg[]
908
+ reorgs: StreamsReorg[];
828
909
  };
829
910
  type StreamsConsumeParams = {
830
911
  /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
831
- cursor?: string | null
832
- types?: readonly StreamsEventType[]
833
- notTypes?: readonly StreamsEventType[]
834
- contractId?: StreamsFilterValue
835
- sender?: StreamsFilterValue
836
- recipient?: StreamsFilterValue
837
- assetIdentifier?: string
912
+ cursor?: string | null;
913
+ types?: readonly StreamsEventType[];
914
+ notTypes?: readonly StreamsEventType[];
915
+ contractId?: StreamsFilterValue;
916
+ sender?: StreamsFilterValue;
917
+ recipient?: StreamsFilterValue;
918
+ assetIdentifier?: string;
919
+ /** Labelled OR-groups — same semantics as `events.consume`; each returned
920
+ * event echoes the labels it matched. */
921
+ filters?: StreamsFilterMap;
838
922
  /** Events per page (the `limit` query param). Default 100. */
839
- batchSize?: number
923
+ batchSize?: number;
840
924
  /** Poll interval while caught up at the tip, in ms. Default 2000. */
841
- intervalMs?: number
925
+ intervalMs?: number;
842
926
  /** Abort to end the iteration. */
843
- signal?: AbortSignal
927
+ signal?: AbortSignal;
844
928
  };
845
929
  type StreamsEventsConsumeResult = {
846
- cursor: string | null
847
- pages: number
848
- emptyPolls: number
930
+ cursor: string | null;
931
+ pages: number;
932
+ emptyPolls: number;
849
933
  };
850
934
  type StreamsEventsReplayParams = {
851
935
  /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
852
- from?: "genesis" | string
936
+ from?: "genesis" | string;
853
937
  /**
854
938
  * Called once per finalized dump file, in block order, before live tailing.
855
939
  * Process the parquet with your own tooling (e.g. DuckDB) — the SDK does not
856
940
  * decode parquet. Use `client.dumps.download(file)` to fetch + verify bytes.
857
941
  */
858
- onDumpFile: (file: StreamsDumpFile) => Promise<void> | void
942
+ onDumpFile: (file: StreamsDumpFile) => Promise<void> | void;
859
943
  /** Called per live page after the dump phase, like `consume`. */
860
- onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined
944
+ onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined;
861
945
  /**
862
946
  * Called when the live-tail phase (after the dump backfill) crosses a reorg,
863
947
  * before the cursor rewinds and re-reads the now-canonical events — same
864
948
  * contract as `consume`. The dump-backfill phase is finalized and never
865
949
  * reorgs; omit this to leave stale rows from an orphaned fork in place.
866
950
  */
867
- onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
868
- mode?: "tail" | "bounded"
869
- batchSize?: number
870
- emptyBackoffMs?: number
871
- maxPages?: number
872
- maxEmptyPolls?: number
873
- signal?: AbortSignal
951
+ onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void;
952
+ mode?: "tail" | "bounded";
953
+ batchSize?: number;
954
+ emptyBackoffMs?: number;
955
+ maxPages?: number;
956
+ maxEmptyPolls?: number;
957
+ signal?: AbortSignal;
958
+ /** Narrow the LIVE TAIL after the dump phase. The dump files themselves are
959
+ * always all-type (block-partitioned parquet) — filter those in your own
960
+ * tooling while processing each file. */
961
+ types?: readonly StreamsEventType[];
962
+ notTypes?: readonly StreamsEventType[];
963
+ /** Labelled OR-groups for the live tail, like `consume`. */
964
+ filters?: StreamsFilterMap;
874
965
  };
875
966
  type FetchLike2 = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
876
967
  /** One bulk parquet file in the dumps manifest. `path` is the object key under
877
968
  * the dumps base URL. */
878
969
  type StreamsDumpFile = {
879
- path: string
880
- from_block: number
881
- to_block: number
882
- min_cursor: string | null
883
- max_cursor: string | null
884
- row_count: number
885
- byte_size: number
886
- sha256: string
887
- schema_version: number
888
- created_at: string
970
+ path: string;
971
+ from_block: number;
972
+ to_block: number;
973
+ min_cursor: string | null;
974
+ max_cursor: string | null;
975
+ row_count: number;
976
+ byte_size: number;
977
+ sha256: string;
978
+ schema_version: number;
979
+ created_at: string;
889
980
  };
890
981
  type StreamsDumpsManifest = {
891
- dataset: string
892
- network: string
893
- version: string
894
- schema_version: number
895
- generated_at: string
896
- producer_version: string
897
- finality_lag_blocks: number
982
+ dataset: string;
983
+ network: string;
984
+ version: string;
985
+ schema_version: number;
986
+ generated_at: string;
987
+ producer_version: string;
988
+ finality_lag_blocks: number;
898
989
  /** Cursor at the end of the finalized bulk coverage — hand to live tailing. */
899
- latest_finalized_cursor: string | null
990
+ latest_finalized_cursor: string | null;
900
991
  coverage: {
901
- from_block: number
902
- to_block: number
903
- }
904
- files: StreamsDumpFile[]
992
+ from_block: number;
993
+ to_block: number;
994
+ };
995
+ files: StreamsDumpFile[];
905
996
  /** ed25519 signature over the manifest's canonical bytes. Absent on legacy
906
997
  * unsigned manifests. Verified by `list()` when `verifyDumpsManifest` is on. */
907
- signature?: string
998
+ signature?: string;
908
999
  /** Short id of the signing public key. */
909
- key_id?: string
1000
+ key_id?: string;
910
1001
  };
911
1002
  type StreamsDumps = {
912
1003
  /** Fetch and parse the latest dumps manifest. */
913
- list(): Promise<StreamsDumpsManifest>
1004
+ list(): Promise<StreamsDumpsManifest>;
914
1005
  /** Absolute URL for a manifest file. */
915
- fileUrl(file: StreamsDumpFile): string
1006
+ fileUrl(file: StreamsDumpFile): string;
916
1007
  /** Download a parquet file and verify its sha256 against the manifest. */
917
- download(file: StreamsDumpFile): Promise<Uint8Array>
1008
+ download(file: StreamsDumpFile): Promise<Uint8Array>;
918
1009
  };
919
1010
  type StreamsClient = {
920
1011
  /**
@@ -931,10 +1022,19 @@ type StreamsClient = {
931
1022
  * rewound automatically — use `events.consume` with `onReorg` for managed
932
1023
  * rollback semantics.
933
1024
  */
934
- consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
1025
+ /** Narrowing overload: a literal `types` array narrows every batch's
1026
+ * event union to exactly those members. */
1027
+ consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeParams & {
1028
+ types: T;
1029
+ }): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
1030
+ consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
935
1031
  events: {
936
- list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
937
- byTxId(txId: string): Promise<StreamsEventsListEnvelope>
1032
+ /** Narrowing overload, matching `consume`. */
1033
+ list<const T extends readonly StreamsEventType[]>(params: StreamsEventsListParams & {
1034
+ types: T;
1035
+ }): Promise<StreamsEventsEnvelope<StreamsEventOfTypes<T>>>;
1036
+ list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>;
1037
+ byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
938
1038
  /**
939
1039
  * Pull pages from Streams and call `onBatch` after each page.
940
1040
  *
@@ -949,8 +1049,8 @@ type StreamsClient = {
949
1049
  TTx = never,
950
1050
  D extends boolean = false
951
1051
  >(params: StreamsEventsConsumeParams<TTx, D, F> & {
952
- sink?: ConsumerSink<TTx>
953
- }): Promise<StreamsEventsConsumeResult>
1052
+ sink?: ConsumerSink<TTx>;
1053
+ }): Promise<StreamsEventsConsumeResult>;
954
1054
  /**
955
1055
  * Backfill from bulk dumps, then continue live from the dump→live seam in
956
1056
  * one call. Iterates finalized dump files (via `onDumpFile`) in block
@@ -958,7 +1058,7 @@ type StreamsClient = {
958
1058
  * (exclusive input → no gap or duplicate at the seam). Requires
959
1059
  * `dumpsBaseUrl`.
960
1060
  */
961
- replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>
1061
+ replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
962
1062
  /**
963
1063
  * Follow Streams as an async iterator.
964
1064
  *
@@ -966,39 +1066,43 @@ type StreamsClient = {
966
1066
  * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
967
1067
  * `maxEmptyPolls` stops it.
968
1068
  */
969
- stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
1069
+ /** Narrowing overload, matching `consume`. */
1070
+ stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamParams & {
1071
+ types: T;
1072
+ }): AsyncIterable<StreamsEventOfTypes<T>>;
1073
+ stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
970
1074
  /**
971
1075
  * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
972
1076
  * canonical event as the server pushes it (chain cadence, not poll-bounded),
973
1077
  * and verifies each frame's inline ed25519 signature when the client was
974
1078
  * created with `verify`. Returns an unsubscribe function.
975
1079
  */
976
- subscribe(params: StreamsEventsSubscribeParams): () => void
977
- }
1080
+ subscribe(params: StreamsEventsSubscribeParams): () => void;
1081
+ };
978
1082
  blocks: {
979
- events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>
980
- }
1083
+ events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
1084
+ };
981
1085
  reorgs: {
982
- list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>
983
- }
1086
+ list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>;
1087
+ };
984
1088
  /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
985
- dumps: StreamsDumps
986
- canonical(height: number): Promise<StreamsCanonicalBlock>
987
- tip(): Promise<StreamsTip>
1089
+ dumps: StreamsDumps;
1090
+ canonical(height: number): Promise<StreamsCanonicalBlock>;
1091
+ tip(): Promise<StreamsTip>;
988
1092
  /** Your own Streams consumption (events today + this month) and tier limits. */
989
- usage(): Promise<StreamsUsage>
1093
+ usage(): Promise<StreamsUsage>;
990
1094
  };
991
1095
  type StreamsUsage = {
992
- product: "streams"
993
- tier: string
1096
+ product: "streams";
1097
+ tier: string;
994
1098
  limits: {
995
- rate_limit_per_second: number | null
996
- retention_days: number | null
997
- }
1099
+ rate_limit_per_second: number | null;
1100
+ retention_days: number | null;
1101
+ };
998
1102
  usage: {
999
- events_today: number
1000
- events_this_month: number
1001
- }
1103
+ events_today: number;
1104
+ events_this_month: number;
1105
+ };
1002
1106
  };
1003
1107
  type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
1004
1108
  /** Options shared by both consume loops' page-fetch retry. Vocabulary matches
@@ -1006,36 +1110,36 @@ type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
1006
1110
  * language across the family, not a third. */
1007
1111
  type PageRetryOptions = {
1008
1112
  /** Retries after the first failure. Default 3; `0` disables. */
1009
- retryCount?: number
1113
+ retryCount?: number;
1010
1114
  /** Base delay in ms; the n-th retry waits `retryDelay * n` (matches the
1011
1115
  * stacks transport). A server `Retry-After` overrides it. Default 1000. */
1012
- retryDelay?: number
1116
+ retryDelay?: number;
1013
1117
  /** Void observer, called before each retry sleep (metrics/logging). The
1014
1118
  * retry policy owns the decision; this cannot change it. */
1015
1119
  onError?: (err: unknown, ctx: {
1016
- attempt: number
1017
- retriesLeft: number
1018
- delayMs: number
1019
- }) => void
1120
+ attempt: number;
1121
+ retriesLeft: number;
1122
+ delayMs: number;
1123
+ }) => void;
1020
1124
  };
1021
1125
  /** Minimum shape a consumed Index row must expose. */
1022
1126
  type IndexFeedItem = {
1023
- cursor: string
1024
- block_height: number
1127
+ cursor: string;
1128
+ block_height: number;
1025
1129
  };
1026
1130
  /** Minimum envelope shape of a consumable Index feed page. */
1027
1131
  type IndexFeedEnvelope = {
1028
- next_cursor: string | null
1029
- tip: IndexTip
1030
- reorgs: IndexReorg[]
1132
+ next_cursor: string | null;
1133
+ tip: IndexTip;
1134
+ reorgs: IndexReorg[];
1031
1135
  };
1032
1136
  /** One page fetch. `fromHeight` is only set on the first page of a fresh
1033
1137
  * consume (no cursor yet) — cursor and from_height are mutually exclusive
1034
1138
  * on the API. */
1035
1139
  type IndexFeedFetcher<TEnvelope extends IndexFeedEnvelope> = (params: {
1036
- cursor: string | null
1037
- fromHeight?: number
1038
- limit: number
1140
+ cursor: string | null;
1141
+ fromHeight?: number;
1142
+ limit: number;
1039
1143
  }) => Promise<TEnvelope>;
1040
1144
  /** Consumer options shared by `index.events.consume` and
1041
1145
  * `index.contractCalls.consume`. Same contract as the Streams consumer:
@@ -1048,18 +1152,18 @@ type IndexConsumeOptions<
1048
1152
  > = {
1049
1153
  /** Resume from a committed checkpoint. Without it (and without
1050
1154
  * `fromHeight`) the API serves only the recent default window. */
1051
- fromCursor?: string | null
1155
+ fromCursor?: string | null;
1052
1156
  /** Start a fresh sweep at this height (e.g. `0` for genesis backfill).
1053
1157
  * Ignored once a cursor exists (including a sink's committed cursor). */
1054
- fromHeight?: number
1158
+ fromHeight?: number;
1055
1159
  /** `tail` (default) keeps polling at the tip; `bounded` returns on the
1056
1160
  * first empty page. */
1057
- mode?: "tail" | "bounded"
1161
+ mode?: "tail" | "bounded";
1058
1162
  /** Emit only rows at or below the tip's `finalized_height`; the
1059
1163
  * unfinalized tail is re-read each poll until it settles. Finalized data
1060
1164
  * never reorgs, so `onReorg` is skipped entirely. */
1061
- finalizedOnly?: boolean
1062
- batchSize?: number
1165
+ finalizedOnly?: boolean;
1166
+ batchSize?: number;
1063
1167
  /**
1064
1168
  * Destination adapter that owns the checkpoint + rollback transaction
1065
1169
  * (e.g. `kyselySink` from `@secondlayer/sdk/sinks/kysely`). With a sink:
@@ -1068,29 +1172,29 @@ type IndexConsumeOptions<
1068
1172
  * transaction — a throw aborts both), reorg rollback is automatic (no
1069
1173
  * `onReorg` needed), and `onBatch`'s return value is ignored.
1070
1174
  */
1071
- sink?: ConsumerSink<TTx>
1175
+ sink?: ConsumerSink<TTx>;
1072
1176
  /** Fires once per page, before `onBatch` and before any early return —
1073
1177
  * an empty page still proves the loop is alive. Feed it to
1074
1178
  * `consumerHealth().record`. */
1075
- onProgress?: (ctx: ConsumerBatchContext) => void
1076
- onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
1179
+ onProgress?: (ctx: ConsumerBatchContext) => void;
1180
+ onBatch: (items: TItem[], envelope: TEnvelope, ctx: ConsumerBatchContext & WithSinkTx<TTx>) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>;
1077
1181
  onReorg?: (reorg: IndexReorg, ctx: {
1078
- cursor: string
1079
- }) => Promise<void> | void
1080
- sleep?: Sleep
1081
- emptyBackoffMs?: number
1082
- maxPages?: number
1083
- maxEmptyPolls?: number
1084
- signal?: AbortSignal
1182
+ cursor: string;
1183
+ }) => Promise<void> | void;
1184
+ sleep?: Sleep;
1185
+ emptyBackoffMs?: number;
1186
+ maxPages?: number;
1187
+ maxEmptyPolls?: number;
1188
+ signal?: AbortSignal;
1085
1189
  /** Page-fetch retries after the first failure (429/5xx/network only —
1086
1190
  * 4xx and handler throws always propagate). Default 3; `0` disables. */
1087
- retryCount?: number
1191
+ retryCount?: number;
1088
1192
  /** Base retry delay in ms; the n-th retry waits `retryDelay * n`. A server
1089
1193
  * `Retry-After` overrides it. Default 1000. */
1090
- retryDelay?: number
1194
+ retryDelay?: number;
1091
1195
  /** Void observer, called before each retry sleep. Cannot change the retry
1092
1196
  * decision — the policy owns it. */
1093
- onError?: PageRetryOptions["onError"]
1197
+ onError?: PageRetryOptions["onError"];
1094
1198
  };
1095
1199
  /**
1096
1200
  * Checkpointed pull loop over a cursor-paginated Index feed — the Index port
@@ -1107,21 +1211,21 @@ declare function consumeIndexFeed<
1107
1211
  TEnvelope extends IndexFeedEnvelope,
1108
1212
  TTx = never
1109
1213
  >(opts: IndexConsumeOptions<TItem, TEnvelope, TTx> & {
1110
- fetchPage: IndexFeedFetcher<TEnvelope>
1111
- itemsOf: (envelope: TEnvelope) => TItem[]
1214
+ fetchPage: IndexFeedFetcher<TEnvelope>;
1215
+ itemsOf: (envelope: TEnvelope) => TItem[];
1112
1216
  }): Promise<{
1113
- cursor: string | null
1114
- pages: number
1115
- emptyPolls: number
1217
+ cursor: string | null;
1218
+ pages: number;
1219
+ emptyPolls: number;
1116
1220
  }>;
1117
1221
  import { SbtcEventTopic as SbtcEventTopic2 } from "@secondlayer/stacks/sbtc";
1118
1222
  type IndexTip = {
1119
- block_height: number
1223
+ block_height: number;
1120
1224
  /** Highest height treated as immutable (past the burn-confirmation
1121
1225
  * finality boundary). Rows at or below it never reorg — `finalizedOnly`
1122
1226
  * consumers gate on this, since Index rows carry no per-event flag. */
1123
- finalized_height: number
1124
- lag_seconds: number
1227
+ finalized_height: number;
1228
+ lag_seconds: number;
1125
1229
  };
1126
1230
  /**
1127
1231
  * A chain reorg overlapping a returned page's height range. Height-keyed feeds
@@ -1134,54 +1238,54 @@ type IndexTip = {
1134
1238
  * inclusive. Empty when the page spans no reorg.
1135
1239
  */
1136
1240
  type IndexReorg = {
1137
- id: string
1138
- detected_at: string
1139
- fork_point_height: number
1140
- old_index_block_hash: string | null
1141
- new_index_block_hash: string | null
1241
+ id: string;
1242
+ detected_at: string;
1243
+ fork_point_height: number;
1244
+ old_index_block_hash: string | null;
1245
+ new_index_block_hash: string | null;
1142
1246
  /** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */
1143
1247
  orphaned_range: {
1144
- from: string
1145
- to: string
1146
- }
1248
+ from: string;
1249
+ to: string;
1250
+ };
1147
1251
  /**
1148
1252
  * First position of the new canonical chain at the fork, `fork:0`
1149
1253
  * (INCLUSIVE). Not an exclusive resume token — resuming a `(bh,ei) > cursor`
1150
1254
  * read directly from it would skip `fork:0`. To re-read the new run, rewind
1151
1255
  * to the foot of `fork_point_height` (`Cursor.atHeight`), not to this value.
1152
1256
  */
1153
- new_canonical_tip: string
1257
+ new_canonical_tip: string;
1154
1258
  };
1155
1259
  type IndexUsage = {
1156
- product: "index"
1157
- tier: string
1260
+ product: "index";
1261
+ tier: string;
1158
1262
  limits: {
1159
- rate_limit_per_second: number | null
1160
- }
1263
+ rate_limit_per_second: number | null;
1264
+ };
1161
1265
  usage: {
1162
- decoded_events_today: number
1163
- decoded_events_this_month: number
1164
- }
1266
+ decoded_events_today: number;
1267
+ decoded_events_this_month: number;
1268
+ };
1165
1269
  };
1166
1270
  type FtTransfer = {
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
- event_type: "ft_transfer"
1174
- contract_id: string
1175
- asset_identifier: string
1176
- sender: string
1177
- recipient: string
1178
- amount: string
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
+ event_type: "ft_transfer";
1278
+ contract_id: string;
1279
+ asset_identifier: string;
1280
+ sender: string;
1281
+ recipient: string;
1282
+ amount: string;
1179
1283
  };
1180
1284
  type FtTransfersEnvelope<TRow = FtTransfer> = {
1181
- events: TRow[]
1182
- next_cursor: string | null
1183
- tip: IndexTip
1184
- reorgs: IndexReorg[]
1285
+ events: TRow[];
1286
+ next_cursor: string | null;
1287
+ tip: IndexTip;
1288
+ reorgs: IndexReorg[];
1185
1289
  };
1186
1290
  /** Transfer columns that survive any projection — the consume contract
1187
1291
  * (`cursor`, `block_height`) plus the `event_type` discriminant. */
@@ -1195,40 +1299,40 @@ type FtTransfersListParams = {
1195
1299
  * one a compile error rather than `undefined` at runtime. Omitting
1196
1300
  * `block_time` also lets the server skip the blocks join.
1197
1301
  */
1198
- fields?: readonly (keyof FtTransfer & string)[]
1199
- cursor?: string | null
1200
- fromCursor?: string | null
1201
- limit?: number
1202
- contractId?: string
1203
- assetIdentifier?: string
1204
- sender?: string
1205
- recipient?: string
1206
- fromHeight?: number
1207
- toHeight?: number
1302
+ fields?: readonly (keyof FtTransfer & string)[];
1303
+ cursor?: string | null;
1304
+ fromCursor?: string | null;
1305
+ limit?: number;
1306
+ contractId?: string;
1307
+ assetIdentifier?: string;
1308
+ sender?: string;
1309
+ recipient?: string;
1310
+ fromHeight?: number;
1311
+ toHeight?: number;
1208
1312
  };
1209
1313
  type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & {
1210
- batchSize?: number
1211
- signal?: AbortSignal
1314
+ batchSize?: number;
1315
+ signal?: AbortSignal;
1212
1316
  };
1213
1317
  type NftTransfer = {
1214
- cursor: string
1215
- block_height: number
1216
- block_time?: string | null
1217
- tx_id: string
1218
- tx_index: number
1219
- event_index: number
1220
- event_type: "nft_transfer"
1221
- contract_id: string
1222
- asset_identifier: string
1223
- sender: string
1224
- recipient: string
1225
- value: string
1318
+ cursor: string;
1319
+ block_height: number;
1320
+ block_time?: string | null;
1321
+ tx_id: string;
1322
+ tx_index: number;
1323
+ event_index: number;
1324
+ event_type: "nft_transfer";
1325
+ contract_id: string;
1326
+ asset_identifier: string;
1327
+ sender: string;
1328
+ recipient: string;
1329
+ value: string;
1226
1330
  };
1227
1331
  type NftTransfersEnvelope<TRow = NftTransfer> = {
1228
- events: TRow[]
1229
- next_cursor: string | null
1230
- tip: IndexTip
1231
- reorgs: IndexReorg[]
1332
+ events: TRow[];
1333
+ next_cursor: string | null;
1334
+ tip: IndexTip;
1335
+ reorgs: IndexReorg[];
1232
1336
  };
1233
1337
  /** See {@link FtTransferAlwaysFields}. */
1234
1338
  type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
@@ -1236,110 +1340,110 @@ type NftTransferAlwaysFields = "cursor" | "block_height" | "event_type";
1236
1340
  type NftTransferFields<F extends keyof NftTransfer & string> = Pick<NftTransfer, (F | NftTransferAlwaysFields) & keyof NftTransfer>;
1237
1341
  type NftTransfersListParams = {
1238
1342
  /** Columns to return (see {@link FtTransfersListParams.fields}). */
1239
- fields?: readonly (keyof NftTransfer & string)[]
1240
- cursor?: string | null
1241
- fromCursor?: string | null
1242
- limit?: number
1243
- contractId?: string
1244
- assetIdentifier?: string
1245
- sender?: string
1246
- recipient?: string
1247
- fromHeight?: number
1248
- toHeight?: number
1343
+ fields?: readonly (keyof NftTransfer & string)[];
1344
+ cursor?: string | null;
1345
+ fromCursor?: string | null;
1346
+ limit?: number;
1347
+ contractId?: string;
1348
+ assetIdentifier?: string;
1349
+ sender?: string;
1350
+ recipient?: string;
1351
+ fromHeight?: number;
1352
+ toHeight?: number;
1249
1353
  };
1250
1354
  type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
1251
- batchSize?: number
1252
- signal?: AbortSignal
1355
+ batchSize?: number;
1356
+ signal?: AbortSignal;
1253
1357
  };
1254
1358
  type IndexEventBase = {
1255
- cursor: string
1256
- block_height: number
1257
- block_time?: string | null
1258
- tx_id: string
1259
- tx_index: number
1260
- event_index: number
1261
- contract_id: string | null
1359
+ cursor: string;
1360
+ block_height: number;
1361
+ block_time?: string | null;
1362
+ tx_id: string;
1363
+ tx_index: number;
1364
+ event_index: number;
1365
+ contract_id: string | null;
1262
1366
  /** Submitting-transaction context, present only when `txContext: true` was
1263
1367
  * requested. `tx_sender` is the real tx sender — distinct from a transfer's
1264
1368
  * asset `sender`, and the only place a `print` event's sender is available.
1265
1369
  * Lets a consumer build per-event tx context without a `/v1/index/transactions`
1266
1370
  * call per event. */
1267
- tx_sender?: string | null
1268
- tx_type?: string | null
1269
- tx_status?: string | null
1270
- tx_contract_id?: string | null
1271
- tx_function_name?: string | null
1371
+ tx_sender?: string | null;
1372
+ tx_type?: string | null;
1373
+ tx_status?: string | null;
1374
+ tx_contract_id?: string | null;
1375
+ tx_function_name?: string | null;
1272
1376
  };
1273
1377
  type IndexFtTransfer = IndexEventBase & {
1274
- event_type: "ft_transfer"
1275
- asset_identifier: string
1276
- sender: string
1277
- recipient: string
1278
- amount: string
1378
+ event_type: "ft_transfer";
1379
+ asset_identifier: string;
1380
+ sender: string;
1381
+ recipient: string;
1382
+ amount: string;
1279
1383
  };
1280
1384
  type IndexNftTransfer = IndexEventBase & {
1281
- event_type: "nft_transfer"
1282
- asset_identifier: string
1283
- sender: string
1284
- recipient: string
1285
- value: string
1385
+ event_type: "nft_transfer";
1386
+ asset_identifier: string;
1387
+ sender: string;
1388
+ recipient: string;
1389
+ value: string;
1286
1390
  };
1287
1391
  type IndexStxTransfer = IndexEventBase & {
1288
- event_type: "stx_transfer"
1289
- sender: string
1290
- recipient: string
1291
- amount: string
1292
- memo: string | null
1392
+ event_type: "stx_transfer";
1393
+ sender: string;
1394
+ recipient: string;
1395
+ amount: string;
1396
+ memo: string | null;
1293
1397
  };
1294
1398
  type IndexStxMint = IndexEventBase & {
1295
- event_type: "stx_mint"
1296
- recipient: string
1297
- amount: string
1399
+ event_type: "stx_mint";
1400
+ recipient: string;
1401
+ amount: string;
1298
1402
  };
1299
1403
  type IndexStxBurn = IndexEventBase & {
1300
- event_type: "stx_burn"
1301
- sender: string
1302
- amount: string
1404
+ event_type: "stx_burn";
1405
+ sender: string;
1406
+ amount: string;
1303
1407
  };
1304
1408
  type IndexStxLock = IndexEventBase & {
1305
- event_type: "stx_lock"
1306
- sender: string
1307
- amount: string
1409
+ event_type: "stx_lock";
1410
+ sender: string;
1411
+ amount: string;
1308
1412
  payload: {
1309
- unlock_height: string | null
1310
- }
1413
+ unlock_height: string | null;
1414
+ };
1311
1415
  };
1312
1416
  type IndexFtMint = IndexEventBase & {
1313
- event_type: "ft_mint"
1314
- asset_identifier: string
1315
- recipient: string
1316
- amount: string
1417
+ event_type: "ft_mint";
1418
+ asset_identifier: string;
1419
+ recipient: string;
1420
+ amount: string;
1317
1421
  };
1318
1422
  type IndexFtBurn = IndexEventBase & {
1319
- event_type: "ft_burn"
1320
- asset_identifier: string
1321
- sender: string
1322
- amount: string
1423
+ event_type: "ft_burn";
1424
+ asset_identifier: string;
1425
+ sender: string;
1426
+ amount: string;
1323
1427
  };
1324
1428
  type IndexNftMint = IndexEventBase & {
1325
- event_type: "nft_mint"
1326
- asset_identifier: string
1327
- recipient: string
1328
- value: string
1429
+ event_type: "nft_mint";
1430
+ asset_identifier: string;
1431
+ recipient: string;
1432
+ value: string;
1329
1433
  };
1330
1434
  type IndexNftBurn = IndexEventBase & {
1331
- event_type: "nft_burn"
1332
- asset_identifier: string
1333
- sender: string
1334
- value: string
1435
+ event_type: "nft_burn";
1436
+ asset_identifier: string;
1437
+ sender: string;
1438
+ value: string;
1335
1439
  };
1336
1440
  type IndexPrint = IndexEventBase & {
1337
- event_type: "print"
1441
+ event_type: "print";
1338
1442
  payload: {
1339
- topic: string | null
1340
- value: unknown
1341
- raw_value: string | null
1342
- }
1443
+ topic: string | null;
1444
+ value: unknown;
1445
+ raw_value: string | null;
1446
+ };
1343
1447
  };
1344
1448
  /** Decoded chain event, discriminated by `event_type`. */
1345
1449
  type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
@@ -1356,39 +1460,39 @@ type EventsEnvelope<
1356
1460
  T extends IndexEventType = IndexEventType,
1357
1461
  TRow = IndexEventOf<T>
1358
1462
  > = {
1359
- events: TRow[]
1360
- next_cursor: string | null
1361
- tip: IndexTip
1362
- reorgs: IndexReorg[]
1463
+ events: TRow[];
1464
+ next_cursor: string | null;
1465
+ tip: IndexTip;
1466
+ reorgs: IndexReorg[];
1363
1467
  };
1364
1468
  /** The single decoded-event member matching one `event_type` literal.
1365
1469
  * `IndexEventOf<"ft_transfer">` is `IndexFtTransfer`. */
1366
1470
  type IndexEventOf<T extends IndexEventType> = Extract<IndexEvent, {
1367
- event_type: T
1471
+ event_type: T;
1368
1472
  }>;
1369
1473
  type EventsListParams<T extends IndexEventType = IndexEventType> = {
1370
1474
  /** Required. One of the decoded event types. Passing a literal narrows the
1371
1475
  * rows every surface hands back to that event's own shape. */
1372
- eventType: T
1373
- cursor?: string | null
1374
- fromCursor?: string | null
1375
- limit?: number
1476
+ eventType: T;
1477
+ cursor?: string | null;
1478
+ fromCursor?: string | null;
1479
+ limit?: number;
1376
1480
  /** One id, or several to scope the sweep to a set of contracts (max 20).
1377
1481
  * Mutually exclusive with `trait`. */
1378
- contractId?: string | readonly string[]
1379
- assetIdentifier?: string
1380
- sender?: string
1381
- recipient?: string
1382
- fromHeight?: number
1383
- toHeight?: number
1482
+ contractId?: string | readonly string[];
1483
+ assetIdentifier?: string;
1484
+ sender?: string;
1485
+ recipient?: string;
1486
+ fromHeight?: number;
1487
+ toHeight?: number;
1384
1488
  /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1385
1489
  * Mutually exclusive with contractId; contract-keyed event types only. */
1386
- trait?: string
1490
+ trait?: string;
1387
1491
  /** Join the submitting transaction into each event — populates `tx_sender`,
1388
1492
  * `tx_type`, `tx_status`, `tx_contract_id`, `tx_function_name`. Off by default.
1389
1493
  * Avoids a `/v1/index/transactions` call per event; for `print` events it's
1390
1494
  * the only source of the submitting sender. */
1391
- txContext?: boolean
1495
+ txContext?: boolean;
1392
1496
  /**
1393
1497
  * Return only these columns. The server projects the SELECT, so an
1394
1498
  * unrequested field is physically absent — and the returned row type
@@ -1403,188 +1507,188 @@ type EventsListParams<T extends IndexEventType = IndexEventType> = {
1403
1507
  * not per field. What it buys is wire bytes, plus skipping the `blocks`
1404
1508
  * join when `block_time` is omitted.
1405
1509
  */
1406
- fields?: readonly (keyof IndexEventOf<T> & string)[]
1510
+ fields?: readonly (keyof IndexEventOf<T> & string)[];
1407
1511
  };
1408
1512
  type EventsWalkParams<T extends IndexEventType = IndexEventType> = Omit<EventsListParams<T>, "limit"> & {
1409
- batchSize?: number
1410
- signal?: AbortSignal
1513
+ batchSize?: number;
1514
+ signal?: AbortSignal;
1411
1515
  };
1412
1516
  type EventsConsumeParams<
1413
1517
  T extends IndexEventType = IndexEventType,
1414
1518
  TTx = never
1415
1519
  > = Omit<EventsListParams<T>, "cursor" | "fromCursor" | "limit" | "fields"> & IndexConsumeOptions<IndexEventOf<T>, EventsEnvelope<T>, TTx>;
1416
1520
  type IndexContractCall = {
1417
- cursor: string
1418
- block_height: number
1419
- block_time?: string | null
1420
- tx_id: string
1421
- tx_index: number
1422
- contract_id: string
1423
- function_name: string
1424
- sender: string
1425
- status: string
1426
- args: unknown[]
1427
- result: unknown
1428
- result_hex: string | null
1521
+ cursor: string;
1522
+ block_height: number;
1523
+ block_time?: string | null;
1524
+ tx_id: string;
1525
+ tx_index: number;
1526
+ contract_id: string;
1527
+ function_name: string;
1528
+ sender: string;
1529
+ status: string;
1530
+ args: unknown[];
1531
+ result: unknown;
1532
+ result_hex: string | null;
1429
1533
  };
1430
1534
  type ContractCallsEnvelope = {
1431
- contract_calls: IndexContractCall[]
1432
- next_cursor: string | null
1433
- tip: IndexTip
1434
- reorgs: IndexReorg[]
1535
+ contract_calls: IndexContractCall[];
1536
+ next_cursor: string | null;
1537
+ tip: IndexTip;
1538
+ reorgs: IndexReorg[];
1435
1539
  };
1436
1540
  type ContractCallsListParams = {
1437
- cursor?: string | null
1438
- fromCursor?: string | null
1439
- limit?: number
1541
+ cursor?: string | null;
1542
+ fromCursor?: string | null;
1543
+ limit?: number;
1440
1544
  /** One id, or several to scope the sweep to a set of contracts (max 20).
1441
1545
  * Mutually exclusive with `trait`. */
1442
- contractId?: string | readonly string[]
1443
- functionName?: string
1444
- sender?: string
1445
- fromHeight?: number
1446
- toHeight?: number
1546
+ contractId?: string | readonly string[];
1547
+ functionName?: string;
1548
+ sender?: string;
1549
+ fromHeight?: number;
1550
+ toHeight?: number;
1447
1551
  /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1448
1552
  * Mutually exclusive with contractId. */
1449
- trait?: string
1553
+ trait?: string;
1450
1554
  };
1451
1555
  type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
1452
- batchSize?: number
1453
- signal?: AbortSignal
1556
+ batchSize?: number;
1557
+ signal?: AbortSignal;
1454
1558
  };
1455
1559
  type ContractCallsConsumeParams<TTx = never> = Omit<ContractCallsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexContractCall, ContractCallsEnvelope, TTx>;
1456
1560
  /** One canonical block in the sync map. Lean by design — block + parent hash
1457
1561
  * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for
1458
1562
  * the full block resource. */
1459
1563
  type IndexCanonicalBlock = {
1460
- cursor: string
1461
- block_height: number
1462
- block_hash: string
1463
- parent_hash: string
1464
- burn_block_height: number
1465
- burn_block_hash: string | null
1564
+ cursor: string;
1565
+ block_height: number;
1566
+ block_hash: string;
1567
+ parent_hash: string;
1568
+ burn_block_height: number;
1569
+ burn_block_hash: string | null;
1466
1570
  };
1467
1571
  type CanonicalEnvelope = {
1468
- canonical: IndexCanonicalBlock[]
1469
- next_cursor: string | null
1470
- tip: IndexTip
1572
+ canonical: IndexCanonicalBlock[];
1573
+ next_cursor: string | null;
1574
+ tip: IndexTip;
1471
1575
  };
1472
1576
  type CanonicalListParams = {
1473
- cursor?: string | null
1474
- fromCursor?: string | null
1475
- limit?: number
1476
- fromHeight?: number
1477
- toHeight?: number
1577
+ cursor?: string | null;
1578
+ fromCursor?: string | null;
1579
+ limit?: number;
1580
+ fromHeight?: number;
1581
+ toHeight?: number;
1478
1582
  };
1479
1583
  type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & {
1480
- batchSize?: number
1481
- signal?: AbortSignal
1584
+ batchSize?: number;
1585
+ signal?: AbortSignal;
1482
1586
  };
1483
1587
  /** A block resource. Metadata is intentionally thin — only chain-linkage and
1484
1588
  * burn-anchor fields are persisted (no miner / tx_count / signer). */
1485
1589
  type IndexBlock = {
1486
- cursor: string
1487
- block_height: number
1488
- block_hash: string
1489
- parent_hash: string
1490
- burn_block_height: number
1491
- burn_block_hash: string | null
1492
- block_time: string | null
1493
- canonical: boolean
1590
+ cursor: string;
1591
+ block_height: number;
1592
+ block_hash: string;
1593
+ parent_hash: string;
1594
+ burn_block_height: number;
1595
+ burn_block_hash: string | null;
1596
+ block_time: string | null;
1597
+ canonical: boolean;
1494
1598
  };
1495
1599
  type BlocksEnvelope = {
1496
- blocks: IndexBlock[]
1497
- next_cursor: string | null
1498
- tip: IndexTip
1600
+ blocks: IndexBlock[];
1601
+ next_cursor: string | null;
1602
+ tip: IndexTip;
1499
1603
  };
1500
1604
  type BlockEnvelope = {
1501
- block: IndexBlock
1502
- tip: IndexTip
1605
+ block: IndexBlock;
1606
+ tip: IndexTip;
1503
1607
  };
1504
1608
  type BlocksListParams = {
1505
- cursor?: string | null
1506
- fromCursor?: string | null
1507
- limit?: number
1508
- fromHeight?: number
1509
- toHeight?: number
1609
+ cursor?: string | null;
1610
+ fromCursor?: string | null;
1611
+ limit?: number;
1612
+ fromHeight?: number;
1613
+ toHeight?: number;
1510
1614
  };
1511
1615
  type BlocksWalkParams = Omit<BlocksListParams, "limit"> & {
1512
- batchSize?: number
1513
- signal?: AbortSignal
1616
+ batchSize?: number;
1617
+ signal?: AbortSignal;
1514
1618
  };
1515
1619
  type IndexPostCondition = {
1516
- type: "stx"
1517
- principal: string
1518
- condition_code: number
1519
- condition_code_name: string | null
1520
- amount: string
1620
+ type: "stx";
1621
+ principal: string;
1622
+ condition_code: number;
1623
+ condition_code_name: string | null;
1624
+ amount: string;
1521
1625
  } | {
1522
- type: "ft"
1523
- principal: string
1524
- asset_identifier: string
1525
- condition_code: number
1526
- condition_code_name: string | null
1527
- amount: string
1626
+ type: "ft";
1627
+ principal: string;
1628
+ asset_identifier: string;
1629
+ condition_code: number;
1630
+ condition_code_name: string | null;
1631
+ amount: string;
1528
1632
  } | {
1529
- type: "nft"
1530
- principal: string
1531
- asset_identifier: string
1532
- asset_value: unknown
1533
- condition_code: number
1534
- condition_code_name: string | null
1633
+ type: "nft";
1634
+ principal: string;
1635
+ asset_identifier: string;
1636
+ asset_value: unknown;
1637
+ condition_code: number;
1638
+ condition_code_name: string | null;
1535
1639
  };
1536
1640
  /** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.
1537
1641
  * Payload sub-objects are present only for the matching `tx_type`; enrichment
1538
1642
  * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */
1539
1643
  type IndexTransaction = {
1540
- cursor: string
1541
- tx_id: string
1542
- block_height: number
1543
- block_time?: string | null
1544
- tx_index: number
1545
- tx_type: string
1546
- sender: string
1547
- status: string
1548
- fee: string | null
1549
- nonce: string | null
1550
- sponsored: boolean | null
1551
- anchor_mode: string | null
1552
- post_condition_mode: string | null
1553
- post_conditions: IndexPostCondition[]
1644
+ cursor: string;
1645
+ tx_id: string;
1646
+ block_height: number;
1647
+ block_time?: string | null;
1648
+ tx_index: number;
1649
+ tx_type: string;
1650
+ sender: string;
1651
+ status: string;
1652
+ fee: string | null;
1653
+ nonce: string | null;
1654
+ sponsored: boolean | null;
1655
+ anchor_mode: string | null;
1656
+ post_condition_mode: string | null;
1657
+ post_conditions: IndexPostCondition[];
1554
1658
  contract_call?: {
1555
- contract_id: string
1556
- function_name: string
1557
- function_args: unknown[]
1659
+ contract_id: string;
1660
+ function_name: string;
1661
+ function_args: unknown[];
1558
1662
  /** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */
1559
- function_args_hex: string[]
1560
- result: unknown
1561
- result_hex: string | null
1562
- }
1663
+ function_args_hex: string[];
1664
+ result: unknown;
1665
+ result_hex: string | null;
1666
+ };
1563
1667
  token_transfer?: {
1564
- recipient: string
1565
- amount: string
1566
- memo: string
1567
- }
1668
+ recipient: string;
1669
+ amount: string;
1670
+ memo: string;
1671
+ };
1568
1672
  smart_contract?: {
1569
- contract_id: string | null
1570
- clarity_version: number | null
1571
- }
1673
+ contract_id: string | null;
1674
+ clarity_version: number | null;
1675
+ };
1572
1676
  coinbase?: {
1573
- alt_recipient: string | null
1574
- }
1677
+ alt_recipient: string | null;
1678
+ };
1575
1679
  tenure_change?: {
1576
- cause: number
1577
- }
1680
+ cause: number;
1681
+ };
1578
1682
  };
1579
1683
  type TransactionsEnvelope<TRow = IndexTransaction> = {
1580
- transactions: TRow[]
1581
- next_cursor: string | null
1582
- tip: IndexTip
1583
- reorgs: IndexReorg[]
1684
+ transactions: TRow[];
1685
+ next_cursor: string | null;
1686
+ tip: IndexTip;
1687
+ reorgs: IndexReorg[];
1584
1688
  };
1585
1689
  type TransactionEnvelope = {
1586
- transaction: IndexTransaction
1587
- tip: IndexTip
1690
+ transaction: IndexTransaction;
1691
+ tip: IndexTip;
1588
1692
  };
1589
1693
  /** Transaction columns that survive any projection. */
1590
1694
  type TransactionAlwaysFields = "cursor" | "block_height" | "tx_id";
@@ -1596,123 +1700,123 @@ type TransactionsListParams = {
1596
1700
  * is physically absent — and the narrowing overload on `list` makes reading
1597
1701
  * one a compile error rather than `undefined` at runtime.
1598
1702
  */
1599
- fields?: readonly (keyof IndexTransaction & string)[]
1600
- cursor?: string | null
1601
- fromCursor?: string | null
1602
- limit?: number
1603
- type?: string
1604
- sender?: string
1605
- contractId?: string
1606
- fromHeight?: number
1607
- toHeight?: number
1703
+ fields?: readonly (keyof IndexTransaction & string)[];
1704
+ cursor?: string | null;
1705
+ fromCursor?: string | null;
1706
+ limit?: number;
1707
+ type?: string;
1708
+ sender?: string;
1709
+ contractId?: string;
1710
+ fromHeight?: number;
1711
+ toHeight?: number;
1608
1712
  };
1609
1713
  type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & {
1610
- batchSize?: number
1611
- signal?: AbortSignal
1714
+ batchSize?: number;
1715
+ signal?: AbortSignal;
1612
1716
  };
1613
1717
  /** A decoded PoX-4 stacking action (one per stacking contract call). */
1614
1718
  type IndexStackingAction = {
1615
- cursor: string
1616
- block_height: number
1617
- block_time?: string | null
1618
- burn_block_height: number
1619
- tx_id: string
1620
- tx_index: number
1621
- function_name: string
1622
- caller: string
1623
- stacker: string | null
1624
- delegate_to: string | null
1625
- amount_ustx: string | null
1626
- lock_period: number | null
1719
+ cursor: string;
1720
+ block_height: number;
1721
+ block_time?: string | null;
1722
+ burn_block_height: number;
1723
+ tx_id: string;
1724
+ tx_index: number;
1725
+ function_name: string;
1726
+ caller: string;
1727
+ stacker: string | null;
1728
+ delegate_to: string | null;
1729
+ amount_ustx: string | null;
1730
+ lock_period: number | null;
1627
1731
  pox_addr: {
1628
- version: number | null
1629
- hashbytes: string | null
1630
- btc: string | null
1631
- }
1632
- start_cycle: number | null
1633
- end_cycle: number | null
1634
- reward_cycle: number | null
1635
- signer_key: string | null
1636
- result_ok: boolean
1732
+ version: number | null;
1733
+ hashbytes: string | null;
1734
+ btc: string | null;
1735
+ };
1736
+ start_cycle: number | null;
1737
+ end_cycle: number | null;
1738
+ reward_cycle: number | null;
1739
+ signer_key: string | null;
1740
+ result_ok: boolean;
1637
1741
  };
1638
1742
  type StackingEnvelope = {
1639
- stacking: IndexStackingAction[]
1640
- next_cursor: string | null
1641
- tip: IndexTip
1642
- reorgs: IndexReorg[]
1743
+ stacking: IndexStackingAction[];
1744
+ next_cursor: string | null;
1745
+ tip: IndexTip;
1746
+ reorgs: IndexReorg[];
1643
1747
  /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
1644
- notes?: string
1748
+ notes?: string;
1645
1749
  };
1646
1750
  type StackingListParams = {
1647
- cursor?: string | null
1648
- fromCursor?: string | null
1649
- limit?: number
1650
- functionName?: string
1651
- stacker?: string
1652
- caller?: string
1653
- fromHeight?: number
1654
- toHeight?: number
1751
+ cursor?: string | null;
1752
+ fromCursor?: string | null;
1753
+ limit?: number;
1754
+ functionName?: string;
1755
+ stacker?: string;
1756
+ caller?: string;
1757
+ fromHeight?: number;
1758
+ toHeight?: number;
1655
1759
  };
1656
1760
  type StackingWalkParams = Omit<StackingListParams, "limit"> & {
1657
- batchSize?: number
1658
- signal?: AbortSignal
1761
+ batchSize?: number;
1762
+ signal?: AbortSignal;
1659
1763
  };
1660
1764
  /** A pending (unconfirmed) transaction. Like a transaction document but
1661
1765
  * pre-chain — no block_height/tx_index/result/events — with `received_at` and
1662
1766
  * a sequence cursor instead of a block position. */
1663
1767
  type IndexMempoolTransaction = {
1664
- cursor: string
1665
- tx_id: string
1666
- tx_type: string
1667
- sender: string
1668
- received_at?: string | null
1669
- fee: string | null
1670
- nonce: string | null
1671
- sponsored: boolean | null
1672
- anchor_mode: string | null
1673
- post_condition_mode: string | null
1674
- post_conditions: IndexPostCondition[]
1768
+ cursor: string;
1769
+ tx_id: string;
1770
+ tx_type: string;
1771
+ sender: string;
1772
+ received_at?: string | null;
1773
+ fee: string | null;
1774
+ nonce: string | null;
1775
+ sponsored: boolean | null;
1776
+ anchor_mode: string | null;
1777
+ post_condition_mode: string | null;
1778
+ post_conditions: IndexPostCondition[];
1675
1779
  contract_call?: {
1676
- contract_id: string
1677
- function_name: string
1678
- function_args: unknown[]
1679
- }
1780
+ contract_id: string;
1781
+ function_name: string;
1782
+ function_args: unknown[];
1783
+ };
1680
1784
  token_transfer?: {
1681
- recipient: string
1682
- amount: string
1683
- memo: string
1684
- }
1785
+ recipient: string;
1786
+ amount: string;
1787
+ memo: string;
1788
+ };
1685
1789
  smart_contract?: {
1686
- clarity_version: number | null
1687
- }
1790
+ clarity_version: number | null;
1791
+ };
1688
1792
  coinbase?: {
1689
- alt_recipient: string | null
1690
- }
1793
+ alt_recipient: string | null;
1794
+ };
1691
1795
  tenure_change?: {
1692
- cause: number
1693
- }
1796
+ cause: number;
1797
+ };
1694
1798
  };
1695
1799
  type MempoolEnvelope = {
1696
- mempool: IndexMempoolTransaction[]
1697
- next_cursor: string | null
1698
- tip: IndexTip
1800
+ mempool: IndexMempoolTransaction[];
1801
+ next_cursor: string | null;
1802
+ tip: IndexTip;
1699
1803
  };
1700
1804
  type MempoolTransactionEnvelope = {
1701
- transaction: IndexMempoolTransaction
1702
- tip: IndexTip
1805
+ transaction: IndexMempoolTransaction;
1806
+ tip: IndexTip;
1703
1807
  };
1704
1808
  type MempoolListParams = {
1705
- cursor?: string | null
1706
- fromCursor?: string | null
1707
- limit?: number
1708
- sender?: string
1709
- type?: string
1809
+ cursor?: string | null;
1810
+ fromCursor?: string | null;
1811
+ limit?: number;
1812
+ sender?: string;
1813
+ type?: string;
1710
1814
  /** Filter to pending calls to a single contract (e.g. `SP….contract`). */
1711
- contractId?: string
1815
+ contractId?: string;
1712
1816
  };
1713
1817
  type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
1714
- batchSize?: number
1715
- signal?: AbortSignal
1818
+ batchSize?: number;
1819
+ signal?: AbortSignal;
1716
1820
  };
1717
1821
  /**
1718
1822
  * Empirical per-topic print payload schema for a contract, inferred from
@@ -1720,194 +1824,194 @@ type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
1720
1824
  * when the contract has more print events than the windows examined.
1721
1825
  */
1722
1826
  type PrintSchemaResponse = {
1723
- contract_id: string
1724
- topics: InferredTopicSchema[]
1725
- sampled: boolean
1726
- total_events: number
1827
+ contract_id: string;
1828
+ topics: InferredTopicSchema[];
1829
+ sampled: boolean;
1830
+ total_events: number;
1727
1831
  /** True when the count hit the server-side cap (total_events is the cap). */
1728
- total_events_capped: boolean
1832
+ total_events_capped: boolean;
1729
1833
  sample: {
1730
- size: number
1731
- newest_height: number | null
1732
- oldest_height: number | null
1733
- }
1734
- tip: IndexTip
1834
+ size: number;
1835
+ newest_height: number | null;
1836
+ oldest_height: number | null;
1837
+ };
1838
+ tip: IndexTip;
1735
1839
  };
1736
1840
  type SbtcWithdrawalStatus = "REQUESTED" | "ACCEPTED" | "REJECTED";
1737
1841
  /** A completed sBTC peg-in, keyed by `bitcoin_txid` (deposits carry no
1738
1842
  * `request_id`). One terminal `completed-deposit` event per deposit. */
1739
1843
  type IndexSbtcDeposit = {
1740
- cursor: string
1741
- block_height: number
1742
- block_time?: string | null
1743
- tx_id: string
1744
- tx_index: number
1745
- event_index: number
1746
- amount: string | null
1747
- sender: string | null
1748
- bitcoin_txid: string | null
1749
- output_index: number | null
1750
- recipient_btc_version: number | null
1751
- recipient_btc_hashbytes: string | null
1844
+ cursor: string;
1845
+ block_height: number;
1846
+ block_time?: string | null;
1847
+ tx_id: string;
1848
+ tx_index: number;
1849
+ event_index: number;
1850
+ amount: string | null;
1851
+ sender: string | null;
1852
+ bitcoin_txid: string | null;
1853
+ output_index: number | null;
1854
+ recipient_btc_version: number | null;
1855
+ recipient_btc_hashbytes: string | null;
1752
1856
  };
1753
1857
  /** A deposit fetched by Bitcoin txid — always terminal, hence `status`. */
1754
1858
  type IndexSbtcDepositDetail = IndexSbtcDeposit & {
1755
- status: "COMPLETED"
1859
+ status: "COMPLETED";
1756
1860
  };
1757
1861
  /** A peg-out collapsed to one row per `request_id`, with lifecycle `status`
1758
1862
  * derived from the latest accept/reject. */
1759
1863
  type IndexSbtcWithdrawal = {
1760
- cursor: string
1761
- request_id: number
1762
- status: SbtcWithdrawalStatus
1763
- amount: string | null
1764
- sender: string | null
1765
- recipient_btc_version: number | null
1766
- recipient_btc_hashbytes: string | null
1767
- sweep_txid: string | null
1864
+ cursor: string;
1865
+ request_id: number;
1866
+ status: SbtcWithdrawalStatus;
1867
+ amount: string | null;
1868
+ sender: string | null;
1869
+ recipient_btc_version: number | null;
1870
+ recipient_btc_hashbytes: string | null;
1871
+ sweep_txid: string | null;
1768
1872
  /** BTC L1 settlement of the committed sweep: true once confirmed, false while
1769
1873
  * pending, null when there is no sweep yet (REQUESTED). */
1770
- settlement_confirmed: boolean | null
1874
+ settlement_confirmed: boolean | null;
1771
1875
  /** BTC confirmations on the sweep tx, null when no settlement row yet. */
1772
- btc_confirmations: number | null
1876
+ btc_confirmations: number | null;
1773
1877
  /** Confirming BTC block height, null while unconfirmed / no sweep. */
1774
- btc_block_height: number | null
1878
+ btc_block_height: number | null;
1775
1879
  /** When the sweep crossed the confirmation threshold (ISO), null otherwise. */
1776
- confirmed_at: string | null
1777
- requested_at?: string | null
1778
- resolved_at?: string | null
1880
+ confirmed_at: string | null;
1881
+ requested_at?: string | null;
1882
+ resolved_at?: string | null;
1779
1883
  };
1780
1884
  /** One phase of a withdrawal's lifecycle (the on-Stacks event that drove it). */
1781
1885
  type IndexSbtcWithdrawalPhase = {
1782
- block_height: number
1783
- block_time: string | null
1784
- tx_id: string
1886
+ block_height: number;
1887
+ block_time: string | null;
1888
+ tx_id: string;
1785
1889
  };
1786
1890
  /** A single peg-out's full assembled lifecycle, fetched by `request_id`.
1787
1891
  * `finalized` is true once terminal and past the reorg margin. */
1788
1892
  type IndexSbtcWithdrawalDetail = {
1789
- request_id: number
1790
- status: SbtcWithdrawalStatus
1791
- amount: string | null
1792
- sender: string | null
1793
- recipient_btc_version: number | null
1794
- recipient_btc_hashbytes: string | null
1795
- requested: IndexSbtcWithdrawalPhase
1893
+ request_id: number;
1894
+ status: SbtcWithdrawalStatus;
1895
+ amount: string | null;
1896
+ sender: string | null;
1897
+ recipient_btc_version: number | null;
1898
+ recipient_btc_hashbytes: string | null;
1899
+ requested: IndexSbtcWithdrawalPhase;
1796
1900
  accepted: (IndexSbtcWithdrawalPhase & {
1797
- sweep_txid: string | null
1798
- signer_bitmap: string | null
1799
- }) | null
1800
- rejected: IndexSbtcWithdrawalPhase | null
1901
+ sweep_txid: string | null;
1902
+ signer_bitmap: string | null;
1903
+ }) | null;
1904
+ rejected: IndexSbtcWithdrawalPhase | null;
1801
1905
  settlement: {
1802
- sweep_txid: string | null
1803
- btc_confirmations: number | null
1804
- settlement_confirmed: boolean | null
1906
+ sweep_txid: string | null;
1907
+ btc_confirmations: number | null;
1908
+ settlement_confirmed: boolean | null;
1805
1909
  /** Confirming Bitcoin block height; null until the sweep confirms. */
1806
- btc_block_height: number | null
1910
+ btc_block_height: number | null;
1807
1911
  /** ISO timestamp the sweep first crossed the confirmation threshold. */
1808
- confirmed_at: string | null
1809
- }
1810
- finalized: boolean
1912
+ confirmed_at: string | null;
1913
+ };
1914
+ finalized: boolean;
1811
1915
  };
1812
1916
  /** A raw decoded sBTC protocol-state event — the full `sbtc_events` row, one
1813
1917
  * per event across all topics. */
1814
1918
  type IndexSbtcEvent = {
1815
- cursor: string
1816
- block_height: number
1817
- block_time?: string | null
1818
- tx_id: string
1819
- tx_index: number
1820
- event_index: number
1821
- topic: SbtcEventTopic
1822
- request_id: number | null
1823
- amount: string | null
1824
- sender: string | null
1825
- recipient_btc_version: number | null
1826
- recipient_btc_hashbytes: string | null
1827
- bitcoin_txid: string | null
1828
- output_index: number | null
1829
- sweep_txid: string | null
1830
- burn_hash: string | null
1831
- burn_height: number | null
1832
- signer_bitmap: string | null
1833
- max_fee: string | null
1834
- fee: string | null
1835
- governance_contract_type: number | null
1836
- governance_new_contract: string | null
1837
- signer_aggregate_pubkey: string | null
1838
- signer_threshold: number | null
1839
- signer_address: string | null
1840
- signer_keys_count: number | null
1919
+ cursor: string;
1920
+ block_height: number;
1921
+ block_time?: string | null;
1922
+ tx_id: string;
1923
+ tx_index: number;
1924
+ event_index: number;
1925
+ topic: SbtcEventTopic;
1926
+ request_id: number | null;
1927
+ amount: string | null;
1928
+ sender: string | null;
1929
+ recipient_btc_version: number | null;
1930
+ recipient_btc_hashbytes: string | null;
1931
+ bitcoin_txid: string | null;
1932
+ output_index: number | null;
1933
+ sweep_txid: string | null;
1934
+ burn_hash: string | null;
1935
+ burn_height: number | null;
1936
+ signer_bitmap: string | null;
1937
+ max_fee: string | null;
1938
+ fee: string | null;
1939
+ governance_contract_type: number | null;
1940
+ governance_new_contract: string | null;
1941
+ signer_aggregate_pubkey: string | null;
1942
+ signer_threshold: number | null;
1943
+ signer_address: string | null;
1944
+ signer_keys_count: number | null;
1841
1945
  };
1842
1946
  /** The peg "scoreboard" — a single all-time canonical aggregate. */
1843
1947
  type IndexSbtcSummary = {
1844
- total_deposits: number
1845
- total_withdrawals_requested: number
1846
- total_withdrawals_accepted: number
1847
- total_withdrawals_rejected: number
1848
- net_peg_flow_sats: string
1849
- total_locked_sats: string
1850
- sbtc_supply_sats: string | null
1948
+ total_deposits: number;
1949
+ total_withdrawals_requested: number;
1950
+ total_withdrawals_accepted: number;
1951
+ total_withdrawals_rejected: number;
1952
+ net_peg_flow_sats: string;
1953
+ total_locked_sats: string;
1954
+ sbtc_supply_sats: string | null;
1851
1955
  };
1852
1956
  type SbtcDepositsEnvelope<TRow = IndexSbtcDeposit> = {
1853
- deposits: TRow[]
1854
- next_cursor: string | null
1855
- tip: IndexTip
1856
- reorgs: IndexReorg[]
1957
+ deposits: TRow[];
1958
+ next_cursor: string | null;
1959
+ tip: IndexTip;
1960
+ reorgs: IndexReorg[];
1857
1961
  /** Present only when the sBTC decoder is disabled, explaining an empty feed. */
1858
- notes?: string
1962
+ notes?: string;
1859
1963
  };
1860
1964
  type SbtcDepositEnvelope = {
1861
- deposit: IndexSbtcDepositDetail
1862
- tip: IndexTip
1965
+ deposit: IndexSbtcDepositDetail;
1966
+ tip: IndexTip;
1863
1967
  };
1864
1968
  type SbtcWithdrawalsEnvelope<TRow = IndexSbtcWithdrawal> = {
1865
- withdrawals: TRow[]
1866
- next_cursor: string | null
1867
- tip: IndexTip
1868
- reorgs: IndexReorg[]
1869
- notes?: string
1969
+ withdrawals: TRow[];
1970
+ next_cursor: string | null;
1971
+ tip: IndexTip;
1972
+ reorgs: IndexReorg[];
1973
+ notes?: string;
1870
1974
  };
1871
1975
  type SbtcWithdrawalEnvelope = {
1872
- withdrawal: IndexSbtcWithdrawalDetail
1873
- tip: IndexTip
1976
+ withdrawal: IndexSbtcWithdrawalDetail;
1977
+ tip: IndexTip;
1874
1978
  };
1875
1979
  type SbtcEventsEnvelope = {
1876
- events: IndexSbtcEvent[]
1877
- next_cursor: string | null
1878
- tip: IndexTip
1879
- reorgs: IndexReorg[]
1880
- notes?: string
1980
+ events: IndexSbtcEvent[];
1981
+ next_cursor: string | null;
1982
+ tip: IndexTip;
1983
+ reorgs: IndexReorg[];
1984
+ notes?: string;
1881
1985
  };
1882
1986
  type SbtcSummaryEnvelope = {
1883
- summary: IndexSbtcSummary
1884
- tip: IndexTip
1885
- notes?: string
1987
+ summary: IndexSbtcSummary;
1988
+ tip: IndexTip;
1989
+ notes?: string;
1886
1990
  };
1887
1991
  type SbtcDepositsListParams = {
1888
- cursor?: string | null
1889
- fromCursor?: string | null
1890
- limit?: number
1992
+ cursor?: string | null;
1993
+ fromCursor?: string | null;
1994
+ limit?: number;
1891
1995
  /** Clamp to the finality boundary — only settled deposits past the reorg margin. */
1892
- confirmed?: boolean
1893
- sender?: string
1894
- bitcoinTxid?: string
1895
- fromHeight?: number
1896
- toHeight?: number
1996
+ confirmed?: boolean;
1997
+ sender?: string;
1998
+ bitcoinTxid?: string;
1999
+ fromHeight?: number;
2000
+ toHeight?: number;
1897
2001
  /**
1898
2002
  * Columns to return. The server projects the row, so an unrequested column
1899
2003
  * is physically absent — and the narrowing overload on `list` makes reading
1900
2004
  * one a compile error rather than `undefined` at runtime.
1901
2005
  */
1902
- fields?: readonly (keyof IndexSbtcDeposit & string)[]
2006
+ fields?: readonly (keyof IndexSbtcDeposit & string)[];
1903
2007
  };
1904
2008
  /** Deposit columns that survive any projection — pagination needs them. */
1905
2009
  type SbtcDepositAlwaysFields = "cursor" | "block_height";
1906
2010
  /** A deposit row narrowed to the requested columns plus the always-present ones. */
1907
2011
  type SbtcDepositFields<F extends keyof IndexSbtcDeposit & string> = Pick<IndexSbtcDeposit, (F | SbtcDepositAlwaysFields) & keyof IndexSbtcDeposit>;
1908
2012
  type SbtcDepositsWalkParams = Omit<SbtcDepositsListParams, "limit"> & {
1909
- batchSize?: number
1910
- signal?: AbortSignal
2013
+ batchSize?: number;
2014
+ signal?: AbortSignal;
1911
2015
  };
1912
2016
  /** SbtcWithdrawal columns that survive any projection. */
1913
2017
  type SbtcWithdrawalAlwaysFields = "cursor" | "request_id";
@@ -1919,39 +2023,39 @@ type SbtcWithdrawalsListParams = {
1919
2023
  * is physically absent — and the narrowing overload on `list` makes reading
1920
2024
  * one a compile error rather than `undefined` at runtime.
1921
2025
  */
1922
- fields?: readonly (keyof IndexSbtcWithdrawal & string)[]
1923
- cursor?: string | null
1924
- fromCursor?: string | null
1925
- limit?: number
1926
- confirmed?: boolean
1927
- status?: SbtcWithdrawalStatus
1928
- sender?: string
1929
- requestId?: number
2026
+ fields?: readonly (keyof IndexSbtcWithdrawal & string)[];
2027
+ cursor?: string | null;
2028
+ fromCursor?: string | null;
2029
+ limit?: number;
2030
+ confirmed?: boolean;
2031
+ status?: SbtcWithdrawalStatus;
2032
+ sender?: string;
2033
+ requestId?: number;
1930
2034
  /** Filter by BTC L1 settlement: true → only confirmed sweeps; false → not
1931
2035
  * yet confirmed (pending or no sweep). */
1932
- settlementConfirmed?: boolean
1933
- fromHeight?: number
1934
- toHeight?: number
2036
+ settlementConfirmed?: boolean;
2037
+ fromHeight?: number;
2038
+ toHeight?: number;
1935
2039
  };
1936
2040
  type SbtcWithdrawalsWalkParams = Omit<SbtcWithdrawalsListParams, "limit"> & {
1937
- batchSize?: number
1938
- signal?: AbortSignal
2041
+ batchSize?: number;
2042
+ signal?: AbortSignal;
1939
2043
  };
1940
2044
  type SbtcEventsListParams = {
1941
- cursor?: string | null
1942
- fromCursor?: string | null
1943
- limit?: number
1944
- confirmed?: boolean
1945
- topic?: SbtcEventTopic
1946
- sender?: string
1947
- requestId?: number
1948
- bitcoinTxid?: string
1949
- fromHeight?: number
1950
- toHeight?: number
2045
+ cursor?: string | null;
2046
+ fromCursor?: string | null;
2047
+ limit?: number;
2048
+ confirmed?: boolean;
2049
+ topic?: SbtcEventTopic;
2050
+ sender?: string;
2051
+ requestId?: number;
2052
+ bitcoinTxid?: string;
2053
+ fromHeight?: number;
2054
+ toHeight?: number;
1951
2055
  };
1952
2056
  type SbtcEventsWalkParams = Omit<SbtcEventsListParams, "limit"> & {
1953
- batchSize?: number
1954
- signal?: AbortSignal
2057
+ batchSize?: number;
2058
+ signal?: AbortSignal;
1955
2059
  };
1956
2060
  type SbtcEventsConsumeParams<TTx = never> = Omit<SbtcEventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcEvent, SbtcEventsEnvelope, TTx>;
1957
2061
  type SbtcDepositsConsumeParams<TTx = never> = Omit<SbtcDepositsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexSbtcDeposit, SbtcDepositsEnvelope, TTx>;
@@ -1962,98 +2066,98 @@ interface SbtcResource {
1962
2066
  /** Narrowing overload: `fields` shrinks the row type to exactly the
1963
2067
  * requested columns plus {@link SbtcDepositAlwaysFields}. */
1964
2068
  list<const F extends keyof IndexSbtcDeposit & string>(params: SbtcDepositsListParams & {
1965
- fields: readonly F[]
1966
- }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>
1967
- list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>
1968
- walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>
2069
+ fields: readonly F[];
2070
+ }): Promise<SbtcDepositsEnvelope<SbtcDepositFields<F>>>;
2071
+ list(params?: SbtcDepositsListParams): Promise<SbtcDepositsEnvelope>;
2072
+ walk(params?: SbtcDepositsWalkParams): AsyncIterable<IndexSbtcDeposit>;
1969
2073
  /** Checkpointed sweep of completed deposits — append-only, so safe to
1970
2074
  * mirror. See {@link IndexConsumeOptions}. */
1971
2075
  consume<TTx = never>(params: SbtcDepositsConsumeParams<TTx> & {
1972
- sink?: ConsumerSink<TTx>
2076
+ sink?: ConsumerSink<TTx>;
1973
2077
  }): Promise<{
1974
- cursor: string | null
1975
- pages: number
1976
- emptyPolls: number
1977
- }>
2078
+ cursor: string | null;
2079
+ pages: number;
2080
+ emptyPolls: number;
2081
+ }>;
1978
2082
  /** Fetch a completed deposit by Bitcoin txid; 404 → null. */
1979
- get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>
2083
+ get(bitcoinTxid: string): Promise<SbtcDepositEnvelope | null>;
1980
2084
  };
1981
2085
  withdrawals: {
1982
2086
  /** Narrowing overload: `fields` shrinks the row type to exactly the
1983
2087
  * requested columns plus {@link SbtcWithdrawalAlwaysFields}. */
1984
2088
  list<const F extends keyof IndexSbtcWithdrawal & string>(params: SbtcWithdrawalsListParams & {
1985
- fields: readonly F[]
1986
- }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>
1987
- list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>
1988
- walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>
2089
+ fields: readonly F[];
2090
+ }): Promise<SbtcWithdrawalsEnvelope<SbtcWithdrawalFields<F>>>;
2091
+ list(params?: SbtcWithdrawalsListParams): Promise<SbtcWithdrawalsEnvelope>;
2092
+ walk(params?: SbtcWithdrawalsWalkParams): AsyncIterable<IndexSbtcWithdrawal>;
1989
2093
  /** Fetch a withdrawal's full lifecycle by request id; 404 → null. */
1990
- get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>
2094
+ get(requestId: number): Promise<SbtcWithdrawalEnvelope | null>;
1991
2095
  };
1992
2096
  events: {
1993
- list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>
1994
- walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>
2097
+ list(params?: SbtcEventsListParams): Promise<SbtcEventsEnvelope>;
2098
+ walk(params?: SbtcEventsWalkParams): AsyncIterable<IndexSbtcEvent>;
1995
2099
  /** Checkpointed sweep of the raw peg event log — append-only across all
1996
2100
  * six topics. See {@link IndexConsumeOptions}. */
1997
2101
  consume<TTx = never>(params: SbtcEventsConsumeParams<TTx> & {
1998
- sink?: ConsumerSink<TTx>
2102
+ sink?: ConsumerSink<TTx>;
1999
2103
  }): Promise<{
2000
- cursor: string | null
2001
- pages: number
2002
- emptyPolls: number
2003
- }>
2104
+ cursor: string | null;
2105
+ pages: number;
2106
+ emptyPolls: number;
2107
+ }>;
2004
2108
  };
2005
2109
  /** The peg scoreboard — a single all-time aggregate (no pagination). */
2006
2110
  summary(): Promise<SbtcSummaryEnvelope>;
2007
2111
  }
2008
2112
  /** Per-function action count within a reward cycle. */
2009
2113
  type IndexPoxFunctionCount = {
2010
- function_name: string
2011
- count: number
2114
+ function_name: string;
2115
+ count: number;
2012
2116
  };
2013
2117
  /** Aggregate stats for one PoX reward cycle — distinct from `index.stacking`
2014
2118
  * (decoded per-call PoX-4 actions); this is the reward-cycle rollup. */
2015
2119
  type IndexPoxCycle = {
2016
- reward_cycle: number
2120
+ reward_cycle: number;
2017
2121
  /** Total ustx locked across all stack-* calls in this cycle (bigint-safe string). */
2018
- total_stacked_ustx: string
2019
- unique_stackers: number
2020
- unique_delegators: number
2021
- action_count: number
2022
- start_block_height: number
2023
- end_block_height: number
2122
+ total_stacked_ustx: string;
2123
+ unique_stackers: number;
2124
+ unique_delegators: number;
2125
+ action_count: number;
2126
+ start_block_height: number;
2127
+ end_block_height: number;
2024
2128
  /** True when this is the latest reward cycle (still accumulating new actions). */
2025
- is_current: boolean
2026
- function_breakdown: IndexPoxFunctionCount[]
2129
+ is_current: boolean;
2130
+ function_breakdown: IndexPoxFunctionCount[];
2027
2131
  };
2028
2132
  type PoxCyclesEnvelope = {
2029
- cycles: IndexPoxCycle[]
2133
+ cycles: IndexPoxCycle[];
2030
2134
  /** The next `reward_cycle` to page from (cycles descend), or null at the end. */
2031
- next_cursor: number | null
2032
- tip: IndexTip
2135
+ next_cursor: number | null;
2136
+ tip: IndexTip;
2033
2137
  /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
2034
- notes?: string
2138
+ notes?: string;
2035
2139
  };
2036
2140
  type PoxCycleEnvelope = {
2037
- cycle: IndexPoxCycle
2038
- tip: IndexTip
2039
- notes?: string
2141
+ cycle: IndexPoxCycle;
2142
+ tip: IndexTip;
2143
+ notes?: string;
2040
2144
  };
2041
2145
  type PoxCyclesListParams = {
2042
2146
  /** A `reward_cycle` to page from; the page returns cycles below it (descending). */
2043
- cursor?: number | null
2044
- limit?: number
2147
+ cursor?: number | null;
2148
+ limit?: number;
2045
2149
  };
2046
2150
  type PoxCyclesWalkParams = Omit<PoxCyclesListParams, "limit"> & {
2047
- batchSize?: number
2048
- signal?: AbortSignal
2151
+ batchSize?: number;
2152
+ signal?: AbortSignal;
2049
2153
  };
2050
2154
  /** `index.pox` — PoX reward-cycle aggregates. */
2051
2155
  interface PoxResource {
2052
2156
  cycles: {
2053
- list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>
2054
- walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>
2157
+ list(params?: PoxCyclesListParams): Promise<PoxCyclesEnvelope>;
2158
+ walk(params?: PoxCyclesWalkParams): AsyncIterable<IndexPoxCycle>;
2055
2159
  /** Fetch one reward cycle's aggregate by number; 404 → null. */
2056
- get(rewardCycle: number): Promise<PoxCycleEnvelope | null>
2160
+ get(rewardCycle: number): Promise<PoxCycleEnvelope | null>;
2057
2161
  };
2058
2162
  }
2059
2163
  /** The decoded `pox-5` boot-contract print topics (SIP-045 Bitcoin Staking) —
@@ -2064,37 +2168,37 @@ type IndexPox5EventTopic = Pox5EventTopic;
2064
2168
  * `data` always carries the full decoded tuple, including nested shapes
2065
2169
  * (`btc-lockup`, `bond-rewards`, `bond-periods`) that have no flat column. */
2066
2170
  type IndexPox5Event = {
2067
- cursor: string
2068
- block_height: number
2069
- block_time: string | null
2070
- tx_id: string
2071
- tx_index: number
2072
- event_index: number
2073
- topic: IndexPox5EventTopic
2074
- staker: string | null
2075
- signer: string | null
2076
- signer_manager: string | null
2077
- bond_index: number | null
2171
+ cursor: string;
2172
+ block_height: number;
2173
+ block_time: string | null;
2174
+ tx_id: string;
2175
+ tx_index: number;
2176
+ event_index: number;
2177
+ topic: IndexPox5EventTopic;
2178
+ staker: string | null;
2179
+ signer: string | null;
2180
+ signer_manager: string | null;
2181
+ bond_index: number | null;
2078
2182
  /** ustx, bigint-safe string. */
2079
- amount_ustx: string | null
2183
+ amount_ustx: string | null;
2080
2184
  /** sats, bigint-safe string. */
2081
- amount_sats: string | null
2082
- reward_cycle: number | null
2083
- first_reward_cycle: number | null
2084
- unlock_cycle: number | null
2085
- unlock_burn_height: number | null
2086
- is_l1_lock: boolean | null
2087
- signer_key: string | null
2185
+ amount_sats: string | null;
2186
+ reward_cycle: number | null;
2187
+ first_reward_cycle: number | null;
2188
+ unlock_cycle: number | null;
2189
+ unlock_burn_height: number | null;
2190
+ is_l1_lock: boolean | null;
2191
+ signer_key: string | null;
2088
2192
  /** The full decoded print tuple as JSON. */
2089
- data: unknown
2193
+ data: unknown;
2090
2194
  };
2091
2195
  type Pox5EventsEnvelope<TRow = IndexPox5Event> = {
2092
- events: TRow[]
2093
- next_cursor: string | null
2094
- tip: IndexTip
2095
- reorgs: IndexReorg[]
2196
+ events: TRow[];
2197
+ next_cursor: string | null;
2198
+ tip: IndexTip;
2199
+ reorgs: IndexReorg[];
2096
2200
  /** Present only when the PoX-5 decoder is disabled, explaining an empty feed. */
2097
- notes?: string
2201
+ notes?: string;
2098
2202
  };
2099
2203
  /** Pox5Event columns that survive any projection. */
2100
2204
  type Pox5EventAlwaysFields = "cursor" | "block_height" | "topic";
@@ -2106,24 +2210,24 @@ type Pox5EventsListParams = {
2106
2210
  * is physically absent — and the narrowing overload on `list` makes reading
2107
2211
  * one a compile error rather than `undefined` at runtime.
2108
2212
  */
2109
- fields?: readonly (keyof IndexPox5Event & string)[]
2110
- cursor?: string | null
2111
- fromCursor?: string | null
2112
- limit?: number
2213
+ fields?: readonly (keyof IndexPox5Event & string)[];
2214
+ cursor?: string | null;
2215
+ fromCursor?: string | null;
2216
+ limit?: number;
2113
2217
  /** Clamp to the finality boundary — only rows past the reorg margin. */
2114
- confirmed?: boolean
2115
- topic?: IndexPox5EventTopic
2116
- staker?: string
2117
- signer?: string
2118
- signerManager?: string
2119
- bondIndex?: number
2120
- rewardCycle?: number
2121
- fromHeight?: number
2122
- toHeight?: number
2218
+ confirmed?: boolean;
2219
+ topic?: IndexPox5EventTopic;
2220
+ staker?: string;
2221
+ signer?: string;
2222
+ signerManager?: string;
2223
+ bondIndex?: number;
2224
+ rewardCycle?: number;
2225
+ fromHeight?: number;
2226
+ toHeight?: number;
2123
2227
  };
2124
2228
  type Pox5EventsWalkParams = Omit<Pox5EventsListParams, "limit"> & {
2125
- batchSize?: number
2126
- signal?: AbortSignal
2229
+ batchSize?: number;
2230
+ signal?: AbortSignal;
2127
2231
  };
2128
2232
  /** `index.pox5` — decoded PoX-5 print events, the staking primitive from the
2129
2233
  * epoch 4.0 hard fork onward (PoX-4's `index.stacking` stream ends there). */
@@ -2132,10 +2236,10 @@ interface Pox5Resource {
2132
2236
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2133
2237
  * requested columns plus {@link Pox5EventAlwaysFields}. */
2134
2238
  list<const F extends keyof IndexPox5Event & string>(params: Pox5EventsListParams & {
2135
- fields: readonly F[]
2136
- }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>
2137
- list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>
2138
- walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>
2239
+ fields: readonly F[];
2240
+ }): Promise<Pox5EventsEnvelope<Pox5EventFields<F>>>;
2241
+ list(params?: Pox5EventsListParams): Promise<Pox5EventsEnvelope>;
2242
+ walk(params?: Pox5EventsWalkParams): AsyncIterable<IndexPox5Event>;
2139
2243
  };
2140
2244
  }
2141
2245
  /**
@@ -2149,20 +2253,20 @@ interface FtTransfersResource {
2149
2253
  /** Narrowing overload for the callable shorthand — same wire path as
2150
2254
  * `list`, so it must narrow identically. */
2151
2255
  <const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2152
- fields: readonly F[]
2256
+ fields: readonly F[];
2153
2257
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2154
2258
  (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2155
2259
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2156
2260
  * requested columns plus {@link FtTransferAlwaysFields}. */
2157
2261
  list<const F extends keyof FtTransfer & string>(params: FtTransfersListParams & {
2158
- fields: readonly F[]
2262
+ fields: readonly F[];
2159
2263
  }): Promise<FtTransfersEnvelope<FtTransferFields<F>>>;
2160
2264
  list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
2161
2265
  /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
2162
2266
  * wire, so without this the yielded rows are stripped while the type
2163
2267
  * still promises every column. */
2164
2268
  walk<const F extends keyof FtTransfer & string>(params: FtTransfersWalkParams & {
2165
- fields: readonly F[]
2269
+ fields: readonly F[];
2166
2270
  }): AsyncIterable<FtTransferFields<F>>;
2167
2271
  walk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;
2168
2272
  }
@@ -2171,18 +2275,18 @@ interface NftTransfersResource {
2171
2275
  /** Narrowing overload for the callable shorthand — same wire path as
2172
2276
  * `list`, so it must narrow identically. */
2173
2277
  <const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2174
- fields: readonly F[]
2278
+ fields: readonly F[];
2175
2279
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2176
2280
  (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2177
2281
  /** Narrowing overload: `fields` shrinks the row type to exactly the
2178
2282
  * requested columns plus {@link NftTransferAlwaysFields}. */
2179
2283
  list<const F extends keyof NftTransfer & string>(params: NftTransfersListParams & {
2180
- fields: readonly F[]
2284
+ fields: readonly F[];
2181
2285
  }): Promise<NftTransfersEnvelope<NftTransferFields<F>>>;
2182
2286
  list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
2183
2287
  /** Narrowing overload, matching `list` (see {@link FtTransfersResource}). */
2184
2288
  walk<const F extends keyof NftTransfer & string>(params: NftTransfersWalkParams & {
2185
- fields: readonly F[]
2289
+ fields: readonly F[];
2186
2290
  }): AsyncIterable<NftTransferFields<F>>;
2187
2291
  walk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;
2188
2292
  }
@@ -2194,7 +2298,7 @@ interface IndexEventsResource {
2194
2298
  T extends IndexEventType,
2195
2299
  const F extends keyof IndexEventOf<T> & string
2196
2300
  >(params: EventsListParams<T> & {
2197
- fields: readonly F[]
2301
+ fields: readonly F[];
2198
2302
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2199
2303
  <T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2200
2304
  /** Narrowing overload: `fields` shrinks the returned row type to exactly
@@ -2204,7 +2308,7 @@ interface IndexEventsResource {
2204
2308
  T extends IndexEventType,
2205
2309
  const F extends keyof IndexEventOf<T> & string
2206
2310
  >(params: EventsListParams<T> & {
2207
- fields: readonly F[]
2311
+ fields: readonly F[];
2208
2312
  }): Promise<EventsEnvelope<T, IndexEventFields<T, F>>>;
2209
2313
  list<T extends IndexEventType>(params: EventsListParams<T>): Promise<EventsEnvelope<T>>;
2210
2314
  /** Narrowing overload, matching `list`: `walk` forwards `fields` to the
@@ -2214,33 +2318,33 @@ interface IndexEventsResource {
2214
2318
  T extends IndexEventType,
2215
2319
  const F extends keyof IndexEventOf<T> & string
2216
2320
  >(params: EventsWalkParams<T> & {
2217
- fields: readonly F[]
2321
+ fields: readonly F[];
2218
2322
  }): AsyncIterable<IndexEventFields<T, F>>;
2219
2323
  walk<T extends IndexEventType>(params: EventsWalkParams<T>): AsyncIterable<IndexEventOf<T>>;
2220
2324
  consume<
2221
2325
  T extends IndexEventType,
2222
2326
  TTx = never
2223
2327
  >(params: EventsConsumeParams<T, TTx> & {
2224
- sink?: ConsumerSink<TTx>
2328
+ sink?: ConsumerSink<TTx>;
2225
2329
  }): Promise<{
2226
- cursor: string | null
2227
- pages: number
2228
- emptyPolls: number
2330
+ cursor: string | null;
2331
+ pages: number;
2332
+ emptyPolls: number;
2229
2333
  }>;
2230
2334
  }
2231
2335
  /** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */
2232
2336
  type IndexEventTypeFilters = {
2233
- columns?: string[]
2234
- allowed_filters?: string[]
2235
- equality_filters?: string[]
2236
- required_non_null?: string[]
2337
+ columns?: string[];
2338
+ allowed_filters?: string[];
2339
+ equality_filters?: string[];
2340
+ required_non_null?: string[];
2237
2341
  };
2238
2342
  /** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.
2239
2343
  * Shape is intentionally open (the server may add fields); the agent-relevant
2240
2344
  * parts are the per-type filter rules. */
2241
2345
  type IndexDiscovery = {
2242
- event_type_filters?: Record<string, IndexEventTypeFilters>
2243
- [key: string]: unknown
2346
+ event_type_filters?: Record<string, IndexEventTypeFilters>;
2347
+ [key: string]: unknown;
2244
2348
  };
2245
2349
  declare class Index extends BaseClient {
2246
2350
  constructor(options?: Partial<SecondLayerOptions>);
@@ -2266,27 +2370,27 @@ declare class Index extends BaseClient {
2266
2370
  * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
2267
2371
  readonly events: IndexEventsResource;
2268
2372
  readonly contractCalls: {
2269
- list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>
2270
- walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>
2373
+ list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>;
2374
+ walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>;
2271
2375
  consume: <TTx = never>(params: ContractCallsConsumeParams<TTx> & {
2272
- sink?: ConsumerSink<TTx>
2376
+ sink?: ConsumerSink<TTx>;
2273
2377
  }) => Promise<{
2274
- cursor: string | null
2275
- pages: number
2276
- emptyPolls: number
2277
- }>
2378
+ cursor: string | null;
2379
+ pages: number;
2380
+ emptyPolls: number;
2381
+ }>;
2278
2382
  };
2279
2383
  /** Canonical block-hash map — sync only the current canonical chain. */
2280
2384
  readonly canonical: {
2281
- list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>
2282
- walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>
2385
+ list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>;
2386
+ walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>;
2283
2387
  };
2284
2388
  /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
2285
2389
  * (resolves to null on 404). */
2286
2390
  readonly blocks: {
2287
- list: (params?: BlocksListParams) => Promise<BlocksEnvelope>
2288
- walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>
2289
- get: (ref: string | number) => Promise<BlockEnvelope | null>
2391
+ list: (params?: BlocksListParams) => Promise<BlocksEnvelope>;
2392
+ walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>;
2393
+ get: (ref: string | number) => Promise<BlockEnvelope | null>;
2290
2394
  };
2291
2395
  /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
2292
2396
  * (resolves to null on 404). */
@@ -2297,26 +2401,26 @@ declare class Index extends BaseClient {
2297
2401
  * overloads. */
2298
2402
  list: {
2299
2403
  <const F extends keyof IndexTransaction & string>(params: TransactionsListParams & {
2300
- fields: readonly F[]
2301
- }): Promise<TransactionsEnvelope<TransactionFields<F>>>
2302
- (params?: TransactionsListParams): Promise<TransactionsEnvelope>
2303
- }
2304
- walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>
2305
- get: (txId: string) => Promise<TransactionEnvelope | null>
2306
- getProof: (txId: string) => Promise<TransactionProof | null>
2404
+ fields: readonly F[];
2405
+ }): Promise<TransactionsEnvelope<TransactionFields<F>>>;
2406
+ (params?: TransactionsListParams): Promise<TransactionsEnvelope>;
2407
+ };
2408
+ walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>;
2409
+ get: (txId: string) => Promise<TransactionEnvelope | null>;
2410
+ getProof: (txId: string) => Promise<TransactionProof | null>;
2307
2411
  };
2308
2412
  /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
2309
2413
  * platform's PoX-4 decoder is disabled. */
2310
2414
  readonly stacking: {
2311
- list: (params?: StackingListParams) => Promise<StackingEnvelope>
2312
- walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
2415
+ list: (params?: StackingListParams) => Promise<StackingEnvelope>;
2416
+ walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>;
2313
2417
  };
2314
2418
  /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
2315
2419
  * tx_id (resolves to null when the tx has confirmed or dropped). */
2316
2420
  readonly mempool: {
2317
- list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
2318
- walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
2319
- get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
2421
+ list: (params?: MempoolListParams) => Promise<MempoolEnvelope>;
2422
+ walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>;
2423
+ get: (txId: string) => Promise<MempoolTransactionEnvelope | null>;
2320
2424
  };
2321
2425
  /** Decoded sBTC peg surface — the only productized decoded sBTC peg feed on
2322
2426
  * Stacks. `deposits`/`withdrawals`/`events` paginate; `summary` is a scalar. */
@@ -2429,7 +2533,7 @@ declare class Projects extends BaseClient {
2429
2533
  constructor(options?: Partial<SecondLayerOptions>);
2430
2534
  /** All projects owned by the account, newest-relevant first. */
2431
2535
  list(): Promise<{
2432
- projects: Project[]
2536
+ projects: Project[];
2433
2537
  }>;
2434
2538
  /** A single project by slug. */
2435
2539
  get(slug: string): Promise<Project>;
@@ -2439,7 +2543,7 @@ declare class Projects extends BaseClient {
2439
2543
  update(slug: string, patch: UpdateProjectParams): Promise<Project>;
2440
2544
  /** Delete a project. The account's last remaining project cannot be deleted. */
2441
2545
  delete(slug: string): Promise<{
2442
- ok: true
2546
+ ok: true;
2443
2547
  }>;
2444
2548
  /** Team members and pending invitations for a project. */
2445
2549
  team(slug: string): Promise<ProjectTeam>;
@@ -2449,7 +2553,7 @@ import { ChainTrigger, ChainTriggerType, CreateSubscriptionRequest as CreateSubs
2449
2553
  import { trigger } from "@secondlayer/shared/schemas/subscriptions";
2450
2554
  declare class Subscriptions extends BaseClient {
2451
2555
  list(): Promise<{
2452
- data: SubscriptionSummary[]
2556
+ data: SubscriptionSummary[];
2453
2557
  }>;
2454
2558
  get(id: string): Promise<SubscriptionDetail>;
2455
2559
  create(input: CreateSubscriptionRequest): Promise<CreateSubscriptionResponse>;
@@ -2457,25 +2561,25 @@ declare class Subscriptions extends BaseClient {
2457
2561
  pause(id: string): Promise<SubscriptionDetail>;
2458
2562
  resume(id: string): Promise<SubscriptionDetail>;
2459
2563
  delete(id: string): Promise<{
2460
- ok: true
2564
+ ok: true;
2461
2565
  }>;
2462
2566
  rotateSecret(id: string): Promise<RotateSecretResponse>;
2463
2567
  /** Send a one-off test webhook to the subscription's URL (built for its
2464
2568
  * format, SSRF-guarded). Logged as a delivery row, visible via recentDeliveries. */
2465
2569
  test(id: string): Promise<SubscriptionTestResult>;
2466
2570
  recentDeliveries(id: string): Promise<{
2467
- data: DeliveryRow[]
2571
+ data: DeliveryRow[];
2468
2572
  }>;
2469
2573
  replay(id: string, range: {
2470
- fromBlock: number
2471
- toBlock: number
2472
- force?: string
2574
+ fromBlock: number;
2575
+ toBlock: number;
2576
+ force?: string;
2473
2577
  }): Promise<ReplayResult>;
2474
2578
  dead(id: string): Promise<{
2475
- data: DeadRow[]
2579
+ data: DeadRow[];
2476
2580
  }>;
2477
2581
  requeueDead(id: string, outboxId: string): Promise<{
2478
- ok: true
2582
+ ok: true;
2479
2583
  }>;
2480
2584
  }
2481
2585
  interface ContextAccount {
@@ -2513,8 +2617,8 @@ interface ContextSnapshot {
2513
2617
  indexTip: IndexTip | null;
2514
2618
  subgraphs: SubgraphSummary2[] | null;
2515
2619
  subscriptions: {
2516
- count: number
2517
- byStatus: Record<string, number>
2620
+ count: number;
2621
+ byStatus: Record<string, number>;
2518
2622
  } | null;
2519
2623
  /** The account's projects (null when unreadable — e.g. a scoped key). */
2520
2624
  projects: ContextProject[] | null;
@@ -2543,14 +2647,14 @@ declare class SecondLayer extends BaseClient {
2543
2647
  * PAYMENT-BALANCE/SESSION) apply to every item.
2544
2648
  */
2545
2649
  batch(requests: Array<{
2546
- path: string
2547
- params?: Record<string, string | number | boolean>
2650
+ path: string;
2651
+ params?: Record<string, string | number | boolean>;
2548
2652
  }>): Promise<{
2549
2653
  results: Array<{
2550
- path: string | null
2551
- status: number
2552
- body: unknown
2553
- }>
2654
+ path: string | null;
2655
+ status: number;
2656
+ body: unknown;
2657
+ }>;
2554
2658
  }>;
2555
2659
  context(): Promise<ContextSnapshot>;
2556
2660
  }
@@ -2569,18 +2673,18 @@ declare class SecondLayer extends BaseClient {
2569
2673
  * ```
2570
2674
  */
2571
2675
  declare function getSubgraph<T extends {
2572
- name: string
2573
- schema: Record<string, unknown>
2676
+ name: string;
2677
+ schema: Record<string, unknown>;
2574
2678
  }>(def: T, options?: Partial<SecondLayerOptions> | SecondLayer | Subgraphs): InferSubgraphClient2<T>;
2575
2679
  type CreateStreamsClientOptions = {
2576
- apiKey: string
2577
- baseUrl?: string
2578
- fetchImpl?: FetchLike2
2680
+ apiKey: string;
2681
+ baseUrl?: string;
2682
+ fetchImpl?: FetchLike2;
2579
2683
  /**
2580
2684
  * Public base URL for bulk parquet dumps (the R2/CDN bucket root). Required
2581
2685
  * to use `client.dumps`. See `GET /public/streams/dumps/manifest`.
2582
2686
  */
2583
- dumpsBaseUrl?: string
2687
+ dumpsBaseUrl?: string;
2584
2688
  /**
2585
2689
  * Verify the ed25519 `X-Signature` on every REST response and per-frame SSE
2586
2690
  * signature. Three states:
@@ -2599,8 +2703,8 @@ type CreateStreamsClientOptions = {
2599
2703
  * rotated `X-Signature-KeyId` triggers one refresh) unless a PEM is pinned.
2600
2704
  */
2601
2705
  verify?: boolean | {
2602
- publicKey: string
2603
- }
2706
+ publicKey: string;
2707
+ };
2604
2708
  /**
2605
2709
  * Verify the bulk dumps manifest's ed25519 signature in `client.dumps.list()`
2606
2710
  * before trusting any file sha256 (default ON). Uses the same key source as
@@ -2608,7 +2712,7 @@ type CreateStreamsClientOptions = {
2608
2712
  * `false` to opt out. A missing or invalid signature throws
2609
2713
  * `StreamsSignatureError`.
2610
2714
  */
2611
- verifyDumpsManifest?: boolean
2715
+ verifyDumpsManifest?: boolean;
2612
2716
  };
2613
2717
  declare function createStreamsClient(options: CreateStreamsClientOptions): StreamsClient;
2614
2718
  /**
@@ -2672,14 +2776,14 @@ declare class SecondLayerError extends Error {
2672
2776
  */
2673
2777
  walk(fn?: (err: unknown) => boolean): unknown;
2674
2778
  toJSON(): {
2675
- name: string
2676
- message: string
2677
- shortMessage: string
2678
- cause: string | undefined
2679
- code: string | undefined
2680
- docsUrl: string | undefined
2681
- retryable: boolean
2682
- retryAfterSeconds: number | undefined
2779
+ name: string;
2780
+ message: string;
2781
+ shortMessage: string;
2782
+ cause: string | undefined;
2783
+ code: string | undefined;
2784
+ docsUrl: string | undefined;
2785
+ retryable: boolean;
2786
+ retryAfterSeconds: number | undefined;
2683
2787
  };
2684
2788
  }
2685
2789
  /**
@@ -2713,9 +2817,9 @@ declare class AuthError extends ApiError {
2713
2817
  * with `retryAfterSeconds` parsed from the `Retry-After` header when sent. */
2714
2818
  declare class RateLimitError extends ApiError {
2715
2819
  /** Raw `Retry-After` header value (seconds or HTTP-date). */
2716
- readonly retryAfter?: string;
2820
+ readonly retryAfter?: string | undefined;
2717
2821
  readonly status: 429;
2718
- constructor(message?: string, retryAfter?: string);
2822
+ constructor(message?: string, retryAfter?: string | undefined);
2719
2823
  }
2720
2824
  /** Thrown on a 4xx the caller can fix (bad cursor, bad params). Never retried. */
2721
2825
  declare class ValidationError extends ApiError {
@@ -2746,8 +2850,7 @@ declare class VersionConflictError extends ApiError {
2746
2850
  * } catch (err) {
2747
2851
  * if (err instanceof ByoBreakingChangeError) {
2748
2852
  * console.log(err.details.plan.dropStatement);
2749
- * console.log(err.details.plan.statements.join(";
2750
- "));
2853
+ * console.log(err.details.plan.statements.join(";\n"));
2751
2854
  * }
2752
2855
  * }
2753
2856
  * ```
@@ -2765,210 +2868,210 @@ declare class StreamsSignatureError extends SecondLayerError {
2765
2868
  constructor(message?: string);
2766
2869
  }
2767
2870
  type FtTransferEvent = Extract<StreamsEvent, {
2768
- event_type: "ft_transfer"
2871
+ event_type: "ft_transfer";
2769
2872
  }>;
2770
2873
  type DecodedFtTransferPayload = {
2771
- asset_identifier: string
2772
- contract_id: string
2773
- token_name: string | null
2774
- sender: string
2775
- recipient: string
2776
- amount: string
2874
+ asset_identifier: string;
2875
+ contract_id: string;
2876
+ token_name: string | null;
2877
+ sender: string;
2878
+ recipient: string;
2879
+ amount: string;
2777
2880
  };
2778
2881
  type DecodedFtTransfer = {
2779
- cursor: string
2780
- block_height: number
2781
- tx_id: string
2782
- tx_index: number
2783
- event_index: number
2784
- event_type: "ft_transfer"
2785
- decoded_payload: DecodedFtTransferPayload
2786
- source_cursor: string
2882
+ cursor: string;
2883
+ block_height: number;
2884
+ tx_id: string;
2885
+ tx_index: number;
2886
+ event_index: number;
2887
+ event_type: "ft_transfer";
2888
+ decoded_payload: DecodedFtTransferPayload;
2889
+ source_cursor: string;
2787
2890
  };
2788
2891
  declare function isFtTransfer(event: StreamsEvent): event is FtTransferEvent;
2789
2892
  declare function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer;
2790
2893
  type NftTransferEvent = Extract<StreamsEvent, {
2791
- event_type: "nft_transfer"
2894
+ event_type: "nft_transfer";
2792
2895
  }>;
2793
2896
  type DecodedNftTransferPayload = {
2794
- asset_identifier: string
2795
- contract_id: string
2796
- token_name: string | null
2797
- sender: string
2798
- recipient: string
2799
- value: string
2897
+ asset_identifier: string;
2898
+ contract_id: string;
2899
+ token_name: string | null;
2900
+ sender: string;
2901
+ recipient: string;
2902
+ value: string;
2800
2903
  };
2801
2904
  type DecodedNftTransfer = {
2802
- cursor: string
2803
- block_height: number
2804
- tx_id: string
2805
- tx_index: number
2806
- event_index: number
2807
- event_type: "nft_transfer"
2808
- decoded_payload: DecodedNftTransferPayload
2809
- source_cursor: string
2905
+ cursor: string;
2906
+ block_height: number;
2907
+ tx_id: string;
2908
+ tx_index: number;
2909
+ event_index: number;
2910
+ event_type: "nft_transfer";
2911
+ decoded_payload: DecodedNftTransferPayload;
2912
+ source_cursor: string;
2810
2913
  };
2811
2914
  declare function isNftTransfer(event: StreamsEvent): event is NftTransferEvent;
2812
2915
  declare function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer;
2813
2916
  type DecodedStxTransferPayload = {
2814
- sender: string
2815
- recipient: string
2816
- amount: string
2817
- memo: string | null
2917
+ sender: string;
2918
+ recipient: string;
2919
+ amount: string;
2920
+ memo: string | null;
2818
2921
  };
2819
2922
  type DecodedStxTransfer = {
2820
- cursor: string
2821
- block_height: number
2822
- tx_id: string
2823
- tx_index: number
2824
- event_index: number
2825
- event_type: "stx_transfer"
2826
- decoded_payload: DecodedStxTransferPayload
2827
- source_cursor: string
2923
+ cursor: string;
2924
+ block_height: number;
2925
+ tx_id: string;
2926
+ tx_index: number;
2927
+ event_index: number;
2928
+ event_type: "stx_transfer";
2929
+ decoded_payload: DecodedStxTransferPayload;
2930
+ source_cursor: string;
2828
2931
  };
2829
2932
  type DecodedStxMintPayload = {
2830
- recipient: string
2831
- amount: string
2933
+ recipient: string;
2934
+ amount: string;
2832
2935
  };
2833
2936
  type DecodedStxMint = {
2834
- cursor: string
2835
- block_height: number
2836
- tx_id: string
2837
- tx_index: number
2838
- event_index: number
2839
- event_type: "stx_mint"
2840
- decoded_payload: DecodedStxMintPayload
2841
- source_cursor: string
2937
+ cursor: string;
2938
+ block_height: number;
2939
+ tx_id: string;
2940
+ tx_index: number;
2941
+ event_index: number;
2942
+ event_type: "stx_mint";
2943
+ decoded_payload: DecodedStxMintPayload;
2944
+ source_cursor: string;
2842
2945
  };
2843
2946
  type DecodedStxBurnPayload = {
2844
- sender: string
2845
- amount: string
2947
+ sender: string;
2948
+ amount: string;
2846
2949
  };
2847
2950
  type DecodedStxBurn = {
2848
- cursor: string
2849
- block_height: number
2850
- tx_id: string
2851
- tx_index: number
2852
- event_index: number
2853
- event_type: "stx_burn"
2854
- decoded_payload: DecodedStxBurnPayload
2855
- source_cursor: string
2951
+ cursor: string;
2952
+ block_height: number;
2953
+ tx_id: string;
2954
+ tx_index: number;
2955
+ event_index: number;
2956
+ event_type: "stx_burn";
2957
+ decoded_payload: DecodedStxBurnPayload;
2958
+ source_cursor: string;
2856
2959
  };
2857
2960
  declare function isStxTransfer(event: StreamsEvent): event is StreamsEvent & {
2858
- event_type: "stx_transfer"
2961
+ event_type: "stx_transfer";
2859
2962
  };
2860
2963
  declare function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer;
2861
2964
  declare function isStxMint(event: StreamsEvent): event is StreamsEvent & {
2862
- event_type: "stx_mint"
2965
+ event_type: "stx_mint";
2863
2966
  };
2864
2967
  declare function decodeStxMint(event: StreamsEvent): DecodedStxMint;
2865
2968
  declare function isStxBurn(event: StreamsEvent): event is StreamsEvent & {
2866
- event_type: "stx_burn"
2969
+ event_type: "stx_burn";
2867
2970
  };
2868
2971
  declare function decodeStxBurn(event: StreamsEvent): DecodedStxBurn;
2869
2972
  type DecodedStxLockPayload = {
2870
- sender: string
2871
- amount: string
2973
+ sender: string;
2974
+ amount: string;
2872
2975
  payload: {
2873
- unlock_height: string | null
2874
- }
2976
+ unlock_height: string | null;
2977
+ };
2875
2978
  };
2876
2979
  type DecodedStxLock = {
2877
- cursor: string
2878
- block_height: number
2879
- tx_id: string
2880
- tx_index: number
2881
- event_index: number
2882
- event_type: "stx_lock"
2883
- decoded_payload: DecodedStxLockPayload
2884
- source_cursor: string
2980
+ cursor: string;
2981
+ block_height: number;
2982
+ tx_id: string;
2983
+ tx_index: number;
2984
+ event_index: number;
2985
+ event_type: "stx_lock";
2986
+ decoded_payload: DecodedStxLockPayload;
2987
+ source_cursor: string;
2885
2988
  };
2886
2989
  declare function isStxLock(event: StreamsEvent): event is StreamsEvent & {
2887
- event_type: "stx_lock"
2990
+ event_type: "stx_lock";
2888
2991
  };
2889
2992
  declare function decodeStxLock(event: StreamsEvent): DecodedStxLock;
2890
2993
  type DecodedFtMintPayload = {
2891
- asset_identifier: string
2892
- contract_id: string
2893
- token_name: string | null
2894
- recipient: string
2895
- amount: string
2994
+ asset_identifier: string;
2995
+ contract_id: string;
2996
+ token_name: string | null;
2997
+ recipient: string;
2998
+ amount: string;
2896
2999
  };
2897
3000
  type DecodedFtMint = {
2898
- cursor: string
2899
- block_height: number
2900
- tx_id: string
2901
- tx_index: number
2902
- event_index: number
2903
- event_type: "ft_mint"
2904
- decoded_payload: DecodedFtMintPayload
2905
- source_cursor: string
3001
+ cursor: string;
3002
+ block_height: number;
3003
+ tx_id: string;
3004
+ tx_index: number;
3005
+ event_index: number;
3006
+ event_type: "ft_mint";
3007
+ decoded_payload: DecodedFtMintPayload;
3008
+ source_cursor: string;
2906
3009
  };
2907
3010
  type DecodedFtBurnPayload = {
2908
- asset_identifier: string
2909
- contract_id: string
2910
- token_name: string | null
2911
- sender: string
2912
- amount: string
3011
+ asset_identifier: string;
3012
+ contract_id: string;
3013
+ token_name: string | null;
3014
+ sender: string;
3015
+ amount: string;
2913
3016
  };
2914
3017
  type DecodedFtBurn = {
2915
- cursor: string
2916
- block_height: number
2917
- tx_id: string
2918
- tx_index: number
2919
- event_index: number
2920
- event_type: "ft_burn"
2921
- decoded_payload: DecodedFtBurnPayload
2922
- source_cursor: string
3018
+ cursor: string;
3019
+ block_height: number;
3020
+ tx_id: string;
3021
+ tx_index: number;
3022
+ event_index: number;
3023
+ event_type: "ft_burn";
3024
+ decoded_payload: DecodedFtBurnPayload;
3025
+ source_cursor: string;
2923
3026
  };
2924
3027
  type DecodedNftMintPayload = {
2925
- asset_identifier: string
2926
- contract_id: string
2927
- token_name: string | null
2928
- recipient: string
2929
- value: string
3028
+ asset_identifier: string;
3029
+ contract_id: string;
3030
+ token_name: string | null;
3031
+ recipient: string;
3032
+ value: string;
2930
3033
  };
2931
3034
  type DecodedNftMint = {
2932
- cursor: string
2933
- block_height: number
2934
- tx_id: string
2935
- tx_index: number
2936
- event_index: number
2937
- event_type: "nft_mint"
2938
- decoded_payload: DecodedNftMintPayload
2939
- source_cursor: string
3035
+ cursor: string;
3036
+ block_height: number;
3037
+ tx_id: string;
3038
+ tx_index: number;
3039
+ event_index: number;
3040
+ event_type: "nft_mint";
3041
+ decoded_payload: DecodedNftMintPayload;
3042
+ source_cursor: string;
2940
3043
  };
2941
3044
  type DecodedNftBurnPayload = {
2942
- asset_identifier: string
2943
- contract_id: string
2944
- token_name: string | null
2945
- sender: string
2946
- value: string
3045
+ asset_identifier: string;
3046
+ contract_id: string;
3047
+ token_name: string | null;
3048
+ sender: string;
3049
+ value: string;
2947
3050
  };
2948
3051
  type DecodedNftBurn = {
2949
- cursor: string
2950
- block_height: number
2951
- tx_id: string
2952
- tx_index: number
2953
- event_index: number
2954
- event_type: "nft_burn"
2955
- decoded_payload: DecodedNftBurnPayload
2956
- source_cursor: string
3052
+ cursor: string;
3053
+ block_height: number;
3054
+ tx_id: string;
3055
+ tx_index: number;
3056
+ event_index: number;
3057
+ event_type: "nft_burn";
3058
+ decoded_payload: DecodedNftBurnPayload;
3059
+ source_cursor: string;
2957
3060
  };
2958
3061
  declare function isFtMint(event: StreamsEvent): event is StreamsEvent & {
2959
- event_type: "ft_mint"
3062
+ event_type: "ft_mint";
2960
3063
  };
2961
3064
  declare function decodeFtMint(event: StreamsEvent): DecodedFtMint;
2962
3065
  declare function isFtBurn(event: StreamsEvent): event is StreamsEvent & {
2963
- event_type: "ft_burn"
3066
+ event_type: "ft_burn";
2964
3067
  };
2965
3068
  declare function decodeFtBurn(event: StreamsEvent): DecodedFtBurn;
2966
3069
  declare function isNftMint(event: StreamsEvent): event is StreamsEvent & {
2967
- event_type: "nft_mint"
3070
+ event_type: "nft_mint";
2968
3071
  };
2969
3072
  declare function decodeNftMint(event: StreamsEvent): DecodedNftMint;
2970
3073
  declare function isNftBurn(event: StreamsEvent): event is StreamsEvent & {
2971
- event_type: "nft_burn"
3074
+ event_type: "nft_burn";
2972
3075
  };
2973
3076
  declare function decodeNftBurn(event: StreamsEvent): DecodedNftBurn;
2974
3077
  /** Decoded form of a Clarity `print` event:
@@ -2977,41 +3080,41 @@ declare function decodeNftBurn(event: StreamsEvent): DecodedNftBurn;
2977
3080
  * `0x…` hex, tuples as objects)
2978
3081
  * - `raw_value`: the canonical serialized hex, for byte-exact consumers */
2979
3082
  type DecodedPrintValue = {
2980
- topic: string | null
2981
- value: unknown
2982
- raw_value: string | null
3083
+ topic: string | null;
3084
+ value: unknown;
3085
+ raw_value: string | null;
2983
3086
  };
2984
3087
  type DecodedPrintPayload = {
2985
- contract_id: string | null
2986
- payload: DecodedPrintValue
3088
+ contract_id: string | null;
3089
+ payload: DecodedPrintValue;
2987
3090
  };
2988
3091
  type DecodedPrint = {
2989
- cursor: string
2990
- block_height: number
2991
- tx_id: string
2992
- tx_index: number
2993
- event_index: number
2994
- event_type: "print"
2995
- decoded_payload: DecodedPrintPayload
2996
- source_cursor: string
3092
+ cursor: string;
3093
+ block_height: number;
3094
+ tx_id: string;
3095
+ tx_index: number;
3096
+ event_index: number;
3097
+ event_type: "print";
3098
+ decoded_payload: DecodedPrintPayload;
3099
+ source_cursor: string;
2997
3100
  };
2998
3101
  declare function isPrint(event: StreamsEvent): event is StreamsEvent & {
2999
- event_type: "print"
3102
+ event_type: "print";
3000
3103
  };
3001
3104
  declare function decodePrint(event: StreamsEvent): DecodedPrint;
3002
3105
  /** Superset of the columns the decoded_events table holds. Every decoded
3003
3106
  * event's `decoded_payload` is assignable to this, so the indexer's writer
3004
3107
  * can map columns generically instead of per-event-type. */
3005
3108
  type DecodedEventColumns = {
3006
- contract_id?: string | null
3007
- asset_identifier?: string | null
3008
- sender?: string | null
3009
- recipient?: string | null
3010
- amount?: string | null
3011
- value?: string | null
3012
- memo?: string | null
3109
+ contract_id?: string | null;
3110
+ asset_identifier?: string | null;
3111
+ sender?: string | null;
3112
+ recipient?: string | null;
3113
+ amount?: string | null;
3114
+ value?: string | null;
3115
+ memo?: string | null;
3013
3116
  /** JSONB overflow for non-flat types (e.g. print's decoded value). */
3014
- payload?: unknown
3117
+ payload?: unknown;
3015
3118
  };
3016
3119
  /**
3017
3120
  * Helpers for Streams cursors. A cursor is the opaque `<block>:<index>` string
@@ -3036,12 +3139,12 @@ declare const Cursor: {
3036
3139
  * type), larger than any real index, so nothing at `height - 1` survives the
3037
3140
  * keyset and the next returned row is exactly `(height, 0)`.
3038
3141
  */
3039
- atHeight(height: number): string
3142
+ atHeight(height: number): string;
3040
3143
  /** Parse a `<block>:<index>` cursor. Throws `ValidationError` if malformed. */
3041
3144
  parse(cursor: string): {
3042
- blockHeight: number
3043
- eventIndex: number
3044
- }
3145
+ blockHeight: number;
3146
+ eventIndex: number;
3147
+ };
3045
3148
  };
3046
3149
  type DecodedEventRow = DecodedFtTransfer | DecodedNftTransfer | DecodedStxTransfer | DecodedStxMint | DecodedStxBurn | DecodedStxLock | DecodedFtMint | DecodedFtBurn | DecodedNftMint | DecodedNftBurn | DecodedPrint;
3047
3150
  import { X402TokenSymbol } from "@secondlayer/shared/x402";
@@ -3058,31 +3161,31 @@ import { StacksChain } from "@secondlayer/stacks/chains";
3058
3161
  * - `buildSignedX402Payment` / `readX402Challenge` — primitives for custom transports.
3059
3162
  */
3060
3163
  type X402Accept = {
3061
- scheme: "exact"
3062
- network: string
3063
- asset: string
3164
+ scheme: "exact";
3165
+ network: string;
3166
+ asset: string;
3064
3167
  /** Atomic units. */
3065
- amount: string
3066
- payTo: string
3067
- maxTimeoutSeconds: number
3168
+ amount: string;
3169
+ payTo: string;
3170
+ maxTimeoutSeconds: number;
3068
3171
  extra: {
3069
- nonce: string
3070
- }
3172
+ nonce: string;
3173
+ };
3071
3174
  };
3072
3175
  type X402Challenge = {
3073
- x402Version: number
3074
- accepts: X402Accept[]
3075
- error?: string
3176
+ x402Version: number;
3177
+ accepts: X402Accept[];
3178
+ error?: string;
3076
3179
  };
3077
3180
  /** Decoded `PAYMENT-RESPONSE` settlement receipt. */
3078
3181
  type X402Receipt = {
3079
- success: boolean
3182
+ success: boolean;
3080
3183
  /** Settlement tier: `optimistic` (served on broadcast-accept, reconciled
3081
3184
  * async) or `confirmed` (canonical). Absent on older deployments. */
3082
- state?: "optimistic" | "confirmed"
3083
- txid: string
3084
- payer: string
3085
- network: string
3185
+ state?: "optimistic" | "confirmed";
3186
+ txid: string;
3187
+ payer: string;
3188
+ network: string;
3086
3189
  };
3087
3190
  /** Bitcoin-native first — sBTC is the compelling micropay asset; USDCx the
3088
3191
  * dollar peg; STX the fallback. Override via `preferAssets`. */
@@ -3097,56 +3200,56 @@ declare function readX402Challenge(res: Response): Promise<X402Challenge | null>
3097
3200
  /** Read the settlement receipt from a paid 200 response. */
3098
3201
  declare function readX402Receipt(res: Response): X402Receipt | null;
3099
3202
  type SelectOfferOptions = {
3100
- preferAssets?: X402TokenSymbol[]
3101
- maxAmountPerCall?: Partial<Record<X402TokenSymbol, bigint>>
3203
+ preferAssets?: X402TokenSymbol[];
3204
+ maxAmountPerCall?: Partial<Record<X402TokenSymbol, bigint>>;
3102
3205
  };
3103
3206
  /** Choose an `accepts[]` entry by preference order, skipping any that exceed the
3104
3207
  * per-asset spend cap. Throws {@link X402SpendGuardError} if none qualify. */
3105
3208
  declare function selectOffer(challenge: X402Challenge, opts?: SelectOfferOptions): {
3106
- accept: X402Accept
3107
- symbol: X402TokenSymbol
3209
+ accept: X402Accept;
3210
+ symbol: X402TokenSymbol;
3108
3211
  };
3109
3212
  /** Fetch the payer account's next nonce from a Stacks node (`/v2/accounts`). */
3110
3213
  declare function resolveAccountNonce(address: string, nodeUrl?: string): Promise<number>;
3111
3214
  type BuildSignedX402PaymentOptions = {
3112
- challenge: X402Challenge
3113
- account: LocalAccount
3215
+ challenge: X402Challenge;
3216
+ account: LocalAccount;
3114
3217
  /** The payer account's next nonce. */
3115
- accountNonce: bigint | number | string
3218
+ accountNonce: bigint | number | string;
3116
3219
  /** Preferred asset string (e.g. an sBTC/USDCx id). Defaults to the first offer. */
3117
- asset?: string
3118
- chain?: StacksChain
3220
+ asset?: string;
3221
+ chain?: StacksChain;
3119
3222
  };
3120
3223
  /** Build a signed, base64 `PAYMENT-SIGNATURE` header for one `accepts[]` entry. */
3121
3224
  declare function buildSignedX402Payment(opts: BuildSignedX402PaymentOptions): Promise<{
3122
- header: string
3123
- accept: X402Accept
3225
+ header: string;
3226
+ accept: X402Accept;
3124
3227
  }>;
3125
3228
  type WithX402Options = SelectOfferOptions & {
3126
- account: LocalAccount
3229
+ account: LocalAccount;
3127
3230
  /** Prepaid-credit token (PAYMENT-BALANCE) from a prior deposit — calls
3128
3231
  * debit the tab server-side instead of settling on-chain per call. */
3129
- balanceToken?: string
3232
+ balanceToken?: string;
3130
3233
  /** Autonomous treasury policy: when the tab's remaining balance (read from
3131
3234
  * X-BALANCE-REMAINING-USD) drops below `whenBelow`, deposit `usd` more in
3132
3235
  * the background (one on-chain payment) and adopt the fresh token. */
3133
3236
  topUp?: {
3134
- usd: number
3135
- whenBelow: number
3136
- }
3237
+ usd: number;
3238
+ whenBelow: number;
3239
+ };
3137
3240
  /** Override the payer nonce; auto-resolved from `nodeUrl` when omitted. */
3138
- accountNonce?: bigint | number | string
3241
+ accountNonce?: bigint | number | string;
3139
3242
  /** Node for auto-nonce lookup. Defaults to {@link DEFAULT_NONCE_NODE_URL}. */
3140
- nodeUrl?: string
3141
- chain?: StacksChain
3243
+ nodeUrl?: string;
3244
+ chain?: StacksChain;
3142
3245
  /** Fired just before the paid retry (the call then blocks on confirmed-tier
3143
3246
  * settle, or returns near-instantly on an optimistic surface). */
3144
3247
  onSettling?: (info: {
3145
- asset: string
3146
- amount: string
3147
- }) => void
3248
+ asset: string;
3249
+ amount: string;
3250
+ }) => void;
3148
3251
  /** Abort the paid retry after this long. */
3149
- timeoutMs?: number
3252
+ timeoutMs?: number;
3150
3253
  };
3151
3254
  type X402Fetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
3152
3255
  /**
@@ -3161,23 +3264,23 @@ type X402Fetch = (input: string | URL, init?: RequestInit) => Promise<Response>;
3161
3264
  */
3162
3265
  declare function withX402(baseFetch: typeof fetch, opts: WithX402Options): X402Fetch;
3163
3266
  type X402ClientOptions = WithX402Options & {
3164
- baseUrl: string
3267
+ baseUrl: string;
3165
3268
  /** Override the underlying fetch (tests). */
3166
- fetch?: typeof fetch
3269
+ fetch?: typeof fetch;
3167
3270
  };
3168
3271
  type X402Result<T = unknown> = {
3169
- data: T
3272
+ data: T;
3170
3273
  /** Settlement receipt, or null if the response carried none. */
3171
- payment: X402Receipt | null
3172
- response: Response
3274
+ payment: X402Receipt | null;
3275
+ response: Response;
3173
3276
  };
3174
3277
  type X402Client = {
3175
3278
  get<T = unknown>(path: string, o?: {
3176
- query?: Record<string, string>
3177
- }): Promise<X402Result<T>>
3279
+ query?: Record<string, string>;
3280
+ }): Promise<X402Result<T>>;
3178
3281
  post<T = unknown>(path: string, o?: {
3179
- body?: unknown
3180
- }): Promise<X402Result<T>>
3282
+ body?: unknown;
3283
+ }): Promise<X402Result<T>>;
3181
3284
  };
3182
3285
  /**
3183
3286
  * A small client over {@link withX402}: `.get/.post` against `baseUrl`, returning
@@ -3192,7 +3295,7 @@ declare function createX402Client(opts: X402ClientOptions): X402Client;
3192
3295
  type X402FetchFn = (extraHeaders: Record<string, string>) => Promise<Response>;
3193
3296
  type PayAndRetryOptions = Omit<WithX402Options, never> & {
3194
3297
  /** Required here (use `withX402` for auto-nonce). */
3195
- accountNonce: bigint | number | string
3298
+ accountNonce: bigint | number | string;
3196
3299
  };
3197
3300
  /**
3198
3301
  * Low-level: run a request via a caller-controlled fetch; if it 402s, pay and
@@ -3224,7 +3327,7 @@ interface ConsumerHealth {
3224
3327
  * should restart on. `blocks_behind` still ships in the body for dashboards.
3225
3328
  */
3226
3329
  declare function consumerHealth(options?: {
3227
- staleAfterMs?: number
3330
+ staleAfterMs?: number;
3228
3331
  }): ConsumerHealth;
3229
3332
  /**
3230
3333
  * An `AbortSignal` wired to SIGTERM/SIGINT (redeploys arrive as SIGTERM).
@@ -3236,7 +3339,7 @@ declare function consumerHealth(options?: {
3236
3339
  * No-op (never fires) on runtimes without `process` signal handling.
3237
3340
  */
3238
3341
  declare function shutdownSignal(options?: {
3239
- signals?: readonly ("SIGTERM" | "SIGINT")[]
3342
+ signals?: readonly ("SIGTERM" | "SIGINT")[];
3240
3343
  }): AbortSignal;
3241
3344
  import { ChainWebhookDelivery } from "@secondlayer/shared";
3242
3345
  import { StandardWebhooksHeaders } from "@secondlayer/shared/crypto/standard-webhooks";
@@ -3244,7 +3347,7 @@ import { StandardWebhooksHeaders as StandardWebhooksHeaders2, verify } from "@se
3244
3347
  import { ChainApplyDeliveryOf, ChainApplyEnvelope, ChainApplyEnvelopeOf, ChainEventEnvelope, ChainFtBurnData, ChainFtMintData, ChainFtTransferData, ChainNftBurnData, ChainNftMintData, ChainNftTransferData, ChainPrintEventData, ChainReorgOrphanedEntry, ChainReorgRollbackDelivery, ChainReorgRollbackEnvelope, ChainStxBurnData, ChainStxLockData, ChainStxMintData, ChainStxTransferData, ChainTestDelivery, ChainTxLevelEvent, ChainWebhookDelivery as ChainWebhookDelivery2, ChainWebhookEnvelope, SbtcDepositEvent, SbtcWithdrawalEvent, SbtcWithdrawalSweptConfirmedEvent } from "@secondlayer/shared";
3245
3348
  type HeaderLookup = (name: string) => string | null | undefined;
3246
3349
  type WebhookHeaderInput = HeaderLookup | StandardWebhooksHeaders | Record<string, string | string[] | undefined> | {
3247
- get: (name: string) => string | null
3350
+ get: (name: string) => string | null;
3248
3351
  };
3249
3352
  /**
3250
3353
  * Verify a Secondlayer webhook delivery signature.