File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments