Skip to content

Commit

Permalink
build: update yarn
Browse files Browse the repository at this point in the history
build: update deps
refactor: upgrade from ethersv5 to ethersv6 typechain target
  • Loading branch information
ahmedali8 committed Jul 7, 2023
1 parent 0499b74 commit d7d7efe
Show file tree
Hide file tree
Showing 7 changed files with 1,517 additions and 2,916 deletions.
81 changes: 36 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hardhat-test-suite-generator",
"version": "1.1.3",
"version": "2.0.0",
"description": "Hardhat plugin for generating test suite",
"author": {
"name": "Ahmed Ali",
Expand All @@ -10,57 +10,50 @@
"url": "https://github.com/ahmedali8/hardhat-test-suite-generator/issues"
},
"dependencies": {
"@typechain/hardhat": "^6.1.5",
"fs-extra": "^11.1.0",
"hardhat": "^2.12.6",
"lodash": "^4.17.21",
"mkdirp": "^1.0.4",
"typechain": "^8.1.1"
"@typechain/hardhat": "^8.0.0",
"@types/prettier": "^2.1.1",
"fs-extra": "^11.1.1",
"hardhat": "^2.16.1",
"lodash": "^4.17.15",
"mkdirp": "^3.0.1",
"prettier": "^2.3.1",
"typechain": "^8.2.0"
},
"devDependencies": {
"@commitlint/cli": "^17.4.2",
"@commitlint/config-conventional": "^17.4.2",
"@ethersproject/abi": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.5",
"@nomicfoundation/hardhat-network-helpers": "^1.0.7",
"@nomicfoundation/hardhat-toolbox": "^2.0.1",
"@nomiclabs/hardhat-ethers": "^2.2.2",
"@nomiclabs/hardhat-etherscan": "^3.1.5",
"@openzeppelin/contracts": "^4.8.1",
"@trivago/prettier-plugin-sort-imports": "^3.4.0",
"@typechain/ethers-v5": "^10.2.0",
"@types/chai": "^4.3.4",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.1",
"@nomicfoundation/hardhat-ethers": "^3.0.3",
"@nomicfoundation/hardhat-network-helpers": "^1.0.8",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.3",
"@openzeppelin/contracts": "^4.9.2",
"@trivago/prettier-plugin-sort-imports": "^4.1.1",
"@typechain/ethers-v6": "^0.4.0",
"@types/chai": "^4.3.5",
"@types/fs-extra": "^11.0.1",
"@types/lodash": "^4.14.191",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^9.1.1",
"@types/node": "^18.13.0",
"@types/prettier": "^2.7.2",
"@typescript-eslint/eslint-plugin": "^5.51.0",
"@typescript-eslint/parser": "^5.51.0",
"@types/lodash": "^4.14.139",
"@types/mkdirp": "^2.0.0",
"@types/mocha": "^10.0.1",
"@types/node": "^20.4.0",
"@typescript-eslint/eslint-plugin": "^5.61.0",
"@typescript-eslint/parser": "^5.61.0",
"chai": "^4.3.7",
"child_process": "^1.0.2",
"commitizen": "^4.3.0",
"cz-conventional-changelog": "^3.3.0",
"earljs": "^0.2.3",
"eslint": "^8.33.0",
"eslint-config-prettier": "^8.6.0",
"ethers": "^5.7.2",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"ethers": "^6.6.2",
"hardhat-gas-reporter": "^1.0.9",
"husky": "^8.0.3",
"lint-staged": "^13.1.1",
"mocha": "^10.2.0",
"nyc": "^15.1.0",
"pinst": "^3.0.0",
"prettier": "^2.8.4",
"shx": "^0.3.4",
"solidity-coverage": "^0.8.2",
"solidity-coverage": "^0.8.4",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1",
"typescript": "^4.9.5"
"typescript": "^5.1.6"
},
"files": [
"/dist/**/*.d.ts",
Expand All @@ -87,15 +80,16 @@
],
"license": "MIT",
"main": "./dist/index.js",
"packageManager": "yarn@3.2.2",
"packageManager": "yarn@3.6.1",
"peerDependencies": {
"@nomicfoundation/hardhat-chai-matchers": "1.x",
"@nomicfoundation/hardhat-chai-matchers": "2.x",
"@nomicfoundation/hardhat-network-helpers": "1.x",
"@nomicfoundation/hardhat-toolbox": "2.x",
"@typechain/hardhat": "6.x",
"@nomicfoundation/hardhat-toolbox": "3.x",
"@typechain/hardhat": "8.x",
"hardhat": "2.x",
"lodash": "4.x",
"typechain": "8.x"
"typechain": "8.x",
"typescript": ">=4.3.0"
},
"publishConfig": {
"access": "public"
Expand All @@ -110,12 +104,9 @@
"coverage": "yarn nyc --nycrc-path ./.nycrc.yml mocha",
"lint": "yarn lint:ts && yarn prettier:check && yarn typecheck",
"lint:ts": "eslint --config \"./.eslintrc.yml\" --ignore-path \"./.eslintignore\" --ext .js,.ts .",
"postinstall": "husky install",
"postpublish": "pinst --enable",
"prepack": "yarn build",
"prepublish": "pinst --disable",
"prettier": "prettier --config \"./.prettierrc.yml\" --ignore-path \"./.prettierignore\" --write \"**/*.{js,json,md,ts,yml}\"",
"prettier:check": "prettier --check --config \"./.prettierrc.yml\" --ignore-path \"./.prettierignore\" \"**/*.{js,json,md,ts,yml}\"",
"prettier:write": "prettier --write --config \"./.prettierrc.yml\" --ignore-path \"./.prettierignore\" \"**/*.{js,json,md,ts,yml}\"",
"test": "mocha --config \"./.mocharc.yml\"",
"typecheck": "tsc --incremental false --noEmit"
},
Expand Down
7 changes: 0 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ task(TASK_GENERATE_TEST_SUITE, "Generates a test suite structure for smart contr
);
}

