@semaphore-protocol/hardhat 4.0.0-beta.9 → 4.0.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/README.md +15 -5
- package/dist/index.cjs +21 -2
- package/dist/index.js +21 -2
- package/package.json +3 -3
- package/src/index.ts +8 -0
- package/src/tasks/deploy-semaphore-verifier.ts +4 -0
- package/src/tasks/deploy-semaphore.ts +7 -0
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<h1 align="center">
|
|
3
3
|
Semaphore Hardhat plugin
|
|
4
4
|
</h1>
|
|
5
|
-
<p align="center">A
|
|
5
|
+
<p align="center">A Hardhat plugin to deploy Semaphore contracts.</p>
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
@@ -46,14 +46,14 @@
|
|
|
46
46
|
</h4>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
49
|
+
| The Semaphore Hardhat plugin simplifies the deployment of Semaphore contracts, reducing setup time and complexity. |
|
|
50
|
+
| ------------------------------------------------------------------------------------------------------------------ |
|
|
51
51
|
|
|
52
52
|
## 🛠 Install
|
|
53
53
|
|
|
54
54
|
### npm or yarn
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
To install the Semaphore Hardhat plugin, use npm or yarn:
|
|
57
57
|
|
|
58
58
|
```bash
|
|
59
59
|
npm i @semaphore-protocol/hardhat
|
|
@@ -67,7 +67,7 @@ yarn add @semaphore-protocol/hardhat
|
|
|
67
67
|
|
|
68
68
|
## 📜 Usage
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
To use the plugin, import it in your Hardhat configuration file (`hardhat.config.ts`):
|
|
71
71
|
|
|
72
72
|
```typescript
|
|
73
73
|
import "@semaphore-protocol/hardhat"
|
|
@@ -110,3 +110,13 @@ task("deploy", "Deploy a Greeter contract")
|
|
|
110
110
|
return greeter
|
|
111
111
|
})
|
|
112
112
|
```
|
|
113
|
+
|
|
114
|
+
### Deploying Contracts
|
|
115
|
+
|
|
116
|
+
Use the provided tasks to deploy your Semaphore contracts:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
npx hardhat deploy
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This command will deploy a Semaphore contract using the addresses provided or deploy necessary dependencies like Semaphore Verifier and Poseidon library.
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version 4.0.
|
|
4
|
-
* @file A
|
|
3
|
+
* @version 4.0.1
|
|
4
|
+
* @file A Hardhat plugin to deploy Semaphore contracts.
|
|
5
5
|
* @copyright Ethereum Foundation 2024
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/hardhat}
|
|
@@ -12,11 +12,16 @@ var config = require('hardhat/config');
|
|
|
12
12
|
require('hardhat-dependency-compiler');
|
|
13
13
|
require('@nomicfoundation/hardhat-ethers');
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Defines a Hardhat task to deploy the Semaphore contract.
|
|
17
|
+
* This task handles the deployment of dependent contracts like SemaphoreVerifier and PoseidonT3 if not provided.
|
|
18
|
+
*/
|
|
15
19
|
config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
16
20
|
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, config.types.string)
|
|
17
21
|
.addOptionalParam("poseidon", "Poseidon library address", undefined, config.types.string)
|
|
18
22
|
.addOptionalParam("logs", "Print the logs", true, config.types.boolean)
|
|
19
23
|
.setAction(async ({ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress }, { ethers }) => {
|
|
24
|
+
// Deploy SemaphoreVerifier if not provided.
|
|
20
25
|
if (!semaphoreVerifierAddress) {
|
|
21
26
|
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
|
|
22
27
|
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
|
|
@@ -25,6 +30,7 @@ config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
25
30
|
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`);
|
|
26
31
|
}
|
|
27
32
|
}
|
|
33
|
+
// Deploy PoseidonT3 if not provided.
|
|
28
34
|
if (!poseidonAddress) {
|
|
29
35
|
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3");
|
|
30
36
|
const poseidonT3 = await PoseidonT3Factory.deploy();
|
|
@@ -33,6 +39,7 @@ config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
33
39
|
console.info(`Poseidon library has been deployed to: ${poseidonAddress}`);
|
|
34
40
|
}
|
|
35
41
|
}
|
|
42
|
+
// Deploy the Semaphore contract with the necessary library.
|
|
36
43
|
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
|
37
44
|
libraries: {
|
|
38
45
|
PoseidonT3: poseidonAddress
|
|
@@ -49,6 +56,10 @@ config.task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
49
56
|
};
|
|
50
57
|
});
|
|
51
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Defines a Hardhat task to deploy the SemaphoreVerifier contract.
|
|
61
|
+
* This task can optionally log the deployment address.
|
|
62
|
+
*/
|
|
52
63
|
config.task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
53
64
|
.addOptionalParam("logs", "Print the logs", true, config.types.boolean)
|
|
54
65
|
.setAction(async ({ logs }, { ethers }) => {
|
|
@@ -62,12 +73,20 @@ config.task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
|
62
73
|
};
|
|
63
74
|
});
|
|
64
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Extends the Hardhat configuration to include paths for dependency compilation.
|
|
78
|
+
* This setup ensures that specific contracts are pre-compiled, optimizing the deployment process.
|
|
79
|
+
* @param config The Hardhat configuration object that is being extended.
|
|
80
|
+
* @param userConfig The user-provided configuration, if any, which may override or extend the default settings.
|
|
81
|
+
*/
|
|
65
82
|
config.extendConfig((config, userConfig) => {
|
|
83
|
+
// Default paths for contracts that need to be compiled before deployment.
|
|
66
84
|
config.dependencyCompiler.paths = [
|
|
67
85
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
68
86
|
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
69
87
|
"poseidon-solidity/PoseidonT3.sol"
|
|
70
88
|
];
|
|
89
|
+
// Merge user-specified paths with the default paths.
|
|
71
90
|
if (userConfig.dependencyCompiler?.paths) {
|
|
72
91
|
config.dependencyCompiler.paths = [...config.dependencyCompiler.paths, ...userConfig.dependencyCompiler.paths];
|
|
73
92
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module @semaphore-protocol/hardhat
|
|
3
|
-
* @version 4.0.
|
|
4
|
-
* @file A
|
|
3
|
+
* @version 4.0.1
|
|
4
|
+
* @file A Hardhat plugin to deploy Semaphore contracts.
|
|
5
5
|
* @copyright Ethereum Foundation 2024
|
|
6
6
|
* @license MIT
|
|
7
7
|
* @see [Github]{@link https://github.com/semaphore-protocol/semaphore/tree/main/packages/hardhat}
|
|
@@ -10,11 +10,16 @@ import { task, types, extendConfig } from 'hardhat/config';
|
|
|
10
10
|
import 'hardhat-dependency-compiler';
|
|
11
11
|
import '@nomicfoundation/hardhat-ethers';
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Defines a Hardhat task to deploy the Semaphore contract.
|
|
15
|
+
* This task handles the deployment of dependent contracts like SemaphoreVerifier and PoseidonT3 if not provided.
|
|
16
|
+
*/
|
|
13
17
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
14
18
|
.addOptionalParam("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
15
19
|
.addOptionalParam("poseidon", "Poseidon library address", undefined, types.string)
|
|
16
20
|
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
|
17
21
|
.setAction(async ({ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress }, { ethers }) => {
|
|
22
|
+
// Deploy SemaphoreVerifier if not provided.
|
|
18
23
|
if (!semaphoreVerifierAddress) {
|
|
19
24
|
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier");
|
|
20
25
|
const semaphoreVerifier = await SemaphoreVerifierFactory.deploy();
|
|
@@ -23,6 +28,7 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
23
28
|
console.info(`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifierAddress}`);
|
|
24
29
|
}
|
|
25
30
|
}
|
|
31
|
+
// Deploy PoseidonT3 if not provided.
|
|
26
32
|
if (!poseidonAddress) {
|
|
27
33
|
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3");
|
|
28
34
|
const poseidonT3 = await PoseidonT3Factory.deploy();
|
|
@@ -31,6 +37,7 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
31
37
|
console.info(`Poseidon library has been deployed to: ${poseidonAddress}`);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
40
|
+
// Deploy the Semaphore contract with the necessary library.
|
|
34
41
|
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
|
35
42
|
libraries: {
|
|
36
43
|
PoseidonT3: poseidonAddress
|
|
@@ -47,6 +54,10 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
47
54
|
};
|
|
48
55
|
});
|
|
49
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Defines a Hardhat task to deploy the SemaphoreVerifier contract.
|
|
59
|
+
* This task can optionally log the deployment address.
|
|
60
|
+
*/
|
|
50
61
|
task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
51
62
|
.addOptionalParam("logs", "Print the logs", true, types.boolean)
|
|
52
63
|
.setAction(async ({ logs }, { ethers }) => {
|
|
@@ -60,12 +71,20 @@ task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
|
60
71
|
};
|
|
61
72
|
});
|
|
62
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Extends the Hardhat configuration to include paths for dependency compilation.
|
|
76
|
+
* This setup ensures that specific contracts are pre-compiled, optimizing the deployment process.
|
|
77
|
+
* @param config The Hardhat configuration object that is being extended.
|
|
78
|
+
* @param userConfig The user-provided configuration, if any, which may override or extend the default settings.
|
|
79
|
+
*/
|
|
63
80
|
extendConfig((config, userConfig) => {
|
|
81
|
+
// Default paths for contracts that need to be compiled before deployment.
|
|
64
82
|
config.dependencyCompiler.paths = [
|
|
65
83
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
66
84
|
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
67
85
|
"poseidon-solidity/PoseidonT3.sol"
|
|
68
86
|
];
|
|
87
|
+
// Merge user-specified paths with the default paths.
|
|
69
88
|
if (userConfig.dependencyCompiler?.paths) {
|
|
70
89
|
config.dependencyCompiler.paths = [...config.dependencyCompiler.paths, ...userConfig.dependencyCompiler.paths];
|
|
71
90
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semaphore-protocol/hardhat",
|
|
3
|
-
"version": "4.0.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"description": "A Hardhat plugin to deploy Semaphore contracts.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@nomicfoundation/hardhat-ethers": "^3.0.0",
|
|
44
|
-
"@semaphore-protocol/contracts": "4.0.
|
|
44
|
+
"@semaphore-protocol/contracts": "4.0.1",
|
|
45
45
|
"ethers": "^6.4.0",
|
|
46
46
|
"hardhat-dependency-compiler": "^1.1.3"
|
|
47
47
|
}
|
package/src/index.ts
CHANGED
|
@@ -6,13 +6,21 @@ import "@nomicfoundation/hardhat-ethers"
|
|
|
6
6
|
import "./tasks/deploy-semaphore"
|
|
7
7
|
import "./tasks/deploy-semaphore-verifier"
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Extends the Hardhat configuration to include paths for dependency compilation.
|
|
11
|
+
* This setup ensures that specific contracts are pre-compiled, optimizing the deployment process.
|
|
12
|
+
* @param config The Hardhat configuration object that is being extended.
|
|
13
|
+
* @param userConfig The user-provided configuration, if any, which may override or extend the default settings.
|
|
14
|
+
*/
|
|
9
15
|
extendConfig((config: HardhatConfig, userConfig: Readonly<HardhatUserConfig>) => {
|
|
16
|
+
// Default paths for contracts that need to be compiled before deployment.
|
|
10
17
|
config.dependencyCompiler.paths = [
|
|
11
18
|
"@semaphore-protocol/contracts/base/SemaphoreVerifier.sol",
|
|
12
19
|
"@semaphore-protocol/contracts/Semaphore.sol",
|
|
13
20
|
"poseidon-solidity/PoseidonT3.sol"
|
|
14
21
|
]
|
|
15
22
|
|
|
23
|
+
// Merge user-specified paths with the default paths.
|
|
16
24
|
if (userConfig.dependencyCompiler?.paths) {
|
|
17
25
|
config.dependencyCompiler.paths = [...config.dependencyCompiler.paths, ...userConfig.dependencyCompiler.paths]
|
|
18
26
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { task, types } from "hardhat/config"
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Defines a Hardhat task to deploy the SemaphoreVerifier contract.
|
|
5
|
+
* This task can optionally log the deployment address.
|
|
6
|
+
*/
|
|
3
7
|
task("deploy:semaphore-verifier", "Deploy a SemaphoreVerifier contract")
|
|
4
8
|
.addOptionalParam<boolean>("logs", "Print the logs", true, types.boolean)
|
|
5
9
|
.setAction(async ({ logs }, { ethers }): Promise<any> => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { task, types } from "hardhat/config"
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Defines a Hardhat task to deploy the Semaphore contract.
|
|
5
|
+
* This task handles the deployment of dependent contracts like SemaphoreVerifier and PoseidonT3 if not provided.
|
|
6
|
+
*/
|
|
3
7
|
task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
4
8
|
.addOptionalParam<boolean>("semaphoreVerifier", "SemaphoreVerifier contract address", undefined, types.string)
|
|
5
9
|
.addOptionalParam<boolean>("poseidon", "Poseidon library address", undefined, types.string)
|
|
@@ -9,6 +13,7 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
9
13
|
{ logs, semaphoreVerifier: semaphoreVerifierAddress, poseidon: poseidonAddress },
|
|
10
14
|
{ ethers }
|
|
11
15
|
): Promise<any> => {
|
|
16
|
+
// Deploy SemaphoreVerifier if not provided.
|
|
12
17
|
if (!semaphoreVerifierAddress) {
|
|
13
18
|
const SemaphoreVerifierFactory = await ethers.getContractFactory("SemaphoreVerifier")
|
|
14
19
|
|
|
@@ -21,6 +26,7 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
21
26
|
}
|
|
22
27
|
}
|
|
23
28
|
|
|
29
|
+
// Deploy PoseidonT3 if not provided.
|
|
24
30
|
if (!poseidonAddress) {
|
|
25
31
|
const PoseidonT3Factory = await ethers.getContractFactory("PoseidonT3")
|
|
26
32
|
const poseidonT3 = await PoseidonT3Factory.deploy()
|
|
@@ -32,6 +38,7 @@ task("deploy:semaphore", "Deploy a Semaphore contract")
|
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
|
|
41
|
+
// Deploy the Semaphore contract with the necessary library.
|
|
35
42
|
const SemaphoreFactory = await ethers.getContractFactory("Semaphore", {
|
|
36
43
|
libraries: {
|
|
37
44
|
PoseidonT3: poseidonAddress
|