Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/app/api/gigs/[id]/escrow/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const createEscrowSchema = z.object({
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(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
arbiter_address: z.string().min(10).optional(),
arbiter_address: z.string().min(10, "Arbiter wallet address must be at least 10 characters").optional(),

});

// GET /api/gigs/[id]/escrow - Get escrow status for a gig
Expand Down Expand Up @@ -70,7 +71,7 @@ export async function POST(
);
}

const { application_id, currency, depositor_address, beneficiary_address } = validationResult.data;
const { application_id, currency, depositor_address, beneficiary_address, arbiter_address } = validationResult.data;

// Get gig — must be poster
const { data: gig } = await supabase
Expand Down Expand Up @@ -161,6 +162,7 @@ export async function POST(
beneficiary_email: `${workerProfile?.username || application.applicant_id}@ugig.net`,
depositor_address,
beneficiary_address,
arbiter_address,
description: `Gig escrow: ${gig.title}`,
metadata: {
gig_id: gigId,
Expand Down Expand Up @@ -190,6 +192,7 @@ export async function POST(
currency,
platform_fee_usd: platformFee,
platform_fee_rate: platformFeeRate,
arbiter_address: arbiter_address || null,
status: "pending_payment",
Comment on lines 192 to 196
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 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.

metadata: {
payment_address: paymentAddress,
Expand Down
2 changes: 2 additions & 0 deletions src/lib/coinpayportal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ export interface CreateEscrowOptions {
beneficiary_email: string;
depositor_address: string;
beneficiary_address: string;
arbiter_address?: string;
description?: string;
auto_release_hours?: number;
webhook_url?: string;
Expand Down Expand Up @@ -801,6 +802,7 @@ export async function createEscrow(options: CreateEscrowOptions): Promise<Escrow
beneficiary_address: options.beneficiary_address,
depositor_email: options.depositor_email,
beneficiary_email: options.beneficiary_email,
arbiter_address: options.arbiter_address,
description: options.description,
auto_release_hours: options.auto_release_hours,
webhook_url: options.webhook_url || `${appUrl}/api/webhooks/coinpay`,
Expand Down
Loading