import { Controller, Post, Get, Body, Param } from '@nestjs/common';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
import { FaucetService } from './faucet.service';
import { IsEthereumAddress } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

class DripRequestDto {
  @ApiProperty({ description: '接收测试代币的地址' })
  @IsEthereumAddress()
  address: string;
}

@ApiTags('faucet')
@Controller('v1/faucet')
export class FaucetController {
  constructor(private readonly faucet: FaucetService) {}

  @Post('drip')
  @ApiOperation({ summary: '领取测试代币（100 GNX + 10,000 USDC，每 24 小时一次）' })
  drip(@Body() body: DripRequestDto) {
    return this.faucet.drip(body.address);
  }

  @Get('balance')
  @ApiOperation({ summary: 'Faucet 钱包余额' })
  getBalance() {
    return this.faucet.getBalance();
  }

  @Get('status/:address')
  @ApiOperation({ summary: '检查地址是否可以领取' })
  getClaimStatus(@Param('address') address: string) {
    return this.faucet.getClaimStatus(address);
  }
}
