Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "plotlink",
"version": "0.1.51",
"version": "0.1.52",
"private": true,
"workspaces": [
"packages/*"
Expand Down
7 changes: 6 additions & 1 deletion src/app/api/cron/backfill/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { Database } from "../../../../../lib/supabase";

const IPFS_GATEWAY = "https://ipfs.filebase.io/ipfs/";
const IPFS_TIMEOUT_MS = 10_000;
const IPFS_MAX_BYTES = 1_000_000;

/**
* How many blocks to scan per cron run (~5 min on Base = ~150 blocks at 2s/block).
Expand All @@ -36,7 +37,11 @@ async function fetchIPFSContent(cid: string): Promise<string | null> {
signal: AbortSignal.timeout(IPFS_TIMEOUT_MS),
});
if (!res.ok) return null;
return await res.text();
const cl = res.headers.get("content-length");
if (cl && parseInt(cl) > IPFS_MAX_BYTES) return null;
const text = await res.text();
if (new TextEncoder().encode(text).byteLength > IPFS_MAX_BYTES) return null;
return text;
} catch {
return null;
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/api/index/plot/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server";
import { type Hex, decodeEventLog, encodeEventTopics } from "viem";
import { publicClient, getReceiptWithRetry } from "../../../../../lib/rpc";

Check warning on line 3 in src/app/api/index/plot/route.ts

View workflow job for this annotation

GitHub Actions / lint-and-typecheck

'getReceiptWithRetry' is defined but never used
import { createServerClient } from "../../../../../lib/supabase";
import { validateRecentTx } from "../../../../../lib/index-auth";
import {
Expand All @@ -14,6 +14,7 @@

const IPFS_GATEWAY = "https://ipfs.filebase.io/ipfs/";
const IPFS_TIMEOUT_MS = 10_000;
const IPFS_MAX_BYTES = 1_000_000;

/** PlotChained event topic0 (keccak256 of the event signature) */
const PLOT_CHAINED_TOPIC = encodeEventTopics({
Expand Down Expand Up @@ -93,7 +94,10 @@
signal: AbortSignal.timeout(IPFS_TIMEOUT_MS),
});
if (!ipfsRes.ok) throw new Error(`IPFS status ${ipfsRes.status}`);
const cl = ipfsRes.headers.get("content-length");
if (cl && parseInt(cl) > IPFS_MAX_BYTES) throw new Error("IPFS content too large");
const ipfsContent = await ipfsRes.text();
if (new TextEncoder().encode(ipfsContent).byteLength > IPFS_MAX_BYTES) throw new Error("IPFS content too large");
// Verify IPFS content hash matches on-chain hash
if (hashContent(ipfsContent) === contentHash) {
content = ipfsContent;
Expand Down
4 changes: 4 additions & 0 deletions src/app/api/index/storyline/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NextResponse } from "next/server";
import { type Hex, decodeEventLog, encodeEventTopics } from "viem";
import { publicClient, getReceiptWithRetry } from "../../../../../lib/rpc";

Check warning on line 3 in src/app/api/index/storyline/route.ts

View workflow job for this annotation

GitHub Actions / lint-and-typecheck

'getReceiptWithRetry' is defined but never used
import { createServerClient } from "../../../../../lib/supabase";
import { validateRecentTx } from "../../../../../lib/index-auth";
import {
Expand All @@ -17,6 +17,7 @@

const IPFS_GATEWAY = "https://ipfs.filebase.io/ipfs/";
const IPFS_TIMEOUT_MS = 10_000;
const IPFS_MAX_BYTES = 1_000_000;

/** StorylineCreated event topic0 */
const STORYLINE_CREATED_TOPIC = encodeEventTopics({
Expand Down Expand Up @@ -121,7 +122,10 @@
signal: AbortSignal.timeout(IPFS_TIMEOUT_MS),
});
if (!ipfsRes.ok) throw new Error(`IPFS status ${ipfsRes.status}`);
const cl = ipfsRes.headers.get("content-length");
if (cl && parseInt(cl) > IPFS_MAX_BYTES) throw new Error("IPFS content too large");
const ipfsContent = await ipfsRes.text();
if (new TextEncoder().encode(ipfsContent).byteLength > IPFS_MAX_BYTES) throw new Error("IPFS content too large");
// Verify IPFS content hash matches on-chain hash
if (hashContent(ipfsContent) === openingHash) {
genesisContent = ipfsContent;
Expand Down
Loading