@saga-sync/client 0.1.3 → 0.2.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 ADDED
@@ -0,0 +1,248 @@
1
+ # @saga-sync/client
2
+
3
+ The consumer side of **saga-sync** — the reference implementation of
4
+ [privacy-protocol-state-distribution](../../README.md). Given a manifest URL it
5
+ reconstructs a privacy protocol's event history by downloading the published
6
+ static files and **verifying every one** against the manifest — no trust in the
7
+ publisher beyond the manifest itself (and, optionally, its signature).
8
+
9
+ Install just this package to consume published state — it pulls in
10
+ [`@saga-sync/core`](../core) and `@noble/*`, and **nothing else**: no viem, no
11
+ `@google-cloud/storage`, no scraper.
12
+
13
+ ```bash
14
+ npm install @saga-sync/client
15
+ ```
16
+
17
+ Ships a library (`@saga-sync/client`) and a CLI (`state-client`). The library
18
+ entry is **browser-safe** — gzip via the web-standard `DecompressionStream`,
19
+ `Uint8Array` + `TextDecoder` instead of `Buffer`, no `node:` imports (a guard test
20
+ enforces it). The CLI and the optional disk cache are Node-only.
21
+
22
+ ## Quick start (library)
23
+
24
+ ```ts
25
+ import { Client, HttpStore } from "@saga-sync/client";
26
+
27
+ // `source` is the Store the manifest + chunks live behind (a CDN/bucket URL).
28
+ const client = new Client({ source: new HttpStore("https://cdn.example/pp-state/") });
29
+
30
+ // List what's published.
31
+ for (const id of await client.listProtocols()) console.log(id);
32
+
33
+ // Stream one protocol's full event history in block order.
34
+ for await (const event of client.streamEvents("tornado-cash-1-eth-0.1")) {
35
+ // event: CanonicalRecord — for a log stream, a CanonicalEvent:
36
+ // { contractAddress, eventTopic, topics, data, blockNumber, logIndex }
37
+ handle(event);
38
+ }
39
+ ```
40
+
41
+ `streamEvents` returns an **`AsyncGenerator<CanonicalRecord>`**, not an array — you
42
+ consume it once with `for await`. That's a deliberate memory choice: events are
43
+ produced lazily and peak memory is bounded to roughly one decompressed chunk
44
+ (~10 MiB) × the fetch concurrency, **independent of total history size**, so you
45
+ can process a stream larger than RAM. It also means an early `break` never
46
+ downloads or verifies the chunks you didn't reach, and you start processing the
47
+ first chunk while later ones are still downloading. If you genuinely want the whole
48
+ array, collect it yourself:
49
+
50
+ ```ts
51
+ const all: CanonicalRecord[] = [];
52
+ for await (const e of client.streamEvents(id)) all.push(e);
53
+ ```
54
+
55
+ ### Filtering
56
+
57
+ `streamEvents(id, opts)` accepts:
58
+
59
+ - **`from` / `to`** — restrict to a block range (`[from, to)`); only overlapping
60
+ chunks are fetched.
61
+ - **`addresses`** — keep only events from these contract addresses.
62
+ - **`eventTopics`** — keep only these event `topic0`s (event types).
63
+
64
+ `addresses`/`eventTopics` are validated against the manifest's `trackedAddresses` /
65
+ `trackedEventTopics` and **throw** if you ask for something the stream doesn't track
66
+ — a mismatched filter is a bug, not a silently-empty result.
67
+
68
+ ```ts
69
+ for await (const e of client.streamEvents(id, {
70
+ from: "0x8b1d26",
71
+ eventTopics: ["0xa945e51e…"], // Deposit only
72
+ })) { … }
73
+ ```
74
+
75
+ ### Selecting a stream by address
76
+
77
+ Don't know (or want to hardcode) the stream id? Pass a **selector** — a contract
78
+ address, optionally with a chain-id guard — instead of an id. The client resolves
79
+ it against the manifest's `trackedAddresses` (and `chainId`) to exactly one stream
80
+ and streams it, implicitly filtered to that address:
81
+
82
+ ```ts
83
+ for await (const e of client.streamEvents({ address: "0x12d66f87…", chainId: "0x1" })) {
84
+ handle(e);
85
+ }
86
+
87
+ // Or resolve without streaming:
88
+ const id = await client.resolveProtocolId({ address: "0x12d66f87…" });
89
+ ```
90
+
91
+ `chainId` is optional. A manifest is single-chain in practice (mainnet and Sepolia
92
+ are separate buckets), so it mostly guards against pointing at the wrong one.
93
+ Resolution **throws** if the address matches no stream, or more than one — a
94
+ selector must name exactly one stream (pass an explicit id to disambiguate).
95
+ Combining a selector with `opts.addresses` also throws (the address is the
96
+ selector).
97
+
98
+ ## Verification model
99
+
100
+ Everything the client serves is verified — **cache hits included**:
101
+
102
+ - **`verifyDigest(meta, bytes)`** recomputes the sha256 of a chunk's uncompressed
103
+ JSONL and compares it to the manifest entry; a mismatch throws
104
+ `DigestMismatchError`.
105
+ - **`verifyChunkEvents(meta, events)`** then enforces the canonical form the digest
106
+ can't catch on its own — every record within the chunk's `[from, to)` range,
107
+ strictly ascending (logs by `(blockNumber, logIndex)`, entity records by
108
+ `(blockNumber, transactionIndex, opIndex)`), and no chunk mixing the two kinds;
109
+ violations throw `CanonicalFormError`.
110
+ - A missing file throws `ChunkNotFoundError`, kept distinct from a digest mismatch
111
+ so callers can tell "absent" from "tampered".
112
+
113
+ ### Manifest signatures (optional)
114
+
115
+ Supply a publisher public key and the client fetches the manifest's signature
116
+ (`index.json.sigs`, falling back to the legacy `index.json.sig`) and verifies it
117
+ **over the raw `index.json` bytes before parsing** — mandatory once enabled
118
+ (missing or mismatched signature throws). Because the manifest holds every chunk's
119
+ digest, one signature transitively authenticates the whole dataset.
120
+
121
+ ```ts
122
+ const client = new Client({ source: new HttpStore(baseUrl), publicKey: "0x…" });
123
+ ```
124
+
125
+ A manifest may carry several signatures, one per algorithm. Pass one key or
126
+ several; each key's algorithm is inferred from its length (32 bytes → Ed25519,
127
+ 33 or 65 → secp256k1), and verification passes if **any** of them verifies:
128
+
129
+ ```ts
130
+ const client = new Client({ source, publicKey: ["0x…ed25519", "0x…secp256k1"] });
131
+ ```
132
+
133
+ Two things worth knowing before pinning more than one key:
134
+
135
+ - Any single valid signature accepts the manifest, so the trust root is only as
136
+ strong as the **weakest** key you pin. More algorithms mean more reach, not
137
+ more security.
138
+ - secp256k1 is **not** bundled by default — it would grow this library by about a
139
+ third. Enable it with a side-effect import:
140
+
141
+ ```ts
142
+ import "@saga-sync/core/secp256k1";
143
+ ```
144
+
145
+ The `state-client` CLI does this already.
146
+
147
+ ### Logs and entity records
148
+
149
+ `streamEvents` yields **`CanonicalRecord`**, which is either a log (the six-field
150
+ shape every stream has always had) or an **entity record** — something an indexer
151
+ derived from data no log carries, such as Railgun's per-transaction operations.
152
+ Narrow with `isEntityRecord`:
153
+
154
+ ```ts
155
+ import { isEntityRecord } from "@saga-sync/core";
156
+
157
+ for await (const record of client.streamEvents(id)) {
158
+ if (isEntityRecord(record)) handleEntity(record); // entity, blockNumber, transactionIndex, opIndex, …
159
+ else handleLog(record); // contractAddress, eventTopic, topics, data, …
160
+ }
161
+ ```
162
+
163
+ A stream carries **one kind**, never a mix — the client rejects a chunk that
164
+ interleaves them. So in practice you know which you are getting from the stream id,
165
+ and the check above is a type-level narrowing rather than a per-record branch. The
166
+ manifest's `protocolMetadata.source` tells you the provenance: absent or `"rpc"`
167
+ means chain-derived and independently checkable; anything else means the records
168
+ were mirrored from that source and are only as good as it is.
169
+
170
+ ## Library API
171
+
172
+ - **`Client`** — `streamEvents(target, opts?)` (merged sealed chunks then the hot
173
+ head, sealed fetched with a bounded-concurrency sliding window and optionally
174
+ cached to a local `Store`). `target` is a protocol id **or** a
175
+ `{ address, chainId? }` selector. `resolveProtocolId(selector)` resolves a
176
+ selector to an id without streaming; `listProtocols(prefix?)` enumerates ids;
177
+ plus manifest inspection helpers.
178
+ - **`loadManifest(store, key, { publicKey? })`** — one fetch; verifies the signature
179
+ when a key is supplied. Re-uses core's `Manifest` so the shape is defined once.
180
+ - **`decodeAndVerify` / `fetchChunkFrom(store, meta)`** — the fetch→gunzip→verify→
181
+ parse→verify-canonical pipeline for a single chunk.
182
+ - **`verifyDigest` / `verifyChunkEvents`** and the error types above.
183
+
184
+ Reads go through core's `Store` seam (`HttpStore` for the network, an optional
185
+ local cache `Store`). Sealed chunks are safe to cache — immutable, content-
186
+ addressed, and re-verified on every read; the hot head is re-fetched every call and
187
+ never cached.
188
+
189
+ ## CLI (`state-client`)
190
+
191
+ Subcommands take a `<manifest-url>` (the manifest is read from `<url>/index.json`);
192
+ the query commands fetch **only** the manifest — no chunk downloads.
193
+
194
+ ```
195
+ state-client <command> <manifest-url> [<protocol-id>] [options]
196
+
197
+ protocols <url> list every protocol + summary (alias: ls)
198
+ info <url> <id> range, size, metadata, hot head, gap/contiguity check
199
+ head <url> <id> latest covered block (alias: latest)
200
+ chunks <url> <id> list a protocol's chunks
201
+ stream <url> [<id>] download + verify + emit NDJSON
202
+
203
+ --json machine-readable output instead of human tables
204
+ --from-block <hex> info/chunks/stream: lower bound of the block range
205
+ --to-block <hex> info/chunks/stream: upper bound (exclusive)
206
+ --address <hex> stream: with an <id>, a repeatable post-decode filter;
207
+ without an <id>, a single --address selects the stream
208
+ --chain <hex> stream: chain-id guard when selecting a stream by --address
209
+ --event-topic <hex> stream: keep only these event topic0s (repeatable)
210
+ --since-block <hex> head: exit 3 if no block beyond this is covered
211
+ --hot chunks: include the mutable hot head
212
+ --cache-dir <path> stream: local cache of verified sealed chunks
213
+ --concurrency <n> stream: parallel chunk fetches (default 4)
214
+ --public-key <hex> require + verify the manifest's signature (repeatable;
215
+ Ed25519 or secp256k1, inferred from the key length)
216
+ ```
217
+
218
+ Stream by address instead of naming the id:
219
+
220
+ ```bash
221
+ state-client stream https://cdn.example/pp-state/ --address 0x12d66f87… --chain 0x1
222
+ ```
223
+
224
+ `stream` emits NDJSON on stdout + a summary on stderr; the query commands print a
225
+ human table or, with `--json`, structured JSON. `--public-key` applies to all
226
+ commands and verifies the manifest's signature before trusting it; pass it more
227
+ than once to accept any of several keys.
228
+
229
+ Exit codes: `0` ok · `1` usage / fetch / not-found · `3` `head --since-block` found
230
+ nothing newer.
231
+
232
+ ```bash
233
+ # serve some published chunks, then:
234
+ node packages/client/dist/cli.js info http://localhost:8080/ tornado-cash-1-eth-0.1
235
+ node packages/client/dist/cli.js stream http://localhost:8080/ tornado-cash-1-eth-0.1 \
236
+ --cache-dir ./client-cache > events.ndjson
237
+ ```
238
+
239
+ ## Modules
240
+
241
+ - **`verify.ts`** — `verifyDigest` + `verifyChunkEvents` (both mandatory on every chunk).
242
+ - **`fetch.ts`** — `decodeAndVerify` + `fetchChunkFrom`; the per-chunk pipeline.
243
+ - **`manifest.ts`** — `loadManifest` + pure `selectSealedChunks` / `selectHotHead`
244
+ range-overlap helpers + signature check.
245
+ - **`client.ts`** — the `Client` class and the merged streaming logic.
246
+ - **`format.ts`** — `humanBytes` + `table`, the CLI's rendering helpers.
247
+ - **`cli.ts`** — the `state-client` entry point.
248
+ - **`index.ts`** — the browser-safe library barrel.
package/dist/cli.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import "@saga-sync/core/secp256k1";
2
3
  import { Client } from "./client.js";
