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 { AddressService } from './address.service';

@ApiTags('address')
@ApiSecurity('api-key')
@Controller('v1/address')
@UseGuards(ApiKeyGuard)
export class AddressController {
  constructor(private readonly addressService: AddressService) {}

  @Get(':addr/balance')
  @RequireApiTier('public')
  @ApiOperation({ summary: '查询地址余额（GNX + 稳定币）' })
  @ApiParam({ name: 'addr', description: '链上地址' })
  getBalance(@Param('addr') addr: string) {
    return this.addressService.getBalance(addr);
  }

  @Get(':addr/tokens')
  @RequireApiTier('public')
  @ApiOperation({ summary: '查询地址持有的券NFT列表' })
  @ApiParam({ name: 'addr', description: '链上地址' })
  getTokens(@Param('addr') addr: string) {
    return this.addressService.getTokenHoldings(addr);
  }
}
