/
NftIssueOperation.ts
47 lines (39 loc) · 1.55 KB
/
NftIssueOperation.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
import { Expose, Type } from "class-transformer";
import { Fee } from "../../DCoreClient";
import { ChainObjectToClass, ChainObjectToPlain } from "../../net/adapter/TypeAdapters";
import { assertThrow } from "../../utils/Utils";
import { ChainObject } from "../ChainObject";
import { Memo } from "../Memo";
import { ObjectType } from "../ObjectType";
import { BaseOperation } from "./BaseOperation";
import { OperationType } from "./OperationType";
export class NftIssueOperation extends BaseOperation {
@ChainObjectToClass
@ChainObjectToPlain
@Expose({ name: "issuer" })
public readonly issuer: ChainObject;
@ChainObjectToClass
@ChainObjectToPlain
@Expose({ name: "nft_id" })
public readonly id: ChainObject;
@ChainObjectToClass
@ChainObjectToPlain
@Expose({ name: "to" })
public readonly to: ChainObject;
@Expose({ name: "data" })
public readonly data: any[];
@Type(() => Memo)
@Expose({ name: "memo" })
public readonly memo?: Memo;
constructor(issuer: ChainObject, id: ChainObject, to: ChainObject, data: any[], memo?: Memo, fee?: Fee) {
super(OperationType.NftIssue, fee);
this.issuer = issuer;
this.id = id;
this.to = to;
this.data = data;
this.memo = memo;
assertThrow(issuer.objectType === ObjectType.Account, () => "not a valid account object id");
assertThrow(to.objectType === ObjectType.Account, () => "not a valid account object id");
assertThrow(id.objectType === ObjectType.Nft, () => "not a valid nft object id");
}
}