Skip to content

Commit

Permalink
Merge pull request #19 from ethpandaops/pk910/fixes
Browse files Browse the repository at this point in the history
fixes
  • Loading branch information
pk910 authored Jun 3, 2024
2 parents 43779a5 + 2d6351c commit bfef8d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
2 changes: 1 addition & 1 deletion fundingvault/hardhat.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ignition");

const DEPLOYER_PRIVATE_KEY = vars.has("DEPLOYER_PRIVATE_KEY") ? [ vars.get("DEPLOYER_PRIVATE_KEY") ] : undefined;
const DEPLOYER_PRIVATE_KEY = vars.has("FUNDINGVAULT_DEPLOYER_PRIVATE_KEY") ? [ vars.get("FUNDINGVAULT_DEPLOYER_PRIVATE_KEY") ] : undefined;

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
Expand Down
43 changes: 36 additions & 7 deletions fundingvault/scripts/bootstrap.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
const { ethers, network } = require("hardhat");
const { vars } = require("hardhat/config");
const fs = require('fs');


/* bootstrap commands:
npx hardhat vars set DEPLOYER_PRIVATE_KEY
npx hardhat vars set FUNDINGVAULT_DEPLOYER_PRIVATE_KEY
npx hardhat vars set FUNDINGVAULT_OWNER_ADDRESS
npx hardhat run scripts/bootstrap.js --network ephemery
*/

async function main() {
const [owner] = await ethers.getSigners();
console.log("deployer address (owner): " + owner.address)
const [deployer] = await ethers.getSigners();
console.log("deployer address (owner): " + deployer.address)
console.log("")

// First deploy proxy
console.log("deploying FundingVaultProxy...")
let Proxy = await ethers.getContractFactory("FundingVaultProxy");
let proxy = await Proxy.connect(owner).deploy();
let proxy = await Proxy.connect(deployer).deploy();
let proxyAddress = await proxy.getAddress();
console.log(" success: " + proxyAddress);

Expand All @@ -28,7 +31,7 @@ async function main() {
// Lastly, deploy vault implementation
console.log("deploying FundingVaultV1...")
let FundingVault = await ethers.getContractFactory("FundingVaultV1");
let vault = await FundingVault.connect(owner).deploy();
let vault = await FundingVault.connect(deployer).deploy();
let vaultAddress = await vault.getAddress();
console.log(" success: " + vaultAddress);

Expand All @@ -38,10 +41,36 @@ async function main() {
// Initialize vault thorugh proxy's upgradeToAndCall
console.log("calling upgradeToAndCall on FundingVaultProxy...")
const initData = vault.interface.encodeFunctionData("initialize(address)", [tokenAddress]);
await proxy.connect(owner).upgradeToAndCall(vaultAddress, initData, {
gasLimit: 100000,
console.log("init data: " + initData)
await proxy.connect(deployer).upgradeToAndCall(vaultAddress, initData, {
gasLimit: 150000,
});
console.log(" success.");

// change owner if set
if(vars.has("FUNDINGVAULT_OWNER_ADDRESS")) {
let ownerAddress = vars.get("FUNDINGVAULT_OWNER_ADDRESS");
let adminRole = "0x0000000000000000000000000000000000000000000000000000000000000000";
console.log("changing FundingVault admin to: " + ownerAddress);

console.log("calling grantRole & setProxyManager on FundingVault...");
await Promise.all([
proxiedVault.connect(deployer).grantRole(adminRole, ownerAddress, {
gasLimit: 60000,
}),
proxiedVault.connect(deployer).setProxyManager(ownerAddress, {
gasLimit: 40000,
}),
]);
console.log(" success.");

console.log("calling revokeRole on FundingVault...");
await proxiedVault.connect(deployer).revokeRole(adminRole, deployer.address, {
gasLimit: 60000,
});
console.log(" success.");
}

}

main()
Expand Down

0 comments on commit bfef8d9

Please sign in to comment.