@secondlayer/sdk 14.5.1 → 15.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -36
- package/dist/index.d.ts +558 -143
- package/dist/index.js +3 -23
- package/dist/index.js.map +12 -12
- package/dist/streams/index.d.ts +109 -59
- package/dist/streams/index.js.map +3 -3
- package/dist/subgraphs/index.d.ts +554 -128
- package/dist/subgraphs/index.js.map +9 -9
- package/dist/webhooks/doctor.d.ts +2 -13
- package/dist/webhooks/doctor.js +3 -23
- package/dist/webhooks/doctor.js.map +3 -3
- package/package.json +5 -5
package/dist/streams/index.d.ts
CHANGED
|
@@ -270,7 +270,7 @@ type StreamsTip = {
|
|
|
270
270
|
/** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
|
|
271
271
|
oldest_cursor?: string | null;
|
|
272
272
|
};
|
|
273
|
-
/** `chain=bitcoin` tip
|
|
273
|
+
/** `chain=bitcoin` tip — no `burn_block_height`/retention fields,
|
|
274
274
|
* since Bitcoin has no burn chain of its own and Runes reads have no
|
|
275
275
|
* retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
|
|
276
276
|
type StreamsBitcoinTip = {
|
|
@@ -286,7 +286,7 @@ type StreamsCanonicalBlock = {
|
|
|
286
286
|
burn_block_hash: string | null;
|
|
287
287
|
is_canonical: true;
|
|
288
288
|
};
|
|
289
|
-
/** `chain=bitcoin` canonical block
|
|
289
|
+
/** `chain=bitcoin` canonical block — no burn-chain fields. */
|
|
290
290
|
type StreamsBitcoinCanonicalBlock = {
|
|
291
291
|
block_height: number;
|
|
292
292
|
block_hash: string;
|
|
@@ -369,8 +369,8 @@ type StreamsEventsListParamsCommon = {
|
|
|
369
369
|
toHeight?: number;
|
|
370
370
|
limit?: number;
|
|
371
371
|
};
|
|
372
|
-
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since
|
|
373
|
-
*
|
|
372
|
+
/** `chain: "stacks"` (default, omit `chain` entirely) — unchanged since before Runes events
|
|
373
|
+
* were added. */
|
|
374
374
|
type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
375
375
|
chain?: "stacks";
|
|
376
376
|
/** `vm` reads ordinal. Omit for Streams 1.0. */
|
|
@@ -390,7 +390,7 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
|
|
|
390
390
|
filters?: StreamsFilterMap;
|
|
391
391
|
};
|
|
392
392
|
/**
|
|
393
|
-
* `chain: "bitcoin"`
|
|
393
|
+
* `chain: "bitcoin"` — Runes events, own cursor space. `types` is
|
|
394
394
|
* restricted to {@link RuneEventType} at the type level, so e.g.
|
|
395
395
|
* `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
|
|
396
396
|
* than a silent 400 at request time. `contractId`/`sender`/`recipient`/
|
|
@@ -428,7 +428,7 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
|
|
|
428
428
|
/** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
|
|
429
429
|
filters?: StreamsFilterMap;
|
|
430
430
|
};
|
|
431
|
-
/** `chain: "bitcoin"`
|
|
431
|
+
/** `chain: "bitcoin"` — Runes events, tailed the same way as
|
|
432
432
|
* the Stacks default. `types` is restricted to {@link RuneEventType} at the
|
|
433
433
|
* type level, matching {@link StreamsEventsBitcoinListParams}.
|
|
434
434
|
* `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
|
|
@@ -486,7 +486,7 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
|
|
|
486
486
|
*/
|
|
487
487
|
onEvent: (event: StreamsEvent) => void | Promise<void>;
|
|
488
488
|
};
|
|
489
|
-
/** `chain: "bitcoin"`
|
|
489
|
+
/** `chain: "bitcoin"` — Runes events pushed live, on their own
|
|
490
490
|
* cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
|
|
491
491
|
* don't exist on this branch — they're Stacks-only. */
|
|
492
492
|
type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
|
|
@@ -696,7 +696,7 @@ type StreamsEventsConsumeParams<
|
|
|
696
696
|
wake?: () => Promise<void>;
|
|
697
697
|
};
|
|
698
698
|
/**
|
|
699
|
-
* `chain: "bitcoin"`
|
|
699
|
+
* `chain: "bitcoin"` — the checkpointed sweep over Runes
|
|
700
700
|
* events. A separate, simpler type from {@link StreamsEventsConsumeParams}
|
|
701
701
|
* rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
|
|
702
702
|
* concepts (labelled OR-groups and Index-shaped projection have no Runes
|
|
@@ -774,7 +774,7 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
|
|
|
774
774
|
* event echoes the labels it matched. */
|
|
775
775
|
filters?: StreamsFilterMap;
|
|
776
776
|
};
|
|
777
|
-
/** `chain: "bitcoin"`
|
|
777
|
+
/** `chain: "bitcoin"` — Runes batches, own cursor space.
|
|
778
778
|
* `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
|
|
779
779
|
* on this branch — they're Stacks-only. */
|
|
780
780
|
type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
|
|
@@ -878,38 +878,43 @@ type StreamsDumps = {
|
|
|
878
878
|
};
|
|
879
879
|
type StreamsClient = {
|
|
880
880
|
/**
|
|
881
|
-
*
|
|
881
|
+
* Read Streams page by page as an async iterator.
|
|
882
882
|
*
|
|
883
|
-
* Yields one {@link StreamsBatch} per
|
|
884
|
-
*
|
|
885
|
-
*
|
|
886
|
-
* because the envelope is page-keyed, so every yield is exactly one fetch.
|
|
887
|
-
* Empty pages are skipped; at the tip the iterator re-polls every
|
|
888
|
-
* `intervalMs` (default 2000) until aborted via `signal`.
|
|
883
|
+
* Yields one {@link StreamsBatch} per events page, so each yield is exactly
|
|
884
|
+
* one API call. Empty pages are skipped; at the tip the iterator polls again
|
|
885
|
+
* every `intervalMs` (default 2000) until `signal` aborts.
|
|
889
886
|
*
|
|
890
|
-
* Reorgs
|
|
891
|
-
*
|
|
892
|
-
*
|
|
887
|
+
* Reorgs appear on `batch.reorgs`, but the cursor is not rewound for you.
|
|
888
|
+
* Use `events.consume` with `onReorg` when you need rollback.
|
|
889
|
+
*
|
|
890
|
+
* A literal `types` array narrows every batch's event union to those types.
|
|
891
|
+
* `chain: "bitcoin"` batches carry Runes rows only, on the bitcoin tip shape.
|
|
893
892
|
*/
|
|
894
|
-
/** `chain: "bitcoin"` — batches carry Runes rows only, on the bitcoin tip
|
|
895
|
-
* shape (plan 059/061). */
|
|
896
893
|
consume(params: StreamsConsumeBitcoinParams): AsyncIterableIterator<StreamsBatch<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
897
|
-
/** Narrowing overload: a literal `types` array narrows every batch's
|
|
898
|
-
* event union to exactly those members. */
|
|
899
894
|
consume<const T extends readonly StreamsEventType[]>(params: StreamsConsumeStacksParams & {
|
|
900
895
|
types: T;
|
|
901
896
|
}): AsyncIterableIterator<StreamsBatch<StreamsEventOfTypes<T>>>;
|
|
902
897
|
consume(params?: StreamsConsumeParams): AsyncIterableIterator<StreamsBatch>;
|
|
903
898
|
events: {
|
|
904
|
-
/**
|
|
905
|
-
*
|
|
906
|
-
*
|
|
899
|
+
/**
|
|
900
|
+
* Read one page of chain events and the next cursor.
|
|
901
|
+
*
|
|
902
|
+
* Narrow with `types`, `notTypes`, `contractId`, `sender`, `recipient`,
|
|
903
|
+
* `assetIdentifier`, `fromHeight`/`toHeight`, or labelled `filters`.
|
|
904
|
+
* Filters match exactly, and an event type without a given field never
|
|
905
|
+
* matches it. Pass `next_cursor` back as `cursor` to continue. The
|
|
906
|
+
* envelope also carries the `tip` and any `reorgs`. To write the events
|
|
907
|
+
* somewhere with a checkpoint, use `events.consume` instead.
|
|
908
|
+
*
|
|
909
|
+
* A literal `types` array narrows every row to those event types.
|
|
910
|
+
* `clock: "vm"` pages carry vm rows only (a parallel vocabulary,
|
|
911
|
+
* `event_index` = `ordinal`), never `StreamsEvent`; it is Stacks only.
|
|
912
|
+
* `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip shape,
|
|
913
|
+
* and filter by `rune` or `address`.
|
|
914
|
+
*/
|
|
907
915
|
list(params: StreamsEventsStacksListParams & {
|
|
908
916
|
clock: "vm";
|
|
909
917
|
}): Promise<StreamsEventsEnvelope<VmStreamsEvent>>;
|
|
910
|
-
/** Narrowing overload, matching `consume`. Classic clock only —
|
|
911
|
-
* `clock: "vm"` is overload 1, and a general `StreamsEventsListParams`
|
|
912
|
-
* variable (clock unresolved) is the wire-union fallback. */
|
|
913
918
|
list<const T extends readonly StreamsEventType[]>(params: Omit<StreamsEventsStacksListParams, "clock" | "types" | "notTypes"> & {
|
|
914
919
|
types: T;
|
|
915
920
|
notTypes?: readonly StreamsEventType[];
|
|
@@ -920,27 +925,35 @@ type StreamsClient = {
|
|
|
920
925
|
notTypes?: readonly StreamsEventType[];
|
|
921
926
|
clock?: "classic";
|
|
922
927
|
}): Promise<StreamsEventsEnvelope>;
|
|
923
|
-
/** `chain: "bitcoin"` pages carry Runes rows only, on the bitcoin tip
|
|
924
|
-
* shape (plan 059). */
|
|
925
928
|
list(params: StreamsEventsBitcoinListParams): Promise<StreamsEventsEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
926
|
-
/** Unresolved `chain`/`clock` on a general params variable: the wire union. */
|
|
927
929
|
list(params: StreamsEventsListParams): Promise<StreamsEventsEnvelope<StreamsWireEvent>>;
|
|
928
|
-
/**
|
|
930
|
+
/**
|
|
931
|
+
* Read every event a transaction emitted.
|
|
932
|
+
*
|
|
933
|
+
* Returns the events and the `tip`, with no `next_cursor`: one transaction
|
|
934
|
+
* is one response.
|
|
935
|
+
*
|
|
936
|
+
* `chain: "bitcoin"` returns the Runes events for one Bitcoin transaction.
|
|
937
|
+
*/
|
|
929
938
|
byTxId(txId: string, opts: {
|
|
930
939
|
chain: "bitcoin";
|
|
931
940
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
932
941
|
byTxId(txId: string): Promise<StreamsEventsListEnvelope>;
|
|
933
942
|
/**
|
|
934
|
-
*
|
|
943
|
+
* Run a checkpointed indexer that rewinds on reorgs.
|
|
944
|
+
*
|
|
945
|
+
* Write your rows in `onBatch` and commit `ctx.cursor` in the same
|
|
946
|
+
* transaction; resume with `fromCursor`. Reorgs at or below your checkpoint
|
|
947
|
+
* call `onReorg`, then the loop re-reads from the fork point. Delivery is
|
|
948
|
+
* at-least-once, so keep writes idempotent. With a `sink`, the checkpoint
|
|
949
|
+
* and rollback are handled for you. `mode: "tail"` (default) keeps polling
|
|
950
|
+
* at the tip; `mode: "bounded"` returns on the first empty page. It also
|
|
951
|
+
* stops on `maxPages`, `maxEmptyPolls`, or `signal`. Pass `finalizedOnly`
|
|
952
|
+
* to skip reorg handling entirely.
|
|
935
953
|
*
|
|
936
|
-
*
|
|
937
|
-
*
|
|
938
|
-
* polling when caught up; `mode: "bounded"` exits on the first empty page.
|
|
939
|
-
* The consumer also exits when `maxPages`, `maxEmptyPolls`, or `signal`
|
|
940
|
-
* stops it.
|
|
954
|
+
* `chain: "bitcoin"` sweeps Runes events; see
|
|
955
|
+
* {@link StreamsEventsConsumeBitcoinParams}.
|
|
941
956
|
*/
|
|
942
|
-
/** `chain: "bitcoin"` — the checkpointed sweep over Runes events; see
|
|
943
|
-
* {@link StreamsEventsConsumeBitcoinParams}. */
|
|
944
957
|
consume<TTx = never>(params: StreamsEventsConsumeBitcoinParams<TTx> & {
|
|
945
958
|
sink?: ConsumerSink<TTx>;
|
|
946
959
|
}): Promise<StreamsEventsConsumeResult>;
|
|
@@ -952,46 +965,66 @@ type StreamsClient = {
|
|
|
952
965
|
sink?: ConsumerSink<TTx>;
|
|
953
966
|
}): Promise<StreamsEventsConsumeResult>;
|
|
954
967
|
/**
|
|
955
|
-
* Backfill from bulk dumps, then continue live
|
|
956
|
-
*
|
|
957
|
-
*
|
|
958
|
-
*
|
|
959
|
-
* `
|
|
968
|
+
* Backfill from bulk dumps, then continue live in one call.
|
|
969
|
+
*
|
|
970
|
+
* Hands each finalized dump file to `onDumpFile` in block order, then tails
|
|
971
|
+
* live from the manifest's `latest_finalized_cursor`, with no gap or
|
|
972
|
+
* duplicate at the seam. A file that straddles `from` is delivered whole,
|
|
973
|
+
* so skip the rows at or below it. Requires `dumpsBaseUrl`.
|
|
960
974
|
*/
|
|
961
975
|
replay(params: StreamsEventsReplayParams): Promise<StreamsEventsConsumeResult>;
|
|
962
976
|
/**
|
|
963
|
-
*
|
|
977
|
+
* Read events one at a time as an async iterator.
|
|
978
|
+
*
|
|
979
|
+
* For live processors and watch-style apps that keep their own state. It
|
|
980
|
+
* tails indefinitely and stops when `signal`, `maxPages`, or
|
|
981
|
+
* `maxEmptyPolls` ends it. There is no checkpoint or reorg handling; use
|
|
982
|
+
* `events.consume` for that.
|
|
964
983
|
*
|
|
965
|
-
*
|
|
966
|
-
*
|
|
967
|
-
* `maxEmptyPolls` stops it.
|
|
984
|
+
* A literal `types` array narrows every event to those types.
|
|
985
|
+
* `chain: "bitcoin"` yields Runes events only.
|
|
968
986
|
*/
|
|
969
|
-
/** `chain: "bitcoin"` — Runes events only (plan 059/061). */
|
|
970
987
|
stream(params: StreamsEventsStreamBitcoinParams): AsyncIterable<RuneStreamsEvent>;
|
|
971
|
-
/** Narrowing overload, matching `consume`. */
|
|
972
988
|
stream<const T extends readonly StreamsEventType[]>(params: StreamsEventsStreamStacksParams & {
|
|
973
989
|
types: T;
|
|
974
990
|
}): AsyncIterable<StreamsEventOfTypes<T>>;
|
|
975
991
|
stream(params?: StreamsEventsStreamParams): AsyncIterable<StreamsEvent>;
|
|
976
992
|
/**
|
|
977
|
-
*
|
|
978
|
-
*
|
|
979
|
-
*
|
|
980
|
-
*
|
|
981
|
-
*
|
|
982
|
-
*
|
|
993
|
+
* Get each new event pushed to `onEvent` as it lands.
|
|
994
|
+
*
|
|
995
|
+
* Reconnects from the last handled cursor after a transport error, and
|
|
996
|
+
* verifies each frame's ed25519 signature when the client has `verify` on.
|
|
997
|
+
* Returns an unsubscribe function whose `done` promise settles when the
|
|
998
|
+
* loop ends. Not reorg-aware: an event delivered and then orphaned is never
|
|
999
|
+
* retracted. Durable writers use `events.consume`.
|
|
1000
|
+
*
|
|
1001
|
+
* `chain: "bitcoin"` delivers Runes rows to `onEvent`.
|
|
983
1002
|
*/
|
|
984
|
-
/** `chain: "bitcoin"` — `onEvent` receives Runes rows (plan 059/061). */
|
|
985
1003
|
subscribe(params: StreamsEventsSubscribeBitcoinParams): StreamsSubscription;
|
|
986
1004
|
subscribe(params: StreamsEventsSubscribeStacksParams): StreamsSubscription;
|
|
987
1005
|
};
|
|
988
1006
|
blocks: {
|
|
1007
|
+
/**
|
|
1008
|
+
* Read every event in one block, by height or hash.
|
|
1009
|
+
*
|
|
1010
|
+
* Returns the events and the `tip`, with no `next_cursor`.
|
|
1011
|
+
*
|
|
1012
|
+
* `chain: "bitcoin"` returns the Runes events in one Bitcoin block.
|
|
1013
|
+
*/
|
|
989
1014
|
events(heightOrHash: number | string, opts: {
|
|
990
1015
|
chain: "bitcoin";
|
|
991
1016
|
}): Promise<StreamsEventsListEnvelope<RuneStreamsEvent, StreamsBitcoinTip>>;
|
|
992
1017
|
events(heightOrHash: number | string): Promise<StreamsEventsListEnvelope>;
|
|
993
1018
|
};
|
|
994
1019
|
reorgs: {
|
|
1020
|
+
/**
|
|
1021
|
+
* List chain reorgs since a cursor.
|
|
1022
|
+
*
|
|
1023
|
+
* `since` is required. Each reorg gives its `fork_point_height` and the
|
|
1024
|
+
* orphaned range. Page with `next_since`.
|
|
1025
|
+
*
|
|
1026
|
+
* `chain: "bitcoin"` lists Bitcoin reorgs, on their own cursor space.
|
|
1027
|
+
*/
|
|
995
1028
|
list(params: StreamsReorgsListParams & {
|
|
996
1029
|
chain: "bitcoin";
|
|
997
1030
|
}): Promise<StreamsReorgsListEnvelope>;
|
|
@@ -999,10 +1032,27 @@ type StreamsClient = {
|
|
|
999
1032
|
};
|
|
1000
1033
|
/** Bulk parquet dumps. Requires `dumpsBaseUrl` on the client. */
|
|
1001
1034
|
dumps: StreamsDumps;
|
|
1035
|
+
/**
|
|
1036
|
+
* Get the canonical block at a height.
|
|
1037
|
+
*
|
|
1038
|
+
* Returns the block hash and, on Stacks, the burn block it anchors to.
|
|
1039
|
+
*
|
|
1040
|
+
* `chain: "bitcoin"` returns the Bitcoin block, without burn-chain fields.
|
|
1041
|
+
*/
|
|
1002
1042
|
canonical(height: number, opts: {
|
|
1003
1043
|
chain: "bitcoin";
|
|
1004
1044
|
}): Promise<StreamsBitcoinCanonicalBlock>;
|
|
1005
1045
|
canonical(height: number): Promise<StreamsCanonicalBlock>;
|
|
1046
|
+
/**
|
|
1047
|
+
* Get the current chain tip.
|
|
1048
|
+
*
|
|
1049
|
+
* Returns the tip height and hash, `finalized_height`, and `lag_seconds`. On
|
|
1050
|
+
* Stacks it also reports the oldest height your tier can seek; older reads
|
|
1051
|
+
* come from the bulk dumps.
|
|
1052
|
+
*
|
|
1053
|
+
* `chain: "bitcoin"` returns the Bitcoin tip, without burn-chain or retention
|
|
1054
|
+
* fields.
|
|
1055
|
+
*/
|
|
1006
1056
|
tip(opts: {
|
|
1007
1057
|
chain: "bitcoin";
|
|
1008
1058
|
}): Promise<StreamsBitcoinTip>;
|