/
CreateErc20Offchain.ts
80 lines (68 loc) Β· 1.69 KB
/
CreateErc20Offchain.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import {Type} from 'class-transformer'
import {
IsIn,
IsNotEmpty,
IsNumber,
IsNumberString,
IsOptional,
Length,
Matches,
Max,
MaxLength,
Min,
Validate,
ValidateIf,
ValidateNested,
} from 'class-validator'
import {Fiat} from '../response'
import {CreateErc20Validator} from './CreateErc20Validator'
import {Currency} from './Currency'
import {CustomerUpdate} from './CustomerUpdate'
export class CreateErc20Offchain {
@IsNotEmpty()
@Length(1, 30)
@Matches(/^[a-zA-Z0-9_]+$/)
public symbol: string;
@IsNotEmpty()
@Length(1, 100)
public description: string;
@IsNotEmpty()
@IsNumberString()
@MaxLength(38)
@Matches(/^[+]?((\d+(\.\d*)?)|(\.\d+))$/)
public supply: string;
@Length(3, 20)
@IsIn([...Object.keys(Currency), ...Object.keys(Fiat)])
@IsNotEmpty()
public basePair: Currency | Fiat;
@Min(0)
@IsOptional()
public baseRate?: number;
@Length(3, 3)
@IsOptional()
public chain?: Currency;
@Length(3, 3)
@IsOptional()
@IsIn(Object.keys(Fiat))
public accountingCurrency?: Fiat;
@ValidateIf(o => (o.xpub && o.address) || !o.address)
@Validate(CreateErc20Validator)
@Length(1, 150)
@IsNotEmpty()
public xpub: string;
@ValidateIf(o => (o.xpub && o.address) || !o.xpub)
@Validate(CreateErc20Validator)
@Length(42, 43)
@IsNotEmpty()
public address: string;
@ValidateIf(o => (o.xpub && o.address) || !o.address)
@IsNumber()
@IsNotEmpty()
@Min(1)
@Max(2147483647)
public derivationIndex: number;
@IsOptional()
@Type(() => CustomerUpdate)
@ValidateNested()
public customer?: CustomerUpdate;
}