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

fixes #19

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
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
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
Loading