@latticexyz/store-indexer 2.2.18-318924725246340b208d3fbee8793314686f1759 → 2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1

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.
Files changed (39) hide show
  1. package/dist/bin/postgres-decoded-indexer.js +1 -90
  2. package/dist/bin/postgres-decoded-indexer.js.map +1 -1
  3. package/dist/bin/postgres-frontend.js +5 -256
  4. package/dist/bin/postgres-frontend.js.map +1 -1
  5. package/dist/bin/postgres-indexer.js +1 -104
  6. package/dist/bin/postgres-indexer.js.map +1 -1
  7. package/dist/bin/sqlite-indexer.js +1 -241
  8. package/dist/bin/sqlite-indexer.js.map +1 -1
  9. package/dist/chunk-7O2ZWWUX.js +2 -0
  10. package/dist/{chunk-YBZTPLEM.js.map → chunk-7O2ZWWUX.js.map} +1 -1
  11. package/dist/chunk-AYPBOJNL.js +2 -0
  12. package/dist/{chunk-JSDKBP77.js.map → chunk-AYPBOJNL.js.map} +1 -1
  13. package/dist/chunk-ED45N3IT.js +2 -0
  14. package/dist/{chunk-H3UGY6JG.js.map → chunk-ED45N3IT.js.map} +1 -1
  15. package/dist/chunk-JDWVOODJ.js +2 -0
  16. package/dist/{chunk-ALQNRR4A.js.map → chunk-JDWVOODJ.js.map} +1 -1
  17. package/dist/chunk-O2SDU7EQ.js +7 -0
  18. package/dist/{chunk-DRMERYGH.js.map → chunk-O2SDU7EQ.js.map} +1 -1
  19. package/dist/chunk-R7HX5BT2.js +2 -0
  20. package/dist/{chunk-7E7HV6WZ.js.map → chunk-R7HX5BT2.js.map} +1 -1
  21. package/dist/chunk-YQ7E5W26.js +2 -0
  22. package/dist/{chunk-MGRTFMMG.js.map → chunk-YQ7E5W26.js.map} +1 -1
  23. package/dist/healthcheck-57YETUEX.js +2 -0
  24. package/dist/helloWorld-4VT4FZ7F.js +2 -0
  25. package/dist/metrics-4BMCDEZZ.js +2 -0
  26. package/package.json +9 -8
  27. package/dist/chunk-7E7HV6WZ.js +0 -38
  28. package/dist/chunk-ALQNRR4A.js +0 -99
  29. package/dist/chunk-DRMERYGH.js +0 -53
  30. package/dist/chunk-H3UGY6JG.js +0 -72
  31. package/dist/chunk-JSDKBP77.js +0 -16
  32. package/dist/chunk-MGRTFMMG.js +0 -44
  33. package/dist/chunk-YBZTPLEM.js +0 -31
  34. package/dist/healthcheck-I7MZ4QZU.js +0 -7
  35. package/dist/helloWorld-SETMCIYX.js +0 -7
  36. package/dist/metrics-UNOJV54N.js +0 -7
  37. /package/dist/{healthcheck-I7MZ4QZU.js.map → healthcheck-57YETUEX.js.map} +0 -0
  38. /package/dist/{helloWorld-SETMCIYX.js.map → helloWorld-4VT4FZ7F.js.map} +0 -0
  39. /package/dist/{metrics-UNOJV54N.js.map → metrics-4BMCDEZZ.js.map} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/store-indexer",
3
- "version": "2.2.18-318924725246340b208d3fbee8793314686f1759",
3
+ "version": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1",
4
4
  "description": "Minimal Typescript indexer for Store",
