@dorafactory/maci-sdk 0.0.9 → 0.0.10

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.
@@ -16,7 +16,7 @@ export declare class Contract {
16
16
  constructor({ rpcEndpoint, registryAddress, maciCodeId, oracleCodeId, feegrantOperator, whitelistBackendPubkey, }: ContractParams);
17
17
  createAMaciRound({ signer, startVoting, endVoting, operator, whitelist, title, description, link, maxVoter, maxOption, voiceCreditAmount, circuitType, preDeactivateRoot, }: CreateAMaciRoundParams): Promise<string>;
18
18
  createMaciRound({ signer, operatorPubkey, startVoting, endVoting, whitelist, title, description, link, maxVoter, maxOption, circuitType, certSystemType, }: CreateMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
19
- createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, maxVoter, maxOption, circuitType, whitelistEcosystem, whitelistSnapshotHeight, whitelistVotingPowerArgs, }: CreateOracleMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
19
+ createOracleMaciRound({ signer, operatorPubkey, startVoting, endVoting, title, description, link, voteOptionMap, circuitType, whitelistEcosystem, whitelistSnapshotHeight, whitelistVotingPowerArgs, }: CreateOracleMaciRoundParams): Promise<import("@cosmjs/cosmwasm-stargate").InstantiateResult>;
20
20
  queryRoundInfo({ signer, roundAddress, }: {
21
21
  signer: OfflineSigner;
22
22
  roundAddress: string;
@@ -9,22 +9,25 @@ export type CreateRoundParams = {
9
9
  link?: string;
10
10
  startVoting: Date;
11
11
  endVoting: Date;
12
- maxVoter: string;
13
- maxOption: string;
14
12
  circuitType: MaciCircuitType;
15
13
  };
16
14
  export type CreateAMaciRoundParams = {
15
+ maxVoter: string;
16
+ maxOption: string;
17
17
  operator: string;
18
18
  whitelist: RegistryWhitelist;
19
19
  voiceCreditAmount: string;
20
20
  preDeactivateRoot?: string;
21
21
  } & CreateRoundParams;
22
22
  export type CreateMaciRoundParams = {
23
+ maxVoter: string;
24
+ maxOption: string;
23
25
  operatorPubkey: string;
24
26
  whitelist: MaciWhitelist;
25
27
  certSystemType: MaciCertSystemType;
26
28
  } & CreateRoundParams;
27
29
  export type CreateOracleMaciRoundParams = {
30
+ voteOptionMap: string[];
28
31
  operatorPubkey: string;
29
32
  whitelistEcosystem: CertificateEcosystem;
30
33
  whitelistSnapshotHeight: string;
@@ -3,6 +3,7 @@ type MixedData<T> = T | Array<MixedData<T>> | {
3
3
  [key: string]: MixedData<T>;
4
4
  };
5
5
  export declare const stringizing: (o: MixedData<bigint>, path?: MixedData<bigint>[]) => MixedData<string>;
6
+ export declare function getCircuitType(circuitType: MaciCircuitType): string;
6
7
  export declare function getContractParams(type: MaciRoundType, circuitType: MaciCircuitType, proofSystem: MaciCertSystemType, maxVoter: string, maxOption: string): {
7
8
  parameters: {
8
9
  state_tree_depth: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dorafactory/maci-sdk",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "SDK for interacting with maci",
5
5
  "keywords": [
6
6
  "maci",
package/src/libs/const.ts CHANGED
@@ -171,7 +171,7 @@ export function getDefaultParams(
171
171
  registryAddress:
172
172
  'dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4',
173
173
  maciCodeId: 106,
174
- oracleCodeId: 111,
174
+ oracleCodeId: 116,
175
175
  oracleWhitelistBackendPubkey:
176
176
  'A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q',
177
177
  oracleFeegrantOperator: 'dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8',
@@ -188,7 +188,7 @@ export function getDefaultParams(
188
188
  registryAddress:
189
189
  'dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd',
190
190
  maciCodeId: 107,
191
- oracleCodeId: 110,
191
+ oracleCodeId: 113,
192
192
  oracleWhitelistBackendPubkey:
193
193
  'AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ',
194
194
  oracleFeegrantOperator: 'dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78',
@@ -27,7 +27,7 @@ import {
27
27
  CreateMaciRoundParams,
28
28
  CreateOracleMaciRoundParams,
29
29
  } from './types';
30
- import { getContractParams } from './utils';
30
+ import { getCircuitType, getContractParams } from './utils';
31
31
  import { QTR_LIB } from './vars';
32
32
  import { MaciRoundType, MaciCertSystemType } from '../../types';
33
33
  import { decompressPublicKey } from '../../utils';
@@ -192,8 +192,7 @@ export class Contract {
192
192
  title,
193
193
  description,
194
194
  link,
195
- maxVoter,
196
- maxOption,
195
+ voteOptionMap,
197
196
  circuitType,
198
197
  whitelistEcosystem,
199
198
  whitelistSnapshotHeight,
@@ -205,20 +204,12 @@ export class Contract {
205
204
  const client = await createContractClientByWallet(this.rpcEndpoint, signer);
206
205
  const { x: operatorPubkeyX, y: operatorPubkeyY } =
207
206
  decompressPublicKey(operatorPubkey);
208
- const {
209
- parameters,
210
- groth16ProcessVkey,
211
- groth16TallyVkey,
212
- plonkProcessVkey,
213
- plonkTallyVkey,
214
- maciVoteType,
215
- maciCertSystem,
216
- } = getContractParams(
207
+ const { maciVoteType, maciCertSystem } = getContractParams(
217
208
  MaciRoundType.ORACLE_MACI,
218
209
  circuitType,
219
210
  MaciCertSystemType.GROTH16,
220
- maxVoter,
221
- maxOption
211
+ '0',
212
+ '0'
222
213
  );
223
214
  const instantiateResponse = await client.instantiate(
224
215
  address,
@@ -229,23 +220,17 @@ export class Contract {
229
220
  start_time,
230
221
  end_time,
231
222
  },
232
- parameters,
233
223
  coordinator: {
234
224
  x: operatorPubkeyX,
235
225
  y: operatorPubkeyY,
236
226
  },
237
- groth16_process_vkey: groth16ProcessVkey,
238
- groth16_tally_vkey: groth16TallyVkey,
239
- plonk_process_vkey: plonkProcessVkey,
240
- plonk_tally_vkey: plonkTallyVkey,
241
- max_vote_options: maxOption,
227
+ vote_option_map: voteOptionMap,
242
228
  whitelist_backend_pubkey: this.whitelistBackendPubkey,
243
229
  whitelist_ecosystem: whitelistEcosystem,
244
230
  whitelist_snapshot_height: whitelistSnapshotHeight,
245
231
  whitelist_voting_power_args: whitelistVotingPowerArgs,
246
232
  circuit_type: maciVoteType,
247
233
  certification_system: maciCertSystem,
248
- qtr_lib: QTR_LIB,
249
234
  feegrant_operator: this.feegrantOperator,
250
235
  },
251
236
  `[Oracle MACI] ${title}`,
@@ -14,12 +14,12 @@ export type CreateRoundParams = {
14
14
  link?: string;
15
15
  startVoting: Date;
16
16
  endVoting: Date;
17
- maxVoter: string;
18
- maxOption: string;
19
17
  circuitType: MaciCircuitType;
20
18
  };
21
19
 
22
20
  export type CreateAMaciRoundParams = {
21
+ maxVoter: string;
22
+ maxOption: string;
23
23
  operator: string;
24
24
  whitelist: RegistryWhitelist;
25
25
  voiceCreditAmount: string;
@@ -27,12 +27,15 @@ export type CreateAMaciRoundParams = {
27
27
  } & CreateRoundParams;
28
28
 
29
29
  export type CreateMaciRoundParams = {
30
+ maxVoter: string;
31
+ maxOption: string;
30
32
  operatorPubkey: string;
31
33
  whitelist: MaciWhitelist;
32
34
  certSystemType: MaciCertSystemType;
33
35
  } & CreateRoundParams;
34
36
 
35
37
  export type CreateOracleMaciRoundParams = {
38
+ voteOptionMap: string[];
36
39
  operatorPubkey: string;
37
40
  whitelistEcosystem: CertificateEcosystem;
38
41
  whitelistSnapshotHeight: string;
@@ -29,6 +29,23 @@ export const stringizing = (
29
29
  }
30
30
  };
31
31
 
32
+ export function getCircuitType(circuitType: MaciCircuitType) {
33
+ let maciVoteType = null;
34
+ switch (circuitType) {
35
+ case MaciCircuitType.IP1V:
36
+ maciVoteType = '0';
37
+ break;
38
+ case MaciCircuitType.QV:
39
+ maciVoteType = '1';
40
+ break;
41
+ default:
42
+ throw new Error(
43
+ `Invalid circuit type ${circuitType}, only support 1P1V and QV`
44
+ );
45
+ }
46
+ return maciVoteType;
47
+ }
48
+
32
49
  export function getContractParams(
33
50
  type: MaciRoundType,
34
51
  circuitType: MaciCircuitType,