@secondlayer/shared 11.5.1 → 11.6.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.
@@ -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;
@@ -812,8 +811,6 @@ interface Database {
812
811
  bns_names: BnsNamesTable;
813
812
  bns_namespaces: BnsNamespacesTable;
814
813
  service_heartbeats: ServiceHeartbeatsTable;
815
- x402_payments: X402PaymentsTable;
816
- x402_balances: X402BalancesTable;
817
814
  chain_read_cache: ChainReadCacheTable;
818
815
  pending_fork_blocks: PendingForkBlocksTable;
819
816
  observer_journal: ObserverJournalTable;
@@ -825,46 +822,10 @@ interface Database {
825
822
  stage_failures: StageFailuresTable;
826
823
  archive_fetches: ArchiveFetchesTable;
827
824
  }
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
825
  interface ServiceHeartbeatsTable {
838
826
  name: string;
839
827
  updated_at: Generated<Date>;
840
828
  }
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
829
  interface AccountSpendCapsTable {
869
830
  account_id: string;
870
831
  monthly_cap_cents: number | null;
@@ -875,7 +836,7 @@ interface AccountSpendCapsTable {
875
836
  frozen_at: Date | null;
876
837
  updated_at: Generated<Date>;
877
838
  }
878
- /** Prepaid dev credits — card-funded balance per account (peer to x402_balances). */
839
+ /** Prepaid dev credits — card-funded balance per account. */
879
840
  interface AccountCreditsTable {
880
841
  account_id: string;
881
842
  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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "11.5.1",
3
+ "version": "11.6.0",
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",