-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathMessageTopic.ts
125 lines (112 loc) · 2.81 KB
/
MessageTopic.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import { jsonObject, jsonMember } from 'typedjson';
import { Hash } from './key';
import { ModuleBytes } from './ExecutableDeployItem';
/**
* Represents a summary of a message topic, including the number of messages and block time.
*/
@jsonObject
export class MessageTopicSummary {
/**
* The total number of messages in this topic.
*/
@jsonMember({ name: 'message_count', constructor: Number })
messageCount: number;
/**
* The block time associated with the topic.
*/
@jsonMember({ name: 'blocktime', constructor: Number })
blockTime: number;
}
/**
* Represents a checksum for a message, stored as a string.
*/
export type MessageChecksum = string;
/**
* Represents a message topic, including the topic name and its hash.
*/
@jsonObject
export class MessageTopic {
/**
* The name of the message topic.
*/
@jsonMember({ name: 'topic_name', constructor: String })
topicName: string;
/**
* The hash of the message topic name.
*/
@jsonMember({
name: 'topic_name_hash',
constructor: Hash,
deserializer: json => Hash.fromJSON(json),
serializer: value => value.toJSON()
})
topicNameHash: Hash;
}
/**
* Represents the payload of a message, which can either be a string or bytes.
*/
@jsonObject
export class MessagePayload {
/**
* The string payload of the message, if available.
*/
@jsonMember({ name: 'String', constructor: String })
string?: string;
/**
* The bytes payload of the message, if available.
*/
@jsonMember({
name: 'Bytes',
constructor: ModuleBytes
})
bytes?: ModuleBytes;
}
/**
* Represents a message with a payload, topic, and related metadata.
*/
@jsonObject
export class Message {
/**
* The payload of the message, which can either be a string or bytes.
*/
@jsonMember({
name: 'message',
constructor: MessagePayload
})
message: MessagePayload;
/**
* The name of the topic associated with this message.
*/
@jsonMember({ name: 'topic_name', constructor: String })
topicName: string;
/**
* The hash of the topic name, which is used to identify the topic.
*/
@jsonMember({
name: 'topic_name_hash',
constructor: Hash,
deserializer: json => Hash.fromJSON(json),
serializer: value => value.toJSON()
})
topicNameHash: Hash;
/**
* The entity address associated with the message, often the sender or origin.
*/
@jsonMember({
name: 'hash_addr',
constructor: Hash,
deserializer: json => Hash.fromJSON(json),
serializer: value => value.toJSON()
})
hashAddr: Hash;
/**
* The index of the block where the message was included.
*/
@jsonMember({ name: 'block_index', constructor: Number })
blockIndex: number;
/**
* The index of the topic within the block.
*/
@jsonMember({ name: 'topic_index', constructor: Number })
topicIndex: number;
}