@secondlayer/sdk 6.21.2 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -273,6 +273,7 @@ declare class Contracts extends BaseClient {
273
273
  includeAbi?: boolean
274
274
  }): Promise<ContractSummary | null>;
275
275
  }
276
+ import { InferredTopicSchema } from "@secondlayer/subgraphs";
276
277
  import { RewardSet } from "@secondlayer/shared/node/consensus";
277
278
  import { MerkleProofStep } from "@secondlayer/shared/node/nakamoto";
278
279
  /**
@@ -352,1120 +353,1235 @@ declare function fetchRewardSet(opts: {
352
353
  declare function verifyTransactionProof(proof: TransactionProof, opts?: {
353
354
  rewardSet?: RewardSet
354
355
  }): TransactionProofVerifyResult;
355
- type IndexTip = {
356
- block_height: number
357
- lag_seconds: number
358
- };
359
- /**
360
- * A chain reorg overlapping a returned page's height range. Height-keyed feeds
361
- * (`/transactions`, `/contract-calls`, `/stacking`) populate this so a consumer
362
- * can reconcile: roll back the rows whose `block_height:tx_index` cursor falls in
363
- * `orphaned_range`, then re-fetch from `new_canonical_tip`. Empty when the page
364
- * spans no reorg.
365
- */
366
- type IndexReorg = {
367
- id: string
368
- detected_at: string
369
- fork_point_height: number
370
- old_index_block_hash: string | null
371
- new_index_block_hash: string | null
372
- /** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */
373
- orphaned_range: {
374
- from: string
375
- to: string
376
- }
377
- /** New canonical tip cursor to resume from. */
378
- new_canonical_tip: string
379
- };
380
- type IndexUsage = {
381
- product: "index"
382
- tier: string
383
- limits: {
384
- rate_limit_per_second: number | null
385
- }
386
- usage: {
387
- decoded_events_today: number
388
- decoded_events_this_month: number
389
- }
390
- };
391
- type FtTransfer = {
392
- cursor: string
393
- block_height: number
394
- tx_id: string
395
- tx_index: number
396
- event_index: number
397
- event_type: "ft_transfer"
398
- contract_id: string
399
- asset_identifier: string
356
+ import { StreamsEventType } from "@secondlayer/shared";
357
+ /** A Clarity value as Streams serves it: the canonical hex string, a typed
358
+ * object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
359
+ * Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
360
+ type StreamsClarityValue = string | {
361
+ hex: string
362
+ } | Record<string, unknown>;
363
+ type StxTransferPayload = {
400
364
  sender: string
401
365
  recipient: string
402
366
  amount: string
367
+ memo?: string
403
368
  };
404
- type FtTransfersEnvelope = {
405
- events: FtTransfer[]
406
- next_cursor: string | null
407
- tip: IndexTip
408
- reorgs: IndexReorg[]
409
- };
410
- type FtTransfersListParams = {
411
- cursor?: string | null
412
- fromCursor?: string | null
413
- limit?: number
414
- contractId?: string
415
- sender?: string
416
- recipient?: string
417
- fromHeight?: number
418
- toHeight?: number
419
- };
420
- type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & {
421
- batchSize?: number
422
- signal?: AbortSignal
423
- };
424
- type NftTransfer = {
425
- cursor: string
426
- block_height: number
427
- tx_id: string
428
- tx_index: number
429
- event_index: number
430
- event_type: "nft_transfer"
431
- contract_id: string
432
- asset_identifier: string
433
- sender: string
369
+ type StxMintPayload = {
434
370
  recipient: string
435
- value: string
436
- };
437
- type NftTransfersEnvelope = {
438
- events: NftTransfer[]
439
- next_cursor: string | null
440
- tip: IndexTip
441
- reorgs: IndexReorg[]
442
- };
443
- type NftTransfersListParams = {
444
- cursor?: string | null
445
- fromCursor?: string | null
446
- limit?: number
447
- contractId?: string
448
- assetIdentifier?: string
449
- sender?: string
450
- recipient?: string
451
- fromHeight?: number
452
- toHeight?: number
453
- };
454
- type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
455
- batchSize?: number
456
- signal?: AbortSignal
457
- };
458
- type IndexEventBase = {
459
- cursor: string
460
- block_height: number
461
- block_time?: string | null
462
- tx_id: string
463
- tx_index: number
464
- event_index: number
465
- contract_id: string | null
371
+ amount: string
466
372
  };
467
- type IndexFtTransfer = IndexEventBase & {
468
- event_type: "ft_transfer"
469
- asset_identifier: string
373
+ type StxBurnPayload = {
470
374
  sender: string
471
- recipient: string
472
375
  amount: string
473
376
  };
474
- type IndexNftTransfer = IndexEventBase & {
475
- event_type: "nft_transfer"
476
- asset_identifier: string
477
- sender: string
478
- recipient: string
479
- value: string
377
+ type StxLockPayload = {
378
+ locked_address: string
379
+ locked_amount: string
380
+ unlock_height: string
480
381
  };
481
- type IndexStxTransfer = IndexEventBase & {
482
- event_type: "stx_transfer"
382
+ type FtTransferPayload = {
383
+ asset_identifier: string
483
384
  sender: string
484
385
  recipient: string
485
386
  amount: string
486
- memo: string | null
487
387
  };
488
- type IndexStxMint = IndexEventBase & {
489
- event_type: "stx_mint"
388
+ type FtMintPayload = {
389
+ asset_identifier: string
490
390
  recipient: string
491
391
  amount: string
492
392
  };
493
- type IndexStxBurn = IndexEventBase & {
494
- event_type: "stx_burn"
495
- sender: string
496
- amount: string
497
- };
498
- type IndexStxLock = IndexEventBase & {
499
- event_type: "stx_lock"
500
- sender: string
501
- amount: string
502
- payload: {
503
- unlock_height: string | null
504
- }
505
- };
506
- type IndexFtMint = IndexEventBase & {
507
- event_type: "ft_mint"
393
+ type FtBurnPayload = {
508
394
  asset_identifier: string
509
- recipient: string
395
+ sender: string
510
396
  amount: string
511
397
  };
512
- type IndexFtBurn = IndexEventBase & {
513
- event_type: "ft_burn"
398
+ type NftTransferPayload = {
514
399
  asset_identifier: string
515
400
  sender: string
516
- amount: string
401
+ recipient: string
402
+ value: StreamsClarityValue
403
+ /** Canonical serialized hex of `value`, when the stream carries it. */
404
+ raw_value?: string
517
405
  };
