@maci-protocol/coordinator 0.0.0-ci.a34075e → 0.0.0-ci.a51dc13
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 +13 -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 +17 -14
- package/build/tests/e2e.aa.test.js.map +1 -1
- package/build/tests/e2e.deploy.test.js +121 -73
- 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 +2 -6
- 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 +14 -43
- 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 +35 -0
- package/build/ts/common/chain.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 +30 -1
- package/build/ts/deployer/__tests__/utils.d.ts.map +1 -1
- package/build/ts/deployer/__tests__/utils.js +46 -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 +172 -459
- 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 +62 -24
- package/build/ts/deployer/types.d.ts.map +1 -1
- package/build/ts/file/__tests__/file.service.test.js +7 -6
- package/build/ts/file/__tests__/file.service.test.js.map +1 -1
- package/build/ts/file/file.service.d.ts +3 -2
- package/build/ts/file/file.service.d.ts.map +1 -1
- package/build/ts/file/file.service.js +9 -4
- package/build/ts/file/file.service.js.map +1 -1
- package/build/ts/proof/__tests__/proof.controller.test.js +5 -2
- package/build/ts/proof/__tests__/proof.controller.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.gateway.test.js +6 -2
- package/build/ts/proof/__tests__/proof.gateway.test.js.map +1 -1
- package/build/ts/proof/__tests__/proof.service.test.js +12 -10
- package/build/ts/proof/__tests__/proof.service.test.js.map +1 -1
- package/build/ts/proof/dto.d.ts +13 -11
- package/build/ts/proof/dto.d.ts.map +1 -1
- package/build/ts/proof/dto.js +51 -29
- 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.map +1 -1
- package/build/ts/proof/proof.service.d.ts +3 -3
- package/build/ts/proof/proof.service.d.ts.map +1 -1
- package/build/ts/proof/proof.service.js +40 -120
- package/build/ts/proof/proof.service.js.map +1 -1
- package/build/ts/proof/types.d.ts +18 -10
- 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 +28 -27
- 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
|
|
10
|
+
import { deployVerifier } from "@maci-protocol/contracts";
|
|
11
|
+
import { PublicKey } from "@maci-protocol/domainobjs";
|
|
12
|
+
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";
|
|
13
|
+
import { Injectable } from "@nestjs/common";
|
|
14
14
|
import { BaseContract } from "ethers";
|
|
15
|
-
import { encodeFunctionData } from "viem";
|
|
16
15
|
import path from "path";
|
|
17
16
|
import { ErrorCodes } from "../common";
|
|
18
|
-
import { getBundlerClient, getDeployedContractAddress, getPublicClient } from "../common/accountAbstraction";
|
|
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,313 +34,166 @@ 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
|
-
storedArgs[0] === args.decoderAddress &&
|
|
136
|
-
storedArgs[1] === args.passingScore;
|
|
137
|
-
return {
|
|
138
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
139
|
-
abi: GitcoinPassportPolicyFactory.abi,
|
|
140
|
-
bytecode: GitcoinPassportPolicyFactory.bytecode,
|
|
141
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
142
|
-
};
|
|
95
|
+
case EPolicies.MerkleProof: {
|
|
96
|
+
[contract] = await deployMerkleProofPolicy({
|
|
97
|
+
root: args.root,
|
|
98
|
+
}, {}, signer, true);
|
|
99
|
+
break;
|
|
143
100
|
}
|
|
144
|
-
case EPolicies.
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
157
|
-
};
|
|
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;
|
|
158
113
|
}
|
|
159
|
-
case EPolicies.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return {
|
|
167
|
-
address: isAlreadyDeployed ? address : undefined,
|
|
168
|
-
abi: ERC20PolicyFactory.abi,
|
|
169
|
-
bytecode: ERC20PolicyFactory.bytecode,
|
|
170
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
171
|
-
};
|
|
114
|
+
case EPolicies.ERC20Votes: {
|
|
115
|
+
[contract] = await deployERC20VotesPolicy({
|
|
116
|
+
snapshotBlock: BigInt(args.snapshotBlock),
|
|
117
|
+
threshold: BigInt(args.threshold),
|
|
118
|
+
token: args.token,
|
|
119
|
+
}, {}, signer, true);
|
|
120
|
+
break;
|
|
172
121
|
}
|
|
173
122
|
default:
|
|
174
123
|
throw new Error(ErrorCodes.UNSUPPORTED_POLICY.toString());
|
|
175
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;
|
|
176
132
|
}
|
|
177
133
|
/**
|
|
178
|
-
* Get the voice credit proxy
|
|
179
|
-
*
|
|
134
|
+
* Get the voice credit proxy contract object
|
|
135
|
+
* always deploy and save it
|
|
180
136
|
*
|
|
137
|
+
* @param signer - the signer
|
|
181
138
|
* @param voiceCreditProxyType - the voice credit proxy type
|
|
182
139
|
* @param network - the network
|
|
183
|
-
* @param args - the
|
|
184
|
-
* @returns - the voice credit proxy
|
|
140
|
+
* @param args - the args
|
|
141
|
+
* @returns - the voice credit proxy contract
|
|
185
142
|
*/
|
|
186
|
-
|
|
187
|
-
let
|
|
188
|
-
let isAlreadyDeployed;
|
|
189
|
-
const address = this.storage.getAddress(voiceCreditProxyType, network);
|
|
143
|
+
async deployAndSaveVoiceCreditProxy(signer, voiceCreditProxyType, network, args) {
|
|
144
|
+
let contract;
|
|
190
145
|
switch (voiceCreditProxyType) {
|
|
191
146
|
case EInitialVoiceCreditProxies.Constant: {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
abi: ConstantInitialVoiceCreditProxyFactory.abi,
|
|
197
|
-
bytecode: ConstantInitialVoiceCreditProxyFactory.bytecode,
|
|
198
|
-
alreadyDeployed: isAlreadyDeployed,
|
|
199
|
-
};
|
|
147
|
+
[contract] = await deployConstantInitialVoiceCreditProxy({
|
|
148
|
+
amount: args.amount,
|
|
149
|
+
}, signer, undefined, true);
|
|
150
|
+
break;
|
|
200
151
|
}
|
|
201
152
|
default:
|
|
202
153
|
throw new Error(ErrorCodes.UNSUPPORTED_VOICE_CREDIT_PROXY.toString());
|
|
203
154
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
* @param publicClient - the public client
|
|
210
|
-
* @returns - the address
|
|
211
|
-
*/
|
|
212
|
-
async deployAndGetAddress(kernelClient, abi, bytecode, args, bundlerClient, publicClient) {
|
|
213
|
-
const deployCallData = await kernelClient.account.encodeDeployCallData({
|
|
214
|
-
abi,
|
|
215
|
-
args,
|
|
216
|
-
bytecode,
|
|
217
|
-
});
|
|
218
|
-
const gasPrice = await kernelClient.getUserOperationGasPrice();
|
|
219
|
-
const opEstimate = await kernelClient.prepareUserOperation({
|
|
220
|
-
callData: deployCallData,
|
|
221
|
-
sender: kernelClient.account.address,
|
|
222
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
223
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
224
|
-
});
|
|
225
|
-
const callGasLimitMultiplier = estimateExtraGasLimit(opEstimate.callGasLimit);
|
|
226
|
-
const tx = await kernelClient.sendUserOperation({
|
|
227
|
-
callData: deployCallData,
|
|
228
|
-
sender: kernelClient.account.address,
|
|
229
|
-
maxFeePerGas: gasPrice.maxFeePerGas,
|
|
230
|
-
maxPriorityFeePerGas: gasPrice.maxPriorityFeePerGas,
|
|
231
|
-
callGasLimit: opEstimate.callGasLimit + callGasLimitMultiplier < MAX_GAS_LIMIT
|
|
232
|
-
? opEstimate.callGasLimit + callGasLimitMultiplier
|
|
233
|
-
: MAX_GAS_LIMIT,
|
|
234
|
-
});
|
|
235
|
-
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
236
|
-
hash: tx,
|
|
237
|
-
});
|
|
238
|
-
const txReceipt = await publicClient.getTransactionReceipt({
|
|
239
|
-
hash: receipt.receipt.transactionHash,
|
|
240
|
-
});
|
|
241
|
-
return getDeployedContractAddress(txReceipt);
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Deploy a contract and store the address
|
|
245
|
-
*
|
|
246
|
-
* @param contract - the contract to deploy
|
|
247
|
-
* @param args - the args
|
|
248
|
-
* @param abi - the abi
|
|
249
|
-
* @param bytecode - the bytecode
|
|
250
|
-
* @param kernelClient - the kernel client
|
|
251
|
-
* @param publicClient - the public client
|
|
252
|
-
* @param chain - the chain
|
|
253
|
-
* @returns - the address of the deployed contract
|
|
254
|
-
*/
|
|
255
|
-
async deployAndStore(contract, args, abi, bytecode, kernelClient, bundlerClient, publicClient, chain) {
|
|
256
|
-
let address = this.storage.getAddress(contract, chain);
|
|
257
|
-
if (!address) {
|
|
258
|
-
address = await this.deployAndGetAddress(kernelClient, abi, bytecode, args, bundlerClient, publicClient);
|
|
259
|
-
if (!address) {
|
|
260
|
-
this.logger.error(`Failed to deploy contract: ${contract}`);
|
|
261
|
-
throw new Error(`${ErrorCodes.FAILED_TO_DEPLOY_CONTRACT} ${contract}`);
|
|
262
|
-
}
|
|
263
|
-
await this.storage.register({
|
|
264
|
-
id: contract,
|
|
265
|
-
contract: new BaseContract(address, abi),
|
|
266
|
-
args: args.map((arg) => {
|
|
267
|
-
if (Array.isArray(arg)) {
|
|
268
|
-
return arg.map((a) => String(a));
|
|
269
|
-
}
|
|
270
|
-
return String(arg);
|
|
271
|
-
}),
|
|
272
|
-
network: chain,
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return address;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Estimate gas, add a bit extra and send the user operation (aka. transaction)
|
|
279
|
-
* @param to - the to address of the user operation
|
|
280
|
-
* @param value - the value of the user operation
|
|
281
|
-
* @param abi - the abi
|
|
282
|
-
* @param functionName - the function name
|
|
283
|
-
* @param args - the args
|
|
284
|
-
* @param errorMessage - the error message
|
|
285
|
-
* @param kernelClient - the kernel client
|
|
286
|
-
* @param bundlerClient - the bundler client
|
|
287
|
-
*/
|
|
288
|
-
async estimateGasAndSend(to, value, abi, functionName, args, errorMessage, kernelClient, bundlerClient) {
|
|
289
|
-
const gasEstimates = await kernelClient.getUserOperationGasPrice();
|
|
290
|
-
const userOperation = {
|
|
291
|
-
sender: kernelClient.account.address,
|
|
292
|
-
maxFeePerGas: gasEstimates.maxFeePerGas,
|
|
293
|
-
maxPriorityFeePerGas: gasEstimates.maxPriorityFeePerGas,
|
|
294
|
-
callData: await kernelClient.account.encodeCalls([
|
|
295
|
-
{
|
|
296
|
-
to,
|
|
297
|
-
value,
|
|
298
|
-
data: encodeFunctionData({
|
|
299
|
-
abi,
|
|
300
|
-
functionName,
|
|
301
|
-
args,
|
|
302
|
-
}),
|
|
303
|
-
},
|
|
304
|
-
]),
|
|
305
|
-
};
|
|
306
|
-
const opEstimate = await kernelClient.prepareUserOperation(userOperation);
|
|
307
|
-
const callGasLimitMultiplier = estimateExtraGasLimit(opEstimate.callGasLimit);
|
|
308
|
-
const userOperationHash = await kernelClient.sendUserOperation({
|
|
309
|
-
...userOperation,
|
|
310
|
-
callGasLimit: opEstimate.callGasLimit + callGasLimitMultiplier < MAX_GAS_LIMIT
|
|
311
|
-
? opEstimate.callGasLimit + callGasLimitMultiplier
|
|
312
|
-
: MAX_GAS_LIMIT,
|
|
155
|
+
await this.storage.register({
|
|
156
|
+
id: voiceCreditProxyType,
|
|
157
|
+
contract,
|
|
158
|
+
args: args ? Object.values(args).map((arg) => String(arg)) : [],
|
|
159
|
+
network,
|
|
313
160
|
});
|
|
314
|
-
|
|
315
|
-
if (!receipt.success) {
|
|
316
|
-
throw new Error(errorMessage);
|
|
317
|
-
}
|
|
318
|
-
return receipt;
|
|
161
|
+
return contract;
|
|
319
162
|
}
|
|
320
163
|
/**
|
|
321
164
|
* Get verifying keys arguments (specially zkey paths)
|
|
322
165
|
* @param signer - the signer
|
|
323
|
-
* @param
|
|
324
|
-
* @param
|
|
166
|
+
* @param verifyingKeysRegistryContract - the deployed verifyingKey registry contract
|
|
167
|
+
* @param verifyingKeysRegistryArgs - the arguments send to the endpoint
|
|
325
168
|
* @param mode - use QV or NON_QV
|
|
326
169
|
* @returns SetVerifyingKeysArgs
|
|
327
170
|
*/
|
|
328
|
-
async getVerifyingKeysArgs(signer,
|
|
329
|
-
const pollJoiningZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME,
|
|
330
|
-
const pollJoinedZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME,
|
|
331
|
-
const processMessagesZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, mode
|
|
332
|
-
|
|
333
|
-
const {
|
|
171
|
+
async getVerifyingKeysArgs(signer, verifyingKeysRegistryAddress, verifyingKeysRegistryArgs, mode) {
|
|
172
|
+
const { zkey: pollJoiningZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME, EMode.QV);
|
|
173
|
+
const { zkey: pollJoinedZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME, EMode.QV);
|
|
174
|
+
const { zkey: processMessagesZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, mode);
|
|
175
|
+
// There are only QV and Non-QV modes
|
|
176
|
+
const { zkey: tallyVotesZkeyPath } = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, mode === EMode.QV ? mode : EMode.NON_QV);
|
|
177
|
+
const { pollJoiningVerifyingKey, pollJoinedVerifyingKey, processVerifyingKey, tallyVerifyingKey } = await extractAllVerifyingKeys({
|
|
334
178
|
pollJoiningZkeyPath,
|
|
335
179
|
pollJoinedZkeyPath,
|
|
336
180
|
processMessagesZkeyPath,
|
|
337
181
|
tallyVotesZkeyPath,
|
|
338
182
|
});
|
|
339
|
-
const { stateTreeDepth,
|
|
183
|
+
const { stateTreeDepth, pollStateTreeDepth, tallyProcessingStateTreeDepth, voteOptionTreeDepth, messageBatchSize } = verifyingKeysRegistryArgs;
|
|
340
184
|
return {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
185
|
+
pollJoiningVerifyingKey: pollJoiningVerifyingKey,
|
|
186
|
+
pollJoinedVerifyingKey: pollJoinedVerifyingKey,
|
|
187
|
+
processMessagesVerifyingKey: processVerifyingKey,
|
|
188
|
+
tallyVotesVerifyingKey: tallyVerifyingKey,
|
|
345
189
|
stateTreeDepth: Number(stateTreeDepth),
|
|
346
|
-
|
|
190
|
+
tallyProcessingStateTreeDepth: Number(tallyProcessingStateTreeDepth),
|
|
347
191
|
voteOptionTreeDepth: Number(voteOptionTreeDepth),
|
|
348
192
|
messageBatchSize: Number(messageBatchSize),
|
|
193
|
+
pollStateTreeDepth: Number(pollStateTreeDepth),
|
|
349
194
|
signer,
|
|
350
195
|
mode,
|
|
351
|
-
|
|
196
|
+
verifyingKeysRegistryAddress,
|
|
352
197
|
};
|
|
353
198
|
}
|
|
354
199
|
/**
|
|
@@ -360,161 +205,46 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
360
205
|
* @returns the address of the deployed maci contract
|
|
361
206
|
*/
|
|
362
207
|
async deployMaci({ approval, sessionKeyAddress, chain, config }) {
|
|
363
|
-
const
|
|
364
|
-
const
|
|
365
|
-
const
|
|
366
|
-
|
|
367
|
-
const
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
//
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": poseidonT4Address,
|
|
404
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": poseidonT5Address,
|
|
405
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": poseidonT6Address,
|
|
406
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
407
|
-
const messageProcessorFactoryAddress = await this.deployAndStore(EContracts.MessageProcessorFactory, [], MessageProcessorFactoryFactory.abi, MessageProcessorFactoryFactory.linkBytecode({
|
|
408
|
-
"contracts/crypto/PoseidonT3.sol:PoseidonT3": poseidonT3Address,
|
|
409
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": poseidonT4Address,
|
|
410
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": poseidonT5Address,
|
|
411
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": poseidonT6Address,
|
|
412
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
413
|
-
// 4. VkRegistry
|
|
414
|
-
const vkRegistryAddress = await this.deployAndStore(EContracts.VkRegistry, [], VkRegistryFactory.abi, VkRegistryFactory.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
415
|
-
try {
|
|
416
|
-
const processMessagesZkeyPathQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, true);
|
|
417
|
-
const tallyVotesZkeyPathQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, true);
|
|
418
|
-
const processMessagesZkeyPathNonQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_MESSAGE_PROCESS_ZKEY_NAME, false);
|
|
419
|
-
const tallyVotesZkeyPathNonQv = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_TALLY_ZKEY_NAME, false);
|
|
420
|
-
const pollJoiningZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINING_ZKEY_NAME, true);
|
|
421
|
-
const pollJoinedZkeyPath = this.fileService.getZkeyFilePaths(process.env.COORDINATOR_POLL_JOINED_ZKEY_NAME, true);
|
|
422
|
-
const [qvProcessVk, qvTallyVk, nonQvProcessVk, nonQvTallyVk, pollJoiningVk, pollJoinedVk] = await Promise.all([
|
|
423
|
-
extractVk(processMessagesZkeyPathQv.zkey),
|
|
424
|
-
extractVk(tallyVotesZkeyPathQv.zkey),
|
|
425
|
-
extractVk(processMessagesZkeyPathNonQv.zkey),
|
|
426
|
-
extractVk(tallyVotesZkeyPathNonQv.zkey),
|
|
427
|
-
extractVk(pollJoiningZkeyPath.zkey),
|
|
428
|
-
extractVk(pollJoinedZkeyPath.zkey),
|
|
429
|
-
]).then((vks) => vks.map((vk) => vk && VerifyingKey.fromObj(vk).asContractParam()));
|
|
430
|
-
const processZkeys = [qvProcessVk, nonQvProcessVk].filter(Boolean);
|
|
431
|
-
const tallyZkeys = [qvTallyVk, nonQvTallyVk].filter(Boolean);
|
|
432
|
-
// check if the keys are already set
|
|
433
|
-
const [isProcessVkSet, isProcessNonQvVkSet, isTallyVkSet, isTallyNonQvVkSet] = await Promise.all([
|
|
434
|
-
publicClient.readContract({
|
|
435
|
-
address: vkRegistryAddress,
|
|
436
|
-
abi: VkRegistryFactory.abi,
|
|
437
|
-
functionName: "hasProcessVk",
|
|
438
|
-
args: [
|
|
439
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
440
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
441
|
-
config.VkRegistry.args.messageBatchSize,
|
|
442
|
-
EMode.QV,
|
|
443
|
-
],
|
|
444
|
-
}),
|
|
445
|
-
publicClient.readContract({
|
|
446
|
-
address: vkRegistryAddress,
|
|
447
|
-
abi: VkRegistryFactory.abi,
|
|
448
|
-
functionName: "hasProcessVk",
|
|
449
|
-
args: [
|
|
450
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
451
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
452
|
-
config.VkRegistry.args.messageBatchSize,
|
|
453
|
-
EMode.NON_QV,
|
|
454
|
-
],
|
|
455
|
-
}),
|
|
456
|
-
publicClient.readContract({
|
|
457
|
-
address: vkRegistryAddress,
|
|
458
|
-
abi: VkRegistryFactory.abi,
|
|
459
|
-
functionName: "hasTallyVk",
|
|
460
|
-
args: [
|
|
461
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
462
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
463
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
464
|
-
EMode.QV,
|
|
465
|
-
],
|
|
466
|
-
}),
|
|
467
|
-
publicClient.readContract({
|
|
468
|
-
address: vkRegistryAddress,
|
|
469
|
-
abi: VkRegistryFactory.abi,
|
|
470
|
-
functionName: "hasTallyVk",
|
|
471
|
-
args: [
|
|
472
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
473
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
474
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
475
|
-
EMode.NON_QV,
|
|
476
|
-
],
|
|
477
|
-
}),
|
|
478
|
-
]);
|
|
479
|
-
if (isProcessVkSet && isProcessNonQvVkSet && isTallyVkSet && isTallyNonQvVkSet) {
|
|
480
|
-
this.logger.debug("Verifying keys are already set on the vk registry");
|
|
481
|
-
}
|
|
482
|
-
else {
|
|
483
|
-
await this.estimateGasAndSend(vkRegistryAddress, 0n, VkRegistryFactory.abi, "setVerifyingKeysBatch", [
|
|
484
|
-
config.VkRegistry.args.stateTreeDepth,
|
|
485
|
-
config.VkRegistry.args.intStateTreeDepth,
|
|
486
|
-
config.VkRegistry.args.voteOptionTreeDepth,
|
|
487
|
-
config.VkRegistry.args.messageBatchSize,
|
|
488
|
-
[EMode.QV, EMode.NON_QV],
|
|
489
|
-
pollJoiningVk,
|
|
490
|
-
pollJoinedVk,
|
|
491
|
-
processZkeys,
|
|
492
|
-
tallyZkeys,
|
|
493
|
-
], ErrorCodes.FAILED_TO_SET_VERIFYING_KEYS_ON_VK_REGISTRY.toString(), kernelClient, bundlerClient);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
catch (error) {
|
|
497
|
-
this.logger.error("Failed to set verifying keys on vk registry: ", error);
|
|
498
|
-
throw error;
|
|
499
|
-
}
|
|
500
|
-
// 5. maci (here we don't check whether one is already deployed, we just deploy it)
|
|
501
|
-
const emptyBallotRoots = genEmptyBallotRoots(config.MACI.stateTreeDepth);
|
|
502
|
-
const maciAddress = await this.deployAndStore(EContracts.MACI, [
|
|
503
|
-
pollFactoryAddress,
|
|
504
|
-
messageProcessorFactoryAddress,
|
|
505
|
-
tallyFactoryAddress,
|
|
506
|
-
policyAddress,
|
|
507
|
-
config.MACI.stateTreeDepth,
|
|
508
|
-
emptyBallotRoots,
|
|
509
|
-
], MACIFactory.abi, MACIFactory.linkBytecode({
|
|
510
|
-
"contracts/crypto/PoseidonT3.sol:PoseidonT3": "0x07490eba00dc4ACA6721D052Fa4C5002Aa077233",
|
|
511
|
-
"contracts/crypto/PoseidonT4.sol:PoseidonT4": "0xbb0e724CE02e5E7eDd31e632dc6e59F229a1126d",
|
|
512
|
-
"contracts/crypto/PoseidonT5.sol:PoseidonT5": "0xE0398F7DFAC494c530F6404AfEaC8669ABeD2679",
|
|
513
|
-
"contracts/crypto/PoseidonT6.sol:PoseidonT6": "0xfD77833F10a29c76A6a0ede235Eb651D744d0E2F",
|
|
514
|
-
}), kernelClient, bundlerClient, publicClient, chain);
|
|
515
|
-
// set the gate on the policy
|
|
516
|
-
await this.estimateGasAndSend(policyAddress, 0n, policyData.abi, "setTarget", [maciAddress], ErrorCodes.FAILED_TO_SET_MACI_INSTANCE_ON_POLICY.toString(), kernelClient, bundlerClient);
|
|
517
|
-
return { address: maciAddress };
|
|
208
|
+
const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
|
|
209
|
+
const policyContract = await this.deployAndSavePolicy(signer, config.policy.type, chain, config.policy.args);
|
|
210
|
+
const policyAddress = await policyContract.getAddress();
|
|
211
|
+
const verifierContract = await deployVerifier(signer, true);
|
|
212
|
+
const verifyingKeysRegistryAddress = await deployVerifyingKeysRegistryContract({ signer });
|
|
213
|
+
const verifyingKeysArgs = await this.getVerifyingKeysArgs(signer, verifyingKeysRegistryAddress, config.VerifyingKeysRegistry.args, EMode.QV);
|
|
214
|
+
await setVerifyingKeys(verifyingKeysArgs);
|
|
215
|
+
// deploy the smart contracts
|
|
216
|
+
const maciAddresses = await deployMaci({
|
|
217
|
+
stateTreeDepth: config.MACI.stateTreeDepth,
|
|
218
|
+
signer,
|
|
219
|
+
signupPolicyAddress: policyAddress,
|
|
220
|
+
});
|
|
221
|
+
// store the contracts
|
|
222
|
+
await Promise.all([
|
|
223
|
+
this.storage.register({
|
|
224
|
+
id: EContracts.Verifier,
|
|
225
|
+
contract: verifierContract,
|
|
226
|
+
network: chain,
|
|
227
|
+
}),
|
|
228
|
+
this.storage.register({
|
|
229
|
+
id: EContracts.VerifyingKeysRegistry,
|
|
230
|
+
contract: new BaseContract(verifyingKeysRegistryAddress, VerifyingKeysRegistryFactory.abi),
|
|
231
|
+
network: chain,
|
|
232
|
+
}),
|
|
233
|
+
this.storage.register({
|
|
234
|
+
id: EContracts.MACI,
|
|
235
|
+
contract: new BaseContract(maciAddresses.maciContractAddress, MACIFactory.abi),
|
|
236
|
+
args: [
|
|
237
|
+
maciAddresses.pollFactoryContractAddress,
|
|
238
|
+
maciAddresses.messageProcessorFactoryContractAddress,
|
|
239
|
+
maciAddresses.tallyFactoryContractAddress,
|
|
240
|
+
policyAddress,
|
|
241
|
+
config.MACI.stateTreeDepth,
|
|
242
|
+
generateEmptyBallotRoots(config.MACI.stateTreeDepth).map((root) => root.toString()),
|
|
243
|
+
],
|
|
244
|
+
network: chain,
|
|
245
|
+
}),
|
|
246
|
+
]);
|
|
247
|
+
return { address: maciAddresses.maciContractAddress };
|
|
518
248
|
}
|
|
519
249
|
/**
|
|
520
250
|
* Deploy a poll
|
|
@@ -523,10 +253,7 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
523
253
|
* @returns poll id
|
|
524
254
|
*/
|
|
525
255
|
async deployPoll({ approval, sessionKeyAddress, chain, config }) {
|
|
526
|
-
const
|
|
527
|
-
const bundlerClient = getBundlerClient(chain);
|
|
528
|
-
const kernelClient = await this.sessionKeysService.generateClientFromSessionKey(sessionKeyAddress, approval, chain);
|
|
529
|
-
const signer = await this.sessionKeysService.getKernelClientSigner(kernelClient);
|
|
256
|
+
const signer = await this.sessionKeysService.getCoordinatorSigner(chain, sessionKeyAddress, approval);
|
|
530
257
|
// check if there is a maci contract deployed on this chain
|
|
531
258
|
const maciAddress = this.storage.getAddress(EContracts.MACI, chain);
|
|
532
259
|
if (!maciAddress) {
|
|
@@ -537,43 +264,35 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
537
264
|
if (!verifierAddress) {
|
|
538
265
|
throw new Error(ErrorCodes.VERIFIER_NOT_DEPLOYED.toString());
|
|
539
266
|
}
|
|
540
|
-
// check if there is a
|
|
541
|
-
const
|
|
542
|
-
if (!
|
|
543
|
-
throw new Error(ErrorCodes.
|
|
267
|
+
// check if there is a verifyingKey registry deployed on this chain
|
|
268
|
+
const verifyingKeysRegistryAddress = this.storage.getAddress(EContracts.VerifyingKeysRegistry, chain);
|
|
269
|
+
if (!verifyingKeysRegistryAddress) {
|
|
270
|
+
throw new Error(ErrorCodes.VERIFYING_KEYS_REGISTRY_NOT_DEPLOYED.toString());
|
|
544
271
|
}
|
|
545
272
|
// check if policy address was given
|
|
546
273
|
let policyAddress = config.policy.address;
|
|
547
274
|
if (!policyAddress) {
|
|
548
|
-
const
|
|
549
|
-
policyAddress =
|
|
550
|
-
// if the policy is not already deployed, we need to deploy it
|
|
551
|
-
if (!policyData.alreadyDeployed) {
|
|
552
|
-
policyAddress = await this.deployAndStore(config.policy.type, config.policy.args ? Object.values(config.policy.args) : [], policyData.abi, policyData.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
553
|
-
}
|
|
275
|
+
const policyContract = await this.deployAndSavePolicy(signer, config.policy.type, chain, config.policy.args);
|
|
276
|
+
policyAddress = (await policyContract.getAddress());
|
|
554
277
|
}
|
|
555
278
|
// check if initial voice credit proxy address was given
|
|
556
279
|
let initialVoiceCreditProxyAddress = config.initialVoiceCreditsProxy.address;
|
|
557
280
|
if (!initialVoiceCreditProxyAddress) {
|
|
558
|
-
const
|
|
559
|
-
initialVoiceCreditProxyAddress =
|
|
560
|
-
// if the voice credit proxy is not already deployed, we need to deploy it
|
|
561
|
-
if (!voiceCreditProxyData.alreadyDeployed) {
|
|
562
|
-
initialVoiceCreditProxyAddress = await this.deployAndStore(config.initialVoiceCreditsProxy.type, Object.values(config.initialVoiceCreditsProxy.args), voiceCreditProxyData.abi, voiceCreditProxyData.bytecode, kernelClient, bundlerClient, publicClient, chain);
|
|
563
|
-
}
|
|
281
|
+
const initialVoiceCreditProxyContract = await this.deployAndSaveVoiceCreditProxy(signer, config.initialVoiceCreditsProxy.type, chain, config.initialVoiceCreditsProxy.args);
|
|
282
|
+
initialVoiceCreditProxyAddress = (await initialVoiceCreditProxyContract.getAddress());
|
|
564
283
|
}
|
|
565
|
-
const mode = config.useQuadraticVoting ? EMode.QV : EMode.NON_QV;
|
|
566
284
|
const deployPollArgs = {
|
|
567
285
|
maciAddress,
|
|
568
286
|
pollStartTimestamp: config.startDate,
|
|
569
287
|
pollEndTimestamp: config.endDate,
|
|
570
|
-
|
|
288
|
+
tallyProcessingStateTreeDepth: config.tallyProcessingStateTreeDepth,
|
|
571
289
|
voteOptionTreeDepth: config.voteOptionTreeDepth,
|
|
572
290
|
messageBatchSize: config.messageBatchSize,
|
|
573
|
-
|
|
291
|
+
stateTreeDepth: config.pollStateTreeDepth,
|
|
292
|
+
coordinatorPublicKey: PublicKey.deserialize(config.coordinatorPublicKey),
|
|
574
293
|
verifierContractAddress: verifierAddress,
|
|
575
|
-
|
|
576
|
-
mode,
|
|
294
|
+
verifyingKeysRegistryContractAddress: verifyingKeysRegistryAddress,
|
|
295
|
+
mode: config.mode,
|
|
577
296
|
policyContractAddress: policyAddress,
|
|
578
297
|
initialVoiceCreditProxyContractAddress: initialVoiceCreditProxyAddress,
|
|
579
298
|
relayers: config.relayers ? config.relayers.map((address) => address) : [],
|
|
@@ -583,43 +302,37 @@ let DeployerService = DeployerService_1 = class DeployerService {
|
|
|
583
302
|
};
|
|
584
303
|
const { pollContractAddress, messageProcessorContractAddress, tallyContractAddress, pollId } = await deployPoll(deployPollArgs);
|
|
585
304
|
const poll = PollFactory.connect(pollContractAddress, signer);
|
|
586
|
-
// read the emptyBallotRoot and extContracts
|
|
587
|
-
const emptyBallotRoot = await poll.emptyBallotRoot();
|
|
588
|
-
const extContracts = await poll.extContracts();
|
|
589
305
|
// store to storage
|
|
590
306
|
await Promise.all([
|
|
591
307
|
this.storage.register({
|
|
592
308
|
id: EContracts.Poll,
|
|
593
309
|
key: `poll-${pollId}`,
|
|
594
310
|
contract: poll,
|
|
595
|
-
args
|
|
596
|
-
|
|
597
|
-
...deployPollArgs,
|
|
598
|
-
extContracts,
|
|
599
|
-
emptyBallotRoot: emptyBallotRoot.toString(),
|
|
600
|
-
},
|
|
601
|
-
],
|
|
311
|
+
// clones do not have args for verification
|
|
312
|
+
args: [],
|
|
602
313
|
network: chain,
|
|
603
314
|
}),
|
|
604
315
|
this.storage.register({
|
|
605
316
|
id: EContracts.MessageProcessor,
|
|
606
317
|
key: `poll-${pollId}`,
|
|
607
|
-
contract:
|
|
608
|
-
|
|
318
|
+
contract: MessageProcessorFactory.connect(messageProcessorContractAddress, signer),
|
|
319
|
+
// clones do not have args for verification
|
|
320
|
+
args: [],
|
|
609
321
|
network: chain,
|
|
610
322
|
}),
|
|
611
323
|
this.storage.register({
|
|
612
324
|
id: EContracts.Tally,
|
|
613
325
|
key: `poll-${pollId}`,
|
|
614
|
-
contract:
|
|
615
|
-
|
|
326
|
+
contract: TallyFactory.connect(tallyContractAddress, signer),
|
|
327
|
+
// clones do not have args for verification
|
|
328
|
+
args: [],
|
|
616
329
|
network: chain,
|
|
617
330
|
}),
|
|
618
331
|
]);
|
|
619
332
|
return { pollId: pollId.toString() };
|
|
620
333
|
}
|
|
621
334
|
};
|
|
622
|
-
DeployerService =
|
|
335
|
+
DeployerService = __decorate([
|
|
623
336
|
Injectable(),
|
|
624
337
|
__metadata("design:paramtypes", [SessionKeysService,
|
|
625
338
|
FileService])
|