diff --git a/deploy/001_deploy_hub_v2.ts b/deploy/001_deploy_hub_v2.ts index dc3ae9f6..8b266ad7 100644 --- a/deploy/001_deploy_hub_v2.ts +++ b/deploy/001_deploy_hub_v2.ts @@ -9,7 +9,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { (hre.helpers.contractDeployments.contracts['Hub'].version !== undefined && !hre.helpers.contractDeployments.contracts['Hub'].version.startsWith('1.')) ) { - if (hre.network.name === 'hardhat') { + if (hre.network.config.environment === 'development') { hre.helpers.resetDeploymentsJson(); console.log('Hardhat deployments config reset.'); } diff --git a/deploy/002_deploy_hub.ts b/deploy/002_deploy_hub.ts index 4da02aaa..0e10c570 100644 --- a/deploy/002_deploy_hub.ts +++ b/deploy/002_deploy_hub.ts @@ -9,7 +9,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { (hre.helpers.contractDeployments.contracts['Hub'].version !== undefined && !hre.helpers.contractDeployments.contracts['Hub'].version.startsWith('2.')) ) { - if (hre.network.name === 'hardhat') { + if (hre.network.config.environment === 'development') { hre.helpers.resetDeploymentsJson(); console.log('Hardhat deployments config reset.'); } diff --git a/deploy/003_deploy_token.ts b/deploy/003_deploy_token.ts index 2c82d90f..a1613d96 100644 --- a/deploy/003_deploy_token.ts +++ b/deploy/003_deploy_token.ts @@ -22,7 +22,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const setTokenTx = await HubController.setContractAddress('Token', tokenAddress); await setTokenTx.wait(); } - } else if (!isDeployed && hre.network.name === 'hardhat') { + } else if (!isDeployed && hre.network.config.environment === 'development') { const Token = await hre.helpers.deploy({ newContractName: 'Token', passHubInConstructor: false, diff --git a/deploy/007_deploy_sha256.ts b/deploy/007_deploy_sha256.ts index 5a444613..a59113c4 100644 --- a/deploy/007_deploy_sha256.ts +++ b/deploy/007_deploy_sha256.ts @@ -10,7 +10,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); if (!isDeployed) { - if (hre.network.name === 'hardhat') { + if (hre.network.config.environment === 'development') { const { deployer } = await hre.getNamedAccounts(); const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; diff --git a/deploy/009_deploy_log2pldsf.ts b/deploy/009_deploy_log2pldsf.ts index 122e4ac8..3be71f74 100644 --- a/deploy/009_deploy_log2pldsf.ts +++ b/deploy/009_deploy_log2pldsf.ts @@ -9,7 +9,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { }); if (!isDeployed) { - if (hre.network.name === 'hardhat') { + if (hre.network.config.environment === 'development') { const { deployer } = await hre.getNamedAccounts(); const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; diff --git a/deploy/998_initialize_contracts.ts b/deploy/998_initialize_contracts.ts index 320cc0d2..386af2aa 100644 --- a/deploy/998_initialize_contracts.ts +++ b/deploy/998_initialize_contracts.ts @@ -21,10 +21,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { newScoreFunctions, ].every((arr) => arr.length === 0); - if ( - !noChangesWereMade && - (hre.network.config.environment === 'testnet' || hre.network.config.environment == 'mainnet') - ) { + if (!noChangesWereMade && hre.network.config.environment !== 'development') { const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; console.log(`HubController: ${hubControllerAddress}`); diff --git a/deploy/999_save_deployments.ts b/deploy/999_save_deployments.ts index 35183f78..b3789d3c 100644 --- a/deploy/999_save_deployments.ts +++ b/deploy/999_save_deployments.ts @@ -2,9 +2,7 @@ import { DeployFunction } from 'hardhat-deploy/types'; import { HardhatRuntimeEnvironment } from 'hardhat/types'; const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { - const networkPrefixes = ['otp', 'gnosis']; - - if (networkPrefixes.some((networkPrefix) => hre.network.name.startsWith(networkPrefix))) { + if (hre.network.config.environment !== 'development') { hre.helpers.saveDeploymentsJson('deployments'); } }; diff --git a/utils/helpers.ts b/utils/helpers.ts index 5c5f5e02..d771475d 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -168,7 +168,7 @@ export class Helpers { log: true, }); } catch (error) { - if (this.hre.network.name !== 'hardhat') { + if (this.hre.network.config.environment !== 'development') { this.saveDeploymentsJson('deployments'); } let message; @@ -184,14 +184,14 @@ export class Helpers { let tx; if (setContractInHub) { - if (this.hre.network.name === 'hardhat') { + if (this.hre.network.config.environment === 'development') { tx = await HubController.setContractAddress(nameInHub, newContract.address); await tx.wait(); } else { this.newContracts.push([nameInHub, newContract.address]); } } else if (setAssetStorageInHub) { - if (this.hre.network.name === 'hardhat') { + if (this.hre.network.config.environment === 'development') { tx = await HubController.setAssetStorageAddress(nameInHub, newContract.address); await tx.wait(); } else { @@ -200,7 +200,7 @@ export class Helpers { } if (this.hasFunction(nameInHub, 'initialize')) { - if ((setContractInHub || setAssetStorageInHub) && this.hre.network.name === 'hardhat') { + if ((setContractInHub || setAssetStorageInHub) && this.hre.network.config.environment === 'development') { const newContractInterface = new this.hre.ethers.utils.Interface(this.getAbi(nameInHub)); const initializeTx = await HubController.forwardCall( newContract.address,