Skip to content

Commit

Permalink
fix: compare lowercase addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyar committed Sep 26, 2024
1 parent 0ff1968 commit d922d09
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
50 changes: 25 additions & 25 deletions deploy/012-transfer-pools-ownership.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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;
2 changes: 1 addition & 1 deletion deploy/018-native-token-gateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
Expand Down

0 comments on commit d922d09

Please sign in to comment.