Skip to content
Merged
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
38 changes: 36 additions & 2 deletions backend/src/api/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Router, Request, Response } from "express";
import { getFeeStats } from "../services/horizon";
import { stellarConfig, CONTRACT_IDS } from "../config/stellar";
import { requireAuth } from "../middleware/auth";
import campaignRoutes from "../routes/campaigns";
import publisherRoutes from "../routes/publishers";
import auctionRoutes from "../routes/auctions";
Expand Down Expand Up @@ -55,8 +56,41 @@ router.get("/network", async (_req: Request, res: Response) => {
}
});

// List deployed contract IDs
router.get("/contracts", (_req: Request, res: Response) => {
// Account details
router.get("/account/:address", async (req: Request, res: Response) => {
try {
const { address } = req.params;
const account = await getAccountDetails(address as string);
if (!account) {
return res.status(404).json({ error: "Account not found or not funded" });
}
res.json(account);
} catch (err: any) {
req.log?.error({ err }, 'Failed to fetch account details');
const details = process.env.NODE_ENV === 'development' ? err.message : undefined;
res.status(500).json({ error: 'Failed to fetch account details', ...(details && { details }) });
}
});

// Account transaction history
router.get(
"/account/:address/transactions",
async (req: Request, res: Response) => {
try {
const { address } = req.params;
const limit = Math.min(parseInt(req.query.limit as string) || 20, 200);
const txs = await getAccountTransactions(address as string, limit);
res.json({ transactions: txs, count: txs.length });
} catch (err: any) {
req.log?.error({ err }, 'Failed to fetch account transactions');
const details = process.env.NODE_ENV === 'development' ? err.message : undefined;
res.status(500).json({ error: 'Failed to fetch account transactions', ...(details && { details }) });
}
},
);

// List deployed contract IDs (auth required)
router.get("/contracts", requireAuth, (_req: Request, res: Response) => {
res.json({ contracts: CONTRACT_IDS });
});

Expand Down
Loading