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
30 changes: 30 additions & 0 deletions app/api/bridge/estimate/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,36 @@ export async function POST(request: NextRequest) {
);
}

// Verify source wallet belongs to the authenticated user
const { data: sourceWalletOwnership, error: sourceOwnershipError } = await supabase
.from("wallets")
.select("circle_wallet_id")
.eq("user_id", user.id)
.eq("circle_wallet_id", sourceWalletId)
.single();

if (sourceOwnershipError || !sourceWalletOwnership) {
return NextResponse.json(
{ error: "Source wallet not found or access denied" },
{ status: 404 }
);
}

// Verify destination wallet belongs to the authenticated user
const { data: destWalletOwnership, error: destOwnershipError } = await supabase
.from("wallets")
.select("circle_wallet_id")
.eq("user_id", user.id)
.eq("circle_wallet_id", destinationWalletId)
.single();

if (destOwnershipError || !destWalletOwnership) {
return NextResponse.json(
{ error: "Destination wallet not found or access denied" },
{ status: 404 }
);
}

// Get source wallet address
const sourceWalletResponse = await circleDeveloperSdk.getWallet({
id: sourceWalletId,
Expand Down
30 changes: 30 additions & 0 deletions app/api/bridge/rebalance/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,36 @@ export async function POST(request: NextRequest) {
);
}

// Verify source wallet belongs to the authenticated user
const { data: sourceWalletOwnership, error: sourceOwnershipError } = await supabase
.from("wallets")
.select("circle_wallet_id")
.eq("user_id", user.id)
.eq("circle_wallet_id", sourceWalletId)
.single();

if (sourceOwnershipError || !sourceWalletOwnership) {
return NextResponse.json(
{ error: "Source wallet not found or access denied" },
{ status: 404 }
);
}

// Verify destination wallet belongs to the authenticated user
const { data: destWalletOwnership, error: destOwnershipError } = await supabase
.from("wallets")
.select("circle_wallet_id")
.eq("user_id", user.id)
.eq("circle_wallet_id", destinationWalletId)
.single();

if (destOwnershipError || !destWalletOwnership) {
return NextResponse.json(
{ error: "Destination wallet not found or access denied" },
{ status: 404 }
);
}

// Get source wallet address
const sourceWalletResponse = await circleDeveloperSdk.getWallet({
id: sourceWalletId,
Expand Down