@dorafactory/maci-sdk 0.0.7 → 0.0.9

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 (50) hide show
  1. package/README.md +27 -7
  2. package/dist/index.js +751 -187
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +748 -187
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/libs/circom/tree.d.ts +20 -20
  7. package/dist/libs/contract/ts/AMaci.client.d.ts +1 -1
  8. package/dist/libs/contract/ts/Maci.client.d.ts +21 -47
  9. package/dist/libs/contract/ts/Maci.types.d.ts +40 -31
  10. package/dist/libs/contract/ts/OracleMaci.client.d.ts +52 -52
  11. package/dist/libs/contract/ts/OracleMaci.types.d.ts +17 -7
  12. package/dist/libs/contract/ts/Registry.client.d.ts +2 -2
  13. package/dist/libs/contract/types.d.ts +2 -2
  14. package/dist/libs/errors/types.d.ts +1 -0
  15. package/dist/libs/http/http.d.ts +1 -1
  16. package/dist/libs/index.d.ts +3 -0
  17. package/dist/libs/indexer/indexer.d.ts +11 -2
  18. package/dist/libs/maci/index.d.ts +1 -0
  19. package/dist/libs/maci/maci.d.ts +64 -5
  20. package/dist/libs/oracle-certificate/oracle-certificate.d.ts +1 -21
  21. package/dist/libs/oracle-certificate/types.d.ts +12 -0
  22. package/dist/libs/query/event.d.ts +7 -0
  23. package/dist/libs/query/index.d.ts +1 -0
  24. package/dist/maci.d.ts +7 -5
  25. package/dist/types/index.d.ts +22 -0
  26. package/package.json +1 -1
  27. package/src/libs/const.ts +3 -2
  28. package/src/libs/contract/contract.ts +2 -6
  29. package/src/libs/contract/ts/AMaci.client.ts +868 -874
  30. package/src/libs/contract/ts/AMaci.types.ts +216 -216
  31. package/src/libs/contract/ts/Maci.client.ts +748 -888
  32. package/src/libs/contract/ts/Maci.types.ts +229 -224
  33. package/src/libs/contract/ts/OracleMaci.client.ts +623 -348
  34. package/src/libs/contract/ts/OracleMaci.types.ts +191 -138
  35. package/src/libs/contract/ts/Registry.client.ts +438 -446
  36. package/src/libs/contract/ts/Registry.types.ts +97 -97
  37. package/src/libs/contract/types.ts +6 -2
  38. package/src/libs/contract/utils.ts +9 -0
  39. package/src/libs/errors/types.ts +1 -0
  40. package/src/libs/http/http.ts +3 -7
  41. package/src/libs/index.ts +3 -0
  42. package/src/libs/indexer/indexer.ts +18 -0
  43. package/src/libs/maci/index.ts +1 -0
  44. package/src/libs/maci/maci.ts +302 -10
  45. package/src/libs/oracle-certificate/oracle-certificate.ts +19 -73
  46. package/src/libs/oracle-certificate/types.ts +15 -1
  47. package/src/libs/query/event.ts +78 -0
  48. package/src/libs/query/index.ts +1 -0
  49. package/src/maci.ts +27 -5
  50. package/src/types/index.ts +28 -0
@@ -1,19 +1,258 @@
1
1
  import { OfflineSigner } from '@cosmjs/proto-signing';
2
2
  import { batchGenMessage, Circom, PublicKey, stringizing } from '../circom';
3
3
  import { Contract } from '../contract';
4
+ import { Indexer } from '../indexer';
5
+ import { OracleCertificate } from '../oracle-certificate';
4
6
  import {
5
7
  MsgExecuteContractEncodeObject,
6
8
  SigningCosmWasmClient,
7
9
  } from '@cosmjs/cosmwasm-stargate';
8
10
  import { GasPrice, calculateFee, StdFee } from '@cosmjs/stargate';
9
11
  import { MsgExecuteContract } from 'cosmjs-types/cosmwasm/wasm/v1/tx';
12
+ import { CertificateEcosystem, ErrorResponse } from '../../types';
13
+ import { SignatureResponse } from '../oracle-certificate/types';
14
+ import { OracleWhitelistConfig } from '../contract/ts/OracleMaci.types';
15
+
16
+ export function isErrorResponse(response: unknown): response is ErrorResponse {
17
+ return (
18
+ typeof response === 'object' &&
19
+ response !== null &&
20
+ 'error' in response &&
21
+ typeof (response as ErrorResponse).error === 'object' &&
22
+ 'message' in (response as ErrorResponse).error
23
+ );
24
+ }
10
25
 
