@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
@@ -6,122 +6,122 @@
6
6
 
7
7
  export type Addr = string;
8
8
  export interface InstantiateMsg {
9
- admin: Addr;
10
- amaci_code_id: number;
11
- operator: Addr;
9
+ admin: Addr;
10
+ amaci_code_id: number;
11
+ operator: Addr;
12
12
  }
13
13
  export type ExecuteMsg =
14
- | {
15
- set_maci_operator: {
16
- operator: Addr;
17
- };
18
- }
19
- | {
20
- set_maci_operator_pubkey: {
21
- pubkey: PubKey;
22
- };
23
- }
24
- | {
25
- set_maci_operator_identity: {
26
- identity: string;
27
- };
28
- }
29
- | {
30
- create_round: {
31
- certification_system: Uint256;
32
- circuit_type: Uint256;
33
- max_option: Uint256;
34
- max_voter: Uint256;
35
- operator: Addr;
36
- pre_deactivate_root: Uint256;
37
- round_info: RoundInfo;
38
- voice_credit_amount: Uint256;
39
- voting_time: VotingTime;
40
- whitelist?: Whitelist | null;
41
- };
42
- }
43
- | {
44
- set_validators: {
45
- addresses: ValidatorSet;
46
- };
47
- }
48
- | {
49
- remove_validator: {
50
- address: Addr;
51
- };
52
- }
53
- | {
54
- update_amaci_code_id: {
55
- amaci_code_id: number;
56
- };
57
- }
58
- | {
59
- change_operator: {
60
- address: Addr;
61
- };
62
- };
14
+ | {
15
+ set_maci_operator: {
16
+ operator: Addr;
17
+ };
18
+ }
19
+ | {
20
+ set_maci_operator_pubkey: {
21
+ pubkey: PubKey;
22
+ };
23
+ }
24
+ | {
25
+ set_maci_operator_identity: {
26
+ identity: string;
27
+ };
28
+ }
29
+ | {
30
+ create_round: {
31
+ certification_system: Uint256;
32
+ circuit_type: Uint256;
33
+ max_option: Uint256;
34
+ max_voter: Uint256;
35
+ operator: Addr;
36
+ pre_deactivate_root: Uint256;
37
+ round_info: RoundInfo;
38
+ voice_credit_amount: Uint256;
39
+ voting_time: VotingTime;
40
+ whitelist?: Whitelist | null;
41
+ };
42
+ }
43
+ | {
44
+ set_validators: {
45
+ addresses: ValidatorSet;
46
+ };
47
+ }
48
+ | {
49
+ remove_validator: {
50
+ address: Addr;
51
+ };
52
+ }
53
+ | {
54
+ update_amaci_code_id: {
55
+ amaci_code_id: number;
56
+ };
57
+ }
58
+ | {
59
+ change_operator: {
60
+ address: Addr;
61
+ };
62
+ };
63
63
  export type Uint256 = string;
64
64
  export type Timestamp = Uint64;
65
65
  export type Uint64 = string;
66
66
  export interface PubKey {
67
- x: Uint256;
68
- y: Uint256;
67
+ x: Uint256;
68
+ y: Uint256;
69
69
  }
70
70
  export interface RoundInfo {
71
- description: string;
72
- link: string;
73
- title: string;
71
+ description: string;
72
+ link: string;
73
+ title: string;
74
74
  }
75
75
  export interface VotingTime {
76
- end_time: Timestamp;
77
- start_time: Timestamp;
76
+ end_time: Timestamp;
77
+ start_time: Timestamp;
78
78
  }
79
79
  export interface Whitelist {
80
- users: WhitelistConfig[];
80
+ users: WhitelistConfig[];
81
81
  }
82
82
  export interface WhitelistConfig {
83
- addr: Addr;
83
+ addr: Addr;
84
84
  }
