From 49014856505dd127596f7d702d9a23e74f5f2b44 Mon Sep 17 00:00:00 2001 From: Debugger022 Date: Wed, 24 Jan 2024 17:28:37 +0530 Subject: [PATCH] feat: add deployment script for vai controller --- deploy/017-deploy-vai-controller.ts | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 deploy/017-deploy-vai-controller.ts diff --git a/deploy/017-deploy-vai-controller.ts b/deploy/017-deploy-vai-controller.ts new file mode 100644 index 000000000..93670d499 --- /dev/null +++ b/deploy/017-deploy-vai-controller.ts @@ -0,0 +1,53 @@ +import { ethers } from "hardhat"; +import { DeployResult } from "hardhat-deploy/dist/types"; +import { DeployFunction } from "hardhat-deploy/types"; +import { HardhatRuntimeEnvironment } from "hardhat/types"; + +import { getConfig } from "../helpers/deploymentConfig"; +import { toAddress } from "../helpers/deploymentUtils"; + +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployments, getNamedAccounts } = hre; + const { deploy } = deployments; + const { deployer } = await getNamedAccounts(); + const deploymentConfig = await getConfig(hre.network.name); + const { preconfiguredAddresses } = deploymentConfig; + + const accessControlManagerAddress = await toAddress( + preconfiguredAddresses.AccessControlManager || "AccessControlManager", + hre, + ); + + // VAIController Beacon + const vaiControllerImp: DeployResult = await deploy("VAIControllerImp", { + contract: "VAIController", + from: deployer, + args: [], + log: true, + autoMine: true, + }); + + const vaiControllerBeacon: DeployResult = await deploy("VAIControllerBeacon", { + contract: "UpgradeableBeacon", + from: deployer, + args: [vaiControllerImp.address], + log: true, + autoMine: true, + }); + + const VAIController = await ethers.getContractFactory("VAIController"); + await deploy("VAIController", { + from: deployer, + contract: "BeaconProxy", + args: [ + vaiControllerBeacon.address, + VAIController.interface.encodeFunctionData("initialize", [accessControlManagerAddress]), + ], + log: true, + autoMine: true, + }); +}; + +func.tags = ["VAIController", "il"]; + +export default func;