3
4
  type Range = {
4
5
  fromBlock?: bigint;
package/dist/cli.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAQA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAyDrC,KAAK,KAAK,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAKtD,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B3F;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,GAC9B,OAAO,CAAC,MAAM,CAAC,CA2CjB;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CA6B3C;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,GAC5C,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAUA,OAAO,2BAA2B,CAAC;AAEnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAoErC,KAAK,KAAK,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAKtD,wBAAsB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CA0B3F;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,GAC9B,OAAO,CAAC,MAAM,CAAC,CAuDjB;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC3C,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,CA6B3C;AAED,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,MAAM,EACV,IAAI,EAAE;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,OAAO,CAAA;CAAE,GAAG,KAAK,GAC5C,OAAO,CAAC,MAAM,CAAC,CAoBjB"}
package/dist/cli.js CHANGED
@@ -5,6 +5,10 @@ import { resolve } from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { HttpStore } from "@saga-sync/core";
7
7
  import { DiskStore } from "@saga-sync/core/node";
8
+ // Registers secp256k1 so `--public-key` accepts one without further ceremony.
9
+ // The CLI is Node-only, so the extra curve costs nothing here; the browser
10
+ // library entry (index.ts) deliberately does NOT import this.
11
+ import "@saga-sync/core/secp256k1";
8
12
  import { Client } from "./client.js";
9
13
  import { selectSealedChunks, selectHotHead } from "./manifest.js";
10
14
  import { humanBytes, table } from "./format.js";
@@ -24,20 +28,30 @@ Commands:
24
28
  info <manifest-url> <protocol-id> detailed summary for one protocol
25
29
  head <manifest-url> <protocol-id> latest covered block / freshness (alias: latest)
26
30
  chunks <manifest-url> <protocol-id> list this protocol's chunks
27
- stream <manifest-url> <protocol-id> download + verify + emit NDJSON
31
+ stream <manifest-url> [<protocol-id>] download + verify + emit NDJSON
28
32
 
29
33
  The manifest is read from <manifest-url>/index.json. The query commands
30
34
  (protocols/info/head/chunks) fetch only the manifest — no chunk downloads.
35
+ For stream, omit <protocol-id> and pass a single --address (optionally --chain)
36
+ to select the stream by contract address instead of its id.
31
37
 
32
38
  Options:
33
39
  --json machine-readable output instead of human tables
34
40
  --from-block <hex> info/chunks/stream: lower bound of the block range
35
41
  --to-block <hex> info/chunks/stream: upper bound (exclusive)
42
+ --address <0xhex> stream: only emit events from this contract address
43
+ (repeatable filter with a <protocol-id>; or, without an
44
+ id, a single --address selects the stream)
45
+ --chain <0xhex> stream: chain-id guard when selecting a stream by --address
46
+ --event-topic <0xhex> stream: only emit events with this topic0 / event type
47
+ (repeatable; must be one the stream tracks)
36
48
  --since-block <hex> head: exit 3 if no block beyond this is covered
37
49
  --hot chunks: include the mutable hot head
38
50
  --cache-dir <path> stream: local cache of verified sealed chunks
39
51
  --concurrency <n> stream: parallel chunk fetches, default ${DEFAULT_CONCURRENCY}
40
- --public-key <hex> require + verify the manifest's Ed25519 signature
52
+ --public-key <hex> require + verify the manifest's signature (repeatable;
53
+ Ed25519 or secp256k1, inferred from the key length —
54
+ any one matching key accepts the manifest)
41
55
  --help show this message
