@secondlayer/cli 13.0.2 → 14.0.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 +27 -18
- package/dist/cli.js +1546 -748
- package/dist/cli.js.map +39 -38
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -14,12 +14,12 @@ secondlayer --version
|
|
|
14
14
|
|
|
15
15
|
Default API is `http://127.0.0.1:3800`. Override with `SL_API_URL`.
|
|
16
16
|
|
|
17
|
-
Writes against a published bind use `INSTANCE_TOKEN` from `secondlayer init
|
|
18
|
-
|
|
17
|
+
Writes against a published bind use `INSTANCE_TOKEN` from `secondlayer init`.
|
|
18
|
+
Loopback reads need no token. `SL_API_KEY` is a legacy alias of `INSTANCE_TOKEN`.
|
|
19
19
|
|
|
20
20
|
```bash
|
|
21
21
|
export SL_API_URL=http://127.0.0.1:3800
|
|
22
|
-
export
|
|
22
|
+
export INSTANCE_TOKEN=<from secondlayer init>
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
## Quickstart
|
|
@@ -29,16 +29,20 @@ bun add -g @secondlayer/cli
|
|
|
29
29
|
secondlayer setup
|
|
30
30
|
|
|
31
31
|
secondlayer subgraphs scaffold SP1234ABCD.my-contract -o subgraphs/my-contract.ts
|
|
32
|
+
git add subgraphs/my-contract.ts # deploy refuses an unstaged file; or pass --allow-uncommitted
|
|
32
33
|
secondlayer subgraphs deploy subgraphs/my-contract.ts --start-block <recent-block>
|
|
33
34
|
secondlayer subgraphs query my-contract <table> --sort _block_height --order desc
|
|
34
35
|
```
|
|
35
36
|
|
|
36
37
|
`secondlayer setup` is a guided wizard: it picks network + node mode (with the
|
|
37
38
|
RAM/disk floor shown live), generates secrets, writes `docker-compose.yml` and
|
|
38
|
-
`.env`
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
`.env` (including the `DATABASE_URL` every later `bootstrap`/`verify`/`repair`
|
|
40
|
+
in that directory connects with) into a target directory, brings the stack up,
|
|
41
|
+
prints the observer stanza for an external node, and restores + verifies
|
|
42
|
+
history from the archive: the one-command replacement for `init` → hand-copy
|
|
43
|
+
secrets → `docker compose up` → `observer` → `bootstrap` → `verify`. `setup`
|
|
44
|
+
is also the only way to bring the stack up: the old `secondlayer start`, which
|
|
45
|
+
printed a compose line for a monorepo checkout, is gone. Without a TTY (or
|
|
42
46
|
with `--yes`), it skips the interactive prompts and runs from flags instead;
|
|
43
47
|
`--network` and `--node-mode` are then required, and `--against` is required
|
|
44
48
|
unless you pass `--skip-bootstrap`:
|
|
@@ -61,12 +65,11 @@ No account. Writes `.env.local`, restores history, prints the Stacks observer st
|
|
|
61
65
|
| Command | What it does |
|
|
62
66
|
|---|---|
|
|
63
67
|
| `secondlayer setup [--network …] [--node-mode external\|stacks\|full] [--api-port <spec>] [--dir <path>] [--against <manifest>] [--skip-bootstrap] [--skip-verify] [--yes] [--force]` | Guided self-host onboarding — secrets, compose + `.env`, docker up, observer stanza, bootstrap, verify. TUI when interactive; flags-only (no prompts) with `--yes` or no TTY |
|
|
64
|
-
| `secondlayer init [--network mainnet\|testnet\|devnet] [--api-url <url>] [--force]` | Write `.env.local` (token, secrets key, webhook signing key). Idempotent |
|
|
65
|
-
| `secondlayer
|
|
66
|
-
| `secondlayer bootstrap --against <manifest> [--to-block <n>] [--public-key <pem>] [-y] [--json]` | Restore chain history from a verified archive into an empty database. Exit `0` restored, `1` diverged, `2` refused |
|
|
68
|
+
| `secondlayer init [--network mainnet\|testnet\|devnet] [--api-url <url>] [--force]` | Write `.env.local` (token, secrets key, webhook signing key). `--network` and `--api-url` are the global flags. Idempotent |
|
|
69
|
+
| `secondlayer bootstrap --against <manifest> [--from-block <n>] [--to-block <n>] [--verify all\|blocks] [--public-key <pem>] [-y] [--json]` | Restore chain history from a verified archive into an empty database. A run that died mid-way resumes per dataset on re-run. After the load, digests for blocks, transactions, and events are checked over the restored range (`--verify blocks` skips the child datasets and the minutes they cost). Partition fetches retry three times with backoff on resets, timeouts, 429 (honoring `Retry-After`) and 5xx; a link that stays down exits `1` with a re-run hint, and the re-run resumes. Exit `0` restored, `1` diverged or interrupted, `2` refused |
|
|
67
70
|
| `secondlayer observer [--mode indexer\|signer-shared] [--endpoint host:port] [--recovery journal\|archive] [--network …]` | Print the `[[events_observer]]` stanza. Signer-shared requires `--recovery` |
|
|
68
71
|
| `secondlayer verify [all\|raw\|decode:<name>\|subgraph:<name>] --against <manifest> [--quick\|--deep\|--anchor]` | Compare local data to a signed archive. Default target `raw`. Exit `0` clean, `1` diverged, `2` unanchored |
|
|
69
|
-
| `secondlayer repair --against <archive> [--apply] [-y]` | Plan (default) or apply an archive repair |
|
|
72
|
+
| `secondlayer repair --against <archive> [--apply] [-y]` | Plan (default) or apply an archive repair. A fixed block is rewritten with its transactions and events from the archive; when the reference has no child partition for a height, the block is rewritten alone, the height is named with a `bootstrap --from-block H --to-block H` remedy, and the exit is `1`. Partition fetches retry like `bootstrap`; a link that stays down exits `1` with a re-run hint, and heights already repaired are kept |
|
|
70
73
|
|
|
71
74
|
Bootstrap and repair against the official hosted archive (`archive.secondlayer.tools`)
|
|
72
75
|
are metered per partition; against any other manifest (a mirror, a teammate's
|
|
@@ -92,7 +95,11 @@ Against the official host, both commands quote before they charge:
|
|
|
92
95
|
3. You confirm, or pass `-y` to skip the prompt. `-y` never skips the quote
|
|
93
96
|
or the balance check: if the balance is short, the command exits before
|
|
94
97
|
any partition is fetched and prints the shortfall and
|
|
95
|
-
`secondlayer credits buy`.
|
|
98
|
+
`secondlayer credits buy`. `--json` never stands in for `-y`: without
|
|
99
|
+
`-y` it prints `{"code":"CONFIRMATION_REQUIRED","quote":…}` to stdout
|
|
100
|
+
and exits 2 so a script can read the price, then re-run with `-y`.
|
|
101
|
+
Without a TTY on stdin every confirmation exits 1 rather than letting an
|
|
102
|
+
empty pipe answer it.
|
|
96
103
|
4. Only then does the command fetch, and only the partitions it actually
|
|
97
104
|
reads are charged.
|
|
98
105
|
|
|
@@ -111,7 +118,7 @@ points at.
|
|
|
111
118
|
|---|---|
|
|
112
119
|
| `secondlayer subgraphs create <name>` | Scaffold a definition file |
|
|
113
120
|
| `secondlayer subgraphs scaffold <SP...::contract> [-o <path>] [--no-install]` | Generate a subgraph from a deployed contract |
|
|
114
|
-
| `secondlayer subgraphs deploy <file> [--start-block <n>]` | Deploy; `--start-block` overrides the definition |
|
|
121
|
+
| `secondlayer subgraphs deploy <file> [--start-block <n>] [-y] [--allow-uncommitted]` | Deploy; `--start-block` overrides the definition. The file must be staged or committed (`git add`), or pass `--allow-uncommitted` |
|
|
115
122
|
| `secondlayer subgraphs list` | List deployments (`ls` alias) |
|
|
116
123
|
| `secondlayer subgraphs dev <file>` | Watch + hot-redeploy |
|
|
117
124
|
| `secondlayer subgraphs query <name> <table>` | Query a table with filters, sort, pagination |
|
|
@@ -126,7 +133,7 @@ points at.
|
|
|
126
133
|
| Command | What it does |
|
|
127
134
|
|---|---|
|
|
128
135
|
| `secondlayer index ft-transfers` / `nft-transfers` / `events --event-type <t>` / `contract-calls` | Decoded Index layer. Anonymous reads OK |
|
|
129
|
-
| `secondlayer streams tip` / `events` / `consume` / `reorgs` / `canonical <h>` / `dumps` | Raw chain event firehose. **Requires `
|
|
136
|
+
| `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** |
|
|
130
137
|
|
|
131
138
|
Reads emit JSON to stdout (`--json` accepted across all read commands); `-o/--output` is a file path, not a format.
|
|
132
139
|
|
|
@@ -134,7 +141,7 @@ Reads emit JSON to stdout (`--json` accepted across all read commands); `-o/--ou
|
|
|
134
141
|
|
|
135
142
|
| Command | What it does |
|
|
136
143
|
|---|---|
|
|
137
|
-
| `secondlayer subscriptions create <name> --subgraph <name> --table <name> [--runtime <inngest\|trigger\|cloudflare\|node>] [--url <url>]` | Subgraph subscription (optional local receiver scaffold) |
|
|
144
|
+
| `secondlayer subscriptions create <name> --subgraph <name> --table <name> [--runtime <inngest\|trigger\|cloudflare\|node>] [--url <url>]` | Subgraph subscription (optional local receiver scaffold). Runtime defaults to `node` once any of `-s/-t/-u` or `--no-scaffold` is given; the menu only appears in a terminal with no flags |
|
|
138
145
|
| `secondlayer subscriptions create <name> --url <url> --trigger '<json>'` | Chain subscription (repeat `--trigger` or pass `--triggers-file`) |
|
|
139
146
|
| `secondlayer subscriptions list` / `get <id\|name>` | List or show config + delivery state |
|
|
140
147
|
| `secondlayer subscriptions update <id\|name> --url <url> [--filter key.gte=value]` | Patch URL, filter, format, retry, etc. |
|
|
@@ -146,7 +153,7 @@ Reads emit JSON to stdout (`--json` accepted across all read commands); `-o/--ou
|
|
|
146
153
|
| `secondlayer subscriptions doctor/test <id\|name>` | Health check / signed fixture |
|
|
147
154
|
|
|
148
155
|
Read/action commands support `--json`. Destructive commands prompt unless
|
|
149
|
-
`-y` / `--yes
|
|
156
|
+
`-y` / `--yes`, default to no, and exit 1 when stdin is not a TTY. Filters are schema-aware: unknown tables/columns, bad operators,
|
|
150
157
|
and non-scalar columns are rejected before the API call.
|
|
151
158
|
|
|
152
159
|
Subscriptions are **subgraph** (a table's rows) or **chain** (raw events, no
|
|
@@ -168,10 +175,12 @@ operates on both kinds.
|
|
|
168
175
|
|
|
169
176
|
| Var | Purpose |
|
|
170
177
|
|---|---|
|
|
171
|
-
| `
|
|
178
|
+
| `INSTANCE_TOKEN` | From `secondlayer init` for writes. Loopback reads need no token |
|
|
179
|
+
| `SL_API_KEY` | Legacy alias of `INSTANCE_TOKEN` |
|
|
172
180
|
| `SL_API_URL` | Instance API. Default `http://127.0.0.1:3800` |
|
|
173
181
|
| `SL_PLATFORM_API_URL` | Alias of `SL_API_URL` |
|
|
174
|
-
| `STACKS_NETWORK` | Default network (also via `--network <
|
|
182
|
+
| `STACKS_NETWORK` | Default network (also via `--network <mainnet\|testnet\|devnet>`) |
|
|
183
|
+
| `DATABASE_URL` | Postgres that `bootstrap`, `verify`, `repair`, and `backup` connect to. `secondlayer setup` writes it into `.env` pointing at the compose Postgres; unset, the shared dev URL `postgres://postgres:postgres@localhost:5432/secondlayer_dev` is used |
|
|
175
184
|
| `HIRO_API_KEY` | Used by `secondlayer codegen contracts` for remote contract fetches |
|
|
176
185
|
|
|
177
186
|
## Code generation (`secondlayer codegen contracts`)
|