-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Expand file tree
/
Copy pathaddPausers.ts
More file actions
38 lines (31 loc) · 1.6 KB
/
addPausers.ts
File metadata and controls
38 lines (31 loc) · 1.6 KB
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
import { task, types } from "hardhat/config";
import { getRequiredEnvVar, loadGatewayAddresses } from "./utils/loadVariables";
// Add pausers to the PauserSet contract
// Note: Internal PauserSet address is defined in the `addresses/` directory. It should be used
// for local testing. By default, we use the PAUSER_SET_ADDRESS env var, as done in deployment
task("task:addGatewayPausers")
.addParam("useInternalProxyAddress", "If proxy address from the /addresses directory should be used", false, types.boolean)
.setAction(async function ({ useInternalProxyAddress }, hre) {
await hre.run("compile:specific", { contract: "contracts/immutable" });
console.log("Adding pausers to PauserSet contract");
const deployerPrivateKey = getRequiredEnvVar("DEPLOYER_PRIVATE_KEY");
const numPausers = parseInt(getRequiredEnvVar("NUM_PAUSERS"));
const deployer = new hre.ethers.Wallet(deployerPrivateKey).connect(hre.ethers.provider);
// Parse the pauser(s)
const pausers = [];
for (let idx = 0; idx < numPausers; idx++) {
pausers.push(getRequiredEnvVar(`PAUSER_ADDRESS_${idx}`));
}
if (useInternalProxyAddress) {
loadGatewayAddresses();
}
const pauserSetAddress = getRequiredEnvVar("PAUSER_SET_ADDRESS");
// Add pauser(s)
const pauserSet = await hre.ethers.getContractAt("PauserSet", pauserSetAddress, deployer);
for (const pauser of pausers) {
await pauserSet.addPauser(pauser);
}
console.log("In PauserSet contract:", pauserSetAddress, "\n");
console.log("Added pausers:", pausers, "\n");
console.log("Pausers registration done!");
});