-
Notifications
You must be signed in to change notification settings - Fork 2
/
transaction-options.dto.ts
62 lines (54 loc) · 1.64 KB
/
transaction-options.dto.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
/* istanbul ignore file */
import { ApiHideProperty, ApiProperty } from '@nestjs/swagger';
import { BigNumber } from '@polymeshassociation/polymesh-sdk';
import { Type } from 'class-transformer';
import {
IsEnum,
IsObject,
IsOptional,
IsString,
IsUrl,
ValidateIf,
ValidateNested,
} from 'class-validator';
import { ToBigNumber } from '~/common/decorators/transformation';
import { IsBigNumber } from '~/common/decorators/validation';
import { MortalityDto } from '~/common/dto/mortality-dto';
import { ProcessMode } from '~/common/types';
export class TransactionOptionsDto {
@ApiProperty({
description: 'An identifier or address for the account that should sign the transaction',
example: 'alice',
})
@IsString()
readonly signer: string;
@ApiProperty({
description: 'Mode for processing the transaction',
enum: ProcessMode,
example: ProcessMode.Submit,
})
@IsEnum(ProcessMode)
readonly processMode: ProcessMode;
// Hide the property so the interactive examples work without additional setup
@ApiHideProperty()
@Type(() => MortalityDto)
@IsOptional()
@ValidateNested()
readonly mortality?: MortalityDto;
@ApiHideProperty()
@IsOptional()
@IsBigNumber()
@ToBigNumber()
readonly nonce?: BigNumber;
// Note: If submitWithCallback is used, the user must provide a webhookUrl
@ApiHideProperty()
@ValidateIf(({ processMode }) => processMode === ProcessMode.SubmitWithCallback)
@IsString()
@IsUrl()
readonly webhookUrl?: string;
@ApiHideProperty()
@ValidateIf(({ processMode }) => processMode === ProcessMode.Offline)
@IsOptional()
@IsObject()
readonly metadata?: Record<string, string>;
}