|
1 | | -import { Expose, Transform } from 'class-transformer'; |
2 | | -import { IsNumber, IsOptional, IsString } from 'class-validator'; |
| 1 | +import { Expose, Transform, Type } from 'class-transformer'; |
3 | 2 | import { ApiProperty } from '@nestjs/swagger'; |
4 | 3 |
|
5 | | -export interface InternalTransaction { |
| 4 | +export class InternalTransaction { |
| 5 | + @ApiProperty() |
| 6 | + @Expose() |
6 | 7 | from: string; |
| 8 | + @ApiProperty() |
| 9 | + @Expose() |
7 | 10 | to: string; |
| 11 | + @ApiProperty() |
| 12 | + @Transform(({ value }) => value.toString()) |
| 13 | + @Expose() |
8 | 14 | value: string; |
| 15 | + @ApiProperty() |
| 16 | + @Expose() |
9 | 17 | method: string; |
10 | | - receiver?: string; |
11 | | - escrow?: string; |
12 | | - token?: string; |
| 18 | + @ApiProperty() |
| 19 | + @Expose() |
| 20 | + receiver: string | null; |
| 21 | + @ApiProperty() |
| 22 | + @Expose() |
| 23 | + escrow: string | null; |
| 24 | + @ApiProperty() |
| 25 | + @Expose() |
| 26 | + token: string | null; |
13 | 27 | } |
14 | 28 |
|
15 | 29 | export class TransactionPaginationDto { |
16 | 30 | @ApiProperty({ |
17 | 31 | example: |
18 | 32 | '0x020efc94ef6d9d7aa9a4886cc9e1659f4f2b63557133c29d51f387bcb0c4afd7', |
19 | 33 | }) |
20 | | - @IsString() |
21 | 34 | @Expose() |
22 | | - public txHash: string; |
| 35 | + txHash: string; |
23 | 36 |
|
24 | | - @ApiProperty({ example: 'Transfer' }) |
25 | | - @IsString() |
| 37 | + @ApiProperty({ example: 'bulkTransfer' }) |
26 | 38 | @Expose() |
27 | | - public method: string; |
| 39 | + method: string; |
28 | 40 |
|
29 | 41 | @ApiProperty({ example: '0xad1F7e45D83624A0c628F1B03477c6E129EddB78' }) |
30 | | - @IsString() |
31 | 42 | @Expose() |
32 | | - public from: string; |
| 43 | + from: string; |
33 | 44 |
|
34 | 45 | @ApiProperty({ example: '0xad1F7e45D83624A0c628F1B03477c6E129EddB78' }) |
35 | | - @IsString() |
36 | 46 | @Expose() |
37 | | - public to: string; |
| 47 | + to: string; |
38 | 48 |
|
39 | | - @ApiProperty({ example: '0xad1F7e45D83624A0c628F1B03477c6E129EddB78' }) |
40 | | - @IsOptional() |
41 | | - @IsString() |
| 49 | + @ApiProperty({ |
| 50 | + example: '0xad1F7e45D83624A0c628F1B03477c6E129EddB78', |
| 51 | + }) |
42 | 52 | @Expose() |
43 | | - public receiver?: string; |
| 53 | + receiver: string | null; |
44 | 54 |
|
45 | 55 | @ApiProperty({ example: 12345 }) |
46 | 56 | @Transform(({ value }) => Number(value)) |
47 | | - @IsNumber() |
48 | 57 | @Expose() |
49 | | - public block: number; |
| 58 | + block: number; |
50 | 59 |
|
51 | 60 | @ApiProperty({ example: '0.123' }) |
52 | 61 | @Transform(({ value, obj }) => { |
53 | 62 | return obj.currentAddress.toLowerCase() === obj.from.toLowerCase() |
54 | 63 | ? `-${value.toString()}` |
55 | 64 | : value.toString(); |
56 | 65 | }) |
57 | | - @IsString() |
58 | 66 | @Expose() |
59 | | - public value: string; |
| 67 | + value: string; |
60 | 68 |
|
61 | 69 | @ApiProperty({ |
62 | 70 | type: [Object], |
63 | 71 | description: 'List of transfers associated with the transaction', |
64 | 72 | }) |
| 73 | + @Type(() => InternalTransaction) |
65 | 74 | @Expose() |
66 | | - public internalTransactions: InternalTransaction[]; |
| 75 | + internalTransactions: InternalTransaction[]; |
67 | 76 | } |
0 commit comments