@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.
Files changed (74) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +11 -0
  3. package/dist/index.js +4157 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +4123 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/dist/libs/const.d.ts +117 -0
  8. package/dist/libs/contract/config.d.ts +29 -0
  9. package/dist/libs/contract/contract.d.ts +37 -0
  10. package/dist/libs/contract/index.d.ts +1 -0
  11. package/dist/libs/contract/ts/AMaci.client.d.ts +216 -0
  12. package/dist/libs/contract/ts/AMaci.types.d.ts +203 -0
  13. package/dist/libs/contract/ts/Maci.client.d.ts +206 -0
  14. package/dist/libs/contract/ts/Maci.types.d.ts +217 -0
  15. package/dist/libs/contract/ts/OracleMaci.client.d.ts +206 -0
  16. package/dist/libs/contract/ts/OracleMaci.types.d.ts +253 -0
  17. package/dist/libs/contract/ts/Registry.client.d.ts +128 -0
  18. package/dist/libs/contract/ts/Registry.types.d.ts +110 -0
  19. package/dist/libs/contract/types.d.ts +50 -0
  20. package/dist/libs/contract/utils.d.ts +67 -0
  21. package/dist/libs/contract/vars.d.ts +65 -0
  22. package/dist/libs/errors/index.d.ts +28 -0
  23. package/dist/libs/errors/types.d.ts +14 -0
  24. package/dist/libs/http/http.d.ts +16 -0
  25. package/dist/libs/http/index.d.ts +1 -0
  26. package/dist/libs/index.d.ts +4 -0
  27. package/dist/libs/indexer/index.d.ts +1 -0
  28. package/dist/libs/indexer/indexer.d.ts +133 -0
  29. package/dist/libs/indexer/types.d.ts +7 -0
  30. package/dist/libs/query/account.d.ts +7 -0
  31. package/dist/libs/query/circuit.d.ts +8 -0
  32. package/dist/libs/query/index.d.ts +6 -0
  33. package/dist/libs/query/operator.d.ts +9 -0
  34. package/dist/libs/query/proof.d.ts +7 -0
  35. package/dist/libs/query/round.d.ts +11 -0
  36. package/dist/libs/query/transaction.d.ts +9 -0
  37. package/dist/maci.d.ts +151 -0
  38. package/dist/types/index.d.ts +254 -0
  39. package/dist/utils/index.d.ts +1 -0
  40. package/package.json +154 -0
  41. package/src/index.ts +11 -0
  42. package/src/libs/const.ts +196 -0
  43. package/src/libs/contract/config.ts +117 -0
  44. package/src/libs/contract/contract.ts +330 -0
  45. package/src/libs/contract/index.ts +1 -0
  46. package/src/libs/contract/ts/AMaci.client.ts +893 -0
  47. package/src/libs/contract/ts/AMaci.types.ts +252 -0
  48. package/src/libs/contract/ts/Maci.client.ts +906 -0
  49. package/src/libs/contract/ts/Maci.types.ts +263 -0
  50. package/src/libs/contract/ts/OracleMaci.client.ts +561 -0
  51. package/src/libs/contract/ts/OracleMaci.types.ts +254 -0
  52. package/src/libs/contract/ts/Registry.client.ts +466 -0
  53. package/src/libs/contract/ts/Registry.types.ts +127 -0
  54. package/src/libs/contract/types.ts +57 -0
  55. package/src/libs/contract/utils.ts +175 -0
  56. package/src/libs/contract/vars.ts +420 -0
  57. package/src/libs/errors/index.ts +122 -0
  58. package/src/libs/errors/types.ts +14 -0
  59. package/src/libs/http/http.ts +152 -0
  60. package/src/libs/http/index.ts +1 -0
  61. package/src/libs/index.ts +4 -0
  62. package/src/libs/indexer/index.ts +1 -0
  63. package/src/libs/indexer/indexer.ts +240 -0
  64. package/src/libs/indexer/types.ts +8 -0
  65. package/src/libs/query/account.ts +39 -0
  66. package/src/libs/query/circuit.ts +99 -0
  67. package/src/libs/query/index.ts +6 -0
  68. package/src/libs/query/operator.ts +263 -0
  69. package/src/libs/query/proof.ts +76 -0
  70. package/src/libs/query/round.ts +533 -0
  71. package/src/libs/query/transaction.ts +204 -0
  72. package/src/maci.ts +313 -0
  73. package/src/types/index.ts +301 -0
  74. package/src/utils/index.ts +44 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,4123 @@