// const outDirName: string = hre.config.testSuiteGenerator.outDirName;

// if (fsExtra.existsSync(join(cwd, outDirName))) {
// console.log(`Test Suite already exists!`);
// return;
// }

const relativePathToContractsSources: string = relative(cwd, hre.config.paths.sources);
const artifactFiles = glob(cwd, [
`${hre.config.paths.artifacts}/${
Expand Down
65 changes: 33 additions & 32 deletions src/utils/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,48 +43,49 @@ export function genFixtureFile(contract: Contract, config: HelperConfig): FileDe
`${pascalCase(contract.name)}.fixture.ts`,
),
contents: `
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { ethers } from "hardhat";
import type { ${pascalCase(contract.name)} } from "${join(
"..",
"..",
"..",
config.typechainOutDir,
config.contractsSources,
...contract.path,
pascalCase(contract.name),
)}";
"..",
"..",
"..",
config.typechainOutDir,
config.contractsSources,
...contract.path,
pascalCase(contract.name),
)}";
import type { ${pascalCase(contract.name)}${FACTORY_POSTFIX} } from "${join(
"..",
"..",
"..",
config.typechainOutDir,
"factories",
config.contractsSources,
...contract.path,
`${pascalCase(contract.name)}${FACTORY_POSTFIX}`,
)}";
"..",
"..",
"..",
config.typechainOutDir,
"factories",
config.contractsSources,
...contract.path,
`${pascalCase(contract.name)}${FACTORY_POSTFIX}`,
)}";
export async function ${camelCase(contract.name)}Fixture(): Promise<{ ${camelCase(
contract.name,
)}: ${pascalCase(contract.name)} }> {
contract.name,
)}: ${pascalCase(contract.name)} }> {
const signers = await ethers.getSigners();
const deployer: SignerWithAddress = signers[0];
const ${pascalCase(contract.name)}Factory: ${pascalCase(
contract.name,
)}${FACTORY_POSTFIX} = await ethers.getContractFactory("${contract.name}") as ${pascalCase(
contract.name,
)}${FACTORY_POSTFIX};
contract.name,
)}${FACTORY_POSTFIX} = await ethers.getContractFactory("${contract.name}") as ${pascalCase(
contract.name,
)}${FACTORY_POSTFIX};
/* Autogenerated arguments for deploy */
/* Please change accordingly */
type DeployArgs = Parameters<typeof ${pascalCase(contract.name)}Factory.deploy>;
const args: DeployArgs = {} as DeployArgs;
const ${camelCase(contract.name)}: ${pascalCase(contract.name)} = await ${pascalCase(
contract.name,
)}Factory.connect(deployer).deploy(...args) as ${pascalCase(contract.name)};
contract.name,
)}Factory.connect(deployer).deploy(...args) as ${pascalCase(contract.name)};
await ${camelCase(contract.name)}.waitForDeployment();
return { ${camelCase(contract.name)} };
}
Expand Down Expand Up @@ -158,16 +159,16 @@ export function genContractFile(contract: Contract, config: HelperConfig): FileD
),
contents: `
import { shouldBehaveLike${pascalCase(contract.name)}Contract } from "./${pascalCase(
contract.name,
)}.behavior";
contract.name,
)}.behavior";
import { ${camelCase(contract.name)}Fixture } from "./${pascalCase(contract.name)}.fixture";
export function test${pascalCase(contract.name)}(): void {
describe("${pascalCase(contract.name)}", function () {
beforeEach(async function () {
const { ${camelCase(contract.name)} } = await this.loadFixture(${camelCase(
contract.name,
)}Fixture);
contract.name,
)}Fixture);
this.contracts.${camelCase(contract.name)} = ${camelCase(contract.name)};
});
Expand All @@ -182,7 +183,7 @@ export function genSharedTypesFile(contracts: Contract[], config: HelperConfig):
return {
path: join(config.outDirAbs, "shared", "types.ts"),
contents: `
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
${contracts
.map((c) => c.name)
.map(
Expand Down Expand Up @@ -228,7 +229,7 @@ export function genIndexFile(contracts: Contract[], config: HelperConfig): FileD
path: join(config.outDirAbs, "unit", "index.ts"),
contents: `
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/signers";
import { ethers } from "hardhat";
import type { Contracts, Signers } from "${join("..", "shared", "types")}";
Expand Down
2 changes: 1 addition & 1 deletion test/fixture-projects/fixture-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const config: HardhatUserConfig = {
solidity: "0.8.18",
typechain: {
outDir: "typechain",
target: "ethers-v5",
target: "ethers-v6",
},
};

Expand Down
2 changes: 1 addition & 1 deletion test/fixture-projects/token-project/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const config: HardhatUserConfig = {
solidity: "0.8.18",
typechain: {
outDir: "types",
target: "ethers-v5",
target: "ethers-v6",
},
};

Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es6"],
"lib": ["es2020"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
Expand All @@ -13,7 +13,7 @@
"skipLibCheck": false,
"sourceMap": true,
"strict": true,
"target": "es5"
"target": "es2020"
},
"exclude": ["**/node_modules", "**/typechain"],
"include": ["src/**/*", "test/**/*"]
Expand Down
Loading

0 comments on commit d7d7efe

Please sign in to comment.