Skip to content

Commit

Permalink
feat: hardhat deployment tasks (Open-Attestation#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
superical committed Jan 19, 2022
1 parent d4d03fe commit e95f2c7
Show file tree
Hide file tree
Showing 22 changed files with 1,300 additions and 579 deletions.
14 changes: 9 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ jobs:
build:
docker:
- image: 'circleci/node:14'
environment:
ENV_NAME: test
steps:
- checkout
- run:
name: install
command: npm ci
command: NODE_ENV=$ENV_NAME npm ci
- run:
name: commitlint
command: npx --no-install commitlint-circle
Expand All @@ -28,23 +30,25 @@ jobs:
command: npm run lint
- run:
name: test
command: npm run test
command: NODE_ENV=$ENV_NAME npm run test
- run:
name: build
command: npm run build
command: NODE_ENV=$ENV_NAME npm run build
- run:
name: release
command: npm run semantic-release
coverage:
docker:
- image: 'circleci/node:14'
environment:
ENV_NAME: test
steps:
- checkout
- run:
name: install
command: npm ci
command: NODE_ENV=$ENV_NAME npm ci
- run:
name: coverage
command: npm run coverage
command: NODE_ENV=$ENV_NAME npm run coverage
- codecov/upload

10 changes: 10 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# API Keys
INFURA_API_KEY=
ETHERSCAN_API_KEY=
COINMARKETCAP_API_KEY=

# Deployer Private Key
DEPLOYER_PK=

# Mnemonic words
MNEMONIC=
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
"rules": {
"no-restricted-globals": "off",
"import/prefer-default-export": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.*", "./hardhat.config.*", "./test/**/*.js", "./test/**/*.ts"]}]
"no-console": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": ["**/*.test.*", "./hardhat.config.*", "./test/**/*.js", "./test/**/*.ts", "./tasks/**"]}]
}
},
{
Expand Down
100 changes: 89 additions & 11 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,114 @@ import "@nomiclabs/hardhat-waffle";
import "hardhat-watcher";
import "hardhat-gas-reporter";
import "solidity-coverage";
import { HardhatUserConfig } from "hardhat/types";
import "@nomiclabs/hardhat-etherscan";
import dotenv from "dotenv";
import { HardhatUserConfig, HttpNetworkUserConfig } from "hardhat/types";
import "./tasks";

dotenv.config();

const { INFURA_API_KEY, MNEMONIC, DEPLOYER_PK, COINMARKETCAP_API_KEY, ETHERSCAN_API_KEY } = process.env;
const IS_TEST_ENV = process.env.NODE_ENV === "test";

if (!IS_TEST_ENV && !INFURA_API_KEY) {
throw new Error("Infura key is not provided in env");
}

if (!IS_TEST_ENV && !DEPLOYER_PK && !MNEMONIC) {
throw new Error("Provide at least either deployer private key or mnemonic in env");
}

const networkConfig: HttpNetworkUserConfig = {};
if (IS_TEST_ENV) {
networkConfig.accounts = ["0xbabe"];
} else if (DEPLOYER_PK) {
networkConfig.accounts = [DEPLOYER_PK];
} else {
networkConfig.accounts = {
mnemonic: MNEMONIC!,
};
}

const config: HardhatUserConfig = {
solidity: {
version: "0.8.4",
settings: {
optimizer: {
enabled: true,
runs: 200
runs: 200,
},
outputSelection: {
"*": {
"*": ["storageLayout"]
}
}
}
"*": ["storageLayout"],
},
},
},
},
typechain: {
outDir: "src/contracts",
alwaysGenerateOverloads: true
alwaysGenerateOverloads: true,
},
watcher: {
test: {
tasks: ["compile", "test"],
files: ["./contracts", "./test"]
}
files: ["./contracts", "./test"],
},
},
gasReporter: {
coinmarketcap: process.env.COINMARKETCAP_TOKEN,
currency: "USD"
coinmarketcap: COINMARKETCAP_API_KEY,
currency: "USD",
},
etherscan: {
apiKey: ETHERSCAN_API_KEY,
},
networks: {
/**
* Ethereum
*/
mainnet: {
...networkConfig,
url: `https://mainnet.infura.io/v3/${INFURA_API_KEY}`,
},
ropsten: {
...networkConfig,
url: `https://ropsten.infura.io/v3/${INFURA_API_KEY}`,
},
goerli: {
...networkConfig,
url: `https://goerli.infura.io/v3/${INFURA_API_KEY}`,
},
rinkeby: {
...networkConfig,
url: `https://rinkeby.infura.io/v3/${INFURA_API_KEY}`,
},
kovan: {
...networkConfig,
url: `https://kovan.infura.io/v3/${INFURA_API_KEY}`,
},
/**
* Polygon
*/
polygon: {
...networkConfig,
url: `https://polygon-mainnet.infura.io/v3/${INFURA_API_KEY}`,
},
mumbai: {
...networkConfig,
url: `https://polygon-mumbai.infura.io/v3/${INFURA_API_KEY}`,
// url: "https://matic-mumbai.chainstacklabs.com",
},
/**
* Development
*/
hardhat: {
allowUnlimitedContractSize: true,
},
localhost: {
...networkConfig,
accounts: "remote",
url: "http://127.0.0.1:8545",
},
},
};

Expand Down

0 comments on commit e95f2c7

Please sign in to comment.