-
Notifications
You must be signed in to change notification settings - Fork 1
/
NftUpdateDataOperation.ts
35 lines (30 loc) · 1.39 KB
/
NftUpdateDataOperation.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
import { Expose, Transform } from "class-transformer";
import { Fee } from "../../DCoreClient";
import { ChainObjectToClass, ChainObjectToPlain } from "../../net/adapter/TypeAdapters";
import { assertThrow } from "../../utils/Utils";
import { ChainObject } from "../ChainObject";
import { ObjectType } from "../ObjectType";
import { BaseOperation } from "./BaseOperation";
import { OperationType } from "./OperationType";
export class NftUpdateDataOperation extends BaseOperation {
@ChainObjectToClass
@ChainObjectToPlain
@Expose({ name: "modifier" })
public readonly modifier: ChainObject;
@ChainObjectToClass
@ChainObjectToPlain
@Expose({ name: "nft_data_id" })
public readonly id: ChainObject;
@Transform((value: any, obj: NftUpdateDataOperation) => Array.from(obj.data), { toPlainOnly: true })
@Transform((value: Array<[string, any]>) => new Map(value), { toClassOnly: true })
@Expose({ name: "data" })
public data: Map<string, any>;
constructor(modifier: ChainObject, id: ChainObject, data: Map<string, any>, fee?: Fee) {
super(OperationType.NftUpdateData, fee);
this.modifier = modifier;
this.id = id;
this.data = data;
assertThrow(modifier.objectType === ObjectType.Account, () => "not a valid account object id");
assertThrow(id.objectType === ObjectType.NftData, () => "not a valid nft data object id");
}
}