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.50",
"version": "0.1.51",
"private": true,
"workspaces": [
"packages/*"
Expand Down
14 changes: 14 additions & 0 deletions src/app/api/index/donation/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/donation/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 Down Expand Up @@ -28,6 +28,20 @@
return error("Missing or invalid txHash");
}

// 0. DB dedup — skip RPC/IPFS if already indexed
const supabaseDedup = createServerClient();
if (supabaseDedup) {
const { data: existing } = await supabaseDedup
.from("donations")
.select("id")
.eq("tx_hash", txHash)
.limit(1)
.maybeSingle();
if (existing) {
return NextResponse.json({ ok: true, cached: true });
}
}

// 1. Validate tx exists and is recent (< 5 min) — prevents spam
const receipt = await validateRecentTx(txHash);
if (!receipt) {
Expand Down
14 changes: 14 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 Down Expand Up @@ -34,6 +34,20 @@
return error("Missing or invalid txHash");
}

// 0. DB dedup — skip RPC/IPFS if already indexed
const supabaseDedup = createServerClient();
if (supabaseDedup) {
const { data: existing } = await supabaseDedup
.from("plots")
.select("id")
.eq("tx_hash", txHash)
.limit(1)
.maybeSingle();
if (existing) {
return NextResponse.json({ ok: true, cached: true });
}
}

// 1. Validate tx exists and is recent (< 5 min) — prevents spam
const receipt = await validateRecentTx(txHash);
if (!receipt) {
Expand Down
14 changes: 14 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 Down Expand Up @@ -41,6 +41,20 @@
return error("Missing or invalid txHash");
}

// 0. DB dedup — skip RPC/IPFS if already indexed
const supabaseDedup = createServerClient();
if (supabaseDedup) {
const { data: existing } = await supabaseDedup
.from("storylines")
.select("id")
.eq("tx_hash", txHash)
.limit(1)
.maybeSingle();
if (existing) {
return NextResponse.json({ ok: true, cached: true });
}
}

// 1. Validate tx exists and is recent (< 5 min) — prevents spam
const receipt = await validateRecentTx(txHash);
if (!receipt) {
Expand Down
4 changes: 4 additions & 0 deletions src/app/api/index/trade/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, formatUnits } from "viem";
import { publicClient, getReceiptWithRetry } from "../../../../../lib/rpc";

Check warning on line 3 in src/app/api/index/trade/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 { mcv2BondEventAbi } from "../../../../../lib/contracts/abi";
import { MCV2_BOND, ZAP_PLOTLINK } from "../../../../../lib/contracts/constants";
Expand All @@ -23,6 +23,10 @@
if (!txHash || !/^0x[0-9a-fA-F]{64}$/.test(txHash)) return error("Missing or invalid txHash");
if (!tokenAddress) return error("tokenAddress required");

// Trade route skips early dedup: a single tx can produce multiple trade logs,
// and partial indexing on a previous attempt must not block retries.
// Per-log upserts handle duplicates safely without IPFS cost.

// Validate tx exists and is recent (< 5 min) — prevents spam with fake hashes
const validatedReceipt = await validateRecentTx(txHash);
if (!validatedReceipt) return error("Transaction not found, failed, or too old", 400);
Expand Down
Loading