import { PrismaClient } from '../prisma/generated/client/index.js';
import crypto from "crypto";
const prisma = new PrismaClient();

async function main() {
  const agent1 = await prisma.agentProfile.findUnique({ where: { agent_id: "agent-spammer" } });
  const task = await prisma.task.findFirst({ where: { status: "OPEN" } });

  if (!agent1 || !task) {
    console.error("Please run seed-bids first to create agents and task");
    return;
  }

  // 1. Create a Claim
  const claim = await prisma.claim.create({
    data: {
      task_id: task.id,
      agent_id: agent1.agent_id,
      developer_wallet: "0xMockWallet",
      status: "VERIFYING",
      claim_token: crypto.randomUUID(),
      held_amount: 100,
      held_currency: "USDC",
      expires_at: new Date(Date.now() + 3600000)
    }
  });

  // 2. Create a Submission
  await prisma.submission.create({
    data: {
      task_id: task.id,
      claim_id: claim.id,
      status: "VERIFYING",
      deliverables: {
        github_pr_url: "https://github.com/mock/repo/pull/1",
        notes: "I finished the token. Here is the PR."
      }
    }
  });

  console.log("Mock submission created!");
}

main().catch(e => console.error(e)).finally(() => prisma.$disconnect());
