@secondlayer/shared 7.0.1 → 7.0.3

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 (35) hide show
  1. package/dist/src/crypto/secondlayer-webhook.js +2 -2
  2. package/dist/src/crypto/secondlayer-webhook.js.map +2 -2
  3. package/dist/src/db/index.js +2 -2
  4. package/dist/src/db/index.js.map +2 -2
  5. package/dist/src/db/queries/chain-reorgs.js +4 -4
  6. package/dist/src/db/queries/chain-reorgs.js.map +4 -4
  7. package/dist/src/db/queries/subgraphs.js +2 -2
  8. package/dist/src/db/queries/subgraphs.js.map +2 -2
  9. package/dist/src/env.d.ts +1 -1
  10. package/dist/src/env.js +2 -2
  11. package/dist/src/env.js.map +2 -2
  12. package/dist/src/index.d.ts +3 -3
  13. package/dist/src/index.js +5 -5
  14. package/dist/src/index.js.map +5 -5
  15. package/dist/src/leader.js +2 -2
  16. package/dist/src/leader.js.map +2 -2
  17. package/dist/src/logger.js +2 -2
  18. package/dist/src/logger.js.map +2 -2
  19. package/dist/src/node/archive-client.js +2 -2
  20. package/dist/src/node/archive-client.js.map +2 -2
  21. package/dist/src/node/hiro-client.js +2 -2
  22. package/dist/src/node/hiro-client.js.map +2 -2
  23. package/dist/src/schemas/filters.d.ts +1 -1
  24. package/dist/src/schemas/filters.js +2 -2
  25. package/dist/src/schemas/filters.js.map +2 -2
  26. package/dist/src/schemas/index.d.ts +3 -3
  27. package/dist/src/schemas/index.js +4 -4
  28. package/dist/src/schemas/index.js.map +4 -4
  29. package/dist/src/schemas/subgraphs.d.ts +1 -1
  30. package/dist/src/schemas/subgraphs.js +2 -2
  31. package/dist/src/schemas/subgraphs.js.map +2 -2
  32. package/dist/src/schemas/subscriptions.d.ts +1 -1
  33. package/dist/src/schemas/subscriptions.js +2 -2
  34. package/dist/src/schemas/subscriptions.js.map +2 -2
  35. package/package.json +2 -2
