@secondlayer/cli 20.0.0 → 20.1.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/README.md CHANGED
@@ -164,7 +164,8 @@ points at.
164
164
  | Command | What it does |
165
165
  |---|---|
166
166
  | `secondlayer index ft-transfers` / `nft-transfers` / `events --event-type <t>` / `contract-calls` | Decoded Index layer. Anonymous reads OK |
167
- | `secondlayer streams tip` / `events` / `consume` / `reorgs` / `canonical <h>` / `dumps` | Raw chain event firehose. `consume` emits one event per line; a reorg appears inline as `{"kind":"reorg","fork_point_height":…}` and the loop rewinds to re-deliver the canonical run, so a reader drops rows at or above the fork point when it sees one. `--max-pages` must be a positive integer. **Requires `INSTANCE_TOKEN` past loopback** |
167
+ | `secondlayer index runes` / `runes get <rune>` / `runes balances (--address <a> \| --outpoint <txid:vout>)` / `runes activity [--kind etch,mint,transfer,burn]` | Bitcoin Runes: catalog, one rune, balances, activity. Hosted answers a "not configured" note until Runes data lands there |
168
+ | `secondlayer streams tip` / `events` / `consume` / `reorgs` / `canonical <h>` / `dumps` | Raw chain event firehose. `consume` emits one event per line; a reorg appears inline as `{"kind":"reorg","fork_point_height":…}` and the loop rewinds to re-deliver the canonical run, so a reader drops rows at or above the fork point when it sees one. `--max-pages` must be a positive integer. `events`, `events by-tx`, `consume` and `reorgs` take `--chain bitcoin` for Runes events (`rune_*` types; Stacks-only filters are refused). **Requires `INSTANCE_TOKEN` past loopback** |
168
169
 
169
170
  Reads emit JSON to stdout (`--json` accepted across all read commands); `-o/--output` is a file path, not a format.
170
171
 
package/dist/cli.js CHANGED
@@ -29423,7 +29423,7 @@ var init_git_status = () => {};
29423
29423
 
29424
29424
  // ../../node_modules/typescript/lib/typescript.js
