@semaphore-protocol/hardhat 0.1.0 → 3.0.0-beta.5
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 +85 -78
- package/dist/index.node.js +85 -78
- package/dist/types/index.d.ts +0 -1
- package/package.json +2 -2
- package/src/index.ts +2 -18
- package/src/tasks/deploy-semaphore.ts +95 -32
- package/dist/types/tasks/deploy-verifier.d.ts +0 -1
- package/src/tasks/deploy-verifier.ts +0 -19
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version 0.
|
|
3
|
+
* @version 3.0.0-beta.5
|
|
4
4
|
* @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -75,92 +75,114 @@ function __spreadArray(to, from, pack) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
78
|
-
.
|
|
78
|
+
.addOptionalParam("pairing", "Pairing library address", undefined, types.string)
|
|
79
|
+
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
80
|
+
.addOptionalParam("poseidon", "Poseidon library address", undefined, types.string)
|
|
81
|
+
.addOptionalParam("incrementalBinaryTree", "IncrementalBinaryTree library address", undefined, types.string)
|
|
79
82
|
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
|
80
83
|
.setAction(function (_a, _b) {
|
|
81
|
-
var logs = _a.logs,
|
|
84
|
+
var logs = _a.logs, pairingAddress = _a.pairing, semaphoreVerifierAddress = _a.semaphoreVerifier, poseidonAddress = _a.poseidon, incrementalBinaryTreeAddress = _a.incrementalBinaryTree;
|
|
82
85
|
var ethers = _b.ethers;
|
|
83
86
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
84
|
-
var poseidonABI, poseidonBytecode, signer,
|
|
87
|
+
var PairingFactory, pairing, SemaphoreVerifierFactory, semaphoreVerifier, poseidonABI, poseidonBytecode, signer, PoseidonFactory, poseidon, IncrementalBinaryTreeFactory, incrementalBinaryTree, SemaphoreFactory, semaphore;
|
|
85
88
|
return __generator(this, function (_c) {
|
|
86
89
|
switch (_c.label) {
|
|
87
90
|
case 0:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return [4 /*yield*/, ethers.
|
|
91
|
+
if (!!semaphoreVerifierAddress) return [3 /*break*/, 8];
|
|
92
|
+
if (!!pairingAddress) return [3 /*break*/, 4];
|
|
93
|
+
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
91
94
|
case 1:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return [4 /*yield*/, PoseidonLibFactory.deploy()];
|
|
95
|
+
PairingFactory = _c.sent();
|
|
96
|
+
return [4 /*yield*/, PairingFactory.deploy()];
|
|
95
97
|
case 2:
|
|
96
|
-
|
|
97
|
-
return [4 /*yield*/,
|
|
98
|
+
pairing = _c.sent();
|
|
99
|
+
return [4 /*yield*/, pairing.deployed()];
|
|
98
100
|
case 3:
|
|
99
101
|
_c.sent();
|
|
100
102
|
if (logs) {
|
|
101
|
-
console.info("
|
|
103
|
+
console.info("Pairing library has been deployed to: ".concat(pairing.address));
|
|
102
104
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
return [4 /*yield*/, IncrementalBinaryTreeLibFactory.deploy()];
|
|
105
|
+
pairingAddress = pairing.address;
|
|
106
|
+
_c.label = 4;
|
|
107
|
+
case 4: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier", {
|
|
108
|
+
libraries: {
|
|
109
|
+
Pairing: pairingAddress
|
|
110
|
+
}
|
|
111
|
+
})];
|
|
111
112
|
case 5:
|
|
112
|
-
|
|
113
|
-
return [4 /*yield*/,
|
|
113
|
+
SemaphoreVerifierFactory = _c.sent();
|
|
114
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
114
115
|
case 6:
|
|
116
|
+
semaphoreVerifier = _c.sent();
|
|
117
|
+
return [4 /*yield*/, semaphoreVerifier.deployed()];
|
|
118
|
+
case 7:
|
|
115
119
|
_c.sent();
|
|
116
120
|
if (logs) {
|
|
117
|
-
console.info("
|
|
121
|
+
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifier.address));
|
|
118
122
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
IncrementalBinaryTree: incrementalBinaryTreeLib.address
|
|
122
|
-
}
|
|
123
|
-
})];
|
|
124
|
-
case 7:
|
|
125
|
-
SemaphoreContractFactory = _c.sent();
|
|
126
|
-
return [4 /*yield*/, SemaphoreContractFactory.deploy(verifiers)];
|
|
123
|
+
semaphoreVerifierAddress = semaphoreVerifier.address;
|
|
124
|
+
_c.label = 8;
|
|
127
125
|
case 8:
|
|
128
|
-
|
|
129
|
-
return [
|
|
126
|
+
if (!!incrementalBinaryTreeAddress) return [3 /*break*/, 16];
|
|
127
|
+
if (!!poseidonAddress) return [3 /*break*/, 12];
|
|
128
|
+
poseidonABI = poseidon_gencontract.generateABI(2);
|
|
129
|
+
poseidonBytecode = poseidon_gencontract.createCode(2);
|
|
130
|
+
return [4 /*yield*/, ethers.getSigners()];
|
|
130
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:
|
|
131
139
|
_c.sent();
|
|
132
140
|
if (logs) {
|
|
133
|
-
console.info("
|
|
141
|
+
console.info("Poseidon library has been deployed to: ".concat(poseidon.address));
|
|
134
142
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
case
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
143
|
+
poseidonAddress = poseidon.address;
|
|
144
|
+
_c.label = 12;
|
|
145
|
+
case 12: return [4 /*yield*/, ethers.getContractFactory("IncrementalBinaryTree", {
|
|
146
|
+
libraries: {
|
|
147
|
+
PoseidonT3: poseidonAddress
|
|
148
|
+
}
|
|
149
|
+
})];
|
|
150
|
+
case 13:
|
|
151
|
+
IncrementalBinaryTreeFactory = _c.sent();
|
|
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();
|
|
170
|
+
return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
|
|
171
|
+
case 18:
|
|
172
|
+
semaphore = _c.sent();
|
|
173
|
+
return [4 /*yield*/, semaphore.deployed()];
|
|
174
|
+
case 19:
|
|
159
175
|
_c.sent();
|
|
160
176
|
if (logs) {
|
|
161
|
-
console.info("
|
|
177
|
+
console.info("Semaphore contract has been deployed to: ".concat(semaphore.address));
|
|
162
178
|
}
|
|
163
|
-
return [2 /*return*/,
|
|
179
|
+
return [2 /*return*/, {
|
|
180
|
+
semaphore: semaphore,
|
|
181
|
+
pairingAddress: pairingAddress,
|
|
182
|
+
semaphoreVerifierAddress: semaphoreVerifierAddress,
|
|
183
|
+
poseidonAddress: poseidonAddress,
|
|
184
|
+
incrementalBinaryTreeAddress: incrementalBinaryTreeAddress
|
|
185
|
+
}];
|
|
164
186
|
}
|
|
165
187
|
});
|
|
166
188
|
});
|
|
@@ -169,23 +191,8 @@ task("deploy:verifier", "Deploy a Verifier contract")
|
|
|
169
191
|
extendConfig(function (config, userConfig) {
|
|
170
192
|
var _a;
|
|
171
193
|
config.dependencyCompiler.paths = [
|
|
172
|
-
"@semaphore-protocol/contracts/
|
|
173
|
-
"@semaphore-protocol/contracts/
|
|
174
|
-
"@semaphore-protocol/contracts/verifiers/Verifier18.sol",
|
|
175
|
-
"@semaphore-protocol/contracts/verifiers/Verifier19.sol",
|
|
176
|
-
"@semaphore-protocol/contracts/verifiers/Verifier20.sol",
|
|
177
|
-
"@semaphore-protocol/contracts/verifiers/Verifier21.sol",
|
|
178
|
-
"@semaphore-protocol/contracts/verifiers/Verifier22.sol",
|
|
179
|
-
"@semaphore-protocol/contracts/verifiers/Verifier23.sol",
|
|
180
|
-
"@semaphore-protocol/contracts/verifiers/Verifier24.sol",
|
|
181
|
-
"@semaphore-protocol/contracts/verifiers/Verifier25.sol",
|
|
182
|
-
"@semaphore-protocol/contracts/verifiers/Verifier26.sol",
|
|
183
|
-
"@semaphore-protocol/contracts/verifiers/Verifier27.sol",
|
|
184
|
-
"@semaphore-protocol/contracts/verifiers/Verifier28.sol",
|
|
185
|
-
"@semaphore-protocol/contracts/verifiers/Verifier29.sol",
|
|
186
|
-
"@semaphore-protocol/contracts/verifiers/Verifier30.sol",
|
|
187
|
-
"@semaphore-protocol/contracts/verifiers/Verifier31.sol",
|
|
188
|
-
"@semaphore-protocol/contracts/verifiers/Verifier32.sol",
|
|
194
|
+
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
195
|
+
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
189
196
|
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
190
197
|
];
|
|
191
198
|
if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
|
package/dist/index.node.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version 0.
|
|
3
|
+
* @version 3.0.0-beta.5
|
|
4
4
|
* @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
|
|
5
5
|
* @copyright Ethereum Foundation 2022
|
|
6
6
|
* @license MIT
|
|
@@ -77,92 +77,114 @@ function __spreadArray(to, from, pack) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
80
|
-
.
|
|
80
|
+
.addOptionalParam("pairing", "Pairing library address", undefined, config.types.string)
|
|
81
|
+
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, config.types.string)
|
|
82
|
+
.addOptionalParam("poseidon", "Poseidon library address", undefined, config.types.string)
|
|
83
|
+
.addOptionalParam("incrementalBinaryTree", "IncrementalBinaryTree library address", undefined, config.types.string)
|
|
81
84
|
.addOptionalParam("logs", "Print the logs", true, config.types.boolean)
|
|
82
85
|
.setAction(function (_a, _b) {
|
|
83
|
-
var logs = _a.logs,
|
|
86
|
+
var logs = _a.logs, pairingAddress = _a.pairing, semaphoreVerifierAddress = _a.semaphoreVerifier, poseidonAddress = _a.poseidon, incrementalBinaryTreeAddress = _a.incrementalBinaryTree;
|
|
84
87
|
var ethers = _b.ethers;
|
|
85
88
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
86
|
-
var poseidonABI, poseidonBytecode, signer,
|
|
89
|
+
var PairingFactory, pairing, SemaphoreVerifierFactory, semaphoreVerifier, poseidonABI, poseidonBytecode, signer, PoseidonFactory, poseidon, IncrementalBinaryTreeFactory, incrementalBinaryTree, SemaphoreFactory, semaphore;
|
|
87
90
|
return __generator(this, function (_c) {
|
|
88
91
|
switch (_c.label) {
|
|
89
92
|
case 0:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return [4 /*yield*/, ethers.
|
|
93
|
+
if (!!semaphoreVerifierAddress) return [3 /*break*/, 8];
|
|
94
|
+
if (!!pairingAddress) return [3 /*break*/, 4];
|
|
95
|
+
return [4 /*yield*/, ethers.getContractFactory("Pairing")];
|
|
93
96
|
case 1:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return [4 /*yield*/, PoseidonLibFactory.deploy()];
|
|
97
|
+
PairingFactory = _c.sent();
|
|
98
|
+
return [4 /*yield*/, PairingFactory.deploy()];
|
|
97
99
|
case 2:
|
|
98
|
-
|
|
99
|
-
return [4 /*yield*/,
|
|
100
|
+
pairing = _c.sent();
|
|
101
|
+
return [4 /*yield*/, pairing.deployed()];
|
|
100
102
|
case 3:
|
|
101
103
|
_c.sent();
|
|
102
104
|
if (logs) {
|
|
103
|
-
console.info("
|
|
105
|
+
console.info("Pairing library has been deployed to: ".concat(pairing.address));
|
|
104
106
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return [4 /*yield*/, IncrementalBinaryTreeLibFactory.deploy()];
|
|
107
|
+
pairingAddress = pairing.address;
|
|
108
|
+
_c.label = 4;
|
|
109
|
+
case 4: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier", {
|
|
110
|
+
libraries: {
|
|
111
|
+
Pairing: pairingAddress
|
|
112
|
+
}
|
|
113
|
+
})];
|
|
113
114
|
case 5:
|
|
114
|
-
|
|
115
|
-
return [4 /*yield*/,
|
|
115
|
+
SemaphoreVerifierFactory = _c.sent();
|
|
116
|
+
return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
|
|
116
117
|
case 6:
|
|
118
|
+
semaphoreVerifier = _c.sent();
|
|
119
|
+
return [4 /*yield*/, semaphoreVerifier.deployed()];
|
|
120
|
+
case 7:
|
|
117
121
|
_c.sent();
|
|
118
122
|
if (logs) {
|
|
119
|
-
console.info("
|
|
123
|
+
console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifier.address));
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
IncrementalBinaryTree: incrementalBinaryTreeLib.address
|
|
124
|
-
}
|
|
125
|
-
})];
|
|
126
|
-
case 7:
|
|
127
|
-
SemaphoreContractFactory = _c.sent();
|
|
128
|
-
return [4 /*yield*/, SemaphoreContractFactory.deploy(verifiers)];
|
|
125
|
+
semaphoreVerifierAddress = semaphoreVerifier.address;
|
|
126
|
+
_c.label = 8;
|
|
129
127
|
case 8:
|
|
130
|
-
|
|
131
|
-
return [
|
|
128
|
+
if (!!incrementalBinaryTreeAddress) return [3 /*break*/, 16];
|
|
129
|
+
if (!!poseidonAddress) return [3 /*break*/, 12];
|
|
130
|
+
poseidonABI = circomlibjs.poseidon_gencontract.generateABI(2);
|
|
131
|
+
poseidonBytecode = circomlibjs.poseidon_gencontract.createCode(2);
|
|
132
|
+
return [4 /*yield*/, ethers.getSigners()];
|
|
132
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:
|
|
133
141
|
_c.sent();
|
|
134
142
|
if (logs) {
|
|
135
|
-
console.info("
|
|
143
|
+
console.info("Poseidon library has been deployed to: ".concat(poseidon.address));
|
|
136
144
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
case
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
145
|
+
poseidonAddress = poseidon.address;
|
|
146
|
+
_c.label = 12;
|
|
147
|
+
case 12: return [4 /*yield*/, ethers.getContractFactory("IncrementalBinaryTree", {
|
|
148
|
+
libraries: {
|
|
149
|
+
PoseidonT3: poseidonAddress
|
|
150
|
+
}
|
|
151
|
+
})];
|
|
152
|
+
case 13:
|
|
153
|
+
IncrementalBinaryTreeFactory = _c.sent();
|
|
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();
|
|
172
|
+
return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
|
|
173
|
+
case 18:
|
|
174
|
+
semaphore = _c.sent();
|
|
175
|
+
return [4 /*yield*/, semaphore.deployed()];
|
|
176
|
+
case 19:
|
|
161
177
|
_c.sent();
|
|
162
178
|
if (logs) {
|
|
163
|
-
console.info("
|
|
179
|
+
console.info("Semaphore contract has been deployed to: ".concat(semaphore.address));
|
|
164
180
|
}
|
|
165
|
-
return [2 /*return*/,
|
|
181
|
+
return [2 /*return*/, {
|
|
182
|
+
semaphore: semaphore,
|
|
183
|
+
pairingAddress: pairingAddress,
|
|
184
|
+
semaphoreVerifierAddress: semaphoreVerifierAddress,
|
|
185
|
+
poseidonAddress: poseidonAddress,
|
|
186
|
+
incrementalBinaryTreeAddress: incrementalBinaryTreeAddress
|
|
187
|
+
}];
|
|
166
188
|
}
|
|
167
189
|
});
|
|
168
190
|
});
|
|
@@ -171,23 +193,8 @@ config.task("deploy:verifier", "Deploy a Verifier contract")
|
|
|
171
193
|
config.extendConfig(function (config, userConfig) {
|
|
172
194
|
var _a;
|
|
173
195
|
config.dependencyCompiler.paths = [
|
|
174
|
-
"@semaphore-protocol/contracts/
|
|
175
|
-
"@semaphore-protocol/contracts/
|
|
176
|
-
"@semaphore-protocol/contracts/verifiers/Verifier18.sol",
|
|
177
|
-
"@semaphore-protocol/contracts/verifiers/Verifier19.sol",
|
|
178
|
-
"@semaphore-protocol/contracts/verifiers/Verifier20.sol",
|
|
179
|
-
"@semaphore-protocol/contracts/verifiers/Verifier21.sol",
|
|
180
|
-
"@semaphore-protocol/contracts/verifiers/Verifier22.sol",
|
|
181
|
-
"@semaphore-protocol/contracts/verifiers/Verifier23.sol",
|
|
182
|
-
"@semaphore-protocol/contracts/verifiers/Verifier24.sol",
|
|
183
|
-
"@semaphore-protocol/contracts/verifiers/Verifier25.sol",
|
|
184
|
-
"@semaphore-protocol/contracts/verifiers/Verifier26.sol",
|
|
185
|
-
"@semaphore-protocol/contracts/verifiers/Verifier27.sol",
|
|
186
|
-
"@semaphore-protocol/contracts/verifiers/Verifier28.sol",
|
|
187
|
-
"@semaphore-protocol/contracts/verifiers/Verifier29.sol",
|
|
188
|
-
"@semaphore-protocol/contracts/verifiers/Verifier30.sol",
|
|
189
|
-
"@semaphore-protocol/contracts/verifiers/Verifier31.sol",
|
|
190
|
-
"@semaphore-protocol/contracts/verifiers/Verifier32.sol",
|
|
196
|
+
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
197
|
+
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
191
198
|
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
192
199
|
];
|
|
193
200
|
if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
|
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": "0.
|
|
3
|
+
"version": "3.0.0-beta.5",
|
|
4
4
|
"description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.node.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@nomiclabs/hardhat-ethers": "^2.1.1",
|
|
41
|
-
"@semaphore-protocol/contracts": "
|
|
41
|
+
"@semaphore-protocol/contracts": "3.0.0-beta.5",
|
|
42
42
|
"circomlibjs": "^0.0.8",
|
|
43
43
|
"ethers": "^5.7.1",
|
|
44
44
|
"hardhat-dependency-compiler": "^1.1.3"
|
package/src/index.ts
CHANGED
|
@@ -4,27 +4,11 @@ import { HardhatConfig, HardhatUserConfig } from "hardhat/types"
|
|
|
4
4
|
import "hardhat-dependency-compiler"
|
|
5
5
|
import "@nomiclabs/hardhat-ethers"
|
|
6
6
|
import "./tasks/deploy-semaphore"
|
|
7
|
-
import "./tasks/deploy-verifier"
|
|
8
7
|
|
|
9
8
|
extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
|
|
10
9
|
config.dependencyCompiler.paths = [
|
|
11
|
-
"@semaphore-protocol/contracts/
|
|
12
|
-
"@semaphore-protocol/contracts/
|
|
13
|
-
"@semaphore-protocol/contracts/verifiers/Verifier18.sol",
|
|
14
|
-
"@semaphore-protocol/contracts/verifiers/Verifier19.sol",
|
|
15
|
-
"@semaphore-protocol/contracts/verifiers/Verifier20.sol",
|
|
16
|
-
"@semaphore-protocol/contracts/verifiers/Verifier21.sol",
|
|
17
|
-
"@semaphore-protocol/contracts/verifiers/Verifier22.sol",
|
|
18
|
-
"@semaphore-protocol/contracts/verifiers/Verifier23.sol",
|
|
19
|
-
"@semaphore-protocol/contracts/verifiers/Verifier24.sol",
|
|
20
|
-
"@semaphore-protocol/contracts/verifiers/Verifier25.sol",
|
|
21
|
-
"@semaphore-protocol/contracts/verifiers/Verifier26.sol",
|
|
22
|
-
"@semaphore-protocol/contracts/verifiers/Verifier27.sol",
|
|
23
|
-
"@semaphore-protocol/contracts/verifiers/Verifier28.sol",
|
|
24
|
-
"@semaphore-protocol/contracts/verifiers/Verifier29.sol",
|
|
25
|
-
"@semaphore-protocol/contracts/verifiers/Verifier30.sol",
|
|
26
|
-
"@semaphore-protocol/contracts/verifiers/Verifier31.sol",
|
|
27
|
-
"@semaphore-protocol/contracts/verifiers/Verifier32.sol",
|
|
10
|
+
"@semaphore-protocol/contracts/base/Pairing.sol",
|
|
11
|
+
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
28
12
|
"@semaphore-protocol/contracts/Semaphore.sol"
|
|
29
13
|
]
|
|
30
14
|
|
|
@@ -1,51 +1,114 @@
|
|
|
1
1
|
import { poseidon_gencontract as poseidonContract } from "circomlibjs"
|
|
2
|
-
import { Contract } from "ethers"
|
|
3
2
|
import { task, types } from "hardhat/config"
|
|
4
3
|
|
|
5
4
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
6
|
-
.
|
|
5
|
+
.addOptionalParam<boolean>("pairing", "Pairing library address", undefined, types.string)
|
|
6
|
+
.addOptionalParam<boolean>("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
7
|
+
.addOptionalParam<boolean>("poseidon", "Poseidon library address", undefined, types.string)
|
|
8
|
+
.addOptionalParam<boolean>(
|
|
9
|
+
"incrementalBinaryTree",
|
|
10
|
+
"IncrementalBinaryTree library address",
|
|
11
|
+
undefined,
|
|
12
|
+
types.string
|
|
13
|
+
)
|
|
7
14
|
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
|
8
|
-
.setAction(
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
.setAction(
|
|
16
|
+
async (
|
|
17
|
+
{
|
|
18
|
+
logs,
|
|
19
|
+
pairing: pairingAddress,
|
|
20
|
+
semaphoreVerifier: semaphoreVerifierAddress,
|
|
21
|
+
poseidon: poseidonAddress,
|
|
22
|
+
incrementalBinaryTree: incrementalBinaryTreeAddress
|
|
23
|
+
},
|
|
24
|
+
{ ethers }
|
|
25
|
+
): Promise<any> => {
|
|
26
|
+
if (!semaphoreVerifierAddress) {
|
|
27
|
+
if (!pairingAddress) {
|
|
28
|
+
const PairingFactory = await ethers.getContractFactory("Pairing")
|
|
29
|
+
const pairing = await PairingFactory.deploy()
|
|
11
30
|
|
|
12
|
-
|
|
31
|
+
await pairing.deployed()
|
|
13
32
|
|
|
14
|
-
|
|
15
|
-
|
|
33
|
+
if (logs) {
|
|
34
|
+
console.info(`Pairing library has been deployed to: ${pairing.address}`)
|
|
35
|
+
}
|
|
16
36
|
|
|
17
|
-
|
|
37
|
+
pairingAddress = pairing.address
|
|
38
|
+
}
|
|
18
39
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
40
|
+
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier", {
|
|
41
|
+
libraries: {
|
|
42
|
+
Pairing: pairingAddress
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy()
|
|
47
|
+
|
|
48
|
+
await semaphoreVerifier.deployed()
|
|
22
49
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
50
|
+
if (logs) {
|
|
51
|
+
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.address}`)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
semaphoreVerifierAddress = semaphoreVerifier.address
|
|
26
55
|
}
|
|
27
|
-
})
|
|
28
|
-
const incrementalBinaryTreeLib = await IncrementalBinaryTreeLibFactory.deploy()
|
|
29
56
|
|
|
30
|
-
|
|
57
|
+
if (!incrementalBinaryTreeAddress) {
|
|
58
|
+
if (!poseidonAddress) {
|
|
59
|
+
const poseidonABI = poseidonContract.generateABI(2)
|
|
60
|
+
const poseidonBytecode = poseidonContract.createCode(2)
|
|
31
61
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
62
|
+
const [signer] = await ethers.getSigners()
|
|
63
|
+
|
|
64
|
+
const PoseidonFactory = new ethers.ContractFactory(poseidonABI, poseidonBytecode, signer)
|
|
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
|
+
}
|
|
35
75
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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()
|
|
84
|
+
|
|
85
|
+
if (logs) {
|
|
86
|
+
console.info(`IncrementalBinaryTree library has been deployed to: ${incrementalBinaryTree.address}`)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
incrementalBinaryTreeAddress = incrementalBinaryTree.address
|
|
39
90
|
}
|
|
40
|
-
})
|
|
41
91
|
|
|
42
|
-
|
|
92
|
+
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
|
93
|
+
libraries: {
|
|
94
|
+
IncrementalBinaryTree: incrementalBinaryTreeAddress
|
|
95
|
+
}
|
|
96
|
+
})
|
|
43
97
|
|
|
44
|
-
|
|
98
|
+
const semaphore = await SemaphoreFactory.deploy(semaphoreVerifierAddress)
|
|
45
99
|
|
|
46
|
-
|
|
47
|
-
console.info(`Semaphore contract has been deployed to: ${semaphoreContract.address}`)
|
|
48
|
-
}
|
|
100
|
+
await semaphore.deployed()
|
|
49
101
|
|
|
50
|
-
|
|
51
|
-
|
|
102
|
+
if (logs) {
|
|
103
|
+
console.info(`Semaphore contract has been deployed to: ${semaphore.address}`)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
semaphore,
|
|
108
|
+
pairingAddress,
|
|
109
|
+
semaphoreVerifierAddress,
|
|
110
|
+
poseidonAddress,
|
|
111
|
+
incrementalBinaryTreeAddress
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Contract } from "ethers"
|
|
2
|
-
import { task, types } from "hardhat/config"
|
|
3
|
-
|
|
4
|
-
task("deploy:verifier", "Deploy a Verifier contract")
|
|
5
|
-
.addParam<number>("merkleTreeDepth", "Merkle tree depth", undefined, types.int)
|
|
6
|
-
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
|
7
|
-
.setAction(async ({ merkleTreeDepth, logs }, { ethers }): Promise<Contract> => {
|
|
8
|
-
const VerifierContractFactory = await ethers.getContractFactory(`Verifier${merkleTreeDepth}`)
|
|
9
|
-
|
|
10
|
-
const verifierContract = await VerifierContractFactory.deploy()
|
|
11
|
-
|
|
12
|
-
await verifierContract.deployed()
|
|
13
|
-
|
|
14
|
-
if (logs) {
|
|
15
|
-
console.info(`Verifier${merkleTreeDepth} contract has been deployed to: ${verifierContract.address}`)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return verifierContract
|
|
19
|
-
})
|