Skip to content

Commit

Permalink
update deploy script for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
kasparkallas committed Apr 10, 2024
1 parent bd008a2 commit 5c75550
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 19 deletions.
8 changes: 7 additions & 1 deletion packages/automation-contracts/scheduler/.env-example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
72 changes: 55 additions & 17 deletions packages/automation-contracts/scheduler/deploy/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
};
18 changes: 17 additions & 1 deletion packages/automation-contracts/scheduler/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,30 @@ 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,
},
},
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/",
},
},
],
},
};
1 change: 1 addition & 0 deletions packages/automation-contracts/scheduler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5c75550

Please sign in to comment.