Skip to content
Open
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
12 changes: 10 additions & 2 deletions app/api/gateway/transfer/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ export async function POST(req: NextRequest) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}

const { sourceChain, destinationChain, amount, recipientAddress } =
await req.json();
let sourceChain: string | undefined;
let destinationChain: string | undefined;
let amount: string | undefined;
let recipientAddress: string | undefined;

try {
({ sourceChain, destinationChain, amount, recipientAddress } =
await req.json());
if (!sourceChain || !destinationChain || !amount) {
return NextResponse.json(
{
Expand Down Expand Up @@ -200,6 +204,10 @@ export async function POST(req: NextRequest) {
recipient,
});
} catch (error: any) {
if (error instanceof SyntaxError) {
return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 });
}

console.error("Error in transfer:", error);

// Check if this is an insufficient gas error
Expand Down