trac-peer 0.0.89 → 0.0.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api.js +93 -110
- package/src/protocol.js +1 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -4,180 +4,163 @@ export class ProtocolApi{
|
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
async getAdmin(signed = true){
|
|
7
|
-
|
|
8
|
-
if(true
|
|
9
|
-
|
|
10
|
-
if(null !== res)
|
|
11
|
-
return res.value
|
|
12
|
-
}
|
|
7
|
+
let res = null;
|
|
8
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('admin');
|
|
9
|
+
if(false === signed) res = await this.peer.protocol_instance.get('admin');
|
|
10
|
+
if(null !== res) return res;
|
|
13
11
|
return null;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
async getWhitelistEnabled(signed = true){
|
|
17
|
-
|
|
18
|
-
if(true
|
|
19
|
-
|
|
20
|
-
if(null !== res)
|
|
21
|
-
return res.value
|
|
22
|
-
}
|
|
15
|
+
let res = null;
|
|
16
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('wlst');
|
|
17
|
+
if(false === signed) res = await this.peer.protocol_instance.get('wlst');
|
|
18
|
+
if(null !== res) return res;
|
|
23
19
|
return false;
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
async getWhitelistStatus(address, signed = true){
|
|
27
|
-
|
|
28
|
-
if(true
|
|
29
|
-
|
|
30
|
-
if(null !== res)
|
|
31
|
-
return res.value
|
|
32
|
-
}
|
|
23
|
+
let res = null;
|
|
24
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('wl/'+address);
|
|
25
|
+
if(false === signed) res = await this.peer.protocol_instance.get('wl/'+address);
|
|
26
|
+
if(null !== res) return res;
|
|
33
27
|
return false;
|
|
34
28
|
}
|
|
35
29
|
|
|
36
30
|
async getModStatus(address, signed = true){
|
|
37
|
-
|
|
38
|
-
if(true
|
|
39
|
-
|
|
40
|
-
if(null !== res)
|
|
41
|
-
return res.value
|
|
42
|
-
}
|
|
31
|
+
let res = null;
|
|
32
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('mod/'+address);
|
|
33
|
+
if(false === signed) res = await this.peer.protocol_instance.get('mod/'+address);
|
|
34
|
+
if(null !== res) return res;
|
|
43
35
|
return false;
|
|
44
36
|
}
|
|
45
37
|
|
|
46
38
|
async getMuteStatus(address, signed = true){
|
|
47
|
-
|
|
48
|
-
if(true
|
|
49
|
-
|
|
50
|
-
if(null !== res)
|
|
51
|
-
return res.value
|
|
52
|
-
}
|
|
39
|
+
let res = null;
|
|
40
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('mtd/'+address);
|
|
41
|
+
if(false === signed) res = await this.peer.protocol_instance.get('mtd/'+address);
|
|
42
|
+
if(null !== res) return res;
|
|
53
43
|
return false;
|
|
54
44
|
}
|
|
55
45
|
|
|
56
46
|
async getAutoAddWritersStatus(signed = true){
|
|
57
|
-
|
|
58
|
-
if(true
|
|
59
|
-
|
|
47
|
+
let res = null;
|
|
48
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('auto_add_writers');
|
|
49
|
+
if(false === signed) res = await this.peer.protocol_instance.get('auto_add_writers');
|
|
60
50
|
if(null !== res) {
|
|
61
|
-
return res
|
|
51
|
+
return res === 'on';
|
|
62
52
|
}
|
|
63
53
|
return false;
|
|
64
54
|
}
|
|
65
55
|
|
|
66
56
|
async getChatStatus(signed = true){
|
|
67
|
-
|
|
68
|
-
if(true
|
|
69
|
-
|
|
57
|
+
let res = null;
|
|
58
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('chat_status');
|
|
59
|
+
if(false === signed) res = await this.peer.protocol_instance.get('chat_status');
|
|
70
60
|
if(null !== res) {
|
|
71
|
-
return res
|
|
61
|
+
return res === 'on';
|
|
72
62
|
}
|
|
73
63
|
return false;
|
|
74
64
|
}
|
|
75
65
|
|
|
76
66
|
async getAddressFromNick(nick, signed = true){
|
|
77
|
-
|
|
78
|
-
if(true
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
67
|
+
let res = null;
|
|
68
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('kcin/'+nick);
|
|
69
|
+
if(false === signed) res = await this.peer.protocol_instance.get('kcin/'+nick);
|
|
70
|
+
console.log(JSON.stringify(res));
|
|
71
|
+
return res;
|
|
84
72
|
}
|
|
85
73
|
|
|
86
74
|
async getNick(address, signed = true){
|
|
87
|
-
|
|
88
|
-
if(true
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
return null;
|
|
75
|
+
let res = null;
|
|
76
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('nick/'+address);
|
|
77
|
+
if(false === signed) res = await this.peer.protocol_instance.get('nick/'+address);
|
|
78
|
+
console.log(JSON.stringify(res));
|
|
79
|
+
return res;
|
|
94
80
|
}
|
|
95
81
|
|
|
96
82
|
async getDeletedMessageLength(signed = true){
|
|
97
|
-
|
|
98
|
-
if(true
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return 0;
|
|
83
|
+
let res = null;
|
|
84
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('delml');
|
|
85
|
+
if(false === signed) res = await this.peer.protocol_instance.get('delml');
|
|
86
|
+
res = res !== null ? res : 0;
|
|
87
|
+
console.log(JSON.stringify(res));
|
|
88
|
+
return res;
|
|
104
89
|
}
|
|
105
90
|
|
|
106
91
|
async getDeletedMessage(index, signed = true){
|
|
107
|
-
|
|
108
|
-
if(true
|
|
109
|
-
|
|
110
|
-
|
|
92
|
+
let res = null;
|
|
93
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('delm/'+parseInt(index));
|
|
94
|
+
if(false === signed) res = await this.peer.protocol_instance.get('delm/'+parseInt(index));
|
|
95
|
+
if(null === res) {
|
|
96
|
+
console.log(JSON.stringify(null));
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
return await this.getMessage(res, signed);
|
|
111
100
|
}
|
|
112
101
|
|
|
113
102
|
async getMessageLength(signed = true){
|
|
114
|
-
|
|
115
|
-
if(true
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return 0;
|
|
103
|
+
let res = null;
|
|
104
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('msgl');
|
|
105
|
+
if(false === signed) res = await this.peer.protocol_instance.get('msgl');
|
|
106
|
+
res = res !== null ? res : 0;
|
|
107
|
+
console.log(JSON.stringify(res));
|
|
108
|
+
return res;
|
|
121
109
|
}
|
|
122
110
|
|
|
123
111
|
async getMessage(index, signed = true){
|
|
124
|
-
|
|
125
|
-
if(true
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
return null;
|
|
112
|
+
let res = null;
|
|
113
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('msg/'+parseInt(index));
|
|
114
|
+
if(false === signed) res = await this.peer.protocol_instance.get('msg/'+parseInt(index));
|
|
115
|
+
console.log(JSON.stringify(res));
|
|
116
|
+
return res;
|
|
131
117
|
}
|
|
132
118
|
|
|
133
119
|
async getUserMessageLength(address, signed = true){
|
|
134
|
-
|
|
135
|
-
if(true
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return 0;
|
|
120
|
+
let res = null;
|
|
121
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('umsgl/'+address);
|
|
122
|
+
if(false === signed) res = await this.peer.protocol_instance.get('umsgl/'+address);
|
|
123
|
+
res = res !== null ? res : 0;
|
|
124
|
+
console.log(JSON.stringify(res));
|
|
125
|
+
return res;
|
|
141
126
|
}
|
|
142
127
|
|
|
143
128
|
async getUserMessage(address, index, signed = true){
|
|
144
|
-
|
|
145
|
-
if(true
|
|
146
|
-
|
|
147
|
-
if(null === res)
|
|
148
|
-
|
|
129
|
+
let res = null;
|
|
130
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('umsg/'+address+'/'+parseInt(index));
|
|
131
|
+
if(false === signed) res = await this.peer.protocol_instance.get('umsg/'+address+'/'+parseInt(index));
|
|
132
|
+
if(null === res) {
|
|
133
|
+
console.log(JSON.stringify(null));
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
return await this.getMessage(res, signed);
|
|
149
137
|
}
|
|
150
138
|
|
|
151
139
|
async getTxLength(signed = true){
|
|
152
|
-
|
|
153
|
-
if(true
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
return 0;
|
|
140
|
+
let res = null;
|
|
141
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('txl');
|
|
142
|
+
if(false === signed) res = await this.peer.protocol_instance.get('txl');
|
|
143
|
+
res = res !== null ? res : 0;
|
|
144
|
+
console.log(JSON.stringify(res));
|
|
145
|
+
return res;
|
|
159
146
|
}
|
|
160
147
|
|
|
161
148
|
async getTx(index, signed = true){
|
|
162
|
-
|
|
163
|
-
if(true
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
return null;
|
|
149
|
+
let res = null;
|
|
150
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('txi/'+parseInt(index));
|
|
151
|
+
if(false === signed) res = await this.peer.protocol_instance.get('txi/'+parseInt(index));
|
|
152
|
+
console.log(JSON.stringify(res));
|
|
153
|
+
return res;
|
|
169
154
|
}
|
|
170
155
|
|
|
171
156
|
async getTxData(index, signed = true){
|
|
172
|
-
const get = this.peer.protocol_instance.getSigned;
|
|
173
|
-
if(true !== signed) this.peer.protocol_instance.get;
|
|
174
157
|
const tx = await this.getTx(index, signed);
|
|
175
158
|
if(null === tx) return null;
|
|
176
|
-
|
|
177
|
-
if(
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
return
|
|
159
|
+
let res = null;
|
|
160
|
+
if(true === signed) res = await this.peer.protocol_instance.getSigned('tx/'+tx);
|
|
161
|
+
if(false === signed) res = await this.peer.protocol_instance.get('tx/'+tx);
|
|
162
|
+
console.log(JSON.stringify(res));
|
|
163
|
+
return res;
|
|
181
164
|
}
|
|
182
165
|
}
|
|
183
166
|
|
package/src/protocol.js
CHANGED
|
@@ -3,6 +3,7 @@ import {ProtocolApi} from './api.js';
|
|
|
3
3
|
|
|
4
4
|
class Protocol{
|
|
5
5
|
constructor(options = {}) {
|
|
6
|
+
this.api = new ProtocolApi({ peer : options.peer });
|
|
6
7
|
this.base = options.base || null;
|
|
7
8
|
this.peer = options.peer || null;
|
|
8
9
|
this.options = options;
|
|
@@ -13,7 +14,6 @@ class Protocol{
|
|
|
13
14
|
this.nonce = 0;
|
|
14
15
|
this.prepared_transactions_content = {};
|
|
15
16
|
this.features = {};
|
|
16
|
-
this.api = new ProtocolApi({ peer : this.peer });
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
safeBigInt(value) {
|