85
85
  export interface ValidatorSet {
86
- addresses: Addr[];
86
+ addresses: Addr[];
87
87
  }
88
88
  export type QueryMsg =
89
- | {
90
- admin: {};
91
- }
92
- | {
93
- operator: {};
94
- }
95
- | {
96
- is_maci_operator: {
97
- address: Addr;
98
- };
99
- }
100
- | {
101
- is_validator: {
102
- address: Addr;
103
- };
104
- }
105
- | {
106
- get_validators: {};
107
- }
108
- | {
109
- get_validator_operator: {
110
- address: Addr;
111
- };
112
- }
113
- | {
114
- get_maci_operator_pubkey: {
115
- address: Addr;
116
- };
117
- }
118
- | {
119
- get_maci_operator_identity: {
120
- address: Addr;
121
- };
122
- };
89
+ | {
90
+ admin: {};
91
+ }
92
+ | {
93
+ operator: {};
94
+ }
95
+ | {
96
+ is_maci_operator: {
97
+ address: Addr;
98
+ };
99
+ }
100
+ | {
101
+ is_validator: {
102
+ address: Addr;
103
+ };
104
+ }
105
+ | {
106
+ get_validators: {};
107
+ }
108
+ | {
109
+ get_validator_operator: {
110
+ address: Addr;
111
+ };
112
+ }
113
+ | {
114
+ get_maci_operator_pubkey: {
115
+ address: Addr;
116
+ };
117
+ }
118
+ | {
119
+ get_maci_operator_identity: {
120
+ address: Addr;
121
+ };
122
+ };
123
123
  export interface AdminResponse {
124
- admin: Addr;
124
+ admin: Addr;
125
125
  }
126
126
  export type String = string;
127
127
  export type Boolean = boolean;
@@ -1,7 +1,11 @@
1
1
  import { Whitelist as RegistryWhitelist } from './ts/Registry.types';
2
2
  import { Whitelist as MaciWhitelist } from './ts/Maci.types';
3
3
  import { OfflineSigner } from '@cosmjs/proto-signing';
4
- import { MaciCircuitType, MaciCertSystemType } from '../../types';
4
+ import {
5
+ MaciCircuitType,
6
+ MaciCertSystemType,
7
+ CertificateEcosystem,
8
+ } from '../../types';
5
9
 
