import { IsString, IsNumber, IsObject, IsEthereumAddress, Min } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';

export class MetaTransactionDto {
  @ApiProperty({ description: '用户地址' })
  @IsEthereumAddress()
  from: string;

  @ApiProperty({ description: '目标合约地址' })
  @IsEthereumAddress()
  target: string;

  @ApiProperty({ description: '编码后的调用数据' })
  @IsString()
  calldata: string;

  @ApiProperty({ description: '用户 nonce（防重放）' })
  @IsNumber()
  @Min(0)
  nonce: number;

  @ApiProperty({ description: 'Gas 限制' })
  @IsString()
  gasLimit: string;

  @ApiProperty({ description: 'EIP-712 签名' })
  @IsString()
  signature: string;

  @ApiProperty({ description: 'EIP-712 域' })
  @IsObject()
  domain: {
    name: string;
    version: string;
    chainId: number;
    verifyingContract: string;
  };
}
