import { Controller, Post, Body, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiSecurity } from '@nestjs/swagger';
import { ApiKeyGuard } from '../../common/guards/api-key.guard';
import { RequireApiTier } from '../../common/decorators/api-tier.decorator';
import { RpcService } from './rpc.service';

@ApiTags('rpc')
@ApiSecurity('api-key')
@Controller('v1/rpc')
@UseGuards(ApiKeyGuard)
export class RpcController {
  constructor(private readonly rpcService: RpcService) {}

  @Post()
  @RequireApiTier('institutional')
  @ApiOperation({ summary: 'JSON-RPC 代理（机构API — eth_call, eth_sendRawTransaction 等）' })
  proxyRpc(@Body() body: { jsonrpc: string; method: string; params: any[]; id: number }) {
    return this.rpcService.proxy(body);
  }
}
