- Add Foundry project configuration (foundry.toml, foundry.lock) - Add Solidity contracts (TokenFactory138, BridgeVault138, ComplianceRegistry, etc.) - Add API definitions (OpenAPI, GraphQL, gRPC, AsyncAPI) - Add comprehensive test suite (unit, integration, fuzz, invariants) - Add API services (REST, GraphQL, orchestrator, packet service) - Add documentation (ISO20022 mapping, runbooks, adapter guides) - Add development tools (RBC tool, Swagger UI, mock server) - Update OpenZeppelin submodules to v5.0.0
95 lines
2.4 KiB
TypeScript
95 lines
2.4 KiB
TypeScript
/**
|
|
* Token controllers
|
|
*/
|
|
|
|
import { Request, Response, NextFunction } from 'express';
|
|
import { tokenService } from '../services/token-service';
|
|
|
|
export async function deployToken(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const token = await tokenService.deployToken(req.body);
|
|
res.status(201).json(token);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function listTokens(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code, issuer, limit, offset } = req.query;
|
|
const result = await tokenService.listTokens({
|
|
code: code as string,
|
|
issuer: issuer as string,
|
|
limit: parseInt(limit as string) || 20,
|
|
offset: parseInt(offset as string) || 0,
|
|
});
|
|
res.json(result);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function getToken(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const token = await tokenService.getToken(code);
|
|
if (!token) {
|
|
return res.status(404).json({ code: 'NOT_FOUND', message: 'Token not found' });
|
|
}
|
|
res.json(token);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function updateTokenPolicy(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const token = await tokenService.updatePolicy(code, req.body);
|
|
res.json(token);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function mintTokens(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const result = await tokenService.mint(code, req.body);
|
|
res.json(result);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function burnTokens(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const result = await tokenService.burn(code, req.body);
|
|
res.json(result);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function clawbackTokens(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const result = await tokenService.clawback(code, req.body);
|
|
res.json(result);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|
|
export async function forceTransferTokens(req: Request, res: Response, next: NextFunction) {
|
|
try {
|
|
const { code } = req.params;
|
|
const result = await tokenService.forceTransfer(code, req.body);
|
|
res.json(result);
|
|
} catch (error) {
|
|
next(error);
|
|
}
|
|
}
|
|
|