5
5
  "repository": {
6
6
  "type": "git",
@@ -50,11 +50,11 @@
50
50
  "superjson": "^1.12.4",
51
51
  "trpc-koa-adapter": "^1.1.3",
52
52
  "zod": "3.23.8",
53
- "@latticexyz/block-logs-stream": "2.2.18-318924725246340b208d3fbee8793314686f1759",
54
- "@latticexyz/common": "2.2.18-318924725246340b208d3fbee8793314686f1759",
55
- "@latticexyz/protocol-parser": "2.2.18-318924725246340b208d3fbee8793314686f1759",
56
- "@latticexyz/store": "2.2.18-318924725246340b208d3fbee8793314686f1759",
57
- "@latticexyz/store-sync": "2.2.18-318924725246340b208d3fbee8793314686f1759"
53
+ "@latticexyz/block-logs-stream": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1",
54
+ "@latticexyz/common": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1",
55
+ "@latticexyz/protocol-parser": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1",
56
+ "@latticexyz/store": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1",
57
+ "@latticexyz/store-sync": "2.2.18-4565714f5e9421cc7b2de56fe51db4434c55f5d1"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/accepts": "^1.3.7",
@@ -65,7 +65,8 @@
65
65
  "@types/koa__cors": "^4.0.3",
66
66
  "@types/koa__router": "^12.0.4",
67
67
  "concurrently": "^8.2.2",
68
- "viem": "2.21.19"
68
+ "viem": "2.21.19",
69
+ "vitest": "0.34.6"
69
70
  },
