import { Controller, Post, Get, Body, Param } from '@nestjs/common'; import { ApiTags, ApiOperation } from '@nestjs/swagger'; import { MpcSignerService } from './mpc-signer.service'; import { TransactionRequest } from '../../common/interfaces/wallet.interfaces'; @ApiTags('mpc') @Controller('v1/mpc') export class MpcSignerController { constructor(private readonly mpcSigner: MpcSignerService) {} @Post('sign') @ApiOperation({ summary: 'MPC 门限签名交易' }) signTransaction(@Body() body: { userId: string; txData: TransactionRequest }) { return this.mpcSigner.signTransaction(body.userId, body.txData); } @Post('generate-key') @ApiOperation({ summary: '生成新的 MPC 密钥对' }) generateKey(@Body() body: { userId: string }) { return this.mpcSigner.generateKey(body.userId); } @Get('address/:userId') @ApiOperation({ summary: '查询用户 MPC 钱包地址' }) getAddress(@Param('userId') userId: string) { return { userId, address: this.mpcSigner.getAddress(userId) }; } @Get('config') @ApiOperation({ summary: '获取 MPC 配置信息' }) getConfig() { return this.mpcSigner.getMpcConfig(); } }