import { Controller, Get, Param, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiParam, ApiSecurity } from '@nestjs/swagger';
import { ApiKeyGuard } from '../../common/guards/api-key.guard';
import { RequireApiTier } from '../../common/decorators/api-tier.decorator';
import { TransactionsService } from './transactions.service';

@ApiTags('transactions')
@ApiSecurity('api-key')
@Controller('v1/transactions')
@UseGuards(ApiKeyGuard)
export class TransactionsController {
  constructor(private readonly txService: TransactionsService) {}

  @Get(':hash')
  @RequireApiTier('public')
  @ApiOperation({ summary: '获取交易详情' })
  @ApiParam({ name: 'hash', description: '交易哈希' })
  getTransaction(@Param('hash') hash: string) {
    return this.txService.getTransaction(hash);
  }
}
