@semaphore-protocol/hardhat 3.15.2 → 4.0.0-alpha.1
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.mjs +62 -130
- package/dist/index.node.js +62 -130
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -7
- package/src/index.ts +3 -3
- package/src/tasks/deploy-semaphore-verifier.ts +4 -25
- package/src/tasks/deploy-semaphore.ts +12 -73
package/dist/index.mjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version
|
|
3
|
+
* @version 4.0.0-alpha.1
|
|
4
4
|
* @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
|
|
5
|
-
* @copyright Ethereum Foundation
|
|
5
|
+
* @copyright Ethereum Foundation 2024
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/hardhat}
|
|
8
8
|
*/
|
|
9
9
|
import { task, types, extendConfig } from 'hardhat/config';
|
|
10
10
|
import 'hardhat-dependency-compiler';
|
|
11
|
-
import '@
|
|
12
|
-
import { poseidonContract } from 'circomlibjs';
|
|
11
|
+
import '@nomicfoundation/hardhat-ethers';
|
|
13
12
|
|
|
14
13
|
/******************************************************************************
|
|
15
14
|
Copyright (c) Microsoft Corporation.
|
|
@@ -75,165 +74,98 @@ function __spreadArray(to, from, pack) {
|
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
78
|
-
.addOptionalParam("pairing", "Pairing library address", undefined, types.string)
|
|
79
77
|
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
80
78
|
.addOptionalParam("poseidon", "Poseidon library address", undefined, types.string)
|
|
81
|
-
.addOptionalParam("incrementalBinaryTree", "IncrementalBinaryTree library address", undefined, types.string)
|
|
82
79
|
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
|
83
80
|
.setAction(function (_a, _b) {
|
|
84
|
-
var logs = _a.logs,
|
|
81
|
+
var logs = _a.logs, semaphoreVerifierAddress = _a.semaphoreVerifier, poseidonAddress = _a.poseidon;
|
|
85
82
|
var ethers = _b.ethers;
|
|
86
83
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
-
var
|
|
88
|
-
return __generator(this, function (
|
|
89
|
-
switch (
|
|
84
|
+
var SemaphoreVerifierFactory, semaphoreVerifier, PoseidonT3Factory, poseidonT3, SemaphoreFactory, semaphore, _c, _d, _e;
|
|
85
|
+
return __generator(this, function (_f) {
|
|
86
|
+
switch (_f.label) {
|
|
90
87
|
case 0:
|
|
91
|
-
if (!!semaphoreVerifierAddress) return [3 /*break*/,
|
|
92
|
-
|
|
93
|
-
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
88
|
+
if (!!semaphoreVerifierAddress) return [3 /*break*/, 4];
|
|
89
|
+
return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
|
|
94
90
|
case 1:
|
|
95
|
-
|
|
96
|
-
return [4 /*yield*/,
|
|
91
|
+
SemaphoreVerifierFactory = _f.sent();
|
|
92
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
97
93
|
case 2:
|
|
98
|
-
|
|
99
|
-
return [4 /*yield*/,
|
|
94
|
+
semaphoreVerifier = _f.sent();
|
|
95
|
+
return [4 /*yield*/, semaphoreVerifier.getAddress()];
|
|
100
96
|
case 3:
|
|
101
|
-
|
|
97
|
+
semaphoreVerifierAddress = _f.sent();
|
|
102
98
|
if (logs) {
|
|
103
|
-
console.info("
|
|
99
|
+
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifierAddress));
|
|
104
100
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
Pairing: pairingAddress
|
|
110
|
-
}
|
|
111
|
-
})];
|
|
101
|
+
_f.label = 4;
|
|
102
|
+
case 4:
|
|
103
|
+
if (!!poseidonAddress) return [3 /*break*/, 8];
|
|
104
|
+
return [4 /*yield*/, ethers.getContractFactory("PoseidonT3")];
|
|
112
105
|
case 5:
|
|
113
|
-
|
|
114
|
-
return [4 /*yield*/,
|
|
106
|
+
PoseidonT3Factory = _f.sent();
|
|
107
|
+
return [4 /*yield*/, PoseidonT3Factory.deploy()];
|
|
115
108
|
case 6:
|
|
116
|
-
|
|
117
|
-
return [4 /*yield*/,
|
|
109
|
+
poseidonT3 = _f.sent();
|
|
110
|
+
return [4 /*yield*/, poseidonT3.getAddress()];
|
|
118
111
|
case 7:
|
|
119
|
-
|
|
112
|
+
poseidonAddress = _f.sent();
|
|
120
113
|
if (logs) {
|
|
121
|
-
console.info("
|
|
114
|
+
console.info("Poseidon library has been deployed to: ".concat(poseidonAddress));
|
|
122
115
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
case 8:
|
|
126
|
-
if (!!incrementalBinaryTreeAddress) return [3 /*break*/, 16];
|
|
127
|
-
if (!!poseidonAddress) return [3 /*break*/, 12];
|
|
128
|
-
poseidonABI = poseidonContract.generateABI(2);
|
|
129
|
-
poseidonBytecode = poseidonContract.createCode(2);
|
|
130
|
-
return [4 /*yield*/, ethers.getSigners()];
|
|
131
|
-
case 9:
|
|
132
|
-
signer = (_c.sent())[0];
|
|
133
|
-
PoseidonFactory = new ethers.ContractFactory(poseidonABI, poseidonBytecode, signer);
|
|
134
|
-
return [4 /*yield*/, PoseidonFactory.deploy()];
|
|
135
|
-
case 10:
|
|
136
|
-
poseidon = _c.sent();
|
|
137
|
-
return [4 /*yield*/, poseidon.deployed()];
|
|
138
|
-
case 11:
|
|
139
|
-
_c.sent();
|
|
140
|
-
if (logs) {
|
|
141
|
-
console.info("Poseidon library has been deployed to: ".concat(poseidon.address));
|
|
142
|
-
}
|
|
143
|
-
poseidonAddress = poseidon.address;
|
|
144
|
-
_c.label = 12;
|
|
145
|
-
case 12: return [4 /*yield*/, ethers.getContractFactory("IncrementalBinaryTree", {
|
|
116
|
+
_f.label = 8;
|
|
117
|
+
case 8: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
|
|
146
118
|
libraries: {
|
|
147
119
|
PoseidonT3: poseidonAddress
|
|
148
120
|
}
|
|
149
121
|
})];
|
|
150
|
-
case
|
|
151
|
-
|
|
152
|
-
return [4 /*yield*/, IncrementalBinaryTreeFactory.deploy()];
|
|
153
|
-
case 14:
|
|
154
|
-
incrementalBinaryTree = _c.sent();
|
|
155
|
-
return [4 /*yield*/, incrementalBinaryTree.deployed()];
|
|
156
|
-
case 15:
|
|
157
|
-
_c.sent();
|
|
158
|
-
if (logs) {
|
|
159
|
-
console.info("IncrementalBinaryTree library has been deployed to: ".concat(incrementalBinaryTree.address));
|
|
160
|
-
}
|
|
161
|
-
incrementalBinaryTreeAddress = incrementalBinaryTree.address;
|
|
162
|
-
_c.label = 16;
|
|
163
|
-
case 16: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
|
|
164
|
-
libraries: {
|
|
165
|
-
IncrementalBinaryTree: incrementalBinaryTreeAddress
|
|
166
|
-
}
|
|
167
|
-
})];
|
|
168
|
-
case 17:
|
|
169
|
-
SemaphoreFactory = _c.sent();
|
|
122
|
+
case 9:
|
|
123
|
+
SemaphoreFactory = _f.sent();
|
|
170
124
|
return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
|
|
171
|
-
case
|
|
172
|
-
semaphore =
|
|
173
|
-
return [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}];
|
|
125
|
+
case 10:
|
|
126
|
+
semaphore = _f.sent();
|
|
127
|
+
if (!logs) return [3 /*break*/, 12];
|
|
128
|
+
_d = (_c = console).info;
|
|
129
|
+
_e = "Semaphore contract has been deployed to: ".concat;
|
|
130
|
+
return [4 /*yield*/, semaphore.getAddress()];
|
|
131
|
+
case 11:
|
|
132
|
+
_d.apply(_c, [_e.apply("Semaphore contract has been deployed to: ", [_f.sent()])]);
|
|
133
|
+
_f.label = 12;
|
|
134
|
+
case 12: return [2 /*return*/, {
|
|
135
|
+
semaphore: semaphore,
|
|
136
|
+
semaphoreVerifierAddress: semaphoreVerifierAddress,
|
|
137
|
+
poseidonAddress: poseidonAddress
|
|
138
|
+
}];
|
|
186
139
|
}
|
|
187
140
|
});
|
|
188
141
|
});
|
|
189
142
|
});
|
|
190
143
|
|
|
191
144
|
task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
192
|
-
.addOptionalParam("pairing", "Pairing library address", undefined, types.string)
|
|
193
145
|
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
|
194
146
|
.setAction(function (_a, _b) {
|
|
195
|
-
var logs = _a.logs
|
|
147
|
+
var logs = _a.logs;
|
|
196
148
|
var ethers = _b.ethers;
|
|
197
149
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
198
|
-
var
|
|
199
|
-
return __generator(this, function (
|
|
200
|
-
switch (
|
|
201
|
-
case 0:
|
|
202
|
-
if (!!pairingAddress) return [3 /*break*/, 4];
|
|
203
|
-
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
150
|
+
var SemaphoreVerifierFactory, semaphoreVerifier, _c, _d, _e;
|
|
151
|
+
return __generator(this, function (_f) {
|
|
152
|
+
switch (_f.label) {
|
|
153
|
+
case 0: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
|
|
204
154
|
case 1:
|
|
205
|
-
|
|
206
|
-
return [4 /*yield*/,
|
|
155
|
+
SemaphoreVerifierFactory = _f.sent();
|
|
156
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
207
157
|
case 2:
|
|
208
|
-
|
|
209
|
-
return [
|
|
158
|
+
semaphoreVerifier = _f.sent();
|
|
159
|
+
if (!logs) return [3 /*break*/, 4];
|
|
160
|
+
_d = (_c = console).info;
|
|
161
|
+
_e = "SemaphoreVerifier contract has been deployed to: ".concat;
|
|
162
|
+
return [4 /*yield*/, semaphoreVerifier.getAddress()];
|
|
210
163
|
case 3:
|
|
211
|
-
_c.sent();
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
_c.label = 4;
|
|
217
|
-
case 4: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier", {
|
|
218
|
-
libraries: {
|
|
219
|
-
Pairing: pairingAddress
|
|
220
|
-
}
|
|
221
|
-
})];
|
|
222
|
-
case 5:
|
|
223
|
-
SemaphoreVerifierFactory = _c.sent();
|
|
224
|
-
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
225
|
-
case 6:
|
|
226
|
-
semaphoreVerifier = _c.sent();
|
|
227
|
-
return [4 /*yield*/, semaphoreVerifier.deployed()];
|
|
228
|
-
case 7:
|
|
229
|
-
_c.sent();
|
|
230
|
-
if (logs) {
|
|
231
|
-
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifier.address));
|
|
232
|
-
}
|
|
233
|
-
return [2 /*return*/, {
|
|
234
|
-
semaphoreVerifier: semaphoreVerifier,
|
|
235
|
-
pairingAddress: pairingAddress
|
|
236
|
-
}];
|
|
164
|
+
_d.apply(_c, [_e.apply("SemaphoreVerifier contract has been deployed to: ", [_f.sent()])]);
|
|
165
|
+
_f.label = 4;
|
|
166
|
+
case 4: return [2 /*return*/, {
|
|
167
|
+
semaphoreVerifier: semaphoreVerifier
|
|
168
|
+
}];
|
|
237
169
|
}
|
|
238
170
|
});
|
|
239
171
|
});
|
|
@@ -242,9 +174,9 @@ task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
|
242
174
|
extendConfig(function (config, userConfig) {
|
|
243
175
|
var _a;
|
|
244
176
|
config.dependencyCompiler.paths = [
|
|
245
|
-
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
246
177
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
247
|
-
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
178
|
+
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
179
|
+
"poseidon-solidity/PoseidonT3.sol"
|
|
248
180
|
];
|
|
249
181
|
if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
|
|
250
182
|
config.dependencyCompiler.paths = __spreadArray(__spreadArray([], config.dependencyCompiler.paths, true), userConfig.dependencyCompiler.paths, true);
|
package/dist/index.node.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version
|
|
3
|
+
* @version 4.0.0-alpha.1
|
|
4
4
|
* @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
|
|
5
|
-
* @copyright Ethereum Foundation
|
|
5
|
+
* @copyright Ethereum Foundation 2024
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/hardhat}
|
|
8
8
|
*/
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
var config = require('hardhat/config');
|
|
12
12
|
require('hardhat-dependency-compiler');
|
|
13
|
-
require('@
|
|
14
|
-
var circomlibjs = require('circomlibjs');
|
|
13
|
+
require('@nomicfoundation/hardhat-ethers');
|
|
15
14
|
|
|
16
15
|
/******************************************************************************
|
|
17
16
|
Copyright (c) Microsoft Corporation.
|
|
@@ -77,165 +76,98 @@ function __spreadArray(to, from, pack) {
|
|
|
77
76
|
}
|
|
78
77
|
|
|
79
78
|
config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
80
|
-
.addOptionalParam("pairing", "Pairing library address", undefined, config.types.string)
|
|
81
79
|
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, config.types.string)
|
|
82
80
|
.addOptionalParam("poseidon", "Poseidon library address", undefined, config.types.string)
|
|
83
|
-
.addOptionalParam("incrementalBinaryTree", "IncrementalBinaryTree library address", undefined, config.types.string)
|
|
84
81
|
.addOptionalParam("logs", "Print the logs", true, config.types.boolean)
|
|
85
82
|
.setAction(function (_a, _b) {
|
|
86
|
-
var logs = _a.logs,
|
|
83
|
+
var logs = _a.logs, semaphoreVerifierAddress = _a.semaphoreVerifier, poseidonAddress = _a.poseidon;
|
|
87
84
|
var ethers = _b.ethers;
|
|
88
85
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
89
|
-
var
|
|
90
|
-
return __generator(this, function (
|
|
91
|
-
switch (
|
|
86
|
+
var SemaphoreVerifierFactory, semaphoreVerifier, PoseidonT3Factory, poseidonT3, SemaphoreFactory, semaphore, _c, _d, _e;
|
|
87
|
+
return __generator(this, function (_f) {
|
|
88
|
+
switch (_f.label) {
|
|
92
89
|
case 0:
|
|
93
|
-
if (!!semaphoreVerifierAddress) return [3 /*break*/,
|
|
94
|
-
|
|
95
|
-
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
90
|
+
if (!!semaphoreVerifierAddress) return [3 /*break*/, 4];
|
|
91
|
+
return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
|
|
96
92
|
case 1:
|
|
97
|
-
|
|
98
|
-
return [4 /*yield*/,
|
|
93
|
+
SemaphoreVerifierFactory = _f.sent();
|
|
94
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
99
95
|
case 2:
|
|
100
|
-
|
|
101
|
-
return [4 /*yield*/,
|
|
96
|
+
semaphoreVerifier = _f.sent();
|
|
97
|
+
return [4 /*yield*/, semaphoreVerifier.getAddress()];
|
|
102
98
|
case 3:
|
|
103
|
-
|
|
99
|
+
semaphoreVerifierAddress = _f.sent();
|
|
104
100
|
if (logs) {
|
|
105
|
-
console.info("
|
|
101
|
+
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifierAddress));
|
|
106
102
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Pairing: pairingAddress
|
|
112
|
-
}
|
|
113
|
-
})];
|
|
103
|
+
_f.label = 4;
|
|
104
|
+
case 4:
|
|
105
|
+
if (!!poseidonAddress) return [3 /*break*/, 8];
|
|
106
|
+
return [4 /*yield*/, ethers.getContractFactory("PoseidonT3")];
|
|
114
107
|
case 5:
|
|
115
|
-
|
|
116
|
-
return [4 /*yield*/,
|
|
108
|
+
PoseidonT3Factory = _f.sent();
|
|
109
|
+
return [4 /*yield*/, PoseidonT3Factory.deploy()];
|
|
117
110
|
case 6:
|
|
118
|
-
|
|
119
|
-
return [4 /*yield*/,
|
|
111
|
+
poseidonT3 = _f.sent();
|
|
112
|
+
return [4 /*yield*/, poseidonT3.getAddress()];
|
|
120
113
|
case 7:
|
|
121
|
-
|
|
114
|
+
poseidonAddress = _f.sent();
|
|
122
115
|
if (logs) {
|
|
123
|
-
console.info("
|
|
116
|
+
console.info("Poseidon library has been deployed to: ".concat(poseidonAddress));
|
|
124
117
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
case 8:
|
|
128
|
-
if (!!incrementalBinaryTreeAddress) return [3 /*break*/, 16];
|
|
129
|
-
if (!!poseidonAddress) return [3 /*break*/, 12];
|
|
130
|
-
poseidonABI = circomlibjs.poseidonContract.generateABI(2);
|
|
131
|
-
poseidonBytecode = circomlibjs.poseidonContract.createCode(2);
|
|
132
|
-
return [4 /*yield*/, ethers.getSigners()];
|
|
133
|
-
case 9:
|
|
134
|
-
signer = (_c.sent())[0];
|
|
135
|
-
PoseidonFactory = new ethers.ContractFactory(poseidonABI, poseidonBytecode, signer);
|
|
136
|
-
return [4 /*yield*/, PoseidonFactory.deploy()];
|
|
137
|
-
case 10:
|
|
138
|
-
poseidon = _c.sent();
|
|
139
|
-
return [4 /*yield*/, poseidon.deployed()];
|
|
140
|
-
case 11:
|
|
141
|
-
_c.sent();
|
|
142
|
-
if (logs) {
|
|
143
|
-
console.info("Poseidon library has been deployed to: ".concat(poseidon.address));
|
|
144
|
-
}
|
|
145
|
-
poseidonAddress = poseidon.address;
|
|
146
|
-
_c.label = 12;
|
|
147
|
-
case 12: return [4 /*yield*/, ethers.getContractFactory("IncrementalBinaryTree", {
|
|
118
|
+
_f.label = 8;
|
|
119
|
+
case 8: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
|
|
148
120
|
libraries: {
|
|
149
121
|
PoseidonT3: poseidonAddress
|
|
150
122
|
}
|
|
151
123
|
})];
|
|
152
|
-
case
|
|
153
|
-
|
|
154
|
-
return [4 /*yield*/, IncrementalBinaryTreeFactory.deploy()];
|
|
155
|
-
case 14:
|
|
156
|
-
incrementalBinaryTree = _c.sent();
|
|
157
|
-
return [4 /*yield*/, incrementalBinaryTree.deployed()];
|
|
158
|
-
case 15:
|
|
159
|
-
_c.sent();
|
|
160
|
-
if (logs) {
|
|
161
|
-
console.info("IncrementalBinaryTree library has been deployed to: ".concat(incrementalBinaryTree.address));
|
|
162
|
-
}
|
|
163
|
-
incrementalBinaryTreeAddress = incrementalBinaryTree.address;
|
|
164
|
-
_c.label = 16;
|
|
165
|
-
case 16: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
|
|
166
|
-
libraries: {
|
|
167
|
-
IncrementalBinaryTree: incrementalBinaryTreeAddress
|
|
168
|
-
}
|
|
169
|
-
})];
|
|
170
|
-
case 17:
|
|
171
|
-
SemaphoreFactory = _c.sent();
|
|
124
|
+
case 9:
|
|
125
|
+
SemaphoreFactory = _f.sent();
|
|
172
126
|
return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
|
|
173
|
-
case
|
|
174
|
-
semaphore =
|
|
175
|
-
return [
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}];
|
|
127
|
+
case 10:
|
|
128
|
+
semaphore = _f.sent();
|
|
129
|
+
if (!logs) return [3 /*break*/, 12];
|
|
130
|
+
_d = (_c = console).info;
|
|
131
|
+
_e = "Semaphore contract has been deployed to: ".concat;
|
|
132
|
+
return [4 /*yield*/, semaphore.getAddress()];
|
|
133
|
+
case 11:
|
|
134
|
+
_d.apply(_c, [_e.apply("Semaphore contract has been deployed to: ", [_f.sent()])]);
|
|
135
|
+
_f.label = 12;
|
|
136
|
+
case 12: return [2 /*return*/, {
|
|
137
|
+
semaphore: semaphore,
|
|
138
|
+
semaphoreVerifierAddress: semaphoreVerifierAddress,
|
|
139
|
+
poseidonAddress: poseidonAddress
|
|
140
|
+
}];
|
|
188
141
|
}
|
|
189
142
|
});
|
|
190
143
|
});
|
|
191
144
|
});
|
|
192
145
|
|
|
193
146
|
config.task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
194
|
-
.addOptionalParam("pairing", "Pairing library address", undefined, config.types.string)
|
|
195
147
|
.addOptionalParam("logs", "Print the logs", true, config.types.boolean)
|
|
196
148
|
.setAction(function (_a, _b) {
|
|
197
|
-
var logs = _a.logs
|
|
149
|
+
var logs = _a.logs;
|
|
198
150
|
var ethers = _b.ethers;
|
|
199
151
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
200
|
-
var
|
|
201
|
-
return __generator(this, function (
|
|
202
|
-
switch (
|
|
203
|
-
case 0:
|
|
204
|
-
if (!!pairingAddress) return [3 /*break*/, 4];
|
|
205
|
-
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
152
|
+
var SemaphoreVerifierFactory, semaphoreVerifier, _c, _d, _e;
|
|
153
|
+
return __generator(this, function (_f) {
|
|
154
|
+
switch (_f.label) {
|
|
155
|
+
case 0: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
|
|
206
156
|
case 1:
|
|
207
|
-
|
|
208
|
-
return [4 /*yield*/,
|
|
157
|
+
SemaphoreVerifierFactory = _f.sent();
|
|
158
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
209
159
|
case 2:
|
|
210
|
-
|
|
211
|
-
return [
|
|
160
|
+
semaphoreVerifier = _f.sent();
|
|
161
|
+
if (!logs) return [3 /*break*/, 4];
|
|
162
|
+
_d = (_c = console).info;
|
|
163
|
+
_e = "SemaphoreVerifier contract has been deployed to: ".concat;
|
|
164
|
+
return [4 /*yield*/, semaphoreVerifier.getAddress()];
|
|
212
165
|
case 3:
|
|
213
|
-
_c.sent();
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
_c.label = 4;
|
|
219
|
-
case 4: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier", {
|
|
220
|
-
libraries: {
|
|
221
|
-
Pairing: pairingAddress
|
|
222
|
-
}
|
|
223
|
-
})];
|
|
224
|
-
case 5:
|
|
225
|
-
SemaphoreVerifierFactory = _c.sent();
|
|
226
|
-
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
227
|
-
case 6:
|
|
228
|
-
semaphoreVerifier = _c.sent();
|
|
229
|
-
return [4 /*yield*/, semaphoreVerifier.deployed()];
|
|
230
|
-
case 7:
|
|
231
|
-
_c.sent();
|
|
232
|
-
if (logs) {
|
|
233
|
-
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifier.address));
|
|
234
|
-
}
|
|
235
|
-
return [2 /*return*/, {
|
|
236
|
-
semaphoreVerifier: semaphoreVerifier,
|
|
237
|
-
pairingAddress: pairingAddress
|
|
238
|
-
}];
|
|
166
|
+
_d.apply(_c, [_e.apply("SemaphoreVerifier contract has been deployed to: ", [_f.sent()])]);
|
|
167
|
+
_f.label = 4;
|
|
168
|
+
case 4: return [2 /*return*/, {
|
|
169
|
+
semaphoreVerifier: semaphoreVerifier
|
|
170
|
+
}];
|
|
239
171
|
}
|
|
240
172
|
});
|
|
241
173
|
});
|
|
@@ -244,9 +176,9 @@ config.task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
|
244
176
|
config.extendConfig(function (config, userConfig) {
|
|
245
177
|
var _a;
|
|
246
178
|
config.dependencyCompiler.paths = [
|
|
247
|
-
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
248
179
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
249
|
-
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
180
|
+
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
181
|
+
"poseidon-solidity/PoseidonT3.sol"
|
|
250
182
|
];
|
|
251
183
|
if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
|
|
252
184
|
config.dependencyCompiler.paths = __spreadArray(__spreadArray([], config.dependencyCompiler.paths, true), userConfig.dependencyCompiler.paths, true);
|
package/dist/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/hardhat",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.node.js",
|
|
@@ -30,18 +30,17 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"hardhat": "^2.
|
|
33
|
+
"hardhat": "^2.19.4",
|
|
34
34
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
35
35
|
"rollup-plugin-typescript2": "^0.31.2"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"hardhat": "^2.
|
|
38
|
+
"hardhat": "^2.19.4"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@
|
|
42
|
-
"@semaphore-protocol/contracts": "
|
|
43
|
-
"
|
|
44
|
-
"ethers": "^5.7.1",
|
|
41
|
+
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
|
42
|
+
"@semaphore-protocol/contracts": "4.0.0-alpha.1",
|
|
43
|
+
"ethers": "^6.4.0",
|
|
45
44
|
"hardhat-dependency-compiler": "^1.1.3"
|
|
46
45
|
}
|
|
47
46
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { extendConfig } from "hardhat/config"
|
|
|
2
2
|
import { HardhatConfig, HardhatUserConfig } from "hardhat/types"
|
|
3
3
|
|
|
4
4
|
import "hardhat-dependency-compiler"
|
|
5
|
-
import "@
|
|
5
|
+
import "@nomicfoundation/hardhat-ethers"
|
|
6
6
|
import "./tasks/deploy-semaphore"
|
|
7
7
|
import "./tasks/deploy-semaphore-verifier"
|
|
8
8
|
|
|
9
9
|
extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
|
|
10
10
|
config.dependencyCompiler.paths = [
|
|
11
|
-
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
12
11
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
13
|
-
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
12
|
+
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
13
|
+
"poseidon-solidity/PoseidonT3.sol"
|
|
14
14
|
]
|
|
15
15
|
|
|
16
16
|
if (userConfig.dependencyCompiler?.paths) {
|
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
import { task, types } from "hardhat/config"
|
|
2
2
|
|
|
3
3
|
task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
4
|
-
.addOptionalParam<boolean>("pairing", "Pairing library address", undefined, types.string)
|
|
5
4
|
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
|
6
|
-
.setAction(async ({ logs
|
|
7
|
-
|
|
8
|
-
const PairingFactory = await ethers.getContractFactory("Pairing")
|
|
9
|
-
const pairing = await PairingFactory.deploy()
|
|
10
|
-
|
|
11
|
-
await pairing.deployed()
|
|
12
|
-
|
|
13
|
-
if (logs) {
|
|
14
|
-
console.info(`Pairing library has been deployed to: ${pairing.address}`)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
pairingAddress = pairing.address
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier", {
|
|
21
|
-
libraries: {
|
|
22
|
-
Pairing: pairingAddress
|
|
23
|
-
}
|
|
24
|
-
})
|
|
5
|
+
.setAction(async ({ logs }, { ethers }): Promise<any> => {
|
|
6
|
+
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier")
|
|
25
7
|
|
|
26
8
|
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy()
|
|
27
9
|
|
|
28
|
-
await semaphoreVerifier.deployed()
|
|
29
|
-
|
|
30
10
|
if (logs) {
|
|
31
|
-
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.
|
|
11
|
+
console.info(`SemaphoreVerifier contract has been deployed to: ${await semaphoreVerifier.getAddress()}`)
|
|
32
12
|
}
|
|
33
13
|
|
|
34
14
|
return {
|
|
35
|
-
semaphoreVerifier
|
|
36
|
-
pairingAddress
|
|
15
|
+
semaphoreVerifier
|
|
37
16
|
}
|
|
38
17
|
})
|
|
@@ -1,114 +1,53 @@
|
|
|
1
|
-
import { poseidonContract } from "circomlibjs"
|
|
2
1
|
import { task, types } from "hardhat/config"
|
|
3
2
|
|
|
4
3
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
5
|
-
.addOptionalParam<boolean>("pairing", "Pairing library address", undefined, types.string)
|
|
6
4
|
.addOptionalParam<boolean>("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
7
5
|
.addOptionalParam<boolean>("poseidon", "Poseidon library address", undefined, types.string)
|
|
8
|
-
.addOptionalParam<boolean>(
|
|
9
|
-
"incrementalBinaryTree",
|
|
10
|
-
"IncrementalBinaryTree library address",
|
|
11
|
-
undefined,
|
|
12
|
-
types.string
|
|
13
|
-
)
|
|
14
6
|
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
|
15
7
|
.setAction(
|
|
16
8
|
async (
|
|
17
|
-
{
|
|
18
|
-
logs,
|
|
19
|
-
pairing: pairingAddress,
|
|
20
|
-
semaphoreVerifier: semaphoreVerifierAddress,
|
|
21
|
-
poseidon: poseidonAddress,
|
|
22
|
-
incrementalBinaryTree: incrementalBinaryTreeAddress
|
|
23
|
-
},
|
|
9
|
+
{ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress },
|
|
24
10
|
{ ethers }
|
|
25
11
|
): Promise<any> => {
|
|
26
12
|
if (!semaphoreVerifierAddress) {
|
|
27
|
-
|
|
28
|
-
const PairingFactory = await ethers.getContractFactory("Pairing")
|
|
29
|
-
const pairing = await PairingFactory.deploy()
|
|
30
|
-
|
|
31
|
-
await pairing.deployed()
|
|
32
|
-
|
|
33
|
-
if (logs) {
|
|
34
|
-
console.info(`Pairing library has been deployed to: ${pairing.address}`)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pairingAddress = pairing.address
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier", {
|
|
41
|
-
libraries: {
|
|
42
|
-
Pairing: pairingAddress
|
|
43
|
-
}
|
|
44
|
-
})
|
|
13
|
+
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier")
|
|
45
14
|
|
|
46
15
|
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy()
|
|
47
16
|
|
|
48
|
-
await semaphoreVerifier.
|
|
17
|
+
semaphoreVerifierAddress = await semaphoreVerifier.getAddress()
|
|
49
18
|
|
|
50
19
|
if (logs) {
|
|
51
|
-
console.info(`SemaphoreVerifier contract has been deployed to: ${
|
|
20
|
+
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`)
|
|
52
21
|
}
|
|
53
|
-
|
|
54
|
-
semaphoreVerifierAddress = semaphoreVerifier.address
|
|
55
22
|
}
|
|
56
23
|
|
|
57
|
-
if (!
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
const poseidonBytecode = poseidonContract.createCode(2)
|
|
61
|
-
|
|
62
|
-
const [signer] = await ethers.getSigners()
|
|
24
|
+
if (!poseidonAddress) {
|
|
25
|
+
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3")
|
|
26
|
+
const poseidonT3 = await PoseidonT3Factory.deploy()
|
|
63
27
|
|
|
64
|
-
|
|
65
|
-
const poseidon = await PoseidonFactory.deploy()
|
|
66
|
-
|
|
67
|
-
await poseidon.deployed()
|
|
68
|
-
|
|
69
|
-
if (logs) {
|
|
70
|
-
console.info(`Poseidon library has been deployed to: ${poseidon.address}`)
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
poseidonAddress = poseidon.address
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const IncrementalBinaryTreeFactory = await ethers.getContractFactory("IncrementalBinaryTree", {
|
|
77
|
-
libraries: {
|
|
78
|
-
PoseidonT3: poseidonAddress
|
|
79
|
-
}
|
|
80
|
-
})
|
|
81
|
-
const incrementalBinaryTree = await IncrementalBinaryTreeFactory.deploy()
|
|
82
|
-
|
|
83
|
-
await incrementalBinaryTree.deployed()
|
|
28
|
+
poseidonAddress = await poseidonT3.getAddress()
|
|
84
29
|
|
|
85
30
|
if (logs) {
|
|
86
|
-
console.info(`
|
|
31
|
+
console.info(`Poseidon library has been deployed to: ${poseidonAddress}`)
|
|
87
32
|
}
|
|
88
|
-
|
|
89
|
-
incrementalBinaryTreeAddress = incrementalBinaryTree.address
|
|
90
33
|
}
|
|
91
34
|
|
|
92
35
|
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
|
93
36
|
libraries: {
|
|
94
|
-
|
|
37
|
+
PoseidonT3: poseidonAddress
|
|
95
38
|
}
|
|
96
39
|
})
|
|
97
40
|
|
|
98
41
|
const semaphore = await SemaphoreFactory.deploy(semaphoreVerifierAddress)
|
|
99
42
|
|
|
100
|
-
await semaphore.deployed()
|
|
101
|
-
|
|
102
43
|
if (logs) {
|
|
103
|
-
console.info(`Semaphore contract has been deployed to: ${semaphore.
|
|
44
|
+
console.info(`Semaphore contract has been deployed to: ${await semaphore.getAddress()}`)
|
|
104
45
|
}
|
|
105
46
|
|
|
106
47
|
return {
|
|
107
48
|
semaphore,
|
|
108
|
-
pairingAddress,
|
|
109
49
|
semaphoreVerifierAddress,
|
|
110
|
-
poseidonAddress
|
|
111
|
-
incrementalBinaryTreeAddress
|
|
50
|
+
poseidonAddress
|
|
112
51
|
}
|
|
113
52
|
}
|
|
114
53
|
)
|