@latticexyz/store-indexer 2.0.0-main-7fb0dadf → 2.0.0-main-131c63e5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/store-indexer",
3
- "version": "2.0.0-main-7fb0dadf",
3
+ "version": "2.0.0-main-131c63e5",
4
4
  "description": "Minimal Typescript indexer for Store",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,10 +25,10 @@
25
25
  "superjson": "^1.12.4",
26
26
  "viem": "1.3.1",
27
27
  "zod": "^3.21.4",
28
- "@latticexyz/block-logs-stream": "2.0.0-main-7fb0dadf",
29
- "@latticexyz/common": "2.0.0-main-7fb0dadf",
30
- "@latticexyz/store": "2.0.0-main-7fb0dadf",
31
- "@latticexyz/store-sync": "2.0.0-main-7fb0dadf"
28
+ "@latticexyz/block-logs-stream": "2.0.0-main-131c63e5",
29
+ "@latticexyz/common": "2.0.0-main-131c63e5",
30
+ "@latticexyz/store": "2.0.0-main-131c63e5",
31
+ "@latticexyz/store-sync": "2.0.0-main-131c63e5"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/better-sqlite3": "^7.6.4",
@@ -1,4 +1,4 @@
1
- import { Chain, PublicClient, Transport } from "viem";
1
+ import { PublicClient } from "viem";
2
2
  import {
3
3
  createBlockStream,
4
4
  isNonPendingBlock,
@@ -24,7 +24,7 @@ type CreateIndexerOptions = {
24
24
  *
25
25
  * [0]: https://viem.sh/docs/clients/public.html
26
26
  */
27
- publicClient: PublicClient<Transport, Chain>;
27
+ publicClient: PublicClient;
28
28
  /**
29
29
  * Optional block number to start indexing from. Useful for resuming the indexer from a particular point in time or starting after a particular contract deployment.
30
30
  */
@@ -41,12 +41,12 @@ type CreateIndexerOptions = {
41
41
  * @param {CreateIndexerOptions} options See `CreateIndexerOptions`.
42
42
  * @returns A function to unsubscribe from the block stream, effectively stopping the indexer.
43
43
  */
44
- export function createIndexer({
44
+ export async function createIndexer({
45
45
  database,
46
46
  publicClient,
47
47
  startBlock = 0n,
48
48
  maxBlockRange,
49
- }: CreateIndexerOptions): () => void {
49
+ }: CreateIndexerOptions): Promise<() => void> {
50
50
  const latestBlock$ = createBlockStream({ publicClient, blockTag: "latest" });
51
51
 
52
52
  const latestBlockNumber$ = latestBlock$.pipe(
@@ -70,7 +70,7 @@ export function createIndexer({
70
70
 
71
71
  const sub = blockLogs$
72
72
  .pipe(
73
- concatMap(blockLogsToStorage(sqliteStorage({ database, publicClient }))),
73
+ concatMap(blockLogsToStorage(await sqliteStorage({ database, publicClient }))),
74
74
  tap(({ blockNumber, operations }) => {
75
75
  debug("stored", operations.length, "operations for block", blockNumber);
76
76
  })