From 302526c5a311dd0f6a456eede616287184e77ad2 Mon Sep 17 00:00:00 2001 From: wojciech-turek Date: Fri, 8 Dec 2023 10:35:28 +0100 Subject: [PATCH] Add ownership transfer scripts --- .../300_catalyst/303_catalyst_upgrade-v2.ts | 18 ++++++++++++++---- .../deploy/400_asset/408_asset_upgrade-v2.ts | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/deploy/deploy/300_catalyst/303_catalyst_upgrade-v2.ts b/packages/deploy/deploy/300_catalyst/303_catalyst_upgrade-v2.ts index 8e33642291..7976ceeb5e 100644 --- a/packages/deploy/deploy/300_catalyst/303_catalyst_upgrade-v2.ts +++ b/packages/deploy/deploy/300_catalyst/303_catalyst_upgrade-v2.ts @@ -4,10 +4,9 @@ import {HardhatRuntimeEnvironment} from 'hardhat/types'; const func: DeployFunction = async function ( hre: HardhatRuntimeEnvironment ): Promise { - const {deployments, getNamedAccounts} = hre; - const {deploy} = deployments; - - const {deployer, upgradeAdmin} = await getNamedAccounts(); + const {deployments, getNamedAccounts, ethers} = hre; + const {execute, read, catchUnknownSigner, deploy} = deployments; + const {deployer, upgradeAdmin, catalystAdmin} = await getNamedAccounts(); await deploy('Catalyst', { from: deployer, @@ -19,6 +18,17 @@ const func: DeployFunction = async function ( upgradeIndex: 1, }, }); + + if ((await read('Catalyst', 'owner')) === ethers.constants.AddressZero) { + await catchUnknownSigner( + execute( + 'Catalyst', + {from: catalystAdmin, log: true}, + 'transferOwnership', + catalystAdmin + ) + ); + } }; export default func; func.tags = ['Catalyst_upgrade']; diff --git a/packages/deploy/deploy/400_asset/408_asset_upgrade-v2.ts b/packages/deploy/deploy/400_asset/408_asset_upgrade-v2.ts index 9e70c55d89..d0d0678eb9 100644 --- a/packages/deploy/deploy/400_asset/408_asset_upgrade-v2.ts +++ b/packages/deploy/deploy/400_asset/408_asset_upgrade-v2.ts @@ -2,9 +2,9 @@ import {HardhatRuntimeEnvironment} from 'hardhat/types'; import {DeployFunction} from 'hardhat-deploy/types'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const {deployments, getNamedAccounts} = hre; - const {deploy} = deployments; - const {deployer, upgradeAdmin} = await getNamedAccounts(); + const {deployments, getNamedAccounts, ethers} = hre; + const {read, catchUnknownSigner, execute, deploy} = deployments; + const {deployer, upgradeAdmin, assetAdmin} = await getNamedAccounts(); await deploy('Asset', { from: deployer, @@ -16,6 +16,17 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }, log: true, }); + + if ((await read('Asset', 'owner')) === ethers.constants.AddressZero) { + await catchUnknownSigner( + execute( + 'Asset', + {from: assetAdmin, log: true}, + 'transferOwnership', + assetAdmin + ) + ); + } }; export default func;