@secondlayer/shared 17.0.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/src/archive/range-digest.d.ts +2 -65
  2. package/dist/src/archive/semantic-digest-builder.d.ts +2 -65
  3. package/dist/src/coverage/index.d.ts +12 -76
  4. package/dist/src/coverage/index.js +19 -60
  5. package/dist/src/coverage/index.js.map +3 -3
  6. package/dist/src/db/index.d.ts +3 -111
  7. package/dist/src/db/index.js +1 -34
  8. package/dist/src/db/index.js.map +5 -5
  9. package/dist/src/db/queries/chain-reorgs.d.ts +2 -65
  10. package/dist/src/db/queries/chain-reorgs.js +1 -34
  11. package/dist/src/db/queries/chain-reorgs.js.map +5 -5
  12. package/dist/src/db/queries/contracts.d.ts +2 -65
  13. package/dist/src/db/queries/contracts.js.map +2 -2
  14. package/dist/src/db/queries/instance.d.ts +2 -65
  15. package/dist/src/db/queries/integrity.d.ts +2 -65
  16. package/dist/src/db/queries/subgraph-gaps.d.ts +2 -65
  17. package/dist/src/db/queries/subgraph-operations.d.ts +2 -65
  18. package/dist/src/db/queries/subgraphs.d.ts +2 -65
  19. package/dist/src/db/queries/sync-scope.d.ts +2 -65
  20. package/dist/src/db/queries/webhook-replays.d.ts +2 -65
  21. package/dist/src/db/queries/webhooks.d.ts +2 -65
  22. package/dist/src/db/schema.d.ts +3 -64
  23. package/dist/src/db/schema.js.map +2 -2
  24. package/dist/src/index.d.ts +20 -111
  25. package/dist/src/index.js +51 -40
  26. package/dist/src/index.js.map +9 -7
  27. package/dist/src/insights/index.d.ts +2 -65
  28. package/dist/src/leader.js +1 -34
  29. package/dist/src/leader.js.map +5 -5
  30. package/dist/src/node/local-client.d.ts +2 -65
  31. package/dist/src/node/tx-summary.d.ts +7 -1
  32. package/dist/src/node/tx-summary.js +17 -2
  33. package/dist/src/node/tx-summary.js.map +3 -3
  34. package/dist/src/queue/listener.js +1 -34
  35. package/dist/src/queue/listener.js.map +5 -5
  36. package/dist/src/schemas/index.js +28 -7
  37. package/dist/src/schemas/index.js.map +5 -4
  38. package/dist/src/schemas/webhooks.js +28 -7
  39. package/dist/src/schemas/webhooks.js.map +5 -4
  40. package/dist/src/streams-rows/index.d.ts +35 -12
  41. package/dist/src/streams-rows/index.js +25 -21
  42. package/dist/src/streams-rows/index.js.map +5 -5
  43. package/migrations/0207_bns_buy_listing_price.ts +39 -0
  44. package/migrations/0208_pox5_calculate_rewards_cycle.ts +31 -0
  45. package/migrations/0209_chain_reorgs_index_block_hash.ts +51 -0
  46. package/migrations/0210_mempool_evict_superseded_nonces.ts +71 -0
  47. package/migrations/0211_decoded_events_slim.ts +114 -0
  48. package/migrations/0212_events_transactions_redundant_indexes.ts +71 -0
  49. package/migrations/0213_drop_sbtc_token_events.ts +32 -0
  50. package/migrations/0214_drop_coverage_receipts.ts +24 -0
  51. package/migrations/0215_decoder_checkpoints_last_output_at.ts +33 -0
  52. package/package.json +1 -1
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/schemas/webhooks.ts", "../src/schemas/chain-triggers.ts"],
3
+ "sources": ["../src/schemas/webhooks.ts", "../src/btc-txid.ts", "../src/schemas/chain-triggers.ts"],
4
4
  "sourcesContent": [
5
- "import { z } from \"zod\";\nimport type { WebhookHealth, WebhookPauseReason } from \"../webhooks/health\";\n\nexport {\n\tCHAIN_TRIGGER_FIELDS,\n\tCHAIN_TRIGGER_TYPES,\n} from \"./chain-triggers\";\nexport type { ChainTriggerType } from \"./chain-triggers\";\n\nexport const WEBHOOK_FORMATS = [\n\t\"standard-webhooks\",\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"cloudevents\",\n\t\"raw\",\n] as const;\n\n/** The database accepts only `active` and `paused`; a failing receiver is\n * `health`, not a status. */\nexport const WEBHOOK_STATUSES = [\"active\", \"paused\"] as const;\n\n/**\n * Delivery-cap ceilings. Self-host defaults keep today's hardcoded limits\n * (100 retries, 300s timeout); an operator raises or lowers them per env.\n * Read live (not baked in at import) so a changed env var takes effect on\n * the next request without a process restart, and so tests can override\n * per-case.\n */\nexport const WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;\nexport const WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300_000;\n\nfunction ceilingFromEnv(envVar: string, fallback: number): number {\n\tconst raw = process.env[envVar];\n\tif (raw === undefined) return fallback;\n\tconst parsed = Number.parseInt(raw, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nexport function webhookMaxRetriesCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_MAX_RETRIES_CEILING\",\n\t\tWEBHOOK_MAX_RETRIES_CEILING_DEFAULT,\n\t);\n}\n\nexport function webhookTimeoutMsCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_TIMEOUT_MS_CEILING\",\n\t\tWEBHOOK_TIMEOUT_MS_CEILING_DEFAULT,\n\t);\n}\n\nfunction maxRetriesField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(0)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookMaxRetriesCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `maxRetries exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nfunction timeoutMsField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(100)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookTimeoutMsCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `timeoutMs exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nconst webhookUrl = z\n\t.string()\n\t.trim()\n\t.min(1)\n\t.refine(\n\t\t(value) => value.startsWith(\"http://\") || value.startsWith(\"https://\"),\n\t\t\"must be an http(s) URL\",\n\t);\n\nconst name = z.string().trim().min(1).max(128);\n\n/** Webhook names another first-party product owns and looks up by name.\n * Renaming one breaks that product's reconcile, so the API refuses it and\n * the dashboard shows the owner instead of Rename. Prefix -> display name. */\nexport const MANAGED_NAME_PREFIXES: Readonly<Record<string, string>> = {\n\t\"sentinel:\": \"Sentinel\",\n};\n\nexport function managedByForName(name: string): string | null {\n\tfor (const [prefix, owner] of Object.entries(MANAGED_NAME_PREFIXES)) {\n\t\tif (name.startsWith(prefix)) return owner;\n\t}\n\treturn null;\n}\n\nexport const WebhookStatusSchema: z.ZodType<WebhookStatus> =\n\tz.enum(WEBHOOK_STATUSES);\nexport const WebhookFormatSchema: z.ZodType<WebhookFormat> =\n\tz.enum(WEBHOOK_FORMATS);\n\n// --- Chain triggers (direct chain-level webhooks) -----------------------\n// A chain webhook reacts to raw chain events matched directly off the\n// Index/Streams clock (no subgraph). `triggers` is an array of these filters —\n// the JSON mirror of the subgraph runtime's `SubgraphFilter` union. Defined\n// here (not imported from @secondlayer/subgraphs) to avoid a shared→subgraphs\n// cycle; the evaluator maps these to `SubgraphFilter` at match time. Amounts are\n// non-negative integer strings (uint128 can exceed JS safe-int) or numbers.\n\n/** Runes trigger types (plan 060) — matched off `chain=bitcoin` Streams events\n * (plan 059), not the Stacks Index clock. `rune` is a RuneRef (an id like\n * `840000:3` or a name like `DOG•GO•TO•THE•MOON`); the API resolves and\n * normalizes it to its canonical id at create time (see `../../routes/webhooks.ts`),\n * rejecting an unresolvable one with 400 when Bitcoin data is configured. */\nconst runeRef = z.string().trim().min(1);\n\nconst triggerAmount = z.union([\n\tz.string().trim().regex(/^\\d+$/, \"must be a non-negative integer string\"),\n\tz.number().int().nonnegative(),\n]);\n/** Principal/identifier/name patterns — `*` wildcards allowed (matched by the\n * evaluator). */\nconst triggerPattern = z.string().trim().min(1);\nconst trait = z.string().trim().min(1);\n\n/**\n * `print_event` `where`: equality on top-level keys of the decoded print\n * tuple, spelled as the contract prints them. An array is any-of; multiple\n * keys AND. Values compare against the field's JSON-normalized form.\n */\nconst printWhereValue = z.string().min(1).max(256);\nexport const PrintWhereSchema: z.ZodType<Record<string, string | string[]>> = z\n\t.record(\n\t\tz.string().trim().min(1).max(64),\n\t\tz.union([printWhereValue, z.array(printWhereValue).min(1).max(20)]),\n\t)\n\t.refine((o) => {\n\t\tconst n = Object.keys(o).length;\n\t\treturn n >= 1 && n <= 10;\n\t}, \"where takes 1 to 10 keys\");\n\nexport const ChainTriggerSchema: z.ZodType<ChainTrigger> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_transfer\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_mint\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_burn\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_lock\"),\n\t\t\t\tlockedAddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_deploy\"),\n\t\t\t\tdeployer: triggerPattern.optional(),\n\t\t\t\tcontractName: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"print_event\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\ttopic: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t\twhere: PrintWhereSchema.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nested_contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"var_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tvarName: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_insert\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_delete\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_deposit\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\tbitcoinTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_create\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_accept\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_reject\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_swept_confirmed\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_etch\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_mint\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_transfer\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t\taddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_burn\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t],\n);\n\nexport const ChainTriggersSchema: z.ZodType<ChainTrigger[]> = z\n\t.array(ChainTriggerSchema)\n\t.min(1)\n\t.max(50);\n\nexport const CreateWebhookRequestSchema: z.ZodType<ParsedCreateWebhookRequest> =\n\tz.object({\n\t\tname,\n\t\ttriggers: ChainTriggersSchema,\n\t\turl: webhookUrl,\n\t\tformat: WebhookFormatSchema.default(\"standard-webhooks\"),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t});\n\nexport const UpdateWebhookRequestSchema: z.ZodType<UpdateWebhookRequest> = z\n\t.object({\n\t\tname: name.optional(),\n\t\turl: webhookUrl.optional(),\n\t\tformat: WebhookFormatSchema.optional(),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t})\n\t.refine((value) => Object.keys(value).length > 0, {\n\t\tmessage: \"At least one field must be provided\",\n\t});\n\nexport const ReplayWebhookRequestSchema: z.ZodType<ReplayWebhookRequest> = z\n\t.object({\n\t\tfromBlock: z.number().int().nonnegative(),\n\t\ttoBlock: z.number().int().nonnegative(),\n\t\tforce: z.string().trim().min(1).max(64).optional(),\n\t})\n\t.refine((value) => value.fromBlock <= value.toBlock, {\n\t\tmessage: \"fromBlock must be less than or equal to toBlock\",\n\t\tpath: [\"toBlock\"],\n\t});\n\nexport const RequeueDeadRequestSchema: z.ZodType<RequeueDeadRequest> = z.object(\n\t{\n\t\treplayId: z\n\t\t\t.string()\n\t\t\t.regex(/^[0-9a-f]{16}$/, \"replayId must be 16 hex characters\")\n\t\t\t.optional(),\n\t\tsince: z.iso.datetime({ offset: true }).optional(),\n\t},\n);\n\nexport type { WebhookHealth, WebhookPauseReason };\nexport type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];\n/** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat = (typeof WEBHOOK_FORMATS)[number];\n\n/** Non-negative integer amount over JSON (string for uint128 safety, or number). */\nexport type ChainTriggerAmount = string | number;\n\ninterface TraitScoped {\n\ttrait?: string;\n}\n\n/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */\nexport type ChainTrigger =\n\t| {\n\t\t\ttype: \"stx_transfer\";\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"stx_mint\"; recipient?: string; minAmount?: ChainTriggerAmount }\n\t| { type: \"stx_burn\"; sender?: string; minAmount?: ChainTriggerAmount }\n\t| {\n\t\t\ttype: \"stx_lock\";\n\t\t\tlockedAddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| ({\n\t\t\ttype: \"ft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t } & TraitScoped)\n\t| { type: \"contract_deploy\"; deployer?: string; contractName?: string }\n\t| ({\n\t\t\ttype: \"print_event\";\n\t\t\tcontractId?: string;\n\t\t\ttopic?: string;\n\t\t\t/** Equality on top-level keys of the decoded print tuple; array = any-of, keys AND. */\n\t\t\twhere?: Record<string, string | readonly string[]>;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nested_contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"var_set\";\n\t\t\tcontractId?: string;\n\t\t\tvarName?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_set\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_insert\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_delete\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| {\n\t\t\ttype: \"sbtc_deposit\";\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\tbitcoinTxid?: string;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_create\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_accept\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"sbtc_withdrawal_reject\"; requestId?: number }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_swept_confirmed\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"rune_etch\"; rune?: string }\n\t| { type: \"rune_mint\"; rune?: string }\n\t| {\n\t\t\ttype: \"rune_transfer\";\n\t\t\trune?: string;\n\t\t\taddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"rune_burn\"; rune?: string };\n\n/** Args for a chain-trigger builder — every field of a variant except `type`. */\ntype TriggerArgs<T extends ChainTrigger[\"type\"]> = Omit<\n\tExtract<ChainTrigger, { type: T }>,\n\t\"type\"\n>;\n\n/**\n * Ergonomic chain-trigger constructors for `webhooks.create({ triggers })`.\n * Each returns a bare `ChainTrigger` (the wire shape the API expects):\n *\n * ```ts\n * client.webhooks.create({\n * url: \"https://my.app/webhook\",\n * triggers: [trigger.contractCall({ contractId: \"SP....amm\", functionName: \"swap-*\" })],\n * });\n * ```\n */\nexport const trigger = {\n\tstxTransfer: (f: TriggerArgs<\"stx_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_transfer\",\n\t\t...f,\n\t}),\n\tstxMint: (f: TriggerArgs<\"stx_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_mint\",\n\t\t...f,\n\t}),\n\tstxBurn: (f: TriggerArgs<\"stx_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_burn\",\n\t\t...f,\n\t}),\n\tstxLock: (f: TriggerArgs<\"stx_lock\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_lock\",\n\t\t...f,\n\t}),\n\tftTransfer: (f: TriggerArgs<\"ft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_transfer\",\n\t\t...f,\n\t}),\n\tftMint: (f: TriggerArgs<\"ft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_mint\",\n\t\t...f,\n\t}),\n\tftBurn: (f: TriggerArgs<\"ft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_burn\",\n\t\t...f,\n\t}),\n\tnftTransfer: (f: TriggerArgs<\"nft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_transfer\",\n\t\t...f,\n\t}),\n\tnftMint: (f: TriggerArgs<\"nft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_mint\",\n\t\t...f,\n\t}),\n\tnftBurn: (f: TriggerArgs<\"nft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_burn\",\n\t\t...f,\n\t}),\n\tcontractCall: (f: TriggerArgs<\"contract_call\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_call\",\n\t\t...f,\n\t}),\n\tcontractDeploy: (f: TriggerArgs<\"contract_deploy\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_deploy\",\n\t\t...f,\n\t}),\n\tprintEvent: (f: TriggerArgs<\"print_event\"> = {}): ChainTrigger => ({\n\t\ttype: \"print_event\",\n\t\t...f,\n\t}),\n\tsbtcDeposit: (f: TriggerArgs<\"sbtc_deposit\"> = {}): ChainTrigger => ({\n\t\ttype: \"sbtc_deposit\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalCreate: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_create\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_create\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalAccept: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_accept\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_accept\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalReject: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_reject\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_reject\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_swept_confirmed\",\n\t\t...f,\n\t}),\n\truneEtch: (f: TriggerArgs<\"rune_etch\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_etch\",\n\t\t...f,\n\t}),\n\truneMint: (f: TriggerArgs<\"rune_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_mint\",\n\t\t...f,\n\t}),\n\truneTransfer: (f: TriggerArgs<\"rune_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_transfer\",\n\t\t...f,\n\t}),\n\truneBurn: (f: TriggerArgs<\"rune_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_burn\",\n\t\t...f,\n\t}),\n} as const;\n\n/** The body for creating a webhook: name, triggers, URL, delivery options. */\nexport interface CreateWebhookRequest {\n\tname: string;\n\ttriggers: ChainTrigger[];\n\turl: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface ParsedCreateWebhookRequest\n\textends Omit<CreateWebhookRequest, \"format\"> {\n\tformat: WebhookFormat;\n}\n\n/** The fields of a webhook you can change. */\nexport interface UpdateWebhookRequest {\n\tname?: string;\n\turl?: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport type ParsedUpdateWebhookRequest = UpdateWebhookRequest;\n\nexport interface ReplayWebhookRequest {\n\tfromBlock: number;\n\ttoBlock: number;\n\tforce?: string;\n}\n\nexport type ParsedReplayWebhookRequest = ReplayWebhookRequest;\n\n/** Body of `POST /:id/dead/requeue`. Both fields narrow which dead rows requeue. */\nexport interface RequeueDeadRequest {\n\treplayId?: string;\n\t/** ISO datetime; only dead rows that failed at or after it. */\n\tsince?: string;\n}\n\n/** A webhook's name, status, format, and URL. */\nexport interface WebhookSummary {\n\tid: string;\n\tname: string;\n\tstatus: WebhookStatus;\n\tkind: WebhookKind;\n\tformat: WebhookFormat;\n\turl: string;\n\tlastDeliveryAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** When the circuit breaker paused this webhook (20 straight failures);\n\t * cleared on resume. Present on the list summary (not detail-only) so a\n\t * numbers-only insight can be shown per row without a per-row fetch. */\n\tcircuitOpenedAt: string | null;\n\t/** Why the webhook is paused: `user` (you paused it) or `circuit` (20\n\t * straight failures tripped the breaker). Null while `active`. Absent from\n\t * servers that predate it. */\n\tpauseReason?: WebhookPauseReason | null;\n\t/** One verdict from the state above: `ok`, `failing` (recent failures),\n\t * `down` (5+ failures in a row and no success for 15 minutes),\n\t * `paused_user` or `paused_circuit`. Absent from servers that predate it. */\n\thealth?: WebhookHealth;\n\t/** Consecutive failed deliveries (reset to 0 on a success). On the\n\t * summary so the list can show a failing receiver per row without a\n\t * per-row fetch. */\n\tcircuitFailures: number;\n\t/** Owning product, derived from the name prefix (`MANAGED_NAME_PREFIXES`).\n\t * When non-null the API refuses to rename the webhook. */\n\tmanagedBy: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** What a webhook's receiver credentials look like once redacted for a\n * response — never the bearer token, basic-auth string, or header values\n * themselves, only enough to show what's set. `authConfig` on create/update\n * is unaffected (write-only: the API still accepts it, just never echoes\n * it back). */\nexport interface WebhookAuth {\n\ttype: \"bearer\" | \"basic\" | \"none\";\n\t/** Keys of any extra headers the receiver expects — never their values. */\n\theaderNames: string[];\n\t/** True when a bearer token or basic-auth string is set, whatever it is. */\n\thasSecret: boolean;\n}\n\n/** A webhook with its triggers, auth, retry, and timeout settings. */\nexport interface WebhookDetail extends WebhookSummary {\n\t/** Chain-trigger filters. */\n\ttriggers: ChainTrigger[];\n\tauth: WebhookAuth;\n\tmaxRetries: number;\n\ttimeoutMs: number;\n\tconcurrency: number;\n\tlastError: string | null;\n\t/** When the receiver's TLS certificate expires, from the periodic probe.\n\t * Null for http receivers, refused or unreachable hosts, and webhooks not\n\t * probed yet. */\n\treceiverCertExpiresAt: string | null;\n\t/** Set when this instance's chain-trigger\n\t * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the\n\t * webhook will never fire until that's fixed. Null otherwise. Surfaced\n\t * on create (so it's seen immediately) and on every read (so `secondlayer\n\t * webhooks doctor` reports it for a webhook created before the mismatch,\n\t * or on an instance whose config changed since). */\n\twarning: string | null;\n}\n\n/** The new webhook and its signing secret, shown once. */\nexport interface CreateWebhookResponse {\n\twebhook: WebhookDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\n/** The webhook and its new signing secret. */\nexport interface RotateSecretResponse {\n\twebhook: WebhookDetail;\n\tsigningSecret: string;\n}\n\n/** One delivery attempt: status code, error, duration, and response. */\nexport interface DeliveryRow {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\terrorMessage: string | null;\n\tdurationMs: number | null;\n\t/** First 512 characters; the full body is on `deliveries.get`. */\n\tresponseBody: string | null;\n\tdispatchedAt: string;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\tblockHeight: number | null;\n\t/** ISO timestamp of the delivered event's block. `null` for test\n\t * deliveries, events already compacted out of the outbox, and rows\n\t * written before this column existed. */\n\tblockTime: string | null;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\ttxId: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`.\n\t * Null for test deliveries, compacted rows, and rows with neither shape\n\t * (a settlement or reorg outbox row). */\n\teventIndex: number | null;\n}\n\n/** One hour of `webhook_outbox` activity (`GET /:id/activity`), zero-filled\n * so the events chart always has 168 bars. */\nexport interface WebhookActivityHour {\n\t/** ISO timestamp, UTC hour start. */\n\thour: string;\n\tdelivered: number;\n\twaiting: number;\n\tgaveUp: number;\n\t/** Failed attempts in the hour (no response or non-2xx), from\n\t * `webhook_deliveries`. Attempts, not events: a retried-then-delivered\n\t * event counts here but is `delivered` above. */\n\tfailed: number;\n}\n\n/** A week of hourly delivery counts and what is waiting now. */\nexport interface WebhookActivity {\n\t/** 168 hours, oldest first. */\n\thours: WebhookActivityHour[];\n\t/** Pending rows right now, no time bound. */\n\twaiting: number;\n\tnextAttemptAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** 7-day counts per `event_type` (same 168-hour window as `hours`), e.g.\n\t * `chain.stx_transfer.apply` — the config card's per-trigger volume. */\n\tbyEventType: Record<string, number>;\n\t/** Typical delivered attempts for each UTC hour of day (p10 and p90 of the\n\t * last 28 days, from `webhook_deliveries`). Null at low volume, where\n\t * \"usual\" is not meaningful. */\n\tusualByHourOfDay: Array<{ lo: number; hi: number }> | null;\n\t/** 30 UTC days, oldest first, from the hourly delivery counts (2xx is\n\t * delivered, everything else failed). */\n\tdays: WebhookActivityDay[];\n}\n\n/** One UTC day of delivery attempts (`GET /:id/activity`). */\nexport interface WebhookActivityDay {\n\t/** YYYY-MM-DD, UTC. */\n\tday: string;\n\tdelivered: number;\n\tfailed: number;\n}\n\n/** Heat data for every webhook on the account (`GET /api/webhooks/activity`),\n * from `webhook_deliveries` attempts. */\nexport interface WebhooksActivitySummary {\n\t/** 168 ISO UTC hour starts, oldest first. */\n\thours: string[];\n\t/** Arrays are aligned to `hours` and zero-filled. */\n\twebhooks: Array<{ id: string; delivered: number[]; failed: number[] }>;\n}\n\n/**\n * One delivery attempt with its outbox context.\n *\n * Serves the delivery card (`GET /:id/deliveries/:deliveryId`). `payload`,\n * `outboxId`, `eventType`, `txId`, `blockHeight`, `blockTime`, and `eventIndex`\n * are null once the outbox row is gone (compacted after 7 days) or for a test\n * delivery, which never had one.\n */\nexport interface WebhookDeliveryDetail {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\tdurationMs: number | null;\n\tdispatchedAt: string;\n\terrorMessage: string | null;\n\tresponseBody: string | null;\n\tresponseHeaders: Record<string, string> | null;\n\toutboxId: string | null;\n\t/** The outbox row's own status — `null` once it's gone (compacted after\n\t * delivery, or never had one, e.g. a test delivery). Only `\"dead\"` means\n\t * a resend is possible: it's the one status `POST /:id/dead/:outboxId/\n\t * requeue` accepts. */\n\toutboxStatus: \"pending\" | \"delivered\" | \"dead\" | null;\n\teventType: string | null;\n\ttxId: string | null;\n\tblockHeight: number | null;\n\tblockTime: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`\n\t * (`event_index` for a chain-trigger row). Null when `row_pk` carries\n\t * none — a settlement or reorg outbox row, or no outbox row at all. */\n\teventIndex: number | null;\n\tpayload: unknown | null;\n}\n\n/** How many events a replay scanned and enqueued. */\nexport interface ReplayResult {\n\treplayId: string;\n\tenqueuedCount: number;\n\tscannedCount: number;\n}\n\n/** Live state of one stored replay. */\nexport interface ReplayProgress {\n\treplayId: string;\n\twebhookId: string;\n\tstatus: \"scanning\" | \"running\" | \"done\" | \"failed\";\n\tfromBlock: number;\n\ttoBlock: number;\n\t/** Events the replay enqueued. */\n\ttotal: number;\n\t/** Delivered or gave up (`total - pending`). */\n\tprocessed: number;\n\tpending: number;\n\t/** Null until the replay finishes. */\n\tdelivered: number | null;\n\t/** Null until the replay finishes. */\n\tgaveUp: number | null;\n\tstartedAt: string;\n\tfinishedAt: string | null;\n\terror: string | null;\n}\n\n/** Range presets for starting a replay, from `GET /:id/replays`. */\nexport interface ReplayRanges {\n\t/** Last evaluated block; null when the webhook has no evaluator state yet. */\n\ttip: number | null;\n\tpresets: Array<{\n\t\tblocks: 100 | 1000 | 10000;\n\t\tfromBlock: number;\n\t\ttoBlock: number;\n\t\t/** Lower bound: delivered rows are deleted after 7 days. */\n\t\tknownEvents: number;\n\t}>;\n\t/** Dead rows since the webhook last succeeded (all dead rows when it never has). */\n\tdeadSinceFailing: { since: string | null; count: number };\n}\n\n/** Result of a one-off test delivery (`POST /:id/test`). Logged as a delivery\n * row (with a null outbox_id) so it shows up under the webhook's deliveries. */\nexport interface WebhookTestResult {\n\tok: boolean;\n\tstatusCode: number | null;\n\terror: string | null;\n\tdurationMs: number;\n\tdeliveryId: string;\n}\n\n/** A delivery that ran out of retries. */\nexport interface DeadRow {\n\tid: string;\n\teventType: string;\n\tattempt: number;\n\tblockHeight: number;\n\ttxId: string | null;\n\tpayload: Record<string, unknown>;\n\tfailedAt: string | null;\n\tcreatedAt: string;\n}\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n\treturn path.length > 0 ? `${path.map(String).join(\".\")}: ` : \"\";\n}\n\nexport function formatWebhookSchemaErrors(error: z.ZodError): string[] {\n\treturn error.issues.map(\n\t\t(issue) => `${formatIssuePath(issue.path)}${issue.message}`,\n\t);\n}\n",
5
+ "import { z } from \"zod\";\nimport { normalizeBtcTxid } from \"../btc-txid\";\nimport type { WebhookHealth, WebhookPauseReason } from \"../webhooks/health\";\n\nexport {\n\tCHAIN_TRIGGER_FIELDS,\n\tCHAIN_TRIGGER_TYPES,\n} from \"./chain-triggers\";\nexport type { ChainTriggerType } from \"./chain-triggers\";\n\nexport const WEBHOOK_FORMATS = [\n\t\"standard-webhooks\",\n\t\"inngest\",\n\t\"trigger\",\n\t\"cloudflare\",\n\t\"cloudevents\",\n\t\"raw\",\n] as const;\n\n/** The database accepts only `active` and `paused`; a failing receiver is\n * `health`, not a status. */\nexport const WEBHOOK_STATUSES = [\"active\", \"paused\"] as const;\n\n/**\n * Delivery-cap ceilings. Self-host defaults keep today's hardcoded limits\n * (100 retries, 300s timeout); an operator raises or lowers them per env.\n * Read live (not baked in at import) so a changed env var takes effect on\n * the next request without a process restart, and so tests can override\n * per-case.\n */\nexport const WEBHOOK_MAX_RETRIES_CEILING_DEFAULT = 100;\nexport const WEBHOOK_TIMEOUT_MS_CEILING_DEFAULT = 300_000;\n\nfunction ceilingFromEnv(envVar: string, fallback: number): number {\n\tconst raw = process.env[envVar];\n\tif (raw === undefined) return fallback;\n\tconst parsed = Number.parseInt(raw, 10);\n\treturn Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;\n}\n\nexport function webhookMaxRetriesCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_MAX_RETRIES_CEILING\",\n\t\tWEBHOOK_MAX_RETRIES_CEILING_DEFAULT,\n\t);\n}\n\nexport function webhookTimeoutMsCeiling(): number {\n\treturn ceilingFromEnv(\n\t\t\"WEBHOOK_TIMEOUT_MS_CEILING\",\n\t\tWEBHOOK_TIMEOUT_MS_CEILING_DEFAULT,\n\t);\n}\n\nfunction maxRetriesField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(0)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookMaxRetriesCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `maxRetries exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nfunction timeoutMsField() {\n\treturn z\n\t\t.number()\n\t\t.int()\n\t\t.min(100)\n\t\t.optional()\n\t\t.superRefine((v, ctx) => {\n\t\t\tif (v === undefined) return;\n\t\t\tconst ceiling = webhookTimeoutMsCeiling();\n\t\t\tif (v > ceiling) {\n\t\t\t\tctx.addIssue({\n\t\t\t\t\tcode: \"custom\",\n\t\t\t\t\tmessage: `timeoutMs exceeds ceiling (${ceiling})`,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n}\n\nconst webhookUrl = z\n\t.string()\n\t.trim()\n\t.min(1)\n\t.refine(\n\t\t(value) => value.startsWith(\"http://\") || value.startsWith(\"https://\"),\n\t\t\"must be an http(s) URL\",\n\t);\n\nconst name = z.string().trim().min(1).max(128);\n\n/** Webhook names another first-party product owns and looks up by name.\n * Renaming one breaks that product's reconcile, so the API refuses it and\n * the dashboard shows the owner instead of Rename. Prefix -> display name. */\nexport const MANAGED_NAME_PREFIXES: Readonly<Record<string, string>> = {\n\t\"sentinel:\": \"Sentinel\",\n};\n\nexport function managedByForName(name: string): string | null {\n\tfor (const [prefix, owner] of Object.entries(MANAGED_NAME_PREFIXES)) {\n\t\tif (name.startsWith(prefix)) return owner;\n\t}\n\treturn null;\n}\n\nexport const WebhookStatusSchema: z.ZodType<WebhookStatus> =\n\tz.enum(WEBHOOK_STATUSES);\nexport const WebhookFormatSchema: z.ZodType<WebhookFormat> =\n\tz.enum(WEBHOOK_FORMATS);\n\n// --- Chain triggers (direct chain-level webhooks) -----------------------\n// A chain webhook reacts to raw chain events matched directly off the\n// Index/Streams clock (no subgraph). `triggers` is an array of these filters —\n// the JSON mirror of the subgraph runtime's `SubgraphFilter` union. Defined\n// here (not imported from @secondlayer/subgraphs) to avoid a shared→subgraphs\n// cycle; the evaluator maps these to `SubgraphFilter` at match time. Amounts are\n// non-negative integer strings (uint128 can exceed JS safe-int) or numbers.\n\n/** Runes trigger types (plan 060) — matched off `chain=bitcoin` Streams events\n * (plan 059), not the Stacks Index clock. `rune` is a RuneRef (an id like\n * `840000:3` or a name like `DOG•GO•TO•THE•MOON`); the API resolves and\n * normalizes it to its canonical id at create time (see `../../routes/webhooks.ts`),\n * rejecting an unresolvable one with 400 when Bitcoin data is configured. */\nconst runeRef = z.string().trim().min(1);\n\nconst triggerAmount = z.union([\n\tz.string().trim().regex(/^\\d+$/, \"must be a non-negative integer string\"),\n\tz.number().int().nonnegative(),\n]);\n/** Principal/identifier/name patterns on Stacks chain-event triggers — `*`\n * wildcards allowed (`matchPattern` in the subgraphs source matcher). */\nconst triggerPattern = z.string().trim().min(1);\n/** sBTC and Runes fields are matched by equality against decoded rows — no\n * wildcards. */\nconst triggerExact = z.string().trim().min(1);\n/** Bitcoin txid: bare explorer hex or `0x`-prefixed, any case. Normalized to\n * the stored form (`0x` + lowercase) so it matches `sbtc_events` rows. */\nconst btcTxid = z.string().transform((value, ctx) => {\n\tconst txid = normalizeBtcTxid(value);\n\tif (txid === null) {\n\t\tctx.addIssue({\n\t\t\tcode: \"custom\",\n\t\t\tmessage: \"must be a 64-character hex Bitcoin txid (0x optional)\",\n\t\t});\n\t\treturn z.NEVER;\n\t}\n\treturn txid;\n});\nconst trait = z.string().trim().min(1);\n\n/**\n * `print_event` `where`: equality on top-level keys of the decoded print\n * tuple, spelled as the contract prints them. An array is any-of; multiple\n * keys AND. Values compare against the field's JSON-normalized form.\n */\nconst printWhereValue = z.string().min(1).max(256);\nexport const PrintWhereSchema: z.ZodType<Record<string, string | string[]>> = z\n\t.record(\n\t\tz.string().trim().min(1).max(64),\n\t\tz.union([printWhereValue, z.array(printWhereValue).min(1).max(20)]),\n\t)\n\t.refine((o) => {\n\t\tconst n = Object.keys(o).length;\n\t\treturn n >= 1 && n <= 10;\n\t}, \"where takes 1 to 10 keys\");\n\nexport const ChainTriggerSchema: z.ZodType<ChainTrigger> = z.discriminatedUnion(\n\t\"type\",\n\t[\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_transfer\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_mint\"),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_burn\"),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"stx_lock\"),\n\t\t\t\tlockedAddress: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"ft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_transfer\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_mint\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\trecipient: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nft_burn\"),\n\t\t\t\tassetIdentifier: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"contract_deploy\"),\n\t\t\t\tdeployer: triggerPattern.optional(),\n\t\t\t\tcontractName: triggerPattern.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"print_event\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\ttopic: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t\twhere: PrintWhereSchema.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"nested_contract_call\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tfunctionName: triggerPattern.optional(),\n\t\t\t\tcaller: triggerPattern.optional(),\n\t\t\t\tsender: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"var_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tvarName: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_set\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_insert\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"map_delete\"),\n\t\t\t\tcontractId: triggerPattern.optional(),\n\t\t\t\tmap: triggerPattern.optional(),\n\t\t\t\ttrait: trait.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_deposit\"),\n\t\t\t\trecipient: triggerExact.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\tbitcoinTxid: btcTxid.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_create\"),\n\t\t\t\tsender: triggerExact.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t\tmaxAmount: triggerAmount.optional(),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_accept\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: btcTxid.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_reject\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"sbtc_withdrawal_swept_confirmed\"),\n\t\t\t\trequestId: z.number().int().nonnegative().optional(),\n\t\t\t\tsweepTxid: btcTxid.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_etch\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_mint\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_transfer\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t\taddress: triggerExact.optional(),\n\t\t\t\tminAmount: triggerAmount.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t\tz\n\t\t\t.object({\n\t\t\t\ttype: z.literal(\"rune_burn\"),\n\t\t\t\trune: runeRef.optional(),\n\t\t\t})\n\t\t\t.strict(),\n\t],\n);\n\nexport const ChainTriggersSchema: z.ZodType<ChainTrigger[]> = z\n\t.array(ChainTriggerSchema)\n\t.min(1)\n\t.max(50);\n\nexport const CreateWebhookRequestSchema: z.ZodType<ParsedCreateWebhookRequest> =\n\tz.object({\n\t\tname,\n\t\ttriggers: ChainTriggersSchema,\n\t\turl: webhookUrl,\n\t\tformat: WebhookFormatSchema.default(\"standard-webhooks\"),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t});\n\nexport const UpdateWebhookRequestSchema: z.ZodType<UpdateWebhookRequest> = z\n\t.object({\n\t\tname: name.optional(),\n\t\turl: webhookUrl.optional(),\n\t\tformat: WebhookFormatSchema.optional(),\n\t\tauthConfig: z.record(z.string(), z.unknown()).optional(),\n\t\tmaxRetries: maxRetriesField(),\n\t\ttimeoutMs: timeoutMsField(),\n\t\tconcurrency: z.number().int().min(1).max(100).optional(),\n\t})\n\t.refine((value) => Object.keys(value).length > 0, {\n\t\tmessage: \"At least one field must be provided\",\n\t});\n\nexport const ReplayWebhookRequestSchema: z.ZodType<ReplayWebhookRequest> = z\n\t.object({\n\t\tfromBlock: z.number().int().nonnegative(),\n\t\ttoBlock: z.number().int().nonnegative(),\n\t\tforce: z.string().trim().min(1).max(64).optional(),\n\t})\n\t.refine((value) => value.fromBlock <= value.toBlock, {\n\t\tmessage: \"fromBlock must be less than or equal to toBlock\",\n\t\tpath: [\"toBlock\"],\n\t});\n\nexport const RequeueDeadRequestSchema: z.ZodType<RequeueDeadRequest> = z.object(\n\t{\n\t\treplayId: z\n\t\t\t.string()\n\t\t\t.regex(/^[0-9a-f]{16}$/, \"replayId must be 16 hex characters\")\n\t\t\t.optional(),\n\t\tsince: z.iso.datetime({ offset: true }).optional(),\n\t},\n);\n\nexport type { WebhookHealth, WebhookPauseReason };\nexport type WebhookStatus = (typeof WEBHOOK_STATUSES)[number];\n/** Webhook kind (mirrors db/types `WebhookKind`). Chain events only. */\nexport type WebhookKind = \"chain\";\nexport type WebhookFormat = (typeof WEBHOOK_FORMATS)[number];\n\n/** Non-negative integer amount over JSON (string for uint128 safety, or number). */\nexport type ChainTriggerAmount = string | number;\n\ninterface TraitScoped {\n\ttrait?: string;\n}\n\n/** JSON mirror of the subgraph runtime's `SubgraphFilter` union. */\nexport type ChainTrigger =\n\t| {\n\t\t\ttype: \"stx_transfer\";\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"stx_mint\"; recipient?: string; minAmount?: ChainTriggerAmount }\n\t| { type: \"stx_burn\"; sender?: string; minAmount?: ChainTriggerAmount }\n\t| {\n\t\t\ttype: \"stx_lock\";\n\t\t\tlockedAddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| ({\n\t\t\ttype: \"ft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"ft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_transfer\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_mint\";\n\t\t\tassetIdentifier?: string;\n\t\t\trecipient?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nft_burn\";\n\t\t\tassetIdentifier?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t } & TraitScoped)\n\t| { type: \"contract_deploy\"; deployer?: string; contractName?: string }\n\t| ({\n\t\t\ttype: \"print_event\";\n\t\t\tcontractId?: string;\n\t\t\ttopic?: string;\n\t\t\t/** Equality on top-level keys of the decoded print tuple; array = any-of, keys AND. */\n\t\t\twhere?: Record<string, string | readonly string[]>;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"nested_contract_call\";\n\t\t\tcontractId?: string;\n\t\t\tfunctionName?: string;\n\t\t\tcaller?: string;\n\t\t\tsender?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"var_set\";\n\t\t\tcontractId?: string;\n\t\t\tvarName?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_set\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_insert\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| ({\n\t\t\ttype: \"map_delete\";\n\t\t\tcontractId?: string;\n\t\t\tmap?: string;\n\t } & TraitScoped)\n\t| {\n\t\t\ttype: \"sbtc_deposit\";\n\t\t\trecipient?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\tbitcoinTxid?: string;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_create\";\n\t\t\tsender?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t\t\tmaxAmount?: ChainTriggerAmount;\n\t\t\trequestId?: number;\n\t }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_accept\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"sbtc_withdrawal_reject\"; requestId?: number }\n\t| {\n\t\t\ttype: \"sbtc_withdrawal_swept_confirmed\";\n\t\t\trequestId?: number;\n\t\t\tsweepTxid?: string;\n\t }\n\t| { type: \"rune_etch\"; rune?: string }\n\t| { type: \"rune_mint\"; rune?: string }\n\t| {\n\t\t\ttype: \"rune_transfer\";\n\t\t\trune?: string;\n\t\t\taddress?: string;\n\t\t\tminAmount?: ChainTriggerAmount;\n\t }\n\t| { type: \"rune_burn\"; rune?: string };\n\n/** Args for a chain-trigger builder — every field of a variant except `type`. */\ntype TriggerArgs<T extends ChainTrigger[\"type\"]> = Omit<\n\tExtract<ChainTrigger, { type: T }>,\n\t\"type\"\n>;\n\n/**\n * Ergonomic chain-trigger constructors for `webhooks.create({ triggers })`.\n * Each returns a bare `ChainTrigger` (the wire shape the API expects):\n *\n * ```ts\n * client.webhooks.create({\n * url: \"https://my.app/webhook\",\n * triggers: [trigger.contractCall({ contractId: \"SP....amm\", functionName: \"swap-*\" })],\n * });\n * ```\n */\nexport const trigger = {\n\tstxTransfer: (f: TriggerArgs<\"stx_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_transfer\",\n\t\t...f,\n\t}),\n\tstxMint: (f: TriggerArgs<\"stx_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_mint\",\n\t\t...f,\n\t}),\n\tstxBurn: (f: TriggerArgs<\"stx_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_burn\",\n\t\t...f,\n\t}),\n\tstxLock: (f: TriggerArgs<\"stx_lock\"> = {}): ChainTrigger => ({\n\t\ttype: \"stx_lock\",\n\t\t...f,\n\t}),\n\tftTransfer: (f: TriggerArgs<\"ft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_transfer\",\n\t\t...f,\n\t}),\n\tftMint: (f: TriggerArgs<\"ft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_mint\",\n\t\t...f,\n\t}),\n\tftBurn: (f: TriggerArgs<\"ft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"ft_burn\",\n\t\t...f,\n\t}),\n\tnftTransfer: (f: TriggerArgs<\"nft_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_transfer\",\n\t\t...f,\n\t}),\n\tnftMint: (f: TriggerArgs<\"nft_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_mint\",\n\t\t...f,\n\t}),\n\tnftBurn: (f: TriggerArgs<\"nft_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"nft_burn\",\n\t\t...f,\n\t}),\n\tcontractCall: (f: TriggerArgs<\"contract_call\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_call\",\n\t\t...f,\n\t}),\n\tcontractDeploy: (f: TriggerArgs<\"contract_deploy\"> = {}): ChainTrigger => ({\n\t\ttype: \"contract_deploy\",\n\t\t...f,\n\t}),\n\tprintEvent: (f: TriggerArgs<\"print_event\"> = {}): ChainTrigger => ({\n\t\ttype: \"print_event\",\n\t\t...f,\n\t}),\n\tsbtcDeposit: (f: TriggerArgs<\"sbtc_deposit\"> = {}): ChainTrigger => ({\n\t\ttype: \"sbtc_deposit\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalCreate: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_create\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_create\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalAccept: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_accept\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_accept\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalReject: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_reject\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_reject\",\n\t\t...f,\n\t}),\n\tsbtcWithdrawalSweptConfirmed: (\n\t\tf: TriggerArgs<\"sbtc_withdrawal_swept_confirmed\"> = {},\n\t): ChainTrigger => ({\n\t\ttype: \"sbtc_withdrawal_swept_confirmed\",\n\t\t...f,\n\t}),\n\truneEtch: (f: TriggerArgs<\"rune_etch\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_etch\",\n\t\t...f,\n\t}),\n\truneMint: (f: TriggerArgs<\"rune_mint\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_mint\",\n\t\t...f,\n\t}),\n\truneTransfer: (f: TriggerArgs<\"rune_transfer\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_transfer\",\n\t\t...f,\n\t}),\n\truneBurn: (f: TriggerArgs<\"rune_burn\"> = {}): ChainTrigger => ({\n\t\ttype: \"rune_burn\",\n\t\t...f,\n\t}),\n} as const;\n\n/** The body for creating a webhook: name, triggers, URL, delivery options. */\nexport interface CreateWebhookRequest {\n\tname: string;\n\ttriggers: ChainTrigger[];\n\turl: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport interface ParsedCreateWebhookRequest\n\textends Omit<CreateWebhookRequest, \"format\"> {\n\tformat: WebhookFormat;\n}\n\n/** The fields of a webhook you can change. */\nexport interface UpdateWebhookRequest {\n\tname?: string;\n\turl?: string;\n\tformat?: WebhookFormat;\n\tauthConfig?: Record<string, unknown>;\n\tmaxRetries?: number;\n\ttimeoutMs?: number;\n\tconcurrency?: number;\n}\n\nexport type ParsedUpdateWebhookRequest = UpdateWebhookRequest;\n\nexport interface ReplayWebhookRequest {\n\tfromBlock: number;\n\ttoBlock: number;\n\tforce?: string;\n}\n\nexport type ParsedReplayWebhookRequest = ReplayWebhookRequest;\n\n/** Body of `POST /:id/dead/requeue`. Both fields narrow which dead rows requeue. */\nexport interface RequeueDeadRequest {\n\treplayId?: string;\n\t/** ISO datetime; only dead rows that failed at or after it. */\n\tsince?: string;\n}\n\n/** A webhook's name, status, format, and URL. */\nexport interface WebhookSummary {\n\tid: string;\n\tname: string;\n\tstatus: WebhookStatus;\n\tkind: WebhookKind;\n\tformat: WebhookFormat;\n\turl: string;\n\tlastDeliveryAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** When the circuit breaker paused this webhook (20 straight failures);\n\t * cleared on resume. Present on the list summary (not detail-only) so a\n\t * numbers-only insight can be shown per row without a per-row fetch. */\n\tcircuitOpenedAt: string | null;\n\t/** Why the webhook is paused: `user` (you paused it) or `circuit` (20\n\t * straight failures tripped the breaker). Null while `active`. Absent from\n\t * servers that predate it. */\n\tpauseReason?: WebhookPauseReason | null;\n\t/** One verdict from the state above: `ok`, `failing` (recent failures),\n\t * `down` (5+ failures in a row and no success for 15 minutes),\n\t * `paused_user` or `paused_circuit`. Absent from servers that predate it. */\n\thealth?: WebhookHealth;\n\t/** Consecutive failed deliveries (reset to 0 on a success). On the\n\t * summary so the list can show a failing receiver per row without a\n\t * per-row fetch. */\n\tcircuitFailures: number;\n\t/** Owning product, derived from the name prefix (`MANAGED_NAME_PREFIXES`).\n\t * When non-null the API refuses to rename the webhook. */\n\tmanagedBy: string | null;\n\tcreatedAt: string;\n\tupdatedAt: string;\n}\n\n/** What a webhook's receiver credentials look like once redacted for a\n * response — never the bearer token, basic-auth string, or header values\n * themselves, only enough to show what's set. `authConfig` on create/update\n * is unaffected (write-only: the API still accepts it, just never echoes\n * it back). */\nexport interface WebhookAuth {\n\ttype: \"bearer\" | \"basic\" | \"none\";\n\t/** Keys of any extra headers the receiver expects — never their values. */\n\theaderNames: string[];\n\t/** True when a bearer token or basic-auth string is set, whatever it is. */\n\thasSecret: boolean;\n}\n\n/** A webhook with its triggers, auth, retry, and timeout settings. */\nexport interface WebhookDetail extends WebhookSummary {\n\t/** Chain-trigger filters. */\n\ttriggers: ChainTrigger[];\n\tauth: WebhookAuth;\n\tmaxRetries: number;\n\ttimeoutMs: number;\n\tconcurrency: number;\n\tlastError: string | null;\n\t/** When the receiver's TLS certificate expires, from the periodic probe.\n\t * Null for http receivers, refused or unreachable hosts, and webhooks not\n\t * probed yet. */\n\treceiverCertExpiresAt: string | null;\n\t/** Set when this instance's chain-trigger\n\t * evaluator isn't running (`SUBGRAPH_SOURCE` != `streams-index`) — the\n\t * webhook will never fire until that's fixed. Null otherwise. Surfaced\n\t * on create (so it's seen immediately) and on every read (so `secondlayer\n\t * webhooks doctor` reports it for a webhook created before the mismatch,\n\t * or on an instance whose config changed since). */\n\twarning: string | null;\n}\n\n/** The new webhook and its signing secret, shown once. */\nexport interface CreateWebhookResponse {\n\twebhook: WebhookDetail;\n\t/** Plaintext signing secret — surfaced ONCE. Store it server-side. */\n\tsigningSecret: string;\n}\n\n/** The webhook and its new signing secret. */\nexport interface RotateSecretResponse {\n\twebhook: WebhookDetail;\n\tsigningSecret: string;\n}\n\n/** One delivery attempt: status code, error, duration, and response. */\nexport interface DeliveryRow {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\terrorMessage: string | null;\n\tdurationMs: number | null;\n\t/** First 512 characters; the full body is on `deliveries.get`. */\n\tresponseBody: string | null;\n\tdispatchedAt: string;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\tblockHeight: number | null;\n\t/** ISO timestamp of the delivered event's block. `null` for test\n\t * deliveries, events already compacted out of the outbox, and rows\n\t * written before this column existed. */\n\tblockTime: string | null;\n\t/** Null for test deliveries and events already compacted out of the\n\t * outbox. */\n\ttxId: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`.\n\t * Null for test deliveries, compacted rows, and rows with neither shape\n\t * (a settlement or reorg outbox row). */\n\teventIndex: number | null;\n}\n\n/** One hour of `webhook_outbox` activity (`GET /:id/activity`), zero-filled\n * so the events chart always has 168 bars. */\nexport interface WebhookActivityHour {\n\t/** ISO timestamp, UTC hour start. */\n\thour: string;\n\tdelivered: number;\n\twaiting: number;\n\tgaveUp: number;\n\t/** Failed attempts in the hour (no response or non-2xx), from\n\t * `webhook_deliveries`. Attempts, not events: a retried-then-delivered\n\t * event counts here but is `delivered` above. */\n\tfailed: number;\n}\n\n/** A week of hourly delivery counts and what is waiting now. */\nexport interface WebhookActivity {\n\t/** 168 hours, oldest first. */\n\thours: WebhookActivityHour[];\n\t/** Pending rows right now, no time bound. */\n\twaiting: number;\n\tnextAttemptAt: string | null;\n\tlastSuccessAt: string | null;\n\t/** 7-day counts per `event_type` (same 168-hour window as `hours`), e.g.\n\t * `chain.stx_transfer.apply` — the config card's per-trigger volume. */\n\tbyEventType: Record<string, number>;\n\t/** Typical delivered attempts for each UTC hour of day (p10 and p90 of the\n\t * last 28 days, from `webhook_deliveries`). Null at low volume, where\n\t * \"usual\" is not meaningful. */\n\tusualByHourOfDay: Array<{ lo: number; hi: number }> | null;\n\t/** 30 UTC days, oldest first, from the hourly delivery counts (2xx is\n\t * delivered, everything else failed). */\n\tdays: WebhookActivityDay[];\n}\n\n/** One UTC day of delivery attempts (`GET /:id/activity`). */\nexport interface WebhookActivityDay {\n\t/** YYYY-MM-DD, UTC. */\n\tday: string;\n\tdelivered: number;\n\tfailed: number;\n}\n\n/** Heat data for every webhook on the account (`GET /api/webhooks/activity`),\n * from `webhook_deliveries` attempts. */\nexport interface WebhooksActivitySummary {\n\t/** 168 ISO UTC hour starts, oldest first. */\n\thours: string[];\n\t/** Arrays are aligned to `hours` and zero-filled. */\n\twebhooks: Array<{ id: string; delivered: number[]; failed: number[] }>;\n}\n\n/**\n * One delivery attempt with its outbox context.\n *\n * Serves the delivery card (`GET /:id/deliveries/:deliveryId`). `payload`,\n * `outboxId`, `eventType`, `txId`, `blockHeight`, `blockTime`, and `eventIndex`\n * are null once the outbox row is gone (compacted after 7 days) or for a test\n * delivery, which never had one.\n */\nexport interface WebhookDeliveryDetail {\n\tid: string;\n\tattempt: number;\n\tstatusCode: number | null;\n\tdurationMs: number | null;\n\tdispatchedAt: string;\n\terrorMessage: string | null;\n\tresponseBody: string | null;\n\tresponseHeaders: Record<string, string> | null;\n\toutboxId: string | null;\n\t/** The outbox row's own status — `null` once it's gone (compacted after\n\t * delivery, or never had one, e.g. a test delivery). Only `\"dead\"` means\n\t * a resend is possible: it's the one status `POST /:id/dead/:outboxId/\n\t * requeue` accepts. */\n\toutboxStatus: \"pending\" | \"delivered\" | \"dead\" | null;\n\teventType: string | null;\n\ttxId: string | null;\n\tblockHeight: number | null;\n\tblockTime: string | null;\n\t/** The row's position within its block/tx, from the outbox's `row_pk`\n\t * (`event_index` for a chain-trigger row). Null when `row_pk` carries\n\t * none — a settlement or reorg outbox row, or no outbox row at all. */\n\teventIndex: number | null;\n\tpayload: unknown | null;\n}\n\n/** How many events a replay scanned and enqueued. */\nexport interface ReplayResult {\n\treplayId: string;\n\tenqueuedCount: number;\n\tscannedCount: number;\n}\n\n/** Live state of one stored replay. */\nexport interface ReplayProgress {\n\treplayId: string;\n\twebhookId: string;\n\tstatus: \"scanning\" | \"running\" | \"done\" | \"failed\";\n\tfromBlock: number;\n\ttoBlock: number;\n\t/** Events the replay enqueued. */\n\ttotal: number;\n\t/** Delivered or gave up (`total - pending`). */\n\tprocessed: number;\n\tpending: number;\n\t/** Null until the replay finishes. */\n\tdelivered: number | null;\n\t/** Null until the replay finishes. */\n\tgaveUp: number | null;\n\tstartedAt: string;\n\tfinishedAt: string | null;\n\terror: string | null;\n}\n\n/** Range presets for starting a replay, from `GET /:id/replays`. */\nexport interface ReplayRanges {\n\t/** Last evaluated block; null when the webhook has no evaluator state yet. */\n\ttip: number | null;\n\tpresets: Array<{\n\t\tblocks: 100 | 1000 | 10000;\n\t\tfromBlock: number;\n\t\ttoBlock: number;\n\t\t/** Lower bound: delivered rows are deleted after 7 days. */\n\t\tknownEvents: number;\n\t}>;\n\t/** Dead rows since the webhook last succeeded (all dead rows when it never has). */\n\tdeadSinceFailing: { since: string | null; count: number };\n}\n\n/** Result of a one-off test delivery (`POST /:id/test`). Logged as a delivery\n * row (with a null outbox_id) so it shows up under the webhook's deliveries. */\nexport interface WebhookTestResult {\n\tok: boolean;\n\tstatusCode: number | null;\n\terror: string | null;\n\tdurationMs: number;\n\tdeliveryId: string;\n}\n\n/** A delivery that ran out of retries. */\nexport interface DeadRow {\n\tid: string;\n\teventType: string;\n\tattempt: number;\n\tblockHeight: number;\n\ttxId: string | null;\n\tpayload: Record<string, unknown>;\n\tfailedAt: string | null;\n\tcreatedAt: string;\n}\n\nfunction formatIssuePath(path: PropertyKey[]): string {\n\treturn path.length > 0 ? `${path.map(String).join(\".\")}: ` : \"\";\n}\n\nexport function formatWebhookSchemaErrors(error: z.ZodError): string[] {\n\treturn error.issues.map(\n\t\t(issue) => `${formatIssuePath(issue.path)}${issue.message}`,\n\t);\n}\n",
6
+ "const BTC_TXID = /^(?:0x)?[0-9a-f]{64}$/;\n\n/**\n * Normalize a Bitcoin txid to the stored form: `0x` + 64 lowercase hex.\n * Explorers show bare hex; the Index stores (and matches) the prefixed form,\n * so every input boundary (trigger schema, API filters) runs through here.\n * Returns null when the value isn't a 32-byte hex txid.\n */\nexport function normalizeBtcTxid(value: string): string | null {\n\tconst v = value.trim().toLowerCase();\n\tif (!BTC_TXID.test(v)) return null;\n\treturn v.startsWith(\"0x\") ? v : `0x${v}`;\n}\n",
6
7
  "// This file must stay import-free. The SDK's `webhooks/triggers` subpath\n// re-exports it, and that reaches the browser through apps/web, so anything\n// imported here (zod especially) would ship to the client bundle.\n//\n// CHAIN_TRIGGER_FIELDS is a literal, checked against ChainTriggerSchema in\n// webhooks.test.ts so it can never drift behind the validator.\n\nexport const CHAIN_TRIGGER_TYPES = [\n\t\"stx_transfer\",\n\t\"stx_mint\",\n\t\"stx_burn\",\n\t\"stx_lock\",\n\t\"ft_transfer\",\n\t\"ft_mint\",\n\t\"ft_burn\",\n\t\"nft_transfer\",\n\t\"nft_mint\",\n\t\"nft_burn\",\n\t\"contract_call\",\n\t\"contract_deploy\",\n\t\"print_event\",\n\t\"nested_contract_call\",\n\t\"var_set\",\n\t\"map_set\",\n\t\"map_insert\",\n\t\"map_delete\",\n\t\"sbtc_deposit\",\n\t\"sbtc_withdrawal_create\",\n\t\"sbtc_withdrawal_accept\",\n\t\"sbtc_withdrawal_reject\",\n\t\"sbtc_withdrawal_swept_confirmed\",\n\t\"rune_etch\",\n\t\"rune_mint\",\n\t\"rune_transfer\",\n\t\"rune_burn\",\n] as const;\n\nexport type ChainTriggerType = (typeof CHAIN_TRIGGER_TYPES)[number];\n\n/**\n * Per-type accepted filter fields for chain triggers, in validator key order.\n */\nexport const CHAIN_TRIGGER_FIELDS: Record<string, string[]> = {\n\tstx_transfer: [\"sender\", \"recipient\", \"minAmount\", \"maxAmount\"],\n\tstx_mint: [\"recipient\", \"minAmount\"],\n\tstx_burn: [\"sender\", \"minAmount\"],\n\tstx_lock: [\"lockedAddress\", \"minAmount\"],\n\tft_transfer: [\"assetIdentifier\", \"sender\", \"recipient\", \"minAmount\", \"trait\"],\n\tft_mint: [\"assetIdentifier\", \"recipient\", \"minAmount\", \"trait\"],\n\tft_burn: [\"assetIdentifier\", \"sender\", \"minAmount\", \"trait\"],\n\tnft_transfer: [\"assetIdentifier\", \"sender\", \"recipient\", \"trait\"],\n\tnft_mint: [\"assetIdentifier\", \"recipient\", \"trait\"],\n\tnft_burn: [\"assetIdentifier\", \"sender\", \"trait\"],\n\tcontract_call: [\"contractId\", \"functionName\", \"caller\", \"trait\"],\n\tcontract_deploy: [\"deployer\", \"contractName\"],\n\tprint_event: [\"contractId\", \"topic\", \"trait\", \"where\"],\n\tnested_contract_call: [\n\t\t\"contractId\",\n\t\t\"functionName\",\n\t\t\"caller\",\n\t\t\"sender\",\n\t\t\"trait\",\n\t],\n\tvar_set: [\"contractId\", \"varName\", \"trait\"],\n\tmap_set: [\"contractId\", \"map\", \"trait\"],\n\tmap_insert: [\"contractId\", \"map\", \"trait\"],\n\tmap_delete: [\"contractId\", \"map\", \"trait\"],\n\tsbtc_deposit: [\"recipient\", \"minAmount\", \"maxAmount\", \"bitcoinTxid\"],\n\tsbtc_withdrawal_create: [\"sender\", \"minAmount\", \"maxAmount\", \"requestId\"],\n\tsbtc_withdrawal_accept: [\"requestId\", \"sweepTxid\"],\n\tsbtc_withdrawal_reject: [\"requestId\"],\n\tsbtc_withdrawal_swept_confirmed: [\"requestId\", \"sweepTxid\"],\n\trune_etch: [\"rune\"],\n\trune_mint: [\"rune\"],\n\trune_transfer: [\"rune\", \"address\", \"minAmount\"],\n\trune_burn: [\"rune\"],\n};\n"
7
8
  ],
