@dorafactory/maci-sdk 0.1.2 → 0.1.3-pre.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.
Files changed (39) hide show
  1. package/dist/index.d.ts +1 -1
  2. package/dist/index.js +2371 -975
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +2369 -975
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/libs/const.d.ts +1 -2
  7. package/dist/libs/contract/config.d.ts +12 -0
  8. package/dist/libs/contract/contract.d.ts +66 -4
  9. package/dist/libs/contract/ts/AMaci.client.d.ts +25 -3
  10. package/dist/libs/contract/ts/AMaci.types.d.ts +26 -1
  11. package/dist/libs/contract/ts/ApiMaci.client.d.ts +170 -0
  12. package/dist/libs/contract/ts/ApiMaci.types.d.ts +187 -0
  13. package/dist/libs/contract/ts/ApiSaas.client.d.ts +148 -0
  14. package/dist/libs/contract/ts/ApiSaas.types.d.ts +126 -0
  15. package/dist/libs/contract/ts/Registry.client.d.ts +17 -7
  16. package/dist/libs/contract/ts/Registry.types.d.ts +16 -5
  17. package/dist/libs/contract/types.d.ts +15 -3
  18. package/dist/libs/crypto/bigintUtils.d.ts +2 -0
  19. package/dist/libs/maci/maci.d.ts +34 -4
  20. package/dist/maci.d.ts +47 -3
  21. package/dist/types/index.d.ts +2 -2
  22. package/package.json +1 -1
  23. package/src/index.ts +5 -1
  24. package/src/libs/const.ts +5 -6
  25. package/src/libs/contract/config.ts +36 -0
  26. package/src/libs/contract/contract.ts +611 -6
  27. package/src/libs/contract/ts/AMaci.client.ts +66 -0
  28. package/src/libs/contract/ts/AMaci.types.ts +30 -1
  29. package/src/libs/contract/ts/ApiMaci.client.ts +459 -0
  30. package/src/libs/contract/ts/ApiMaci.types.ts +188 -0
  31. package/src/libs/contract/ts/ApiSaas.client.ts +581 -0
  32. package/src/libs/contract/ts/ApiSaas.types.ts +144 -0
  33. package/src/libs/contract/ts/Registry.client.ts +57 -9
  34. package/src/libs/contract/ts/Registry.types.ts +18 -5
  35. package/src/libs/contract/types.ts +16 -3
  36. package/src/libs/crypto/bigintUtils.ts +28 -0
  37. package/src/libs/maci/maci.ts +190 -9
  38. package/src/maci.ts +86 -4
  39. package/src/types/index.ts +2 -2
package/dist/index.mjs CHANGED
@@ -338,15 +338,14 @@ function getDefaultParams(network = "mainnet") {
338
338
  certificateApiEndpoint: "https://vota-certificate-api.dorafactory.org/api/v1",
339
339
  registryAddress: "dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4",
340
340
  saasAddress: "dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8",
341
+ apiSaasAddress: "dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8",
341
342
  maciCodeId: 106,
342
343
  // oracleCodeId: 116,// 9-4-3-625
343
344
  oracleCodeId: 119,
344
345
  // 6-3-3-125
345
- saasCodeId: 124,
346
346
  oracleWhitelistBackendPubkey: "A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q",
347
347
  oracleFeegrantOperator: "dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8",
348
- oracleCodeIds: ["101", "116", "117", "119"],
349
- saasCodeIds: ["124"]
348
+ oracleCodeIds: ["101", "116", "117", "119"]
350
349
  };
351
350
  case "testnet":
352
351
  return {
@@ -358,15 +357,14 @@ function getDefaultParams(network = "mainnet") {
358
357
  certificateApiEndpoint: "https://vota-testnet-certificate-api.dorafactory.org/api/v1",
359
358
  registryAddress: "dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd",
360
359
  saasAddress: "dora1dgnszrwnwxgr5djprrr6w4q45z8s3ghsew869g6tlp4ruqah39nqnemjya",
360
+ apiSaasAddress: "dora16xj2yrh3snq8f2qvma9uzjd5m2qgvzaqjcqmeuweh73t29c4rhusxm9hq6",
361
361
  maciCodeId: 134,
362
362
  // oracleCodeId: 113, // 9-4-3-625
363
363
  oracleCodeId: 123,
364
364
  // 6-3-3-125
365
- saasCodeId: 152,
366
365
  oracleWhitelistBackendPubkey: "AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ",
367
366
  oracleFeegrantOperator: "dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78",
368
- oracleCodeIds: ["102", "105", "108", "110", "113", "115", "123"],
369
- saasCodeIds: ["152"]
367
+ oracleCodeIds: ["102", "105", "108", "110", "113", "115", "123"]
370
368
  };
371
369
  }
372
370
  }
@@ -477,6 +475,28 @@ var bigInt2Buffer = (i) => {
477
475
  }
478
476
  return Buffer.from(hex, "hex");
479
477
  };
478
+ var buffer2Bigint = (buffer) => {
479
+ const buf = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
480
+ const hex = buf.toString("hex");
481
+ return BigInt("0x" + hex);
482
+ };
483
+ var destringizing = (o, path = []) => {
484
+ if (path.includes(o)) {
485
+ throw new Error("loop nesting!");
486
+ }
487
+ const newPath = [...path, o];
488
+ if (Array.isArray(o)) {
489
+ return o.map((item) => destringizing(item, newPath));
490
+ } else if (typeof o === "object" && o !== null) {
491
+ const output = {};
492
+ for (const key in o) {
493
+ output[key] = destringizing(o[key], newPath);
494
+ }
495
+ return output;
496
+ } else {
497
+ return BigInt(o);
498
+ }
499
+ };
480
500
 
481
501
  // src/libs/crypto/keys.ts
482
502
  import { poseidonEncrypt } from "@zk-kit/poseidon-cipher";
@@ -3204,6 +3224,38 @@ var AMaciQueryClient = class {
3204
3224
  get_delay_records: {}
3205
3225
  });
3206
3226
  };
3227
+ this.getTallyDelay = async () => {
3228
+ return this.client.queryContractSmart(this.contractAddress, {
3229
+ get_tally_delay: {}
3230
+ });
3231
+ };
3232
+ this.queryOracleWhitelistConfig = async () => {
3233
+ return this.client.queryContractSmart(this.contractAddress, {
3234
+ query_oracle_whitelist_config: {}
3235
+ });
3236
+ };
3237
+ this.canSignUpWithOracle = async ({
3238
+ certificate,
3239
+ pubkey
3240
+ }) => {
3241
+ return this.client.queryContractSmart(this.contractAddress, {
3242
+ can_sign_up_with_oracle: {
3243
+ certificate,
3244
+ pubkey
3245
+ }
3246
+ });
3247
+ };
3248
+ this.whiteBalanceOf = async ({
3249
+ certificate,
3250
+ pubkey
3251
+ }) => {
3252
+ return this.client.queryContractSmart(this.contractAddress, {
3253
+ white_balance_of: {
3254
+ certificate,
3255
+ pubkey
3256
+ }
3257
+ });
3258
+ };
3207
3259
  this.client = client;
3208
3260
  this.contractAddress = contractAddress;
3209
3261
  this.admin = this.admin.bind(this);
@@ -3234,6 +3286,10 @@ var AMaciQueryClient = class {
3234
3286
  this.queryCertSystem = this.queryCertSystem.bind(this);
3235
3287
  this.queryPreDeactivateRoot = this.queryPreDeactivateRoot.bind(this);
3236
3288
  this.getDelayRecords = this.getDelayRecords.bind(this);
3289
+ this.getTallyDelay = this.getTallyDelay.bind(this);
3290
+ this.queryOracleWhitelistConfig = this.queryOracleWhitelistConfig.bind(this);
3291
+ this.canSignUpWithOracle = this.canSignUpWithOracle.bind(this);
3292
+ this.whiteBalanceOf = this.whiteBalanceOf.bind(this);
3237
3293
  }
3238
3294
  };
3239
3295
  var AMaciClient = class extends AMaciQueryClient {
@@ -3288,6 +3344,7 @@ var AMaciClient = class extends AMaciQueryClient {
3288
3344
  );
3289
3345
  };
3290
3346
  this.signUp = async ({
3347
+ certificate,
3291
3348
  pubkey
3292
3349
  }, fee = "auto", memo, _funds) => {
3293
3350
  return await this.client.execute(
@@ -3295,6 +3352,7 @@ var AMaciClient = class extends AMaciQueryClient {
3295
3352
  this.contractAddress,
3296
3353
  {
3297
3354
  sign_up: {
3355
+ certificate,
3298
3356
  pubkey
3299
3357
  }
3300
3358
  },
@@ -3575,6 +3633,11 @@ var RegistryQueryClient = class {
3575
3633
  }
3576
3634
  });
3577
3635
  };
3636
+ this.getCircuitChargeConfig = async () => {
3637
+ return this.client.queryContractSmart(this.contractAddress, {
3638
+ get_circuit_charge_config: {}
3639
+ });
3640
+ };
3578
3641
  this.client = client;
3579
3642
  this.contractAddress = contractAddress;
3580
3643
  this.admin = this.admin.bind(this);
@@ -3585,6 +3648,7 @@ var RegistryQueryClient = class {
3585
3648
  this.getValidatorOperator = this.getValidatorOperator.bind(this);
3586
3649
  this.getMaciOperatorPubkey = this.getMaciOperatorPubkey.bind(this);
3587
3650
  this.getMaciOperatorIdentity = this.getMaciOperatorIdentity.bind(this);
3651
+ this.getCircuitChargeConfig = this.getCircuitChargeConfig.bind(this);
3588
3652
  }
3589
3653
  };
