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
7 changes: 3 additions & 4 deletions app/api/compliance/screen/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,14 @@ export async function POST(req: NextRequest) {
} catch (error) {
console.error('Compliance screening error:', error);

// Return a graceful error response
return NextResponse.json(
{
success: false,
result: 'PASS',
message: 'Compliance screening temporarily unavailable. Proceeding with caution.',
result: 'FAIL',
message: 'Compliance screening unavailable. Transaction blocked.',
error: error instanceof Error ? error.message : 'Unknown error',
},
{ status: 500 }
{ status: 503 }
);
}
}
12 changes: 12 additions & 0 deletions app/api/payout/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import { NextRequest, NextResponse } from "next/server";
import { createClient } from "@/lib/supabase/server";
import { circleDeveloperSdk } from "@/lib/circle/developer-controlled-wallets-client";
import { screenAddress, mapComplianceResult } from "@/lib/compliance/utils";
import {
signAndSubmitGatewayBurnIntent,
executeGatewayMint,
Expand Down Expand Up @@ -271,6 +272,17 @@ export async function POST(req: NextRequest) {
const amountInAtomicUnits = BigInt(convertToSmallestUnit(amount));
const destinationChain: SupportedChain = requestedChain || "arcTestnet";

// Server-side compliance enforcement — must pass before any funds move
const complianceChain = CHAIN_TO_BLOCKCHAIN[destinationChain];
const circleComplianceResponse = await screenAddress(recipientAddress, complianceChain);
const complianceResult = mapComplianceResult(circleComplianceResponse);
if (complianceResult !== "PASS") {
return NextResponse.json(
{ error: "Transaction blocked by compliance screening", result: complianceResult },
{ status: 403 }
);
}

// Fetch user's wallets
const { data: wallets, error: walletsError } = await supabase
.from("wallets")
Expand Down