11
26
  export class MACI {
12
27
  public circom: Circom;
13
28
  public contract: Contract;
14
- constructor({ circom, contract }: { circom: Circom; contract: Contract }) {
29
+ public indexer: Indexer;
30
+ public oracleCertificate: OracleCertificate;
31
+ constructor({
32
+ circom,
33
+ contract,
34
+ indexer,
35
+ oracleCertificate,
36
+ }: {
37
+ circom: Circom;
38
+ contract: Contract;
39
+ indexer: Indexer;
40
+ oracleCertificate: OracleCertificate;
41
+ }) {
15
42
  this.circom = circom;
16
43
  this.contract = contract;
44
+ this.indexer = indexer;
45
+ this.oracleCertificate = oracleCertificate;
46
+ }
47
+
48
+ async getStateIdxInc({
49
+ signer,
50
+ address,
51
+ contractAddress,
52
+ }: {
53
+ signer: OfflineSigner;
54
+ address: string;
55
+ contractAddress: string;
56
+ }) {
57
+ const client = await this.contract.maciClient({
58
+ signer,
59
+ contractAddress,
60
+ });
61
+
62
+ const stateIdx = await client.getStateIdxInc({ address });
63
+ return stateIdx;
64
+ }
65
+
66
+ async getVoiceCreditBalance({
67
+ signer,
68
+ stateIdx,
69
+ contractAddress,
70
+ }: {
71
+ signer: OfflineSigner;
72
+ stateIdx: number;
73
+ contractAddress: string;
74
+ }) {
75
+ const client = await this.contract.maciClient({
76
+ signer,
77
+ contractAddress,
78
+ });
79
+
80
+ const voiceCredit = await client.getVoiceCreditBalance({
81
+ index: stateIdx.toString(),
82
+ });
83
+ return voiceCredit;
84
+ }
85
+
86
+ async getStateIdxByPubKey({
87
+ contractAddress,
88
+ pubKey,
89
+ }: {
90
+ contractAddress: string;
91
+ pubKey: bigint[];
92
+ }) {
93
+ const response = await this.indexer.getSignUpEventByPubKey(
94
+ contractAddress,
95
+ pubKey
96
+ );
97
+
98
+ if (isErrorResponse(response)) {
99
+ return -1;
100
+ }
101
+ return response.data.signUpEvents[0].stateIdx;
102
+ }
103
+
104
+ // only for maci and oracle maci, amaci will set the voice credit when deploy the contract
105
+ async queryWhitelistBalanceOf({
106
+ signer,
107
+ address,
108
+ contractAddress,
109
+ certificate,
110
+ mode = 'maci',
111
+ }: {
112
+ signer: OfflineSigner;
113
+ address: string;
114
+ contractAddress: string;
115
+ certificate?: string;
116
+ mode?: 'maci' | 'amaci';
117
+ }): Promise<string> {
118
+ if (mode === 'amaci') {
119
+ const isWhiteListed = await this.isWhitelisted({
120
+ signer,
121
+ address,
122
+ contractAddress,
123
+ });
124
+
125
+ if (isWhiteListed) {
126
+ const round = await this.indexer.getRoundById(contractAddress);
127
+
128
+ if (!isErrorResponse(round)) {
129
+ return round.data.round.voiceCreditAmount;
130
+ } else {
131
+ throw new Error(
132
+ `Failed to query amaci voice credit: ${round.error.type}`
133
+ );
134
+ }
135
+ } else {
136
+ return '0';
137
+ }
138
+ }
139
+
140
+ if (certificate) {
141
+ const client = await this.contract.oracleMaciClient({
142
+ signer,
143
+ contractAddress,
144
+ });
145
+
146
+ const balance = await client.whiteBalanceOf({
147
+ amount: address,
148
+ certificate,
149
+ sender: address,
150
+ });
151
+
152
+ return balance;
153
+ } else {
154
+ const client = await this.contract.maciClient({
155
+ signer,
156
+ contractAddress,
157
+ });
158
+
159
+ const balance = await client.whiteBalanceOf({
160
+ sender: address,
161
+ });
162
+
163
+ return balance;
164
+ }
165
+ }
166
+
167
+ async isWhitelisted({
168
+ signer,
169
+ address,
170
+ contractAddress,
171
+ }: {
172
+ signer: OfflineSigner;
173
+ address: string;
174
+ contractAddress: string;
175
+ }) {
176
+ const client = await this.contract.amaciClient({
177
+ signer,
178
+ contractAddress,
179
+ });
180
+
181
+ const isWhitelisted = await client.isWhiteList({
182
+ sender: address,
183
+ });
184
+
185
+ return isWhitelisted;
186
+ }
187
+
188
+ async getOracleWhitelistConfig({
189
+ signer,
190
+ contractAddress,
191
+ }: {
192
+ signer: OfflineSigner;
193
+ contractAddress: string;
194
+ }): Promise<OracleWhitelistConfig> {
195
+ const client = await this.contract.oracleMaciClient({
196
+ signer,
197
+ contractAddress,
198
+ });
199
+
200
+ const snapshotHeight = await client.queryOracleWhitelistConfig();
201
+ return snapshotHeight;
202
+ }
203
+
204
+ async getRoundInfo({ contractAddress }: { contractAddress: string }) {
205
+ const roundInfo = await this.indexer.getRoundById(contractAddress);
206
+
207
+ if (isErrorResponse(roundInfo)) {
208
+ throw new Error(`Failed to get round info: ${roundInfo.error.type}`);
209
+ }
210
+
211
+ return roundInfo.data.round;
212
+ }
213
+
214
+ async getRoundCircuitType({ contractAddress }: { contractAddress: string }) {
215
+ const roundInfo = await this.getRoundInfo({ contractAddress });
216
+
217
+ return roundInfo.circuitType; // 0: 1p1v, 1: qv
218
+ }
219
+
220
+ async queryRoundIsQv({ contractAddress }: { contractAddress: string }) {
221
+ const circuitType = await this.getRoundCircuitType({ contractAddress });
222
+
223
+ return circuitType === '1';
224
+ }
225
+
226
+ async queryRoundGasStation({ contractAddress }: { contractAddress: string }) {
227
+ const roundInfo = await this.getRoundInfo({ contractAddress });
228
+
229
+ return roundInfo.gasStationEnable;
230
+ }
231
+
232
+ async requestOracleCertificate({
233
+ signer,
234
+ ecosystem,
235
+ address,
236
+ contractAddress,
237
+ }: {
238
+ signer: OfflineSigner;
239
+ ecosystem: CertificateEcosystem;
240
+ address: string;
241
+ contractAddress: string;
242
+ }): Promise<SignatureResponse> {
243
+ const oracleWhitelistConfig = await this.getOracleWhitelistConfig({
244
+ signer,
245
+ contractAddress,
246
+ });
247
+
248
+ const signResponse = await this.oracleCertificate.sign({
249
+ ecosystem,
250
+ address,
251
+ contractAddress,
252
+ height: oracleWhitelistConfig.snapshot_height,
253
+ });
254
+
255
+ return signResponse;
17
256
  }
18
257
 
19
258
  async signup({
@@ -40,7 +279,7 @@ export class MACI {
40
279
  });
41
280
 
42
281
  if (oracleCertificate) {
43
- await this.signupOracle({
282
+ return await this.signupOracle({
44
283
  client,
45
284
  address,
46
285
  pubKey: maciAccount.pubKey,
@@ -49,7 +288,7 @@ export class MACI {
49
288
  gasStation,
50
289
  });
51
290
  } else {
52
- await this.signupSimple({
291
+ return await this.signupSimple({
53
292
  client,
54
293
  address,
55
294
  pubKey: maciAccount.pubKey,
@@ -62,7 +301,46 @@ export class MACI {
62
301
  }
63
302
  }
64
303
 
65
- submit = async ({
304
+ private async processVoteOptions({
305
+ selectedOptions,
306
+ contractAddress,
307
+ voiceCreditBalance,
308
+ }: {
309
+ selectedOptions: {
310
+ idx: number;
311
+ vc: number;
312
+ }[];
313
+ contractAddress: string;
314
+ voiceCreditBalance: string;
315
+ }) {
316
+ // Check for duplicate options
317
+ const idxSet = new Set();
318
+ for (const option of selectedOptions) {
319
+ if (idxSet.has(option.idx)) {
320
+ throw new Error(
321
+ `Duplicate option index (${option.idx}) is not allowed`
322
+ );
323
+ }
324
+ idxSet.add(option.idx);
325
+ }
326
+
327
+ // Filter and sort options
328
+ const options = selectedOptions
329
+ .filter((o) => !!o.vc)
330
+ .sort((a, b) => a.idx - b.idx);
331
+
332
+ // Calculate used voice credits
333
+ const isQv = await this.queryRoundIsQv({ contractAddress });
334
+ const usedVc = options.reduce((s, o) => s + (isQv ? o.vc * o.vc : o.vc), 0);
335
+
336
+ if (Number(voiceCreditBalance) < usedVc) {
337
+ throw new Error('Insufficient voice credit balance');
338
+ }
339
+
340
+ return options;
341
+ }
342
+
343
+ async vote({
66
344
  signer,
67
345
  address,
68
346
  stateIdx,
@@ -81,10 +359,24 @@ export class MACI {
81
359
  }[];
82
360
  operatorCoordPubKey: PublicKey;
83
361
  gasStation?: boolean;
84
- }) => {
85
- const options = selectedOptions.filter((o) => !!o.vc);
362
+ }) {
363
+ if (stateIdx === -1) {
364
+ throw new Error('State index is not set, Please signup first');
365
+ }
86
366
 
87
367
  try {
368
+ const voiceCreditBalance = await this.getVoiceCreditBalance({
369
+ signer,
370
+ stateIdx,
371
+ contractAddress,
372
+ });
373
+
374
+ const options = await this.processVoteOptions({
375
+ selectedOptions,
376
+ contractAddress,
377
+ voiceCreditBalance,
378
+ });
379
+
88
380
  const maciAccount = await this.circom.genKeypairFromSign(signer, address);
89
381
 
90
382
  const plan = options.map((o) => {
@@ -102,7 +394,7 @@ export class MACI {
102
394
  signer,
103
395
  });
104
396
 
105
- await this.submitPlan({
397
+ return await this.publishMessage({
106
398
  client,
107
399
  address,
108
400
  payload,
@@ -110,11 +402,11 @@ export class MACI {
110
402
  gasStation,
111
403
  });
112
404
  } catch (error) {
113
- throw Error(`Submit failed! ${error}`);
405
+ throw Error(`Vote failed! ${error}`);
114
406
  }
115
- };
407
+ }
116
408
 
117
- async submitPlan({
409
+ async publishMessage({
118
410
  client,
119
411
  address,
120
412
  payload,
@@ -1,49 +1,9 @@
1
- import {
2
- BalanceResponse,
3
- RoundResponse,
4
- RoundsResponse,
5
- OperatorResponse,
6
- OperatorsResponse,
7
- CircuitResponse,
8
- TransactionResponse,
9
- TransactionsResponse,
10
- CircuitsResponse,
11
- ProofResponse,
12
- } from '../../types';
13
1
  import { Http } from '../http';
14
2
  import {
15
- Round,
16
- UserAccount,
17
- Circuit,
18
- Operator,
19
- Proof,
20
- Transaction,
21
- } from '../query';
22
- import { handleError, ErrorType } from '../errors';
23
- import { ERROR } from '../errors/types';
24
- import { OracleCertificateParams } from './types';
25
-
26
- /**
27
- * @class Indexer
28
- * @description This class is used to interact with Maci Indexer.
29
- */
30
- export interface SignatureRequest {
31
- address: string;
32
- height: string;
33
- contractAddress: string;
34
- amount?: string;
35
- }
36
-
37
- export interface SignatureResponse {
38
- code: number;
39
- data?: {
40
- signature: string;
41
- };
42
- error?: {
43
- message: string;
44
- type: string;
45
- };
46
- }
3
+ OracleCertificateParams,
4
+ SignatureRequest,
5
+ SignatureResponse,
6
+ } from './types';
47
7
 
48
8
  export class OracleCertificate {
49
9
  private certificateApiEndpoint: string;
@@ -55,36 +15,22 @@ export class OracleCertificate {
55
15
  }
56
16
 
57
17
  async sign(data: SignatureRequest): Promise<SignatureResponse> {
58
- try {
59
- const response = await fetch(
60
- `${this.certificateApiEndpoint}/cosmoshub/sign`,
61
- {
62
- method: 'POST',
63
- headers: {
64
- 'Content-Type': 'application/json',
65
- },
66
- body: JSON.stringify(data),
67
- }
68
- );
69
-
70
- if (!response.ok) {
71
- return {
72
- code: response.status,
73
- error: {
74
- message: `Signature request failed: ${response.status} ${response.statusText}`,
75
- type: 'error',
76
- },
77
- };
18
+ const response = await this.http.fetch(
19
+ `${this.certificateApiEndpoint}/${data.ecosystem}/sign`,
20
+ {
21
+ method: 'POST',
22
+ headers: {
23
+ 'Content-Type': 'application/json',
24
+ },
25
+ body: JSON.stringify({
26
+ address: data.address,
27
+ height: data.height,
28
+ contractAddress: data.contractAddress,
29
+ }),
78
30
  }
31
+ );
32
+ const signatureData = await response.json();
79
33
 
80
- const signatureData = await response.json();
81
-
82
- return {
83
- code: 200,
84
- data: signatureData,
85
- };
86
- } catch (error) {
87
- return handleError(error as ErrorType);
88
- }
34
+ return signatureData;
89
35
  }
90
36
  }
@@ -1,6 +1,20 @@
1
- import { FetchOptions, Http } from '../http/http';
1
+ import { CertificateEcosystem } from '../../types';
2
+ import { Http } from '../http/http';
2
3
 
3
4
  export type OracleCertificateParams = {
4
5
  certificateApiEndpoint: string;
5
6
  http: Http;
6
7
  };
8
+
9
+ export type SignatureRequest = {
10
+ ecosystem: CertificateEcosystem;
11
+ address: string;
12
+ height: string;
13
+ contractAddress: string;
14
+ };
15
+
16
+ export type SignatureResponse = {
17
+ signature: string;
18
+ amount: string;
19
+ snapshotHeight: string;
20
+ };
@@ -0,0 +1,78 @@
1
+ import { Http } from '../../libs';
2
+ import { SignUpEventsGraphqlResponse, SignUpEventsResponse } from '../../types';
3
+ import { handleError, ErrorType } from '../errors';
4
+ import { ERROR } from '../errors/types';
5
+
6
+ export class Event {
7
+ public http: Http;
8
+
9
+ constructor(http: Http) {
10
+ this.http = http;
11
+ }
12
+
13
+ async getSignUpEventByPubKey(
14
+ contractAddress: string,
15
+ pubKey: bigint[]
16
+ ): Promise<SignUpEventsResponse> {
17
+ try {
18
+ const STATE_IDX_BY_PUB_KEY_QUERY = `
19
+ query signUpEvents($limit: Int, $after: Cursor) {
20
+ signUpEvents(
21
+ first: $limit, after: $after,
22
+ filter: {
23
+ contractAddress: {
24
+ equalTo: "${contractAddress}"
25
+ }
26
+ pubKey: {
27
+ equalTo: "${pubKey.map((n) => `\\"${n}\\"`).join(',')}"
28
+ }
29
+ }) {
30
+ nodes {
31
+ id
32
+ blockHeight
33
+ txHash
34
+ contractAddress
35
+ timestamp
36
+ pubKey
37
+ stateIdx
38
+ balance
39
+ }
40
+ }
41
+ }
42
+ `;
43
+
44
+ const response =
45
+ await this.http.fetchGraphql<SignUpEventsGraphqlResponse>(
46
+ STATE_IDX_BY_PUB_KEY_QUERY,
47
+ ''
48
+ );
49
+
50
+ if (
51
+ !response ||
52
+ !response.data ||
53
+ !response.data.signUpEvents ||
54
+ !response.data.signUpEvents.nodes ||
55
+ response.data.signUpEvents.nodes.length === 0
56
+ ) {
57
+ return {
58
+ code: 404,
59
+ error: {
60
+ message: `No signUpEvents found for pubKey ${pubKey
61
+ .map((n) => `"${n}"`)
62
+ .join(',')}`,
63
+ type: ERROR.ERROR_SIGN_UP_EVENTS_NOT_FOUND,
64
+ },
65
+ };
66
+ }
67
+
68
+ return {
69
+ code: 200,
70
+ data: {
71
+ signUpEvents: response.data.signUpEvents.nodes,
72
+ },
73
+ };
74
+ } catch (error: any) {
75
+ return handleError(error as ErrorType);
76
+ }
77
+ }
78
+ }
@@ -4,3 +4,4 @@ export { Operator } from './operator';
4
4
  export { Round } from './round';
5
5
  export { Transaction } from './transaction';
6
6
  export { Proof } from './proof';
7
+ export { Event } from './event';
package/src/maci.ts CHANGED
@@ -11,7 +11,14 @@ import {
11
11
  CircuitsResponse,
12
12
  ProofResponse,
13
13
  } from './types';
14
- import { Http, Indexer, Contract } from './libs';
14
+ import {
15
+ Http,
16
+ Indexer,
17
+ Contract,
18
+ OracleCertificate,
19
+ Circom,
20
+ MACI,
21
+ } from './libs';
15
22
  import { getDefaultParams } from './libs/const';
16
23
  import {
17
24
  CreateAMaciRoundParams,
@@ -19,7 +26,6 @@ import {
19
26
  CreateOracleMaciRoundParams,
20
27
  } from './libs/contract/types';
21
28
  import { OfflineSigner } from '@cosmjs/proto-signing';
22
- import { Circom } from './libs/circom';
23
29
 
24
30
  /**
25
31
  * @class MaciClient
@@ -29,17 +35,20 @@ export class MaciClient {
29
35
  public rpcEndpoint: string;
30
36
  public restEndpoint: string;
31
37
  public apiEndpoint: string;
38
+ public certificateApiEndpoint: string;
39
+
32
40
  public registryAddress: string;
33
41
  public maciCodeId: number;
34
42
  public oracleCodeId: number;
43
+ public feegrantOperator: string;
44
+ public whitelistBackendPubkey: string;
35
45
 
36
46
  public http: Http;
37
47
  public indexer: Indexer;
38
48
  public contract: Contract;
39
49
  public circom: Circom;
40
-
41
- public feegrantOperator: string;
42
- public whitelistBackendPubkey: string;
50
+ public oracleCertificate: OracleCertificate;
51
+ public maci: MACI;
43
52
 
44
53
  /**
45
54
  * @constructor
@@ -57,12 +66,15 @@ export class MaciClient {
57
66
  defaultOptions,
58
67
  feegrantOperator,
59
68
  whitelistBackendPubkey,
69
+ certificateApiEndpoint,
60
70
  }: ClientParams) {
61
71
  const defaultParams = getDefaultParams(network);
62
72
 
63
73
  this.rpcEndpoint = rpcEndpoint || defaultParams.rpcEndpoint;
64
74
  this.restEndpoint = restEndpoint || defaultParams.restEndpoint;
65
75
  this.apiEndpoint = apiEndpoint || defaultParams.apiEndpoint;
76
+ this.certificateApiEndpoint =
77
+ certificateApiEndpoint || defaultParams.certificateApiEndpoint;
66
78
  this.registryAddress = registryAddress || defaultParams.registryAddress;
67
79
  this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
68
80
  this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
@@ -92,6 +104,16 @@ export class MaciClient {
92
104
  whitelistBackendPubkey: this.whitelistBackendPubkey,
93
105
  });
94
106
  this.circom = new Circom({ network });
107
+ this.oracleCertificate = new OracleCertificate({
108
+ certificateApiEndpoint: this.certificateApiEndpoint,
109
+ http: this.http,
110
+ });
111
+ this.maci = new MACI({
112
+ circom: this.circom,
113
+ contract: this.contract,
114
+ indexer: this.indexer,
115
+ oracleCertificate: this.oracleCertificate,
116
+ });
95
117
  }
96
118
 
97
119
  async oracleMaciClient({
@@ -17,11 +17,14 @@ export enum MaciRoundType {
17
17
  ORACLE_MACI = '2',
18
18
  }
19
19
 
20
+ export type CertificateEcosystem = 'cosmoshub' | 'doravota';
21
+
20
22
  export type ClientParams = {
21
23
  network: 'mainnet' | 'testnet';
22
24
  rpcEndpoint?: string;
23
25
  restEndpoint?: string;
24
26
  apiEndpoint?: string;
27
+ certificateApiEndpoint?: string;
25
28
  registryAddress?: string;
26
29
  maciCodeId?: number;
27
30
  oracleCodeId?: number;
@@ -133,6 +136,17 @@ export type CircuitType = {
133
136
  roundCount?: number;
134
137
  };
135
138
 
139
+ export type SignUpEventType = {
140
+ id: string;
141
+ blockHeight: string;
142
+ txHash: string;
143
+ contractAddress: string;
144
+ timestamp: string;
145
+ pubKey: string;
146
+ stateIdx: number;
147
+ balance: string;
148
+ };
149
+
136
150
  export type CircuitsCountGraphqlResponse = {
137
151
  data: {
138
152
  rounds: {
@@ -320,3 +334,17 @@ export type ProofGraphqlResponse = {
320
334
  proofData: ProofType;
321
335
  };
322
336
  };
337
+
338
+ export type SignUpEventsResponse =
339
+ | SuccessResponse<{
340
+ signUpEvents: SignUpEventType[];
341
+ }>
342
+ | ErrorResponse;
343
+
344
+ export type SignUpEventsGraphqlResponse = {
345
+ data: {
346
+ signUpEvents: {
347
+ nodes: SignUpEventType[];
348
+ };
349
+ };
350
+ };