@effectstream/sync 0.100.14 → 0.100.15

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,68 @@
1
+ # @effectstream/sync
2
+
3
+ The blockchain-sync service inside an EffectStream node. Reads finalized
4
+ blocks from every chain you've configured (EVM, Bitcoin, Cardano, Midnight,
5
+ Avail, Celestia, NEAR…), normalizes them into a single rollup ordering,
6
+ and stages the inputs the state machine consumes.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ bun add @effectstream/sync
12
+ # or
13
+ npm install @effectstream/sync
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ This package pairs with [`@effectstream/runtime`](https://www.npmjs.com/package/@effectstream/runtime),
19
+ which boots sync as part of `start()`: it calls `genSyncProtocols(...)`
20
+ against the `syncProtocols` section of your
21
+ [`@effectstream/config`](https://www.npmjs.com/package/@effectstream/config),
22
+ then drives the resulting fetcher + state pairs every block. As an app
23
+ author you declare which protocols to sync in your config; everything
24
+ else runs automatically.
25
+
26
+ If you're building a new chain integration, implement the sync-protocol
27
+ interfaces in [`src/sync-protocols/`](https://github.com/PaimaStudios/paima-engine/tree/main/packages/node-sdk/sync/src/sync-protocols).
28
+
29
+ ## Inside EffectStream
30
+
31
+ `genSyncProtocols(config)` is what the runtime calls during boot. It walks
32
+ the `syncProtocols` section of your `@effectstream/config`, instantiates a
33
+ fetcher for each chain (viem for EVM, UTXORpc for Cardano, the Midnight
34
+ SDK for Midnight, etc.), and writes paginated blocks into PostgreSQL
35
+ through `@effectstream/db`. The state machine then drains that queue.
36
+
37
+ ```typescript
38
+ import { genSyncProtocols } from "@effectstream/sync";
39
+ // inside the runtime startup path:
40
+ const protocols = await genSyncProtocols(config);
41
+ // protocols.parallelEvmRPC_fast.runOne() // poll one block
42
+ ```
43
+
44
+ ## Key exports
45
+
46
+ - `genSyncProtocols(dbConn, syncInfo)` — Effection generator that instantiates a runtime fetcher + state pair for every protocol in `syncInfo` (from `config.syncProtocols`). Called from the runtime's process-blocks loop.
47
+ - `AllSyncProtocols` — union type covering every supported protocol; useful when authoring config that fans out.
48
+ - `ChainBlock`, plus base `Fetcher`/`State` types from `sync-protocols/base/` — the wire shape per chain.
49
+
50
+ Per-chain `Fetcher` / `SyncState` classes (`EvmFetcher`,
51
+ `BitcoinFetcher`, `MidnightFetcher`, `AvailFetcher`, `UtxoRpcFetcher`,
52
+ `NtpFetcher`, `CelestiaFetcher`, `NearFetcher`, and matching `*SyncState`
53
+ classes) are exported but are internal to the factory wiring —
54
+ application code drives them through `genSyncProtocols` rather than
55
+ instantiating them directly. Reach for them only if you're writing a
56
+ custom orchestration layer.
57
+
58
+ ## Examples
59
+
60
+ End-to-end sync test (boots a node, reads blocks, asserts the DB):
61
+ [`e2e/evm/sync/`](https://github.com/PaimaStudios/paima-engine/tree/main/e2e/evm/sync).
62
+
63
+ Runnable: [`test/examples.test.ts`](./test/examples.test.ts).
64
+
65
+ ## Links
66
+
67
+ - Docs: https://effectstream.github.io/docs/packages/node/sync
68
+ - Source: https://github.com/PaimaStudios/paima-engine/tree/main/packages/node-sdk/sync
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effectstream/sync",
3
- "version": "0.100.14",
3
+ "version": "0.100.15",
4
4
  "license": "MIT",
5
5
  "homepage": "https://effectstream.github.io/docs/",
6
6
  "repository": {
@@ -13,10 +13,10 @@
13
13
  },
14
14
  "exports": "./src/mod.ts",
15
15
  "dependencies": {
16
- "@effectstream/config": "0.100.14",
17
- "@effectstream/db": "0.100.14",
18
- "@effectstream/log": "0.100.14",
19
- "@effectstream/utils": "0.100.14",
16
+ "@effectstream/config": "0.100.15",
17
+ "@effectstream/db": "0.100.15",
18
+ "@effectstream/log": "0.100.15",
19
+ "@effectstream/utils": "0.100.15",
20
20
  "@midnight-ntwrk/ledger-v8": "8.0.3",
21
21
  "@midnight-ntwrk/midnight-js-indexer-public-data-provider": "4.0.2",
22
22
  "@midnight-ntwrk/onchain-runtime": "npm:@midnight-ntwrk/onchain-runtime-v3@3.0.0",
@@ -0,0 +1,18 @@
1
+ // Examples for the README — verify public exports resolve.
2
+
3
+ import { test, expect } from "bun:test";
4
+ import * as sync from "../src/mod.ts";
5
+
6
+ test("README: genSyncProtocols is exported as a generator factory", () => {
7
+ expect(typeof sync.genSyncProtocols).toBe("function");
8
+ });
9
+
10
+ test("README: per-chain fetchers and states are exported", () => {
11
+ // A sampling of the protocols supported by the package.
12
+ expect("EvmFetcher" in sync).toBe(true);
13
+ expect("BitcoinFetcher" in sync).toBe(true);
14
+ expect("MidnightFetcher" in sync).toBe(true);
15
+ expect("AvailFetcher" in sync).toBe(true);
16
+ expect("UtxoRpcFetcher" in sync).toBe(true);
17
+ expect("CelestiaFetcher" in sync).toBe(true);
18
+ });