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 43105b89..386af2aa 100644 --- a/deploy/998_initialize_contracts.ts +++ b/deploy/998_initialize_contracts.ts @@ -21,50 +21,29 @@ 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; - const multiSigWalletAddress = process.env['MULTISIG_' + hre.network.name.toUpperCase()]; - - if (multiSigWalletAddress === undefined) { - throw new Error(`MULTISIG_ADDRESS should be defined in the environment for the ${hre.network.name} blockchain!`); - } console.log(`HubController: ${hubControllerAddress}`); - console.log(`MultiSigWallet: ${multiSigWalletAddress}`); const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); - const MultiSigWallet = await hre.ethers.getContractAt('MultiSigWallet', multiSigWalletAddress, deployer); console.log(`New or redeployed contracts: ${JSON.stringify(newContracts)}`); console.log(`New or redeployed Asset Storage contracts: ${JSON.stringify(newAssetStorageContracts)}`); - console.log(`Initialized contracts: ${JSON.stringify(contractsForReinitialization)}`); - console.log(`Encoded data for parameters settings: ${JSON.stringify(setParametersEncodedData)}`); console.log(`New or redeployed hash functions set in the proxy: ${JSON.stringify(newHashFunctions)}`); console.log(`New or redeployed score functions set in the proxy: ${JSON.stringify(newScoreFunctions)}`); + console.log(`Initialized contracts: ${JSON.stringify(contractsForReinitialization)}`); + console.log(`Encoded data for parameters settings: ${JSON.stringify(setParametersEncodedData)}`); - // Prepare the data for the setAndReinitializeContracts function call - const encodedData = HubController.interface.encodeFunctionData('setAndReinitializeContracts', [ + const setAndReinitializeContractsTx = await HubController.setAndReinitializeContracts( newContracts, newAssetStorageContracts, newHashFunctions, newScoreFunctions, contractsForReinitialization, setParametersEncodedData, - ]); - - MultiSigWallet.on('Submission', (transactionId) => { - console.log(`[Multisig] HubController.setAndReinitializeContracts Transaction ID: ${transactionId}`); - }); - - // Submit the transaction to the multisig wallet - const submitTx = await MultiSigWallet.submitTransaction(hubControllerAddress, 0, encodedData); - await submitTx.wait(); - - // After that, other owners of the multisig wallet should use 'confirmTransaction' function. - // When needed confirmations amount is reached, 'executeTransaction' should be executed. + ); + await setAndReinitializeContractsTx.wait(); } }; 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,