@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
package/dist/src/index.js CHANGED
@@ -431,20 +431,6 @@ var SOURCE_READ_COLUMNS = {
431
431
  "tx_id",
432
432
  "tx_index"
433
433
  ],
434
- sbtc_token_events: [
435
- "amount",
436
- "block_height",
437
- "block_time",
438
- "canonical",
439
- "cursor",
440
- "event_index",
441
- "event_type",
442
- "memo",
443
- "recipient",
444
- "sender",
445
- "tx_id",
446
- "tx_index"
447
- ],
448
434
  bns_name_events: [
449
435
  "block_height",
450
436
  "block_time",
@@ -643,20 +629,6 @@ var SOURCE_READ_TYPES = {
643
629
  tx_id: { type: "text" },
644
630
  tx_index: { type: "int" }
645
631
  },
646
- sbtc_token_events: {
647
- amount: { type: "text" },
648
- block_height: { type: "int" },
649
- block_time: { type: "timestamp" },
650
- canonical: { type: "boolean" },
651
- cursor: { type: "text" },
652
- event_index: { type: "int" },
653
- event_type: { type: "text" },
654
- memo: { type: "text", nullable: true },
655
- recipient: { type: "text", nullable: true },
656
- sender: { type: "text", nullable: true },
657
- tx_id: { type: "text" },
658
- tx_index: { type: "int" }
659
- },
660
632
  bns_name_events: {
661
633
  block_height: { type: "int" },
662
634
  block_time: { type: "timestamp" },
@@ -766,7 +738,6 @@ var SOURCE_READ_PKS = {
766
738
  mempool_transactions: ["seq"],
767
739
  pox5_events: ["cursor"],
768
740
  sbtc_events: ["cursor"],
769
- sbtc_token_events: ["cursor"],
770
741
  bns_name_events: ["cursor"],
771
742
  bns_namespace_events: ["cursor"],
772
743
  bns_marketplace_events: ["cursor"],
@@ -830,9 +801,6 @@ var TABLE_TO_DB = {
830
801
  observer_journal: "source",
831
802
  sync_scopes: "source",
832
803
  stage_registry: "source",
833
- stage_runs: "source",
834
- stage_block_receipts: "source",
835
- coverage_segments: "source",
836
804
  stage_failures: "source",
837
805
  decoded_events: "source",
838
806
  decoder_checkpoints: "source",
@@ -842,7 +810,6 @@ var TABLE_TO_DB = {
842
810
  burn_block_rewards: "source",
843
811
  burn_block_reward_slots: "source",
844
812
  sbtc_events: "source",
845
- sbtc_token_events: "source",
846
813
  sbtc_settlements: "source",
847
814
  bns_name_events: "source",
848
815
  bns_namespace_events: "source",
@@ -1320,6 +1287,34 @@ function blockEndCursor(height) {
1320
1287
  event_index: EMPTY_RANGE_EVENT_INDEX_SENTINEL
1321
1288
  };
1322
1289
  }
1290
+ // src/btc-txid.ts
1291
+ var BTC_TXID = /^(?:0x)?[0-9a-f]{64}$/;
1292
+ function normalizeBtcTxid(value) {
1293
+ const v = value.trim().toLowerCase();
1294
+ if (!BTC_TXID.test(v))
1295
+ return null;
1296
+ return v.startsWith("0x") ? v : `0x${v}`;
1297
+ }
1298
+ // src/pox-contracts.ts
1299
+ var BOOT = "SP000000000000000000002Q6VF78";
1300
+ var MAINNET_POX_CONTRACT_ERAS = [
1301
+ { fromBurnHeight: 0, contractId: `${BOOT}.pox` },
1302
+ { fromBurnHeight: 781551, contractId: `${BOOT}.pox-2` },
1303
+ { fromBurnHeight: 789250, contractId: `${BOOT}.pox-3` },
1304
+ { fromBurnHeight: 840360, contractId: `${BOOT}.pox-4` },
1305
+ { fromBurnHeight: 960230, contractId: `${BOOT}.pox-5` }
1306
+ ];
1307
+ function mainnetPoxContractAt(burnHeight) {
1308
+ let contractId = MAINNET_POX_CONTRACT_ERAS[0].contractId;
1309
+ for (const era of MAINNET_POX_CONTRACT_ERAS) {
1310
+ if (burnHeight >= era.fromBurnHeight)
1311
+ contractId = era.contractId;
1312
+ }
1313
+ return contractId;
1314
+ }
1315
+ function isPoxContractId(contractId) {
1316
+ return /\.pox(-\d+)?$/.test(contractId);
1317
+ }
1323
1318
  // src/schemas/subgraphs.ts
1324
1319
  import { z as z2 } from "zod";
1325
1320
  var DeploySubgraphRequestSchema = z2.object({
@@ -1585,6 +1580,18 @@ var triggerAmount = z4.union([
1585
1580
  z4.number().int().nonnegative()
1586
1581
  ]);
1587
1582
  var triggerPattern = z4.string().trim().min(1);
1583
+ var triggerExact = z4.string().trim().min(1);
1584
+ var btcTxid = z4.string().transform((value, ctx) => {
1585
+ const txid = normalizeBtcTxid(value);
1586
+ if (txid === null) {
1587
+ ctx.addIssue({
1588
+ code: "custom",
1589
+ message: "must be a 64-character hex Bitcoin txid (0x optional)"
1590
+ });
1591
+ return z4.NEVER;
1592
+ }
1593
+ return txid;
1594
+ });
1588
1595
  var trait = z4.string().trim().min(1);
1589
1596
  var printWhereValue = z4.string().min(1).max(256);
1590
1597
  var PrintWhereSchema = z4.record(z4.string().trim().min(1).max(64), z4.union([printWhereValue, z4.array(printWhereValue).min(1).max(20)])).refine((o) => {
@@ -1708,14 +1715,14 @@ var ChainTriggerSchema = z4.discriminatedUnion("type", [
1708
1715
  }).strict(),
1709
1716
  z4.object({
1710
1717
  type: z4.literal("sbtc_deposit"),
1711
- recipient: triggerPattern.optional(),
1718
+ recipient: triggerExact.optional(),
1712
1719
  minAmount: triggerAmount.optional(),
1713
1720
  maxAmount: triggerAmount.optional(),
1714
- bitcoinTxid: triggerPattern.optional()
1721
+ bitcoinTxid: btcTxid.optional()
1715
1722
  }).strict(),
1716
1723
  z4.object({
1717
1724
  type: z4.literal("sbtc_withdrawal_create"),
1718
- sender: triggerPattern.optional(),
1725
+ sender: triggerExact.optional(),
1719
1726
  minAmount: triggerAmount.optional(),
1720
1727
  maxAmount: triggerAmount.optional(),
1721
1728
  requestId: z4.number().int().nonnegative().optional()
@@ -1723,7 +1730,7 @@ var ChainTriggerSchema = z4.discriminatedUnion("type", [
1723
1730
  z4.object({
1724
1731
  type: z4.literal("sbtc_withdrawal_accept"),
1725
1732
  requestId: z4.number().int().nonnegative().optional(),
1726
- sweepTxid: triggerPattern.optional()
1733
+ sweepTxid: btcTxid.optional()
1727
1734
  }).strict(),
1728
1735
  z4.object({
1729
1736
  type: z4.literal("sbtc_withdrawal_reject"),
@@ -1732,7 +1739,7 @@ var ChainTriggerSchema = z4.discriminatedUnion("type", [
1732
1739
  z4.object({
1733
1740
  type: z4.literal("sbtc_withdrawal_swept_confirmed"),
1734
1741
  requestId: z4.number().int().nonnegative().optional(),
1735
- sweepTxid: triggerPattern.optional()
1742
+ sweepTxid: btcTxid.optional()
1736
1743
  }).strict(),
1737
1744
  z4.object({
1738
1745
  type: z4.literal("rune_etch"),
@@ -1745,7 +1752,7 @@ var ChainTriggerSchema = z4.discriminatedUnion("type", [
1745
1752
  z4.object({
1746
1753
  type: z4.literal("rune_transfer"),
1747
1754
  rune: runeRef.optional(),
1748
- address: triggerPattern.optional(),
1755
+ address: triggerExact.optional(),
1749
1756
  minAmount: triggerAmount.optional()
1750
1757
  }).strict(),
1751
1758
  z4.object({
@@ -2391,6 +2398,7 @@ export {
2391
2398
  InsightSchema,
2392
2399
  InsightSeveritySchema,
2393
2400
  KeyRotatedError,
2401
+ MAINNET_POX_CONTRACT_ERAS,
2394
2402
  NotFoundError,
2395
2403
  OBSERVER_JOURNAL_STATUSES,
2396
2404
  PaymentRequiredError,
@@ -2455,9 +2463,12 @@ export {
2455
2463
  isBnsDecoderEnabled,
2456
2464
  isEmptyRangeCursor,
2457
2465
  isPox5DecoderEnabled,
2466
+ isPoxContractId,
2458
2467
  isSbtcDecoderEnabled,
2459
2468
  jsonb,
2460
2469
  logger,
2470
+ mainnetPoxContractAt,
2471
+ normalizeBtcTxid,
2461
2472
  onChainPlane,
2462
2473
  onControlPlane,
2463
2474
  parseJsonb,
@@ -2469,5 +2480,5 @@ export {
2469
2480
  syncState
2470
2481
  };
2471
2482
 
2472
- //# debugId=1C7D1E7027A70E3164756E2164756E21
2483
+ //# debugId=778D07D2CAA9BD8A64756E2164756E21
2473
2484
  //# sourceMappingURL=index.js.map