@semaphore-protocol/hardhat 4.0.0-beta.4 → 4.0.0-beta.6

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.
Files changed (3) hide show
  1. package/dist/index.cjs +44 -139
  2. package/dist/index.js +44 -139
  3. package/package.json +2 -2
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/hardhat
3
- * @version 4.0.0-beta.4
3
+ * @version 4.0.0-beta.6
4
4
  * @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -12,158 +12,63 @@ var config = require('hardhat/config');
12
12
  require('hardhat-dependency-compiler');
13
13
  require('@nomicfoundation/hardhat-ethers');
14
14
 
15
- function __awaiter(thisArg, _arguments, P, generator) {
16
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
- return new (P || (P = Promise))(function (resolve, reject) {
18
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
- step((generator = generator.apply(thisArg, _arguments || [])).next());
22
- });
23
- }
24
- function __generator(thisArg, body) {
25
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
- function verb(n) { return function (v) { return step([n, v]); }; }
28
- function step(op) {
29
- if (f) throw new TypeError("Generator is already executing.");
30
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
31
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
- if (y = 0, t) op = [op[0] & 2, t.value];
33
- switch (op[0]) {
34
- case 0: case 1: t = op; break;
35
- case 4: _.label++; return { value: op[1], done: false };
36
- case 5: _.label++; y = op[1]; op = [0]; continue;
37
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
- default:
39
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
- if (t[2]) _.ops.pop();
44
- _.trys.pop(); continue;
45
- }
46
- op = body.call(thisArg, _);
47
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
- }
50
- }
51
- function __spreadArray(to, from, pack) {
52
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
53
- if (ar || !(i in from)) {
54
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
55
- ar[i] = from[i];
56
- }
57
- }
58
- return to.concat(ar || Array.prototype.slice.call(from));
59
- }
60
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
61
- var e = new Error(message);
62
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
63
- };
64
-
65
15
  config.task("deploy:semaphore", "Deploy a Semaphore contract")
66
16
  .addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, config.types.string)
67
17
  .addOptionalParam("poseidon", "Poseidon library address", undefined, config.types.string)
68
18
  .addOptionalParam("logs", "Print the logs", true, config.types.boolean)
