Skip to content

Commit

Permalink
Merge pull request #410 from alpaca-finance/feat/transfer-ownership
Browse files Browse the repository at this point in the history
[main][feat] transfer ownership
  • Loading branch information
jr-alpaca authored Aug 29, 2023
2 parents 306ce9e + 3b09765 commit 1b07130
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 143 deletions.
14 changes: 7 additions & 7 deletions deploy/config/accept-ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Check all variables below before execute the deployment script
*/

// verify that the target contract is correct
const targetContract = config.moneyMarket.moneyMarketDiamond;
const contractToAcceptOwnership = [config.moneyMarket.moneyMarketDiamond];

// funcSig of "acceptOwnership()" should be 0x79ba5097
const funcSig = ethers.utils.keccak256(utils.toUtf8Bytes("acceptOwnership()")).slice(0, 10);

const deployerWallet = new ethers.Wallet(process.env.DEPLOYER_PRIVATE_KEY as string, deployer.provider);

const multiSig = new GnosisSafeMultiSigService(chainId, config.opMultiSig, deployerWallet);
const txHash = await multiSig.proposeTransaction(targetContract, "0", funcSig);

console.log(`> 🟢 Transaction Proposed`);
console.log(`> ✅ Tx hash: ${txHash}`);
for (const targetContract of contractToAcceptOwnership) {
const multiSig = new GnosisSafeMultiSigService(chainId, config.opMultiSig, deployerWallet);
const txHash = await multiSig.proposeTransaction(targetContract, "0", funcSig);
console.log(`> 🟢 Transaction Proposed Tx hash: ${txHash}`);
}
};

export default func;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { DeployFunction } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { ConfigFileHelper } from "../file-helper.ts/config-file.helper";
import { getDeployer } from "../utils/deployer-helper";
import { MiniFL__factory } from "../../typechain";
import { OwnableUpgradeable__factory } from "../../typechain/factories/@openzeppelin/contracts-upgradeable/access/index";

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const configFileHelper = new ConfigFileHelper();
const config = configFileHelper.getConfig();

/*
░██╗░░░░░░░██╗░█████╗░██████╗░███╗░░██╗██╗███╗░░██╗░██████╗░
░██║░░██╗░░██║██╔══██╗██╔══██╗████╗░██║██║████╗░██║██╔════╝░
Expand All @@ -15,25 +18,29 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
Check all variables below before execute the deployment script
*/

const configFileHelper = new ConfigFileHelper();
const contractToTransfers = [
config.moneyMarket.moneyMarketDiamond,
config.oracle.alpacaV2Oracle02,
config.oracle.chainlinkOracle,
config.oracle.oracleMedianizer,
config.miniFL.proxy,
config.rewarders[0].address,
config.rewarders[1].address,
];

const config = configFileHelper.getConfig();
const deployer = await getDeployer();
const multiSig = config.opMultiSig;

const miniFl = MiniFL__factory.connect(config.miniFL.proxy, deployer);

console.log("----------------------");
console.log(">>> Transfer MiniFL Ownership\n");
const opMultiSig = config.opMultiSig;

console.log(`> Transfering ownership from ${deployer.address} to multisig (${multiSig}}) ...\n`);
const tx = await miniFl.transferOwnership(multiSig);
await tx.wait();
for (const contractAddress of contractToTransfers) {
console.log(`>>> 🔧 Transfer ownership of ${contractAddress} to: ${opMultiSig}`);
const contract = OwnableUpgradeable__factory.connect(contractAddress, deployer);
const transferOwnershipTx = await contract.transferOwnership(opMultiSig);
await transferOwnershipTx.wait();
console.log(`> 🟢 Done | Tx hash: ${transferOwnershipTx.hash}\n`);
}

console.log(`> ✅ Tx hash: ${tx.hash}\n`);
console.log(`> ✅ Done`);
console.log("----------------------");
console.log("\n✅ All Done");
};

export default func;
func.tags = ["TransferMiniFLOwnership"];
func.tags = ["TransferOwnership"];
61 changes: 0 additions & 61 deletions deploy/core/facets/ownership/transfer-ownership.ts

This file was deleted.

54 changes: 0 additions & 54 deletions deploy/oracle/transfer-ownership.ts

This file was deleted.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@
"----------Deploy Hardhat -------------": "----------Deploy Hardhat -------------",
"exec:bsc_mainnet:money-market:diamond-cut": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags ExecuteDiamondCut",
"exec:bsc_mainnet:money-market:upgrade:account-manager": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags UpgradeMoneyMarketAccountManager",
"exec:bsc_mainnet:money-market:transfer-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags TransferMoneyMarketOwnership",
"exec:bsc_mainnet:oracle:transfer-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags TransferOraclesOwnership",
"exec:bsc_mainnet:miniFL:transfer-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags TransferMiniFLOwnership",
"exec:bsc_mainnet:config:transfer-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags TransferOwnership",
"exec:bsc_mainnet:config:accept-ownership": "hardhat --network bsc_mainnet deploy --no-compile --reset --tags AcceptOwnership"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion script/deployments/MoneyMarket/config/SetOperatorsOk.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract SetOperatorsOkScript is BaseScript {

bool isOk = true;
address[] memory operators = new address[](1);
operators[0] = 0xC44f82b07Ab3E691F826951a6E335E1bC1bB0B51;
operators[0] = 0x18F59e8dDDef9e000863082a37fc56a2a5475D01;

//---- execution ----//
_startDeployerBroadcast();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ contract SetRiskManagersOkScript is BaseScript {

bool isOk = true;
address[] memory riskManagers = new address[](1);
riskManagers[0] = 0xC44f82b07Ab3E691F826951a6E335E1bC1bB0B51;
riskManagers[0] = 0x18F59e8dDDef9e000863082a37fc56a2a5475D01;

//---- execution ----//
_startDeployerBroadcast();
Expand Down

0 comments on commit 1b07130

Please sign in to comment.