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