69
- .setAction(function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
70
- var SemaphoreVerifierFactory, semaphoreVerifier, PoseidonT3Factory, poseidonT3, SemaphoreFactory, semaphore, _e, _f, _g;
71
- var logs = _c.logs, semaphoreVerifierAddress = _c.semaphoreVerifier, poseidonAddress = _c.poseidon;
72
- var ethers = _d.ethers;
73
- return __generator(this, function (_h) {
74
- switch (_h.label) {
75
- case 0:
76
- if (!!semaphoreVerifierAddress) return [3 /*break*/, 4];
77
- return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
78
- case 1:
79
- SemaphoreVerifierFactory = _h.sent();
80
- return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
81
- case 2:
82
- semaphoreVerifier = _h.sent();
83
- return [4 /*yield*/, semaphoreVerifier.getAddress()];
84
- case 3:
85
- semaphoreVerifierAddress = _h.sent();
86
- if (logs) {
87
- console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifierAddress));
88
- }
89
- _h.label = 4;
90
- case 4:
91
- if (!!poseidonAddress) return [3 /*break*/, 8];
92
- return [4 /*yield*/, ethers.getContractFactory("PoseidonT3")];
93
- case 5:
94
- PoseidonT3Factory = _h.sent();
95
- return [4 /*yield*/, PoseidonT3Factory.deploy()];
96
- case 6:
97
- poseidonT3 = _h.sent();
98
- return [4 /*yield*/, poseidonT3.getAddress()];
99
- case 7:
100
- poseidonAddress = _h.sent();
101
- if (logs) {
102
- console.info("Poseidon library has been deployed to: ".concat(poseidonAddress));
103
- }
104
- _h.label = 8;
105
- case 8: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
106
- libraries: {
107
- PoseidonT3: poseidonAddress
108
- }
109
- })];
110
- case 9:
111
- SemaphoreFactory = _h.sent();
112
- return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
113
- case 10:
114
- semaphore = _h.sent();
115
- if (!logs) return [3 /*break*/, 12];
116
- _f = (_e = console).info;
117
- _g = "Semaphore contract has been deployed to: ".concat;
118
- return [4 /*yield*/, semaphore.getAddress()];
119
- case 11:
120
- _f.apply(_e, [_g.apply("Semaphore contract has been deployed to: ", [_h.sent()])]);
121
- _h.label = 12;
122
- case 12: return [2 /*return*/, {
123
- semaphore: semaphore,
124
- semaphoreVerifierAddress: semaphoreVerifierAddress,
125
- poseidonAddress: poseidonAddress
126
- }];
19
+ .setAction(async ({ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress }, { ethers }) => {
20
+ if (!semaphoreVerifierAddress) {
21
+ const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
22
+ const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
23
+ semaphoreVerifierAddress = await semaphoreVerifier.getAddress();
24
+ if (logs) {
25
+ console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`);
26
+ }
27
+ }
28
+ if (!poseidonAddress) {
29
+ const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3");
30
+ const poseidonT3 = await PoseidonT3Factory.deploy();
31
+ poseidonAddress = await poseidonT3.getAddress();
32
+ if (logs) {
33
+ console.info(`Poseidon library has been deployed to: ${poseidonAddress}`);
34
+ }
35
+ }
36
+ const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
37
+ libraries: {
38
+ PoseidonT3: poseidonAddress
127
39
  }
128
40
  });
129
- }); });
41
+ const semaphore = await SemaphoreFactory.deploy(semaphoreVerifierAddress);
42
+ if (logs) {
43
+ console.info(`Semaphore contract has been deployed to: ${await semaphore.getAddress()}`);
44
+ }
45
+ return {
46
+ semaphore,
47
+ semaphoreVerifierAddress,
48
+ poseidonAddress
49
+ };
50
+ });
130
51
 
131
52
  config.task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
132
53
  .addOptionalParam("logs", "Print the logs", true, config.types.boolean)
133
- .setAction(function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
134
- var SemaphoreVerifierFactory, semaphoreVerifier, _e, _f, _g;
135
- var logs = _c.logs;
136
- var ethers = _d.ethers;
137
- return __generator(this, function (_h) {
138
- switch (_h.label) {
139
- case 0: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
140
- case 1:
141
- SemaphoreVerifierFactory = _h.sent();
142
- return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
143
- case 2:
144
- semaphoreVerifier = _h.sent();
145
- if (!logs) return [3 /*break*/, 4];
146
- _f = (_e = console).info;
147
- _g = "SemaphoreVerifier contract has been deployed to: ".concat;
148
- return [4 /*yield*/, semaphoreVerifier.getAddress()];
149
- case 3:
150
- _f.apply(_e, [_g.apply("SemaphoreVerifier contract has been deployed to: ", [_h.sent()])]);
151
- _h.label = 4;
152
- case 4: return [2 /*return*/, {
153
- semaphoreVerifier: semaphoreVerifier
154
- }];
155
- }
156
- });
157
- }); });
54
+ .setAction(async ({ logs }, { ethers }) => {
55
+ const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
56
+ const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
57
+ if (logs) {
58
+ console.info(`SemaphoreVerifier contract has been deployed to: ${await semaphoreVerifier.getAddress()}`);
59
+ }
60
+ return {
61
+ semaphoreVerifier
62
+ };
63
+ });
158
64
 
159
- config.extendConfig(function (config, userConfig) {
160
- var _a;
65
+ config.extendConfig((config, userConfig) => {
161
66
  config.dependencyCompiler.paths = [
162
67
  "@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
163
68
  "@semaphore-protocol/contracts/Semaphore.sol",
164
69
  "poseidon-solidity/PoseidonT3.sol"
165
70
  ];
166
- if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
167
- config.dependencyCompiler.paths = __spreadArray(__spreadArray([], config.dependencyCompiler.paths, true), userConfig.dependencyCompiler.paths, true);
71
+ if (userConfig.dependencyCompiler?.paths) {
72
+ config.dependencyCompiler.paths = [...config.dependencyCompiler.paths, ...userConfig.dependencyCompiler.paths];
168
73
  }
169
74
  });
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @module @semaphore-protocol/hardhat
3
- * @version 4.0.0-beta.4
3
+ * @version 4.0.0-beta.6
4
4
  * @file A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.
5
5
  * @copyright Ethereum Foundation 2024
6
6
  * @license MIT
@@ -10,158 +10,63 @@ import { task, types, extendConfig } from 'hardhat/config';
10
10
  import 'hardhat-dependency-compiler';
11
11
  import '@nomicfoundation/hardhat-ethers';
12
12
 
13
- function __awaiter(thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- }
22
- function __generator(thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- }
49
- function __spreadArray(to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- }
58
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
59
- var e = new Error(message);
60
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
61
- };
62
-
63
13
  task("deploy:semaphore", "Deploy a Semaphore contract")
64
14
  .addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
65
15
  .addOptionalParam("poseidon", "Poseidon library address", undefined, types.string)
66
16
  .addOptionalParam("logs", "Print the logs", true, types.boolean)
67
- .setAction(function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
68
- var SemaphoreVerifierFactory, semaphoreVerifier, PoseidonT3Factory, poseidonT3, SemaphoreFactory, semaphore, _e, _f, _g;
69
- var logs = _c.logs, semaphoreVerifierAddress = _c.semaphoreVerifier, poseidonAddress = _c.poseidon;
70
- var ethers = _d.ethers;
71
- return __generator(this, function (_h) {
72
- switch (_h.label) {
73
- case 0:
74
- if (!!semaphoreVerifierAddress) return [3 /*break*/, 4];
75
- return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
76
- case 1:
77
- SemaphoreVerifierFactory = _h.sent();
78
- return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
79
- case 2:
80
- semaphoreVerifier = _h.sent();
81
- return [4 /*yield*/, semaphoreVerifier.getAddress()];
82
- case 3:
83
- semaphoreVerifierAddress = _h.sent();
84
- if (logs) {
85
- console.info("SemaphoreVerifier contract has been deployed to: ".concat(semaphoreVerifierAddress));
86
- }
87
- _h.label = 4;
88
- case 4:
89
- if (!!poseidonAddress) return [3 /*break*/, 8];
90
- return [4 /*yield*/, ethers.getContractFactory("PoseidonT3")];
91
- case 5:
92
- PoseidonT3Factory = _h.sent();
93
- return [4 /*yield*/, PoseidonT3Factory.deploy()];
94
- case 6:
95
- poseidonT3 = _h.sent();
96
- return [4 /*yield*/, poseidonT3.getAddress()];
97
- case 7:
98
- poseidonAddress = _h.sent();
99
- if (logs) {
100
- console.info("Poseidon library has been deployed to: ".concat(poseidonAddress));
101
- }
102
- _h.label = 8;
103
- case 8: return [4 /*yield*/, ethers.getContractFactory("Semaphore", {
104
- libraries: {
105
- PoseidonT3: poseidonAddress
106
- }
107
- })];
108
- case 9:
109
- SemaphoreFactory = _h.sent();
110
- return [4 /*yield*/, SemaphoreFactory.deploy(semaphoreVerifierAddress)];
111
- case 10:
112
- semaphore = _h.sent();
113
- if (!logs) return [3 /*break*/, 12];
114
- _f = (_e = console).info;
115
- _g = "Semaphore contract has been deployed to: ".concat;
116
- return [4 /*yield*/, semaphore.getAddress()];
117
- case 11:
118
- _f.apply(_e, [_g.apply("Semaphore contract has been deployed to: ", [_h.sent()])]);
119
- _h.label = 12;
120
- case 12: return [2 /*return*/, {
121
- semaphore: semaphore,
122
- semaphoreVerifierAddress: semaphoreVerifierAddress,
123
- poseidonAddress: poseidonAddress
124
- }];
17
+ .setAction(async ({ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress }, { ethers }) => {
18
+ if (!semaphoreVerifierAddress) {
19
+ const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
20
+ const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
21
+ semaphoreVerifierAddress = await semaphoreVerifier.getAddress();
22
+ if (logs) {
23
+ console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`);
24
+ }
25
+ }
26
+ if (!poseidonAddress) {
27
+ const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3");
28
+ const poseidonT3 = await PoseidonT3Factory.deploy();
29
+ poseidonAddress = await poseidonT3.getAddress();
30
+ if (logs) {
31
+ console.info(`Poseidon library has been deployed to: ${poseidonAddress}`);
32
+ }
33
+ }
34
+ const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
35
+ libraries: {
36
+ PoseidonT3: poseidonAddress
125
37
  }
126
38
  });
