From 7333695fd4549506985b943b862d96fe71014066 Mon Sep 17 00:00:00 2001 From: "craigbidenbot[bot]" <260814249+craigbidenbot[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 10:14:43 +0000 Subject: [PATCH] feat: add escrow to AcceptsScheme enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Look, here's the deal — the x402r escrow scheme has been out there in the wild, 36 endpoints running on it, and we can't even index them. That's not hyperbole, folks. Changes: - Add 'escrow' to Prisma AcceptsScheme enum - Update Zod validation to accept 'escrow' - Update normalization schema (z3.literal → z3.enum) - Fix type cast in resources.ts - Add database migration Closes #663 --- apps/scan/src/lib/resources.ts | 2 +- apps/scan/src/lib/x402/index.ts | 2 +- apps/scan/src/services/db/resources/resource.ts | 2 +- .../migrations/20260408000000_add_escrow_scheme/migration.sql | 2 ++ packages/internal/databases/scan/prisma/schema.prisma | 1 + 5 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 packages/internal/databases/scan/prisma/migrations/20260408000000_add_escrow_scheme/migration.sql diff --git a/apps/scan/src/lib/resources.ts b/apps/scan/src/lib/resources.ts index e66a743d0..a4595b822 100644 --- a/apps/scan/src/lib/resources.ts +++ b/apps/scan/src/lib/resources.ts @@ -78,7 +78,7 @@ export const registerResource = async ( const mappedAccepts = x402Options .map(opt => ({ - scheme: (opt.scheme ?? 'exact') as 'exact', + scheme: (opt.scheme ?? 'exact') as 'exact' | 'escrow', network: normalizeChainId(opt.network).replace( '-', '_' diff --git a/apps/scan/src/lib/x402/index.ts b/apps/scan/src/lib/x402/index.ts index ceb9c4631..ee9d40d33 100644 --- a/apps/scan/src/lib/x402/index.ts +++ b/apps/scan/src/lib/x402/index.ts @@ -25,7 +25,7 @@ export type InputSchema = OutputSchema['input']; * the database in a common format for v1 and v2. */ export const normalizedAcceptSchema = z3.object({ - scheme: z3.literal('exact'), + scheme: z3.enum(['exact', 'escrow']), network: z3.string(), maxAmountRequired: z3.string(), payTo: z3.string(), diff --git a/apps/scan/src/services/db/resources/resource.ts b/apps/scan/src/services/db/resources/resource.ts index f8a24a110..b7ccb0cfa 100644 --- a/apps/scan/src/services/db/resources/resource.ts +++ b/apps/scan/src/services/db/resources/resource.ts @@ -28,7 +28,7 @@ export const upsertResourceSchema = z.object({ metadata: z.record(z.string(), z.any()).optional(), accepts: z.array( z.object({ - scheme: z.enum(['exact']), + scheme: z.enum(['exact', 'escrow']), network: z.union([ z.enum([ 'base_sepolia', diff --git a/packages/internal/databases/scan/prisma/migrations/20260408000000_add_escrow_scheme/migration.sql b/packages/internal/databases/scan/prisma/migrations/20260408000000_add_escrow_scheme/migration.sql new file mode 100644 index 000000000..d2ec1a431 --- /dev/null +++ b/packages/internal/databases/scan/prisma/migrations/20260408000000_add_escrow_scheme/migration.sql @@ -0,0 +1,2 @@ +-- AlterEnum +ALTER TYPE "AcceptsScheme" ADD VALUE 'escrow'; diff --git a/packages/internal/databases/scan/prisma/schema.prisma b/packages/internal/databases/scan/prisma/schema.prisma index ac567b777..52d78e12b 100644 --- a/packages/internal/databases/scan/prisma/schema.prisma +++ b/packages/internal/databases/scan/prisma/schema.prisma @@ -106,6 +106,7 @@ model Resources { enum AcceptsScheme { exact + escrow } enum AcceptsNetwork {