From bed84e08e26911108b135df8a71b90fffa99a0f8 Mon Sep 17 00:00:00 2001 From: Eric Lau Date: Wed, 5 Jul 2023 13:44:46 -0400 Subject: [PATCH] Update readmes for ethers v6 --- README.md | 8 ++++---- packages/plugin-hardhat/README.md | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index dc71e9e3a..313141a80 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ ``` npm install --save-dev @openzeppelin/hardhat-upgrades -npm install --save-dev '@nomiclabs/hardhat-ethers@^2.0.0' 'ethers@^5.0.0' # peer dependencies +npm install --save-dev @nomicfoundation/hardhat-ethers ethers # peer dependencies ``` ```js @@ -46,11 +46,11 @@ async function main() { // Deploying const Box = await ethers.getContractFactory("Box"); const instance = await upgrades.deployProxy(Box, [42]); - await instance.deployed(); + await instance.waitForDeployment(); // Upgrading const BoxV2 = await ethers.getContractFactory("BoxV2"); - const upgraded = await upgrades.upgradeProxy(instance.address, BoxV2); + const upgraded = await upgrades.upgradeProxy(await instance.getAddress(), BoxV2); } main(); @@ -77,7 +77,7 @@ it('works before and after upgrading', async function () { const instance = await upgrades.deployProxy(Box, [42]); assert.strictEqual(await instance.retrieve(), 42); - await upgrades.upgradeProxy(instance.address, BoxV2); + await upgrades.upgradeProxy(instance, BoxV2); assert.strictEqual(await instance.retrieve(), 42); }); ``` diff --git a/packages/plugin-hardhat/README.md b/packages/plugin-hardhat/README.md index f1a8b07ae..54ba98af0 100644 --- a/packages/plugin-hardhat/README.md +++ b/packages/plugin-hardhat/README.md @@ -9,7 +9,7 @@ ``` npm install --save-dev @openzeppelin/hardhat-upgrades -npm install --save-dev @nomiclabs/hardhat-ethers ethers # peer dependencies +npm install --save-dev @nomicfoundation/hardhat-ethers ethers # peer dependencies ``` And register the plugin in your [`hardhat.config.js`](https://hardhat.org/config/): @@ -35,8 +35,8 @@ const { ethers, upgrades } = require("hardhat"); async function main() { const Box = await ethers.getContractFactory("Box"); const box = await upgrades.deployProxy(Box, [42]); - await box.deployed(); - console.log("Box deployed to:", box.address); + await box.waitForDeployment(); + console.log("Box deployed to:", await box.getAddress()); } main(); @@ -75,12 +75,12 @@ async function main() { const Box = await ethers.getContractFactory("Box"); const beacon = await upgrades.deployBeacon(Box); - await beacon.deployed(); - console.log("Beacon deployed to:", beacon.address); + await beacon.waitForDeployment(); + console.log("Beacon deployed to:", await beacon.getAddress()); const box = await upgrades.deployBeaconProxy(beacon, Box, [42]); - await box.deployed(); - console.log("Box deployed to:", box.address); + await box.waitForDeployment(); + console.log("Box deployed to:", await box.getAddress()); } main(); @@ -119,7 +119,7 @@ describe("Box", function() { const BoxV2 = await ethers.getContractFactory("BoxV2"); const instance = await upgrades.deployProxy(Box, [42]); - const upgraded = await upgrades.upgradeProxy(instance.address, BoxV2); + const upgraded = await upgrades.upgradeProxy(await instance.getAddress(), BoxV2); const value = await upgraded.value(); expect(value.toString()).to.equal('42'); @@ -141,7 +141,7 @@ describe("Box", function() { const instance = await upgrades.deployBeaconProxy(beacon, Box, [42]); await upgrades.upgradeBeacon(beacon, BoxV2); - const upgraded = BoxV2.attach(instance.address); + const upgraded = BoxV2.attach(await instance.getAddress()); const value = await upgraded.value(); expect(value.toString()).to.equal('42');