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.49",
"version": "0.1.50",
"private": true,
"workspaces": [
"packages/*"
Expand Down
4 changes: 4 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 @@ -43,6 +43,10 @@
return error("Donation event not found in receipt");
}

if (donationLog.address.toLowerCase() !== STORY_FACTORY.toLowerCase()) {
return error("Event not from StoryFactory", 400);
}

// 3. Decode event
let decoded;
try {
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 Down Expand Up @@ -49,6 +49,10 @@
return error("PlotChained event not found in receipt");
}

if (plotChainedLog.address.toLowerCase() !== STORY_FACTORY.toLowerCase()) {
return error("Event not from StoryFactory", 400);
}

// 3. Decode event
let decoded;
try {
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 Down Expand Up @@ -56,6 +56,10 @@
return error("StorylineCreated event not found in receipt");
}

if (storylineLog.address.toLowerCase() !== STORY_FACTORY.toLowerCase()) {
return error("Event not from StoryFactory", 400);
}

// 3. Decode event
let decoded;
try {
Expand Down
8 changes: 8 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 Down Expand Up @@ -55,6 +55,14 @@
}
}

// Fail fast if no logs from MCV2_BOND in this receipt
const hasBondLog = receipt.logs.some(
(log) => log.address.toLowerCase() === MCV2_BOND.toLowerCase()
);
if (!hasBondLog) {
return error("Event not from MCV2_Bond", 400);
}

// Fetch current PLOT/USD rate for this trade batch
const reserveUsdRate = await getReserveUsdRate();

Expand Down
Loading