From d922d09c1962d15c4d1214916a5b3eddce8eb482 Mon Sep 17 00:00:00 2001 From: Corey Rice Date: Tue, 24 Sep 2024 16:19:10 -0300 Subject: [PATCH] fix: compare lowercase addresses --- deploy/012-transfer-pools-ownership.ts | 50 +++++++++++++------------- deploy/018-native-token-gateway.ts | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/deploy/012-transfer-pools-ownership.ts b/deploy/012-transfer-pools-ownership.ts index 028e9fc60..1a2ca23cc 100644 --- a/deploy/012-transfer-pools-ownership.ts +++ b/deploy/012-transfer-pools-ownership.ts @@ -4,29 +4,6 @@ import { HardhatRuntimeEnvironment } from "hardhat/types"; import { PoolConfig, getConfig } from "../helpers/deploymentConfig"; -const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const { deployer } = await getNamedAccounts(); - const { poolConfig, preconfiguredAddresses } = await getConfig(hre.getNetworkName()); - const targetOwner = preconfiguredAddresses.NormalTimelock || deployer; - - const rewardsDistributors = poolConfig - .map((pool: PoolConfig) => { - const rewards = pool.rewards || []; - return rewards.map((_, idx: number) => `RewardsDistributor_${pool.id}_${idx}`); - }) - .flat(); - - const comptrollers = poolConfig.map((pool: PoolConfig) => `Comptroller_${pool.id}`); - - const contracts = { - singleStepOwnership: ["ComptrollerBeacon", "VTokenBeacon"], - twoStepOwnership: ["PoolRegistry", ...comptrollers, ...rewardsDistributors], - }; - - await transferSingleStepOwnerships(contracts.singleStepOwnership, targetOwner); - await transfer2StepOwnerships(contracts.twoStepOwnership, targetOwner); -}; - const transfer2StepOwnerships = async (contractNames: string[], targetOwner: string) => { const abi = [ "function owner() view returns (address)", @@ -40,7 +17,7 @@ const transfer2StepOwnerships = async (contractNames: string[], targetOwner: str const pendingOwner = await contract.pendingOwner(); let tx; - if (owner !== targetOwner && pendingOwner !== targetOwner) { + if (owner.toLowerCase() !== targetOwner.toLowerCase() && pendingOwner.toLowerCase() !== targetOwner.toLowerCase()) { tx = await contract.transferOwnership(targetOwner); await tx.wait(1); const pendingOwner = await contract.pendingOwner(); @@ -59,7 +36,7 @@ const transferSingleStepOwnerships = async (contractNames: string[], targetOwner const owner = await contract.owner(); let tx; - if (owner !== targetOwner) { + if (owner.toLowerCase() !== targetOwner.toLowerCase()) { tx = await contract.transferOwnership(targetOwner); await tx.wait(1); const newOwner = await contract.owner(); @@ -70,6 +47,29 @@ const transferSingleStepOwnerships = async (contractNames: string[], targetOwner } }; +const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { + const { deployer } = await getNamedAccounts(); + const { poolConfig, preconfiguredAddresses } = await getConfig(hre.getNetworkName()); + const targetOwner = preconfiguredAddresses.NormalTimelock || deployer; + + const rewardsDistributors = poolConfig + .map((pool: PoolConfig) => { + const rewards = pool.rewards || []; + return rewards.map((_, idx: number) => `RewardsDistributor_${pool.id}_${idx}`); + }) + .flat(); + + const comptrollers = poolConfig.map((pool: PoolConfig) => `Comptroller_${pool.id}`); + + const contracts = { + singleStepOwnership: ["ComptrollerBeacon", "VTokenBeacon"], + twoStepOwnership: ["PoolRegistry", ...comptrollers, ...rewardsDistributors], + }; + + await transferSingleStepOwnerships(contracts.singleStepOwnership, targetOwner); + await transfer2StepOwnerships(contracts.twoStepOwnership, targetOwner); +}; + func.tags = ["TransferPoolsOwnership", "il"]; func.id = "transfer_pools_ownership"; // id required to prevent re-execution export default func; diff --git a/deploy/018-native-token-gateway.ts b/deploy/018-native-token-gateway.ts index b5ee80714..aa1c36cb9 100644 --- a/deploy/018-native-token-gateway.ts +++ b/deploy/018-native-token-gateway.ts @@ -133,7 +133,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const nativeTokenGateway = await ethers.getContract(`NativeTokenGateway_${vWNativeInfo.name}`); const targetOwner = preconfiguredAddresses.NormalTimelock || deployer; - if (hre.network.live && await nativeTokenGateway.owner() !== targetOwner) { + if (hre.network.live && (await nativeTokenGateway.owner()).toLowerCase() !== targetOwner.toLowerCase()) { const tx = await nativeTokenGateway.transferOwnership(targetOwner); await tx.wait(); console.log(`Transferred ownership of NativeTokenGateway_${vWNativeInfo.name} to Timelock`);