-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathdeployVeVirtual.ts
More file actions
47 lines (40 loc) · 1.74 KB
/
deployVeVirtual.ts
File metadata and controls
47 lines (40 loc) · 1.74 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
39
40
41
42
43
44
45
46
47
import { ethers, upgrades } from "hardhat";
(async () => {
try {
const args = [process.env.BRIDGED_TOKEN, 104];
const Contract = await ethers.getContractFactory("veVirtual");
const contract = await upgrades.deployProxy(Contract, args, {
initialOwner: process.env.CONTRACT_CONTROLLER,
});
await contract.waitForDeployment();
console.log("veVirtual deployed to:", contract.target);
// Note: initialOwner only sets ProxyAdmin owner, not AccessControl roles
// We need to manually grant roles to CONTRACT_CONTROLLER and ADMIN
const CONTRACT_CONTROLLER = process.env.CONTRACT_CONTROLLER;
const ADMIN = process.env.ADMIN;
const DEFAULT_ADMIN_ROLE = await contract.DEFAULT_ADMIN_ROLE();
const ADMIN_ROLE = await contract.ADMIN_ROLE();
if (CONTRACT_CONTROLLER) {
// Grant DEFAULT_ADMIN_ROLE to CONTRACT_CONTROLLER
const tx1 = await contract.grantRole(DEFAULT_ADMIN_ROLE, CONTRACT_CONTROLLER);
await tx1.wait();
console.log("Granted DEFAULT_ADMIN_ROLE to CONTRACT_CONTROLLER:", CONTRACT_CONTROLLER);
// Grant ADMIN_ROLE to CONTRACT_CONTROLLER
const tx2 = await contract.grantRole(ADMIN_ROLE, CONTRACT_CONTROLLER);
await tx2.wait();
console.log("Granted ADMIN_ROLE to CONTRACT_CONTROLLER:", CONTRACT_CONTROLLER);
}
if (ADMIN) {
// Grant DEFAULT_ADMIN_ROLE to ADMIN
const tx3 = await contract.grantRole(DEFAULT_ADMIN_ROLE, ADMIN);
await tx3.wait();
console.log("Granted DEFAULT_ADMIN_ROLE to ADMIN:", ADMIN);
// Grant ADMIN_ROLE to ADMIN
const tx4 = await contract.grantRole(ADMIN_ROLE, ADMIN);
await tx4.wait();
console.log("Granted ADMIN_ROLE to ADMIN:", ADMIN);
}
} catch (e) {
console.log(e);
}
})();