@secondlayer/shared 11.5.1 → 11.6.1

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.
@@ -137,7 +137,6 @@ interface SubgraphsTable {
137
137
  expires_at: Date | null;
138
138
  /** (event type, contract) probe pairs persisted at deploy for weight classification. */
139
139
  sparse_probe_targets: unknown | null;
140
- database_url_enc: ColumnType<Buffer | null, Buffer | null | undefined, Buffer | null>;
141
140
  sandbox_workers: Generated<boolean>;
142
141
  created_at: Generated<Date>;
143
142
  updated_at: Generated<Date>;
@@ -233,7 +232,7 @@ interface AccountsTable {
233
232
  email: string | null;
234
233
  /** True for anonymous self-serve accounts until claimed via magic link. */
235
234
  ghost: Generated<boolean>;
236
- /** Stacks principal owning a wallet-ghost account (x402-paid deploys). */
235
+ /** Stacks principal owning a wallet-ghost account. */
237
236
  wallet_principal: string | null;
238
237
  display_name: string | null;
239
238
  bio: string | null;
@@ -295,14 +294,6 @@ interface SubgraphProcessingStatsTable {
295
294
  is_catchup: Generated<boolean>;
296
295
  created_at: Generated<Date>;
297
296
  }
298
- interface SubgraphTableSnapshotsTable {
299
- id: Generated<string>;
300
- subgraph_name: string;
301
- api_key_id: string | null;
302
- table_name: string;
303
- row_count: number | null;
304
- created_at: Generated<Date>;
305
- }
306
297
  interface SubgraphHealthSnapshotsTable {
307
298
  id: Generated<string>;
308
299
  subgraph_id: string;
@@ -392,26 +383,6 @@ interface Pox4CallsTable {
392
383
  source_cursor: string;
393
384
  created_at: Generated<Date>;
394
385
  }
395
- interface Pox4CyclesDailyTable {
396
- date: string;
397
- reward_cycle: number;
398
- total_stacked_ustx: Generated<string>;
399
- solo_stackers: Generated<number>;
400
- delegated_principals: Generated<number>;
401
- unique_pools: Generated<number>;
402
- unique_signers: Generated<number>;
403
- calls_today: Generated<number>;
404
- updated_at: Generated<Date>;
405
- }
406
- interface Pox4SignersDailyTable {
407
- date: string;
408
- reward_cycle: number;
409
- signer_key: string;
410
- weight_ustx: Generated<string>;
411
- stacker_count: Generated<number>;
412
- aggregation_calls: Generated<number>;
413
- updated_at: Generated<Date>;
414
- }
415
386
  type Pox5EventTopic = "set-bond-admin" | "set-pause-admin" | "pause-rewards" | "setup-bond" | "add-to-allowlist" | "register-for-bond" | "update-bond-registration" | "register-signer" | "stake" | "stake-update" | "announce-l1-early-exit" | "unstake-sbtc" | "unstake" | "calculate-rewards" | "bond-distribution" | "claim-rewards" | "claim-staker-rewards-for-signer" | "grant-signer-key" | "revoke-signer-grant";
416
387
  interface Pox5EventsTable {
417
388
  cursor: string;
@@ -529,17 +500,6 @@ interface SbtcSettlementsTable {
529
500
  confirmed_at: Date | null;
530
501
  updated_at: Generated<Date>;
531
502
  }
532
- interface SbtcSupplySnapshotsTable {
533
- date: string;
534
- total_supply: Generated<string>;
535
- mints_today: Generated<string>;
536
- burns_today: Generated<string>;
537
- deposit_count: Generated<number>;
538
- withdrawal_create_count: Generated<number>;
539
- withdrawal_accept_count: Generated<number>;
540
- withdrawal_reject_count: Generated<number>;
541
- updated_at: Generated<Date>;
542
- }
543
503
  type BnsNameEventTopic = "new-name" | "transfer-name" | "renew-name" | "burn-name" | "new-airdrop";
544
504
  interface BnsNameEventsTable {
545
505
  cursor: string;
@@ -781,7 +741,6 @@ interface Database {
781
741
  play_provisions: PlayProvisionsTable;
782
742
  subgraph_health_snapshots: SubgraphHealthSnapshotsTable;
783
743
  subgraph_processing_stats: SubgraphProcessingStatsTable;
784
- subgraph_table_snapshots: SubgraphTableSnapshotsTable;
785
744
  subgraph_gaps: SubgraphGapsTable;
786
745
  subgraph_violations: SubgraphViolationsTable;
787
746
  subgraph_operations: SubgraphOperationsTable;
@@ -797,23 +756,18 @@ interface Database {
797
756
  decoder_checkpoints: DecoderCheckpointsTable;
798
757
  chain_reorgs: ChainReorgsTable;
799
758
  pox4_calls: Pox4CallsTable;
800
- pox4_cycles_daily: Pox4CyclesDailyTable;
801
- pox4_signers_daily: Pox4SignersDailyTable;
802
759
  pox5_events: Pox5EventsTable;
803
760
  burn_block_rewards: BurnBlockRewardsTable;
804
761
  burn_block_reward_slots: BurnBlockRewardSlotsTable;
805
762
  sbtc_events: SbtcEventsTable;
806
763
  sbtc_token_events: SbtcTokenEventsTable;
807
764
  sbtc_settlements: SbtcSettlementsTable;
808
- sbtc_supply_snapshots: SbtcSupplySnapshotsTable;
809
765
  bns_name_events: BnsNameEventsTable;
810
766
  bns_namespace_events: BnsNamespaceEventsTable;
811
767
  bns_marketplace_events: BnsMarketplaceEventsTable;
812
768
  bns_names: BnsNamesTable;
813
769
  bns_namespaces: BnsNamespacesTable;
814
770
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
771
  chain_read_cache: ChainReadCacheTable;
818
772
  pending_fork_blocks: PendingForkBlocksTable;
819
773
  observer_journal: ObserverJournalTable;
@@ -825,46 +779,10 @@ interface Database {
825
779
  stage_failures: StageFailuresTable;
826
780
  archive_fetches: ArchiveFetchesTable;
827
781
  }
828
- /** Prepaid x402 credit — one running USD-micros balance per payer principal. */
829
- interface X402BalancesTable {
830
- principal: string;
831
- balance_usd_micros: Generated<string | number | bigint>;
832
- /** Month bucket ("YYYY-MM") the spend counter applies to. */
833
- spent_month: string | null;
834
- spent_month_usd_micros: Generated<string | number | bigint>;
835
- updated_at: Generated<Date>;
836
- }
837
782
  interface ServiceHeartbeatsTable {
838
783
  name: string;
839
784
  updated_at: Generated<Date>;
840
785
  }
841
- /** x402 pay-per-request ledger (control plane). One row per settled payment,
842
- * keyed by challenge nonce + settled txid. `state` tracks confirmed-tier
843
- * settlement and post-serve reorg reversal. */
844
- interface X402PaymentsTable {
845
- id: Generated<string>;
846
- nonce: string;
847
- txid: string;
848
- asset: string;
849
- amount: string;
850
- payer: string;
851
- surface: string;
852
- state: Generated<"pending" | "confirmed" | "reverted">;
853
- created_at: Generated<Date>;
854
- updated_at: Generated<Date>;
855
- /** "payment" = per-call settle; "deposit" = prepaid balance top-up. */
856
- kind: Generated<string>;
857
- /** Linked claimed account once the paying wallet is attached (continuity). */
858
- account_id: string | null;
859
- /** USD-micros to credit on confirmation, for deposit rows the reconciler
860
- * settles asynchronously. NULL for per-call settles (credit nothing). */
861
- credit_usd_micros: string | null;
862
- /** Idempotency key: stamped exactly once when this row's credit is applied.
863
- * NULL means never credited (or not a credit-bearing row). Pre-migration
864
- * non-pending deposit rows are backfilled to a non-null sentinel so the
865
- * reconciler's heal path can never double-credit them. */
866
- credited_at: Generated<Date> | null;
867
- }
868
786
  interface AccountSpendCapsTable {
869
787
  account_id: string;
870
788
  monthly_cap_cents: number | null;
@@ -875,7 +793,7 @@ interface AccountSpendCapsTable {
875
793
  frozen_at: Date | null;
876
794
  updated_at: Generated<Date>;
877
795
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
796
+ /** Prepaid dev credits — card-funded balance per account. */
879
797
  interface AccountCreditsTable {
880
798
  account_id: string;
881
799
  balance_usd_micros: Generated<string | number | bigint>;
@@ -0,0 +1,21 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Drop the deleted x402 pay-per-call tables. The rail 404s; no live queries
6
+ * remain. Prod leftover rows (payments + balances) are intentionally dropped.
7
+ *
8
+ * `down` is a no-op — recreating empty tables cannot restore those rows, and
9
+ * the creating migrations (0091/0095/…) remain the historical schema record.
10
+ */
11
+ export async function up(db: Kysely<unknown>): Promise<void> {
12
+ await onControlPlane(async () => {
13
+ await sql`SET lock_timeout = '30s'`.execute(db);
14
+ await sql`DROP TABLE IF EXISTS x402_payments`.execute(db);
15
+ await sql`DROP TABLE IF EXISTS x402_balances`.execute(db);
16
+ });
17
+ }
18
+
19
+ export async function down(_db: Kysely<unknown>): Promise<void> {
20
+ // No-op: cannot restore dropped payment/balance rows.
21
+ }
@@ -0,0 +1,24 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Drop unused subgraphs.database_url_enc. BYO data plane was removed as a
6
+ * deploy path; the column was always written null. Prod had 0 non-null rows.
7
+ * Historical add remains in 0081.
8
+ */
9
+ export async function up(db: Kysely<unknown>): Promise<void> {
10
+ await sql`SET lock_timeout = '30s'`.execute(db);
11
+ await onControlPlane(async () => {
12
+ await sql`ALTER TABLE subgraphs DROP COLUMN IF EXISTS database_url_enc`.execute(
13
+ db,
14
+ );
15
+ });
16
+ }
17
+
18
+ export async function down(db: Kysely<unknown>): Promise<void> {
19
+ await onControlPlane(async () => {
20
+ await sql`ALTER TABLE subgraphs ADD COLUMN IF NOT EXISTS database_url_enc BYTEA`.execute(
21
+ db,
22
+ );
23
+ });
24
+ }
@@ -0,0 +1,26 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onChainPlane, onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ /**
5
+ * Drop four tables that were created, typed, and never written. Prod
6
+ * 2026-09-17: count(*) = 0 on all four (source: pox4_cycles_daily,
7
+ * pox4_signers_daily, sbtc_supply_snapshots; target: subgraph_table_snapshots).
8
+ * Historical CREATE stays in 0014/0015/0070/0071.
9
+ */
10
+ export async function up(db: Kysely<unknown>): Promise<void> {
11
+ await sql`SET lock_timeout = '30s'`.execute(db);
12
+ await onChainPlane(async () => {
13
+ await sql`DROP TABLE IF EXISTS pox4_signers_daily CASCADE`.execute(db);
14
+ await sql`DROP TABLE IF EXISTS pox4_cycles_daily CASCADE`.execute(db);
15
+ await sql`DROP TABLE IF EXISTS sbtc_supply_snapshots CASCADE`.execute(db);
16
+ });
17
+ await onControlPlane(async () => {
18
+ await sql`DROP TABLE IF EXISTS subgraph_table_snapshots CASCADE`.execute(
19
+ db,
20
+ );
21
+ });
22
+ }
23
+
24
+ export async function down(_db: Kysely<unknown>): Promise<void> {
25
+ // Irreversible: the dropped tables were empty. Recreate from 0070/0071/0014.
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "11.5.1",
3
+ "version": "11.6.1",
4
4
  "description": "Internal building blocks shared across Secondlayer packages.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -233,7 +233,7 @@
233
233
  "prepublishOnly": "bun run build"
234
234
  },
235
235
  "dependencies": {
236
- "@secondlayer/stacks": "^5.1.3",
236
+ "@secondlayer/stacks": "^6.0.0",
237
237
  "kysely": "0.28.17",
238
238
  "kysely-postgres-js": "3.0.0",
239
239
  "postgres": "^3.4.6",
@@ -1,2 +0,0 @@
1
- declare const ADMIN_EMAILS: string[];
2
- export { ADMIN_EMAILS };
@@ -1,24 +0,0 @@
1
- import { createRequire } from "node:module";
2
- var __defProp = Object.defineProperty;
3
- var __returnValue = (v) => v;
4
- function __exportSetter(name, newValue) {
5
- this[name] = __returnValue.bind(null, newValue);
6
- }
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, {
10
- get: all[name],
11
- enumerable: true,
12
- configurable: true,
13
- set: __exportSetter.bind(all, name)
14
- });
15
- };
16
-
17
- // src/constants.ts
18
- var ADMIN_EMAILS = ["ryan.waits@gmail.com"];
19
- export {
20
- ADMIN_EMAILS
21
- };
22
-
23
- //# debugId=171573A31D5D2E7964756E2164756E21
24
- //# sourceMappingURL=constants.js.map
@@ -1,10 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/constants.ts"],
4
- "sourcesContent": [
5
- "export const ADMIN_EMAILS: string[] = [\"ryan.waits@gmail.com\"];\n"
6
- ],
7
- "mappings": ";;;;;;;;;;;;;;;;;AAAO,IAAM,eAAyB,CAAC,sBAAsB;",
8
- "debugId": "171573A31D5D2E7964756E2164756E21",
9
- "names": []
10
- }