Skip to content

Commit

Permalink
Fix/ethers v6 migration in hardhat (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
swellander authored Jan 17, 2024
1 parent 78ed168 commit 24d96ff
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/hardhat/deploy/00_deploy_your_contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
// import { Contract } from "ethers";

/**
* Deploys a contract named "deployYourContract" using the deployer account and
Expand Down Expand Up @@ -31,7 +32,7 @@ const deployYourContract: DeployFunction = async function (hre: HardhatRuntimeEn
autoMine: true,
});

// const yourContract = await hre.ethers.getContract("YourContract", deployer);
// const batchRegistry = await hre.ethers.getContract<Contract>("BatchRegistry", deployer);
};

export default deployYourContract;
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"eslint": "^8.26.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"ethers": "^5.7.1",
"ethers": "^6.10.0",
"hardhat": "^2.19.4",
"hardhat-deploy": "^0.11.45",
"hardhat-deploy-ethers": "^0.4.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/hardhat/scripts/listAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@ async function main() {
try {
const network = availableNetworks[networkName];
if (!("url" in network)) continue;
const provider = new ethers.providers.JsonRpcProvider(network.url);
const provider = new ethers.JsonRpcProvider(network.url);
await provider._detectNetwork();
const balance = await provider.getBalance(address);
console.log("--", networkName, "-- 📡");
console.log(" balance:", +ethers.utils.formatEther(balance));
console.log(" balance:", +ethers.formatEther(balance));
console.log(" nonce:", +(await provider.getTransactionCount(address)));
} catch (e) {
console.log("Can't connect to network", networkName);
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/test/YourContract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("YourContract", function () {
const [owner] = await ethers.getSigners();
const yourContractFactory = await ethers.getContractFactory("YourContract");
yourContract = (await yourContractFactory.deploy(owner.address)) as YourContract;
await yourContract.deployed();
await yourContract.waitForDeployment();
});

describe("Deployment", function () {
Expand Down
48 changes: 46 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ __metadata:
eslint: ^8.26.0
eslint-config-prettier: ^8.5.0
eslint-plugin-prettier: ^4.2.1
ethers: ^5.7.1
ethers: ^6.10.0
hardhat: ^2.19.4
hardhat-deploy: ^0.11.45
hardhat-deploy-ethers: ^0.4.1
Expand Down Expand Up @@ -2646,6 +2646,13 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:18.15.13":
version: 18.15.13
resolution: "@types/node@npm:18.15.13"
checksum: 79cc5a2b5f98e8973061a4260a781425efd39161a0e117a69cd089603964816c1a14025e1387b4590c8e82d05133b7b4154fa53a7dffb3877890a66145e76515
languageName: node
linkType: hard

"@types/node@npm:^10.0.3":
version: 10.17.60
resolution: "@types/node@npm:10.17.60"
Expand Down Expand Up @@ -4047,6 +4054,13 @@ __metadata:
languageName: node
linkType: hard

"aes-js@npm:4.0.0-beta.5":
version: 4.0.0-beta.5
resolution: "aes-js@npm:4.0.0-beta.5"
checksum: cc2ea969d77df939c32057f7e361b6530aa6cb93cb10617a17a45cd164e6d761002f031ff6330af3e67e58b1f0a3a8fd0b63a720afd591a653b02f649470e15b
languageName: node
linkType: hard

"aes-js@npm:^3.1.2":
version: 3.1.2
resolution: "aes-js@npm:3.1.2"
Expand Down Expand Up @@ -7065,6 +7079,21 @@ __metadata:
languageName: node
linkType: hard

"ethers@npm:^6.10.0":
version: 6.10.0
resolution: "ethers@npm:6.10.0"
dependencies:
"@adraffy/ens-normalize": 1.10.0
"@noble/curves": 1.2.0
"@noble/hashes": 1.3.2
"@types/node": 18.15.13
aes-js: 4.0.0-beta.5
tslib: 2.4.0
ws: 8.5.0
checksum: 6f0a834b9b9bb31eceda9ac0a841b1061d5e2eefb5d0b042013db1c5abf48fa993ec0a602ae4c64d9e259d495fc01c100cf61f17e928e09eb43f0c7860f2a317
languageName: node
linkType: hard

"ethjs-unit@npm:0.1.6":
version: 0.1.6
resolution: "ethjs-unit@npm:0.1.6"
Expand Down Expand Up @@ -13312,7 +13341,7 @@ __metadata:
languageName: node
linkType: hard

"tslib@npm:^2.0.0, tslib@npm:^2.1.0, tslib@npm:^2.4.0":
"tslib@npm:2.4.0, tslib@npm:^2.0.0, tslib@npm:^2.1.0, tslib@npm:^2.4.0":
version: 2.4.0
resolution: "tslib@npm:2.4.0"
checksum: 8c4aa6a3c5a754bf76aefc38026134180c053b7bd2f81338cb5e5ebf96fefa0f417bff221592bf801077f5bf990562f6264fecbc42cd3309b33872cb6fc3b113
Expand Down Expand Up @@ -14217,6 +14246,21 @@ __metadata:
languageName: node
linkType: hard

"ws@npm:8.5.0":
version: 8.5.0
resolution: "ws@npm:8.5.0"
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: ^5.0.2
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
checksum: 76f2f90e40344bf18fd544194e7067812fb1372b2a37865678d8f12afe4b478ff2ebc0c7c0aff82cd5e6b66fc43d889eec0f1865c2365d8f7a66d92da7744a77
languageName: node
linkType: hard

"ws@npm:^7.4.5, ws@npm:^7.4.6, ws@npm:^7.5.1":
version: 7.5.9
resolution: "ws@npm:7.5.9"
Expand Down

0 comments on commit 24d96ff

Please sign in to comment.