Skip to content

Commit

Permalink
Port regenerate upgrade info tool
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Mar 19, 2024
1 parent d378a7b commit 67eaf3a
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions upgrade/tool-regen-upgrade-info/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
input.json
33 changes: 33 additions & 0 deletions upgrade/tool-regen-upgrade-info/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Regenerate upgrade info

## pre-requisites
- move to the commit where the last upgrade has been done
- delete folder `artifacts` and `cache` folder

## set project root environment variables
- `cp .env.example .env` in root folder and set your own variables

## input variables
- copy input.example.json into your input file and fill in with your parameters:
- `cp upgrade/tool-regen-upgrade-info/input.example.json upgrade/tool-regen-upgrade-info/input.json`

- input parameters:
```
{
"proxyAddress": "0x012345",
"implementationName": "PolygonZkEVMUpgraded",
"constructorArgs": [
"0x6407cf296a27B38fd29c401518504D388F1DFB3d",
"0xF1b13757bcF3EF902a7847f409A6068BA43a89D4",
"0xeDB618947F59FC5caA8bc9c24283807FDdAf6E2c",
"0xcFA773Cc48FBde3CA4D24eeCb19D224d697026b2",
1440,
3
]
}
```

## run the script
- Run the following commands from the root repository:
- command: `npx hardhat run regenerate-upgrade-info.js --network {networkName}`
- output: create `.openzeppelin` folder with `${networkName}.json`
12 changes: 12 additions & 0 deletions upgrade/tool-regen-upgrade-info/input.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"proxyAddress": "0x012345",
"implementationName": "PolygonZkEVMUpgraded",
"constructorArgs": [
"0x6407cf296a27B38fd29c401518504D388F1DFB3d",
"0xF1b13757bcF3EF902a7847f409A6068BA43a89D4",
"0xeDB618947F59FC5caA8bc9c24283807FDdAf6E2c",
"0xcFA773Cc48FBde3CA4D24eeCb19D224d697026b2",
1440,
3
]
}
24 changes: 24 additions & 0 deletions upgrade/tool-regen-upgrade-info/regen-upgrade-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-console, no-inner-declarations, no-undef, import/no-unresolved */
const { ethers, upgrades } = require('hardhat');
const path = require('path');
const fs = require('fs');

async function main() {
// load input file
const input = JSON.parse(fs.readFileSync(path.resolve(__dirname, './input.json')));

// Load implementation contract
const PolygonZkEVMFactory = await ethers.getContractFactory(input.implementationName, ethers.provider);

// Import OZ upgrades
await upgrades.forceImport(input.proxyAddress, PolygonZkEVMFactory, {
kind: 'transparent',
constructorArgs: input.constructorArgs,
});
}

main().catch((e) => {
console.error(e);
process.exit(1);
});

0 comments on commit 67eaf3a

Please sign in to comment.