127
- }); });
39
+ const semaphore = await SemaphoreFactory.deploy(semaphoreVerifierAddress);
40
+ if (logs) {
41
+ console.info(`Semaphore contract has been deployed to: ${await semaphore.getAddress()}`);
42
+ }
43
+ return {
44
+ semaphore,
45
+ semaphoreVerifierAddress,
46
+ poseidonAddress
47
+ };
48
+ });
128
49
 
129
50
  task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
130
51
  .addOptionalParam("logs", "Print the logs", true, types.boolean)
131
- .setAction(function (_a, _b) { return __awaiter(void 0, [_a, _b], void 0, function (_c, _d) {
132
- var SemaphoreVerifierFactory, semaphoreVerifier, _e, _f, _g;
133
- var logs = _c.logs;
134
- var ethers = _d.ethers;
135
- return __generator(this, function (_h) {
136
- switch (_h.label) {
137
- case 0: return [4 /*yield*/, ethers.getContractFactory("SemaphoreVerifier")];
138
- case 1:
139
- SemaphoreVerifierFactory = _h.sent();
140
- return [4 /*yield*/, SemaphoreVerifierFactory.deploy()];
141
- case 2:
142
- semaphoreVerifier = _h.sent();
143
- if (!logs) return [3 /*break*/, 4];
144
- _f = (_e = console).info;
145
- _g = "SemaphoreVerifier contract has been deployed to: ".concat;
146
- return [4 /*yield*/, semaphoreVerifier.getAddress()];
147
- case 3:
148
- _f.apply(_e, [_g.apply("SemaphoreVerifier contract has been deployed to: ", [_h.sent()])]);
149
- _h.label = 4;
150
- case 4: return [2 /*return*/, {
151
- semaphoreVerifier: semaphoreVerifier
152
- }];
153
- }
154
- });
155
- }); });
52
+ .setAction(async ({ logs }, { ethers }) => {
53
+ const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
54
+ const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
55
+ if (logs) {
56
+ console.info(`SemaphoreVerifier contract has been deployed to: ${await semaphoreVerifier.getAddress()}`);
57
+ }
58
+ return {
59
+ semaphoreVerifier
60
+ };
61
+ });
156
62
 
