diff --git a/contracts/v1/storage/assets/ContentAssetStorage.sol b/contracts/v1/storage/assets/ContentAssetStorage.sol index 74d3219f..2518a35c 100644 --- a/contracts/v1/storage/assets/ContentAssetStorage.sol +++ b/contracts/v1/storage/assets/ContentAssetStorage.sol @@ -20,7 +20,7 @@ contract ContentAssetStorage is AbstractAsset, ERC721 { mapping(bytes32 => address) public issuers; // solhint-disable-next-line no-empty-blocks - constructor(address hubAddress) AbstractAsset(hubAddress) ERC721("ContentAssetStorage", "DKG") {} + constructor(address hubAddress) AbstractAsset(hubAddress) ERC721("KnowledgeAssetCollection", "DKG") {} function name() public view virtual override(Named, ERC721) returns (string memory) { return ERC721.name(); diff --git a/deploy/001_deploy_hub_v2.ts b/deploy/001_deploy_hub_v2.ts index 8b266ad7..0da15b52 100644 --- a/deploy/001_deploy_hub_v2.ts +++ b/deploy/001_deploy_hub_v2.ts @@ -42,12 +42,18 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { setContractInHub: false, }); - if (previousHubControllerAddress == null) { + if (previousHubControllerAddress === null) { 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', @@ -55,11 +61,15 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { 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})`); + } + } } }; diff --git a/deploy/002_deploy_hub.ts b/deploy/002_deploy_hub.ts index 0e10c570..fb372910 100644 --- a/deploy/002_deploy_hub.ts +++ b/deploy/002_deploy_hub.ts @@ -42,25 +42,33 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { setContractInHub: false, }); - if (previousHubControllerAddress == null) { + if (previousHubControllerAddress === null) { 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})`); + } } } }; diff --git a/deploy/003_deploy_token.ts b/deploy/003_deploy_token.ts index a1613d96..12ace36c 100644 --- a/deploy/003_deploy_token.ts +++ b/deploy/003_deploy_token.ts @@ -13,14 +13,7 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const tokenInHub = await Hub['isContract(string)']('Token'); if (!tokenInHub) { - const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; - const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); - - const tokenAddress = hre.helpers.contractDeployments.contracts['Token'].evmAddress; - - console.log(`Setting Token (${tokenAddress}) in the Hub (${Hub.address}).`); - const setTokenTx = await HubController.setContractAddress('Token', tokenAddress); - await setTokenTx.wait(); + hre.helpers.newContracts.push(['Token', hre.helpers.contractDeployments.contracts['Token'].evmAddress]); } } else if (!isDeployed && hre.network.config.environment === 'development') { const Token = await hre.helpers.deploy({ @@ -43,6 +36,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { const mintTx = await Token.mint(acc.address, amountToMint, { from: deployer, gasLimit: 80_000 }); await mintTx.wait(); } + } else { + throw new Error('Missing Token address in the JSON config!'); } }; diff --git a/deploy/019_deploy_content_asset_storage_v2.ts b/deploy/019_deploy_content_asset_storage_v2.ts index be92f66b..de188906 100644 --- a/deploy/019_deploy_content_asset_storage_v2.ts +++ b/deploy/019_deploy_content_asset_storage_v2.ts @@ -12,6 +12,8 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { console.log('Deploying ContentAssetStorage V2...'); + const isDeployed = hre.helpers.isDeployed('ContentAssetStorage'); + const ContentAssetStorage = await hre.helpers.deploy({ newContractName: 'ContentAssetStorageV2', newContractNameInHub: 'ContentAssetStorage', @@ -20,20 +22,22 @@ const func: DeployFunction = async function (hre: HardhatRuntimeEnvironment) { setAssetStorageInHub: true, }); - const encodedData = ContentAssetStorage.interface.encodeFunctionData('setBaseURI', [ - `did:dkg:${hre.network.name.split('_')[0]}:${hre.network.config.chainId}/${ContentAssetStorage.address}/`, - ]); + if (!isDeployed) { + const encodedData = ContentAssetStorage.interface.encodeFunctionData('setBaseURI', [ + `did:dkg:${hre.network.name.split('_')[0]}:${hre.network.config.chainId}/${ContentAssetStorage.address}/`, + ]); - if (hre.network.config.environment == 'development') { - const { deployer } = await hre.getNamedAccounts(); + if (hre.network.config.environment === 'development') { + const { deployer } = await hre.getNamedAccounts(); - const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; - const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); + const hubControllerAddress = hre.helpers.contractDeployments.contracts['HubController'].evmAddress; + const HubController = await hre.ethers.getContractAt('HubController', hubControllerAddress, deployer); - const setBaseURITx = await HubController.forwardCall(ContentAssetStorage.address, encodedData); - await setBaseURITx.wait(); - } else { - hre.helpers.setParametersEncodedData.push(['ContentAssetStorage', [encodedData]]); + const setBaseURITx = await HubController.forwardCall(ContentAssetStorage.address, encodedData); + await setBaseURITx.wait(); + } else { + hre.helpers.setParametersEncodedData.push(['ContentAssetStorage', [encodedData]]); + } } }; diff --git a/deployments/gnosis_mainnet_contracts.json b/deployments/gnosis_mainnet_contracts.json new file mode 100644 index 00000000..170bdb7e --- /dev/null +++ b/deployments/gnosis_mainnet_contracts.json @@ -0,0 +1,240 @@ +{ + "contracts": { + "Assertion": { + "deployed": true, + "deploymentTimestamp": 1703023107033, + "evmAddress": "0xB86D4A6deB4e507DF21A29efa00b908d39f730B3", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "AssertionStorage": { + "deployed": true, + "deploymentTimestamp": 1703022989141, + "evmAddress": "0xff1c0D62eAC3fE4Fd69e42e587107fb5EaBf6836", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "CommitManagerV1": { + "deployed": true, + "deploymentTimestamp": 1703023158518, + "evmAddress": "0xa4809dFDD80DF5D79fE938d9e01E795A84E014CA", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "CommitManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1703023188102, + "evmAddress": "0x40bb23901022b9b3B055bee49cCcd462c1756Db2", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "ContentAsset": { + "deployed": true, + "deploymentTimestamp": 1703023247599, + "evmAddress": "0xa51BA17e7bE776ccf1FBe5177f7356b63486c54F", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "ContentAssetStorage": { + "deployed": true, + "deploymentTimestamp": 1703023075721, + "evmAddress": "0x9157595f26F6069A7c29e988c4249bA98A53c697", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "2.0.1" + }, + "HashingProxy": { + "deployed": true, + "deploymentTimestamp": 1703022944891, + "evmAddress": "0xEAE9dE9AA95AFc43CAB20970f1883c4857bC4a16", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "Hub": { + "deployed": true, + "deploymentTimestamp": 1703022869550, + "evmAddress": "0xbEF14fc04F870c2dD65c13Df4faB6ba01A9c746b", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "2.0.0" + }, + "HubController": { + "deployed": true, + "deploymentTimestamp": 1703022879509, + "evmAddress": "0x48EA24e5C817C13215B3121bd6Fcc6B93D3c0caC", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "Identity": { + "deployed": true, + "deploymentTimestamp": 1703023115582, + "evmAddress": "0xd821411AA4347906CF3FB6B6F65391Ef3976ff2d", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "IdentityStorage": { + "deployed": true, + "deploymentTimestamp": 1703022999913, + "evmAddress": "0x85f868877Ccd88e1cd7936443ceD093f7E67BA37", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "2.0.0" + }, + "Log2PLDSF": { + "deployed": true, + "deploymentTimestamp": 1703025999344, + "evmAddress": "0xcA9f750Cd07ACd2F1Ca9cB1d1Dfdcf19e2E9773e", + "gitBranch": "gnosis-mainnet-deployment", + "gitCommitHash": "e1347318d5badad802c1b802f3aa270be7843e26", + "version": null + }, + "ParametersStorage": { + "deployed": true, + "deploymentTimestamp": 1703022903732, + "evmAddress": "0x394e73722B13F162778d9F9Ad0ce49f02aB51210", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.1.0" + }, + "Profile": { + "deployed": true, + "deploymentTimestamp": 1703023151472, + "evmAddress": "0x3Bb0F09B3625eF43afe1e590e4C41F63db7fF0C1", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "ProfileStorage": { + "deployed": true, + "deploymentTimestamp": 1703023027670, + "evmAddress": "0x8E24940cA87B23a742E70Ca93BD43a13211B2c4d", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "ProofManagerV1": { + "deployed": true, + "deploymentTimestamp": 1703023171376, + "evmAddress": "0x3d2f4a8c4d33D21415bCC107cE65cEbC0108326b", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "ProofManagerV1U1": { + "deployed": true, + "deploymentTimestamp": 1703023211461, + "evmAddress": "0xa606689669BABb9C0D48A9B9C5C37cb874ACda4D", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "SHA256": { + "deployed": true, + "deploymentTimestamp": 1703025987942, + "evmAddress": "0x01BF84f88861294Dc6FcAF14f6cAA9FAe604A528", + "gitBranch": "gnosis-mainnet-deployment", + "gitCommitHash": "e1347318d5badad802c1b802f3aa270be7843e26", + "version": null + }, + "ScoringProxy": { + "deployed": true, + "deploymentTimestamp": 1703022965121, + "evmAddress": "0xC7C52e75bc43147779A2F4C065324C3A0f7AfbEe", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "ServiceAgreementStorageProxy": { + "deployed": true, + "deploymentTimestamp": 1703023064603, + "evmAddress": "0x8f8430045Fc2CAbD37cc744633987e1dBFfA1A7C", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1": { + "deployed": true, + "deploymentTimestamp": 1703023042140, + "evmAddress": "0xb3db60d04D2Ea88c21C4A27960665e0e1eEE8c28", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "ServiceAgreementStorageV1U1": { + "deployed": true, + "deploymentTimestamp": 1703023053866, + "evmAddress": "0xC2bf77D0A4C5B6EfE2D0A37cb45B9e31C3E49a58", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "ServiceAgreementV1": { + "deployed": true, + "deploymentTimestamp": 1703023240311, + "evmAddress": "0xC20dC8df633b049e9C227f1161548C6FA99c1d02", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.1.1" + }, + "ShardingTable": { + "deployed": true, + "deploymentTimestamp": 1703023127708, + "evmAddress": "0xd8B622e5D98d358C0DC730e90d749B3371054655", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.1" + }, + "ShardingTableStorage": { + "deployed": true, + "deploymentTimestamp": 1703023010069, + "evmAddress": "0xFD9B5c2221f4c248761710020edb8b565A7f220a", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "Staking": { + "deployed": true, + "deploymentTimestamp": 1703023140241, + "evmAddress": "0x0ea866cB43BF4088F5ECC94bd6eD588154e8b972", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.2" + }, + "StakingStorage": { + "deployed": true, + "deploymentTimestamp": 1703023020919, + "evmAddress": "0xBA854b8d7052fcE6ff58D04818D68B9dC0718Fdd", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "Token": { + "deployed": true, + "evmAddress": "0xEddd81E0792E764501AaE206EB432399a0268DB5" + }, + "UnfinalizedStateStorage": { + "deployed": true, + "deploymentTimestamp": 1703023096226, + "evmAddress": "0x22617263B5a2cab82d7c6f2956867eb4CDd29F6a", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + }, + "WhitelistStorage": { + "deployed": true, + "deploymentTimestamp": 1703022936712, + "evmAddress": "0xa1238eD2C1DCe4EA5c51038396404114ACA7DdBF", + "gitBranch": "main", + "gitCommitHash": "c993c8564d17e5b8fbab770b020d7c926608ea24", + "version": "1.0.0" + } + } +} diff --git a/test/v1/unit/HubController.test.ts b/test/v1/unit/HubController.test.ts index 97300760..1a9a83b4 100644 --- a/test/v1/unit/HubController.test.ts +++ b/test/v1/unit/HubController.test.ts @@ -3,7 +3,7 @@ import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers'; import { expect } from 'chai'; import hre from 'hardhat'; -import { Hub, HubController, Profile } from '../../../typechain'; +import { Hub, HubController, Profile, Token } from '../../../typechain'; import { GeneralStructs } from '../../../typechain/contracts/v1/HubController'; type HubControllerFixture = { @@ -110,4 +110,146 @@ describe('@v1 @unit HubController contract', function () { .to.emit(ScoringProxy, 'NewScoringFunctionContract') .withArgs(1, Log2PLDSF.address); }); + + it('Deploy full set of contracts and set new contract in Hub using HubController; Expect to be successful', async () => { + await hre.deployments.fixture(['Hub', 'Token']); + + HubController = await hre.ethers.getContract('HubController'); + const Token = await hre.ethers.getContract('Token'); + + const ParametersStorage = await hre.helpers.deploy({ newContractName: 'ParametersStorage' }); + const WhitelistStorage = await hre.helpers.deploy({ newContractName: 'WhitelistStorage' }); + const HashingProxy = await hre.helpers.deploy({ newContractName: 'HashingProxy' }); + const SHA256 = await hre.helpers.deploy({ + newContractName: 'SHA256', + passHubInConstructor: false, + }); + const ScoringProxy = await hre.helpers.deploy({ newContractName: 'ScoringProxy' }); + const Log2PLDSF = await hre.helpers.deploy({ newContractName: 'Log2PLDSF' }); + const AssertionStorage = await hre.helpers.deploy({ newContractName: 'AssertionStorage' }); + const IdentityStorage = await hre.helpers.deploy({ newContractName: 'IdentityStorage' }); + const ShardingTableStorage = await hre.helpers.deploy({ newContractName: 'ShardingTableStorage' }); + const StakingStorage = await hre.helpers.deploy({ newContractName: 'StakingStorage' }); + const ProfileStorage = await hre.helpers.deploy({ newContractName: 'ProfileStorage' }); + const ServiceAgreementStorageV1 = await hre.helpers.deploy({ newContractName: 'ServiceAgreementStorageV1' }); + const ServiceAgreementStorageV1U1 = await hre.helpers.deploy({ newContractName: 'ServiceAgreementStorageV1U1' }); + const ServiceAgreementStorageProxy = await hre.helpers.deploy({ newContractName: 'ServiceAgreementStorageProxy' }); + const ContentAssetStorage = await hre.helpers.deploy({ + newContractName: 'ContentAssetStorage', + passHubInConstructor: true, + setContractInHub: false, + setAssetStorageInHub: true, + }); + const UnfinalizedStateStorage = await hre.helpers.deploy({ newContractName: 'UnfinalizedStateStorage' }); + const Assertion = await hre.helpers.deploy({ newContractName: 'Assertion' }); + const Identity = await hre.helpers.deploy({ newContractName: 'Identity' }); + const ShardingTable = await hre.helpers.deploy({ newContractName: 'ShardingTable' }); + const Staking = await hre.helpers.deploy({ newContractName: 'Staking' }); + const Profile = await hre.helpers.deploy({ newContractName: 'Profile' }); + const CommitManagerV1 = await hre.helpers.deploy({ newContractName: 'CommitManagerV1' }); + const ProofManagerV1 = await hre.helpers.deploy({ newContractName: 'ProofManagerV1' }); + const CommitManagerV1U1 = await hre.helpers.deploy({ newContractName: 'CommitManagerV1U1' }); + const ProofManagerV1U1 = await hre.helpers.deploy({ newContractName: 'ProofManagerV1U1' }); + const ServiceAgreementV1 = await hre.helpers.deploy({ newContractName: 'ServiceAgreementV1' }); + const ContentAsset = await hre.helpers.deploy({ newContractName: 'ContentAsset' }); + + const newContracts = [ + { name: 'Token', addr: Token.address }, + { name: 'ParametersStorage', addr: ParametersStorage.address }, + { name: 'WhitelistStorage', addr: WhitelistStorage.address }, + { name: 'HashingProxy', addr: HashingProxy.address }, + { name: 'SHA256', addr: SHA256.address }, + { name: 'ScoringProxy', addr: ScoringProxy.address }, + { name: 'Log2PLDSF', addr: Log2PLDSF.address }, + { name: 'AssertionStorage', addr: AssertionStorage.address }, + { name: 'IdentityStorage', addr: IdentityStorage.address }, + { name: 'ShardingTableStorage', addr: ShardingTableStorage.address }, + { name: 'StakingStorage', addr: StakingStorage.address }, + { name: 'ProfileStorage', addr: ProfileStorage.address }, + { name: 'ServiceAgreementStorageV1', addr: ServiceAgreementStorageV1.address }, + { name: 'ServiceAgreementStorageV1U1', addr: ServiceAgreementStorageV1U1.address }, + { name: 'ServiceAgreementStorageProxy', addr: ServiceAgreementStorageProxy.address }, + { name: 'UnfinalizedStateStorage', addr: UnfinalizedStateStorage.address }, + { name: 'Assertion', addr: Assertion.address }, + { name: 'Identity', addr: Identity.address }, + { name: 'ShardingTable', addr: ShardingTable.address }, + { name: 'Staking', addr: Staking.address }, + { name: 'Profile', addr: Profile.address }, + { name: 'CommitManagerV1', addr: CommitManagerV1.address }, + { name: 'ProofManagerV1', addr: ProofManagerV1.address }, + { name: 'CommitManagerV1U1', addr: CommitManagerV1U1.address }, + { name: 'ProofManagerV1U1', addr: ProofManagerV1U1.address }, + { name: 'ServiceAgreementV1', addr: ServiceAgreementV1.address }, + { name: 'ContentAsset', addr: ContentAsset.address }, + ]; + const newAssetStorageContracts = [{ name: 'ContentAssetStorage', addr: ContentAssetStorage.address }]; + const newHashFunctions = [SHA256.address]; + const newScoreFunctions = [Log2PLDSF.address]; + const contractsForReinitialization = [ + Log2PLDSF.address, + StakingStorage.address, + ProfileStorage.address, + ServiceAgreementStorageV1.address, + ServiceAgreementStorageV1U1.address, + ServiceAgreementStorageProxy.address, + Assertion.address, + Identity.address, + ShardingTable.address, + Staking.address, + Profile.address, + CommitManagerV1.address, + ProofManagerV1.address, + CommitManagerV1U1.address, + ProofManagerV1U1.address, + ServiceAgreementV1.address, + ContentAsset.address, + ]; + const setParametersEncodedData = [ + { + contractName: 'ParametersStorage', + encodedData: [ + '0x0d8d840b0000000000000000000000000000000000000000000000000000000000000e10', + '0x51ce6d3e0000000000000000000000000000000000000000000000000000000000000258', + ], + }, + { + contractName: 'CommitManagerV1', + encodedData: [ + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', + ], + }, + { + contractName: 'ProofManagerV1', + encodedData: [ + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001', + ], + }, + { + contractName: 'CommitManagerV1U1', + encodedData: [ + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001', + ], + }, + { + contractName: 'ProofManagerV1U1', + encodedData: [ + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001', + '0x7ea63c6e00000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001', + ], + }, + ]; + + const setAndReinitializeContractsTx = await HubController.setAndReinitializeContracts( + newContracts, + newAssetStorageContracts, + newHashFunctions, + newScoreFunctions, + contractsForReinitialization, + setParametersEncodedData, + ); + + await expect(setAndReinitializeContractsTx).to.not.be.reverted; + }); }); diff --git a/test/v2/unit/ContentAssetStorageV2.test.ts b/test/v2/unit/ContentAssetStorageV2.test.ts index b7fb6035..92ea1b94 100644 --- a/test/v2/unit/ContentAssetStorageV2.test.ts +++ b/test/v2/unit/ContentAssetStorageV2.test.ts @@ -73,7 +73,7 @@ describe('@v2 @unit ContentAssetStorageV2', function () { // Test for successful deployment it('Should deploy successfully with correct initial parameters', async function () { - expect(await ContentAssetStorageV2.name()).to.equal('ContentAssetStorage'); + expect(await ContentAssetStorageV2.name()).to.equal('KnowledgeAssetCollection'); expect(await ContentAssetStorageV2.version()).to.equal('2.0.1'); }); diff --git a/utils/helpers.ts b/utils/helpers.ts index da8ba3a8..a786ddc7 100644 --- a/utils/helpers.ts +++ b/utils/helpers.ts @@ -138,7 +138,7 @@ export class Helpers { if (this.isDeployed(nameInHub)) { const contractInstance = await this.hre.ethers.getContractAt( - nameInHub, + this.getAbi(newContractName), this.contractDeployments.contracts[nameInHub].evmAddress, deployer, ); @@ -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) { @@ -283,12 +283,12 @@ export class Helpers { } else { throw Error(`Parameter '${getterName}' doesn't exist in the contract '${contractName}'.`); } - - if (encodedData[1].length !== 0) { - this.setParametersEncodedData.push(encodedData); - } } } + + if (encodedData[1].length !== 0) { + this.setParametersEncodedData.push(encodedData); + } } public inConfig(contractName: string): boolean {