3590
3654
  var RegistryClient = class extends RegistryQueryClient {
@@ -3641,12 +3705,13 @@ var RegistryClient = class extends RegistryQueryClient {
3641
3705
  this.createRound = async ({
3642
3706
  certificationSystem,
3643
3707
  circuitType,
3644
- maxOption,
3645
3708
  maxVoter,
3646
3709
  operator,
3710
+ oracleWhitelistPubkey,
3647
3711
  preDeactivateRoot,
3648
3712
  roundInfo,
3649
3713
  voiceCreditAmount,
3714
+ voteOptionMap,
3650
3715
  votingTime,
3651
3716
  whitelist
3652
3717
  }, fee = "auto", memo, _funds) => {
@@ -3657,12 +3722,13 @@ var RegistryClient = class extends RegistryQueryClient {
3657
3722
  create_round: {
3658
3723
  certification_system: certificationSystem,
3659
3724
  circuit_type: circuitType,
3660
- max_option: maxOption,
3661
3725
  max_voter: maxVoter,
3662
3726
  operator,
3727
+ oracle_whitelist_pubkey: oracleWhitelistPubkey,
3663
3728
  pre_deactivate_root: preDeactivateRoot,
3664
3729
  round_info: roundInfo,
3665
3730
  voice_credit_amount: voiceCreditAmount,
3731
+ vote_option_map: voteOptionMap,
3666
3732
  voting_time: votingTime,
3667
3733
  whitelist
3668
3734
  }
@@ -3736,6 +3802,22 @@ var RegistryClient = class extends RegistryQueryClient {
3736
3802
  _funds
3737
3803
  );
3738
3804
  };
3805
+ this.changeChargeConfig = async ({
3806
+ config
3807
+ }, fee = "auto", memo, _funds) => {
3808
+ return await this.client.execute(
3809
+ this.sender,
3810
+ this.contractAddress,
3811
+ {
3812
+ change_charge_config: {
3813
+ config
3814
+ }
3815
+ },
3816
+ fee,
3817
+ memo,
3818
+ _funds
3819
+ );
3820
+ };
3739
3821
  this.client = client;
3740
3822
  this.sender = sender;
3741
3823
  this.contractAddress = contractAddress;
@@ -3747,6 +3829,7 @@ var RegistryClient = class extends RegistryQueryClient {
3747
3829
  this.removeValidator = this.removeValidator.bind(this);
3748
3830
  this.updateAmaciCodeId = this.updateAmaciCodeId.bind(this);
3749
3831
  this.changeOperator = this.changeOperator.bind(this);
3832
+ this.changeChargeConfig = this.changeChargeConfig.bind(this);
3750
3833
  }
3751
3834
  };
3752
3835
 
@@ -4486,46 +4569,627 @@ var SaasClient = class extends SaasQueryClient {
4486
4569
  }
4487
4570
  };
4488
4571
 
4489
- // src/libs/contract/config.ts
4490
- var defaultSigningClientOptions = {
4491
- broadcastPollIntervalMs: 8e3,
4492
- broadcastTimeoutMs: 15e4,
4493
- // 2min30s for the tx to be confirmed
4494
- gasPrice: GasPrice.fromString("10000000000peaka")
4572
+ // src/libs/contract/ts/ApiMaci.client.ts
4573
+ var ApiMaciQueryClient = class {
4574
+ constructor(client, contractAddress) {
4575
+ this.getRoundInfo = async () => {
4576
+ return this.client.queryContractSmart(this.contractAddress, {
4577
+ get_round_info: {}
4578
+ });
4579
+ };
4580
+ this.getVotingTime = async () => {
4581
+ return this.client.queryContractSmart(this.contractAddress, {
4582
+ get_voting_time: {}
4583
+ });
4584
+ };
4585
+ this.getPeriod = async () => {
4586
+ return this.client.queryContractSmart(this.contractAddress, {
4587
+ get_period: {}
4588
+ });
4589
+ };
4590
+ this.getNumSignUp = async () => {
4591
+ return this.client.queryContractSmart(this.contractAddress, {
4592
+ get_num_sign_up: {}
4593
+ });
4594
+ };
4595
+ this.getMsgChainLength = async () => {
4596
+ return this.client.queryContractSmart(this.contractAddress, {
4597
+ get_msg_chain_length: {}
4598
+ });
4599
+ };
4600
+ this.getProcessedMsgCount = async () => {
4601
+ return this.client.queryContractSmart(this.contractAddress, {
4602
+ get_processed_msg_count: {}
4603
+ });
4604
+ };
4605
+ this.getProcessedUserCount = async () => {
4606
+ return this.client.queryContractSmart(this.contractAddress, {
4607
+ get_processed_user_count: {}
4608
+ });
4609
+ };
4610
+ this.getResult = async ({
4611
+ index
4612
+ }) => {
4613
+ return this.client.queryContractSmart(this.contractAddress, {
4614
+ get_result: {
4615
+ index
4616
+ }
4617
+ });
4618
+ };
4619
+ this.getAllResult = async () => {
4620
+ return this.client.queryContractSmart(this.contractAddress, {
4621
+ get_all_result: {}
4622
+ });
4623
+ };
4624
+ this.getStateIdxInc = async ({
4625
+ address
4626
+ }) => {
4627
+ return this.client.queryContractSmart(this.contractAddress, {
4628
+ get_state_idx_inc: {
4629
+ address
4630
+ }
4631
+ });
4632
+ };
4633
+ this.getVoiceCreditBalance = async ({
4634
+ index
4635
+ }) => {
4636
+ return this.client.queryContractSmart(this.contractAddress, {
4637
+ get_voice_credit_balance: {
4638
+ index
4639
+ }
4640
+ });
4641
+ };
4642
+ this.isWhiteList = async ({
4643
+ amount,
4644
+ certificate,
4645
+ pubkey
4646
+ }) => {
4647
+ return this.client.queryContractSmart(this.contractAddress, {
4648
+ is_white_list: {
4649
+ amount,
4650
+ certificate,
4651
+ pubkey
4652
+ }
4653
+ });
4654
+ };
4655
+ this.whiteBalanceOf = async ({
4656
+ amount,
4657
+ certificate,
4658
+ pubkey
4659
+ }) => {
4660
+ return this.client.queryContractSmart(this.contractAddress, {
4661
+ white_balance_of: {
4662
+ amount,
4663
+ certificate,
4664
+ pubkey
4665
+ }
4666
+ });
4667
+ };
4668
+ this.whiteInfo = async ({
4669
+ pubkey
4670
+ }) => {
4671
+ return this.client.queryContractSmart(this.contractAddress, {
4672
+ white_info: {
4673
+ pubkey
4674
+ }
4675
+ });
4676
+ };
4677
+ this.maxWhitelistNum = async () => {
4678
+ return this.client.queryContractSmart(this.contractAddress, {
4679
+ max_whitelist_num: {}
4680
+ });
4681
+ };
4682
+ this.voteOptionMap = async () => {
4683
+ return this.client.queryContractSmart(this.contractAddress, {
4684
+ vote_option_map: {}
4685
+ });
4686
+ };
4687
+ this.maxVoteOptions = async () => {
4688
+ return this.client.queryContractSmart(this.contractAddress, {
4689
+ max_vote_options: {}
4690
+ });
4691
+ };
4692
+ this.queryTotalFeeGrant = async () => {
4693
+ return this.client.queryContractSmart(this.contractAddress, {
4694
+ query_total_fee_grant: {}
4695
+ });
4696
+ };
4697
+ this.queryCircuitType = async () => {
4698
+ return this.client.queryContractSmart(this.contractAddress, {
4699
+ query_circuit_type: {}
4700
+ });
4701
+ };
4702
+ this.queryCertSystem = async () => {
4703
+ return this.client.queryContractSmart(this.contractAddress, {
4704
+ query_cert_system: {}
4705
+ });
4706
+ };
4707
+ this.queryOracleWhitelistConfig = async () => {
4708
+ return this.client.queryContractSmart(this.contractAddress, {
4709
+ query_oracle_whitelist_config: {}
4710
+ });
4711
+ };
4712
+ this.client = client;
4713
+ this.contractAddress = contractAddress;
4714
+ this.getRoundInfo = this.getRoundInfo.bind(this);
4715
+ this.getVotingTime = this.getVotingTime.bind(this);
4716
+ this.getPeriod = this.getPeriod.bind(this);
4717
+ this.getNumSignUp = this.getNumSignUp.bind(this);
4718
+ this.getMsgChainLength = this.getMsgChainLength.bind(this);
4719
+ this.getProcessedMsgCount = this.getProcessedMsgCount.bind(this);
4720
+ this.getProcessedUserCount = this.getProcessedUserCount.bind(this);
4721
+ this.getResult = this.getResult.bind(this);
4722
+ this.getAllResult = this.getAllResult.bind(this);
4723
+ this.getStateIdxInc = this.getStateIdxInc.bind(this);
4724
+ this.getVoiceCreditBalance = this.getVoiceCreditBalance.bind(this);
4725
+ this.isWhiteList = this.isWhiteList.bind(this);
4726
+ this.whiteBalanceOf = this.whiteBalanceOf.bind(this);
4727
+ this.whiteInfo = this.whiteInfo.bind(this);
4728
+ this.maxWhitelistNum = this.maxWhitelistNum.bind(this);
4729
+ this.voteOptionMap = this.voteOptionMap.bind(this);
4730
+ this.maxVoteOptions = this.maxVoteOptions.bind(this);
4731
+ this.queryTotalFeeGrant = this.queryTotalFeeGrant.bind(this);
4732
+ this.queryCircuitType = this.queryCircuitType.bind(this);
4733
+ this.queryCertSystem = this.queryCertSystem.bind(this);
4734
+ this.queryOracleWhitelistConfig = this.queryOracleWhitelistConfig.bind(this);
4735
+ }
4495
4736
  };
4496
- async function createMaciClientBy({
4497
- rpcEndpoint,
4498
- wallet,
4499
- contractAddress
4500
- }) {
4501
- const signingCosmWasmClient = await createContractClientByWallet(
4502
- rpcEndpoint,
4503
- wallet
4504
- );
4505
- const [{ address }] = await wallet.getAccounts();
4506
- return new MaciClient(signingCosmWasmClient, address, contractAddress);
4507
- }
4508
- async function createAMaciClientBy({
4509
- rpcEndpoint,
4510
- wallet,
4511
- contractAddress
4512
- }) {
4513
- const signingCosmWasmClient = await createContractClientByWallet(
4514
- rpcEndpoint,
4515
- wallet
4516
- );
4517
- const [{ address }] = await wallet.getAccounts();
4518
- return new AMaciClient(signingCosmWasmClient, address, contractAddress);
4519
- }
4520
- async function createRegistryClientBy({
4521
- rpcEndpoint,
4522
- wallet,
4523
- contractAddress
4524
- }) {
4525
- const signingCosmWasmClient = await createContractClientByWallet(
4526
- rpcEndpoint,
4527
- wallet
4528
- );
4737
+ var ApiMaciClient = class extends ApiMaciQueryClient {
4738
+ constructor(client, sender, contractAddress) {
4739
+ super(client, contractAddress);
4740
+ this.setRoundInfo = async ({
4741
+ roundInfo
4742
+ }, fee = "auto", memo, _funds) => {
4743
+ return await this.client.execute(this.sender, this.contractAddress, {
4744
+ set_round_info: {
4745
+ round_info: roundInfo
4746
+ }
4747
+ }, fee, memo, _funds);
4748
+ };
4749
+ this.setVoteOptionsMap = async ({
4750
+ voteOptionMap
4751
+ }, fee = "auto", memo, _funds) => {
4752
+ return await this.client.execute(this.sender, this.contractAddress, {
4753
+ set_vote_options_map: {
4754
+ vote_option_map: voteOptionMap
4755
+ }
4756
+ }, fee, memo, _funds);
4757
+ };
4758
+ this.signUp = async ({
4759
+ amount,
4760
+ certificate,
4761
+ pubkey
4762
+ }, fee = "auto", memo, _funds) => {
4763
+ return await this.client.execute(this.sender, this.contractAddress, {
4764
+ sign_up: {
4765
+ amount,
4766
+ certificate,
4767
+ pubkey
4768
+ }
4769
+ }, fee, memo, _funds);
4770
+ };
4771
+ this.startProcessPeriod = async (fee = "auto", memo, _funds) => {
4772
+ return await this.client.execute(this.sender, this.contractAddress, {
4773
+ start_process_period: {}
4774
+ }, fee, memo, _funds);
4775
+ };
4776
+ this.publishMessage = async ({
4777
+ encPubKey,
4778
+ message
4779
+ }, fee = "auto", memo, _funds) => {
4780
+ return await this.client.execute(this.sender, this.contractAddress, {
4781
+ publish_message: {
4782
+ enc_pub_key: encPubKey,
4783
+ message
4784
+ }
4785
+ }, fee, memo, _funds);
4786
+ };
4787
+ this.processMessage = async ({
4788
+ groth16Proof,
4789
+ newStateCommitment,
4790
+ plonkProof
4791
+ }, fee = "auto", memo, _funds) => {
4792
+ return await this.client.execute(this.sender, this.contractAddress, {
4793
+ process_message: {
4794
+ groth16_proof: groth16Proof,
4795
+ new_state_commitment: newStateCommitment,
4796
+ plonk_proof: plonkProof
4797
+ }
4798
+ }, fee, memo, _funds);
4799
+ };
4800
+ this.stopProcessingPeriod = async (fee = "auto", memo, _funds) => {
4801
+ return await this.client.execute(this.sender, this.contractAddress, {
4802
+ stop_processing_period: {}
4803
+ }, fee, memo, _funds);
4804
+ };
4805
+ this.processTally = async ({
4806
+ groth16Proof,
4807
+ newTallyCommitment,
4808
+ plonkProof
4809
+ }, fee = "auto", memo, _funds) => {
4810
+ return await this.client.execute(this.sender, this.contractAddress, {
4811
+ process_tally: {
4812
+ groth16_proof: groth16Proof,
4813
+ new_tally_commitment: newTallyCommitment,
4814
+ plonk_proof: plonkProof
4815
+ }
4816
+ }, fee, memo, _funds);
4817
+ };
4818
+ this.stopTallyingPeriod = async ({
4819
+ results,
4820
+ salt
4821
+ }, fee = "auto", memo, _funds) => {
4822
+ return await this.client.execute(this.sender, this.contractAddress, {
4823
+ stop_tallying_period: {
4824
+ results,
4825
+ salt
4826
+ }
4827
+ }, fee, memo, _funds);
4828
+ };
4829
+ this.bond = async (fee = "auto", memo, _funds) => {
4830
+ return await this.client.execute(this.sender, this.contractAddress, {
4831
+ bond: {}
4832
+ }, fee, memo, _funds);
4833
+ };
4834
+ this.withdraw = async ({
4835
+ amount
4836
+ }, fee = "auto", memo, _funds) => {
4837
+ return await this.client.execute(this.sender, this.contractAddress, {
4838
+ withdraw: {
4839
+ amount
4840
+ }
4841
+ }, fee, memo, _funds);
4842
+ };
4843
+ this.client = client;
4844
+ this.sender = sender;
4845
+ this.contractAddress = contractAddress;
4846
+ this.setRoundInfo = this.setRoundInfo.bind(this);
4847
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
4848
+ this.signUp = this.signUp.bind(this);
4849
+ this.startProcessPeriod = this.startProcessPeriod.bind(this);
4850
+ this.publishMessage = this.publishMessage.bind(this);
4851
+ this.processMessage = this.processMessage.bind(this);
4852
+ this.stopProcessingPeriod = this.stopProcessingPeriod.bind(this);
4853
+ this.processTally = this.processTally.bind(this);
4854
+ this.stopTallyingPeriod = this.stopTallyingPeriod.bind(this);
4855
+ this.bond = this.bond.bind(this);
4856
+ this.withdraw = this.withdraw.bind(this);
4857
+ }
4858
+ };
4859
+
4860
+ // src/libs/contract/ts/ApiSaas.client.ts
4861
+ var ApiSaasQueryClient = class {
4862
+ constructor(client, contractAddress) {
4863
+ this.config = async () => {
4864
+ return this.client.queryContractSmart(this.contractAddress, {
4865
+ config: {}
4866
+ });
4867
+ };
4868
+ this.operators = async () => {
4869
+ return this.client.queryContractSmart(this.contractAddress, {
4870
+ operators: {}
4871
+ });
4872
+ };
4873
+ this.isOperator = async ({ address }) => {
4874
+ return this.client.queryContractSmart(this.contractAddress, {
4875
+ is_operator: {
4876
+ address
4877
+ }
4878
+ });
4879
+ };
4880
+ this.balance = async () => {
4881
+ return this.client.queryContractSmart(this.contractAddress, {
4882
+ balance: {}
4883
+ });
4884
+ };
4885
+ this.maciCodeId = async () => {
4886
+ return this.client.queryContractSmart(this.contractAddress, {
4887
+ maci_code_id: {}
4888
+ });
4889
+ };
4890
+ this.treasuryManager = async () => {
4891
+ return this.client.queryContractSmart(this.contractAddress, {
4892
+ treasury_manager: {}
4893
+ });
4894
+ };
4895
+ this.client = client;
4896
+ this.contractAddress = contractAddress;
4897
+ this.config = this.config.bind(this);
4898
+ this.operators = this.operators.bind(this);
4899
+ this.isOperator = this.isOperator.bind(this);
4900
+ this.balance = this.balance.bind(this);
4901
+ this.maciCodeId = this.maciCodeId.bind(this);
4902
+ this.treasuryManager = this.treasuryManager.bind(this);
4903
+ }
4904
+ };
4905
+ var ApiSaasClient = class extends ApiSaasQueryClient {
4906
+ constructor(client, sender, contractAddress) {
4907
+ super(client, contractAddress);
4908
+ this.updateConfig = async ({
4909
+ admin,
4910
+ denom
4911
+ }, fee = "auto", memo, _funds) => {
4912
+ return await this.client.execute(
4913
+ this.sender,
4914
+ this.contractAddress,
4915
+ {
4916
+ update_config: {
4917
+ admin,
4918
+ denom
4919
+ }
4920
+ },
4921
+ fee,
4922
+ memo,
4923
+ _funds
4924
+ );
4925
+ };
4926
+ this.updateMaciCodeId = async ({
4927
+ codeId
4928
+ }, fee = "auto", memo, _funds) => {
4929
+ return await this.client.execute(
4930
+ this.sender,
4931
+ this.contractAddress,
4932
+ {
4933
+ update_maci_code_id: {
4934
+ code_id: codeId
4935
+ }
4936
+ },
4937
+ fee,
4938
+ memo,
4939
+ _funds
4940
+ );
4941
+ };
4942
+ this.updateAmaciRegistryContract = async ({
4943
+ registryContract
4944
+ }, fee = "auto", memo, _funds) => {
4945
+ return await this.client.execute(
4946
+ this.sender,
4947
+ this.contractAddress,
4948
+ {
4949
+ update_amaci_registry_contract: {
4950
+ registry_contract: registryContract
4951
+ }
4952
+ },
4953
+ fee,
4954
+ memo,
4955
+ _funds
4956
+ );
4957
+ };
4958
+ this.addOperator = async ({
4959
+ operator
4960
+ }, fee = "auto", memo, _funds) => {
4961
+ return await this.client.execute(
4962
+ this.sender,
4963
+ this.contractAddress,
4964
+ {
4965
+ add_operator: {
4966
+ operator
4967
+ }
4968
+ },
4969
+ fee,
4970
+ memo,
4971
+ _funds
4972
+ );
4973
+ };
4974
+ this.removeOperator = async ({
4975
+ operator
4976
+ }, fee = "auto", memo, _funds) => {
4977
+ return await this.client.execute(
4978
+ this.sender,
4979
+ this.contractAddress,
4980
+ {
4981
+ remove_operator: {
4982
+ operator
4983
+ }
4984
+ },
4985
+ fee,
4986
+ memo,
4987
+ _funds
4988
+ );
4989
+ };
4990
+ this.deposit = async (fee = "auto", memo, _funds) => {
4991
+ return await this.client.execute(
4992
+ this.sender,
4993
+ this.contractAddress,
4994
+ {
4995
+ deposit: {}
4996
+ },
4997
+ fee,
4998
+ memo,
4999
+ _funds
5000
+ );
5001
+ };
5002
+ this.withdraw = async ({
5003
+ amount,
5004
+ recipient
5005
+ }, fee = "auto", memo, _funds) => {
5006
+ return await this.client.execute(
5007
+ this.sender,
5008
+ this.contractAddress,
5009
+ {
5010
+ withdraw: {
5011
+ amount,
5012
+ recipient
5013
+ }
5014
+ },
5015
+ fee,
5016
+ memo,
5017
+ _funds
5018
+ );
5019
+ };
5020
+ this.createMaciRound = async ({
5021
+ certificationSystem,
5022
+ circuitType,
5023
+ coordinator,
5024
+ endTime,
5025
+ maxVoters,
5026
+ roundInfo,
5027
+ startTime,
5028
+ voteOptionMap,
5029
+ whitelistBackendPubkey
5030
+ }, fee = "auto", memo, _funds) => {
5031
+ return await this.client.execute(
5032
+ this.sender,
5033
+ this.contractAddress,
5034
+ {
5035
+ create_maci_round: {
5036
+ certification_system: certificationSystem,
5037
+ circuit_type: circuitType,
5038
+ coordinator,
5039
+ end_time: endTime,
5040
+ max_voters: maxVoters.toString(),
5041
+ round_info: roundInfo,
5042
+ start_time: startTime,
5043
+ vote_option_map: voteOptionMap,
5044
+ whitelist_backend_pubkey: whitelistBackendPubkey
5045
+ }
5046
+ },
5047
+ fee,
5048
+ memo,
5049
+ _funds
5050
+ );
5051
+ };
5052
+ this.createAmaciRound = async ({
5053
+ certificationSystem,
5054
+ circuitType,
5055
+ maxVoter,
5056
+ operator,
5057
+ oracleWhitelistPubkey,
5058
+ preDeactivateRoot,
5059
+ roundInfo,
5060
+ voiceCreditAmount,
5061
+ voteOptionMap,
5062
+ votingTime,
5063
+ whitelist
5064
+ }, fee = "auto", memo, _funds) => {
5065
+ return await this.client.execute(
5066
+ this.sender,
5067
+ this.contractAddress,
5068
+ {
5069
+ create_amaci_round: {
5070
+ certification_system: certificationSystem,
5071
+ circuit_type: circuitType,
5072
+ max_voter: maxVoter,
5073
+ operator,
5074
+ oracle_whitelist_pubkey: oracleWhitelistPubkey,
5075
+ pre_deactivate_root: preDeactivateRoot,
5076
+ round_info: roundInfo,
5077
+ voice_credit_amount: voiceCreditAmount,
5078
+ vote_option_map: voteOptionMap,
5079
+ voting_time: votingTime,
5080
+ whitelist
5081
+ }
5082
+ },
5083
+ fee,
5084
+ memo,
5085
+ _funds
5086
+ );
5087
+ };
5088
+ this.setRoundInfo = async ({
5089
+ contractAddr,
5090
+ roundInfo
5091
+ }, fee = "auto", memo, _funds) => {
5092
+ return await this.client.execute(
5093
+ this.sender,
5094
+ this.contractAddress,
5095
+ {
5096
+ set_round_info: {
5097
+ contract_addr: contractAddr,
5098
+ round_info: roundInfo
5099
+ }
5100
+ },
5101
+ fee,
5102
+ memo,
5103
+ _funds
5104
+ );
5105
+ };
5106
+ this.setVoteOptionsMap = async ({
5107
+ contractAddr,
5108
+ voteOptionMap
5109
+ }, fee = "auto", memo, _funds) => {
5110
+ return await this.client.execute(
5111
+ this.sender,
5112
+ this.contractAddress,
5113
+ {
5114
+ set_vote_options_map: {
5115
+ contract_addr: contractAddr,
5116
+ vote_option_map: voteOptionMap
5117
+ }
5118
+ },
5119
+ fee,
5120
+ memo,
5121
+ _funds
5122
+ );
5123
+ };
5124
+ this.client = client;
5125
+ this.sender = sender;
5126
+ this.contractAddress = contractAddress;
5127
+ this.updateConfig = this.updateConfig.bind(this);
5128
+ this.updateMaciCodeId = this.updateMaciCodeId.bind(this);
5129
+ this.updateAmaciRegistryContract = this.updateAmaciRegistryContract.bind(this);
5130
+ this.addOperator = this.addOperator.bind(this);
5131
+ this.removeOperator = this.removeOperator.bind(this);
5132
+ this.deposit = this.deposit.bind(this);
5133
+ this.withdraw = this.withdraw.bind(this);
5134
+ this.createMaciRound = this.createMaciRound.bind(this);
5135
+ this.createAmaciRound = this.createAmaciRound.bind(this);
5136
+ this.setRoundInfo = this.setRoundInfo.bind(this);
5137
+ this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
5138
+ }
5139
+ };
5140
+
5141
+ // src/libs/contract/config.ts
5142
+ var defaultSigningClientOptions = {
5143
+ broadcastPollIntervalMs: 8e3,
5144
+ broadcastTimeoutMs: 15e4,
5145
+ // 2min30s for the tx to be confirmed
5146
+ gasPrice: GasPrice.fromString("10000000000peaka")
5147
+ };
5148
+ async function createMaciClientBy({
5149
+ rpcEndpoint,
5150
+ wallet,
5151
+ contractAddress
5152
+ }) {
5153
+ const signingCosmWasmClient = await createContractClientByWallet(
5154
+ rpcEndpoint,
5155
+ wallet
5156
+ );
5157
+ const [{ address }] = await wallet.getAccounts();
5158
+ return new MaciClient(signingCosmWasmClient, address, contractAddress);
5159
+ }
5160
+ async function createAMaciClientBy({
5161
+ rpcEndpoint,
5162
+ wallet,
5163
+ contractAddress
5164
+ }) {
5165
+ const signingCosmWasmClient = await createContractClientByWallet(
5166
+ rpcEndpoint,
5167
+ wallet
5168
+ );
5169
+ const [{ address }] = await wallet.getAccounts();
5170
+ return new AMaciClient(signingCosmWasmClient, address, contractAddress);
5171
+ }
5172
+ async function createApiMaciClientBy({
5173
+ rpcEndpoint,
5174
+ wallet,
5175
+ contractAddress
5176
+ }) {
5177
+ const signingCosmWasmClient = await createContractClientByWallet(
5178
+ rpcEndpoint,
5179
+ wallet
5180
+ );
5181
+ const [{ address }] = await wallet.getAccounts();
5182
+ return new ApiMaciClient(signingCosmWasmClient, address, contractAddress);
5183
+ }
5184
+ async function createRegistryClientBy({
5185
+ rpcEndpoint,
5186
+ wallet,
5187
+ contractAddress
5188
+ }) {
5189
+ const signingCosmWasmClient = await createContractClientByWallet(
5190
+ rpcEndpoint,
5191
+ wallet
5192
+ );
4529
5193
  const [{ address }] = await wallet.getAccounts();
4530
5194
  return new RegistryClient(signingCosmWasmClient, address, contractAddress);
4531
5195
  }
@@ -4541,6 +5205,18 @@ async function createSaasClientBy({
4541
5205
  const [{ address }] = await wallet.getAccounts();
4542
5206
  return new SaasClient(signingCosmWasmClient, address, contractAddress);
4543
5207
  }
5208
+ async function createApiSaasClientBy({
5209
+ rpcEndpoint,
5210
+ wallet,
5211
+ contractAddress
5212
+ }) {
5213
+ const signingCosmWasmClient = await createContractClientByWallet(
5214
+ rpcEndpoint,
5215
+ wallet
5216
+ );
5217
+ const [{ address }] = await wallet.getAccounts();
5218
+ return new ApiSaasClient(signingCosmWasmClient, address, contractAddress);
5219
+ }
4544
5220
  async function createOracleMaciClientBy({
4545
5221
  rpcEndpoint,
4546
5222
  wallet,
@@ -4553,711 +5229,1381 @@ async function createOracleMaciClientBy({
4553
5229
  const [{ address }] = await wallet.getAccounts();
4554
5230
  return new OracleMaciClient(signingCosmWasmClient, address, contractAddress);
4555
5231
  }
4556
- async function createContractClientByWallet(rpcEndpoint, wallet) {
4557
- const client = await SigningCosmWasmClient.connectWithSigner(
4558
- rpcEndpoint,
4559
- wallet,
4560
- {
4561
- ...defaultSigningClientOptions
5232
+ async function createContractClientByWallet(rpcEndpoint, wallet) {
5233
+ const client = await SigningCosmWasmClient.connectWithSigner(
5234
+ rpcEndpoint,
5235
+ wallet,
5236
+ {
5237
+ ...defaultSigningClientOptions
5238
+ }
5239
+ );
5240
+ return client;
5241
+ }
5242
+
5243
+ // src/types/index.ts
5244
+ var MaciCircuitType = /* @__PURE__ */ ((MaciCircuitType2) => {
5245
+ MaciCircuitType2["IP1V"] = "0";
5246
+ MaciCircuitType2["QV"] = "1";
5247
+ return MaciCircuitType2;
5248
+ })(MaciCircuitType || {});
5249
+ var MaciCertSystemType = /* @__PURE__ */ ((MaciCertSystemType2) => {
5250
+ MaciCertSystemType2["GROTH16"] = "groth16";
5251
+ MaciCertSystemType2["PLONK"] = "plonk";
5252
+ return MaciCertSystemType2;
5253
+ })(MaciCertSystemType || {});
5254
+ var MaciRoundType = /* @__PURE__ */ ((MaciRoundType2) => {
5255
+ MaciRoundType2["MACI"] = "0";
5256
+ MaciRoundType2["AMACI"] = "1";
5257
+ MaciRoundType2["ORACLE_MACI"] = "2";
5258
+ return MaciRoundType2;
5259
+ })(MaciRoundType || {});
5260
+
5261
+ // src/libs/contract/vars.ts
5262
+ var CIRCUIT_INFO = {
5263
+ "2-1-1-5": {
5264
+ parameter: {
5265
+ state_tree_depth: "2",
5266
+ int_state_tree_depth: "1",
5267
+ vote_option_tree_depth: "1",
5268
+ message_batch_size: "5"
5269
+ },
5270
+ groth16: {
5271
+ process_vkey: {
5272
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5273
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5274
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5275
+ vk_delta_2: "2178a9c3805dd82071b2b28bb4c0ffc8178cad913c8c990b98b4863284dc3a5d175c0be554fc060c27c551e5e32effef015b918a0f5a2dc1b92909b8272719301c521d5f6542db5ea4775a42d32159c356a696599c1a3df011ec00559ae1c2b60d860f7e6513a7d20feaeaca401863e35a0f691dd7d30ce06d07946840de1ec8",
5276
+ vk_ic0: "19126a54a9b6d0d415f892c246485cb2889487cf9c4a8cd88dab5e1140e1d0630d1d76ef4652df8887c9dc557aa57f25e221db7e5b2e4cf618a362bece107f5c",
5277
+ vk_ic1: "0632e625fefc7172e8aec1070c4d32b90b6c482f6f3806773a4c55a03877c2d716cfd935eb3e3883f580c93f56adbf3a253ce3c208c52fb784f9d8fec139c617"
5278
+ },
5279
+ tally_vkey: {
5280
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5281
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5282
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5283
+ vk_delta_2: "2e9fad39728c543c5213599111e1a44b01720c999a6785e8136c3e3b3bf8e07e248e1933d477969ca6e27cb7a74bca18cac7e3bbdf9371be5c54fe151f6376a30955609ec69b89329322a2f435b706ca248d1312c7513853a50ef37ed0f7826c25a5c57bf07789d89e538bc24017cf2722811f21480b0bb8030ed0028ecb7cd8",
5284
+ vk_ic0: "1bc1a1a3444256469c07cd6f4d1cfd9f7c9ddce596a306e0af077ca9e9c0fe9602db2a9aecef76a9dc4c19bf88c0099b04fc75410cc9004f0966440825e3790a",
5285
+ vk_ic1: "05b8b475f2bfedba4fa04ab1972006da9764c2c3e6fb65d6dd0aac938fd298112a560e13770b06a3f709a49fddf016331ea205fa125026993f6666eff69f4def"
5286
+ }
5287
+ },
5288
+ plonk: {
5289
+ process_vkey: {
5290
+ n: 1048575,
5291
+ num_inputs: 1,
5292
+ selector_commitments: [
5293
+ "29b0f4a90bea69583a8fca1e74d23adf739d605af605a0e0971fac548df976fb2e10a42dfca2325684c1bca5fabbf9d7022fc8b997ea478f1052dd8808d99e44",
5294
+ "119002055b6c2f98314ef408e4a917a6678f114ca991185749289f171f61efc32b3a931c700271b82d22c2073af9b7fffcb7bfa644ea09102d9ef8482410a991",
5295
+ "10c5f32870d26f8e26d2eaae2705557b18210b2355677172e1bef5fe684120891f8317185390ddbb22ecb922d37e03c3cc524c84f65c8045f2324b0f164cfbdb",
5296
+ "115a5f9af5d438d3261cfa31b7050b931b7d22647f628a43af41a41dcd44cb8d2e99368eb15cdc6d1f16faf9db0db4825613d6893c776aef456705bdc76eb728",
5297
+ "1a61cc5f0fbe92fbc8c9bd58928ce467f63e4771e4d517966afbaf220ea069a91cec3231c370be07fee8d9ec01660d054c549b034715855ffa652ad5b67ced86",
5298
+ "19e0d095a343115f6e7ad7ae1f51e375cd648fb35451cb2d5a8cf3bafbb25d0525efdc2cc5b5600ee0ae954dca3bf67c8277d470161fe23b4be7a5bcdf641e68"
5299
+ ],
5300
+ next_step_selector_commitments: [
5301
+ "246ce82e01ed312e81492f132da2ee16bc13cc0024fbcc668de30173ad59067f0f072a892451cc495f5d9b8b99c8dc29be1d42d3004aed45fd5b2cd32a420016"
5302
+ ],
5303
+ permutation_commitments: [
5304
+ "19c4143f41738480adc5ae49922d31b8a5afaa1d25ced5c20b869c0e1ccad91920c267c53d33907318cd194ba2ea08a85f250779765ba4121f7a0edfe1afe22b",
5305
+ "114bda14aa702a0815e3f91318a08a2798244420fd6675c8fc3cc2b0232298890d2eb3c1f27a83f4a3be777524d6cc65aa435e0a472fae8d1158e0a6ded685d0",
5306
+ "289f0b046968d2c095d05350e43996756fc85d2deb0e267a069615f0889a249413bdbe6f09edb4db956b8f3fc4488c4681cd52469dc0d419dab99a65b88309f7",
5307
+ "16dd74a2089960aac0d68309d5e81c6b45c29fafe4d42c922c06eb633ed48d551d347d1f43ee9b137772eefc43a6dcdf5ac35ee1615bc8f7c243bce071c410a9"
5308
+ ],
5309
+ non_residues: [
5310
+ "0000000000000000000000000000000000000000000000000000000000000005",
5311
+ "0000000000000000000000000000000000000000000000000000000000000007",
5312
+ "000000000000000000000000000000000000000000000000000000000000000a"
5313
+ ],
5314
+ g2_elements: [
5315
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5316
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5317
+ ]
5318
+ },
5319
+ tally_vkey: {
5320
+ n: 524287,
5321
+ num_inputs: 1,
5322
+ selector_commitments: [
5323
+ "18c2bb75c8ed53a5d15a56cc91c56f14c832419994ce7187c7c98b5e622cac0808b773f05e09822d8d267646198a78359ea2aa6fbaeb01317142f99fd11da6c0",
5324
+ "181499098243a5968f5490b7759aa15f0f769f24f3f4219b69f96913cf4fb23c1cd7b3f109196d7577390fd2e6d3930a71b0559aff756f3ca43eef66ce7333f4",
5325
+ "07ba2bdd452503fb16b56ea2940e95a98118c9dd120ae192680fe2b80bdb26f10ac6cdc7cb12b581a8c64d45b5af3d253c4282405eed3fd4d091ae05aac45cb6",
5326
+ "1caf01f1775eeafa78a11202e926ee92be997ce040f9c6fbce161348a40aeda70d9f15738cccf538083784e566ceef651d000223ae810c980e2d5d98b91b4665",
5327
+ "2c377c69cae1d591af413da2fd986ef3dca595d0c5817ee4932b92169d37c52d1218ce63dde705ebd1dc66d9b62daca287e4fdf6800b69204e5b78bfe84365a1",
5328
+ "175dd4ff280e39f0e080c181f853845e40c4b91709a93e4398d24befc9cf556903675361817e031e86bd896ff1dd7bc1cc31ca920a101499db0c58d77f0730ec"
5329
+ ],
5330
+ next_step_selector_commitments: [
5331
+ "12d76999d26137d433f7119ab34f3fc63cfedb9172052cfb34acfc3cdc570f511aba802ebe92b87f913496314b938cf526078280a68826c90b686b90420c7742"
5332
+ ],
5333
+ permutation_commitments: [
5334
+ "167b05c0132399e7126e8d16efb224b1c6729942048fc7e730fd1451116e0a6e05acaf2a6d2c88cc25610474b651c8cdcb7e8e14e59ddfad819123e888c4b1b6",
5335
+ "25aed62de4b701dc645e076543e2553c306010f2776c74edae55ea5253d9540403d042c4cb699cc04b2bb63d3c3edc0c85b049a84dc2fd44369f957d81363563",
5336
+ "0e77fb0b0e84da1d955da3d66dbb8fa3988f22e999a34bc4ac537a0f9187ac40156f8d7cb6d005fd85a0178d794f941b4e84832fd389a37c2a78112dac09b758",
5337
+ "051d3d906d457eaa9eff77a296dfa1760fd9ea379eec60487be38de91545ca2c1fcf457d6ac31afee10951245b0cc1e2c7674596f65955d189d48b6938fb3594"
5338
+ ],
5339
+ non_residues: [
5340
+ "0000000000000000000000000000000000000000000000000000000000000005",
5341
+ "0000000000000000000000000000000000000000000000000000000000000007",
5342
+ "000000000000000000000000000000000000000000000000000000000000000a"
5343
+ ],
5344
+ g2_elements: [
5345
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5346
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5347
+ ]
5348
+ }
5349
+ }
5350
+ },
5351
+ "4-2-2-25": {
5352
+ parameter: {
5353
+ state_tree_depth: "4",
5354
+ int_state_tree_depth: "2",
5355
+ vote_option_tree_depth: "2",
5356
+ message_batch_size: "25"
5357
+ },
5358
+ groth16: {
5359
+ process_vkey: {
5360
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5361
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5362
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5363
+ vk_delta_2: "0d0fe390b9dd4d1d0f486787b6ea96765cbeaa8f00310fecc3429673c5866c081a27998596ba296f66f3f7b5e2450d1ce1bcc535c133b2e8b577ba07dc1ccb4c1895f7afb9b3168a6d628c9173157cd56ca51948cc66c129a25f80e3b665e4b12c9c50f0cc0d070978ed2fb8ce15956d67c5dc6c07c7f45f1facfb5522d7b656",
5364
+ vk_ic0: "0ff2b22774da5c0ba94db4d759827b8c962aaf44db2649eb10407de02a40463a26497581d6d0979ad7f9057f26e048109158b0872700e2ad8447ffc9b4bf146b",
5365
+ vk_ic1: "0a47be101a59d20641e1369c0b2b9fb839cd35ecbfbeac3866df43723b70c78d17e96303c417743d93b7726805b736f364d305036b50e4ad1b885fc41284daf5"
5366
+ },
5367
+ tally_vkey: {
5368
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5369
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5370
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5371
+ vk_delta_2: "08e44e0876bd574d8a3411e374884eb61da7292ca52903fa96553c37311b66ce0f2f529e59b1d37e55794a575d0f87548ca0d03331c19689bc203a68c1c4bae20e9fd25a7bffaa9b7409e694a48bc0d57f42df164d4a01bd5deecffedd2d3a3125eff290efb93eaf9c578cc7ee9d00406137607b9602de02424ff413ac948690",
5372
+ vk_ic0: "295c8e84b4b6b8de44b24f80eb5cae1df65e4877c4af8da2dbadfbfc3586dc790661b9e636f2c2a83028d11cbb7c753675481b65a5dfe32fff7a558231b3c9ef",
5373
+ vk_ic1: "299cfb28054cde0470bd7ff280349089350226d1ca154dcf6544b2680bf3bea925026e6644668273d6066ef6766c2f561c3607c523fbbd1379c5002376ef69c3"
5374
+ }
5375
+ },
5376
+ plonk: {
5377
+ process_vkey: {
5378
+ n: 2097151,
5379
+ num_inputs: 1,
5380
+ selector_commitments: [
5381
+ "126cbf10e0b68a56d45614be16c5bb48bd1374478e17b9fe1a78b726ea70f9b21f3cd20fd178d89e5923c422ef050ccc7134fbd76c9efdbb90f677ee41e01edb",
5382
+ "12813166f206c95eddd998a40d8d2e54e29dd393f543e3583a7999b18d674832024cdd935540bd3b96207ec0609c6718ad8b14e2ef315594454c57d606494485",
5383
+ "05da9eea3ee7151355067ced11a8e8ff57a56c758493afc9cbb6cfbacfc42e7b08993dfa25c85f20aeb7f64e87fe56ac8066cf6b8479dc96294e302ef5d55372",
5384
+ "2e446e540bacde7daea23c93a67bc6b1424b7c16b33fd2cee251b0d093cd78300030b8e340f01f320639d60b77724e58fc8a2d778b7b2a5df2c953ce34debeea",
5385
+ "1cf8c75b18071ede19d196b46a8776efc29ac514458a698d9f2e50b7bc692f6e06f7ff96897240eca31058fe330e8cbcd911324b79a3a34d03340a3cfed85fd5",
5386
+ "17101fb5c293438a695075b221219679e278e4bd147239c9fc69081b19cacefe218eb895f1456ca81e29731967588aee4b0758ea51aa28e5fefc81fed4a11513"
5387
+ ],
5388
+ next_step_selector_commitments: [
5389
+ "0cebff4fe8cd70325f986088a1e17ae129a025481137bd80aef9c1f1c2e52f1e265a4ccae1ed89cb2fba527165f007898e70f988311ee4e4e87e41376cfeed03"
5390
+ ],
5391
+ permutation_commitments: [
5392
+ "025b5db167721133693f0b6d9d7cfadce68ad15365ef1605dda4a6c809edeea61927b27ca11713fc683c88f6330e9621837b05e5db74d5994d1cf04bc3d529b3",
5393
+ "1fac93999f33b145613901846e6403d7f4237d582b51ccc4fb5c70038284c6e21cc804cc3cf7170b96da74fcbb30c81cd8c3405a629327c657025db7332f169a",
5394
+ "0b6d7d383de73dbfc16f2c0f3af763135ff05a12ec937548008cfee944c195f902336a68a50f62f595953e44401e872fb41abb66a733684b079ffe550d09c233",
5395
+ "225a1f5e92d105d3be026ae68904826f89b786faad75a846ef966ed714568bba28d1388786fde71dea206cdef16faa7a589e90863e6245d271e3f154c75c5531"
5396
+ ],
5397
+ non_residues: [
5398
+ "0000000000000000000000000000000000000000000000000000000000000005",
5399
+ "0000000000000000000000000000000000000000000000000000000000000007",
5400
+ "000000000000000000000000000000000000000000000000000000000000000a"
5401
+ ],
5402
+ g2_elements: [
5403
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5404
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5405
+ ]
5406
+ },
5407
+ tally_vkey: {
5408
+ n: 1048575,
5409
+ num_inputs: 1,
5410
+ selector_commitments: [
5411
+ "1588fb667b3f0e4d0970b8208e4b6b4c729c4926b936f8d877017cf42d07ca15069643791d98abcd6b7d0b0546e7560ab9011e069f2ee48ede581fc72d8b5e04",
5412
+ "09c5480b103c44a81850ffd9a61ec21f7db41bc89996d8df075c3e029290eb5b083cb2b184d95c0761e585547be33250c8939929b87fdc39775ccea17d51b481",
5413
+ "278e239bcac0a945a17572a6d61ba59f705746e6893a10a44841933a8c8310e712e4ee913af9b77c8fdcdc365316aa9f1b8dc081eb99ad80265768ec9f484beb",
5414
+ "12532585ea307c5559b18a4d01db59b544a88088f61a5b5ed0431393e6f675af1309bf0dcaa7a552849e5f28d0300c8c61b18393fb638aed3b7d70e27bb91c35",
5415
+ "172e7ecb8e485aaee801fd78b8fd7c0b862baef65e39e6832cffa2170b6f981928d86ab5887e8c3210e34e03cada468bd501f60ec3a8fa35b4c7067d6fb8c6ae",
5416
+ "0c27211d046735fc681228b8366be2c8cf9a256cbd03dcd4af65152e94f95a6f1af151a5311b195b0f4acffeec4952cc52edbb7045aab61bbd3be9cd322ab99e"
5417
+ ],
5418
+ next_step_selector_commitments: [
5419
+ "25ee15301d562e6c630946b3fbe36b9fbd8dfbd44ddf70cc825fb1fa1ebd966229081f6b9297da671c69064e10b8f5dd0f69b69d1bf79122c6197f119087ebe1"
5420
+ ],
5421
+ permutation_commitments: [
5422
+ "194849a6ec5cb37e09d20801d387abbab04e453f630c5fbbf5c4819c5569480c0c8bf0ce2b4955cc4c891840da1d9e99feb81e8d43251dffbe4d6167639b9f9b",
5423
+ "17717d2638632d406b3c8aa69550c8aeed1b79def3ab55e9d0c4bdf21cc339ad07d3bd3a331145fc96f34c85469a34a8c93b53b7aa36bb5a94c31e3b4d47713e",
5424
+ "277b0c99b63c79bb9ed2f677c3987cf00acb293933dfced82b5afcb8bf0c34570d3187ce5c7e892582ddda4322cf7c50d41105fe98503fb60e41f4a08da5916d",
5425
+ "0489f6dec0f27a8c21d147ebb9781b68b4b73db065a6017924c543f6d9fadbe922d24c0946bd8b19df7659810296d063b557cdf7aba510b11e08fbf2e9d37931"
5426
+ ],
5427
+ non_residues: [
5428
+ "0000000000000000000000000000000000000000000000000000000000000005",
5429
+ "0000000000000000000000000000000000000000000000000000000000000007",
5430
+ "000000000000000000000000000000000000000000000000000000000000000a"
5431
+ ],
5432
+ g2_elements: [
5433
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5434
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5435
+ ]
5436
+ }
5437
+ }
5438
+ },
5439
+ "6-3-3-125": {
5440
+ parameter: {
5441
+ state_tree_depth: "6",
5442
+ int_state_tree_depth: "3",
5443
+ vote_option_tree_depth: "3",
5444
+ message_batch_size: "125"
5445
+ },
5446
+ groth16: {
5447
+ process_vkey: {
5448
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5449
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5450
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5451
+ vk_delta_2: "057f25675851ef5a79a6d8706a43a6cd8e494cfb12c241ede46991d9174cf30605b081ff44f3ede774dab68ea9324c12308c13cb09cbb129adf94401b9134f5b16137d952fd32ab2d4243ebff4cb15d17206948ef17909ea8606886a8109bdad082f7d27e1cbf98925f055b39d1c89f9bcc4f6d92fdb920934ff5e37ba4d9b49",
5452
+ vk_ic0: "27c937c032a18a320566e934448a0ffceea7050492a509c45a3bcb7e8ff8905d20789ada31729a833a4f595ff9f49f88adb66f2ab987de15a15deccb0e785bf4",
5453
+ vk_ic1: "0ed2cefc103a2234dbc6bbd8634812d65332218b7589f4079b2c08eb5a4f5f63113a7f3cb53797a7f5819d7de7e3f0b2197d1c34790685a4a59af4314810420b"
5454
+ },
5455
+ tally_vkey: {
5456
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5457
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5458
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5459
+ vk_delta_2: "2065e91c00fcc5cbc3d974cf52e24de972bdb1b4d8ded629dec20b5c904c3fa327ffe02402094795ff4d02588c8268fcad738f69eb4c732a0c98b485035e1f4913ede11b074ff143a929673e581a547717c58ce01af87d9d8b28f65f506093a61013e367b93e6782129362065840a0af9b77d7d9659a84577176e64a918d8d4c",
5460
+ vk_ic0: "11db4a022aab89a265f06ff62aa18c74b21e913a8b23e7fce9cb46f76d1c4d9f2a7475b1eeb7be0a0dc457e6d52536ba351b621b63a7d77da75d4e773048537e",
5461
+ vk_ic1: "0f298d235d0822ad281386abdf511853529af4c864b0cd54140facebfc1356a3059cd6d0d4b27b39e5683548fe12025e2a6b2e2724c2ca87d2008ef932ed3801"
5462
+ }
5463
+ },
5464
+ plonk: {
5465
+ process_vkey: {
5466
+ n: 8388607,
5467
+ num_inputs: 1,
5468
+ selector_commitments: [
5469
+ "216533ab27390f98812429524326ac08736d636d2891fb81446796cc1771a3230642f49db115acc15a186a1013f91a08efcd05640eb137d700276e80fd05bc90",
5470
+ "11747f6f378e26dbdacff464ce7eb6a8869750d0fa7e508e263ac77b582c1e9b24ba3d208650b0c28943915c563cc94cc3f98cdb5fd8adc4f4d3e2a60eda3302",
5471
+ "09239eb768d8d47b91c7e08e2ec6a374571964ed16be293cdc35e112393c4fd1182a0794be7f1441418664e9f718b67ed392a7da3e2868375bcf629131bb2680",
5472
+ "2020f7db24940bbf38d097ea5d7ef7253e38b154d7eb0ff1782ea18ce215dd7b0e8475197b071b118adc6418b7b7fb42fea19b6272d1bb460cc47deacb299ec7",
5473
+ "298923db1618185064bbab5df30ee03a3c9cbc7ce8f096d76cbd2a5ab3df86cd05bbedb938e6e0ff35cce23609458aff8081cdf3163655672074d1b18b0007bd",
5474
+ "0effaabe8c6e8a076aedd36d10f2926f9871f552d93e22bfbe69e3c828a546fa2d0cd163b49a6de219ac2c048a8459ae448047748ba078b9d5d07b290c946b08"
5475
+ ],
5476
+ next_step_selector_commitments: [
5477
+ "13e3d7299e30e6142699469d620df721eca35bbb807a8f4298f165260fdc24f823e7bd9bcb6506a094a5ebef44434c62e4bcb5d3dd7e092c49d5cb80b8ae0757"
5478
+ ],
5479
+ permutation_commitments: [
5480
+ "03d94ab8fdc681523a8eec10f1ce5552937c268d1d970f9e75ee8657cd4c12a81e03476f83ef5c14db2f4d931b833a3b65b8d5689b37cc7f183914c90d3d065d",
5481
+ "1b9c6ef20e68355c535bda6ff04a8a61d7552a594bb8e88d69a6f8840ddab04d2884824cc356d0d90cc278c247fc531de62efca4b19ed1be6f071144474d2037",
5482
+ "1ff82de8312481e1591d2d1c2698fa3944b3f0afa0dd702be8a1a944a5a8997323ffbd0ab39a2e13608a8e76803c33ffda7317bb7101e335ce5552ed62dcd09d",
5483
+ "2cb2bbdd51d22b79957b0401ecb6fe089f05426ba092b1205fa92f39b36cc5fc0c36c3934e47b7d407d4cda0c78c2b3fb23162cb0d295e8a8cce1a274956c34a"
5484
+ ],
5485
+ non_residues: [
5486
+ "0000000000000000000000000000000000000000000000000000000000000005",
5487
+ "0000000000000000000000000000000000000000000000000000000000000007",
5488
+ "000000000000000000000000000000000000000000000000000000000000000a"
5489
+ ],
5490
+ g2_elements: [
5491
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5492
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5493
+ ]
5494
+ },
5495
+ tally_vkey: {
5496
+ n: 8388607,
5497
+ num_inputs: 1,
5498
+ selector_commitments: [
5499
+ "258d101f9499e81c0d0da8986c659ef33da19d4955a142e56b4854d1327c902c1996baecd81432717a9cbf92ccf651e4217a788c1a2ed855f749480f8ce8203c",
5500
+ "1892a17c9c01389e3149b0663069a1ad4fd3c8e2db5ce99795b781c47b55acf9001cf5f0b4c1d088fa2058ca19cd2f1e9559ebe059897bb0aadcb540ce5f468a",
5501
+ "09912d6eaa4a22802451135d9a221ebf97c2ce8ad5bbb2942d5a860482e8e4202573995072c4b014cd0e9d09a1fd53ee7d602070b404288a7fd0d97b57d8f07d",
5502
+ "0c62ef7ad01b05b2c01fca6188de269d63d725348a07a99bbc50f24c1518aa871fdc61bbf42399433a0917c919dcfe9e851b206e1c37dec0908f69ad89bb1f8e",
5503
+ "07d181c1026ef4a6732bff3dffbc5ae0e3746e4860f478c6c2e8e258df2ed7671efe073fb31cf5a61c0eedceccb5e968220b9ff7e2b055b11d7c456a57fe7ac9",
5504
+ "1bbd7ad96893df675c811e5a2be184e2e3bc9af0ce30a7b26e53a916a10a777a01ffa70dbe585201ac09778429c04c71229392608095d220c7d82631a0caedd6"
5505
+ ],
5506
+ next_step_selector_commitments: [
5507
+ "2ae6c5c98d4c384e8e645d85a4ca362de4c4e75efe3c79d5bcbd126a9e305b831618df99300c7327f1eac6a498c8feac6013d4ba09b7ea046340f99b0598a832"
5508
+ ],
5509
+ permutation_commitments: [
5510
+ "2458c5fb474ab3e7ae9c6b82cc432a111954d8be5e7e9b4fc58c14e1aed77f3207426dbe08272aa69ba8b73809f27f9ff083641b5c3c896c386a74bbed3083dd",
5511
+ "0879ac4885674b1af0ab67c7b505bce6234f32a0335bdfd229023fea5f303ece0973ba8abc9ade8edcfb68c7d4b8b98272c7bf33eff841fec78d21c0c2e82aa6",
5512
+ "07b74f37fcbcb2d9962a529fbc254d54925aeb1be1a49517affeb3571ef3e31e3033f7900ff5bb5759cbb98b64ca7f42967278c328d00e60c042aa65f2178ded",
5513
+ "203c948fdc386e7bfbdc37363ab489e9ce3264f4ccd23c33dd8f2337fb9007a621cabf740aa26e522dcb7af6c0de9f93cbc69595b29b02e75c2f3507e97664ec"
5514
+ ],
5515
+ non_residues: [
5516
+ "0000000000000000000000000000000000000000000000000000000000000005",
5517
+ "0000000000000000000000000000000000000000000000000000000000000007",
5518
+ "000000000000000000000000000000000000000000000000000000000000000a"
5519
+ ],
5520
+ g2_elements: [
5521
+ "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5522
+ "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
5523
+ ]
5524
+ }
5525
+ }
5526
+ },
5527
+ "9-4-3-625": {
5528
+ parameter: {
5529
+ state_tree_depth: "9",
5530
+ int_state_tree_depth: "4",
5531
+ message_batch_size: "625",
5532
+ vote_option_tree_depth: "3"
5533
+ },
5534
+ groth16: {
5535
+ process_1p1v_vkey: {
5536
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5537
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5538
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5539
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5540
+ vk_ic0: "1195be678487bbc8c0ae726c0985a5caf6f75e3f8327926926c4f89e498ad733043e46e10b506d194b27275f402bc3fb208a2f5be69662e7c9898d1c0ece4f04",
5541
+ vk_ic1: "10c34362189a7ee44b1c5e57755d7e0d672dba552e614d5cd9a53081bee2333425879fa4e4a9e3fff287824cce35f94725ca0edb60a4ffcbf50becb2fd96cb0b"
5542
+ },
5543
+ tally_1p1v_vkey: {
5544
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5545
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5546
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5547
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5548
+ vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
5549
+ vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
5550
+ },
5551
+ process_qv_vkey: {
5552
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5553
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5554
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5555
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5556
+ vk_ic0: "1832600210a459fe61d971081d4baa1a1add23f87c8a8dc4042cd5cf6c6fdf8e3018489aec30d9deb26629e05965a3a7e038be58ce10c854cb7e1071f2708aad",
5557
+ vk_ic1: "0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6"
5558
+ },
5559
+ tally_qv_vkey: {
5560
+ vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
5561
+ vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
5562
+ vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5563
+ vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
5564
+ vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
5565
+ vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
5566
+ }
5567
+ }
5568
+ }
5569
+ };
5570
+ var QTR_LIB = {
5571
+ zeros: [
5572
+ "0",
5573
+ "14655542659562014735865511769057053982292279840403315552050801315682099828156",
5574
+ "19261153649140605024552417994922546473530072875902678653210025980873274131905",
5575
+ "21526503558325068664033192388586640128492121680588893182274749683522508994597",
5576
+ "20017764101928005973906869479218555869286328459998999367935018992260318153770",
5577
+ "16998355316577652097112514691750893516081130026395813155204269482715045879598",
5578
+ "2612442706402737973181840577010736087708621987282725873936541279764292204086",
5579
+ "17716535433480122581515618850811568065658392066947958324371350481921422579201",
5580
+ "17437916409890180001398333108882255895598851862997171508841759030332444017770"
5581
+ ]
5582
+ };
5583
+
5584
+ // src/libs/contract/utils.ts
5585
+ function getContractParams(type, circuitType, proofSystem, maxVoter, maxOption) {
5586
+ let parameters;
5587
+ let groth16ProcessVkey = null;
5588
+ let groth16TallyVkey = null;
5589
+ let plonkProcessVkey = null;
5590
+ let plonkTallyVkey = null;
5591
+ let maciVoteType = null;
5592
+ let maciCertSystem = null;
5593
+ switch (circuitType) {
5594
+ case "0" /* IP1V */:
5595
+ maciVoteType = "0";
5596
+ break;
5597
+ case "1" /* QV */:
5598
+ maciVoteType = "1";
5599
+ break;
5600
+ default:
5601
+ throw new Error(
5602
+ `Invalid circuit type ${circuitType}, only support 1P1V and QV`
5603
+ );
5604
+ }
5605
+ switch (proofSystem) {
5606
+ case "groth16" /* GROTH16 */:
5607
+ maciCertSystem = "0";
5608
+ break;
5609
+ case "plonk" /* PLONK */:
5610
+ maciCertSystem = "1";
5611
+ break;
5612
+ default:
5613
+ throw new Error(
5614
+ `Invalid proof system ${proofSystem}, only support GROTH16 and PLONK`
5615
+ );
5616
+ }
5617
+ if (maxVoter <= 25 && maxOption <= 5) {
5618
+ parameters = CIRCUIT_INFO["2-1-1-5"].parameter;
5619
+ if (proofSystem === "groth16" /* GROTH16 */) {
5620
+ groth16ProcessVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].process_vkey;
5621
+ groth16TallyVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].tally_vkey;
5622
+ } else if (proofSystem === "plonk" /* PLONK */) {
5623
+ plonkProcessVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.process_vkey;
5624
+ plonkTallyVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.tally_vkey;
5625
+ }
5626
+ } else if (maxVoter <= 625 && maxOption <= 25) {
5627
+ parameters = CIRCUIT_INFO["4-2-2-25"].parameter;
5628
+ if (proofSystem === "groth16" /* GROTH16 */) {
5629
+ groth16ProcessVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].process_vkey;
5630
+ groth16TallyVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].tally_vkey;
5631
+ } else if (proofSystem === "plonk" /* PLONK */) {
5632
+ plonkProcessVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.process_vkey;
5633
+ plonkTallyVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.tally_vkey;
5634
+ }
5635
+ } else if (maxVoter <= 15625 && maxOption <= 125) {
5636
+ parameters = CIRCUIT_INFO["6-3-3-125"].parameter;
5637
+ if (proofSystem === "groth16" /* GROTH16 */) {
5638
+ groth16ProcessVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].process_vkey;
5639
+ groth16TallyVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].tally_vkey;
5640
+ } else if (proofSystem === "plonk" /* PLONK */) {
5641
+ plonkProcessVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.process_vkey;
5642
+ plonkTallyVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.tally_vkey;
5643
+ }
5644
+ } else if (maxVoter <= 1953125 && maxOption <= 125) {
5645
+ parameters = CIRCUIT_INFO["9-4-3-625"].parameter;
5646
+ if (proofSystem === "groth16" /* GROTH16 */) {
5647
+ if (circuitType === "0" /* IP1V */) {
5648
+ groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
5649
+ groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
5650
+ } else if (circuitType === "1" /* QV */) {
5651
+ groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
5652
+ groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
5653
+ }
5654
+ } else if (proofSystem === "plonk" /* PLONK */) {
5655
+ throw new Error("PLONK is not supported for MACI-9");
5656
+ }
5657
+ } else {
5658
+ throw new Error("Number of voters or options is too large.");
5659
+ }
5660
+ switch (type) {
5661
+ case "0" /* MACI */:
5662
+ return {
5663
+ parameters,
5664
+ groth16ProcessVkey,
5665
+ groth16TallyVkey,
5666
+ plonkProcessVkey,
5667
+ plonkTallyVkey,
5668
+ maciVoteType,
5669
+ maciCertSystem
5670
+ };
5671
+ case "1" /* AMACI */:
5672
+ return {
5673
+ // parameters,
5674
+ // groth16ProcessVkey,
5675
+ // groth16TallyVkey,
5676
+ // plonkProcessVkey,
5677
+ // plonkTallyVkey,
5678
+ };
5679
+ case "2" /* ORACLE_MACI */:
5680
+ if (circuitType === "0" /* IP1V */) {
5681
+ groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
5682
+ groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
5683
+ } else if (circuitType === "1" /* QV */) {
5684
+ groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
5685
+ groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
5686
+ }
5687
+ return {
5688
+ parameters: CIRCUIT_INFO["9-4-3-625"].parameter,
5689
+ groth16ProcessVkey,
5690
+ groth16TallyVkey,
5691
+ plonkProcessVkey: null,
5692
+ plonkTallyVkey: null,
5693
+ maciVoteType,
5694
+ maciCertSystem: "0"
5695
+ };
5696
+ }
5697
+ }
5698
+ function getAMaciRoundCircuitFee(network, maxVoter, maxOption) {
5699
+ let requiredFee = {
5700
+ denom: "peaka",
5701
+ amount: "0"
5702
+ };
5703
+ if (maxVoter <= 25 && maxOption <= 5) {
5704
+ if (network === "mainnet") {
5705
+ requiredFee.amount = "20000000000000000000";
5706
+ } else {
5707
+ requiredFee.amount = "20000000000000000000";
4562
5708
  }
4563
- );
4564
- return client;
5709
+ } else if (maxVoter <= 625 && maxOption <= 25) {
5710
+ if (network === "mainnet") {
5711
+ requiredFee.amount = "750000000000000000000";
5712
+ } else {
5713
+ requiredFee.amount = "750000000000000000000";
5714
+ }
5715
+ } else {
5716
+ throw new Error("Number of voters or options is too large.");
5717
+ }
5718
+ return requiredFee;
4565
5719
  }
4566
5720
 
4567
- // src/types/index.ts
4568
- var MaciCircuitType = /* @__PURE__ */ ((MaciCircuitType2) => {
4569
- MaciCircuitType2["IP1V"] = "0";
4570
- MaciCircuitType2["QV"] = "1";
4571
- return MaciCircuitType2;
4572
- })(MaciCircuitType || {});
4573
- var MaciCertSystemType = /* @__PURE__ */ ((MaciCertSystemType2) => {
4574
- MaciCertSystemType2["GROTH16"] = "groth16";
4575
- MaciCertSystemType2["PLONK"] = "plonk";
4576
- return MaciCertSystemType2;
4577
- })(MaciCertSystemType || {});
4578
- var MaciRoundType = /* @__PURE__ */ ((MaciRoundType2) => {
4579
- MaciRoundType2["MACI"] = "0";
4580
- MaciRoundType2["AMACI"] = "1";
4581
- MaciRoundType2["ORACLE_MACI"] = "2";
4582
- return MaciRoundType2;
4583
- })(MaciRoundType || {});
4584
-
4585
- // src/libs/contract/vars.ts
4586
- var CIRCUIT_INFO = {
4587
- "2-1-1-5": {
4588
- parameter: {
4589
- state_tree_depth: "2",
4590
- int_state_tree_depth: "1",
4591
- vote_option_tree_depth: "1",
4592
- message_batch_size: "5"
4593
- },
4594
- groth16: {
4595
- process_vkey: {
4596
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4597
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4598
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4599
- vk_delta_2: "2178a9c3805dd82071b2b28bb4c0ffc8178cad913c8c990b98b4863284dc3a5d175c0be554fc060c27c551e5e32effef015b918a0f5a2dc1b92909b8272719301c521d5f6542db5ea4775a42d32159c356a696599c1a3df011ec00559ae1c2b60d860f7e6513a7d20feaeaca401863e35a0f691dd7d30ce06d07946840de1ec8",
4600
- vk_ic0: "19126a54a9b6d0d415f892c246485cb2889487cf9c4a8cd88dab5e1140e1d0630d1d76ef4652df8887c9dc557aa57f25e221db7e5b2e4cf618a362bece107f5c",
4601
- vk_ic1: "0632e625fefc7172e8aec1070c4d32b90b6c482f6f3806773a4c55a03877c2d716cfd935eb3e3883f580c93f56adbf3a253ce3c208c52fb784f9d8fec139c617"
5721
+ // src/libs/contract/contract.ts
5722
+ import { GasPrice as GasPrice2, calculateFee } from "@cosmjs/stargate";
5723
+ var Contract = class {
5724
+ constructor({
5725
+ network,
5726
+ rpcEndpoint,
5727
+ registryAddress,
5728
+ saasAddress,
5729
+ apiSaasAddress,
5730
+ maciCodeId,
5731
+ oracleCodeId,
5732
+ feegrantOperator,
5733
+ whitelistBackendPubkey
5734
+ }) {
5735
+ this.network = network;
5736
+ this.rpcEndpoint = rpcEndpoint;
5737
+ this.registryAddress = registryAddress;
5738
+ this.saasAddress = saasAddress;
5739
+ this.apiSaasAddress = apiSaasAddress;
5740
+ this.maciCodeId = maciCodeId;
5741
+ this.oracleCodeId = oracleCodeId;
5742
+ this.feegrantOperator = feegrantOperator;
5743
+ this.whitelistBackendPubkey = whitelistBackendPubkey;
5744
+ }
5745
+ async createAMaciRound({
5746
+ signer,
5747
+ startVoting,
5748
+ endVoting,
5749
+ operator,
5750
+ whitelist,
5751
+ title,
5752
+ description,
5753
+ link,
5754
+ maxVoter,
5755
+ voteOptionMap,
5756
+ voiceCreditAmount,
5757
+ circuitType,
5758
+ preDeactivateRoot,
5759
+ oracleWhitelistPubkey,
5760
+ fee = "auto"
5761
+ }) {
5762
+ const start_time = (startVoting.getTime() * 10 ** 6).toString();
5763
+ const end_time = (endVoting.getTime() * 10 ** 6).toString();
5764
+ const client = await createRegistryClientBy({
5765
+ rpcEndpoint: this.rpcEndpoint,
5766
+ wallet: signer,
5767
+ contractAddress: this.registryAddress
5768
+ });
5769
+ const requiredFee = getAMaciRoundCircuitFee(
5770
+ this.network,
5771
+ maxVoter,
5772
+ voteOptionMap.length
5773
+ );
5774
+ preDeactivateRoot = preDeactivateRoot || "0";
5775
+ const res = await client.createRound(
5776
+ {
5777
+ operator,
5778
+ preDeactivateRoot,
5779
+ voiceCreditAmount,
5780
+ whitelist,
5781
+ roundInfo: {
5782
+ title,
5783
+ description: description || "",
5784
+ link: link || ""
5785
+ },
5786
+ votingTime: {
5787
+ start_time,
5788
+ end_time
5789
+ },
5790
+ maxVoter: maxVoter.toString(),
5791
+ voteOptionMap,
5792
+ certificationSystem: "0",
5793
+ circuitType,
5794
+ oracleWhitelistPubkey
5795
+ },
5796
+ fee,
5797
+ void 0,
5798
+ [requiredFee]
5799
+ );
5800
+ let contractAddress = "";
5801
+ res.events.map((event) => {
5802
+ if (event.type === "wasm") {
5803
+ let actionEvent = event.attributes.find(
5804
+ (attr) => attr.key === "action"
5805
+ );
5806
+ if (actionEvent.value === "created_round") {
5807
+ contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
5808
+ }
5809
+ }
5810
+ });
5811
+ return {
5812
+ ...res,
5813
+ contractAddress
5814
+ };
5815
+ }
5816
+ async createMaciRound({
5817
+ signer,
5818
+ operatorPubkey,
5819
+ startVoting,
5820
+ endVoting,
5821
+ whitelist,
5822
+ title,
5823
+ description,
5824
+ link,
5825
+ maxVoter,
5826
+ maxOption,
5827
+ circuitType,
5828
+ certSystemType,
5829
+ fee = "auto"
5830
+ }) {
5831
+ const start_time = (startVoting.getTime() * 10 ** 6).toString();
5832
+ const end_time = (endVoting.getTime() * 10 ** 6).toString();
5833
+ const [{ address }] = await signer.getAccounts();
5834
+ const client = await createContractClientByWallet(this.rpcEndpoint, signer);
5835
+ const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5836
+ BigInt(operatorPubkey)
5837
+ );
5838
+ const {
5839
+ parameters,
5840
+ groth16ProcessVkey,
5841
+ groth16TallyVkey,
5842
+ plonkProcessVkey,
5843
+ plonkTallyVkey,
5844
+ maciVoteType,
5845
+ maciCertSystem
5846
+ } = getContractParams(
5847
+ "0" /* MACI */,
5848
+ circuitType,
5849
+ certSystemType,
5850
+ maxVoter,
5851
+ maxOption
5852
+ );
5853
+ const instantiateResponse = await client.instantiate(
5854
+ address,
5855
+ this.maciCodeId,
5856
+ {
5857
+ round_info: { title, description: description || "", link: link || "" },
5858
+ voting_time: {
5859
+ start_time,
5860
+ end_time
5861
+ },
5862
+ parameters,
5863
+ coordinator: {
5864
+ x: operatorPubkeyX.toString(),
5865
+ y: operatorPubkeyY.toString()
5866
+ },
5867
+ groth16_process_vkey: groth16ProcessVkey,
5868
+ groth16_tally_vkey: groth16TallyVkey,
5869
+ plonk_process_vkey: plonkProcessVkey,
5870
+ plonk_tally_vkey: plonkTallyVkey,
5871
+ max_vote_options: maxOption.toString(),
5872
+ whitelist,
5873
+ circuit_type: maciVoteType,
5874
+ certification_system: maciCertSystem,
5875
+ qtr_lib: QTR_LIB
4602
5876
  },
4603
- tally_vkey: {
4604
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4605
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4606
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4607
- vk_delta_2: "2e9fad39728c543c5213599111e1a44b01720c999a6785e8136c3e3b3bf8e07e248e1933d477969ca6e27cb7a74bca18cac7e3bbdf9371be5c54fe151f6376a30955609ec69b89329322a2f435b706ca248d1312c7513853a50ef37ed0f7826c25a5c57bf07789d89e538bc24017cf2722811f21480b0bb8030ed0028ecb7cd8",
4608
- vk_ic0: "1bc1a1a3444256469c07cd6f4d1cfd9f7c9ddce596a306e0af077ca9e9c0fe9602db2a9aecef76a9dc4c19bf88c0099b04fc75410cc9004f0966440825e3790a",
4609
- vk_ic1: "05b8b475f2bfedba4fa04ab1972006da9764c2c3e6fb65d6dd0aac938fd298112a560e13770b06a3f709a49fddf016331ea205fa125026993f6666eff69f4def"
4610
- }
4611
- },
4612
- plonk: {
4613
- process_vkey: {
4614
- n: 1048575,
4615
- num_inputs: 1,
4616
- selector_commitments: [
4617
- "29b0f4a90bea69583a8fca1e74d23adf739d605af605a0e0971fac548df976fb2e10a42dfca2325684c1bca5fabbf9d7022fc8b997ea478f1052dd8808d99e44",
4618
- "119002055b6c2f98314ef408e4a917a6678f114ca991185749289f171f61efc32b3a931c700271b82d22c2073af9b7fffcb7bfa644ea09102d9ef8482410a991",
4619
- "10c5f32870d26f8e26d2eaae2705557b18210b2355677172e1bef5fe684120891f8317185390ddbb22ecb922d37e03c3cc524c84f65c8045f2324b0f164cfbdb",
4620
- "115a5f9af5d438d3261cfa31b7050b931b7d22647f628a43af41a41dcd44cb8d2e99368eb15cdc6d1f16faf9db0db4825613d6893c776aef456705bdc76eb728",
4621
- "1a61cc5f0fbe92fbc8c9bd58928ce467f63e4771e4d517966afbaf220ea069a91cec3231c370be07fee8d9ec01660d054c549b034715855ffa652ad5b67ced86",
4622
- "19e0d095a343115f6e7ad7ae1f51e375cd648fb35451cb2d5a8cf3bafbb25d0525efdc2cc5b5600ee0ae954dca3bf67c8277d470161fe23b4be7a5bcdf641e68"
4623
- ],
4624
- next_step_selector_commitments: [
4625
- "246ce82e01ed312e81492f132da2ee16bc13cc0024fbcc668de30173ad59067f0f072a892451cc495f5d9b8b99c8dc29be1d42d3004aed45fd5b2cd32a420016"
4626
- ],
4627
- permutation_commitments: [
4628
- "19c4143f41738480adc5ae49922d31b8a5afaa1d25ced5c20b869c0e1ccad91920c267c53d33907318cd194ba2ea08a85f250779765ba4121f7a0edfe1afe22b",
4629
- "114bda14aa702a0815e3f91318a08a2798244420fd6675c8fc3cc2b0232298890d2eb3c1f27a83f4a3be777524d6cc65aa435e0a472fae8d1158e0a6ded685d0",
4630
- "289f0b046968d2c095d05350e43996756fc85d2deb0e267a069615f0889a249413bdbe6f09edb4db956b8f3fc4488c4681cd52469dc0d419dab99a65b88309f7",
4631
- "16dd74a2089960aac0d68309d5e81c6b45c29fafe4d42c922c06eb633ed48d551d347d1f43ee9b137772eefc43a6dcdf5ac35ee1615bc8f7c243bce071c410a9"
4632
- ],
4633
- non_residues: [
4634
- "0000000000000000000000000000000000000000000000000000000000000005",
4635
- "0000000000000000000000000000000000000000000000000000000000000007",
4636
- "000000000000000000000000000000000000000000000000000000000000000a"
4637
- ],
4638
- g2_elements: [
4639
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4640
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4641
- ]
5877
+ `[MACI] ${title}`,
5878
+ fee
5879
+ );
5880
+ return instantiateResponse;
5881
+ }
5882
+ async createOracleMaciRound({
5883
+ signer,
5884
+ operatorPubkey,
5885
+ startVoting,
5886
+ endVoting,
5887
+ title,
5888
+ description,
5889
+ link,
5890
+ voteOptionMap,
5891
+ circuitType,
5892
+ whitelistEcosystem,
5893
+ whitelistSnapshotHeight,
5894
+ whitelistVotingPowerArgs,
5895
+ fee = "auto"
5896
+ }) {
5897
+ const start_time = (startVoting.getTime() * 1e6).toString();
5898
+ const end_time = (endVoting.getTime() * 1e6).toString();
5899
+ const [{ address }] = await signer.getAccounts();
5900
+ const client = await createContractClientByWallet(this.rpcEndpoint, signer);
5901
+ const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5902
+ BigInt(operatorPubkey)
5903
+ );
5904
+ const { maciVoteType, maciCertSystem } = getContractParams(
5905
+ "2" /* ORACLE_MACI */,
5906
+ circuitType,
5907
+ "groth16" /* GROTH16 */,
5908
+ 0,
5909
+ 0
5910
+ );
5911
+ const instantiateResponse = await client.instantiate(
5912
+ address,
5913
+ this.oracleCodeId,
5914
+ {
5915
+ round_info: { title, description: description || "", link: link || "" },
5916
+ voting_time: {
5917
+ start_time,
5918
+ end_time
5919
+ },
5920
+ coordinator: {
5921
+ x: operatorPubkeyX.toString(),
5922
+ y: operatorPubkeyY.toString()
5923
+ },
5924
+ vote_option_map: voteOptionMap,
5925
+ whitelist_backend_pubkey: this.whitelistBackendPubkey,
5926
+ whitelist_ecosystem: whitelistEcosystem,
5927
+ whitelist_snapshot_height: whitelistSnapshotHeight,
5928
+ whitelist_voting_power_args: whitelistVotingPowerArgs,
5929
+ circuit_type: maciVoteType,
5930
+ certification_system: maciCertSystem,
5931
+ feegrant_operator: this.feegrantOperator
4642
5932
  },
4643
- tally_vkey: {
4644
- n: 524287,
4645
- num_inputs: 1,
4646
- selector_commitments: [
4647
- "18c2bb75c8ed53a5d15a56cc91c56f14c832419994ce7187c7c98b5e622cac0808b773f05e09822d8d267646198a78359ea2aa6fbaeb01317142f99fd11da6c0",
4648
- "181499098243a5968f5490b7759aa15f0f769f24f3f4219b69f96913cf4fb23c1cd7b3f109196d7577390fd2e6d3930a71b0559aff756f3ca43eef66ce7333f4",
4649
- "07ba2bdd452503fb16b56ea2940e95a98118c9dd120ae192680fe2b80bdb26f10ac6cdc7cb12b581a8c64d45b5af3d253c4282405eed3fd4d091ae05aac45cb6",
4650
- "1caf01f1775eeafa78a11202e926ee92be997ce040f9c6fbce161348a40aeda70d9f15738cccf538083784e566ceef651d000223ae810c980e2d5d98b91b4665",
4651
- "2c377c69cae1d591af413da2fd986ef3dca595d0c5817ee4932b92169d37c52d1218ce63dde705ebd1dc66d9b62daca287e4fdf6800b69204e5b78bfe84365a1",
4652
- "175dd4ff280e39f0e080c181f853845e40c4b91709a93e4398d24befc9cf556903675361817e031e86bd896ff1dd7bc1cc31ca920a101499db0c58d77f0730ec"
4653
- ],
4654
- next_step_selector_commitments: [
4655
- "12d76999d26137d433f7119ab34f3fc63cfedb9172052cfb34acfc3cdc570f511aba802ebe92b87f913496314b938cf526078280a68826c90b686b90420c7742"
4656
- ],
4657
- permutation_commitments: [
4658
- "167b05c0132399e7126e8d16efb224b1c6729942048fc7e730fd1451116e0a6e05acaf2a6d2c88cc25610474b651c8cdcb7e8e14e59ddfad819123e888c4b1b6",
4659
- "25aed62de4b701dc645e076543e2553c306010f2776c74edae55ea5253d9540403d042c4cb699cc04b2bb63d3c3edc0c85b049a84dc2fd44369f957d81363563",
4660
- "0e77fb0b0e84da1d955da3d66dbb8fa3988f22e999a34bc4ac537a0f9187ac40156f8d7cb6d005fd85a0178d794f941b4e84832fd389a37c2a78112dac09b758",
4661
- "051d3d906d457eaa9eff77a296dfa1760fd9ea379eec60487be38de91545ca2c1fcf457d6ac31afee10951245b0cc1e2c7674596f65955d189d48b6938fb3594"
4662
- ],
4663
- non_residues: [
4664
- "0000000000000000000000000000000000000000000000000000000000000005",
4665
- "0000000000000000000000000000000000000000000000000000000000000007",
4666
- "000000000000000000000000000000000000000000000000000000000000000a"
4667
- ],
4668
- g2_elements: [
4669
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4670
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4671
- ]
4672
- }
4673
- }
4674
- },
4675
- "4-2-2-25": {
4676
- parameter: {
4677
- state_tree_depth: "4",
4678
- int_state_tree_depth: "2",
4679
- vote_option_tree_depth: "2",
4680
- message_batch_size: "25"
4681
- },
4682
- groth16: {
4683
- process_vkey: {
4684
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4685
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4686
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4687
- vk_delta_2: "0d0fe390b9dd4d1d0f486787b6ea96765cbeaa8f00310fecc3429673c5866c081a27998596ba296f66f3f7b5e2450d1ce1bcc535c133b2e8b577ba07dc1ccb4c1895f7afb9b3168a6d628c9173157cd56ca51948cc66c129a25f80e3b665e4b12c9c50f0cc0d070978ed2fb8ce15956d67c5dc6c07c7f45f1facfb5522d7b656",
4688
- vk_ic0: "0ff2b22774da5c0ba94db4d759827b8c962aaf44db2649eb10407de02a40463a26497581d6d0979ad7f9057f26e048109158b0872700e2ad8447ffc9b4bf146b",
4689
- vk_ic1: "0a47be101a59d20641e1369c0b2b9fb839cd35ecbfbeac3866df43723b70c78d17e96303c417743d93b7726805b736f364d305036b50e4ad1b885fc41284daf5"
5933
+ `[Oracle MACI] ${title}`,
5934
+ fee
5935
+ );
5936
+ return instantiateResponse;
5937
+ }
5938
+ async createSaasOracleMaciRound({
5939
+ signer,
5940
+ operatorPubkey,
5941
+ startVoting,
5942
+ endVoting,
5943
+ title,
5944
+ description,
5945
+ link,
5946
+ maxVoter,
5947
+ voteOptionMap,
5948
+ whitelistBackendPubkey,
5949
+ gasStation = false,
5950
+ fee = 1.8
5951
+ }) {
5952
+ const startTime = (startVoting.getTime() * 1e6).toString();
5953
+ const endTime = (endVoting.getTime() * 1e6).toString();
5954
+ const client = await createSaasClientBy({
5955
+ rpcEndpoint: this.rpcEndpoint,
5956
+ wallet: signer,
5957
+ contractAddress: this.saasAddress
5958
+ });
5959
+ const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5960
+ BigInt(operatorPubkey)
5961
+ );
5962
+ const roundParams = {
5963
+ certificationSystem: "0",
5964
+ circuitType: "0",
5965
+ coordinator: {
5966
+ x: operatorPubkeyX.toString(),
5967
+ y: operatorPubkeyY.toString()
4690
5968
  },
4691
- tally_vkey: {
4692
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4693
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4694
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4695
- vk_delta_2: "08e44e0876bd574d8a3411e374884eb61da7292ca52903fa96553c37311b66ce0f2f529e59b1d37e55794a575d0f87548ca0d03331c19689bc203a68c1c4bae20e9fd25a7bffaa9b7409e694a48bc0d57f42df164d4a01bd5deecffedd2d3a3125eff290efb93eaf9c578cc7ee9d00406137607b9602de02424ff413ac948690",
4696
- vk_ic0: "295c8e84b4b6b8de44b24f80eb5cae1df65e4877c4af8da2dbadfbfc3586dc790661b9e636f2c2a83028d11cbb7c753675481b65a5dfe32fff7a558231b3c9ef",
4697
- vk_ic1: "299cfb28054cde0470bd7ff280349089350226d1ca154dcf6544b2680bf3bea925026e6644668273d6066ef6766c2f561c3607c523fbbd1379c5002376ef69c3"
4698
- }
4699
- },
4700
- plonk: {
4701
- process_vkey: {
4702
- n: 2097151,
4703
- num_inputs: 1,
4704
- selector_commitments: [
4705
- "126cbf10e0b68a56d45614be16c5bb48bd1374478e17b9fe1a78b726ea70f9b21f3cd20fd178d89e5923c422ef050ccc7134fbd76c9efdbb90f677ee41e01edb",
4706
- "12813166f206c95eddd998a40d8d2e54e29dd393f543e3583a7999b18d674832024cdd935540bd3b96207ec0609c6718ad8b14e2ef315594454c57d606494485",
4707
- "05da9eea3ee7151355067ced11a8e8ff57a56c758493afc9cbb6cfbacfc42e7b08993dfa25c85f20aeb7f64e87fe56ac8066cf6b8479dc96294e302ef5d55372",
4708
- "2e446e540bacde7daea23c93a67bc6b1424b7c16b33fd2cee251b0d093cd78300030b8e340f01f320639d60b77724e58fc8a2d778b7b2a5df2c953ce34debeea",
4709
- "1cf8c75b18071ede19d196b46a8776efc29ac514458a698d9f2e50b7bc692f6e06f7ff96897240eca31058fe330e8cbcd911324b79a3a34d03340a3cfed85fd5",
4710
- "17101fb5c293438a695075b221219679e278e4bd147239c9fc69081b19cacefe218eb895f1456ca81e29731967588aee4b0758ea51aa28e5fefc81fed4a11513"
4711
- ],
4712
- next_step_selector_commitments: [
4713
- "0cebff4fe8cd70325f986088a1e17ae129a025481137bd80aef9c1f1c2e52f1e265a4ccae1ed89cb2fba527165f007898e70f988311ee4e4e87e41376cfeed03"
4714
- ],
4715
- permutation_commitments: [
4716
- "025b5db167721133693f0b6d9d7cfadce68ad15365ef1605dda4a6c809edeea61927b27ca11713fc683c88f6330e9621837b05e5db74d5994d1cf04bc3d529b3",
4717
- "1fac93999f33b145613901846e6403d7f4237d582b51ccc4fb5c70038284c6e21cc804cc3cf7170b96da74fcbb30c81cd8c3405a629327c657025db7332f169a",
4718
- "0b6d7d383de73dbfc16f2c0f3af763135ff05a12ec937548008cfee944c195f902336a68a50f62f595953e44401e872fb41abb66a733684b079ffe550d09c233",
4719
- "225a1f5e92d105d3be026ae68904826f89b786faad75a846ef966ed714568bba28d1388786fde71dea206cdef16faa7a589e90863e6245d271e3f154c75c5531"
4720
- ],
4721
- non_residues: [
4722
- "0000000000000000000000000000000000000000000000000000000000000005",
4723
- "0000000000000000000000000000000000000000000000000000000000000007",
4724
- "000000000000000000000000000000000000000000000000000000000000000a"
4725
- ],
4726
- g2_elements: [
4727
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4728
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4729
- ]
5969
+ maxVoters: maxVoter,
5970
+ roundInfo: {
5971
+ title,
5972
+ description: description || "",
5973
+ link: link || ""
4730
5974
  },
4731
- tally_vkey: {
4732
- n: 1048575,
4733
- num_inputs: 1,
4734
- selector_commitments: [
4735
- "1588fb667b3f0e4d0970b8208e4b6b4c729c4926b936f8d877017cf42d07ca15069643791d98abcd6b7d0b0546e7560ab9011e069f2ee48ede581fc72d8b5e04",
4736
- "09c5480b103c44a81850ffd9a61ec21f7db41bc89996d8df075c3e029290eb5b083cb2b184d95c0761e585547be33250c8939929b87fdc39775ccea17d51b481",
4737
- "278e239bcac0a945a17572a6d61ba59f705746e6893a10a44841933a8c8310e712e4ee913af9b77c8fdcdc365316aa9f1b8dc081eb99ad80265768ec9f484beb",
4738
- "12532585ea307c5559b18a4d01db59b544a88088f61a5b5ed0431393e6f675af1309bf0dcaa7a552849e5f28d0300c8c61b18393fb638aed3b7d70e27bb91c35",
4739
- "172e7ecb8e485aaee801fd78b8fd7c0b862baef65e39e6832cffa2170b6f981928d86ab5887e8c3210e34e03cada468bd501f60ec3a8fa35b4c7067d6fb8c6ae",
4740
- "0c27211d046735fc681228b8366be2c8cf9a256cbd03dcd4af65152e94f95a6f1af151a5311b195b0f4acffeec4952cc52edbb7045aab61bbd3be9cd322ab99e"
4741
- ],
4742
- next_step_selector_commitments: [
4743
- "25ee15301d562e6c630946b3fbe36b9fbd8dfbd44ddf70cc825fb1fa1ebd966229081f6b9297da671c69064e10b8f5dd0f69b69d1bf79122c6197f119087ebe1"
4744
- ],
4745
- permutation_commitments: [
4746
- "194849a6ec5cb37e09d20801d387abbab04e453f630c5fbbf5c4819c5569480c0c8bf0ce2b4955cc4c891840da1d9e99feb81e8d43251dffbe4d6167639b9f9b",
4747
- "17717d2638632d406b3c8aa69550c8aeed1b79def3ab55e9d0c4bdf21cc339ad07d3bd3a331145fc96f34c85469a34a8c93b53b7aa36bb5a94c31e3b4d47713e",
4748
- "277b0c99b63c79bb9ed2f677c3987cf00acb293933dfced82b5afcb8bf0c34570d3187ce5c7e892582ddda4322cf7c50d41105fe98503fb60e41f4a08da5916d",
4749
- "0489f6dec0f27a8c21d147ebb9781b68b4b73db065a6017924c543f6d9fadbe922d24c0946bd8b19df7659810296d063b557cdf7aba510b11e08fbf2e9d37931"
4750
- ],
4751
- non_residues: [
4752
- "0000000000000000000000000000000000000000000000000000000000000005",
4753
- "0000000000000000000000000000000000000000000000000000000000000007",
4754
- "000000000000000000000000000000000000000000000000000000000000000a"
5975
+ startTime,
5976
+ endTime,
5977
+ voteOptionMap,
5978
+ whitelistBackendPubkey: whitelistBackendPubkey || this.whitelistBackendPubkey
5979
+ };
5980
+ let createResponse;
5981
+ if (gasStation && typeof fee !== "object") {
5982
+ const [{ address }] = await signer.getAccounts();
5983
+ const contractClient = await this.contractClient({ signer });
5984
+ const msg = {
5985
+ create_oracle_maci_round: {
5986
+ certification_system: "0",
5987
+ circuit_type: "0",
5988
+ coordinator: roundParams.coordinator,
5989
+ max_voters: roundParams.maxVoters.toString(),
5990
+ round_info: roundParams.roundInfo,
5991
+ start_time: roundParams.startTime,
5992
+ end_time: roundParams.endTime,
5993
+ vote_option_map: roundParams.voteOptionMap,
5994
+ whitelist_backend_pubkey: roundParams.whitelistBackendPubkey
5995
+ }
5996
+ };
5997
+ const gasEstimation = await contractClient.simulate(
5998
+ address,
5999
+ [
6000
+ {
6001
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6002
+ value: {
6003
+ sender: address,
6004
+ contract: this.saasAddress,
6005
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6006
+ }
6007
+ }
4755
6008
  ],
4756
- g2_elements: [
4757
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4758
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4759
- ]
4760
- }
6009
+ ""
6010
+ );
6011
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6012
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6013
+ const calculatedFee = calculateFee(
6014
+ Math.round(gasEstimation * multiplier),
6015
+ gasPrice
6016
+ );
6017
+ const grantFee = {
6018
+ amount: calculatedFee.amount,
6019
+ gas: calculatedFee.gas,
6020
+ granter: this.saasAddress
6021
+ };
6022
+ createResponse = await client.createOracleMaciRound(
6023
+ roundParams,
6024
+ grantFee
6025
+ );
6026
+ } else if (gasStation && typeof fee === "object") {
6027
+ const grantFee = {
6028
+ ...fee,
6029
+ granter: this.saasAddress
6030
+ };
6031
+ createResponse = await client.createOracleMaciRound(
6032
+ roundParams,
6033
+ grantFee
6034
+ );
6035
+ } else {
6036
+ createResponse = await client.createOracleMaciRound(roundParams, fee);
4761
6037
  }
4762
- },
4763
- "6-3-3-125": {
4764
- parameter: {
4765
- state_tree_depth: "6",
4766
- int_state_tree_depth: "3",
4767
- vote_option_tree_depth: "3",
4768
- message_batch_size: "125"
4769
- },
4770
- groth16: {
4771
- process_vkey: {
4772
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4773
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4774
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4775
- vk_delta_2: "057f25675851ef5a79a6d8706a43a6cd8e494cfb12c241ede46991d9174cf30605b081ff44f3ede774dab68ea9324c12308c13cb09cbb129adf94401b9134f5b16137d952fd32ab2d4243ebff4cb15d17206948ef17909ea8606886a8109bdad082f7d27e1cbf98925f055b39d1c89f9bcc4f6d92fdb920934ff5e37ba4d9b49",
4776
- vk_ic0: "27c937c032a18a320566e934448a0ffceea7050492a509c45a3bcb7e8ff8905d20789ada31729a833a4f595ff9f49f88adb66f2ab987de15a15deccb0e785bf4",
4777
- vk_ic1: "0ed2cefc103a2234dbc6bbd8634812d65332218b7589f4079b2c08eb5a4f5f63113a7f3cb53797a7f5819d7de7e3f0b2197d1c34790685a4a59af4314810420b"
4778
- },
4779
- tally_vkey: {
4780
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4781
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4782
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4783
- vk_delta_2: "2065e91c00fcc5cbc3d974cf52e24de972bdb1b4d8ded629dec20b5c904c3fa327ffe02402094795ff4d02588c8268fcad738f69eb4c732a0c98b485035e1f4913ede11b074ff143a929673e581a547717c58ce01af87d9d8b28f65f506093a61013e367b93e6782129362065840a0af9b77d7d9659a84577176e64a918d8d4c",
4784
- vk_ic0: "11db4a022aab89a265f06ff62aa18c74b21e913a8b23e7fce9cb46f76d1c4d9f2a7475b1eeb7be0a0dc457e6d52536ba351b621b63a7d77da75d4e773048537e",
4785
- vk_ic1: "0f298d235d0822ad281386abdf511853529af4c864b0cd54140facebfc1356a3059cd6d0d4b27b39e5683548fe12025e2a6b2e2724c2ca87d2008ef932ed3801"
6038
+ let contractAddress = "";
6039
+ createResponse.events.map((event) => {
6040
+ if (event.type === "wasm") {
6041
+ let actionEvent = event.attributes.find(
6042
+ (attr) => attr.key === "action"
6043
+ );
6044
+ if (actionEvent.value === "created_oracle_maci_round") {
6045
+ contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
6046
+ }
4786
6047
  }
4787
- },
4788
- plonk: {
4789
- process_vkey: {
4790
- n: 8388607,
4791
- num_inputs: 1,
4792
- selector_commitments: [
4793
- "216533ab27390f98812429524326ac08736d636d2891fb81446796cc1771a3230642f49db115acc15a186a1013f91a08efcd05640eb137d700276e80fd05bc90",
4794
- "11747f6f378e26dbdacff464ce7eb6a8869750d0fa7e508e263ac77b582c1e9b24ba3d208650b0c28943915c563cc94cc3f98cdb5fd8adc4f4d3e2a60eda3302",
4795
- "09239eb768d8d47b91c7e08e2ec6a374571964ed16be293cdc35e112393c4fd1182a0794be7f1441418664e9f718b67ed392a7da3e2868375bcf629131bb2680",
4796
- "2020f7db24940bbf38d097ea5d7ef7253e38b154d7eb0ff1782ea18ce215dd7b0e8475197b071b118adc6418b7b7fb42fea19b6272d1bb460cc47deacb299ec7",
4797
- "298923db1618185064bbab5df30ee03a3c9cbc7ce8f096d76cbd2a5ab3df86cd05bbedb938e6e0ff35cce23609458aff8081cdf3163655672074d1b18b0007bd",
4798
- "0effaabe8c6e8a076aedd36d10f2926f9871f552d93e22bfbe69e3c828a546fa2d0cd163b49a6de219ac2c048a8459ae448047748ba078b9d5d07b290c946b08"
4799
- ],
4800
- next_step_selector_commitments: [
4801
- "13e3d7299e30e6142699469d620df721eca35bbb807a8f4298f165260fdc24f823e7bd9bcb6506a094a5ebef44434c62e4bcb5d3dd7e092c49d5cb80b8ae0757"
4802
- ],
4803
- permutation_commitments: [
4804
- "03d94ab8fdc681523a8eec10f1ce5552937c268d1d970f9e75ee8657cd4c12a81e03476f83ef5c14db2f4d931b833a3b65b8d5689b37cc7f183914c90d3d065d",
4805
- "1b9c6ef20e68355c535bda6ff04a8a61d7552a594bb8e88d69a6f8840ddab04d2884824cc356d0d90cc278c247fc531de62efca4b19ed1be6f071144474d2037",
4806
- "1ff82de8312481e1591d2d1c2698fa3944b3f0afa0dd702be8a1a944a5a8997323ffbd0ab39a2e13608a8e76803c33ffda7317bb7101e335ce5552ed62dcd09d",
4807
- "2cb2bbdd51d22b79957b0401ecb6fe089f05426ba092b1205fa92f39b36cc5fc0c36c3934e47b7d407d4cda0c78c2b3fb23162cb0d295e8a8cce1a274956c34a"
6048
+ });
6049
+ return {
6050
+ ...createResponse,
6051
+ contractAddress
6052
+ };
6053
+ }
6054
+ async setSaasOracleMaciRoundInfo({
6055
+ signer,
6056
+ contractAddress,
6057
+ title,
6058
+ description,
6059
+ link,
6060
+ gasStation = false,
6061
+ fee = 1.8
6062
+ }) {
6063
+ const client = await createSaasClientBy({
6064
+ rpcEndpoint: this.rpcEndpoint,
6065
+ wallet: signer,
6066
+ contractAddress: this.saasAddress
6067
+ });
6068
+ const roundInfo = {
6069
+ title,
6070
+ description,
6071
+ link
6072
+ };
6073
+ if (gasStation && typeof fee !== "object") {
6074
+ const [{ address }] = await signer.getAccounts();
6075
+ const contractClient = await this.contractClient({ signer });
6076
+ const msg = {
6077
+ set_round_info: {
6078
+ contract_addr: contractAddress,
6079
+ round_info: roundInfo
6080
+ }
6081
+ };
6082
+ const gasEstimation = await contractClient.simulate(
6083
+ address,
6084
+ [
6085
+ {
6086
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6087
+ value: {
6088
+ sender: address,
6089
+ contract: this.saasAddress,
6090
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6091
+ }
6092
+ }
4808
6093
  ],
4809
- non_residues: [
4810
- "0000000000000000000000000000000000000000000000000000000000000005",
4811
- "0000000000000000000000000000000000000000000000000000000000000007",
4812
- "000000000000000000000000000000000000000000000000000000000000000a"
6094
+ ""
6095
+ );
6096
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6097
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6098
+ const calculatedFee = calculateFee(
6099
+ Math.round(gasEstimation * multiplier),
6100
+ gasPrice
6101
+ );
6102
+ const grantFee = {
6103
+ amount: calculatedFee.amount,
6104
+ gas: calculatedFee.gas,
6105
+ granter: this.saasAddress
6106
+ };
6107
+ return client.setRoundInfo(
6108
+ {
6109
+ contractAddr: contractAddress,
6110
+ roundInfo
6111
+ },
6112
+ grantFee
6113
+ );
6114
+ } else if (gasStation && typeof fee === "object") {
6115
+ const grantFee = {
6116
+ ...fee,
6117
+ granter: this.saasAddress
6118
+ };
6119
+ return client.setRoundInfo(
6120
+ {
6121
+ contractAddr: contractAddress,
6122
+ roundInfo
6123
+ },
6124
+ grantFee
6125
+ );
6126
+ }
6127
+ return client.setRoundInfo(
6128
+ {
6129
+ contractAddr: contractAddress,
6130
+ roundInfo
6131
+ },
6132
+ fee
6133
+ );
6134
+ }
6135
+ async setSaasOracleMaciRoundVoteOptions({
6136
+ signer,
6137
+ contractAddress,
6138
+ voteOptionMap,
6139
+ gasStation = false,
6140
+ fee = 1.8
6141
+ }) {
6142
+ const client = await createSaasClientBy({
6143
+ rpcEndpoint: this.rpcEndpoint,
6144
+ wallet: signer,
6145
+ contractAddress: this.saasAddress
6146
+ });
6147
+ if (gasStation && typeof fee !== "object") {
6148
+ const [{ address }] = await signer.getAccounts();
6149
+ const contractClient = await this.contractClient({ signer });
6150
+ const msg = {
6151
+ set_vote_options_map: {
6152
+ contract_addr: contractAddress,
6153
+ vote_option_map: voteOptionMap
6154
+ }
6155
+ };
6156
+ const gasEstimation = await contractClient.simulate(
6157
+ address,
6158
+ [
6159
+ {
6160
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6161
+ value: {
6162
+ sender: address,
6163
+ contract: this.saasAddress,
6164
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6165
+ }
6166
+ }
4813
6167
  ],
4814
- g2_elements: [
4815
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4816
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4817
- ]
6168
+ ""
6169
+ );
6170
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6171
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6172
+ const calculatedFee = calculateFee(
6173
+ Math.round(gasEstimation * multiplier),
6174
+ gasPrice
6175
+ );
6176
+ const grantFee = {
6177
+ amount: calculatedFee.amount,
6178
+ gas: calculatedFee.gas,
6179
+ granter: this.saasAddress
6180
+ };
6181
+ return client.setVoteOptionsMap(
6182
+ {
6183
+ contractAddr: contractAddress,
6184
+ voteOptionMap
6185
+ },
6186
+ grantFee
6187
+ );
6188
+ } else if (gasStation && typeof fee === "object") {
6189
+ const grantFee = {
6190
+ ...fee,
6191
+ granter: this.saasAddress
6192
+ };
6193
+ return client.setVoteOptionsMap(
6194
+ {
6195
+ contractAddr: contractAddress,
6196
+ voteOptionMap
6197
+ },
6198
+ grantFee
6199
+ );
6200
+ }
6201
+ return client.setVoteOptionsMap(
6202
+ {
6203
+ contractAddr: contractAddress,
6204
+ voteOptionMap
4818
6205
  },
4819
- tally_vkey: {
4820
- n: 8388607,
4821
- num_inputs: 1,
4822
- selector_commitments: [
4823
- "258d101f9499e81c0d0da8986c659ef33da19d4955a142e56b4854d1327c902c1996baecd81432717a9cbf92ccf651e4217a788c1a2ed855f749480f8ce8203c",
4824
- "1892a17c9c01389e3149b0663069a1ad4fd3c8e2db5ce99795b781c47b55acf9001cf5f0b4c1d088fa2058ca19cd2f1e9559ebe059897bb0aadcb540ce5f468a",
4825
- "09912d6eaa4a22802451135d9a221ebf97c2ce8ad5bbb2942d5a860482e8e4202573995072c4b014cd0e9d09a1fd53ee7d602070b404288a7fd0d97b57d8f07d",
4826
- "0c62ef7ad01b05b2c01fca6188de269d63d725348a07a99bbc50f24c1518aa871fdc61bbf42399433a0917c919dcfe9e851b206e1c37dec0908f69ad89bb1f8e",
4827
- "07d181c1026ef4a6732bff3dffbc5ae0e3746e4860f478c6c2e8e258df2ed7671efe073fb31cf5a61c0eedceccb5e968220b9ff7e2b055b11d7c456a57fe7ac9",
4828
- "1bbd7ad96893df675c811e5a2be184e2e3bc9af0ce30a7b26e53a916a10a777a01ffa70dbe585201ac09778429c04c71229392608095d220c7d82631a0caedd6"
4829
- ],
4830
- next_step_selector_commitments: [
4831
- "2ae6c5c98d4c384e8e645d85a4ca362de4c4e75efe3c79d5bcbd126a9e305b831618df99300c7327f1eac6a498c8feac6013d4ba09b7ea046340f99b0598a832"
4832
- ],
4833
- permutation_commitments: [
4834
- "2458c5fb474ab3e7ae9c6b82cc432a111954d8be5e7e9b4fc58c14e1aed77f3207426dbe08272aa69ba8b73809f27f9ff083641b5c3c896c386a74bbed3083dd",
4835
- "0879ac4885674b1af0ab67c7b505bce6234f32a0335bdfd229023fea5f303ece0973ba8abc9ade8edcfb68c7d4b8b98272c7bf33eff841fec78d21c0c2e82aa6",
4836
- "07b74f37fcbcb2d9962a529fbc254d54925aeb1be1a49517affeb3571ef3e31e3033f7900ff5bb5759cbb98b64ca7f42967278c328d00e60c042aa65f2178ded",
4837
- "203c948fdc386e7bfbdc37363ab489e9ce3264f4ccd23c33dd8f2337fb9007a621cabf740aa26e522dcb7af6c0de9f93cbc69595b29b02e75c2f3507e97664ec"
4838
- ],
4839
- non_residues: [
4840
- "0000000000000000000000000000000000000000000000000000000000000005",
4841
- "0000000000000000000000000000000000000000000000000000000000000007",
4842
- "000000000000000000000000000000000000000000000000000000000000000a"
6206
+ fee
6207
+ );
6208
+ }
6209
+ async saasGrantToVoter({
6210
+ signer,
6211
+ baseAmount,
6212
+ contractAddress,
6213
+ grantee,
6214
+ gasStation = false,
6215
+ fee = 1.8
6216
+ }) {
6217
+ const client = await createSaasClientBy({
6218
+ rpcEndpoint: this.rpcEndpoint,
6219
+ wallet: signer,
6220
+ contractAddress: this.saasAddress
6221
+ });
6222
+ if (gasStation && typeof fee !== "object") {
6223
+ const [{ address }] = await signer.getAccounts();
6224
+ const contractClient = await this.contractClient({ signer });
6225
+ const msg = {
6226
+ grant_to_voter: {
6227
+ base_amount: baseAmount,
6228
+ contract_addr: contractAddress,
6229
+ grantee
6230
+ }
6231
+ };
6232
+ const gasEstimation = await contractClient.simulate(
6233
+ address,
6234
+ [
6235
+ {
6236
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6237
+ value: {
6238
+ sender: address,
6239
+ contract: this.saasAddress,
6240
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6241
+ }
6242
+ }
4843
6243
  ],
4844
- g2_elements: [
4845
- "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4846
- "260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
4847
- ]
4848
- }
6244
+ ""
6245
+ );
6246
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6247
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6248
+ const calculatedFee = calculateFee(
6249
+ Math.round(gasEstimation * multiplier),
6250
+ gasPrice
6251
+ );
6252
+ const grantFee = {
6253
+ amount: calculatedFee.amount,
6254
+ gas: calculatedFee.gas,
6255
+ granter: this.saasAddress
6256
+ };
6257
+ return client.grantToVoter(
6258
+ {
6259
+ baseAmount,
6260
+ contractAddr: contractAddress,
6261
+ grantee
6262
+ },
6263
+ grantFee
6264
+ );
6265
+ } else if (gasStation && typeof fee === "object") {
6266
+ const grantFee = {
6267
+ ...fee,
6268
+ granter: this.saasAddress
6269
+ };
6270
+ return client.grantToVoter(
6271
+ {
6272
+ baseAmount,
6273
+ contractAddr: contractAddress,
6274
+ grantee
6275
+ },
6276
+ grantFee
6277
+ );
4849
6278
  }
4850
- },
4851
- "9-4-3-625": {
4852
- parameter: {
4853
- state_tree_depth: "9",
4854
- int_state_tree_depth: "4",
4855
- message_batch_size: "625",
4856
- vote_option_tree_depth: "3"
4857
- },
4858
- groth16: {
4859
- process_1p1v_vkey: {
4860
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4861
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4862
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4863
- vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4864
- vk_ic0: "1195be678487bbc8c0ae726c0985a5caf6f75e3f8327926926c4f89e498ad733043e46e10b506d194b27275f402bc3fb208a2f5be69662e7c9898d1c0ece4f04",
4865
- vk_ic1: "10c34362189a7ee44b1c5e57755d7e0d672dba552e614d5cd9a53081bee2333425879fa4e4a9e3fff287824cce35f94725ca0edb60a4ffcbf50becb2fd96cb0b"
4866
- },
4867
- tally_1p1v_vkey: {
4868
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4869
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4870
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4871
- vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4872
- vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
4873
- vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
4874
- },
4875
- process_qv_vkey: {
4876
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4877
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4878
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4879
- vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4880
- vk_ic0: "1832600210a459fe61d971081d4baa1a1add23f87c8a8dc4042cd5cf6c6fdf8e3018489aec30d9deb26629e05965a3a7e038be58ce10c854cb7e1071f2708aad",
4881
- vk_ic1: "0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6"
6279
+ return client.grantToVoter(
6280
+ {
6281
+ baseAmount,
6282
+ contractAddr: contractAddress,
6283
+ grantee
4882
6284
  },
4883
- tally_qv_vkey: {
4884
- vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
4885
- vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
4886
- vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4887
- vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
4888
- vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
4889
- vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
4890
- }
4891
- }
6285
+ fee
6286
+ );
4892
6287
  }
4893
- };
4894
- var QTR_LIB = {
4895
- zeros: [
4896
- "0",
4897
- "14655542659562014735865511769057053982292279840403315552050801315682099828156",
4898
- "19261153649140605024552417994922546473530072875902678653210025980873274131905",
4899
- "21526503558325068664033192388586640128492121680588893182274749683522508994597",
4900
- "20017764101928005973906869479218555869286328459998999367935018992260318153770",
4901
- "16998355316577652097112514691750893516081130026395813155204269482715045879598",
4902
- "2612442706402737973181840577010736087708621987282725873936541279764292204086",
4903
- "17716535433480122581515618850811568065658392066947958324371350481921422579201",
4904
- "17437916409890180001398333108882255895598851862997171508841759030332444017770"
4905
- ]
4906
- };
4907
-
4908
- // src/libs/contract/utils.ts
4909
- function getContractParams(type, circuitType, proofSystem, maxVoter, maxOption) {
4910
- let parameters;
4911
- let groth16ProcessVkey = null;
4912
- let groth16TallyVkey = null;
4913
- let plonkProcessVkey = null;
4914
- let plonkTallyVkey = null;
4915
- let maciVoteType = null;
4916
- let maciCertSystem = null;
4917
- switch (circuitType) {
4918
- case "0" /* IP1V */:
4919
- maciVoteType = "0";
4920
- break;
4921
- case "1" /* QV */:
4922
- maciVoteType = "1";
4923
- break;
4924
- default:
4925
- throw new Error(
4926
- `Invalid circuit type ${circuitType}, only support 1P1V and QV`
6288
+ async addSaasOperator({
6289
+ signer,
6290
+ operator,
6291
+ gasStation = false,
6292
+ fee = 1.8
6293
+ }) {
6294
+ const client = await createSaasClientBy({
6295
+ rpcEndpoint: this.rpcEndpoint,
6296
+ wallet: signer,
6297
+ contractAddress: this.saasAddress
6298
+ });
6299
+ if (gasStation && typeof fee !== "object") {
6300
+ const [{ address }] = await signer.getAccounts();
6301
+ const contractClient = await this.contractClient({ signer });
6302
+ const msg = {
6303
+ add_operator: {
6304
+ operator
6305
+ }
6306
+ };
6307
+ const gasEstimation = await contractClient.simulate(
6308
+ address,
6309
+ [
6310
+ {
6311
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6312
+ value: {
6313
+ sender: address,
6314
+ contract: this.saasAddress,
6315
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6316
+ }
6317
+ }
6318
+ ],
6319
+ ""
4927
6320
  );
4928
- }
4929
- switch (proofSystem) {
4930
- case "groth16" /* GROTH16 */:
4931
- maciCertSystem = "0";
4932
- break;
4933
- case "plonk" /* PLONK */:
4934
- maciCertSystem = "1";
4935
- break;
4936
- default:
4937
- throw new Error(
4938
- `Invalid proof system ${proofSystem}, only support GROTH16 and PLONK`
6321
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6322
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6323
+ const calculatedFee = calculateFee(
6324
+ Math.round(gasEstimation * multiplier),
6325
+ gasPrice
4939
6326
  );
4940
- }
4941
- if (maxVoter <= 25 && maxOption <= 5) {
4942
- parameters = CIRCUIT_INFO["2-1-1-5"].parameter;
4943
- if (proofSystem === "groth16" /* GROTH16 */) {
4944
- groth16ProcessVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].process_vkey;
4945
- groth16TallyVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].tally_vkey;
4946
- } else if (proofSystem === "plonk" /* PLONK */) {
4947
- plonkProcessVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.process_vkey;
4948
- plonkTallyVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.tally_vkey;
4949
- }
4950
- } else if (maxVoter <= 625 && maxOption <= 25) {
4951
- parameters = CIRCUIT_INFO["4-2-2-25"].parameter;
4952
- if (proofSystem === "groth16" /* GROTH16 */) {
4953
- groth16ProcessVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].process_vkey;
4954
- groth16TallyVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].tally_vkey;
4955
- } else if (proofSystem === "plonk" /* PLONK */) {
4956
- plonkProcessVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.process_vkey;
4957
- plonkTallyVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.tally_vkey;
6327
+ const grantFee = {
6328
+ amount: calculatedFee.amount,
6329
+ gas: calculatedFee.gas,
6330
+ granter: this.saasAddress
6331
+ };
6332
+ return client.addOperator({ operator }, grantFee);
6333
+ } else if (gasStation && typeof fee === "object") {
6334
+ const grantFee = {
6335
+ ...fee,
6336
+ granter: this.saasAddress
6337
+ };
6338
+ return client.addOperator({ operator }, grantFee);
4958
6339
  }
4959
- } else if (maxVoter <= 15625 && maxOption <= 125) {
4960
- parameters = CIRCUIT_INFO["6-3-3-125"].parameter;
4961
- if (proofSystem === "groth16" /* GROTH16 */) {
4962
- groth16ProcessVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].process_vkey;
4963
- groth16TallyVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].tally_vkey;
4964
- } else if (proofSystem === "plonk" /* PLONK */) {
4965
- plonkProcessVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.process_vkey;
4966
- plonkTallyVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.tally_vkey;
6340
+ return client.addOperator({ operator }, fee);
6341
+ }
6342
+ async removeSaasOperator({
6343
+ signer,
6344
+ operator,
6345
+ gasStation = false,
6346
+ fee = 1.8
6347
+ }) {
6348
+ const client = await createSaasClientBy({
6349
+ rpcEndpoint: this.rpcEndpoint,
6350
+ wallet: signer,
6351
+ contractAddress: this.saasAddress
6352
+ });
6353
+ if (gasStation && typeof fee !== "object") {
6354
+ const [{ address }] = await signer.getAccounts();
6355
+ const contractClient = await this.contractClient({ signer });
6356
+ const msg = {
6357
+ remove_operator: {
6358
+ operator
6359
+ }
6360
+ };
6361
+ const gasEstimation = await contractClient.simulate(
6362
+ address,
6363
+ [
6364
+ {
6365
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6366
+ value: {
6367
+ sender: address,
6368
+ contract: this.saasAddress,
6369
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6370
+ }
6371
+ }
6372
+ ],
6373
+ ""
6374
+ );
6375
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6376
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6377
+ const calculatedFee = calculateFee(
6378
+ Math.round(gasEstimation * multiplier),
6379
+ gasPrice
6380
+ );
6381
+ const grantFee = {
6382
+ amount: calculatedFee.amount,
6383
+ gas: calculatedFee.gas,
6384
+ granter: this.saasAddress
6385
+ };
6386
+ return client.removeOperator({ operator }, grantFee);
6387
+ } else if (gasStation && typeof fee === "object") {
6388
+ const grantFee = {
6389
+ ...fee,
6390
+ granter: this.saasAddress
6391
+ };
6392
+ return client.removeOperator({ operator }, grantFee);
4967
6393
  }
4968
- } else if (maxVoter <= 1953125 && maxOption <= 125) {
4969
- parameters = CIRCUIT_INFO["9-4-3-625"].parameter;
4970
- if (proofSystem === "groth16" /* GROTH16 */) {
4971
- if (circuitType === "0" /* IP1V */) {
4972
- groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
4973
- groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
4974
- } else if (circuitType === "1" /* QV */) {
4975
- groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
4976
- groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
6394
+ return client.removeOperator({ operator }, fee);
6395
+ }
6396
+ async isSaasOperator({
6397
+ signer,
6398
+ operator
6399
+ }) {
6400
+ const client = await createSaasClientBy({
6401
+ rpcEndpoint: this.rpcEndpoint,
6402
+ wallet: signer,
6403
+ contractAddress: this.saasAddress
6404
+ });
6405
+ return client.isOperator({ address: operator });
6406
+ }
6407
+ async depositSaas({
6408
+ signer,
6409
+ amount,
6410
+ gasStation = false,
6411
+ fee = 1.8
6412
+ }) {
6413
+ const client = await createSaasClientBy({
6414
+ rpcEndpoint: this.rpcEndpoint,
6415
+ wallet: signer,
6416
+ contractAddress: this.saasAddress
6417
+ });
6418
+ const funds = [
6419
+ {
6420
+ denom: "peaka",
6421
+ amount
4977
6422
  }
4978
- } else if (proofSystem === "plonk" /* PLONK */) {
4979
- throw new Error("PLONK is not supported for MACI-9");
6423
+ ];
6424
+ if (gasStation && typeof fee !== "object") {
6425
+ const [{ address }] = await signer.getAccounts();
6426
+ const contractClient = await this.contractClient({ signer });
6427
+ const msg = {
6428
+ deposit: {}
6429
+ };
6430
+ const gasEstimation = await contractClient.simulate(
6431
+ address,
6432
+ [
6433
+ {
6434
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6435
+ value: {
6436
+ sender: address,
6437
+ contract: this.saasAddress,
6438
+ msg: new TextEncoder().encode(JSON.stringify(msg)),
6439
+ funds
6440
+ }
6441
+ }
6442
+ ],
6443
+ ""
6444
+ );
6445
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6446
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6447
+ const calculatedFee = calculateFee(
6448
+ Math.round(gasEstimation * multiplier),
6449
+ gasPrice
6450
+ );
6451
+ const grantFee = {
6452
+ amount: calculatedFee.amount,
6453
+ gas: calculatedFee.gas,
6454
+ granter: this.saasAddress
6455
+ };
6456
+ return client.deposit(grantFee, void 0, funds);
6457
+ } else if (gasStation && typeof fee === "object") {
6458
+ const grantFee = {
6459
+ ...fee,
6460
+ granter: this.saasAddress
6461
+ };
6462
+ return client.deposit(grantFee, void 0, funds);
4980
6463
  }
4981
- } else {
4982
- throw new Error("Number of voters or options is too large.");
6464
+ return client.deposit(fee, void 0, funds);
4983
6465
  }
4984
- switch (type) {
4985
- case "0" /* MACI */:
4986
- return {
4987
- parameters,
4988
- groth16ProcessVkey,
4989
- groth16TallyVkey,
4990
- plonkProcessVkey,
4991
- plonkTallyVkey,
4992
- maciVoteType,
4993
- maciCertSystem
6466
+ async withdrawSaas({
6467
+ signer,
6468
+ amount,
6469
+ gasStation = false,
6470
+ fee = 1.8
6471
+ }) {
6472
+ const client = await createSaasClientBy({
6473
+ rpcEndpoint: this.rpcEndpoint,
6474
+ wallet: signer,
6475
+ contractAddress: this.saasAddress
6476
+ });
6477
+ if (gasStation && typeof fee !== "object") {
6478
+ const [{ address }] = await signer.getAccounts();
6479
+ const contractClient = await this.contractClient({ signer });
6480
+ const msg = {
6481
+ withdraw: {
6482
+ amount
6483
+ }
4994
6484
  };
4995
- case "1" /* AMACI */:
4996
- return {
4997
- // parameters,
4998
- // groth16ProcessVkey,
4999
- // groth16TallyVkey,
5000
- // plonkProcessVkey,
5001
- // plonkTallyVkey,
6485
+ const gasEstimation = await contractClient.simulate(
6486
+ address,
6487
+ [
6488
+ {
6489
+ typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
6490
+ value: {
6491
+ sender: address,
6492
+ contract: this.saasAddress,
6493
+ msg: new TextEncoder().encode(JSON.stringify(msg))
6494
+ }
6495
+ }
6496
+ ],
6497
+ ""
6498
+ );
6499
+ const multiplier = typeof fee === "number" ? fee : 1.8;
6500
+ const gasPrice = GasPrice2.fromString("10000000000peaka");
6501
+ const calculatedFee = calculateFee(
6502
+ Math.round(gasEstimation * multiplier),
6503
+ gasPrice
6504
+ );
6505
+ const grantFee = {
6506
+ amount: calculatedFee.amount,
6507
+ gas: calculatedFee.gas,
6508
+ granter: this.saasAddress
5002
6509
  };
5003
- case "2" /* ORACLE_MACI */:
5004
- if (circuitType === "0" /* IP1V */) {
5005
- groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
5006
- groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
5007
- } else if (circuitType === "1" /* QV */) {
5008
- groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
5009
- groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
5010
- }
5011
- return {
5012
- parameters: CIRCUIT_INFO["9-4-3-625"].parameter,
5013
- groth16ProcessVkey,
5014
- groth16TallyVkey,
5015
- plonkProcessVkey: null,
5016
- plonkTallyVkey: null,
5017
- maciVoteType,
5018
- maciCertSystem: "0"
6510
+ return client.withdraw({ amount }, grantFee);
6511
+ } else if (gasStation && typeof fee === "object") {
6512
+ const grantFee = {
6513
+ ...fee,
6514
+ granter: this.saasAddress
5019
6515
  };
5020
- }
5021
- }
5022
- function getAMaciRoundCircuitFee(network, maxVoter, maxOption) {
5023
- let requiredFee = {
5024
- denom: "peaka",
5025
- amount: "0"
5026
- };
5027
- if (maxVoter <= 25 && maxOption <= 5) {
5028
- if (network === "mainnet") {
5029
- requiredFee.amount = "20000000000000000000";
5030
- } else {
5031
- requiredFee.amount = "20000000000000000000";
5032
- }
5033
- } else if (maxVoter <= 625 && maxOption <= 25) {
5034
- if (network === "mainnet") {
5035
- requiredFee.amount = "750000000000000000000";
5036
- } else {
5037
- requiredFee.amount = "750000000000000000000";
6516
+ return client.withdraw({ amount }, grantFee);
5038
6517
  }
5039
- } else {
5040
- throw new Error("Number of voters or options is too large.");
6518
+ return client.withdraw({ amount }, fee);
5041
6519
  }
5042
- return requiredFee;
5043
- }
5044
-
5045
- // src/libs/contract/contract.ts
5046
- import { GasPrice as GasPrice2, calculateFee } from "@cosmjs/stargate";
5047
- var Contract = class {
5048
- constructor({
5049
- network,
5050
- rpcEndpoint,
5051
- registryAddress,
5052
- saasAddress,
5053
- maciCodeId,
5054
- oracleCodeId,
5055
- saasOracleCodeId,
5056
- feegrantOperator,
5057
- whitelistBackendPubkey
6520
+ async queryRoundInfo({
6521
+ signer,
6522
+ roundAddress
5058
6523
  }) {
5059
- this.network = network;
5060
- this.rpcEndpoint = rpcEndpoint;
5061
- this.registryAddress = registryAddress;
5062
- this.saasAddress = saasAddress;
5063
- this.maciCodeId = maciCodeId;
5064
- this.oracleCodeId = oracleCodeId;
5065
- this.saasOracleCodeId = saasOracleCodeId;
5066
- this.feegrantOperator = feegrantOperator;
5067
- this.whitelistBackendPubkey = whitelistBackendPubkey;
6524
+ const client = await createMaciClientBy({
6525
+ rpcEndpoint: this.rpcEndpoint,
6526
+ wallet: signer,
6527
+ contractAddress: roundAddress
6528
+ });
6529
+ const roundInfo = await client.getRoundInfo();
6530
+ return roundInfo;
5068
6531
  }
5069
- async createAMaciRound({
6532
+ async oracleMaciClient({
5070
6533
  signer,
5071
- startVoting,
5072
- endVoting,
5073
- operator,
5074
- whitelist,
5075
- title,
5076
- description,
5077
- link,
5078
- maxVoter,
5079
- maxOption,
5080
- voiceCreditAmount,
5081
- circuitType,
5082
- preDeactivateRoot,
5083
- fee = "auto"
6534
+ contractAddress
5084
6535
  }) {
5085
- const start_time = (startVoting.getTime() * 10 ** 6).toString();
5086
- const end_time = (endVoting.getTime() * 10 ** 6).toString();
5087
- const client = await createRegistryClientBy({
6536
+ const client = await createOracleMaciClientBy({
5088
6537
  rpcEndpoint: this.rpcEndpoint,
5089
6538
  wallet: signer,
5090
- contractAddress: this.registryAddress
6539
+ contractAddress
5091
6540
  });
5092
- const requiredFee = getAMaciRoundCircuitFee(
5093
- this.network,
5094
- maxVoter,
5095
- maxOption
5096
- );
5097
- preDeactivateRoot = preDeactivateRoot || "0";
5098
- const res = await client.createRound(
5099
- {
5100
- operator,
5101
- preDeactivateRoot,
5102
- voiceCreditAmount,
5103
- whitelist,
5104
- roundInfo: {
5105
- title,
5106
- description: description || "",
5107
- link: link || ""
5108
- },
5109
- votingTime: {
5110
- start_time,
5111
- end_time
5112
- },
5113
- maxVoter: maxVoter.toString(),
5114
- maxOption: maxOption.toString(),
5115
- certificationSystem: "0",
5116
- circuitType
5117
- },
5118
- fee,
5119
- void 0,
5120
- [requiredFee]
5121
- );
5122
- let contractAddress = "";
5123
- res.events.map((event) => {
5124
- if (event.type === "wasm") {
5125
- let actionEvent = event.attributes.find(
5126
- (attr) => attr.key === "action"
5127
- );
5128
- if (actionEvent.value === "created_round") {
5129
- contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
5130
- }
5131
- }
6541
+ return client;
6542
+ }
6543
+ async registryClient({
6544
+ signer,
6545
+ contractAddress
6546
+ }) {
6547
+ return createRegistryClientBy({
6548
+ rpcEndpoint: this.rpcEndpoint,
6549
+ wallet: signer,
6550
+ contractAddress
5132
6551
  });
5133
- return {
5134
- ...res,
6552
+ }
6553
+ async maciClient({
6554
+ signer,
6555
+ contractAddress
6556
+ }) {
6557
+ return createMaciClientBy({
6558
+ rpcEndpoint: this.rpcEndpoint,
6559
+ wallet: signer,
5135
6560
  contractAddress
5136
- };
6561
+ });
5137
6562
  }
5138
- async createMaciRound({
6563
+ async amaciClient({
5139
6564
  signer,
5140
- operatorPubkey,
5141
- startVoting,
5142
- endVoting,
5143
- whitelist,
5144
- title,
5145
- description,
5146
- link,
5147
- maxVoter,
5148
- maxOption,
5149
- circuitType,
5150
- certSystemType,
5151
- fee = "auto"
6565
+ contractAddress
5152
6566
  }) {
5153
- const start_time = (startVoting.getTime() * 10 ** 6).toString();
5154
- const end_time = (endVoting.getTime() * 10 ** 6).toString();
5155
- const [{ address }] = await signer.getAccounts();
5156
- const client = await createContractClientByWallet(this.rpcEndpoint, signer);
5157
- const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5158
- BigInt(operatorPubkey)
5159
- );
5160
- const {
5161
- parameters,
5162
- groth16ProcessVkey,
5163
- groth16TallyVkey,
5164
- plonkProcessVkey,
5165
- plonkTallyVkey,
5166
- maciVoteType,
5167
- maciCertSystem
5168
- } = getContractParams(
5169
- "0" /* MACI */,
5170
- circuitType,
5171
- certSystemType,
5172
- maxVoter,
5173
- maxOption
5174
- );
5175
- const instantiateResponse = await client.instantiate(
5176
- address,
5177
- this.maciCodeId,
5178
- {
5179
- round_info: { title, description: description || "", link: link || "" },
5180
- voting_time: {
5181
- start_time,
5182
- end_time
5183
- },
5184
- parameters,
5185
- coordinator: {
5186
- x: operatorPubkeyX.toString(),
5187
- y: operatorPubkeyY.toString()
5188
- },
5189
- groth16_process_vkey: groth16ProcessVkey,
5190
- groth16_tally_vkey: groth16TallyVkey,
5191
- plonk_process_vkey: plonkProcessVkey,
5192
- plonk_tally_vkey: plonkTallyVkey,
5193
- max_vote_options: maxOption.toString(),
5194
- whitelist,
5195
- circuit_type: maciVoteType,
5196
- certification_system: maciCertSystem,
5197
- qtr_lib: QTR_LIB
5198
- },
5199
- `[MACI] ${title}`,
5200
- fee
5201
- );
5202
- return instantiateResponse;
6567
+ return createAMaciClientBy({
6568
+ rpcEndpoint: this.rpcEndpoint,
6569
+ wallet: signer,
6570
+ contractAddress
6571
+ });
5203
6572
  }
5204
- async createOracleMaciRound({
6573
+ async apiMaciClient({
5205
6574
  signer,
5206
- operatorPubkey,
5207
- startVoting,
5208
- endVoting,
5209
- title,
5210
- description,
5211
- link,
5212
- voteOptionMap,
5213
- circuitType,
5214
- whitelistEcosystem,
5215
- whitelistSnapshotHeight,
5216
- whitelistVotingPowerArgs,
5217
- fee = "auto"
6575
+ contractAddress
6576
+ }) {
6577
+ return createApiMaciClientBy({
6578
+ rpcEndpoint: this.rpcEndpoint,
6579
+ wallet: signer,
6580
+ contractAddress
6581
+ });
6582
+ }
6583
+ async saasClient({
6584
+ signer,
6585
+ contractAddress
6586
+ }) {
6587
+ return createSaasClientBy({
6588
+ rpcEndpoint: this.rpcEndpoint,
6589
+ wallet: signer,
6590
+ contractAddress
6591
+ });
6592
+ }
6593
+ async apiSaasClient({
6594
+ signer,
6595
+ contractAddress
5218
6596
  }) {
5219
- const start_time = (startVoting.getTime() * 1e6).toString();
5220
- const end_time = (endVoting.getTime() * 1e6).toString();
5221
- const [{ address }] = await signer.getAccounts();
5222
- const client = await createContractClientByWallet(this.rpcEndpoint, signer);
5223
- const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5224
- BigInt(operatorPubkey)
5225
- );
5226
- const { maciVoteType, maciCertSystem } = getContractParams(
5227
- "2" /* ORACLE_MACI */,
5228
- circuitType,
5229
- "groth16" /* GROTH16 */,
5230
- 0,
5231
- 0
5232
- );
5233
- const instantiateResponse = await client.instantiate(
5234
- address,
5235
- this.oracleCodeId,
5236
- {
5237
- round_info: { title, description: description || "", link: link || "" },
5238
- voting_time: {
5239
- start_time,
5240
- end_time
5241
- },
5242
- coordinator: {
5243
- x: operatorPubkeyX.toString(),
5244
- y: operatorPubkeyY.toString()
5245
- },
5246
- vote_option_map: voteOptionMap,
5247
- whitelist_backend_pubkey: this.whitelistBackendPubkey,
5248
- whitelist_ecosystem: whitelistEcosystem,
5249
- whitelist_snapshot_height: whitelistSnapshotHeight,
5250
- whitelist_voting_power_args: whitelistVotingPowerArgs,
5251
- circuit_type: maciVoteType,
5252
- certification_system: maciCertSystem,
5253
- feegrant_operator: this.feegrantOperator
5254
- },
5255
- `[Oracle MACI] ${title}`,
5256
- fee
5257
- );
5258
- return instantiateResponse;
6597
+ return createApiSaasClientBy({
6598
+ rpcEndpoint: this.rpcEndpoint,
6599
+ wallet: signer,
6600
+ contractAddress
6601
+ });
5259
6602
  }
5260
- async createSaasOracleMaciRound({
6603
+ async contractClient({ signer }) {
6604
+ return createContractClientByWallet(this.rpcEndpoint, signer);
6605
+ }
6606
+ async createApiSaasMaciRound({
5261
6607
  signer,
5262
6608
  operatorPubkey,
5263
6609
  startVoting,
@@ -5273,10 +6619,10 @@ var Contract = class {
5273
6619
  }) {
5274
6620
  const startTime = (startVoting.getTime() * 1e6).toString();
5275
6621
  const endTime = (endVoting.getTime() * 1e6).toString();
5276
- const client = await createSaasClientBy({
6622
+ const client = await createApiSaasClientBy({
5277
6623
  rpcEndpoint: this.rpcEndpoint,
5278
6624
  wallet: signer,
5279
- contractAddress: this.saasAddress
6625
+ contractAddress: this.apiSaasAddress
5280
6626
  });
5281
6627
  const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
5282
6628
  BigInt(operatorPubkey)
@@ -5304,7 +6650,7 @@ var Contract = class {
5304
6650
  const [{ address }] = await signer.getAccounts();
5305
6651
  const contractClient = await this.contractClient({ signer });
5306
6652
  const msg = {
5307
- create_oracle_maci_round: {
6653
+ create_api_maci_round: {
5308
6654
  certification_system: "0",
5309
6655
  circuit_type: "0",
5310
6656
  coordinator: roundParams.coordinator,
@@ -5323,7 +6669,7 @@ var Contract = class {
5323
6669
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5324
6670
  value: {
5325
6671
  sender: address,
5326
- contract: this.saasAddress,
6672
+ contract: this.apiSaasAddress,
5327
6673
  msg: new TextEncoder().encode(JSON.stringify(msg))
5328
6674
  }
5329
6675
  }
@@ -5339,23 +6685,17 @@ var Contract = class {
5339
6685
  const grantFee = {
5340
6686
  amount: calculatedFee.amount,
5341
6687
  gas: calculatedFee.gas,
5342
- granter: this.saasAddress
6688
+ granter: this.apiSaasAddress
5343
6689
  };
5344
- createResponse = await client.createOracleMaciRound(
5345
- roundParams,
5346
- grantFee
5347
- );
6690
+ createResponse = await client.createMaciRound(roundParams, grantFee);
5348
6691
  } else if (gasStation && typeof fee === "object") {
5349
6692
  const grantFee = {
5350
6693
  ...fee,
5351
- granter: this.saasAddress
6694
+ granter: this.apiSaasAddress
5352
6695
  };
5353
- createResponse = await client.createOracleMaciRound(
5354
- roundParams,
5355
- grantFee
5356
- );
6696
+ createResponse = await client.createMaciRound(roundParams, grantFee);
5357
6697
  } else {
5358
- createResponse = await client.createOracleMaciRound(roundParams, fee);
6698
+ createResponse = await client.createMaciRound(roundParams, fee);
5359
6699
  }
5360
6700
  let contractAddress = "";
5361
6701
  createResponse.events.map((event) => {
@@ -5363,7 +6703,7 @@ var Contract = class {
5363
6703
  let actionEvent = event.attributes.find(
5364
6704
  (attr) => attr.key === "action"
5365
6705
  );
5366
- if (actionEvent.value === "created_oracle_maci_round") {
6706
+ if (actionEvent.value === "created_maci_round") {
5367
6707
  contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
5368
6708
  }
5369
6709
  }
@@ -5373,7 +6713,7 @@ var Contract = class {
5373
6713
  contractAddress
5374
6714
  };
5375
6715
  }
5376
- async setSaasOracleMaciRoundInfo({
6716
+ async setApiSaasMaciRoundInfo({
5377
6717
  signer,
5378
6718
  contractAddress,
5379
6719
  title,
@@ -5382,10 +6722,10 @@ var Contract = class {
5382
6722
  gasStation = false,
5383
6723
  fee = 1.8
5384
6724
  }) {
5385
- const client = await createSaasClientBy({
6725
+ const client = await createApiSaasClientBy({
5386
6726
  rpcEndpoint: this.rpcEndpoint,
5387
6727
  wallet: signer,
5388
- contractAddress: this.saasAddress
6728
+ contractAddress: this.apiSaasAddress
5389
6729
  });
5390
6730
  const roundInfo = {
5391
6731
  title,
@@ -5408,7 +6748,7 @@ var Contract = class {
5408
6748
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5409
6749
  value: {
5410
6750
  sender: address,
5411
- contract: this.saasAddress,
6751
+ contract: this.apiSaasAddress,
5412
6752
  msg: new TextEncoder().encode(JSON.stringify(msg))
5413
6753
  }
5414
6754
  }
@@ -5424,7 +6764,7 @@ var Contract = class {
5424
6764
  const grantFee = {
5425
6765
  amount: calculatedFee.amount,
5426
6766
  gas: calculatedFee.gas,
5427
- granter: this.saasAddress
6767
+ granter: this.apiSaasAddress
5428
6768
  };
5429
6769
  return client.setRoundInfo(
5430
6770
  {
@@ -5436,7 +6776,7 @@ var Contract = class {
5436
6776
  } else if (gasStation && typeof fee === "object") {
5437
6777
  const grantFee = {
5438
6778
  ...fee,
5439
- granter: this.saasAddress
6779
+ granter: this.apiSaasAddress
5440
6780
  };
5441
6781
  return client.setRoundInfo(
5442
6782
  {
@@ -5454,17 +6794,17 @@ var Contract = class {
5454
6794
  fee
5455
6795
  );
5456
6796
  }
5457
- async setSaasOracleMaciRoundVoteOptions({
6797
+ async setApiSaasMaciRoundVoteOptions({
5458
6798
  signer,
5459
6799
  contractAddress,
5460
6800
  voteOptionMap,
5461
6801
  gasStation = false,
5462
6802
  fee = 1.8
5463
6803
  }) {
5464
- const client = await createSaasClientBy({
6804
+ const client = await createApiSaasClientBy({
5465
6805
  rpcEndpoint: this.rpcEndpoint,
5466
6806
  wallet: signer,
5467
- contractAddress: this.saasAddress
6807
+ contractAddress: this.apiSaasAddress
5468
6808
  });
5469
6809
  if (gasStation && typeof fee !== "object") {
5470
6810
  const [{ address }] = await signer.getAccounts();
@@ -5482,7 +6822,7 @@ var Contract = class {
5482
6822
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5483
6823
  value: {
5484
6824
  sender: address,
5485
- contract: this.saasAddress,
6825
+ contract: this.apiSaasAddress,
5486
6826
  msg: new TextEncoder().encode(JSON.stringify(msg))
5487
6827
  }
5488
6828
  }
@@ -5498,7 +6838,7 @@ var Contract = class {
5498
6838
  const grantFee = {
5499
6839
  amount: calculatedFee.amount,
5500
6840
  gas: calculatedFee.gas,
5501
- granter: this.saasAddress
6841
+ granter: this.apiSaasAddress
5502
6842
  };
5503
6843
  return client.setVoteOptionsMap(
5504
6844
  {
@@ -5510,7 +6850,7 @@ var Contract = class {
5510
6850
  } else if (gasStation && typeof fee === "object") {
5511
6851
  const grantFee = {
5512
6852
  ...fee,
5513
- granter: this.saasAddress
6853
+ granter: this.apiSaasAddress
5514
6854
  };
5515
6855
  return client.setVoteOptionsMap(
5516
6856
  {
@@ -5528,95 +6868,16 @@ var Contract = class {
5528
6868
  fee
5529
6869
  );
5530
6870
  }
5531
- async saasGrantToVoter({
5532
- signer,
5533
- baseAmount,
5534
- contractAddress,
5535
- grantee,
5536
- gasStation = false,
5537
- fee = 1.8
5538
- }) {
5539
- const client = await createSaasClientBy({
5540
- rpcEndpoint: this.rpcEndpoint,
5541
- wallet: signer,
5542
- contractAddress: this.saasAddress
5543
- });
5544
- if (gasStation && typeof fee !== "object") {
5545
- const [{ address }] = await signer.getAccounts();
5546
- const contractClient = await this.contractClient({ signer });
5547
- const msg = {
5548
- grant_to_voter: {
5549
- base_amount: baseAmount,
5550
- contract_addr: contractAddress,
5551
- grantee
5552
- }
5553
- };
5554
- const gasEstimation = await contractClient.simulate(
5555
- address,
5556
- [
5557
- {
5558
- typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5559
- value: {
5560
- sender: address,
5561
- contract: this.saasAddress,
5562
- msg: new TextEncoder().encode(JSON.stringify(msg))
5563
- }
5564
- }
5565
- ],
5566
- ""
5567
- );
5568
- const multiplier = typeof fee === "number" ? fee : 1.8;
5569
- const gasPrice = GasPrice2.fromString("10000000000peaka");
5570
- const calculatedFee = calculateFee(
5571
- Math.round(gasEstimation * multiplier),
5572
- gasPrice
5573
- );
5574
- const grantFee = {
5575
- amount: calculatedFee.amount,
5576
- gas: calculatedFee.gas,
5577
- granter: this.saasAddress
5578
- };
5579
- return client.grantToVoter(
5580
- {
5581
- baseAmount,
5582
- contractAddr: contractAddress,
5583
- grantee
5584
- },
5585
- grantFee
5586
- );
5587
- } else if (gasStation && typeof fee === "object") {
5588
- const grantFee = {
5589
- ...fee,
5590
- granter: this.saasAddress
5591
- };
5592
- return client.grantToVoter(
5593
- {
5594
- baseAmount,
5595
- contractAddr: contractAddress,
5596
- grantee
5597
- },
5598
- grantFee
5599
- );
5600
- }
5601
- return client.grantToVoter(
5602
- {
5603
- baseAmount,
5604
- contractAddr: contractAddress,
5605
- grantee
5606
- },
5607
- fee
5608
- );
5609
- }
5610
- async addSaasOperator({
6871
+ async addApiSaasOperator({
5611
6872
  signer,
5612
6873
  operator,
5613
6874
  gasStation = false,
5614
6875
  fee = 1.8
5615
6876
  }) {
5616
- const client = await createSaasClientBy({
6877
+ const client = await createApiSaasClientBy({
5617
6878
  rpcEndpoint: this.rpcEndpoint,
5618
6879
  wallet: signer,
5619
- contractAddress: this.saasAddress
6880
+ contractAddress: this.apiSaasAddress
5620
6881
  });
5621
6882
  if (gasStation && typeof fee !== "object") {
5622
6883
  const [{ address }] = await signer.getAccounts();
@@ -5633,7 +6894,7 @@ var Contract = class {
5633
6894
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5634
6895
  value: {
5635
6896
  sender: address,
5636
- contract: this.saasAddress,
6897
+ contract: this.apiSaasAddress,
5637
6898
  msg: new TextEncoder().encode(JSON.stringify(msg))
5638
6899
  }
5639
6900
  }
@@ -5649,28 +6910,28 @@ var Contract = class {
5649
6910
  const grantFee = {
5650
6911
  amount: calculatedFee.amount,
5651
6912
  gas: calculatedFee.gas,
5652
- granter: this.saasAddress
6913
+ granter: this.apiSaasAddress
5653
6914
  };
5654
6915
  return client.addOperator({ operator }, grantFee);
5655
6916
  } else if (gasStation && typeof fee === "object") {
5656
6917
  const grantFee = {
5657
6918
  ...fee,
5658
- granter: this.saasAddress
6919
+ granter: this.apiSaasAddress
5659
6920
  };
5660
6921
  return client.addOperator({ operator }, grantFee);
5661
6922
  }
5662
6923
  return client.addOperator({ operator }, fee);
5663
6924
  }
5664
- async removeSaasOperator({
6925
+ async removeApiSaasOperator({
5665
6926
  signer,
5666
6927
  operator,
5667
6928
  gasStation = false,
5668
6929
  fee = 1.8
5669
6930
  }) {
5670
- const client = await createSaasClientBy({
6931
+ const client = await createApiSaasClientBy({
5671
6932
  rpcEndpoint: this.rpcEndpoint,
5672
6933
  wallet: signer,
5673
- contractAddress: this.saasAddress
6934
+ contractAddress: this.apiSaasAddress
5674
6935
  });
5675
6936
  if (gasStation && typeof fee !== "object") {
5676
6937
  const [{ address }] = await signer.getAccounts();
@@ -5687,7 +6948,7 @@ var Contract = class {
5687
6948
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5688
6949
  value: {
5689
6950
  sender: address,
5690
- contract: this.saasAddress,
6951
+ contract: this.apiSaasAddress,
5691
6952
  msg: new TextEncoder().encode(JSON.stringify(msg))
5692
6953
  }
5693
6954
  }
@@ -5703,105 +6964,91 @@ var Contract = class {
5703
6964
  const grantFee = {
5704
6965
  amount: calculatedFee.amount,
5705
6966
  gas: calculatedFee.gas,
5706
- granter: this.saasAddress
6967
+ granter: this.apiSaasAddress
5707
6968
  };
5708
6969
  return client.removeOperator({ operator }, grantFee);
5709
6970
  } else if (gasStation && typeof fee === "object") {
5710
6971
  const grantFee = {
5711
6972
  ...fee,
5712
- granter: this.saasAddress
6973
+ granter: this.apiSaasAddress
5713
6974
  };
5714
6975
  return client.removeOperator({ operator }, grantFee);
5715
6976
  }
5716
6977
  return client.removeOperator({ operator }, fee);
5717
6978
  }
5718
- async isSaasOperator({
6979
+ async isApiSaasOperator({
5719
6980
  signer,
5720
6981
  operator
5721
6982
  }) {
5722
- const client = await createSaasClientBy({
6983
+ const client = await createApiSaasClientBy({
5723
6984
  rpcEndpoint: this.rpcEndpoint,
5724
6985
  wallet: signer,
5725
- contractAddress: this.saasAddress
6986
+ contractAddress: this.apiSaasAddress
5726
6987
  });
5727
6988
  return client.isOperator({ address: operator });
5728
6989
  }
5729
- async depositSaas({
5730
- signer,
5731
- amount,
5732
- gasStation = false,
5733
- fee = 1.8
5734
- }) {
5735
- const client = await createSaasClientBy({
5736
- rpcEndpoint: this.rpcEndpoint,
5737
- wallet: signer,
5738
- contractAddress: this.saasAddress
5739
- });
5740
- const funds = [
5741
- {
5742
- denom: "peaka",
5743
- amount
5744
- }
5745
- ];
5746
- if (gasStation && typeof fee !== "object") {
5747
- const [{ address }] = await signer.getAccounts();
5748
- const contractClient = await this.contractClient({ signer });
5749
- const msg = {
5750
- deposit: {}
5751
- };
5752
- const gasEstimation = await contractClient.simulate(
5753
- address,
5754
- [
5755
- {
5756
- typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5757
- value: {
5758
- sender: address,
5759
- contract: this.saasAddress,
5760
- msg: new TextEncoder().encode(JSON.stringify(msg)),
5761
- funds
5762
- }
5763
- }
5764
- ],
5765
- ""
5766
- );
5767
- const multiplier = typeof fee === "number" ? fee : 1.8;
5768
- const gasPrice = GasPrice2.fromString("10000000000peaka");
5769
- const calculatedFee = calculateFee(
5770
- Math.round(gasEstimation * multiplier),
5771
- gasPrice
5772
- );
5773
- const grantFee = {
5774
- amount: calculatedFee.amount,
5775
- gas: calculatedFee.gas,
5776
- granter: this.saasAddress
5777
- };
5778
- return client.deposit(grantFee, void 0, funds);
5779
- } else if (gasStation && typeof fee === "object") {
5780
- const grantFee = {
5781
- ...fee,
5782
- granter: this.saasAddress
5783
- };
5784
- return client.deposit(grantFee, void 0, funds);
5785
- }
5786
- return client.deposit(fee, void 0, funds);
5787
- }
5788
- async withdrawSaas({
6990
+ async createApiSaasAmaciRound({
5789
6991
  signer,
5790
- amount,
6992
+ operator,
6993
+ startVoting,
6994
+ endVoting,
6995
+ title,
6996
+ description,
6997
+ link,
6998
+ maxVoter,
6999
+ voteOptionMap,
7000
+ whitelist,
7001
+ voiceCreditAmount,
7002
+ preDeactivateRoot,
7003
+ oracleWhitelistPubkey,
7004
+ circuitType,
5791
7005
  gasStation = false,
5792
7006
  fee = 1.8
5793
7007
  }) {
5794
- const client = await createSaasClientBy({
7008
+ const startTime = (startVoting.getTime() * 1e6).toString();
7009
+ const endTime = (endVoting.getTime() * 1e6).toString();
7010
+ const client = await createApiSaasClientBy({
5795
7011
  rpcEndpoint: this.rpcEndpoint,
5796
7012
  wallet: signer,
5797
- contractAddress: this.saasAddress
7013
+ contractAddress: this.apiSaasAddress
5798
7014
  });
7015
+ const roundParams = {
7016
+ certificationSystem: "0",
7017
+ circuitType: circuitType.toString(),
7018
+ maxVoter: maxVoter.toString(),
7019
+ operator,
7020
+ oracleWhitelistPubkey,
7021
+ preDeactivateRoot: preDeactivateRoot || "0",
7022
+ roundInfo: {
7023
+ title,
7024
+ description: description || "",
7025
+ link: link || ""
7026
+ },
7027
+ voiceCreditAmount,
7028
+ voteOptionMap,
7029
+ votingTime: {
7030
+ start_time: startTime,
7031
+ end_time: endTime
7032
+ },
7033
+ whitelist
7034
+ };
7035
+ let createResponse;
5799
7036
  if (gasStation && typeof fee !== "object") {
5800
7037
  const [{ address }] = await signer.getAccounts();
5801
7038
  const contractClient = await this.contractClient({ signer });
5802
7039
  const msg = {
5803
- withdraw: {
5804
- amount
7040
+ create_amaci_round: {
7041
+ certification_system: "0",
7042
+ circuit_type: circuitType.toString(),
7043
+ max_voter: maxVoter.toString(),
7044
+ operator,
7045
+ oracle_whitelist_pubkey: oracleWhitelistPubkey,
7046
+ pre_deactivate_root: preDeactivateRoot || "0",
7047
+ round_info: roundParams.roundInfo,
7048
+ voice_credit_amount: voiceCreditAmount,
7049
+ vote_option_map: voteOptionMap,
7050
+ voting_time: roundParams.votingTime,
7051
+ whitelist
5805
7052
  }
5806
7053
  };
5807
7054
  const gasEstimation = await contractClient.simulate(
@@ -5811,7 +7058,7 @@ var Contract = class {
5811
7058
  typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
5812
7059
  value: {
5813
7060
  sender: address,
5814
- contract: this.saasAddress,
7061
+ contract: this.apiSaasAddress,
5815
7062
  msg: new TextEncoder().encode(JSON.stringify(msg))
5816
7063
  }
5817
7064
  }
@@ -5827,83 +7074,38 @@ var Contract = class {
5827
7074
  const grantFee = {
5828
7075
  amount: calculatedFee.amount,
5829
7076
  gas: calculatedFee.gas,
5830
- granter: this.saasAddress
7077
+ granter: this.apiSaasAddress
5831
7078
  };
5832
- return client.withdraw({ amount }, grantFee);
7079
+ createResponse = await client.createAmaciRound(roundParams, grantFee);
5833
7080
  } else if (gasStation && typeof fee === "object") {
5834
7081
  const grantFee = {
5835
7082
  ...fee,
5836
- granter: this.saasAddress
7083
+ granter: this.apiSaasAddress
5837
7084
  };
5838
- return client.withdraw({ amount }, grantFee);
7085
+ createResponse = await client.createAmaciRound(roundParams, grantFee);
7086
+ } else {
7087
+ createResponse = await client.createAmaciRound(roundParams, fee);
5839
7088
  }
5840
- return client.withdraw({ amount }, fee);
5841
- }
5842
- async queryRoundInfo({
5843
- signer,
5844
- roundAddress
5845
- }) {
5846
- const client = await createMaciClientBy({
5847
- rpcEndpoint: this.rpcEndpoint,
5848
- wallet: signer,
5849
- contractAddress: roundAddress
5850
- });
5851
- const roundInfo = await client.getRoundInfo();
5852
- return roundInfo;
5853
- }
5854
- async oracleMaciClient({
5855
- signer,
5856
- contractAddress
5857
- }) {
5858
- const client = await createOracleMaciClientBy({
5859
- rpcEndpoint: this.rpcEndpoint,
5860
- wallet: signer,
5861
- contractAddress
5862
- });
5863
- return client;
5864
- }
5865
- async registryClient({
5866
- signer,
5867
- contractAddress
5868
- }) {
5869
- return createRegistryClientBy({
5870
- rpcEndpoint: this.rpcEndpoint,
5871
- wallet: signer,
5872
- contractAddress
5873
- });
5874
- }
5875
- async maciClient({
5876
- signer,
5877
- contractAddress
5878
- }) {
5879
- return createMaciClientBy({
5880
- rpcEndpoint: this.rpcEndpoint,
5881
- wallet: signer,
5882
- contractAddress
5883
- });
5884
- }
5885
- async amaciClient({
5886
- signer,
5887
- contractAddress
5888
- }) {
5889
- return createAMaciClientBy({
5890
- rpcEndpoint: this.rpcEndpoint,
5891
- wallet: signer,
5892
- contractAddress
7089
+ let contractAddress = "";
7090
+ createResponse.events.map((event) => {
7091
+ if (event.type === "wasm") {
7092
+ let actionEvent = event.attributes.find(
7093
+ (attr) => attr.key === "action"
7094
+ );
7095
+ if (actionEvent && actionEvent.value === "created_round") {
7096
+ const roundAddrEvent = event.attributes.find(
7097
+ (attr) => attr.key === "round_addr"
7098
+ );
7099
+ if (roundAddrEvent) {
7100
+ contractAddress = roundAddrEvent.value.toString();
7101
+ }
7102
+ }
7103
+ }
5893
7104
  });
5894
- }
5895
- async saasClient({
5896
- signer,
5897
- contractAddress
5898
- }) {
5899
- return createSaasClientBy({
5900
- rpcEndpoint: this.rpcEndpoint,
5901
- wallet: signer,
7105
+ return {
7106
+ ...createResponse,
5902
7107
  contractAddress
5903
- });
5904
- }
5905
- async contractClient({ signer }) {
5906
- return createContractClientByWallet(this.rpcEndpoint, signer);
7108
+ };
5907
7109
  }
5908
7110
  };
5909
7111
 
@@ -6286,13 +7488,16 @@ var MACI = class {
6286
7488
  const client = await this.contract.contractClient({
6287
7489
  signer
6288
7490
  });
6289
- if (oracleCertificate) {
7491
+ if (oracleCertificate && oracleCertificate.amount) {
6290
7492
  return await this.signupOracle({
6291
7493
  client,
6292
7494
  address,
6293
7495
  pubKey: maciKeypair.pubKey,
6294
7496
  contractAddress,
6295
- oracleCertificate,
7497
+ oracleCertificate: {
7498
+ amount: oracleCertificate.amount,
7499
+ signature: oracleCertificate.signature
7500
+ },
6296
7501
  gasStation,
6297
7502
  fee
6298
7503
  });
@@ -6302,7 +7507,55 @@ var MACI = class {
6302
7507
  address,
6303
7508
  pubKey: maciKeypair.pubKey,
6304
7509
  contractAddress,
7510
+ certificate: oracleCertificate?.signature,
7511
+ gasStation,
7512
+ fee
7513
+ });
7514
+ }
7515
+ } catch (error) {
7516
+ throw Error(`Signup failed! ${error}`);
7517
+ }
7518
+ }
7519
+ async rawSignup({
7520
+ signer,
7521
+ address,
7522
+ contractAddress,
7523
+ pubKey,
7524
+ oracleCertificate,
7525
+ gasStation = false,
7526
+ granter,
7527
+ fee
7528
+ }) {
7529
+ try {
7530
+ if (!address) {
7531
+ address = (await signer.getAccounts())[0].address;
7532
+ }
7533
+ const client = await this.contract.contractClient({
7534
+ signer
7535
+ });
7536
+ if (oracleCertificate && oracleCertificate.amount) {
7537
+ return await this.signupOracle({
7538
+ client,
7539
+ address,
7540
+ pubKey,
7541
+ contractAddress,
7542
+ oracleCertificate: {
7543
+ amount: oracleCertificate.amount,
7544
+ signature: oracleCertificate.signature
7545
+ },
7546
+ gasStation,
7547
+ granter,
7548
+ fee
7549
+ });
7550
+ } else {
7551
+ return await this.signupSimple({
7552
+ client,
7553
+ address,
7554
+ pubKey,
7555
+ contractAddress,
7556
+ certificate: oracleCertificate?.signature,
6305
7557
  gasStation,
7558
+ granter,
6306
7559
  fee
6307
7560
  });
6308
7561
  }
@@ -6428,12 +7681,93 @@ var MACI = class {
6428
7681
  throw Error(`Vote failed! ${error}`);
6429
7682
  }
6430
7683
  }
7684
+ async rawVote({
7685
+ signer,
7686
+ address,
7687
+ contractAddress,
7688
+ pubKey,
7689
+ payload,
7690
+ gasStation = false,
7691
+ granter,
7692
+ fee = 1.8
7693
+ }) {
7694
+ const stateIdx = await this.getStateIdxByPubKey({
7695
+ contractAddress,
7696
+ pubKey
7697
+ });
7698
+ if (stateIdx === -1) {
7699
+ throw new Error(
7700
+ "State index is not set, Please signup or addNewKey first"
7701
+ );
7702
+ }
7703
+ try {
7704
+ const round = await this.indexer.getRoundWithFields(contractAddress, [
7705
+ "maciType",
7706
+ "voiceCreditAmount"
7707
+ ]);
7708
+ if (isErrorResponse(round)) {
7709
+ throw new Error(
7710
+ `Failed to get round info: ${round.error.type} ${round.error.message}`
7711
+ );
7712
+ }
7713
+ let voiceCreditBalance;
7714
+ if (round.data.round.maciType === "aMACI") {
7715
+ const isWhiteListed = await this.isWhitelisted({
7716
+ signer,
7717
+ address,
7718
+ contractAddress
7719
+ });
7720
+ if (isWhiteListed) {
7721
+ const round2 = await this.indexer.getRoundWithFields(contractAddress, [
7722
+ "voiceCreditAmount"
7723
+ ]);
7724
+ if (!isErrorResponse(round2)) {
7725
+ if (round2.data.round.voiceCreditAmount) {
7726
+ voiceCreditBalance = round2.data.round.voiceCreditAmount;
7727
+ } else {
7728
+ voiceCreditBalance = "0";
7729
+ }
7730
+ } else {
7731
+ throw new Error(
7732
+ `Failed to query amaci voice credit: ${round2.error.type} ${round2.error.message}`
7733
+ );
7734
+ }
7735
+ } else {
7736
+ voiceCreditBalance = "0";
7737
+ }
7738
+ } else {
7739
+ voiceCreditBalance = await this.getVoiceCreditBalance({
7740
+ signer,
7741
+ stateIdx,
7742
+ contractAddress
7743
+ });
7744
+ }
7745
+ if (!address) {
7746
+ address = (await signer.getAccounts())[0].address;
7747
+ }
7748
+ const client = await this.contract.contractClient({
7749
+ signer
7750
+ });
7751
+ return await this.publishMessage({
7752
+ client,
7753
+ address,
7754
+ payload,
7755
+ contractAddress,
7756
+ gasStation,
7757
+ granter,
7758
+ fee
7759
+ });
7760
+ } catch (error) {
7761
+ throw Error(`Vote failed! ${error}`);
7762
+ }
7763
+ }
6431
7764
  async publishMessage({
6432
7765
  client,
6433
7766
  address,
6434
7767
  payload,
6435
7768
  contractAddress,
6436
7769
  gasStation,
7770
+ granter,
6437
7771
  fee = 1.8
6438
7772
  }) {
6439
7773
  const msgs = payload.map(
@@ -6471,13 +7805,13 @@ var MACI = class {
6471
7805
  const grantFee = {
6472
7806
  amount: calculatedFee.amount,
6473
7807
  gas: calculatedFee.gas,
6474
- granter: contractAddress
7808
+ granter: granter || contractAddress
6475
7809
  };
6476
7810
  return client.signAndBroadcast(address, msgs, grantFee);
6477
7811
  } else if (gasStation && typeof fee === "object") {
6478
7812
  const grantFee = {
6479
7813
  ...fee,
6480
- granter: contractAddress
7814
+ granter: granter || contractAddress
6481
7815
  };
6482
7816
  return client.signAndBroadcast(address, msgs, grantFee);
6483
7817
  }
@@ -6488,11 +7822,14 @@ var MACI = class {
6488
7822
  address,
6489
7823
  pubKey,
6490
7824
  contractAddress,
7825
+ certificate,
6491
7826
  gasStation,
7827
+ granter,
6492
7828
  fee = 1.8
6493
7829
  }) {
6494
7830
  const msg = {
6495
7831
  sign_up: {
7832
+ certificate,
6496
7833
  pubkey: {
6497
7834
  x: pubKey[0].toString(),
6498
7835
  y: pubKey[1].toString()
@@ -6523,13 +7860,13 @@ var MACI = class {
6523
7860
  const grantFee = {
6524
7861
  amount: calculatedFee.amount,
6525
7862
  gas: calculatedFee.gas,
6526
- granter: contractAddress
7863
+ granter: granter || contractAddress
6527
7864
  };
6528
7865
  return client.execute(address, contractAddress, msg, grantFee);
6529
7866
  } else if (gasStation === true && typeof fee === "object") {
6530
7867
  const grantFee = {
6531
7868
  ...fee,
6532
- granter: contractAddress
7869
+ granter: granter || contractAddress
6533
7870
  };
6534
7871
  return client.execute(address, contractAddress, msg, grantFee);
6535
7872
  }
@@ -6542,6 +7879,7 @@ var MACI = class {
6542
7879
  contractAddress,
6543
7880
  oracleCertificate,
6544
7881
  gasStation,
7882
+ granter,
6545
7883
  fee = 1.8
6546
7884
  }) {
6547
7885
  const msg = {
@@ -6578,13 +7916,13 @@ var MACI = class {
6578
7916
  const grantFee = {
6579
7917
  amount: calculatedFee.amount,
6580
7918
  gas: calculatedFee.gas,
6581
- granter: contractAddress
7919
+ granter: granter || contractAddress
6582
7920
  };
6583
7921
  return client.execute(address, contractAddress, msg, grantFee);
6584
7922
  } else if (gasStation === true && typeof fee === "object") {
6585
7923
  const grantFee = {
6586
7924
  ...fee,
6587
- granter: contractAddress
7925
+ granter: granter || contractAddress
6588
7926
  };
6589
7927
  return client.execute(address, contractAddress, msg, grantFee);
6590
7928
  }
@@ -6891,9 +8229,9 @@ var MaciClient2 = class {
6891
8229
  apiEndpoint,
6892
8230
  registryAddress,
6893
8231
  saasAddress,
8232
+ apiSaasAddress,
6894
8233
  maciCodeId,
6895
8234
  oracleCodeId,
6896
- saasOracleCodeId,
6897
8235
  customFetch,
6898
8236
  defaultOptions,
6899
8237
  feegrantOperator,
@@ -6910,9 +8248,9 @@ var MaciClient2 = class {
6910
8248
  this.certificateApiEndpoint = certificateApiEndpoint || defaultParams.certificateApiEndpoint;
6911
8249
  this.registryAddress = registryAddress || defaultParams.registryAddress;
6912
8250
  this.saasAddress = saasAddress || defaultParams.saasAddress;
8251
+ this.apiSaasAddress = apiSaasAddress || defaultParams.apiSaasAddress;
6913
8252
  this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
6914
8253
  this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
6915
- this.saasOracleCodeId = saasOracleCodeId || defaultParams.saasCodeId;
6916
8254
  this.feegrantOperator = feegrantOperator || defaultParams.oracleFeegrantOperator;
6917
8255
  this.whitelistBackendPubkey = whitelistBackendPubkey || defaultParams.oracleWhitelistBackendPubkey;
6918
8256
  this.maciKeypair = maciKeypair ?? genKeypair();
@@ -6933,9 +8271,9 @@ var MaciClient2 = class {
6933
8271
  rpcEndpoint: this.rpcEndpoint,
6934
8272
  registryAddress: this.registryAddress,
6935
8273
  saasAddress: this.saasAddress,
8274
+ apiSaasAddress: this.apiSaasAddress,
6936
8275
  maciCodeId: this.maciCodeId,
6937
8276
  oracleCodeId: this.oracleCodeId,
6938
- saasOracleCodeId: this.saasOracleCodeId,
6939
8277
  feegrantOperator: this.feegrantOperator,
6940
8278
  whitelistBackendPubkey: this.whitelistBackendPubkey
6941
8279
  });
@@ -7030,6 +8368,18 @@ var MaciClient2 = class {
7030
8368
  ...params
7031
8369
  });
7032
8370
  }
8371
+ async createApiSaasMaciRound(params) {
8372
+ return await this.contract.createApiSaasMaciRound({
8373
+ signer: this.getSigner(params.signer),
8374
+ ...params
8375
+ });
8376
+ }
8377
+ async createApiSaasAmaciRound(params) {
8378
+ return await this.contract.createApiSaasAmaciRound({
8379
+ signer: this.getSigner(params.signer),
8380
+ ...params
8381
+ });
8382
+ }
7033
8383
  async genKeypairFromSign({
7034
8384
  signer,
7035
8385
  address
@@ -7336,6 +8686,48 @@ var MaciClient2 = class {
7336
8686
  fee
7337
8687
  });
7338
8688
  }
8689
+ async rawSignup({
8690
+ signer,
8691
+ address,
8692
+ contractAddress,
8693
+ pubKey,
8694
+ oracleCertificate,
8695
+ gasStation = false,
8696
+ granter,
8697
+ fee
8698
+ }) {
8699
+ return await this.maci.rawSignup({
8700
+ signer: this.getSigner(signer),
8701
+ address,
8702
+ contractAddress,
8703
+ pubKey,
8704
+ oracleCertificate,
8705
+ gasStation,
8706
+ granter,
8707
+ fee
8708
+ });
8709
+ }
8710
+ async rawVote({
8711
+ signer,
8712
+ address,
8713
+ contractAddress,
8714
+ pubKey,
8715
+ payload,
8716
+ gasStation = false,
8717
+ granter,
8718
+ fee
8719
+ }) {
8720
+ return await this.maci.rawVote({
8721
+ signer: this.getSigner(signer),
8722
+ address,
8723
+ contractAddress,
8724
+ pubKey,
8725
+ payload,
8726
+ gasStation,
8727
+ granter,
8728
+ fee
8729
+ });
8730
+ }
7339
8731
  };
7340
8732
  export {
7341
8733
  Circuit,
@@ -7357,7 +8749,9 @@ export {
7357
8749
  UserAccount,
7358
8750
  batchGenMessage,
7359
8751
  bigInt2Buffer,
8752
+ buffer2Bigint,
7360
8753
  circuits,
8754
+ destringizing,
7361
8755
  formatPrivKeyForBabyJub,
7362
8756
  genAddKeyInput,
7363
8757
  genEcdhSharedKey,