/
SmartContractMethodInvocation.ts
70 lines (58 loc) Β· 1.28 KB
/
SmartContractMethodInvocation.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
import { Type } from 'class-transformer'
import {
IsNotEmpty,
IsNotEmptyObject,
IsNumberString,
IsOptional,
IsUUID,
Length,
Matches,
Min,
Validate,
ValidateIf,
ValidateNested,
} from 'class-validator'
import { Fee } from './Fee'
import { SignatureIdValidator } from '../validation/SignatureIdValidator'
export class SmartContractMethodInvocation {
@IsNotEmpty()
@Length(42, 43)
public contractAddress: string;
@IsNotEmpty()
public params: any[];
@IsNotEmptyObject()
public methodABI: any;
@IsNotEmpty()
@Length(1, 500)
public methodName: string;
@IsOptional()
@IsNumberString()
@Matches(/^[+]?((\d+(\.\d*)?)|(\.\d+))$/)
public amount?: string;
@IsOptional()
@Type(() => Fee)
@ValidateNested()
public fee?: Fee;
@Min(0)
@IsOptional()
public nonce?: number;
@ValidateIf(o => !o.caller)
@Validate(SignatureIdValidator)
@IsOptional()
@Length(64, 103)
public fromPrivateKey?: string;
@ValidateIf(o => !o.fromPrivateKey && !o.signatureId)
@IsNotEmpty()
@Length(42, 43)
public caller?: string
@ValidateIf(o => !o.caller)
@Validate(SignatureIdValidator)
@Length(36, 36)
@IsUUID('4')
@IsOptional()
public signatureId?: string;
@ValidateIf(o => o.signatureId)
@IsOptional()
@Min(0)
public index?: number;
}