@dorafactory/maci-sdk 0.0.1
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/README.md +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +4157 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4123 -0
- package/dist/index.mjs.map +1 -0
- package/dist/libs/const.d.ts +117 -0
- package/dist/libs/contract/config.d.ts +29 -0
- package/dist/libs/contract/contract.d.ts +37 -0
- package/dist/libs/contract/index.d.ts +1 -0
- package/dist/libs/contract/ts/AMaci.client.d.ts +216 -0
- package/dist/libs/contract/ts/AMaci.types.d.ts +203 -0
- package/dist/libs/contract/ts/Maci.client.d.ts +206 -0
- package/dist/libs/contract/ts/Maci.types.d.ts +217 -0
- package/dist/libs/contract/ts/OracleMaci.client.d.ts +206 -0
- package/dist/libs/contract/ts/OracleMaci.types.d.ts +253 -0
- package/dist/libs/contract/ts/Registry.client.d.ts +128 -0
- package/dist/libs/contract/ts/Registry.types.d.ts +110 -0
- package/dist/libs/contract/types.d.ts +50 -0
- package/dist/libs/contract/utils.d.ts +67 -0
- package/dist/libs/contract/vars.d.ts +65 -0
- package/dist/libs/errors/index.d.ts +28 -0
- package/dist/libs/errors/types.d.ts +14 -0
- package/dist/libs/http/http.d.ts +16 -0
- package/dist/libs/http/index.d.ts +1 -0
- package/dist/libs/index.d.ts +4 -0
- package/dist/libs/indexer/index.d.ts +1 -0
- package/dist/libs/indexer/indexer.d.ts +133 -0
- package/dist/libs/indexer/types.d.ts +7 -0
- package/dist/libs/query/account.d.ts +7 -0
- package/dist/libs/query/circuit.d.ts +8 -0
- package/dist/libs/query/index.d.ts +6 -0
- package/dist/libs/query/operator.d.ts +9 -0
- package/dist/libs/query/proof.d.ts +7 -0
- package/dist/libs/query/round.d.ts +11 -0
- package/dist/libs/query/transaction.d.ts +9 -0
- package/dist/maci.d.ts +151 -0
- package/dist/types/index.d.ts +254 -0
- package/dist/utils/index.d.ts +1 -0
- package/package.json +154 -0
- package/src/index.ts +11 -0
- package/src/libs/const.ts +196 -0
- package/src/libs/contract/config.ts +117 -0
- package/src/libs/contract/contract.ts +330 -0
- package/src/libs/contract/index.ts +1 -0
- package/src/libs/contract/ts/AMaci.client.ts +893 -0
- package/src/libs/contract/ts/AMaci.types.ts +252 -0
- package/src/libs/contract/ts/Maci.client.ts +906 -0
- package/src/libs/contract/ts/Maci.types.ts +263 -0
- package/src/libs/contract/ts/OracleMaci.client.ts +561 -0
- package/src/libs/contract/ts/OracleMaci.types.ts +254 -0
- package/src/libs/contract/ts/Registry.client.ts +466 -0
- package/src/libs/contract/ts/Registry.types.ts +127 -0
- package/src/libs/contract/types.ts +57 -0
- package/src/libs/contract/utils.ts +175 -0
- package/src/libs/contract/vars.ts +420 -0
- package/src/libs/errors/index.ts +122 -0
- package/src/libs/errors/types.ts +14 -0
- package/src/libs/http/http.ts +152 -0
- package/src/libs/http/index.ts +1 -0
- package/src/libs/index.ts +4 -0
- package/src/libs/indexer/index.ts +1 -0
- package/src/libs/indexer/indexer.ts +240 -0
- package/src/libs/indexer/types.ts +8 -0
- package/src/libs/query/account.ts +39 -0
- package/src/libs/query/circuit.ts +99 -0
- package/src/libs/query/index.ts +6 -0
- package/src/libs/query/operator.ts +263 -0
- package/src/libs/query/proof.ts +76 -0
- package/src/libs/query/round.ts +533 -0
- package/src/libs/query/transaction.ts +204 -0
- package/src/maci.ts +313 -0
- package/src/types/index.ts +301 -0
- package/src/utils/index.ts +44 -0
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RoundsResponse,
|
|
3
|
+
RoundResponse,
|
|
4
|
+
RoundGraphqlResponse,
|
|
5
|
+
RoundsGraphqlResponse,
|
|
6
|
+
} from '../../types';
|
|
7
|
+
import { Http } from '../../libs';
|
|
8
|
+
import { isValidAddress } from '../../utils';
|
|
9
|
+
import { handleError, ErrorType } from '../errors';
|
|
10
|
+
import { ERROR } from '../errors/types';
|
|
11
|
+
|
|
12
|
+
export class Round {
|
|
13
|
+
public http: Http;
|
|
14
|
+
|
|
15
|
+
constructor(http: Http) {
|
|
16
|
+
this.http = http;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async getRoundById(address: string): Promise<RoundResponse> {
|
|
20
|
+
try {
|
|
21
|
+
if (!isValidAddress(address)) {
|
|
22
|
+
return {
|
|
23
|
+
code: 400,
|
|
24
|
+
error: {
|
|
25
|
+
message: 'Invalid round address format',
|
|
26
|
+
type: ERROR.ERROR_ROUND_INVALID_ADDRESS,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const ROUND_QUERY = `query {
|
|
32
|
+
round(id: "${address}") {
|
|
33
|
+
id
|
|
34
|
+
blockHeight
|
|
35
|
+
txHash
|
|
36
|
+
caller
|
|
37
|
+
admin
|
|
38
|
+
operator
|
|
39
|
+
contractAddress
|
|
40
|
+
circuitName
|
|
41
|
+
timestamp
|
|
42
|
+
votingStart
|
|
43
|
+
votingEnd
|
|
44
|
+
status
|
|
45
|
+
period
|
|
46
|
+
actionType
|
|
47
|
+
roundTitle
|
|
48
|
+
roundDescription
|
|
49
|
+
roundLink
|
|
50
|
+
coordinatorPubkeyX
|
|
51
|
+
coordinatorPubkeyY
|
|
52
|
+
voteOptionMap
|
|
53
|
+
results
|
|
54
|
+
allResult
|
|
55
|
+
gasStationEnable
|
|
56
|
+
totalGrant
|
|
57
|
+
baseGrant
|
|
58
|
+
totalBond
|
|
59
|
+
circuitType
|
|
60
|
+
circuitPower
|
|
61
|
+
certificationSystem
|
|
62
|
+
codeId
|
|
63
|
+
maciType
|
|
64
|
+
voiceCreditAmount
|
|
65
|
+
preDeactivateRoot
|
|
66
|
+
identity
|
|
67
|
+
}
|
|
68
|
+
}`;
|
|
69
|
+
|
|
70
|
+
const response = await this.http.fetchGraphql<RoundGraphqlResponse>(
|
|
71
|
+
ROUND_QUERY,
|
|
72
|
+
''
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
if (!response || !response.data || !response.data.round) {
|
|
76
|
+
return {
|
|
77
|
+
code: 404,
|
|
78
|
+
error: {
|
|
79
|
+
message: `No round data found for address ${address}`,
|
|
80
|
+
type: ERROR.ERROR_ROUND_NOT_FOUND,
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
response.data.round.operatorLogoUrl = '';
|
|
86
|
+
response.data.round.operatorMoniker = '';
|
|
87
|
+
|
|
88
|
+
const identity = response.data.round.identity;
|
|
89
|
+
// try {
|
|
90
|
+
const keybaseUrl = `https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}`;
|
|
91
|
+
const keybaseResponse = await this.http.fetch(keybaseUrl);
|
|
92
|
+
const keybaseData = await keybaseResponse.json();
|
|
93
|
+
|
|
94
|
+
if (keybaseData.status.code === 0) {
|
|
95
|
+
if (keybaseData.them[0]?.pictures?.primary?.url) {
|
|
96
|
+
response.data.round.operatorLogoUrl =
|
|
97
|
+
keybaseData.them[0].pictures.primary.url;
|
|
98
|
+
}
|
|
99
|
+
if (keybaseData.them[0]?.basics?.username_cased) {
|
|
100
|
+
response.data.round.operatorMoniker =
|
|
101
|
+
keybaseData.them[0].profile.full_name;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// } catch (error) {
|
|
105
|
+
// console.error('Error fetching keybase data:', error);
|
|
106
|
+
// }
|
|
107
|
+
|
|
108
|
+
const results = JSON.parse(response.data.round.results);
|
|
109
|
+
const votes = results.map((r: string) => ({
|
|
110
|
+
v: Number(r.slice(0, -24)),
|
|
111
|
+
v2: Number(r.slice(-24)),
|
|
112
|
+
}));
|
|
113
|
+
const totalVotes = votes.reduce(
|
|
114
|
+
(s: { v: number; v2: number }, c: { v: number; v2: number }) => ({
|
|
115
|
+
v: s.v + c.v,
|
|
116
|
+
v2: s.v2 + c.v2,
|
|
117
|
+
}),
|
|
118
|
+
{ v: 0, v2: 0 }
|
|
119
|
+
);
|
|
120
|
+
const resultsList = votes.map((v: { v: number; v2: number }) => ({
|
|
121
|
+
v: totalVotes.v === 0 ? '0.0' : ((v.v / totalVotes.v) * 100).toFixed(3),
|
|
122
|
+
v2:
|
|
123
|
+
totalVotes.v2 === 0
|
|
124
|
+
? '0.0'
|
|
125
|
+
: ((v.v2 / totalVotes.v2) * 100).toFixed(3),
|
|
126
|
+
}));
|
|
127
|
+
response.data.round.resultsList = resultsList;
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
code: 200,
|
|
131
|
+
data: response.data,
|
|
132
|
+
};
|
|
133
|
+
} catch (error: any) {
|
|
134
|
+
return handleError(error as ErrorType);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async getRounds(after: string, limit?: number): Promise<RoundsResponse> {
|
|
139
|
+
try {
|
|
140
|
+
const ROUND_HISTORY_QUERY = `query ($limit: Int, $after: Cursor) {
|
|
141
|
+
rounds(first: $limit, after: $after, orderBy: [TIMESTAMP_DESC]){
|
|
142
|
+
pageInfo {
|
|
143
|
+
endCursor
|
|
144
|
+
hasNextPage
|
|
145
|
+
}
|
|
146
|
+
totalCount
|
|
147
|
+
edges {
|
|
148
|
+
node {
|
|
149
|
+
id
|
|
150
|
+
blockHeight
|
|
151
|
+
txHash
|
|
152
|
+
caller
|
|
153
|
+
admin
|
|
154
|
+
operator
|
|
155
|
+
contractAddress
|
|
156
|
+
circuitName
|
|
157
|
+
timestamp
|
|
158
|
+
votingStart
|
|
159
|
+
votingEnd
|
|
160
|
+
status
|
|
161
|
+
period
|
|
162
|
+
actionType
|
|
163
|
+
roundTitle
|
|
164
|
+
roundDescription
|
|
165
|
+
roundLink
|
|
166
|
+
coordinatorPubkeyX
|
|
167
|
+
coordinatorPubkeyY
|
|
168
|
+
voteOptionMap
|
|
169
|
+
results
|
|
170
|
+
allResult
|
|
171
|
+
gasStationEnable
|
|
172
|
+
totalGrant
|
|
173
|
+
baseGrant
|
|
174
|
+
totalBond
|
|
175
|
+
circuitType
|
|
176
|
+
circuitPower
|
|
177
|
+
certificationSystem
|
|
178
|
+
codeId
|
|
179
|
+
maciType
|
|
180
|
+
voiceCreditAmount
|
|
181
|
+
preDeactivateRoot
|
|
182
|
+
}
|
|
183
|
+
cursor
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
const response = await this.http.fetchGraphql<RoundsGraphqlResponse>(
|
|
190
|
+
ROUND_HISTORY_QUERY,
|
|
191
|
+
after,
|
|
192
|
+
limit
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
if (
|
|
196
|
+
!response ||
|
|
197
|
+
!response.data ||
|
|
198
|
+
!response.data.rounds ||
|
|
199
|
+
!response.data.rounds.edges
|
|
200
|
+
) {
|
|
201
|
+
return {
|
|
202
|
+
code: 404,
|
|
203
|
+
error: {
|
|
204
|
+
message: 'No rounds data found',
|
|
205
|
+
type: ERROR.ERROR_ROUNDS_NOT_FOUND,
|
|
206
|
+
},
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
code: 200,
|
|
212
|
+
data: response.data,
|
|
213
|
+
};
|
|
214
|
+
} catch (error) {
|
|
215
|
+
return handleError(error as ErrorType);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
async getRoundsByCircuitName(
|
|
220
|
+
circuitName: string,
|
|
221
|
+
after: string,
|
|
222
|
+
limit?: number
|
|
223
|
+
): Promise<RoundsResponse> {
|
|
224
|
+
try {
|
|
225
|
+
const ROUND_HISTORY_QUERY = `query ($limit: Int, $after: Cursor) {
|
|
226
|
+
rounds(first: $limit, after: $after, filter:{
|
|
227
|
+
circuitName:{
|
|
228
|
+
equalTo: "${circuitName}"
|
|
229
|
+
}
|
|
230
|
+
}, orderBy: [TIMESTAMP_DESC]){
|
|
231
|
+
pageInfo {
|
|
232
|
+
endCursor
|
|
233
|
+
hasNextPage
|
|
234
|
+
}
|
|
235
|
+
totalCount
|
|
236
|
+
edges {
|
|
237
|
+
cursor
|
|
238
|
+
node {
|
|
239
|
+
id
|
|
240
|
+
blockHeight
|
|
241
|
+
txHash
|
|
242
|
+
caller
|
|
243
|
+
admin
|
|
244
|
+
operator
|
|
245
|
+
contractAddress
|
|
246
|
+
circuitName
|
|
247
|
+
timestamp
|
|
248
|
+
votingStart
|
|
249
|
+
votingEnd
|
|
250
|
+
status
|
|
251
|
+
period
|
|
252
|
+
actionType
|
|
253
|
+
roundTitle
|
|
254
|
+
roundDescription
|
|
255
|
+
roundLink
|
|
256
|
+
coordinatorPubkeyX
|
|
257
|
+
coordinatorPubkeyY
|
|
258
|
+
voteOptionMap
|
|
259
|
+
results
|
|
260
|
+
allResult
|
|
261
|
+
gasStationEnable
|
|
262
|
+
totalGrant
|
|
263
|
+
baseGrant
|
|
264
|
+
totalBond
|
|
265
|
+
circuitType
|
|
266
|
+
circuitPower
|
|
267
|
+
certificationSystem
|
|
268
|
+
codeId
|
|
269
|
+
maciType
|
|
270
|
+
voiceCreditAmount
|
|
271
|
+
preDeactivateRoot
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
`;
|
|
277
|
+
|
|
278
|
+
const response = await this.http.fetchGraphql<RoundsGraphqlResponse>(
|
|
279
|
+
ROUND_HISTORY_QUERY,
|
|
280
|
+
after,
|
|
281
|
+
limit
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
if (
|
|
285
|
+
!response ||
|
|
286
|
+
!response.data ||
|
|
287
|
+
!response.data.rounds ||
|
|
288
|
+
!response.data.rounds.edges
|
|
289
|
+
) {
|
|
290
|
+
return {
|
|
291
|
+
code: 404,
|
|
292
|
+
error: {
|
|
293
|
+
message: `No rounds data found for circuit name ${circuitName}`,
|
|
294
|
+
type: ERROR.ERROR_ROUNDS_NOT_FOUND,
|
|
295
|
+
},
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
return {
|
|
300
|
+
code: 200,
|
|
301
|
+
data: response.data,
|
|
302
|
+
};
|
|
303
|
+
} catch (error: any) {
|
|
304
|
+
return handleError(error as ErrorType);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
async getRoundsByStatus(
|
|
309
|
+
status: string,
|
|
310
|
+
after: string,
|
|
311
|
+
limit?: number
|
|
312
|
+
): Promise<RoundsResponse> {
|
|
313
|
+
try {
|
|
314
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
315
|
+
let filterCondition = '';
|
|
316
|
+
|
|
317
|
+
switch (status) {
|
|
318
|
+
case 'Created':
|
|
319
|
+
filterCondition = `
|
|
320
|
+
or: [
|
|
321
|
+
{ votingStart: { equalTo: "0" } },
|
|
322
|
+
{ and: [
|
|
323
|
+
{ votingStart: { notEqualTo: "0" } },
|
|
324
|
+
{ votingStart: { greaterThan: "${currentTime.toString()}" } }
|
|
325
|
+
] }
|
|
326
|
+
]
|
|
327
|
+
`;
|
|
328
|
+
break;
|
|
329
|
+
case 'Ongoing':
|
|
330
|
+
filterCondition = `
|
|
331
|
+
or: [
|
|
332
|
+
{ votingStart: { equalTo: "0" }},
|
|
333
|
+
{ votingStart: { lessThanOrEqualTo: "${currentTime.toString()}" }, votingEnd: { greaterThan: "${currentTime.toString()}" } }
|
|
334
|
+
]
|
|
335
|
+
`;
|
|
336
|
+
break;
|
|
337
|
+
case 'Tallying':
|
|
338
|
+
filterCondition = `
|
|
339
|
+
and: [
|
|
340
|
+
{ status: { notEqualTo: "Closed" } },
|
|
341
|
+
{ votingEnd: { lessThan: "${currentTime.toString()}" } },
|
|
342
|
+
{ votingEnd: { notEqualTo: "0" } }
|
|
343
|
+
]
|
|
344
|
+
`;
|
|
345
|
+
break;
|
|
346
|
+
case 'Closed':
|
|
347
|
+
filterCondition = `status: { equalTo: "Closed" }`;
|
|
348
|
+
break;
|
|
349
|
+
default:
|
|
350
|
+
return {
|
|
351
|
+
code: 400,
|
|
352
|
+
error: {
|
|
353
|
+
message: `Invalid status: ${status}`,
|
|
354
|
+
type: ERROR.ERROR_ROUND_INVALID_STATUS,
|
|
355
|
+
},
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
const ROUND_HISTORY_QUERY = `query ($limit: Int!, $after: Cursor) {
|
|
360
|
+
rounds(first: $limit, after: $after, filter: { ${filterCondition} }, orderBy: [TIMESTAMP_DESC]) {
|
|
361
|
+
pageInfo {
|
|
362
|
+
endCursor
|
|
363
|
+
hasNextPage
|
|
364
|
+
}
|
|
365
|
+
totalCount
|
|
366
|
+
edges {
|
|
367
|
+
cursor
|
|
368
|
+
node {
|
|
369
|
+
id
|
|
370
|
+
blockHeight
|
|
371
|
+
txHash
|
|
372
|
+
caller
|
|
373
|
+
admin
|
|
374
|
+
operator
|
|
375
|
+
contractAddress
|
|
376
|
+
circuitName
|
|
377
|
+
timestamp
|
|
378
|
+
votingStart
|
|
379
|
+
votingEnd
|
|
380
|
+
status
|
|
381
|
+
period
|
|
382
|
+
actionType
|
|
383
|
+
roundTitle
|
|
384
|
+
roundDescription
|
|
385
|
+
roundLink
|
|
386
|
+
coordinatorPubkeyX
|
|
387
|
+
coordinatorPubkeyY
|
|
388
|
+
voteOptionMap
|
|
389
|
+
results
|
|
390
|
+
allResult
|
|
391
|
+
gasStationEnable
|
|
392
|
+
totalGrant
|
|
393
|
+
baseGrant
|
|
394
|
+
totalBond
|
|
395
|
+
circuitType
|
|
396
|
+
circuitPower
|
|
397
|
+
certificationSystem
|
|
398
|
+
codeId
|
|
399
|
+
maciType
|
|
400
|
+
voiceCreditAmount
|
|
401
|
+
preDeactivateRoot
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}`;
|
|
406
|
+
|
|
407
|
+
const response = await this.http.fetchGraphql<RoundsGraphqlResponse>(
|
|
408
|
+
ROUND_HISTORY_QUERY,
|
|
409
|
+
after,
|
|
410
|
+
limit
|
|
411
|
+
);
|
|
412
|
+
if (
|
|
413
|
+
!response ||
|
|
414
|
+
!response.data ||
|
|
415
|
+
!response.data.rounds ||
|
|
416
|
+
!response.data.rounds.edges
|
|
417
|
+
) {
|
|
418
|
+
return {
|
|
419
|
+
code: 404,
|
|
420
|
+
error: {
|
|
421
|
+
message: `No rounds data found for status ${status}`,
|
|
422
|
+
type: ERROR.ERROR_ROUNDS_NOT_FOUND,
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
return {
|
|
428
|
+
code: 200,
|
|
429
|
+
data: response.data,
|
|
430
|
+
};
|
|
431
|
+
} catch (error: any) {
|
|
432
|
+
return handleError(error as ErrorType);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async getRoundsByOperator(
|
|
437
|
+
operator: string,
|
|
438
|
+
after: string,
|
|
439
|
+
limit?: number
|
|
440
|
+
): Promise<RoundsResponse> {
|
|
441
|
+
try {
|
|
442
|
+
if (!isValidAddress(operator)) {
|
|
443
|
+
return {
|
|
444
|
+
code: 400,
|
|
445
|
+
error: {
|
|
446
|
+
message: 'Invalid operator address format',
|
|
447
|
+
type: ERROR.ERROR_OPERATOR_INVALID_ADDRESS,
|
|
448
|
+
},
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
const ROUND_HISTORY_QUERY = `query ($limit: Int!, $after: Cursor) {
|
|
453
|
+
rounds(first: $limit, after: $after, filter:{
|
|
454
|
+
operator:{
|
|
455
|
+
equalTo: "${operator}"
|
|
456
|
+
}
|
|
457
|
+
}, orderBy: [TIMESTAMP_DESC]){
|
|
458
|
+
pageInfo {
|
|
459
|
+
endCursor
|
|
460
|
+
hasNextPage
|
|
461
|
+
}
|
|
462
|
+
totalCount
|
|
463
|
+
edges {
|
|
464
|
+
cursor
|
|
465
|
+
node {
|
|
466
|
+
id
|
|
467
|
+
blockHeight
|
|
468
|
+
txHash
|
|
469
|
+
caller
|
|
470
|
+
admin
|
|
471
|
+
operator
|
|
472
|
+
contractAddress
|
|
473
|
+
circuitName
|
|
474
|
+
timestamp
|
|
475
|
+
votingStart
|
|
476
|
+
votingEnd
|
|
477
|
+
status
|
|
478
|
+
period
|
|
479
|
+
actionType
|
|
480
|
+
roundTitle
|
|
481
|
+
roundDescription
|
|
482
|
+
roundLink
|
|
483
|
+
coordinatorPubkeyX
|
|
484
|
+
coordinatorPubkeyY
|
|
485
|
+
voteOptionMap
|
|
486
|
+
results
|
|
487
|
+
allResult
|
|
488
|
+
gasStationEnable
|
|
489
|
+
totalGrant
|
|
490
|
+
baseGrant
|
|
491
|
+
totalBond
|
|
492
|
+
circuitType
|
|
493
|
+
circuitPower
|
|
494
|
+
certificationSystem
|
|
495
|
+
codeId
|
|
496
|
+
maciType
|
|
497
|
+
voiceCreditAmount
|
|
498
|
+
preDeactivateRoot
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}`;
|
|
503
|
+
|
|
504
|
+
const response = await this.http.fetchGraphql<RoundsGraphqlResponse>(
|
|
505
|
+
ROUND_HISTORY_QUERY,
|
|
506
|
+
after,
|
|
507
|
+
limit
|
|
508
|
+
);
|
|
509
|
+
|
|
510
|
+
if (
|
|
511
|
+
!response ||
|
|
512
|
+
!response.data ||
|
|
513
|
+
!response.data.rounds ||
|
|
514
|
+
!response.data.rounds.edges
|
|
515
|
+
) {
|
|
516
|
+
return {
|
|
517
|
+
code: 404,
|
|
518
|
+
error: {
|
|
519
|
+
message: `No rounds data found for operator ${operator}`,
|
|
520
|
+
type: ERROR.ERROR_ROUNDS_NOT_FOUND,
|
|
521
|
+
},
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return {
|
|
526
|
+
code: 200,
|
|
527
|
+
data: response.data,
|
|
528
|
+
};
|
|
529
|
+
} catch (error: any) {
|
|
530
|
+
return handleError(error as ErrorType);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
}
|