@secondlayer/shared 6.33.1 → 6.33.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.
- package/dist/src/crypto/secondlayer-webhook.d.ts +15 -1
- package/dist/src/crypto/secondlayer-webhook.js +66 -1
- package/dist/src/crypto/secondlayer-webhook.js.map +5 -4
- package/dist/src/db/index.d.ts +15 -1
- package/dist/src/db/index.js +6 -2
- package/dist/src/db/index.js.map +6 -6
- package/dist/src/db/queries/chain-reorgs.d.ts +10 -0
- package/dist/src/db/queries/chain-reorgs.js +6 -2
- package/dist/src/db/queries/chain-reorgs.js.map +6 -6
- package/dist/src/db/queries/contracts.d.ts +10 -0
- package/dist/src/db/queries/integrity.d.ts +10 -0
- package/dist/src/db/queries/subgraph-gaps.d.ts +10 -0
- package/dist/src/db/queries/subgraph-operations.d.ts +10 -0
- package/dist/src/db/queries/subgraphs.d.ts +10 -0
- package/dist/src/db/queries/subgraphs.js +6 -2
- package/dist/src/db/queries/subgraphs.js.map +6 -6
- package/dist/src/db/queries/subscriptions.d.ts +10 -0
- package/dist/src/db/schema.d.ts +14 -1
- package/dist/src/env.d.ts +14 -1
- package/dist/src/env.js +5 -1
- package/dist/src/env.js.map +3 -3
- package/dist/src/index.d.ts +15 -1
- package/dist/src/index.js +6 -2
- package/dist/src/index.js.map +6 -6
- package/dist/src/leader.js +4 -1
- package/dist/src/leader.js.map +3 -3
- package/dist/src/logger.js +4 -1
- package/dist/src/logger.js.map +3 -3
- package/dist/src/node/archive-client.js +4 -1
- package/dist/src/node/archive-client.js.map +3 -3
- package/dist/src/node/hiro-client.js +4 -1
- package/dist/src/node/hiro-client.js.map +3 -3
- package/dist/src/node/local-client.d.ts +10 -0
- package/migrations/0100_account_credits.ts +37 -0
- package/package.json +1 -1
package/dist/src/leader.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/env.ts", "../src/logger.ts", "../src/leader.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 * 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/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",
|
|
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
|
"import postgres from \"postgres\";\nimport { logger } from \"./logger.ts\";\n\n/**\n * Single-leader election via a Postgres session advisory lock.\n *\n * Exactly one process across the fleet holds `lockKey` and runs the leader-only\n * work. Others poll and take over if the leader exits or its connection dies.\n * The lock lives on a dedicated long-lived connection — a pooled connection\n * would silently drop a session lock — and is released by closing it.\n *\n * Lock keys are centralized here so the fleet-wide set stays distinct: a\n * collision would let two unrelated singletons exclude each other.\n */\n\n/** Advisory lock key for the indexer's singleton loops. */\nexport const INDEXER_LEADER_LOCK_KEY = 770_2026;\n/** Advisory lock key for the chain-subscription trigger evaluator (+ its\n * chain-reorg cursor rewind — they mutate the same `trigger_evaluator_state`\n * row and so must share one lock). */\nexport const SUBSCRIPTION_EVALUATOR_LOCK_KEY = 770_2027;\n/** Advisory lock key for the subgraph catch-up driver. */\nexport const SUBGRAPH_CATCHUP_LOCK_KEY = 770_2028;\n\nexport type StopFn = () => void | Promise<void>;\n\n/**\n * Backend for the advisory lock. Abstracted so the election logic is testable\n * without a database; the default is Postgres-backed.\n */\nexport type LeaderBackend = {\n\t/** Try to grab the lock without blocking. */\n\ttryAcquire(lockKey: number): Promise<boolean>;\n\t/** Liveness check; throws if the lock-holding connection is gone. */\n\tping(): Promise<void>;\n\t/** Release the lock (closes the dedicated connection). */\n\tclose(): Promise<void>;\n};\n\nfunction leaderDatabaseUrl(): string {\n\treturn (\n\t\tprocess.env.SOURCE_DATABASE_URL ||\n\t\tprocess.env.DATABASE_URL ||\n\t\t\"postgres://localhost:5432/secondlayer\"\n\t);\n}\n\n/**\n * Postgres-backed advisory lock on a dedicated connection.\n *\n * Pass an explicit `url` to pin the lock to the DB that holds the serialized\n * row — after the source/target split, control-plane state (subscriptions,\n * subgraphs) lives on the target DB, so a lock on the default source DB would\n * guard nothing.\n */\nexport function createPostgresLeaderBackend(url?: string): LeaderBackend {\n\tconst resolvedUrl = url ?? leaderDatabaseUrl();\n\tconst host = (() => {\n\t\ttry {\n\t\t\treturn new URL(resolvedUrl).hostname;\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\t})();\n\tconst isLocal =\n\t\thost === \"localhost\" || host === \"127.0.0.1\" || !host.includes(\".\");\n\t// max:1 + idle_timeout:0 keeps one connection open so the session lock holds.\n\tconst sql = postgres(resolvedUrl, {\n\t\tmax: 1,\n\t\tidle_timeout: 0,\n\t\tssl: isLocal\n\t\t\t? undefined\n\t\t\t: {\n\t\t\t\t\trejectUnauthorized: process.env.NODE_TLS_REJECT_UNAUTHORIZED !== \"0\",\n\t\t\t\t},\n\t});\n\treturn {\n\t\tasync tryAcquire(lockKey) {\n\t\t\tconst rows = await sql<{ locked: boolean }[]>`\n\t\t\t\tSELECT pg_try_advisory_lock(${lockKey}) AS locked\n\t\t\t`;\n\t\t\treturn rows[0]?.locked === true;\n\t\t},\n\t\tasync ping() {\n\t\t\t// Verify we STILL hold the advisory lock — not just that the connection\n\t\t\t// is alive. The driver auto-reconnects transparently; a reconnect starts\n\t\t\t// a new backend session, which silently drops the session-scoped lock. A\n\t\t\t// plain `SELECT 1` would succeed on the new session and never notice, so\n\t\t\t// two instances could both believe they're leader. The lock is held on\n\t\t\t// this (max:1) connection, so count advisory locks on the current\n\t\t\t// backend; 0 means we lost it (reconnect) → relinquish + re-elect.\n\t\t\tconst rows = await sql<{ held: number }[]>`\n\t\t\t\tSELECT count(*)::int AS held\n\t\t\t\tFROM pg_locks\n\t\t\t\tWHERE locktype = 'advisory' AND pid = pg_backend_pid()\n\t\t\t`;\n\t\t\tif ((rows[0]?.held ?? 0) === 0) {\n\t\t\t\tthrow new Error(\"advisory lock no longer held (connection reset?)\");\n\t\t\t}\n\t\t},\n\t\tasync close() {\n\t\t\t// Closing the session releases all advisory locks it held.\n\t\t\tawait sql.end({ timeout: 5 });\n\t\t},\n\t};\n}\n\nexport type WithLeaderLockOptions = {\n\tpollMs?: number;\n\theartbeatMs?: number;\n\t/** Injectable for tests; defaults to the Postgres backend. */\n\tcreateBackend?: () => LeaderBackend;\n};\n\n/**\n * Run `startWork` only while this process is leader. Returns a stop function\n * that ends election, stops the work, and releases the lock.\n */\nexport function withLeaderLock(\n\tlockKey: number,\n\tstartWork: () => StopFn | Promise<StopFn>,\n\topts: WithLeaderLockOptions = {},\n): () => Promise<void> {\n\tconst pollMs = opts.pollMs ?? 15_000;\n\tconst heartbeatMs = opts.heartbeatMs ?? 10_000;\n\tconst backend = (opts.createBackend ?? createPostgresLeaderBackend)();\n\n\tlet stopped = false;\n\tlet isLeader = false;\n\tlet stopWork: StopFn | null = null;\n\tlet pollTimer: ReturnType<typeof setInterval> | null = null;\n\tlet heartbeatTimer: ReturnType<typeof setInterval> | null = null;\n\n\tasync function relinquish() {\n\t\tisLeader = false;\n\t\tif (heartbeatTimer) {\n\t\t\tclearInterval(heartbeatTimer);\n\t\t\theartbeatTimer = null;\n\t\t}\n\t\tif (stopWork) {\n\t\t\ttry {\n\t\t\t\tawait stopWork();\n\t\t\t} catch (err) {\n\t\t\t\tlogger.warn(\"Leader work stop failed\", { error: String(err) });\n\t\t\t}\n\t\t\tstopWork = null;\n\t\t}\n\t}\n\n\tfunction startHeartbeat() {\n\t\theartbeatTimer = setInterval(async () => {\n\t\t\tif (stopped || !isLeader) return;\n\t\t\ttry {\n\t\t\t\tawait backend.ping();\n\t\t\t} catch (err) {\n\t\t\t\tlogger.warn(\"Leader heartbeat failed; relinquishing\", {\n\t\t\t\t\tlockKey,\n\t\t\t\t\terror: String(err),\n\t\t\t\t});\n\t\t\t\tawait relinquish();\n\t\t\t}\n\t\t}, heartbeatMs);\n\t}\n\n\tasync function tryAcquire() {\n\t\tif (stopped || isLeader) return;\n\t\ttry {\n\t\t\tif (await backend.tryAcquire(lockKey)) {\n\t\t\t\tisLeader = true;\n\t\t\t\tlogger.info(\"Acquired leader lock\", { lockKey });\n\t\t\t\tstopWork = await startWork();\n\t\t\t\tstartHeartbeat();\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tlogger.warn(\"Leader lock acquire failed\", {\n\t\t\t\tlockKey,\n\t\t\t\terror: String(err),\n\t\t\t});\n\t\t}\n\t}\n\n\tpollTimer = setInterval(tryAcquire, pollMs);\n\tvoid tryAcquire();\n\n\treturn async () => {\n\t\tstopped = true;\n\t\tif (pollTimer) clearInterval(pollTimer);\n\t\tawait relinquish();\n\t\tawait backend.close().catch(() => {});\n\t};\n}\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EA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;AAAA,OAEhB,WAAW;AAAA;AAAA,EAGf,eAAe,UAAU,GAAG;AAAA,IAC3B,IAAI,WAAW;AAAA,MAAU;AAAA,IACzB,IAAI;AAAA,MACH,IAAI,MAAM,QAAQ,WAAW,OAAO,GAAG;AAAA,QACtC,WAAW;AAAA,QACX,OAAO,KAAK,wBAAwB,EAAE,QAAQ,CAAC;AAAA,QAC/C,WAAW,MAAM,UAAU;AAAA,QAC3B,eAAe;AAAA,MAChB;AAAA,MACC,OAAO,KAAK;AAAA,MACb,OAAO,KAAK,8BAA8B;AAAA,QACzC;AAAA,QACA,OAAO,OAAO,GAAG;AAAA,MAClB,CAAC;AAAA;AAAA;AAAA,EAIH,YAAY,YAAY,YAAY,MAAM;AAAA,EACrC,WAAW;AAAA,EAEhB,OAAO,YAAY;AAAA,IAClB,UAAU;AAAA,IACV,IAAI;AAAA,MAAW,cAAc,SAAS;AAAA,IACtC,MAAM,WAAW;AAAA,IACjB,MAAM,QAAQ,MAAM,EAAE,MAAM,MAAM,EAAE;AAAA;AAAA;",
|
|
10
|
+
"debugId": "9BB99206C51AF0D164756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/src/logger.js
CHANGED
|
@@ -57,6 +57,9 @@ function getEnv() {
|
|
|
57
57
|
cachedEnv = { ...result.data, enabledNetworks };
|
|
58
58
|
return cachedEnv;
|
|
59
59
|
}
|
|
60
|
+
function isProductionEnv() {
|
|
61
|
+
return process.env["NODE_ENV"] === "production";
|
|
62
|
+
}
|
|
60
63
|
function isPox4DecoderEnabled() {
|
|
61
64
|
return process.env.POX4_DECODER_ENABLED !== "false";
|
|
62
65
|
}
|
|
@@ -135,5 +138,5 @@ export {
|
|
|
135
138
|
logger
|
|
136
139
|
};
|
|
137
140
|
|
|
138
|
-
//# debugId=
|
|
141
|
+
//# debugId=33C9C7B4C1B00A7964756E2164756E21
|
|
139
142
|
//# sourceMappingURL=logger.js.map
|
package/dist/src/logger.js.map
CHANGED
|
@@ -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 * 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/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",
|
|
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
|
-
"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,WA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,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",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
|
@@ -57,6 +57,9 @@ function getEnv() {
|
|
|
57
57
|
cachedEnv = { ...result.data, enabledNetworks };
|
|
58
58
|
return cachedEnv;
|
|
59
59
|
}
|
|
60
|
+
function isProductionEnv() {
|
|
61
|
+
return process.env["NODE_ENV"] === "production";
|
|
62
|
+
}
|
|
60
63
|
function isPox4DecoderEnabled() {
|
|
61
64
|
return process.env.POX4_DECODER_ENABLED !== "false";
|
|
62
65
|
}
|
|
@@ -397,5 +400,5 @@ export {
|
|
|
397
400
|
ArchiveReplayClient
|
|
398
401
|
};
|
|
399
402
|
|
|
400
|
-
//# debugId=
|
|
403
|
+
//# debugId=DF0DB5FD47016FBE64756E2164756E21
|
|
401
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 * 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/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",
|
|
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
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAGA,IAAM,iBAAiB,EAAE,OAAO,EAAE,UAAU,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|
@@ -57,6 +57,9 @@ function getEnv() {
|
|
|
57
57
|
cachedEnv = { ...result.data, enabledNetworks };
|
|
58
58
|
return cachedEnv;
|
|
59
59
|
}
|
|
60
|
+
function isProductionEnv() {
|
|
61
|
+
return process.env["NODE_ENV"] === "production";
|
|
62
|
+
}
|
|
60
63
|
function isPox4DecoderEnabled() {
|
|
61
64
|
return process.env.POX4_DECODER_ENABLED !== "false";
|
|
62
65
|
}
|
|
@@ -522,5 +525,5 @@ export {
|
|
|
522
525
|
HiroClient
|
|
523
526
|
};
|
|
524
527
|
|
|
525
|
-
//# debugId=
|
|
528
|
+
//# debugId=679094A893C0896364756E2164756E21
|
|
526
529
|
//# 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 * 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/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",
|
|
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\n/** Minimal shape returned by `HiroClient.getTransaction` (extended `/v1/tx`). */\nexport interface HiroTransaction {\n\ttx_id: string;\n\ttx_status: string;\n\tblock_height: number | null;\n\tcanonical?: boolean;\n\tis_unanchored?: boolean;\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 single transaction's status by txid (Hiro extended `/v1/tx`).\n\t * Used by the x402 reconciler to advance/revert ledger rows. Returns null on\n\t * 404 (unknown/not-yet-indexed tx).\n\t */\n\tasync getTransaction(txId: string): Promise<HiroTransaction | null> {\n\t\tconst res = await this.fetchWithRetry(\n\t\t\t`${this.apiUrl}/extended/v1/tx/${txId}`,\n\t\t);\n\t\tif (res.status === 404) return null;\n\t\tif (!res.ok) {\n\t\t\tthrow new Error(`Hiro getTransaction ${txId} failed: ${res.status}`);\n\t\t}\n\t\treturn (await res.json()) as HiroTransaction;\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\t/** Fetch current chain tip height from Hiro API status endpoint */\n\tasync fetchChainTip(): Promise<number> {\n\t\tconst res = await this.fetchWithRetry(`${this.apiUrl}/extended/v1/status`);\n\t\tif (!res.ok) throw new Error(`Hiro API /status returned ${res.status}`);\n\t\tconst data = (await res.json()) as {\n\t\t\tchain_tip?: { block_height: number };\n\t\t\tstacks_tip_height?: number;\n\t\t};\n\t\treturn data.chain_tip?.block_height ?? data.stacks_tip_height ?? 0;\n\t}\n\n\tasync isHealthy(): Promise<boolean> {\n\t\ttry {\n\t\t\tconst res = await fetch(`${this.apiUrl}/extended/v1/status`, {\n\t\t\t\theaders: this.headers,\n\t\t\t\tsignal: AbortSignal.timeout(10_000),\n\t\t\t});\n\t\t\t// 429 = rate limited but reachable\n\t\t\treturn res.ok || res.status === 429;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\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};\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A,QACD;AAAA,WACI;AAAA,QACJ,OAAO;AAAA,aACH;AAAA,UACH,MAAM;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": "679094A893C0896364756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -650,6 +650,7 @@ interface Database {
|
|
|
650
650
|
tenant_usage_monthly: TenantUsageMonthlyTable;
|
|
651
651
|
tenant_compute_addons: TenantComputeAddonsTable;
|
|
652
652
|
account_spend_caps: AccountSpendCapsTable;
|
|
653
|
+
account_credits: AccountCreditsTable;
|
|
653
654
|
provisioning_audit_log: ProvisioningAuditLogTable;
|
|
654
655
|
subscriptions: SubscriptionsTable;
|
|
655
656
|
subscription_outbox: SubscriptionOutboxTable;
|
|
@@ -768,6 +769,15 @@ interface AccountSpendCapsTable {
|
|
|
768
769
|
frozen_at: Date | null;
|
|
769
770
|
updated_at: Generated<Date>;
|
|
770
771
|
}
|
|
772
|
+
/** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
|
|
773
|
+
interface AccountCreditsTable {
|
|
774
|
+
account_id: string;
|
|
775
|
+
balance_usd_micros: Generated<string | number | bigint>;
|
|
776
|
+
/** Month bucket ("YYYY-MM") the spend counter applies to. */
|
|
777
|
+
spent_month: string | null;
|
|
778
|
+
spent_month_usd_micros: Generated<string | number | bigint>;
|
|
779
|
+
updated_at: Generated<Date>;
|
|
780
|
+
}
|
|
771
781
|
type ProvisioningAuditEvent = "provision.start" | "provision.success" | "provision.failure" | "suspend" | "resume" | "resize" | "keys.rotate" | "bastion.key.upload" | "bastion.key.revoke" | "teardown";
|
|
772
782
|
type ProvisioningAuditStatus = "ok" | "error";
|
|
773
783
|
interface ProvisioningAuditLogTable {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { sql } from "kysely";
|
|
2
|
+
import type { Kysely } from "kysely";
|
|
3
|
+
import { onControlPlane } from "../src/db/migration-role.ts";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Prepaid dev credits — the card-funded peer to the wallet-funded
|
|
7
|
+
* `x402_balances` rail.
|
|
8
|
+
*
|
|
9
|
+
* One running USD-micros balance per account. Stripe card top-ups
|
|
10
|
+
* (`PaymentIntent`, one-time) credit it; metered reads / subgraph indexing
|
|
11
|
+
* debit it atomically (`balance >= price` guard in the UPDATE, CHECK as the
|
|
12
|
+
* backstop) — same mechanics as `x402_balances`, keyed by `account_id` instead
|
|
13
|
+
* of a wallet principal. The prepaid balance is itself the hard bill-shock
|
|
14
|
+
* ceiling; the rolling `spent_month_usd_micros` counter feeds an optional
|
|
15
|
+
* per-account monthly cap (reuses `account_spend_caps`).
|
|
16
|
+
*
|
|
17
|
+
* Control plane (TARGET) — billing data alongside `accounts` / `x402_balances`.
|
|
18
|
+
*/
|
|
19
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
20
|
+
await onControlPlane(async () => {
|
|
21
|
+
await sql`
|
|
22
|
+
CREATE TABLE account_credits (
|
|
23
|
+
account_id UUID PRIMARY KEY REFERENCES accounts(id) ON DELETE CASCADE,
|
|
24
|
+
balance_usd_micros BIGINT NOT NULL DEFAULT 0 CHECK (balance_usd_micros >= 0),
|
|
25
|
+
spent_month TEXT,
|
|
26
|
+
spent_month_usd_micros BIGINT NOT NULL DEFAULT 0,
|
|
27
|
+
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
28
|
+
)
|
|
29
|
+
`.execute(db);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export async function down(db: Kysely<unknown>): Promise<void> {
|
|
34
|
+
await onControlPlane(async () => {
|
|
35
|
+
await sql`DROP TABLE IF EXISTS account_credits`.execute(db);
|
|
36
|
+
});
|
|
37
|
+
}
|