Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgradable proxies guide #6015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 13 additions & 25 deletions docs/src/content/ignition/docs/guides/upgradeable-proxies.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,34 +313,28 @@ import { expect } from "chai";
import { ignition, ethers } from "hardhat";

import ProxyModule from "../ignition/modules/ProxyModule";
import UpgradeModule from "../ignition/modules/UpgradeModule";
import DemoV2 from "../ignition/modules/DemoV2";

describe("Demo Proxy", function () {
describe("Proxy interaction", async function () {
it("Should be interactable via proxy", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(ProxyModule);

expect(await demo.connect(otherAccount).version()).to.equal("1.0.0");
expect(await demo.read.version()).to.equal("1.0.0");
});
});

describe("Upgrading", function () {
it("Should have upgraded the proxy to DemoV2", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(UpgradeModule);
const { demo } = await ignition.deploy(DemoV2Module);

expect(await demo.connect(otherAccount).version()).to.equal("2.0.0");
expect(await demo.read.version()).to.equal("2.0.0");
});

it("Should have set the name during upgrade", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(UpgradeModule);
const { demo } = await ignition.deploy(DemoV2Module);

expect(await demo.connect(otherAccount).name()).to.equal("Example Name");
expect(await demo.read.name()).to.equal("Example Name");
});
});
});
Expand All @@ -354,34 +348,28 @@ describe("Demo Proxy", function () {
const { expect } = require("chai");

const ProxyModule = require("../ignition/modules/ProxyModule");
const UpgradeModule = require("../ignition/modules/UpgradeModule");
const DemoV2Module = require("../ignition/modules/DemoV2Module");

describe("Demo Proxy", function () {
describe("Proxy interaction", async function () {
it("Should be interactable via proxy", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(ProxyModule);

expect(await demo.connect(otherAccount).version()).to.equal("1.0.0");
expect(await demo.read.version()).to.equal("1.0.0");
});
});

describe("Upgrading", function () {
it("Should have upgraded the proxy to DemoV2", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(UpgradeModule);
const { demo } = await ignition.deploy(DemoV2Module);

expect(await demo.connect(otherAccount).version()).to.equal("2.0.0");
expect(await demo.read.version()).to.equal("2.0.0");
});

it("Should have set the name during upgrade", async function () {
const [, otherAccount] = await ethers.getSigners();

const { demo } = await ignition.deploy(UpgradeModule);
const { demo } = await ignition.deploy(DemoV2Module);

expect(await demo.connect(otherAccount).name()).to.equal("Example Name");
expect(await demo.read.name()).to.equal("Example Name");
});
});
});
Expand All @@ -391,7 +379,7 @@ describe("Demo Proxy", function () {

::::

Here we use Hardhat Ignition to deploy our imported modules. First, we deploy our base `ProxyModule` that returns the first version of our `Demo` contract and tests it to ensure the proxy worked and retrieves the appropriate version string. Then, we deploy our `UpgradeModule` that returns an upgraded version of our `Demo` contract and tests it to ensure the proxy returns the updated version string. We also test that our initialization function was called, setting the `name` state variable to `"Example Name"`.
Here we use Hardhat Ignition to deploy our imported modules. First, we deploy our base `ProxyModule` that returns the first version of our `Demo` contract and tests it to ensure the proxy worked and retrieves the appropriate version string. Then, we deploy our `DemoV2Module` that returns an upgraded version of our `Demo` contract and tests it to ensure the proxy returns the updated version string. We also test that our initialization function was called, setting the `name` state variable to `"Example Name"`.

## Further reading

Expand Down
Loading