@secondlayer/sdk 15.0.1 → 15.0.2

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.
@@ -147,6 +147,7 @@ type IndexEventBase = {
147
147
  tx_contract_id?: string | null;
148
148
  tx_function_name?: string | null;
149
149
  };
150
+ /** A fungible-token transfer event. */
150
151
  type IndexFtTransfer = IndexEventBase & {
151
152
  event_type: "ft_transfer";
152
153
  asset_identifier: string;
@@ -154,6 +155,7 @@ type IndexFtTransfer = IndexEventBase & {
154
155
  recipient: string;
155
156
  amount: string;
156
157
  };
158
+ /** A non-fungible-token transfer event. */
157
159
  type IndexNftTransfer = IndexEventBase & {
158
160
  event_type: "nft_transfer";
159
161
  asset_identifier: string;
@@ -161,6 +163,7 @@ type IndexNftTransfer = IndexEventBase & {
161
163
  recipient: string;
162
164
  value: string;
163
165
  };
166
+ /** An STX transfer event. */
164
167
  type IndexStxTransfer = IndexEventBase & {
165
168
  event_type: "stx_transfer";
166
169
  sender: string;
@@ -168,16 +171,19 @@ type IndexStxTransfer = IndexEventBase & {
168
171
  amount: string;
169
172
  memo: string | null;
170
173
  };
174
+ /** An STX mint event. */
171
175
  type IndexStxMint = IndexEventBase & {
172
176
  event_type: "stx_mint";
173
177
  recipient: string;
174
178
  amount: string;
175
179
  };
180
+ /** An STX burn event. */
176
181
  type IndexStxBurn = IndexEventBase & {
177
182
  event_type: "stx_burn";
178
183
  sender: string;
179
184
  amount: string;
180
185
  };
186
+ /** An STX lock event with its unlock height. */
181
187
  type IndexStxLock = IndexEventBase & {
182
188
  event_type: "stx_lock";
183
189
  sender: string;
@@ -186,30 +192,35 @@ type IndexStxLock = IndexEventBase & {
186
192
  unlock_height: string | null;
187
193
  };
188
194
  };
195
+ /** A fungible-token mint event. */
189
196
  type IndexFtMint = IndexEventBase & {
190
197
  event_type: "ft_mint";
191
198
  asset_identifier: string;
192
199
  recipient: string;
193
200
  amount: string;
194
201
  };
202
+ /** A fungible-token burn event. */
195
203
  type IndexFtBurn = IndexEventBase & {
196
204
  event_type: "ft_burn";
197
205
  asset_identifier: string;
198
206
  sender: string;
199
207
  amount: string;
200
208
  };
209
+ /** A non-fungible-token mint event. */
201
210
  type IndexNftMint = IndexEventBase & {
202
211
  event_type: "nft_mint";
203
212
  asset_identifier: string;
204
213
  recipient: string;
205
214
  value: string;
206
215
  };
216
+ /** A non-fungible-token burn event. */
207
217
  type IndexNftBurn = IndexEventBase & {
208
218
  event_type: "nft_burn";
209
219
  asset_identifier: string;
210
220
  sender: string;
211
221
  value: string;
212
222
  };
223
+ /** A contract `print` event with its topic and value. */
213
224
  type IndexPrint = IndexEventBase & {
214
225
  event_type: "print";
215
226
  payload: {
@@ -218,6 +229,7 @@ type IndexPrint = IndexEventBase & {
218
229
  raw_value: string | null;
219
230
  };
220
231
  };
232
+ /** A contract call made from inside another contract call. */
221
233
  type IndexNestedContractCall = IndexEventBase & {
222
234
  event_type: "nested_contract_call";
223
235
  sender: string | null;
@@ -226,23 +238,27 @@ type IndexNestedContractCall = IndexEventBase & {
226
238
  function_args: unknown;
227
239
  raw_result: string | null;
228
240
  };
241
+ /** A contract data variable write. */
229
242
  type IndexVarSet = IndexEventBase & {
230
243
  event_type: "var_set";
231
244
  var_name: string;
232
245
  raw_value: string;
233
246
  };
247
+ /** A contract map entry overwrite. */
234
248
  type IndexMapSet = IndexEventBase & {
235
249
  event_type: "map_set";
236
250
  map: string;
237
251
  raw_key: string;
238
252
  raw_value: string;
239
253
  };
254
+ /** A new contract map entry. */
240
255
  type IndexMapInsert = IndexEventBase & {
241
256
  event_type: "map_insert";
242
257
  map: string;
243
258
  raw_key: string;
244
259
  raw_value: string;
245
260
  };
261
+ /** A contract map entry deletion. */
246
262
  type IndexMapDelete = IndexEventBase & {
247
263
  event_type: "map_delete";
248
264
  map: string;
@@ -251,6 +267,7 @@ type IndexMapDelete = IndexEventBase & {
251
267
  /** Decoded chain event, discriminated by `event_type`. */
252
268
  type IndexEvent = IndexFtTransfer | IndexNftTransfer | IndexStxTransfer | IndexStxMint | IndexStxBurn | IndexStxLock | IndexFtMint | IndexFtBurn | IndexNftMint | IndexNftBurn | IndexPrint | IndexNestedContractCall | IndexVarSet | IndexMapSet | IndexMapInsert | IndexMapDelete;
253
269
  import { StreamsWireEvent as StreamsWireEvent2, RuneEtchEntry, RuneEventPayload, StreamsEventPayload } from "@secondlayer/shared/streams-rows";
270
+ /** The chain tip: latest block, Bitcoin anchor, and finality boundary. */
254
271
  type StreamsTip = {
255
272
  block_height: number;
256
273
  block_hash: string;
@@ -270,15 +287,19 @@ type StreamsTip = {
270
287
  /** Oldest seekable cursor (`<oldest_seekable_height>:0`); `null` = unlimited. */
271
288
  oldest_cursor?: string | null;
272
289
  };
273
- /** `chain=bitcoin` tip — no `burn_block_height`/retention fields,
274
- * since Bitcoin has no burn chain of its own and Runes reads have no
275
- * retention ladder. Returned by `tip({ chain: "bitcoin" })`. */
290
+ /**
291
+ * The Bitcoin tip, without burn-chain or retention fields.
292
+ *
293
+ * Bitcoin has no burn chain of its own, and Runes reads have no retention
294
+ * ladder. Returned by `tip({ chain: "bitcoin" })`.
295
+ */
276
296
  type StreamsBitcoinTip = {
277
297
  block_height: number;
278
298
  block_hash: string;
279
299
  finalized_height: number;
280
300
  lag_seconds: number;
281
301
  };
302
+ /** A canonical Stacks block with its Bitcoin anchor. */
282
303
  type StreamsCanonicalBlock = {
283
304
  block_height: number;
284
305
  block_hash: string;
@@ -286,7 +307,7 @@ type StreamsCanonicalBlock = {
286
307
  burn_block_hash: string | null;
287
308
  is_canonical: true;
288
309
  };
289
- /** `chain=bitcoin` canonical block — no burn-chain fields. */
310
+ /** A Bitcoin canonical block, without burn-chain fields. */
290
311
  type StreamsBitcoinCanonicalBlock = {
291
312
  block_height: number;
292
313
  block_hash: string;
@@ -307,6 +328,7 @@ type StreamsReorg = {
307
328
  */
308
329
  new_canonical_tip: string;
309
330
  };
331
+ /** One page of events with the next cursor, tip, and reorgs. */
310
332
  type StreamsEventsEnvelope<
311
333
  TEvent = StreamsEvent,
312
334
  TTip = StreamsTip
@@ -316,24 +338,30 @@ type StreamsEventsEnvelope<
316
338
  tip: TTip;
317
339
  reorgs: StreamsReorg[];
318
340
  };
341
+ /** One page of events with the tip and reorgs, no cursor. */
319
342
  type StreamsEventsListEnvelope<
320
343
  TEvent = StreamsEvent,
321
344
  TTip = StreamsTip
322
345
  > = Omit<StreamsEventsEnvelope<TEvent, TTip>, "next_cursor">;
323
- /** The StreamsEvent union narrowed to a `types` selection — what a
324
- * const-generic `types: ["ft_transfer"]` buys at the type level. */
346
+ /**
347
+ * The event union narrowed to a `types` selection.
348
+ *
349
+ * A const-generic `types: ["ft_transfer"]` narrows the event type.
350
+ */
325
351
  type StreamsEventOfTypes<T extends readonly StreamsEventType[]> = Extract<StreamsEvent, {
326
352
  event_type: T[number];
327
353
  }>;
354
+ /** A starting point and limit for listing reorgs. */
328
355
  type StreamsReorgsListParams = {
329
356
  since: string;
330
357
  limit?: number;
331
358
  };
359
+ /** A list of reorgs and the cursor to resume from. */
332
360
  type StreamsReorgsListEnvelope = {
333
361
  reorgs: StreamsReorg[];
334
362
  next_since: string | null;
335
363
  };
336
- /** A filter that matches a single value or any value in a list. */
364
+ /** A single value or a list of values to match. */
337
365
  type StreamsFilterValue = string | readonly string[];
338
366
  /**
339
367
  * One labelled filter group. Fields inside a group AND together; groups in a
@@ -363,6 +391,7 @@ type StreamsEventForFilter<
363
391
  }> : Extract<StreamsEvent, {
364
392
  event_type: T;
365
393
  }> : D extends true ? IndexEvent : StreamsEvent;
394
+ /** Cursor, height range, and limit shared by every list call. */
366
395
  type StreamsEventsListParamsCommon = {
367
396
  cursor?: string | null;
368
397
  fromHeight?: number;
@@ -390,12 +419,13 @@ type StreamsEventsStacksListParams = StreamsEventsListParamsCommon & {
390
419
  filters?: StreamsFilterMap;
391
420
  };
392
421
  /**
393
- * `chain: "bitcoin"` — Runes events, own cursor space. `types` is
394
- * restricted to {@link RuneEventType} at the type level, so e.g.
395
- * `{ chain: "bitcoin", types: ["ft_transfer"] }` is a compile error rather
396
- * than a silent 400 at request time. `contractId`/`sender`/`recipient`/
397
- * `assetIdentifier`/`filters`/`clock` don't exist on this branch — they're
398
- * Stacks-only (the server 400s on them too).
422
+ * List options for Runes events, with their own cursor space.
423
+ *
424
+ * `types` is restricted to `RuneEventType` at the type level, so e.g. `{ chain:
425
+ * "bitcoin", types: ["ft_transfer"] }` is a compile error rather than a silent
426
+ * 400 at request time. `contractId`, `sender`, `recipient`, `assetIdentifier`,
427
+ * `filters`, and `clock` don't exist on this branch; they're Stacks-only (the
428
+ * server 400s on them too).
399
429
  */
400
430
  type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
401
431
  chain: "bitcoin";
@@ -406,7 +436,9 @@ type StreamsEventsBitcoinListParams = StreamsEventsListParamsCommon & {
406
436
  /** A mainnet address. */
407
437
  address?: string;
408
438
  };
439
+ /** Chain, cursor, height range, and filters for listing Streams events. */
409
440
  type StreamsEventsListParams = StreamsEventsStacksListParams | StreamsEventsBitcoinListParams;
441
+ /** Cursor, batching, and stop options shared by every event stream. */
410
442
  type StreamsEventsStreamCommon = {
411
443
  fromCursor?: string | null;
412
444
  batchSize?: number;
@@ -415,8 +447,12 @@ type StreamsEventsStreamCommon = {
415
447
  maxEmptyPolls?: number;
416
448
  signal?: AbortSignal;
417
449
  };
418
- /** `chain: "stacks"` (default, omit `chain` entirely) — matches
419
- * {@link StreamsEventsStacksListParams}. */
450
+ /**
451
+ * Stream options for Stacks events, the default chain.
452
+ *
453
+ * `chain: "stacks"` is the default, so omit `chain` entirely. Matches
454
+ * `StreamsEventsStacksListParams`.
455
+ */
420
456
  type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
421
457
  chain?: "stacks";
422
458
  types?: readonly StreamsEventType[];
@@ -428,11 +464,14 @@ type StreamsEventsStreamStacksParams = StreamsEventsStreamCommon & {
428
464
  /** Labelled filter groups; see {@link StreamsEventsListParams.filters}. */
429
465
  filters?: StreamsFilterMap;
430
466
  };
431
- /** `chain: "bitcoin"` — Runes events, tailed the same way as
432
- * the Stacks default. `types` is restricted to {@link RuneEventType} at the
433
- * type level, matching {@link StreamsEventsBitcoinListParams}.
434
- * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
435
- * on this branch — they're Stacks-only. */
467
+ /**
468
+ * Stream options for Runes events, tailed like the Stacks default.
469
+ *
470
+ * `types` is restricted to `RuneEventType` at the type level, matching
471
+ * `StreamsEventsBitcoinListParams`. `contractId`, `sender`, `recipient`,
472
+ * `assetIdentifier`, and `filters` don't exist on this branch; they're
473
+ * Stacks-only.
474
+ */
436
475
  type StreamsEventsStreamBitcoinParams = StreamsEventsStreamCommon & {
437
476
  chain: "bitcoin";
438
477
  types?: readonly RuneEventType[];
@@ -486,9 +525,12 @@ type StreamsEventsSubscribeStacksParams = StreamsEventsSubscribeCommon & {
486
525
  */
487
526
  onEvent: (event: StreamsEvent) => void | Promise<void>;
488
527
  };
489
- /** `chain: "bitcoin"` — Runes events pushed live, on their own
490
- * cursor space. `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters`
491
- * don't exist on this branch — they're Stacks-only. */
528
+ /**
529
+ * Options for pushing Runes events live, on their own cursor space.
530
+ *
531
+ * `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
532
+ * exist on this branch; they're Stacks-only.
533
+ */
492
534
  type StreamsEventsSubscribeBitcoinParams = StreamsEventsSubscribeCommon & {
493
535
  chain: "bitcoin";
494
536
  types?: readonly RuneEventType[];
@@ -579,6 +621,7 @@ type StreamsBatchContext = ConsumerBatchContext;
579
621
  type StreamsReorgContext = {
580
622
  cursor: string | null;
581
623
  };
624
+ /** Options for consuming Streams events: cursor, batching, filters, handler. */
582
625
  type StreamsEventsConsumeParams<
583
626
  TTx = never,
584
627
  D extends boolean = false,
@@ -696,13 +739,14 @@ type StreamsEventsConsumeParams<
696
739
  wake?: () => Promise<void>;
697
740
  };
698
741
  /**
699
- * `chain: "bitcoin"` — the checkpointed sweep over Runes
700
- * events. A separate, simpler type from {@link StreamsEventsConsumeParams}
701
- * rather than a widened union member: `filters`/`on`/`decoded` are Stacks-only
702
- * concepts (labelled OR-groups and Index-shaped projection have no Runes
703
- * equivalent yet), so `onBatch` is the only way in and is required. Reorg
704
- * rewind still works the same way (bitcoin reorgs carry the same
705
- * `fork_point_height` + `new_canonical_tip` shape as Stacks ones).
742
+ * Options for the checkpointed sweep over Runes events.
743
+ *
744
+ * A separate, simpler type from `StreamsEventsConsumeParams` rather than a
745
+ * widened union member: `filters`, `on`, and `decoded` are Stacks-only concepts
746
+ * (labelled OR-groups and Index-shaped projection have no Runes equivalent
747
+ * yet), so `onBatch` is the only way in and is required. Reorg rewind still
748
+ * works the same way (bitcoin reorgs carry the same `fork_point_height` and
749
+ * `new_canonical_tip` shape as Stacks ones).
706
750
  */
707
751
  type StreamsEventsConsumeBitcoinParams<TTx = never> = {
708
752
  chain: "bitcoin";
@@ -735,9 +779,10 @@ type StreamsEventsConsumeBitcoinParams<TTx = never> = {
735
779
  wake?: () => Promise<void>;
736
780
  };
737
781
  /**
738
- * One yielded page from {@link StreamsClient.consume} — the
739
- * `GET /v1/streams/events` envelope verbatim, with `next_cursor` renamed to
740
- * `cursor` (the checkpoint to persist and resume from).
782
+ * One page yielded by `consume`, with `cursor` to persist and resume.
783
+ *
784
+ * It is the `GET /v1/streams/events` envelope verbatim, with `next_cursor`
785
+ * renamed to `cursor`.
741
786
  */
742
787
  type StreamsBatch<
743
788
  TEvent = StreamsEvent,
@@ -751,6 +796,7 @@ type StreamsBatch<
751
796
  /** Chain reorgs reported alongside this page; empty when none. */
752
797
  reorgs: StreamsReorg[];
753
798
  };
799
+ /** Cursor, batch size, and polling options shared by every consume loop. */
754
800
  type StreamsConsumeCommon = {
755
801
  /** Resume strictly after this cursor; omit to start from the oldest seekable page. */
756
802
  cursor?: string | null;
@@ -774,9 +820,12 @@ type StreamsConsumeStacksParams = StreamsConsumeCommon & {
774
820
  * event echoes the labels it matched. */
775
821
  filters?: StreamsFilterMap;
776
822
  };
777
- /** `chain: "bitcoin"` — Runes batches, own cursor space.
778
- * `contractId`/`sender`/`recipient`/`assetIdentifier`/`filters` don't exist
779
- * on this branch — they're Stacks-only. */
823
+ /**
824
+ * Consume options for Runes batches, with their own cursor space.
825
+ *
826
+ * `contractId`, `sender`, `recipient`, `assetIdentifier`, and `filters` don't
827
+ * exist on this branch; they're Stacks-only.
828
+ */
780
829
  type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
781
830
  chain: "bitcoin";
782
831
  types?: readonly RuneEventType[];
@@ -787,11 +836,13 @@ type StreamsConsumeBitcoinParams = StreamsConsumeCommon & {
787
836
  address?: string;
788
837
  };
789
838
  type StreamsConsumeParams = StreamsConsumeStacksParams | StreamsConsumeBitcoinParams;
839
+ /** Where a consume loop stopped: cursor, pages read, empty polls. */
790
840
  type StreamsEventsConsumeResult = {
791
841
  cursor: string | null;
792
842
  pages: number;
793
843
  emptyPolls: number;
794
844
  };
845
+ /** Options for replaying history from dump files, then tailing live. */
795
846
  type StreamsEventsReplayParams = {
796
847
  /** Start point: `"genesis"` (default) or a `<block>:<index>` cursor. */
797
848
  from?: "genesis" | string;
@@ -847,6 +898,7 @@ type StreamsDumpFile = {
847
898
  schema_version: number;
848
899
  created_at: string;
849
900
  };
901
+ /** The index of finalized Parquet dump files for one dataset. */
850
902
  type StreamsDumpsManifest = {
851
903
  dataset: string;
852
904
  network: string;