@@ -15,7 +15,7 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/env.ts
18
- import { z } from "zod/v4";
18
+ import { z } from "zod";
19
19
  var networksSchema = z.string().transform((val) => {
20
20
  const networks = val.split(",").map((n) => n.trim()).filter(Boolean);
21
21
  const valid = ["mainnet", "testnet"];
@@ -138,5 +138,5 @@ export {
138
138
  logger
139
139
  };
140
140
 
141
- //# debugId=33C9C7B4C1B00A7964756E2164756E21
141
+ //# debugId=C6A4155FD8A624C664756E2164756E21
142
142
  //# sourceMappingURL=logger.js.map
@@ -2,10 +2,10 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/env.ts", "../src/logger.ts"],
4
4
  "sourcesContent": [
5
- "import { z } from \"zod/v4\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
5
+ "import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
6
6
  "import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n"
7
7
  ],
8
8
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,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K,UAAU,MAAM,GAAG;AAAA,MAC3B,QAAQ,KAAK,KAAK,cAAc,QAAQ,SAAS,IAAI,CAAC;AAAA,IACvD;AAAA;AAAA,EAID,IAAI,CAAC,SAAiB,MAAkC;AAAA,IACvD,IAAI,KAAK,UAAU,MAAM,GAAG;AAAA,MAC3B,QAAQ,KAAK,KAAK,cAAc,QAAQ,SAAS,IAAI,CAAC;AAAA,IACvD;AAAA;AAAA,EAID,KAAK,CAAC,SAAiB,MAAkC;AAAA,IACxD,IAAI,KAAK,UAAU,OAAO,GAAG;AAAA,MAC5B,QAAQ,MAAM,KAAK,cAAc,SAAS,SAAS,IAAI,CAAC;AAAA,IACzD;AAAA;AAEF;AAGO,IAAM,SAAiB,IAAI;",
9
- "debugId": "33C9C7B4C1B00A7964756E2164756E21",
9
+ "debugId": "C6A4155FD8A624C664756E2164756E21",
10
10
  "names": []
11
11
  }
@@ -15,7 +15,7 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/env.ts
18
- import { z } from "zod/v4";
18
+ import { z } from "zod";
19
19
  var networksSchema = z.string().transform((val) => {
20
20
  const networks = val.split(",").map((n) => n.trim()).filter(Boolean);
21
21
  const valid = ["mainnet", "testnet"];
@@ -400,5 +400,5 @@ export {
400
400
  ArchiveReplayClient
401
401
  };
402
402
 
403
- //# debugId=DF0DB5FD47016FBE64756E2164756E21
403
+ //# debugId=361D452B10DA861864756E2164756E21
404
404
  //# sourceMappingURL=archive-client.js.map
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/env.ts", "../src/logger.ts", "../src/node/archive-client.ts"],
4
4
  "sourcesContent": [
5
- "import { z } from \"zod/v4\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
5
+ "import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
6
6
  "import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
7
7
  "/**\n * Archive Replay Client — backfills blocks from Hiro's daily event observer archive.\n *\n * The archive at archive.hiro.so contains zstd-compressed TSV files of raw\n * /new_block payloads (the exact NewBlockPayload JSON our indexer expects).\n * This client downloads the archive, streams + filters for specific block\n * heights, and POSTs matching payloads directly to the indexer.\n *\n * Caches the archive locally for up to 24h to avoid redundant ~25GB downloads.\n * Zero external API dependency — only needs the static archive file.\n */\n\nimport {\n\texistsSync,\n\treadFileSync,\n\trenameSync,\n\tunlinkSync,\n\twriteFileSync,\n} from \"node:fs\";\nimport { logger } from \"../logger.ts\";\n\nconst DEFAULT_ARCHIVE_URL =\n\t\"https://archive.hiro.so/mainnet/stacks-blockchain-api/mainnet-stacks-blockchain-api-latest.zst\";\n\nconst HEIGHT_REGEX = /\"block_height\":\\s*(\\d+)/;\nconst CACHE_MAX_AGE_MS = 24 * 60 * 60 * 1000; // 24 hours\n\ninterface ArchiveMeta {\n\tlastModified: string | null;\n\tdownloadedAt: string;\n}\n\nexport interface ReplayResult {\n\treplayed: number;\n\terrors: number;\n}\n\nexport interface ReplayOptions {\n\tonProgress?: (count: number, height: number) => void;\n}\n\nexport class ArchiveReplayClient {\n\tprivate archiveUrl: string;\n\tprivate archiveDir: string;\n\n\tconstructor(opts?: { archiveUrl?: string; archiveDir?: string }) {\n\t\tthis.archiveUrl =\n\t\t\topts?.archiveUrl || process.env.ARCHIVE_URL || DEFAULT_ARCHIVE_URL;\n\t\tthis.archiveDir = opts?.archiveDir || process.env.ARCHIVE_DIR || \"/tmp\";\n\t}\n\n\tprivate get archivePath() {\n\t\treturn `${this.archiveDir}/secondlayer-archive.zst`;\n\t}\n\tprivate get metaPath() {\n\t\treturn `${this.archiveDir}/secondlayer-archive.meta.json`;\n\t}\n\tprivate get partialPath() {\n\t\treturn `${this.archiveDir}/secondlayer-archive.zst.partial`;\n\t}\n\n\t/** HEAD request to archive URL — verify reachable and has content */\n\tasync isAvailable(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst res = await fetch(this.archiveUrl, {\n\t\t\t\tmethod: \"HEAD\",\n\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t});\n\t\t\tconst contentLength = Number(res.headers.get(\"content-length\") || 0);\n\t\t\treturn res.ok && contentLength > 0;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/**\n\t * Download archive, stream-decompress, replay blocks matching gapHeights\n\t * to the indexer's /new_block endpoint.\n\t */\n\tasync replayGaps(\n\t\tgapHeights: Set<number>,\n\t\tindexerUrl: string,\n\t\topts?: ReplayOptions,\n\t): Promise<ReplayResult> {\n\t\tif (gapHeights.size === 0) return { replayed: 0, errors: 0 };\n\n\t\t// Iterate, don't spread: a full-history gap set is millions of heights,\n\t\t// and `Math.max(...set)` spreads them all as call arguments → instant\n\t\t// RangeError (max call-stack) on any large backfill.\n\t\tlet maxHeight = 0;\n\t\tfor (const h of gapHeights) if (h > maxHeight) maxHeight = h;\n\t\tlet replayed = 0;\n\t\tlet errors = 0;\n\n\t\ttry {\n\t\t\tawait this.ensureArchive();\n\n\t\t\tlogger.info(\"Archive replay: starting decompression + replay\", {\n\t\t\t\ttargetHeights: gapHeights.size,\n\t\t\t\tmaxHeight,\n\t\t\t});\n\n\t\t\t// Decompress via zstd subprocess\n\t\t\tconst proc = Bun.spawn([\"zstd\", \"-d\", this.archivePath, \"--stdout\"], {\n\t\t\t\tstdout: \"pipe\",\n\t\t\t\tstderr: \"ignore\",\n\t\t\t});\n\n\t\t\tconst reader = proc.stdout.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tlet buffer = \"\";\n\t\t\tconst remaining = new Set(gapHeights);\n\n\t\t\twhile (true) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) break;\n\n\t\t\t\tbuffer += decoder.decode(value, { stream: true });\n\t\t\t\tconst lines = buffer.split(\"\\n\");\n\t\t\t\tbuffer = lines.pop() || \"\";\n\n\t\t\t\tfor (const line of lines) {\n\t\t\t\t\tif (remaining.size === 0) break;\n\n\t\t\t\t\t// Quick height check via regex (avoid full JSON parse)\n\t\t\t\t\tconst match = HEIGHT_REGEX.exec(line);\n\t\t\t\t\tif (!match) continue;\n\n\t\t\t\t\tconst height = Number.parseInt(match[1]);\n\n\t\t\t\t\t// Skip blocks we don't need\n\t\t\t\t\tif (!remaining.has(height)) {\n\t\t\t\t\t\t// Early exit if past all gap heights\n\t\t\t\t\t\tif (height > maxHeight) break;\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\t// Extract payload from TSV (id \\t timestamp \\t path \\t payload)\n\t\t\t\t\tconst tabIdx3 = nthIndex(line, \"\\t\", 3);\n\t\t\t\t\tif (tabIdx3 === -1) continue;\n\n\t\t\t\t\tconst path = line.substring(nthIndex(line, \"\\t\", 2) + 1, tabIdx3);\n\t\t\t\t\tif (path !== \"/new_block\") continue;\n\n\t\t\t\t\tconst payload = line.substring(tabIdx3 + 1);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst res = await fetch(`${indexerUrl}/new_block`, {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t\"Content-Type\": \"application/json\",\n\t\t\t\t\t\t\t\t\"X-Source\": \"archive-replay\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: payload,\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (res.ok) {\n\t\t\t\t\t\t\treplayed++;\n\t\t\t\t\t\t\tremaining.delete(height);\n\t\t\t\t\t\t\topts?.onProgress?.(replayed, height);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terrors++;\n\t\t\t\t\t\t\tlogger.warn(\"Archive replay: indexer rejected block\", {\n\t\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\t\tstatus: res.status,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\terrors++;\n\t\t\t\t\t\tlogger.warn(\"Archive replay: POST failed\", {\n\t\t\t\t\t\t\theight,\n\t\t\t\t\t\t\terror: String(err),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Early exit if all gaps filled or past max height\n\t\t\t\tif (remaining.size === 0) {\n\t\t\t\t\tproc.kill();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Wait for process to exit\n\t\t\tawait proc.exited;\n\n\t\t\tif (remaining.size > 0) {\n\t\t\t\t// Don't spread `remaining` (can be millions) just to sample a few.\n\t\t\t\tconst sample: number[] = [];\n\t\t\t\tfor (const h of remaining) {\n\t\t\t\t\tsample.push(h);\n\t\t\t\t\tif (sample.length === 5) break;\n\t\t\t\t}\n\t\t\t\tlogger.warn(\"Archive replay: some heights not found in archive\", {\n\t\t\t\t\tmissing: remaining.size,\n\t\t\t\t\tsample,\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlogger.info(\"Archive replay: complete\", {\n\t\t\t\treplayed,\n\t\t\t\terrors,\n\t\t\t\tmissing: remaining.size,\n\t\t\t});\n\t\t} catch (err) {\n\t\t\t// Clean up on error (corrupt/partial downloads)\n\t\t\tthis.cleanupFile(this.archivePath);\n\t\t\tthis.cleanupFile(this.metaPath);\n\t\t\tthis.cleanupFile(this.partialPath);\n\t\t\tthrow err;\n\t\t}\n\n\t\treturn { replayed, errors };\n\t}\n\n\t/**\n\t * Ensure a fresh-enough archive exists locally.\n\t * Uses HTTP conditional requests to avoid redundant downloads.\n\t */\n\tprivate async ensureArchive(): Promise<void> {\n\t\tthis.cleanStaleFiles();\n\n\t\tconst meta = this.readMeta();\n\t\tconst cached = existsSync(this.archivePath) && meta !== null;\n\n\t\tif (cached) {\n\t\t\tconst age = Date.now() - new Date(meta.downloadedAt).getTime();\n\t\t\tif (age < CACHE_MAX_AGE_MS) {\n\t\t\t\t// Cache is fresh enough — check if remote has a newer version\n\t\t\t\tconst headers: Record<string, string> = {};\n\t\t\t\tif (meta.lastModified) {\n\t\t\t\t\theaders[\"If-Modified-Since\"] = meta.lastModified;\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst res = await fetch(this.archiveUrl, {\n\t\t\t\t\t\tmethod: \"HEAD\",\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tsignal: AbortSignal.timeout(15_000),\n\t\t\t\t\t});\n\n\t\t\t\t\tif (res.status === 304) {\n\t\t\t\t\t\tlogger.info(\"Archive replay: using cached archive\", {\n\t\t\t\t\t\t\tageHrs: (age / 3600000).toFixed(1),\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\t// 200 = remote is newer, re-download below\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\"Archive replay: remote archive is newer, re-downloading\",\n\t\t\t\t\t);\n\t\t\t\t} catch {\n\t\t\t\t\t// Can't reach remote — use cache anyway\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t\"Archive replay: remote unreachable, using cached archive\",\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tlogger.info(\"Archive replay: cache expired, re-downloading\");\n\t\t\t}\n\t\t}\n\n\t\t// Download fresh archive\n\t\tlogger.info(\"Archive replay: downloading archive\", {\n\t\t\turl: this.archiveUrl.split(\"/\").pop(),\n\t\t});\n\n\t\tconst lastModified = await this.download(this.partialPath);\n\n\t\t// Atomic rename: partial → final\n\t\trenameSync(this.partialPath, this.archivePath);\n\n\t\t// Write meta sidecar\n\t\tthis.writeMeta({ lastModified, downloadedAt: new Date().toISOString() });\n\n\t\tlogger.info(\"Archive replay: download complete\");\n\t}\n\n\t/** Remove stale cache (> 24h) and orphaned partial files */\n\tprivate cleanStaleFiles(): void {\n\t\ttry {\n\t\t\t// Clean orphaned partial downloads\n\t\t\tif (existsSync(this.partialPath)) {\n\t\t\t\tunlinkSync(this.partialPath);\n\t\t\t}\n\n\t\t\t// Clean stale cache\n\t\t\tconst meta = this.readMeta();\n\t\t\tif (meta) {\n\t\t\t\tconst age = Date.now() - new Date(meta.downloadedAt).getTime();\n\t\t\t\tif (age > CACHE_MAX_AGE_MS) {\n\t\t\t\t\tthis.cleanupFile(this.archivePath);\n\t\t\t\t\tthis.cleanupFile(this.metaPath);\n\t\t\t\t\tlogger.info(\"Archive replay: cleaned stale cache\");\n\t\t\t\t}\n\t\t\t} else if (existsSync(this.archivePath)) {\n\t\t\t\t// Archive without meta — orphaned, clean up\n\t\t\t\tthis.cleanupFile(this.archivePath);\n\t\t\t}\n\t\t} catch {\n\t\t\t// Best-effort cleanup\n\t\t}\n\t}\n\n\tprivate readMeta(): ArchiveMeta | null {\n\t\ttry {\n\t\t\tif (!existsSync(this.metaPath)) return null;\n\t\t\treturn JSON.parse(readFileSync(this.metaPath, \"utf-8\")) as ArchiveMeta;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\tprivate writeMeta(meta: ArchiveMeta): void {\n\t\ttry {\n\t\t\twriteFileSync(this.metaPath, JSON.stringify(meta));\n\t\t} catch {\n\t\t\t// Best-effort\n\t\t}\n\t}\n\n\tprivate cleanupFile(path: string): void {\n\t\ttry {\n\t\t\tif (existsSync(path)) unlinkSync(path);\n\t\t} catch {\n\t\t\t// Best-effort\n\t\t}\n\t}\n\n\t/** Download archive to disk with streaming. Returns Last-Modified header. */\n\tprivate async download(destPath: string): Promise<string | null> {\n\t\tconst res = await fetch(this.archiveUrl, {\n\t\t\tsignal: AbortSignal.timeout(30 * 60 * 1000), // 30 min timeout\n\t\t});\n\n\t\tif (!res.ok || !res.body) {\n\t\t\tthrow new Error(`Archive download failed: HTTP ${res.status}`);\n\t\t}\n\n\t\tconst lastModified = res.headers.get(\"last-modified\");\n\t\tconst totalBytes = Number(res.headers.get(\"content-length\") || 0);\n\t\tconst writer = Bun.file(destPath).writer();\n\t\tlet downloaded = 0;\n\t\tlet lastLog = 0;\n\n\t\tfor await (const chunk of res.body) {\n\t\t\twriter.write(chunk);\n\t\t\tdownloaded += chunk.byteLength;\n\n\t\t\t// Log progress every 5GB\n\t\t\tif (totalBytes > 0 && downloaded - lastLog > 5_000_000_000) {\n\t\t\t\tlastLog = downloaded;\n\t\t\t\tconst pct = ((downloaded / totalBytes) * 100).toFixed(0);\n\t\t\t\tlogger.info(\"Archive replay: downloading\", { progress: `${pct}%` });\n\t\t\t}\n\t\t}\n\n\t\tawait writer.end();\n\t\treturn lastModified;\n\t}\n}\n\n/** Find the nth occurrence of a character in a string */\nfunction nthIndex(str: string, char: string, n: number): number {\n\tlet idx = -1;\n\tfor (let i = 0; i < n; i++) {\n\t\tidx = str.indexOf(char, idx + 1);\n\t\tif (idx === -1) return -1;\n\t}\n\treturn idx;\n}\n"
8
8
  ],
9
9
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE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AY,QAAQ,KAAK,KAAK,IAAI;AAAA,IAC3C,CAAC;AAAA,IAED,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,MAAM;AAAA,MACzB,MAAM,IAAI,MAAM,iCAAiC,IAAI,QAAQ;AAAA,IAC9D;AAAA,IAEA,MAAM,eAAe,IAAI,QAAQ,IAAI,eAAe;AAAA,IACpD,MAAM,aAAa,OAAO,IAAI,QAAQ,IAAI,gBAAgB,KAAK,CAAC;AAAA,IAChE,MAAM,SAAS,IAAI,KAAK,QAAQ,EAAE,OAAO;AAAA,IACzC,IAAI,aAAa;AAAA,IACjB,IAAI,UAAU;AAAA,IAEd,iBAAiB,SAAS,IAAI,MAAM;AAAA,MACnC,OAAO,MAAM,KAAK;AAAA,MAClB,cAAc,MAAM;AAAA,MAGpB,IAAI,aAAa,KAAK,aAAa,UAAU,YAAe;AAAA,QAC3D,UAAU;AAAA,QACV,MAAM,OAAQ,aAAa,aAAc,KAAK,QAAQ,CAAC;AAAA,QACvD,OAAO,KAAK,+BAA+B,EAAE,UAAU,GAAG,OAAO,CAAC;AAAA,MACnE;AAAA,IACD;AAAA,IAEA,MAAM,OAAO,IAAI;AAAA,IACjB,OAAO;AAAA;AAET;AAGA,SAAS,QAAQ,CAAC,KAAa,MAAc,GAAmB;AAAA,EAC/D,IAAI,MAAM;AAAA,EACV,SAAS,IAAI,EAAG,IAAI,GAAG,KAAK;AAAA,IAC3B,MAAM,IAAI,QAAQ,MAAM,MAAM,CAAC;AAAA,IAC/B,IAAI,QAAQ;AAAA,MAAI,OAAO;AAAA,EACxB;AAAA,EACA,OAAO;AAAA;",
10
- "debugId": "DF0DB5FD47016FBE64756E2164756E21",
10
+ "debugId": "361D452B10DA861864756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -15,7 +15,7 @@ var __export = (target, all) => {
15
15
  };
16
16
 
17
17
  // src/env.ts
18
- import { z } from "zod/v4";
18
+ import { z } from "zod";
19
19
  var networksSchema = z.string().transform((val) => {
20
20
  const networks = val.split(",").map((n) => n.trim()).filter(Boolean);
21
21
  const valid = ["mainnet", "testnet"];
@@ -498,5 +498,5 @@ export {
498
498
  HiroClient
499
499
  };
500
500
 
501
- //# debugId=1FB15B4363B2E96864756E2164756E21
501
+ //# debugId=62A7E2C25A1EFE8B64756E2164756E21
502
502
  //# sourceMappingURL=hiro-client.js.map
@@ -2,11 +2,11 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/env.ts", "../src/logger.ts", "../src/node/hiro-client.ts"],
4
4
  "sourcesContent": [
5
- "import { z } from \"zod/v4\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
5
+ "import { z } from \"zod\";\n\n// Parse comma-separated networks\nconst networksSchema = z.string().transform((val) => {\n\tconst networks = val\n\t\t.split(\",\")\n\t\t.map((n) => n.trim())\n\t\t.filter(Boolean);\n\tconst valid = [\"mainnet\", \"testnet\"];\n\tfor (const n of networks) {\n\t\tif (!valid.includes(n)) {\n\t\t\tthrow new Error(\n\t\t\t\t`Invalid network: ${n}. Must be one of: ${valid.join(\", \")}`,\n\t\t\t);\n\t\t}\n\t}\n\treturn networks as (\"mainnet\" | \"testnet\")[];\n});\n\ninterface EnvSchemaOutput {\n\tDATABASE_URL?: string;\n\t/**\n\t * Shared indexer DB (blocks/txs/events). Falls back to DATABASE_URL.\n\t * Set this alongside TARGET_DATABASE_URL to enable dual-DB mode.\n\t */\n\tSOURCE_DATABASE_URL?: string;\n\t/**\n\t * Tenant DB (subgraph schemas + subgraphs table). Falls back to DATABASE_URL.\n\t * Set this alongside SOURCE_DATABASE_URL to enable dual-DB mode.\n\t */\n\tTARGET_DATABASE_URL?: string;\n\tNETWORK?: \"mainnet\" | \"testnet\";\n\tNETWORKS?: (\"mainnet\" | \"testnet\")[];\n\tLOG_LEVEL: \"debug\" | \"info\" | \"warn\" | \"error\";\n\tNODE_ENV: \"development\" | \"production\" | \"test\";\n}\n\n// Cast needed: z.preprocess / z.default create different _input vs _output types\n// that z.ZodType<T> can't represent without explicit input type param\nconst envSchema: z.ZodType<EnvSchemaOutput> = z.object({\n\tDATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tSOURCE_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tTARGET_DATABASE_URL: z.preprocess(\n\t\t(val) => (typeof val === \"string\" && val.length === 0 ? undefined : val),\n\t\tz.string().url().optional(),\n\t),\n\tNETWORK: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tNETWORKS: networksSchema.optional(),\n\tLOG_LEVEL: z.enum([\"debug\", \"info\", \"warn\", \"error\"]).default(\"info\"),\n\tNODE_ENV: z\n\t\t.enum([\"development\", \"production\", \"test\"])\n\t\t.default(\"development\"),\n}) as unknown as z.ZodType<EnvSchemaOutput>;\n\nexport type Env = EnvSchemaOutput & {\n\tenabledNetworks: (\"mainnet\" | \"testnet\")[];\n};\n\nlet cachedEnv: Env | null = null;\n\nexport function getEnv(): Env {\n\tif (cachedEnv) {\n\t\treturn cachedEnv;\n\t}\n\n\tconst result = envSchema.safeParse(process.env);\n\n\tif (!result.success) {\n\t\tconsole.error(\"❌ Invalid environment configuration:\");\n\t\tconsole.error(z.treeifyError(result.error));\n\t\tthrow new Error(\"Invalid environment configuration\");\n\t}\n\n\t// Compute enabled networks from NETWORKS or NETWORK\n\tlet enabledNetworks: (\"mainnet\" | \"testnet\")[];\n\tif (result.data.NETWORKS && result.data.NETWORKS.length > 0) {\n\t\tenabledNetworks = result.data.NETWORKS;\n\t} else if (result.data.NETWORK) {\n\t\tenabledNetworks = [result.data.NETWORK];\n\t} else {\n\t\tenabledNetworks = [\"mainnet\"]; // Default\n\t}\n\n\tcachedEnv = { ...result.data, enabledNetworks };\n\treturn cachedEnv;\n}\n\n/**\n * True when `NODE_ENV=production`, read at RUNTIME — the single source of truth\n * for prod-vs-dev branching in this package.\n *\n * Why a helper instead of inlining `process.env.NODE_ENV === \"production\"`:\n * bunup/esbuild constant-folds the dot-access `process.env.NODE_ENV` to its\n * BUILD-time value. `@secondlayer/shared` is consumed by other services as its\n * built `dist`, so an inlined check freezes to a literal in the shipped bundle\n * (e.g. `const isProd = false`) and silently ignores the container's real\n * NODE_ENV. The bracket access below is NOT folded, so it stays a runtime read.\n * Route every prod check through here so the footgun lives in exactly one place.\n */\nexport function isProductionEnv(): boolean {\n\t// biome-ignore lint/complexity/useLiteralKeys: bracket access is deliberate — dot-access gets constant-folded by the bundler, freezing this to a build-time literal in the shipped dist.\n\treturn process.env[\"NODE_ENV\"] === \"production\";\n}\n\n/**\n * PoX-4 stacking decoder is ON by default — `/v1/index/stacking` is part of the\n * public surface, so the decoder that fills `pox4_calls` runs unless explicitly\n * opted out with `POX4_DECODER_ENABLED=false` (mirrors the sBTC decoder policy).\n */\nexport function isPox4DecoderEnabled(): boolean {\n\treturn process.env.POX4_DECODER_ENABLED !== \"false\";\n}\n\n// Export for testing\nexport { envSchema };\n",
6
6
  "import { getEnv } from \"./env.ts\";\n\ntype LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nconst LOG_LEVELS: Record<LogLevel, number> = {\n\tdebug: 0,\n\tinfo: 1,\n\twarn: 2,\n\terror: 3,\n};\n\nclass Logger {\n\tprivate _level?: LogLevel;\n\tprivate _isProduction?: boolean;\n\tprivate _initialized = false;\n\n\tprivate init() {\n\t\tif (this._initialized) return;\n\t\tthis._initialized = true;\n\t\ttry {\n\t\t\tconst env = getEnv();\n\t\t\tthis._level = env.LOG_LEVEL;\n\t\t\tthis._isProduction = env.NODE_ENV === \"production\";\n\t\t} catch {\n\t\t\t// Fallback when env is unavailable (e.g. tests without DATABASE_URL)\n\t\t\tthis._level = \"info\";\n\t\t\tthis._isProduction = false;\n\t\t}\n\t}\n\n\tprivate get level(): LogLevel {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._level!;\n\t}\n\n\tprivate get isProduction(): boolean {\n\t\tthis.init();\n\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\treturn this._isProduction!;\n\t}\n\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\treturn LOG_LEVELS[level] >= LOG_LEVELS[this.level];\n\t}\n\n\tprivate formatMessage(\n\t\tlevel: LogLevel,\n\t\tmessage: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tmeta?: Record<string, any>,\n\t) {\n\t\tconst timestamp = new Date().toISOString();\n\n\t\tif (this.isProduction) {\n\t\t\t// JSON output for production\n\t\t\treturn JSON.stringify({\n\t\t\t\ttimestamp,\n\t\t\t\tlevel,\n\t\t\t\tmessage,\n\t\t\t\t...meta,\n\t\t\t});\n\t\t}\n\n\t\t// Human-readable output for development\n\t\tconst metaStr = meta ? ` ${JSON.stringify(meta)}` : \"\";\n\t\treturn `[${timestamp}] ${level.toUpperCase()}: ${message}${metaStr}`;\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tdebug(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"debug\")) {\n\t\t\tconsole.debug(this.formatMessage(\"debug\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tinfo(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"info\")) {\n\t\t\tconsole.info(this.formatMessage(\"info\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\twarn(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"warn\")) {\n\t\t\tconsole.warn(this.formatMessage(\"warn\", message, meta));\n\t\t}\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\terror(message: string, meta?: Record<string, any>): void {\n\t\tif (this.shouldLog(\"error\")) {\n\t\t\tconsole.error(this.formatMessage(\"error\", message, meta));\n\t\t}\n\t}\n}\n\n// Export singleton instance\nexport const logger: Logger = new Logger();\n",
7
7
  "/**\n * Hiro public API client for backfilling historical block data.\n *\n * The stacks-node RPC `/v2/blocks/{height}` only returns block headers + tx IDs,\n * not full transaction data or events. The Hiro API serves complete block data\n * that we can transform into the NewBlockPayload format our indexer expects.\n */\n\nimport { logger } from \"../logger.ts\";\n\nconst DEFAULT_HIRO_API_URL = \"https://api.mainnet.hiro.so\";\n\n/** v2 /extended/v2/blocks/{height} response */\nexport interface HiroBlockResponse {\n\tcanonical: boolean;\n\theight: number;\n\thash: string;\n\tblock_time: number;\n\tblock_time_iso: string;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_time: number;\n\tminer_txid: string;\n\ttx_count: number;\n}\n\n/** v2 /extended/v2/blocks/{height}/transactions response */\nexport interface HiroBlockTxsResponse {\n\tlimit: number;\n\toffset: number;\n\ttotal: number;\n\tresults: HiroTxResponse[];\n}\n\nexport interface HiroTxResponse {\n\ttx_id: string;\n\ttx_type: string;\n\ttx_status: string;\n\tsender_address: string;\n\tfee_rate: string;\n\tnonce: number;\n\tblock_hash: string;\n\tblock_height: number;\n\tburn_block_height: number;\n\ttx_index: number;\n\tevent_count: number;\n\ttoken_transfer?: {\n\t\trecipient_address: string;\n\t\tamount: string;\n\t\tmemo: string;\n\t};\n\tcontract_call?: {\n\t\tcontract_id: string;\n\t\tfunction_name: string;\n\t\tfunction_args: unknown[];\n\t};\n\tsmart_contract?: {\n\t\tcontract_id: string;\n\t\tsource_code: string;\n\t};\n}\n\nexport interface HiroEvent {\n\tevent_index: number;\n\tevent_type: string; // \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n\ttx_id: string;\n\tasset?: {\n\t\tasset_event_type: string; // \"transfer\" | \"mint\" | \"burn\"\n\t\tsender?: string;\n\t\trecipient?: string;\n\t\tamount?: string;\n\t\tmemo?: string;\n\t\tasset_id?: string;\n\t\tvalue?: unknown;\n\t};\n\tcontract_log?: {\n\t\tcontract_id: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface HiroEventsResponse {\n\tlimit: number;\n\toffset: number;\n\tevents: HiroEvent[];\n}\n\n/** Shape our indexer expects at POST /new_block */\nexport interface NewBlockPayload {\n\tblock_hash: string;\n\tblock_height: number;\n\tindex_block_hash: string;\n\tparent_block_hash: string;\n\tparent_index_block_hash: string;\n\tburn_block_hash: string;\n\tburn_block_height: number;\n\tburn_block_timestamp: number;\n\tminer_txid: string;\n\ttimestamp: number;\n\ttransactions: TransactionPayload[];\n\tevents: TransactionEventPayload[];\n}\n\ninterface TransactionPayload {\n\ttxid: string;\n\traw_tx: string;\n\tstatus: string;\n\ttx_index: number;\n\ttx_type?: string;\n\tsender_address?: string;\n}\n\ninterface TransactionEventPayload {\n\ttxid: string;\n\tevent_index: number;\n\tcommitted: boolean;\n\ttype: string;\n\tstx_transfer_event?: {\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t\tmemo?: string;\n\t};\n\tstx_mint_event?: { recipient: string; amount: string };\n\tstx_burn_event?: { sender: string; amount: string };\n\tstx_lock_event?: {\n\t\tlocked_amount: string;\n\t\tunlock_height: string;\n\t\tlocked_address: string;\n\t};\n\tft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tamount: string;\n\t};\n\tft_burn_event?: { asset_identifier: string; sender: string; amount: string };\n\tnft_transfer_event?: {\n\t\tasset_identifier: string;\n\t\tsender: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_mint_event?: {\n\t\tasset_identifier: string;\n\t\trecipient: string;\n\t\tvalue: unknown;\n\t};\n\tnft_burn_event?: { asset_identifier: string; sender: string; value: unknown };\n\tsmart_contract_event?: {\n\t\tcontract_identifier: string;\n\t\ttopic: string;\n\t\tvalue: unknown;\n\t};\n}\n\nexport interface GetBlockOptions {\n\t/** Fetch actual raw_tx hex for each transaction (instead of \"0x00\" placeholder) */\n\tincludeRawTx?: boolean;\n\t/** Max concurrent raw_tx fetches per block (default: 10) */\n\trawTxConcurrency?: number;\n}\n\nexport class HiroClient {\n\tprivate apiUrl: string;\n\tprivate fallbackUrl: string | undefined;\n\tprivate apiKey: string | undefined;\n\tprivate maxRetries: number;\n\n\tconstructor(apiUrl?: string, maxRetries = 5) {\n\t\tthis.apiUrl = apiUrl || process.env.HIRO_API_URL || DEFAULT_HIRO_API_URL;\n\t\tthis.fallbackUrl = process.env.HIRO_FALLBACK_URL;\n\t\tthis.apiKey = process.env.HIRO_API_KEY;\n\t\tthis.maxRetries = maxRetries;\n\t}\n\n\tprivate get headers(): Record<string, string> {\n\t\treturn this.apiKey ? { \"x-hiro-api-key\": this.apiKey } : {};\n\t}\n\n\t/** Fetch with retry on 429/5xx using exponential backoff */\n\tprivate async fetchWithRetry(\n\t\turl: string,\n\t\ttimeoutMs = 120_000,\n\t): Promise<Response> {\n\t\tfor (let attempt = 0; attempt < this.maxRetries; attempt++) {\n\t\t\tconst res = await fetch(url, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t\t});\n\n\t\t\tif (res.ok || res.status === 404) return res;\n\n\t\t\tif (res.status === 429 || res.status >= 500) {\n\t\t\t\tconst delay = Math.min(1000 * 2 ** attempt, 10_000);\n\t\t\t\tlogger.info(\"Rate limited, retrying\", {\n\t\t\t\t\turl: url.split(\"/\").slice(-2).join(\"/\"),\n\t\t\t\t\tattempt,\n\t\t\t\t\tdelay,\n\t\t\t\t});\n\t\t\t\tawait new Promise((r) => setTimeout(r, delay));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// 4xx (not 404/429) — don't retry\n\t\t\treturn res;\n\t\t}\n\n\t\t// Final attempt\n\t\treturn fetch(url, {\n\t\t\theaders: this.headers,\n\t\t\tsignal: AbortSignal.timeout(timeoutMs),\n\t\t});\n\t}\n\n\t/**\n\t * Fetch a complete block by height, including all transactions and events,\n\t * transformed into the NewBlockPayload format our indexer expects.\n\t *\n\t * Uses 3-step approach:\n\t * 1. GET /extended/v2/blocks/{height} — block metadata\n\t * 2. GET /extended/v2/blocks/{height}/transactions — all txs (paginated)\n\t * 3. GET /extended/v1/tx/events?tx_id={txId} — events per tx (only for txs with events)\n\t */\n\tasync getBlockForIndexer(\n\t\theight: number,\n\t\toptions?: GetBlockOptions,\n\t): Promise<NewBlockPayload | null> {\n\t\t// 1. Fetch block metadata (try primary, fallback on 404)\n\t\tlet block = await this.fetchBlock(height);\n\t\tconst fallbackUrl = this.fallbackUrl;\n\t\tlet usingFallback = false;\n\t\tif (!block && fallbackUrl) {\n\t\t\tblock = await this.fetchBlock(height, fallbackUrl);\n\t\t\tif (block) usingFallback = true;\n\t\t}\n\t\tif (!block) return null;\n\n\t\t// 2. Fetch all transactions via v2 block/transactions endpoint\n\t\tconst baseUrl = usingFallback && fallbackUrl ? fallbackUrl : this.apiUrl;\n\t\tconst hiroTxs = await this.fetchBlockTransactions(height, baseUrl);\n\n\t\tconst txPayloads: TransactionPayload[] = [];\n\t\tconst eventPayloads: TransactionEventPayload[] = [];\n\n\t\tfor (const hiroTx of hiroTxs) {\n\t\t\ttxPayloads.push({\n\t\t\t\ttxid: hiroTx.tx_id,\n\t\t\t\traw_tx: \"0x00\",\n\t\t\t\tstatus: mapTxStatus(hiroTx.tx_status),\n\t\t\t\ttx_index: hiroTx.tx_index ?? 0,\n\t\t\t\ttx_type: mapTxType(hiroTx.tx_type),\n\t\t\t\tsender_address: hiroTx.sender_address,\n\t\t\t});\n\n\t\t\t// 3. Fetch events only for txs that have them\n\t\t\tif (hiroTx.event_count > 0) {\n\t\t\t\tif (hiroTx.event_count > 1000) {\n\t\t\t\t\tlogger.info(\"Fetching large event set\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\teventCount: hiroTx.event_count,\n\t\t\t\t\t\theight,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tconst events = await this.fetchAllEvents(hiroTx.tx_id, baseUrl);\n\t\t\t\t\teventPayloads.push(...events);\n\t\t\t\t} catch (err) {\n\t\t\t\t\tlogger.warn(\"Failed to fetch events for backfill\", {\n\t\t\t\t\t\ttxId: hiroTx.tx_id,\n\t\t\t\t\t\terror: String(err),\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// 4. Optionally fetch raw_tx for all transactions\n\t\tif (options?.includeRawTx && txPayloads.length > 0) {\n\t\t\tconst txIds = txPayloads.map((t) => t.txid);\n\t\t\tconst rawTxMap = await this.fetchRawTxBatch(\n\t\t\t\ttxIds,\n\t\t\t\toptions.rawTxConcurrency,\n\t\t\t);\n\t\t\tfor (const txPayload of txPayloads) {\n\t\t\t\tconst raw = rawTxMap.get(txPayload.txid);\n\t\t\t\tif (raw) txPayload.raw_tx = raw;\n\t\t\t}\n\t\t}\n\n\t\treturn {\n\t\t\tblock_hash: block.hash,\n\t\t\tblock_height: block.height,\n\t\t\tindex_block_hash: block.index_block_hash,\n\t\t\tparent_block_hash: block.parent_block_hash,\n\t\t\tparent_index_block_hash: block.parent_index_block_hash,\n\t\t\tburn_block_hash: block.burn_block_hash,\n\t\t\tburn_block_height: block.burn_block_height,\n\t\t\tburn_block_timestamp: block.burn_block_time,\n\t\t\tminer_txid: block.miner_txid,\n\t\t\ttimestamp: block.block_time,\n\t\t\ttransactions: txPayloads,\n\t\t\tevents: eventPayloads,\n\t\t};\n\t}\n\n\t/** v2 block metadata */\n\tprivate async fetchBlock(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroBlockResponse | null> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst res = await this.fetchWithRetry(\n\t\t\t`${url}/extended/v2/blocks/${height}`,\n\t\t);\n\t\tif (res.status === 404) return null;\n\t\tif (!res.ok)\n\t\t\tthrow new Error(`Hiro API block/${height} returned ${res.status}`);\n\t\treturn res.json() as Promise<HiroBlockResponse>;\n\t}\n\n\t/** v2 block transactions (paginated) */\n\tprivate async fetchBlockTransactions(\n\t\theight: number,\n\t\tbaseUrl?: string,\n\t): Promise<HiroTxResponse[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst txs: HiroTxResponse[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 50;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v2/blocks/${height}/transactions?limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Hiro API block/${height}/transactions returned ${res.status}`,\n\t\t\t\t);\n\n\t\t\tconst data = (await res.json()) as HiroBlockTxsResponse;\n\t\t\ttxs.push(...data.results);\n\n\t\t\tif (txs.length >= data.total || data.results.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn txs;\n\t}\n\n\tprivate async fetchAllEvents(\n\t\ttxId: string,\n\t\tbaseUrl?: string,\n\t\t_maxEvents?: number,\n\t): Promise<TransactionEventPayload[]> {\n\t\tconst url = baseUrl || this.apiUrl;\n\t\tconst events: TransactionEventPayload[] = [];\n\t\tlet offset = 0;\n\t\tconst limit = 100;\n\n\t\twhile (true) {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${url}/extended/v1/tx/events?tx_id=${txId}&limit=${limit}&offset=${offset}`,\n\t\t\t);\n\t\t\tif (!res.ok) {\n\t\t\t\tlogger.warn(\"Failed to fetch events from Hiro\", {\n\t\t\t\t\ttxId,\n\t\t\t\t\tstatus: res.status,\n\t\t\t\t});\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tconst data = (await res.json()) as HiroEventsResponse;\n\t\t\tfor (const hEvent of data.events) {\n\t\t\t\tconst converted = convertHiroEvent(hEvent);\n\t\t\t\tif (converted) events.push(converted);\n\t\t\t}\n\n\t\t\tif (data.events.length < limit) break;\n\t\t\toffset += limit;\n\t\t}\n\n\t\treturn events;\n\t}\n\n\t/** Fetch raw_tx hex for a single transaction */\n\tasync fetchRawTx(txId: string): Promise<string | null> {\n\t\ttry {\n\t\t\tconst res = await this.fetchWithRetry(\n\t\t\t\t`${this.apiUrl}/extended/v1/tx/${txId}/raw`,\n\t\t\t\t10_000,\n\t\t\t);\n\t\t\tif (!res.ok) return null;\n\t\t\tconst data = (await res.json()) as { raw_tx: string };\n\t\t\treturn data.raw_tx || null;\n\t\t} catch {\n\t\t\treturn null;\n\t\t}\n\t}\n\n\t/** Fetch raw_tx for multiple transactions with bounded concurrency */\n\tasync fetchRawTxBatch(\n\t\ttxIds: string[],\n\t\tconcurrency = 10,\n\t): Promise<Map<string, string>> {\n\t\tconst results = new Map<string, string>();\n\t\tfor (let i = 0; i < txIds.length; i += concurrency) {\n\t\t\tconst chunk = txIds.slice(i, i + concurrency);\n\t\t\tconst settled = await Promise.allSettled(\n\t\t\t\tchunk.map(async (txId) => {\n\t\t\t\t\tconst raw = await this.fetchRawTx(txId);\n\t\t\t\t\treturn { txId, raw };\n\t\t\t\t}),\n\t\t\t);\n\t\t\tfor (const result of settled) {\n\t\t\t\tif (result.status === \"fulfilled\" && result.value.raw) {\n\t\t\t\t\tresults.set(result.value.txId, result.value.raw);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn results;\n\t}\n\n\tgetApiUrl(): string {\n\t\treturn this.apiUrl;\n\t}\n}\n\n/** Map Hiro tx_status to our indexer's expected format */\nfunction mapTxStatus(status: string): string {\n\tswitch (status) {\n\t\tcase \"success\":\n\t\t\treturn \"success\";\n\t\tcase \"abort_by_response\":\n\t\tcase \"abort_by_post_condition\":\n\t\t\treturn status;\n\t\tdefault:\n\t\t\treturn \"success\";\n\t}\n}\n\n/** Map Hiro tx_type to node event tx_type */\nfunction mapTxType(type: string): string {\n\tswitch (type) {\n\t\tcase \"token_transfer\":\n\t\t\treturn \"token_transfer\";\n\t\tcase \"contract_call\":\n\t\t\treturn \"contract_call\";\n\t\tcase \"smart_contract\":\n\t\t\treturn \"smart_contract\";\n\t\tcase \"coinbase\":\n\t\t\treturn \"coinbase\";\n\t\tcase \"tenure_change\":\n\t\t\treturn \"tenure_change\";\n\t\tcase \"poison_microblock\":\n\t\t\treturn \"poison_microblock\";\n\t\tdefault:\n\t\t\treturn type;\n\t}\n}\n\n/**\n * Convert a Hiro API event to our indexer's TransactionEvent format.\n *\n * Hiro uses:\n * event_type: \"stx_asset\" | \"fungible_token_asset\" | \"non_fungible_token_asset\" | \"smart_contract_log\"\n * asset.asset_event_type: \"transfer\" | \"mint\" | \"burn\" | \"lock\"\n *\n * Our indexer expects:\n * type: \"stx_transfer_event\" | \"stx_mint_event\" | \"ft_transfer_event\" | \"smart_contract_event\" | ...\n */\nfunction convertHiroEvent(hEvent: HiroEvent): TransactionEventPayload | null {\n\tconst base = {\n\t\ttxid: hEvent.tx_id,\n\t\tevent_index: hEvent.event_index,\n\t\tcommitted: true,\n\t};\n\n\tif (hEvent.event_type === \"stx_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_transfer_event\",\n\t\t\t\t\tstx_transfer_event: {\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t\tmemo: a.memo,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_mint_event\",\n\t\t\t\t\tstx_mint_event: {\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_burn_event\",\n\t\t\t\t\tstx_burn_event: { sender: a.sender ?? \"\", amount: a.amount ?? \"0\" },\n\t\t\t\t};\n\t\t\tcase \"lock\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"stx_lock_event\",\n\t\t\t\t\tstx_lock_event: {\n\t\t\t\t\t\tlocked_amount: a.amount ?? \"0\",\n\t\t\t\t\t\tunlock_height: \"0\",\n\t\t\t\t\t\tlocked_address: a.sender ?? \"\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_transfer_event\",\n\t\t\t\t\tft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_mint_event\",\n\t\t\t\t\tft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"ft_burn_event\",\n\t\t\t\t\tft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tamount: a.amount ?? \"0\",\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"non_fungible_token_asset\" && hEvent.asset) {\n\t\tconst a = hEvent.asset;\n\t\tconst assetId = a.asset_id || \"\";\n\t\tswitch (a.asset_event_type) {\n\t\t\tcase \"transfer\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_transfer_event\",\n\t\t\t\t\tnft_transfer_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"mint\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_mint_event\",\n\t\t\t\t\tnft_mint_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\trecipient: a.recipient ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\tcase \"burn\":\n\t\t\t\treturn {\n\t\t\t\t\t...base,\n\t\t\t\t\ttype: \"nft_burn_event\",\n\t\t\t\t\tnft_burn_event: {\n\t\t\t\t\t\tasset_identifier: assetId,\n\t\t\t\t\t\tsender: a.sender ?? \"\",\n\t\t\t\t\t\tvalue: a.value,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t}\n\t}\n\n\tif (hEvent.event_type === \"smart_contract_log\" && hEvent.contract_log) {\n\t\treturn {\n\t\t\t...base,\n\t\t\ttype: \"smart_contract_event\",\n\t\t\tsmart_contract_event: {\n\t\t\t\tcontract_identifier: hEvent.contract_log.contract_id,\n\t\t\t\ttopic: hEvent.contract_log.topic,\n\t\t\t\tvalue: hEvent.contract_log.value,\n\t\t\t},\n\t\t};\n\t}\n\n\tlogger.debug(\"Unknown Hiro event type, skipping\", {\n\t\teventType: hEvent.event_type,\n\t\ttxId: hEvent.tx_id,\n\t});\n\treturn null;\n}\n"
8
8
  ],
9
9
  "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,CAAC,QAAQ;AAAA,EACpD,MAAM,WAAW,IACf,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,OAAO,OAAO;AAAA,EAChB,MAAM,QAAQ,CAAC,WAAW,SAAS;AAAA,EACnC,WAAW,KAAK,UAAU;AAAA,IACzB,IAAI,CAAC,MAAM,SAAS,CAAC,GAAG;AAAA,MACvB,MAAM,IAAI,MACT,oBAAoB,sBAAsB,MAAM,KAAK,IAAI,GAC1D;AAAA,IACD;AAAA,EACD;AAAA,EACA,OAAO;AAAA,CACP;AAsBD,IAAM,YAAwC,EAAE,OAAO;AAAA,EACtD,cAAc,EAAE,WACf,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B;AAAA,EACA,qBAAqB,EAAE,WACtB,CAAC,QAAS,OAAO,QAAQ,YAAY,IAAI,WAAW,IAAI,YAAY,KACpE,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,CAC3B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AM;AAAA,UACN,gBAAgB;AAAA,YACf,kBAAkB;AAAA,YAClB,QAAQ,EAAE,UAAU;AAAA,YACpB,OAAO,EAAE;AAAA,UACV;AAAA,QACD;AAAA;AAAA,EAEH;AAAA,EAEA,IAAI,OAAO,eAAe,wBAAwB,OAAO,cAAc;AAAA,IACtE,OAAO;AAAA,SACH;AAAA,MACH,MAAM;AAAA,MACN,sBAAsB;AAAA,QACrB,qBAAqB,OAAO,aAAa;AAAA,QACzC,OAAO,OAAO,aAAa;AAAA,QAC3B,OAAO,OAAO,aAAa;AAAA,MAC5B;AAAA,IACD;AAAA,EACD;AAAA,EAEA,OAAO,MAAM,qCAAqC;AAAA,IACjD,WAAW,OAAO;AAAA,IAClB,MAAM,OAAO;AAAA,EACd,CAAC;AAAA,EACD,OAAO;AAAA;",
10
- "debugId": "1FB15B4363B2E96864756E2164756E21",
10
+ "debugId": "62A7E2C25A1EFE8B64756E2164756E21",
11
11
  "names": []
12
12
  }
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v4";
1
+ import { z } from "zod";
2
2
  interface StxTransferFilter {
3
3
  type: "stx_transfer";
4
4
  sender?: string;
@@ -16,7 +16,7 @@ var __export = (target, all) => {
16
16
 
17
17
  // src/schemas/filters.ts
18
18
  import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
19
- import { z } from "zod/v4";
19
+ import { z } from "zod";
20
20
  var isValidAddress = _isValidAddress;
21
21
  var stacksPrincipal = z.string().refine((val) => {
22
22
  const parts = val.split(".");
@@ -134,5 +134,5 @@ export {
134
134
  ContractCallFilterSchema
135
135
  };
136
136
 
137
- //# debugId=DB823597308735A664756E2164756E21
137
+ //# debugId=22EC52EBFE392C8E64756E2164756E21
138
138
  //# sourceMappingURL=filters.js.map
@@ -2,9 +2,9 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/schemas/filters.ts"],
4
4
  "sourcesContent": [
5
- "import { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\nimport { z } from \"zod/v4\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\n\n/** Validate a Stacks principal (standard or contract, e.g. SP2J...ABC or SP2J...ABC.contract-name) */\nconst stacksPrincipal = z.string().refine((val) => {\n\tconst parts = val.split(\".\");\n\tif (parts.length > 2) return false;\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn isValidAddress(parts[0]!);\n}, \"Invalid Stacks principal address\");\n\n// Base filter with common fields\nconst baseFilter = {\n\t// Optional: filter by sender\n\tsender: stacksPrincipal.optional(),\n\t// Optional: filter by recipient\n\trecipient: stacksPrincipal.optional(),\n};\n\n// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n\ttype: \"stx_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tminAmount?: number;\n\tmaxAmount?: number;\n}\n\nexport interface StxMintFilter {\n\ttype: \"stx_mint\";\n\trecipient?: string;\n\tminAmount?: number;\n}\n\nexport interface StxBurnFilter {\n\ttype: \"stx_burn\";\n\tsender?: string;\n\tminAmount?: number;\n}\n\nexport interface StxLockFilter {\n\ttype: \"stx_lock\";\n\tlockedAddress?: string;\n\tminAmount?: number;\n}\n\nexport interface FtTransferFilter {\n\ttype: \"ft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtMintFilter {\n\ttype: \"ft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtBurnFilter {\n\ttype: \"ft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface NftTransferFilter {\n\ttype: \"nft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftMintFilter {\n\ttype: \"nft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftBurnFilter {\n\ttype: \"nft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface ContractCallFilter {\n\ttype: \"contract_call\";\n\tcontractId?: string;\n\tfunctionName?: string;\n\tcaller?: string;\n}\n\nexport interface ContractDeployFilter {\n\ttype: \"contract_deploy\";\n\tdeployer?: string;\n\tcontractName?: string;\n}\n\nexport interface PrintEventFilter {\n\ttype: \"print_event\";\n\tcontractId?: string;\n\ttopic?: string;\n\tcontains?: string;\n}\n\nexport type EventFilter =\n\t| StxTransferFilter\n\t| StxMintFilter\n\t| StxBurnFilter\n\t| StxLockFilter\n\t| FtTransferFilter\n\t| FtMintFilter\n\t| FtBurnFilter\n\t| NftTransferFilter\n\t| NftMintFilter\n\t| NftBurnFilter\n\t| ContractCallFilter\n\t| ContractDeployFilter\n\t| PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = z.object({\n\ttype: z.literal(\"stx_transfer\"),\n\t...baseFilter,\n\t// Optional: minimum amount in microSTX\n\tminAmount: z.coerce.number().int().positive().optional(),\n\t// Optional: maximum amount in microSTX\n\tmaxAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Mint Filter\nexport const StxMintFilterSchema: z.ZodType<StxMintFilter> = z.object({\n\ttype: z.literal(\"stx_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Burn Filter\nexport const StxBurnFilterSchema: z.ZodType<StxBurnFilter> = z.object({\n\ttype: z.literal(\"stx_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Lock Filter\nexport const StxLockFilterSchema: z.ZodType<StxLockFilter> = z.object({\n\ttype: z.literal(\"stx_lock\"),\n\tlockedAddress: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Transfer Filter\nexport const FtTransferFilterSchema: z.ZodType<FtTransferFilter> = z.object({\n\ttype: z.literal(\"ft_transfer\"),\n\t...baseFilter,\n\t// Contract that defines the token (e.g., SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx)\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Mint Filter\nexport const FtMintFilterSchema: z.ZodType<FtMintFilter> = z.object({\n\ttype: z.literal(\"ft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Burn Filter\nexport const FtBurnFilterSchema: z.ZodType<FtBurnFilter> = z.object({\n\ttype: z.literal(\"ft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// NFT Transfer Filter\nexport const NftTransferFilterSchema: z.ZodType<NftTransferFilter> = z.object({\n\ttype: z.literal(\"nft_transfer\"),\n\t...baseFilter,\n\tassetIdentifier: z.string().optional(),\n\t// Optional: filter by specific token ID (Clarity value as hex)\n\ttokenId: z.string().optional(),\n});\n\n// NFT Mint Filter\nexport const NftMintFilterSchema: z.ZodType<NftMintFilter> = z.object({\n\ttype: z.literal(\"nft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// NFT Burn Filter\nexport const NftBurnFilterSchema: z.ZodType<NftBurnFilter> = z.object({\n\ttype: z.literal(\"nft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// Contract Call Filter\nexport const ContractCallFilterSchema: z.ZodType<ContractCallFilter> = z.object(\n\t{\n\t\ttype: z.literal(\"contract_call\"),\n\t\t// Contract being called\n\t\tcontractId: stacksPrincipal.optional(),\n\t\t// Function name (supports wildcards with *)\n\t\tfunctionName: z.string().optional(),\n\t\t// Caller address\n\t\tcaller: stacksPrincipal.optional(),\n\t},\n);\n\n// Contract Deploy Filter\nexport const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter> =\n\tz.object({\n\t\ttype: z.literal(\"contract_deploy\"),\n\t\t// Deployer address\n\t\tdeployer: stacksPrincipal.optional(),\n\t\t// Contract name pattern (supports wildcards)\n\t\tcontractName: z.string().optional(),\n\t});\n\n// Print Event Filter (smart contract events)\nexport const PrintEventFilterSchema: z.ZodType<PrintEventFilter> = z.object({\n\ttype: z.literal(\"print_event\"),\n\t// Contract emitting the event\n\tcontractId: stacksPrincipal.optional(),\n\t// Topic/name of the event\n\ttopic: z.string().optional(),\n\t// Search for substring in event data\n\tcontains: z.string().optional(),\n});\n\n// Union of all filter types\nexport const EventFilterSchema: z.ZodType<EventFilter> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxLockFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractCallFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractDeployFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tPrintEventFilterSchema as any,\n\t],\n);\n"
5
+ "import { isValidAddress as _isValidAddress } from \"@secondlayer/stacks\";\nimport { z } from \"zod\";\n\nconst isValidAddress = _isValidAddress as (addr: string) => boolean;\n\n/** Validate a Stacks principal (standard or contract, e.g. SP2J...ABC or SP2J...ABC.contract-name) */\nconst stacksPrincipal = z.string().refine((val) => {\n\tconst parts = val.split(\".\");\n\tif (parts.length > 2) return false;\n\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\treturn isValidAddress(parts[0]!);\n}, \"Invalid Stacks principal address\");\n\n// Base filter with common fields\nconst baseFilter = {\n\t// Optional: filter by sender\n\tsender: stacksPrincipal.optional(),\n\t// Optional: filter by recipient\n\trecipient: stacksPrincipal.optional(),\n};\n\n// Type exports — defined first so they can annotate schemas\nexport interface StxTransferFilter {\n\ttype: \"stx_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tminAmount?: number;\n\tmaxAmount?: number;\n}\n\nexport interface StxMintFilter {\n\ttype: \"stx_mint\";\n\trecipient?: string;\n\tminAmount?: number;\n}\n\nexport interface StxBurnFilter {\n\ttype: \"stx_burn\";\n\tsender?: string;\n\tminAmount?: number;\n}\n\nexport interface StxLockFilter {\n\ttype: \"stx_lock\";\n\tlockedAddress?: string;\n\tminAmount?: number;\n}\n\nexport interface FtTransferFilter {\n\ttype: \"ft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtMintFilter {\n\ttype: \"ft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface FtBurnFilter {\n\ttype: \"ft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\tminAmount?: number;\n}\n\nexport interface NftTransferFilter {\n\ttype: \"nft_transfer\";\n\tsender?: string;\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftMintFilter {\n\ttype: \"nft_mint\";\n\trecipient?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface NftBurnFilter {\n\ttype: \"nft_burn\";\n\tsender?: string;\n\tassetIdentifier?: string;\n\ttokenId?: string;\n}\n\nexport interface ContractCallFilter {\n\ttype: \"contract_call\";\n\tcontractId?: string;\n\tfunctionName?: string;\n\tcaller?: string;\n}\n\nexport interface ContractDeployFilter {\n\ttype: \"contract_deploy\";\n\tdeployer?: string;\n\tcontractName?: string;\n}\n\nexport interface PrintEventFilter {\n\ttype: \"print_event\";\n\tcontractId?: string;\n\ttopic?: string;\n\tcontains?: string;\n}\n\nexport type EventFilter =\n\t| StxTransferFilter\n\t| StxMintFilter\n\t| StxBurnFilter\n\t| StxLockFilter\n\t| FtTransferFilter\n\t| FtMintFilter\n\t| FtBurnFilter\n\t| NftTransferFilter\n\t| NftMintFilter\n\t| NftBurnFilter\n\t| ContractCallFilter\n\t| ContractDeployFilter\n\t| PrintEventFilter;\n\n// STX Transfer Filter\nexport const StxTransferFilterSchema: z.ZodType<StxTransferFilter> = z.object({\n\ttype: z.literal(\"stx_transfer\"),\n\t...baseFilter,\n\t// Optional: minimum amount in microSTX\n\tminAmount: z.coerce.number().int().positive().optional(),\n\t// Optional: maximum amount in microSTX\n\tmaxAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Mint Filter\nexport const StxMintFilterSchema: z.ZodType<StxMintFilter> = z.object({\n\ttype: z.literal(\"stx_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Burn Filter\nexport const StxBurnFilterSchema: z.ZodType<StxBurnFilter> = z.object({\n\ttype: z.literal(\"stx_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// STX Lock Filter\nexport const StxLockFilterSchema: z.ZodType<StxLockFilter> = z.object({\n\ttype: z.literal(\"stx_lock\"),\n\tlockedAddress: stacksPrincipal.optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Transfer Filter\nexport const FtTransferFilterSchema: z.ZodType<FtTransferFilter> = z.object({\n\ttype: z.literal(\"ft_transfer\"),\n\t...baseFilter,\n\t// Contract that defines the token (e.g., SP3K8BC0PPEVCV7NZ6QSRWPQ2JE9E5B6N3PA0KBR9.token-wstx)\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Mint Filter\nexport const FtMintFilterSchema: z.ZodType<FtMintFilter> = z.object({\n\ttype: z.literal(\"ft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// FT Burn Filter\nexport const FtBurnFilterSchema: z.ZodType<FtBurnFilter> = z.object({\n\ttype: z.literal(\"ft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\tminAmount: z.coerce.number().int().positive().optional(),\n});\n\n// NFT Transfer Filter\nexport const NftTransferFilterSchema: z.ZodType<NftTransferFilter> = z.object({\n\ttype: z.literal(\"nft_transfer\"),\n\t...baseFilter,\n\tassetIdentifier: z.string().optional(),\n\t// Optional: filter by specific token ID (Clarity value as hex)\n\ttokenId: z.string().optional(),\n});\n\n// NFT Mint Filter\nexport const NftMintFilterSchema: z.ZodType<NftMintFilter> = z.object({\n\ttype: z.literal(\"nft_mint\"),\n\trecipient: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// NFT Burn Filter\nexport const NftBurnFilterSchema: z.ZodType<NftBurnFilter> = z.object({\n\ttype: z.literal(\"nft_burn\"),\n\tsender: stacksPrincipal.optional(),\n\tassetIdentifier: z.string().optional(),\n\ttokenId: z.string().optional(),\n});\n\n// Contract Call Filter\nexport const ContractCallFilterSchema: z.ZodType<ContractCallFilter> = z.object(\n\t{\n\t\ttype: z.literal(\"contract_call\"),\n\t\t// Contract being called\n\t\tcontractId: stacksPrincipal.optional(),\n\t\t// Function name (supports wildcards with *)\n\t\tfunctionName: z.string().optional(),\n\t\t// Caller address\n\t\tcaller: stacksPrincipal.optional(),\n\t},\n);\n\n// Contract Deploy Filter\nexport const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter> =\n\tz.object({\n\t\ttype: z.literal(\"contract_deploy\"),\n\t\t// Deployer address\n\t\tdeployer: stacksPrincipal.optional(),\n\t\t// Contract name pattern (supports wildcards)\n\t\tcontractName: z.string().optional(),\n\t});\n\n// Print Event Filter (smart contract events)\nexport const PrintEventFilterSchema: z.ZodType<PrintEventFilter> = z.object({\n\ttype: z.literal(\"print_event\"),\n\t// Contract emitting the event\n\tcontractId: stacksPrincipal.optional(),\n\t// Topic/name of the event\n\ttopic: z.string().optional(),\n\t// Search for substring in event data\n\tcontains: z.string().optional(),\n});\n\n// Union of all filter types\nexport const EventFilterSchema: z.ZodType<EventFilter> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tStxLockFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tFtBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftTransferFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftMintFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tNftBurnFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractCallFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tContractDeployFilterSchema as any,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tPrintEventFilterSchema as any,\n\t],\n);\n"
6
6
  ],
7
7
  "mappings": ";;;;;;;;;;;;;;;;;AAAA,2BAAS;AACT;AAEA,IAAM,iBAAiB;AAGvB,IAAM,kBAAkB,EAAE,OAAO,EAAE,OAAO,CAAC,QAAQ;AAAA,EAClD,MAAM,QAAQ,IAAI,MAAM,GAAG;AAAA,EAC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M,6BACZ,EAAE,OAAO;AAAA,EACR,MAAM,EAAE,QAAQ,iBAAiB;AAAA,EAEjC,UAAU,gBAAgB,SAAS;AAAA,EAEnC,cAAc,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AAGK,IAAM,yBAAsD,EAAE,OAAO;AAAA,EAC3E,MAAM,EAAE,QAAQ,aAAa;AAAA,EAE7B,YAAY,gBAAgB,SAAS;AAAA,EAErC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAE3B,UAAU,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAGM,IAAM,oBAA4C,EAAE,mBAC1D,QACA;AAAA,EAEC;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AAAA,EAEA;AACD,CACD;",
8
- "debugId": "DB823597308735A664756E2164756E21",
8
+ "debugId": "22EC52EBFE392C8E64756E2164756E21",
9
9
  "names": []
10
10
  }
@@ -1,4 +1,4 @@
1
- import { z } from "zod/v4";
1
+ import { z } from "zod";
2
2
  interface StxTransferFilter {
3
3
  type: "stx_transfer";
4
4
  sender?: string;
@@ -91,7 +91,7 @@ declare const ContractCallFilterSchema: z.ZodType<ContractCallFilter>;
91
91
  declare const ContractDeployFilterSchema: z.ZodType<ContractDeployFilter>;
92
92
  declare const PrintEventFilterSchema: z.ZodType<PrintEventFilter>;
93
93
  declare const EventFilterSchema: z.ZodType<EventFilter>;
94
- import { z as z2 } from "zod/v4";
94
+ import { z as z2 } from "zod";
95
95
  interface DeploySubgraphRequest {
96
96
  name: string;
97
97
  version?: string;
@@ -318,7 +318,7 @@ interface SubgraphAggregateResponse {
318
318
  min?: Record<string, string | null>;
319
319
  max?: Record<string, string | null>;
320
320
  }
321
- import { z as z3 } from "zod/v4";
321
+ import { z as z3 } from "zod";
322
322
  declare const SUBSCRIPTION_FORMATS: readonly ["standard-webhooks", "inngest", "trigger", "cloudflare", "cloudevents", "raw"];
323
323
  declare const SUBSCRIPTION_RUNTIMES: readonly ["inngest", "trigger", "cloudflare", "node"];
324
324
  declare const SUBSCRIPTION_STATUSES: readonly ["active", "paused", "error"];
@@ -16,7 +16,7 @@ var __export = (target, all) => {
16
16
 
17
17
  // src/schemas/filters.ts
18
18
  import { isValidAddress as _isValidAddress } from "@secondlayer/stacks";
19
- import { z } from "zod/v4";
19
+ import { z } from "zod";
20
20
  var isValidAddress = _isValidAddress;
21
21
  var stacksPrincipal = z.string().refine((val) => {
22
22
  const parts = val.split(".");
@@ -119,7 +119,7 @@ var EventFilterSchema = z.discriminatedUnion("type", [
119
119
  ]);
120
120
 
121
121
  // src/schemas/subgraphs.ts
122
- import { z as z2 } from "zod/v4";
122
+ import { z as z2 } from "zod";
123
123
  var DeploySubgraphRequestSchema = z2.object({
124
124
  name: z2.string().regex(/^[a-z0-9-]+$/, "lowercase alphanumeric + hyphens only").max(63),
125
125
  version: z2.string().optional(),
@@ -135,7 +135,7 @@ var DeploySubgraphRequestSchema = z2.object({
135
135
  });
136
136
 
137
137
  // src/schemas/subscriptions.ts
138
- import { z as z3 } from "zod/v4";
138
+ import { z as z3 } from "zod";
139
139
  var SUBSCRIPTION_FORMATS = [
140
140
  "standard-webhooks",
141
141
  "inngest",
@@ -538,5 +538,5 @@ export {
538
538
  CHAIN_TRIGGER_FIELDS
539
539
  };
540
540
 
541
- //# debugId=BD30EE809E5DF72D64756E2164756E21
541
+ //# debugId=0630F78448A93F0564756E2164756E21
542
542
  //# sourceMappingURL=index.js.map