Skip to content

Commit

Permalink
added scipt for upgrade and clean install
Browse files Browse the repository at this point in the history
  • Loading branch information
MSalman6 committed Oct 25, 2024
1 parent 822b2c8 commit 78a2c3a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"clean": "rm -rf artifacts/ cache/ coverage/ typechain/ typechain-types/ coverage.json",
"coverage": "npx hardhat coverage --show-stack-traces --config ./hardhat-coverage.config.ts --solcoverjs ./.solcover.js",
"update-core": "rm -rf node_modules/diamond-contracts-core && npm install diamond-contracts-core --save --legacy-peer-deps",
"deployForDaoUpgrade": "npx hardhat run scripts/deployForDaoUpgrade.ts"
"deployForDaoUpgrade": "npx hardhat run scripts/deployForDaoUpgrade.ts",
"clean-install": "rm -f package-lock.json && rm -rf node_modules/diamond-contracts-core && npm install"
},
"repository": {
"type": "git",
Expand Down
29 changes: 29 additions & 0 deletions scripts/getUpgradeCallData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import hre from "hardhat";
import { ethers, upgrades } from "hardhat";
import { attachProxyAdminV5, } from "@openzeppelin/hardhat-upgrades/dist/utils";

const daoAddress = "0xDA0da0da0Da0Da0Da0DA00DA0da0da0DA0DA0dA0";

async function getUpgradeCalldata() {
const proxyAdmin = await attachProxyAdminV5(
hre,
await upgrades.erc1967.getAdminAddress(daoAddress)
);

console.log("Proxy Admin: ", proxyAdmin.target)
const factory = await ethers.getContractFactory("DiamondDao");
const newImplementation = await upgrades.deployImplementation(factory);

console.log("New imp. address: ", newImplementation)
const calldata = proxyAdmin.interface.encodeFunctionData("upgradeAndCall", [
daoAddress,
newImplementation,
ethers.hexlify(new Uint8Array()),
]);
console.log("Calldata: ", calldata);
}

getUpgradeCalldata().catch((error) => {
console.error(error);
process.exitCode = 1;
});

0 comments on commit 78a2c3a

Please sign in to comment.