6
10
  export type CreateRoundParams = {
7
11
  signer: OfflineSigner;
@@ -30,7 +34,7 @@ export type CreateMaciRoundParams = {
30
34
 
31
35
  export type CreateOracleMaciRoundParams = {
32
36
  operatorPubkey: string;
33
- whitelistEcosystem: 'cosmoshub' | 'doravota';
37
+ whitelistEcosystem: CertificateEcosystem;
34
38
  whitelistSnapshotHeight: string;
35
39
  whitelistVotingPowerArgs: {
36
40
  mode: 'slope' | 'threshold';
@@ -148,6 +148,15 @@ export function getContractParams(
148
148
  // plonkTallyVkey,
149
149
  };
150
150
  case MaciRoundType.ORACLE_MACI:
151
+ if (circuitType === MaciCircuitType.IP1V) {
152
+ groth16ProcessVkey =
153
+ CIRCUIT_INFO['9-4-3-625']['groth16'].process_1p1v_vkey;
154
+ groth16TallyVkey = CIRCUIT_INFO['9-4-3-625']['groth16'].tally_1p1v_vkey;
155
+ } else if (circuitType === MaciCircuitType.QV) {
156
+ groth16ProcessVkey =
157
+ CIRCUIT_INFO['9-4-3-625']['groth16'].process_qv_vkey;
158
+ groth16TallyVkey = CIRCUIT_INFO['9-4-3-625']['groth16'].tally_qv_vkey;
159
+ }
151
160
  return {
152
161
  parameters: CIRCUIT_INFO['9-4-3-625'].parameter,
153
162
  groth16ProcessVkey,
@@ -11,4 +11,5 @@ export const ERROR = {
11
11
  ERROR_ROUNDS_NOT_FOUND: 'ERROR_ROUNDS_NOT_FOUND',
12
12
  ERROR_TRANSACTION_NOT_FOUND: 'ERROR_TRANSACTION_NOT_FOUND',
13
13
  ERROR_TRANSACTIONS_NOT_FOUND: 'ERROR_TRANSACTIONS_NOT_FOUND',
14
+ ERROR_SIGN_UP_EVENTS_NOT_FOUND: 'ERROR_SIGN_UP_EVENTS_NOT_FOUND',
14
15
  };
@@ -1,9 +1,4 @@
1
- import {
2
- BaseError,
3
- HttpError,
4
- GraphQLError,
5
- ParseError,
6
- } from '../errors';
1
+ import { BaseError, HttpError, GraphQLError, ParseError } from '../errors';
7
2
 
8
3
  export type FetchOptions = RequestInit & {
9
4
  next?: {
@@ -31,11 +26,12 @@ export class Http {
31
26
  return this.customFetch || fetch;
32
27
  }
33
28
 
34
- async fetch(url: string): Promise<Response> {
29
+ async fetch(url: string, options?: any): Promise<Response> {
35
30
  try {
36
31
  const fetchFn = this.getFetch();
37
32
  const response = await fetchFn(url, {
38
33
  ...this.defaultOptions,
34
+ ...options,
39
35
  });
40
36
 
41
37
  if (!response.ok) {
package/src/libs/index.ts CHANGED
@@ -2,3 +2,6 @@ export { Http } from './http';
2
2
  export * from './query';
3
3
  export * from './indexer';
4
4
  export * from './contract';
5
+ export * from './oracle-certificate';
6
+ export * from './circom';
7
+ export * from './maci';
@@ -9,6 +9,7 @@ import {
9
9
  TransactionsResponse,
10
10
  CircuitsResponse,
11
11
  ProofResponse,
12
+ SignUpEventsResponse,
12
13
  } from '../../types';
13
14
  import { IndexerParams } from './types';
14
15
  import { Http } from '../http';
@@ -19,6 +20,7 @@ import {
19
20
  Operator,
20
21
  Proof,
21
22
  Transaction,
23
+ Event,
22
24
  } from '../query';
23
25
 
24
26
  /**
@@ -37,6 +39,7 @@ export class Indexer {
37
39
  public operator: Operator;
38
40
  public proof: Proof;
39
41
  public transaction: Transaction;
42
+ public event: Event;
40
43
 
41
44
  /**
42
45
  * @constructor
@@ -60,6 +63,7 @@ export class Indexer {
60
63
  this.operator = new Operator(this.http, this.registryAddress);
61
64
  this.proof = new Proof(this.http);
62
65
  this.transaction = new Transaction(this.http);
66
+ this.event = new Event(this.http);
63
67
  }
64
68
 
65
69
  /**
@@ -237,4 +241,18 @@ export class Indexer {
237
241
  async getProofByContractAddress(address: string): Promise<ProofResponse> {
238
242
  return await this.proof.getProofByContractAddress(address);
239
243
  }
244
+
245
+ /**
246
+ * @method getStateIdxByPubKey
247
+ * @description Get the state index of a specific public key.
248
+ * @param {string} contractAddress - The contract address.
249
+ * @param {bigint[]} pubKey - The public key.
250
+ * @returns {Promise<SignUpEventsResponse>} The sign up events response.
251
+ */
252
+ async getSignUpEventByPubKey(
253
+ contractAddress: string,
254
+ pubKey: bigint[]
255
+ ): Promise<SignUpEventsResponse> {
256
+ return await this.event.getSignUpEventByPubKey(contractAddress, pubKey);
257
+ }
240
258
  }
@@ -0,0 +1 @@
1
+ export { MACI } from './maci';