29425
29425
  var require_typescript = __commonJS(function(exports, module) {
29426
- var __dirname = "/Users/ryan/projects/secondlayer/node_modules/typescript/lib", __filename = "/Users/ryan/projects/secondlayer/node_modules/typescript/lib/typescript.js";
29426
+ var __dirname = "/Users/ryan/projects/secondlayer/.claude/worktrees/agent-acfa3defe852cdfd5/node_modules/typescript/lib", __filename = "/Users/ryan/projects/secondlayer/.claude/worktrees/agent-acfa3defe852cdfd5/node_modules/typescript/lib/typescript.js";
29427
29427
  /*! *****************************************************************************
29428
29428
  Copyright (c) Microsoft Corporation. All rights reserved.
29429
29429
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
@@ -200299,6 +200299,34 @@ function fail(action, err) {
200299
200299
  }
200300
200300
  process.exit(1);
200301
200301
  }
200302
+ function parseRuneSort(value) {
200303
+ if (value === undefined)
200304
+ return;
200305
+ if (!RUNE_SORTS.includes(value)) {
200306
+ throw new Error(`invalid --sort "${value}"; expected one of: ${RUNE_SORTS.join(", ")}`);
200307
+ }
200308
+ return value;
200309
+ }
200310
+ function parseRuneKinds(value) {
200311
+ if (value === undefined)
200312
+ return;
200313
+ return value.split(",").map((raw) => {
200314
+ const name = raw.trim();
200315
+ if (!RUNE_KINDS.includes(name)) {
200316
+ throw new Error(`invalid --kind "${name}"; expected one or more of: ${RUNE_KINDS.join(", ")}`);
200317
+ }
200318
+ return `rune_${name}`;
200319
+ });
200320
+ }
200321
+ function runeBalanceSubject(o) {
200322
+ if (o.address !== undefined && o.outpoint === undefined) {
200323
+ return { address: o.address };
200324
+ }
200325
+ if (o.outpoint !== undefined && o.address === undefined) {
200326
+ return { outpoint: o.outpoint };
200327
+ }
200328
+ throw new Error("pass --address or --outpoint (one of them)");
200329
+ }
200302
200330
  function heightParams(o) {
200303
200331
  return {
200304
200332
  fromHeight: o.fromHeight ? Number.parseInt(o.fromHeight, 10) : undefined,
@@ -200456,6 +200484,53 @@ function registerIndexCommand(program) {
200456
200484
  fail("get mempool tx", err);
200457
200485
  }
200458
200486
  });
200487
+ const runes = index.command("runes").description("List etched runes (Bitcoin; run `runes get <rune>` for one)").option("--search <prefix>", "Name prefix, spacers and case ignored").option("--sort <order>", "number (etch order) or mints (busiest first)").option("--cursor <cursor>", "Resume token from a previous next_cursor").option("--limit <n>", "Rows per page").option("--json", "Print the full envelope as JSON").action(async (o) => {
200488
+ try {
200489
+ emit(await client().runes.list({
200490
+ search: o.search,
200491
+ sort: parseRuneSort(o.sort),
200492
+ cursor: o.cursor,
200493
+ limit: o.limit ? Number.parseInt(o.limit, 10) : undefined
200494
+ }), o.json);
200495
+ } catch (err) {
200496
+ fail("list runes", err);
200497
+ }
200498
+ });
200499
+ runes.command("get <rune>").description("Get one rune by id (840000:3) or name, any spacing or case").option("--json", "Print as JSON").action(async (rune, _o, cmd) => {
200500
+ const o = cmd.optsWithGlobals();
200501
+ try {
200502
+ emitOne(await client().runes.get(rune), `rune ${rune}`, o.json);
200503
+ } catch (err) {
200504
+ fail("get rune", err);
200505
+ }
200506
+ });
200507
+ runes.command("balances").description("Current rune balances by address or outpoint (Bitcoin)").option("--address <address>", "Bitcoin address").option("--outpoint <txid:vout>", "Unspent output").option("--rune <ref>", "Narrow to one rune (id or name)").option("--cursor <cursor>", "Resume token from a previous next_cursor").option("--limit <n>", "Rows per page").option("--json", "Print the full envelope as JSON").action(async (_o, cmd) => {
200508
+ const o = cmd.optsWithGlobals();
200509
+ try {
200510
+ emit(await client().runes.balances({
200511
+ ...runeBalanceSubject(o),
200512
+ rune: o.rune,
200513
+ cursor: o.cursor,
200514
+ limit: o.limit ? Number.parseInt(o.limit, 10) : undefined
200515
+ }), o.json);
200516
+ } catch (err) {
200517
+ fail("list rune balances", err);
200518
+ }
200519
+ });
200520
+ runes.command("activity").description("List rune etches, mints, transfers and burns (Bitcoin)").option("--rune <ref>", "Filter by rune (id or name)").option("--address <address>", "Filter by Bitcoin address").option("--kind <kinds>", `Comma list of ${RUNE_KINDS.join(", ")}`).option("--txid <txid>", "Filter by Bitcoin transaction id").option("--from-height <n>", "Start Bitcoin block height (inclusive)").option("--to-height <n>", "End Bitcoin block height (inclusive)").option("--cursor <cursor>", "Resume token from a previous next_cursor").option("--limit <n>", "Rows per page").option("--json", "Print the full envelope as JSON").action(async (_o, cmd) => {
200521
+ const o = cmd.optsWithGlobals();
200522
+ try {
200523
+ emit(await client().runes.activity.list({
200524
+ ...heightParams(o),
200525
+ rune: o.rune,
200526
+ address: o.address,
200527
+ kind: parseRuneKinds(o.kind),
200528
+ txid: o.txid
200529
+ }), o.json);
200530
+ } catch (err) {
200531
+ fail("list rune activity", err);
200532
+ }
200533
+ });
200459
200534
  }
200460
200535
  async function runIndexCodegen(o) {
200461
200536
  try {
@@ -200482,12 +200557,14 @@ async function runIndexCodegen(o) {
200482
200557
  process.exit(1);
200483
200558
  }
200484
200559
  }
200485
- var VALID_INDEX_TYPES;
200560
+ var VALID_INDEX_TYPES, RUNE_SORTS, RUNE_KINDS;
200486
200561
  var init_index_api = __esm(() => {
200487
200562
  init_fs();
200488
200563
  init_output();
200489
200564
  init_resolve_auth();
200490
200565
  VALID_INDEX_TYPES = DECODED_EVENT_TYPES3;
200566
+ RUNE_SORTS = ["number", "mints"];
200567
+ RUNE_KINDS = ["etch", "mint", "transfer", "burn"];
200491
200568
  });
200492
200569
 
200493
200570
  // ../../node_modules/postgres/src/query.js
@@ -202569,7 +202646,7 @@ var {
202569
202646
  // package.json
202570
202647
  var package_default = {
202571
202648
  name: "@secondlayer/cli",
202572
- version: "20.0.0",
202649
+ version: "20.1.0",
202573
202650
  description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
202574
202651
  repository: {
202575
202652
  type: "git",
@@ -202611,8 +202688,8 @@ var package_default = {
202611
202688
  "@secondlayer/sdk": "^15.0.0",
202612
202689
  "@secondlayer/shared": "^12.0.0",
202613
202690
  "@secondlayer/stacks": "^6.2.0",
202614
- "@secondlayer/subgraphs": "^7.0.0",
202615
- "@secondlayer/verify": "^0.4.0",
202691
+ "@secondlayer/subgraphs": "^7.0.1",
202692
+ "@secondlayer/verify": "^0.5.0",
202616
202693
  esbuild: "^0.28.2",
202617
202694
  "smol-toml": "^1.9.1",
202618
202695
  zod: "^4.3.6"
@@ -204051,24 +204128,12 @@ init_resolve_auth();
204051
204128
  import { readFile as readFile3 } from "node:fs/promises";
204052
204129
  import {
204053
204130
  BlockVerifier,
204131
+ LINKS,
204054
204132
  MAINNET_CHECKPOINT,
204055
204133
  NodeRpcProofSource,
204056
204134
  SecondlayerProofSource,
204057
- parseNakamotoHeader,
204058
- unhex
204135
+ describeLinks
204059
204136
  } from "@secondlayer/verify";
204060
- var LINKS = [
204061
- { step: "ancestry", label: "ancestry" },
204062
- { step: "block", label: "block" },
204063
- { step: "bitcoin", label: "bitcoin" },
204064
- { step: "burn", label: "burn" },
204065
- { step: "signer-set", label: "cycle" },
204066
- { step: "signatures", label: "signatures" },
204067
- { step: "txs", label: "txs" },
204068
- { step: "witness", label: "state root" },
204069
- { step: "names", label: "diff" },
204070
- { step: "rows", label: "rows" }
204071
- ];
204072
204137
  var LABEL_WIDTH = Math.max(...LINKS.map((l) => l.label.length));
204073
204138
  var n = (v) => v.toLocaleString("en-US");
204074
204139
  function parseBlockRef(raw) {
@@ -204122,81 +204187,20 @@ function prepareSource(src) {
204122
204187
  };
204123
204188
  return out;
204124
204189
  }
204125
- function linkDetail(step, r, cp) {
204126
- switch (step) {
204127
- case "ancestry": {
204128
- const a = r.ancestry;
204129
- if (!a)
204130
- return "";
204131
- const checkpoint = parseNakamotoHeader(unhex(cp.stacks.header));
204132
- const start = a.fromHeight === Number(checkpoint.chainLength) ? `the checkpoint ${n(a.fromHeight)}` : `block ${n(a.fromHeight)}`;
204133
- return a.via === "marf" ? `${n(r.height ?? 0)} proven in the state of ${start} (one MARF proof)` : `${n(r.height ?? 0)} reached from ${start} by parent links`;
204134
- }
204135
- case "block":
204136
- return `${n(r.height ?? 0)} ${r.blockId}`;
204137
- case "bitcoin":
204138
- return `headers ${n(cp.bitcoin.height)}..${n(r.burnHeight ?? 0)}, proof-of-work and retargets checked`;
204139
- case "burn":
204140
- return `height ${n(r.burnHeight ?? 0)} ${r.bitcoinBlockHash}`;
204141
- case "signer-set":
204142
- return r.cycle === cp.stacks.cycle ? `${r.cycle}, the checkpoint's own signer set` : `${r.cycle}, signer set proven forward from checkpoint cycle ${cp.stacks.cycle}`;
204143
- case "signatures":
204144
- return `${n(r.signerWeight ?? 0n)} / ${n(r.totalWeight ?? 0n)} weight signed, threshold ${n(r.threshold ?? 0n)}`;
204145
- case "txs":
204146
- return `${n(r.transactions?.length ?? 0)} transactions match the tx merkle root`;
204147
- case "witness":
204148
- return `${r.stateRoot} matches the witness`;
204149
- case "names": {
204150
- const d = r.diff;
204151
- if (!d)
204152
- return "";
204153
- const named = d.writes.filter((w) => w.named).length;
204154
- const written = named ? `${d.writes.length} written (${named} named, ${d.writes.length - named} unnamed)` : `${d.writes.length} written (unnamed)`;
204155
- return `${written}, ${d.carried.length} carried, ${d.internal.length} internal`;
204156
- }
204157
- case "rows":
204158
- return `${n(r.rowsChecked ?? 0)} vm_events rows match the diff`;
204159
- }
204160
- }
204161
- function notNeeded(step, r) {
204162
- if (!r.ancestry)
204163
- return false;
204164
- if (step === "bitcoin" || step === "burn")
204165
- return r.burnHeight === undefined;
204166
- return step === "signer-set" || step === "signatures";
204167
- }
204168
204190
  function report(r, cp, rows) {
204169
- const first = r.failures[0];
204170
- const broken = first ? LINKS.findIndex((l) => l.step === first.step) : LINKS.length;
204171
- for (const [i, link] of LINKS.entries()) {
204172
- const label = link.label.padEnd(LABEL_WIDTH);
204173
- const failure = r.failures.find((f) => f.step === link.step);
204174
- if (link.step === "ancestry" && !failure && !r.ancestry)
204175
- continue;
204176
- if (failure)
204177
- writeData(`${red("✗")} ${label} ${failure.message}`);
204178
- else if (link.step === "rows" && !rows)
204179
- writeData(dim(`· ${label} not checked (pass --rows)`));
204180
- else if (i > broken)
204181
- writeData(dim(`· ${label} not checked: an earlier link is broken`));
204182
- else if (notNeeded(link.step, r))
204183
- writeData(dim(`· ${label} not needed: the block is hash-chained to the checkpoint`));
204184
- else if (link.step === "rows" && r.rowsChecked === undefined)
204185
- writeData(dim(`· ${label} not checked: the source serves no indexed rows`));
204186
- else if (link.step === "txs" && r.transactions === undefined)
204187
- writeData(dim(`· ${label} not checked: no transaction bytes (epoch 2.x, or the source served the header only)`));
204191
+ const { lines, verdict } = describeLinks(r, cp, { rows });
204192
+ for (const line of lines) {
204193
+ const label = line.label.padEnd(LABEL_WIDTH);
204194
+ if (line.status === "failed")
204195
+ writeData(`${red("✗")} ${label} ${line.detail}`);
204196
+ else if (line.status === "skipped")
204197
+ writeData(dim(`· ${label} ${line.detail}`));
204188
204198
  else
204189
- writeData(`${green("✓")} ${label} ${linkDetail(link.step, r, cp)}`);
204199
+ writeData(`${green("✓")} ${label} ${line.detail}`);
204190
204200
  }
204191
204201
  for (const line of r.notes)
204192
204202
  note(` note: ${line}`);
204193
- if (!first) {
204194
- const from = n(parseNakamotoHeader(unhex(cp.stacks.header)).chainLength);
204195
- writeData(green(`✓ Block ${n(r.height ?? 0)} is proven. Trusted: only the checkpoint (Stacks ${from}, Bitcoin ${n(cp.bitcoin.height)}).`));
204196
- return;
204197
- }
204198
- const label = LINKS[broken]?.label ?? first.step;
204199
- writeData(red(first.code === "unavailable" ? `✗ Could not check the ${label} link: the source could not serve it.` : `✗ Not proven: the ${label} link is broken.`));
204203
+ writeData(verdict.ok ? green(`✓ ${verdict.text}`) : red(`✗ ${verdict.text}`));
204200
204204
  }
204201
204205
  function verificationJson(r) {
204202
204206
  const { transactions, ...rest } = r;
@@ -204280,8 +204284,8 @@ import {
204280
204284
  } from "@secondlayer/subgraphs/verify";
204281
204285
  import {
204282
204286
  MAINNET_CHECKPOINT as MAINNET_CHECKPOINT2,
204283
- parseNakamotoHeader as parseNakamotoHeader2,
204284
- unhex as unhex2
204287
+ parseNakamotoHeader,
204288
+ unhex
204285
204289
  } from "@secondlayer/verify";
204286
204290
  var LINKS2 = [
204287
204291
  { step: "pin", label: "pin" },
@@ -204369,7 +204373,7 @@ function report2(r, from, to) {
204369
204373
  return VERIFY_EXIT.UNANCHORED;
204370
204374
  }
204371
204375
  const cp = MAINNET_CHECKPOINT2;
204372
- const stacks = n2(Number(parseNakamotoHeader2(unhex2(cp.stacks.header)).chainLength));
204376
+ const stacks = n2(Number(parseNakamotoHeader(unhex(cp.stacks.header)).chainLength));
204373
204377
  writeData(green(`✓ ${r.name} ${n2(from)}..${n2(to)} recomputed from proven inputs. Trusted: only the checkpoint (Stacks ${stacks}, Bitcoin ${n2(cp.bitcoin.height)}).`));
204374
204378
  writeData(dim(` unproven, so not compared: ${[...r.unproven, "rows compare declared columns and _block_height only"].join("; ")}`));
204375
204379
  return VERIFY_EXIT.CLEAN;
@@ -206802,7 +206806,7 @@ import { createHash as createHash5 } from "node:crypto";
206802
206806
  import { mkdir as mkdir3, open as open2, rename as rename2 } from "node:fs/promises";
206803
206807
  import { dirname as dirname8, isAbsolute, resolve as resolve7, sep as sep2 } from "node:path";
206804
206808
  import { createStreamsClient } from "@secondlayer/sdk";
206805
- import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
206809
+ import { RUNE_EVENT_TYPES, STREAMS_EVENT_TYPES } from "@secondlayer/shared";
206806
206810
  var VALID_TYPES = STREAMS_EVENT_TYPES;
206807
206811
  function client2() {
206808
206812
  return createStreamsClient({
@@ -206864,17 +206868,40 @@ async function downloadDumpTo(file, dest, fetchImpl, url) {
206864
206868
  await rename2(part, dest);
206865
206869
  return bytes;
206866
206870
  }
206867
- function parseTypes(value, flag = "--types") {
206871
+ function parseChain(value) {
206872
+ if (value === undefined || value === "stacks")
206873
+ return;
206874
+ if (value !== "bitcoin") {
206875
+ throw new Error(`invalid --chain "${value}"; expected stacks or bitcoin`);
206876
+ }
206877
+ return "bitcoin";
206878
+ }
206879
+ function parseTypes(value, flag = "--types", chain) {
206868
206880
  if (!value)
206869
206881
  return;
206882
+ const valid = chain === "bitcoin" ? RUNE_EVENT_TYPES : VALID_TYPES;
206870
206883
  const parts = value.split(",").map((s) => s.trim());
206871
206884
  for (const p of parts) {
206872
- if (!VALID_TYPES.includes(p)) {
206873
- throw new Error(`invalid ${flag} value "${p}"; expected one of: ${VALID_TYPES.join(", ")}`);
206885
+ if (!valid.includes(p)) {
206886
+ throw new Error(`invalid ${flag} value "${p}"; expected one of: ${valid.join(", ")}`);
206874
206887
  }
206875
206888
  }
206876
206889
  return parts;
206877
206890
  }
206891
+ function rejectStacksFilters(chain, o) {
206892
+ if (chain !== "bitcoin")
206893
+ return;
206894
+ for (const [flag, value] of [
206895
+ ["--contract-id", o.contractId],
206896
+ ["--sender", o.sender],
206897
+ ["--recipient", o.recipient]
206898
+ ]) {
206899
+ if (value !== undefined) {
206900
+ throw new Error(`${flag} is Stacks-only; drop it with --chain bitcoin`);
206901
+ }
206902
+ }
206903
+ }
206904
+ var CHAIN_HELP = "stacks (default) or bitcoin (Runes events, their own cursors)";
206878
206905
  function parseList(value) {
206879
206906
  if (value === undefined)
206880
206907
  return;
@@ -206935,16 +206962,20 @@ function registerStreamsCommand(program) {
206935
206962
  process.exit(1);
206936
206963
  }
206937
206964
  });
206938
- const events = streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--event-type <type>", "alias for a single-value --types (the Index spelling)").option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").addHelpText("after", `
206965
+ const events = streams.command("events").description("List events (cursor-paginated; one page per call)").option("--chain <chain>", CHAIN_HELP).option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")}; ${RUNE_EVENT_TYPES.join(", ")} with --chain bitcoin)`).option("--event-type <type>", "alias for a single-value --types (the Index spelling)").option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").addHelpText("after", `
206939
206966
  Examples:
206940
206967
  $ secondlayer streams events --types stx_transfer,print --limit 50
206941
206968
  $ secondlayer streams events --not-types print --contract-id SP00....token,SP01....token
206942
206969
  $ secondlayer streams events --sender SP1...,SP2... --from-block 150000 --to-block 160000
206943
- $ secondlayer streams events --cursor 150000:3`).action(async (options) => {
206970
+ $ secondlayer streams events --cursor 150000:3
206971
+ $ secondlayer streams events --chain bitcoin --types rune_mint --limit 50`).action(async (options) => {
206944
206972
  try {
206973
+ const chain = parseChain(options.chain);
206974
+ rejectStacksFilters(chain, options);
206945
206975
  const envelope = await client2().events.list({
206946
- types: parseTypes(options.types ?? options.eventType),
206947
- notTypes: parseTypes(options.notTypes, "--not-types"),
206976
+ chain,
206977
+ types: parseTypes(options.types ?? options.eventType, "--types", chain),
206978
+ notTypes: parseTypes(options.notTypes, "--not-types", chain),
206948
206979
  contractId: parseList(options.contractId),
206949
206980
  sender: parseList(options.sender),
206950
206981
  recipient: parseList(options.recipient),
@@ -206959,22 +206990,26 @@ Examples:
206959
206990
  process.exit(1);
206960
206991
  }
206961
206992
  });
206962
- events.command("by-tx <txId>").description("List all events emitted by a single transaction").option("--json", "Output as JSON (streams always emits JSON)").action(async (txId) => {
206993
+ events.command("by-tx <txId>").description("List all events emitted by a single transaction").option("--chain <chain>", CHAIN_HELP).option("--json", "Output as JSON (streams always emits JSON)").action(async (txId, _o, cmd) => {
206994
+ const options = cmd.optsWithGlobals();
206963
206995
  try {
206964
- const envelope = await client2().events.byTxId(txId);
206996
+ const chain = parseChain(options.chain);
206997
+ const envelope = chain ? await client2().events.byTxId(txId, { chain }) : await client2().events.byTxId(txId);
206965
206998
  writeData(JSON.stringify(envelope, null, 2));
206966
206999
  } catch (err) {
206967
207000
  error(err instanceof Error ? err.message : String(err));
206968
207001
  process.exit(1);
206969
207002
  }
206970
207003
  });
206971
- streams.command("consume").description("Long-running pull from a cursor; emits one event per line (jsonl) until SIGINT or --max-pages").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--batch-size <n>", "events per batch (1-1000, default 100)", "100").option("--max-pages <n>", "stop after N pages (default: run until SIGINT)").addHelpText("after", `
207004
+ streams.command("consume").description("Long-running pull from a cursor; emits one event per line (jsonl) until SIGINT or --max-pages").option("--chain <chain>", CHAIN_HELP).option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")}; ${RUNE_EVENT_TYPES.join(", ")} with --chain bitcoin)`).option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--batch-size <n>", "events per batch (1-1000, default 100)", "100").option("--max-pages <n>", "stop after N pages (default: run until SIGINT)").addHelpText("after", `
206972
207005
  Examples:
206973
207006
  $ secondlayer streams consume --types print --cursor 150000:0
206974
207007
  $ secondlayer streams consume --not-types print --sender SP1...,SP2... --batch-size 500 --max-pages 10`).action(async (options) => {
206975
207008
  try {
206976
207009
  const batchSize = parseLimit(options.batchSize) ?? 100;
206977
207010
  const maxPages = parseMaxPages(options.maxPages);
207011
+ const chain = parseChain(options.chain);
207012
+ rejectStacksFilters(chain, options);
206978
207013
  note('# streaming events to stdout (jsonl); reorgs appear inline as {"kind":"reorg"}; next_cursor printed to stderr');
206979
207014
  const handlers = consumeHandlers({
206980
207015
  stdout: (line) => process.stdout.write(`${line}
@@ -206983,9 +207018,10 @@ Examples:
206983
207018
  `)
206984
207019
  });
206985
207020
  await client2().events.consume({
207021
+ chain,
206986
207022
  fromCursor: options.cursor,
206987
- types: parseTypes(options.types),
206988
- notTypes: parseTypes(options.notTypes, "--not-types"),
207023
+ types: parseTypes(options.types, "--types", chain),
207024
+ notTypes: parseTypes(options.notTypes, "--not-types", chain),
206989
207025
  contractId: parseList(options.contractId),
206990
207026
  sender: parseList(options.sender),
206991
207027
  recipient: parseList(options.recipient),
@@ -207000,9 +207036,11 @@ Examples:
207000
207036
  process.exit(1);
207001
207037
  }
207002
207038
  });
207003
- streams.command("reorgs").description("List recent reorgs (cursor-paginated)").requiredOption("--since <cursor>", "start cursor (block_height:event_index)").option("--limit <n>", "page size (default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").action(async (options) => {
207039
+ streams.command("reorgs").description("List recent reorgs (cursor-paginated)").requiredOption("--since <cursor>", "start cursor (block_height:event_index)").option("--chain <chain>", CHAIN_HELP).option("--limit <n>", "page size (default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").action(async (options) => {
207004
207040
  try {
207041
+ const chain = parseChain(options.chain);
207005
207042
  const envelope = await client2().reorgs.list({
207043
+ ...chain && { chain },
207006
207044
  since: options.since,
207007
207045
  limit: parseLimit(options.limit)
207008
207046
  });
@@ -209466,5 +209504,5 @@ registerCreditsCommand(program);
209466
209504
  registerArchiveCommand(program);
209467
209505
  program.parse();
209468
209506
 
209469
- //# debugId=DA489CE32ABB5ED564756E2164756E21
209507
+ //# debugId=1F734CB2F24A078564756E2164756E21
209470
209508
  //# sourceMappingURL=cli.js.map