-
Notifications
You must be signed in to change notification settings - Fork 71
/
Copy pathdeploy-bandada-semaphore.ts
89 lines (74 loc) · 2.57 KB
/
deploy-bandada-semaphore.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Contract } from "ethers"
import { task, types } from "hardhat/config"
task("deploy:bandada-semaphore", "Deploy a BandadaSemaphore contract")
.addOptionalParam("logs", "Print the logs", true, types.boolean)
.addOptionalParam(
"bandada",
"Bandada contract address",
undefined,
types.string
)
.addOptionalParam(
"semaphoreVerifier",
"SemaphoreVerifier contract address",
undefined,
types.string
)
.setAction(
async (
{
logs,
bandada: bandadaAddress,
semaphoreVerifier: semaphoreVerifierAddress
},
{ ethers, run }
): Promise<Contract> => {
if (!semaphoreVerifierAddress) {
const PairingFactory = await ethers.getContractFactory(
"Pairing"
)
const pairing = await PairingFactory.deploy()
await pairing.deployed()
if (logs) {
console.info(
`Pairing library has been deployed to: ${pairing.address}`
)
}
const SemaphoreVerifierFactory =
await ethers.getContractFactory("SemaphoreVerifier", {
libraries: {
Pairing: pairing.address
}
})
const semaphoreVerifier =
await SemaphoreVerifierFactory.deploy()
await semaphoreVerifier.deployed()
if (logs) {
console.info(
`SemaphoreVerifier contract has been deployed to: ${semaphoreVerifier.address}`
)
}
semaphoreVerifierAddress = semaphoreVerifier.address
}
if (!bandadaAddress) {
const bandada = await run("deploy:bandada", {
logs
})
bandadaAddress = bandada.address
}
const ContractFactory = await ethers.getContractFactory(
"BandadaSemaphore"
)
const contract = await ContractFactory.deploy(
semaphoreVerifierAddress,
bandadaAddress
)
await contract.deployed()
if (logs) {
console.info(
`BandadaSemaphore contract has been deployed to: ${contract.address}`
)
}
return contract
}
)