crawl-hive/scripts/e2e-spawn.mjs
h100envy e3ee8a88c1 Live crawlers with per-crawler specifications, private signals, wallet sign-in; MIT
- real collectors: X via Grok x_search, public Telegram channels (t.me/s),
  DexScreener feeds and watchlists, page-change tracking
- crawler specification: plain-language instructions read by Grok, keywords,
  excludes, signal kinds, min confidence, on-chain filters, outcome rule
- scheduler with concurrency, X cost limits and a daily Grok budget
- signals scored against the real price after the owner's horizon (hit/miss),
  feeding reputation
- signals are private to the owner/renter: My Signals inbox, redacted public feed
- sign-in with a wallet signature (Phantom signMessage or local demo keypair),
  HMAC session tokens; x-wallet header no longer trusted
- live crawlers, signals, payments and balances persisted to .data/state.json
- docs/CRAWLERS.md, LICENSE (MIT)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-10 18:17:34 +03:00

32 lines
1.7 KiB
JavaScript

// Сквозная проверка on-chain спавна без браузера: ключ из файла играет роль Phantom.
// node scripts/e2e-spawn.mjs <keypair.json> [baseUrl] [tier]
import { Connection, Keypair, Transaction } from "@solana/web3.js";
import { readFileSync } from "node:fs";
import { signIn, client } from "./signin.mjs";
const [keyPath, base = "http://localhost:3000", tier = "larva"] = process.argv.slice(2);
const kp = Keypair.fromSecretKey(Uint8Array.from(JSON.parse(readFileSync(keyPath, "utf8"))));
const wallet = kp.publicKey.toBase58();
const conn = new Connection(process.env.SOLANA_RPC_URL ?? "https://api.devnet.solana.com", "confirmed");
const token = await signIn(base, kp);
const api = client(base, token);
const call = (path, body) => api(path, "POST", body);
const input = { name: "E2E Spider", source: "onchain", chain: "solana", narratives: ["ai"], targets: ["pump.fun/new"], frequencyMin: 30, tier };
const intent = await call("/api/spawn/intent", input);
console.log("intent", intent.intentId, intent.amount, intent.unit);
const tx = Transaction.from(Buffer.from(intent.transaction, "base64"));
tx.sign(kp);
const sig = await conn.sendRawTransaction(tx.serialize());
console.log("sent", sig);
const crawler = await call("/api/spawn/confirm", { intentId: intent.intentId, signature: sig });
console.log("spawned", crawler.id, crawler.payment);
// Повторное предъявление той же транзакции должно отклоняться.
try {
await call("/api/spawn/confirm", { intentId: intent.intentId, signature: sig });
console.log("REPLAY ACCEPTED — BUG");
} catch (e) {
console.log("replay rejected:", e.message);
}