@maci-protocol/coordinator 0.0.0-ci.8a288fb → 0.0.0-ci.8ab32a1
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/LICENSE +1 -2
- package/README.md +31 -6
- package/build/hardhat.config.cjs +3 -0
- package/build/hardhat.config.cjs.map +1 -1
- package/build/hardhat.config.d.cts +3 -0
- package/build/scripts/generateMaciKeyPair.js +2 -2
- package/build/scripts/generateMaciKeyPair.js.map +1 -1
- package/build/tests/constants.d.ts +0 -1
- package/build/tests/constants.d.ts.map +1 -1
- package/build/tests/constants.js +0 -1
- package/build/tests/constants.js.map +1 -1
- package/build/tests/e2e.aa.test.js +18 -25
- package/build/tests/e2e.aa.test.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +127 -82
- package/build/tests/e2e.deploy.test.js.map +1 -1
- package/build/tests/utils.d.ts +6 -0
- package/build/tests/utils.d.ts.map +1 -1
- package/build/tests/utils.js +12 -3
- package/build/tests/utils.js.map +1 -1
- package/build/ts/common/__tests__/common.test.js +9 -13
- package/build/ts/common/__tests__/common.test.js.map +1 -1
- package/build/ts/common/accountAbstraction.d.ts +2 -19
- package/build/ts/common/accountAbstraction.d.ts.map +1 -1
- package/build/ts/common/accountAbstraction.js +15 -44
- package/build/ts/common/accountAbstraction.js.map +1 -1
- package/build/ts/common/chain.d.ts +16 -0
- package/build/ts/common/chain.d.ts.map +1 -0
- package/build/ts/common/chain.js +32 -0
- package/build/ts/common/chain.js.map +1 -0
- package/build/ts/common/coordinatorKeypair.d.ts +7 -0
- package/build/ts/common/coordinatorKeypair.d.ts.map +1 -0
- package/build/ts/common/coordinatorKeypair.js +14 -0
- package/build/ts/common/coordinatorKeypair.js.map +1 -0
- package/build/ts/common/errors.d.ts +17 -18
- package/build/ts/common/errors.d.ts.map +1 -1
- package/build/ts/common/errors.js +17 -18
- package/build/ts/common/errors.js.map +1 -1
- package/build/ts/common/index.d.ts +2 -0
- package/build/ts/common/index.d.ts.map +1 -1
- package/build/ts/common/index.js +2 -0
- package/build/ts/common/index.js.map +1 -1
- package/build/ts/common/types.d.ts +2 -3
- package/build/ts/common/types.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/deployer.service.test.js +30 -289
- package/build/ts/deployer/__tests__/deployer.service.test.js.map +1 -1
- package/build/ts/deployer/__tests__/utils.d.ts +27 -1
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +42 -11
- package/build/ts/deployer/__tests__/utils.js.map +1 -1
- package/build/ts/deployer/deployer.service.d.ts +17 -53
- package/build/ts/deployer/deployer.service.d.ts.map +1 -1
- package/build/ts/deployer/deployer.service.js +178 -447
- package/build/ts/deployer/deployer.service.js.map +1 -1
- package/build/ts/deployer/dto.d.ts +4 -4
- package/build/ts/deployer/dto.d.ts.map +1 -1
- package/build/ts/deployer/dto.js +9 -1
- package/build/ts/deployer/dto.js.map +1 -1
- package/build/ts/deployer/types.d.ts +74 -26
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/__tests__/file.service.test.js +12 -11
- package/build/ts/file/__tests__/file.service.test.js.map +1 -1
- package/build/ts/file/file.service.d.ts +4 -3
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +14 -9
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/file/types.d.ts +2 -2
- package/build/ts/file/types.d.ts.map +1 -1
- package/build/ts/proof/__tests__/proof.controller.test.js +5 -3
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +6 -3
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +18 -31
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +13 -15
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +51 -44
- package/build/ts/proof/dto.js.map +1 -1
- package/build/ts/proof/proof.controller.d.ts +3 -2
- package/build/ts/proof/proof.controller.d.ts.map +1 -1
- package/build/ts/proof/proof.controller.js +1 -4
- package/build/ts/proof/proof.controller.js.map +1 -1
- package/build/ts/proof/proof.service.d.ts +4 -6
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +48 -130
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +19 -14
- package/build/ts/proof/types.d.ts.map +1 -1
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts +53 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.d.ts.map +1 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js +105 -0
- package/build/ts/sessionKeys/provider/KernelEIP1193Provider.js.map +1 -0
- package/build/ts/sessionKeys/sessionKeys.service.d.ts +13 -2
- package/build/ts/sessionKeys/sessionKeys.service.d.ts.map +1 -1
- package/build/ts/sessionKeys/sessionKeys.service.js +22 -4
- package/build/ts/sessionKeys/sessionKeys.service.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +35 -35
- package/build/ts/deployer/utils.d.ts +0 -8
- package/build/ts/deployer/utils.d.ts.map +0 -1
- package/build/ts/deployer/utils.js +0 -9
- package/build/ts/deployer/utils.js.map +0 -1
|
@@ -7,29 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { Injectable, Logger } from "@nestjs/common";
|
|
10
|
+
import { deployVerifier } from "@maci-protocol/contracts";
|
|
11
|
+
import { ContractStorage, EPolicies, VerifyingKeysRegistry__factory as VerifyingKeysRegistryFactory, MessageProcessor__factory as MessageProcessorFactory, Tally__factory as TallyFactory, Poll__factory as PollFactory, MACI__factory as MACIFactory, EContracts, EInitialVoiceCreditProxies, EMode, deployPoll, extractAllVerifyingKeys, deployConstantInitialVoiceCreditProxy, deployFreeForAllSignUpPolicy, deployERC20VotesPolicy, deployAnonAadhaarPolicy, deploySignupTokenPolicy, deployMerkleProofPolicy, deploySemaphoreSignupPolicy, deployZupassSignUpPolicy, deployGitcoinPassportPolicy, deployEASSignUpPolicy, deployHatsSignupPolicy, deployMaci, setVerifyingKeys, deployVerifyingKeysRegistryContract, generateEmptyBallotRoots, } from "@maci-protocol/sdk";
|
|
12
|
+
import { Injectable } from "@nestjs/common";
|
|
14
13
|
import { BaseContract } from "ethers";
|
|
15
|
-
import { encodeFunctionData } from "viem";
|
|
16
14
|
import path from "path";
|
|
17
15
|
import { ErrorCodes } from "../common";
|
|
18
|
-
import {
|
|
16
|
+
import { getCoordinatorKeypair } from "../common/coordinatorKeypair";
|
|
19
17
|
import { FileService } from "../file/file.service";
|
|
20
18
|
import { SessionKeysService } from "../sessionKeys/sessionKeys.service";
|
|
21
|
-
import { MAX_GAS_LIMIT } from "./constants";
|
|
22
|
-
import { estimateExtraGasLimit } from "./utils";
|
|
23
19
|
/**
|
|
24
20
|
* DeployerService is responsible for deploying contracts.
|
|
25
21
|
*/
|
|
26
|
-
let DeployerService =
|
|
22
|
+
let DeployerService = class DeployerService {
|
|
27
23
|
sessionKeysService;
|
|
28
24
|
fileService;
|
|
29
|
-
/**
|
|
30
|
-
* Logger
|
|
31
|
-
*/
|
|
32
|
-
logger = new Logger(DeployerService_1.name);
|
|
33
25
|
/**
|
|
34
26
|
* Contract storage instance
|
|
35
27
|
*/
|
|
@@ -42,299 +34,168 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
42
34
|
constructor(sessionKeysService, fileService) {
|
|
43
35
|
this.sessionKeysService = sessionKeysService;
|
|
44
36
|
this.fileService = fileService;
|
|
45
|
-
this.logger = new Logger(DeployerService_1.name);
|
|
46
37
|
this.storage = ContractStorage.getInstance(path.join(process.cwd(), "deployed-contracts.json"));
|
|
47
38
|
}
|
|
48
39
|
/**
|
|
49
|
-
* Get the policy
|
|
50
|
-
*
|
|
40
|
+
* Get the policy contract object
|
|
41
|
+
* always deploy and save it
|
|
51
42
|
*
|
|
43
|
+
* @param signer - the signer
|
|
52
44
|
* @param policyType - the policy type
|
|
53
45
|
* @param network - the network
|
|
54
46
|
* @param args - the policy args
|
|
55
|
-
* @returns - the policy
|
|
47
|
+
* @returns - the policy contract
|
|
56
48
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let storedArgs;
|
|
60
|
-
let isAlreadyDeployed;
|
|
49
|
+
async deployAndSavePolicy(signer, policyType, network, args) {
|
|
50
|
+
let contract;
|
|
61
51
|
// based on the policy type, we need to deploy the correct policy
|
|
62
52
|
switch (policyType) {
|
|
63
53
|
case EPolicies.FreeForAll: {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
abi: FreeForAllPolicyFactory.abi,
|
|
67
|
-
bytecode: FreeForAllPolicyFactory.bytecode,
|
|
68
|
-
alreadyDeployed: !!address,
|
|
69
|
-
};
|
|
54
|
+
[contract] = await deployFreeForAllSignUpPolicy({}, signer, true);
|
|
55
|
+
break;
|
|
70
56
|
}
|
|
71
57
|
case EPolicies.EAS: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
storedArgs[2] === args.attester;
|
|
79
|
-
return {
|
|
80
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
81
|
-
abi: EASPolicyFactory.abi,
|
|
82
|
-
bytecode: EASPolicyFactory.bytecode,
|
|
83
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
84
|
-
};
|
|
58
|
+
[contract] = await deployEASSignUpPolicy({
|
|
59
|
+
eas: args.easAddress,
|
|
60
|
+
attester: args.attester,
|
|
61
|
+
schema: args.schema,
|
|
62
|
+
}, {}, signer, true);
|
|
63
|
+
break;
|
|
85
64
|
}
|
|
86
|
-
case EPolicies.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
storedArgs[1] === args.signer2 &&
|
|
93
|
-
storedArgs[2] === args.eventId &&
|
|
94
|
-
storedArgs[3] === args.zupassVerifier;
|
|
95
|
-
return {
|
|
96
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
97
|
-
abi: ZupassPolicyFactory.abi,
|
|
98
|
-
bytecode: ZupassPolicyFactory.bytecode,
|
|
99
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
100
|
-
};
|
|
65
|
+
case EPolicies.GitcoinPassport: {
|
|
66
|
+
[contract] = await deployGitcoinPassportPolicy({
|
|
67
|
+
decoderAddress: args.decoderAddress,
|
|
68
|
+
minimumScore: Number(args.passingScore),
|
|
69
|
+
}, {}, signer, true);
|
|
70
|
+
break;
|
|
101
71
|
}
|
|
102
72
|
case EPolicies.Hats: {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
73
|
+
[contract] = await deployHatsSignupPolicy({
|
|
74
|
+
hats: args.hatsProtocolAddress,
|
|
75
|
+
criterionHats: args.critrionHats.map((c) => BigInt(c)),
|
|
76
|
+
}, {}, signer, true);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
case EPolicies.Zupass: {
|
|
80
|
+
[contract] = await deployZupassSignUpPolicy({
|
|
81
|
+
eventId: args.eventId,
|
|
82
|
+
signer1: args.signer1,
|
|
83
|
+
signer2: args.signer2,
|
|
84
|
+
verifier: args.zupassVerifier,
|
|
85
|
+
}, {}, signer, true);
|
|
86
|
+
break;
|
|
115
87
|
}
|
|
116
88
|
case EPolicies.Semaphore: {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
storedArgs[1] === args.groupId;
|
|
123
|
-
return {
|
|
124
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
125
|
-
abi: SemaphorePolicyFactory.abi,
|
|
126
|
-
bytecode: SemaphorePolicyFactory.bytecode,
|
|
127
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
128
|
-
};
|
|
89
|
+
[contract] = await deploySemaphoreSignupPolicy({
|
|
90
|
+
semaphore: args.semaphoreContract,
|
|
91
|
+
groupId: BigInt(args.groupId),
|
|
92
|
+
}, {}, signer, true);
|
|
93
|
+
break;
|
|
129
94
|
}
|
|
130
|
-
case EPolicies.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
95
|
+
case EPolicies.MerkleProof: {
|
|
96
|
+
[contract] = await deployMerkleProofPolicy({
|
|
97
|
+
root: args.root,
|
|
98
|
+
}, {}, signer, true);
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
case EPolicies.Token: {
|
|
102
|
+
[contract] = await deploySignupTokenPolicy({
|
|
103
|
+
token: args.token,
|
|
104
|
+
}, {}, signer, true);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
case EPolicies.AnonAadhaar: {
|
|
108
|
+
[contract] = await deployAnonAadhaarPolicy({
|
|
109
|
+
verifierAddress: args.verifier,
|
|
110
|
+
nullifierSeed: args.nullifierSeed,
|
|
111
|
+
}, {}, signer, true);
|
|
112
|
+
break;
|
|
143
113
|
}
|
|
144
114
|
case EPolicies.ERC20Votes: {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
storedArgs[2] === args.snapshotBlock;
|
|
152
|
-
return {
|
|
153
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
154
|
-
abi: ERC20VotesPolicyFactory.abi,
|
|
155
|
-
bytecode: ERC20VotesPolicyFactory.bytecode,
|
|
156
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
157
|
-
};
|
|
115
|
+
[contract] = await deployERC20VotesPolicy({
|
|
116
|
+
snapshotBlock: BigInt(args.snapshotBlock),
|
|
117
|
+
threshold: BigInt(args.threshold),
|
|
118
|
+
token: args.token,
|
|
119
|
+
}, {}, signer, true);
|
|
120
|
+
break;
|
|
158
121
|
}
|
|
159
122
|
default:
|
|
160
123
|
throw new Error(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
161
124
|
}
|
|
125
|
+
await this.storage.register({
|
|
126
|
+
id: policyType,
|
|
127
|
+
contract,
|
|
128
|
+
args: args ? Object.values(args).map((arg) => String(arg)) : [],
|
|
129
|
+
network,
|
|
130
|
+
});
|
|
131
|
+
return contract;
|
|
162
132
|
}
|
|
163
133
|
/**
|
|
164
|
-
* Get the voice credit proxy
|
|
165
|
-
*
|
|
134
|
+
* Get the voice credit proxy contract object
|
|
135
|
+
* always deploy and save it
|
|
166
136
|
*
|
|
137
|
+
* @param signer - the signer
|
|
167
138
|
* @param voiceCreditProxyType - the voice credit proxy type
|
|
168
139
|
* @param network - the network
|
|
169
|
-
* @param args - the
|
|
170
|
-
* @returns - the voice credit proxy
|
|
140
|
+
* @param args - the args
|
|
141
|
+
* @returns - the voice credit proxy contract
|
|
171
142
|
*/
|
|
172
|
-
|
|
173
|
-
let
|
|
174
|
-
let isAlreadyDeployed;
|
|
175
|
-
const address = this.storage.getAddress(voiceCreditProxyType, network);
|
|
143
|
+
async deployAndSaveVoiceCreditProxy(signer, voiceCreditProxyType, network, args) {
|
|
144
|
+
let contract;
|
|
176
145
|
switch (voiceCreditProxyType) {
|
|
177
146
|
case EInitialVoiceCreditProxies.Constant: {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
abi: ConstantInitialVoiceCreditProxyFactory.abi,
|
|
183
|
-
bytecode: ConstantInitialVoiceCreditProxyFactory.bytecode,
|
|
184
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
185
|
-
};
|
|
147
|
+
[contract] = await deployConstantInitialVoiceCreditProxy({
|
|
148
|
+
amount: args.amount,
|
|
149
|
+
}, signer, undefined, true);
|
|
150
|
+
break;
|
|
186
151
|
}
|
|
187
152
|
default:
|
|
188
153
|
throw new Error(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
189
154
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
* @param publicClient - the public client
|
|
196
|
-
* @returns - the address
|
|
197
|
-
*/
|
|
198
|
-
async deployAndGetAddress(kernelClient, abi, bytecode, args, bundlerClient, publicClient) {
|
|
199
|
-
const deployCallData = await kernelClient.account.encodeDeployCallData({
|
|
200
|
-
abi,
|
|
201
|
-
args,
|
|
202
|
-
bytecode,
|
|
203
|
-
});
|
|
204
|
-
const gasPrice = await kernelClient.getUserOperationGasPrice();
|
|
205
|
-
const opEstimate = await kernelClient.prepareUserOperation({
|
|
206
|
-
callData: deployCallData,
|
|
207
|
-
sender: kernelClient.account.address,
|
|
208
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
209
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
210
|
-
});
|
|
211
|
-
const callGasLimitMultiplier = estimateExtraGasLimit(opEstimate.callGasLimit);
|
|
212
|
-
const tx = await kernelClient.sendUserOperation({
|
|
213
|
-
callData: deployCallData,
|
|
214
|
-
sender: kernelClient.account.address,
|
|
215
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
216
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
217
|
-
callGasLimit: opEstimate.callGasLimit + callGasLimitMultiplier < MAX_GAS_LIMIT
|
|
218
|
-
? opEstimate.callGasLimit + callGasLimitMultiplier
|
|
219
|
-
: MAX_GAS_LIMIT,
|
|
220
|
-
});
|
|
221
|
-
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
222
|
-
hash: tx,
|
|
155
|
+
await this.storage.register({
|
|
156
|
+
id: voiceCreditProxyType,
|
|
157
|
+
contract,
|
|
158
|
+
args: args ? Object.values(args).map((arg) => String(arg)) : [],
|
|
159
|
+
network,
|
|
223
160
|
});
|
|
224
|
-
|
|
225
|
-
hash: receipt.receipt.transactionHash,
|
|
226
|
-
});
|
|
227
|
-
return getDeployedContractAddress(txReceipt);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Deploy a contract and store the address
|
|
231
|
-
*
|
|
232
|
-
* @param contract - the contract to deploy
|
|
233
|
-
* @param args - the args
|
|
234
|
-
* @param abi - the abi
|
|
235
|
-
* @param bytecode - the bytecode
|
|
236
|
-
* @param kernelClient - the kernel client
|
|
237
|
-
* @param publicClient - the public client
|
|
238
|
-
* @param chain - the chain
|
|
239
|
-
* @returns - the address of the deployed contract
|
|
240
|
-
*/
|
|
241
|
-
async deployAndStore(contract, args, abi, bytecode, kernelClient, bundlerClient, publicClient, chain) {
|
|
242
|
-
let address = this.storage.getAddress(contract, chain);
|
|
243
|
-
if (!address) {
|
|
244
|
-
address = await this.deployAndGetAddress(kernelClient, abi, bytecode, args, bundlerClient, publicClient);
|
|
245
|
-
if (!address) {
|
|
246
|
-
this.logger.error(`Failed to deploy contract: ${contract}`);
|
|
247
|
-
throw new Error(`${ErrorCodes.FAILED_TO_DEPLOY_CONTRACT} ${contract}`);
|
|
248
|
-
}
|
|
249
|
-
await this.storage.register({
|
|
250
|
-
id: contract,
|
|
251
|
-
contract: new BaseContract(address, abi),
|
|
252
|
-
args: args.map((arg) => {
|
|
253
|
-
if (Array.isArray(arg)) {
|
|
254
|
-
return arg.map((a) => String(a));
|
|
255
|
-
}
|
|
256
|
-
return String(arg);
|
|
257
|
-
}),
|
|
258
|
-
network: chain,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
return address;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Estimate gas, add a bit extra and send the user operation (aka. transaction)
|
|
265
|
-
* @param to - the to address of the user operation
|
|
266
|
-
* @param value - the value of the user operation
|
|
267
|
-
* @param abi - the abi
|
|
268
|
-
* @param functionName - the function name
|
|
269
|
-
* @param args - the args
|
|
270
|
-
* @param errorMessage - the error message
|
|
271
|
-
* @param kernelClient - the kernel client
|
|
272
|
-
* @param bundlerClient - the bundler client
|
|
273
|
-
*/
|
|
274
|
-
async estimateGasAndSend(to, value, abi, functionName, args, errorMessage, kernelClient, bundlerClient) {
|
|
275
|
-
const gasEstimates = await kernelClient.getUserOperationGasPrice();
|
|
276
|
-
const userOperation = {
|
|
277
|
-
sender: kernelClient.account.address,
|
|
278
|
-
maxFeePerGas: gasEstimates.maxFeePerGas,
|
|
279
|
-
maxPriorityFeePerGas: gasEstimates.maxPriorityFeePerGas,
|
|
280
|
-
callData: await kernelClient.account.encodeCalls([
|
|
281
|
-
{
|
|
282
|
-
to,
|
|
283
|
-
value,
|
|
284
|
-
data: encodeFunctionData({
|
|
285
|
-
abi,
|
|
286
|
-
functionName,
|
|
287
|
-
args,
|
|
288
|
-
}),
|
|
289
|
-
},
|
|
290
|
-
]),
|
|
291
|
-
};
|
|
292
|
-
const opEstimate = await kernelClient.prepareUserOperation(userOperation);
|
|
293
|
-
const callGasLimitMultiplier = estimateExtraGasLimit(opEstimate.callGasLimit);
|
|
294
|
-
const userOperationHash = await kernelClient.sendUserOperation({
|
|
295
|
-
...userOperation,
|
|
296
|
-
callGasLimit: opEstimate.callGasLimit + callGasLimitMultiplier < MAX_GAS_LIMIT
|
|
297
|
-
? opEstimate.callGasLimit + callGasLimitMultiplier
|
|
298
|
-
: MAX_GAS_LIMIT,
|
|
299
|
-
});
|
|
300
|
-
const receipt = await bundlerClient.waitForUserOperationReceipt({ hash: userOperationHash });
|
|
301
|
-
if (!receipt.success) {
|
|
302
|
-
throw new Error(errorMessage);
|
|
303
|
-
}
|
|
304
|
-
return receipt;
|
|
161
|
+
return contract;
|
|
305
162
|
}
|
|
306
163
|
/**
|
|
307
164
|
* Get verifying keys arguments (specially zkey paths)
|
|
308
165
|
* @param signer - the signer
|
|
309
|
-
* @param
|
|
310
|
-
* @param
|
|
166
|
+
* @param verifyingKeysRegistryContract - the deployed verifyingKey registry contract
|
|
167
|
+
* @param verifyingKeysRegistryArgs - the arguments send to the endpoint
|
|
311
168
|
* @param mode - use QV or NON_QV
|
|
312
169
|
* @returns SetVerifyingKeysArgs
|
|
313
170
|
*/
|
|
314
|
-
async getVerifyingKeysArgs(signer,
|
|
315
|
-
const pollJoiningZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME
|
|
316
|
-
const pollJoinedZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME
|
|
317
|
-
const
|
|
318
|
-
|
|
319
|
-
const {
|
|
171
|
+
async getVerifyingKeysArgs(signer, verifyingKeysRegistryAddress, verifyingKeysRegistryArgs, mode) {
|
|
172
|
+
const { zkey: pollJoiningZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME);
|
|
173
|
+
const { zkey: pollJoinedZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME);
|
|
174
|
+
const { zkey: messageProcessorZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, mode);
|
|
175
|
+
// There are only QV and Non-QV modes available for tally circuit
|
|
176
|
+
const { zkey: voteTallyZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME,
|
|
177
|
+
// if FULL use NON_QV because there are only VoteTallyQV and VoteTallyNonQV zkeys
|
|
178
|
+
mode === EMode.FULL ? EMode.NON_QV : mode);
|
|
179
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await extractAllVerifyingKeys({
|
|
320
180
|
pollJoiningZkeyPath,
|
|
321
181
|
pollJoinedZkeyPath,
|
|
322
|
-
|
|
323
|
-
|
|
182
|
+
messageProcessorZkeyPath,
|
|
183
|
+
voteTallyZkeyPath,
|
|
324
184
|
});
|
|
325
|
-
const { stateTreeDepth,
|
|
185
|
+
const { stateTreeDepth, pollStateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize } = verifyingKeysRegistryArgs;
|
|
326
186
|
return {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
187
|
+
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
188
|
+
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
189
|
+
processMessagesVerifyingKey: processVerifyingKey,
|
|
190
|
+
tallyVotesVerifyingKey: tallyVerifyingKey,
|
|
331
191
|
stateTreeDepth: Number(stateTreeDepth),
|
|
332
|
-
|
|
192
|
+
tallyProcessingStateTreeDepth: Number(tallyProcessingStateTreeDepth),
|
|
333
193
|
voteOptionTreeDepth: Number(voteOptionTreeDepth),
|
|
334
194
|
messageBatchSize: Number(messageBatchSize),
|
|
195
|
+
pollStateTreeDepth: Number(pollStateTreeDepth),
|
|
335
196
|
signer,
|
|
336
197
|
mode,
|
|
337
|
-
|
|
198
|
+
verifyingKeysRegistryAddress,
|
|
338
199
|
};
|
|
339
200
|
}
|
|
340
201
|
/**
|
|
@@ -346,161 +207,46 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
346
207
|
* @returns the address of the deployed maci contract
|
|
347
208
|
*/
|
|
348
209
|
async deployMaci({ approval, sessionKeyAddress, chain, config }) {
|
|
349
|
-
const
|
|
350
|
-
const
|
|
351
|
-
const
|
|
352
|
-
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
//
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": poseidonT4Address,
|
|
390
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": poseidonT5Address,
|
|
391
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": poseidonT6Address,
|
|
392
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
393
|
-
const messageProcessorFactoryAddress = await this.deployAndStore(EContracts.MessageProcessorFactory, [], MessageProcessorFactoryFactory.abi, MessageProcessorFactoryFactory.linkBytecode({
|
|
394
|
-
"contracts/crypto/PoseidonT3.sol:PoseidonT3": poseidonT3Address,
|
|
395
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": poseidonT4Address,
|
|
396
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": poseidonT5Address,
|
|
397
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": poseidonT6Address,
|
|
398
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
399
|
-
// 4. VkRegistry
|
|
400
|
-
const vkRegistryAddress = await this.deployAndStore(EContracts.VkRegistry, [], VkRegistryFactory.abi, VkRegistryFactory.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
401
|
-
try {
|
|
402
|
-
const processMessagesZkeyPathQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, true);
|
|
403
|
-
const tallyVotesZkeyPathQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, true);
|
|
404
|
-
const processMessagesZkeyPathNonQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, false);
|
|
405
|
-
const tallyVotesZkeyPathNonQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, false);
|
|
406
|
-
const pollJoiningZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME, true);
|
|
407
|
-
const pollJoinedZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME, true);
|
|
408
|
-
const [qvProcessVk, qvTallyVk, nonQvProcessVk, nonQvTallyVk, pollJoiningVk, pollJoinedVk] = await Promise.all([
|
|
409
|
-
extractVk(processMessagesZkeyPathQv.zkey),
|
|
410
|
-
extractVk(tallyVotesZkeyPathQv.zkey),
|
|
411
|
-
extractVk(processMessagesZkeyPathNonQv.zkey),
|
|
412
|
-
extractVk(tallyVotesZkeyPathNonQv.zkey),
|
|
413
|
-
extractVk(pollJoiningZkeyPath.zkey),
|
|
414
|
-
extractVk(pollJoinedZkeyPath.zkey),
|
|
415
|
-
]).then((vks) => vks.map((vk) => vk && VerifyingKey.fromObj(vk).asContractParam()));
|
|
416
|
-
const processZkeys = [qvProcessVk, nonQvProcessVk].filter(Boolean);
|
|
417
|
-
const tallyZkeys = [qvTallyVk, nonQvTallyVk].filter(Boolean);
|
|
418
|
-
// check if the keys are already set
|
|
419
|
-
const [isProcessVkSet, isProcessNonQvVkSet, isTallyVkSet, isTallyNonQvVkSet] = await Promise.all([
|
|
420
|
-
publicClient.readContract({
|
|
421
|
-
address: vkRegistryAddress,
|
|
422
|
-
abi: VkRegistryFactory.abi,
|
|
423
|
-
functionName: "hasProcessVk",
|
|
424
|
-
args: [
|
|
425
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
426
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
427
|
-
config.VkRegistry.args.messageBatchSize,
|
|
428
|
-
EMode.QV,
|
|
429
|
-
],
|
|
430
|
-
}),
|
|
431
|
-
publicClient.readContract({
|
|
432
|
-
address: vkRegistryAddress,
|
|
433
|
-
abi: VkRegistryFactory.abi,
|
|
434
|
-
functionName: "hasProcessVk",
|
|
435
|
-
args: [
|
|
436
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
437
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
438
|
-
config.VkRegistry.args.messageBatchSize,
|
|
439
|
-
EMode.NON_QV,
|
|
440
|
-
],
|
|
441
|
-
}),
|
|
442
|
-
publicClient.readContract({
|
|
443
|
-
address: vkRegistryAddress,
|
|
444
|
-
abi: VkRegistryFactory.abi,
|
|
445
|
-
functionName: "hasTallyVk",
|
|
446
|
-
args: [
|
|
447
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
448
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
449
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
450
|
-
EMode.QV,
|
|
451
|
-
],
|
|
452
|
-
}),
|
|
453
|
-
publicClient.readContract({
|
|
454
|
-
address: vkRegistryAddress,
|
|
455
|
-
abi: VkRegistryFactory.abi,
|
|
456
|
-
functionName: "hasTallyVk",
|
|
457
|
-
args: [
|
|
458
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
459
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
460
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
461
|
-
EMode.NON_QV,
|
|
462
|
-
],
|
|
463
|
-
}),
|
|
464
|
-
]);
|
|
465
|
-
if (isProcessVkSet && isProcessNonQvVkSet && isTallyVkSet && isTallyNonQvVkSet) {
|
|
466
|
-
this.logger.debug("Verifying keys are already set on the vk registry");
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
await this.estimateGasAndSend(vkRegistryAddress, 0n, VkRegistryFactory.abi, "setVerifyingKeysBatch", [
|
|
470
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
471
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
472
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
473
|
-
config.VkRegistry.args.messageBatchSize,
|
|
474
|
-
[EMode.QV, EMode.NON_QV],
|
|
475
|
-
pollJoiningVk,
|
|
476
|
-
pollJoinedVk,
|
|
477
|
-
processZkeys,
|
|
478
|
-
tallyZkeys,
|
|
479
|
-
], ErrorCodes.FAILED_TO_SET_VERIFYING_KEYS_ON_VK_REGISTRY.toString(), kernelClient, bundlerClient);
|
|
480
|
-
}
|
|
481
|
-
}
|
|
482
|
-
catch (error) {
|
|
483
|
-
this.logger.error("Failed to set verifying keys on vk registry: ", error);
|
|
484
|
-
throw error;
|
|
485
|
-
}
|
|
486
|
-
// 5. maci (here we don't check whether one is already deployed, we just deploy it)
|
|
487
|
-
const emptyBallotRoots = genEmptyBallotRoots(config.MACI.stateTreeDepth);
|
|
488
|
-
const maciAddress = await this.deployAndStore(EContracts.MACI, [
|
|
489
|
-
pollFactoryAddress,
|
|
490
|
-
messageProcessorFactoryAddress,
|
|
491
|
-
tallyFactoryAddress,
|
|
492
|
-
policyAddress,
|
|
493
|
-
config.MACI.stateTreeDepth,
|
|
494
|
-
emptyBallotRoots,
|
|
495
|
-
], MACIFactory.abi, MACIFactory.linkBytecode({
|
|
496
|
-
"contracts/crypto/PoseidonT3.sol:PoseidonT3": "0x07490eba00dc4ACA6721D052Fa4C5002Aa077233",
|
|
497
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": "0xbb0e724CE02e5E7eDd31e632dc6e59F229a1126d",
|
|
498
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": "0xE0398F7DFAC494c530F6404AfEaC8669ABeD2679",
|
|
499
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": "0xfD77833F10a29c76A6a0ede235Eb651D744d0E2F",
|
|
500
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
501
|
-
// set the gate on the policy
|
|
502
|
-
await this.estimateGasAndSend(policyAddress, 0n, policyData.abi, "setTarget", [maciAddress], ErrorCodes.FAILED_TO_SET_MACI_INSTANCE_ON_POLICY.toString(), kernelClient, bundlerClient);
|
|
503
|
-
return { address: maciAddress };
|
|
210
|
+
const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
|
|
211
|
+
const policyContract = await this.deployAndSavePolicy(signer, config.policy.type, chain, config.policy.args);
|
|
212
|
+
const policyAddress = await policyContract.getAddress();
|
|
213
|
+
const verifierContract = await deployVerifier(signer, true);
|
|
214
|
+
const verifyingKeysRegistryAddress = await deployVerifyingKeysRegistryContract({ signer });
|
|
215
|
+
const verifyingKeysArgs = await this.getVerifyingKeysArgs(signer, verifyingKeysRegistryAddress, config.VerifyingKeysRegistry.args, config.MACI.mode);
|
|
216
|
+
await setVerifyingKeys(verifyingKeysArgs);
|
|
217
|
+
// deploy the smart contracts
|
|
218
|
+
const maciAddresses = await deployMaci({
|
|
219
|
+
stateTreeDepth: config.MACI.stateTreeDepth,
|
|
220
|
+
signer,
|
|
221
|
+
signupPolicyAddress: policyAddress,
|
|
222
|
+
});
|
|
223
|
+
// store the contracts
|
|
224
|
+
await Promise.all([
|
|
225
|
+
this.storage.register({
|
|
226
|
+
id: EContracts.Verifier,
|
|
227
|
+
contract: verifierContract,
|
|
228
|
+
network: chain,
|
|
229
|
+
}),
|
|
230
|
+
this.storage.register({
|
|
231
|
+
id: EContracts.VerifyingKeysRegistry,
|
|
232
|
+
contract: new BaseContract(verifyingKeysRegistryAddress, VerifyingKeysRegistryFactory.abi),
|
|
233
|
+
network: chain,
|
|
234
|
+
}),
|
|
235
|
+
this.storage.register({
|
|
236
|
+
id: EContracts.MACI,
|
|
237
|
+
contract: new BaseContract(maciAddresses.maciContractAddress, MACIFactory.abi),
|
|
238
|
+
args: [
|
|
239
|
+
maciAddresses.pollFactoryContractAddress,
|
|
240
|
+
maciAddresses.messageProcessorFactoryContractAddress,
|
|
241
|
+
maciAddresses.tallyFactoryContractAddress,
|
|
242
|
+
policyAddress,
|
|
243
|
+
config.MACI.stateTreeDepth,
|
|
244
|
+
generateEmptyBallotRoots(config.MACI.stateTreeDepth).map((root) => root.toString()),
|
|
245
|
+
],
|
|
246
|
+
network: chain,
|
|
247
|
+
}),
|
|
248
|
+
]);
|
|
249
|
+
return { address: maciAddresses.maciContractAddress };
|
|
504
250
|
}
|
|
505
251
|
/**
|
|
506
252
|
* Deploy a poll
|
|
@@ -509,10 +255,7 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
509
255
|
* @returns poll id
|
|
510
256
|
*/
|
|
511
257
|
async deployPoll({ approval, sessionKeyAddress, chain, config }) {
|
|
512
|
-
const
|
|
513
|
-
const bundlerClient = getBundlerClient(chain);
|
|
514
|
-
const kernelClient = await this.sessionKeysService.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
515
|
-
const signer = await this.sessionKeysService.getKernelClientSigner(kernelClient);
|
|
258
|
+
const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
|
|
516
259
|
// check if there is a maci contract deployed on this chain
|
|
517
260
|
const maciAddress = this.storage.getAddress(EContracts.MACI, chain);
|
|
518
261
|
if (!maciAddress) {
|
|
@@ -523,43 +266,37 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
523
266
|
if (!verifierAddress) {
|
|
524
267
|
throw new Error(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
525
268
|
}
|
|
526
|
-
// check if there is a
|
|
527
|
-
const
|
|
528
|
-
if (!
|
|
529
|
-
throw new Error(ErrorCodes.
|
|
269
|
+
// check if there is a verifyingKey registry deployed on this chain
|
|
270
|
+
const verifyingKeysRegistryAddress = this.storage.getAddress(EContracts.VerifyingKeysRegistry, chain);
|
|
271
|
+
if (!verifyingKeysRegistryAddress) {
|
|
272
|
+
throw new Error(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
530
273
|
}
|
|
531
274
|
// check if policy address was given
|
|
532
275
|
let policyAddress = config.policy.address;
|
|
533
276
|
if (!policyAddress) {
|
|
534
|
-
const
|
|
535
|
-
policyAddress =
|
|
536
|
-
// if the policy is not already deployed, we need to deploy it
|
|
537
|
-
if (!policyData.alreadyDeployed) {
|
|
538
|
-
policyAddress = await this.deployAndStore(config.policy.type, config.policy.args ? Object.values(config.policy.args) : [], policyData.abi, policyData.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
539
|
-
}
|
|
277
|
+
const policyContract = await this.deployAndSavePolicy(signer, config.policy.type, chain, config.policy.args);
|
|
278
|
+
policyAddress = (await policyContract.getAddress());
|
|
540
279
|
}
|
|
541
280
|
// check if initial voice credit proxy address was given
|
|
542
281
|
let initialVoiceCreditProxyAddress = config.initialVoiceCreditsProxy.address;
|
|
543
282
|
if (!initialVoiceCreditProxyAddress) {
|
|
544
|
-
const
|
|
545
|
-
initialVoiceCreditProxyAddress =
|
|
546
|
-
// if the voice credit proxy is not already deployed, we need to deploy it
|
|
547
|
-
if (!voiceCreditProxyData.alreadyDeployed) {
|
|
548
|
-
initialVoiceCreditProxyAddress = await this.deployAndStore(config.initialVoiceCreditsProxy.type, Object.values(config.initialVoiceCreditsProxy.args), voiceCreditProxyData.abi, voiceCreditProxyData.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
549
|
-
}
|
|
283
|
+
const initialVoiceCreditProxyContract = await this.deployAndSaveVoiceCreditProxy(signer, config.initialVoiceCreditsProxy.type, chain, config.initialVoiceCreditsProxy.args);
|
|
284
|
+
initialVoiceCreditProxyAddress = (await initialVoiceCreditProxyContract.getAddress());
|
|
550
285
|
}
|
|
551
|
-
|
|
286
|
+
// instantiate the coordinator MACI keypair
|
|
287
|
+
const coordinatorKeypair = getCoordinatorKeypair();
|
|
552
288
|
const deployPollArgs = {
|
|
553
289
|
maciAddress,
|
|
554
290
|
pollStartTimestamp: config.startDate,
|
|
555
291
|
pollEndTimestamp: config.endDate,
|
|
556
|
-
|
|
292
|
+
tallyProcessingStateTreeDepth: config.tallyProcessingStateTreeDepth,
|
|
557
293
|
voteOptionTreeDepth: config.voteOptionTreeDepth,
|
|
558
294
|
messageBatchSize: config.messageBatchSize,
|
|
559
|
-
|
|
295
|
+
stateTreeDepth: config.pollStateTreeDepth,
|
|
296
|
+
coordinatorPublicKey: coordinatorKeypair.publicKey,
|
|
560
297
|
verifierContractAddress: verifierAddress,
|
|
561
|
-
|
|
562
|
-
mode,
|
|
298
|
+
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
299
|
+
mode: config.mode,
|
|
563
300
|
policyContractAddress: policyAddress,
|
|
564
301
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
565
302
|
relayers: config.relayers ? config.relayers.map((address) => address) : [],
|
|
@@ -569,43 +306,37 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
569
306
|
};
|
|
570
307
|
const { pollContractAddress, messageProcessorContractAddress, tallyContractAddress, pollId } = await deployPoll(deployPollArgs);
|
|
571
308
|
const poll = PollFactory.connect(pollContractAddress, signer);
|
|
572
|
-
// read the emptyBallotRoot and extContracts
|
|
573
|
-
const emptyBallotRoot = await poll.emptyBallotRoot();
|
|
574
|
-
const extContracts = await poll.extContracts();
|
|
575
309
|
// store to storage
|
|
576
310
|
await Promise.all([
|
|
577
311
|
this.storage.register({
|
|
578
312
|
id: EContracts.Poll,
|
|
579
313
|
key: `poll-${pollId}`,
|
|
580
314
|
contract: poll,
|
|
581
|
-
args
|
|
582
|
-
|
|
583
|
-
...deployPollArgs,
|
|
584
|
-
extContracts,
|
|
585
|
-
emptyBallotRoot: emptyBallotRoot.toString(),
|
|
586
|
-
},
|
|
587
|
-
],
|
|
315
|
+
// clones do not have args for verification
|
|
316
|
+
args: [],
|
|
588
317
|
network: chain,
|
|
589
318
|
}),
|
|
590
319
|
this.storage.register({
|
|
591
320
|
id: EContracts.MessageProcessor,
|
|
592
321
|
key: `poll-${pollId}`,
|
|
593
|
-
contract:
|
|
594
|
-
|
|
322
|
+
contract: MessageProcessorFactory.connect(messageProcessorContractAddress, signer),
|
|
323
|
+
// clones do not have args for verification
|
|
324
|
+
args: [],
|
|
595
325
|
network: chain,
|
|
596
326
|
}),
|
|
597
327
|
this.storage.register({
|
|
598
328
|
id: EContracts.Tally,
|
|
599
329
|
key: `poll-${pollId}`,
|
|
600
|
-
contract:
|
|
601
|
-
|
|
330
|
+
contract: TallyFactory.connect(tallyContractAddress, signer),
|
|
331
|
+
// clones do not have args for verification
|
|
332
|
+
args: [],
|
|
602
333
|
network: chain,
|
|
603
334
|
}),
|
|
604
335
|
]);
|
|
605
336
|
return { pollId: pollId.toString() };
|
|
606
337
|
}
|
|
607
338
|
};
|
|
608
|
-
DeployerService =
|
|
339
|
+
DeployerService = __decorate([
|
|
609
340
|
Injectable(),
|
|
610
341
|
__metadata("design:paramtypes", [SessionKeysService,
|
|
611
342
|
FileService])
|