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

chore: updating deployment scripts to change owner in staking contracts #194

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module.exports = {
chainId: 10,
urls: {
apiURL: "https://api-optimistic.etherscan.io/api",
browserURL: "https://sepolia-optimistic.etherscan.io"
browserURL: "https://optimistic.etherscan.io"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correcting a wrong link

},
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*global process*/

const { ethers } = require("hardhat");
const { LedgerSigner } = require("@anders-t/ethers-ledger");

async function main() {
const fs = require("fs");
const globalsFile = "globals.json";
const dataFromJSON = fs.readFileSync(globalsFile, "utf8");
let parsedData = JSON.parse(dataFromJSON);
const useLedger = parsedData.useLedger;
const derivationPath = parsedData.derivationPath;
const providerName = parsedData.providerName;
const gasPriceInGwei = parsedData.gasPriceInGwei;
const stakingVerifierAddress = parsedData.stakingVerifierAddress;
const stakingFactoryAddress = parsedData.stakingFactoryAddress;
const bridgeMediatorAddress = parsedData.bridgeMediatorAddress;

let networkURL = parsedData.networkURL;
if (providerName === "mainnet") {
if (!process.env.ALCHEMY_API_KEY_MAINNET) {
console.log("set ALCHEMY_API_KEY_MAINNET env variable");
}
networkURL += process.env.ALCHEMY_API_KEY_MAINNET;
}
if (providerName === "polygon") {
if (!process.env.ALCHEMY_API_KEY_MATIC) {
console.log("set ALCHEMY_API_KEY_MATIC env variable");
}
networkURL += process.env.ALCHEMY_API_KEY_MATIC;
} else if (providerName === "polygonAmoy") {
if (!process.env.ALCHEMY_API_KEY_AMOY) {
console.log("set ALCHEMY_API_KEY_AMOY env variable");
return;
}
networkURL += process.env.ALCHEMY_API_KEY_AMOY;
}

const provider = new ethers.providers.JsonRpcProvider(networkURL);
const signers = await ethers.getSigners();

let EOA;
if (useLedger) {
EOA = new LedgerSigner(provider, derivationPath);
} else {
EOA = signers[0];
}
// EOA address
const deployer = await EOA.getAddress();
console.log("EOA is:", deployer);

// Get all the contracts
const stakingVerifier = await ethers.getContractAt("StakingVerifier", stakingVerifierAddress);
const stakingFactory = await ethers.getContractAt("StakingFactory", stakingFactoryAddress);

// Gas pricing
const gasPrice = ethers.utils.parseUnits(gasPriceInGwei, "gwei");

// Transaction signing and execution
// 21. EOA to transfer ownership rights of StakingVerifier to BridgeMediator calling `changeOwner(BridgeMediator)`;
console.log("21. You are signing the following transaction: StakingVerifier.connect(EOA).changeOwner()");
let result = await stakingVerifier.connect(EOA).changeOwner(bridgeMediatorAddress, { gasPrice });
// Transaction details
console.log("Contract address:", stakingVerifierAddress);
console.log("Transaction:", result.hash);

// 22. EOA to transfer ownership rights of StakingFactory to BridgeMediator calling `changeOwner(BridgeMediator)`;
console.log("22. You are signing the following transaction: StakingFactory.connect(EOA).changeOwner()");
result = await stakingFactory.connect(EOA).changeOwner(bridgeMediatorAddress, { gasPrice });
// Transaction details
console.log("Contract address:", stakingFactoryAddress);
console.log("Transaction:", result.hash);
}

main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});
3 changes: 2 additions & 1 deletion scripts/deployment/l2/globals_ethereum_mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"derivationPath": "m/44'/60'/2'/0/0",
"providerName": "mainnet",
"networkURL": "https://eth-mainnet.g.alchemy.com/v2/",
"gasPriceInGwei": "15",
"gasPriceInGwei": "30",
"bridgeMediatorAddress": "0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the timelock?

"serviceRegistryAddress": "0x48b6af7B12C71f09e2fC8aF4855De4Ff54e775cA",
"serviceRegistryTokenUtilityAddress": "0x3Fb926116D454b95c669B6Bf2E7c3bad8d19affA",
"olasAddress": "0x0001A500A6B18995B03f44bb040A5fFc28E45CB0",
Expand Down
Loading