Skip to content

Commit

Permalink
Merge pull request #28 from Arrow-air/brasslion/feature/upgrade-process
Browse files Browse the repository at this point in the history
Add upgrade script and process
  • Loading branch information
BrassLion authored Mar 31, 2022
2 parents d1545cc + a693e54 commit 7b476cb
Show file tree
Hide file tree
Showing 5 changed files with 401 additions and 7 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,39 @@ npx hardhat test
8. Run the deployment script to deploy the latest contracts to the testnet.

```
npx hardhat deploy --network rinkeby
npx hardhat deploy --network rinkeby --tags Deployment
```

## Upgrading

Upgrading contracts that are owned by a multisig should be proposed using [Defender](https://docs.openzeppelin.com/defender/guide-upgrades)

1. Sign up for a Defender account and generate an API key.

2. Export the API key and secret key into your local environment.

```
export DEFENDER_TEAM_API_KEY=<API_KEY>
export DEFENDER_TEAM_API_SECRET_KEY=<SECRET_KEY>
```

3. Export the addresses of the token proxy contract to be upgraded and the owning Gnosis multisig address.

```
export ARROW_TOKEN_PROXY_CONTRACT=<TOKEN_ADDRESS>
export ARROW_TOKEN_MUTISIG=<MULTISIG_ADDRESS>
```

4. Run the upgrade script to generate an upgrade proposal in Defender.

```
npx hardhat deploy --network rinkeby --tags Upgrade
```

5. Use the multisig to approve and execute the upgrade proposal.

6. Verify the newly deployed implementation on Etherscan.

## Deployments

### Rinkeby
Expand Down
33 changes: 33 additions & 0 deletions deploy/upgradeArrowTokenHot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

const func = async (hre) => {
const { deployments, upgrades, getNamedAccounts, ethers } = hre;

const proxyAddress = process.env.ARROW_TOKEN_PROXY_CONTRACT;
const multisigAddress = process.env.ARROW_TOKEN_MUTISIG;

if (proxyAddress === undefined) {
console.log("error: Undefined ARROW_TOKEN_PROXY_CONTRACT environment variable. Please define with the Arrow token proxy contract that should have it's implementation upgraded.");
process.exit(1);
}

if (multisigAddress === undefined) {
console.log("error: Undefined ARROW_TOKEN_MUTISIG environment variable. Please define with the Gnosis multisig address that holds ownership of the Arrow token contract.");
process.exit(1);
}

const erc20Factory = await hre.ethers.getContractFactory("ArrowToken");
const oldToken = erc20Factory.attach(proxyAddress)

console.log("Upgrading " + await oldToken.name() + "...")

const proposal = await defender.proposeUpgrade(proxyAddress, erc20Factory, {
multisig: multisigAddress,
multisigType: "Gnosis Safe",
title: "Upgrade ArrowToken",
});

console.log("Upgrade proposal created at:", proposal.url);
}

func.tags = ["ArrowERC20", "Upgrade"];
module.exports = func;
5 changes: 5 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ require("@nomiclabs/hardhat-web3");
require("@nomiclabs/hardhat-etherscan");
require("@nomiclabs/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades");
require("@openzeppelin/hardhat-defender");


/**
Expand Down Expand Up @@ -37,6 +38,10 @@ module.exports = {
// Obtain one at https://etherscan.io/
apiKey: process.env.ETHERSCAN_API_KEY,
},
defender: {
apiKey: process.env.DEFENDER_TEAM_API_KEY,
apiSecret: process.env.DEFENDER_TEAM_API_SECRET_KEY
},
namedAccounts: {
deployer: {
default: 0,
Expand Down
Loading

0 comments on commit 7b476cb

Please sign in to comment.