157
- extendConfig(function (config, userConfig) {
158
- var _a;
63
+ extendConfig((config, userConfig) => {
159
64
  config.dependencyCompiler.paths = [
160
65
  "@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
161
66
  "@semaphore-protocol/contracts/Semaphore.sol",
162
67
  "poseidon-solidity/PoseidonT3.sol"
163
68
  ];
164
- if ((_a = userConfig.dependencyCompiler) === null || _a === void 0 ? void 0 : _a.paths) {
165
- config.dependencyCompiler.paths = __spreadArray(__spreadArray([], config.dependencyCompiler.paths, true), userConfig.dependencyCompiler.paths, true);
69
+ if (userConfig.dependencyCompiler?.paths) {
70
+ config.dependencyCompiler.paths = [...config.dependencyCompiler.paths, ...userConfig.dependencyCompiler.paths];
166
71
  }
167
72
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@semaphore-protocol/hardhat",
3
- "version": "4.0.0-beta.4",
3
+ "version": "4.0.0-beta.6",
4
4
  "description": "A Semaphore Hardhat plugin to deploy verifiers and Semaphore contract.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@nomicfoundation/hardhat-ethers": "^3.0.0",
44
- "@semaphore-protocol/contracts": "4.0.0-beta.4",
44
+ "@semaphore-protocol/contracts": "4.0.0-beta.6",
45
45
  "ethers": "^6.4.0",
46
46
  "hardhat-dependency-compiler": "^1.1.3"
47
47
  }