Skip to content

Commit 6c3aa96

Browse files
committed
Merge branch 'develop' into feature/sharing-github-actions-refactoring
2 parents df815e0 + 5e32a6a commit 6c3aa96

File tree

6 files changed

+74
-11
lines changed

6 files changed

+74
-11
lines changed

packages/sharing-smart-contract/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ All notable changes to this project will be documented in this file.
77
### Changed
88

99
- Refactor sharing contract CI to use reusable workflows (#442)
10+
- Import Ignition deployment in OZ upgrades plugin (#441)
11+
- Deploy contracts using Hardhat Ignition (#440)
1012
- [BREAKING] Remove result proxy url from contract config and deal params (#438).
1113
- Fix Sharing contract constructor arguments order (#433)
1214
- Update blockscout url

packages/sharing-smart-contract/config/config.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Hardhat Ignition does not support ESM modules, so we use CommonJS syntax.
22
// TODO refactor this to use ESM syntax when Hardhat Ignition supports it.
33

4+
// TODO define addresses by network.
5+
46
module.exports = {
57
POCO_ADDRESS: '0x3eca1B216A7DF1C7689aEb259fFB83ADFB894E7f',
68
DATASET_REGISTRY_ADDRESS: '0x799DAa22654128d0C64d5b79eac9283008158730',

packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cts renamed to packages/sharing-smart-contract/ignition/modules/DataProtectorSharingModule.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable import/extensions */
12
const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules');
23

34
const {

packages/sharing-smart-contract/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clean": "hardhat clean",
1010
"compile": "hardhat clean && hardhat compile && npm run artifact-to-abis",
1111
"verify": "hardhat verify",
12-
"deploy": "hardhat ignition deploy ignition/modules/DataProtectorSharingModule.cts --strategy create2",
12+
"deploy": "hardhat run scripts/deploy.js",
1313
"update-env": "hardhat run ./scripts/updateEnv.js",
1414
"upgrade": "hardhat run ./scripts/upgrade.js",
1515
"upgrade-local-fork": "mkdir -p .openzeppelin/local-fork && cp -r .openzeppelin/prod/. .openzeppelin/local-fork && MANIFEST_DEFAULT_DIR=.openzeppelin/local-fork ENV=prod hardhat run ./scripts/upgrade-local-fork.js",
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import hre from 'hardhat';
2+
import { env } from '../config/env.js';
3+
import DataProtectorSharingModule from '../ignition/modules/DataProtectorSharingModule.cjs';
4+
5+
const { ethers, upgrades } = hre;
6+
7+
/**
8+
* This script deploys DataProtectorSharing contract and its dependencies using
9+
* Hardhat Ignition and createX factory if supported.
10+
* It also imports the deployed contracts into the OpenZeppelin upgrades plugin.
11+
*/
12+
13+
async function main() {
14+
const pocoAddress = env.POCO_ADDRESS;
15+
const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS;
16+
if (!pocoAddress || !datasetRegistryAddress) {
17+
throw new Error('POCO_ADDRESS and DATASET_REGISTRY_ADDRESS are required.');
18+
}
19+
console.log('Deploying DataProtectorSharingModule...');
20+
console.log('PoCo address:', pocoAddress);
21+
console.log('DatasetRegistry address:', datasetRegistryAddress);
22+
// Check if the CreateX factory is supported on the current network.
23+
const isCreatexSupported = await isCreatexFactorySupported();
24+
if (isCreatexSupported) {
25+
console.log('CreateX factory is supported.');
26+
} else {
27+
console.log('⚠️ CreateX factory is NOT supported.');
28+
}
29+
// Deploy contracts using Ignition module.
30+
const { addOnlyAppWhitelistRegistry, dataProtectorSharing } = await hre.ignition.deploy(
31+
DataProtectorSharingModule,
32+
{
33+
...(isCreatexSupported && {
34+
strategy: 'create2',
35+
strategyConfig: hre.userConfig.ignition.strategyConfig.create2,
36+
}),
37+
displayUi: true, // for logs.
38+
},
39+
);
40+
// Import proxies in OZ `upgrades` plugin for future upgrades.
41+
console.log(`Importing proxy contracts in OZ upgrades...`);
42+
const whitelistProxyAddress = await addOnlyAppWhitelistRegistry.getAddress();
43+
await upgrades.forceImport(
44+
whitelistProxyAddress,
45+
await ethers.getContractFactory('AddOnlyAppWhitelistRegistry'),
46+
{
47+
kind: 'transparent',
48+
},
49+
);
50+
await upgrades.forceImport(
51+
await dataProtectorSharing.getAddress(),
52+
await ethers.getContractFactory('DataProtectorSharing'),
53+
{
54+
kind: 'transparent',
55+
constructorArgs: [pocoAddress, datasetRegistryAddress, whitelistProxyAddress],
56+
},
57+
);
58+
}
59+
60+
async function isCreatexFactorySupported() {
61+
const code = await ethers.provider.getCode('0xba5Ed099633D3B313e4D5F7bdc1305d3c28ba5Ed');
62+
return code !== '0x';
63+
}
64+
65+
main().catch((error) => {
66+
console.error(error);
67+
process.exitCode = 1;
68+
});

packages/sharing-smart-contract/tsconfig.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)