Skip to content

Commit

Permalink
Merge pull request #207 from OriginTrail/gnosis-mainnet-deployment
Browse files Browse the repository at this point in the history
Small fixes in deployment scripts, added additional test for HubController, deployed contracts on Gnosis Mainnet
  • Loading branch information
u-hubar authored Dec 20, 2023
2 parents c993c85 + 870e790 commit 56fd79b
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 43 deletions.
2 changes: 1 addition & 1 deletion contracts/v1/storage/assets/ContentAssetStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
24 changes: 17 additions & 7 deletions deploy/001_deploy_hub_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,34 @@ 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',
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
24 changes: 16 additions & 8 deletions deploy/002_deploy_hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})`);
}
}
}
};
Expand Down
11 changes: 3 additions & 8 deletions deploy/003_deploy_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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!');
}
};

Expand Down
26 changes: 15 additions & 11 deletions deploy/019_deploy_content_asset_storage_v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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]]);
}
}
};

Expand Down
Loading

0 comments on commit 56fd79b

Please sign in to comment.