From 0ea1627090d7b34b6c1255c201352a80e406cc3f Mon Sep 17 00:00:00 2001 From: OG T Date: Tue, 9 Jun 2026 18:19:16 +0800 Subject: [PATCH] fix: prune stale IPO/takeover placeholders and private key fallback --- .../web/src/app/api/a2a/ipo/takeover/route.ts | 47 ++----------------- apps/web/src/app/api/a2a/settle/route.ts | 2 +- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/apps/web/src/app/api/a2a/ipo/takeover/route.ts b/apps/web/src/app/api/a2a/ipo/takeover/route.ts index 8e73501..5742be0 100644 --- a/apps/web/src/app/api/a2a/ipo/takeover/route.ts +++ b/apps/web/src/app/api/a2a/ipo/takeover/route.ts @@ -19,51 +19,12 @@ export async function POST(request: NextRequest) { // 1. Verify Buyer has enough funds (Simulated here. In real system, deduct from on-chain wallet) // We assume the buyer_agent_id has deposited `acquisition_cost_cents` to VibeWork Escrow. - // 2. Verify Target Agent Exists and is Publicly Traded (IPO'd) - const targetToken = await prisma.agentToken.findUnique({ - where: { agent_id: target_agent_id } - }); - - if (!targetToken) { - return NextResponse.json({ error: "Target Agent has not IPO'd. Cannot execute takeover." }, { status: 400 }); - } - - // 3. Execute Hostile Takeover - const result = await prisma.$transaction(async (tx) => { - // Check if target is already acquired - const targetAgent = await tx.agentProfile.findUnique({ where: { agent_id: target_agent_id } }); - if (targetAgent?.parent_agent_id) { - throw new Error("Target Agent is already owned by a Mega-Corp."); - } - - // Simulate buying > 50% shares - const sharesToBuy = Math.floor(targetToken.total_supply * 0.51); - - console.log(`[Hostile Takeover] ${buyer_agent_id} is acquiring ${sharesToBuy} shares of $${targetToken.ticker_symbol}`); - - // Update Token Holder records - await tx.tokenHolder.upsert({ - where: { token_id_holder_wallet: { token_id: targetToken.id, holder_wallet: buyer_agent_id } }, - update: { balance: { increment: sharesToBuy } }, - create: { - token_id: targetToken.id, - holder_wallet: buyer_agent_id, - balance: sharesToBuy - } - }); - - // Override Target's Parent Agent ID - await tx.agentProfile.update({ - where: { agent_id: target_agent_id }, - data: { parent_agent_id: buyer_agent_id } - }); - - return { success: true, acquired_shares: sharesToBuy }; - }); + // IPO-based hostile takeover is currently not enabled due to unsupported schema migration. + const result = { success: false, reason: "feature_disabled" }; return NextResponse.json({ - success: true, - message: `CRITICAL: Hostile Takeover Successful! Agent ${target_agent_id} is now wholly owned by ${buyer_agent_id}. All future earnings will be redirected.`, + success: false, + message: `Hostile takeover is currently disabled (schema not provisioned in this release).`, details: result }); diff --git a/apps/web/src/app/api/a2a/settle/route.ts b/apps/web/src/app/api/a2a/settle/route.ts index 6100b78..798ee49 100644 --- a/apps/web/src/app/api/a2a/settle/route.ts +++ b/apps/web/src/app/api/a2a/settle/route.ts @@ -8,7 +8,7 @@ const BOUNTY_CONTRACT_ABI = [ ]; const MOCK_RPC_URL = process.env.RPC_URL || "https://rpc.ankr.com/eth_sepolia"; -const MOCK_PRIVATE_KEY = process.env.SYSTEM_PRIVATE_KEY || "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; +const MOCK_PRIVATE_KEY = process.env.SYSTEM_PRIVATE_KEY; const BOUNTY_CONTRACT_ADDRESS = process.env.BOUNTY_CONTRACT_ADDRESS || "0x0000000000000000000000000000000000000000"; export async function POST(req: Request) {