8
- "mappings": ";AAAA;;;ACOO,IAAM,sBAAsB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAOO,IAAM,uBAAiD;AAAA,EAC7D,cAAc,CAAC,UAAU,aAAa,aAAa,WAAW;AAAA,EAC9D,UAAU,CAAC,aAAa,WAAW;AAAA,EACnC,UAAU,CAAC,UAAU,WAAW;AAAA,EAChC,UAAU,CAAC,iBAAiB,WAAW;AAAA,EACvC,aAAa,CAAC,mBAAmB,UAAU,aAAa,aAAa,OAAO;AAAA,EAC5E,SAAS,CAAC,mBAAmB,aAAa,aAAa,OAAO;AAAA,EAC9D,SAAS,CAAC,mBAAmB,UAAU,aAAa,OAAO;AAAA,EAC3D,cAAc,CAAC,mBAAmB,UAAU,aAAa,OAAO;AAAA,EACh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IAAkC,CAAC,OAAqB;AAAA,IACtE,MAAM;AAAA,OACH;AAAA,EACJ;AAAA,EACA,UAAU,CAAC,IAA8B,CAAC,OAAqB;AAAA,IAC9D,MAAM;AAAA,OACH;AAAA,EACJ;AACD;AAgTA,SAAS,eAAe,CAAC,MAA6B;AAAA,EACrD,OAAO,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI,MAAM,EAAE,KAAK,GAAG,QAAQ;AAAA;AAGvD,SAAS,yBAAyB,CAAC,OAA6B;AAAA,EACtE,OAAO,MAAM,OAAO,IACnB,CAAC,UAAU,GAAG,gBAAgB,MAAM,IAAI,IAAI,MAAM,SACnD;AAAA;",
10
+ "debugId": "986311831A7603CC64756E2164756E21",
10
11
  "names": []
