Skip to content

Commit aebb4e7

Browse files
committed
spike
1 parent eb2396a commit aebb4e7

3 files changed

Lines changed: 569 additions & 38 deletions

File tree

src/app/api/rejected/route.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { NextResponse } from "next/server";
2+
import {
3+
getRejectedTransaction,
4+
listRejectedTransactions,
5+
type RejectedTransaction,
6+
} from "@/lib/s3";
7+
8+
export interface RejectedTransactionsResponse {
9+
transactions: RejectedTransaction[];
10+
}
11+
12+
export async function GET() {
13+
try {
14+
const summaries = await listRejectedTransactions(100);
15+
16+
const transactions = (
17+
await Promise.all(
18+
summaries.map((s) => getRejectedTransaction(s.blockNumber, s.txHash)),
19+
)
20+
).filter((tx): tx is RejectedTransaction => tx !== null);
21+
22+
const response: RejectedTransactionsResponse = { transactions };
23+
return NextResponse.json(response);
24+
} catch (error) {
25+
console.error("Error fetching rejected transactions:", error);
26+
return NextResponse.json(
27+
{ error: "Internal server error" },
28+
{ status: 500 },
29+
);
30+
}
31+
}

0 commit comments

Comments
 (0)