1
+ // src/libs/errors/index.ts
2
+ var BaseError = class extends Error {
3
+ constructor(message, code, type) {
4
+ super(message);
5
+ this.code = code;
6
+ this.type = type;
7
+ this.name = this.constructor.name;
8
+ }
9
+ };
10
+ var HttpError = class extends BaseError {
11
+ constructor(message, code) {
12
+ super(message, code, "ERROR_HTTP");
13
+ }
14
+ };
15
+ var GraphQLError = class extends BaseError {
16
+ constructor(message) {
17
+ super(message, 400, "ERROR_GRAPHQL");
18
+ }
19
+ };
20
+ var ValidationError = class extends BaseError {
21
+ constructor(message) {
22
+ super(message, 400, "ERROR_VALIDATION");
23
+ }
24
+ };
25
+ var NotFoundError = class extends BaseError {
26
+ constructor(message) {
27
+ super(message, 404, "ERROR_NOT_FOUND");
28
+ }
29
+ };
30
+ var ParseError = class extends BaseError {
31
+ constructor(message) {
32
+ super(message, 500, "ERROR_PARSE");
33
+ }
34
+ };
35
+ function handleError(error) {
36
+ if (!(error instanceof Error)) {
37
+ return {
38
+ code: 500,
39
+ error: {
40
+ message: "Unknown error occurred",
41
+ type: `ERROR_UNKNOWN`
42
+ }
43
+ };
44
+ }
45
+ switch (true) {
46
+ case error instanceof HttpError:
47
+ return {
48
+ code: error.code,
49
+ error: {
50
+ message: error.message,
51
+ type: "ERROR_HTTP"
52
+ }
53
+ };
54
+ case error instanceof GraphQLError:
55
+ return {
56
+ code: 400,
57
+ error: {
58
+ message: error.message,
59
+ type: "ERROR_GRAPHQL"
60
+ }
61
+ };
62
+ case error instanceof ValidationError:
63
+ return {
64
+ code: 400,
65
+ error: {
66
+ message: error.message,
67
+ type: "ERROR_VALIDATION"
68
+ }
69
+ };
70
+ case error instanceof NotFoundError:
71
+ return {
72
+ code: 404,
73
+ error: {
74
+ message: error.message,
75
+ type: "ERROR_NOT_FOUND"
76
+ }
77
+ };
78
+ case error instanceof ParseError:
79
+ return {
80
+ code: 500,
81
+ error: {
82
+ message: error.message,
83
+ type: "ERROR_PARSE"
84
+ }
85
+ };
86
+ case error instanceof BaseError:
87
+ return {
88
+ code: error.code,
89
+ error: {
90
+ message: error.message,
91
+ type: error.type
92
+ }
93
+ };
94
+ default:
95
+ return {
96
+ code: 500,
97
+ error: {
98
+ message: error.message || "Internal server error",
99
+ type: "ERROR_UNKNOWN"
100
+ }
101
+ };
102
+ }
103
+ }
104
+
105
+ // src/libs/http/http.ts
106
+ var Http = class {
107
+ constructor(apiEndpoint, restEndpoint, customFetch, defaultOptions) {
108
+ this.customFetch = customFetch;
109
+ this.apiEndpoint = apiEndpoint;
110
+ this.restEndpoint = restEndpoint;
111
+ this.defaultOptions = defaultOptions;
112
+ }
113
+ getFetch() {
114
+ return this.customFetch || fetch;
115
+ }
116
+ async fetch(url) {
117
+ try {
118
+ const fetchFn = this.getFetch();
119
+ const response = await fetchFn(url, {
120
+ ...this.defaultOptions
121
+ });
122
+ if (!response.ok) {
123
+ throw new HttpError(
124
+ `HTTP error! status: ${response.status}`,
125
+ response.status
126
+ );
127
+ }
128
+ return response;
129
+ } catch (error) {
130
+ if (error instanceof HttpError) {
131
+ throw error;
132
+ }
133
+ throw new HttpError(`Failed to fetch: ${error.message}`, 500);
134
+ }
135
+ }
136
+ async fetchGraphql(query, after, limit = 10) {
137
+ try {
138
+ const isFirstPage = after === "first";
139
+ const fetchFn = this.getFetch();
140
+ const response = await fetchFn(this.apiEndpoint, {
141
+ method: "POST",
142
+ headers: {
143
+ "Content-Type": "application/json",
144
+ Accept: "application/json"
145
+ },
146
+ body: JSON.stringify({
147
+ query,
148
+ variables: { limit, after: isFirstPage ? void 0 : after }
149
+ }),
150
+ ...this.defaultOptions
151
+ });
152
+ if (!response.ok) {
153
+ const errorData = await response.json();
154
+ if (errorData.errors?.[0]?.message?.includes("Syntax Error")) {
155
+ throw new GraphQLError(
156
+ `GraphQL syntax error: ${errorData.errors[0].message}`
157
+ );
158
+ }
159
+ if (errorData.errors?.length > 0) {
160
+ throw new GraphQLError(
161
+ errorData.errors[0].message || "Unknown GraphQL error"
162
+ );
163
+ }
164
+ throw new HttpError(
165
+ `HTTP error: ${JSON.stringify(errorData)}`,
166
+ response.status
167
+ );
168
+ }
169
+ const data = await response.json();
170
+ if (data.errors) {
171
+ throw new GraphQLError(
172
+ data.errors[0]?.message || "GraphQL query failed"
173
+ );
174
+ }
175
+ return data;
176
+ } catch (error) {
177
+ if (error instanceof BaseError) {
178
+ throw error;
179
+ }
180
+ if (error instanceof SyntaxError) {
181
+ throw new ParseError("Failed to parse JSON response");
182
+ }
183
+ throw new HttpError(
184
+ `Failed to fetch GraphQL: ${error.message}`,
185
+ 500
186
+ );
187
+ }
188
+ }
189
+ async fetchRest(path) {
190
+ try {
191
+ const fetchFn = this.getFetch();
192
+ const response = await fetchFn(`${this.restEndpoint}${path}`, {
193
+ ...this.defaultOptions
194
+ });
195
+ if (!response.ok) {
196
+ throw new HttpError(
197
+ `HTTP error! status: ${response.status}`,
198
+ response.status
199
+ );
200
+ }
201
+ try {
202
+ return await response.json();
203
+ } catch (error) {
204
+ throw new ParseError("Failed to parse JSON response");
205
+ }
206
+ } catch (error) {
207
+ if (error instanceof BaseError) {
208
+ throw error;
209
+ }
210
+ throw new HttpError(
211
+ `Failed to fetch REST: ${error.message}`,
212
+ 500
213
+ );
214
+ }
215
+ }
216
+ };
217
+
218
+ // src/libs/errors/types.ts
219
+ var ERROR = {
220
+ ERROR_ADDRESS_NOT_FOUND: "ERROR_ADDRESS_NOT_FOUND",
221
+ ERROR_CIRCUIT_NOT_FOUND: "ERROR_CIRCUIT_NOT_FOUND",
222
+ ERROR_OPERATOR_INVALID_ADDRESS: "ERROR_OPERATOR_INVALID_ADDRESS",
223
+ ERROR_OPERATOR_NOT_FOUND: "ERROR_OPERATOR_NOT_FOUND",
224
+ ERROR_OPERATORS_NOT_FOUND: "ERROR_OPERATORS_NOT_FOUND",
225
+ ERROR_PROOF_NOT_FOUND: "ERROR_PROOF_NOT_FOUND",
226
+ ERROR_ROUND_INVALID_ADDRESS: "ERROR_ROUND_INVALID_ADDRESS",
227
+ ERROR_ROUND_INVALID_STATUS: "ERROR_ROUND_INVALID_STATUS",
228
+ ERROR_ROUND_NOT_FOUND: "ERROR_ROUND_NOT_FOUND",
229
+ ERROR_ROUNDS_NOT_FOUND: "ERROR_ROUNDS_NOT_FOUND",
230
+ ERROR_TRANSACTION_NOT_FOUND: "ERROR_TRANSACTION_NOT_FOUND",
231
+ ERROR_TRANSACTIONS_NOT_FOUND: "ERROR_TRANSACTIONS_NOT_FOUND"
232
+ };
233
+
234
+ // src/libs/query/account.ts
235
+ var Account = class {
236
+ constructor(http) {
237
+ this.http = http;
238
+ }
239
+ async balanceOf(address) {
240
+ try {
241
+ const path = `/cosmos/bank/v1beta1/balances/${address}/by_denom?denom=peaka`;
242
+ const data = await this.http.fetchRest(path);
243
+ if (data["code"] === void 0) {
244
+ const response = {
245
+ code: 200,
246
+ data: {
247
+ balance: data["balance"]["amount"]
248
+ }
249
+ };
250
+ return response;
251
+ } else {
252
+ return {
253
+ code: 404,
254
+ error: {
255
+ message: "Address not found",
256
+ type: ERROR.ERROR_ADDRESS_NOT_FOUND
257
+ }
258
+ };
259
+ }
260
+ } catch (error) {
261
+ return handleError(error);
262
+ }
263
+ }
264
+ };
265
+
266
+ // src/libs/const.ts
267
+ var circuits = {
268
+ "maci-1p1v": {
269
+ maciType: "MACI",
270
+ circuitType: "1p1v",
271
+ displayName: "MACI-1p1v",
272
+ repoUrl: "https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/maci",
273
+ zipUrl: "https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip"
274
+ },
275
+ "maci-qv": {
276
+ maciType: "MACI",
277
+ circuitType: "QV",
278
+ displayName: "MACI-QV",
279
+ repoUrl: "https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/maci",
280
+ zipUrl: "https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip"
281
+ },
282
+ "amaci-1p1v": {
283
+ maciType: "aMACI",
284
+ circuitType: "1p1v",
285
+ displayName: "aMACI-1p1v",
286
+ repoUrl: "https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/amaci",
287
+ zipUrl: "https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip"
288
+ },
289
+ "amaci-qv": {
290
+ maciType: "aMACI",
291
+ circuitType: "QV",
292
+ displayName: "aMACI-QV",
293
+ repoUrl: "https://github.com/DoraFactory/Vota-Circuits/tree/main/circuits/amaci",
294
+ zipUrl: "https://github.com/DoraFactory/Vota-Circuits/archive/refs/heads/main.zip"
295
+ }
296
+ };
297
+ var validator_operator_set = {
298
+ doravaloper12yk434ut3un4wx0rult2aww89rsrel8nhmp387: {
299
+ operator_address: "",
300
+ account_address: "dora12yk434ut3un4wx0rult2aww89rsrel8nydy83p",
301
+ allocation: "22571615985356796592128",
302
+ allocation_dora: 22571.615985356795,
303
+ moniker: "\u{1D425}\u{1D41E}\u{1D42C}\u{1D427}\u{1D422}\u{1D424} | \u{1D414}\u{1D413}\u{1D412}\u{1D400}",
304
+ program_voting_power: 0.06432895760166438,
305
+ tokens: "200731587709257889972292"
306
+ },
307
+ doravaloper15frh0nn3v4yp3vv6sk4pn6jg9l8rt82f7uqfk5: {
308
+ operator_address: "",
309
+ account_address: "dora15frh0nn3v4yp3vv6sk4pn6jg9l8rt82fd29lqt",
310
+ allocation: "33745159209325474873344",
311
+ allocation_dora: 33745.15920932547,
312
+ moniker: "NomadValidator",
313
+ program_voting_power: 0.09617348254756773,
314
+ tokens: "300099000000000000000000"
315
+ },
316
+ doravaloper1ddewp74vd2w8jhth2p0uazmc8ajgtcuf3ntqgn: {
317
+ operator_address: "",
318
+ account_address: "dora1ddewp74vd2w8jhth2p0uazmc8ajgtcufz9wk7v",
319
+ allocation: "40789397021635754590208",
320
+ allocation_dora: 40789.397021635756,
321
+ moniker: "polkachu.com",
322
+ program_voting_power: 0.11624951413777938,
323
+ tokens: "362744095556470434789338"
324
+ },
325
+ doravaloper1gh8j89jtc2vx6d3y4ehllcdlvluwa49w6xmjsm: {
326
+ operator_address: "",
327
+ account_address: "dora1gh8j89jtc2vx6d3y4ehllcdlvluwa49wfs7yxy",
328
+ allocation: "33743029941764137943040",
329
+ allocation_dora: 33743.029941764136,
330
+ moniker: "ITRocket",
331
+ program_voting_power: 0.09616741414897524,
332
+ tokens: "300080064215405665352721"
333
+ },
334
+ doravaloper1j8ru7p8zctup6grfwuga6ndrjj7v88wzn407x7: {
335
+ operator_address: "",
336
+ account_address: "dora1j8ru7p8zctup6grfwuga6ndrjj7v88wzqr2gsp",
337
+ allocation: "22646525272055477174272",
338
+ allocation_dora: 22646.525272055478,
339
+ moniker: "StakeUs",
340
+ program_voting_power: 0.06454244857772638,
341
+ tokens: "201397763319500000000000"
342
+ },
343
+ doravaloper1l5zz0kkjt2n7nllsrymy96mc2v2gehda0zc85s: {
344
+ operator_address: "",
345
+ account_address: "dora1l5zz0kkjt2n7nllsrymy96mc2v2gehdau5a3z0",
346
+ allocation: "22622846742220005965824",
347
+ allocation_dora: 22622.846742220005,
348
+ moniker: "BlackNodes",
349
+ program_voting_power: 0.06447496492290769,
350
+ tokens: "201187187838702364379121"
351
+ },
352
+ doravaloper1m9v3txhhtadjxpv09gwjhhs344qsxgfscwxjkg: {
353
+ operator_address: "",
354
+ account_address: "dora1m9v3txhhtadjxpv09gwjhhs344qsxgfstcryqh",
355
+ allocation: "22549006983854435598336",
356
+ allocation_dora: 22549.006983854437,
357
+ moniker: "\u{1F44B} 79anvi \u{1F340}",
358
+ program_voting_power: 0.06426452209558432,
359
+ tokens: "200530523648490887200824"
360
+ },
361
+ doravaloper1tu8006g60t62zwgwf5knkaujv0uzhp2a6wh94h: {
362
+ operator_address: "",
363
+ account_address: "dora1tu8006g60t62zwgwf5knkaujv0uzhp2afcjnrg",
364
+ allocation: "39369183740744815345664",
365
+ allocation_dora: 39369.18374074482,
366
+ moniker: "Citadel.one",
367
+ program_voting_power: 0.11220191559671686,
368
+ tokens: "350114000000000000000000"
369
+ },
370
+ doravaloper1x5z0tkafrgyeuqkrwfjr933vghjxchqnqlhcdw: {
371
+ operator_address: "",
372
+ account_address: "dora1x5z0tkafrgyeuqkrwfjr933vghjxchqnnfjwm3",
373
+ allocation: "22611521290904268701696",
374
+ allocation_dora: 22611.521290904268,
375
+ moniker: "1ce",
376
+ program_voting_power: 0.064442687460896,
377
+ tokens: "201086469492900000000000"
378
+ },
379
+ doravaloper1z6kfew2nhuh02szc2hdecw4fqey2d32auucvux: {
380
+ operator_address: "",
381
+ account_address: "dora1z6kfew2nhuh02szc2hdecw4fqey2d32a02a62e",
382
+ allocation: "45246951843662957379584",
383
+ allocation_dora: 45246.95184366296,
384
+ moniker: "Nodes.Guru",
385
+ program_voting_power: 0.12895351616135226,
386
+ tokens: "402385566389000000000006"
387
+ },
388
+ doravaloper1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v: {
389
+ operator_address: "",
390
+ account_address: "dora1zzne8ufazycklx4j6mgc987t8ykd6wxu63223v",
391
+ allocation: "44982761968475888943104",
392
+ allocation_dora: 44982.76196847589,
393
+ moniker: "ZKV",
394
+ program_voting_power: 0.12820057674882976,
395
+ tokens: "400036100000000000000000"
396
+ }
397
+ };
398
+ function getDefaultParams(network = "mainnet") {
399
+ switch (network) {
400
+ case "mainnet":
401
+ return {
402
+ network: "mainnet",
403
+ chainId: "vota-ash",
404
+ rpcEndpoint: "https://vota-rpc.dorafactory.org",
405
+ restEndpoint: "https://vota-rest.dorafactory.org",
406
+ apiEndpoint: "https://vota-api.dorafactory.org",
407
+ certificateApiEndpoint: "https://vota-certificate-api.dorafactory.org",
408
+ registryAddress: "dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4",
409
+ maciCodeId: 106,
410
+ oracleCodeId: 111,
411
+ oracleWhitelistBackendPubkey: "A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q",
412
+ oracleFeegrantOperator: "dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8"
413
+ };
414
+ case "testnet":
415
+ return {
416
+ network: "testnet",
417
+ chainId: "vota-testnet",
418
+ rpcEndpoint: "https://vota-testnet-rpc.dorafactory.org",
419
+ restEndpoint: "https://vota-testnet-rest.dorafactory.org",
420
+ apiEndpoint: "https://vota-testnet-api.dorafactory.org",
421
+ certificateApiEndpoint: "https://vota-testnet-certificate-api.dorafactory.org",
422
+ registryAddress: "dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd",
423
+ maciCodeId: 107,
424
+ oracleCodeId: 110,
425
+ oracleWhitelistBackendPubkey: "AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ",
426
+ oracleFeegrantOperator: "dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78"
427
+ };
428
+ }
429
+ }
430
+
431
+ // src/libs/query/circuit.ts
432
+ var Circuit = class {
433
+ constructor(http) {
434
+ this.http = http;
435
+ }
436
+ async getCircuitByName(name) {
437
+ try {
438
+ const circuitName = name;
439
+ const circuitData = circuits[circuitName];
440
+ if (circuitData === void 0) {
441
+ return {
442
+ code: 404,
443
+ error: {
444
+ message: `Circuit ${circuitName} not found`,
445
+ type: ERROR.ERROR_CIRCUIT_NOT_FOUND
446
+ }
447
+ };
448
+ }
449
+ const CIRCUIT_ROUNDS_COUNT_QUERY = `
450
+ query {
451
+ rounds(filter: { circuitName: { equalTo: "${circuitData.displayName}" } }) {
452
+ totalCount
453
+ }
454
+ }
455
+ `;
456
+ const circuitRoundsCountResponse = await this.http.fetchGraphql(
457
+ CIRCUIT_ROUNDS_COUNT_QUERY,
458
+ ""
459
+ );
460
+ circuitData.roundCount = circuitRoundsCountResponse.data.rounds.totalCount;
461
+ const response = {
462
+ code: 200,
463
+ data: {
464
+ circuit: circuitData
465
+ }
466
+ };
467
+ return response;
468
+ } catch (error) {
469
+ return handleError(error);
470
+ }
471
+ }
472
+ async getCircuits() {
473
+ try {
474
+ const circuitsArray = Object.values(circuits).sort(
475
+ (a, b) => a.displayName.localeCompare(b.displayName)
476
+ );
477
+ const circuitsWithRoundCount = await Promise.all(
478
+ circuitsArray.map(async (circuit) => {
479
+ const CIRCUIT_ROUNDS_COUNT_QUERY = `
480
+ query {
481
+ rounds(filter: { circuitName: { equalTo: "${circuit.displayName}" } }) {
482
+ totalCount
483
+ }
484
+ }
485
+ `;
486
+ const circuitRoundsCountResponse = await this.http.fetchGraphql(CIRCUIT_ROUNDS_COUNT_QUERY, "");
487
+ return {
488
+ ...circuit,
489
+ roundCount: circuitRoundsCountResponse.data.rounds.totalCount
490
+ };
491
+ })
492
+ );
493
+ const response = {
494
+ code: 200,
495
+ data: {
496
+ circuits: circuitsWithRoundCount
497
+ }
498
+ };
499
+ return response;
500
+ } catch (error) {
501
+ return handleError(error);
502
+ }
503
+ }
504
+ };
505
+
506
+ // src/utils/index.ts
507
+ import { decode } from "bech32";
508
+ function verifyIsBech32(address) {
509
+ try {
510
+ decode(address);
511
+ } catch (error) {
512
+ return error instanceof Error ? error : new Error("Unknown error");
513
+ }
514
+ return void 0;
515
+ }
516
+ function isValidAddress(address) {
517
+ return address.startsWith("dora") && verifyIsBech32(address) === void 0;
518
+ }
519
+
520
+ // src/libs/query/operator.ts
521
+ var Operator = class {
522
+ constructor(http, amaciRegistryContract) {
523
+ this.http = http;
524
+ this.amaciRegistryContract = amaciRegistryContract;
525
+ }
526
+ async getOperatorByAddress(address) {
527
+ try {
528
+ if (!isValidAddress(address)) {
529
+ return {
530
+ code: 400,
531
+ error: {
532
+ message: "Invalid operator address format",
533
+ type: ERROR.ERROR_OPERATOR_INVALID_ADDRESS
534
+ }
535
+ };
536
+ }
537
+ const OPERATORS_QUERY = `query {
538
+ operators(filter: { operatorAddress: { equalTo: "${address}" } }) {
539
+ edges {
540
+ node {
541
+ id
542
+ validatorAddress
543
+ operatorAddress
544
+ coordinatorPubkeyX
545
+ coordinatorPubkeyY
546
+ identity
547
+ }
548
+ }
549
+ }
550
+ }`;
551
+ const response = await this.http.fetchGraphql(
552
+ OPERATORS_QUERY,
553
+ ""
554
+ );
555
+ if (!response || !response.data || !response.data.operators || !response.data.operators.edges || response.data.operators.edges.length === 0) {
556
+ return {
557
+ code: 404,
558
+ error: {
559
+ message: `No operator found for address ${address}`,
560
+ type: ERROR.ERROR_OPERATOR_NOT_FOUND
561
+ }
562
+ };
563
+ }
564
+ const operatorResponse = response.data.operators.edges[0].node;
565
+ if (operatorResponse.operatorAddress === "" || operatorResponse.coordinatorPubkeyX === "") {
566
+ operatorResponse.activeRoundsCount = 0;
567
+ operatorResponse.completedRoundsCount = 0;
568
+ } else {
569
+ const ROUNDS_QUERY = `query {
570
+ activeRoundsCount: rounds(filter: {
571
+ period: {notEqualTo: "Ended"},
572
+ operator: {equalTo: "${operatorResponse.operatorAddress}"},
573
+ caller: {equalTo: "${this.amaciRegistryContract}"}
574
+ }) {
575
+ totalCount
576
+ }
577
+ completedRoundsCount: rounds(filter: {
578
+ period: {equalTo: "Ended"},
579
+ operator: {equalTo: "${operatorResponse.operatorAddress}"},
580
+ caller: {equalTo: "${this.amaciRegistryContract}"}
581
+ }) {
582
+ totalCount
583
+ }
584
+ }`;
585
+ const roundsCount = await this.http.fetchGraphql(
586
+ ROUNDS_QUERY,
587
+ ""
588
+ );
589
+ operatorResponse.activeRoundsCount = roundsCount.data.activeRoundsCount.totalCount;
590
+ operatorResponse.completedRoundsCount = roundsCount.data.completedRoundsCount.totalCount;
591
+ }
592
+ operatorResponse.logoUrl = "";
593
+ operatorResponse.moniker = "";
594
+ const identity = response.data.operators.edges[0].node.identity;
595
+ const keybaseUrl = `https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}`;
596
+ const keybaseResponse = await this.http.fetch(keybaseUrl);
597
+ const keybaseData = await keybaseResponse.json();
598
+ if (keybaseData.status.code === 0) {
599
+ if (keybaseData.them[0]?.pictures?.primary?.url) {
600
+ operatorResponse.logoUrl = keybaseData.them[0].pictures.primary.url;
601
+ }
602
+ if (keybaseData.them[0]?.basics?.username_cased) {
603
+ operatorResponse.moniker = keybaseData.them[0].profile.full_name;
604
+ }
605
+ }
606
+ const operator = {
607
+ code: 200,
608
+ data: {
609
+ operator: operatorResponse
610
+ }
611
+ };
612
+ return operator;
613
+ } catch (error) {
614
+ return handleError(error);
615
+ }
616
+ }
617
+ async getOperators(after, limit) {
618
+ try {
619
+ const OPERATORS_QUERY = `query ($limit: Int, $after: Cursor) {
620
+ operators(first: $limit, after: $after) {
621
+ pageInfo {
622
+ endCursor
623
+ hasNextPage
624
+ }
625
+ totalCount
626
+ edges {
627
+ cursor
628
+ node {
629
+ id
630
+ validatorAddress
631
+ operatorAddress
632
+ coordinatorPubkeyX
633
+ coordinatorPubkeyY
634
+ identity
635
+ }
636
+ }
637
+ }
638
+ }`;
639
+ const response = await this.http.fetchGraphql(
640
+ OPERATORS_QUERY,
641
+ after,
642
+ limit
643
+ );
644
+ if (!response || !response.data || !response.data.operators || !response.data.operators.edges) {
645
+ return {
646
+ code: 404,
647
+ error: {
648
+ message: "No operators found",
649
+ type: ERROR.ERROR_OPERATORS_NOT_FOUND
650
+ }
651
+ };
652
+ }
653
+ const operatorsWithRounds = await Promise.all(
654
+ response.data.operators.edges.map(async (edge) => {
655
+ const operator = edge.node;
656
+ if (operator.operatorAddress === "" || operator.coordinatorPubkeyX === "") {
657
+ operator.activeRoundsCount = 0;
658
+ operator.completedRoundsCount = 0;
659
+ return operator;
660
+ }
661
+ const ROUNDS_QUERY = `query {
662
+ activeRoundsCount: rounds(filter: {
663
+ period: {notEqualTo: "Ended"},
664
+ operator: {equalTo: "${operator.operatorAddress}"},
665
+ caller: {equalTo: "${this.amaciRegistryContract}"}
666
+ }) {
667
+ totalCount
668
+ }
669
+ completedRoundsCount: rounds(filter: {
670
+ period: {equalTo: "Ended"},
671
+ operator: {equalTo: "${operator.operatorAddress}"},
672
+ caller: {equalTo: "${this.amaciRegistryContract}"}
673
+ }) {
674
+ totalCount
675
+ }
676
+ }`;
677
+ const roundsCount = await this.http.fetchGraphql(
678
+ ROUNDS_QUERY,
679
+ ""
680
+ );
681
+ operator.activeRoundsCount = roundsCount.data.activeRoundsCount.totalCount;
682
+ operator.completedRoundsCount = roundsCount.data.completedRoundsCount.totalCount;
683
+ return operator;
684
+ })
685
+ );
686
+ response.data.operators.edges = operatorsWithRounds.map(
687
+ (operator, index) => ({
688
+ cursor: response.data.operators.edges[index].cursor,
689
+ node: operator
690
+ })
691
+ );
692
+ await Promise.all(
693
+ response.data.operators.edges.map(async (edge) => {
694
+ const operator = edge.node;
695
+ const identity = operator.identity;
696
+ operator.logoUrl = "";
697
+ operator.moniker = "";
698
+ const keybaseUrl = `https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}`;
699
+ const keybaseResponse = await this.http.fetch(keybaseUrl);
700
+ const keybaseData = await keybaseResponse.json();
701
+ if (keybaseData.status.code === 0) {
702
+ if (keybaseData.them[0]?.pictures?.primary?.url) {
703
+ operator.logoUrl = keybaseData.them[0].pictures.primary.url;
704
+ }
705
+ if (keybaseData.them[0]?.basics?.username_cased) {
706
+ operator.moniker = keybaseData.them[0].profile.full_name;
707
+ }
708
+ }
709
+ return operator;
710
+ })
711
+ );
712
+ return {
713
+ code: 200,
714
+ data: response.data
715
+ };
716
+ } catch (error) {
717
+ return handleError(error);
718
+ }
719
+ }
720
+ };
721
+
722
+ // src/libs/query/round.ts
723
+ var Round = class {
724
+ constructor(http) {
725
+ this.http = http;
726
+ }
727
+ async getRoundById(address) {
728
+ try {
729
+ if (!isValidAddress(address)) {
730
+ return {
731
+ code: 400,
732
+ error: {
733
+ message: "Invalid round address format",
734
+ type: ERROR.ERROR_ROUND_INVALID_ADDRESS
735
+ }
736
+ };
737
+ }
738
+ const ROUND_QUERY = `query {
739
+ round(id: "${address}") {
740
+ id
741
+ blockHeight
742
+ txHash
743
+ caller
744
+ admin
745
+ operator
746
+ contractAddress
747
+ circuitName
748
+ timestamp
749
+ votingStart
750
+ votingEnd
751
+ status
752
+ period
753
+ actionType
754
+ roundTitle
755
+ roundDescription
756
+ roundLink
757
+ coordinatorPubkeyX
758
+ coordinatorPubkeyY
759
+ voteOptionMap
760
+ results
761
+ allResult
762
+ gasStationEnable
763
+ totalGrant
764
+ baseGrant
765
+ totalBond
766
+ circuitType
767
+ circuitPower
768
+ certificationSystem
769
+ codeId
770
+ maciType
771
+ voiceCreditAmount
772
+ preDeactivateRoot
773
+ identity
774
+ }
775
+ }`;
776
+ const response = await this.http.fetchGraphql(
777
+ ROUND_QUERY,
778
+ ""
779
+ );
780
+ if (!response || !response.data || !response.data.round) {
781
+ return {
782
+ code: 404,
783
+ error: {
784
+ message: `No round data found for address ${address}`,
785
+ type: ERROR.ERROR_ROUND_NOT_FOUND
786
+ }
787
+ };
788
+ }
789
+ response.data.round.operatorLogoUrl = "";
790
+ response.data.round.operatorMoniker = "";
791
+ const identity = response.data.round.identity;
792
+ const keybaseUrl = `https://keybase.io/_/api/1.0/user/lookup.json?key_suffix=${identity}`;
793
+ const keybaseResponse = await this.http.fetch(keybaseUrl);
794
+ const keybaseData = await keybaseResponse.json();
795
+ if (keybaseData.status.code === 0) {
796
+ if (keybaseData.them[0]?.pictures?.primary?.url) {
797
+ response.data.round.operatorLogoUrl = keybaseData.them[0].pictures.primary.url;
798
+ }
799
+ if (keybaseData.them[0]?.basics?.username_cased) {
800
+ response.data.round.operatorMoniker = keybaseData.them[0].profile.full_name;
801
+ }
802
+ }
803
+ const results = JSON.parse(response.data.round.results);
804
+ const votes = results.map((r) => ({
805
+ v: Number(r.slice(0, -24)),
806
+ v2: Number(r.slice(-24))
807
+ }));
808
+ const totalVotes = votes.reduce(
809
+ (s, c) => ({
810
+ v: s.v + c.v,
811
+ v2: s.v2 + c.v2
812
+ }),
813
+ { v: 0, v2: 0 }
814
+ );
815
+ const resultsList = votes.map((v) => ({
816
+ v: totalVotes.v === 0 ? "0.0" : (v.v / totalVotes.v * 100).toFixed(3),
817
+ v2: totalVotes.v2 === 0 ? "0.0" : (v.v2 / totalVotes.v2 * 100).toFixed(3)
818
+ }));
819
+ response.data.round.resultsList = resultsList;
820
+ return {
821
+ code: 200,
822
+ data: response.data
823
+ };
824
+ } catch (error) {
825
+ return handleError(error);
826
+ }
827
+ }
828
+ async getRounds(after, limit) {
829
+ try {
830
+ const ROUND_HISTORY_QUERY = `query ($limit: Int, $after: Cursor) {
831
+ rounds(first: $limit, after: $after, orderBy: [TIMESTAMP_DESC]){
832
+ pageInfo {
833
+ endCursor
834
+ hasNextPage
835
+ }
836
+ totalCount
837
+ edges {
838
+ node {
839
+ id
840
+ blockHeight
841
+ txHash
842
+ caller
843
+ admin
844
+ operator
845
+ contractAddress
846
+ circuitName
847
+ timestamp
848
+ votingStart
849
+ votingEnd
850
+ status
851
+ period
852
+ actionType
853
+ roundTitle
854
+ roundDescription
855
+ roundLink
856
+ coordinatorPubkeyX
857
+ coordinatorPubkeyY
858
+ voteOptionMap
859
+ results
860
+ allResult
861
+ gasStationEnable
862
+ totalGrant
863
+ baseGrant
864
+ totalBond
865
+ circuitType
866
+ circuitPower
867
+ certificationSystem
868
+ codeId
869
+ maciType
870
+ voiceCreditAmount
871
+ preDeactivateRoot
872
+ }
873
+ cursor
874
+ }
875
+ }
876
+ }
877
+ `;
878
+ const response = await this.http.fetchGraphql(
879
+ ROUND_HISTORY_QUERY,
880
+ after,
881
+ limit
882
+ );
883
+ if (!response || !response.data || !response.data.rounds || !response.data.rounds.edges) {
884
+ return {
885
+ code: 404,
886
+ error: {
887
+ message: "No rounds data found",
888
+ type: ERROR.ERROR_ROUNDS_NOT_FOUND
889
+ }
890
+ };
891
+ }
892
+ return {
893
+ code: 200,
894
+ data: response.data
895
+ };
896
+ } catch (error) {
897
+ return handleError(error);
898
+ }
899
+ }
900
+ async getRoundsByCircuitName(circuitName, after, limit) {
901
+ try {
902
+ const ROUND_HISTORY_QUERY = `query ($limit: Int, $after: Cursor) {
903
+ rounds(first: $limit, after: $after, filter:{
904
+ circuitName:{
905
+ equalTo: "${circuitName}"
906
+ }
907
+ }, orderBy: [TIMESTAMP_DESC]){
908
+ pageInfo {
909
+ endCursor
910
+ hasNextPage
911
+ }
912
+ totalCount
913
+ edges {
914
+ cursor
915
+ node {
916
+ id
917
+ blockHeight
918
+ txHash
919
+ caller
920
+ admin
921
+ operator
922
+ contractAddress
923
+ circuitName
924
+ timestamp
925
+ votingStart
926
+ votingEnd
927
+ status
928
+ period
929
+ actionType
930
+ roundTitle
931
+ roundDescription
932
+ roundLink
933
+ coordinatorPubkeyX
934
+ coordinatorPubkeyY
935
+ voteOptionMap
936
+ results
937
+ allResult
938
+ gasStationEnable
939
+ totalGrant
940
+ baseGrant
941
+ totalBond
942
+ circuitType
943
+ circuitPower
944
+ certificationSystem
945
+ codeId
946
+ maciType
947
+ voiceCreditAmount
948
+ preDeactivateRoot
949
+ }
950
+ }
951
+ }
952
+ }
953
+ `;
954
+ const response = await this.http.fetchGraphql(
955
+ ROUND_HISTORY_QUERY,
956
+ after,
957
+ limit
958
+ );
959
+ if (!response || !response.data || !response.data.rounds || !response.data.rounds.edges) {
960
+ return {
961
+ code: 404,
962
+ error: {
963
+ message: `No rounds data found for circuit name ${circuitName}`,
964
+ type: ERROR.ERROR_ROUNDS_NOT_FOUND
965
+ }
966
+ };
967
+ }
968
+ return {
969
+ code: 200,
970
+ data: response.data
971
+ };
972
+ } catch (error) {
973
+ return handleError(error);
974
+ }
975
+ }
976
+ async getRoundsByStatus(status, after, limit) {
977
+ try {
978
+ const currentTime = Math.floor(Date.now() / 1e3);
979
+ let filterCondition = "";
980
+ switch (status) {
981
+ case "Created":
982
+ filterCondition = `
983
+ or: [
984
+ { votingStart: { equalTo: "0" } },
985
+ { and: [
986
+ { votingStart: { notEqualTo: "0" } },
987
+ { votingStart: { greaterThan: "${currentTime.toString()}" } }
988
+ ] }
989
+ ]
990
+ `;
991
+ break;
992
+ case "Ongoing":
993
+ filterCondition = `
994
+ or: [
995
+ { votingStart: { equalTo: "0" }},
996
+ { votingStart: { lessThanOrEqualTo: "${currentTime.toString()}" }, votingEnd: { greaterThan: "${currentTime.toString()}" } }
997
+ ]
998
+ `;
999
+ break;
1000
+ case "Tallying":
1001
+ filterCondition = `
1002
+ and: [
1003
+ { status: { notEqualTo: "Closed" } },
1004
+ { votingEnd: { lessThan: "${currentTime.toString()}" } },
1005
+ { votingEnd: { notEqualTo: "0" } }
1006
+ ]
1007
+ `;
1008
+ break;
1009
+ case "Closed":
1010
+ filterCondition = `status: { equalTo: "Closed" }`;
1011
+ break;
1012
+ default:
1013
+ return {
1014
+ code: 400,
1015
+ error: {
1016
+ message: `Invalid status: ${status}`,
1017
+ type: ERROR.ERROR_ROUND_INVALID_STATUS
1018
+ }
1019
+ };
1020
+ }
1021
+ const ROUND_HISTORY_QUERY = `query ($limit: Int!, $after: Cursor) {
1022
+ rounds(first: $limit, after: $after, filter: { ${filterCondition} }, orderBy: [TIMESTAMP_DESC]) {
1023
+ pageInfo {
1024
+ endCursor
1025
+ hasNextPage
1026
+ }
1027
+ totalCount
1028
+ edges {
1029
+ cursor
1030
+ node {
1031
+ id
1032
+ blockHeight
1033
+ txHash
1034
+ caller
1035
+ admin
1036
+ operator
1037
+ contractAddress
1038
+ circuitName
1039
+ timestamp
1040
+ votingStart
1041
+ votingEnd
1042
+ status
1043
+ period
1044
+ actionType
1045
+ roundTitle
1046
+ roundDescription
1047
+ roundLink
1048
+ coordinatorPubkeyX
1049
+ coordinatorPubkeyY
1050
+ voteOptionMap
1051
+ results
1052
+ allResult
1053
+ gasStationEnable
1054
+ totalGrant
1055
+ baseGrant
1056
+ totalBond
1057
+ circuitType
1058
+ circuitPower
1059
+ certificationSystem
1060
+ codeId
1061
+ maciType
1062
+ voiceCreditAmount
1063
+ preDeactivateRoot
1064
+ }
1065
+ }
1066
+ }
1067
+ }`;
1068
+ const response = await this.http.fetchGraphql(
1069
+ ROUND_HISTORY_QUERY,
1070
+ after,
1071
+ limit
1072
+ );
1073
+ if (!response || !response.data || !response.data.rounds || !response.data.rounds.edges) {
1074
+ return {
1075
+ code: 404,
1076
+ error: {
1077
+ message: `No rounds data found for status ${status}`,
1078
+ type: ERROR.ERROR_ROUNDS_NOT_FOUND
1079
+ }
1080
+ };
1081
+ }
1082
+ return {
1083
+ code: 200,
1084
+ data: response.data
1085
+ };
1086
+ } catch (error) {
1087
+ return handleError(error);
1088
+ }
1089
+ }
1090
+ async getRoundsByOperator(operator, after, limit) {
1091
+ try {
1092
+ if (!isValidAddress(operator)) {
1093
+ return {
1094
+ code: 400,
1095
+ error: {
1096
+ message: "Invalid operator address format",
1097
+ type: ERROR.ERROR_OPERATOR_INVALID_ADDRESS
1098
+ }
1099
+ };
1100
+ }
1101
+ const ROUND_HISTORY_QUERY = `query ($limit: Int!, $after: Cursor) {
1102
+ rounds(first: $limit, after: $after, filter:{
1103
+ operator:{
1104
+ equalTo: "${operator}"
1105
+ }
1106
+ }, orderBy: [TIMESTAMP_DESC]){
1107
+ pageInfo {
1108
+ endCursor
1109
+ hasNextPage
1110
+ }
1111
+ totalCount
1112
+ edges {
1113
+ cursor
1114
+ node {
1115
+ id
1116
+ blockHeight
1117
+ txHash
1118
+ caller
1119
+ admin
1120
+ operator
1121
+ contractAddress
1122
+ circuitName
1123
+ timestamp
1124
+ votingStart
1125
+ votingEnd
1126
+ status
1127
+ period
1128
+ actionType
1129
+ roundTitle
1130
+ roundDescription
1131
+ roundLink
1132
+ coordinatorPubkeyX
1133
+ coordinatorPubkeyY
1134
+ voteOptionMap
1135
+ results
1136
+ allResult
1137
+ gasStationEnable
1138
+ totalGrant
1139
+ baseGrant
1140
+ totalBond
1141
+ circuitType
1142
+ circuitPower
1143
+ certificationSystem
1144
+ codeId
1145
+ maciType
1146
+ voiceCreditAmount
1147
+ preDeactivateRoot
1148
+ }
1149
+ }
1150
+ }
1151
+ }`;
1152
+ const response = await this.http.fetchGraphql(
1153
+ ROUND_HISTORY_QUERY,
1154
+ after,
1155
+ limit
1156
+ );
1157
+ if (!response || !response.data || !response.data.rounds || !response.data.rounds.edges) {
1158
+ return {
1159
+ code: 404,
1160
+ error: {
1161
+ message: `No rounds data found for operator ${operator}`,
1162
+ type: ERROR.ERROR_ROUNDS_NOT_FOUND
1163
+ }
1164
+ };
1165
+ }
1166
+ return {
1167
+ code: 200,
1168
+ data: response.data
1169
+ };
1170
+ } catch (error) {
1171
+ return handleError(error);
1172
+ }
1173
+ }
1174
+ };
1175
+
1176
+ // src/libs/query/transaction.ts
1177
+ var Transaction = class {
1178
+ constructor(http) {
1179
+ this.http = http;
1180
+ }
1181
+ async getTransactionByHash(txHash) {
1182
+ try {
1183
+ const TRANSACTION_QUERY = `query {
1184
+ transaction(id: "${txHash}") {
1185
+ id
1186
+ blockHeight
1187
+ txHash
1188
+ timestamp
1189
+ type
1190
+ status
1191
+ circuitName
1192
+ fee
1193
+ gasUsed
1194
+ gasWanted
1195
+ caller
1196
+ contractAddress
1197
+ }
1198
+ }`;
1199
+ const response = await this.http.fetchGraphql(
1200
+ TRANSACTION_QUERY,
1201
+ ""
1202
+ );
1203
+ if (!response || !response.data || !response.data.transaction) {
1204
+ return {
1205
+ code: 404,
1206
+ error: {
1207
+ message: `No transaction found for txHash ${txHash}`,
1208
+ type: ERROR.ERROR_TRANSACTION_NOT_FOUND
1209
+ }
1210
+ };
1211
+ }
1212
+ return {
1213
+ code: 200,
1214
+ data: response.data
1215
+ };
1216
+ } catch (error) {
1217
+ return handleError(error);
1218
+ }
1219
+ }
1220
+ async getTransactions(after, limit) {
1221
+ try {
1222
+ const TRANSACTION_HISTORY_QUERY = `query transactions($limit: Int, $after: Cursor) {
1223
+ transactions(first: $limit, after: $after, orderBy: [TIMESTAMP_DESC]
1224
+ ){
1225
+ pageInfo {
1226
+ endCursor
1227
+ hasNextPage
1228
+ }
1229
+ totalCount
1230
+ edges {
1231
+ cursor
1232
+ node {
1233
+ id
1234
+ blockHeight
1235
+ txHash
1236
+ timestamp
1237
+ type
1238
+ status
1239
+ circuitName
1240
+ fee
1241
+ gasUsed
1242
+ gasWanted
1243
+ caller
1244
+ contractAddress
1245
+ }
1246
+ }
1247
+ }
1248
+ }`;
1249
+ const response = await this.http.fetchGraphql(
1250
+ TRANSACTION_HISTORY_QUERY,
1251
+ after,
1252
+ limit
1253
+ );
1254
+ if (!response || !response.data || !response.data.transactions || !response.data.transactions.edges) {
1255
+ return {
1256
+ code: 404,
1257
+ error: {
1258
+ message: "No transactions data found",
1259
+ type: ERROR.ERROR_TRANSACTIONS_NOT_FOUND
1260
+ }
1261
+ };
1262
+ }
1263
+ return {
1264
+ code: 200,
1265
+ data: response.data
1266
+ };
1267
+ } catch (error) {
1268
+ return handleError(error);
1269
+ }
1270
+ }
1271
+ async getTransactionsByContractAddress(address, after, limit) {
1272
+ try {
1273
+ if (!isValidAddress(address)) {
1274
+ return {
1275
+ code: 400,
1276
+ error: {
1277
+ message: "Invalid round address format",
1278
+ type: ERROR.ERROR_ROUND_INVALID_ADDRESS
1279
+ }
1280
+ };
1281
+ }
1282
+ const TRANSACTION_HISTORY_QUERY = `query transactions($limit: Int!, $after: Cursor) {
1283
+ transactions(first: $limit, after: $after, filter:{
1284
+ contractAddress:{
1285
+ equalTo: "${address}"
1286
+ }
1287
+ }, orderBy: [TIMESTAMP_DESC]
1288
+ ){
1289
+ pageInfo {
1290
+ endCursor
1291
+ hasNextPage
1292
+ }
1293
+ totalCount
1294
+ edges {
1295
+ cursor
1296
+ node {
1297
+ id
1298
+ blockHeight
1299
+ txHash
1300
+ timestamp
1301
+ type
1302
+ status
1303
+ circuitName
1304
+ fee
1305
+ gasUsed
1306
+ gasWanted
1307
+ caller
1308
+ contractAddress
1309
+ }
1310
+ }
1311
+ }
1312
+ }`;
1313
+ const response = await this.http.fetchGraphql(
1314
+ TRANSACTION_HISTORY_QUERY,
1315
+ after,
1316
+ limit
1317
+ );
1318
+ if (!response || !response.data || !response.data.transactions || !response.data.transactions.edges) {
1319
+ return {
1320
+ code: 404,
1321
+ error: {
1322
+ message: "No transactions data found",
1323
+ type: ERROR.ERROR_TRANSACTIONS_NOT_FOUND
1324
+ }
1325
+ };
1326
+ }
1327
+ return {
1328
+ code: 200,
1329
+ data: response.data
1330
+ };
1331
+ } catch (error) {
1332
+ return handleError(error);
1333
+ }
1334
+ }
1335
+ };
1336
+
1337
+ // src/libs/query/proof.ts
1338
+ var Proof = class {
1339
+ constructor(http) {
1340
+ this.http = http;
1341
+ }
1342
+ async getProofByContractAddress(address) {
1343
+ try {
1344
+ if (!isValidAddress(address)) {
1345
+ return {
1346
+ code: 400,
1347
+ error: {
1348
+ message: "Invalid round address format",
1349
+ type: ERROR.ERROR_ROUND_INVALID_ADDRESS
1350
+ }
1351
+ };
1352
+ }
1353
+ const PROOF_QUERY = `query HomePage {
1354
+ proofData(first: 100, filter:{
1355
+ contractAddress:{
1356
+ equalTo: "${address}"
1357
+ }
1358
+ } ,orderBy: [TIMESTAMP_DESC]
1359
+ ){
1360
+ nodes {
1361
+ id
1362
+ blockHeight
1363
+ txHash
1364
+ contractAddress
1365
+ timestamp
1366
+ actionType
1367
+ commitment
1368
+ proof
1369
+ }
1370
+ }
1371
+ }
1372
+ `;
1373
+ const response = await this.http.fetchGraphql(
1374
+ PROOF_QUERY,
1375
+ ""
1376
+ );
1377
+ if (!response || !response.data || !response.data.proofData || !response.data.proofData.nodes || response.data.proofData.nodes.length === 0) {
1378
+ return {
1379
+ code: 404,
1380
+ error: {
1381
+ message: `No proof found for round address ${address}`,
1382
+ type: ERROR.ERROR_PROOF_NOT_FOUND
1383
+ }
1384
+ };
1385
+ }
1386
+ return {
1387
+ code: 200,
1388
+ data: response.data
1389
+ };
1390
+ } catch (error) {
1391
+ return handleError(error);
1392
+ }
1393
+ }
1394
+ };
1395
+
1396
+ // src/libs/indexer/indexer.ts
1397
+ var Indexer = class {
1398
+ /**
1399
+ * @constructor
1400
+ * @param {IndexerParams} params - The parameters for the Maci Indexer instance.
1401
+ */
1402
+ constructor({
1403
+ restEndpoint,
1404
+ apiEndpoint,
1405
+ registryAddress,
1406
+ http
1407
+ }) {
1408
+ this.http = http;
1409
+ this.restEndpoint = restEndpoint;
1410
+ this.apiEndpoint = apiEndpoint;
1411
+ this.registryAddress = registryAddress;
1412
+ this.round = new Round(this.http);
1413
+ this.account = new Account(this.http);
1414
+ this.circuit = new Circuit(this.http);
1415
+ this.operator = new Operator(this.http, this.registryAddress);
1416
+ this.proof = new Proof(this.http);
1417
+ this.transaction = new Transaction(this.http);
1418
+ }
1419
+ /**
1420
+ * @method balanceOf
1421
+ * @description Get the balance of a specific address.
1422
+ * @param {string} address - The address to check the balance for.
1423
+ * @returns {Promise<BalanceResponse>} The balance response.
1424
+ */
1425
+ async balanceOf(address) {
1426
+ return await this.account.balanceOf(address);
1427
+ }
1428
+ /**
1429
+ * @method getRoundById
1430
+ * @description Get a round by its ID.
1431
+ * @param {string} id - The ID of the round.
1432
+ * @returns {Promise<RoundResponse>} The round response.
1433
+ */
1434
+ async getRoundById(id) {
1435
+ return await this.round.getRoundById(id);
1436
+ }
1437
+ /**
1438
+ * @method getRounds
1439
+ * @description Get multiple rounds.
1440
+ * @param {string} after - The cursor to start after.
1441
+ * @param {number} [limit] - The number of rounds to retrieve.
1442
+ * @returns {Promise<RoundsResponse>} The rounds response.
1443
+ */
1444
+ async getRounds(after, limit) {
1445
+ return await this.round.getRounds(after, limit);
1446
+ }
1447
+ /**
1448
+ * @method getRoundsByStatus
1449
+ * @description Get rounds by their status.
1450
+ * @param {string} status - The status of the rounds to retrieve.
1451
+ * @param {string} after - The cursor to start after.
1452
+ * @param {number} [limit] - The number of rounds to retrieve.
1453
+ * @returns {Promise<RoundsResponse>} The rounds response.
1454
+ */
1455
+ async getRoundsByStatus(status, after, limit) {
1456
+ return await this.round.getRoundsByStatus(status, after, limit);
1457
+ }
1458
+ /**
1459
+ * @method getRoundsByCircuitName
1460
+ * @description Get rounds by their circuit name.
1461
+ * @param {string} name - The name of the circuit.
1462
+ * @param {string} after - The cursor to start after.
1463
+ * @param {number} [limit] - The number of rounds to retrieve.
1464
+ * @returns {Promise<RoundsResponse>} The rounds response.
1465
+ */
1466
+ async getRoundsByCircuitName(name, after, limit) {
1467
+ return await this.round.getRoundsByCircuitName(name, after, limit);
1468
+ }
1469
+ /**
1470
+ * @method getRoundsByOperator
1471
+ * @description Get rounds by their operator address.
1472
+ * @param {string} address - The address of the operator.
1473
+ * @param {string} after - The cursor to start after.
1474
+ * @param {number} [limit] - The number of rounds to retrieve.
1475
+ * @returns {Promise<RoundsResponse>} The rounds response.
1476
+ */
1477
+ async getRoundsByOperator(address, after, limit) {
1478
+ return await this.round.getRoundsByOperator(address, after, limit);
1479
+ }
1480
+ /**
1481
+ * @method getOperatorByAddress
1482
+ * @description Get an operator by their address.
1483
+ * @param {string} address - The address of the operator.
1484
+ * @returns {Promise<OperatorResponse>} The operator response.
1485
+ */
1486
+ async getOperatorByAddress(address) {
1487
+ return await this.operator.getOperatorByAddress(address);
1488
+ }
1489
+ /**
1490
+ * @method getOperators
1491
+ * @description Get multiple operators.
1492
+ * @param {string} after - The cursor to start after.
1493
+ * @param {number} [limit] - The number of operators to retrieve.
1494
+ * @returns {Promise<OperatorsResponse>} The operators response.
1495
+ */
1496
+ async getOperators(after, limit) {
1497
+ return await this.operator.getOperators(after, limit);
1498
+ }
1499
+ /**
1500
+ * @method getCircuitByName
1501
+ * @description Get a circuit by its name.
1502
+ * @param {string} name - The name of the circuit.
1503
+ * @returns {Promise<CircuitResponse>} The circuit response.
1504
+ */
1505
+ async getCircuitByName(name) {
1506
+ return await this.circuit.getCircuitByName(name);
1507
+ }
1508
+ /**
1509
+ * @method getCircuits
1510
+ * @description Get all available circuits.
1511
+ * @returns {Promise<CircuitsResponse>} The circuits response.
1512
+ */
1513
+ async getCircuits() {
1514
+ return await this.circuit.getCircuits();
1515
+ }
1516
+ /**
1517
+ * @method getTransactionByHash
1518
+ * @description Get a transaction by its hash.
1519
+ * @param {string} hash - The hash of the transaction.
1520
+ * @returns {Promise<TransactionResponse>} The transaction response.
1521
+ */
1522
+ async getTransactionByHash(hash) {
1523
+ return await this.transaction.getTransactionByHash(hash);
1524
+ }
1525
+ /**
1526
+ * @method getTransactions
1527
+ * @description Get multiple transactions.
1528
+ * @param {string} after - The cursor to start after.
1529
+ * @param {number} [limit] - The number of transactions to retrieve.
1530
+ * @returns {Promise<TransactionsResponse>} The transactions response.
1531
+ */
1532
+ async getTransactions(after, limit) {
1533
+ return await this.transaction.getTransactions(after, limit);
1534
+ }
1535
+ /**
1536
+ * @method getTransactionsByContractAddress
1537
+ * @description Get transactions by contract address.
1538
+ * @param {string} address - The contract address.
1539
+ * @param {string} after - The cursor to start after.
1540
+ * @param {number} [limit] - The number of transactions to retrieve.
1541
+ * @returns {Promise<TransactionsResponse>} The transactions response.
1542
+ */
1543
+ async getTransactionsByContractAddress(address, after, limit) {
1544
+ return await this.transaction.getTransactionsByContractAddress(
1545
+ address,
1546
+ after,
1547
+ limit
1548
+ );
1549
+ }
1550
+ /**
1551
+ * @method getProofByContractAddress
1552
+ * @description Get proof data by contract address.
1553
+ * @param {string} address - The contract address.
1554
+ * @returns {Promise<ProofResponse>} The proof response.
1555
+ */
1556
+ async getProofByContractAddress(address) {
1557
+ return await this.proof.getProofByContractAddress(address);
1558
+ }
1559
+ };
1560
+
1561
+ // src/libs/contract/config.ts
1562
+ import {
1563
+ GasPrice,
1564
+ SigningStargateClient
1565
+ } from "@cosmjs/stargate";
1566
+ import {
1567
+ SigningCosmWasmClient
1568
+ } from "@cosmjs/cosmwasm-stargate";
1569
+
1570
+ // src/libs/contract/ts/Maci.client.ts
1571
+ var MaciQueryClient = class {
1572
+ constructor(client, contractAddress) {
1573
+ this.getRoundInfo = async () => {
1574
+ return this.client.queryContractSmart(this.contractAddress, {
1575
+ get_round_info: {}
1576
+ });
1577
+ };
1578
+ this.getVotingTime = async () => {
1579
+ return this.client.queryContractSmart(this.contractAddress, {
1580
+ get_voting_time: {}
1581
+ });
1582
+ };
1583
+ this.getPeriod = async () => {
1584
+ return this.client.queryContractSmart(this.contractAddress, {
1585
+ get_period: {}
1586
+ });
1587
+ };
1588
+ this.getNumSignUp = async () => {
1589
+ return this.client.queryContractSmart(this.contractAddress, {
1590
+ get_num_sign_up: {}
1591
+ });
1592
+ };
1593
+ this.getMsgChainLength = async () => {
1594
+ return this.client.queryContractSmart(this.contractAddress, {
1595
+ get_msg_chain_length: {}
1596
+ });
1597
+ };
1598
+ this.getDMsgChainLength = async () => {
1599
+ return this.client.queryContractSmart(this.contractAddress, {
1600
+ get_d_msg_chain_length: {}
1601
+ });
1602
+ };
1603
+ this.getProcessedDMsgCount = async () => {
1604
+ return this.client.queryContractSmart(this.contractAddress, {
1605
+ get_processed_d_msg_count: {}
1606
+ });
1607
+ };
1608
+ this.getProcessedMsgCount = async () => {
1609
+ return this.client.queryContractSmart(this.contractAddress, {
1610
+ get_processed_msg_count: {}
1611
+ });
1612
+ };
1613
+ this.getProcessedUserCount = async () => {
1614
+ return this.client.queryContractSmart(this.contractAddress, {
1615
+ get_processed_user_count: {}
1616
+ });
1617
+ };
1618
+ this.getResult = async ({ index }) => {
1619
+ return this.client.queryContractSmart(this.contractAddress, {
1620
+ get_result: {
1621
+ index
1622
+ }
1623
+ });
1624
+ };
1625
+ this.getAllResult = async () => {
1626
+ return this.client.queryContractSmart(this.contractAddress, {
1627
+ get_all_result: {}
1628
+ });
1629
+ };
1630
+ this.getStateIdxInc = async ({
1631
+ address
1632
+ }) => {
1633
+ return this.client.queryContractSmart(this.contractAddress, {
1634
+ get_state_idx_inc: {
1635
+ address
1636
+ }
1637
+ });
1638
+ };
1639
+ this.getVoiceCreditBalance = async ({
1640
+ index
1641
+ }) => {
1642
+ return this.client.queryContractSmart(this.contractAddress, {
1643
+ get_voice_credit_balance: {
1644
+ index
1645
+ }
1646
+ });
1647
+ };
1648
+ this.whiteList = async () => {
1649
+ return this.client.queryContractSmart(this.contractAddress, {
1650
+ white_list: {}
1651
+ });
1652
+ };
1653
+ this.isWhiteList = async ({ sender }) => {
1654
+ return this.client.queryContractSmart(this.contractAddress, {
1655
+ is_white_list: {
1656
+ sender
1657
+ }
1658
+ });
1659
+ };
1660
+ this.voteOptionMap = async () => {
1661
+ return this.client.queryContractSmart(this.contractAddress, {
1662
+ vote_option_map: {}
1663
+ });
1664
+ };
1665
+ this.maxVoteOptions = async () => {
1666
+ return this.client.queryContractSmart(this.contractAddress, {
1667
+ max_vote_options: {}
1668
+ });
1669
+ };
1670
+ this.queryTotalFeeGrant = async () => {
1671
+ return this.client.queryContractSmart(this.contractAddress, {
1672
+ query_total_fee_grant: {}
1673
+ });
1674
+ };
1675
+ this.queryCircuitType = async () => {
1676
+ return this.client.queryContractSmart(this.contractAddress, {
1677
+ query_circuit_type: {}
1678
+ });
1679
+ };
1680
+ this.queryCertSystem = async () => {
1681
+ return this.client.queryContractSmart(this.contractAddress, {
1682
+ query_cert_system: {}
1683
+ });
1684
+ };
1685
+ this.client = client;
1686
+ this.contractAddress = contractAddress;
1687
+ this.getRoundInfo = this.getRoundInfo.bind(this);
1688
+ this.getVotingTime = this.getVotingTime.bind(this);
1689
+ this.getPeriod = this.getPeriod.bind(this);
1690
+ this.getNumSignUp = this.getNumSignUp.bind(this);
1691
+ this.getMsgChainLength = this.getMsgChainLength.bind(this);
1692
+ this.getDMsgChainLength = this.getDMsgChainLength.bind(this);
1693
+ this.getProcessedDMsgCount = this.getProcessedDMsgCount.bind(this);
1694
+ this.getProcessedMsgCount = this.getProcessedMsgCount.bind(this);
1695
+ this.getProcessedUserCount = this.getProcessedUserCount.bind(this);
1696
+ this.getResult = this.getResult.bind(this);
1697
+ this.getAllResult = this.getAllResult.bind(this);
1698
+ this.getStateIdxInc = this.getStateIdxInc.bind(this);
1699
+ this.getVoiceCreditBalance = this.getVoiceCreditBalance.bind(this);
1700
+ this.whiteList = this.whiteList.bind(this);
1701
+ this.isWhiteList = this.isWhiteList.bind(this);
1702
+ this.voteOptionMap = this.voteOptionMap.bind(this);
1703
+ this.maxVoteOptions = this.maxVoteOptions.bind(this);
1704
+ this.queryTotalFeeGrant = this.queryTotalFeeGrant.bind(this);
1705
+ this.queryCircuitType = this.queryCircuitType.bind(this);
1706
+ this.queryCertSystem = this.queryCertSystem.bind(this);
1707
+ }
1708
+ };
1709
+ var MaciClient = class extends MaciQueryClient {
1710
+ constructor(client, sender, contractAddress) {
1711
+ super(client, contractAddress);
1712
+ this.setParams = async ({
1713
+ intStateTreeDepth,
1714
+ messageBatchSize,
1715
+ stateTreeDepth,
1716
+ voteOptionTreeDepth
1717
+ }, fee = "auto", memo, _funds) => {
1718
+ return await this.client.execute(
1719
+ this.sender,
1720
+ this.contractAddress,
1721
+ {
1722
+ set_params: {
1723
+ int_state_tree_depth: intStateTreeDepth,
1724
+ message_batch_size: messageBatchSize,
1725
+ state_tree_depth: stateTreeDepth,
1726
+ vote_option_tree_depth: voteOptionTreeDepth
1727
+ }
1728
+ },
1729
+ fee,
1730
+ memo,
1731
+ _funds
1732
+ );
1733
+ };
1734
+ this.setRoundInfo = async ({
1735
+ roundInfo
1736
+ }, fee = "auto", memo, _funds) => {
1737
+ return await this.client.execute(
1738
+ this.sender,
1739
+ this.contractAddress,
1740
+ {
1741
+ set_round_info: {
1742
+ round_info: roundInfo
1743
+ }
1744
+ },
1745
+ fee,
1746
+ memo,
1747
+ _funds
1748
+ );
1749
+ };
1750
+ this.setWhitelists = async ({
1751
+ whitelists
1752
+ }, fee = "auto", memo, _funds) => {
1753
+ return await this.client.execute(
1754
+ this.sender,
1755
+ this.contractAddress,
1756
+ {
1757
+ set_whitelists: {
1758
+ whitelists
1759
+ }
1760
+ },
1761
+ fee,
1762
+ memo,
1763
+ _funds
1764
+ );
1765
+ };
1766
+ this.setVoteOptionsMap = async ({
1767
+ voteOptionMap
1768
+ }, fee = "auto", memo, _funds) => {
1769
+ return await this.client.execute(
1770
+ this.sender,
1771
+ this.contractAddress,
1772
+ {
1773
+ set_vote_options_map: {
1774
+ vote_option_map: voteOptionMap
1775
+ }
1776
+ },
1777
+ fee,
1778
+ memo,
1779
+ _funds
1780
+ );
1781
+ };
1782
+ this.startVotingPeriod = async (fee = "auto", memo, _funds) => {
1783
+ return await this.client.execute(
1784
+ this.sender,
1785
+ this.contractAddress,
1786
+ {
1787
+ start_voting_period: {}
1788
+ },
1789
+ fee,
1790
+ memo,
1791
+ _funds
1792
+ );
1793
+ };
1794
+ this.signUp = async ({
1795
+ pubkey
1796
+ }, fee = "auto", memo, _funds) => {
1797
+ return await this.client.execute(
1798
+ this.sender,
1799
+ this.contractAddress,
1800
+ {
1801
+ sign_up: {
1802
+ pubkey
1803
+ }
1804
+ },
1805
+ fee,
1806
+ memo,
1807
+ _funds
1808
+ );
1809
+ };
1810
+ this.startProcessPeriod = async (fee = "auto", memo, _funds) => {
1811
+ return await this.client.execute(
1812
+ this.sender,
1813
+ this.contractAddress,
1814
+ {
1815
+ start_process_period: {}
1816
+ },
1817
+ fee,
1818
+ memo,
1819
+ _funds
1820
+ );
1821
+ };
1822
+ this.stopVotingPeriod = async (fee = "auto", memo, _funds) => {
1823
+ return await this.client.execute(
1824
+ this.sender,
1825
+ this.contractAddress,
1826
+ {
1827
+ stop_voting_period: {}
1828
+ },
1829
+ fee,
1830
+ memo,
1831
+ _funds
1832
+ );
1833
+ };
1834
+ this.publishDeactivateMessage = async ({
1835
+ encPubKey,
1836
+ message
1837
+ }, fee = "auto", memo, _funds) => {
1838
+ return await this.client.execute(
1839
+ this.sender,
1840
+ this.contractAddress,
1841
+ {
1842
+ publish_deactivate_message: {
1843
+ enc_pub_key: encPubKey,
1844
+ message
1845
+ }
1846
+ },
1847
+ fee,
1848
+ memo,
1849
+ _funds
1850
+ );
1851
+ };
1852
+ this.processDeactivateMessage = async ({
1853
+ groth16Proof,
1854
+ newDeactivateCommitment,
1855
+ newDeactivateRoot,
1856
+ size
1857
+ }, fee = "auto", memo, _funds) => {
1858
+ return await this.client.execute(
1859
+ this.sender,
1860
+ this.contractAddress,
1861
+ {
1862
+ process_deactivate_message: {
1863
+ groth16_proof: groth16Proof,
1864
+ new_deactivate_commitment: newDeactivateCommitment,
1865
+ new_deactivate_root: newDeactivateRoot,
1866
+ size
1867
+ }
1868
+ },
1869
+ fee,
1870
+ memo,
1871
+ _funds
1872
+ );
1873
+ };
1874
+ this.addNewKey = async ({
1875
+ d,
1876
+ groth16Proof,
1877
+ nullifier,
1878
+ pubkey
1879
+ }, fee = "auto", memo, _funds) => {
1880
+ return await this.client.execute(
1881
+ this.sender,
1882
+ this.contractAddress,
1883
+ {
1884
+ add_new_key: {
1885
+ d,
1886
+ groth16_proof: groth16Proof,
1887
+ nullifier,
1888
+ pubkey
1889
+ }
1890
+ },
1891
+ fee,
1892
+ memo,
1893
+ _funds
1894
+ );
1895
+ };
1896
+ this.publishMessage = async ({
1897
+ encPubKey,
1898
+ message
1899
+ }, fee = "auto", memo, _funds) => {
1900
+ return await this.client.execute(
1901
+ this.sender,
1902
+ this.contractAddress,
1903
+ {
1904
+ publish_message: {
1905
+ enc_pub_key: encPubKey,
1906
+ message
1907
+ }
1908
+ },
1909
+ fee,
1910
+ memo,
1911
+ _funds
1912
+ );
1913
+ };
1914
+ this.processMessage = async ({
1915
+ groth16Proof,
1916
+ newStateCommitment
1917
+ }, fee = "auto", memo, _funds) => {
1918
+ return await this.client.execute(
1919
+ this.sender,
1920
+ this.contractAddress,
1921
+ {
1922
+ process_message: {
1923
+ groth16_proof: groth16Proof,
1924
+ new_state_commitment: newStateCommitment
1925
+ }
1926
+ },
1927
+ fee,
1928
+ memo,
1929
+ _funds
1930
+ );
1931
+ };
1932
+ this.stopProcessingPeriod = async (fee = "auto", memo, _funds) => {
1933
+ return await this.client.execute(
1934
+ this.sender,
1935
+ this.contractAddress,
1936
+ {
1937
+ stop_processing_period: {}
1938
+ },
1939
+ fee,
1940
+ memo,
1941
+ _funds
1942
+ );
1943
+ };
1944
+ this.processTally = async ({
1945
+ groth16Proof,
1946
+ newTallyCommitment
1947
+ }, fee = "auto", memo, _funds) => {
1948
+ return await this.client.execute(
1949
+ this.sender,
1950
+ this.contractAddress,
1951
+ {
1952
+ process_tally: {
1953
+ groth16_proof: groth16Proof,
1954
+ new_tally_commitment: newTallyCommitment
1955
+ }
1956
+ },
1957
+ fee,
1958
+ memo,
1959
+ _funds
1960
+ );
1961
+ };
1962
+ this.stopTallyingPeriod = async ({
1963
+ results,
1964
+ salt
1965
+ }, fee = "auto", memo, _funds) => {
1966
+ return await this.client.execute(
1967
+ this.sender,
1968
+ this.contractAddress,
1969
+ {
1970
+ stop_tallying_period: {
1971
+ results,
1972
+ salt
1973
+ }
1974
+ },
1975
+ fee,
1976
+ memo,
1977
+ _funds
1978
+ );
1979
+ };
1980
+ this.grant = async ({
1981
+ maxAmount
1982
+ }, fee = "auto", memo, _funds) => {
1983
+ return await this.client.execute(
1984
+ this.sender,
1985
+ this.contractAddress,
1986
+ {
1987
+ grant: {
1988
+ max_amount: maxAmount
1989
+ }
1990
+ },
1991
+ fee,
1992
+ memo,
1993
+ _funds
1994
+ );
1995
+ };
1996
+ this.revoke = async (fee = "auto", memo, _funds) => {
1997
+ return await this.client.execute(
1998
+ this.sender,
1999
+ this.contractAddress,
2000
+ {
2001
+ revoke: {}
2002
+ },
2003
+ fee,
2004
+ memo,
2005
+ _funds
2006
+ );
2007
+ };
2008
+ this.bond = async (fee = "auto", memo, _funds) => {
2009
+ return await this.client.execute(
2010
+ this.sender,
2011
+ this.contractAddress,
2012
+ {
2013
+ bond: {}
2014
+ },
2015
+ fee,
2016
+ memo,
2017
+ _funds
2018
+ );
2019
+ };
2020
+ this.withdraw = async ({
2021
+ amount
2022
+ }, fee = "auto", memo, _funds) => {
2023
+ return await this.client.execute(
2024
+ this.sender,
2025
+ this.contractAddress,
2026
+ {
2027
+ withdraw: {
2028
+ amount
2029
+ }
2030
+ },
2031
+ fee,
2032
+ memo,
2033
+ _funds
2034
+ );
2035
+ };
2036
+ this.client = client;
2037
+ this.sender = sender;
2038
+ this.contractAddress = contractAddress;
2039
+ this.setParams = this.setParams.bind(this);
2040
+ this.setRoundInfo = this.setRoundInfo.bind(this);
2041
+ this.setWhitelists = this.setWhitelists.bind(this);
2042
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
2043
+ this.startVotingPeriod = this.startVotingPeriod.bind(this);
2044
+ this.signUp = this.signUp.bind(this);
2045
+ this.startProcessPeriod = this.startProcessPeriod.bind(this);
2046
+ this.stopVotingPeriod = this.stopVotingPeriod.bind(this);
2047
+ this.publishDeactivateMessage = this.publishDeactivateMessage.bind(this);
2048
+ this.processDeactivateMessage = this.processDeactivateMessage.bind(this);
2049
+ this.addNewKey = this.addNewKey.bind(this);
2050
+ this.publishMessage = this.publishMessage.bind(this);
2051
+ this.processMessage = this.processMessage.bind(this);
2052
+ this.stopProcessingPeriod = this.stopProcessingPeriod.bind(this);
2053
+ this.processTally = this.processTally.bind(this);
2054
+ this.stopTallyingPeriod = this.stopTallyingPeriod.bind(this);
2055
+ this.grant = this.grant.bind(this);
2056
+ this.revoke = this.revoke.bind(this);
2057
+ this.bond = this.bond.bind(this);
2058
+ this.withdraw = this.withdraw.bind(this);
2059
+ }
2060
+ };
2061
+
2062
+ // src/libs/contract/ts/AMaci.client.ts
2063
+ var AMaciQueryClient = class {
2064
+ constructor(client, contractAddress) {
2065
+ this.admin = async () => {
2066
+ return this.client.queryContractSmart(this.contractAddress, {
2067
+ admin: {}
2068
+ });
2069
+ };
2070
+ this.operator = async () => {
2071
+ return this.client.queryContractSmart(this.contractAddress, {
2072
+ operator: {}
2073
+ });
2074
+ };
2075
+ this.getRoundInfo = async () => {
2076
+ return this.client.queryContractSmart(this.contractAddress, {
2077
+ get_round_info: {}
2078
+ });
2079
+ };
2080
+ this.getVotingTime = async () => {
2081
+ return this.client.queryContractSmart(this.contractAddress, {
2082
+ get_voting_time: {}
2083
+ });
2084
+ };
2085
+ this.getPeriod = async () => {
2086
+ return this.client.queryContractSmart(this.contractAddress, {
2087
+ get_period: {}
2088
+ });
2089
+ };
2090
+ this.getNumSignUp = async () => {
2091
+ return this.client.queryContractSmart(this.contractAddress, {
2092
+ get_num_sign_up: {}
2093
+ });
2094
+ };
2095
+ this.getMsgChainLength = async () => {
2096
+ return this.client.queryContractSmart(this.contractAddress, {
2097
+ get_msg_chain_length: {}
2098
+ });
2099
+ };
2100
+ this.getDMsgChainLength = async () => {
2101
+ return this.client.queryContractSmart(this.contractAddress, {
2102
+ get_d_msg_chain_length: {}
2103
+ });
2104
+ };
2105
+ this.getProcessedDMsgCount = async () => {
2106
+ return this.client.queryContractSmart(this.contractAddress, {
2107
+ get_processed_d_msg_count: {}
2108
+ });
2109
+ };
2110
+ this.getProcessedMsgCount = async () => {
2111
+ return this.client.queryContractSmart(this.contractAddress, {
2112
+ get_processed_msg_count: {}
2113
+ });
2114
+ };
2115
+ this.getProcessedUserCount = async () => {
2116
+ return this.client.queryContractSmart(this.contractAddress, {
2117
+ get_processed_user_count: {}
2118
+ });
2119
+ };
2120
+ this.getResult = async ({ index }) => {
2121
+ return this.client.queryContractSmart(this.contractAddress, {
2122
+ get_result: {
2123
+ index
2124
+ }
2125
+ });
2126
+ };
2127
+ this.getAllResult = async () => {
2128
+ return this.client.queryContractSmart(this.contractAddress, {
2129
+ get_all_result: {}
2130
+ });
2131
+ };
2132
+ this.getStateIdxInc = async ({
2133
+ address
2134
+ }) => {
2135
+ return this.client.queryContractSmart(this.contractAddress, {
2136
+ get_state_idx_inc: {
2137
+ address
2138
+ }
2139
+ });
2140
+ };
2141
+ this.getVoiceCreditBalance = async ({
2142
+ index
2143
+ }) => {
2144
+ return this.client.queryContractSmart(this.contractAddress, {
2145
+ get_voice_credit_balance: {
2146
+ index
2147
+ }
2148
+ });
2149
+ };
2150
+ this.getVoiceCreditAmount = async () => {
2151
+ return this.client.queryContractSmart(this.contractAddress, {
2152
+ get_voice_credit_amount: {}
2153
+ });
2154
+ };
2155
+ this.whiteList = async () => {
2156
+ return this.client.queryContractSmart(this.contractAddress, {
2157
+ white_list: {}
2158
+ });
2159
+ };
2160
+ this.isWhiteList = async ({ sender }) => {
2161
+ return this.client.queryContractSmart(this.contractAddress, {
2162
+ is_white_list: {
2163
+ sender
2164
+ }
2165
+ });
2166
+ };
2167
+ this.signuped = async ({ pubkeyX }) => {
2168
+ return this.client.queryContractSmart(this.contractAddress, {
2169
+ signuped: {
2170
+ pubkey_x: pubkeyX
2171
+ }
2172
+ });
2173
+ };
2174
+ this.voteOptionMap = async () => {
2175
+ return this.client.queryContractSmart(this.contractAddress, {
2176
+ vote_option_map: {}
2177
+ });
2178
+ };
2179
+ this.maxVoteOptions = async () => {
2180
+ return this.client.queryContractSmart(this.contractAddress, {
2181
+ max_vote_options: {}
2182
+ });
2183
+ };
2184
+ this.queryTotalFeeGrant = async () => {
2185
+ return this.client.queryContractSmart(this.contractAddress, {
2186
+ query_total_fee_grant: {}
2187
+ });
2188
+ };
2189
+ this.queryCircuitType = async () => {
2190
+ return this.client.queryContractSmart(this.contractAddress, {
2191
+ query_circuit_type: {}
2192
+ });
2193
+ };
2194
+ this.queryCertSystem = async () => {
2195
+ return this.client.queryContractSmart(this.contractAddress, {
2196
+ query_cert_system: {}
2197
+ });
2198
+ };
2199
+ this.queryPreDeactivateRoot = async () => {
2200
+ return this.client.queryContractSmart(this.contractAddress, {
2201
+ query_pre_deactivate_root: {}
2202
+ });
2203
+ };
2204
+ this.client = client;
2205
+ this.contractAddress = contractAddress;
2206
+ this.admin = this.admin.bind(this);
2207
+ this.operator = this.operator.bind(this);
2208
+ this.getRoundInfo = this.getRoundInfo.bind(this);
2209
+ this.getVotingTime = this.getVotingTime.bind(this);
2210
+ this.getPeriod = this.getPeriod.bind(this);
2211
+ this.getNumSignUp = this.getNumSignUp.bind(this);
2212
+ this.getMsgChainLength = this.getMsgChainLength.bind(this);
2213
+ this.getDMsgChainLength = this.getDMsgChainLength.bind(this);
2214
+ this.getProcessedDMsgCount = this.getProcessedDMsgCount.bind(this);
2215
+ this.getProcessedMsgCount = this.getProcessedMsgCount.bind(this);
2216
+ this.getProcessedUserCount = this.getProcessedUserCount.bind(this);
2217
+ this.getResult = this.getResult.bind(this);
2218
+ this.getAllResult = this.getAllResult.bind(this);
2219
+ this.getStateIdxInc = this.getStateIdxInc.bind(this);
2220
+ this.getVoiceCreditBalance = this.getVoiceCreditBalance.bind(this);
2221
+ this.getVoiceCreditAmount = this.getVoiceCreditAmount.bind(this);
2222
+ this.whiteList = this.whiteList.bind(this);
2223
+ this.isWhiteList = this.isWhiteList.bind(this);
2224
+ this.signuped = this.signuped.bind(this);
2225
+ this.voteOptionMap = this.voteOptionMap.bind(this);
2226
+ this.maxVoteOptions = this.maxVoteOptions.bind(this);
2227
+ this.queryTotalFeeGrant = this.queryTotalFeeGrant.bind(this);
2228
+ this.queryCircuitType = this.queryCircuitType.bind(this);
2229
+ this.queryCertSystem = this.queryCertSystem.bind(this);
2230
+ this.queryPreDeactivateRoot = this.queryPreDeactivateRoot.bind(this);
2231
+ }
2232
+ };
2233
+ var AMaciClient = class extends AMaciQueryClient {
2234
+ constructor(client, sender, contractAddress) {
2235
+ super(client, contractAddress);
2236
+ this.setRoundInfo = async ({
2237
+ roundInfo
2238
+ }, fee = "auto", memo, _funds) => {
2239
+ return await this.client.execute(
2240
+ this.sender,
2241
+ this.contractAddress,
2242
+ {
2243
+ set_round_info: {
2244
+ round_info: roundInfo
2245
+ }
2246
+ },
2247
+ fee,
2248
+ memo,
2249
+ _funds
2250
+ );
2251
+ };
2252
+ this.setWhitelists = async ({
2253
+ whitelists
2254
+ }, fee = "auto", memo, _funds) => {
2255
+ return await this.client.execute(
2256
+ this.sender,
2257
+ this.contractAddress,
2258
+ {
2259
+ set_whitelists: {
2260
+ whitelists
2261
+ }
2262
+ },
2263
+ fee,
2264
+ memo,
2265
+ _funds
2266
+ );
2267
+ };
2268
+ this.setVoteOptionsMap = async ({
2269
+ voteOptionMap
2270
+ }, fee = "auto", memo, _funds) => {
2271
+ return await this.client.execute(
2272
+ this.sender,
2273
+ this.contractAddress,
2274
+ {
2275
+ set_vote_options_map: {
2276
+ vote_option_map: voteOptionMap
2277
+ }
2278
+ },
2279
+ fee,
2280
+ memo,
2281
+ _funds
2282
+ );
2283
+ };
2284
+ this.signUp = async ({
2285
+ pubkey
2286
+ }, fee = "auto", memo, _funds) => {
2287
+ return await this.client.execute(
2288
+ this.sender,
2289
+ this.contractAddress,
2290
+ {
2291
+ sign_up: {
2292
+ pubkey
2293
+ }
2294
+ },
2295
+ fee,
2296
+ memo,
2297
+ _funds
2298
+ );
2299
+ };
2300
+ this.startProcessPeriod = async (fee = "auto", memo, _funds) => {
2301
+ return await this.client.execute(
2302
+ this.sender,
2303
+ this.contractAddress,
2304
+ {
2305
+ start_process_period: {}
2306
+ },
2307
+ fee,
2308
+ memo,
2309
+ _funds
2310
+ );
2311
+ };
2312
+ this.publishDeactivateMessage = async ({
2313
+ encPubKey,
2314
+ message
2315
+ }, fee = "auto", memo, _funds) => {
2316
+ return await this.client.execute(
2317
+ this.sender,
2318
+ this.contractAddress,
2319
+ {
2320
+ publish_deactivate_message: {
2321
+ enc_pub_key: encPubKey,
2322
+ message
2323
+ }
2324
+ },
2325
+ fee,
2326
+ memo,
2327
+ _funds
2328
+ );
2329
+ };
2330
+ this.processDeactivateMessage = async ({
2331
+ groth16Proof,
2332
+ newDeactivateCommitment,
2333
+ newDeactivateRoot,
2334
+ size
2335
+ }, fee = "auto", memo, _funds) => {
2336
+ return await this.client.execute(
2337
+ this.sender,
2338
+ this.contractAddress,
2339
+ {
2340
+ process_deactivate_message: {
2341
+ groth16_proof: groth16Proof,
2342
+ new_deactivate_commitment: newDeactivateCommitment,
2343
+ new_deactivate_root: newDeactivateRoot,
2344
+ size
2345
+ }
2346
+ },
2347
+ fee,
2348
+ memo,
2349
+ _funds
2350
+ );
2351
+ };
2352
+ this.addNewKey = async ({
2353
+ d,
2354
+ groth16Proof,
2355
+ nullifier,
2356
+ pubkey
2357
+ }, fee = "auto", memo, _funds) => {
2358
+ return await this.client.execute(
2359
+ this.sender,
2360
+ this.contractAddress,
2361
+ {
2362
+ add_new_key: {
2363
+ d,
2364
+ groth16_proof: groth16Proof,
2365
+ nullifier,
2366
+ pubkey
2367
+ }
2368
+ },
2369
+ fee,
2370
+ memo,
2371
+ _funds
2372
+ );
2373
+ };
2374
+ this.preAddNewKey = async ({
2375
+ d,
2376
+ groth16Proof,
2377
+ nullifier,
2378
+ pubkey
2379
+ }, fee = "auto", memo, _funds) => {
2380
+ return await this.client.execute(
2381
+ this.sender,
2382
+ this.contractAddress,
2383
+ {
2384
+ pre_add_new_key: {
2385
+ d,
2386
+ groth16_proof: groth16Proof,
2387
+ nullifier,
2388
+ pubkey
2389
+ }
2390
+ },
2391
+ fee,
2392
+ memo,
2393
+ _funds
2394
+ );
2395
+ };
2396
+ this.publishMessage = async ({
2397
+ encPubKey,
2398
+ message
2399
+ }, fee = "auto", memo, _funds) => {
2400
+ return await this.client.execute(
2401
+ this.sender,
2402
+ this.contractAddress,
2403
+ {
2404
+ publish_message: {
2405
+ enc_pub_key: encPubKey,
2406
+ message
2407
+ }
2408
+ },
2409
+ fee,
2410
+ memo,
2411
+ _funds
2412
+ );
2413
+ };
2414
+ this.processMessage = async ({
2415
+ groth16Proof,
2416
+ newStateCommitment
2417
+ }, fee = "auto", memo, _funds) => {
2418
+ return await this.client.execute(
2419
+ this.sender,
2420
+ this.contractAddress,
2421
+ {
2422
+ process_message: {
2423
+ groth16_proof: groth16Proof,
2424
+ new_state_commitment: newStateCommitment
2425
+ }
2426
+ },
2427
+ fee,
2428
+ memo,
2429
+ _funds
2430
+ );
2431
+ };
2432
+ this.stopProcessingPeriod = async (fee = "auto", memo, _funds) => {
2433
+ return await this.client.execute(
2434
+ this.sender,
2435
+ this.contractAddress,
2436
+ {
2437
+ stop_processing_period: {}
2438
+ },
2439
+ fee,
2440
+ memo,
2441
+ _funds
2442
+ );
2443
+ };
2444
+ this.processTally = async ({
2445
+ groth16Proof,
2446
+ newTallyCommitment
2447
+ }, fee = "auto", memo, _funds) => {
2448
+ return await this.client.execute(
2449
+ this.sender,
2450
+ this.contractAddress,
2451
+ {
2452
+ process_tally: {
2453
+ groth16_proof: groth16Proof,
2454
+ new_tally_commitment: newTallyCommitment
2455
+ }
2456
+ },
2457
+ fee,
2458
+ memo,
2459
+ _funds
2460
+ );
2461
+ };
2462
+ this.stopTallyingPeriod = async ({
2463
+ results,
2464
+ salt
2465
+ }, fee = "auto", memo, _funds) => {
2466
+ return await this.client.execute(
2467
+ this.sender,
2468
+ this.contractAddress,
2469
+ {
2470
+ stop_tallying_period: {
2471
+ results,
2472
+ salt
2473
+ }
2474
+ },
2475
+ fee,
2476
+ memo,
2477
+ _funds
2478
+ );
2479
+ };
2480
+ this.grant = async ({
2481
+ maxAmount
2482
+ }, fee = "auto", memo, _funds) => {
2483
+ return await this.client.execute(
2484
+ this.sender,
2485
+ this.contractAddress,
2486
+ {
2487
+ grant: {
2488
+ max_amount: maxAmount
2489
+ }
2490
+ },
2491
+ fee,
2492
+ memo,
2493
+ _funds
2494
+ );
2495
+ };
2496
+ this.revoke = async (fee = "auto", memo, _funds) => {
2497
+ return await this.client.execute(
2498
+ this.sender,
2499
+ this.contractAddress,
2500
+ {
2501
+ revoke: {}
2502
+ },
2503
+ fee,
2504
+ memo,
2505
+ _funds
2506
+ );
2507
+ };
2508
+ this.bond = async (fee = "auto", memo, _funds) => {
2509
+ return await this.client.execute(
2510
+ this.sender,
2511
+ this.contractAddress,
2512
+ {
2513
+ bond: {}
2514
+ },
2515
+ fee,
2516
+ memo,
2517
+ _funds
2518
+ );
2519
+ };
2520
+ this.withdraw = async ({
2521
+ amount
2522
+ }, fee = "auto", memo, _funds) => {
2523
+ return await this.client.execute(
2524
+ this.sender,
2525
+ this.contractAddress,
2526
+ {
2527
+ withdraw: {
2528
+ amount
2529
+ }
2530
+ },
2531
+ fee,
2532
+ memo,
2533
+ _funds
2534
+ );
2535
+ };
2536
+ this.client = client;
2537
+ this.sender = sender;
2538
+ this.contractAddress = contractAddress;
2539
+ this.setRoundInfo = this.setRoundInfo.bind(this);
2540
+ this.setWhitelists = this.setWhitelists.bind(this);
2541
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
2542
+ this.signUp = this.signUp.bind(this);
2543
+ this.startProcessPeriod = this.startProcessPeriod.bind(this);
2544
+ this.publishDeactivateMessage = this.publishDeactivateMessage.bind(this);
2545
+ this.processDeactivateMessage = this.processDeactivateMessage.bind(this);
2546
+ this.addNewKey = this.addNewKey.bind(this);
2547
+ this.preAddNewKey = this.preAddNewKey.bind(this);
2548
+ this.publishMessage = this.publishMessage.bind(this);
2549
+ this.processMessage = this.processMessage.bind(this);
2550
+ this.stopProcessingPeriod = this.stopProcessingPeriod.bind(this);
2551
+ this.processTally = this.processTally.bind(this);
2552
+ this.stopTallyingPeriod = this.stopTallyingPeriod.bind(this);
2553
+ this.grant = this.grant.bind(this);
2554
+ this.revoke = this.revoke.bind(this);
2555
+ this.bond = this.bond.bind(this);
2556
+ this.withdraw = this.withdraw.bind(this);
2557
+ }
2558
+ };
2559
+
2560
+ // src/libs/contract/ts/Registry.client.ts
2561
+ var RegistryQueryClient = class {
2562
+ constructor(client, contractAddress) {
2563
+ this.admin = async () => {
2564
+ return this.client.queryContractSmart(this.contractAddress, {
2565
+ admin: {}
2566
+ });
2567
+ };
2568
+ this.operator = async () => {
2569
+ return this.client.queryContractSmart(this.contractAddress, {
2570
+ operator: {}
2571
+ });
2572
+ };
2573
+ this.isMaciOperator = async ({
2574
+ address
2575
+ }) => {
2576
+ return this.client.queryContractSmart(this.contractAddress, {
2577
+ is_maci_operator: {
2578
+ address
2579
+ }
2580
+ });
2581
+ };
2582
+ this.isValidator = async ({ address }) => {
2583
+ return this.client.queryContractSmart(this.contractAddress, {
2584
+ is_validator: {
2585
+ address
2586
+ }
2587
+ });
2588
+ };
2589
+ this.getValidators = async () => {
2590
+ return this.client.queryContractSmart(this.contractAddress, {
2591
+ get_validators: {}
2592
+ });
2593
+ };
2594
+ this.getValidatorOperator = async ({
2595
+ address
2596
+ }) => {
2597
+ return this.client.queryContractSmart(this.contractAddress, {
2598
+ get_validator_operator: {
2599
+ address
2600
+ }
2601
+ });
2602
+ };
2603
+ this.getMaciOperatorPubkey = async ({
2604
+ address
2605
+ }) => {
2606
+ return this.client.queryContractSmart(this.contractAddress, {
2607
+ get_maci_operator_pubkey: {
2608
+ address
2609
+ }
2610
+ });
2611
+ };
2612
+ this.getMaciOperatorIdentity = async ({
2613
+ address
2614
+ }) => {
2615
+ return this.client.queryContractSmart(this.contractAddress, {
2616
+ get_maci_operator_identity: {
2617
+ address
2618
+ }
2619
+ });
2620
+ };
2621
+ this.client = client;
2622
+ this.contractAddress = contractAddress;
2623
+ this.admin = this.admin.bind(this);
2624
+ this.operator = this.operator.bind(this);
2625
+ this.isMaciOperator = this.isMaciOperator.bind(this);
2626
+ this.isValidator = this.isValidator.bind(this);
2627
+ this.getValidators = this.getValidators.bind(this);
2628
+ this.getValidatorOperator = this.getValidatorOperator.bind(this);
2629
+ this.getMaciOperatorPubkey = this.getMaciOperatorPubkey.bind(this);
2630
+ this.getMaciOperatorIdentity = this.getMaciOperatorIdentity.bind(this);
2631
+ }
2632
+ };
2633
+ var RegistryClient = class extends RegistryQueryClient {
2634
+ constructor(client, sender, contractAddress) {
2635
+ super(client, contractAddress);
2636
+ this.setMaciOperator = async ({
2637
+ operator
2638
+ }, fee = "auto", memo, _funds) => {
2639
+ return await this.client.execute(
2640
+ this.sender,
2641
+ this.contractAddress,
2642
+ {
2643
+ set_maci_operator: {
2644
+ operator
2645
+ }
2646
+ },
2647
+ fee,
2648
+ memo,
2649
+ _funds
2650
+ );
2651
+ };
2652
+ this.setMaciOperatorPubkey = async ({
2653
+ pubkey
2654
+ }, fee = "auto", memo, _funds) => {
2655
+ return await this.client.execute(
2656
+ this.sender,
2657
+ this.contractAddress,
2658
+ {
2659
+ set_maci_operator_pubkey: {
2660
+ pubkey
2661
+ }
2662
+ },
2663
+ fee,
2664
+ memo,
2665
+ _funds
2666
+ );
2667
+ };
2668
+ this.setMaciOperatorIdentity = async ({
2669
+ identity
2670
+ }, fee = "auto", memo, _funds) => {
2671
+ return await this.client.execute(
2672
+ this.sender,
2673
+ this.contractAddress,
2674
+ {
2675
+ set_maci_operator_identity: {
2676
+ identity
2677
+ }
2678
+ },
2679
+ fee,
2680
+ memo,
2681
+ _funds
2682
+ );
2683
+ };
2684
+ this.createRound = async ({
2685
+ certificationSystem,
2686
+ circuitType,
2687
+ maxOption,
2688
+ maxVoter,
2689
+ operator,
2690
+ preDeactivateRoot,
2691
+ roundInfo,
2692
+ voiceCreditAmount,
2693
+ votingTime,
2694
+ whitelist
2695
+ }, fee = "auto", memo, _funds) => {
2696
+ return await this.client.execute(
2697
+ this.sender,
2698
+ this.contractAddress,
2699
+ {
2700
+ create_round: {
2701
+ certification_system: certificationSystem,
2702
+ circuit_type: circuitType,
2703
+ max_option: maxOption,
2704
+ max_voter: maxVoter,
2705
+ operator,
2706
+ pre_deactivate_root: preDeactivateRoot,
2707
+ round_info: roundInfo,
2708
+ voice_credit_amount: voiceCreditAmount,
2709
+ voting_time: votingTime,
2710
+ whitelist
2711
+ }
2712
+ },
2713
+ fee,
2714
+ memo,
2715
+ _funds
2716
+ );
2717
+ };
2718
+ this.setValidators = async ({
2719
+ addresses
2720
+ }, fee = "auto", memo, _funds) => {
2721
+ return await this.client.execute(
2722
+ this.sender,
2723
+ this.contractAddress,
2724
+ {
2725
+ set_validators: {
2726
+ addresses
2727
+ }
2728
+ },
2729
+ fee,
2730
+ memo,
2731
+ _funds
2732
+ );
2733
+ };
2734
+ this.removeValidator = async ({
2735
+ address
2736
+ }, fee = "auto", memo, _funds) => {
2737
+ return await this.client.execute(
2738
+ this.sender,
2739
+ this.contractAddress,
2740
+ {
2741
+ remove_validator: {
2742
+ address
2743
+ }
2744
+ },
2745
+ fee,
2746
+ memo,
2747
+ _funds
2748
+ );
2749
+ };
2750
+ this.updateAmaciCodeId = async ({
2751
+ amaciCodeId
2752
+ }, fee = "auto", memo, _funds) => {
2753
+ return await this.client.execute(
2754
+ this.sender,
2755
+ this.contractAddress,
2756
+ {
2757
+ update_amaci_code_id: {
2758
+ amaci_code_id: amaciCodeId
2759
+ }
2760
+ },
2761
+ fee,
2762
+ memo,
2763
+ _funds
2764
+ );
2765
+ };
2766
+ this.changeOperator = async ({
2767
+ address
2768
+ }, fee = "auto", memo, _funds) => {
2769
+ return await this.client.execute(
2770
+ this.sender,
2771
+ this.contractAddress,
2772
+ {
2773
+ change_operator: {
2774
+ address
2775
+ }
2776
+ },
2777
+ fee,
2778
+ memo,
2779
+ _funds
2780
+ );
2781
+ };
2782
+ this.client = client;
2783
+ this.sender = sender;
2784
+ this.contractAddress = contractAddress;
2785
+ this.setMaciOperator = this.setMaciOperator.bind(this);
2786
+ this.setMaciOperatorPubkey = this.setMaciOperatorPubkey.bind(this);
2787
+ this.setMaciOperatorIdentity = this.setMaciOperatorIdentity.bind(this);
2788
+ this.createRound = this.createRound.bind(this);
2789
+ this.setValidators = this.setValidators.bind(this);
2790
+ this.removeValidator = this.removeValidator.bind(this);
2791
+ this.updateAmaciCodeId = this.updateAmaciCodeId.bind(this);
2792
+ this.changeOperator = this.changeOperator.bind(this);
2793
+ }
2794
+ };
2795
+
2796
+ // src/libs/contract/ts/OracleMaci.client.ts
2797
+ var OracleMaciQueryClient = class {
2798
+ constructor(client, contractAddress) {
2799
+ this.getRoundInfo = async () => {
2800
+ return this.client.queryContractSmart(this.contractAddress, {
2801
+ get_round_info: {}
2802
+ });
2803
+ };
2804
+ this.getVotingTime = async () => {
2805
+ return this.client.queryContractSmart(this.contractAddress, {
2806
+ get_voting_time: {}
2807
+ });
2808
+ };
2809
+ this.getPeriod = async () => {
2810
+ return this.client.queryContractSmart(this.contractAddress, {
2811
+ get_period: {}
2812
+ });
2813
+ };
2814
+ this.getNumSignUp = async () => {
2815
+ return this.client.queryContractSmart(this.contractAddress, {
2816
+ get_num_sign_up: {}
2817
+ });
2818
+ };
2819
+ this.getMsgChainLength = async () => {
2820
+ return this.client.queryContractSmart(this.contractAddress, {
2821
+ get_msg_chain_length: {}
2822
+ });
2823
+ };
2824
+ this.getProcessedMsgCount = async () => {
2825
+ return this.client.queryContractSmart(this.contractAddress, {
2826
+ get_processed_msg_count: {}
2827
+ });
2828
+ };
2829
+ this.getProcessedUserCount = async () => {
2830
+ return this.client.queryContractSmart(this.contractAddress, {
2831
+ get_processed_user_count: {}
2832
+ });
2833
+ };
2834
+ this.getResult = async ({
2835
+ index
2836
+ }) => {
2837
+ return this.client.queryContractSmart(this.contractAddress, {
2838
+ get_result: {
2839
+ index
2840
+ }
2841
+ });
2842
+ };
2843
+ this.getAllResult = async () => {
2844
+ return this.client.queryContractSmart(this.contractAddress, {
2845
+ get_all_result: {}
2846
+ });
2847
+ };
2848
+ this.getStateIdxInc = async ({
2849
+ address
2850
+ }) => {
2851
+ return this.client.queryContractSmart(this.contractAddress, {
2852
+ get_state_idx_inc: {
2853
+ address
2854
+ }
2855
+ });
2856
+ };
2857
+ this.getVoiceCreditBalance = async ({
2858
+ index
2859
+ }) => {
2860
+ return this.client.queryContractSmart(this.contractAddress, {
2861
+ get_voice_credit_balance: {
2862
+ index
2863
+ }
2864
+ });
2865
+ };
2866
+ this.isWhiteList = async ({
2867
+ amount,
2868
+ certificate,
2869
+ sender
2870
+ }) => {
2871
+ return this.client.queryContractSmart(this.contractAddress, {
2872
+ is_white_list: {
2873
+ amount,
2874
+ certificate,
2875
+ sender
2876
+ }
2877
+ });
2878
+ };
2879
+ this.whiteBalanceOf = async ({
2880
+ amount,
2881
+ certificate,
2882
+ sender
2883
+ }) => {
2884
+ return this.client.queryContractSmart(this.contractAddress, {
2885
+ white_balance_of: {
2886
+ amount,
2887
+ certificate,
2888
+ sender
2889
+ }
2890
+ });
2891
+ };
2892
+ this.whiteInfo = async ({
2893
+ sender
2894
+ }) => {
2895
+ return this.client.queryContractSmart(this.contractAddress, {
2896
+ white_info: {
2897
+ sender
2898
+ }
2899
+ });
2900
+ };
2901
+ this.grantInfo = async ({
2902
+ grantee
2903
+ }) => {
2904
+ return this.client.queryContractSmart(this.contractAddress, {
2905
+ grant_info: {
2906
+ grantee
2907
+ }
2908
+ });
2909
+ };
2910
+ this.maxWhitelistNum = async () => {
2911
+ return this.client.queryContractSmart(this.contractAddress, {
2912
+ max_whitelist_num: {}
2913
+ });
2914
+ };
2915
+ this.voteOptionMap = async () => {
2916
+ return this.client.queryContractSmart(this.contractAddress, {
2917
+ vote_option_map: {}
2918
+ });
2919
+ };
2920
+ this.maxVoteOptions = async () => {
2921
+ return this.client.queryContractSmart(this.contractAddress, {
2922
+ max_vote_options: {}
2923
+ });
2924
+ };
2925
+ this.queryTotalFeeGrant = async () => {
2926
+ return this.client.queryContractSmart(this.contractAddress, {
2927
+ query_total_fee_grant: {}
2928
+ });
2929
+ };
2930
+ this.queryCircuitType = async () => {
2931
+ return this.client.queryContractSmart(this.contractAddress, {
2932
+ query_circuit_type: {}
2933
+ });
2934
+ };
2935
+ this.queryCertSystem = async () => {
2936
+ return this.client.queryContractSmart(this.contractAddress, {
2937
+ query_cert_system: {}
2938
+ });
2939
+ };
2940
+ this.queryOracleWhitelistConfig = async () => {
2941
+ return this.client.queryContractSmart(this.contractAddress, {
2942
+ query_oracle_whitelist_config: {}
2943
+ });
2944
+ };
2945
+ this.client = client;
2946
+ this.contractAddress = contractAddress;
2947
+ this.getRoundInfo = this.getRoundInfo.bind(this);
2948
+ this.getVotingTime = this.getVotingTime.bind(this);
2949
+ this.getPeriod = this.getPeriod.bind(this);
2950
+ this.getNumSignUp = this.getNumSignUp.bind(this);
2951
+ this.getMsgChainLength = this.getMsgChainLength.bind(this);
2952
+ this.getProcessedMsgCount = this.getProcessedMsgCount.bind(this);
2953
+ this.getProcessedUserCount = this.getProcessedUserCount.bind(this);
2954
+ this.getResult = this.getResult.bind(this);
2955
+ this.getAllResult = this.getAllResult.bind(this);
2956
+ this.getStateIdxInc = this.getStateIdxInc.bind(this);
2957
+ this.getVoiceCreditBalance = this.getVoiceCreditBalance.bind(this);
2958
+ this.isWhiteList = this.isWhiteList.bind(this);
2959
+ this.whiteBalanceOf = this.whiteBalanceOf.bind(this);
2960
+ this.whiteInfo = this.whiteInfo.bind(this);
2961
+ this.grantInfo = this.grantInfo.bind(this);
2962
+ this.maxWhitelistNum = this.maxWhitelistNum.bind(this);
2963
+ this.voteOptionMap = this.voteOptionMap.bind(this);
2964
+ this.maxVoteOptions = this.maxVoteOptions.bind(this);
2965
+ this.queryTotalFeeGrant = this.queryTotalFeeGrant.bind(this);
2966
+ this.queryCircuitType = this.queryCircuitType.bind(this);
2967
+ this.queryCertSystem = this.queryCertSystem.bind(this);
2968
+ this.queryOracleWhitelistConfig = this.queryOracleWhitelistConfig.bind(this);
2969
+ }
2970
+ };
2971
+ var OracleMaciClient = class extends OracleMaciQueryClient {
2972
+ constructor(client, sender, contractAddress) {
2973
+ super(client, contractAddress);
2974
+ this.setParams = async ({
2975
+ intStateTreeDepth,
2976
+ messageBatchSize,
2977
+ stateTreeDepth,
2978
+ voteOptionTreeDepth
2979
+ }, fee = "auto", memo, _funds) => {
2980
+ return await this.client.execute(this.sender, this.contractAddress, {
2981
+ set_params: {
2982
+ int_state_tree_depth: intStateTreeDepth,
2983
+ message_batch_size: messageBatchSize,
2984
+ state_tree_depth: stateTreeDepth,
2985
+ vote_option_tree_depth: voteOptionTreeDepth
2986
+ }
2987
+ }, fee, memo, _funds);
2988
+ };
2989
+ this.setRoundInfo = async ({
2990
+ roundInfo
2991
+ }, fee = "auto", memo, _funds) => {
2992
+ return await this.client.execute(this.sender, this.contractAddress, {
2993
+ set_round_info: {
2994
+ round_info: roundInfo
2995
+ }
2996
+ }, fee, memo, _funds);
2997
+ };
2998
+ this.setVoteOptionsMap = async ({
2999
+ voteOptionMap
3000
+ }, fee = "auto", memo, _funds) => {
3001
+ return await this.client.execute(this.sender, this.contractAddress, {
3002
+ set_vote_options_map: {
3003
+ vote_option_map: voteOptionMap
3004
+ }
3005
+ }, fee, memo, _funds);
3006
+ };
3007
+ this.startVotingPeriod = async (fee = "auto", memo, _funds) => {
3008
+ return await this.client.execute(this.sender, this.contractAddress, {
3009
+ start_voting_period: {}
3010
+ }, fee, memo, _funds);
3011
+ };
3012
+ this.signUp = async ({
3013
+ amount,
3014
+ certificate,
3015
+ pubkey
3016
+ }, fee = "auto", memo, _funds) => {
3017
+ return await this.client.execute(this.sender, this.contractAddress, {
3018
+ sign_up: {
3019
+ amount,
3020
+ certificate,
3021
+ pubkey
3022
+ }
3023
+ }, fee, memo, _funds);
3024
+ };
3025
+ this.startProcessPeriod = async (fee = "auto", memo, _funds) => {
3026
+ return await this.client.execute(this.sender, this.contractAddress, {
3027
+ start_process_period: {}
3028
+ }, fee, memo, _funds);
3029
+ };
3030
+ this.stopVotingPeriod = async (fee = "auto", memo, _funds) => {
3031
+ return await this.client.execute(this.sender, this.contractAddress, {
3032
+ stop_voting_period: {}
3033
+ }, fee, memo, _funds);
3034
+ };
3035
+ this.publishMessage = async ({
3036
+ encPubKey,
3037
+ message
3038
+ }, fee = "auto", memo, _funds) => {
3039
+ return await this.client.execute(this.sender, this.contractAddress, {
3040
+ publish_message: {
3041
+ enc_pub_key: encPubKey,
3042
+ message
3043
+ }
3044
+ }, fee, memo, _funds);
3045
+ };
3046
+ this.processMessage = async ({
3047
+ groth16Proof,
3048
+ newStateCommitment,
3049
+ plonkProof
3050
+ }, fee = "auto", memo, _funds) => {
3051
+ return await this.client.execute(this.sender, this.contractAddress, {
3052
+ process_message: {
3053
+ groth16_proof: groth16Proof,
3054
+ new_state_commitment: newStateCommitment,
3055
+ plonk_proof: plonkProof
3056
+ }
3057
+ }, fee, memo, _funds);
3058
+ };
3059
+ this.stopProcessingPeriod = async (fee = "auto", memo, _funds) => {
3060
+ return await this.client.execute(this.sender, this.contractAddress, {
3061
+ stop_processing_period: {}
3062
+ }, fee, memo, _funds);
3063
+ };
3064
+ this.processTally = async ({
3065
+ groth16Proof,
3066
+ newTallyCommitment,
3067
+ plonkProof
3068
+ }, fee = "auto", memo, _funds) => {
3069
+ return await this.client.execute(this.sender, this.contractAddress, {
3070
+ process_tally: {
3071
+ groth16_proof: groth16Proof,
3072
+ new_tally_commitment: newTallyCommitment,
3073
+ plonk_proof: plonkProof
3074
+ }
3075
+ }, fee, memo, _funds);
3076
+ };
3077
+ this.stopTallyingPeriod = async ({
3078
+ results,
3079
+ salt
3080
+ }, fee = "auto", memo, _funds) => {
3081
+ return await this.client.execute(this.sender, this.contractAddress, {
3082
+ stop_tallying_period: {
3083
+ results,
3084
+ salt
3085
+ }
3086
+ }, fee, memo, _funds);
3087
+ };
3088
+ this.grant = async ({
3089
+ baseAmount,
3090
+ grantee
3091
+ }, fee = "auto", memo, _funds) => {
3092
+ return await this.client.execute(this.sender, this.contractAddress, {
3093
+ grant: {
3094
+ base_amount: baseAmount,
3095
+ grantee
3096
+ }
3097
+ }, fee, memo, _funds);
3098
+ };
3099
+ this.revoke = async ({
3100
+ grantee
3101
+ }, fee = "auto", memo, _funds) => {
3102
+ return await this.client.execute(this.sender, this.contractAddress, {
3103
+ revoke: {
3104
+ grantee
3105
+ }
3106
+ }, fee, memo, _funds);
3107
+ };
3108
+ this.bond = async (fee = "auto", memo, _funds) => {
3109
+ return await this.client.execute(this.sender, this.contractAddress, {
3110
+ bond: {}
3111
+ }, fee, memo, _funds);
3112
+ };
3113
+ this.withdraw = async ({
3114
+ amount
3115
+ }, fee = "auto", memo, _funds) => {
3116
+ return await this.client.execute(this.sender, this.contractAddress, {
3117
+ withdraw: {
3118
+ amount
3119
+ }
3120
+ }, fee, memo, _funds);
3121
+ };
3122
+ this.client = client;
3123
+ this.sender = sender;
3124
+ this.contractAddress = contractAddress;
3125
+ this.setParams = this.setParams.bind(this);
3126
+ this.setRoundInfo = this.setRoundInfo.bind(this);
3127
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
3128
+ this.startVotingPeriod = this.startVotingPeriod.bind(this);
3129
+ this.signUp = this.signUp.bind(this);
3130
+ this.startProcessPeriod = this.startProcessPeriod.bind(this);
3131
+ this.stopVotingPeriod = this.stopVotingPeriod.bind(this);
3132
+ this.publishMessage = this.publishMessage.bind(this);
3133
+ this.processMessage = this.processMessage.bind(this);
3134
+ this.stopProcessingPeriod = this.stopProcessingPeriod.bind(this);
3135
+ this.processTally = this.processTally.bind(this);
3136
+ this.stopTallyingPeriod = this.stopTallyingPeriod.bind(this);
3137
+ this.grant = this.grant.bind(this);
3138
+ this.revoke = this.revoke.bind(this);
3139
+ this.bond = this.bond.bind(this);
3140
+ this.withdraw = this.withdraw.bind(this);
3141
+ }
3142
+ };
3143
+
3144
+ // src/libs/contract/config.ts
3145
+ var defaultSigningClientOptions = {
3146
+ broadcastPollIntervalMs: 8e3,
3147
+ broadcastTimeoutMs: 64e3,
3148
+ gasPrice: GasPrice.fromString("100000000000peaka")
3149
+ };
3150
+ async function createMaciClientBy({
3151
+ rpcEndpoint,
3152
+ wallet,
3153
+ contractAddress
3154
+ }) {
3155
+ const signingCosmWasmClient = await createContractClientByWallet(
3156
+ rpcEndpoint,
3157
+ wallet
3158
+ );
3159
+ const [{ address }] = await wallet.getAccounts();
3160
+ return new MaciClient(signingCosmWasmClient, address, contractAddress);
3161
+ }
3162
+ async function createAMaciClientBy({
3163
+ rpcEndpoint,
3164
+ wallet,
3165
+ contractAddress
3166
+ }) {
3167
+ const signingCosmWasmClient = await createContractClientByWallet(
3168
+ rpcEndpoint,
3169
+ wallet
3170
+ );
3171
+ const [{ address }] = await wallet.getAccounts();
3172
+ return new AMaciClient(signingCosmWasmClient, address, contractAddress);
3173
+ }
3174
+ async function createRegistryClientBy({
3175
+ rpcEndpoint,
3176
+ wallet,
3177
+ contractAddress
3178
+ }) {
3179
+ const signingCosmWasmClient = await createContractClientByWallet(
3180
+ rpcEndpoint,
3181
+ wallet
3182
+ );
3183
+ const [{ address }] = await wallet.getAccounts();
3184
+ return new RegistryClient(signingCosmWasmClient, address, contractAddress);
3185
+ }
3186
+ async function createOracleMaciClientBy({
3187
+ rpcEndpoint,
3188
+ wallet,
3189
+ contractAddress
3190
+ }) {
3191
+ const signingCosmWasmClient = await createContractClientByWallet(
3192
+ rpcEndpoint,
3193
+ wallet
3194
+ );
3195
+ const [{ address }] = await wallet.getAccounts();
3196
+ return new OracleMaciClient(signingCosmWasmClient, address, contractAddress);
3197
+ }
3198
+ async function createContractClientByWallet(rpcEndpoint, wallet) {
3199
+ const client = await SigningCosmWasmClient.connectWithSigner(
3200
+ rpcEndpoint,
3201
+ wallet,
3202
+ {
3203
+ ...defaultSigningClientOptions
3204
+ }
3205
+ );
3206
+ return client;
3207
+ }
3208
+
3209
+ // src/libs/contract/vars.ts
3210
+ var CIRCUIT_INFO = {
3211
+ "2-1-1-5": {
3212
+ parameter: {
3213
+ state_tree_depth: "2",
3214
+ int_state_tree_depth: "1",
3215
+ vote_option_tree_depth: "1",
3216
+ message_batch_size: "5"
3217
+ },
3218
+ groth16: {
3219
+ process_vkey: {
3220
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3221
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3222
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3223
+ vk_delta_2: "2178a9c3805dd82071b2b28bb4c0ffc8178cad913c8c990b98b4863284dc3a5d175c0be554fc060c27c551e5e32effef015b918a0f5a2dc1b92909b8272719301c521d5f6542db5ea4775a42d32159c356a696599c1a3df011ec00559ae1c2b60d860f7e6513a7d20feaeaca401863e35a0f691dd7d30ce06d07946840de1ec8",
3224
+ vk_ic0: "19126a54a9b6d0d415f892c246485cb2889487cf9c4a8cd88dab5e1140e1d0630d1d76ef4652df8887c9dc557aa57f25e221db7e5b2e4cf618a362bece107f5c",
3225
+ vk_ic1: "0632e625fefc7172e8aec1070c4d32b90b6c482f6f3806773a4c55a03877c2d716cfd935eb3e3883f580c93f56adbf3a253ce3c208c52fb784f9d8fec139c617"
3226
+ },
3227
+ tally_vkey: {
3228
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3229
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3230
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3231
+ vk_delta_2: "2e9fad39728c543c5213599111e1a44b01720c999a6785e8136c3e3b3bf8e07e248e1933d477969ca6e27cb7a74bca18cac7e3bbdf9371be5c54fe151f6376a30955609ec69b89329322a2f435b706ca248d1312c7513853a50ef37ed0f7826c25a5c57bf07789d89e538bc24017cf2722811f21480b0bb8030ed0028ecb7cd8",
3232
+ vk_ic0: "1bc1a1a3444256469c07cd6f4d1cfd9f7c9ddce596a306e0af077ca9e9c0fe9602db2a9aecef76a9dc4c19bf88c0099b04fc75410cc9004f0966440825e3790a",
3233
+ vk_ic1: "05b8b475f2bfedba4fa04ab1972006da9764c2c3e6fb65d6dd0aac938fd298112a560e13770b06a3f709a49fddf016331ea205fa125026993f6666eff69f4def"
3234
+ }
3235
+ },
3236
+ plonk: {
3237
+ process_vkey: {
3238
+ n: 1048575,
3239
+ num_inputs: 1,
3240
+ selector_commitments: [
3241
+ "29b0f4a90bea69583a8fca1e74d23adf739d605af605a0e0971fac548df976fb2e10a42dfca2325684c1bca5fabbf9d7022fc8b997ea478f1052dd8808d99e44",
3242
+ "119002055b6c2f98314ef408e4a917a6678f114ca991185749289f171f61efc32b3a931c700271b82d22c2073af9b7fffcb7bfa644ea09102d9ef8482410a991",
3243
+ "10c5f32870d26f8e26d2eaae2705557b18210b2355677172e1bef5fe684120891f8317185390ddbb22ecb922d37e03c3cc524c84f65c8045f2324b0f164cfbdb",
3244
+ "115a5f9af5d438d3261cfa31b7050b931b7d22647f628a43af41a41dcd44cb8d2e99368eb15cdc6d1f16faf9db0db4825613d6893c776aef456705bdc76eb728",
3245
+ "1a61cc5f0fbe92fbc8c9bd58928ce467f63e4771e4d517966afbaf220ea069a91cec3231c370be07fee8d9ec01660d054c549b034715855ffa652ad5b67ced86",
3246
+ "19e0d095a343115f6e7ad7ae1f51e375cd648fb35451cb2d5a8cf3bafbb25d0525efdc2cc5b5600ee0ae954dca3bf67c8277d470161fe23b4be7a5bcdf641e68"
3247
+ ],
3248
+ next_step_selector_commitments: [
3249
+ "246ce82e01ed312e81492f132da2ee16bc13cc0024fbcc668de30173ad59067f0f072a892451cc495f5d9b8b99c8dc29be1d42d3004aed45fd5b2cd32a420016"
3250
+ ],
3251
+ permutation_commitments: [
3252
+ "19c4143f41738480adc5ae49922d31b8a5afaa1d25ced5c20b869c0e1ccad91920c267c53d33907318cd194ba2ea08a85f250779765ba4121f7a0edfe1afe22b",
3253
+ "114bda14aa702a0815e3f91318a08a2798244420fd6675c8fc3cc2b0232298890d2eb3c1f27a83f4a3be777524d6cc65aa435e0a472fae8d1158e0a6ded685d0",
3254
+ "289f0b046968d2c095d05350e43996756fc85d2deb0e267a069615f0889a249413bdbe6f09edb4db956b8f3fc4488c4681cd52469dc0d419dab99a65b88309f7",
3255
+ "16dd74a2089960aac0d68309d5e81c6b45c29fafe4d42c922c06eb633ed48d551d347d1f43ee9b137772eefc43a6dcdf5ac35ee1615bc8f7c243bce071c410a9"
3256
+ ],
3257
+ non_residues: [
3258
+ "0000000000000000000000000000000000000000000000000000000000000005",
3259
+ "0000000000000000000000000000000000000000000000000000000000000007",
3260
+ "000000000000000000000000000000000000000000000000000000000000000a"
3261
+ ],
3262
+ g2_elements: [
3263
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3264
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3265
+ ]
3266
+ },
3267
+ tally_vkey: {
3268
+ n: 524287,
3269
+ num_inputs: 1,
3270
+ selector_commitments: [
3271
+ "18c2bb75c8ed53a5d15a56cc91c56f14c832419994ce7187c7c98b5e622cac0808b773f05e09822d8d267646198a78359ea2aa6fbaeb01317142f99fd11da6c0",
3272
+ "181499098243a5968f5490b7759aa15f0f769f24f3f4219b69f96913cf4fb23c1cd7b3f109196d7577390fd2e6d3930a71b0559aff756f3ca43eef66ce7333f4",
3273
+ "07ba2bdd452503fb16b56ea2940e95a98118c9dd120ae192680fe2b80bdb26f10ac6cdc7cb12b581a8c64d45b5af3d253c4282405eed3fd4d091ae05aac45cb6",
3274
+ "1caf01f1775eeafa78a11202e926ee92be997ce040f9c6fbce161348a40aeda70d9f15738cccf538083784e566ceef651d000223ae810c980e2d5d98b91b4665",
3275
+ "2c377c69cae1d591af413da2fd986ef3dca595d0c5817ee4932b92169d37c52d1218ce63dde705ebd1dc66d9b62daca287e4fdf6800b69204e5b78bfe84365a1",
3276
+ "175dd4ff280e39f0e080c181f853845e40c4b91709a93e4398d24befc9cf556903675361817e031e86bd896ff1dd7bc1cc31ca920a101499db0c58d77f0730ec"
3277
+ ],
3278
+ next_step_selector_commitments: [
3279
+ "12d76999d26137d433f7119ab34f3fc63cfedb9172052cfb34acfc3cdc570f511aba802ebe92b87f913496314b938cf526078280a68826c90b686b90420c7742"
3280
+ ],
3281
+ permutation_commitments: [
3282
+ "167b05c0132399e7126e8d16efb224b1c6729942048fc7e730fd1451116e0a6e05acaf2a6d2c88cc25610474b651c8cdcb7e8e14e59ddfad819123e888c4b1b6",
3283
+ "25aed62de4b701dc645e076543e2553c306010f2776c74edae55ea5253d9540403d042c4cb699cc04b2bb63d3c3edc0c85b049a84dc2fd44369f957d81363563",
3284
+ "0e77fb0b0e84da1d955da3d66dbb8fa3988f22e999a34bc4ac537a0f9187ac40156f8d7cb6d005fd85a0178d794f941b4e84832fd389a37c2a78112dac09b758",
3285
+ "051d3d906d457eaa9eff77a296dfa1760fd9ea379eec60487be38de91545ca2c1fcf457d6ac31afee10951245b0cc1e2c7674596f65955d189d48b6938fb3594"
3286
+ ],
3287
+ non_residues: [
3288
+ "0000000000000000000000000000000000000000000000000000000000000005",
3289
+ "0000000000000000000000000000000000000000000000000000000000000007",
3290
+ "000000000000000000000000000000000000000000000000000000000000000a"
3291
+ ],
3292
+ g2_elements: [
3293
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3294
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3295
+ ]
3296
+ }
3297
+ }
3298
+ },
3299
+ "4-2-2-25": {
3300
+ parameter: {
3301
+ state_tree_depth: "4",
3302
+ int_state_tree_depth: "2",
3303
+ vote_option_tree_depth: "2",
3304
+ message_batch_size: "25"
3305
+ },
3306
+ groth16: {
3307
+ process_vkey: {
3308
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3309
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3310
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3311
+ vk_delta_2: "0d0fe390b9dd4d1d0f486787b6ea96765cbeaa8f00310fecc3429673c5866c081a27998596ba296f66f3f7b5e2450d1ce1bcc535c133b2e8b577ba07dc1ccb4c1895f7afb9b3168a6d628c9173157cd56ca51948cc66c129a25f80e3b665e4b12c9c50f0cc0d070978ed2fb8ce15956d67c5dc6c07c7f45f1facfb5522d7b656",
3312
+ vk_ic0: "0ff2b22774da5c0ba94db4d759827b8c962aaf44db2649eb10407de02a40463a26497581d6d0979ad7f9057f26e048109158b0872700e2ad8447ffc9b4bf146b",
3313
+ vk_ic1: "0a47be101a59d20641e1369c0b2b9fb839cd35ecbfbeac3866df43723b70c78d17e96303c417743d93b7726805b736f364d305036b50e4ad1b885fc41284daf5"
3314
+ },
3315
+ tally_vkey: {
3316
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3317
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3318
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3319
+ vk_delta_2: "08e44e0876bd574d8a3411e374884eb61da7292ca52903fa96553c37311b66ce0f2f529e59b1d37e55794a575d0f87548ca0d03331c19689bc203a68c1c4bae20e9fd25a7bffaa9b7409e694a48bc0d57f42df164d4a01bd5deecffedd2d3a3125eff290efb93eaf9c578cc7ee9d00406137607b9602de02424ff413ac948690",
3320
+ vk_ic0: "295c8e84b4b6b8de44b24f80eb5cae1df65e4877c4af8da2dbadfbfc3586dc790661b9e636f2c2a83028d11cbb7c753675481b65a5dfe32fff7a558231b3c9ef",
3321
+ vk_ic1: "299cfb28054cde0470bd7ff280349089350226d1ca154dcf6544b2680bf3bea925026e6644668273d6066ef6766c2f561c3607c523fbbd1379c5002376ef69c3"
3322
+ }
3323
+ },
3324
+ plonk: {
3325
+ process_vkey: {
3326
+ n: 2097151,
3327
+ num_inputs: 1,
3328
+ selector_commitments: [
3329
+ "126cbf10e0b68a56d45614be16c5bb48bd1374478e17b9fe1a78b726ea70f9b21f3cd20fd178d89e5923c422ef050ccc7134fbd76c9efdbb90f677ee41e01edb",
3330
+ "12813166f206c95eddd998a40d8d2e54e29dd393f543e3583a7999b18d674832024cdd935540bd3b96207ec0609c6718ad8b14e2ef315594454c57d606494485",
3331
+ "05da9eea3ee7151355067ced11a8e8ff57a56c758493afc9cbb6cfbacfc42e7b08993dfa25c85f20aeb7f64e87fe56ac8066cf6b8479dc96294e302ef5d55372",
3332
+ "2e446e540bacde7daea23c93a67bc6b1424b7c16b33fd2cee251b0d093cd78300030b8e340f01f320639d60b77724e58fc8a2d778b7b2a5df2c953ce34debeea",
3333
+ "1cf8c75b18071ede19d196b46a8776efc29ac514458a698d9f2e50b7bc692f6e06f7ff96897240eca31058fe330e8cbcd911324b79a3a34d03340a3cfed85fd5",
3334
+ "17101fb5c293438a695075b221219679e278e4bd147239c9fc69081b19cacefe218eb895f1456ca81e29731967588aee4b0758ea51aa28e5fefc81fed4a11513"
3335
+ ],
3336
+ next_step_selector_commitments: [
3337
+ "0cebff4fe8cd70325f986088a1e17ae129a025481137bd80aef9c1f1c2e52f1e265a4ccae1ed89cb2fba527165f007898e70f988311ee4e4e87e41376cfeed03"
3338
+ ],
3339
+ permutation_commitments: [
3340
+ "025b5db167721133693f0b6d9d7cfadce68ad15365ef1605dda4a6c809edeea61927b27ca11713fc683c88f6330e9621837b05e5db74d5994d1cf04bc3d529b3",
3341
+ "1fac93999f33b145613901846e6403d7f4237d582b51ccc4fb5c70038284c6e21cc804cc3cf7170b96da74fcbb30c81cd8c3405a629327c657025db7332f169a",
3342
+ "0b6d7d383de73dbfc16f2c0f3af763135ff05a12ec937548008cfee944c195f902336a68a50f62f595953e44401e872fb41abb66a733684b079ffe550d09c233",
3343
+ "225a1f5e92d105d3be026ae68904826f89b786faad75a846ef966ed714568bba28d1388786fde71dea206cdef16faa7a589e90863e6245d271e3f154c75c5531"
3344
+ ],
3345
+ non_residues: [
3346
+ "0000000000000000000000000000000000000000000000000000000000000005",
3347
+ "0000000000000000000000000000000000000000000000000000000000000007",
3348
+ "000000000000000000000000000000000000000000000000000000000000000a"
3349
+ ],
3350
+ g2_elements: [
3351
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3352
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3353
+ ]
3354
+ },
3355
+ tally_vkey: {
3356
+ n: 1048575,
3357
+ num_inputs: 1,
3358
+ selector_commitments: [
3359
+ "1588fb667b3f0e4d0970b8208e4b6b4c729c4926b936f8d877017cf42d07ca15069643791d98abcd6b7d0b0546e7560ab9011e069f2ee48ede581fc72d8b5e04",
3360
+ "09c5480b103c44a81850ffd9a61ec21f7db41bc89996d8df075c3e029290eb5b083cb2b184d95c0761e585547be33250c8939929b87fdc39775ccea17d51b481",
3361
+ "278e239bcac0a945a17572a6d61ba59f705746e6893a10a44841933a8c8310e712e4ee913af9b77c8fdcdc365316aa9f1b8dc081eb99ad80265768ec9f484beb",
3362
+ "12532585ea307c5559b18a4d01db59b544a88088f61a5b5ed0431393e6f675af1309bf0dcaa7a552849e5f28d0300c8c61b18393fb638aed3b7d70e27bb91c35",
3363
+ "172e7ecb8e485aaee801fd78b8fd7c0b862baef65e39e6832cffa2170b6f981928d86ab5887e8c3210e34e03cada468bd501f60ec3a8fa35b4c7067d6fb8c6ae",
3364
+ "0c27211d046735fc681228b8366be2c8cf9a256cbd03dcd4af65152e94f95a6f1af151a5311b195b0f4acffeec4952cc52edbb7045aab61bbd3be9cd322ab99e"
3365
+ ],
3366
+ next_step_selector_commitments: [
3367
+ "25ee15301d562e6c630946b3fbe36b9fbd8dfbd44ddf70cc825fb1fa1ebd966229081f6b9297da671c69064e10b8f5dd0f69b69d1bf79122c6197f119087ebe1"
3368
+ ],
3369
+ permutation_commitments: [
3370
+ "194849a6ec5cb37e09d20801d387abbab04e453f630c5fbbf5c4819c5569480c0c8bf0ce2b4955cc4c891840da1d9e99feb81e8d43251dffbe4d6167639b9f9b",
3371
+ "17717d2638632d406b3c8aa69550c8aeed1b79def3ab55e9d0c4bdf21cc339ad07d3bd3a331145fc96f34c85469a34a8c93b53b7aa36bb5a94c31e3b4d47713e",
3372
+ "277b0c99b63c79bb9ed2f677c3987cf00acb293933dfced82b5afcb8bf0c34570d3187ce5c7e892582ddda4322cf7c50d41105fe98503fb60e41f4a08da5916d",
3373
+ "0489f6dec0f27a8c21d147ebb9781b68b4b73db065a6017924c543f6d9fadbe922d24c0946bd8b19df7659810296d063b557cdf7aba510b11e08fbf2e9d37931"
3374
+ ],
3375
+ non_residues: [
3376
+ "0000000000000000000000000000000000000000000000000000000000000005",
3377
+ "0000000000000000000000000000000000000000000000000000000000000007",
3378
+ "000000000000000000000000000000000000000000000000000000000000000a"
3379
+ ],
3380
+ g2_elements: [
3381
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3382
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3383
+ ]
3384
+ }
3385
+ }
3386
+ },
3387
+ "6-3-3-125": {
3388
+ parameter: {
3389
+ state_tree_depth: "6",
3390
+ int_state_tree_depth: "3",
3391
+ vote_option_tree_depth: "3",
3392
+ message_batch_size: "125"
3393
+ },
3394
+ groth16: {
3395
+ process_vkey: {
3396
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3397
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3398
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3399
+ vk_delta_2: "057f25675851ef5a79a6d8706a43a6cd8e494cfb12c241ede46991d9174cf30605b081ff44f3ede774dab68ea9324c12308c13cb09cbb129adf94401b9134f5b16137d952fd32ab2d4243ebff4cb15d17206948ef17909ea8606886a8109bdad082f7d27e1cbf98925f055b39d1c89f9bcc4f6d92fdb920934ff5e37ba4d9b49",
3400
+ vk_ic0: "27c937c032a18a320566e934448a0ffceea7050492a509c45a3bcb7e8ff8905d20789ada31729a833a4f595ff9f49f88adb66f2ab987de15a15deccb0e785bf4",
3401
+ vk_ic1: "0ed2cefc103a2234dbc6bbd8634812d65332218b7589f4079b2c08eb5a4f5f63113a7f3cb53797a7f5819d7de7e3f0b2197d1c34790685a4a59af4314810420b"
3402
+ },
3403
+ tally_vkey: {
3404
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3405
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3406
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3407
+ vk_delta_2: "2065e91c00fcc5cbc3d974cf52e24de972bdb1b4d8ded629dec20b5c904c3fa327ffe02402094795ff4d02588c8268fcad738f69eb4c732a0c98b485035e1f4913ede11b074ff143a929673e581a547717c58ce01af87d9d8b28f65f506093a61013e367b93e6782129362065840a0af9b77d7d9659a84577176e64a918d8d4c",
3408
+ vk_ic0: "11db4a022aab89a265f06ff62aa18c74b21e913a8b23e7fce9cb46f76d1c4d9f2a7475b1eeb7be0a0dc457e6d52536ba351b621b63a7d77da75d4e773048537e",
3409
+ vk_ic1: "0f298d235d0822ad281386abdf511853529af4c864b0cd54140facebfc1356a3059cd6d0d4b27b39e5683548fe12025e2a6b2e2724c2ca87d2008ef932ed3801"
3410
+ }
3411
+ },
3412
+ plonk: {
3413
+ process_vkey: {
3414
+ n: 8388607,
3415
+ num_inputs: 1,
3416
+ selector_commitments: [
3417
+ "216533ab27390f98812429524326ac08736d636d2891fb81446796cc1771a3230642f49db115acc15a186a1013f91a08efcd05640eb137d700276e80fd05bc90",
3418
+ "11747f6f378e26dbdacff464ce7eb6a8869750d0fa7e508e263ac77b582c1e9b24ba3d208650b0c28943915c563cc94cc3f98cdb5fd8adc4f4d3e2a60eda3302",
3419
+ "09239eb768d8d47b91c7e08e2ec6a374571964ed16be293cdc35e112393c4fd1182a0794be7f1441418664e9f718b67ed392a7da3e2868375bcf629131bb2680",
3420
+ "2020f7db24940bbf38d097ea5d7ef7253e38b154d7eb0ff1782ea18ce215dd7b0e8475197b071b118adc6418b7b7fb42fea19b6272d1bb460cc47deacb299ec7",
3421
+ "298923db1618185064bbab5df30ee03a3c9cbc7ce8f096d76cbd2a5ab3df86cd05bbedb938e6e0ff35cce23609458aff8081cdf3163655672074d1b18b0007bd",
3422
+ "0effaabe8c6e8a076aedd36d10f2926f9871f552d93e22bfbe69e3c828a546fa2d0cd163b49a6de219ac2c048a8459ae448047748ba078b9d5d07b290c946b08"
3423
+ ],
3424
+ next_step_selector_commitments: [
3425
+ "13e3d7299e30e6142699469d620df721eca35bbb807a8f4298f165260fdc24f823e7bd9bcb6506a094a5ebef44434c62e4bcb5d3dd7e092c49d5cb80b8ae0757"
3426
+ ],
3427
+ permutation_commitments: [
3428
+ "03d94ab8fdc681523a8eec10f1ce5552937c268d1d970f9e75ee8657cd4c12a81e03476f83ef5c14db2f4d931b833a3b65b8d5689b37cc7f183914c90d3d065d",
3429
+ "1b9c6ef20e68355c535bda6ff04a8a61d7552a594bb8e88d69a6f8840ddab04d2884824cc356d0d90cc278c247fc531de62efca4b19ed1be6f071144474d2037",
3430
+ "1ff82de8312481e1591d2d1c2698fa3944b3f0afa0dd702be8a1a944a5a8997323ffbd0ab39a2e13608a8e76803c33ffda7317bb7101e335ce5552ed62dcd09d",
3431
+ "2cb2bbdd51d22b79957b0401ecb6fe089f05426ba092b1205fa92f39b36cc5fc0c36c3934e47b7d407d4cda0c78c2b3fb23162cb0d295e8a8cce1a274956c34a"
3432
+ ],
3433
+ non_residues: [
3434
+ "0000000000000000000000000000000000000000000000000000000000000005",
3435
+ "0000000000000000000000000000000000000000000000000000000000000007",
3436
+ "000000000000000000000000000000000000000000000000000000000000000a"
3437
+ ],
3438
+ g2_elements: [
3439
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3440
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3441
+ ]
3442
+ },
3443
+ tally_vkey: {
3444
+ n: 8388607,
3445
+ num_inputs: 1,
3446
+ selector_commitments: [
3447
+ "258d101f9499e81c0d0da8986c659ef33da19d4955a142e56b4854d1327c902c1996baecd81432717a9cbf92ccf651e4217a788c1a2ed855f749480f8ce8203c",
3448
+ "1892a17c9c01389e3149b0663069a1ad4fd3c8e2db5ce99795b781c47b55acf9001cf5f0b4c1d088fa2058ca19cd2f1e9559ebe059897bb0aadcb540ce5f468a",
3449
+ "09912d6eaa4a22802451135d9a221ebf97c2ce8ad5bbb2942d5a860482e8e4202573995072c4b014cd0e9d09a1fd53ee7d602070b404288a7fd0d97b57d8f07d",
3450
+ "0c62ef7ad01b05b2c01fca6188de269d63d725348a07a99bbc50f24c1518aa871fdc61bbf42399433a0917c919dcfe9e851b206e1c37dec0908f69ad89bb1f8e",
3451
+ "07d181c1026ef4a6732bff3dffbc5ae0e3746e4860f478c6c2e8e258df2ed7671efe073fb31cf5a61c0eedceccb5e968220b9ff7e2b055b11d7c456a57fe7ac9",
3452
+ "1bbd7ad96893df675c811e5a2be184e2e3bc9af0ce30a7b26e53a916a10a777a01ffa70dbe585201ac09778429c04c71229392608095d220c7d82631a0caedd6"
3453
+ ],
3454
+ next_step_selector_commitments: [
3455
+ "2ae6c5c98d4c384e8e645d85a4ca362de4c4e75efe3c79d5bcbd126a9e305b831618df99300c7327f1eac6a498c8feac6013d4ba09b7ea046340f99b0598a832"
3456
+ ],
3457
+ permutation_commitments: [
3458
+ "2458c5fb474ab3e7ae9c6b82cc432a111954d8be5e7e9b4fc58c14e1aed77f3207426dbe08272aa69ba8b73809f27f9ff083641b5c3c896c386a74bbed3083dd",
3459
+ "0879ac4885674b1af0ab67c7b505bce6234f32a0335bdfd229023fea5f303ece0973ba8abc9ade8edcfb68c7d4b8b98272c7bf33eff841fec78d21c0c2e82aa6",
3460
+ "07b74f37fcbcb2d9962a529fbc254d54925aeb1be1a49517affeb3571ef3e31e3033f7900ff5bb5759cbb98b64ca7f42967278c328d00e60c042aa65f2178ded",
3461
+ "203c948fdc386e7bfbdc37363ab489e9ce3264f4ccd23c33dd8f2337fb9007a621cabf740aa26e522dcb7af6c0de9f93cbc69595b29b02e75c2f3507e97664ec"
3462
+ ],
3463
+ non_residues: [
3464
+ "0000000000000000000000000000000000000000000000000000000000000005",
3465
+ "0000000000000000000000000000000000000000000000000000000000000007",
3466
+ "000000000000000000000000000000000000000000000000000000000000000a"
3467
+ ],
3468
+ g2_elements: [
3469
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3470
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
3471
+ ]
3472
+ }
3473
+ }
3474
+ },
3475
+ "9-4-3-625": {
3476
+ parameter: {
3477
+ state_tree_depth: "9",
3478
+ int_state_tree_depth: "4",
3479
+ message_batch_size: "625",
3480
+ vote_option_tree_depth: "3"
3481
+ },
3482
+ groth16: {
3483
+ process_vkey: {
3484
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3485
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3486
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3487
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3488
+ vk_ic0: "1832600210a459fe61d971081d4baa1a1add23f87c8a8dc4042cd5cf6c6fdf8e3018489aec30d9deb26629e05965a3a7e038be58ce10c854cb7e1071f2708aad",
3489
+ vk_ic1: "0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6"
3490
+ },
3491
+ tally_vkey: {
3492
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
3493
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
3494
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3495
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
3496
+ vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
3497
+ vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
3498
+ }
3499
+ }
3500
+ }
3501
+ };
3502
+ var QTR_LIB = {
3503
+ zeros: [
3504
+ "0",
3505
+ "14655542659562014735865511769057053982292279840403315552050801315682099828156",
3506
+ "19261153649140605024552417994922546473530072875902678653210025980873274131905",
3507
+ "21526503558325068664033192388586640128492121680588893182274749683522508994597",
3508
+ "20017764101928005973906869479218555869286328459998999367935018992260318153770",
3509
+ "16998355316577652097112514691750893516081130026395813155204269482715045879598",
3510
+ "2612442706402737973181840577010736087708621987282725873936541279764292204086",
3511
+ "17716535433480122581515618850811568065658392066947958324371350481921422579201",
3512
+ "17437916409890180001398333108882255895598851862997171508841759030332444017770"
3513
+ ]
3514
+ };
3515
+
3516
+ // src/libs/contract/utils.ts
3517
+ function getContractParams(type, circuitType, proofSystem, maxVoter, maxOption) {
3518
+ let parameters;
3519
+ let groth16ProcessVkey = null;
3520
+ let groth16TallyVkey = null;
3521
+ let plonkProcessVkey = null;
3522
+ let plonkTallyVkey = null;
3523
+ let maciVoteType = null;
3524
+ let maciCertSystem = null;
3525
+ switch (circuitType) {
3526
+ case "0" /* IP1V */:
3527
+ maciVoteType = "0";
3528
+ break;
3529
+ case "1" /* QV */:
3530
+ maciVoteType = "1";
3531
+ break;
3532
+ default:
3533
+ throw new Error(
3534
+ `Invalid circuit type ${circuitType}, only support 1P1V and QV`
3535
+ );
3536
+ }
3537
+ switch (proofSystem) {
3538
+ case "groth16" /* GROTH16 */:
3539
+ maciCertSystem = "0";
3540
+ break;
3541
+ case "plonk" /* PLONK */:
3542
+ maciCertSystem = "1";
3543
+ break;
3544
+ default:
3545
+ throw new Error(
3546
+ `Invalid proof system ${proofSystem}, only support GROTH16 and PLONK`
3547
+ );
3548
+ }
3549
+ if (Number(maxVoter) <= 25 && Number(maxOption) <= 5) {
3550
+ parameters = CIRCUIT_INFO["2-1-1-5"].parameter;
3551
+ if (proofSystem === "groth16" /* GROTH16 */) {
3552
+ groth16ProcessVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].process_vkey;
3553
+ groth16TallyVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].tally_vkey;
3554
+ } else if (proofSystem === "plonk" /* PLONK */) {
3555
+ plonkProcessVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.process_vkey;
3556
+ plonkTallyVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.tally_vkey;
3557
+ }
3558
+ } else if (Number(maxVoter) <= 625 && Number(maxOption) <= 25) {
3559
+ parameters = CIRCUIT_INFO["4-2-2-25"].parameter;
3560
+ if (proofSystem === "groth16" /* GROTH16 */) {
3561
+ groth16ProcessVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].process_vkey;
3562
+ groth16TallyVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].tally_vkey;
3563
+ } else if (proofSystem === "plonk" /* PLONK */) {
3564
+ plonkProcessVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.process_vkey;
3565
+ plonkTallyVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.tally_vkey;
3566
+ }
3567
+ } else if (Number(maxVoter) <= 15625 && Number(maxOption) <= 125) {
3568
+ parameters = CIRCUIT_INFO["6-3-3-125"].parameter;
3569
+ if (proofSystem === "groth16" /* GROTH16 */) {
3570
+ groth16ProcessVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].process_vkey;
3571
+ groth16TallyVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].tally_vkey;
3572
+ } else if (proofSystem === "plonk" /* PLONK */) {
3573
+ plonkProcessVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.process_vkey;
3574
+ plonkTallyVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.tally_vkey;
3575
+ }
3576
+ } else if (Number(maxVoter) <= 1953125 && Number(maxOption) <= 125) {
3577
+ parameters = CIRCUIT_INFO["9-4-3-625"].parameter;
3578
+ if (proofSystem === "groth16" /* GROTH16 */) {
3579
+ groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_vkey;
3580
+ groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_vkey;
3581
+ } else if (proofSystem === "plonk" /* PLONK */) {
3582
+ throw new Error("PLONK is not supported for MACI-9");
3583
+ }
3584
+ } else {
3585
+ throw new Error("Number of voters or options is too large.");
3586
+ }
3587
+ switch (type) {
3588
+ case "0" /* MACI */:
3589
+ return {
3590
+ parameters,
3591
+ groth16ProcessVkey,
3592
+ groth16TallyVkey,
3593
+ plonkProcessVkey,
3594
+ plonkTallyVkey,
3595
+ maciVoteType,
3596
+ maciCertSystem
3597
+ };
3598
+ case "1" /* AMACI */:
3599
+ return {
3600
+ // parameters,
3601
+ // groth16ProcessVkey,
3602
+ // groth16TallyVkey,
3603
+ // plonkProcessVkey,
3604
+ // plonkTallyVkey,
3605
+ };
3606
+ case "2" /* ORACLE_MACI */:
3607
+ return {
3608
+ parameters: CIRCUIT_INFO["9-4-3-625"].parameter,
3609
+ groth16ProcessVkey: CIRCUIT_INFO["9-4-3-625"]["groth16"].process_vkey,
3610
+ groth16TallyVkey: CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_vkey,
3611
+ plonkProcessVkey: null,
3612
+ plonkTallyVkey: null,
3613
+ maciVoteType,
3614
+ maciCertSystem: "0"
3615
+ };
3616
+ }
3617
+ }
3618
+ function hexToDecimalString(hexString) {
3619
+ const decimalString = BigInt("0x" + hexString).toString(10);
3620
+ return decimalString;
3621
+ }
3622
+ function parsePubkey(publickKey) {
3623
+ const x = publickKey.slice(0, 64);
3624
+ const y = publickKey.slice(64);
3625
+ return {
3626
+ x: hexToDecimalString(x),
3627
+ y: hexToDecimalString(y)
3628
+ };
3629
+ }
3630
+
3631
+ // src/libs/contract/contract.ts
3632
+ var Contract = class {
3633
+ constructor({
3634
+ rpcEndpoint,
3635
+ registryAddress,
3636
+ maciCodeId,
3637
+ oracleCodeId
3638
+ }) {
3639
+ this.rpcEndpoint = rpcEndpoint;
3640
+ this.registryAddress = registryAddress;
3641
+ this.maciCodeId = maciCodeId;
3642
+ this.oracleCodeId = oracleCodeId;
3643
+ }
3644
+ async createAMaciRound({
3645
+ signer,
3646
+ startVoting,
3647
+ endVoting,
3648
+ operator,
3649
+ whitelist,
3650
+ title,
3651
+ description,
3652
+ link,
3653
+ maxVoter,
3654
+ maxOption,
3655
+ voiceCreditAmount,
3656
+ circuitType,
3657
+ preDeactivateRoot
3658
+ }) {
3659
+ const start_time = (startVoting.getTime() * 10 ** 6).toString();
3660
+ const end_time = (endVoting.getTime() * 10 ** 6).toString();
3661
+ const client = await createRegistryClientBy({
3662
+ rpcEndpoint: this.rpcEndpoint,
3663
+ wallet: signer,
3664
+ contractAddress: this.registryAddress
3665
+ });
3666
+ preDeactivateRoot = preDeactivateRoot || "0";
3667
+ const res = await client.createRound({
3668
+ operator,
3669
+ preDeactivateRoot,
3670
+ voiceCreditAmount,
3671
+ whitelist,
3672
+ roundInfo: {
3673
+ title,
3674
+ description: description || "",
3675
+ link: link || ""
3676
+ },
3677
+ votingTime: {
3678
+ start_time,
3679
+ end_time
3680
+ },
3681
+ maxVoter,
3682
+ maxOption,
3683
+ certificationSystem: "0",
3684
+ circuitType
3685
+ });
3686
+ let contractAddress = "";
3687
+ res.events.map((event) => {
3688
+ if (event.type === "wasm") {
3689
+ let actionEvent = event.attributes.find(
3690
+ (attr) => attr.key === "action"
3691
+ );
3692
+ if (actionEvent.value === "created_round") {
3693
+ contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
3694
+ }
3695
+ }
3696
+ });
3697
+ console.log(`Deploy tx: ${res.transactionHash} - ${contractAddress}`);
3698
+ return contractAddress;
3699
+ }
3700
+ async createMaciRound({
3701
+ signer,
3702
+ operatorPubkey,
3703
+ startVoting,
3704
+ endVoting,
3705
+ whitelist,
3706
+ title,
3707
+ description,
3708
+ link,
3709
+ maxVoter,
3710
+ maxOption,
3711
+ circuitType,
3712
+ certSystemType
3713
+ }) {
3714
+ const start_time = (startVoting.getTime() * 10 ** 6).toString();
3715
+ const end_time = (endVoting.getTime() * 10 ** 6).toString();
3716
+ const [{ address }] = await signer.getAccounts();
3717
+ const client = await createContractClientByWallet(this.rpcEndpoint, signer);
3718
+ const { x: operatorPubkeyX, y: operatorPubkeyY } = parsePubkey(operatorPubkey);
3719
+ const {
3720
+ parameters,
3721
+ groth16ProcessVkey,
3722
+ groth16TallyVkey,
3723
+ plonkProcessVkey,
3724
+ plonkTallyVkey,
3725
+ maciVoteType,
3726
+ maciCertSystem
3727
+ } = getContractParams(
3728
+ "0" /* MACI */,
3729
+ circuitType,
3730
+ certSystemType,
3731
+ maxVoter,
3732
+ maxOption
3733
+ );
3734
+ const instantiateResponse = await client.instantiate(
3735
+ address,
3736
+ this.maciCodeId,
3737
+ {
3738
+ round_info: { title, description, link },
3739
+ voting_time: {
3740
+ start_time,
3741
+ end_time
3742
+ },
3743
+ parameters,
3744
+ coordinator: {
3745
+ x: operatorPubkeyX,
3746
+ y: operatorPubkeyY
3747
+ },
3748
+ groth16_process_vkey: groth16ProcessVkey,
3749
+ groth16_tally_vkey: groth16TallyVkey,
3750
+ plonk_process_vkey: plonkProcessVkey,
3751
+ plonk_tally_vkey: plonkTallyVkey,
3752
+ max_vote_options: maxOption,
3753
+ whitelist,
3754
+ circuit_type: maciVoteType,
3755
+ certification_system: maciCertSystem,
3756
+ qtr_lib: QTR_LIB
3757
+ },
3758
+ "MACI",
3759
+ "auto"
3760
+ );
3761
+ return instantiateResponse;
3762
+ }
3763
+ async createOracleMaciRound({
3764
+ signer,
3765
+ operatorPubkey,
3766
+ startVoting,
3767
+ endVoting,
3768
+ title,
3769
+ description,
3770
+ link,
3771
+ maxVoter,
3772
+ maxOption,
3773
+ circuitType,
3774
+ whitelistBackendPubkey,
3775
+ whitelistEcosystem,
3776
+ whitelistSnapshotHeight,
3777
+ whitelistVotingPowerArgs,
3778
+ feegrantOperator
3779
+ }) {
3780
+ const start_time = (startVoting.getTime() * 1e6).toString();
3781
+ const end_time = (endVoting.getTime() * 1e6).toString();
3782
+ const [{ address }] = await signer.getAccounts();
3783
+ const client = await createContractClientByWallet(this.rpcEndpoint, signer);
3784
+ const { x: operatorPubkeyX, y: operatorPubkeyY } = parsePubkey(operatorPubkey);
3785
+ const {
3786
+ parameters,
3787
+ groth16ProcessVkey,
3788
+ groth16TallyVkey,
3789
+ plonkProcessVkey,
3790
+ plonkTallyVkey,
3791
+ maciVoteType,
3792
+ maciCertSystem
3793
+ } = getContractParams(
3794
+ "2" /* ORACLE_MACI */,
3795
+ circuitType,
3796
+ "groth16" /* GROTH16 */,
3797
+ maxVoter,
3798
+ maxOption
3799
+ );
3800
+ const instantiateResponse = await client.instantiate(
3801
+ address,
3802
+ this.oracleCodeId,
3803
+ {
3804
+ round_info: { title, description: description || "", link: link || "" },
3805
+ voting_time: {
3806
+ start_time,
3807
+ end_time
3808
+ },
3809
+ parameters,
3810
+ coordinator: {
3811
+ x: operatorPubkeyX,
3812
+ y: operatorPubkeyY
3813
+ },
3814
+ groth16_process_vkey: groth16ProcessVkey,
3815
+ groth16_tally_vkey: groth16TallyVkey,
3816
+ plonk_process_vkey: plonkProcessVkey,
3817
+ plonk_tally_vkey: plonkTallyVkey,
3818
+ max_vote_options: maxOption,
3819
+ whitelist_backend_pubkey: whitelistBackendPubkey,
3820
+ whitelist_ecosystem: whitelistEcosystem,
3821
+ whitelist_snapshot_height: whitelistSnapshotHeight,
3822
+ whitelist_voting_power_args: whitelistVotingPowerArgs,
3823
+ circuit_type: maciVoteType,
3824
+ certification_system: maciCertSystem,
3825
+ qtr_lib: QTR_LIB,
3826
+ feegrant_operator: feegrantOperator
3827
+ },
3828
+ "[Oracle MACI]" + title,
3829
+ "auto"
3830
+ );
3831
+ return instantiateResponse;
3832
+ }
3833
+ async queryRoundInfo({
3834
+ signer,
3835
+ roundAddress
3836
+ }) {
3837
+ const client = await createMaciClientBy({
3838
+ rpcEndpoint: this.rpcEndpoint,
3839
+ wallet: signer,
3840
+ contractAddress: roundAddress
3841
+ });
3842
+ const roundInfo = await client.getRoundInfo();
3843
+ return roundInfo;
3844
+ }
3845
+ async oracleMaciClient({
3846
+ signer,
3847
+ contractAddress
3848
+ }) {
3849
+ const client = await createOracleMaciClientBy({
3850
+ rpcEndpoint: this.rpcEndpoint,
3851
+ wallet: signer,
3852
+ contractAddress
3853
+ });
3854
+ return client;
3855
+ }
3856
+ async registryClient({
3857
+ signer,
3858
+ contractAddress
3859
+ }) {
3860
+ return createRegistryClientBy({
3861
+ rpcEndpoint: this.rpcEndpoint,
3862
+ wallet: signer,
3863
+ contractAddress
3864
+ });
3865
+ }
3866
+ async maciClient({
3867
+ signer,
3868
+ contractAddress
3869
+ }) {
3870
+ return createMaciClientBy({
3871
+ rpcEndpoint: this.rpcEndpoint,
3872
+ wallet: signer,
3873
+ contractAddress
3874
+ });
3875
+ }
3876
+ async amaciClient({
3877
+ signer,
3878
+ contractAddress
3879
+ }) {
3880
+ return createAMaciClientBy({
3881
+ rpcEndpoint: this.rpcEndpoint,
3882
+ wallet: signer,
3883
+ contractAddress
3884
+ });
3885
+ }
3886
+ };
3887
+
3888
+ // src/maci.ts
3889
+ var MaciClient2 = class {
3890
+ /**
3891
+ * @constructor
3892
+ * @param {ClientParams} params - The parameters for the Maci Client instance.
3893
+ */
3894
+ constructor({
3895
+ network,
3896
+ rpcEndpoint,
3897
+ restEndpoint,
3898
+ apiEndpoint,
3899
+ registryAddress,
3900
+ maciCodeId,
3901
+ oracleCodeId,
3902
+ customFetch,
3903
+ defaultOptions
3904
+ }) {
3905
+ const defaultParams = getDefaultParams(network);
3906
+ this.rpcEndpoint = rpcEndpoint || defaultParams.rpcEndpoint;
3907
+ this.restEndpoint = restEndpoint || defaultParams.restEndpoint;
3908
+ this.apiEndpoint = apiEndpoint || defaultParams.apiEndpoint;
3909
+ this.registryAddress = registryAddress || defaultParams.registryAddress;
3910
+ this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
3911
+ this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
3912
+ this.http = new Http(
3913
+ this.apiEndpoint,
3914
+ this.restEndpoint,
3915
+ customFetch,
3916
+ defaultOptions
3917
+ );
3918
+ this.indexer = new Indexer({
3919
+ restEndpoint: this.restEndpoint,
3920
+ apiEndpoint: this.apiEndpoint,
3921
+ registryAddress: this.registryAddress,
3922
+ http: this.http
3923
+ });
3924
+ this.contract = new Contract({
3925
+ rpcEndpoint: this.rpcEndpoint,
3926
+ registryAddress: this.registryAddress,
3927
+ maciCodeId: this.maciCodeId,
3928
+ oracleCodeId: this.oracleCodeId
3929
+ });
3930
+ }
3931
+ async oracleMaciClient({
3932
+ signer,
3933
+ contractAddress
3934
+ }) {
3935
+ return await this.contract.oracleMaciClient({
3936
+ signer,
3937
+ contractAddress
3938
+ });
3939
+ }
3940
+ async registryClient({
3941
+ signer,
3942
+ contractAddress
3943
+ }) {
3944
+ return await this.contract.registryClient({ signer, contractAddress });
3945
+ }
3946
+ async maciClient({
3947
+ signer,
3948
+ contractAddress
3949
+ }) {
3950
+ return await this.contract.maciClient({ signer, contractAddress });
3951
+ }
3952
+ async amaciClient({
3953
+ signer,
3954
+ contractAddress
3955
+ }) {
3956
+ return await this.contract.amaciClient({ signer, contractAddress });
3957
+ }
3958
+ async createAMaciRound(params) {
3959
+ return await this.contract.createAMaciRound(params);
3960
+ }
3961
+ async createMaciRound(params) {
3962
+ return await this.contract.createMaciRound(params);
3963
+ }
3964
+ async createOracleMaciRound(params) {
3965
+ return await this.contract.createOracleMaciRound(params);
3966
+ }
3967
+ /**
3968
+ * @method balanceOf
3969
+ * @description Get the balance of a specific address.
3970
+ * @param {string} address - The address to check the balance for.
3971
+ * @returns {Promise<BalanceResponse>} The balance response.
3972
+ */
3973
+ async balanceOf(address) {
3974
+ return await this.indexer.account.balanceOf(address);
3975
+ }
3976
+ /**
3977
+ * @method getRoundById
3978
+ * @description Get a round by its ID.
3979
+ * @param {string} id - The ID of the round.
3980
+ * @returns {Promise<RoundResponse>} The round response.
3981
+ */
3982
+ async getRoundById(id) {
3983
+ return await this.indexer.round.getRoundById(id);
3984
+ }
3985
+ /**
3986
+ * @method getRounds
3987
+ * @description Get multiple rounds.
3988
+ * @param {string} after - The cursor to start after.
3989
+ * @param {number} [limit] - The number of rounds to retrieve.
3990
+ * @returns {Promise<RoundsResponse>} The rounds response.
3991
+ */
3992
+ async getRounds(after, limit) {
3993
+ return await this.indexer.round.getRounds(after, limit);
3994
+ }
3995
+ /**
3996
+ * @method getRoundsByStatus
3997
+ * @description Get rounds by their status.
3998
+ * @param {string} status - The status of the rounds to retrieve.
3999
+ * @param {string} after - The cursor to start after.
4000
+ * @param {number} [limit] - The number of rounds to retrieve.
4001
+ * @returns {Promise<RoundsResponse>} The rounds response.
4002
+ */
4003
+ async getRoundsByStatus(status, after, limit) {
4004
+ return await this.indexer.round.getRoundsByStatus(status, after, limit);
4005
+ }
4006
+ /**
4007
+ * @method getRoundsByCircuitName
4008
+ * @description Get rounds by their circuit name.
4009
+ * @param {string} name - The name of the circuit.
4010
+ * @param {string} after - The cursor to start after.
4011
+ * @param {number} [limit] - The number of rounds to retrieve.
4012
+ * @returns {Promise<RoundsResponse>} The rounds response.
4013
+ */
4014
+ async getRoundsByCircuitName(name, after, limit) {
4015
+ return await this.indexer.round.getRoundsByCircuitName(name, after, limit);
4016
+ }
4017
+ /**
4018
+ * @method getRoundsByOperator
4019
+ * @description Get rounds by their operator address.
4020
+ * @param {string} address - The address of the operator.
4021
+ * @param {string} after - The cursor to start after.
4022
+ * @param {number} [limit] - The number of rounds to retrieve.
4023
+ * @returns {Promise<RoundsResponse>} The rounds response.
4024
+ */
4025
+ async getRoundsByOperator(address, after, limit) {
4026
+ return await this.indexer.round.getRoundsByOperator(address, after, limit);
4027
+ }
4028
+ /**
4029
+ * @method getOperatorByAddress
4030
+ * @description Get an operator by their address.
4031
+ * @param {string} address - The address of the operator.
4032
+ * @returns {Promise<OperatorResponse>} The operator response.
4033
+ */
4034
+ async getOperatorByAddress(address) {
4035
+ return await this.indexer.operator.getOperatorByAddress(address);
4036
+ }
4037
+ /**
4038
+ * @method getOperators
4039
+ * @description Get multiple operators.
4040
+ * @param {string} after - The cursor to start after.
4041
+ * @param {number} [limit] - The number of operators to retrieve.
4042
+ * @returns {Promise<OperatorsResponse>} The operators response.
4043
+ */
4044
+ async getOperators(after, limit) {
4045
+ return await this.indexer.operator.getOperators(after, limit);
4046
+ }
4047
+ /**
4048
+ * @method getCircuitByName
4049
+ * @description Get a circuit by its name.
4050
+ * @param {string} name - The name of the circuit.
4051
+ * @returns {Promise<CircuitResponse>} The circuit response.
4052
+ */
4053
+ async getCircuitByName(name) {
4054
+ return await this.indexer.circuit.getCircuitByName(name);
4055
+ }
4056
+ /**
4057
+ * @method getCircuits
4058
+ * @description Get all available circuits.
4059
+ * @returns {Promise<CircuitsResponse>} The circuits response.
4060
+ */
4061
+ async getCircuits() {
4062
+ return await this.indexer.circuit.getCircuits();
4063
+ }
4064
+ /**
4065
+ * @method getTransactionByHash
4066
+ * @description Get a transaction by its hash.
4067
+ * @param {string} hash - The hash of the transaction.
4068
+ * @returns {Promise<TransactionResponse>} The transaction response.
4069
+ */
4070
+ async getTransactionByHash(hash) {
4071
+ return await this.indexer.transaction.getTransactionByHash(hash);
4072
+ }
4073
+ /**
4074
+ * @method getTransactions
4075
+ * @description Get multiple transactions.
4076
+ * @param {string} after - The cursor to start after.
4077
+ * @param {number} [limit] - The number of transactions to retrieve.
4078
+ * @returns {Promise<TransactionsResponse>} The transactions response.
4079
+ */
4080
+ async getTransactions(after, limit) {
4081
+ return await this.indexer.transaction.getTransactions(after, limit);
4082
+ }
4083
+ /**
4084
+ * @method getTransactionsByContractAddress
4085
+ * @description Get transactions by contract address.
4086
+ * @param {string} address - The contract address.
4087
+ * @param {string} after - The cursor to start after.
4088
+ * @param {number} [limit] - The number of transactions to retrieve.
4089
+ * @returns {Promise<TransactionsResponse>} The transactions response.
4090
+ */
4091
+ async getTransactionsByContractAddress(address, after, limit) {
4092
+ return await this.indexer.transaction.getTransactionsByContractAddress(
4093
+ address,
4094
+ after,
4095
+ limit
4096
+ );
4097
+ }
4098
+ /**
4099
+ * @method getProofByContractAddress
4100
+ * @description Get proof data by contract address.
4101
+ * @param {string} address - The contract address.
4102
+ * @returns {Promise<ProofResponse>} The proof response.
4103
+ */
4104
+ async getProofByContractAddress(address) {
4105
+ return await this.indexer.proof.getProofByContractAddress(address);
4106
+ }
4107
+ };
4108
+ export {
4109
+ Account,
4110
+ Circuit,
4111
+ Contract,
4112
+ Http,
4113
+ Indexer,
4114
+ MaciClient2 as MaciClient,
4115
+ Operator,
4116
+ Proof,
4117
+ Round,
4118
+ Transaction,
4119
+ circuits,
4120
+ getDefaultParams,
4121
+ validator_operator_set
4122
+ };
4123
+ //# sourceMappingURL=index.mjs.map