forked from CodeChain-io/codechain-sdk-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathText.ts
36 lines (31 loc) · 878 Bytes
/
Text.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
import { PlatformAddress } from "codechain-primitives";
export interface TextJSON {
content: string;
certifier: string;
}
/**
* Object used when getting a text by chain_getText.
*/
export class Text {
public static fromJSON(data: TextJSON) {
const { content, certifier } = data;
return new Text({
content,
certifier: PlatformAddress.ensure(certifier)
});
}
public readonly content: string;
public readonly certifier: PlatformAddress;
constructor(data: { content: string; certifier: PlatformAddress }) {
const { content, certifier } = data;
this.content = content;
this.certifier = certifier;
}
public toJSON(): TextJSON {
const { content, certifier } = this;
return {
content,
certifier: certifier.value
};
}
}