42
56
 
43
57
  Exit codes: 0 ok · 1 usage/fetch/not-found · 3 head --since-block found nothing newer
@@ -98,6 +112,11 @@ export async function cmdInfo(client, id, opts) {
98
112
  if (opts.json) {
99
113
  return JSON.stringify({
100
114
  protocolId: id,
115
+ protocol: manifest.protocolName(id) ?? null,
116
+ protocolMetadata: manifest.protocolMetadata(id) ?? null,
117
+ chainId: manifest.chainId(id) ?? null,
118
+ trackedAddresses: manifest.trackedAddresses(id) ?? [],
119
+ trackedEventTopics: manifest.trackedEventTopics(id) ?? [],
101
120
  manifestVersion: manifest.version(),
102
121
  updatedAt: manifest.updatedAt() ?? null,
103
122
  fromBlock: hexOrNull(first),
@@ -109,8 +128,15 @@ export async function cmdInfo(client, id, opts) {
109
128
  }, null, 2);
110
129
  }
111
130
  const ranged = opts.fromBlock !== undefined || opts.toBlock !== undefined;
131
+ const meta = manifest.protocolMetadata(id);
132
+ const tracked = manifest.trackedAddresses(id) ?? [];
133
+ const topics = manifest.trackedEventTopics(id) ?? [];
112
134
  return [
113
135
  `protocol: ${id}`,
136
+ `type: ${manifest.protocolName(id) ?? "-"}${manifest.chainId(id) ? ` (chain ${manifest.chainId(id)})` : ""}`,
137
+ ...(meta && Object.keys(meta).length ? [`metadata: ${JSON.stringify(meta)}`] : []),
138
+ ...(tracked.length ? [`tracked addrs: ${tracked.join(", ")}`] : []),
139
+ ...(topics.length ? [`tracked topics: ${topics.join(", ")}`] : []),
114
140
  `manifest: v${manifest.version()}${manifest.updatedAt() ? `, updated ${manifest.updatedAt()}` : ""}`,
115
141
  `block range: ${hexOrNull(first) ?? "-"} → ${hexOrNull(last) ?? "-"}`,
116
142
  `sealed chunks: ${sealed.length}`,
@@ -167,7 +193,7 @@ export async function cmdChunks(client, id, opts) {
167
193
  c.digest.data,
168
194
  ]));
169
195
  }
