Skip to content

Commit

Permalink
Merge pull request #195 from OriginTrail/fix/hub-controller-deployment
Browse files Browse the repository at this point in the history
Updated Hub/HubController deployment scripts
  • Loading branch information
u-hubar authored Nov 27, 2023
2 parents d41b0e6 + 2f27f86 commit ad6fa94
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
32 changes: 15 additions & 17 deletions deploy/001_deploy_hub_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (
hre.helpers.isDeployed('Hub') &&
(hre.helpers.contractDeployments.contracts['Hub'].version === undefined ||
hre.helpers.contractDeployments.contracts['Hub'].version?.startsWith('1.'))
) {
return;
}

const { deployer } = await hre.getNamedAccounts();

if (hre.network.name === 'hardhat') {
hre.helpers.resetDeploymentsJson();
console.log('Hardhat deployments config reset.');
}
if (
!hre.helpers.isDeployed('Hub') ||
(hre.helpers.contractDeployments.contracts['Hub'].version !== undefined &&
!hre.helpers.contractDeployments.contracts['Hub'].version.startsWith('1.'))
) {
if (hre.network.name === 'hardhat') {
hre.helpers.resetDeploymentsJson();
console.log('Hardhat deployments config reset.');
}

if (!hre.helpers.isDeployed('Hub')) {
console.log('Deploying Hub V2...');
if (!hre.helpers.isDeployed('Hub')) {
console.log('Deploying Hub V2...');

const Hub = await hre.deployments.deploy('Hub', { contract: 'HubV2', from: deployer, log: true });
const Hub = await hre.deployments.deploy('Hub', { contract: 'HubV2', from: deployer, log: true });

hre.helpers.updateDeploymentsJson('Hub', Hub.address);
hre.helpers.updateDeploymentsJson('Hub', Hub.address);
}
}

// New HubController should be manually deployed for testnet/mainnet:
Expand All @@ -31,7 +29,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// 3. Transfer ownership of the new HubController to the MultiSig Wallet.
// 4. Update address of new HubController to deployments/otp_{testnet/mainnet}_contracts.json and commit the change
// 5. Add software burner wallet that will be used for redeployment of other contracts to the MultiSig (remove after redeployment).
if (!hre.helpers.isDeployed('HubController') && !['otp_testnet', 'otp_mainnet'].includes(hre.network.name)) {
if (!hre.helpers.isDeployed('HubController')) {
let previousHubControllerAddress;
if (hre.helpers.inConfig('HubController')) {
previousHubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress;
Expand Down
32 changes: 15 additions & 17 deletions deploy/002_deploy_hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,25 @@ import { DeployFunction } from 'hardhat-deploy/types';
import { HardhatRuntimeEnvironment } from 'hardhat/types';

const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
if (
hre.helpers.isDeployed('Hub') &&
(hre.helpers.contractDeployments.contracts['Hub'].version === undefined ||
hre.helpers.contractDeployments.contracts['Hub'].version?.startsWith('2.'))
) {
return;
}

const { deployer } = await hre.getNamedAccounts();

if (hre.network.name === 'hardhat') {
hre.helpers.resetDeploymentsJson();
console.log('Hardhat deployments config reset.');
}
if (
!hre.helpers.isDeployed('Hub') ||
(hre.helpers.contractDeployments.contracts['Hub'].version !== undefined &&
!hre.helpers.contractDeployments.contracts['Hub'].version.startsWith('2.'))
) {
if (hre.network.name === 'hardhat') {
hre.helpers.resetDeploymentsJson();
console.log('Hardhat deployments config reset.');
}

if (!hre.helpers.isDeployed('Hub')) {
console.log('Deploying Hub V1...');
if (!hre.helpers.isDeployed('Hub')) {
console.log('Deploying Hub V1...');

const Hub = await hre.deployments.deploy('Hub', { from: deployer, log: true });
const Hub = await hre.deployments.deploy('Hub', { from: deployer, log: true });

hre.helpers.updateDeploymentsJson('Hub', Hub.address);
hre.helpers.updateDeploymentsJson('Hub', Hub.address);
}
}

// New HubController should be manually deployed for testnet/mainnet:
Expand All @@ -31,7 +29,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) {
// 3. Transfer ownership of the new HubController to the MultiSig Wallet.
// 4. Update address of new HubController to deployments/otp_{testnet/mainnet}_contracts.json and commit the change
// 5. Add software burner wallet that will be used for redeployment of other contracts to the MultiSig (remove after redeployment).
if (!hre.helpers.isDeployed('HubController') && !['otp_testnet', 'otp_mainnet'].includes(hre.network.name)) {
if (!hre.helpers.isDeployed('HubController')) {
let previousHubControllerAddress;
if (hre.helpers.inConfig('HubController')) {
previousHubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress;
Expand Down

0 comments on commit ad6fa94

Please sign in to comment.