11
12
  }
@@ -32,7 +32,8 @@ type StxTransferPayload = {
32
32
  sender: string
33
33
  recipient: string
34
34
  amount: string
35
- memo?: string
35
+ /** `0x` hex, or null when the transfer carried no memo. */
36
+ memo: string | null
36
37
  };
37
38
  type StxMintPayload = {
38
39
  recipient: string
@@ -46,6 +47,8 @@ type StxLockPayload = {
46
47
  locked_address: string
47
48
  locked_amount: string
48
49
  unlock_height: string
50
+ /** The PoX contract that made the lock (`…pox-4`, `…pox-5`, …). */
51
+ contract_identifier: string
49
52
  };
50
53
  type FtTransferPayload = {
51
54
  asset_identifier: string
@@ -67,27 +70,36 @@ type NftTransferPayload = {
67
70
  asset_identifier: string
68
71
  sender: string
69
72
  recipient: string
70
- value: StreamsClarityValue
71
- /** Canonical serialized hex of `value`, when the stream carries it. */
72
- raw_value?: string
73
+ /** The token id as canonical serialized Clarity hex (`0x…`). */
74
+ raw_value: string
75
+ /** @deprecated Legacy, only on rows before block ~8.124M and in varying
76
+ * shapes. Read `raw_value`. */
77
+ value?: StreamsClarityValue
73
78
  };
74
79
  type NftMintPayload = {
75
80
  asset_identifier: string
76
81
  recipient: string
77
- value: StreamsClarityValue
78
- raw_value?: string
82
+ /** The token id as canonical serialized Clarity hex (`0x…`). */
83
+ raw_value: string
84
+ /** @deprecated Legacy; read `raw_value`. */
85
+ value?: StreamsClarityValue
79
86
  };
80
87
  type NftBurnPayload = {
81
88
  asset_identifier: string
82
89
  sender: string
83
- value: StreamsClarityValue
84
- raw_value?: string
90
+ /** The token id as canonical serialized Clarity hex (`0x…`). */
91
+ raw_value: string
92
+ /** @deprecated Legacy; read `raw_value`. */
93
+ value?: StreamsClarityValue
85
94
  };
86
95
  type PrintPayload = {
87
96
  contract_id?: string | null
88
97
  topic?: string
98
+ /** The printed value as canonical serialized Clarity hex (`0x…`). */
99
+ raw_value: string
100
+ /** @deprecated Legacy, only on rows before block ~8.124M and in varying
101
+ * shapes. Read `raw_value`. */
89
102
  value?: unknown
90
- raw_value?: string
91
103
  };
92
104
  /** Union of every Streams payload shape, discriminated by `event_type` on the
93
105
  * parent `StreamsEvent`. */
@@ -261,9 +273,20 @@ declare function parseAssetIdentifier(assetIdentifier: string, eventType: string
261
273
  contract_id: string
262
274
  token_name: string | null
263
275
  };
264
- /** NFT token id: live streams emits a typed Clarity value at `value` and the
265
- * canonical hex at `raw_value`; prefer raw_value when present. */
276
+ /** The canonical `0x` hex of a payload's Clarity value, from whichever field
277
+ * the row's ingestion era wrote: `raw_value` (from ~7.46M), a `0x` string at
278
+ * `value` (before that), or a typed `{ hex }` object. Null when none is hex. */
279
+ declare function clarityHexOf(payload: Record<string, unknown>): string | null;
280
+ /** NFT token id as canonical `0x` hex; throws when missing or malformed. */
266
281
  declare function requireHexValue(payload: Record<string, unknown>, eventType: string): string;
282
+ /**
283
+ * A transfer memo as `0x` hex, or null when the transfer carried none.
284
+ *
285
+ * Stored memos come in three spellings depending on ingestion era: `0x…`
286
+ * (before ~7.4M), bare hex (after), and missing or `""` for transfers made
287
+ * without a memo. Non-hex strings pass through untouched.
288
+ */
289
+ declare function normalizeMemoHex(memo: unknown): string | null;
267
290
  /** Common envelope fields shared by every decoded event, lifted off the
268
291
  * source StreamsEvent. The decoder supplies event_type + decoded_payload. */
269
292
  declare function decodedRow<
@@ -517,4 +540,4 @@ declare function decodeNftBurn(event: StreamsEvent): DecodedNftBurn;
517
540
  /** Union of every decoded DB-row shape the guard+decode pairs produce —
518
541
  * exactly what the `decoded_events` table stores. */
519
542
  type DecodedEventRow = DecodedFtTransfer | DecodedNftTransfer | DecodedStxTransfer | DecodedStxMint | DecodedStxBurn | DecodedStxLock | DecodedFtMint | DecodedFtBurn | DecodedNftMint | DecodedNftBurn | DecodedPrint;
520
- export { DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, FtBurnPayload, FtMintPayload, FtTransferEvent, FtTransferPayload, MapDeletePayload, MapWritePayload, NestedContractCallPayload, NftBurnPayload, NftMintPayload, NftTransferEvent, NftTransferPayload, PrintPayload, RUNE_EVENT_TYPES, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneStreamsEvent, STREAMS_EVENT_TYPES, StreamsClarityValue, StreamsEvent, StreamsEventBase, StreamsEventPayload, StreamsEventType, StreamsWireEvent, StxBurnPayload, StxLockPayload, StxMintPayload, StxTransferPayload, VarSetPayload, VmStreamsEvent, decodeClarityValue, decodeFtBurn, decodeFtMint, decodeFtTransfer, decodeNftBurn, decodeNftMint, decodeNftTransfer, decodePrint, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, decodedRow, isFtBurn, isFtMint, isFtTransfer, isNftBurn, isNftMint, isNftTransfer, isPrint, isStxBurn, isStxLock, isStxMint, isStxTransfer, optionalString, parseAssetIdentifier, requireAmount, requireAmountField, requireHexValue, requireString, toJsonSafe };
543
+ export { DecodedEventColumns, DecodedEventRow, DecodedFtBurn, DecodedFtBurnPayload, DecodedFtMint, DecodedFtMintPayload, DecodedFtTransfer, DecodedFtTransferPayload, DecodedNftBurn, DecodedNftBurnPayload, DecodedNftMint, DecodedNftMintPayload, DecodedNftTransfer, DecodedNftTransferPayload, DecodedPrint, DecodedPrintPayload, DecodedPrintValue, DecodedStxBurn, DecodedStxBurnPayload, DecodedStxLock, DecodedStxLockPayload, DecodedStxMint, DecodedStxMintPayload, DecodedStxTransfer, DecodedStxTransferPayload, FtBurnPayload, FtMintPayload, FtTransferEvent, FtTransferPayload, MapDeletePayload, MapWritePayload, NestedContractCallPayload, NftBurnPayload, NftMintPayload, NftTransferEvent, NftTransferPayload, PrintPayload, RUNE_EVENT_TYPES, RuneEtchEntry, RuneEventPayload, RuneEventType, RuneStreamsEvent, STREAMS_EVENT_TYPES, StreamsClarityValue, StreamsEvent, StreamsEventBase, StreamsEventPayload, StreamsEventType, StreamsWireEvent, StxBurnPayload, StxLockPayload, StxMintPayload, StxTransferPayload, VarSetPayload, VmStreamsEvent, clarityHexOf, decodeClarityValue, decodeFtBurn, decodeFtMint, decodeFtTransfer, decodeNftBurn, decodeNftMint, decodeNftTransfer, decodePrint, decodeStxBurn, decodeStxLock, decodeStxMint, decodeStxTransfer, decodedRow, isFtBurn, isFtMint, isFtTransfer, isNftBurn, isNftMint, isNftTransfer, isPrint, isStxBurn, isStxLock, isStxMint, isStxTransfer, normalizeMemoHex, optionalString, parseAssetIdentifier, requireAmount, requireAmountField, requireHexValue, requireString, toJsonSafe };
@@ -76,16 +76,21 @@ function parseAssetIdentifier(assetIdentifier, eventType) {
76
76
  token_name: tokenName && tokenName.length > 0 ? tokenName : null
77
77
  };
78
78
  }
79
- function requireHexValue(payload, eventType) {
79
+ var HEX_BODY = /^[0-9a-fA-F]*$/;
80
+ function clarityHexOf(payload) {
80
81
  const rawValue = payload.raw_value;
81
- if (typeof rawValue === "string") {
82
- if (!/^0x[0-9a-fA-F]*$/.test(rawValue)) {
83
- throw new Error(`${eventType} payload has malformed value`);
84
- }
82
+ if (typeof rawValue === "string")
85
83
  return rawValue;
86
- }
87
84
  const value = payload.value;
88
- const hex = typeof value === "string" ? value : value && typeof value === "object" && typeof value.hex === "string" ? value.hex : null;
85
+ if (typeof value === "string" && value.startsWith("0x"))
86
+ return value;
87
+ if (value && typeof value === "object" && typeof value.hex === "string") {
88
+ return value.hex;
89
+ }
90
+ return null;
91
+ }
92
+ function requireHexValue(payload, eventType) {
93
+ const hex = clarityHexOf(payload) ?? (typeof payload.value === "string" ? payload.value : null);
89
94
  if (!hex) {
90
95
  throw new Error(`${eventType} payload missing value`);
91
96
  }
@@ -94,6 +99,14 @@ function requireHexValue(payload, eventType) {
94
99
  }
95
100
  return hex;
96
101
  }
102
+ function normalizeMemoHex(memo) {
103
+ if (typeof memo !== "string")
104
+ return null;
105
+ const body = memo.startsWith("0x") ? memo.slice(2) : memo;
106
+ if (body.length === 0)
107
+ return null;
108
+ return HEX_BODY.test(body) ? `0x${body}` : memo;
109
+ }
97
110
  function decodedRow(event, eventType, decoded_payload) {
98
111
  return {
99
112
  cursor: event.cursor,
@@ -153,17 +166,6 @@ function decodeNftTransfer(event) {
153
166
  });
154
167
  }
155
168
  // src/streams-rows/print.ts
156
- function printValueHex(payload) {
157
- if (typeof payload.raw_value === "string")
158
- return payload.raw_value;
159
- const value = payload.value;
160
- if (typeof value === "string" && value.startsWith("0x"))
161
- return value;
162
- if (value && typeof value === "object" && typeof value.hex === "string") {
163
- return value.hex;
164
- }
165
- return null;
166
- }
167
169
  function isPrint(event) {
168
170
  return event.event_type === "print";
169
171
  }
@@ -173,7 +175,7 @@ function decodePrint(event) {
173
175
  }
174
176
  const payload = event.payload;
175
177
  const topic = optionalString(payload.topic);
176
- const rawValue = printValueHex(payload);
178
+ const rawValue = clarityHexOf(payload);
177
179
  const value = rawValue ? decodeClarityValue(rawValue) : toJsonSafe(payload.value ?? null);
178
180
  return decodedRow(event, "print", {
179
181
  contract_id: event.contract_id ?? optionalString(payload.contract_id),
@@ -193,7 +195,7 @@ function decodeStxTransfer(event) {
193
195
  sender: requireString(payload, "sender", "stx_transfer"),
194
196
  recipient: requireString(payload, "recipient", "stx_transfer"),
195
197
  amount: requireAmount(payload, "stx_transfer"),
196
- memo: optionalString(payload.memo)
198
+ memo: normalizeMemoHex(payload.memo)
197
199
  });
198
200
  }
199
201
  function isStxMint(event) {
@@ -301,6 +303,7 @@ function decodeNftBurn(event) {
301
303
  export {
302
304
  RUNE_EVENT_TYPES,
303
305
  STREAMS_EVENT_TYPES,
306
+ clarityHexOf,
304
307
  decodeClarityValue,
305
308
  decodeFtBurn,
306
309
  decodeFtMint,
@@ -325,6 +328,7 @@ export {
325
328
  isStxLock,
326
329
  isStxMint,
327
330
  isStxTransfer,
331
+ normalizeMemoHex,
328
332
  optionalString,
329
333
  parseAssetIdentifier,
330
334
  requireAmount,
@@ -334,5 +338,5 @@ export {
334
338
  toJsonSafe
335
339
  };
336
340
 
337
- //# debugId=A2147D16D1091C0C64756E2164756E21
341
+ //# debugId=7D4E3A3C6B9DB6E864756E2164756E21
338
342
  //# sourceMappingURL=index.js.map
@@ -4,14 +4,14 @@
4
4
  "sourcesContent": [
5
5
  "import { cvToValue, deserializeCV } from \"@secondlayer/stacks/clarity\";\n\n/** Make a cvToValue result JSON-serializable: Clarity (u)ints decode to bigint,\n * which JSON.stringify can't handle — convert recursively to strings. */\nexport function toJsonSafe(value: unknown): unknown {\n\tif (typeof value === \"bigint\") return value.toString();\n\tif (Array.isArray(value)) return value.map(toJsonSafe);\n\tif (value && typeof value === \"object\") {\n\t\tconst out: Record<string, unknown> = {};\n\t\tfor (const [key, val] of Object.entries(value)) {\n\t\t\tout[key] = toJsonSafe(val);\n\t\t}\n\t\treturn out;\n\t}\n\treturn value;\n}\n\n/** Decode a hex-encoded Clarity value to JSON-safe JS (uints as strings,\n * buffers as `0x…` hex, tuples as objects). Returns the input hex on failure. */\nexport function decodeClarityValue(hex: string): unknown {\n\ttry {\n\t\tconst clean = hex.startsWith(\"0x\") ? hex.slice(2) : hex;\n\t\treturn toJsonSafe(cvToValue(deserializeCV(clean)));\n\t} catch {\n\t\treturn hex;\n\t}\n}\n",
6
6
  "// The decoded event-type vocabulary — canonical home is now\n// `@secondlayer/stacks/filters` (the LEAF of the dependency graph: shared\n// depends on stacks, never the reverse, so no package can drift a private\n// copy upward). Re-exported here so every existing `@secondlayer/shared`\n// import keeps working unchanged.\nimport {\n\tDECODED_EVENT_TYPES,\n\ttype VM_NODE_TO_STORED_TYPE,\n} from \"@secondlayer/stacks/filters\";\nimport type { DecodedEventType } from \"@secondlayer/stacks/filters\";\n\nexport {\n\tDECODED_EVENT_TYPES,\n\tVM_EVENT_TYPES,\n\tVM_NODE_TO_STORED_TYPE,\n\ttype DecodedEventType,\n\ttype VmEventType,\n\ttype VmNodeEventType,\n} from \"@secondlayer/stacks/filters\";\n\ntype VmStoredToNode = {\n\t[K in keyof typeof VM_NODE_TO_STORED_TYPE as (typeof VM_NODE_TO_STORED_TYPE)[K]]: K;\n};\n\n/** Inverse of {@link VM_NODE_TO_STORED_TYPE}. Replay reconstruction emits the\n * node-shaped `/new_block.vm_events` body, so ingest can re-parse it. */\nexport const VM_STORED_TO_NODE_TYPE: VmStoredToNode = {\n\tnested_contract_call: \"contract_call_event\",\n\tvar_set: \"var_set_event\",\n\tmap_set: \"map_set_event\",\n\tmap_insert: \"map_insert_event\",\n\tmap_delete: \"map_delete_event\",\n};\n\n/** Alias kept for the Streams surface (identical to {@link DECODED_EVENT_TYPES}).\n * Explicit type annotation required — isolatedDeclarations emits `unknown` for\n * a bare const-to-const alias. */\nexport const STREAMS_EVENT_TYPES: typeof DECODED_EVENT_TYPES =\n\tDECODED_EVENT_TYPES;\nexport type StreamsEventType = DecodedEventType;\n\n/**\n * Wire vocabulary for `chain=bitcoin` Streams events (plan 059) — Runes\n * activity, mirroring the Stacks `ft_*` family. Same four kinds as 058's\n * `RuneEventKind` (`packages/api/src/index/runes.ts`), duplicated here as the\n * canonical shared const rather than imported from the api package (shared\n * never depends on api); the DB `kind` column (`etch|mint|transfer|burn`) is\n * mapped at the edge in both readers.\n */\nexport const RUNE_EVENT_TYPES = [\n\t\"rune_etch\",\n\t\"rune_mint\",\n\t\"rune_transfer\",\n\t\"rune_burn\",\n] as const;\nexport type RuneEventType = (typeof RUNE_EVENT_TYPES)[number];\n",
7
- "import type { StreamsEvent } from \"./events.ts\";\n\n/** Superset of the columns the decoded_events table holds. Every decoded\n * event's `decoded_payload` is assignable to this, so the indexer's writer\n * can map columns generically instead of per-event-type. */\nexport type DecodedEventColumns = {\n\tcontract_id?: string | null;\n\tasset_identifier?: string | null;\n\tsender?: string | null;\n\trecipient?: string | null;\n\tamount?: string | null;\n\tvalue?: string | null;\n\tmemo?: string | null;\n\t/** JSONB overflow for non-flat types (e.g. print's decoded value). */\n\tpayload?: unknown;\n};\n\nexport function requireString(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`${eventType} payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nexport function optionalString(value: unknown): string | null {\n\treturn typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function requireAmountField(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst amount = requireString(payload, field, eventType);\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(`${eventType} payload has malformed ${field}`);\n\t}\n\treturn amount;\n}\n\nexport function requireAmount(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\treturn requireAmountField(payload, \"amount\", eventType);\n}\n\nexport function parseAssetIdentifier(\n\tassetIdentifier: string,\n\teventType: string,\n): { contract_id: string; token_name: string | null } {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(`${eventType} payload has malformed asset_identifier`);\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\n/** NFT token id: live streams emits a typed Clarity value at `value` and the\n * canonical hex at `raw_value`; prefer raw_value when present. */\nexport function requireHexValue(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\tconst rawValue = payload.raw_value;\n\tif (typeof rawValue === \"string\") {\n\t\tif (!/^0x[0-9a-fA-F]*$/.test(rawValue)) {\n\t\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t\t}\n\t\treturn rawValue;\n\t}\n\n\tconst value = payload.value;\n\tconst hex =\n\t\ttypeof value === \"string\"\n\t\t\t? value\n\t\t\t: value &&\n\t\t\t\t\ttypeof value === \"object\" &&\n\t\t\t\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t\t\t\t? (value as { hex: string }).hex\n\t\t\t\t: null;\n\n\tif (!hex) {\n\t\tthrow new Error(`${eventType} payload missing value`);\n\t}\n\tif (!/^0x[0-9a-fA-F]*$/.test(hex)) {\n\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t}\n\treturn hex;\n}\n\n/** Common envelope fields shared by every decoded event, lifted off the\n * source StreamsEvent. The decoder supplies event_type + decoded_payload. */\nexport function decodedRow<T extends string, P>(\n\tevent: StreamsEvent,\n\teventType: T,\n\tdecoded_payload: P,\n): {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: T;\n\tdecoded_payload: P;\n\tsource_cursor: string;\n} {\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: eventType,\n\t\tdecoded_payload,\n\t\tsource_cursor: event.cursor,\n\t};\n}\n",
7
+ "import type { StreamsEvent } from \"./events.ts\";\n\n/** Superset of the columns the decoded_events table holds. Every decoded\n * event's `decoded_payload` is assignable to this, so the indexer's writer\n * can map columns generically instead of per-event-type. */\nexport type DecodedEventColumns = {\n\tcontract_id?: string | null;\n\tasset_identifier?: string | null;\n\tsender?: string | null;\n\trecipient?: string | null;\n\tamount?: string | null;\n\tvalue?: string | null;\n\tmemo?: string | null;\n\t/** JSONB overflow for non-flat types (e.g. print's decoded value). */\n\tpayload?: unknown;\n};\n\nexport function requireString(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst value = payload[field];\n\tif (typeof value !== \"string\" || value.length === 0) {\n\t\tthrow new Error(`${eventType} payload missing ${field}`);\n\t}\n\treturn value;\n}\n\nexport function optionalString(value: unknown): string | null {\n\treturn typeof value === \"string\" && value.length > 0 ? value : null;\n}\n\nexport function requireAmountField(\n\tpayload: Record<string, unknown>,\n\tfield: string,\n\teventType: string,\n): string {\n\tconst amount = requireString(payload, field, eventType);\n\tif (!/^(0|[1-9]\\d*)$/.test(amount)) {\n\t\tthrow new Error(`${eventType} payload has malformed ${field}`);\n\t}\n\treturn amount;\n}\n\nexport function requireAmount(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\treturn requireAmountField(payload, \"amount\", eventType);\n}\n\nexport function parseAssetIdentifier(\n\tassetIdentifier: string,\n\teventType: string,\n): { contract_id: string; token_name: string | null } {\n\tconst [contractId, tokenName] = assetIdentifier.split(\"::\");\n\tif (!contractId) {\n\t\tthrow new Error(`${eventType} payload has malformed asset_identifier`);\n\t}\n\treturn {\n\t\tcontract_id: contractId,\n\t\ttoken_name: tokenName && tokenName.length > 0 ? tokenName : null,\n\t};\n}\n\nconst HEX_BODY = /^[0-9a-fA-F]*$/;\n\n/** The canonical `0x` hex of a payload's Clarity value, from whichever field\n * the row's ingestion era wrote: `raw_value` (from ~7.46M), a `0x` string at\n * `value` (before that), or a typed `{ hex }` object. Null when none is hex. */\nexport function clarityHexOf(payload: Record<string, unknown>): string | null {\n\tconst rawValue = payload.raw_value;\n\tif (typeof rawValue === \"string\") return rawValue;\n\tconst value = payload.value;\n\tif (typeof value === \"string\" && value.startsWith(\"0x\")) return value;\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t) {\n\t\treturn (value as { hex: string }).hex;\n\t}\n\treturn null;\n}\n\n/** NFT token id as canonical `0x` hex; throws when missing or malformed. */\nexport function requireHexValue(\n\tpayload: Record<string, unknown>,\n\teventType: string,\n): string {\n\tconst hex =\n\t\tclarityHexOf(payload) ??\n\t\t(typeof payload.value === \"string\" ? payload.value : null);\n\tif (!hex) {\n\t\tthrow new Error(`${eventType} payload missing value`);\n\t}\n\tif (!/^0x[0-9a-fA-F]*$/.test(hex)) {\n\t\tthrow new Error(`${eventType} payload has malformed value`);\n\t}\n\treturn hex;\n}\n\n/**\n * A transfer memo as `0x` hex, or null when the transfer carried none.\n *\n * Stored memos come in three spellings depending on ingestion era: `0x…`\n * (before ~7.4M), bare hex (after), and missing or `\"\"` for transfers made\n * without a memo. Non-hex strings pass through untouched.\n */\nexport function normalizeMemoHex(memo: unknown): string | null {\n\tif (typeof memo !== \"string\") return null;\n\tconst body = memo.startsWith(\"0x\") ? memo.slice(2) : memo;\n\tif (body.length === 0) return null;\n\treturn HEX_BODY.test(body) ? `0x${body}` : memo;\n}\n\n/** Common envelope fields shared by every decoded event, lifted off the\n * source StreamsEvent. The decoder supplies event_type + decoded_payload. */\nexport function decodedRow<T extends string, P>(\n\tevent: StreamsEvent,\n\teventType: T,\n\tdecoded_payload: P,\n): {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: T;\n\tdecoded_payload: P;\n\tsource_cursor: string;\n} {\n\treturn {\n\t\tcursor: event.cursor,\n\t\tblock_height: event.block_height,\n\t\ttx_id: event.tx_id,\n\t\ttx_index: event.tx_index,\n\t\tevent_index: event.event_index,\n\t\tevent_type: eventType,\n\t\tdecoded_payload,\n\t\tsource_cursor: event.cursor,\n\t};\n}\n",
8
8
  "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { FtTransferPayload } from \"./events.ts\";\n\nexport type FtTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"ft_transfer\" }\n>;\n\nexport type DecodedFtTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_transfer\";\n\tdecoded_payload: DecodedFtTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isFtTransfer(event: StreamsEvent): event is FtTransferEvent {\n\treturn event.event_type === \"ft_transfer\";\n}\n\nexport function decodeFtTransfer(event: StreamsEvent): DecodedFtTransfer {\n\tif (!isFtTransfer(event)) {\n\t\tthrow new Error(`Expected ft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"ft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"ft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"ft_transfer\");\n\tconst amount = requireAmount(payload, \"ft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"ft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"ft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tamount,\n\t});\n}\n",
9
9
  "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type { NftTransferPayload } from \"./events.ts\";\n\nexport type NftTransferEvent = Extract<\n\tStreamsEvent,\n\t{ event_type: \"nft_transfer\" }\n>;\n\nexport type DecodedNftTransferPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_transfer\";\n\tdecoded_payload: DecodedNftTransferPayload;\n\tsource_cursor: string;\n};\n\nexport function isNftTransfer(event: StreamsEvent): event is NftTransferEvent {\n\treturn event.event_type === \"nft_transfer\";\n}\n\nexport function decodeNftTransfer(event: StreamsEvent): DecodedNftTransfer {\n\tif (!isNftTransfer(event)) {\n\t\tthrow new Error(`Expected nft_transfer event, got ${event.event_type}`);\n\t}\n\n\tconst payload = event.payload;\n\tconst assetIdentifier = requireString(\n\t\tpayload,\n\t\t\"asset_identifier\",\n\t\t\"nft_transfer\",\n\t);\n\tconst sender = requireString(payload, \"sender\", \"nft_transfer\");\n\tconst recipient = requireString(payload, \"recipient\", \"nft_transfer\");\n\tconst value = requireHexValue(payload, \"nft_transfer\");\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\t\"nft_transfer\",\n\t);\n\n\treturn decodedRow(event, \"nft_transfer\", {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t\tsender,\n\t\trecipient,\n\t\tvalue,\n\t});\n}\n",
10
- "import { decodedRow, optionalString } from \"./_payload.ts\";\nimport { decodeClarityValue, toJsonSafe } from \"./clarity.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\n/** Decoded form of a Clarity `print` event:\n * - `topic`: the print topic, when the contract emits a `{ topic, ... }` tuple\n * - `value`: the Clarity value decoded to JSON (uints as strings, buffers as\n * `0x…` hex, tuples as objects)\n * - `raw_value`: the canonical serialized hex, for byte-exact consumers */\nexport type DecodedPrintValue = {\n\ttopic: string | null;\n\tvalue: unknown;\n\traw_value: string | null;\n};\n\nexport type DecodedPrintPayload = {\n\tcontract_id: string | null;\n\tpayload: DecodedPrintValue;\n};\n\nexport type DecodedPrint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"print\";\n\tdecoded_payload: DecodedPrintPayload;\n\tsource_cursor: string;\n};\n\nfunction printValueHex(payload: Record<string, unknown>): string | null {\n\tif (typeof payload.raw_value === \"string\") return payload.raw_value;\n\tconst value = payload.value;\n\tif (typeof value === \"string\" && value.startsWith(\"0x\")) return value;\n\tif (\n\t\tvalue &&\n\t\ttypeof value === \"object\" &&\n\t\ttypeof (value as { hex?: unknown }).hex === \"string\"\n\t) {\n\t\treturn (value as { hex: string }).hex;\n\t}\n\treturn null;\n}\n\nexport function isPrint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"print\" } {\n\treturn event.event_type === \"print\";\n}\n\nexport function decodePrint(event: StreamsEvent): DecodedPrint {\n\tif (!isPrint(event)) {\n\t\tthrow new Error(`Expected print event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\tconst topic = optionalString(payload.topic);\n\tconst rawValue = printValueHex(payload);\n\n\tconst value = rawValue\n\t\t? decodeClarityValue(rawValue)\n\t\t: toJsonSafe(payload.value ?? null);\n\n\treturn decodedRow(event, \"print\", {\n\t\tcontract_id: event.contract_id ?? optionalString(payload.contract_id),\n\t\tpayload: { topic, value, raw_value: rawValue },\n\t});\n}\n",
11
- "import {\n\tdecodedRow,\n\toptionalString,\n\trequireAmount,\n\trequireAmountField,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedStxTransferPayload = {\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\n\nexport type DecodedStxTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_transfer\";\n\tdecoded_payload: DecodedStxTransferPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxMintPayload = {\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedStxMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_mint\";\n\tdecoded_payload: DecodedStxMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxBurnPayload = {\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedStxBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_burn\";\n\tdecoded_payload: DecodedStxBurnPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxTransfer(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_transfer\" } {\n\treturn event.event_type === \"stx_transfer\";\n}\n\nexport function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer {\n\tif (!isStxTransfer(event)) {\n\t\tthrow new Error(`Expected stx_transfer event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_transfer\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_transfer\"),\n\t\trecipient: requireString(payload, \"recipient\", \"stx_transfer\"),\n\t\tamount: requireAmount(payload, \"stx_transfer\"),\n\t\tmemo: optionalString(payload.memo),\n\t});\n}\n\nexport function isStxMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_mint\" } {\n\treturn event.event_type === \"stx_mint\";\n}\n\nexport function decodeStxMint(event: StreamsEvent): DecodedStxMint {\n\tif (!isStxMint(event)) {\n\t\tthrow new Error(`Expected stx_mint event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_mint\", {\n\t\trecipient: requireString(payload, \"recipient\", \"stx_mint\"),\n\t\tamount: requireAmount(payload, \"stx_mint\"),\n\t});\n}\n\nexport function isStxBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_burn\" } {\n\treturn event.event_type === \"stx_burn\";\n}\n\nexport function decodeStxBurn(event: StreamsEvent): DecodedStxBurn {\n\tif (!isStxBurn(event)) {\n\t\tthrow new Error(`Expected stx_burn event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_burn\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_burn\"),\n\t\tamount: requireAmount(payload, \"stx_burn\"),\n\t});\n}\n\nexport type DecodedStxLockPayload = {\n\t// The locked principal maps to `sender` and the locked uSTX to `amount` so\n\t// stx_lock is filterable like the other STX types; the lock-specific\n\t// unlock_height rides in the jsonb `payload` overflow.\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\n\nexport type DecodedStxLock = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_lock\";\n\tdecoded_payload: DecodedStxLockPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxLock(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_lock\" } {\n\treturn event.event_type === \"stx_lock\";\n}\n\nexport function decodeStxLock(event: StreamsEvent): DecodedStxLock {\n\tif (!isStxLock(event)) {\n\t\tthrow new Error(`Expected stx_lock event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_lock\", {\n\t\tsender: requireString(payload, \"locked_address\", \"stx_lock\"),\n\t\tamount: requireAmountField(payload, \"locked_amount\", \"stx_lock\"),\n\t\tpayload: { unlock_height: optionalString(payload.unlock_height) },\n\t});\n}\n",
10
+ "import { clarityHexOf, decodedRow, optionalString } from \"./_payload.ts\";\nimport { decodeClarityValue, toJsonSafe } from \"./clarity.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\n/** Decoded form of a Clarity `print` event:\n * - `topic`: the print topic, when the contract emits a `{ topic, ... }` tuple\n * - `value`: the Clarity value decoded to JSON (uints as strings, buffers as\n * `0x…` hex, tuples as objects)\n * - `raw_value`: the canonical serialized hex, for byte-exact consumers */\nexport type DecodedPrintValue = {\n\ttopic: string | null;\n\tvalue: unknown;\n\traw_value: string | null;\n};\n\nexport type DecodedPrintPayload = {\n\tcontract_id: string | null;\n\tpayload: DecodedPrintValue;\n};\n\nexport type DecodedPrint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"print\";\n\tdecoded_payload: DecodedPrintPayload;\n\tsource_cursor: string;\n};\n\nexport function isPrint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"print\" } {\n\treturn event.event_type === \"print\";\n}\n\nexport function decodePrint(event: StreamsEvent): DecodedPrint {\n\tif (!isPrint(event)) {\n\t\tthrow new Error(`Expected print event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\tconst topic = optionalString(payload.topic);\n\tconst rawValue = clarityHexOf(payload);\n\n\tconst value = rawValue\n\t\t? decodeClarityValue(rawValue)\n\t\t: toJsonSafe(payload.value ?? null);\n\n\treturn decodedRow(event, \"print\", {\n\t\tcontract_id: event.contract_id ?? optionalString(payload.contract_id),\n\t\tpayload: { topic, value, raw_value: rawValue },\n\t});\n}\n",
11
+ "import {\n\tdecodedRow,\n\tnormalizeMemoHex,\n\toptionalString,\n\trequireAmount,\n\trequireAmountField,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedStxTransferPayload = {\n\tsender: string;\n\trecipient: string;\n\tamount: string;\n\tmemo: string | null;\n};\n\nexport type DecodedStxTransfer = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_transfer\";\n\tdecoded_payload: DecodedStxTransferPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxMintPayload = {\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedStxMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_mint\";\n\tdecoded_payload: DecodedStxMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedStxBurnPayload = {\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedStxBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_burn\";\n\tdecoded_payload: DecodedStxBurnPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxTransfer(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_transfer\" } {\n\treturn event.event_type === \"stx_transfer\";\n}\n\nexport function decodeStxTransfer(event: StreamsEvent): DecodedStxTransfer {\n\tif (!isStxTransfer(event)) {\n\t\tthrow new Error(`Expected stx_transfer event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_transfer\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_transfer\"),\n\t\trecipient: requireString(payload, \"recipient\", \"stx_transfer\"),\n\t\tamount: requireAmount(payload, \"stx_transfer\"),\n\t\tmemo: normalizeMemoHex(payload.memo),\n\t});\n}\n\nexport function isStxMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_mint\" } {\n\treturn event.event_type === \"stx_mint\";\n}\n\nexport function decodeStxMint(event: StreamsEvent): DecodedStxMint {\n\tif (!isStxMint(event)) {\n\t\tthrow new Error(`Expected stx_mint event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_mint\", {\n\t\trecipient: requireString(payload, \"recipient\", \"stx_mint\"),\n\t\tamount: requireAmount(payload, \"stx_mint\"),\n\t});\n}\n\nexport function isStxBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_burn\" } {\n\treturn event.event_type === \"stx_burn\";\n}\n\nexport function decodeStxBurn(event: StreamsEvent): DecodedStxBurn {\n\tif (!isStxBurn(event)) {\n\t\tthrow new Error(`Expected stx_burn event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_burn\", {\n\t\tsender: requireString(payload, \"sender\", \"stx_burn\"),\n\t\tamount: requireAmount(payload, \"stx_burn\"),\n\t});\n}\n\nexport type DecodedStxLockPayload = {\n\t// The locked principal maps to `sender` and the locked uSTX to `amount` so\n\t// stx_lock is filterable like the other STX types; the lock-specific\n\t// unlock_height rides in the jsonb `payload` overflow.\n\tsender: string;\n\tamount: string;\n\tpayload: { unlock_height: string | null };\n};\n\nexport type DecodedStxLock = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"stx_lock\";\n\tdecoded_payload: DecodedStxLockPayload;\n\tsource_cursor: string;\n};\n\nexport function isStxLock(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"stx_lock\" } {\n\treturn event.event_type === \"stx_lock\";\n}\n\nexport function decodeStxLock(event: StreamsEvent): DecodedStxLock {\n\tif (!isStxLock(event)) {\n\t\tthrow new Error(`Expected stx_lock event, got ${event.event_type}`);\n\t}\n\tconst payload = event.payload;\n\treturn decodedRow(event, \"stx_lock\", {\n\t\tsender: requireString(payload, \"locked_address\", \"stx_lock\"),\n\t\tamount: requireAmountField(payload, \"locked_amount\", \"stx_lock\"),\n\t\tpayload: { unlock_height: optionalString(payload.unlock_height) },\n\t});\n}\n",
12
12
  "import {\n\tdecodedRow,\n\tparseAssetIdentifier,\n\trequireAmount,\n\trequireHexValue,\n\trequireString,\n} from \"./_payload.ts\";\nimport type { StreamsEvent } from \"./events.ts\";\n\nexport type DecodedFtMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tamount: string;\n};\n\nexport type DecodedFtMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_mint\";\n\tdecoded_payload: DecodedFtMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedFtBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tamount: string;\n};\n\nexport type DecodedFtBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"ft_burn\";\n\tdecoded_payload: DecodedFtBurnPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftMintPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\trecipient: string;\n\tvalue: string;\n};\n\nexport type DecodedNftMint = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_mint\";\n\tdecoded_payload: DecodedNftMintPayload;\n\tsource_cursor: string;\n};\n\nexport type DecodedNftBurnPayload = {\n\tasset_identifier: string;\n\tcontract_id: string;\n\ttoken_name: string | null;\n\tsender: string;\n\tvalue: string;\n};\n\nexport type DecodedNftBurn = {\n\tcursor: string;\n\tblock_height: number;\n\ttx_id: string;\n\ttx_index: number;\n\tevent_index: number;\n\tevent_type: \"nft_burn\";\n\tdecoded_payload: DecodedNftBurnPayload;\n\tsource_cursor: string;\n};\n\nfunction assetFields(event: StreamsEvent, eventType: string) {\n\tconst assetIdentifier = requireString(\n\t\tevent.payload,\n\t\t\"asset_identifier\",\n\t\teventType,\n\t);\n\tconst { contract_id, token_name } = parseAssetIdentifier(\n\t\tassetIdentifier,\n\t\teventType,\n\t);\n\treturn {\n\t\tasset_identifier: assetIdentifier,\n\t\tcontract_id: event.contract_id ?? contract_id,\n\t\ttoken_name,\n\t};\n}\n\nexport function isFtMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_mint\" } {\n\treturn event.event_type === \"ft_mint\";\n}\n\nexport function decodeFtMint(event: StreamsEvent): DecodedFtMint {\n\tif (!isFtMint(event)) {\n\t\tthrow new Error(`Expected ft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_mint\", {\n\t\t...assetFields(event, \"ft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"ft_mint\"),\n\t\tamount: requireAmount(event.payload, \"ft_mint\"),\n\t});\n}\n\nexport function isFtBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"ft_burn\" } {\n\treturn event.event_type === \"ft_burn\";\n}\n\nexport function decodeFtBurn(event: StreamsEvent): DecodedFtBurn {\n\tif (!isFtBurn(event)) {\n\t\tthrow new Error(`Expected ft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"ft_burn\", {\n\t\t...assetFields(event, \"ft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"ft_burn\"),\n\t\tamount: requireAmount(event.payload, \"ft_burn\"),\n\t});\n}\n\nexport function isNftMint(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_mint\" } {\n\treturn event.event_type === \"nft_mint\";\n}\n\nexport function decodeNftMint(event: StreamsEvent): DecodedNftMint {\n\tif (!isNftMint(event)) {\n\t\tthrow new Error(`Expected nft_mint event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_mint\", {\n\t\t...assetFields(event, \"nft_mint\"),\n\t\trecipient: requireString(event.payload, \"recipient\", \"nft_mint\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_mint\"),\n\t});\n}\n\nexport function isNftBurn(\n\tevent: StreamsEvent,\n): event is StreamsEvent & { event_type: \"nft_burn\" } {\n\treturn event.event_type === \"nft_burn\";\n}\n\nexport function decodeNftBurn(event: StreamsEvent): DecodedNftBurn {\n\tif (!isNftBurn(event)) {\n\t\tthrow new Error(`Expected nft_burn event, got ${event.event_type}`);\n\t}\n\treturn decodedRow(event, \"nft_burn\", {\n\t\t...assetFields(event, \"nft_burn\"),\n\t\tsender: requireString(event.payload, \"sender\", \"nft_burn\"),\n\t\tvalue: requireHexValue(event.payload, \"nft_burn\"),\n\t});\n}\n"
13
13
  ],
14
- "mappings": ";AAAA;AAIO,SAAS,UAAU,CAAC,OAAyB;AAAA,EACnD,IAAI,OAAO,UAAU;AAAA,IAAU,OAAO,MAAM,SAAS;AAAA,EACrD,IAAI,MAAM,QAAQ,KAAK;AAAA,IAAG,OAAO,MAAM,IAAI,UAAU;AAAA,EACrD,IAAI,SAAS,OAAO,UAAU,UAAU;AAAA,IACvC,MAAM,MAA+B,CAAC;AAAA,IACtC,YAAY,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAAG;AAAA,MAC/C,IAAI,OAAO,WAAW,GAAG;AAAA,IAC1B;AAAA,IACA,OAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA;AAKD,SAAS,kBAAkB,CAAC,KAAsB;AAAA,EACxD,IAAI;AAAA,IACH,MAAM,QAAQ,IAAI,WAAW,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI;AAAA,IACpD,OAAO,WAAW,UAAU,cAAc,KAAK,CAAC,CAAC;AAAA,IAChD,MAAM;AAAA,IACP,OAAO;AAAA;AAAA;;ACnBT;AAAA;AAAA;AAMA;AAAA,yBACC;AAAA;AAAA;AAAA;AAcM,IAAM,yBAAyC;AAAA,EACrD,sBAAsB;AAAA,EACtB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,YAAY;AACb;AAKO,IAAM,sBACZ;AAWM,IAAM,mBAAmB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;;ACrCO,SAAS,aAAa,CAC5B,SACA,OACA,WACS;AAAA,EACT,MAAM,QAAQ,QAAQ;AAAA,EACtB,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAA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SAAS,CACxB,OACqD;AAAA,EACrD,OAAO,MAAM,eAAe;AAAA;AAGtB,SAAS,aAAa,CAAC,OAAqC;AAAA,EAClE,IAAI,CAAC,UAAU,KAAK,GAAG;AAAA,IACtB,MAAM,IAAI,MAAM,gCAAgC,MAAM,YAAY;AAAA,EACnE;AAAA,EACA,OAAO,WAAW,OAAO,YAAY;AAAA,OACjC,YAAY,OAAO,UAAU;AAAA,IAChC,WAAW,cAAc,MAAM,SAAS,aAAa,UAAU;AAAA,IAC/D,OAAO,gBAAgB,MAAM,SAAS,UAAU;AAAA,EACjD,CAAC;AAAA;AAGK,SAAS,SAAS,CACxB,OACqD;AAAA,EACrD,OAAO,MAAM,eAAe;AAAA;AAGtB,SAAS,aAAa,CAAC,OAAqC;AAAA,EAClE,IAAI,CAAC,UAAU,KAAK,GAAG;AAAA,IACtB,MAAM,IAAI,MAAM,gCAAgC,MAAM,YAAY;AAAA,EACnE;AAAA,EACA,OAAO,WAAW,OAAO,YAAY;AAAA,OACjC,YAAY,OAAO,UAAU;AAAA,IAChC,QAAQ,cAAc,MAAM,SAAS,UAAU,UAAU;AAAA,IACzD,OAAO,gBAAgB,MAAM,SAAS,UAAU;AAAA,EACjD,CAAC;AAAA;",
15
+ "debugId": "7D4E3A3C6B9DB6E864756E2164756E21",
16
16
  "names": []
17
17
  }
@@ -0,0 +1,39 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onChainPlane } from "../src/db/migration-role.ts";
3
+
4
+ // BNS-V2 `buy-in-ustx` prints only `{a, id}`, so buys had no price. A buy needs
5
+ // a `market` entry, which only `list-in-ustx` sets, so the price and commission
6
+ // are on the latest listing for that id before the buy; the decoder now copies
7
+ // them on write. Fill stored buys the same way (133 rows at writing; buys whose
8
+ // listing predates the table stay null). Skipped when the table is absent.
9
+ async function tableExists(db: Kysely<unknown>, table: string) {
10
+ const { rows } = await sql<{ exists: boolean }>`
11
+ SELECT to_regclass(${`public.${table}`}) IS NOT NULL AS exists
12
+ `.execute(db);
13
+ return rows[0]?.exists === true;
14
+ }
15
+
16
+ export async function up(db: Kysely<unknown>): Promise<void> {
17
+ await sql`SET lock_timeout = '30s'`.execute(db);
18
+ await onChainPlane(async () => {
19
+ if (!(await tableExists(db, "bns_marketplace_events"))) return;
20
+ await sql`
21
+ UPDATE bns_marketplace_events b
22
+ SET (price_ustx, commission) = (
23
+ SELECT l.price_ustx, l.commission
24
+ FROM bns_marketplace_events l
25
+ WHERE l.bns_id = b.bns_id
26
+ AND l.action = 'list-in-ustx'
27
+ AND l.canonical
28
+ AND (l.block_height, l.event_index) < (b.block_height, b.event_index)
29
+ ORDER BY l.block_height DESC, l.event_index DESC
30
+ LIMIT 1
31
+ )
32
+ WHERE b.action = 'buy-in-ustx'
33
+ AND b.price_ustx IS NULL
34
+ `.execute(db);
35
+ });
36
+ }
37
+
38
+ // Data fill only: the decoder writes the same values, nothing to undo.
39
+ export async function down(): Promise<void> {}