70
71
  "peerDependencies": {
71
72
  "viem": "2.x"
@@ -81,7 +82,7 @@
81
82
  "dev": "tsup --watch",
82
83
  "lint": "eslint .",
83
84
  "start:postgres": "concurrently -n indexer,frontend -c cyan,magenta 'tsx src/bin/postgres-indexer' 'tsx src/bin/postgres-frontend'",
84
- "start:postgres-decoded": "concurrently -n indexer,frontend -c cyan,magenta 'tsx src/bin/postgres-decoded-indexer' 'tsx src/bin/postgres-frontend'",
85
+ "start:postgres-decoded": "tsx src/bin/postgres-decoded-indexer",
85
86
  "start:postgres-decoded:local": "DATABASE_URL=postgres://127.0.0.1/postgres RPC_HTTP_URL=http://127.0.0.1:8545 pnpm start:postgres-decoded",
86
87
  "start:postgres-decoded:testnet": "DATABASE_URL=postgres://127.0.0.1/postgres RPC_HTTP_URL=https://rpc.holesky.redstone.xyz pnpm start:postgres-decoded",
87
88
  "start:postgres:local": "DATABASE_URL=postgres://127.0.0.1/postgres RPC_HTTP_URL=http://127.0.0.1:8545 pnpm start:postgres",
@@ -1,38 +0,0 @@
1
- // src/koa-middleware/compress.ts
2
- import { Stream } from "node:stream";
3
- import accepts from "accepts";
4
- import { createBrotliCompress, createDeflate, createGzip } from "node:zlib";
5
- import { includes } from "@latticexyz/common/utils";
6
- var encodings = {
7
- br: createBrotliCompress,
8
- gzip: createGzip,
9
- deflate: createDeflate
10
- };
11
- var encodingNames = Object.keys(encodings);
12
- function flushEvery(stream, bytesThreshold) {
13
- let bytesSinceFlush = 0;
14
- stream.on("data", (data) => {
15
- bytesSinceFlush += data.length;
16
- if (bytesSinceFlush > bytesThreshold) {
17
- bytesSinceFlush = 0;
18
- stream.flush();
19
- }
20
- });
21
- return stream;
22
- }
23
- function compress({ flushThreshold = 1024 * 4 } = {}) {
24
- return async function compressMiddleware(ctx, next) {
25
- ctx.vary("Accept-Encoding");
26
- await next();
27
- const encoding = accepts(ctx.req).encoding(encodingNames);
28
- if (!includes(encodingNames, encoding)) return;
29
- const compressed = flushEvery(encodings[encoding](), flushThreshold);
30
- ctx.set("Content-Encoding", encoding);
31
- ctx.body = ctx.body instanceof Stream ? ctx.body.pipe(compressed) : compressed.end(ctx.body);
32
- };
33
- }
34
-
35
- export {
36
- compress
37
- };
38
- //# sourceMappingURL=chunk-7E7HV6WZ.js.map
@@ -1,99 +0,0 @@
1
- // src/koa-middleware/sentry.ts
2
- import * as Sentry from "@sentry/node";
3
- import { ProfilingIntegration } from "@sentry/profiling-node";
4
- import { stripUrlQueryAndFragment } from "@sentry/utils";
5
-
6
- // src/debug.ts
7
- import createDebug from "debug";
8
- var debug = createDebug("mud:store-indexer");
9
- var error = createDebug("mud:store-indexer");
10
- debug.log = console.debug.bind(console);
11
- error.log = console.error.bind(console);
12
-
13
- // src/koa-middleware/sentry.ts
14
- import compose from "koa-compose";
15
- function errorHandler() {
16
- return async function errorHandlerMiddleware(ctx, next) {
17
- try {
18
- await next();
19
- } catch (err) {
20
- Sentry.withScope((scope) => {
21
- scope.addEventProcessor((event) => {
22
- return Sentry.addRequestDataToEvent(event, ctx.request);
23
- });
24
- Sentry.captureException(err);
25
- });
26
- throw err;
27
- }
28
- };
29
- }
30
- function requestHandler() {
31
- return async function requestHandlerMiddleware(ctx, next) {
32
- await Sentry.runWithAsyncContext(async () => {
33
- const hub = Sentry.getCurrentHub();
34
- hub.configureScope(
35
- (scope) => scope.addEventProcessor(
36
- (event) => Sentry.addRequestDataToEvent(event, ctx.request, {
37
- include: {
38
- user: false
39
- }
40
- })
41
- )
42
- );
43
- await next();
44
- });
45
- };
46
- }
47
- function tracing() {
48
- return async function tracingMiddleware(ctx, next) {
49
- const reqMethod = (ctx.method || "").toUpperCase();
50
- const reqUrl = ctx.url && stripUrlQueryAndFragment(ctx.url);
51
- let traceparentData;
52
- if (ctx.request.get("sentry-trace")) {
53
- traceparentData = Sentry.extractTraceparentData(ctx.request.get("sentry-trace"));
54
- }
55
- const transaction = Sentry.startTransaction({
56
- name: `${reqMethod} ${reqUrl}`,
57
- op: "http.server",
58
- ...traceparentData
59
- });
60
- ctx.__sentry_transaction = transaction;
61
- Sentry.getCurrentHub().configureScope((scope) => {
62
- scope.setSpan(transaction);
63
- });
64
- ctx.res.on("finish", () => {
65
- setImmediate(() => {
66
- if (ctx._matchedRoute) {
67
- const mountPath = ctx.mountPath || "";
68
- transaction.setName(`${reqMethod} ${mountPath}${ctx._matchedRoute}`);
69
- }
70
- transaction.setHttpStatus(ctx.status);
71
- transaction.finish();
72
- });
73
- });
74
- await next();
75
- };
76
- }
77
- function sentry(dsn) {
78
- debug("Initializing Sentry");
79
- Sentry.init({
80
- dsn,
81
- integrations: [
82
- // Automatically instrument Node.js libraries and frameworks
83
- ...Sentry.autoDiscoverNodePerformanceMonitoringIntegrations(),
84
- new ProfilingIntegration()
85
- ],
86
- // Performance Monitoring
87
- tracesSampleRate: 1,
88
- // Set sampling rate for profiling - this is relative to tracesSampleRate
89
- profilesSampleRate: 1
90
- });
91
- return compose([errorHandler(), requestHandler(), tracing()]);
92
- }
93
-
94
- export {
95
- debug,
96
- error,
97
- sentry
98
- };
99
- //# sourceMappingURL=chunk-ALQNRR4A.js.map
@@ -1,53 +0,0 @@
1
- // src/bin/parseEnv.ts
2
- import { isHex } from "viem";
3
- import { z, ZodError } from "zod";
4
- var frontendEnvSchema = z.object({
5
- HOST: z.string().default("0.0.0.0"),
6
- PORT: z.coerce.number().positive().default(3001)
7
- });
8
- var indexerEnvSchema = z.intersection(
9
- z.object({
10
- FOLLOW_BLOCK_TAG: z.enum(["latest", "safe", "finalized"]).default("safe"),
11
- START_BLOCK: z.coerce.bigint().nonnegative().default(0n),
12
- MAX_BLOCK_RANGE: z.coerce.bigint().positive().default(1000n),
13
- POLLING_INTERVAL: z.coerce.number().positive().default(1e3),
14
- STORE_ADDRESS: z.string().optional().transform((input) => input === "" ? void 0 : input).refine(isHexOrUndefined),
15
- INTERNAL__VALIDATE_BLOCK_RANGE: z.string().optional().transform((input) => input === "true" || input === "1")
16
- }),
17
- z.union([
18
- z.object({
19
- RPC_HTTP_URL: z.string(),
20
- RPC_WS_URL: z.string().optional()
21
- }),
22
- z.object({
23
- RPC_HTTP_URL: z.string().optional(),
24
- RPC_WS_URL: z.string()
25
- })
26
- ])
27
- );
28
- function parseEnv(envSchema) {
29
- try {
30
- return envSchema.parse(process.env);
31
- } catch (error) {
32
- if (error instanceof ZodError) {
33
- const { ...invalidEnvVars } = error.format();
34
- console.error(`
35
- Missing or invalid environment variables:
36
-
37
- ${Object.keys(invalidEnvVars).join("\n ")}
38
- `);
39
- process.exit(1);
40
- }
41
- throw error;
42
- }
43
- }
44
- function isHexOrUndefined(input) {
45
- return input === void 0 || isHex(input);
46
- }
47
-
48
- export {
49
- frontendEnvSchema,
50
- indexerEnvSchema,
51
- parseEnv
52
- };
53
- //# sourceMappingURL=chunk-DRMERYGH.js.map
@@ -1,72 +0,0 @@
1
- // src/koa-middleware/metrics.ts
2
- import promClient from "prom-client";
3
- function metrics({
4
- isHealthy,
5
- isReady,
6
- getLatestStoredBlockNumber,
7
- getDistanceFromFollowBlock,
8
- followBlockTag
9
- } = {}) {
10
- promClient.collectDefaultMetrics();
11
- if (isHealthy != null) {
12
- new promClient.Gauge({
13
- name: "health_status",
14
- help: "Health status (0 = unhealthy, 1 = healthy)",
15
- collect() {
16
- this.set(Number(isHealthy()));
17
- }
18
- });
19
- }
20
- if (isReady != null) {
21
- new promClient.Gauge({
22
- name: "readiness_status",
23
- help: "Readiness status (whether the service is ready to receive requests, 0 = not ready, 1 = ready)",
24
- collect() {
25
- this.set(Number(isReady()));
26
- }
27
- });
28
- }
29
- if (getLatestStoredBlockNumber != null) {
30
- new promClient.Gauge({
31
- name: "latest_stored_block_number",
32
- help: "Latest block number stored in the database",
33
- async collect() {
34
- this.set(Number(await getLatestStoredBlockNumber()));
35
- }
36
- });
37
- }
38
- if (followBlockTag != null) {
39
- const blockTagGauge = new promClient.Gauge({
40
- name: "follow_block_tag",
41
- help: "Block tag the indexer is following (0 = finalized, 1 = safe, 2 = latest)"
42
- });
43
- const blockTagToValue = {
44
- finalized: 0,
45
- safe: 1,
46
- latest: 2
47
- };
48
- blockTagGauge.set(blockTagToValue[followBlockTag]);
49
- }
50
- if (getDistanceFromFollowBlock != null) {
51
- new promClient.Gauge({
52
- name: "distance_from_follow_block",
53
- help: "Block distance from the block tag this the indexer is following",
54
- async collect() {
55
- this.set(Number(await getDistanceFromFollowBlock()));
56
- }
57
- });
58
- }
59
- return async function metricsMiddleware(ctx, next) {
60
- if (ctx.path === "/metrics") {
61
- ctx.status = 200;
62
- ctx.body = await promClient.register.metrics();
63
- return;
64
- }
65
- await next();
66
- };
67
- }
68
-
69
- export {
70
- metrics
71
- };
72
- //# sourceMappingURL=chunk-H3UGY6JG.js.map
@@ -1,16 +0,0 @@
1
- // src/koa-middleware/helloWorld.ts
2
- function helloWorld() {
3
- return async function helloWorldMiddleware(ctx, next) {
4
- if (ctx.path === "/") {
5
- ctx.status = 200;
6
- ctx.body = "emit HelloWorld();";
7
- return;
8
- }
9
- await next();
10
- };
11
- }
12
-
13
- export {
14
- helloWorld
15
- };
16
- //# sourceMappingURL=chunk-JSDKBP77.js.map
@@ -1,44 +0,0 @@
1
- // src/bin/getClientOptions.ts
2
- import { createClient, fallback, http, webSocket } from "viem";
3
- import { isDefined } from "@latticexyz/common/utils";
4
- import { getChainId } from "viem/actions";
5
- async function getClientOptions(env) {
6
- if (env.INTERNAL__VALIDATE_BLOCK_RANGE) {
7
- const rpcHttpUrl = env.RPC_HTTP_URL;
8
- if (!rpcHttpUrl) {
9
- throw new Error("Must provide RPC_HTTP_URL when using INTERNAL__VALIDATE_BLOCK_RANGE.");
10
- }
11
- const chainId = await getChainId(createClient({ transport: http(rpcHttpUrl) }));
12
- const chain = {
13
- id: chainId,
14
- name: "Unknown",
15
- nativeCurrency: { decimals: 18, name: "Ether", symbol: "ETH" },
16
- rpcUrls: { default: { http: [rpcHttpUrl] } }
17
- };
18
- return {
19
- internal_clientOptions: {
20
- chain,
21
- pollingInterval: env.POLLING_INTERVAL,
22
- validateBlockRange: env.INTERNAL__VALIDATE_BLOCK_RANGE
23
- }
24
- };
25
- }
26
- const transport = fallback(
27
- [
28
- // prefer WS when specified
29
- env.RPC_WS_URL ? webSocket(env.RPC_WS_URL) : void 0,
30
- // otherwise use or fallback to HTTP
31
- env.RPC_HTTP_URL ? http(env.RPC_HTTP_URL) : void 0
32
- ].filter(isDefined)
33
- );
34
- const publicClient = createClient({
35
- transport,
36
- pollingInterval: env.POLLING_INTERVAL
37
- });
38
- return { publicClient };
39
- }
40
-
41
- export {
42
- getClientOptions
43
- };
44
- //# sourceMappingURL=chunk-MGRTFMMG.js.map
@@ -1,31 +0,0 @@
1
- // src/koa-middleware/healthcheck.ts
2
- function healthcheck({ isHealthy, isReady } = {}) {
3
- return async function healthcheckMiddleware(ctx, next) {
4
- if (ctx.path === "/healthz") {
5
- if (isHealthy == null || isHealthy()) {
6
- ctx.status = 200;
7
- ctx.body = "healthy";
8
- } else {
9
- ctx.status = 503;
10
- ctx.body = "not healthy";
11
- }
12
- return;
13
- }
14
- if (ctx.path === "/readyz") {
15
- if (isReady == null || isReady()) {
16
- ctx.status = 200;
17
- ctx.body = "ready";
18
- } else {
19
- ctx.status = 503;
20
- ctx.body = "not ready";
21
- }
22
- return;
23
- }
24
- await next();
25
- };
26
- }
27
-
28
- export {
29
- healthcheck
30
- };
31
- //# sourceMappingURL=chunk-YBZTPLEM.js.map
@@ -1,7 +0,0 @@
1
- import {
2
- healthcheck
3
- } from "./chunk-YBZTPLEM.js";
4
- export {
5
- healthcheck
6
- };
7
- //# sourceMappingURL=healthcheck-I7MZ4QZU.js.map
@@ -1,7 +0,0 @@
1
- import {
2
- helloWorld
3
- } from "./chunk-JSDKBP77.js";
4
- export {
5
- helloWorld
6
- };
7
- //# sourceMappingURL=helloWorld-SETMCIYX.js.map
@@ -1,7 +0,0 @@
1
- import {
2
- metrics
3
- } from "./chunk-H3UGY6JG.js";
4
- export {
5
- metrics
6
- };
7
- //# sourceMappingURL=metrics-UNOJV54N.js.map