@secondlayer/sdk 6.47.0 → 6.48.1

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