manifoldHttpmain.ts19 matches
6const [url, setUrl] = useState("");
7const [result, setResult] = useState<any>(null);
8const [apiKey, setApiKey] = useState("");
9const [betAmount, setBetAmount] = useState(0);
10const [status, setStatus] = useState<string | null>(null);
1112useEffect(() => {
13const storedKey = localStorage.getItem("manifoldApiKey");
14if (storedKey) setApiKey(storedKey);
15}, []);
1617function saveKey() {
18localStorage.setItem("manifoldApiKey", apiKey);
19alert("API key saved locally");
20}
213334async function handleBetAll() {
35if (!result || !apiKey || betAmount <= 0) return;
36setStatus("Placing bets...");
3741body: JSON.stringify({
42url,
43apiKey,
44amount: betAmount
45})
5556<div className="mb-4">
57<h2 className="font-semibold mb-2">API Key</h2>
58<input
59type="password"
60value={apiKey}
61onChange={(e) => setApiKey(e.target.value)}
62placeholder="Enter Manifold API key"
63className="border p-2 rounded w-full mb-2"
64/>
132const slug = parts.pop() || parts.pop();
133134const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
135const res = await fetch(apiUrl);
136if (!res.ok) return new Response(`Failed to fetch market: ${res.statusText}`, { status: 500 });
137150151if (pathname === "/betAll" && req.method === "POST") {
152const { url, apiKey, amount } = await req.json();
153if (!url || !apiKey || !amount) return new Response("Missing parameters", { status: 400 });
154155const parts = url.split("/");
156const slug = parts.pop() || parts.pop();
157158const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
159const res = await fetch(apiUrl);
160if (!res.ok) return new Response(`Failed to fetch market: ${res.statusText}`, { status: 500 });
161167const results: any[] = [];
168for (const ans of data.answers) {
169const betRes = await fetch("https://manifold.markets/api/v0/bet", {
170method: "POST",
171headers: {
172"content-type": "application/json",
173"Authorization": `Key ${apiKey}`,
174},
175body: JSON.stringify({
manifoldSummain.ts2 matches
4const slug = parts.pop() || parts.pop(); // handle trailing slash
56const apiUrl = `https://manifold.markets/api/v0/slug/${slug}`;
7const res = await fetch(apiUrl);
8if (!res.ok) throw new Error(`Failed to fetch market: ${res.statusText}`);
9const data = await res.json();
185<meta name="viewport" content="width=device-width, initial-scale=1.0">
186<title>Principia</title>
187<link rel="preconnect" href="https://fonts.googleapis.com">
188<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
189<link href="https://fonts.googleapis.com/css2?family=Merriweather:wght@300;400;700&family=Roboto+Mono:wght@300;400&display=swap" rel="stylesheet">
190<style>
191:root {
h6-val-summary.ts3 matches
18SUM(num_images) as total_images
19FROM ${USAGE_TABLE}
20WHERE val_id = ? AND our_api_token = 1
21GROUP BY val_id
22`, [valId]);
34FROM ${INFERENCE_CALLS_TABLE} i
35JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
36WHERE u.val_id = ? AND u.our_api_token = 1
37GROUP BY u.val_id
38`, [valId]);
41const requestsResult = await sqlite.execute(`
42SELECT * FROM ${USAGE_TABLE}
43WHERE val_id = ? AND our_api_token = 1
44ORDER BY timestamp DESC
45`, [valId]);
h6-val-detail.ts1 match
18finish_reason?: string;
19num_images?: number;
20our_api_token: boolean;
21}
22
h6-useUser.tsx1 match
1import { useState, useEffect } from "react";
23const USER_ENDPOINT = "/api/user";
45export function useUser() {
h6-user-summary.ts2 matches
20SUM(num_images) as total_images
21FROM ${USAGE_TABLE}
22WHERE our_api_token = 1
23`;
24
41FROM ${INFERENCE_CALLS_TABLE} i
42JOIN ${USAGE_TABLE} u ON i.usage_id = u.id
43WHERE u.our_api_token = 1
44`;
45
h6-user-detail.ts2 matches
1import { renderLayout } from "./layout.ts";
2import { formatNumber, formatPrice, formatDate, formatBoolean } from "../utils/formatters.ts";
3import { CreditAddition } from "../api/credit-additions.ts";
45interface UserSummaryRow {
33finish_reason?: string;
34num_images?: number;
35our_api_token: boolean;
36}
37
h6-useProject.tsx2 matches
1import { useState, useEffect } from "react";
23const PROJECT_ENDPOINT = "/api/project";
4const FILES_ENDPOINT = "/api/project-files";
56export function useProject(projectId: string, branchId?: string) {
h6-useProjects.tsx1 match
1import { useState, useEffect } from "react";
23const ENDPOINT = "/api/projects-loader";
45export function useProjects() {