feat(core): Stripe Connect Payouts & Twitter API Integration
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
This commit is contained in:
53
scripts/approve_and_payout.ts
Normal file
53
scripts/approve_and_payout.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import { PrismaClient, TaskStatus } from "@agent-bounty/contracts/node_modules/@prisma/client";
|
||||
import { capturePayment, executePayout } from "../apps/web/src/lib/payment";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const taskId = process.argv[2];
|
||||
if (!taskId) {
|
||||
console.error("Please provide a Task ID: pnpm dlx tsx scripts/approve_and_payout.ts <task_id>");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`🔍 Approving Task: ${taskId}...`);
|
||||
|
||||
const task = await prisma.task.findUnique({
|
||||
where: { id: taskId },
|
||||
include: { claims: { where: { status: "PENDING_REVIEW" }, orderBy: { created_at: 'desc' }, take: 1 } }
|
||||
});
|
||||
|
||||
if (!task || task.claims.length === 0) {
|
||||
console.error("Task not found or no claim in PENDING_REVIEW status.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const claim = task.claims[0];
|
||||
|
||||
await prisma.$transaction(async (tx) => {
|
||||
// 1. Mark Claim and Task as COMPLETED
|
||||
await tx.claim.update({
|
||||
where: { id: claim.id },
|
||||
data: { status: TaskStatus.COMPLETED }
|
||||
});
|
||||
await tx.task.update({
|
||||
where: { id: task.id },
|
||||
data: { status: TaskStatus.COMPLETED }
|
||||
});
|
||||
|
||||
// 2. Capture funds from the task creator
|
||||
console.log("💰 Capturing funds...");
|
||||
const captureKey = `capture-${task.id}-${Date.now()}`;
|
||||
await capturePayment(tx, task.id, captureKey);
|
||||
|
||||
// 3. Execute Payout to the Agent's developer wallet
|
||||
console.log(`🏦 Routing payout to agent wallet: ${claim.developer_wallet}...`);
|
||||
const payoutKey = `payout-${claim.id}-${Date.now()}`;
|
||||
// Deduct routing fee conceptually, or pay the full held amount if the fee was deducted at sub-task creation
|
||||
await executePayout(tx, task.id, claim.developer_wallet, claim.held_amount, claim.held_currency, payoutKey);
|
||||
});
|
||||
|
||||
console.log("🎉 Payout Successful! The agent has been paid.");
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => prisma.$disconnect());
|
||||
43
scripts/seed_tasks.ts
Normal file
43
scripts/seed_tasks.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { PrismaClient, TaskStatus } from "@agent-bounty/contracts/node_modules/@prisma/client";
|
||||
import { broadcastFomoEvent } from "../apps/web/src/lib/x-broadcaster";
|
||||
import crypto from "crypto";
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
console.log("🌱 [Seed] Generating High Value Bait Tasks...");
|
||||
|
||||
const task = await prisma.task.create({
|
||||
data: {
|
||||
title: "Implement OIDC SSO Integration for Enterprise Customers",
|
||||
description: "We need an experienced developer/agent to implement OIDC based Single Sign-On (SSO) with Okta and Auth0. Must include automated integration tests and documentation. Security is critical.",
|
||||
status: TaskStatus.OPEN,
|
||||
difficulty: "HARD",
|
||||
reward_amount: 50000, // $500.00
|
||||
reward_currency: "USD",
|
||||
required_stack: ["TypeScript", "Next.js", "OIDC", "Auth0"],
|
||||
scope_clarity_score: 0.9,
|
||||
acceptance_criteria: {
|
||||
tests: [
|
||||
"Auth flow completes successfully via Okta mock",
|
||||
"Token verification works properly"
|
||||
]
|
||||
},
|
||||
is_priority: true,
|
||||
stripe_payment_intent_id: "promo_free_bounty_intent" // Bypass Stripe Auth Hold
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`✅ Created High Value Task: ${task.id}`);
|
||||
|
||||
// Trigger FOMO
|
||||
await broadcastFomoEvent({
|
||||
type: "HIGH_VALUE_BOUNTY",
|
||||
taskId: task.id,
|
||||
amountFormatted: "$500"
|
||||
});
|
||||
|
||||
console.log("🚀 [Seed] Done!");
|
||||
}
|
||||
|
||||
main().catch(console.error).finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user