@secondlayer/shared 6.35.0 → 6.35.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.
@@ -725,6 +725,9 @@ interface X402PaymentsTable {
725
725
  kind: Generated<string>;
726
726
  /** Linked claimed account once the paying wallet is attached (continuity). */
727
727
  account_id: string | null;
728
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
729
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
730
+ credit_usd_micros: string | null;
728
731
  }
729
732
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
730
733
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -708,6 +708,9 @@ interface X402PaymentsTable {
708
708
  kind: Generated<string>;
709
709
  /** Linked claimed account once the paying wallet is attached (continuity). */
710
710
  account_id: string | null;
711
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
712
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
713
+ credit_usd_micros: string | null;
711
714
  }
712
715
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
713
716
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -706,6 +706,9 @@ interface X402PaymentsTable {
706
706
  kind: Generated<string>;
707
707
  /** Linked claimed account once the paying wallet is attached (continuity). */
708
708
  account_id: string | null;
709
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
710
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
711
+ credit_usd_micros: string | null;
709
712
  }
710
713
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
711
714
  interface TenantsTable {
@@ -706,6 +706,9 @@ interface X402PaymentsTable {
706
706
  kind: Generated<string>;
707
707
  /** Linked claimed account once the paying wallet is attached (continuity). */
708
708
  account_id: string | null;
709
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
710
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
711
+ credit_usd_micros: string | null;
709
712
  }
710
713
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
711
714
  interface TenantsTable {
@@ -707,6 +707,9 @@ interface X402PaymentsTable {
707
707
  kind: Generated<string>;
708
708
  /** Linked claimed account once the paying wallet is attached (continuity). */
709
709
  account_id: string | null;
710
+ /** USD-micros to credit on confirmation, for deposit rows the reconciler
711
+ * settles asynchronously. NULL for per-call settles (credit nothing). */
712
+ credit_usd_micros: string | null;
710
713
  }
711
714
  type TenantStatus = "provisioning" | "active" | "limit_warning" | "paused_limit" | "suspended" | "error" | "deleted";
712
715
  interface TenantsTable {
@@ -0,0 +1,28 @@
1
+ import { type Kysely, sql } from "kysely";
2
+ import { onControlPlane } from "../src/db/migration-role.ts";
3
+
4
+ // R7 fix: a confirmed-tier deposit that broadcasts on-chain but does not turn
5
+ // canonical within the settle deadline used to throw `awaiting_confirmation`
6
+ // with NO ledger row — the payer was charged but never credited, unrecoverable.
7
+ // We now insert a `pending` deposit row up front and let the reconciler credit
8
+ // it on confirmation. The reconciler runs in the worker (no access to the API's
9
+ // USD↔token spot conversion), so the USD-micros to credit is persisted on the
10
+ // row here. NULL for non-deposit rows (per-call settles credit nothing).
11
+ export async function up(db: Kysely<unknown>): Promise<void> {
12
+ await sql`SET lock_timeout = '30s'`.execute(db);
13
+ await onControlPlane(async () => {
14
+ await sql`
15
+ ALTER TABLE x402_payments
16
+ ADD COLUMN IF NOT EXISTS credit_usd_micros TEXT
17
+ `.execute(db);
18
+ });
19
+ }
20
+
21
+ export async function down(db: Kysely<unknown>): Promise<void> {
22
+ await onControlPlane(async () => {
23
+ await sql`
24
+ ALTER TABLE x402_payments
25
+ DROP COLUMN IF EXISTS credit_usd_micros
26
+ `.execute(db);
27
+ });
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@secondlayer/shared",
3
- "version": "6.35.0",
3
+ "version": "6.35.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",