Skip to content

Commit

Permalink
Merge pull request PaulRBerg#164 from fvictorio/update-ethers-v6
Browse files Browse the repository at this point in the history
Update dependencies to use ethers v6
  • Loading branch information
PaulRBerg authored Jun 17, 2023
2 parents 28a2d98 + b579971 commit ac68274
Show file tree
Hide file tree
Showing 10 changed files with 179 additions and 176 deletions.
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const config: HardhatUserConfig = {
},
typechain: {
outDir: "types",
target: "ethers-v5",
target: "ethers-v6",
},
};

Expand Down
21 changes: 8 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,14 @@
"url": "https://github.com/PaulRBerg"
},
"devDependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/bignumber": "^5.7.0",
"@ethersproject/bytes": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nomicfoundation/hardhat-chai-matchers": "^1.0.4",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
"@nomicfoundation/hardhat-network-helpers": "^1.0.6",
"@nomicfoundation/hardhat-toolbox": "^2.0.0",
"@nomiclabs/hardhat-ethers": "^2.2.1",
"@nomiclabs/hardhat-etherscan": "^3.1.2",
"@nomicfoundation/hardhat-toolbox": "^3.0.0",
"@nomicfoundation/hardhat-ethers": "^3.0.0",
"@nomicfoundation/hardhat-verify": "^1.0.0",
"@trivago/prettier-plugin-sort-imports": "^4.0.0",
"@typechain/ethers-v5": "^10.1.1",
"@typechain/hardhat": "^6.1.4",
"@typechain/ethers-v6": "^0.4.0",
"@typechain/hardhat": "^8.0.0",
"@types/chai": "^4.3.4",
"@types/fs-extra": "^9.0.13",
"@types/mocha": "^10.0.0",
Expand All @@ -31,7 +26,7 @@
"dotenv": "^16.0.3",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"ethers": "^5.7.2",
"ethers": "^6.4.0",
"fs-extra": "^10.1.0",
"hardhat": "^2.12.2",
"hardhat-deploy": "^0.11.29",
Expand All @@ -46,7 +41,7 @@
"solidity-coverage": "^0.8.2",
"ts-generator": "^0.1.1",
"ts-node": "^10.9.1",
"typechain": "^8.1.1",
"typechain": "^8.2.0",
"typescript": "^4.9.3"
},
"files": [
Expand Down
281 changes: 150 additions & 131 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions tasks/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { Signer } from "@ethersproject/abstract-signer";
import { task } from "hardhat/config";

task("accounts", "Prints the list of accounts", async (_taskArgs, hre) => {
const accounts: Signer[] = await hre.ethers.getSigners();
const accounts = await hre.ethers.getSigners();

for (const account of accounts) {
console.log(await account.getAddress());
console.log(account.address);
}
});
8 changes: 2 additions & 6 deletions tasks/greet.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

import type { Greeter } from "../../types/Greeter";
import type { Greeter__factory } from "../../types/factories/Greeter__factory";

task("task:setGreeting")
.addParam("greeting", "Say hello, be nice")
.addParam("account", "Specify which account [0, 9]")
Expand All @@ -13,9 +9,9 @@ task("task:setGreeting")

const Greeter = await deployments.get("Greeter");

const signers: SignerWithAddress[] = await ethers.getSigners();
const signers = await ethers.getSigners();

const greeter = <Greeter>await ethers.getContractAt("Greeter", Greeter.address);
const greeter = await ethers.getContractAt("Greeter", Greeter.address);

await greeter.connect(signers[taskArguments.account]).setGreeting(taskArguments.greeting);

Expand Down
14 changes: 5 additions & 9 deletions tasks/taskDeploy.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { task } from "hardhat/config";
import type { TaskArguments } from "hardhat/types";

import type { Greeter } from "../../types/Greeter";
import type { Greeter__factory } from "../../types/factories/Greeter__factory";

task("task:deployGreeter")
.addParam("greeting", "Say hello, be nice")
.setAction(async function (taskArguments: TaskArguments, { ethers }) {
const signers: SignerWithAddress[] = await ethers.getSigners();
const greeterFactory: Greeter__factory = <Greeter__factory>await ethers.getContractFactory("Greeter");
const greeter: Greeter = <Greeter>await greeterFactory.connect(signers[0]).deploy(taskArguments.greeting);
await greeter.deployed();
console.log("Greeter deployed to: ", greeter.address);
const signers = await ethers.getSigners();
const greeterFactory = await ethers.getContractFactory("Greeter");
const greeter = await greeterFactory.connect(signers[0]).deploy(taskArguments.greeting);
await greeter.waitForDeployment();
console.log("Greeter deployed to: ", await greeter.getAddress());
});
13 changes: 6 additions & 7 deletions test/greeter/Greeter.fixture.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import { ethers } from "hardhat";

import type { Greeter } from "../../types/Greeter";
import type { Greeter__factory } from "../../types/factories/Greeter__factory";

export async function deployGreeterFixture(): Promise<{ greeter: Greeter }> {
const signers: SignerWithAddress[] = await ethers.getSigners();
const admin: SignerWithAddress = signers[0];
const signers = await ethers.getSigners();
const admin = signers[0];

const greeting: string = "Hello, world!";
const greeterFactory: Greeter__factory = <Greeter__factory>await ethers.getContractFactory("Greeter");
const greeter: Greeter = <Greeter>await greeterFactory.connect(admin).deploy(greeting);
await greeter.deployed();
const greeting = "Hello, world!";
const greeterFactory = await ethers.getContractFactory("Greeter");
const greeter = await greeterFactory.connect(admin).deploy(greeting);
await greeter.waitForDeployment();

return { greeter };
}
3 changes: 1 addition & 2 deletions test/greeter/Greeter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import { ethers } from "hardhat";

import type { Signers } from "../types";
Expand All @@ -10,7 +9,7 @@ describe("Unit tests", function () {
before(async function () {
this.signers = {} as Signers;

const signers: SignerWithAddress[] = await ethers.getSigners();
const signers = await ethers.getSigners();
this.signers.admin = signers[0];

this.loadFixture = loadFixture;
Expand Down
2 changes: 1 addition & 1 deletion test/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { SignerWithAddress } from "@nomiclabs/hardhat-ethers/dist/src/signer-with-address";
import type { SignerWithAddress } from "@nomicfoundation/hardhat-ethers/dist/src/signer-with-address";

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

Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
"esModuleInterop": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"lib": ["es6"],
"lib": ["es2020"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
"removeComments": true,
"resolveJsonModule": true,
"sourceMap": true,
"strict": true,
"target": "es6"
"target": "es2020"
},
"exclude": ["node_modules"],
"files": ["./hardhat.config.ts"],
"include": ["src/**/*", "tasks/**/*", "test/**/*", "deploy/**/*"]
"include": ["src/**/*", "tasks/**/*", "test/**/*", "deploy/**/*", "types/"]
}

0 comments on commit ac68274

Please sign in to comment.