Skip to content

Commit

Permalink
Small fixes in deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
u-hubar committed Dec 20, 2023
1 parent 7017386 commit 870e790
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
22 changes: 16 additions & 6 deletions deploy/001_deploy_hub_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,30 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const hubAddress = hre.helpers.contractDeployments.contracts['Hub'].evmAddress;
const Hub = await hre.ethers.getContractAt('Hub', hubAddress, deployer);

const transferHubOwneshipTx = await Hub.transferOwnership(HubController.address);
await transferHubOwneshipTx.wait();
const hubOwner = await Hub.owner();

if (deployer.toLowerCase() === hubOwner.toLowerCase()) {
const transferHubOwneshipTx = await Hub.transferOwnership(HubController.address);
await transferHubOwneshipTx.wait();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
}
} else {
const previousHubController = await hre.ethers.getContractAt(
'HubController',
previousHubControllerAddress,
deployer,
);

const transferHubOwneshipTx = await previousHubController.transferHubOwnership(HubController.address);
await transferHubOwneshipTx.wait();
}
const previousHubControllerOwner = await previousHubController.owner();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
if (deployer.toLowerCase() === previousHubControllerOwner.toLowerCase()) {
const transferHubOwneshipTx = await previousHubController.transferHubOwnership(HubController.address);
await transferHubOwneshipTx.wait();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
}
}
}
};

Expand Down
22 changes: 15 additions & 7 deletions deploy/002_deploy_hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,29 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
const hubAddress = hre.helpers.contractDeployments.contracts['Hub'].evmAddress;
const Hub = await hre.ethers.getContractAt('Hub', hubAddress, deployer);

const transferHubOwneshipTx = await Hub.transferOwnership(HubController.address);
await transferHubOwneshipTx.wait();
const hubOwner = await Hub.owner();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
} else if (hre.network.config.environment !== 'testnet' && hre.network.config.environment !== 'mainnet') {
if (deployer.toLowerCase() === hubOwner.toLowerCase()) {
const transferHubOwneshipTx = await Hub.transferOwnership(HubController.address);
await transferHubOwneshipTx.wait();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
}
} else {
const previousHubController = await hre.ethers.getContractAt(
'HubController',
previousHubControllerAddress,
deployer,
);

const transferHubOwneshipTx = await previousHubController.transferHubOwnership(HubController.address);
await transferHubOwneshipTx.wait();
const previousHubControllerOwner = await previousHubController.owner();

if (deployer.toLowerCase() === previousHubControllerOwner.toLowerCase()) {
const transferHubOwneshipTx = await previousHubController.transferHubOwnership(HubController.address);
await transferHubOwneshipTx.wait();

console.log(`Hub ownership transferred to HubController (${HubController.address})`);
console.log(`Hub ownership transferred to HubController (${HubController.address})`);
}
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ export class Helpers {

await this.updateDeploymentsJson(nameInHub, newContract.address);

return await this.hre.ethers.getContractAt(newContractName, newContract.address, deployer);
return await this.hre.ethers.getContractAt(this.getAbi(newContractName), newContract.address, deployer);
}

public async updateContractParameters(contractName: string, contract: Contract) {
Expand Down

0 comments on commit 870e790

Please sign in to comment.