feat(escrow): add arbiter_address support for 2-of-3 multisig escrow#256
feat(escrow): add arbiter_address support for 2-of-3 multisig escrow#256Aiden181 wants to merge 1 commit into
Conversation
Greptile SummaryThis PR adds optional
Confidence Score: 2/5Not safe to merge — the unconditional DB insert of arbiter_address breaks all escrow creation until a migration is added. The arbiter_address field is written into every gig_escrows INSERT regardless of whether the caller supplies it, but the column has never been added to the table. This regresses the existing custodial escrow flow, not just the new multisig path. src/app/api/gigs/[id]/escrow/route.ts needs a companion migration file before the insert will succeed. Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Route as POST /api/gigs/[id]/escrow
participant CPP as CoinPayPortal API
participant DB as gig_escrows
Client->>Route: depositor_address, beneficiary_address, arbiter_address optional
Route->>Route: Zod validate arbiter_address optional min 10
Route->>CPP: createEscrow with arbiter_address optional
Note over CPP: Key omitted from JSON when undefined for custodial mode
CPP-->>Route: escrowResult with escrow_id and payment_address
Route->>DB: INSERT gig_escrows with arbiter_address value or null
Note over DB: Column does not exist - no migration in this PR
DB-->>Route: error column arbiter_address does not exist
Route-->>Client: 500 Failed to create escrow
Reviews (1): Last reviewed commit: "feat(escrow): add arbiter_address suppor..." | Re-trigger Greptile |
| currency, | ||
| platform_fee_usd: platformFee, | ||
| platform_fee_rate: platformFeeRate, | ||
| arbiter_address: arbiter_address || null, | ||
| status: "pending_payment", |
There was a problem hiding this comment.
Missing database migration for
arbiter_address column
The gig_escrows table (created in 20260321080000_add_gig_escrows.sql) has no arbiter_address column, and no migration in the repository adds one. Because arbiter_address: arbiter_address || null is unconditionally included in every insert payload (not gated on a defined value), every call to POST /api/gigs/[id]/escrow will hit a PostgreSQL error like column "arbiter_address" of relation "gig_escrows" does not exist, completely breaking escrow creation even when no arbiter is supplied.
A new migration — e.g. ALTER TABLE gig_escrows ADD COLUMN arbiter_address text; — must be included in this PR.
| currency: z.enum(["usdc_pol", "usdc_sol", "pol", "sol", "btc", "eth", "usdc_eth", "usdt"]), | ||
| depositor_address: z.string().min(10, "Depositor wallet address is required"), | ||
| beneficiary_address: z.string().min(10, "Beneficiary wallet address is required"), | ||
| arbiter_address: z.string().min(10).optional(), |
There was a problem hiding this comment.
The
arbiter_address min-length validation is missing a user-facing error message, unlike the required depositor_address and beneficiary_address fields which both have descriptive messages.
| arbiter_address: z.string().min(10).optional(), | |
| arbiter_address: z.string().min(10, "Arbiter wallet address must be at least 10 characters").optional(), |
Summary
Adds
arbiter_addresssupport to enable 2-of-3 Multisig escrow via CoinPayPortal. Previously, only the Custodial escrow model was supported.Changes
src/lib/coinpayportal.tsarbiter_address?: stringto theCreateEscrowOptionsinterfacearbiter_address: options.arbiter_addressto the API request body sent to CoinPayPortalsrc/app/api/gigs/[id]/escrow/route.tsarbiter_address: z.string().min(10).optional()to the Zod validation schemaarbiter_addressto the destructured params from the validated request bodyarbiter_addressto thecreateEscrow()callarbiter_address: arbiter_address || nullto thegig_escrowsdatabase insertRelated
skill.md(lines 144, 175) — PR fix(skill.md): change PATCH to PUT for gigs and posts update routes #254 by forgou37 addresses that