@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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2371 -975
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2369 -975
- package/dist/index.mjs.map +1 -1
- package/dist/libs/const.d.ts +1 -2
- package/dist/libs/contract/config.d.ts +12 -0
- package/dist/libs/contract/contract.d.ts +66 -4
- package/dist/libs/contract/ts/AMaci.client.d.ts +25 -3
- package/dist/libs/contract/ts/AMaci.types.d.ts +26 -1
- package/dist/libs/contract/ts/ApiMaci.client.d.ts +170 -0
- package/dist/libs/contract/ts/ApiMaci.types.d.ts +187 -0
- package/dist/libs/contract/ts/ApiSaas.client.d.ts +148 -0
- package/dist/libs/contract/ts/ApiSaas.types.d.ts +126 -0
- package/dist/libs/contract/ts/Registry.client.d.ts +17 -7
- package/dist/libs/contract/ts/Registry.types.d.ts +16 -5
- package/dist/libs/contract/types.d.ts +15 -3
- package/dist/libs/crypto/bigintUtils.d.ts +2 -0
- package/dist/libs/maci/maci.d.ts +34 -4
- package/dist/maci.d.ts +47 -3
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/index.ts +5 -1
- package/src/libs/const.ts +5 -6
- package/src/libs/contract/config.ts +36 -0
- package/src/libs/contract/contract.ts +611 -6
- package/src/libs/contract/ts/AMaci.client.ts +66 -0
- package/src/libs/contract/ts/AMaci.types.ts +30 -1
- package/src/libs/contract/ts/ApiMaci.client.ts +459 -0
- package/src/libs/contract/ts/ApiMaci.types.ts +188 -0
- package/src/libs/contract/ts/ApiSaas.client.ts +581 -0
- package/src/libs/contract/ts/ApiSaas.types.ts +144 -0
- package/src/libs/contract/ts/Registry.client.ts +57 -9
- package/src/libs/contract/ts/Registry.types.ts +18 -5
- package/src/libs/contract/types.ts +16 -3
- package/src/libs/crypto/bigintUtils.ts +28 -0
- package/src/libs/maci/maci.ts +190 -9
- package/src/maci.ts +86 -4
- package/src/types/index.ts +2 -2
package/dist/index.js
CHANGED
|
@@ -49,7 +49,9 @@ __export(index_exports, {
|
|
|
49
49
|
UserAccount: () => UserAccount,
|
|
50
50
|
batchGenMessage: () => batchGenMessage,
|
|
51
51
|
bigInt2Buffer: () => bigInt2Buffer,
|
|
52
|
+
buffer2Bigint: () => buffer2Bigint,
|
|
52
53
|
circuits: () => circuits,
|
|
54
|
+
destringizing: () => destringizing,
|
|
53
55
|
formatPrivKeyForBabyJub: () => formatPrivKeyForBabyJub,
|
|
54
56
|
genAddKeyInput: () => genAddKeyInput,
|
|
55
57
|
genEcdhSharedKey: () => genEcdhSharedKey,
|
|
@@ -428,15 +430,14 @@ function getDefaultParams(network = "mainnet") {
|
|
|
428
430
|
certificateApiEndpoint: "https://vota-certificate-api.dorafactory.org/api/v1",
|
|
429
431
|
registryAddress: "dora1smg5qp5trjdkcekdjssqpjehdjf6n4cjss0clyvqcud3t3u3948s8rmgg4",
|
|
430
432
|
saasAddress: "dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8",
|
|
433
|
+
apiSaasAddress: "dora1ksxvvve2nsw5uyvg7y6lnnxcqxadjepc78z0qa8enm5zhayxaqgqpsewf8",
|
|
431
434
|
maciCodeId: 106,
|
|
432
435
|
// oracleCodeId: 116,// 9-4-3-625
|
|
433
436
|
oracleCodeId: 119,
|
|
434
437
|
// 6-3-3-125
|
|
435
|
-
saasCodeId: 124,
|
|
436
438
|
oracleWhitelistBackendPubkey: "A61YtCv2ibMZmDeM02nEElil8wlHx1tLKogBk5dPgf/Q",
|
|
437
439
|
oracleFeegrantOperator: "dora16s9tljk8dy9ae335yvyzlm8gvkypx9228q8pq8",
|
|
438
|
-
oracleCodeIds: ["101", "116", "117", "119"]
|
|
439
|
-
saasCodeIds: ["124"]
|
|
440
|
+
oracleCodeIds: ["101", "116", "117", "119"]
|
|
440
441
|
};
|
|
441
442
|
case "testnet":
|
|
442
443
|
return {
|
|
@@ -448,15 +449,14 @@ function getDefaultParams(network = "mainnet") {
|
|
|
448
449
|
certificateApiEndpoint: "https://vota-testnet-certificate-api.dorafactory.org/api/v1",
|
|
449
450
|
registryAddress: "dora13c8aecstyxrhax9znvvh5zey89edrmd2k5va57pxvpe3fxtfsfeqlhsjnd",
|
|
450
451
|
saasAddress: "dora1dgnszrwnwxgr5djprrr6w4q45z8s3ghsew869g6tlp4ruqah39nqnemjya",
|
|
452
|
+
apiSaasAddress: "dora16xj2yrh3snq8f2qvma9uzjd5m2qgvzaqjcqmeuweh73t29c4rhusxm9hq6",
|
|
451
453
|
maciCodeId: 134,
|
|
452
454
|
// oracleCodeId: 113, // 9-4-3-625
|
|
453
455
|
oracleCodeId: 123,
|
|
454
456
|
// 6-3-3-125
|
|
455
|
-
saasCodeId: 152,
|
|
456
457
|
oracleWhitelistBackendPubkey: "AoYo/zENN/JquagPdG0/NMbWBBYxOM8BVN677mBXJKJQ",
|
|
457
458
|
oracleFeegrantOperator: "dora1xp0twdzsdeq4qg3c64v66552deax8zmvq4zw78",
|
|
458
|
-
oracleCodeIds: ["102", "105", "108", "110", "113", "115", "123"]
|
|
459
|
-
saasCodeIds: ["152"]
|
|
459
|
+
oracleCodeIds: ["102", "105", "108", "110", "113", "115", "123"]
|
|
460
460
|
};
|
|
461
461
|
}
|
|
462
462
|
}
|
|
@@ -567,6 +567,28 @@ var bigInt2Buffer = (i) => {
|
|
|
567
567
|
}
|
|
568
568
|
return Buffer.from(hex, "hex");
|
|
569
569
|
};
|
|
570
|
+
var buffer2Bigint = (buffer) => {
|
|
571
|
+
const buf = Buffer.isBuffer(buffer) ? buffer : Buffer.from(buffer);
|
|
572
|
+
const hex = buf.toString("hex");
|
|
573
|
+
return BigInt("0x" + hex);
|
|
574
|
+
};
|
|
575
|
+
var destringizing = (o, path = []) => {
|
|
576
|
+
if (path.includes(o)) {
|
|
577
|
+
throw new Error("loop nesting!");
|
|
578
|
+
}
|
|
579
|
+
const newPath = [...path, o];
|
|
580
|
+
if (Array.isArray(o)) {
|
|
581
|
+
return o.map((item) => destringizing(item, newPath));
|
|
582
|
+
} else if (typeof o === "object" && o !== null) {
|
|
583
|
+
const output = {};
|
|
584
|
+
for (const key in o) {
|
|
585
|
+
output[key] = destringizing(o[key], newPath);
|
|
586
|
+
}
|
|
587
|
+
return output;
|
|
588
|
+
} else {
|
|
589
|
+
return BigInt(o);
|
|
590
|
+
}
|
|
591
|
+
};
|
|
570
592
|
|
|
571
593
|
// src/libs/crypto/keys.ts
|
|
572
594
|
var import_poseidon_cipher2 = require("@zk-kit/poseidon-cipher");
|
|
@@ -3285,6 +3307,38 @@ var AMaciQueryClient = class {
|
|
|
3285
3307
|
get_delay_records: {}
|
|
3286
3308
|
});
|
|
3287
3309
|
};
|
|
3310
|
+
this.getTallyDelay = async () => {
|
|
3311
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
3312
|
+
get_tally_delay: {}
|
|
3313
|
+
});
|
|
3314
|
+
};
|
|
3315
|
+
this.queryOracleWhitelistConfig = async () => {
|
|
3316
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
3317
|
+
query_oracle_whitelist_config: {}
|
|
3318
|
+
});
|
|
3319
|
+
};
|
|
3320
|
+
this.canSignUpWithOracle = async ({
|
|
3321
|
+
certificate,
|
|
3322
|
+
pubkey
|
|
3323
|
+
}) => {
|
|
3324
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
3325
|
+
can_sign_up_with_oracle: {
|
|
3326
|
+
certificate,
|
|
3327
|
+
pubkey
|
|
3328
|
+
}
|
|
3329
|
+
});
|
|
3330
|
+
};
|
|
3331
|
+
this.whiteBalanceOf = async ({
|
|
3332
|
+
certificate,
|
|
3333
|
+
pubkey
|
|
3334
|
+
}) => {
|
|
3335
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
3336
|
+
white_balance_of: {
|
|
3337
|
+
certificate,
|
|
3338
|
+
pubkey
|
|
3339
|
+
}
|
|
3340
|
+
});
|
|
3341
|
+
};
|
|
3288
3342
|
this.client = client;
|
|
3289
3343
|
this.contractAddress = contractAddress;
|
|
3290
3344
|
this.admin = this.admin.bind(this);
|
|
@@ -3315,6 +3369,10 @@ var AMaciQueryClient = class {
|
|
|
3315
3369
|
this.queryCertSystem = this.queryCertSystem.bind(this);
|
|
3316
3370
|
this.queryPreDeactivateRoot = this.queryPreDeactivateRoot.bind(this);
|
|
3317
3371
|
this.getDelayRecords = this.getDelayRecords.bind(this);
|
|
3372
|
+
this.getTallyDelay = this.getTallyDelay.bind(this);
|
|
3373
|
+
this.queryOracleWhitelistConfig = this.queryOracleWhitelistConfig.bind(this);
|
|
3374
|
+
this.canSignUpWithOracle = this.canSignUpWithOracle.bind(this);
|
|
3375
|
+
this.whiteBalanceOf = this.whiteBalanceOf.bind(this);
|
|
3318
3376
|
}
|
|
3319
3377
|
};
|
|
3320
3378
|
var AMaciClient = class extends AMaciQueryClient {
|
|
@@ -3369,6 +3427,7 @@ var AMaciClient = class extends AMaciQueryClient {
|
|
|
3369
3427
|
);
|
|
3370
3428
|
};
|
|
3371
3429
|
this.signUp = async ({
|
|
3430
|
+
certificate,
|
|
3372
3431
|
pubkey
|
|
3373
3432
|
}, fee = "auto", memo, _funds) => {
|
|
3374
3433
|
return await this.client.execute(
|
|
@@ -3376,6 +3435,7 @@ var AMaciClient = class extends AMaciQueryClient {
|
|
|
3376
3435
|
this.contractAddress,
|
|
3377
3436
|
{
|
|
3378
3437
|
sign_up: {
|
|
3438
|
+
certificate,
|
|
3379
3439
|
pubkey
|
|
3380
3440
|
}
|
|
3381
3441
|
},
|
|
@@ -3656,6 +3716,11 @@ var RegistryQueryClient = class {
|
|
|
3656
3716
|
}
|
|
3657
3717
|
});
|
|
3658
3718
|
};
|
|
3719
|
+
this.getCircuitChargeConfig = async () => {
|
|
3720
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
3721
|
+
get_circuit_charge_config: {}
|
|
3722
|
+
});
|
|
3723
|
+
};
|
|
3659
3724
|
this.client = client;
|
|
3660
3725
|
this.contractAddress = contractAddress;
|
|
3661
3726
|
this.admin = this.admin.bind(this);
|
|
@@ -3666,6 +3731,7 @@ var RegistryQueryClient = class {
|
|
|
3666
3731
|
this.getValidatorOperator = this.getValidatorOperator.bind(this);
|
|
3667
3732
|
this.getMaciOperatorPubkey = this.getMaciOperatorPubkey.bind(this);
|
|
3668
3733
|
this.getMaciOperatorIdentity = this.getMaciOperatorIdentity.bind(this);
|
|
3734
|
+
this.getCircuitChargeConfig = this.getCircuitChargeConfig.bind(this);
|
|
3669
3735
|
}
|
|
3670
3736
|
};
|
|
3671
3737
|
var RegistryClient = class extends RegistryQueryClient {
|
|
@@ -3722,12 +3788,13 @@ var RegistryClient = class extends RegistryQueryClient {
|
|
|
3722
3788
|
this.createRound = async ({
|
|
3723
3789
|
certificationSystem,
|
|
3724
3790
|
circuitType,
|
|
3725
|
-
maxOption,
|
|
3726
3791
|
maxVoter,
|
|
3727
3792
|
operator,
|
|
3793
|
+
oracleWhitelistPubkey,
|
|
3728
3794
|
preDeactivateRoot,
|
|
3729
3795
|
roundInfo,
|
|
3730
3796
|
voiceCreditAmount,
|
|
3797
|
+
voteOptionMap,
|
|
3731
3798
|
votingTime,
|
|
3732
3799
|
whitelist
|
|
3733
3800
|
}, fee = "auto", memo, _funds) => {
|
|
@@ -3738,12 +3805,13 @@ var RegistryClient = class extends RegistryQueryClient {
|
|
|
3738
3805
|
create_round: {
|
|
3739
3806
|
certification_system: certificationSystem,
|
|
3740
3807
|
circuit_type: circuitType,
|
|
3741
|
-
max_option: maxOption,
|
|
3742
3808
|
max_voter: maxVoter,
|
|
3743
3809
|
operator,
|
|
3810
|
+
oracle_whitelist_pubkey: oracleWhitelistPubkey,
|
|
3744
3811
|
pre_deactivate_root: preDeactivateRoot,
|
|
3745
3812
|
round_info: roundInfo,
|
|
3746
3813
|
voice_credit_amount: voiceCreditAmount,
|
|
3814
|
+
vote_option_map: voteOptionMap,
|
|
3747
3815
|
voting_time: votingTime,
|
|
3748
3816
|
whitelist
|
|
3749
3817
|
}
|
|
@@ -3817,6 +3885,22 @@ var RegistryClient = class extends RegistryQueryClient {
|
|
|
3817
3885
|
_funds
|
|
3818
3886
|
);
|
|
3819
3887
|
};
|
|
3888
|
+
this.changeChargeConfig = async ({
|
|
3889
|
+
config
|
|
3890
|
+
}, fee = "auto", memo, _funds) => {
|
|
3891
|
+
return await this.client.execute(
|
|
3892
|
+
this.sender,
|
|
3893
|
+
this.contractAddress,
|
|
3894
|
+
{
|
|
3895
|
+
change_charge_config: {
|
|
3896
|
+
config
|
|
3897
|
+
}
|
|
3898
|
+
},
|
|
3899
|
+
fee,
|
|
3900
|
+
memo,
|
|
3901
|
+
_funds
|
|
3902
|
+
);
|
|
3903
|
+
};
|
|
3820
3904
|
this.client = client;
|
|
3821
3905
|
this.sender = sender;
|
|
3822
3906
|
this.contractAddress = contractAddress;
|
|
@@ -3828,6 +3912,7 @@ var RegistryClient = class extends RegistryQueryClient {
|
|
|
3828
3912
|
this.removeValidator = this.removeValidator.bind(this);
|
|
3829
3913
|
this.updateAmaciCodeId = this.updateAmaciCodeId.bind(this);
|
|
3830
3914
|
this.changeOperator = this.changeOperator.bind(this);
|
|
3915
|
+
this.changeChargeConfig = this.changeChargeConfig.bind(this);
|
|
3831
3916
|
}
|
|
3832
3917
|
};
|
|
3833
3918
|
|
|
@@ -4567,46 +4652,627 @@ var SaasClient = class extends SaasQueryClient {
|
|
|
4567
4652
|
}
|
|
4568
4653
|
};
|
|
4569
4654
|
|
|
4570
|
-
// src/libs/contract/
|
|
4571
|
-
var
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
|
|
4575
|
-
|
|
4655
|
+
// src/libs/contract/ts/ApiMaci.client.ts
|
|
4656
|
+
var ApiMaciQueryClient = class {
|
|
4657
|
+
constructor(client, contractAddress) {
|
|
4658
|
+
this.getRoundInfo = async () => {
|
|
4659
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4660
|
+
get_round_info: {}
|
|
4661
|
+
});
|
|
4662
|
+
};
|
|
4663
|
+
this.getVotingTime = async () => {
|
|
4664
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4665
|
+
get_voting_time: {}
|
|
4666
|
+
});
|
|
4667
|
+
};
|
|
4668
|
+
this.getPeriod = async () => {
|
|
4669
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4670
|
+
get_period: {}
|
|
4671
|
+
});
|
|
4672
|
+
};
|
|
4673
|
+
this.getNumSignUp = async () => {
|
|
4674
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4675
|
+
get_num_sign_up: {}
|
|
4676
|
+
});
|
|
4677
|
+
};
|
|
4678
|
+
this.getMsgChainLength = async () => {
|
|
4679
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4680
|
+
get_msg_chain_length: {}
|
|
4681
|
+
});
|
|
4682
|
+
};
|
|
4683
|
+
this.getProcessedMsgCount = async () => {
|
|
4684
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4685
|
+
get_processed_msg_count: {}
|
|
4686
|
+
});
|
|
4687
|
+
};
|
|
4688
|
+
this.getProcessedUserCount = async () => {
|
|
4689
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4690
|
+
get_processed_user_count: {}
|
|
4691
|
+
});
|
|
4692
|
+
};
|
|
4693
|
+
this.getResult = async ({
|
|
4694
|
+
index
|
|
4695
|
+
}) => {
|
|
4696
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4697
|
+
get_result: {
|
|
4698
|
+
index
|
|
4699
|
+
}
|
|
4700
|
+
});
|
|
4701
|
+
};
|
|
4702
|
+
this.getAllResult = async () => {
|
|
4703
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4704
|
+
get_all_result: {}
|
|
4705
|
+
});
|
|
4706
|
+
};
|
|
4707
|
+
this.getStateIdxInc = async ({
|
|
4708
|
+
address
|
|
4709
|
+
}) => {
|
|
4710
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4711
|
+
get_state_idx_inc: {
|
|
4712
|
+
address
|
|
4713
|
+
}
|
|
4714
|
+
});
|
|
4715
|
+
};
|
|
4716
|
+
this.getVoiceCreditBalance = async ({
|
|
4717
|
+
index
|
|
4718
|
+
}) => {
|
|
4719
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4720
|
+
get_voice_credit_balance: {
|
|
4721
|
+
index
|
|
4722
|
+
}
|
|
4723
|
+
});
|
|
4724
|
+
};
|
|
4725
|
+
this.isWhiteList = async ({
|
|
4726
|
+
amount,
|
|
4727
|
+
certificate,
|
|
4728
|
+
pubkey
|
|
4729
|
+
}) => {
|
|
4730
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4731
|
+
is_white_list: {
|
|
4732
|
+
amount,
|
|
4733
|
+
certificate,
|
|
4734
|
+
pubkey
|
|
4735
|
+
}
|
|
4736
|
+
});
|
|
4737
|
+
};
|
|
4738
|
+
this.whiteBalanceOf = async ({
|
|
4739
|
+
amount,
|
|
4740
|
+
certificate,
|
|
4741
|
+
pubkey
|
|
4742
|
+
}) => {
|
|
4743
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4744
|
+
white_balance_of: {
|
|
4745
|
+
amount,
|
|
4746
|
+
certificate,
|
|
4747
|
+
pubkey
|
|
4748
|
+
}
|
|
4749
|
+
});
|
|
4750
|
+
};
|
|
4751
|
+
this.whiteInfo = async ({
|
|
4752
|
+
pubkey
|
|
4753
|
+
}) => {
|
|
4754
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4755
|
+
white_info: {
|
|
4756
|
+
pubkey
|
|
4757
|
+
}
|
|
4758
|
+
});
|
|
4759
|
+
};
|
|
4760
|
+
this.maxWhitelistNum = async () => {
|
|
4761
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4762
|
+
max_whitelist_num: {}
|
|
4763
|
+
});
|
|
4764
|
+
};
|
|
4765
|
+
this.voteOptionMap = async () => {
|
|
4766
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4767
|
+
vote_option_map: {}
|
|
4768
|
+
});
|
|
4769
|
+
};
|
|
4770
|
+
this.maxVoteOptions = async () => {
|
|
4771
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4772
|
+
max_vote_options: {}
|
|
4773
|
+
});
|
|
4774
|
+
};
|
|
4775
|
+
this.queryTotalFeeGrant = async () => {
|
|
4776
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4777
|
+
query_total_fee_grant: {}
|
|
4778
|
+
});
|
|
4779
|
+
};
|
|
4780
|
+
this.queryCircuitType = async () => {
|
|
4781
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4782
|
+
query_circuit_type: {}
|
|
4783
|
+
});
|
|
4784
|
+
};
|
|
4785
|
+
this.queryCertSystem = async () => {
|
|
4786
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4787
|
+
query_cert_system: {}
|
|
4788
|
+
});
|
|
4789
|
+
};
|
|
4790
|
+
this.queryOracleWhitelistConfig = async () => {
|
|
4791
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4792
|
+
query_oracle_whitelist_config: {}
|
|
4793
|
+
});
|
|
4794
|
+
};
|
|
4795
|
+
this.client = client;
|
|
4796
|
+
this.contractAddress = contractAddress;
|
|
4797
|
+
this.getRoundInfo = this.getRoundInfo.bind(this);
|
|
4798
|
+
this.getVotingTime = this.getVotingTime.bind(this);
|
|
4799
|
+
this.getPeriod = this.getPeriod.bind(this);
|
|
4800
|
+
this.getNumSignUp = this.getNumSignUp.bind(this);
|
|
4801
|
+
this.getMsgChainLength = this.getMsgChainLength.bind(this);
|
|
4802
|
+
this.getProcessedMsgCount = this.getProcessedMsgCount.bind(this);
|
|
4803
|
+
this.getProcessedUserCount = this.getProcessedUserCount.bind(this);
|
|
4804
|
+
this.getResult = this.getResult.bind(this);
|
|
4805
|
+
this.getAllResult = this.getAllResult.bind(this);
|
|
4806
|
+
this.getStateIdxInc = this.getStateIdxInc.bind(this);
|
|
4807
|
+
this.getVoiceCreditBalance = this.getVoiceCreditBalance.bind(this);
|
|
4808
|
+
this.isWhiteList = this.isWhiteList.bind(this);
|
|
4809
|
+
this.whiteBalanceOf = this.whiteBalanceOf.bind(this);
|
|
4810
|
+
this.whiteInfo = this.whiteInfo.bind(this);
|
|
4811
|
+
this.maxWhitelistNum = this.maxWhitelistNum.bind(this);
|
|
4812
|
+
this.voteOptionMap = this.voteOptionMap.bind(this);
|
|
4813
|
+
this.maxVoteOptions = this.maxVoteOptions.bind(this);
|
|
4814
|
+
this.queryTotalFeeGrant = this.queryTotalFeeGrant.bind(this);
|
|
4815
|
+
this.queryCircuitType = this.queryCircuitType.bind(this);
|
|
4816
|
+
this.queryCertSystem = this.queryCertSystem.bind(this);
|
|
4817
|
+
this.queryOracleWhitelistConfig = this.queryOracleWhitelistConfig.bind(this);
|
|
4818
|
+
}
|
|
4576
4819
|
};
|
|
4577
|
-
|
|
4578
|
-
|
|
4579
|
-
|
|
4580
|
-
|
|
4581
|
-
|
|
4582
|
-
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
}
|
|
4589
|
-
async
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4820
|
+
var ApiMaciClient = class extends ApiMaciQueryClient {
|
|
4821
|
+
constructor(client, sender, contractAddress) {
|
|
4822
|
+
super(client, contractAddress);
|
|
4823
|
+
this.setRoundInfo = async ({
|
|
4824
|
+
roundInfo
|
|
4825
|
+
}, fee = "auto", memo, _funds) => {
|
|
4826
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4827
|
+
set_round_info: {
|
|
4828
|
+
round_info: roundInfo
|
|
4829
|
+
}
|
|
4830
|
+
}, fee, memo, _funds);
|
|
4831
|
+
};
|
|
4832
|
+
this.setVoteOptionsMap = async ({
|
|
4833
|
+
voteOptionMap
|
|
4834
|
+
}, fee = "auto", memo, _funds) => {
|
|
4835
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4836
|
+
set_vote_options_map: {
|
|
4837
|
+
vote_option_map: voteOptionMap
|
|
4838
|
+
}
|
|
4839
|
+
}, fee, memo, _funds);
|
|
4840
|
+
};
|
|
4841
|
+
this.signUp = async ({
|
|
4842
|
+
amount,
|
|
4843
|
+
certificate,
|
|
4844
|
+
pubkey
|
|
4845
|
+
}, fee = "auto", memo, _funds) => {
|
|
4846
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4847
|
+
sign_up: {
|
|
4848
|
+
amount,
|
|
4849
|
+
certificate,
|
|
4850
|
+
pubkey
|
|
4851
|
+
}
|
|
4852
|
+
}, fee, memo, _funds);
|
|
4853
|
+
};
|
|
4854
|
+
this.startProcessPeriod = async (fee = "auto", memo, _funds) => {
|
|
4855
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4856
|
+
start_process_period: {}
|
|
4857
|
+
}, fee, memo, _funds);
|
|
4858
|
+
};
|
|
4859
|
+
this.publishMessage = async ({
|
|
4860
|
+
encPubKey,
|
|
4861
|
+
message
|
|
4862
|
+
}, fee = "auto", memo, _funds) => {
|
|
4863
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4864
|
+
publish_message: {
|
|
4865
|
+
enc_pub_key: encPubKey,
|
|
4866
|
+
message
|
|
4867
|
+
}
|
|
4868
|
+
}, fee, memo, _funds);
|
|
4869
|
+
};
|
|
4870
|
+
this.processMessage = async ({
|
|
4871
|
+
groth16Proof,
|
|
4872
|
+
newStateCommitment,
|
|
4873
|
+
plonkProof
|
|
4874
|
+
}, fee = "auto", memo, _funds) => {
|
|
4875
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4876
|
+
process_message: {
|
|
4877
|
+
groth16_proof: groth16Proof,
|
|
4878
|
+
new_state_commitment: newStateCommitment,
|
|
4879
|
+
plonk_proof: plonkProof
|
|
4880
|
+
}
|
|
4881
|
+
}, fee, memo, _funds);
|
|
4882
|
+
};
|
|
4883
|
+
this.stopProcessingPeriod = async (fee = "auto", memo, _funds) => {
|
|
4884
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4885
|
+
stop_processing_period: {}
|
|
4886
|
+
}, fee, memo, _funds);
|
|
4887
|
+
};
|
|
4888
|
+
this.processTally = async ({
|
|
4889
|
+
groth16Proof,
|
|
4890
|
+
newTallyCommitment,
|
|
4891
|
+
plonkProof
|
|
4892
|
+
}, fee = "auto", memo, _funds) => {
|
|
4893
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4894
|
+
process_tally: {
|
|
4895
|
+
groth16_proof: groth16Proof,
|
|
4896
|
+
new_tally_commitment: newTallyCommitment,
|
|
4897
|
+
plonk_proof: plonkProof
|
|
4898
|
+
}
|
|
4899
|
+
}, fee, memo, _funds);
|
|
4900
|
+
};
|
|
4901
|
+
this.stopTallyingPeriod = async ({
|
|
4902
|
+
results,
|
|
4903
|
+
salt
|
|
4904
|
+
}, fee = "auto", memo, _funds) => {
|
|
4905
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4906
|
+
stop_tallying_period: {
|
|
4907
|
+
results,
|
|
4908
|
+
salt
|
|
4909
|
+
}
|
|
4910
|
+
}, fee, memo, _funds);
|
|
4911
|
+
};
|
|
4912
|
+
this.bond = async (fee = "auto", memo, _funds) => {
|
|
4913
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4914
|
+
bond: {}
|
|
4915
|
+
}, fee, memo, _funds);
|
|
4916
|
+
};
|
|
4917
|
+
this.withdraw = async ({
|
|
4918
|
+
amount
|
|
4919
|
+
}, fee = "auto", memo, _funds) => {
|
|
4920
|
+
return await this.client.execute(this.sender, this.contractAddress, {
|
|
4921
|
+
withdraw: {
|
|
4922
|
+
amount
|
|
4923
|
+
}
|
|
4924
|
+
}, fee, memo, _funds);
|
|
4925
|
+
};
|
|
4926
|
+
this.client = client;
|
|
4927
|
+
this.sender = sender;
|
|
4928
|
+
this.contractAddress = contractAddress;
|
|
4929
|
+
this.setRoundInfo = this.setRoundInfo.bind(this);
|
|
4930
|
+
this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
|
|
4931
|
+
this.signUp = this.signUp.bind(this);
|
|
4932
|
+
this.startProcessPeriod = this.startProcessPeriod.bind(this);
|
|
4933
|
+
this.publishMessage = this.publishMessage.bind(this);
|
|
4934
|
+
this.processMessage = this.processMessage.bind(this);
|
|
4935
|
+
this.stopProcessingPeriod = this.stopProcessingPeriod.bind(this);
|
|
4936
|
+
this.processTally = this.processTally.bind(this);
|
|
4937
|
+
this.stopTallyingPeriod = this.stopTallyingPeriod.bind(this);
|
|
4938
|
+
this.bond = this.bond.bind(this);
|
|
4939
|
+
this.withdraw = this.withdraw.bind(this);
|
|
4940
|
+
}
|
|
4941
|
+
};
|
|
4942
|
+
|
|
4943
|
+
// src/libs/contract/ts/ApiSaas.client.ts
|
|
4944
|
+
var ApiSaasQueryClient = class {
|
|
4945
|
+
constructor(client, contractAddress) {
|
|
4946
|
+
this.config = async () => {
|
|
4947
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4948
|
+
config: {}
|
|
4949
|
+
});
|
|
4950
|
+
};
|
|
4951
|
+
this.operators = async () => {
|
|
4952
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4953
|
+
operators: {}
|
|
4954
|
+
});
|
|
4955
|
+
};
|
|
4956
|
+
this.isOperator = async ({ address }) => {
|
|
4957
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4958
|
+
is_operator: {
|
|
4959
|
+
address
|
|
4960
|
+
}
|
|
4961
|
+
});
|
|
4962
|
+
};
|
|
4963
|
+
this.balance = async () => {
|
|
4964
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4965
|
+
balance: {}
|
|
4966
|
+
});
|
|
4967
|
+
};
|
|
4968
|
+
this.maciCodeId = async () => {
|
|
4969
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4970
|
+
maci_code_id: {}
|
|
4971
|
+
});
|
|
4972
|
+
};
|
|
4973
|
+
this.treasuryManager = async () => {
|
|
4974
|
+
return this.client.queryContractSmart(this.contractAddress, {
|
|
4975
|
+
treasury_manager: {}
|
|
4976
|
+
});
|
|
4977
|
+
};
|
|
4978
|
+
this.client = client;
|
|
4979
|
+
this.contractAddress = contractAddress;
|
|
4980
|
+
this.config = this.config.bind(this);
|
|
4981
|
+
this.operators = this.operators.bind(this);
|
|
4982
|
+
this.isOperator = this.isOperator.bind(this);
|
|
4983
|
+
this.balance = this.balance.bind(this);
|
|
4984
|
+
this.maciCodeId = this.maciCodeId.bind(this);
|
|
4985
|
+
this.treasuryManager = this.treasuryManager.bind(this);
|
|
4986
|
+
}
|
|
4987
|
+
};
|
|
4988
|
+
var ApiSaasClient = class extends ApiSaasQueryClient {
|
|
4989
|
+
constructor(client, sender, contractAddress) {
|
|
4990
|
+
super(client, contractAddress);
|
|
4991
|
+
this.updateConfig = async ({
|
|
4992
|
+
admin,
|
|
4993
|
+
denom
|
|
4994
|
+
}, fee = "auto", memo, _funds) => {
|
|
4995
|
+
return await this.client.execute(
|
|
4996
|
+
this.sender,
|
|
4997
|
+
this.contractAddress,
|
|
4998
|
+
{
|
|
4999
|
+
update_config: {
|
|
5000
|
+
admin,
|
|
5001
|
+
denom
|
|
5002
|
+
}
|
|
5003
|
+
},
|
|
5004
|
+
fee,
|
|
5005
|
+
memo,
|
|
5006
|
+
_funds
|
|
5007
|
+
);
|
|
5008
|
+
};
|
|
5009
|
+
this.updateMaciCodeId = async ({
|
|
5010
|
+
codeId
|
|
5011
|
+
}, fee = "auto", memo, _funds) => {
|
|
5012
|
+
return await this.client.execute(
|
|
5013
|
+
this.sender,
|
|
5014
|
+
this.contractAddress,
|
|
5015
|
+
{
|
|
5016
|
+
update_maci_code_id: {
|
|
5017
|
+
code_id: codeId
|
|
5018
|
+
}
|
|
5019
|
+
},
|
|
5020
|
+
fee,
|
|
5021
|
+
memo,
|
|
5022
|
+
_funds
|
|
5023
|
+
);
|
|
5024
|
+
};
|
|
5025
|
+
this.updateAmaciRegistryContract = async ({
|
|
5026
|
+
registryContract
|
|
5027
|
+
}, fee = "auto", memo, _funds) => {
|
|
5028
|
+
return await this.client.execute(
|
|
5029
|
+
this.sender,
|
|
5030
|
+
this.contractAddress,
|
|
5031
|
+
{
|
|
5032
|
+
update_amaci_registry_contract: {
|
|
5033
|
+
registry_contract: registryContract
|
|
5034
|
+
}
|
|
5035
|
+
},
|
|
5036
|
+
fee,
|
|
5037
|
+
memo,
|
|
5038
|
+
_funds
|
|
5039
|
+
);
|
|
5040
|
+
};
|
|
5041
|
+
this.addOperator = async ({
|
|
5042
|
+
operator
|
|
5043
|
+
}, fee = "auto", memo, _funds) => {
|
|
5044
|
+
return await this.client.execute(
|
|
5045
|
+
this.sender,
|
|
5046
|
+
this.contractAddress,
|
|
5047
|
+
{
|
|
5048
|
+
add_operator: {
|
|
5049
|
+
operator
|
|
5050
|
+
}
|
|
5051
|
+
},
|
|
5052
|
+
fee,
|
|
5053
|
+
memo,
|
|
5054
|
+
_funds
|
|
5055
|
+
);
|
|
5056
|
+
};
|
|
5057
|
+
this.removeOperator = async ({
|
|
5058
|
+
operator
|
|
5059
|
+
}, fee = "auto", memo, _funds) => {
|
|
5060
|
+
return await this.client.execute(
|
|
5061
|
+
this.sender,
|
|
5062
|
+
this.contractAddress,
|
|
5063
|
+
{
|
|
5064
|
+
remove_operator: {
|
|
5065
|
+
operator
|
|
5066
|
+
}
|
|
5067
|
+
},
|
|
5068
|
+
fee,
|
|
5069
|
+
memo,
|
|
5070
|
+
_funds
|
|
5071
|
+
);
|
|
5072
|
+
};
|
|
5073
|
+
this.deposit = async (fee = "auto", memo, _funds) => {
|
|
5074
|
+
return await this.client.execute(
|
|
5075
|
+
this.sender,
|
|
5076
|
+
this.contractAddress,
|
|
5077
|
+
{
|
|
5078
|
+
deposit: {}
|
|
5079
|
+
},
|
|
5080
|
+
fee,
|
|
5081
|
+
memo,
|
|
5082
|
+
_funds
|
|
5083
|
+
);
|
|
5084
|
+
};
|
|
5085
|
+
this.withdraw = async ({
|
|
5086
|
+
amount,
|
|
5087
|
+
recipient
|
|
5088
|
+
}, fee = "auto", memo, _funds) => {
|
|
5089
|
+
return await this.client.execute(
|
|
5090
|
+
this.sender,
|
|
5091
|
+
this.contractAddress,
|
|
5092
|
+
{
|
|
5093
|
+
withdraw: {
|
|
5094
|
+
amount,
|
|
5095
|
+
recipient
|
|
5096
|
+
}
|
|
5097
|
+
},
|
|
5098
|
+
fee,
|
|
5099
|
+
memo,
|
|
5100
|
+
_funds
|
|
5101
|
+
);
|
|
5102
|
+
};
|
|
5103
|
+
this.createMaciRound = async ({
|
|
5104
|
+
certificationSystem,
|
|
5105
|
+
circuitType,
|
|
5106
|
+
coordinator,
|
|
5107
|
+
endTime,
|
|
5108
|
+
maxVoters,
|
|
5109
|
+
roundInfo,
|
|
5110
|
+
startTime,
|
|
5111
|
+
voteOptionMap,
|
|
5112
|
+
whitelistBackendPubkey
|
|
5113
|
+
}, fee = "auto", memo, _funds) => {
|
|
5114
|
+
return await this.client.execute(
|
|
5115
|
+
this.sender,
|
|
5116
|
+
this.contractAddress,
|
|
5117
|
+
{
|
|
5118
|
+
create_maci_round: {
|
|
5119
|
+
certification_system: certificationSystem,
|
|
5120
|
+
circuit_type: circuitType,
|
|
5121
|
+
coordinator,
|
|
5122
|
+
end_time: endTime,
|
|
5123
|
+
max_voters: maxVoters.toString(),
|
|
5124
|
+
round_info: roundInfo,
|
|
5125
|
+
start_time: startTime,
|
|
5126
|
+
vote_option_map: voteOptionMap,
|
|
5127
|
+
whitelist_backend_pubkey: whitelistBackendPubkey
|
|
5128
|
+
}
|
|
5129
|
+
},
|
|
5130
|
+
fee,
|
|
5131
|
+
memo,
|
|
5132
|
+
_funds
|
|
5133
|
+
);
|
|
5134
|
+
};
|
|
5135
|
+
this.createAmaciRound = async ({
|
|
5136
|
+
certificationSystem,
|
|
5137
|
+
circuitType,
|
|
5138
|
+
maxVoter,
|
|
5139
|
+
operator,
|
|
5140
|
+
oracleWhitelistPubkey,
|
|
5141
|
+
preDeactivateRoot,
|
|
5142
|
+
roundInfo,
|
|
5143
|
+
voiceCreditAmount,
|
|
5144
|
+
voteOptionMap,
|
|
5145
|
+
votingTime,
|
|
5146
|
+
whitelist
|
|
5147
|
+
}, fee = "auto", memo, _funds) => {
|
|
5148
|
+
return await this.client.execute(
|
|
5149
|
+
this.sender,
|
|
5150
|
+
this.contractAddress,
|
|
5151
|
+
{
|
|
5152
|
+
create_amaci_round: {
|
|
5153
|
+
certification_system: certificationSystem,
|
|
5154
|
+
circuit_type: circuitType,
|
|
5155
|
+
max_voter: maxVoter,
|
|
5156
|
+
operator,
|
|
5157
|
+
oracle_whitelist_pubkey: oracleWhitelistPubkey,
|
|
5158
|
+
pre_deactivate_root: preDeactivateRoot,
|
|
5159
|
+
round_info: roundInfo,
|
|
5160
|
+
voice_credit_amount: voiceCreditAmount,
|
|
5161
|
+
vote_option_map: voteOptionMap,
|
|
5162
|
+
voting_time: votingTime,
|
|
5163
|
+
whitelist
|
|
5164
|
+
}
|
|
5165
|
+
},
|
|
5166
|
+
fee,
|
|
5167
|
+
memo,
|
|
5168
|
+
_funds
|
|
5169
|
+
);
|
|
5170
|
+
};
|
|
5171
|
+
this.setRoundInfo = async ({
|
|
5172
|
+
contractAddr,
|
|
5173
|
+
roundInfo
|
|
5174
|
+
}, fee = "auto", memo, _funds) => {
|
|
5175
|
+
return await this.client.execute(
|
|
5176
|
+
this.sender,
|
|
5177
|
+
this.contractAddress,
|
|
5178
|
+
{
|
|
5179
|
+
set_round_info: {
|
|
5180
|
+
contract_addr: contractAddr,
|
|
5181
|
+
round_info: roundInfo
|
|
5182
|
+
}
|
|
5183
|
+
},
|
|
5184
|
+
fee,
|
|
5185
|
+
memo,
|
|
5186
|
+
_funds
|
|
5187
|
+
);
|
|
5188
|
+
};
|
|
5189
|
+
this.setVoteOptionsMap = async ({
|
|
5190
|
+
contractAddr,
|
|
5191
|
+
voteOptionMap
|
|
5192
|
+
}, fee = "auto", memo, _funds) => {
|
|
5193
|
+
return await this.client.execute(
|
|
5194
|
+
this.sender,
|
|
5195
|
+
this.contractAddress,
|
|
5196
|
+
{
|
|
5197
|
+
set_vote_options_map: {
|
|
5198
|
+
contract_addr: contractAddr,
|
|
5199
|
+
vote_option_map: voteOptionMap
|
|
5200
|
+
}
|
|
5201
|
+
},
|
|
5202
|
+
fee,
|
|
5203
|
+
memo,
|
|
5204
|
+
_funds
|
|
5205
|
+
);
|
|
5206
|
+
};
|
|
5207
|
+
this.client = client;
|
|
5208
|
+
this.sender = sender;
|
|
5209
|
+
this.contractAddress = contractAddress;
|
|
5210
|
+
this.updateConfig = this.updateConfig.bind(this);
|
|
5211
|
+
this.updateMaciCodeId = this.updateMaciCodeId.bind(this);
|
|
5212
|
+
this.updateAmaciRegistryContract = this.updateAmaciRegistryContract.bind(this);
|
|
5213
|
+
this.addOperator = this.addOperator.bind(this);
|
|
5214
|
+
this.removeOperator = this.removeOperator.bind(this);
|
|
5215
|
+
this.deposit = this.deposit.bind(this);
|
|
5216
|
+
this.withdraw = this.withdraw.bind(this);
|
|
5217
|
+
this.createMaciRound = this.createMaciRound.bind(this);
|
|
5218
|
+
this.createAmaciRound = this.createAmaciRound.bind(this);
|
|
5219
|
+
this.setRoundInfo = this.setRoundInfo.bind(this);
|
|
5220
|
+
this.setVoteOptionsMap = this.setVoteOptionsMap.bind(this);
|
|
5221
|
+
}
|
|
5222
|
+
};
|
|
5223
|
+
|
|
5224
|
+
// src/libs/contract/config.ts
|
|
5225
|
+
var defaultSigningClientOptions = {
|
|
5226
|
+
broadcastPollIntervalMs: 8e3,
|
|
5227
|
+
broadcastTimeoutMs: 15e4,
|
|
5228
|
+
// 2min30s for the tx to be confirmed
|
|
5229
|
+
gasPrice: import_stargate.GasPrice.fromString("10000000000peaka")
|
|
5230
|
+
};
|
|
5231
|
+
async function createMaciClientBy({
|
|
5232
|
+
rpcEndpoint,
|
|
5233
|
+
wallet,
|
|
5234
|
+
contractAddress
|
|
5235
|
+
}) {
|
|
5236
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
5237
|
+
rpcEndpoint,
|
|
5238
|
+
wallet
|
|
5239
|
+
);
|
|
5240
|
+
const [{ address }] = await wallet.getAccounts();
|
|
5241
|
+
return new MaciClient(signingCosmWasmClient, address, contractAddress);
|
|
5242
|
+
}
|
|
5243
|
+
async function createAMaciClientBy({
|
|
5244
|
+
rpcEndpoint,
|
|
5245
|
+
wallet,
|
|
5246
|
+
contractAddress
|
|
5247
|
+
}) {
|
|
5248
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
5249
|
+
rpcEndpoint,
|
|
5250
|
+
wallet
|
|
5251
|
+
);
|
|
5252
|
+
const [{ address }] = await wallet.getAccounts();
|
|
5253
|
+
return new AMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
5254
|
+
}
|
|
5255
|
+
async function createApiMaciClientBy({
|
|
5256
|
+
rpcEndpoint,
|
|
5257
|
+
wallet,
|
|
5258
|
+
contractAddress
|
|
5259
|
+
}) {
|
|
5260
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
5261
|
+
rpcEndpoint,
|
|
5262
|
+
wallet
|
|
5263
|
+
);
|
|
5264
|
+
const [{ address }] = await wallet.getAccounts();
|
|
5265
|
+
return new ApiMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
5266
|
+
}
|
|
5267
|
+
async function createRegistryClientBy({
|
|
5268
|
+
rpcEndpoint,
|
|
5269
|
+
wallet,
|
|
5270
|
+
contractAddress
|
|
5271
|
+
}) {
|
|
5272
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
5273
|
+
rpcEndpoint,
|
|
5274
|
+
wallet
|
|
5275
|
+
);
|
|
4610
5276
|
const [{ address }] = await wallet.getAccounts();
|
|
4611
5277
|
return new RegistryClient(signingCosmWasmClient, address, contractAddress);
|
|
4612
5278
|
}
|
|
@@ -4622,6 +5288,18 @@ async function createSaasClientBy({
|
|
|
4622
5288
|
const [{ address }] = await wallet.getAccounts();
|
|
4623
5289
|
return new SaasClient(signingCosmWasmClient, address, contractAddress);
|
|
4624
5290
|
}
|
|
5291
|
+
async function createApiSaasClientBy({
|
|
5292
|
+
rpcEndpoint,
|
|
5293
|
+
wallet,
|
|
5294
|
+
contractAddress
|
|
5295
|
+
}) {
|
|
5296
|
+
const signingCosmWasmClient = await createContractClientByWallet(
|
|
5297
|
+
rpcEndpoint,
|
|
5298
|
+
wallet
|
|
5299
|
+
);
|
|
5300
|
+
const [{ address }] = await wallet.getAccounts();
|
|
5301
|
+
return new ApiSaasClient(signingCosmWasmClient, address, contractAddress);
|
|
5302
|
+
}
|
|
4625
5303
|
async function createOracleMaciClientBy({
|
|
4626
5304
|
rpcEndpoint,
|
|
4627
5305
|
wallet,
|
|
@@ -4634,711 +5312,1381 @@ async function createOracleMaciClientBy({
|
|
|
4634
5312
|
const [{ address }] = await wallet.getAccounts();
|
|
4635
5313
|
return new OracleMaciClient(signingCosmWasmClient, address, contractAddress);
|
|
4636
5314
|
}
|
|
4637
|
-
async function createContractClientByWallet(rpcEndpoint, wallet) {
|
|
4638
|
-
const client = await import_cosmwasm_stargate.SigningCosmWasmClient.connectWithSigner(
|
|
4639
|
-
rpcEndpoint,
|
|
4640
|
-
wallet,
|
|
4641
|
-
{
|
|
4642
|
-
...defaultSigningClientOptions
|
|
5315
|
+
async function createContractClientByWallet(rpcEndpoint, wallet) {
|
|
5316
|
+
const client = await import_cosmwasm_stargate.SigningCosmWasmClient.connectWithSigner(
|
|
5317
|
+
rpcEndpoint,
|
|
5318
|
+
wallet,
|
|
5319
|
+
{
|
|
5320
|
+
...defaultSigningClientOptions
|
|
5321
|
+
}
|
|
5322
|
+
);
|
|
5323
|
+
return client;
|
|
5324
|
+
}
|
|
5325
|
+
|
|
5326
|
+
// src/types/index.ts
|
|
5327
|
+
var MaciCircuitType = /* @__PURE__ */ ((MaciCircuitType2) => {
|
|
5328
|
+
MaciCircuitType2["IP1V"] = "0";
|
|
5329
|
+
MaciCircuitType2["QV"] = "1";
|
|
5330
|
+
return MaciCircuitType2;
|
|
5331
|
+
})(MaciCircuitType || {});
|
|
5332
|
+
var MaciCertSystemType = /* @__PURE__ */ ((MaciCertSystemType2) => {
|
|
5333
|
+
MaciCertSystemType2["GROTH16"] = "groth16";
|
|
5334
|
+
MaciCertSystemType2["PLONK"] = "plonk";
|
|
5335
|
+
return MaciCertSystemType2;
|
|
5336
|
+
})(MaciCertSystemType || {});
|
|
5337
|
+
var MaciRoundType = /* @__PURE__ */ ((MaciRoundType2) => {
|
|
5338
|
+
MaciRoundType2["MACI"] = "0";
|
|
5339
|
+
MaciRoundType2["AMACI"] = "1";
|
|
5340
|
+
MaciRoundType2["ORACLE_MACI"] = "2";
|
|
5341
|
+
return MaciRoundType2;
|
|
5342
|
+
})(MaciRoundType || {});
|
|
5343
|
+
|
|
5344
|
+
// src/libs/contract/vars.ts
|
|
5345
|
+
var CIRCUIT_INFO = {
|
|
5346
|
+
"2-1-1-5": {
|
|
5347
|
+
parameter: {
|
|
5348
|
+
state_tree_depth: "2",
|
|
5349
|
+
int_state_tree_depth: "1",
|
|
5350
|
+
vote_option_tree_depth: "1",
|
|
5351
|
+
message_batch_size: "5"
|
|
5352
|
+
},
|
|
5353
|
+
groth16: {
|
|
5354
|
+
process_vkey: {
|
|
5355
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5356
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5357
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5358
|
+
vk_delta_2: "2178a9c3805dd82071b2b28bb4c0ffc8178cad913c8c990b98b4863284dc3a5d175c0be554fc060c27c551e5e32effef015b918a0f5a2dc1b92909b8272719301c521d5f6542db5ea4775a42d32159c356a696599c1a3df011ec00559ae1c2b60d860f7e6513a7d20feaeaca401863e35a0f691dd7d30ce06d07946840de1ec8",
|
|
5359
|
+
vk_ic0: "19126a54a9b6d0d415f892c246485cb2889487cf9c4a8cd88dab5e1140e1d0630d1d76ef4652df8887c9dc557aa57f25e221db7e5b2e4cf618a362bece107f5c",
|
|
5360
|
+
vk_ic1: "0632e625fefc7172e8aec1070c4d32b90b6c482f6f3806773a4c55a03877c2d716cfd935eb3e3883f580c93f56adbf3a253ce3c208c52fb784f9d8fec139c617"
|
|
5361
|
+
},
|
|
5362
|
+
tally_vkey: {
|
|
5363
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5364
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5365
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5366
|
+
vk_delta_2: "2e9fad39728c543c5213599111e1a44b01720c999a6785e8136c3e3b3bf8e07e248e1933d477969ca6e27cb7a74bca18cac7e3bbdf9371be5c54fe151f6376a30955609ec69b89329322a2f435b706ca248d1312c7513853a50ef37ed0f7826c25a5c57bf07789d89e538bc24017cf2722811f21480b0bb8030ed0028ecb7cd8",
|
|
5367
|
+
vk_ic0: "1bc1a1a3444256469c07cd6f4d1cfd9f7c9ddce596a306e0af077ca9e9c0fe9602db2a9aecef76a9dc4c19bf88c0099b04fc75410cc9004f0966440825e3790a",
|
|
5368
|
+
vk_ic1: "05b8b475f2bfedba4fa04ab1972006da9764c2c3e6fb65d6dd0aac938fd298112a560e13770b06a3f709a49fddf016331ea205fa125026993f6666eff69f4def"
|
|
5369
|
+
}
|
|
5370
|
+
},
|
|
5371
|
+
plonk: {
|
|
5372
|
+
process_vkey: {
|
|
5373
|
+
n: 1048575,
|
|
5374
|
+
num_inputs: 1,
|
|
5375
|
+
selector_commitments: [
|
|
5376
|
+
"29b0f4a90bea69583a8fca1e74d23adf739d605af605a0e0971fac548df976fb2e10a42dfca2325684c1bca5fabbf9d7022fc8b997ea478f1052dd8808d99e44",
|
|
5377
|
+
"119002055b6c2f98314ef408e4a917a6678f114ca991185749289f171f61efc32b3a931c700271b82d22c2073af9b7fffcb7bfa644ea09102d9ef8482410a991",
|
|
5378
|
+
"10c5f32870d26f8e26d2eaae2705557b18210b2355677172e1bef5fe684120891f8317185390ddbb22ecb922d37e03c3cc524c84f65c8045f2324b0f164cfbdb",
|
|
5379
|
+
"115a5f9af5d438d3261cfa31b7050b931b7d22647f628a43af41a41dcd44cb8d2e99368eb15cdc6d1f16faf9db0db4825613d6893c776aef456705bdc76eb728",
|
|
5380
|
+
"1a61cc5f0fbe92fbc8c9bd58928ce467f63e4771e4d517966afbaf220ea069a91cec3231c370be07fee8d9ec01660d054c549b034715855ffa652ad5b67ced86",
|
|
5381
|
+
"19e0d095a343115f6e7ad7ae1f51e375cd648fb35451cb2d5a8cf3bafbb25d0525efdc2cc5b5600ee0ae954dca3bf67c8277d470161fe23b4be7a5bcdf641e68"
|
|
5382
|
+
],
|
|
5383
|
+
next_step_selector_commitments: [
|
|
5384
|
+
"246ce82e01ed312e81492f132da2ee16bc13cc0024fbcc668de30173ad59067f0f072a892451cc495f5d9b8b99c8dc29be1d42d3004aed45fd5b2cd32a420016"
|
|
5385
|
+
],
|
|
5386
|
+
permutation_commitments: [
|
|
5387
|
+
"19c4143f41738480adc5ae49922d31b8a5afaa1d25ced5c20b869c0e1ccad91920c267c53d33907318cd194ba2ea08a85f250779765ba4121f7a0edfe1afe22b",
|
|
5388
|
+
"114bda14aa702a0815e3f91318a08a2798244420fd6675c8fc3cc2b0232298890d2eb3c1f27a83f4a3be777524d6cc65aa435e0a472fae8d1158e0a6ded685d0",
|
|
5389
|
+
"289f0b046968d2c095d05350e43996756fc85d2deb0e267a069615f0889a249413bdbe6f09edb4db956b8f3fc4488c4681cd52469dc0d419dab99a65b88309f7",
|
|
5390
|
+
"16dd74a2089960aac0d68309d5e81c6b45c29fafe4d42c922c06eb633ed48d551d347d1f43ee9b137772eefc43a6dcdf5ac35ee1615bc8f7c243bce071c410a9"
|
|
5391
|
+
],
|
|
5392
|
+
non_residues: [
|
|
5393
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5394
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5395
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5396
|
+
],
|
|
5397
|
+
g2_elements: [
|
|
5398
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5399
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5400
|
+
]
|
|
5401
|
+
},
|
|
5402
|
+
tally_vkey: {
|
|
5403
|
+
n: 524287,
|
|
5404
|
+
num_inputs: 1,
|
|
5405
|
+
selector_commitments: [
|
|
5406
|
+
"18c2bb75c8ed53a5d15a56cc91c56f14c832419994ce7187c7c98b5e622cac0808b773f05e09822d8d267646198a78359ea2aa6fbaeb01317142f99fd11da6c0",
|
|
5407
|
+
"181499098243a5968f5490b7759aa15f0f769f24f3f4219b69f96913cf4fb23c1cd7b3f109196d7577390fd2e6d3930a71b0559aff756f3ca43eef66ce7333f4",
|
|
5408
|
+
"07ba2bdd452503fb16b56ea2940e95a98118c9dd120ae192680fe2b80bdb26f10ac6cdc7cb12b581a8c64d45b5af3d253c4282405eed3fd4d091ae05aac45cb6",
|
|
5409
|
+
"1caf01f1775eeafa78a11202e926ee92be997ce040f9c6fbce161348a40aeda70d9f15738cccf538083784e566ceef651d000223ae810c980e2d5d98b91b4665",
|
|
5410
|
+
"2c377c69cae1d591af413da2fd986ef3dca595d0c5817ee4932b92169d37c52d1218ce63dde705ebd1dc66d9b62daca287e4fdf6800b69204e5b78bfe84365a1",
|
|
5411
|
+
"175dd4ff280e39f0e080c181f853845e40c4b91709a93e4398d24befc9cf556903675361817e031e86bd896ff1dd7bc1cc31ca920a101499db0c58d77f0730ec"
|
|
5412
|
+
],
|
|
5413
|
+
next_step_selector_commitments: [
|
|
5414
|
+
"12d76999d26137d433f7119ab34f3fc63cfedb9172052cfb34acfc3cdc570f511aba802ebe92b87f913496314b938cf526078280a68826c90b686b90420c7742"
|
|
5415
|
+
],
|
|
5416
|
+
permutation_commitments: [
|
|
5417
|
+
"167b05c0132399e7126e8d16efb224b1c6729942048fc7e730fd1451116e0a6e05acaf2a6d2c88cc25610474b651c8cdcb7e8e14e59ddfad819123e888c4b1b6",
|
|
5418
|
+
"25aed62de4b701dc645e076543e2553c306010f2776c74edae55ea5253d9540403d042c4cb699cc04b2bb63d3c3edc0c85b049a84dc2fd44369f957d81363563",
|
|
5419
|
+
"0e77fb0b0e84da1d955da3d66dbb8fa3988f22e999a34bc4ac537a0f9187ac40156f8d7cb6d005fd85a0178d794f941b4e84832fd389a37c2a78112dac09b758",
|
|
5420
|
+
"051d3d906d457eaa9eff77a296dfa1760fd9ea379eec60487be38de91545ca2c1fcf457d6ac31afee10951245b0cc1e2c7674596f65955d189d48b6938fb3594"
|
|
5421
|
+
],
|
|
5422
|
+
non_residues: [
|
|
5423
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5424
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5425
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5426
|
+
],
|
|
5427
|
+
g2_elements: [
|
|
5428
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5429
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5430
|
+
]
|
|
5431
|
+
}
|
|
5432
|
+
}
|
|
5433
|
+
},
|
|
5434
|
+
"4-2-2-25": {
|
|
5435
|
+
parameter: {
|
|
5436
|
+
state_tree_depth: "4",
|
|
5437
|
+
int_state_tree_depth: "2",
|
|
5438
|
+
vote_option_tree_depth: "2",
|
|
5439
|
+
message_batch_size: "25"
|
|
5440
|
+
},
|
|
5441
|
+
groth16: {
|
|
5442
|
+
process_vkey: {
|
|
5443
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5444
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5445
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5446
|
+
vk_delta_2: "0d0fe390b9dd4d1d0f486787b6ea96765cbeaa8f00310fecc3429673c5866c081a27998596ba296f66f3f7b5e2450d1ce1bcc535c133b2e8b577ba07dc1ccb4c1895f7afb9b3168a6d628c9173157cd56ca51948cc66c129a25f80e3b665e4b12c9c50f0cc0d070978ed2fb8ce15956d67c5dc6c07c7f45f1facfb5522d7b656",
|
|
5447
|
+
vk_ic0: "0ff2b22774da5c0ba94db4d759827b8c962aaf44db2649eb10407de02a40463a26497581d6d0979ad7f9057f26e048109158b0872700e2ad8447ffc9b4bf146b",
|
|
5448
|
+
vk_ic1: "0a47be101a59d20641e1369c0b2b9fb839cd35ecbfbeac3866df43723b70c78d17e96303c417743d93b7726805b736f364d305036b50e4ad1b885fc41284daf5"
|
|
5449
|
+
},
|
|
5450
|
+
tally_vkey: {
|
|
5451
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5452
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5453
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5454
|
+
vk_delta_2: "08e44e0876bd574d8a3411e374884eb61da7292ca52903fa96553c37311b66ce0f2f529e59b1d37e55794a575d0f87548ca0d03331c19689bc203a68c1c4bae20e9fd25a7bffaa9b7409e694a48bc0d57f42df164d4a01bd5deecffedd2d3a3125eff290efb93eaf9c578cc7ee9d00406137607b9602de02424ff413ac948690",
|
|
5455
|
+
vk_ic0: "295c8e84b4b6b8de44b24f80eb5cae1df65e4877c4af8da2dbadfbfc3586dc790661b9e636f2c2a83028d11cbb7c753675481b65a5dfe32fff7a558231b3c9ef",
|
|
5456
|
+
vk_ic1: "299cfb28054cde0470bd7ff280349089350226d1ca154dcf6544b2680bf3bea925026e6644668273d6066ef6766c2f561c3607c523fbbd1379c5002376ef69c3"
|
|
5457
|
+
}
|
|
5458
|
+
},
|
|
5459
|
+
plonk: {
|
|
5460
|
+
process_vkey: {
|
|
5461
|
+
n: 2097151,
|
|
5462
|
+
num_inputs: 1,
|
|
5463
|
+
selector_commitments: [
|
|
5464
|
+
"126cbf10e0b68a56d45614be16c5bb48bd1374478e17b9fe1a78b726ea70f9b21f3cd20fd178d89e5923c422ef050ccc7134fbd76c9efdbb90f677ee41e01edb",
|
|
5465
|
+
"12813166f206c95eddd998a40d8d2e54e29dd393f543e3583a7999b18d674832024cdd935540bd3b96207ec0609c6718ad8b14e2ef315594454c57d606494485",
|
|
5466
|
+
"05da9eea3ee7151355067ced11a8e8ff57a56c758493afc9cbb6cfbacfc42e7b08993dfa25c85f20aeb7f64e87fe56ac8066cf6b8479dc96294e302ef5d55372",
|
|
5467
|
+
"2e446e540bacde7daea23c93a67bc6b1424b7c16b33fd2cee251b0d093cd78300030b8e340f01f320639d60b77724e58fc8a2d778b7b2a5df2c953ce34debeea",
|
|
5468
|
+
"1cf8c75b18071ede19d196b46a8776efc29ac514458a698d9f2e50b7bc692f6e06f7ff96897240eca31058fe330e8cbcd911324b79a3a34d03340a3cfed85fd5",
|
|
5469
|
+
"17101fb5c293438a695075b221219679e278e4bd147239c9fc69081b19cacefe218eb895f1456ca81e29731967588aee4b0758ea51aa28e5fefc81fed4a11513"
|
|
5470
|
+
],
|
|
5471
|
+
next_step_selector_commitments: [
|
|
5472
|
+
"0cebff4fe8cd70325f986088a1e17ae129a025481137bd80aef9c1f1c2e52f1e265a4ccae1ed89cb2fba527165f007898e70f988311ee4e4e87e41376cfeed03"
|
|
5473
|
+
],
|
|
5474
|
+
permutation_commitments: [
|
|
5475
|
+
"025b5db167721133693f0b6d9d7cfadce68ad15365ef1605dda4a6c809edeea61927b27ca11713fc683c88f6330e9621837b05e5db74d5994d1cf04bc3d529b3",
|
|
5476
|
+
"1fac93999f33b145613901846e6403d7f4237d582b51ccc4fb5c70038284c6e21cc804cc3cf7170b96da74fcbb30c81cd8c3405a629327c657025db7332f169a",
|
|
5477
|
+
"0b6d7d383de73dbfc16f2c0f3af763135ff05a12ec937548008cfee944c195f902336a68a50f62f595953e44401e872fb41abb66a733684b079ffe550d09c233",
|
|
5478
|
+
"225a1f5e92d105d3be026ae68904826f89b786faad75a846ef966ed714568bba28d1388786fde71dea206cdef16faa7a589e90863e6245d271e3f154c75c5531"
|
|
5479
|
+
],
|
|
5480
|
+
non_residues: [
|
|
5481
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5482
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5483
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5484
|
+
],
|
|
5485
|
+
g2_elements: [
|
|
5486
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5487
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5488
|
+
]
|
|
5489
|
+
},
|
|
5490
|
+
tally_vkey: {
|
|
5491
|
+
n: 1048575,
|
|
5492
|
+
num_inputs: 1,
|
|
5493
|
+
selector_commitments: [
|
|
5494
|
+
"1588fb667b3f0e4d0970b8208e4b6b4c729c4926b936f8d877017cf42d07ca15069643791d98abcd6b7d0b0546e7560ab9011e069f2ee48ede581fc72d8b5e04",
|
|
5495
|
+
"09c5480b103c44a81850ffd9a61ec21f7db41bc89996d8df075c3e029290eb5b083cb2b184d95c0761e585547be33250c8939929b87fdc39775ccea17d51b481",
|
|
5496
|
+
"278e239bcac0a945a17572a6d61ba59f705746e6893a10a44841933a8c8310e712e4ee913af9b77c8fdcdc365316aa9f1b8dc081eb99ad80265768ec9f484beb",
|
|
5497
|
+
"12532585ea307c5559b18a4d01db59b544a88088f61a5b5ed0431393e6f675af1309bf0dcaa7a552849e5f28d0300c8c61b18393fb638aed3b7d70e27bb91c35",
|
|
5498
|
+
"172e7ecb8e485aaee801fd78b8fd7c0b862baef65e39e6832cffa2170b6f981928d86ab5887e8c3210e34e03cada468bd501f60ec3a8fa35b4c7067d6fb8c6ae",
|
|
5499
|
+
"0c27211d046735fc681228b8366be2c8cf9a256cbd03dcd4af65152e94f95a6f1af151a5311b195b0f4acffeec4952cc52edbb7045aab61bbd3be9cd322ab99e"
|
|
5500
|
+
],
|
|
5501
|
+
next_step_selector_commitments: [
|
|
5502
|
+
"25ee15301d562e6c630946b3fbe36b9fbd8dfbd44ddf70cc825fb1fa1ebd966229081f6b9297da671c69064e10b8f5dd0f69b69d1bf79122c6197f119087ebe1"
|
|
5503
|
+
],
|
|
5504
|
+
permutation_commitments: [
|
|
5505
|
+
"194849a6ec5cb37e09d20801d387abbab04e453f630c5fbbf5c4819c5569480c0c8bf0ce2b4955cc4c891840da1d9e99feb81e8d43251dffbe4d6167639b9f9b",
|
|
5506
|
+
"17717d2638632d406b3c8aa69550c8aeed1b79def3ab55e9d0c4bdf21cc339ad07d3bd3a331145fc96f34c85469a34a8c93b53b7aa36bb5a94c31e3b4d47713e",
|
|
5507
|
+
"277b0c99b63c79bb9ed2f677c3987cf00acb293933dfced82b5afcb8bf0c34570d3187ce5c7e892582ddda4322cf7c50d41105fe98503fb60e41f4a08da5916d",
|
|
5508
|
+
"0489f6dec0f27a8c21d147ebb9781b68b4b73db065a6017924c543f6d9fadbe922d24c0946bd8b19df7659810296d063b557cdf7aba510b11e08fbf2e9d37931"
|
|
5509
|
+
],
|
|
5510
|
+
non_residues: [
|
|
5511
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5512
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5513
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5514
|
+
],
|
|
5515
|
+
g2_elements: [
|
|
5516
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5517
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5518
|
+
]
|
|
5519
|
+
}
|
|
5520
|
+
}
|
|
5521
|
+
},
|
|
5522
|
+
"6-3-3-125": {
|
|
5523
|
+
parameter: {
|
|
5524
|
+
state_tree_depth: "6",
|
|
5525
|
+
int_state_tree_depth: "3",
|
|
5526
|
+
vote_option_tree_depth: "3",
|
|
5527
|
+
message_batch_size: "125"
|
|
5528
|
+
},
|
|
5529
|
+
groth16: {
|
|
5530
|
+
process_vkey: {
|
|
5531
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5532
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5533
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5534
|
+
vk_delta_2: "057f25675851ef5a79a6d8706a43a6cd8e494cfb12c241ede46991d9174cf30605b081ff44f3ede774dab68ea9324c12308c13cb09cbb129adf94401b9134f5b16137d952fd32ab2d4243ebff4cb15d17206948ef17909ea8606886a8109bdad082f7d27e1cbf98925f055b39d1c89f9bcc4f6d92fdb920934ff5e37ba4d9b49",
|
|
5535
|
+
vk_ic0: "27c937c032a18a320566e934448a0ffceea7050492a509c45a3bcb7e8ff8905d20789ada31729a833a4f595ff9f49f88adb66f2ab987de15a15deccb0e785bf4",
|
|
5536
|
+
vk_ic1: "0ed2cefc103a2234dbc6bbd8634812d65332218b7589f4079b2c08eb5a4f5f63113a7f3cb53797a7f5819d7de7e3f0b2197d1c34790685a4a59af4314810420b"
|
|
5537
|
+
},
|
|
5538
|
+
tally_vkey: {
|
|
5539
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5540
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5541
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5542
|
+
vk_delta_2: "2065e91c00fcc5cbc3d974cf52e24de972bdb1b4d8ded629dec20b5c904c3fa327ffe02402094795ff4d02588c8268fcad738f69eb4c732a0c98b485035e1f4913ede11b074ff143a929673e581a547717c58ce01af87d9d8b28f65f506093a61013e367b93e6782129362065840a0af9b77d7d9659a84577176e64a918d8d4c",
|
|
5543
|
+
vk_ic0: "11db4a022aab89a265f06ff62aa18c74b21e913a8b23e7fce9cb46f76d1c4d9f2a7475b1eeb7be0a0dc457e6d52536ba351b621b63a7d77da75d4e773048537e",
|
|
5544
|
+
vk_ic1: "0f298d235d0822ad281386abdf511853529af4c864b0cd54140facebfc1356a3059cd6d0d4b27b39e5683548fe12025e2a6b2e2724c2ca87d2008ef932ed3801"
|
|
5545
|
+
}
|
|
5546
|
+
},
|
|
5547
|
+
plonk: {
|
|
5548
|
+
process_vkey: {
|
|
5549
|
+
n: 8388607,
|
|
5550
|
+
num_inputs: 1,
|
|
5551
|
+
selector_commitments: [
|
|
5552
|
+
"216533ab27390f98812429524326ac08736d636d2891fb81446796cc1771a3230642f49db115acc15a186a1013f91a08efcd05640eb137d700276e80fd05bc90",
|
|
5553
|
+
"11747f6f378e26dbdacff464ce7eb6a8869750d0fa7e508e263ac77b582c1e9b24ba3d208650b0c28943915c563cc94cc3f98cdb5fd8adc4f4d3e2a60eda3302",
|
|
5554
|
+
"09239eb768d8d47b91c7e08e2ec6a374571964ed16be293cdc35e112393c4fd1182a0794be7f1441418664e9f718b67ed392a7da3e2868375bcf629131bb2680",
|
|
5555
|
+
"2020f7db24940bbf38d097ea5d7ef7253e38b154d7eb0ff1782ea18ce215dd7b0e8475197b071b118adc6418b7b7fb42fea19b6272d1bb460cc47deacb299ec7",
|
|
5556
|
+
"298923db1618185064bbab5df30ee03a3c9cbc7ce8f096d76cbd2a5ab3df86cd05bbedb938e6e0ff35cce23609458aff8081cdf3163655672074d1b18b0007bd",
|
|
5557
|
+
"0effaabe8c6e8a076aedd36d10f2926f9871f552d93e22bfbe69e3c828a546fa2d0cd163b49a6de219ac2c048a8459ae448047748ba078b9d5d07b290c946b08"
|
|
5558
|
+
],
|
|
5559
|
+
next_step_selector_commitments: [
|
|
5560
|
+
"13e3d7299e30e6142699469d620df721eca35bbb807a8f4298f165260fdc24f823e7bd9bcb6506a094a5ebef44434c62e4bcb5d3dd7e092c49d5cb80b8ae0757"
|
|
5561
|
+
],
|
|
5562
|
+
permutation_commitments: [
|
|
5563
|
+
"03d94ab8fdc681523a8eec10f1ce5552937c268d1d970f9e75ee8657cd4c12a81e03476f83ef5c14db2f4d931b833a3b65b8d5689b37cc7f183914c90d3d065d",
|
|
5564
|
+
"1b9c6ef20e68355c535bda6ff04a8a61d7552a594bb8e88d69a6f8840ddab04d2884824cc356d0d90cc278c247fc531de62efca4b19ed1be6f071144474d2037",
|
|
5565
|
+
"1ff82de8312481e1591d2d1c2698fa3944b3f0afa0dd702be8a1a944a5a8997323ffbd0ab39a2e13608a8e76803c33ffda7317bb7101e335ce5552ed62dcd09d",
|
|
5566
|
+
"2cb2bbdd51d22b79957b0401ecb6fe089f05426ba092b1205fa92f39b36cc5fc0c36c3934e47b7d407d4cda0c78c2b3fb23162cb0d295e8a8cce1a274956c34a"
|
|
5567
|
+
],
|
|
5568
|
+
non_residues: [
|
|
5569
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5570
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5571
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5572
|
+
],
|
|
5573
|
+
g2_elements: [
|
|
5574
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5575
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5576
|
+
]
|
|
5577
|
+
},
|
|
5578
|
+
tally_vkey: {
|
|
5579
|
+
n: 8388607,
|
|
5580
|
+
num_inputs: 1,
|
|
5581
|
+
selector_commitments: [
|
|
5582
|
+
"258d101f9499e81c0d0da8986c659ef33da19d4955a142e56b4854d1327c902c1996baecd81432717a9cbf92ccf651e4217a788c1a2ed855f749480f8ce8203c",
|
|
5583
|
+
"1892a17c9c01389e3149b0663069a1ad4fd3c8e2db5ce99795b781c47b55acf9001cf5f0b4c1d088fa2058ca19cd2f1e9559ebe059897bb0aadcb540ce5f468a",
|
|
5584
|
+
"09912d6eaa4a22802451135d9a221ebf97c2ce8ad5bbb2942d5a860482e8e4202573995072c4b014cd0e9d09a1fd53ee7d602070b404288a7fd0d97b57d8f07d",
|
|
5585
|
+
"0c62ef7ad01b05b2c01fca6188de269d63d725348a07a99bbc50f24c1518aa871fdc61bbf42399433a0917c919dcfe9e851b206e1c37dec0908f69ad89bb1f8e",
|
|
5586
|
+
"07d181c1026ef4a6732bff3dffbc5ae0e3746e4860f478c6c2e8e258df2ed7671efe073fb31cf5a61c0eedceccb5e968220b9ff7e2b055b11d7c456a57fe7ac9",
|
|
5587
|
+
"1bbd7ad96893df675c811e5a2be184e2e3bc9af0ce30a7b26e53a916a10a777a01ffa70dbe585201ac09778429c04c71229392608095d220c7d82631a0caedd6"
|
|
5588
|
+
],
|
|
5589
|
+
next_step_selector_commitments: [
|
|
5590
|
+
"2ae6c5c98d4c384e8e645d85a4ca362de4c4e75efe3c79d5bcbd126a9e305b831618df99300c7327f1eac6a498c8feac6013d4ba09b7ea046340f99b0598a832"
|
|
5591
|
+
],
|
|
5592
|
+
permutation_commitments: [
|
|
5593
|
+
"2458c5fb474ab3e7ae9c6b82cc432a111954d8be5e7e9b4fc58c14e1aed77f3207426dbe08272aa69ba8b73809f27f9ff083641b5c3c896c386a74bbed3083dd",
|
|
5594
|
+
"0879ac4885674b1af0ab67c7b505bce6234f32a0335bdfd229023fea5f303ece0973ba8abc9ade8edcfb68c7d4b8b98272c7bf33eff841fec78d21c0c2e82aa6",
|
|
5595
|
+
"07b74f37fcbcb2d9962a529fbc254d54925aeb1be1a49517affeb3571ef3e31e3033f7900ff5bb5759cbb98b64ca7f42967278c328d00e60c042aa65f2178ded",
|
|
5596
|
+
"203c948fdc386e7bfbdc37363ab489e9ce3264f4ccd23c33dd8f2337fb9007a621cabf740aa26e522dcb7af6c0de9f93cbc69595b29b02e75c2f3507e97664ec"
|
|
5597
|
+
],
|
|
5598
|
+
non_residues: [
|
|
5599
|
+
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
5600
|
+
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
5601
|
+
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
5602
|
+
],
|
|
5603
|
+
g2_elements: [
|
|
5604
|
+
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5605
|
+
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
5606
|
+
]
|
|
5607
|
+
}
|
|
5608
|
+
}
|
|
5609
|
+
},
|
|
5610
|
+
"9-4-3-625": {
|
|
5611
|
+
parameter: {
|
|
5612
|
+
state_tree_depth: "9",
|
|
5613
|
+
int_state_tree_depth: "4",
|
|
5614
|
+
message_batch_size: "625",
|
|
5615
|
+
vote_option_tree_depth: "3"
|
|
5616
|
+
},
|
|
5617
|
+
groth16: {
|
|
5618
|
+
process_1p1v_vkey: {
|
|
5619
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5620
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5621
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5622
|
+
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5623
|
+
vk_ic0: "1195be678487bbc8c0ae726c0985a5caf6f75e3f8327926926c4f89e498ad733043e46e10b506d194b27275f402bc3fb208a2f5be69662e7c9898d1c0ece4f04",
|
|
5624
|
+
vk_ic1: "10c34362189a7ee44b1c5e57755d7e0d672dba552e614d5cd9a53081bee2333425879fa4e4a9e3fff287824cce35f94725ca0edb60a4ffcbf50becb2fd96cb0b"
|
|
5625
|
+
},
|
|
5626
|
+
tally_1p1v_vkey: {
|
|
5627
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5628
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5629
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5630
|
+
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5631
|
+
vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
|
|
5632
|
+
vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
|
|
5633
|
+
},
|
|
5634
|
+
process_qv_vkey: {
|
|
5635
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5636
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5637
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5638
|
+
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5639
|
+
vk_ic0: "1832600210a459fe61d971081d4baa1a1add23f87c8a8dc4042cd5cf6c6fdf8e3018489aec30d9deb26629e05965a3a7e038be58ce10c854cb7e1071f2708aad",
|
|
5640
|
+
vk_ic1: "0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6"
|
|
5641
|
+
},
|
|
5642
|
+
tally_qv_vkey: {
|
|
5643
|
+
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
5644
|
+
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
5645
|
+
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5646
|
+
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
5647
|
+
vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
|
|
5648
|
+
vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
|
|
5649
|
+
}
|
|
5650
|
+
}
|
|
5651
|
+
}
|
|
5652
|
+
};
|
|
5653
|
+
var QTR_LIB = {
|
|
5654
|
+
zeros: [
|
|
5655
|
+
"0",
|
|
5656
|
+
"14655542659562014735865511769057053982292279840403315552050801315682099828156",
|
|
5657
|
+
"19261153649140605024552417994922546473530072875902678653210025980873274131905",
|
|
5658
|
+
"21526503558325068664033192388586640128492121680588893182274749683522508994597",
|
|
5659
|
+
"20017764101928005973906869479218555869286328459998999367935018992260318153770",
|
|
5660
|
+
"16998355316577652097112514691750893516081130026395813155204269482715045879598",
|
|
5661
|
+
"2612442706402737973181840577010736087708621987282725873936541279764292204086",
|
|
5662
|
+
"17716535433480122581515618850811568065658392066947958324371350481921422579201",
|
|
5663
|
+
"17437916409890180001398333108882255895598851862997171508841759030332444017770"
|
|
5664
|
+
]
|
|
5665
|
+
};
|
|
5666
|
+
|
|
5667
|
+
// src/libs/contract/utils.ts
|
|
5668
|
+
function getContractParams(type, circuitType, proofSystem, maxVoter, maxOption) {
|
|
5669
|
+
let parameters;
|
|
5670
|
+
let groth16ProcessVkey = null;
|
|
5671
|
+
let groth16TallyVkey = null;
|
|
5672
|
+
let plonkProcessVkey = null;
|
|
5673
|
+
let plonkTallyVkey = null;
|
|
5674
|
+
let maciVoteType = null;
|
|
5675
|
+
let maciCertSystem = null;
|
|
5676
|
+
switch (circuitType) {
|
|
5677
|
+
case "0" /* IP1V */:
|
|
5678
|
+
maciVoteType = "0";
|
|
5679
|
+
break;
|
|
5680
|
+
case "1" /* QV */:
|
|
5681
|
+
maciVoteType = "1";
|
|
5682
|
+
break;
|
|
5683
|
+
default:
|
|
5684
|
+
throw new Error(
|
|
5685
|
+
`Invalid circuit type ${circuitType}, only support 1P1V and QV`
|
|
5686
|
+
);
|
|
5687
|
+
}
|
|
5688
|
+
switch (proofSystem) {
|
|
5689
|
+
case "groth16" /* GROTH16 */:
|
|
5690
|
+
maciCertSystem = "0";
|
|
5691
|
+
break;
|
|
5692
|
+
case "plonk" /* PLONK */:
|
|
5693
|
+
maciCertSystem = "1";
|
|
5694
|
+
break;
|
|
5695
|
+
default:
|
|
5696
|
+
throw new Error(
|
|
5697
|
+
`Invalid proof system ${proofSystem}, only support GROTH16 and PLONK`
|
|
5698
|
+
);
|
|
5699
|
+
}
|
|
5700
|
+
if (maxVoter <= 25 && maxOption <= 5) {
|
|
5701
|
+
parameters = CIRCUIT_INFO["2-1-1-5"].parameter;
|
|
5702
|
+
if (proofSystem === "groth16" /* GROTH16 */) {
|
|
5703
|
+
groth16ProcessVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].process_vkey;
|
|
5704
|
+
groth16TallyVkey = CIRCUIT_INFO["2-1-1-5"]["groth16"].tally_vkey;
|
|
5705
|
+
} else if (proofSystem === "plonk" /* PLONK */) {
|
|
5706
|
+
plonkProcessVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.process_vkey;
|
|
5707
|
+
plonkTallyVkey = CIRCUIT_INFO["2-1-1-5"]["plonk"]?.tally_vkey;
|
|
5708
|
+
}
|
|
5709
|
+
} else if (maxVoter <= 625 && maxOption <= 25) {
|
|
5710
|
+
parameters = CIRCUIT_INFO["4-2-2-25"].parameter;
|
|
5711
|
+
if (proofSystem === "groth16" /* GROTH16 */) {
|
|
5712
|
+
groth16ProcessVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].process_vkey;
|
|
5713
|
+
groth16TallyVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].tally_vkey;
|
|
5714
|
+
} else if (proofSystem === "plonk" /* PLONK */) {
|
|
5715
|
+
plonkProcessVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.process_vkey;
|
|
5716
|
+
plonkTallyVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.tally_vkey;
|
|
5717
|
+
}
|
|
5718
|
+
} else if (maxVoter <= 15625 && maxOption <= 125) {
|
|
5719
|
+
parameters = CIRCUIT_INFO["6-3-3-125"].parameter;
|
|
5720
|
+
if (proofSystem === "groth16" /* GROTH16 */) {
|
|
5721
|
+
groth16ProcessVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].process_vkey;
|
|
5722
|
+
groth16TallyVkey = CIRCUIT_INFO["6-3-3-125"]["groth16"].tally_vkey;
|
|
5723
|
+
} else if (proofSystem === "plonk" /* PLONK */) {
|
|
5724
|
+
plonkProcessVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.process_vkey;
|
|
5725
|
+
plonkTallyVkey = CIRCUIT_INFO["6-3-3-125"]["plonk"]?.tally_vkey;
|
|
5726
|
+
}
|
|
5727
|
+
} else if (maxVoter <= 1953125 && maxOption <= 125) {
|
|
5728
|
+
parameters = CIRCUIT_INFO["9-4-3-625"].parameter;
|
|
5729
|
+
if (proofSystem === "groth16" /* GROTH16 */) {
|
|
5730
|
+
if (circuitType === "0" /* IP1V */) {
|
|
5731
|
+
groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
|
|
5732
|
+
groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
|
|
5733
|
+
} else if (circuitType === "1" /* QV */) {
|
|
5734
|
+
groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
|
|
5735
|
+
groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
|
|
5736
|
+
}
|
|
5737
|
+
} else if (proofSystem === "plonk" /* PLONK */) {
|
|
5738
|
+
throw new Error("PLONK is not supported for MACI-9");
|
|
5739
|
+
}
|
|
5740
|
+
} else {
|
|
5741
|
+
throw new Error("Number of voters or options is too large.");
|
|
5742
|
+
}
|
|
5743
|
+
switch (type) {
|
|
5744
|
+
case "0" /* MACI */:
|
|
5745
|
+
return {
|
|
5746
|
+
parameters,
|
|
5747
|
+
groth16ProcessVkey,
|
|
5748
|
+
groth16TallyVkey,
|
|
5749
|
+
plonkProcessVkey,
|
|
5750
|
+
plonkTallyVkey,
|
|
5751
|
+
maciVoteType,
|
|
5752
|
+
maciCertSystem
|
|
5753
|
+
};
|
|
5754
|
+
case "1" /* AMACI */:
|
|
5755
|
+
return {
|
|
5756
|
+
// parameters,
|
|
5757
|
+
// groth16ProcessVkey,
|
|
5758
|
+
// groth16TallyVkey,
|
|
5759
|
+
// plonkProcessVkey,
|
|
5760
|
+
// plonkTallyVkey,
|
|
5761
|
+
};
|
|
5762
|
+
case "2" /* ORACLE_MACI */:
|
|
5763
|
+
if (circuitType === "0" /* IP1V */) {
|
|
5764
|
+
groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_1p1v_vkey;
|
|
5765
|
+
groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_1p1v_vkey;
|
|
5766
|
+
} else if (circuitType === "1" /* QV */) {
|
|
5767
|
+
groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
|
|
5768
|
+
groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
|
|
5769
|
+
}
|
|
5770
|
+
return {
|
|
5771
|
+
parameters: CIRCUIT_INFO["9-4-3-625"].parameter,
|
|
5772
|
+
groth16ProcessVkey,
|
|
5773
|
+
groth16TallyVkey,
|
|
5774
|
+
plonkProcessVkey: null,
|
|
5775
|
+
plonkTallyVkey: null,
|
|
5776
|
+
maciVoteType,
|
|
5777
|
+
maciCertSystem: "0"
|
|
5778
|
+
};
|
|
5779
|
+
}
|
|
5780
|
+
}
|
|
5781
|
+
function getAMaciRoundCircuitFee(network, maxVoter, maxOption) {
|
|
5782
|
+
let requiredFee = {
|
|
5783
|
+
denom: "peaka",
|
|
5784
|
+
amount: "0"
|
|
5785
|
+
};
|
|
5786
|
+
if (maxVoter <= 25 && maxOption <= 5) {
|
|
5787
|
+
if (network === "mainnet") {
|
|
5788
|
+
requiredFee.amount = "20000000000000000000";
|
|
5789
|
+
} else {
|
|
5790
|
+
requiredFee.amount = "20000000000000000000";
|
|
4643
5791
|
}
|
|
4644
|
-
)
|
|
4645
|
-
|
|
5792
|
+
} else if (maxVoter <= 625 && maxOption <= 25) {
|
|
5793
|
+
if (network === "mainnet") {
|
|
5794
|
+
requiredFee.amount = "750000000000000000000";
|
|
5795
|
+
} else {
|
|
5796
|
+
requiredFee.amount = "750000000000000000000";
|
|
5797
|
+
}
|
|
5798
|
+
} else {
|
|
5799
|
+
throw new Error("Number of voters or options is too large.");
|
|
5800
|
+
}
|
|
5801
|
+
return requiredFee;
|
|
4646
5802
|
}
|
|
4647
5803
|
|
|
4648
|
-
// src/
|
|
4649
|
-
var
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
5804
|
+
// src/libs/contract/contract.ts
|
|
5805
|
+
var import_stargate2 = require("@cosmjs/stargate");
|
|
5806
|
+
var Contract = class {
|
|
5807
|
+
constructor({
|
|
5808
|
+
network,
|
|
5809
|
+
rpcEndpoint,
|
|
5810
|
+
registryAddress,
|
|
5811
|
+
saasAddress,
|
|
5812
|
+
apiSaasAddress,
|
|
5813
|
+
maciCodeId,
|
|
5814
|
+
oracleCodeId,
|
|
5815
|
+
feegrantOperator,
|
|
5816
|
+
whitelistBackendPubkey
|
|
5817
|
+
}) {
|
|
5818
|
+
this.network = network;
|
|
5819
|
+
this.rpcEndpoint = rpcEndpoint;
|
|
5820
|
+
this.registryAddress = registryAddress;
|
|
5821
|
+
this.saasAddress = saasAddress;
|
|
5822
|
+
this.apiSaasAddress = apiSaasAddress;
|
|
5823
|
+
this.maciCodeId = maciCodeId;
|
|
5824
|
+
this.oracleCodeId = oracleCodeId;
|
|
5825
|
+
this.feegrantOperator = feegrantOperator;
|
|
5826
|
+
this.whitelistBackendPubkey = whitelistBackendPubkey;
|
|
5827
|
+
}
|
|
5828
|
+
async createAMaciRound({
|
|
5829
|
+
signer,
|
|
5830
|
+
startVoting,
|
|
5831
|
+
endVoting,
|
|
5832
|
+
operator,
|
|
5833
|
+
whitelist,
|
|
5834
|
+
title,
|
|
5835
|
+
description,
|
|
5836
|
+
link,
|
|
5837
|
+
maxVoter,
|
|
5838
|
+
voteOptionMap,
|
|
5839
|
+
voiceCreditAmount,
|
|
5840
|
+
circuitType,
|
|
5841
|
+
preDeactivateRoot,
|
|
5842
|
+
oracleWhitelistPubkey,
|
|
5843
|
+
fee = "auto"
|
|
5844
|
+
}) {
|
|
5845
|
+
const start_time = (startVoting.getTime() * 10 ** 6).toString();
|
|
5846
|
+
const end_time = (endVoting.getTime() * 10 ** 6).toString();
|
|
5847
|
+
const client = await createRegistryClientBy({
|
|
5848
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
5849
|
+
wallet: signer,
|
|
5850
|
+
contractAddress: this.registryAddress
|
|
5851
|
+
});
|
|
5852
|
+
const requiredFee = getAMaciRoundCircuitFee(
|
|
5853
|
+
this.network,
|
|
5854
|
+
maxVoter,
|
|
5855
|
+
voteOptionMap.length
|
|
5856
|
+
);
|
|
5857
|
+
preDeactivateRoot = preDeactivateRoot || "0";
|
|
5858
|
+
const res = await client.createRound(
|
|
5859
|
+
{
|
|
5860
|
+
operator,
|
|
5861
|
+
preDeactivateRoot,
|
|
5862
|
+
voiceCreditAmount,
|
|
5863
|
+
whitelist,
|
|
5864
|
+
roundInfo: {
|
|
5865
|
+
title,
|
|
5866
|
+
description: description || "",
|
|
5867
|
+
link: link || ""
|
|
5868
|
+
},
|
|
5869
|
+
votingTime: {
|
|
5870
|
+
start_time,
|
|
5871
|
+
end_time
|
|
5872
|
+
},
|
|
5873
|
+
maxVoter: maxVoter.toString(),
|
|
5874
|
+
voteOptionMap,
|
|
5875
|
+
certificationSystem: "0",
|
|
5876
|
+
circuitType,
|
|
5877
|
+
oracleWhitelistPubkey
|
|
5878
|
+
},
|
|
5879
|
+
fee,
|
|
5880
|
+
void 0,
|
|
5881
|
+
[requiredFee]
|
|
5882
|
+
);
|
|
5883
|
+
let contractAddress = "";
|
|
5884
|
+
res.events.map((event) => {
|
|
5885
|
+
if (event.type === "wasm") {
|
|
5886
|
+
let actionEvent = event.attributes.find(
|
|
5887
|
+
(attr) => attr.key === "action"
|
|
5888
|
+
);
|
|
5889
|
+
if (actionEvent.value === "created_round") {
|
|
5890
|
+
contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
|
|
5891
|
+
}
|
|
5892
|
+
}
|
|
5893
|
+
});
|
|
5894
|
+
return {
|
|
5895
|
+
...res,
|
|
5896
|
+
contractAddress
|
|
5897
|
+
};
|
|
5898
|
+
}
|
|
5899
|
+
async createMaciRound({
|
|
5900
|
+
signer,
|
|
5901
|
+
operatorPubkey,
|
|
5902
|
+
startVoting,
|
|
5903
|
+
endVoting,
|
|
5904
|
+
whitelist,
|
|
5905
|
+
title,
|
|
5906
|
+
description,
|
|
5907
|
+
link,
|
|
5908
|
+
maxVoter,
|
|
5909
|
+
maxOption,
|
|
5910
|
+
circuitType,
|
|
5911
|
+
certSystemType,
|
|
5912
|
+
fee = "auto"
|
|
5913
|
+
}) {
|
|
5914
|
+
const start_time = (startVoting.getTime() * 10 ** 6).toString();
|
|
5915
|
+
const end_time = (endVoting.getTime() * 10 ** 6).toString();
|
|
5916
|
+
const [{ address }] = await signer.getAccounts();
|
|
5917
|
+
const client = await createContractClientByWallet(this.rpcEndpoint, signer);
|
|
5918
|
+
const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
|
|
5919
|
+
BigInt(operatorPubkey)
|
|
5920
|
+
);
|
|
5921
|
+
const {
|
|
5922
|
+
parameters,
|
|
5923
|
+
groth16ProcessVkey,
|
|
5924
|
+
groth16TallyVkey,
|
|
5925
|
+
plonkProcessVkey,
|
|
5926
|
+
plonkTallyVkey,
|
|
5927
|
+
maciVoteType,
|
|
5928
|
+
maciCertSystem
|
|
5929
|
+
} = getContractParams(
|
|
5930
|
+
"0" /* MACI */,
|
|
5931
|
+
circuitType,
|
|
5932
|
+
certSystemType,
|
|
5933
|
+
maxVoter,
|
|
5934
|
+
maxOption
|
|
5935
|
+
);
|
|
5936
|
+
const instantiateResponse = await client.instantiate(
|
|
5937
|
+
address,
|
|
5938
|
+
this.maciCodeId,
|
|
5939
|
+
{
|
|
5940
|
+
round_info: { title, description: description || "", link: link || "" },
|
|
5941
|
+
voting_time: {
|
|
5942
|
+
start_time,
|
|
5943
|
+
end_time
|
|
5944
|
+
},
|
|
5945
|
+
parameters,
|
|
5946
|
+
coordinator: {
|
|
5947
|
+
x: operatorPubkeyX.toString(),
|
|
5948
|
+
y: operatorPubkeyY.toString()
|
|
5949
|
+
},
|
|
5950
|
+
groth16_process_vkey: groth16ProcessVkey,
|
|
5951
|
+
groth16_tally_vkey: groth16TallyVkey,
|
|
5952
|
+
plonk_process_vkey: plonkProcessVkey,
|
|
5953
|
+
plonk_tally_vkey: plonkTallyVkey,
|
|
5954
|
+
max_vote_options: maxOption.toString(),
|
|
5955
|
+
whitelist,
|
|
5956
|
+
circuit_type: maciVoteType,
|
|
5957
|
+
certification_system: maciCertSystem,
|
|
5958
|
+
qtr_lib: QTR_LIB
|
|
4683
5959
|
},
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
4697
|
-
|
|
4698
|
-
|
|
4699
|
-
|
|
4700
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
4709
|
-
|
|
4710
|
-
|
|
4711
|
-
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
|
|
4717
|
-
|
|
4718
|
-
|
|
4719
|
-
|
|
4720
|
-
|
|
4721
|
-
|
|
4722
|
-
|
|
5960
|
+
`[MACI] ${title}`,
|
|
5961
|
+
fee
|
|
5962
|
+
);
|
|
5963
|
+
return instantiateResponse;
|
|
5964
|
+
}
|
|
5965
|
+
async createOracleMaciRound({
|
|
5966
|
+
signer,
|
|
5967
|
+
operatorPubkey,
|
|
5968
|
+
startVoting,
|
|
5969
|
+
endVoting,
|
|
5970
|
+
title,
|
|
5971
|
+
description,
|
|
5972
|
+
link,
|
|
5973
|
+
voteOptionMap,
|
|
5974
|
+
circuitType,
|
|
5975
|
+
whitelistEcosystem,
|
|
5976
|
+
whitelistSnapshotHeight,
|
|
5977
|
+
whitelistVotingPowerArgs,
|
|
5978
|
+
fee = "auto"
|
|
5979
|
+
}) {
|
|
5980
|
+
const start_time = (startVoting.getTime() * 1e6).toString();
|
|
5981
|
+
const end_time = (endVoting.getTime() * 1e6).toString();
|
|
5982
|
+
const [{ address }] = await signer.getAccounts();
|
|
5983
|
+
const client = await createContractClientByWallet(this.rpcEndpoint, signer);
|
|
5984
|
+
const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
|
|
5985
|
+
BigInt(operatorPubkey)
|
|
5986
|
+
);
|
|
5987
|
+
const { maciVoteType, maciCertSystem } = getContractParams(
|
|
5988
|
+
"2" /* ORACLE_MACI */,
|
|
5989
|
+
circuitType,
|
|
5990
|
+
"groth16" /* GROTH16 */,
|
|
5991
|
+
0,
|
|
5992
|
+
0
|
|
5993
|
+
);
|
|
5994
|
+
const instantiateResponse = await client.instantiate(
|
|
5995
|
+
address,
|
|
5996
|
+
this.oracleCodeId,
|
|
5997
|
+
{
|
|
5998
|
+
round_info: { title, description: description || "", link: link || "" },
|
|
5999
|
+
voting_time: {
|
|
6000
|
+
start_time,
|
|
6001
|
+
end_time
|
|
6002
|
+
},
|
|
6003
|
+
coordinator: {
|
|
6004
|
+
x: operatorPubkeyX.toString(),
|
|
6005
|
+
y: operatorPubkeyY.toString()
|
|
6006
|
+
},
|
|
6007
|
+
vote_option_map: voteOptionMap,
|
|
6008
|
+
whitelist_backend_pubkey: this.whitelistBackendPubkey,
|
|
6009
|
+
whitelist_ecosystem: whitelistEcosystem,
|
|
6010
|
+
whitelist_snapshot_height: whitelistSnapshotHeight,
|
|
6011
|
+
whitelist_voting_power_args: whitelistVotingPowerArgs,
|
|
6012
|
+
circuit_type: maciVoteType,
|
|
6013
|
+
certification_system: maciCertSystem,
|
|
6014
|
+
feegrant_operator: this.feegrantOperator
|
|
4723
6015
|
},
|
|
4724
|
-
|
|
4725
|
-
|
|
4726
|
-
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4732
|
-
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
int_state_tree_depth: "2",
|
|
4760
|
-
vote_option_tree_depth: "2",
|
|
4761
|
-
message_batch_size: "25"
|
|
4762
|
-
},
|
|
4763
|
-
groth16: {
|
|
4764
|
-
process_vkey: {
|
|
4765
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4766
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4767
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4768
|
-
vk_delta_2: "0d0fe390b9dd4d1d0f486787b6ea96765cbeaa8f00310fecc3429673c5866c081a27998596ba296f66f3f7b5e2450d1ce1bcc535c133b2e8b577ba07dc1ccb4c1895f7afb9b3168a6d628c9173157cd56ca51948cc66c129a25f80e3b665e4b12c9c50f0cc0d070978ed2fb8ce15956d67c5dc6c07c7f45f1facfb5522d7b656",
|
|
4769
|
-
vk_ic0: "0ff2b22774da5c0ba94db4d759827b8c962aaf44db2649eb10407de02a40463a26497581d6d0979ad7f9057f26e048109158b0872700e2ad8447ffc9b4bf146b",
|
|
4770
|
-
vk_ic1: "0a47be101a59d20641e1369c0b2b9fb839cd35ecbfbeac3866df43723b70c78d17e96303c417743d93b7726805b736f364d305036b50e4ad1b885fc41284daf5"
|
|
6016
|
+
`[Oracle MACI] ${title}`,
|
|
6017
|
+
fee
|
|
6018
|
+
);
|
|
6019
|
+
return instantiateResponse;
|
|
6020
|
+
}
|
|
6021
|
+
async createSaasOracleMaciRound({
|
|
6022
|
+
signer,
|
|
6023
|
+
operatorPubkey,
|
|
6024
|
+
startVoting,
|
|
6025
|
+
endVoting,
|
|
6026
|
+
title,
|
|
6027
|
+
description,
|
|
6028
|
+
link,
|
|
6029
|
+
maxVoter,
|
|
6030
|
+
voteOptionMap,
|
|
6031
|
+
whitelistBackendPubkey,
|
|
6032
|
+
gasStation = false,
|
|
6033
|
+
fee = 1.8
|
|
6034
|
+
}) {
|
|
6035
|
+
const startTime = (startVoting.getTime() * 1e6).toString();
|
|
6036
|
+
const endTime = (endVoting.getTime() * 1e6).toString();
|
|
6037
|
+
const client = await createSaasClientBy({
|
|
6038
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6039
|
+
wallet: signer,
|
|
6040
|
+
contractAddress: this.saasAddress
|
|
6041
|
+
});
|
|
6042
|
+
const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
|
|
6043
|
+
BigInt(operatorPubkey)
|
|
6044
|
+
);
|
|
6045
|
+
const roundParams = {
|
|
6046
|
+
certificationSystem: "0",
|
|
6047
|
+
circuitType: "0",
|
|
6048
|
+
coordinator: {
|
|
6049
|
+
x: operatorPubkeyX.toString(),
|
|
6050
|
+
y: operatorPubkeyY.toString()
|
|
4771
6051
|
},
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
vk_ic0: "295c8e84b4b6b8de44b24f80eb5cae1df65e4877c4af8da2dbadfbfc3586dc790661b9e636f2c2a83028d11cbb7c753675481b65a5dfe32fff7a558231b3c9ef",
|
|
4778
|
-
vk_ic1: "299cfb28054cde0470bd7ff280349089350226d1ca154dcf6544b2680bf3bea925026e6644668273d6066ef6766c2f561c3607c523fbbd1379c5002376ef69c3"
|
|
4779
|
-
}
|
|
4780
|
-
},
|
|
4781
|
-
plonk: {
|
|
4782
|
-
process_vkey: {
|
|
4783
|
-
n: 2097151,
|
|
4784
|
-
num_inputs: 1,
|
|
4785
|
-
selector_commitments: [
|
|
4786
|
-
"126cbf10e0b68a56d45614be16c5bb48bd1374478e17b9fe1a78b726ea70f9b21f3cd20fd178d89e5923c422ef050ccc7134fbd76c9efdbb90f677ee41e01edb",
|
|
4787
|
-
"12813166f206c95eddd998a40d8d2e54e29dd393f543e3583a7999b18d674832024cdd935540bd3b96207ec0609c6718ad8b14e2ef315594454c57d606494485",
|
|
4788
|
-
"05da9eea3ee7151355067ced11a8e8ff57a56c758493afc9cbb6cfbacfc42e7b08993dfa25c85f20aeb7f64e87fe56ac8066cf6b8479dc96294e302ef5d55372",
|
|
4789
|
-
"2e446e540bacde7daea23c93a67bc6b1424b7c16b33fd2cee251b0d093cd78300030b8e340f01f320639d60b77724e58fc8a2d778b7b2a5df2c953ce34debeea",
|
|
4790
|
-
"1cf8c75b18071ede19d196b46a8776efc29ac514458a698d9f2e50b7bc692f6e06f7ff96897240eca31058fe330e8cbcd911324b79a3a34d03340a3cfed85fd5",
|
|
4791
|
-
"17101fb5c293438a695075b221219679e278e4bd147239c9fc69081b19cacefe218eb895f1456ca81e29731967588aee4b0758ea51aa28e5fefc81fed4a11513"
|
|
4792
|
-
],
|
|
4793
|
-
next_step_selector_commitments: [
|
|
4794
|
-
"0cebff4fe8cd70325f986088a1e17ae129a025481137bd80aef9c1f1c2e52f1e265a4ccae1ed89cb2fba527165f007898e70f988311ee4e4e87e41376cfeed03"
|
|
4795
|
-
],
|
|
4796
|
-
permutation_commitments: [
|
|
4797
|
-
"025b5db167721133693f0b6d9d7cfadce68ad15365ef1605dda4a6c809edeea61927b27ca11713fc683c88f6330e9621837b05e5db74d5994d1cf04bc3d529b3",
|
|
4798
|
-
"1fac93999f33b145613901846e6403d7f4237d582b51ccc4fb5c70038284c6e21cc804cc3cf7170b96da74fcbb30c81cd8c3405a629327c657025db7332f169a",
|
|
4799
|
-
"0b6d7d383de73dbfc16f2c0f3af763135ff05a12ec937548008cfee944c195f902336a68a50f62f595953e44401e872fb41abb66a733684b079ffe550d09c233",
|
|
4800
|
-
"225a1f5e92d105d3be026ae68904826f89b786faad75a846ef966ed714568bba28d1388786fde71dea206cdef16faa7a589e90863e6245d271e3f154c75c5531"
|
|
4801
|
-
],
|
|
4802
|
-
non_residues: [
|
|
4803
|
-
"0000000000000000000000000000000000000000000000000000000000000005",
|
|
4804
|
-
"0000000000000000000000000000000000000000000000000000000000000007",
|
|
4805
|
-
"000000000000000000000000000000000000000000000000000000000000000a"
|
|
4806
|
-
],
|
|
4807
|
-
g2_elements: [
|
|
4808
|
-
"198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4809
|
-
"260e01b251f6f1c7e7ff4e580791dee8ea51d87a358e038b4efe30fac09383c10118c4d5b837bcc2bc89b5b398b5974e9f5944073b32078b7e231fec938883b004fc6369f7110fe3d25156c1bb9a72859cf2a04641f99ba4ee413c80da6a5fe422febda3c0c0632a56475b4214e5615e11e6dd3f96e6cea2854a87d4dacc5e55"
|
|
4810
|
-
]
|
|
6052
|
+
maxVoters: maxVoter,
|
|
6053
|
+
roundInfo: {
|
|
6054
|
+
title,
|
|
6055
|
+
description: description || "",
|
|
6056
|
+
link: link || ""
|
|
4811
6057
|
},
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
"
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
6058
|
+
startTime,
|
|
6059
|
+
endTime,
|
|
6060
|
+
voteOptionMap,
|
|
6061
|
+
whitelistBackendPubkey: whitelistBackendPubkey || this.whitelistBackendPubkey
|
|
6062
|
+
};
|
|
6063
|
+
let createResponse;
|
|
6064
|
+
if (gasStation && typeof fee !== "object") {
|
|
6065
|
+
const [{ address }] = await signer.getAccounts();
|
|
6066
|
+
const contractClient = await this.contractClient({ signer });
|
|
6067
|
+
const msg = {
|
|
6068
|
+
create_oracle_maci_round: {
|
|
6069
|
+
certification_system: "0",
|
|
6070
|
+
circuit_type: "0",
|
|
6071
|
+
coordinator: roundParams.coordinator,
|
|
6072
|
+
max_voters: roundParams.maxVoters.toString(),
|
|
6073
|
+
round_info: roundParams.roundInfo,
|
|
6074
|
+
start_time: roundParams.startTime,
|
|
6075
|
+
end_time: roundParams.endTime,
|
|
6076
|
+
vote_option_map: roundParams.voteOptionMap,
|
|
6077
|
+
whitelist_backend_pubkey: roundParams.whitelistBackendPubkey
|
|
6078
|
+
}
|
|
6079
|
+
};
|
|
6080
|
+
const gasEstimation = await contractClient.simulate(
|
|
6081
|
+
address,
|
|
6082
|
+
[
|
|
6083
|
+
{
|
|
6084
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6085
|
+
value: {
|
|
6086
|
+
sender: address,
|
|
6087
|
+
contract: this.saasAddress,
|
|
6088
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6089
|
+
}
|
|
6090
|
+
}
|
|
4836
6091
|
],
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
6092
|
+
""
|
|
6093
|
+
);
|
|
6094
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6095
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6096
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6097
|
+
Math.round(gasEstimation * multiplier),
|
|
6098
|
+
gasPrice
|
|
6099
|
+
);
|
|
6100
|
+
const grantFee = {
|
|
6101
|
+
amount: calculatedFee.amount,
|
|
6102
|
+
gas: calculatedFee.gas,
|
|
6103
|
+
granter: this.saasAddress
|
|
6104
|
+
};
|
|
6105
|
+
createResponse = await client.createOracleMaciRound(
|
|
6106
|
+
roundParams,
|
|
6107
|
+
grantFee
|
|
6108
|
+
);
|
|
6109
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6110
|
+
const grantFee = {
|
|
6111
|
+
...fee,
|
|
6112
|
+
granter: this.saasAddress
|
|
6113
|
+
};
|
|
6114
|
+
createResponse = await client.createOracleMaciRound(
|
|
6115
|
+
roundParams,
|
|
6116
|
+
grantFee
|
|
6117
|
+
);
|
|
6118
|
+
} else {
|
|
6119
|
+
createResponse = await client.createOracleMaciRound(roundParams, fee);
|
|
4842
6120
|
}
|
|
4843
|
-
|
|
4844
|
-
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
process_vkey: {
|
|
4853
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4854
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4855
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4856
|
-
vk_delta_2: "057f25675851ef5a79a6d8706a43a6cd8e494cfb12c241ede46991d9174cf30605b081ff44f3ede774dab68ea9324c12308c13cb09cbb129adf94401b9134f5b16137d952fd32ab2d4243ebff4cb15d17206948ef17909ea8606886a8109bdad082f7d27e1cbf98925f055b39d1c89f9bcc4f6d92fdb920934ff5e37ba4d9b49",
|
|
4857
|
-
vk_ic0: "27c937c032a18a320566e934448a0ffceea7050492a509c45a3bcb7e8ff8905d20789ada31729a833a4f595ff9f49f88adb66f2ab987de15a15deccb0e785bf4",
|
|
4858
|
-
vk_ic1: "0ed2cefc103a2234dbc6bbd8634812d65332218b7589f4079b2c08eb5a4f5f63113a7f3cb53797a7f5819d7de7e3f0b2197d1c34790685a4a59af4314810420b"
|
|
4859
|
-
},
|
|
4860
|
-
tally_vkey: {
|
|
4861
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4862
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4863
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4864
|
-
vk_delta_2: "2065e91c00fcc5cbc3d974cf52e24de972bdb1b4d8ded629dec20b5c904c3fa327ffe02402094795ff4d02588c8268fcad738f69eb4c732a0c98b485035e1f4913ede11b074ff143a929673e581a547717c58ce01af87d9d8b28f65f506093a61013e367b93e6782129362065840a0af9b77d7d9659a84577176e64a918d8d4c",
|
|
4865
|
-
vk_ic0: "11db4a022aab89a265f06ff62aa18c74b21e913a8b23e7fce9cb46f76d1c4d9f2a7475b1eeb7be0a0dc457e6d52536ba351b621b63a7d77da75d4e773048537e",
|
|
4866
|
-
vk_ic1: "0f298d235d0822ad281386abdf511853529af4c864b0cd54140facebfc1356a3059cd6d0d4b27b39e5683548fe12025e2a6b2e2724c2ca87d2008ef932ed3801"
|
|
6121
|
+
let contractAddress = "";
|
|
6122
|
+
createResponse.events.map((event) => {
|
|
6123
|
+
if (event.type === "wasm") {
|
|
6124
|
+
let actionEvent = event.attributes.find(
|
|
6125
|
+
(attr) => attr.key === "action"
|
|
6126
|
+
);
|
|
6127
|
+
if (actionEvent.value === "created_oracle_maci_round") {
|
|
6128
|
+
contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
|
|
6129
|
+
}
|
|
4867
6130
|
}
|
|
4868
|
-
}
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
|
|
4872
|
-
|
|
4873
|
-
|
|
4874
|
-
|
|
4875
|
-
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
6131
|
+
});
|
|
6132
|
+
return {
|
|
6133
|
+
...createResponse,
|
|
6134
|
+
contractAddress
|
|
6135
|
+
};
|
|
6136
|
+
}
|
|
6137
|
+
async setSaasOracleMaciRoundInfo({
|
|
6138
|
+
signer,
|
|
6139
|
+
contractAddress,
|
|
6140
|
+
title,
|
|
6141
|
+
description,
|
|
6142
|
+
link,
|
|
6143
|
+
gasStation = false,
|
|
6144
|
+
fee = 1.8
|
|
6145
|
+
}) {
|
|
6146
|
+
const client = await createSaasClientBy({
|
|
6147
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6148
|
+
wallet: signer,
|
|
6149
|
+
contractAddress: this.saasAddress
|
|
6150
|
+
});
|
|
6151
|
+
const roundInfo = {
|
|
6152
|
+
title,
|
|
6153
|
+
description,
|
|
6154
|
+
link
|
|
6155
|
+
};
|
|
6156
|
+
if (gasStation && typeof fee !== "object") {
|
|
6157
|
+
const [{ address }] = await signer.getAccounts();
|
|
6158
|
+
const contractClient = await this.contractClient({ signer });
|
|
6159
|
+
const msg = {
|
|
6160
|
+
set_round_info: {
|
|
6161
|
+
contract_addr: contractAddress,
|
|
6162
|
+
round_info: roundInfo
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6165
|
+
const gasEstimation = await contractClient.simulate(
|
|
6166
|
+
address,
|
|
6167
|
+
[
|
|
6168
|
+
{
|
|
6169
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6170
|
+
value: {
|
|
6171
|
+
sender: address,
|
|
6172
|
+
contract: this.saasAddress,
|
|
6173
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6174
|
+
}
|
|
6175
|
+
}
|
|
4889
6176
|
],
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
6177
|
+
""
|
|
6178
|
+
);
|
|
6179
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6180
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6181
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6182
|
+
Math.round(gasEstimation * multiplier),
|
|
6183
|
+
gasPrice
|
|
6184
|
+
);
|
|
6185
|
+
const grantFee = {
|
|
6186
|
+
amount: calculatedFee.amount,
|
|
6187
|
+
gas: calculatedFee.gas,
|
|
6188
|
+
granter: this.saasAddress
|
|
6189
|
+
};
|
|
6190
|
+
return client.setRoundInfo(
|
|
6191
|
+
{
|
|
6192
|
+
contractAddr: contractAddress,
|
|
6193
|
+
roundInfo
|
|
6194
|
+
},
|
|
6195
|
+
grantFee
|
|
6196
|
+
);
|
|
6197
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6198
|
+
const grantFee = {
|
|
6199
|
+
...fee,
|
|
6200
|
+
granter: this.saasAddress
|
|
6201
|
+
};
|
|
6202
|
+
return client.setRoundInfo(
|
|
6203
|
+
{
|
|
6204
|
+
contractAddr: contractAddress,
|
|
6205
|
+
roundInfo
|
|
6206
|
+
},
|
|
6207
|
+
grantFee
|
|
6208
|
+
);
|
|
6209
|
+
}
|
|
6210
|
+
return client.setRoundInfo(
|
|
6211
|
+
{
|
|
6212
|
+
contractAddr: contractAddress,
|
|
6213
|
+
roundInfo
|
|
6214
|
+
},
|
|
6215
|
+
fee
|
|
6216
|
+
);
|
|
6217
|
+
}
|
|
6218
|
+
async setSaasOracleMaciRoundVoteOptions({
|
|
6219
|
+
signer,
|
|
6220
|
+
contractAddress,
|
|
6221
|
+
voteOptionMap,
|
|
6222
|
+
gasStation = false,
|
|
6223
|
+
fee = 1.8
|
|
6224
|
+
}) {
|
|
6225
|
+
const client = await createSaasClientBy({
|
|
6226
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6227
|
+
wallet: signer,
|
|
6228
|
+
contractAddress: this.saasAddress
|
|
6229
|
+
});
|
|
6230
|
+
if (gasStation && typeof fee !== "object") {
|
|
6231
|
+
const [{ address }] = await signer.getAccounts();
|
|
6232
|
+
const contractClient = await this.contractClient({ signer });
|
|
6233
|
+
const msg = {
|
|
6234
|
+
set_vote_options_map: {
|
|
6235
|
+
contract_addr: contractAddress,
|
|
6236
|
+
vote_option_map: voteOptionMap
|
|
6237
|
+
}
|
|
6238
|
+
};
|
|
6239
|
+
const gasEstimation = await contractClient.simulate(
|
|
6240
|
+
address,
|
|
6241
|
+
[
|
|
6242
|
+
{
|
|
6243
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6244
|
+
value: {
|
|
6245
|
+
sender: address,
|
|
6246
|
+
contract: this.saasAddress,
|
|
6247
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6248
|
+
}
|
|
6249
|
+
}
|
|
4894
6250
|
],
|
|
4895
|
-
|
|
4896
|
-
|
|
4897
|
-
|
|
4898
|
-
|
|
6251
|
+
""
|
|
6252
|
+
);
|
|
6253
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6254
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6255
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6256
|
+
Math.round(gasEstimation * multiplier),
|
|
6257
|
+
gasPrice
|
|
6258
|
+
);
|
|
6259
|
+
const grantFee = {
|
|
6260
|
+
amount: calculatedFee.amount,
|
|
6261
|
+
gas: calculatedFee.gas,
|
|
6262
|
+
granter: this.saasAddress
|
|
6263
|
+
};
|
|
6264
|
+
return client.setVoteOptionsMap(
|
|
6265
|
+
{
|
|
6266
|
+
contractAddr: contractAddress,
|
|
6267
|
+
voteOptionMap
|
|
6268
|
+
},
|
|
6269
|
+
grantFee
|
|
6270
|
+
);
|
|
6271
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6272
|
+
const grantFee = {
|
|
6273
|
+
...fee,
|
|
6274
|
+
granter: this.saasAddress
|
|
6275
|
+
};
|
|
6276
|
+
return client.setVoteOptionsMap(
|
|
6277
|
+
{
|
|
6278
|
+
contractAddr: contractAddress,
|
|
6279
|
+
voteOptionMap
|
|
6280
|
+
},
|
|
6281
|
+
grantFee
|
|
6282
|
+
);
|
|
6283
|
+
}
|
|
6284
|
+
return client.setVoteOptionsMap(
|
|
6285
|
+
{
|
|
6286
|
+
contractAddr: contractAddress,
|
|
6287
|
+
voteOptionMap
|
|
4899
6288
|
},
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
|
|
4917
|
-
|
|
4918
|
-
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
6289
|
+
fee
|
|
6290
|
+
);
|
|
6291
|
+
}
|
|
6292
|
+
async saasGrantToVoter({
|
|
6293
|
+
signer,
|
|
6294
|
+
baseAmount,
|
|
6295
|
+
contractAddress,
|
|
6296
|
+
grantee,
|
|
6297
|
+
gasStation = false,
|
|
6298
|
+
fee = 1.8
|
|
6299
|
+
}) {
|
|
6300
|
+
const client = await createSaasClientBy({
|
|
6301
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6302
|
+
wallet: signer,
|
|
6303
|
+
contractAddress: this.saasAddress
|
|
6304
|
+
});
|
|
6305
|
+
if (gasStation && typeof fee !== "object") {
|
|
6306
|
+
const [{ address }] = await signer.getAccounts();
|
|
6307
|
+
const contractClient = await this.contractClient({ signer });
|
|
6308
|
+
const msg = {
|
|
6309
|
+
grant_to_voter: {
|
|
6310
|
+
base_amount: baseAmount,
|
|
6311
|
+
contract_addr: contractAddress,
|
|
6312
|
+
grantee
|
|
6313
|
+
}
|
|
6314
|
+
};
|
|
6315
|
+
const gasEstimation = await contractClient.simulate(
|
|
6316
|
+
address,
|
|
6317
|
+
[
|
|
6318
|
+
{
|
|
6319
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6320
|
+
value: {
|
|
6321
|
+
sender: address,
|
|
6322
|
+
contract: this.saasAddress,
|
|
6323
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6324
|
+
}
|
|
6325
|
+
}
|
|
4924
6326
|
],
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
4929
|
-
|
|
6327
|
+
""
|
|
6328
|
+
);
|
|
6329
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6330
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6331
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6332
|
+
Math.round(gasEstimation * multiplier),
|
|
6333
|
+
gasPrice
|
|
6334
|
+
);
|
|
6335
|
+
const grantFee = {
|
|
6336
|
+
amount: calculatedFee.amount,
|
|
6337
|
+
gas: calculatedFee.gas,
|
|
6338
|
+
granter: this.saasAddress
|
|
6339
|
+
};
|
|
6340
|
+
return client.grantToVoter(
|
|
6341
|
+
{
|
|
6342
|
+
baseAmount,
|
|
6343
|
+
contractAddr: contractAddress,
|
|
6344
|
+
grantee
|
|
6345
|
+
},
|
|
6346
|
+
grantFee
|
|
6347
|
+
);
|
|
6348
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6349
|
+
const grantFee = {
|
|
6350
|
+
...fee,
|
|
6351
|
+
granter: this.saasAddress
|
|
6352
|
+
};
|
|
6353
|
+
return client.grantToVoter(
|
|
6354
|
+
{
|
|
6355
|
+
baseAmount,
|
|
6356
|
+
contractAddr: contractAddress,
|
|
6357
|
+
grantee
|
|
6358
|
+
},
|
|
6359
|
+
grantFee
|
|
6360
|
+
);
|
|
4930
6361
|
}
|
|
4931
|
-
|
|
4932
|
-
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
message_batch_size: "625",
|
|
4937
|
-
vote_option_tree_depth: "3"
|
|
4938
|
-
},
|
|
4939
|
-
groth16: {
|
|
4940
|
-
process_1p1v_vkey: {
|
|
4941
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4942
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4943
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4944
|
-
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4945
|
-
vk_ic0: "1195be678487bbc8c0ae726c0985a5caf6f75e3f8327926926c4f89e498ad733043e46e10b506d194b27275f402bc3fb208a2f5be69662e7c9898d1c0ece4f04",
|
|
4946
|
-
vk_ic1: "10c34362189a7ee44b1c5e57755d7e0d672dba552e614d5cd9a53081bee2333425879fa4e4a9e3fff287824cce35f94725ca0edb60a4ffcbf50becb2fd96cb0b"
|
|
4947
|
-
},
|
|
4948
|
-
tally_1p1v_vkey: {
|
|
4949
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4950
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4951
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4952
|
-
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4953
|
-
vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
|
|
4954
|
-
vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
|
|
4955
|
-
},
|
|
4956
|
-
process_qv_vkey: {
|
|
4957
|
-
vk_alpha1: "2d4d9aa7e302d9df41749d5507949d05dbea33fbb16c643b22f599a2be6df2e214bedd503c37ceb061d8ec60209fe345ce89830a19230301f076caff004d1926",
|
|
4958
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4959
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4960
|
-
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4961
|
-
vk_ic0: "1832600210a459fe61d971081d4baa1a1add23f87c8a8dc4042cd5cf6c6fdf8e3018489aec30d9deb26629e05965a3a7e038be58ce10c854cb7e1071f2708aad",
|
|
4962
|
-
vk_ic1: "0274a24117a799333754d646e35f37292e7ca9984fb8781211504b158d69d2c422aa99651ca207c77084988b16ef363664b9cf36071f7131dcc10b98ea27d7f6"
|
|
6362
|
+
return client.grantToVoter(
|
|
6363
|
+
{
|
|
6364
|
+
baseAmount,
|
|
6365
|
+
contractAddr: contractAddress,
|
|
6366
|
+
grantee
|
|
4963
6367
|
},
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
vk_beta_2: "0967032fcbf776d1afc985f88877f182d38480a653f2decaa9794cbc3bf3060c0e187847ad4c798374d0d6732bf501847dd68bc0e071241e0213bc7fc13db7ab304cfbd1e08a704a99f5e847d93f8c3caafddec46b7a0d379da69a4d112346a71739c1b1a457a8c7313123d24d2f9192f896b7c63eea05a9d57f06547ad0cec8",
|
|
4967
|
-
vk_gamma_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4968
|
-
vk_delta_2: "198e9393920d483a7260bfb731fb5d25f1aa493335a9e71297e485b7aef312c21800deef121f1e76426a00665e5c4479674322d4f75edadd46debd5cd992f6ed090689d0585ff075ec9e99ad690c3395bc4b313370b38ef355acdadcd122975b12c85ea5db8c6deb4aab71808dcb408fe3d1e7690c43d37b4ce6cc0166fa7daa",
|
|
4969
|
-
vk_ic0: "2ec191d51bd4ac7cd65cb3dd2decfa4e56c4f167bbc40e2c9e1ca728f9bc5b0e2ed1c82319dc554aea5ff2ca05d6f4d4d61e8f059a8c05d4b4faabae5128a437",
|
|
4970
|
-
vk_ic1: "2f19db8f03b6b5896abc6989273371b14833356f45c12685e57bc292eccc53570cb629e551df179f73b9f3391946bad29739af8b808c80b0f057af45aea59849"
|
|
4971
|
-
}
|
|
4972
|
-
}
|
|
6368
|
+
fee
|
|
6369
|
+
);
|
|
4973
6370
|
}
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
4977
|
-
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
"
|
|
4986
|
-
|
|
4987
|
-
};
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
throw new Error(
|
|
5007
|
-
`Invalid circuit type ${circuitType}, only support 1P1V and QV`
|
|
6371
|
+
async addSaasOperator({
|
|
6372
|
+
signer,
|
|
6373
|
+
operator,
|
|
6374
|
+
gasStation = false,
|
|
6375
|
+
fee = 1.8
|
|
6376
|
+
}) {
|
|
6377
|
+
const client = await createSaasClientBy({
|
|
6378
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6379
|
+
wallet: signer,
|
|
6380
|
+
contractAddress: this.saasAddress
|
|
6381
|
+
});
|
|
6382
|
+
if (gasStation && typeof fee !== "object") {
|
|
6383
|
+
const [{ address }] = await signer.getAccounts();
|
|
6384
|
+
const contractClient = await this.contractClient({ signer });
|
|
6385
|
+
const msg = {
|
|
6386
|
+
add_operator: {
|
|
6387
|
+
operator
|
|
6388
|
+
}
|
|
6389
|
+
};
|
|
6390
|
+
const gasEstimation = await contractClient.simulate(
|
|
6391
|
+
address,
|
|
6392
|
+
[
|
|
6393
|
+
{
|
|
6394
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6395
|
+
value: {
|
|
6396
|
+
sender: address,
|
|
6397
|
+
contract: this.saasAddress,
|
|
6398
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6399
|
+
}
|
|
6400
|
+
}
|
|
6401
|
+
],
|
|
6402
|
+
""
|
|
5008
6403
|
);
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5014
|
-
case "plonk" /* PLONK */:
|
|
5015
|
-
maciCertSystem = "1";
|
|
5016
|
-
break;
|
|
5017
|
-
default:
|
|
5018
|
-
throw new Error(
|
|
5019
|
-
`Invalid proof system ${proofSystem}, only support GROTH16 and PLONK`
|
|
6404
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6405
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6406
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6407
|
+
Math.round(gasEstimation * multiplier),
|
|
6408
|
+
gasPrice
|
|
5020
6409
|
);
|
|
5021
|
-
|
|
5022
|
-
|
|
5023
|
-
|
|
5024
|
-
|
|
5025
|
-
|
|
5026
|
-
|
|
5027
|
-
} else if (
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
|
-
|
|
5031
|
-
|
|
5032
|
-
|
|
5033
|
-
if (proofSystem === "groth16" /* GROTH16 */) {
|
|
5034
|
-
groth16ProcessVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].process_vkey;
|
|
5035
|
-
groth16TallyVkey = CIRCUIT_INFO["4-2-2-25"]["groth16"].tally_vkey;
|
|
5036
|
-
} else if (proofSystem === "plonk" /* PLONK */) {
|
|
5037
|
-
plonkProcessVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.process_vkey;
|
|
5038
|
-
plonkTallyVkey = CIRCUIT_INFO["4-2-2-25"]["plonk"]?.tally_vkey;
|
|
6410
|
+
const grantFee = {
|
|
6411
|
+
amount: calculatedFee.amount,
|
|
6412
|
+
gas: calculatedFee.gas,
|
|
6413
|
+
granter: this.saasAddress
|
|
6414
|
+
};
|
|
6415
|
+
return client.addOperator({ operator }, grantFee);
|
|
6416
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6417
|
+
const grantFee = {
|
|
6418
|
+
...fee,
|
|
6419
|
+
granter: this.saasAddress
|
|
6420
|
+
};
|
|
6421
|
+
return client.addOperator({ operator }, grantFee);
|
|
5039
6422
|
}
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
6423
|
+
return client.addOperator({ operator }, fee);
|
|
6424
|
+
}
|
|
6425
|
+
async removeSaasOperator({
|
|
6426
|
+
signer,
|
|
6427
|
+
operator,
|
|
6428
|
+
gasStation = false,
|
|
6429
|
+
fee = 1.8
|
|
6430
|
+
}) {
|
|
6431
|
+
const client = await createSaasClientBy({
|
|
6432
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6433
|
+
wallet: signer,
|
|
6434
|
+
contractAddress: this.saasAddress
|
|
6435
|
+
});
|
|
6436
|
+
if (gasStation && typeof fee !== "object") {
|
|
6437
|
+
const [{ address }] = await signer.getAccounts();
|
|
6438
|
+
const contractClient = await this.contractClient({ signer });
|
|
6439
|
+
const msg = {
|
|
6440
|
+
remove_operator: {
|
|
6441
|
+
operator
|
|
6442
|
+
}
|
|
6443
|
+
};
|
|
6444
|
+
const gasEstimation = await contractClient.simulate(
|
|
6445
|
+
address,
|
|
6446
|
+
[
|
|
6447
|
+
{
|
|
6448
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6449
|
+
value: {
|
|
6450
|
+
sender: address,
|
|
6451
|
+
contract: this.saasAddress,
|
|
6452
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
],
|
|
6456
|
+
""
|
|
6457
|
+
);
|
|
6458
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6459
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6460
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6461
|
+
Math.round(gasEstimation * multiplier),
|
|
6462
|
+
gasPrice
|
|
6463
|
+
);
|
|
6464
|
+
const grantFee = {
|
|
6465
|
+
amount: calculatedFee.amount,
|
|
6466
|
+
gas: calculatedFee.gas,
|
|
6467
|
+
granter: this.saasAddress
|
|
6468
|
+
};
|
|
6469
|
+
return client.removeOperator({ operator }, grantFee);
|
|
6470
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6471
|
+
const grantFee = {
|
|
6472
|
+
...fee,
|
|
6473
|
+
granter: this.saasAddress
|
|
6474
|
+
};
|
|
6475
|
+
return client.removeOperator({ operator }, grantFee);
|
|
5048
6476
|
}
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
|
-
|
|
5052
|
-
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
6477
|
+
return client.removeOperator({ operator }, fee);
|
|
6478
|
+
}
|
|
6479
|
+
async isSaasOperator({
|
|
6480
|
+
signer,
|
|
6481
|
+
operator
|
|
6482
|
+
}) {
|
|
6483
|
+
const client = await createSaasClientBy({
|
|
6484
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6485
|
+
wallet: signer,
|
|
6486
|
+
contractAddress: this.saasAddress
|
|
6487
|
+
});
|
|
6488
|
+
return client.isOperator({ address: operator });
|
|
6489
|
+
}
|
|
6490
|
+
async depositSaas({
|
|
6491
|
+
signer,
|
|
6492
|
+
amount,
|
|
6493
|
+
gasStation = false,
|
|
6494
|
+
fee = 1.8
|
|
6495
|
+
}) {
|
|
6496
|
+
const client = await createSaasClientBy({
|
|
6497
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6498
|
+
wallet: signer,
|
|
6499
|
+
contractAddress: this.saasAddress
|
|
6500
|
+
});
|
|
6501
|
+
const funds = [
|
|
6502
|
+
{
|
|
6503
|
+
denom: "peaka",
|
|
6504
|
+
amount
|
|
5058
6505
|
}
|
|
5059
|
-
|
|
5060
|
-
|
|
6506
|
+
];
|
|
6507
|
+
if (gasStation && typeof fee !== "object") {
|
|
6508
|
+
const [{ address }] = await signer.getAccounts();
|
|
6509
|
+
const contractClient = await this.contractClient({ signer });
|
|
6510
|
+
const msg = {
|
|
6511
|
+
deposit: {}
|
|
6512
|
+
};
|
|
6513
|
+
const gasEstimation = await contractClient.simulate(
|
|
6514
|
+
address,
|
|
6515
|
+
[
|
|
6516
|
+
{
|
|
6517
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6518
|
+
value: {
|
|
6519
|
+
sender: address,
|
|
6520
|
+
contract: this.saasAddress,
|
|
6521
|
+
msg: new TextEncoder().encode(JSON.stringify(msg)),
|
|
6522
|
+
funds
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
],
|
|
6526
|
+
""
|
|
6527
|
+
);
|
|
6528
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6529
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6530
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6531
|
+
Math.round(gasEstimation * multiplier),
|
|
6532
|
+
gasPrice
|
|
6533
|
+
);
|
|
6534
|
+
const grantFee = {
|
|
6535
|
+
amount: calculatedFee.amount,
|
|
6536
|
+
gas: calculatedFee.gas,
|
|
6537
|
+
granter: this.saasAddress
|
|
6538
|
+
};
|
|
6539
|
+
return client.deposit(grantFee, void 0, funds);
|
|
6540
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6541
|
+
const grantFee = {
|
|
6542
|
+
...fee,
|
|
6543
|
+
granter: this.saasAddress
|
|
6544
|
+
};
|
|
6545
|
+
return client.deposit(grantFee, void 0, funds);
|
|
5061
6546
|
}
|
|
5062
|
-
|
|
5063
|
-
throw new Error("Number of voters or options is too large.");
|
|
6547
|
+
return client.deposit(fee, void 0, funds);
|
|
5064
6548
|
}
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5069
|
-
|
|
5070
|
-
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
6549
|
+
async withdrawSaas({
|
|
6550
|
+
signer,
|
|
6551
|
+
amount,
|
|
6552
|
+
gasStation = false,
|
|
6553
|
+
fee = 1.8
|
|
6554
|
+
}) {
|
|
6555
|
+
const client = await createSaasClientBy({
|
|
6556
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6557
|
+
wallet: signer,
|
|
6558
|
+
contractAddress: this.saasAddress
|
|
6559
|
+
});
|
|
6560
|
+
if (gasStation && typeof fee !== "object") {
|
|
6561
|
+
const [{ address }] = await signer.getAccounts();
|
|
6562
|
+
const contractClient = await this.contractClient({ signer });
|
|
6563
|
+
const msg = {
|
|
6564
|
+
withdraw: {
|
|
6565
|
+
amount
|
|
6566
|
+
}
|
|
5075
6567
|
};
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5080
|
-
|
|
5081
|
-
|
|
5082
|
-
|
|
6568
|
+
const gasEstimation = await contractClient.simulate(
|
|
6569
|
+
address,
|
|
6570
|
+
[
|
|
6571
|
+
{
|
|
6572
|
+
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
6573
|
+
value: {
|
|
6574
|
+
sender: address,
|
|
6575
|
+
contract: this.saasAddress,
|
|
6576
|
+
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
],
|
|
6580
|
+
""
|
|
6581
|
+
);
|
|
6582
|
+
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
6583
|
+
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
6584
|
+
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
6585
|
+
Math.round(gasEstimation * multiplier),
|
|
6586
|
+
gasPrice
|
|
6587
|
+
);
|
|
6588
|
+
const grantFee = {
|
|
6589
|
+
amount: calculatedFee.amount,
|
|
6590
|
+
gas: calculatedFee.gas,
|
|
6591
|
+
granter: this.saasAddress
|
|
5083
6592
|
};
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
groth16ProcessVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].process_qv_vkey;
|
|
5090
|
-
groth16TallyVkey = CIRCUIT_INFO["9-4-3-625"]["groth16"].tally_qv_vkey;
|
|
5091
|
-
}
|
|
5092
|
-
return {
|
|
5093
|
-
parameters: CIRCUIT_INFO["9-4-3-625"].parameter,
|
|
5094
|
-
groth16ProcessVkey,
|
|
5095
|
-
groth16TallyVkey,
|
|
5096
|
-
plonkProcessVkey: null,
|
|
5097
|
-
plonkTallyVkey: null,
|
|
5098
|
-
maciVoteType,
|
|
5099
|
-
maciCertSystem: "0"
|
|
6593
|
+
return client.withdraw({ amount }, grantFee);
|
|
6594
|
+
} else if (gasStation && typeof fee === "object") {
|
|
6595
|
+
const grantFee = {
|
|
6596
|
+
...fee,
|
|
6597
|
+
granter: this.saasAddress
|
|
5100
6598
|
};
|
|
5101
|
-
|
|
5102
|
-
}
|
|
5103
|
-
function getAMaciRoundCircuitFee(network, maxVoter, maxOption) {
|
|
5104
|
-
let requiredFee = {
|
|
5105
|
-
denom: "peaka",
|
|
5106
|
-
amount: "0"
|
|
5107
|
-
};
|
|
5108
|
-
if (maxVoter <= 25 && maxOption <= 5) {
|
|
5109
|
-
if (network === "mainnet") {
|
|
5110
|
-
requiredFee.amount = "20000000000000000000";
|
|
5111
|
-
} else {
|
|
5112
|
-
requiredFee.amount = "20000000000000000000";
|
|
5113
|
-
}
|
|
5114
|
-
} else if (maxVoter <= 625 && maxOption <= 25) {
|
|
5115
|
-
if (network === "mainnet") {
|
|
5116
|
-
requiredFee.amount = "750000000000000000000";
|
|
5117
|
-
} else {
|
|
5118
|
-
requiredFee.amount = "750000000000000000000";
|
|
6599
|
+
return client.withdraw({ amount }, grantFee);
|
|
5119
6600
|
}
|
|
5120
|
-
|
|
5121
|
-
throw new Error("Number of voters or options is too large.");
|
|
6601
|
+
return client.withdraw({ amount }, fee);
|
|
5122
6602
|
}
|
|
5123
|
-
|
|
5124
|
-
|
|
5125
|
-
|
|
5126
|
-
// src/libs/contract/contract.ts
|
|
5127
|
-
var import_stargate2 = require("@cosmjs/stargate");
|
|
5128
|
-
var Contract = class {
|
|
5129
|
-
constructor({
|
|
5130
|
-
network,
|
|
5131
|
-
rpcEndpoint,
|
|
5132
|
-
registryAddress,
|
|
5133
|
-
saasAddress,
|
|
5134
|
-
maciCodeId,
|
|
5135
|
-
oracleCodeId,
|
|
5136
|
-
saasOracleCodeId,
|
|
5137
|
-
feegrantOperator,
|
|
5138
|
-
whitelistBackendPubkey
|
|
6603
|
+
async queryRoundInfo({
|
|
6604
|
+
signer,
|
|
6605
|
+
roundAddress
|
|
5139
6606
|
}) {
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
this.feegrantOperator = feegrantOperator;
|
|
5148
|
-
this.whitelistBackendPubkey = whitelistBackendPubkey;
|
|
6607
|
+
const client = await createMaciClientBy({
|
|
6608
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6609
|
+
wallet: signer,
|
|
6610
|
+
contractAddress: roundAddress
|
|
6611
|
+
});
|
|
6612
|
+
const roundInfo = await client.getRoundInfo();
|
|
6613
|
+
return roundInfo;
|
|
5149
6614
|
}
|
|
5150
|
-
async
|
|
6615
|
+
async oracleMaciClient({
|
|
5151
6616
|
signer,
|
|
5152
|
-
|
|
5153
|
-
endVoting,
|
|
5154
|
-
operator,
|
|
5155
|
-
whitelist,
|
|
5156
|
-
title,
|
|
5157
|
-
description,
|
|
5158
|
-
link,
|
|
5159
|
-
maxVoter,
|
|
5160
|
-
maxOption,
|
|
5161
|
-
voiceCreditAmount,
|
|
5162
|
-
circuitType,
|
|
5163
|
-
preDeactivateRoot,
|
|
5164
|
-
fee = "auto"
|
|
6617
|
+
contractAddress
|
|
5165
6618
|
}) {
|
|
5166
|
-
const
|
|
5167
|
-
const end_time = (endVoting.getTime() * 10 ** 6).toString();
|
|
5168
|
-
const client = await createRegistryClientBy({
|
|
6619
|
+
const client = await createOracleMaciClientBy({
|
|
5169
6620
|
rpcEndpoint: this.rpcEndpoint,
|
|
5170
6621
|
wallet: signer,
|
|
5171
|
-
contractAddress
|
|
6622
|
+
contractAddress
|
|
5172
6623
|
});
|
|
5173
|
-
|
|
5174
|
-
|
|
5175
|
-
|
|
5176
|
-
|
|
5177
|
-
|
|
5178
|
-
|
|
5179
|
-
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
voiceCreditAmount,
|
|
5184
|
-
whitelist,
|
|
5185
|
-
roundInfo: {
|
|
5186
|
-
title,
|
|
5187
|
-
description: description || "",
|
|
5188
|
-
link: link || ""
|
|
5189
|
-
},
|
|
5190
|
-
votingTime: {
|
|
5191
|
-
start_time,
|
|
5192
|
-
end_time
|
|
5193
|
-
},
|
|
5194
|
-
maxVoter: maxVoter.toString(),
|
|
5195
|
-
maxOption: maxOption.toString(),
|
|
5196
|
-
certificationSystem: "0",
|
|
5197
|
-
circuitType
|
|
5198
|
-
},
|
|
5199
|
-
fee,
|
|
5200
|
-
void 0,
|
|
5201
|
-
[requiredFee]
|
|
5202
|
-
);
|
|
5203
|
-
let contractAddress = "";
|
|
5204
|
-
res.events.map((event) => {
|
|
5205
|
-
if (event.type === "wasm") {
|
|
5206
|
-
let actionEvent = event.attributes.find(
|
|
5207
|
-
(attr) => attr.key === "action"
|
|
5208
|
-
);
|
|
5209
|
-
if (actionEvent.value === "created_round") {
|
|
5210
|
-
contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
|
|
5211
|
-
}
|
|
5212
|
-
}
|
|
6624
|
+
return client;
|
|
6625
|
+
}
|
|
6626
|
+
async registryClient({
|
|
6627
|
+
signer,
|
|
6628
|
+
contractAddress
|
|
6629
|
+
}) {
|
|
6630
|
+
return createRegistryClientBy({
|
|
6631
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6632
|
+
wallet: signer,
|
|
6633
|
+
contractAddress
|
|
5213
6634
|
});
|
|
5214
|
-
|
|
5215
|
-
|
|
6635
|
+
}
|
|
6636
|
+
async maciClient({
|
|
6637
|
+
signer,
|
|
6638
|
+
contractAddress
|
|
6639
|
+
}) {
|
|
6640
|
+
return createMaciClientBy({
|
|
6641
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6642
|
+
wallet: signer,
|
|
5216
6643
|
contractAddress
|
|
5217
|
-
};
|
|
6644
|
+
});
|
|
5218
6645
|
}
|
|
5219
|
-
async
|
|
6646
|
+
async amaciClient({
|
|
5220
6647
|
signer,
|
|
5221
|
-
|
|
5222
|
-
startVoting,
|
|
5223
|
-
endVoting,
|
|
5224
|
-
whitelist,
|
|
5225
|
-
title,
|
|
5226
|
-
description,
|
|
5227
|
-
link,
|
|
5228
|
-
maxVoter,
|
|
5229
|
-
maxOption,
|
|
5230
|
-
circuitType,
|
|
5231
|
-
certSystemType,
|
|
5232
|
-
fee = "auto"
|
|
6648
|
+
contractAddress
|
|
5233
6649
|
}) {
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
BigInt(operatorPubkey)
|
|
5240
|
-
);
|
|
5241
|
-
const {
|
|
5242
|
-
parameters,
|
|
5243
|
-
groth16ProcessVkey,
|
|
5244
|
-
groth16TallyVkey,
|
|
5245
|
-
plonkProcessVkey,
|
|
5246
|
-
plonkTallyVkey,
|
|
5247
|
-
maciVoteType,
|
|
5248
|
-
maciCertSystem
|
|
5249
|
-
} = getContractParams(
|
|
5250
|
-
"0" /* MACI */,
|
|
5251
|
-
circuitType,
|
|
5252
|
-
certSystemType,
|
|
5253
|
-
maxVoter,
|
|
5254
|
-
maxOption
|
|
5255
|
-
);
|
|
5256
|
-
const instantiateResponse = await client.instantiate(
|
|
5257
|
-
address,
|
|
5258
|
-
this.maciCodeId,
|
|
5259
|
-
{
|
|
5260
|
-
round_info: { title, description: description || "", link: link || "" },
|
|
5261
|
-
voting_time: {
|
|
5262
|
-
start_time,
|
|
5263
|
-
end_time
|
|
5264
|
-
},
|
|
5265
|
-
parameters,
|
|
5266
|
-
coordinator: {
|
|
5267
|
-
x: operatorPubkeyX.toString(),
|
|
5268
|
-
y: operatorPubkeyY.toString()
|
|
5269
|
-
},
|
|
5270
|
-
groth16_process_vkey: groth16ProcessVkey,
|
|
5271
|
-
groth16_tally_vkey: groth16TallyVkey,
|
|
5272
|
-
plonk_process_vkey: plonkProcessVkey,
|
|
5273
|
-
plonk_tally_vkey: plonkTallyVkey,
|
|
5274
|
-
max_vote_options: maxOption.toString(),
|
|
5275
|
-
whitelist,
|
|
5276
|
-
circuit_type: maciVoteType,
|
|
5277
|
-
certification_system: maciCertSystem,
|
|
5278
|
-
qtr_lib: QTR_LIB
|
|
5279
|
-
},
|
|
5280
|
-
`[MACI] ${title}`,
|
|
5281
|
-
fee
|
|
5282
|
-
);
|
|
5283
|
-
return instantiateResponse;
|
|
6650
|
+
return createAMaciClientBy({
|
|
6651
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6652
|
+
wallet: signer,
|
|
6653
|
+
contractAddress
|
|
6654
|
+
});
|
|
5284
6655
|
}
|
|
5285
|
-
async
|
|
6656
|
+
async apiMaciClient({
|
|
5286
6657
|
signer,
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
6658
|
+
contractAddress
|
|
6659
|
+
}) {
|
|
6660
|
+
return createApiMaciClientBy({
|
|
6661
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6662
|
+
wallet: signer,
|
|
6663
|
+
contractAddress
|
|
6664
|
+
});
|
|
6665
|
+
}
|
|
6666
|
+
async saasClient({
|
|
6667
|
+
signer,
|
|
6668
|
+
contractAddress
|
|
6669
|
+
}) {
|
|
6670
|
+
return createSaasClientBy({
|
|
6671
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6672
|
+
wallet: signer,
|
|
6673
|
+
contractAddress
|
|
6674
|
+
});
|
|
6675
|
+
}
|
|
6676
|
+
async apiSaasClient({
|
|
6677
|
+
signer,
|
|
6678
|
+
contractAddress
|
|
5299
6679
|
}) {
|
|
5300
|
-
|
|
5301
|
-
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
BigInt(operatorPubkey)
|
|
5306
|
-
);
|
|
5307
|
-
const { maciVoteType, maciCertSystem } = getContractParams(
|
|
5308
|
-
"2" /* ORACLE_MACI */,
|
|
5309
|
-
circuitType,
|
|
5310
|
-
"groth16" /* GROTH16 */,
|
|
5311
|
-
0,
|
|
5312
|
-
0
|
|
5313
|
-
);
|
|
5314
|
-
const instantiateResponse = await client.instantiate(
|
|
5315
|
-
address,
|
|
5316
|
-
this.oracleCodeId,
|
|
5317
|
-
{
|
|
5318
|
-
round_info: { title, description: description || "", link: link || "" },
|
|
5319
|
-
voting_time: {
|
|
5320
|
-
start_time,
|
|
5321
|
-
end_time
|
|
5322
|
-
},
|
|
5323
|
-
coordinator: {
|
|
5324
|
-
x: operatorPubkeyX.toString(),
|
|
5325
|
-
y: operatorPubkeyY.toString()
|
|
5326
|
-
},
|
|
5327
|
-
vote_option_map: voteOptionMap,
|
|
5328
|
-
whitelist_backend_pubkey: this.whitelistBackendPubkey,
|
|
5329
|
-
whitelist_ecosystem: whitelistEcosystem,
|
|
5330
|
-
whitelist_snapshot_height: whitelistSnapshotHeight,
|
|
5331
|
-
whitelist_voting_power_args: whitelistVotingPowerArgs,
|
|
5332
|
-
circuit_type: maciVoteType,
|
|
5333
|
-
certification_system: maciCertSystem,
|
|
5334
|
-
feegrant_operator: this.feegrantOperator
|
|
5335
|
-
},
|
|
5336
|
-
`[Oracle MACI] ${title}`,
|
|
5337
|
-
fee
|
|
5338
|
-
);
|
|
5339
|
-
return instantiateResponse;
|
|
6680
|
+
return createApiSaasClientBy({
|
|
6681
|
+
rpcEndpoint: this.rpcEndpoint,
|
|
6682
|
+
wallet: signer,
|
|
6683
|
+
contractAddress
|
|
6684
|
+
});
|
|
5340
6685
|
}
|
|
5341
|
-
async
|
|
6686
|
+
async contractClient({ signer }) {
|
|
6687
|
+
return createContractClientByWallet(this.rpcEndpoint, signer);
|
|
6688
|
+
}
|
|
6689
|
+
async createApiSaasMaciRound({
|
|
5342
6690
|
signer,
|
|
5343
6691
|
operatorPubkey,
|
|
5344
6692
|
startVoting,
|
|
@@ -5354,10 +6702,10 @@ var Contract = class {
|
|
|
5354
6702
|
}) {
|
|
5355
6703
|
const startTime = (startVoting.getTime() * 1e6).toString();
|
|
5356
6704
|
const endTime = (endVoting.getTime() * 1e6).toString();
|
|
5357
|
-
const client = await
|
|
6705
|
+
const client = await createApiSaasClientBy({
|
|
5358
6706
|
rpcEndpoint: this.rpcEndpoint,
|
|
5359
6707
|
wallet: signer,
|
|
5360
|
-
contractAddress: this.
|
|
6708
|
+
contractAddress: this.apiSaasAddress
|
|
5361
6709
|
});
|
|
5362
6710
|
const [operatorPubkeyX, operatorPubkeyY] = unpackPubKey(
|
|
5363
6711
|
BigInt(operatorPubkey)
|
|
@@ -5385,7 +6733,7 @@ var Contract = class {
|
|
|
5385
6733
|
const [{ address }] = await signer.getAccounts();
|
|
5386
6734
|
const contractClient = await this.contractClient({ signer });
|
|
5387
6735
|
const msg = {
|
|
5388
|
-
|
|
6736
|
+
create_api_maci_round: {
|
|
5389
6737
|
certification_system: "0",
|
|
5390
6738
|
circuit_type: "0",
|
|
5391
6739
|
coordinator: roundParams.coordinator,
|
|
@@ -5404,7 +6752,7 @@ var Contract = class {
|
|
|
5404
6752
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5405
6753
|
value: {
|
|
5406
6754
|
sender: address,
|
|
5407
|
-
contract: this.
|
|
6755
|
+
contract: this.apiSaasAddress,
|
|
5408
6756
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5409
6757
|
}
|
|
5410
6758
|
}
|
|
@@ -5420,23 +6768,17 @@ var Contract = class {
|
|
|
5420
6768
|
const grantFee = {
|
|
5421
6769
|
amount: calculatedFee.amount,
|
|
5422
6770
|
gas: calculatedFee.gas,
|
|
5423
|
-
granter: this.
|
|
6771
|
+
granter: this.apiSaasAddress
|
|
5424
6772
|
};
|
|
5425
|
-
createResponse = await client.
|
|
5426
|
-
roundParams,
|
|
5427
|
-
grantFee
|
|
5428
|
-
);
|
|
6773
|
+
createResponse = await client.createMaciRound(roundParams, grantFee);
|
|
5429
6774
|
} else if (gasStation && typeof fee === "object") {
|
|
5430
6775
|
const grantFee = {
|
|
5431
6776
|
...fee,
|
|
5432
|
-
granter: this.
|
|
6777
|
+
granter: this.apiSaasAddress
|
|
5433
6778
|
};
|
|
5434
|
-
createResponse = await client.
|
|
5435
|
-
roundParams,
|
|
5436
|
-
grantFee
|
|
5437
|
-
);
|
|
6779
|
+
createResponse = await client.createMaciRound(roundParams, grantFee);
|
|
5438
6780
|
} else {
|
|
5439
|
-
createResponse = await client.
|
|
6781
|
+
createResponse = await client.createMaciRound(roundParams, fee);
|
|
5440
6782
|
}
|
|
5441
6783
|
let contractAddress = "";
|
|
5442
6784
|
createResponse.events.map((event) => {
|
|
@@ -5444,7 +6786,7 @@ var Contract = class {
|
|
|
5444
6786
|
let actionEvent = event.attributes.find(
|
|
5445
6787
|
(attr) => attr.key === "action"
|
|
5446
6788
|
);
|
|
5447
|
-
if (actionEvent.value === "
|
|
6789
|
+
if (actionEvent.value === "created_maci_round") {
|
|
5448
6790
|
contractAddress = event.attributes.find((attr) => attr.key === "round_addr").value.toString();
|
|
5449
6791
|
}
|
|
5450
6792
|
}
|
|
@@ -5454,7 +6796,7 @@ var Contract = class {
|
|
|
5454
6796
|
contractAddress
|
|
5455
6797
|
};
|
|
5456
6798
|
}
|
|
5457
|
-
async
|
|
6799
|
+
async setApiSaasMaciRoundInfo({
|
|
5458
6800
|
signer,
|
|
5459
6801
|
contractAddress,
|
|
5460
6802
|
title,
|
|
@@ -5463,10 +6805,10 @@ var Contract = class {
|
|
|
5463
6805
|
gasStation = false,
|
|
5464
6806
|
fee = 1.8
|
|
5465
6807
|
}) {
|
|
5466
|
-
const client = await
|
|
6808
|
+
const client = await createApiSaasClientBy({
|
|
5467
6809
|
rpcEndpoint: this.rpcEndpoint,
|
|
5468
6810
|
wallet: signer,
|
|
5469
|
-
contractAddress: this.
|
|
6811
|
+
contractAddress: this.apiSaasAddress
|
|
5470
6812
|
});
|
|
5471
6813
|
const roundInfo = {
|
|
5472
6814
|
title,
|
|
@@ -5489,7 +6831,7 @@ var Contract = class {
|
|
|
5489
6831
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5490
6832
|
value: {
|
|
5491
6833
|
sender: address,
|
|
5492
|
-
contract: this.
|
|
6834
|
+
contract: this.apiSaasAddress,
|
|
5493
6835
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5494
6836
|
}
|
|
5495
6837
|
}
|
|
@@ -5505,7 +6847,7 @@ var Contract = class {
|
|
|
5505
6847
|
const grantFee = {
|
|
5506
6848
|
amount: calculatedFee.amount,
|
|
5507
6849
|
gas: calculatedFee.gas,
|
|
5508
|
-
granter: this.
|
|
6850
|
+
granter: this.apiSaasAddress
|
|
5509
6851
|
};
|
|
5510
6852
|
return client.setRoundInfo(
|
|
5511
6853
|
{
|
|
@@ -5517,7 +6859,7 @@ var Contract = class {
|
|
|
5517
6859
|
} else if (gasStation && typeof fee === "object") {
|
|
5518
6860
|
const grantFee = {
|
|
5519
6861
|
...fee,
|
|
5520
|
-
granter: this.
|
|
6862
|
+
granter: this.apiSaasAddress
|
|
5521
6863
|
};
|
|
5522
6864
|
return client.setRoundInfo(
|
|
5523
6865
|
{
|
|
@@ -5535,17 +6877,17 @@ var Contract = class {
|
|
|
5535
6877
|
fee
|
|
5536
6878
|
);
|
|
5537
6879
|
}
|
|
5538
|
-
async
|
|
6880
|
+
async setApiSaasMaciRoundVoteOptions({
|
|
5539
6881
|
signer,
|
|
5540
6882
|
contractAddress,
|
|
5541
6883
|
voteOptionMap,
|
|
5542
6884
|
gasStation = false,
|
|
5543
6885
|
fee = 1.8
|
|
5544
6886
|
}) {
|
|
5545
|
-
const client = await
|
|
6887
|
+
const client = await createApiSaasClientBy({
|
|
5546
6888
|
rpcEndpoint: this.rpcEndpoint,
|
|
5547
6889
|
wallet: signer,
|
|
5548
|
-
contractAddress: this.
|
|
6890
|
+
contractAddress: this.apiSaasAddress
|
|
5549
6891
|
});
|
|
5550
6892
|
if (gasStation && typeof fee !== "object") {
|
|
5551
6893
|
const [{ address }] = await signer.getAccounts();
|
|
@@ -5563,7 +6905,7 @@ var Contract = class {
|
|
|
5563
6905
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5564
6906
|
value: {
|
|
5565
6907
|
sender: address,
|
|
5566
|
-
contract: this.
|
|
6908
|
+
contract: this.apiSaasAddress,
|
|
5567
6909
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5568
6910
|
}
|
|
5569
6911
|
}
|
|
@@ -5579,7 +6921,7 @@ var Contract = class {
|
|
|
5579
6921
|
const grantFee = {
|
|
5580
6922
|
amount: calculatedFee.amount,
|
|
5581
6923
|
gas: calculatedFee.gas,
|
|
5582
|
-
granter: this.
|
|
6924
|
+
granter: this.apiSaasAddress
|
|
5583
6925
|
};
|
|
5584
6926
|
return client.setVoteOptionsMap(
|
|
5585
6927
|
{
|
|
@@ -5591,7 +6933,7 @@ var Contract = class {
|
|
|
5591
6933
|
} else if (gasStation && typeof fee === "object") {
|
|
5592
6934
|
const grantFee = {
|
|
5593
6935
|
...fee,
|
|
5594
|
-
granter: this.
|
|
6936
|
+
granter: this.apiSaasAddress
|
|
5595
6937
|
};
|
|
5596
6938
|
return client.setVoteOptionsMap(
|
|
5597
6939
|
{
|
|
@@ -5609,95 +6951,16 @@ var Contract = class {
|
|
|
5609
6951
|
fee
|
|
5610
6952
|
);
|
|
5611
6953
|
}
|
|
5612
|
-
async
|
|
5613
|
-
signer,
|
|
5614
|
-
baseAmount,
|
|
5615
|
-
contractAddress,
|
|
5616
|
-
grantee,
|
|
5617
|
-
gasStation = false,
|
|
5618
|
-
fee = 1.8
|
|
5619
|
-
}) {
|
|
5620
|
-
const client = await createSaasClientBy({
|
|
5621
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5622
|
-
wallet: signer,
|
|
5623
|
-
contractAddress: this.saasAddress
|
|
5624
|
-
});
|
|
5625
|
-
if (gasStation && typeof fee !== "object") {
|
|
5626
|
-
const [{ address }] = await signer.getAccounts();
|
|
5627
|
-
const contractClient = await this.contractClient({ signer });
|
|
5628
|
-
const msg = {
|
|
5629
|
-
grant_to_voter: {
|
|
5630
|
-
base_amount: baseAmount,
|
|
5631
|
-
contract_addr: contractAddress,
|
|
5632
|
-
grantee
|
|
5633
|
-
}
|
|
5634
|
-
};
|
|
5635
|
-
const gasEstimation = await contractClient.simulate(
|
|
5636
|
-
address,
|
|
5637
|
-
[
|
|
5638
|
-
{
|
|
5639
|
-
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5640
|
-
value: {
|
|
5641
|
-
sender: address,
|
|
5642
|
-
contract: this.saasAddress,
|
|
5643
|
-
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5644
|
-
}
|
|
5645
|
-
}
|
|
5646
|
-
],
|
|
5647
|
-
""
|
|
5648
|
-
);
|
|
5649
|
-
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
5650
|
-
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
5651
|
-
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
5652
|
-
Math.round(gasEstimation * multiplier),
|
|
5653
|
-
gasPrice
|
|
5654
|
-
);
|
|
5655
|
-
const grantFee = {
|
|
5656
|
-
amount: calculatedFee.amount,
|
|
5657
|
-
gas: calculatedFee.gas,
|
|
5658
|
-
granter: this.saasAddress
|
|
5659
|
-
};
|
|
5660
|
-
return client.grantToVoter(
|
|
5661
|
-
{
|
|
5662
|
-
baseAmount,
|
|
5663
|
-
contractAddr: contractAddress,
|
|
5664
|
-
grantee
|
|
5665
|
-
},
|
|
5666
|
-
grantFee
|
|
5667
|
-
);
|
|
5668
|
-
} else if (gasStation && typeof fee === "object") {
|
|
5669
|
-
const grantFee = {
|
|
5670
|
-
...fee,
|
|
5671
|
-
granter: this.saasAddress
|
|
5672
|
-
};
|
|
5673
|
-
return client.grantToVoter(
|
|
5674
|
-
{
|
|
5675
|
-
baseAmount,
|
|
5676
|
-
contractAddr: contractAddress,
|
|
5677
|
-
grantee
|
|
5678
|
-
},
|
|
5679
|
-
grantFee
|
|
5680
|
-
);
|
|
5681
|
-
}
|
|
5682
|
-
return client.grantToVoter(
|
|
5683
|
-
{
|
|
5684
|
-
baseAmount,
|
|
5685
|
-
contractAddr: contractAddress,
|
|
5686
|
-
grantee
|
|
5687
|
-
},
|
|
5688
|
-
fee
|
|
5689
|
-
);
|
|
5690
|
-
}
|
|
5691
|
-
async addSaasOperator({
|
|
6954
|
+
async addApiSaasOperator({
|
|
5692
6955
|
signer,
|
|
5693
6956
|
operator,
|
|
5694
6957
|
gasStation = false,
|
|
5695
6958
|
fee = 1.8
|
|
5696
6959
|
}) {
|
|
5697
|
-
const client = await
|
|
6960
|
+
const client = await createApiSaasClientBy({
|
|
5698
6961
|
rpcEndpoint: this.rpcEndpoint,
|
|
5699
6962
|
wallet: signer,
|
|
5700
|
-
contractAddress: this.
|
|
6963
|
+
contractAddress: this.apiSaasAddress
|
|
5701
6964
|
});
|
|
5702
6965
|
if (gasStation && typeof fee !== "object") {
|
|
5703
6966
|
const [{ address }] = await signer.getAccounts();
|
|
@@ -5714,7 +6977,7 @@ var Contract = class {
|
|
|
5714
6977
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5715
6978
|
value: {
|
|
5716
6979
|
sender: address,
|
|
5717
|
-
contract: this.
|
|
6980
|
+
contract: this.apiSaasAddress,
|
|
5718
6981
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5719
6982
|
}
|
|
5720
6983
|
}
|
|
@@ -5730,28 +6993,28 @@ var Contract = class {
|
|
|
5730
6993
|
const grantFee = {
|
|
5731
6994
|
amount: calculatedFee.amount,
|
|
5732
6995
|
gas: calculatedFee.gas,
|
|
5733
|
-
granter: this.
|
|
6996
|
+
granter: this.apiSaasAddress
|
|
5734
6997
|
};
|
|
5735
6998
|
return client.addOperator({ operator }, grantFee);
|
|
5736
6999
|
} else if (gasStation && typeof fee === "object") {
|
|
5737
7000
|
const grantFee = {
|
|
5738
7001
|
...fee,
|
|
5739
|
-
granter: this.
|
|
7002
|
+
granter: this.apiSaasAddress
|
|
5740
7003
|
};
|
|
5741
7004
|
return client.addOperator({ operator }, grantFee);
|
|
5742
7005
|
}
|
|
5743
7006
|
return client.addOperator({ operator }, fee);
|
|
5744
7007
|
}
|
|
5745
|
-
async
|
|
7008
|
+
async removeApiSaasOperator({
|
|
5746
7009
|
signer,
|
|
5747
7010
|
operator,
|
|
5748
7011
|
gasStation = false,
|
|
5749
7012
|
fee = 1.8
|
|
5750
7013
|
}) {
|
|
5751
|
-
const client = await
|
|
7014
|
+
const client = await createApiSaasClientBy({
|
|
5752
7015
|
rpcEndpoint: this.rpcEndpoint,
|
|
5753
7016
|
wallet: signer,
|
|
5754
|
-
contractAddress: this.
|
|
7017
|
+
contractAddress: this.apiSaasAddress
|
|
5755
7018
|
});
|
|
5756
7019
|
if (gasStation && typeof fee !== "object") {
|
|
5757
7020
|
const [{ address }] = await signer.getAccounts();
|
|
@@ -5768,7 +7031,7 @@ var Contract = class {
|
|
|
5768
7031
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5769
7032
|
value: {
|
|
5770
7033
|
sender: address,
|
|
5771
|
-
contract: this.
|
|
7034
|
+
contract: this.apiSaasAddress,
|
|
5772
7035
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5773
7036
|
}
|
|
5774
7037
|
}
|
|
@@ -5784,105 +7047,91 @@ var Contract = class {
|
|
|
5784
7047
|
const grantFee = {
|
|
5785
7048
|
amount: calculatedFee.amount,
|
|
5786
7049
|
gas: calculatedFee.gas,
|
|
5787
|
-
granter: this.
|
|
7050
|
+
granter: this.apiSaasAddress
|
|
5788
7051
|
};
|
|
5789
7052
|
return client.removeOperator({ operator }, grantFee);
|
|
5790
7053
|
} else if (gasStation && typeof fee === "object") {
|
|
5791
7054
|
const grantFee = {
|
|
5792
7055
|
...fee,
|
|
5793
|
-
granter: this.
|
|
7056
|
+
granter: this.apiSaasAddress
|
|
5794
7057
|
};
|
|
5795
7058
|
return client.removeOperator({ operator }, grantFee);
|
|
5796
7059
|
}
|
|
5797
7060
|
return client.removeOperator({ operator }, fee);
|
|
5798
7061
|
}
|
|
5799
|
-
async
|
|
7062
|
+
async isApiSaasOperator({
|
|
5800
7063
|
signer,
|
|
5801
7064
|
operator
|
|
5802
7065
|
}) {
|
|
5803
|
-
const client = await
|
|
7066
|
+
const client = await createApiSaasClientBy({
|
|
5804
7067
|
rpcEndpoint: this.rpcEndpoint,
|
|
5805
7068
|
wallet: signer,
|
|
5806
|
-
contractAddress: this.
|
|
7069
|
+
contractAddress: this.apiSaasAddress
|
|
5807
7070
|
});
|
|
5808
7071
|
return client.isOperator({ address: operator });
|
|
5809
7072
|
}
|
|
5810
|
-
async
|
|
5811
|
-
signer,
|
|
5812
|
-
amount,
|
|
5813
|
-
gasStation = false,
|
|
5814
|
-
fee = 1.8
|
|
5815
|
-
}) {
|
|
5816
|
-
const client = await createSaasClientBy({
|
|
5817
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5818
|
-
wallet: signer,
|
|
5819
|
-
contractAddress: this.saasAddress
|
|
5820
|
-
});
|
|
5821
|
-
const funds = [
|
|
5822
|
-
{
|
|
5823
|
-
denom: "peaka",
|
|
5824
|
-
amount
|
|
5825
|
-
}
|
|
5826
|
-
];
|
|
5827
|
-
if (gasStation && typeof fee !== "object") {
|
|
5828
|
-
const [{ address }] = await signer.getAccounts();
|
|
5829
|
-
const contractClient = await this.contractClient({ signer });
|
|
5830
|
-
const msg = {
|
|
5831
|
-
deposit: {}
|
|
5832
|
-
};
|
|
5833
|
-
const gasEstimation = await contractClient.simulate(
|
|
5834
|
-
address,
|
|
5835
|
-
[
|
|
5836
|
-
{
|
|
5837
|
-
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5838
|
-
value: {
|
|
5839
|
-
sender: address,
|
|
5840
|
-
contract: this.saasAddress,
|
|
5841
|
-
msg: new TextEncoder().encode(JSON.stringify(msg)),
|
|
5842
|
-
funds
|
|
5843
|
-
}
|
|
5844
|
-
}
|
|
5845
|
-
],
|
|
5846
|
-
""
|
|
5847
|
-
);
|
|
5848
|
-
const multiplier = typeof fee === "number" ? fee : 1.8;
|
|
5849
|
-
const gasPrice = import_stargate2.GasPrice.fromString("10000000000peaka");
|
|
5850
|
-
const calculatedFee = (0, import_stargate2.calculateFee)(
|
|
5851
|
-
Math.round(gasEstimation * multiplier),
|
|
5852
|
-
gasPrice
|
|
5853
|
-
);
|
|
5854
|
-
const grantFee = {
|
|
5855
|
-
amount: calculatedFee.amount,
|
|
5856
|
-
gas: calculatedFee.gas,
|
|
5857
|
-
granter: this.saasAddress
|
|
5858
|
-
};
|
|
5859
|
-
return client.deposit(grantFee, void 0, funds);
|
|
5860
|
-
} else if (gasStation && typeof fee === "object") {
|
|
5861
|
-
const grantFee = {
|
|
5862
|
-
...fee,
|
|
5863
|
-
granter: this.saasAddress
|
|
5864
|
-
};
|
|
5865
|
-
return client.deposit(grantFee, void 0, funds);
|
|
5866
|
-
}
|
|
5867
|
-
return client.deposit(fee, void 0, funds);
|
|
5868
|
-
}
|
|
5869
|
-
async withdrawSaas({
|
|
7073
|
+
async createApiSaasAmaciRound({
|
|
5870
7074
|
signer,
|
|
5871
|
-
|
|
7075
|
+
operator,
|
|
7076
|
+
startVoting,
|
|
7077
|
+
endVoting,
|
|
7078
|
+
title,
|
|
7079
|
+
description,
|
|
7080
|
+
link,
|
|
7081
|
+
maxVoter,
|
|
7082
|
+
voteOptionMap,
|
|
7083
|
+
whitelist,
|
|
7084
|
+
voiceCreditAmount,
|
|
7085
|
+
preDeactivateRoot,
|
|
7086
|
+
oracleWhitelistPubkey,
|
|
7087
|
+
circuitType,
|
|
5872
7088
|
gasStation = false,
|
|
5873
7089
|
fee = 1.8
|
|
5874
7090
|
}) {
|
|
5875
|
-
const
|
|
7091
|
+
const startTime = (startVoting.getTime() * 1e6).toString();
|
|
7092
|
+
const endTime = (endVoting.getTime() * 1e6).toString();
|
|
7093
|
+
const client = await createApiSaasClientBy({
|
|
5876
7094
|
rpcEndpoint: this.rpcEndpoint,
|
|
5877
7095
|
wallet: signer,
|
|
5878
|
-
contractAddress: this.
|
|
7096
|
+
contractAddress: this.apiSaasAddress
|
|
5879
7097
|
});
|
|
7098
|
+
const roundParams = {
|
|
7099
|
+
certificationSystem: "0",
|
|
7100
|
+
circuitType: circuitType.toString(),
|
|
7101
|
+
maxVoter: maxVoter.toString(),
|
|
7102
|
+
operator,
|
|
7103
|
+
oracleWhitelistPubkey,
|
|
7104
|
+
preDeactivateRoot: preDeactivateRoot || "0",
|
|
7105
|
+
roundInfo: {
|
|
7106
|
+
title,
|
|
7107
|
+
description: description || "",
|
|
7108
|
+
link: link || ""
|
|
7109
|
+
},
|
|
7110
|
+
voiceCreditAmount,
|
|
7111
|
+
voteOptionMap,
|
|
7112
|
+
votingTime: {
|
|
7113
|
+
start_time: startTime,
|
|
7114
|
+
end_time: endTime
|
|
7115
|
+
},
|
|
7116
|
+
whitelist
|
|
7117
|
+
};
|
|
7118
|
+
let createResponse;
|
|
5880
7119
|
if (gasStation && typeof fee !== "object") {
|
|
5881
7120
|
const [{ address }] = await signer.getAccounts();
|
|
5882
7121
|
const contractClient = await this.contractClient({ signer });
|
|
5883
7122
|
const msg = {
|
|
5884
|
-
|
|
5885
|
-
|
|
7123
|
+
create_amaci_round: {
|
|
7124
|
+
certification_system: "0",
|
|
7125
|
+
circuit_type: circuitType.toString(),
|
|
7126
|
+
max_voter: maxVoter.toString(),
|
|
7127
|
+
operator,
|
|
7128
|
+
oracle_whitelist_pubkey: oracleWhitelistPubkey,
|
|
7129
|
+
pre_deactivate_root: preDeactivateRoot || "0",
|
|
7130
|
+
round_info: roundParams.roundInfo,
|
|
7131
|
+
voice_credit_amount: voiceCreditAmount,
|
|
7132
|
+
vote_option_map: voteOptionMap,
|
|
7133
|
+
voting_time: roundParams.votingTime,
|
|
7134
|
+
whitelist
|
|
5886
7135
|
}
|
|
5887
7136
|
};
|
|
5888
7137
|
const gasEstimation = await contractClient.simulate(
|
|
@@ -5892,7 +7141,7 @@ var Contract = class {
|
|
|
5892
7141
|
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
|
|
5893
7142
|
value: {
|
|
5894
7143
|
sender: address,
|
|
5895
|
-
contract: this.
|
|
7144
|
+
contract: this.apiSaasAddress,
|
|
5896
7145
|
msg: new TextEncoder().encode(JSON.stringify(msg))
|
|
5897
7146
|
}
|
|
5898
7147
|
}
|
|
@@ -5908,83 +7157,38 @@ var Contract = class {
|
|
|
5908
7157
|
const grantFee = {
|
|
5909
7158
|
amount: calculatedFee.amount,
|
|
5910
7159
|
gas: calculatedFee.gas,
|
|
5911
|
-
granter: this.
|
|
7160
|
+
granter: this.apiSaasAddress
|
|
5912
7161
|
};
|
|
5913
|
-
|
|
7162
|
+
createResponse = await client.createAmaciRound(roundParams, grantFee);
|
|
5914
7163
|
} else if (gasStation && typeof fee === "object") {
|
|
5915
7164
|
const grantFee = {
|
|
5916
7165
|
...fee,
|
|
5917
|
-
granter: this.
|
|
7166
|
+
granter: this.apiSaasAddress
|
|
5918
7167
|
};
|
|
5919
|
-
|
|
7168
|
+
createResponse = await client.createAmaciRound(roundParams, grantFee);
|
|
7169
|
+
} else {
|
|
7170
|
+
createResponse = await client.createAmaciRound(roundParams, fee);
|
|
5920
7171
|
}
|
|
5921
|
-
|
|
5922
|
-
|
|
5923
|
-
|
|
5924
|
-
|
|
5925
|
-
|
|
5926
|
-
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
signer,
|
|
5937
|
-
contractAddress
|
|
5938
|
-
}) {
|
|
5939
|
-
const client = await createOracleMaciClientBy({
|
|
5940
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5941
|
-
wallet: signer,
|
|
5942
|
-
contractAddress
|
|
5943
|
-
});
|
|
5944
|
-
return client;
|
|
5945
|
-
}
|
|
5946
|
-
async registryClient({
|
|
5947
|
-
signer,
|
|
5948
|
-
contractAddress
|
|
5949
|
-
}) {
|
|
5950
|
-
return createRegistryClientBy({
|
|
5951
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5952
|
-
wallet: signer,
|
|
5953
|
-
contractAddress
|
|
5954
|
-
});
|
|
5955
|
-
}
|
|
5956
|
-
async maciClient({
|
|
5957
|
-
signer,
|
|
5958
|
-
contractAddress
|
|
5959
|
-
}) {
|
|
5960
|
-
return createMaciClientBy({
|
|
5961
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5962
|
-
wallet: signer,
|
|
5963
|
-
contractAddress
|
|
5964
|
-
});
|
|
5965
|
-
}
|
|
5966
|
-
async amaciClient({
|
|
5967
|
-
signer,
|
|
5968
|
-
contractAddress
|
|
5969
|
-
}) {
|
|
5970
|
-
return createAMaciClientBy({
|
|
5971
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5972
|
-
wallet: signer,
|
|
5973
|
-
contractAddress
|
|
7172
|
+
let contractAddress = "";
|
|
7173
|
+
createResponse.events.map((event) => {
|
|
7174
|
+
if (event.type === "wasm") {
|
|
7175
|
+
let actionEvent = event.attributes.find(
|
|
7176
|
+
(attr) => attr.key === "action"
|
|
7177
|
+
);
|
|
7178
|
+
if (actionEvent && actionEvent.value === "created_round") {
|
|
7179
|
+
const roundAddrEvent = event.attributes.find(
|
|
7180
|
+
(attr) => attr.key === "round_addr"
|
|
7181
|
+
);
|
|
7182
|
+
if (roundAddrEvent) {
|
|
7183
|
+
contractAddress = roundAddrEvent.value.toString();
|
|
7184
|
+
}
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
5974
7187
|
});
|
|
5975
|
-
|
|
5976
|
-
|
|
5977
|
-
signer,
|
|
5978
|
-
contractAddress
|
|
5979
|
-
}) {
|
|
5980
|
-
return createSaasClientBy({
|
|
5981
|
-
rpcEndpoint: this.rpcEndpoint,
|
|
5982
|
-
wallet: signer,
|
|
7188
|
+
return {
|
|
7189
|
+
...createResponse,
|
|
5983
7190
|
contractAddress
|
|
5984
|
-
}
|
|
5985
|
-
}
|
|
5986
|
-
async contractClient({ signer }) {
|
|
5987
|
-
return createContractClientByWallet(this.rpcEndpoint, signer);
|
|
7191
|
+
};
|
|
5988
7192
|
}
|
|
5989
7193
|
};
|
|
5990
7194
|
|
|
@@ -6367,13 +7571,16 @@ var MACI = class {
|
|
|
6367
7571
|
const client = await this.contract.contractClient({
|
|
6368
7572
|
signer
|
|
6369
7573
|
});
|
|
6370
|
-
if (oracleCertificate) {
|
|
7574
|
+
if (oracleCertificate && oracleCertificate.amount) {
|
|
6371
7575
|
return await this.signupOracle({
|
|
6372
7576
|
client,
|
|
6373
7577
|
address,
|
|
6374
7578
|
pubKey: maciKeypair.pubKey,
|
|
6375
7579
|
contractAddress,
|
|
6376
|
-
oracleCertificate
|
|
7580
|
+
oracleCertificate: {
|
|
7581
|
+
amount: oracleCertificate.amount,
|
|
7582
|
+
signature: oracleCertificate.signature
|
|
7583
|
+
},
|
|
6377
7584
|
gasStation,
|
|
6378
7585
|
fee
|
|
6379
7586
|
});
|
|
@@ -6383,7 +7590,55 @@ var MACI = class {
|
|
|
6383
7590
|
address,
|
|
6384
7591
|
pubKey: maciKeypair.pubKey,
|
|
6385
7592
|
contractAddress,
|
|
7593
|
+
certificate: oracleCertificate?.signature,
|
|
7594
|
+
gasStation,
|
|
7595
|
+
fee
|
|
7596
|
+
});
|
|
7597
|
+
}
|
|
7598
|
+
} catch (error) {
|
|
7599
|
+
throw Error(`Signup failed! ${error}`);
|
|
7600
|
+
}
|
|
7601
|
+
}
|
|
7602
|
+
async rawSignup({
|
|
7603
|
+
signer,
|
|
7604
|
+
address,
|
|
7605
|
+
contractAddress,
|
|
7606
|
+
pubKey,
|
|
7607
|
+
oracleCertificate,
|
|
7608
|
+
gasStation = false,
|
|
7609
|
+
granter,
|
|
7610
|
+
fee
|
|
7611
|
+
}) {
|
|
7612
|
+
try {
|
|
7613
|
+
if (!address) {
|
|
7614
|
+
address = (await signer.getAccounts())[0].address;
|
|
7615
|
+
}
|
|
7616
|
+
const client = await this.contract.contractClient({
|
|
7617
|
+
signer
|
|
7618
|
+
});
|
|
7619
|
+
if (oracleCertificate && oracleCertificate.amount) {
|
|
7620
|
+
return await this.signupOracle({
|
|
7621
|
+
client,
|
|
7622
|
+
address,
|
|
7623
|
+
pubKey,
|
|
7624
|
+
contractAddress,
|
|
7625
|
+
oracleCertificate: {
|
|
7626
|
+
amount: oracleCertificate.amount,
|
|
7627
|
+
signature: oracleCertificate.signature
|
|
7628
|
+
},
|
|
7629
|
+
gasStation,
|
|
7630
|
+
granter,
|
|
7631
|
+
fee
|
|
7632
|
+
});
|
|
7633
|
+
} else {
|
|
7634
|
+
return await this.signupSimple({
|
|
7635
|
+
client,
|
|
7636
|
+
address,
|
|
7637
|
+
pubKey,
|
|
7638
|
+
contractAddress,
|
|
7639
|
+
certificate: oracleCertificate?.signature,
|
|
6386
7640
|
gasStation,
|
|
7641
|
+
granter,
|
|
6387
7642
|
fee
|
|
6388
7643
|
});
|
|
6389
7644
|
}
|
|
@@ -6509,12 +7764,93 @@ var MACI = class {
|
|
|
6509
7764
|
throw Error(`Vote failed! ${error}`);
|
|
6510
7765
|
}
|
|
6511
7766
|
}
|
|
7767
|
+
async rawVote({
|
|
7768
|
+
signer,
|
|
7769
|
+
address,
|
|
7770
|
+
contractAddress,
|
|
7771
|
+
pubKey,
|
|
7772
|
+
payload,
|
|
7773
|
+
gasStation = false,
|
|
7774
|
+
granter,
|
|
7775
|
+
fee = 1.8
|
|
7776
|
+
}) {
|
|
7777
|
+
const stateIdx = await this.getStateIdxByPubKey({
|
|
7778
|
+
contractAddress,
|
|
7779
|
+
pubKey
|
|
7780
|
+
});
|
|
7781
|
+
if (stateIdx === -1) {
|
|
7782
|
+
throw new Error(
|
|
7783
|
+
"State index is not set, Please signup or addNewKey first"
|
|
7784
|
+
);
|
|
7785
|
+
}
|
|
7786
|
+
try {
|
|
7787
|
+
const round = await this.indexer.getRoundWithFields(contractAddress, [
|
|
7788
|
+
"maciType",
|
|
7789
|
+
"voiceCreditAmount"
|
|
7790
|
+
]);
|
|
7791
|
+
if (isErrorResponse(round)) {
|
|
7792
|
+
throw new Error(
|
|
7793
|
+
`Failed to get round info: ${round.error.type} ${round.error.message}`
|
|
7794
|
+
);
|
|
7795
|
+
}
|
|
7796
|
+
let voiceCreditBalance;
|
|
7797
|
+
if (round.data.round.maciType === "aMACI") {
|
|
7798
|
+
const isWhiteListed = await this.isWhitelisted({
|
|
7799
|
+
signer,
|
|
7800
|
+
address,
|
|
7801
|
+
contractAddress
|
|
7802
|
+
});
|
|
7803
|
+
if (isWhiteListed) {
|
|
7804
|
+
const round2 = await this.indexer.getRoundWithFields(contractAddress, [
|
|
7805
|
+
"voiceCreditAmount"
|
|
7806
|
+
]);
|
|
7807
|
+
if (!isErrorResponse(round2)) {
|
|
7808
|
+
if (round2.data.round.voiceCreditAmount) {
|
|
7809
|
+
voiceCreditBalance = round2.data.round.voiceCreditAmount;
|
|
7810
|
+
} else {
|
|
7811
|
+
voiceCreditBalance = "0";
|
|
7812
|
+
}
|
|
7813
|
+
} else {
|
|
7814
|
+
throw new Error(
|
|
7815
|
+
`Failed to query amaci voice credit: ${round2.error.type} ${round2.error.message}`
|
|
7816
|
+
);
|
|
7817
|
+
}
|
|
7818
|
+
} else {
|
|
7819
|
+
voiceCreditBalance = "0";
|
|
7820
|
+
}
|
|
7821
|
+
} else {
|
|
7822
|
+
voiceCreditBalance = await this.getVoiceCreditBalance({
|
|
7823
|
+
signer,
|
|
7824
|
+
stateIdx,
|
|
7825
|
+
contractAddress
|
|
7826
|
+
});
|
|
7827
|
+
}
|
|
7828
|
+
if (!address) {
|
|
7829
|
+
address = (await signer.getAccounts())[0].address;
|
|
7830
|
+
}
|
|
7831
|
+
const client = await this.contract.contractClient({
|
|
7832
|
+
signer
|
|
7833
|
+
});
|
|
7834
|
+
return await this.publishMessage({
|
|
7835
|
+
client,
|
|
7836
|
+
address,
|
|
7837
|
+
payload,
|
|
7838
|
+
contractAddress,
|
|
7839
|
+
gasStation,
|
|
7840
|
+
granter,
|
|
7841
|
+
fee
|
|
7842
|
+
});
|
|
7843
|
+
} catch (error) {
|
|
7844
|
+
throw Error(`Vote failed! ${error}`);
|
|
7845
|
+
}
|
|
7846
|
+
}
|
|
6512
7847
|
async publishMessage({
|
|
6513
7848
|
client,
|
|
6514
7849
|
address,
|
|
6515
7850
|
payload,
|
|
6516
7851
|
contractAddress,
|
|
6517
7852
|
gasStation,
|
|
7853
|
+
granter,
|
|
6518
7854
|
fee = 1.8
|
|
6519
7855
|
}) {
|
|
6520
7856
|
const msgs = payload.map(
|
|
@@ -6552,13 +7888,13 @@ var MACI = class {
|
|
|
6552
7888
|
const grantFee = {
|
|
6553
7889
|
amount: calculatedFee.amount,
|
|
6554
7890
|
gas: calculatedFee.gas,
|
|
6555
|
-
granter: contractAddress
|
|
7891
|
+
granter: granter || contractAddress
|
|
6556
7892
|
};
|
|
6557
7893
|
return client.signAndBroadcast(address, msgs, grantFee);
|
|
6558
7894
|
} else if (gasStation && typeof fee === "object") {
|
|
6559
7895
|
const grantFee = {
|
|
6560
7896
|
...fee,
|
|
6561
|
-
granter: contractAddress
|
|
7897
|
+
granter: granter || contractAddress
|
|
6562
7898
|
};
|
|
6563
7899
|
return client.signAndBroadcast(address, msgs, grantFee);
|
|
6564
7900
|
}
|
|
@@ -6569,11 +7905,14 @@ var MACI = class {
|
|
|
6569
7905
|
address,
|
|
6570
7906
|
pubKey,
|
|
6571
7907
|
contractAddress,
|
|
7908
|
+
certificate,
|
|
6572
7909
|
gasStation,
|
|
7910
|
+
granter,
|
|
6573
7911
|
fee = 1.8
|
|
6574
7912
|
}) {
|
|
6575
7913
|
const msg = {
|
|
6576
7914
|
sign_up: {
|
|
7915
|
+
certificate,
|
|
6577
7916
|
pubkey: {
|
|
6578
7917
|
x: pubKey[0].toString(),
|
|
6579
7918
|
y: pubKey[1].toString()
|
|
@@ -6604,13 +7943,13 @@ var MACI = class {
|
|
|
6604
7943
|
const grantFee = {
|
|
6605
7944
|
amount: calculatedFee.amount,
|
|
6606
7945
|
gas: calculatedFee.gas,
|
|
6607
|
-
granter: contractAddress
|
|
7946
|
+
granter: granter || contractAddress
|
|
6608
7947
|
};
|
|
6609
7948
|
return client.execute(address, contractAddress, msg, grantFee);
|
|
6610
7949
|
} else if (gasStation === true && typeof fee === "object") {
|
|
6611
7950
|
const grantFee = {
|
|
6612
7951
|
...fee,
|
|
6613
|
-
granter: contractAddress
|
|
7952
|
+
granter: granter || contractAddress
|
|
6614
7953
|
};
|
|
6615
7954
|
return client.execute(address, contractAddress, msg, grantFee);
|
|
6616
7955
|
}
|
|
@@ -6623,6 +7962,7 @@ var MACI = class {
|
|
|
6623
7962
|
contractAddress,
|
|
6624
7963
|
oracleCertificate,
|
|
6625
7964
|
gasStation,
|
|
7965
|
+
granter,
|
|
6626
7966
|
fee = 1.8
|
|
6627
7967
|
}) {
|
|
6628
7968
|
const msg = {
|
|
@@ -6659,13 +7999,13 @@ var MACI = class {
|
|
|
6659
7999
|
const grantFee = {
|
|
6660
8000
|
amount: calculatedFee.amount,
|
|
6661
8001
|
gas: calculatedFee.gas,
|
|
6662
|
-
granter: contractAddress
|
|
8002
|
+
granter: granter || contractAddress
|
|
6663
8003
|
};
|
|
6664
8004
|
return client.execute(address, contractAddress, msg, grantFee);
|
|
6665
8005
|
} else if (gasStation === true && typeof fee === "object") {
|
|
6666
8006
|
const grantFee = {
|
|
6667
8007
|
...fee,
|
|
6668
|
-
granter: contractAddress
|
|
8008
|
+
granter: granter || contractAddress
|
|
6669
8009
|
};
|
|
6670
8010
|
return client.execute(address, contractAddress, msg, grantFee);
|
|
6671
8011
|
}
|
|
@@ -6972,9 +8312,9 @@ var MaciClient2 = class {
|
|
|
6972
8312
|
apiEndpoint,
|
|
6973
8313
|
registryAddress,
|
|
6974
8314
|
saasAddress,
|
|
8315
|
+
apiSaasAddress,
|
|
6975
8316
|
maciCodeId,
|
|
6976
8317
|
oracleCodeId,
|
|
6977
|
-
saasOracleCodeId,
|
|
6978
8318
|
customFetch,
|
|
6979
8319
|
defaultOptions,
|
|
6980
8320
|
feegrantOperator,
|
|
@@ -6991,9 +8331,9 @@ var MaciClient2 = class {
|
|
|
6991
8331
|
this.certificateApiEndpoint = certificateApiEndpoint || defaultParams.certificateApiEndpoint;
|
|
6992
8332
|
this.registryAddress = registryAddress || defaultParams.registryAddress;
|
|
6993
8333
|
this.saasAddress = saasAddress || defaultParams.saasAddress;
|
|
8334
|
+
this.apiSaasAddress = apiSaasAddress || defaultParams.apiSaasAddress;
|
|
6994
8335
|
this.maciCodeId = maciCodeId || defaultParams.maciCodeId;
|
|
6995
8336
|
this.oracleCodeId = oracleCodeId || defaultParams.oracleCodeId;
|
|
6996
|
-
this.saasOracleCodeId = saasOracleCodeId || defaultParams.saasCodeId;
|
|
6997
8337
|
this.feegrantOperator = feegrantOperator || defaultParams.oracleFeegrantOperator;
|
|
6998
8338
|
this.whitelistBackendPubkey = whitelistBackendPubkey || defaultParams.oracleWhitelistBackendPubkey;
|
|
6999
8339
|
this.maciKeypair = maciKeypair ?? genKeypair();
|
|
@@ -7014,9 +8354,9 @@ var MaciClient2 = class {
|
|
|
7014
8354
|
rpcEndpoint: this.rpcEndpoint,
|
|
7015
8355
|
registryAddress: this.registryAddress,
|
|
7016
8356
|
saasAddress: this.saasAddress,
|
|
8357
|
+
apiSaasAddress: this.apiSaasAddress,
|
|
7017
8358
|
maciCodeId: this.maciCodeId,
|
|
7018
8359
|
oracleCodeId: this.oracleCodeId,
|
|
7019
|
-
saasOracleCodeId: this.saasOracleCodeId,
|
|
7020
8360
|
feegrantOperator: this.feegrantOperator,
|
|
7021
8361
|
whitelistBackendPubkey: this.whitelistBackendPubkey
|
|
7022
8362
|
});
|
|
@@ -7111,6 +8451,18 @@ var MaciClient2 = class {
|
|
|
7111
8451
|
...params
|
|
7112
8452
|
});
|
|
7113
8453
|
}
|
|
8454
|
+
async createApiSaasMaciRound(params) {
|
|
8455
|
+
return await this.contract.createApiSaasMaciRound({
|
|
8456
|
+
signer: this.getSigner(params.signer),
|
|
8457
|
+
...params
|
|
8458
|
+
});
|
|
8459
|
+
}
|
|
8460
|
+
async createApiSaasAmaciRound(params) {
|
|
8461
|
+
return await this.contract.createApiSaasAmaciRound({
|
|
8462
|
+
signer: this.getSigner(params.signer),
|
|
8463
|
+
...params
|
|
8464
|
+
});
|
|
8465
|
+
}
|
|
7114
8466
|
async genKeypairFromSign({
|
|
7115
8467
|
signer,
|
|
7116
8468
|
address
|
|
@@ -7417,6 +8769,48 @@ var MaciClient2 = class {
|
|
|
7417
8769
|
fee
|
|
7418
8770
|
});
|
|
7419
8771
|
}
|
|
8772
|
+
async rawSignup({
|
|
8773
|
+
signer,
|
|
8774
|
+
address,
|
|
8775
|
+
contractAddress,
|
|
8776
|
+
pubKey,
|
|
8777
|
+
oracleCertificate,
|
|
8778
|
+
gasStation = false,
|
|
8779
|
+
granter,
|
|
8780
|
+
fee
|
|
8781
|
+
}) {
|
|
8782
|
+
return await this.maci.rawSignup({
|
|
8783
|
+
signer: this.getSigner(signer),
|
|
8784
|
+
address,
|
|
8785
|
+
contractAddress,
|
|
8786
|
+
pubKey,
|
|
8787
|
+
oracleCertificate,
|
|
8788
|
+
gasStation,
|
|
8789
|
+
granter,
|
|
8790
|
+
fee
|
|
8791
|
+
});
|
|
8792
|
+
}
|
|
8793
|
+
async rawVote({
|
|
8794
|
+
signer,
|
|
8795
|
+
address,
|
|
8796
|
+
contractAddress,
|
|
8797
|
+
pubKey,
|
|
8798
|
+
payload,
|
|
8799
|
+
gasStation = false,
|
|
8800
|
+
granter,
|
|
8801
|
+
fee
|
|
8802
|
+
}) {
|
|
8803
|
+
return await this.maci.rawVote({
|
|
8804
|
+
signer: this.getSigner(signer),
|
|
8805
|
+
address,
|
|
8806
|
+
contractAddress,
|
|
8807
|
+
pubKey,
|
|
8808
|
+
payload,
|
|
8809
|
+
gasStation,
|
|
8810
|
+
granter,
|
|
8811
|
+
fee
|
|
8812
|
+
});
|
|
8813
|
+
}
|
|
7420
8814
|
};
|
|
7421
8815
|
// Annotate the CommonJS export names for ESM import in node:
|
|
7422
8816
|
0 && (module.exports = {
|
|
@@ -7439,7 +8833,9 @@ var MaciClient2 = class {
|
|
|
7439
8833
|
UserAccount,
|
|
7440
8834
|
batchGenMessage,
|
|
7441
8835
|
bigInt2Buffer,
|
|
8836
|
+
buffer2Bigint,
|
|
7442
8837
|
circuits,
|
|
8838
|
+
destringizing,
|
|
7443
8839
|
formatPrivKeyForBabyJub,
|
|
7444
8840
|
genAddKeyInput,
|
|
7445
8841
|
genEcdhSharedKey,
|