518
- type IndexNftMint = IndexEventBase & {
519
- event_type: "nft_mint"
406
+ type NftMintPayload = {
520
407
  asset_identifier: string
521
408
  recipient: string
522
- value: string
409
+ value: StreamsClarityValue
410
+ raw_value?: string
523
411
  };
524
- type IndexNftBurn = IndexEventBase & {
525
- event_type: "nft_burn"
412
+ type NftBurnPayload = {
526
413
  asset_identifier: string
527
414
  sender: string
528
- value: string
529
- };
530
- type IndexPrint = IndexEventBase & {
531
- event_type: "print"
532
- payload: {
533
- topic: string | null
534
- value: unknown
535
- raw_value: string | null
536
- }
537
- };
538
- /** Decoded chain event, discriminated by `event_type`. */
539
- type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
540
- type IndexEventType = IndexEvent["event_type"];
541
- type EventsEnvelope = {
542
- events: IndexEvent[]
543
- next_cursor: string | null
544
- tip: IndexTip
545
- reorgs: IndexReorg[]
546
- };
547
- type EventsListParams = {
548
- /** Required. One of the decoded event types. */
549
- eventType: IndexEventType
550
- cursor?: string | null
551
- fromCursor?: string | null
552
- limit?: number
553
- contractId?: string
554
- assetIdentifier?: string
555
- sender?: string
556
- recipient?: string
557
- fromHeight?: number
558
- toHeight?: number
559
- /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
560
- * Mutually exclusive with contractId; contract-keyed event types only. */
561
- trait?: string
415
+ value: StreamsClarityValue
416
+ raw_value?: string
562
417
  };
563
- type EventsWalkParams = Omit<EventsListParams, "limit"> & {
564
- batchSize?: number
565
- signal?: AbortSignal
418
+ type PrintPayload = {
419
+ contract_id?: string | null
420
+ topic?: string
421
+ value?: unknown
422
+ raw_value?: string
566
423
  };
567
- type IndexContractCall = {
424
+ /** Union of every Streams payload shape, discriminated by `event_type` on the
425
+ * parent `StreamsEvent`. */
426
+ type StreamsEventPayload = StxTransferPayload | StxMintPayload | StxBurnPayload | StxLockPayload | FtTransferPayload | FtMintPayload | FtBurnPayload | NftTransferPayload | NftMintPayload | NftBurnPayload | PrintPayload;
427
+ type StreamsEventBase = {
428
+ /**
429
+ * Globally unique, monotonic position of this event (`<block>:<index>`). Use
430
+ * it as the primary key of your projection rows — replaying a batch then
431
+ * upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
432
+ */
568
433
  cursor: string
569
434
  block_height: number
570
- block_time?: string | null
435
+ block_hash: string
436
+ burn_block_height: number
571
437
  tx_id: string
572
438
  tx_index: number
573
- contract_id: string
574
- function_name: string
575
- sender: string
576
- status: string
577
- args: unknown[]
578
- result: unknown
579
- result_hex: string | null
580
- };
581
- type ContractCallsEnvelope = {
582
- contract_calls: IndexContractCall[]
583
- next_cursor: string | null
584
- tip: IndexTip
585
- reorgs: IndexReorg[]
439
+ event_index: number
440
+ contract_id: string | null
441
+ ts: string
442
+ /**
443
+ * True when this event's block is past the finality boundary (immutable).
444
+ * Optional for back-compat; the API always sets it on Streams responses.
445
+ */
446
+ finalized?: boolean
586
447
  };
587
- type ContractCallsListParams = {
588
- cursor?: string | null
589
- fromCursor?: string | null
590
- limit?: number
591
- contractId?: string
592
- functionName?: string
593
- sender?: string
594
- fromHeight?: number
595
- toHeight?: number
596
- /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
597
- * Mutually exclusive with contractId. */
598
- trait?: string
599
- };
600
- type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
601
- batchSize?: number
602
- signal?: AbortSignal
448
+ type StreamsEventOf<
449
+ T extends StreamsEventType,
450
+ P
451
+ > = StreamsEventBase & {
452
+ event_type: T
453
+ payload: P
603
454
  };
604
- /** One canonical block in the sync map. Lean by design block + parent hash
605
- * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for
606
- * the full block resource. */
607
- type IndexCanonicalBlock = {
608
- cursor: string
455
+ /** A raw Streams event. Discriminated on `event_type`, so `event.payload`
456
+ * narrows to the matching payload shape once the type is checked. */
457
+ 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>;
458
+ type StreamsTip = {
609
459
  block_height: number
610
460
  block_hash: string
611
- parent_hash: string
612
461
  burn_block_height: number
613
- burn_block_hash: string | null
614
- };
615
- type CanonicalEnvelope = {
616
- canonical: IndexCanonicalBlock[]
617
- next_cursor: string | null
618
- tip: IndexTip
619
- };
620
- type CanonicalListParams = {
621
- cursor?: string | null
622
- fromCursor?: string | null
623
- limit?: number
624
- fromHeight?: number
625
- toHeight?: number
626
- };
627
- type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & {
628
- batchSize?: number
629
- signal?: AbortSignal
462
+ /**
463
+ * Highest Stacks block past the burn-confirmation finality boundary.
464
+ * Optional for back-compat; the API always sets it.
465
+ */
466
+ finalized_height?: number
467
+ lag_seconds: number
468
+ /**
469
+ * Oldest height still seekable on the live API for the caller's tier
470
+ * (`tip - retention`). `null` = unlimited retention. Older reads must use the
471
+ * cold dumps lane. Optional for back-compat.
472
+ */
473
+ oldest_seekable_height?: number | null
474
+ /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
475
+ oldest_cursor?: string | null
630
476
  };
631
- /** A block resource. Metadata is intentionally thin — only chain-linkage and
632
- * burn-anchor fields are persisted (no miner / tx_count / signer). */
633
- type IndexBlock = {
634
- cursor: string
477
+ type StreamsCanonicalBlock = {
635
478
  block_height: number
636
479
  block_hash: string
637
- parent_hash: string
638
480
  burn_block_height: number
639
481
  burn_block_hash: string | null
640
- block_time: string | null
641
- canonical: boolean
482
+ is_canonical: true
642
483
  };
643
- type BlocksEnvelope = {
644
- blocks: IndexBlock[]
484
+ type StreamsReorg = {
485
+ detected_at: string
486
+ fork_point_height: number
487
+ orphaned_range: {
488
+ from: string
489
+ to: string
490
+ }
491
+ new_canonical_tip: string
492
+ };
493
+ type StreamsEventsEnvelope = {
494
+ events: StreamsEvent[]
645
495
  next_cursor: string | null
646
- tip: IndexTip
496
+ tip: StreamsTip
497
+ reorgs: StreamsReorg[]
647
498
  };
648
- type BlockEnvelope = {
649
- block: IndexBlock
650
- tip: IndexTip
499
+ type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
500
+ type StreamsReorgsListParams = {
501
+ since: string
502
+ limit?: number
651
503
  };
652
- type BlocksListParams = {
504
+ type StreamsReorgsListEnvelope = {
505
+ reorgs: StreamsReorg[]
506
+ next_since: string | null
507
+ };
508
+ /** A filter that matches a single value or any value in a list. */
509
+ type StreamsFilterValue = string | readonly string[];
510
+ type StreamsEventsListParams = {
653
511
  cursor?: string | null
654
- fromCursor?: string | null
655
- limit?: number
656
512
  fromHeight?: number
657
513
  toHeight?: number
514
+ types?: readonly StreamsEventType[]
515
+ /** Event types to exclude (applied after `types`). */
516
+ notTypes?: readonly StreamsEventType[]
517
+ contractId?: StreamsFilterValue
518
+ sender?: StreamsFilterValue
519
+ recipient?: StreamsFilterValue
520
+ assetIdentifier?: string
521
+ limit?: number
658
522
  };
659
- type BlocksWalkParams = Omit<BlocksListParams, "limit"> & {
523
+ type StreamsEventsStreamParams = {
524
+ fromCursor?: string | null
525
+ types?: readonly StreamsEventType[]
526
+ notTypes?: readonly StreamsEventType[]
527
+ contractId?: StreamsFilterValue
528
+ sender?: StreamsFilterValue
529
+ recipient?: StreamsFilterValue
530
+ assetIdentifier?: string
660
531
  batchSize?: number
532
+ emptyBackoffMs?: number
533
+ maxPages?: number
534
+ maxEmptyPolls?: number
661
535
  signal?: AbortSignal
662
536
  };
663
- type IndexPostCondition = {
664
- type: "stx"
665
- principal: string
666
- condition_code: number
667
- condition_code_name: string | null
668
- amount: string
669
- } | {
670
- type: "ft"
671
- principal: string
672
- asset_identifier: string
673
- condition_code: number
674
- condition_code_name: string | null
675
- amount: string
676
- } | {
677
- type: "nft"
678
- principal: string
679
- asset_identifier: string
680
- asset_value: unknown
681
- condition_code: number
682
- condition_code_name: string | null
683
- };
684
- /** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.
685
- * Payload sub-objects are present only for the matching `tx_type`; enrichment
686
- * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */
687
- type IndexTransaction = {
688
- cursor: string
689
- tx_id: string
690
- block_height: number
691
- block_time?: string | null
692
- tx_index: number
693
- tx_type: string
694
- sender: string
695
- status: string
696
- fee: string | null
697
- nonce: string | null
698
- sponsored: boolean | null
699
- anchor_mode: string | null
700
- post_condition_mode: string | null
701
- post_conditions: IndexPostCondition[]
702
- contract_call?: {
703
- contract_id: string
704
- function_name: string
705
- function_args: unknown[]
706
- /** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */
707
- function_args_hex: string[]
708
- result: unknown
709
- result_hex: string | null
710
- }
711
- token_transfer?: {
712
- recipient: string
713
- amount: string
714
- memo: string
715
- }
716
- smart_contract?: {
717
- contract_id: string | null
718
- clarity_version: number | null
719
- }
720
- coinbase?: {
721
- alt_recipient: string | null
722
- }
723
- tenure_change?: {
724
- cause: number
725
- }
537
+ type StreamsEventsSubscribeParams = {
538
+ /** Resume strictly after this cursor; omit to live-tail from the tip. */
539
+ fromCursor?: string | null
540
+ types?: readonly StreamsEventType[]
541
+ notTypes?: readonly StreamsEventType[]
542
+ contractId?: StreamsFilterValue
543
+ sender?: StreamsFilterValue
544
+ recipient?: StreamsFilterValue
545
+ assetIdentifier?: string
546
+ /** Abort to unsubscribe (the returned function does the same). */
547
+ signal?: AbortSignal
548
+ /** Called for each pushed event, in order. */
549
+ onEvent: (event: StreamsEvent) => void | Promise<void>
550
+ /** Called on a connection error; the subscription auto-reconnects from the
551
+ * last delivered cursor unless the signal has aborted. */
552
+ onError?: (err: unknown) => void
726
553
  };
727
- type TransactionsEnvelope = {
728
- transactions: IndexTransaction[]
729
- next_cursor: string | null
730
- tip: IndexTip
731
- reorgs: IndexReorg[]
554
+ /**
555
+ * The checkpoint the SDK computes for a batch. Persist `cursor` inside the same
556
+ * transaction as your projection writes, then resume from it via `fromCursor`.
557
+ * It is the position to advance to: `next_cursor` normally, or the last
558
+ * finalized event when `finalizedOnly` is set.
559
+ */
560
+ type StreamsBatchContext = {
561
+ cursor: string | null
732
562
  };
733
- type TransactionEnvelope = {
734
- transaction: IndexTransaction
735
- tip: IndexTip
563
+ /**
564
+ * The checkpoint for a reorg rollback. Persist `cursor` (the rewind position)
565
+ * inside the same transaction as your rollback so the two commit atomically.
566
+ */
567
+ type StreamsReorgContext = {
568
+ cursor: string
736
569
  };
737
- type TransactionsListParams = {
738
- cursor?: string | null
570
+ type StreamsEventsConsumeParams = {
739
571
  fromCursor?: string | null
740
- limit?: number
741
- type?: string
742
- sender?: string
743
- contractId?: string
744
- fromHeight?: number
745
- toHeight?: number
746
- };
747
- type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & {
572
+ mode?: "tail" | "bounded"
573
+ /**
574
+ * Emit only finalized (immutable) events and never surface reorgs. The SDK
575
+ * checkpoints at the last finalized event and re-reads the unfinalized tail
576
+ * until it settles. Trades finality lag for zero reorg handling; `onReorg` is
577
+ * ignored.
578
+ */
579
+ finalizedOnly?: boolean
580
+ types?: readonly StreamsEventType[]
581
+ notTypes?: readonly StreamsEventType[]
582
+ contractId?: StreamsFilterValue
583
+ sender?: StreamsFilterValue
584
+ recipient?: StreamsFilterValue
585
+ assetIdentifier?: string
748
586
  batchSize?: number
749
- signal?: AbortSignal
750
- };
751
- /** A decoded PoX-4 stacking action (one per stacking contract call). */
752
- type IndexStackingAction = {
753
- cursor: string
754
- block_height: number
755
- block_time?: string | null
756
- burn_block_height: number
757
- tx_id: string
758
- tx_index: number
759
- function_name: string
760
- caller: string
761
- stacker: string | null
762
- delegate_to: string | null
763
- amount_ustx: string | null
764
- lock_period: number | null
765
- pox_addr: {
766
- version: number | null
767
- hashbytes: string | null
768
- btc: string | null
769
- }
770
- start_cycle: number | null
771
- end_cycle: number | null
772
- reward_cycle: number | null
773
- signer_key: string | null
774
- result_ok: boolean
587
+ /**
588
+ * Apply a page of canonical events. Persist `ctx.cursor` in the same
589
+ * transaction as your writes. Returning a cursor overrides `ctx.cursor` as
590
+ * the resume point (advanced manual control); returning nothing uses it.
591
+ */
592
+ onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
593
+ /**
594
+ * Roll your projection back to `reorg.fork_point_height`, persisting
595
+ * `ctx.cursor` in the same transaction. Called once per *new* reorg
596
+ * (deduped in-memory, fork-ascending) before the SDK rewinds and re-reads the
597
+ * now-canonical events. Omit it to ignore reorgs (events stay canonical, but
598
+ * stale rows from an orphaned fork are left in place).
599
+ */
600
+ onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
601
+ emptyBackoffMs?: number
602
+ maxPages?: number
603
+ maxEmptyPolls?: number
604
+ signal?: AbortSignal
775
605
  };
776
- type StackingEnvelope = {
777
- stacking: IndexStackingAction[]
778
- next_cursor: string | null
779
- tip: IndexTip
780
- reorgs: IndexReorg[]
781
- /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
782
- notes?: string
606
+ /**
607
+ * One yielded page from {@link StreamsClient.consume} — the
608
+ * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
609
+ * `cursor` (the checkpoint to persist and resume from).
610
+ */
611
+ type StreamsBatch = {
612
+ /** Canonical events of this page, in cursor order. */
613
+ events: StreamsEvent[]
614
+ /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
615
+ cursor: string | null
616
+ tip: StreamsTip
617
+ /** Chain reorgs reported alongside this page; empty when none. */
618
+ reorgs: StreamsReorg[]
783
619
  };
784
- type StackingListParams = {
620
+ type StreamsConsumeParams = {
621
+ /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
785
622
  cursor?: string | null
786
- fromCursor?: string | null
787
- limit?: number
788
- functionName?: string
789
- stacker?: string
790
- caller?: string
791
- fromHeight?: number
792
- toHeight?: number
623
+ types?: readonly StreamsEventType[]
624
+ notTypes?: readonly StreamsEventType[]
625
+ contractId?: StreamsFilterValue
626
+ sender?: StreamsFilterValue
627
+ recipient?: StreamsFilterValue
628
+ assetIdentifier?: string
629
+ /** Events per page (the `limit` query param). Default 100. */
630
+ batchSize?: number
631
+ /** Poll interval while caught up at the tip, in ms. Default 2000. */
632
+ intervalMs?: number
633
+ /** Abort to end the iteration. */
634
+ signal?: AbortSignal
793
635
  };
794
- type StackingWalkParams = Omit<StackingListParams, "limit"> & {
636
+ type StreamsEventsConsumeResult = {
637
+ cursor: string | null
638
+ pages: number
639
+ emptyPolls: number
640
+ };
641
+ type StreamsEventsReplayParams = {
642
+ /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
643
+ from?: "genesis" | string
644
+ /**
645
+ * Called once per finalized dump file, in block order, before live tailing.
646
+ * Process the parquet with your own tooling (e.g. DuckDB) — the SDK does not
647
+ * decode parquet. Use `client.dumps.download(file)` to fetch + verify bytes.
648
+ */
649
+ onDumpFile: (file: StreamsDumpFile) => Promise<void> | void
650
+ /** Called per live page after the dump phase, like `consume`. */
651
+ onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined
652
+ mode?: "tail" | "bounded"
795
653
  batchSize?: number
654
+ emptyBackoffMs?: number
655
+ maxPages?: number
656
+ maxEmptyPolls?: number
796
657
  signal?: AbortSignal
797
658
  };
798
- /** A pending (unconfirmed) transaction. Like a transaction document but
799
- * pre-chain no block_height/tx_index/result/events with `received_at` and
800
- * a sequence cursor instead of a block position. */
801
- type IndexMempoolTransaction = {
802
- cursor: string
803
- tx_id: string
804
- tx_type: string
805
- sender: string
806
- received_at?: string | null
807
- fee: string | null
808
- nonce: string | null
809
- sponsored: boolean | null
810
- anchor_mode: string | null
811
- post_condition_mode: string | null
812
- post_conditions: IndexPostCondition[]
813
- contract_call?: {
814
- contract_id: string
815
- function_name: string
816
- function_args: unknown[]
659
+ type FetchLike2 = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
660
+ /** One bulk parquet file in the dumps manifest. `path` is the object key under
661
+ * the dumps base URL. */
662
+ type StreamsDumpFile = {
663
+ path: string
664
+ from_block: number
665
+ to_block: number
666
+ min_cursor: string | null
667
+ max_cursor: string | null
668
+ row_count: number
669
+ byte_size: number
670
+ sha256: string
671
+ schema_version: number
672
+ created_at: string
673
+ };
674
+ type StreamsDumpsManifest = {
675
+ dataset: string
676
+ network: string
677
+ version: string
678
+ schema_version: number
679
+ generated_at: string
680
+ producer_version: string
681
+ finality_lag_blocks: number
682
+ /** Cursor at the end of the finalized bulk coverage — hand to live tailing. */
683
+ latest_finalized_cursor: string | null
684
+ coverage: {
685
+ from_block: number
686
+ to_block: number
817
687
  }
818
- token_transfer?: {
819
- recipient: string
820
- amount: string
821
- memo: string
688
+ files: StreamsDumpFile[]
689
+ /** ed25519 signature over the manifest's canonical bytes. Absent on legacy
690
+ * unsigned manifests. Verified by `list()` when `verifyDumpsManifest` is on. */
691
+ signature?: string
692
+ /** Short id of the signing public key. */
693
+ key_id?: string
694
+ };
695
+ type StreamsDumps = {
696
+ /** Fetch and parse the latest dumps manifest. */
697
+ list(): Promise<StreamsDumpsManifest>
698
+ /** Absolute URL for a manifest file. */
699
+ fileUrl(file: StreamsDumpFile): string
700
+ /** Download a parquet file and verify its sha256 against the manifest. */
701
+ download(file: StreamsDumpFile): Promise<Uint8Array>
702
+ };
703
+ type StreamsClient = {
704
+ /**
705
+ * Follow Streams as an async iterator of page batches.
706
+ *
707
+ * Yields one {@link StreamsBatch} per `GET /v1/streams/events` page — the
708
+ * existing envelope (`events`, `next_cursor` → `cursor`, `tip`, `reorgs`)
709
+ * with zero extra API calls. Batches are chosen over per-block groupings
710
+ * because the envelope is page-keyed, so every yield is exactly one fetch.
711
+ * Empty pages are skipped; at the tip the iterator re-polls every
712
+ * `intervalMs` (default 2000) until aborted via `signal`.
713
+ *
714
+ * Reorgs are surfaced on the batch (`batch.reorgs`) but the cursor is not
715
+ * rewound automatically — use `events.consume` with `onReorg` for managed
716
+ * rollback semantics.
717
+ */
718
+ consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
719
+ events: {
720
+ list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
721
+ byTxId(txId: string): Promise<StreamsEventsListEnvelope>
722
+ /**
723
+ * Pull pages from Streams and call `onBatch` after each page.
724
+ *
725
+ * Use `consume` for indexers and ETL jobs that own checkpointing. Return
726
+ * the checkpoint cursor from `onBatch`. Default `mode: "tail"` keeps
727
+ * polling when caught up; `mode: "bounded"` exits on the first empty page.
728
+ * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
729
+ * stops it.
730
+ */
731
+ consume(params: StreamsEventsConsumeParams): Promise<StreamsEventsConsumeResult>
732
+ /**
733
+ * Backfill from bulk dumps, then continue live from the dump→live seam in
734
+ * one call. Iterates finalized dump files (via `onDumpFile`) in block
735
+ * order, then tails live from the manifest's `latest_finalized_cursor`
736
+ * (exclusive input → no gap or duplicate at the seam). Requires
737
+ * `dumpsBaseUrl`.
738
+ */
739
+ replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>
740
+ /**
741
+ * Follow Streams as an async iterator.
742
+ *
743
+ * Use `stream` for live processors and watch-style apps. It tails
744
+ * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
745
+ * `maxEmptyPolls` stops it.
746
+ */
747
+ stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
748
+ /**
749
+ * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
750
+ * canonical event as the server pushes it (chain cadence, not poll-bounded),
751
+ * and verifies each frame's inline ed25519 signature when the client was
752
+ * created with `verify`. Returns an unsubscribe function.
753
+ */
754
+ subscribe(params: StreamsEventsSubscribeParams): () => void
822
755
  }
823
- smart_contract?: {
824
- clarity_version: number | null
756
+ blocks: {
757
+ events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>
825
758
  }
826
- coinbase?: {
827
- alt_recipient: string | null
759
+ reorgs: {
760
+ list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>
828
761
  }
829
- tenure_change?: {
830
- cause: number
762
+ /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
763
+ dumps: StreamsDumps
764
+ canonical(height: number): Promise<StreamsCanonicalBlock>
765
+ tip(): Promise<StreamsTip>
766
+ /** Your own Streams consumption (events today + this month) and tier limits. */
767
+ usage(): Promise<StreamsUsage>
768
+ };
769
+ type StreamsUsage = {
770
+ product: "streams"
771
+ tier: string
772
+ limits: {
773
+ rate_limit_per_second: number | null
774
+ retention_days: number | null
775
+ }
776
+ usage: {
777
+ events_today: number
778
+ events_this_month: number
831
779
  }
832
780
  };
833
- type MempoolEnvelope = {
834
- mempool: IndexMempoolTransaction[]
835
- next_cursor: string | null
836
- tip: IndexTip
781
+ type Sleep = (ms: number, signal?: AbortSignal) => Promise<void>;
782
+ /** Minimum shape a consumed Index row must expose. */
783
+ type IndexFeedItem = {
784
+ cursor: string
785
+ block_height: number
837
786
  };
838
- type MempoolTransactionEnvelope = {
839
- transaction: IndexMempoolTransaction
787
+ /** Minimum envelope shape of a consumable Index feed page. */
788
+ type IndexFeedEnvelope = {
789
+ next_cursor: string | null
840
790
  tip: IndexTip
791
+ reorgs: IndexReorg[]
841
792
  };
842
- type MempoolListParams = {
843
- cursor?: string | null
793
+ /** One page fetch. `fromHeight` is only set on the first page of a fresh
794
+ * consume (no cursor yet) cursor and from_height are mutually exclusive
795
+ * on the API. */
796
+ type IndexFeedFetcher<TEnvelope extends IndexFeedEnvelope> = (params: {
797
+ cursor: string | null
798
+ fromHeight?: number
799
+ limit: number
800
+ }) => Promise<TEnvelope>;
801
+ /** Consumer options shared by `index.events.consume` and
802
+ * `index.contractCalls.consume`. Same contract as the Streams consumer:
803
+ * commit your writes inside `onBatch`, return the cursor you committed. */
804
+ type IndexConsumeOptions<
805
+ TItem extends IndexFeedItem,
806
+ TEnvelope extends IndexFeedEnvelope
807
+ > = {
808
+ /** Resume from a committed checkpoint. Without it (and without
809
+ * `fromHeight`) the API serves only the recent default window. */
844
810
  fromCursor?: string | null
845
- limit?: number
846
- sender?: string
847
- type?: string
848
- /** Filter to pending calls to a single contract (e.g. `SP….contract`). */
849
- contractId?: string
850
- };
851
- type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
811
+ /** Start a fresh sweep at this height (e.g. `0` for genesis backfill).
812
+ * Ignored once a cursor exists. */
813
+ fromHeight?: number
814
+ /** `tail` (default) keeps polling at the tip; `bounded` returns on the
815
+ * first empty page. */
816
+ mode?: "tail" | "bounded"
817
+ /** Emit only rows at or below the tip's `finalized_height`; the
818
+ * unfinalized tail is re-read each poll until it settles. Finalized data
819
+ * never reorgs, so `onReorg` is skipped entirely. */
820
+ finalizedOnly?: boolean
852
821
  batchSize?: number
822
+ onBatch: (items: TItem[], envelope: TEnvelope, ctx: {
823
+ cursor: string | null
824
+ }) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
825
+ onReorg?: (reorg: IndexReorg, ctx: {
826
+ cursor: string
827
+ }) => Promise<void> | void
828
+ sleep?: Sleep
829
+ emptyBackoffMs?: number
830
+ maxPages?: number
831
+ maxEmptyPolls?: number
853
832
  signal?: AbortSignal
854
833
  };
855
834
  /**
856
- * `index.ftTransfers` callable shorthand for `.list()`, with `.list`/`.walk`
857
- * still available: `await sl.index.ftTransfers({ contractId })`.
835
+ * Checkpointed pull loop over a cursor-paginated Index feed — the Index port
836
+ * of `consumeStreamsEvents`, sharing its contract: at-least-once delivery,
837
+ * client-owned checkpoints (`onBatch` may return the cursor it committed),
838
+ * and automatic reorg rewind to the lowest fresh fork point.
858
839
  *
859
- * The API accepts `contract_id`/`sender`/`recipient` equality filters only
860
- * no amount filtering and no asset-slug resolution on /v1/index/ft-transfers.
840
+ * Differs from Streams in how finality is read: Index rows carry no
841
+ * per-event `finalized` flag, so `finalizedOnly` gates by
842
+ * `block_height <= tip.finalized_height` instead.
861
843
  */
862
- interface FtTransfersResource {
863
- (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
864
- list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
865
- walk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;
866
- }
867
- /** `index.nftTransfers` — callable shorthand for `.list()` (see {@link FtTransfersResource}). */
868
- interface NftTransfersResource {
869
- (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
870
- list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
871
- walk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;
872
- }
873
- /** `index.events` callable shorthand for `.list()`; `eventType` is required. */
874
- interface IndexEventsResource {
875
- (params: EventsListParams): Promise<EventsEnvelope>;
876
- list(params: EventsListParams): Promise<EventsEnvelope>;
877
- walk(params: EventsWalkParams): AsyncIterable<IndexEvent>;
878
- }
879
- /** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */
880
- type IndexEventTypeFilters = {
881
- columns?: string[]
882
- allowed_filters?: string[]
883
- equality_filters?: string[]
884
- required_non_null?: string[]
885
- };
886
- /** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.
887
- * Shape is intentionally open (the server may add fields); the agent-relevant
888
- * parts are the per-type filter rules. */
889
- type IndexDiscovery = {
890
- event_type_filters?: Record<string, IndexEventTypeFilters>
891
- [key: string]: unknown
844
+ declare function consumeIndexFeed<
845
+ TItem extends IndexFeedItem,
846
+ TEnvelope extends IndexFeedEnvelope
847
+ >(opts: IndexConsumeOptions<TItem, TEnvelope> & {
848
+ fetchPage: IndexFeedFetcher<TEnvelope>
849
+ itemsOf: (envelope: TEnvelope) => TItem[]
850
+ }): Promise<{
851
+ cursor: string | null
852
+ pages: number
853
+ emptyPolls: number
854
+ }>;
855
+ type IndexTip = {
856
+ block_height: number
857
+ /** Highest height treated as immutable (past the burn-confirmation
858
+ * finality boundary). Rows at or below it never reorg — `finalizedOnly`
859
+ * consumers gate on this, since Index rows carry no per-event flag. */
860
+ finalized_height: number
861
+ lag_seconds: number
892
862
  };
893
- declare class Index extends BaseClient {
894
- constructor(options?: Partial<SecondLayerOptions>);
895
- /** Your own Index consumption (decoded events today + this month) and tier limits. */
896
- usage(): Promise<IndexUsage>;
897
- /**
898
- * Index discovery doc — the live vocabulary: every endpoint, each event type's
899
- * columns, allowed/equality filters, and required-non-null fields. Read this to
900
- * learn what's queryable (and which types accept `trait`) instead of hardcoding.
901
- */
902
- discover(): Promise<IndexDiscovery>;
903
- /** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
904
- readonly ftTransfers: FtTransfersResource;
905
- /** Callable: `index.nftTransfers(params)` ≡ `index.nftTransfers.list(params)`. */
906
- readonly nftTransfers: NftTransfersResource;
907
- /** Generic decoded events by `event_type` (the full /v1/index/events surface).
908
- * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
909
- readonly events: IndexEventsResource;
910
- readonly contractCalls: {
911
- list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>
912
- walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>
913
- };
914
- /** Canonical block-hash map — sync only the current canonical chain. */
915
- readonly canonical: {
916
- list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>
917
- walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>
918
- };
919
- /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
920
- * (resolves to null on 404). */
921
- readonly blocks: {
922
- list: (params?: BlocksListParams) => Promise<BlocksEnvelope>
923
- walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>
924
- get: (ref: string | number) => Promise<BlockEnvelope | null>
925
- };
926
- /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
927
- * (resolves to null on 404). */
928
- readonly transactions: {
929
- list: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>
930
- walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>
931
- get: (txId: string) => Promise<TransactionEnvelope | null>
932
- getProof: (txId: string) => Promise<TransactionProof | null>
933
- };
934
- /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
935
- * platform's PoX-4 decoder is disabled. */
936
- readonly stacking: {
937
- list: (params?: StackingListParams) => Promise<StackingEnvelope>
938
- walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
939
- };
940
- /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
941
- * tx_id (resolves to null when the tx has confirmed or dropped). */
942
- readonly mempool: {
943
- list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
944
- walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
945
- get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
946
- };
947
- private listFtTransfers;
948
- private listNftTransfers;
949
- private walkFtTransfers;
950
- private walkNftTransfers;
951
- private listEvents;
952
- private walkEvents;
953
- private listContractCalls;
954
- private walkContractCalls;
955
- private listCanonical;
956
- private walkCanonical;
957
- private listBlocks;
958
- private getBlock;
959
- private walkBlocks;
960
- private listTransactions;
961
- private getTransaction;
962
- /** Fetch the inclusion proof for a tx (raw tx + Nakamoto header + merkle path)
963
- * to verify client-side with `verifyTransactionProof`. 404 → null. A 503
964
- * (`PROOF_TX_SET_INCOMPLETE` / `PROOF_NODE_UNAVAILABLE`) surfaces as an
965
- * ApiError — the proof can't be assembled on this deployment right now. */
966
- private getTransactionProof;
967
- private walkTransactions;
968
- private listStacking;
969
- private walkStacking;
970
- private listMempool;
971
- private getMempoolTx;
972
- private walkMempool;
973
- }
974
863
  /**
975
- * Typed client for project management (`/api/projects/*`).
976
- *
977
- * Projects are the account-scoped containers for work. Every method requires an
978
- * account-level (owner) API key or a dashboard session — scoped read keys are
979
- * rejected. Team mutations (invite/remove/role) are intentionally not exposed
980
- * here; only the read view ({@link Projects.team}) is.
864
+ * A chain reorg overlapping a returned page's height range. Height-keyed feeds
865
+ * (`/transactions`, `/contract-calls`, `/stacking`) populate this so a consumer
866
+ * can reconcile: roll back the rows whose `block_height:tx_index` cursor falls in
867
+ * `orphaned_range`, then re-fetch from `new_canonical_tip`. Empty when the page
868
+ * spans no reorg.
981
869
  */
982
- interface Project {
983
- id: string;
984
- name: string;
985
- slug: string;
986
- network: string;
987
- nodeRpc: string | null;
988
- settings: Record<string, unknown> | null;
989
- createdAt: string;
990
- updatedAt: string;
991
- }
992
- interface ProjectTeamMember {
993
- id: string;
994
- role: string;
995
- email: string;
996
- displayName: string | null;
997
- avatarUrl: string | null;
998
- createdAt: string;
999
- }
1000
- interface ProjectInvitation {
1001
- id: string;
1002
- email: string;
1003
- role: string;
1004
- expiresAt: string;
1005
- createdAt: string;
1006
- }
1007
- interface ProjectTeam {
1008
- members: ProjectTeamMember[];
1009
- invitations: ProjectInvitation[];
1010
- }
1011
- interface CreateProjectParams {
1012
- name: string;
1013
- slug?: string;
1014
- network?: string;
1015
- nodeRpc?: string;
1016
- }
1017
- interface UpdateProjectParams {
1018
- name?: string;
1019
- /** Rename the project's URL slug. */
1020
- slug?: string;
1021
- network?: string;
1022
- nodeRpc?: string;
1023
- settings?: Record<string, unknown>;
1024
- }
1025
- declare class Projects extends BaseClient {
1026
- constructor(options?: Partial<SecondLayerOptions>);
1027
- /** All projects owned by the account, newest-relevant first. */
1028
- list(): Promise<{
1029
- projects: Project[]
1030
- }>;
1031
- /** A single project by slug. */
1032
- get(slug: string): Promise<Project>;
1033
- /** Create a project. The creator is added as the project owner. */
1034
- create(params: CreateProjectParams): Promise<Project>;
1035
- /** Update a project's name, slug (rename), network, RPC, or settings. */
1036
- update(slug: string, patch: UpdateProjectParams): Promise<Project>;
1037
- /** Delete a project. The account's last remaining project cannot be deleted. */
1038
- delete(slug: string): Promise<{
1039
- ok: true
1040
- }>;
1041
- /** Team members and pending invitations for a project. */
1042
- team(slug: string): Promise<ProjectTeam>;
1043
- }
1044
- import { StreamsEventType } from "@secondlayer/shared";
1045
- /** A Clarity value as Streams serves it: the canonical hex string, a typed
1046
- * object carrying that hex (`{ hex }`), or a decoded Clarity-JSON object.
1047
- * Decode helpers (`decodeNftTransfer`, etc.) resolve it to a concrete value. */
1048
- type StreamsClarityValue = string | {
1049
- hex: string
1050
- } | Record<string, unknown>;
1051
- type StxTransferPayload = {
870
+ type IndexReorg = {
871
+ id: string
872
+ detected_at: string
873
+ fork_point_height: number
874
+ old_index_block_hash: string | null
875
+ new_index_block_hash: string | null
876
+ /** Orphaned cursor span `<block_height>:<tx_index>`, inclusive. */
877
+ orphaned_range: {
878
+ from: string
879
+ to: string
880
+ }
881
+ /** New canonical tip cursor to resume from. */
882
+ new_canonical_tip: string
883
+ };
884
+ type IndexUsage = {
885
+ product: "index"
886
+ tier: string
887
+ limits: {
888
+ rate_limit_per_second: number | null
889
+ }
890
+ usage: {
891
+ decoded_events_today: number
892
+ decoded_events_this_month: number
893
+ }
894
+ };
895
+ type FtTransfer = {
896
+ cursor: string
897
+ block_height: number
898
+ tx_id: string
899
+ tx_index: number
900
+ event_index: number
901
+ event_type: "ft_transfer"
902
+ contract_id: string
903
+ asset_identifier: string
1052
904
  sender: string
1053
905
  recipient: string
1054
906
  amount: string
1055
- memo?: string
1056
907
  };
1057
- type StxMintPayload = {
1058
- recipient: string
1059
- amount: string
908
+ type FtTransfersEnvelope = {
909
+ events: FtTransfer[]
910
+ next_cursor: string | null
911
+ tip: IndexTip
912
+ reorgs: IndexReorg[]
1060
913
  };
1061
- type StxBurnPayload = {
914
+ type FtTransfersListParams = {
915
+ cursor?: string | null
916
+ fromCursor?: string | null
917
+ limit?: number
918
+ contractId?: string
919
+ sender?: string
920
+ recipient?: string
921
+ fromHeight?: number
922
+ toHeight?: number
923
+ };
924
+ type FtTransfersWalkParams = Omit<FtTransfersListParams, "limit"> & {
925
+ batchSize?: number
926
+ signal?: AbortSignal
927
+ };
928
+ type NftTransfer = {
929
+ cursor: string
930
+ block_height: number
931
+ tx_id: string
932
+ tx_index: number
933
+ event_index: number
934
+ event_type: "nft_transfer"
935
+ contract_id: string
936
+ asset_identifier: string
1062
937
  sender: string
1063
- amount: string
938
+ recipient: string
939
+ value: string
1064
940
  };
1065
- type StxLockPayload = {
1066
- locked_address: string
1067
- locked_amount: string
1068
- unlock_height: string
941
+ type NftTransfersEnvelope = {
942
+ events: NftTransfer[]
943
+ next_cursor: string | null
944
+ tip: IndexTip
945
+ reorgs: IndexReorg[]
1069
946
  };
1070
- type FtTransferPayload = {
947
+ type NftTransfersListParams = {
948
+ cursor?: string | null
949
+ fromCursor?: string | null
950
+ limit?: number
951
+ contractId?: string
952
+ assetIdentifier?: string
953
+ sender?: string
954
+ recipient?: string
955
+ fromHeight?: number
956
+ toHeight?: number
957
+ };
958
+ type NftTransfersWalkParams = Omit<NftTransfersListParams, "limit"> & {
959
+ batchSize?: number
960
+ signal?: AbortSignal
961
+ };
962
+ type IndexEventBase = {
963
+ cursor: string
964
+ block_height: number
965
+ block_time?: string | null
966
+ tx_id: string
967
+ tx_index: number
968
+ event_index: number
969
+ contract_id: string | null
970
+ };
971
+ type IndexFtTransfer = IndexEventBase & {
972
+ event_type: "ft_transfer"
1071
973
  asset_identifier: string
1072
974
  sender: string
1073
975
  recipient: string
1074
976
  amount: string
1075
977
  };
1076
- type FtMintPayload = {
978
+ type IndexNftTransfer = IndexEventBase & {
979
+ event_type: "nft_transfer"
1077
980
  asset_identifier: string
981
+ sender: string
982
+ recipient: string
983
+ value: string
984
+ };
985
+ type IndexStxTransfer = IndexEventBase & {
986
+ event_type: "stx_transfer"
987
+ sender: string
988
+ recipient: string
989
+ amount: string
990
+ memo: string | null
991
+ };
992
+ type IndexStxMint = IndexEventBase & {
993
+ event_type: "stx_mint"
1078
994
  recipient: string
1079
995
  amount: string
1080
996
  };
1081
- type FtBurnPayload = {
1082
- asset_identifier: string
997
+ type IndexStxBurn = IndexEventBase & {
998
+ event_type: "stx_burn"
1083
999
  sender: string
1084
1000
  amount: string
1085
1001
  };
1086
- type NftTransferPayload = {
1087
- asset_identifier: string
1002
+ type IndexStxLock = IndexEventBase & {
1003
+ event_type: "stx_lock"
1088
1004
  sender: string
1005
+ amount: string
1006
+ payload: {
1007
+ unlock_height: string | null
1008
+ }
1009
+ };
1010
+ type IndexFtMint = IndexEventBase & {
1011
+ event_type: "ft_mint"
1012
+ asset_identifier: string
1089
1013
  recipient: string
1090
- value: StreamsClarityValue
1091
- /** Canonical serialized hex of `value`, when the stream carries it. */
1092
- raw_value?: string
1014
+ amount: string
1093
1015
  };
1094
- type NftMintPayload = {
1016
+ type IndexFtBurn = IndexEventBase & {
1017
+ event_type: "ft_burn"
1018
+ asset_identifier: string
1019
+ sender: string
1020
+ amount: string
1021
+ };
1022
+ type IndexNftMint = IndexEventBase & {
1023
+ event_type: "nft_mint"
1095
1024
  asset_identifier: string
1096
1025
  recipient: string
1097
- value: StreamsClarityValue
1098
- raw_value?: string
1026
+ value: string
1099
1027
  };
1100
- type NftBurnPayload = {
1028
+ type IndexNftBurn = IndexEventBase & {
1029
+ event_type: "nft_burn"
1101
1030
  asset_identifier: string
1102
1031
  sender: string
1103
- value: StreamsClarityValue
1104
- raw_value?: string
1032
+ value: string
1105
1033
  };
1106
- type PrintPayload = {
1107
- contract_id?: string | null
1108
- topic?: string
1109
- value?: unknown
1110
- raw_value?: string
1034
+ type IndexPrint = IndexEventBase & {
1035
+ event_type: "print"
1036
+ payload: {
1037
+ topic: string | null
1038
+ value: unknown
1039
+ raw_value: string | null
1040
+ }
1111
1041
  };
1112
- /** Union of every Streams payload shape, discriminated by `event_type` on the
1113
- * parent `StreamsEvent`. */
1114
- type StreamsEventPayload = StxTransferPayload | StxMintPayload | StxBurnPayload | StxLockPayload | FtTransferPayload | FtMintPayload | FtBurnPayload | NftTransferPayload | NftMintPayload | NftBurnPayload | PrintPayload;
1115
- type StreamsEventBase = {
1116
- /**
1117
- * Globally unique, monotonic position of this event (`<block>:<index>`). Use
1118
- * it as the primary key of your projection rows — replaying a batch then
1119
- * upserts cleanly. Don't synthesize your own id from `tx_id`/`event_index`.
1120
- */
1042
+ /** Decoded chain event, discriminated by `event_type`. */
1043
+ type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint;
1044
+ type IndexEventType = IndexEvent["event_type"];
1045
+ type EventsEnvelope = {
1046
+ events: IndexEvent[]
1047
+ next_cursor: string | null
1048
+ tip: IndexTip
1049
+ reorgs: IndexReorg[]
1050
+ };
1051
+ type EventsListParams = {
1052
+ /** Required. One of the decoded event types. */
1053
+ eventType: IndexEventType
1054
+ cursor?: string | null
1055
+ fromCursor?: string | null
1056
+ limit?: number
1057
+ contractId?: string
1058
+ assetIdentifier?: string
1059
+ sender?: string
1060
+ recipient?: string
1061
+ fromHeight?: number
1062
+ toHeight?: number
1063
+ /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1064
+ * Mutually exclusive with contractId; contract-keyed event types only. */
1065
+ trait?: string
1066
+ };
1067
+ type EventsWalkParams = Omit<EventsListParams, "limit"> & {
1068
+ batchSize?: number
1069
+ signal?: AbortSignal
1070
+ };
1071
+ type EventsConsumeParams = Omit<EventsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexEvent, EventsEnvelope>;
1072
+ type IndexContractCall = {
1121
1073
  cursor: string
1122
1074
  block_height: number
1123
- block_hash: string
1124
- burn_block_height: number
1075
+ block_time?: string | null
1125
1076
  tx_id: string
1126
1077
  tx_index: number
1127
- event_index: number
1128
- contract_id: string | null
1129
- ts: string
1130
- /**
1131
- * True when this event's block is past the finality boundary (immutable).
1132
- * Optional for back-compat; the API always sets it on Streams responses.
1133
- */
1134
- finalized?: boolean
1078
+ contract_id: string
1079
+ function_name: string
1080
+ sender: string
1081
+ status: string
1082
+ args: unknown[]
1083
+ result: unknown
1084
+ result_hex: string | null
1135
1085
  };
1136
- type StreamsEventOf<
1137
- T extends StreamsEventType,
1138
- P
1139
- > = StreamsEventBase & {
1140
- event_type: T
1141
- payload: P
1086
+ type ContractCallsEnvelope = {
1087
+ contract_calls: IndexContractCall[]
1088
+ next_cursor: string | null
1089
+ tip: IndexTip
1090
+ reorgs: IndexReorg[]
1142
1091
  };
1143
- /** A raw Streams event. Discriminated on `event_type`, so `event.payload`
1144
- * narrows to the matching payload shape once the type is checked. */
1145
- 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>;
1146
- type StreamsTip = {
1147
- block_height: number
1148
- block_hash: string
1149
- burn_block_height: number
1150
- /**
1151
- * Highest Stacks block past the burn-confirmation finality boundary.
1152
- * Optional for back-compat; the API always sets it.
1153
- */
1154
- finalized_height?: number
1155
- lag_seconds: number
1156
- /**
1157
- * Oldest height still seekable on the live API for the caller's tier
1158
- * (`tip - retention`). `null` = unlimited retention. Older reads must use the
1159
- * cold dumps lane. Optional for back-compat.
1160
- */
1161
- oldest_seekable_height?: number | null
1162
- /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
1163
- oldest_cursor?: string | null
1092
+ type ContractCallsListParams = {
1093
+ cursor?: string | null
1094
+ fromCursor?: string | null
1095
+ limit?: number
1096
+ contractId?: string
1097
+ functionName?: string
1098
+ sender?: string
1099
+ fromHeight?: number
1100
+ toHeight?: number
1101
+ /** Restrict to contracts conforming to a trait/standard (e.g. "sip-010").
1102
+ * Mutually exclusive with contractId. */
1103
+ trait?: string
1164
1104
  };
1165
- type StreamsCanonicalBlock = {
1105
+ type ContractCallsWalkParams = Omit<ContractCallsListParams, "limit"> & {
1106
+ batchSize?: number
1107
+ signal?: AbortSignal
1108
+ };
1109
+ type ContractCallsConsumeParams = Omit<ContractCallsListParams, "cursor" | "fromCursor" | "limit"> & IndexConsumeOptions<IndexContractCall, ContractCallsEnvelope>;
1110
+ /** One canonical block in the sync map. Lean by design — block + parent hash
1111
+ * for chain linkage, burn anchor for Bitcoin confirmations. Use `blocks` for
1112
+ * the full block resource. */
1113
+ type IndexCanonicalBlock = {
1114
+ cursor: string
1166
1115
  block_height: number
1167
1116
  block_hash: string
1117
+ parent_hash: string
1168
1118
  burn_block_height: number
1169
1119
  burn_block_hash: string | null
1170
- is_canonical: true
1171
1120
  };
1172
- type StreamsReorg = {
1173
- detected_at: string
1174
- fork_point_height: number
1175
- orphaned_range: {
1176
- from: string
1177
- to: string
1178
- }
1179
- new_canonical_tip: string
1180
- };
1181
- type StreamsEventsEnvelope = {
1182
- events: StreamsEvent[]
1121
+ type CanonicalEnvelope = {
1122
+ canonical: IndexCanonicalBlock[]
1183
1123
  next_cursor: string | null
1184
- tip: StreamsTip
1185
- reorgs: StreamsReorg[]
1186
- };
1187
- type StreamsEventsListEnvelope = Omit<StreamsEventsEnvelope, "next_cursor">;
1188
- type StreamsReorgsListParams = {
1189
- since: string
1190
- limit?: number
1191
- };
1192
- type StreamsReorgsListEnvelope = {
1193
- reorgs: StreamsReorg[]
1194
- next_since: string | null
1124
+ tip: IndexTip
1195
1125
  };
1196
- /** A filter that matches a single value or any value in a list. */
1197
- type StreamsFilterValue = string | readonly string[];
1198
- type StreamsEventsListParams = {
1126
+ type CanonicalListParams = {
1199
1127
  cursor?: string | null
1128
+ fromCursor?: string | null
1129
+ limit?: number
1200
1130
  fromHeight?: number
1201
1131
  toHeight?: number
1202
- types?: readonly StreamsEventType[]
1203
- /** Event types to exclude (applied after `types`). */
1204
- notTypes?: readonly StreamsEventType[]
1205
- contractId?: StreamsFilterValue
1206
- sender?: StreamsFilterValue
1207
- recipient?: StreamsFilterValue
1208
- assetIdentifier?: string
1209
- limit?: number
1210
1132
  };
1211
- type StreamsEventsStreamParams = {
1212
- fromCursor?: string | null
1213
- types?: readonly StreamsEventType[]
1214
- notTypes?: readonly StreamsEventType[]
1215
- contractId?: StreamsFilterValue
1216
- sender?: StreamsFilterValue
1217
- recipient?: StreamsFilterValue
1218
- assetIdentifier?: string
1133
+ type CanonicalWalkParams = Omit<CanonicalListParams, "limit"> & {
1219
1134
  batchSize?: number
1220
- emptyBackoffMs?: number
1221
- maxPages?: number
1222
- maxEmptyPolls?: number
1223
1135
  signal?: AbortSignal
1224
1136
  };
1225
- type StreamsEventsSubscribeParams = {
1226
- /** Resume strictly after this cursor; omit to live-tail from the tip. */
1227
- fromCursor?: string | null
1228
- types?: readonly StreamsEventType[]
1229
- notTypes?: readonly StreamsEventType[]
1230
- contractId?: StreamsFilterValue
1231
- sender?: StreamsFilterValue
1232
- recipient?: StreamsFilterValue
1233
- assetIdentifier?: string
1234
- /** Abort to unsubscribe (the returned function does the same). */
1235
- signal?: AbortSignal
1236
- /** Called for each pushed event, in order. */
1237
- onEvent: (event: StreamsEvent) => void | Promise<void>
1238
- /** Called on a connection error; the subscription auto-reconnects from the
1239
- * last delivered cursor unless the signal has aborted. */
1240
- onError?: (err: unknown) => void
1137
+ /** A block resource. Metadata is intentionally thin — only chain-linkage and
1138
+ * burn-anchor fields are persisted (no miner / tx_count / signer). */
1139
+ type IndexBlock = {
1140
+ cursor: string
1141
+ block_height: number
1142
+ block_hash: string
1143
+ parent_hash: string
1144
+ burn_block_height: number
1145
+ burn_block_hash: string | null
1146
+ block_time: string | null
1147
+ canonical: boolean
1241
1148
  };
1242
- /**
1243
- * The checkpoint the SDK computes for a batch. Persist `cursor` inside the same
1244
- * transaction as your projection writes, then resume from it via `fromCursor`.
1245
- * It is the position to advance to: `next_cursor` normally, or the last
1246
- * finalized event when `finalizedOnly` is set.
1247
- */
1248
- type StreamsBatchContext = {
1249
- cursor: string | null
1149
+ type BlocksEnvelope = {
1150
+ blocks: IndexBlock[]
1151
+ next_cursor: string | null
1152
+ tip: IndexTip
1250
1153
  };
1251
- /**
1252
- * The checkpoint for a reorg rollback. Persist `cursor` (the rewind position)
1253
- * inside the same transaction as your rollback so the two commit atomically.
1254
- */
1255
- type StreamsReorgContext = {
1256
- cursor: string
1154
+ type BlockEnvelope = {
1155
+ block: IndexBlock
1156
+ tip: IndexTip
1257
1157
  };
1258
- type StreamsEventsConsumeParams = {
1158
+ type BlocksListParams = {
1159
+ cursor?: string | null
1259
1160
  fromCursor?: string | null
1260
- mode?: "tail" | "bounded"
1261
- /**
1262
- * Emit only finalized (immutable) events and never surface reorgs. The SDK
1263
- * checkpoints at the last finalized event and re-reads the unfinalized tail
1264
- * until it settles. Trades finality lag for zero reorg handling; `onReorg` is
1265
- * ignored.
1266
- */
1267
- finalizedOnly?: boolean
1268
- types?: readonly StreamsEventType[]
1269
- notTypes?: readonly StreamsEventType[]
1270
- contractId?: StreamsFilterValue
1271
- sender?: StreamsFilterValue
1272
- recipient?: StreamsFilterValue
1273
- assetIdentifier?: string
1161
+ limit?: number
1162
+ fromHeight?: number
1163
+ toHeight?: number
1164
+ };
1165
+ type BlocksWalkParams = Omit<BlocksListParams, "limit"> & {
1274
1166
  batchSize?: number
1275
- /**
1276
- * Apply a page of canonical events. Persist `ctx.cursor` in the same
1277
- * transaction as your writes. Returning a cursor overrides `ctx.cursor` as
1278
- * the resume point (advanced manual control); returning nothing uses it.
1279
- */
1280
- onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope, ctx: StreamsBatchContext) => void | string | null | undefined | Promise<void> | Promise<string | null | undefined>
1281
- /**
1282
- * Roll your projection back to `reorg.fork_point_height`, persisting
1283
- * `ctx.cursor` in the same transaction. Called once per *new* reorg
1284
- * (deduped in-memory, fork-ascending) before the SDK rewinds and re-reads the
1285
- * now-canonical events. Omit it to ignore reorgs (events stay canonical, but
1286
- * stale rows from an orphaned fork are left in place).
1287
- */
1288
- onReorg?: (reorg: StreamsReorg, ctx: StreamsReorgContext) => Promise<void> | void
1289
- emptyBackoffMs?: number
1290
- maxPages?: number
1291
- maxEmptyPolls?: number
1292
1167
  signal?: AbortSignal
1293
1168
  };
1294
- /**
1295
- * One yielded page from {@link StreamsClient.consume} — the
1296
- * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
1297
- * `cursor` (the checkpoint to persist and resume from).
1298
- */
1299
- type StreamsBatch = {
1300
- /** Canonical events of this page, in cursor order. */
1301
- events: StreamsEvent[]
1302
- /** Checkpoint after this page — pass back as `consume({ cursor })` to resume. */
1303
- cursor: string | null
1304
- tip: StreamsTip
1305
- /** Chain reorgs reported alongside this page; empty when none. */
1306
- reorgs: StreamsReorg[]
1169
+ type IndexPostCondition = {
1170
+ type: "stx"
1171
+ principal: string
1172
+ condition_code: number
1173
+ condition_code_name: string | null
1174
+ amount: string
1175
+ } | {
1176
+ type: "ft"
1177
+ principal: string
1178
+ asset_identifier: string
1179
+ condition_code: number
1180
+ condition_code_name: string | null
1181
+ amount: string
1182
+ } | {
1183
+ type: "nft"
1184
+ principal: string
1185
+ asset_identifier: string
1186
+ asset_value: unknown
1187
+ condition_code: number
1188
+ condition_code_name: string | null
1307
1189
  };
1308
- type StreamsConsumeParams = {
1309
- /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
1190
+ /** Full transaction document: columnar fields plus `raw_tx`-decoded enrichment.
1191
+ * Payload sub-objects are present only for the matching `tx_type`; enrichment
1192
+ * fields are null when `raw_tx` isn't decodable (e.g. burnchain ops). */
1193
+ type IndexTransaction = {
1194
+ cursor: string
1195
+ tx_id: string
1196
+ block_height: number
1197
+ block_time?: string | null
1198
+ tx_index: number
1199
+ tx_type: string
1200
+ sender: string
1201
+ status: string
1202
+ fee: string | null
1203
+ nonce: string | null
1204
+ sponsored: boolean | null
1205
+ anchor_mode: string | null
1206
+ post_condition_mode: string | null
1207
+ post_conditions: IndexPostCondition[]
1208
+ contract_call?: {
1209
+ contract_id: string
1210
+ function_name: string
1211
+ function_args: unknown[]
1212
+ /** Raw hex-encoded ClarityValues; decode(function_args_hex[i]) === function_args[i]. */
1213
+ function_args_hex: string[]
1214
+ result: unknown
1215
+ result_hex: string | null
1216
+ }
1217
+ token_transfer?: {
1218
+ recipient: string
1219
+ amount: string
1220
+ memo: string
1221
+ }
1222
+ smart_contract?: {
1223
+ contract_id: string | null
1224
+ clarity_version: number | null
1225
+ }
1226
+ coinbase?: {
1227
+ alt_recipient: string | null
1228
+ }
1229
+ tenure_change?: {
1230
+ cause: number
1231
+ }
1232
+ };
1233
+ type TransactionsEnvelope = {
1234
+ transactions: IndexTransaction[]
1235
+ next_cursor: string | null
1236
+ tip: IndexTip
1237
+ reorgs: IndexReorg[]
1238
+ };
1239
+ type TransactionEnvelope = {
1240
+ transaction: IndexTransaction
1241
+ tip: IndexTip
1242
+ };
1243
+ type TransactionsListParams = {
1310
1244
  cursor?: string | null
1311
- types?: readonly StreamsEventType[]
1312
- notTypes?: readonly StreamsEventType[]
1313
- contractId?: StreamsFilterValue
1314
- sender?: StreamsFilterValue
1315
- recipient?: StreamsFilterValue
1316
- assetIdentifier?: string
1317
- /** Events per page (the `limit` query param). Default 100. */
1245
+ fromCursor?: string | null
1246
+ limit?: number
1247
+ type?: string
1248
+ sender?: string
1249
+ contractId?: string
1250
+ fromHeight?: number
1251
+ toHeight?: number
1252
+ };
1253
+ type TransactionsWalkParams = Omit<TransactionsListParams, "limit"> & {
1318
1254
  batchSize?: number
1319
- /** Poll interval while caught up at the tip, in ms. Default 2000. */
1320
- intervalMs?: number
1321
- /** Abort to end the iteration. */
1322
1255
  signal?: AbortSignal
1323
1256
  };
1324
- type StreamsEventsConsumeResult = {
1325
- cursor: string | null
1326
- pages: number
1327
- emptyPolls: number
1328
- };
1329
- type StreamsEventsReplayParams = {
1330
- /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
1331
- from?: "genesis" | string
1332
- /**
1333
- * Called once per finalized dump file, in block order, before live tailing.
1334
- * Process the parquet with your own tooling (e.g. DuckDB) — the SDK does not
1335
- * decode parquet. Use `client.dumps.download(file)` to fetch + verify bytes.
1336
- */
1337
- onDumpFile: (file: StreamsDumpFile) => Promise<void> | void
1338
- /** Called per live page after the dump phase, like `consume`. */
1339
- onBatch: (events: StreamsEvent[], envelope: StreamsEventsEnvelope) => Promise<string | null | undefined> | string | null | undefined
1340
- mode?: "tail" | "bounded"
1341
- batchSize?: number
1342
- emptyBackoffMs?: number
1343
- maxPages?: number
1344
- maxEmptyPolls?: number
1345
- signal?: AbortSignal
1257
+ /** A decoded PoX-4 stacking action (one per stacking contract call). */
1258
+ type IndexStackingAction = {
1259
+ cursor: string
1260
+ block_height: number
1261
+ block_time?: string | null
1262
+ burn_block_height: number
1263
+ tx_id: string
1264
+ tx_index: number
1265
+ function_name: string
1266
+ caller: string
1267
+ stacker: string | null
1268
+ delegate_to: string | null
1269
+ amount_ustx: string | null
1270
+ lock_period: number | null
1271
+ pox_addr: {
1272
+ version: number | null
1273
+ hashbytes: string | null
1274
+ btc: string | null
1275
+ }
1276
+ start_cycle: number | null
1277
+ end_cycle: number | null
1278
+ reward_cycle: number | null
1279
+ signer_key: string | null
1280
+ result_ok: boolean
1346
1281
  };
1347
- type FetchLike2 = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
1348
- /** One bulk parquet file in the dumps manifest. `path` is the object key under
1349
- * the dumps base URL. */
1350
- type StreamsDumpFile = {
1351
- path: string
1352
- from_block: number
1353
- to_block: number
1354
- min_cursor: string | null
1355
- max_cursor: string | null
1356
- row_count: number
1357
- byte_size: number
1358
- sha256: string
1359
- schema_version: number
1360
- created_at: string
1282
+ type StackingEnvelope = {
1283
+ stacking: IndexStackingAction[]
1284
+ next_cursor: string | null
1285
+ tip: IndexTip
1286
+ reorgs: IndexReorg[]
1287
+ /** Present only when the PoX-4 decoder is disabled, explaining an empty feed. */
1288
+ notes?: string
1361
1289
  };
1362
- type StreamsDumpsManifest = {
1363
- dataset: string
1364
- network: string
1365
- version: string
1366
- schema_version: number
1367
- generated_at: string
1368
- producer_version: string
1369
- finality_lag_blocks: number
1370
- /** Cursor at the end of the finalized bulk coverage — hand to live tailing. */
1371
- latest_finalized_cursor: string | null
1372
- coverage: {
1373
- from_block: number
1374
- to_block: number
1375
- }
1376
- files: StreamsDumpFile[]
1377
- /** ed25519 signature over the manifest's canonical bytes. Absent on legacy
1378
- * unsigned manifests. Verified by `list()` when `verifyDumpsManifest` is on. */
1379
- signature?: string
1380
- /** Short id of the signing public key. */
1381
- key_id?: string
1290
+ type StackingListParams = {
1291
+ cursor?: string | null
1292
+ fromCursor?: string | null
1293
+ limit?: number
1294
+ functionName?: string
1295
+ stacker?: string
1296
+ caller?: string
1297
+ fromHeight?: number
1298
+ toHeight?: number
1382
1299
  };
1383
- type StreamsDumps = {
1384
- /** Fetch and parse the latest dumps manifest. */
1385
- list(): Promise<StreamsDumpsManifest>
1386
- /** Absolute URL for a manifest file. */
1387
- fileUrl(file: StreamsDumpFile): string
1388
- /** Download a parquet file and verify its sha256 against the manifest. */
1389
- download(file: StreamsDumpFile): Promise<Uint8Array>
1300
+ type StackingWalkParams = Omit<StackingListParams, "limit"> & {
1301
+ batchSize?: number
1302
+ signal?: AbortSignal
1390
1303
  };
1391
- type StreamsClient = {
1392
- /**
1393
- * Follow Streams as an async iterator of page batches.
1394
- *
1395
- * Yields one {@link StreamsBatch} per `GET /v1/streams/events` page — the
1396
- * existing envelope (`events`, `next_cursor` → `cursor`, `tip`, `reorgs`)
1397
- * with zero extra API calls. Batches are chosen over per-block groupings
1398
- * because the envelope is page-keyed, so every yield is exactly one fetch.
1399
- * Empty pages are skipped; at the tip the iterator re-polls every
1400
- * `intervalMs` (default 2000) until aborted via `signal`.
1401
- *
1402
- * Reorgs are surfaced on the batch (`batch.reorgs`) but the cursor is not
1403
- * rewound automatically — use `events.consume` with `onReorg` for managed
1404
- * rollback semantics.
1405
- */
1406
- consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>
1407
- events: {
1408
- list(params?: StreamsEventsListParams): Promise<StreamsEventsEnvelope>
1409
- byTxId(txId: string): Promise<StreamsEventsListEnvelope>
1410
- /**
1411
- * Pull pages from Streams and call `onBatch` after each page.
1412
- *
1413
- * Use `consume` for indexers and ETL jobs that own checkpointing. Return
1414
- * the checkpoint cursor from `onBatch`. Default `mode: "tail"` keeps
1415
- * polling when caught up; `mode: "bounded"` exits on the first empty page.
1416
- * The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
1417
- * stops it.
1418
- */
1419
- consume(params: StreamsEventsConsumeParams): Promise<StreamsEventsConsumeResult>
1420
- /**
1421
- * Backfill from bulk dumps, then continue live from the dump→live seam in
1422
- * one call. Iterates finalized dump files (via `onDumpFile`) in block
1423
- * order, then tails live from the manifest's `latest_finalized_cursor`
1424
- * (exclusive input → no gap or duplicate at the seam). Requires
1425
- * `dumpsBaseUrl`.
1426
- */
1427
- replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>
1428
- /**
1429
- * Follow Streams as an async iterator.
1430
- *
1431
- * Use `stream` for live processors and watch-style apps. It tails
1432
- * indefinitely by default and stops when its `AbortSignal`, `maxPages`, or
1433
- * `maxEmptyPolls` stops it.
1434
- */
1435
- stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>
1436
- /**
1437
- * Subscribe to the real-time SSE push surface. Calls `onEvent` for each new
1438
- * canonical event as the server pushes it (chain cadence, not poll-bounded),
1439
- * and verifies each frame's inline ed25519 signature when the client was
1440
- * created with `verify`. Returns an unsubscribe function.
1441
- */
1442
- subscribe(params: StreamsEventsSubscribeParams): () => void
1304
+ /** A pending (unconfirmed) transaction. Like a transaction document but
1305
+ * pre-chain — no block_height/tx_index/result/events — with `received_at` and
1306
+ * a sequence cursor instead of a block position. */
1307
+ type IndexMempoolTransaction = {
1308
+ cursor: string
1309
+ tx_id: string
1310
+ tx_type: string
1311
+ sender: string
1312
+ received_at?: string | null
1313
+ fee: string | null
1314
+ nonce: string | null
1315
+ sponsored: boolean | null
1316
+ anchor_mode: string | null
1317
+ post_condition_mode: string | null
1318
+ post_conditions: IndexPostCondition[]
1319
+ contract_call?: {
1320
+ contract_id: string
1321
+ function_name: string
1322
+ function_args: unknown[]
1443
1323
  }
1444
- blocks: {
1445
- events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>
1324
+ token_transfer?: {
1325
+ recipient: string
1326
+ amount: string
1327
+ memo: string
1446
1328
  }
1447
- reorgs: {
1448
- list(params: StreamsReorgsListParams): Promise<StreamsReorgsListEnvelope>
1329
+ smart_contract?: {
1330
+ clarity_version: number | null
1449
1331
  }
1450
- /** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
1451
- dumps: StreamsDumps
1452
- canonical(height: number): Promise<StreamsCanonicalBlock>
1453
- tip(): Promise<StreamsTip>
1454
- /** Your own Streams consumption (events today + this month) and tier limits. */
1455
- usage(): Promise<StreamsUsage>
1456
- };
1457
- type StreamsUsage = {
1458
- product: "streams"
1459
- tier: string
1460
- limits: {
1461
- rate_limit_per_second: number | null
1462
- retention_days: number | null
1332
+ coinbase?: {
1333
+ alt_recipient: string | null
1463
1334
  }
1464
- usage: {
1465
- events_today: number
1466
- events_this_month: number
1335
+ tenure_change?: {
1336
+ cause: number
1337
+ }
1338
+ };
1339
+ type MempoolEnvelope = {
1340
+ mempool: IndexMempoolTransaction[]
1341
+ next_cursor: string | null
1342
+ tip: IndexTip
1343
+ };
1344
+ type MempoolTransactionEnvelope = {
1345
+ transaction: IndexMempoolTransaction
1346
+ tip: IndexTip
1347
+ };
1348
+ type MempoolListParams = {
1349
+ cursor?: string | null
1350
+ fromCursor?: string | null
1351
+ limit?: number
1352
+ sender?: string
1353
+ type?: string
1354
+ /** Filter to pending calls to a single contract (e.g. `SP….contract`). */
1355
+ contractId?: string
1356
+ };
1357
+ type MempoolWalkParams = Omit<MempoolListParams, "limit"> & {
1358
+ batchSize?: number
1359
+ signal?: AbortSignal
1360
+ };
1361
+ /**
1362
+ * Empirical per-topic print payload schema for a contract, inferred from
1363
+ * sampled on-chain events. `topics` is sorted by count desc; `sampled` is true
1364
+ * when the contract has more print events than the windows examined.
1365
+ */
1366
+ type PrintSchemaResponse = {
1367
+ contract_id: string
1368
+ topics: InferredTopicSchema[]
1369
+ sampled: boolean
1370
+ total_events: number
1371
+ /** True when the count hit the server-side cap (total_events is the cap). */
1372
+ total_events_capped: boolean
1373
+ sample: {
1374
+ size: number
1375
+ newest_height: number | null
1376
+ oldest_height: number | null
1467
1377
  }
1378
+ tip: IndexTip
1379
+ };
1380
+ /**
1381
+ * `index.ftTransfers` — callable shorthand for `.list()`, with `.list`/`.walk`
1382
+ * still available: `await sl.index.ftTransfers({ contractId })`.
1383
+ *
1384
+ * The API accepts `contract_id`/`sender`/`recipient` equality filters only —
1385
+ * no amount filtering and no asset-slug resolution on /v1/index/ft-transfers.
1386
+ */
1387
+ interface FtTransfersResource {
1388
+ (params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
1389
+ list(params?: FtTransfersListParams): Promise<FtTransfersEnvelope>;
1390
+ walk(params?: FtTransfersWalkParams): AsyncIterable<FtTransfer>;
1391
+ }
1392
+ /** `index.nftTransfers` — callable shorthand for `.list()` (see {@link FtTransfersResource}). */
1393
+ interface NftTransfersResource {
1394
+ (params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
1395
+ list(params?: NftTransfersListParams): Promise<NftTransfersEnvelope>;
1396
+ walk(params?: NftTransfersWalkParams): AsyncIterable<NftTransfer>;
1397
+ }
1398
+ /** `index.events` — callable shorthand for `.list()`; `eventType` is required. */
1399
+ interface IndexEventsResource {
1400
+ (params: EventsListParams): Promise<EventsEnvelope>;
1401
+ list(params: EventsListParams): Promise<EventsEnvelope>;
1402
+ walk(params: EventsWalkParams): AsyncIterable<IndexEvent>;
1403
+ consume(params: EventsConsumeParams): Promise<{
1404
+ cursor: string | null
1405
+ pages: number
1406
+ emptyPolls: number
1407
+ }>;
1408
+ }
1409
+ /** Per-event-type filter vocabulary in the {@link IndexDiscovery} doc. */
1410
+ type IndexEventTypeFilters = {
1411
+ columns?: string[]
1412
+ allowed_filters?: string[]
1413
+ equality_filters?: string[]
1414
+ required_non_null?: string[]
1468
1415
  };
1416
+ /** The `GET /v1/index` discovery doc — live endpoint + filter vocabulary.
1417
+ * Shape is intentionally open (the server may add fields); the agent-relevant
1418
+ * parts are the per-type filter rules. */
1419
+ type IndexDiscovery = {
1420
+ event_type_filters?: Record<string, IndexEventTypeFilters>
1421
+ [key: string]: unknown
1422
+ };
1423
+ declare class Index extends BaseClient {
1424
+ constructor(options?: Partial<SecondLayerOptions>);
1425
+ /** Your own Index consumption (decoded events today + this month) and tier limits. */
1426
+ usage(): Promise<IndexUsage>;
1427
+ /**
1428
+ * Index discovery doc — the live vocabulary: every endpoint, each event type's
1429
+ * columns, allowed/equality filters, and required-non-null fields. Read this to
1430
+ * learn what's queryable (and which types accept `trait`) instead of hardcoding.
1431
+ */
1432
+ discover(): Promise<IndexDiscovery>;
1433
+ /**
1434
+ * Empirical per-topic print payload schema for a contract — what topics it
1435
+ * emits and each field's observed Clarity/TS/column types. Anonymous read;
1436
+ * 404 → null.
1437
+ */
1438
+ printSchema(contractId: string): Promise<PrintSchemaResponse | null>;
1439
+ /** Callable: `index.ftTransfers(params)` ≡ `index.ftTransfers.list(params)`. */
1440
+ readonly ftTransfers: FtTransfersResource;
1441
+ /** Callable: `index.nftTransfers(params)` ≡ `index.nftTransfers.list(params)`. */
1442
+ readonly nftTransfers: NftTransfersResource;
1443
+ /** Generic decoded events by `event_type` (the full /v1/index/events surface).
1444
+ * Callable: `index.events(params)` ≡ `index.events.list(params)`. */
1445
+ readonly events: IndexEventsResource;
1446
+ readonly contractCalls: {
1447
+ list: (params?: ContractCallsListParams) => Promise<ContractCallsEnvelope>
1448
+ walk: (params?: ContractCallsWalkParams) => AsyncIterable<IndexContractCall>
1449
+ consume: (params: ContractCallsConsumeParams) => Promise<{
1450
+ cursor: string | null
1451
+ pages: number
1452
+ emptyPolls: number
1453
+ }>
1454
+ };
1455
+ /** Canonical block-hash map — sync only the current canonical chain. */
1456
+ readonly canonical: {
1457
+ list: (params?: CanonicalListParams) => Promise<CanonicalEnvelope>
1458
+ walk: (params?: CanonicalWalkParams) => AsyncIterable<IndexCanonicalBlock>
1459
+ };
1460
+ /** Canonical blocks: paginated `list`/`walk`, plus `get` by height or hash
1461
+ * (resolves to null on 404). */
1462
+ readonly blocks: {
1463
+ list: (params?: BlocksListParams) => Promise<BlocksEnvelope>
1464
+ walk: (params?: BlocksWalkParams) => AsyncIterable<IndexBlock>
1465
+ get: (ref: string | number) => Promise<BlockEnvelope | null>
1466
+ };
1467
+ /** Full transaction documents: paginated `list`/`walk`, plus `get` by tx_id
1468
+ * (resolves to null on 404). */
1469
+ readonly transactions: {
1470
+ list: (params?: TransactionsListParams) => Promise<TransactionsEnvelope>
1471
+ walk: (params?: TransactionsWalkParams) => AsyncIterable<IndexTransaction>
1472
+ get: (txId: string) => Promise<TransactionEnvelope | null>
1473
+ getProof: (txId: string) => Promise<TransactionProof | null>
1474
+ };
1475
+ /** Decoded PoX-4 stacking actions. Empty (with a `notes` hint) when the
1476
+ * platform's PoX-4 decoder is disabled. */
1477
+ readonly stacking: {
1478
+ list: (params?: StackingListParams) => Promise<StackingEnvelope>
1479
+ walk: (params?: StackingWalkParams) => AsyncIterable<IndexStackingAction>
1480
+ };
1481
+ /** Pending (unconfirmed) transactions: paginated `list`/`walk`, plus `get` by
1482
+ * tx_id (resolves to null when the tx has confirmed or dropped). */
1483
+ readonly mempool: {
1484
+ list: (params?: MempoolListParams) => Promise<MempoolEnvelope>
1485
+ walk: (params?: MempoolWalkParams) => AsyncIterable<IndexMempoolTransaction>
1486
+ get: (txId: string) => Promise<MempoolTransactionEnvelope | null>
1487
+ };
1488
+ private listFtTransfers;
1489
+ private listNftTransfers;
1490
+ private walkFtTransfers;
1491
+ private walkNftTransfers;
1492
+ private listEvents;
1493
+ private walkEvents;
1494
+ private listContractCalls;
1495
+ private walkContractCalls;
1496
+ private listCanonical;
1497
+ private walkCanonical;
1498
+ private listBlocks;
1499
+ private getBlock;
1500
+ private walkBlocks;
1501
+ private listTransactions;
1502
+ private getTransaction;
1503
+ /** Fetch the inclusion proof for a tx (raw tx + Nakamoto header + merkle path)
1504
+ * to verify client-side with `verifyTransactionProof`. 404 → null. A 503
1505
+ * (`PROOF_TX_SET_INCOMPLETE` / `PROOF_NODE_UNAVAILABLE`) surfaces as an
1506
+ * ApiError — the proof can't be assembled on this deployment right now. */
1507
+ private getTransactionProof;
1508
+ private walkTransactions;
1509
+ private listStacking;
1510
+ private walkStacking;
1511
+ private listMempool;
1512
+ private getMempoolTx;
1513
+ private walkMempool;
1514
+ }
1515
+ /**
1516
+ * Typed client for project management (`/api/projects/*`).
1517
+ *
1518
+ * Projects are the account-scoped containers for work. Every method requires an
1519
+ * account-level (owner) API key or a dashboard session — scoped read keys are
1520
+ * rejected. Team mutations (invite/remove/role) are intentionally not exposed
1521
+ * here; only the read view ({@link Projects.team}) is.
1522
+ */
1523
+ interface Project {
1524
+ id: string;
1525
+ name: string;
1526
+ slug: string;
1527
+ network: string;
1528
+ nodeRpc: string | null;
1529
+ settings: Record<string, unknown> | null;
1530
+ createdAt: string;
1531
+ updatedAt: string;
1532
+ }
1533
+ interface ProjectTeamMember {
1534
+ id: string;
1535
+ role: string;
1536
+ email: string;
1537
+ displayName: string | null;
1538
+ avatarUrl: string | null;
1539
+ createdAt: string;
1540
+ }
1541
+ interface ProjectInvitation {
1542
+ id: string;
1543
+ email: string;
1544
+ role: string;
1545
+ expiresAt: string;
1546
+ createdAt: string;
1547
+ }
1548
+ interface ProjectTeam {
1549
+ members: ProjectTeamMember[];
1550
+ invitations: ProjectInvitation[];
1551
+ }
1552
+ interface CreateProjectParams {
1553
+ name: string;
1554
+ slug?: string;
1555
+ network?: string;
1556
+ nodeRpc?: string;
1557
+ }
1558
+ interface UpdateProjectParams {
1559
+ name?: string;
1560
+ /** Rename the project's URL slug. */
1561
+ slug?: string;
1562
+ network?: string;
1563
+ nodeRpc?: string;
1564
+ settings?: Record<string, unknown>;
1565
+ }
1566
+ declare class Projects extends BaseClient {
1567
+ constructor(options?: Partial<SecondLayerOptions>);
1568
+ /** All projects owned by the account, newest-relevant first. */
1569
+ list(): Promise<{
1570
+ projects: Project[]
1571
+ }>;
1572
+ /** A single project by slug. */
1573
+ get(slug: string): Promise<Project>;
1574
+ /** Create a project. The creator is added as the project owner. */
1575
+ create(params: CreateProjectParams): Promise<Project>;
1576
+ /** Update a project's name, slug (rename), network, RPC, or settings. */
1577
+ update(slug: string, patch: UpdateProjectParams): Promise<Project>;
1578
+ /** Delete a project. The account's last remaining project cannot be deleted. */
1579
+ delete(slug: string): Promise<{
1580
+ ok: true
1581
+ }>;
1582
+ /** Team members and pending invitations for a project. */
1583
+ team(slug: string): Promise<ProjectTeam>;
1584
+ }
1469
1585
  import { CreateSubscriptionRequest, CreateSubscriptionResponse, DeadRow, DeliveryRow, ReplayResult, RotateSecretResponse, SubscriptionDetail, SubscriptionSummary, SubscriptionTestResult, UpdateSubscriptionRequest } from "@secondlayer/shared/schemas/subscriptions";
1470
1586
  import { ChainTrigger, ChainTriggerType, CreateSubscriptionRequest as CreateSubscriptionRequest2, CreateSubscriptionResponse as CreateSubscriptionResponse2, DeadRow as DeadRow2, DeliveryRow as DeliveryRow2, ReplayResult as ReplayResult2, RotateSecretResponse as RotateSecretResponse2, SubscriptionDetail as SubscriptionDetail2, SubscriptionFormat, SubscriptionKind, SubscriptionRuntime, SubscriptionStatus, SubscriptionSummary as SubscriptionSummary2, UpdateSubscriptionRequest as UpdateSubscriptionRequest2 } from "@secondlayer/shared/schemas/subscriptions";
1471
1587
  import { trigger } from "@secondlayer/shared/schemas/subscriptions";
@@ -2242,4 +2358,4 @@ declare function toJsonSafe(value: unknown): unknown;
2242
2358
  /** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,
2243
2359
  * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */
2244
2360
  declare function decodeClarityValue(hex: string): unknown;
2245
- export { withX402, verifyWebhookSignature, verifyTransactionProof, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createX402Client, createStreamsClient, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexReorg, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainTriggerType, ChainTrigger, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };
2361
+ export { withX402, verifyWebhookSignature, verifyTransactionProof, verifySecondlayerSignature, trigger, toJsonSafe, selectOffer, resolveAccountNonce, readX402Receipt, readX402Challenge, payAndRetry, isStxTransfer, isStxMint, isStxLock, isStxBurn, isPrint, isNftTransfer, isNftMint, isNftBurn, isFtTransfer, isFtMint, isFtBurn, getSubgraph, fetchRewardSet, decodeStxTransfer, decodeStxMint, decodeStxLock, decodeStxBurn, decodePrint, decodeNftTransfer, decodeNftMint, decodeNftBurn, decodeFtTransfer, decodeFtMint, decodeFtBurn, decodeClarityValue, createX402Client, createStreamsClient, consumeIndexFeed, buildSignedX402Payment, X402SpendGuardError, X402Result, X402Receipt, X402Fetch, X402ClientOptions, X402Client, X402Challenge, X402Accept, WithX402Options, VersionConflictError, ValidationError, UpdateSubscriptionRequest2 as UpdateSubscriptionRequest, UpdateProjectParams, TransactionsWalkParams, TransactionsListParams, TransactionsEnvelope, TransactionProofVerifyResult, TransactionProof, TransactionEnvelope, Subscriptions, SubscriptionSummary2 as SubscriptionSummary, SubscriptionStatus, SubscriptionRuntime, SubscriptionKind, SubscriptionFormat, SubscriptionDetail2 as SubscriptionDetail, Subgraphs, SubgraphSpecOptions3 as SubgraphSpecOptions, SubgraphSpecFormat2 as SubgraphSpecFormat, SubgraphOperationStatus, SubgraphAgentSchema3 as SubgraphAgentSchema, StreamsUsage, StreamsTip, StreamsSignatureError, StreamsServerError, StreamsReorgsListParams, StreamsReorgsListEnvelope, StreamsReorgContext, StreamsReorg, StreamsEventsSubscribeParams, StreamsEventsStreamParams, StreamsEventsListParams, StreamsEventsListEnvelope, StreamsEventsEnvelope, StreamsEventsConsumeResult, StreamsEventsConsumeParams, StreamsEventType, StreamsEventPayload, StreamsEvent, StreamsDumpsManifest, StreamsDumps, StreamsDumpFile, StreamsConsumeParams, StreamsClient, StreamsCanonicalBlock, StreamsBatchContext, StreamsBatch, StackingWalkParams, StackingListParams, StackingEnvelope, SelectOfferOptions, SecondLayerOptions, SecondLayer, ScopedKeyProduct, RotateSecretResponse2 as RotateSecretResponse, RewardSet2 as RewardSet, ReplayResult2 as ReplayResult, RateLimitError, Projects, ProjectTeamMember, ProjectTeam, ProjectInvitation, Project, PrintSchemaResponse, PayAndRetryOptions, NftTransfersWalkParams, NftTransfersResource, NftTransfersListParams, NftTransfersEnvelope, NftTransferPayload, NftTransferEvent, NftTransfer, MempoolWalkParams, MempoolTransactionEnvelope, MempoolListParams, MempoolEnvelope, IndexUsage, IndexTransaction, IndexTip, IndexStackingAction, IndexReorg, IndexPostCondition, IndexMempoolTransaction, IndexEventsResource, IndexEventTypeFilters, IndexEventType, IndexEvent, IndexDiscovery, IndexContractCall, IndexConsumeOptions, IndexCanonicalBlock, IndexBlock, Index, FtTransfersWalkParams, FtTransfersResource, FtTransfersListParams, FtTransfersEnvelope, FtTransferPayload, FtTransferEvent, FtTransfer, FetchLike2 as FetchLike, EventsWalkParams, EventsListParams, EventsEnvelope, EventsConsumeParams, DeliveryRow2 as DeliveryRow, DecodedStxTransferPayload, DecodedStxTransfer, DecodedStxMintPayload, DecodedStxMint, DecodedStxLockPayload, DecodedStxLock, DecodedStxBurnPayload, DecodedStxBurn, DecodedPrintValue, DecodedPrintPayload, DecodedPrint, DecodedNftTransferPayload, DecodedNftTransfer, DecodedNftMintPayload, DecodedNftMint, DecodedNftBurnPayload, DecodedNftBurn, DecodedFtTransferPayload, DecodedFtTransfer, DecodedFtMintPayload, DecodedFtMint, DecodedFtBurnPayload, DecodedFtBurn, DecodedEventRow, DecodedEventColumns, DeadRow2 as DeadRow, DEFAULT_PREFER_ASSETS, Cursor, CreateSubscriptionResponse2 as CreateSubscriptionResponse, CreateSubscriptionRequest2 as CreateSubscriptionRequest, CreateProjectParams, CreateApiKeyResponse, CreateApiKeyParams, ContractsListParams, ContractsEnvelope, Contracts, ContractSummary, ContractConformance, ContractCallsWalkParams, ContractCallsListParams, ContractCallsEnvelope, ContractCallsConsumeParams, ContextSnapshot, ContextProject, ContextApiKey, ContextAccount, ChainTriggerType, ChainTrigger, CanonicalWalkParams, CanonicalListParams, CanonicalEnvelope, ByoBreakingChangeError, ByoBreakingChangeDetails, BuildSignedX402PaymentOptions, BlocksWalkParams, BlocksListParams, BlocksEnvelope, BlockEnvelope, AuthError, ApiKeys, ApiKeySummary, ApiError, ActiveSubgraphOperation };