170
- async function runStream(manifestUrl, id, opts) {
196
+ async function runStream(manifestUrl, target, opts) {
171
197
  const source = new HttpStore(manifestUrl);
172
198
  const cache = opts.cacheDir ? new DiskStore(opts.cacheDir) : undefined;
173
199
  const client = new Client({
@@ -176,10 +202,13 @@ async function runStream(manifestUrl, id, opts) {
176
202
  concurrency: opts.concurrency,
177
203
  publicKey: opts.publicKey,
178
204
  });
205
+ const label = typeof target === "string" ? target : target.address;
179
206
  let count = 0;
180
- for await (const event of client.streamEvents(id, {
207
+ for await (const event of client.streamEvents(target, {
181
208
  fromBlock: opts.fromBlock,
182
209
  toBlock: opts.toBlock,
210
+ ...(opts.addresses ? { addresses: opts.addresses } : {}),
211
+ ...(opts.eventTopics ? { eventTopics: opts.eventTopics } : {}),
183
212
  })) {
184
213
  process.stdout.write(JSON.stringify(event) + "\n");
185
214
  count++;
@@ -188,7 +217,7 @@ async function runStream(manifestUrl, id, opts) {
188
217
  ? ` in [${opts.fromBlock !== undefined ? numberToHex(opts.fromBlock) : "*"},` +
189
218
  `${opts.toBlock !== undefined ? numberToHex(opts.toBlock) : "*"})`
190
219
  : "";
191
- process.stderr.write(`state-client: ${count} event(s) for ${id}${range}` +
220
+ process.stderr.write(`state-client: ${count} event(s) for ${label}${range}` +
192
221
  (opts.cacheDir ? ` (cache=${opts.cacheDir})` : "") +
193
222
  `\n`);
194
223
  }
@@ -204,7 +233,10 @@ async function main() {
204
233
  "since-block": { type: "string" },
205
234
  hot: { type: "boolean", default: false },
206
235
  concurrency: { type: "string" },
207
- "public-key": { type: "string" },
236
+ "public-key": { type: "string", multiple: true },
237
+ address: { type: "string", multiple: true },
238
+ "event-topic": { type: "string", multiple: true },
239
+ chain: { type: "string" },
208
240
  },
209
241
  });
210
242
  if (values.help || positionals.length === 0) {
@@ -252,10 +284,32 @@ async function main() {
252
284
  if (!Number.isInteger(concurrency) || concurrency < 1) {
253
285
  fail(`--concurrency must be a positive integer; got ${values.concurrency}`);
254
286
  }
255
- await runStream(manifestUrl, needId(), {
287
+ const addresses = values.address;
288
+ const id = positionals[2];
289
+ let target;
290
+ if (id) {
291
+ target = id;
292
+ }
293
+ else {
294
+ // No protocol id → select the stream by exactly one --address (with an
295
+ // optional --chain guard). The address doubles as the post-decode filter.
296
+ if (!addresses || addresses.length !== 1) {
297
+ fail(`stream needs a <protocol-id>, or exactly one --address ` +
298
+ `(with optional --chain) to select a stream\n\n${USAGE}`);
299
+ }
300
+ target = {
301
+ address: addresses[0],
302
+ ...(values.chain ? { chainId: values.chain } : {}),
303
+ };
304
+ }
305
+ await runStream(manifestUrl, target, {
256
306
  cacheDir: values["cache-dir"] ? resolve(values["cache-dir"]) : undefined,
257
307
  concurrency,
258
308
  publicKey,
309
+ // Pass --address as a post-decode filter only when a protocol id was
310
+ // named; with a selector the address is the selector, not opts.addresses.
311
+ ...(id && addresses ? { addresses } : {}),
312
+ ...(values["event-topic"] ? { eventTopics: values["event-topic"] } : {}),
259
313
  ...range,
260
314
  });
261
315
  return;
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,kFAAkF;AAClF,mFAAmF;AACnF,SAAS,WAAW,CAAC,KAAsB;IACzC,OAAO,KAAK,KAAK,CAAC,QAAQ,CAAC,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0EAA0E;gBAC1E,GAAG,CAAC,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzC,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,aAAa,CAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACjF,GAAG,KAAK;aACT,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD;YACE,IAAI,CAAC,oBAAoB,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC;AAED,SAAS,YAAY;IACnB,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,YAAY,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,YAAY,EAAE,EAAE,CAAC;IACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;QAC5B,IAAI,CAAC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import type { CanonicalEvent } from "@saga-sync/core";
1
+ import type { CanonicalRecord } from "@saga-sync/core";
2
+ import type { Hex } from "@saga-sync/core";
2
3
  import type { Store } from "@saga-sync/core";
3
4
  import type { ChunkMeta } from "@saga-sync/core";
4
5
  import { Manifest } from "@saga-sync/core";
@@ -6,12 +7,19 @@ export type ClientOptions = {
6
7
  source: Store;
7
8
  cache?: Store;
8
9
  concurrency?: number;
9
- publicKey?: string;
10
+ publicKey?: string | string[];
10
11
  };
11
12
  export type StreamOptions = {
12
13
  fromBlock?: bigint;
13
14
  toBlock?: bigint;
15
+ addresses?: Hex[];
16
+ eventTopics?: Hex[];
14
17
  };
18
+ export type ProtocolSelector = {
19
+ address: Hex;
20
+ chainId?: Hex;
21
+ };
22
+ export type StreamTarget = string | ProtocolSelector;
15
23
  export declare class Client {
16
24
  private readonly source;
17
25
  private readonly cache;
@@ -21,9 +29,10 @@ export declare class Client {
21
29
  fetchManifest(key?: string): Promise<Manifest>;
22
30
  fetchChunk(meta: ChunkMeta, opts?: {
23
31
  hot?: boolean;
24
- }): Promise<CanonicalEvent[]>;
32
+ }): Promise<CanonicalRecord[]>;
25
33
  listProtocols(prefix?: string): Promise<string[]>;
26
- streamEvents(protocolId: string, opts?: StreamOptions): AsyncGenerator<CanonicalEvent, void, void>;
34
+ resolveProtocolId(selector: ProtocolSelector): Promise<string>;
35
+ streamEvents(target: StreamTarget, opts?: StreamOptions): AsyncGenerator<CanonicalRecord, void, void>;
27
36
  private fetchSealed;
28
37
  private fetchSealedOrdered;
29
38
  }
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAI3C,MAAM,MAAM,aAAa,GAAG;IAG1B,MAAM,EAAE,KAAK,CAAC;IAKd,KAAK,CAAC,EAAE,KAAK,CAAC;IAGd,WAAW,CAAC,EAAE,MAAM,CAAC;IAGrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,CAAC,EAAE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Verify, fetchChunkFrom, ChunkNotFoundError } from "./fetch.js";
2
3
  import { loadManifest, selectSealedChunks, selectHotHead } from "./manifest.js";
3
4
  const DEFAULT_CONCURRENCY = 4;
@@ -38,21 +39,45 @@ export class Client {
38
39
  const ids = (await this.fetchManifest()).protocolIds();
39
40
  return (prefix === undefined ? ids : ids.filter((id) => matchesFamily(id, prefix))).sort();
40
41
  }
42
+ // Resolve an address selector to exactly one stream id (or throw if none / more
43
+ // than one match). Exposed so a caller can resolve without streaming.
44
+ async resolveProtocolId(selector) {
45
+ return resolveOne(await this.fetchManifest(), selector);
46
+ }
41
47
  // Layer 3: merged event stream for a protocol. Yields events in block order
42
48
  // across all sealed chunks in the optional [fromBlock, toBlock) window,
43
- // then the hot head (re-fetched every call, never cached).
44
- async *streamEvents(protocolId, opts = {}) {
49
+ // then the hot head (re-fetched every call, never cached). `target` is either
50
+ // a protocol id or an address selector; a selector resolves to one stream and
51
+ // implicitly filters to that address.
52
+ async *streamEvents(target, opts = {}) {
45
53
  const manifest = await this.fetchManifest();
46
- const sealed = selectSealedChunks(manifest.sealedChunks(protocolId), opts);
47
- const hot = selectHotHead(manifest.hotHead(protocolId), opts);
54
+ let protocolId;
55
+ let effectiveOpts = opts;
56
+ if (typeof target === "string") {
57
+ protocolId = target;
58
+ }
59
+ else {
60
+ if (opts.addresses !== undefined) {
61
+ throw new Error("streamEvents: pass the address via the selector, not opts.addresses");
62
+ }
63
+ protocolId = resolveOne(manifest, target);
64
+ effectiveOpts = { ...opts, addresses: [target.address] };
65
+ }
66
+ const sealed = selectSealedChunks(manifest.sealedChunks(protocolId), effectiveOpts);
67
+ const hot = selectHotHead(manifest.hotHead(protocolId), effectiveOpts);
68
+ const keepAddress = buildSetFilter(protocolId, effectiveOpts.addresses, manifest.trackedAddresses(protocolId), "address(es)", (e) => e.contractAddress);
69
+ const keepTopic = buildSetFilter(protocolId, effectiveOpts.eventTopics, manifest.trackedEventTopics(protocolId), "event topic(s)", (e) => e.eventTopic);
70
+ const keep = (e) => keepAddress(e) && keepTopic(e);
48
71
  for await (const events of this.fetchSealedOrdered(sealed)) {
49
72
  for (const event of events)
50
- yield event;
73
+ if (keep(event))
74
+ yield event;
51
75
  }
52
76
  if (hot) {
53
77
  const events = await fetchChunkFrom(this.source, hot);
54
78
  for (const event of events)
55
- yield event;
79
+ if (keep(event))
80
+ yield event;
56
81
  }
57
82
  }
58
83
  // Cache-aware sealed fetch: check cache → on miss, fetch from source, verify,
@@ -97,4 +122,62 @@ export class Client {
97
122
  function matchesFamily(id, prefix) {
98
123
  return id === prefix || id.startsWith(`${prefix}-`);
99
124
  }
125
+ // Resolve an address selector against a manifest to exactly one protocol id.
126
+ // Matches on `trackedAddresses` (case-insensitive) and, when given, `chainId`
127
+ // (compared numerically). Throws on zero or multiple matches — a selector must
128
+ // name one stream.
129
+ function resolveOne(manifest, selector) {
130
+ const addr = selector.address.toLowerCase();
131
+ const matches = manifest.protocolIds().filter((id) => {
132
+ const addrs = manifest.trackedAddresses(id);
133
+ if (!addrs?.some((a) => a.toLowerCase() === addr))
134
+ return false;
135
+ if (selector.chainId === undefined)
136
+ return true;
137
+ const cid = manifest.chainId(id);
138
+ return cid !== undefined && sameQuantity(cid, selector.chainId);
139
+ });
140
+ const on = selector.chainId ? ` on chain ${selector.chainId}` : "";
141
+ if (matches.length === 0) {
142
+ throw new Error(`streamEvents: no stream tracks address ${selector.address}${on} in this manifest`);
143
+ }
144
+ if (matches.length > 1) {
145
+ throw new Error(`streamEvents: address ${selector.address}${on} matches multiple streams ` +
146
+ `(${matches.join(", ")}); pass a protocol id to disambiguate`);
147
+ }
148
+ return matches[0];
149
+ }
150
+ // Compare two 0x-hex quantities numerically ("0x1" == "0x01"), falling back to
151
+ // a case-insensitive string match if either is not a valid quantity.
152
+ function sameQuantity(a, b) {
153
+ try {
154
+ return BigInt(a) === BigInt(b);
155
+ }
156
+ catch {
157
+ return a.toLowerCase() === b.toLowerCase();
158
+ }
159
+ }
160
+ // Build a per-event predicate for streamEvents' `addresses`/`eventTopics`
161
+ // filters. No `requested` → keep everything. Otherwise match (case-insensitively)
162
+ // on the field `pick` returns, after asserting every requested value is one the
163
+ // stream actually tracks — a typo'd or wrong-stream value fails loudly instead
164
+ // of silently yielding nothing. `tracked` is the manifest's advertised set (may
165
+ // be undefined on a pre-metadata manifest, in which case the guard is skipped).
166
+ function buildSetFilter(protocolId, requested, tracked, label, pick) {
167
+ if (requested === undefined)
168
+ return () => true;
169
+ const want = new Set(requested.map((v) => v.toLowerCase()));
170
+ if (tracked) {
171
+ const trackedSet = new Set(tracked.map((v) => v.toLowerCase()));
172
+ const unknown = [...want].filter((v) => !trackedSet.has(v));
173
+ if (unknown.length > 0) {
174
+ throw new Error(`stream "${protocolId}" does not track ${label}: ${unknown.join(", ")}. ` +
175
+ `Tracked: ${tracked.join(", ")}`);
176
+ }
177
+ }
178
+ // Entity records have no contract address or topic; a filter on either simply
179
+ // cannot match one. Excluding them is the honest answer — the alternative is
180
+ // throwing on a field they never had.
181
+ return (event) => !isEntityRecord(event) && want.has(pick(event).toLowerCase());
182
+ }
100
183
  //# sourceMappingURL=client.js.map