Skip to content

Commit

Permalink
refactor: move typechain bindings from "typechain" to "types"
Browse files Browse the repository at this point in the history
chore: delete "onCompileComplete" and "onIstanbulComplete" hooks in ".solcover.js"
chore: generate TypeChain bindings before running coverage script
  • Loading branch information
PaulRBerg committed Oct 19, 2021
1 parent 1d085a9 commit afe1da2
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**/coverage
**/dist
**/node_modules
**/typechain
**/types

# files
*.env
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
**/.coverage_contracts
**/dist
**/node_modules
**/typechain
**/types

# files
*.env
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
**/coverage
**/dist
**/node_modules
**/typechain
**/types

# files
*.env
Expand Down
10 changes: 1 addition & 9 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,8 @@ const shell = require("shelljs");

module.exports = {
istanbulReporter: ["html", "lcov"],
onCompileComplete: async function (_config) {
await run("typechain");
},
onIstanbulComplete: async function (_config) {
// We need to do this because solcover generates bespoke artifacts.
shell.rm("-rf", "./artifacts");
shell.rm("-rf", "./typechain");
},
providerOptions: {
mnemonic: process.env.MNEMONIC,
},
skipFiles: ["mocks", "test"],
skipFiles: ["test"],
};
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const config: HardhatUserConfig = {
},
},
typechain: {
outDir: "typechain",
outDir: "types",
target: "ethers-v5",
},
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
"access": "public"
},
"scripts": {
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./typechain ./coverage.json",
"clean": "shx rm -rf ./artifacts ./cache ./coverage ./types ./coverage.json",
"commit": "git-cz",
"compile": "cross-env TS_NODE_TRANSPILE_ONLY=true hardhat compile",
"coverage": "cross-env CODE_COVERAGE=true hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\"",
"coverage": "yarn typechain && hardhat coverage --solcoverjs ./.solcover.js --temp artifacts --testfiles \"./test/**/*.ts\"",
"deploy": "hardhat deploy:Greeter",
"lint": "yarn lint:sol && yarn lint:ts && yarn prettier:check",
"lint:sol": "solhint --config ./.solhint.json --max-warnings 0 \"contracts/**/*.sol\"",
Expand Down
3 changes: 2 additions & 1 deletion tasks/deploy/greeter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { task } from "hardhat/config";
import { TaskArguments } from "hardhat/types";

import { Greeter, Greeter__factory } from "../../typechain";
import { Greeter } from "../../types/Greeter";
import { Greeter__factory } from "../../types/Greeter__factory";

task("deploy:Greeter")
.addParam("greeting", "Say hello, be nice")
Expand Down
2 changes: 1 addition & 1 deletion test/greeter/Greeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import hre from "hardhat";
import { Artifact } from "hardhat/types";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";

import { Greeter } from "../../typechain/Greeter";
import { Greeter } from "../../types/Greeter";
import { Signers } from "../types";
import { shouldBehaveLikeGreeter } from "./Greeter.behavior";

Expand Down
2 changes: 1 addition & 1 deletion test/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import { Fixture } from "ethereum-waffle";

import { Greeter } from "../typechain/Greeter";
import { Greeter } from "../types/Greeter";

declare module "mocha" {
export interface Context {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
},
"exclude": ["node_modules"],
"files": ["./hardhat.config.ts"],
"include": ["tasks/**/*.ts", "test/**/*.ts", "typechain/**/*.d.ts", "typechain/**/*.ts"]
"include": ["tasks/**/*", "test/**/*", "types/**/*"]
}

0 comments on commit afe1da2

Please sign in to comment.