diff --git a/packages/automation-contracts/scheduler/.env-example b/packages/automation-contracts/scheduler/.env-example index 3e29df7dad..7e55793109 100644 --- a/packages/automation-contracts/scheduler/.env-example +++ b/packages/automation-contracts/scheduler/.env-example @@ -3,9 +3,15 @@ MUMBAI_PRIVATE_KEY= POLYGON_PRIVATE_KEY= BSC_PRIVATE_KEY= +OPSEPOLIA_PRIVATE_KEY= MUMBAI_URL= POLYGON_URL= BSC_URL= +OPSEPOLIA_URL= -ETHERSCAN_API_KEY = +ETHERSCAN_API_KEY= + +DEPLOY_FLOW_SCHEDULER= +DEPLOY_VESTING_SCHEDULER= +DEPLOY_VESTING_SCHEDULER_V2= \ No newline at end of file diff --git a/packages/automation-contracts/scheduler/deploy/deploy.js b/packages/automation-contracts/scheduler/deploy/deploy.js index 718fd771d9..b9ee36347d 100644 --- a/packages/automation-contracts/scheduler/deploy/deploy.js +++ b/packages/automation-contracts/scheduler/deploy/deploy.js @@ -24,41 +24,79 @@ module.exports = async function ({ deployments, getNamedAccounts }) { const { deploy } = deployments; const { deployer } = await getNamedAccounts(); + console.log(`network: ${hre.network.name}`); console.log(`chainId: ${chainId}`); console.log(`rpc: ${hre.network.config.url}`); console.log(`host: ${host}`); - const FlowScheduler = await deploy("FlowScheduler", { - from: deployer, - args: [host, registrationKey], - log: true, - skipIfAlreadyDeployed: false, - }); - const VestingScheduler = await deploy("VestingScheduler", { - from: deployer, - args: [host, registrationKey], - log: true, - skipIfAlreadyDeployed: false, - }); + const deployFlowScheduler = process.env.DEPLOY_FLOW_SCHEDULER?.toLowerCase() === "true"; + const deployVestingScheduler = process.env.DEPLOY_VESTING_SCHEDULER?.toLowerCase() === "true"; + const deployVestingSchedulerV2 = process.env.DEPLOY_VESTING_SCHEDULER_V2?.toLowerCase() === "true"; + console.log(`deployFlowScheduler: ${deployFlowScheduler}`); + console.log(`deployVestingScheduler: ${deployVestingScheduler}`); + console.log(`deployVestingSchedulerV2: ${deployVestingSchedulerV2}`); + + if (deployFlowScheduler) { + console.log("Deploying FlowScheduler..."); + const FlowScheduler = await deploy("FlowScheduler", { + from: deployer, + args: [host, registrationKey], + log: true, + skipIfAlreadyDeployed: false, + }); - // wait for 15 seconds to allow etherscan to indexed the contracts - await sleep(15000); + // wait for 15 seconds to allow etherscan to indexed the contracts + await sleep(15000); - try { + console.log("Verifying FlowScheduler..."); await hre.run("verify:verify", { address: FlowScheduler.address, constructorArguments: [host, registrationKey], contract: "contracts/FlowScheduler.sol:FlowScheduler", }); + } + + if (deployVestingScheduler) { + console.log("Deploying VestingScheduler..."); + const VestingScheduler = await deploy("VestingScheduler", { + from: deployer, + args: [host, registrationKey], + log: true, + skipIfAlreadyDeployed: false, + }); + + // wait for 15 seconds to allow etherscan to indexed the contracts + await sleep(15000); + console.log("Verifying VestingScheduler..."); await hre.run("verify:verify", { address: VestingScheduler.address, constructorArguments: [host, registrationKey], contract: "contracts/VestingScheduler.sol:VestingScheduler", }); - } catch (err) { - console.error(err); } + + if (deployVestingSchedulerV2) { + console.log("Deploying VestingSchedulerV2..."); + const VestingSchedulerV2 = await deploy("VestingSchedulerV2", { + from: deployer, + args: [host, registrationKey], + log: true, + skipIfAlreadyDeployed: false, + }); + + // wait for 15 seconds to allow etherscan to indexed the contracts + await sleep(15000); + + console.log("Verifying VestingSchedulerV2..."); + await hre.run("verify:verify", { + address: VestingSchedulerV2.address, + constructorArguments: [host, registrationKey], + contract: "contracts/VestingSchedulerV2.sol:VestingSchedulerV2", + }); + } + + console.log("Finished."); }; diff --git a/packages/automation-contracts/scheduler/hardhat.config.js b/packages/automation-contracts/scheduler/hardhat.config.js index 5711a7e622..3c86819248 100644 --- a/packages/automation-contracts/scheduler/hardhat.config.js +++ b/packages/automation-contracts/scheduler/hardhat.config.js @@ -40,8 +40,14 @@ module.exports = { accounts: process.env.BSC_PRIVATE_KEY !== undefined ? [process.env.BSC_PRIVATE_KEY] : [], }, + opsepolia: { + url: process.env.OPSEPOLIA_URL || "", + accounts: + process.env.OPSEPOLIA_PRIVATE_KEY !== undefined + ? [process.env.OPSEPOLIA_PRIVATE_KEY] + : [], + }, }, - namedAccounts: { deployer: { default: 0, @@ -49,5 +55,15 @@ module.exports = { }, etherscan: { apiKey: process.env.ETHERSCAN_API_KEY, + customChains: [ + { + network: "opsepolia", + chainId: 11155420, + urls: { + apiURL: "https://api-sepolia-optimistic.etherscan.io/api", + browserURL: "https://sepolia-optimism.etherscan.io/", + }, + }, + ], }, }; diff --git a/packages/automation-contracts/scheduler/package.json b/packages/automation-contracts/scheduler/package.json index 9136ddd415..af83916949 100644 --- a/packages/automation-contracts/scheduler/package.json +++ b/packages/automation-contracts/scheduler/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "forge test", "build": "forge build", + "deploy": "npx hardhat deploy --network", "lint": "run-s lint:*", "lint:sol": "solhint -w 0 contracts/*.sol contracts/*/*.sol && echo '✔ Your .sol files look good.'", "pre-commit": "if [ ! -z \"$(git status -s .)\" ];then run-s pre-commit:*;else true;fi",