|
| 1 | +const { buildModule } = require('@nomicfoundation/hardhat-ignition/modules'); |
| 2 | + |
| 3 | +const { |
| 4 | + DATASET_REGISTRY_ADDRESS: defaultDatasetRegistryAddress, |
| 5 | + POCO_ADDRESS: defaultPocoAddress, |
| 6 | +} = require('../../config/config.cjs'); |
| 7 | +const { env } = require('../../config/env.cjs'); |
| 8 | + |
| 9 | +// Hardhat Ignition does not support ESM yet. |
| 10 | + |
| 11 | +// @ts-ignore |
| 12 | +module.exports = buildModule('DataProtectorSharingModule', (m) => { |
| 13 | + const proxyAdminOwner = m.getAccount(0); |
| 14 | + const pocoAddress = env.POCO_ADDRESS || defaultPocoAddress; |
| 15 | + const datasetRegistryAddress = env.DATASET_REGISTRY_ADDRESS || defaultDatasetRegistryAddress; |
| 16 | + |
| 17 | + // Whitelist |
| 18 | + const addOnlyAppWhitelistRegistryImpl = m.contract('AddOnlyAppWhitelistRegistry', [], { |
| 19 | + id: 'AddOnlyAppWhitelistRegistryImpl', |
| 20 | + }); |
| 21 | + const addOnlyAppWhitelistRegistryProxy = m.contract( |
| 22 | + 'TransparentUpgradeableProxy', |
| 23 | + [ |
| 24 | + addOnlyAppWhitelistRegistryImpl, |
| 25 | + proxyAdminOwner, |
| 26 | + '0x', // No initialization data. |
| 27 | + ], |
| 28 | + { |
| 29 | + id: 'AddOnlyAppWhitelistRegistryProxy', |
| 30 | + }, |
| 31 | + ); |
| 32 | + const addOnlyAppWhitelistRegistry = m.contractAt( |
| 33 | + 'AddOnlyAppWhitelistRegistry', |
| 34 | + addOnlyAppWhitelistRegistryProxy, |
| 35 | + ); |
| 36 | + |
| 37 | + // DPS |
| 38 | + const dataProtectorSharingImpl = m.contract( |
| 39 | + 'DataProtectorSharing', |
| 40 | + [pocoAddress, datasetRegistryAddress, addOnlyAppWhitelistRegistryProxy], |
| 41 | + { |
| 42 | + id: 'DataProtectorSharingImpl', |
| 43 | + }, |
| 44 | + ); |
| 45 | + const dataProtectorSharingProxy = m.contract( |
| 46 | + 'TransparentUpgradeableProxy', |
| 47 | + [ |
| 48 | + dataProtectorSharingImpl, |
| 49 | + proxyAdminOwner, |
| 50 | + '0x', // No initialization data. |
| 51 | + ], |
| 52 | + { |
| 53 | + id: 'DataProtectorSharingProxy', |
| 54 | + }, |
| 55 | + ); |
| 56 | + const dataProtectorSharing = m.contractAt('DataProtectorSharing', dataProtectorSharingProxy); |
| 57 | + |
| 58 | + return { addOnlyAppWhitelistRegistry, dataProtectorSharing }; |
| 59 | +}); |
0 commit comments