Skip to content

Commit

Permalink
chore: write tasks for OH
Browse files Browse the repository at this point in the history
Every time I make edits to the OffsetHelper I need to re-deploy and re-verify. I coded a task to make this process easier.

fix: CI deployment

I didn't notice the CI deployed on hardhat before. I edited the CI and the task such that it can deploy on hardhat.
  • Loading branch information
mauricedesaxe committed May 15, 2022
1 parent 639e09d commit ca53cff
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
POLYGON_URL=https://matic-mainnet.chainstacklabs.com
POLYGON_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
POLYGONSCAN_KEY=abc123abc123abc123abc123abc123abc123abc
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ jobs:
POLYGON_URL: ${{ secrets.POLYGON_URL }}

- name: Deploy contract
run: yarn hardhat --network hardhat run ./scripts/deployOffsetHelper.ts
run: yarn hardhat --network hardhat deployOffsetHelper
env:
POLYGON_URL: ${{ secrets.POLYGON_URL }}
48 changes: 41 additions & 7 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import * as dotenv from "dotenv";

import { HardhatUserConfig, task } from "hardhat/config";
import { HardhatUserConfig, subtask, task } from "hardhat/config";
import "@nomiclabs/hardhat-etherscan";
import "@nomiclabs/hardhat-waffle";
import "@typechain/hardhat";
import "hardhat-gas-reporter";
import "solidity-coverage";
import { tokens } from "./utils/tokens";
import addresses, { mumbaiAddresses } from "./utils/addresses";
import { network } from "hardhat";

dotenv.config();

Expand All @@ -17,6 +20,41 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
}
});

task("deployOffsetHelper", "Deploys and verifies OffsetHelper").setAction(
async (taskArgs, hre) => {
const OffsetHelper = await hre.ethers.getContractFactory("OffsetHelper");

const addressesToUse =
hre.network.name == "mumbai" ? mumbaiAddresses : addresses;

const oh = await OffsetHelper.deploy(tokens, [
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
]);
await oh.deployed();
await oh.deployTransaction.wait(5);
console.log(`OffsetHelper deployed on ${hre.network.name} to:`, oh.address);

await hre.run("verify:verify", {
address: oh.address,
constructorArguments: [
tokens,
[
addressesToUse.bct,
addressesToUse.nct,
addressesToUse.usdc,
addressesToUse.weth,
addressesToUse.wmatic,
],
],
});
console.log(`OffsetHelper verified on ${hre.network.name} to:`, oh.address);
}
);

const config: HardhatUserConfig = {
defaultNetwork: "hardhat",
solidity: {
Expand All @@ -33,16 +71,12 @@ const config: HardhatUserConfig = {
url:
process.env.POLYGON_URL || "https://matic-mainnet.chainstacklabs.com",
accounts:
process.env.POLYGON_PRIVATE_KEY !== undefined
? [process.env.POLYGON_PRIVATE_KEY]
: [],
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
mumbai: {
url: process.env.MUMBAI_URL || "https://matic-mumbai.chainstacklabs.com",
accounts:
process.env.MUMBAI_PRIVATE_KEY !== undefined
? [process.env.MUMBAI_PRIVATE_KEY]
: [],
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
hardhat: {
forking: {
Expand Down
33 changes: 0 additions & 33 deletions scripts/deployOffsetHelper.ts

This file was deleted.

13 changes: 0 additions & 13 deletions utils/OHConstructorArgsPolygon.ts

This file was deleted.

13 changes: 0 additions & 13 deletions utils/deployArguments.ts

This file was deleted.

0 comments on commit ca53cff

Please sign in to comment.